mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
fix(teleporter): use coreTools constants for trajectory deserialization
This commit is contained in:
@@ -22,3 +22,4 @@ Thumbs.db
|
|||||||
.pytest_cache
|
.pytest_cache
|
||||||
**/SKILL.md
|
**/SKILL.md
|
||||||
packages/sdk/test-data/*.json
|
packages/sdk/test-data/*.json
|
||||||
|
packages/core/src/teleportation/trajectory_teleporter.min.js
|
||||||
|
|||||||
@@ -20,11 +20,18 @@ vi.mock('./loggers.js', () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Mock os module
|
// Mock os module
|
||||||
vi.mock('node:os', () => ({
|
vi.mock('node:os', () => {
|
||||||
|
const mockOs = {
|
||||||
platform: vi.fn(() => 'darwin'),
|
platform: vi.fn(() => 'darwin'),
|
||||||
arch: vi.fn(() => 'x64'),
|
arch: vi.fn(() => 'x64'),
|
||||||
release: vi.fn(() => '22.6.0'),
|
release: vi.fn(() => '22.6.0'),
|
||||||
}));
|
homedir: vi.fn(() => '/mocked/home'),
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
...mockOs,
|
||||||
|
default: mockOs,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
// Mock fs module
|
// Mock fs module
|
||||||
vi.mock('node:fs', () => ({
|
vi.mock('node:fs', () => ({
|
||||||
|
|||||||
@@ -7,12 +7,19 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-type-assertion */
|
/* eslint-disable @typescript-eslint/no-unsafe-type-assertion */
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
import {
|
import type { ConversationRecord, ToolCallRecord, MessageRecord } from '../types.js';
|
||||||
type ConversationRecord,
|
|
||||||
type MessageRecord,
|
|
||||||
type ToolCallRecord,
|
|
||||||
} from '../services/chatRecordingService.js';
|
|
||||||
import { CoreToolCallStatus } from '../scheduler/types.js';
|
import { CoreToolCallStatus } from '../scheduler/types.js';
|
||||||
|
import {
|
||||||
|
EDIT_TOOL_NAME,
|
||||||
|
GLOB_TOOL_NAME,
|
||||||
|
GREP_TOOL_NAME,
|
||||||
|
LS_TOOL_NAME,
|
||||||
|
READ_FILE_TOOL_NAME,
|
||||||
|
SHELL_TOOL_NAME,
|
||||||
|
WEB_FETCH_TOOL_NAME,
|
||||||
|
WEB_SEARCH_TOOL_NAME,
|
||||||
|
WRITE_FILE_TOOL_NAME,
|
||||||
|
} from '../tools/definitions/coreTools.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an Antigravity Trajectory JSON to a Gemini CLI ConversationRecord.
|
* Converts an Antigravity Trajectory JSON to a Gemini CLI ConversationRecord.
|
||||||
@@ -153,43 +160,43 @@ function mapAgyStepToToolCall(step: Record<string, any>): ToolCallRecord {
|
|||||||
let result: any = null;
|
let result: any = null;
|
||||||
|
|
||||||
if (step['viewFile']) {
|
if (step['viewFile']) {
|
||||||
name = 'view_file';
|
name = READ_FILE_TOOL_NAME;
|
||||||
args = { AbsolutePath: step['viewFile']['absolutePathUri'] };
|
args = { AbsolutePath: step['viewFile']['absolutePathUri'] };
|
||||||
result = [{ text: step['viewFile']['content'] || '' }];
|
result = [{ text: step['viewFile']['content'] || '' }];
|
||||||
} else if (step['listDirectory']) {
|
} else if (step['listDirectory']) {
|
||||||
name = 'list_dir';
|
name = LS_TOOL_NAME;
|
||||||
args = { DirectoryPath: step['listDirectory']['directoryPathUri'] };
|
args = { DirectoryPath: step['listDirectory']['directoryPathUri'] };
|
||||||
} else if (step['grepSearch']) {
|
} else if (step['grepSearch']) {
|
||||||
name = 'grep_search';
|
name = GREP_TOOL_NAME;
|
||||||
args = {
|
args = {
|
||||||
Query: step['grepSearch']['query'],
|
Query: step['grepSearch']['query'],
|
||||||
SearchPath: step['grepSearch']['searchPathUri'],
|
SearchPath: step['grepSearch']['searchPathUri'],
|
||||||
};
|
};
|
||||||
result = [{ text: step['grepSearch']['rawOutput'] || '' }];
|
result = [{ text: step['grepSearch']['rawOutput'] || '' }];
|
||||||
} else if (step['runCommand']) {
|
} else if (step['runCommand']) {
|
||||||
name = 'run_command';
|
name = SHELL_TOOL_NAME;
|
||||||
args = { CommandLine: step['runCommand']['commandLine'] };
|
args = { CommandLine: step['runCommand']['commandLine'] };
|
||||||
result = [{ text: step['runCommand']['combinedOutput']?.['full'] || '' }];
|
result = [{ text: step['runCommand']['combinedOutput']?.['full'] || '' }];
|
||||||
} else if (step['fileChange']) {
|
} else if (step['fileChange']) {
|
||||||
name = 'replace_file_content'; // Or multi_replace_file_content
|
name = EDIT_TOOL_NAME; // Or multi_replace_file_content
|
||||||
args = { TargetFile: step['fileChange']['absolutePathUri'] };
|
args = { TargetFile: step['fileChange']['absolutePathUri'] };
|
||||||
} else if (step['writeToFile']) {
|
} else if (step['writeToFile']) {
|
||||||
name = 'write_file';
|
name = WRITE_FILE_TOOL_NAME;
|
||||||
args = { TargetFile: step['writeToFile']['targetFileUri'] };
|
args = { TargetFile: step['writeToFile']['targetFileUri'] };
|
||||||
} else if (step['find']) {
|
} else if (step['find']) {
|
||||||
name = 'glob';
|
name = GLOB_TOOL_NAME;
|
||||||
args = {
|
args = {
|
||||||
Pattern: step['find']['pattern'],
|
Pattern: step['find']['pattern'],
|
||||||
SearchDirectory: step['find']['searchDirectory'],
|
SearchDirectory: step['find']['searchDirectory'],
|
||||||
};
|
};
|
||||||
result = [{ text: step['find']['truncatedOutput'] || '' }];
|
result = [{ text: step['find']['truncatedOutput'] || '' }];
|
||||||
} else if (step['readUrlContent']) {
|
} else if (step['readUrlContent']) {
|
||||||
name = 'web_fetch';
|
name = WEB_FETCH_TOOL_NAME;
|
||||||
args = { Url: step['readUrlContent']['url'] };
|
args = { Url: step['readUrlContent']['url'] };
|
||||||
// We intentionally don't try fully mapping the complex KnowledgeBaseItem struct into a string here
|
// We intentionally don't try fully mapping the complex KnowledgeBaseItem struct into a string here
|
||||||
result = [{ text: 'successfully read url content' }];
|
result = [{ text: 'successfully read url content' }];
|
||||||
} else if (step['searchWeb']) {
|
} else if (step['searchWeb']) {
|
||||||
name = 'google_web_search'; // Usually mapped from 'searchWeb'
|
name = WEB_SEARCH_TOOL_NAME; // Usually mapped from 'searchWeb'
|
||||||
args = { query: step['searchWeb']['query'] };
|
args = { query: step['searchWeb']['query'] };
|
||||||
if (step['searchWeb']['domain']) {
|
if (step['searchWeb']['domain']) {
|
||||||
args['domain'] = step['searchWeb']['domain'];
|
args['domain'] = step['searchWeb']['domain'];
|
||||||
|
|||||||
+14163
-22512
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user