zerg-ztc 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/bin/ztc-audio-darwin-arm64 +0 -0
  2. package/dist/utils/dictation_native.d.ts.map +1 -1
  3. package/dist/utils/dictation_native.js +43 -23
  4. package/dist/utils/dictation_native.js.map +1 -1
  5. package/package.json +5 -4
  6. package/packages/ztc-dictation/Cargo.toml +0 -43
  7. package/packages/ztc-dictation/README.md +0 -65
  8. package/packages/ztc-dictation/index.d.ts +0 -16
  9. package/packages/ztc-dictation/index.js +0 -74
  10. package/packages/ztc-dictation/package.json +0 -41
  11. package/packages/ztc-dictation/src/main.rs +0 -430
  12. package/src/App.tsx +0 -910
  13. package/src/agent/agent.ts +0 -534
  14. package/src/agent/backends/anthropic.ts +0 -86
  15. package/src/agent/backends/gemini.ts +0 -119
  16. package/src/agent/backends/inception.ts +0 -23
  17. package/src/agent/backends/index.ts +0 -17
  18. package/src/agent/backends/openai.ts +0 -23
  19. package/src/agent/backends/openai_compatible.ts +0 -143
  20. package/src/agent/backends/types.ts +0 -83
  21. package/src/agent/commands/clipboard.ts +0 -77
  22. package/src/agent/commands/config.ts +0 -204
  23. package/src/agent/commands/debug.ts +0 -23
  24. package/src/agent/commands/dictation.ts +0 -11
  25. package/src/agent/commands/emulation.ts +0 -80
  26. package/src/agent/commands/execution.ts +0 -9
  27. package/src/agent/commands/help.ts +0 -20
  28. package/src/agent/commands/history.ts +0 -13
  29. package/src/agent/commands/index.ts +0 -48
  30. package/src/agent/commands/input_mode.ts +0 -22
  31. package/src/agent/commands/keybindings.ts +0 -40
  32. package/src/agent/commands/model.ts +0 -11
  33. package/src/agent/commands/models.ts +0 -116
  34. package/src/agent/commands/permissions.ts +0 -64
  35. package/src/agent/commands/retry.ts +0 -9
  36. package/src/agent/commands/shell.ts +0 -68
  37. package/src/agent/commands/skills.ts +0 -54
  38. package/src/agent/commands/status.ts +0 -19
  39. package/src/agent/commands/types.ts +0 -88
  40. package/src/agent/commands/update.ts +0 -32
  41. package/src/agent/factory.ts +0 -60
  42. package/src/agent/index.ts +0 -20
  43. package/src/agent/runtime/capabilities.ts +0 -7
  44. package/src/agent/runtime/memory.ts +0 -23
  45. package/src/agent/runtime/policy.ts +0 -48
  46. package/src/agent/runtime/session.ts +0 -18
  47. package/src/agent/runtime/tracing.ts +0 -23
  48. package/src/agent/tools/file.ts +0 -178
  49. package/src/agent/tools/index.ts +0 -52
  50. package/src/agent/tools/screenshot.ts +0 -821
  51. package/src/agent/tools/search.ts +0 -138
  52. package/src/agent/tools/shell.ts +0 -69
  53. package/src/agent/tools/skills.ts +0 -28
  54. package/src/agent/tools/types.ts +0 -14
  55. package/src/agent/tools/zerg.ts +0 -50
  56. package/src/cli.tsx +0 -163
  57. package/src/components/ActivityLine.tsx +0 -23
  58. package/src/components/FullScreen.tsx +0 -79
  59. package/src/components/Header.tsx +0 -27
  60. package/src/components/InputArea.tsx +0 -1660
  61. package/src/components/MessageList.tsx +0 -71
  62. package/src/components/SingleMessage.tsx +0 -298
  63. package/src/components/StatusBar.tsx +0 -55
  64. package/src/components/index.tsx +0 -8
  65. package/src/config/types.ts +0 -19
  66. package/src/config.ts +0 -186
  67. package/src/debug/logger.ts +0 -14
  68. package/src/emulation/README.md +0 -24
  69. package/src/emulation/catalog.ts +0 -82
  70. package/src/emulation/trace_style.ts +0 -8
  71. package/src/emulation/types.ts +0 -7
  72. package/src/skills/index.ts +0 -36
  73. package/src/skills/loader.ts +0 -135
  74. package/src/skills/registry.ts +0 -6
  75. package/src/skills/types.ts +0 -10
  76. package/src/types.ts +0 -84
  77. package/src/ui/README.md +0 -44
  78. package/src/ui/core/factory.ts +0 -9
  79. package/src/ui/core/index.ts +0 -4
  80. package/src/ui/core/input.ts +0 -38
  81. package/src/ui/core/input_segments.ts +0 -410
  82. package/src/ui/core/input_state.ts +0 -17
  83. package/src/ui/core/layout_yoga.ts +0 -122
  84. package/src/ui/core/style.ts +0 -38
  85. package/src/ui/core/types.ts +0 -54
  86. package/src/ui/ink/index.tsx +0 -1
  87. package/src/ui/ink/render.tsx +0 -60
  88. package/src/ui/views/activity_line.ts +0 -33
  89. package/src/ui/views/app.ts +0 -111
  90. package/src/ui/views/header.ts +0 -44
  91. package/src/ui/views/input_area.ts +0 -255
  92. package/src/ui/views/message_list.ts +0 -443
  93. package/src/ui/views/status_bar.ts +0 -114
  94. package/src/ui/vue/index.ts +0 -53
  95. package/src/ui/web/frame_render.tsx +0 -148
  96. package/src/ui/web/index.tsx +0 -1
  97. package/src/ui/web/render.tsx +0 -41
  98. package/src/utils/clipboard.ts +0 -39
  99. package/src/utils/clipboard_image.ts +0 -40
  100. package/src/utils/dictation.ts +0 -467
  101. package/src/utils/dictation_native.ts +0 -258
  102. package/src/utils/diff.ts +0 -52
  103. package/src/utils/image_preview.ts +0 -36
  104. package/src/utils/models.ts +0 -98
  105. package/src/utils/path_complete.ts +0 -173
  106. package/src/utils/path_format.ts +0 -99
  107. package/src/utils/shell.ts +0 -72
  108. package/src/utils/spinner_frames.ts +0 -1
  109. package/src/utils/spinner_verbs.ts +0 -23
  110. package/src/utils/table.ts +0 -171
  111. package/src/utils/tool_summary.ts +0 -56
  112. package/src/utils/tool_trace.ts +0 -346
  113. package/src/utils/update.ts +0 -44
  114. package/src/utils/version.ts +0 -15
  115. package/src/web/index.html +0 -352
  116. package/src/web/mirror-favicon.svg +0 -4
  117. package/src/web/mirror.html +0 -641
  118. package/src/web/mirror_hook.ts +0 -25
  119. package/src/web/mirror_server.ts +0 -204
  120. package/tsconfig.json +0 -22
  121. package/vite.config.ts +0 -363
  122. /package/{packages/ztc-dictation/bin → bin}/.gitkeep +0 -0
@@ -1,88 +0,0 @@
1
- import { AgentState, Message } from '../../types.js';
2
- import { ZTCConfig } from '../../config/types.js';
3
- import type { EmulationProfile } from '../../emulation/types.js';
4
- import type { Skill } from '../../skills/types.js';
5
-
6
- export interface ConfigController {
7
- locationLabel?: string;
8
- get: () => ZTCConfig;
9
- set: <K extends keyof ZTCConfig>(key: K, value: ZTCConfig[K]) => void;
10
- refresh?: () => Promise<void>;
11
- hasApiKey: () => boolean;
12
- getApiKey: (provider?: string) => string | undefined;
13
- setApiKey: (key: string, provider?: string) => void;
14
- getMaskedApiKey: () => string;
15
- getProvider: () => string;
16
- setProvider: (provider: string) => void;
17
- getOpenAICompatibleBaseUrl: () => string | undefined;
18
- setOpenAICompatibleBaseUrl: (url: string | undefined) => void;
19
- getEmulationId: () => string | undefined;
20
- setEmulationId: (id: string | undefined) => void;
21
- save: () => void | Promise<void>;
22
- }
23
-
24
- export interface EmulationController {
25
- list: () => EmulationProfile[];
26
- get: (id: string) => EmulationProfile | undefined;
27
- }
28
-
29
- export interface ShellResult {
30
- command: string;
31
- cwd: string;
32
- stdout: string;
33
- stderr: string;
34
- exitCode: number;
35
- truncated: boolean;
36
- }
37
-
38
- export interface ShellController {
39
- run: (command: string) => Promise<ShellResult>;
40
- getCwd: () => string;
41
- setCwd: (path: string) => Promise<string>;
42
- }
43
-
44
- export interface ClipboardController {
45
- writeText: (text: string) => Promise<void>;
46
- }
47
-
48
- export interface ModelsController {
49
- list: (provider?: string) => Promise<string[]>;
50
- }
51
-
52
- export interface SkillsController {
53
- list: () => Promise<Skill[]>;
54
- }
55
-
56
- export interface DictationController {
57
- startRecording: () => void;
58
- stopRecording: () => Promise<string>; // Returns transcribed text
59
- isRecording: () => boolean;
60
- }
61
-
62
- export interface CommandContext {
63
- addMessage: (msg: Omit<Message, 'id' | 'timestamp'>) => void;
64
- clearMessages: () => void;
65
- getMessages: () => Message[];
66
- setAgentState: (state: AgentState) => void;
67
- reloadAgent: () => void;
68
- setDebug: (debug: boolean) => void;
69
- retry: () => void;
70
- exit: () => void;
71
- config: ConfigController;
72
- emulation: EmulationController;
73
- shell: ShellController;
74
- clipboard: ClipboardController;
75
- models: ModelsController;
76
- skills: SkillsController;
77
- dictation?: DictationController;
78
- getInputMode: () => 'queue' | 'interrupt';
79
- setInputMode: (mode: 'queue' | 'interrupt') => void;
80
- setInputText?: (text: string) => void; // Set input field text
81
- }
82
-
83
- export interface Command {
84
- name: string;
85
- description: string;
86
- usage?: string;
87
- handler: (args: string[], ctx: CommandContext) => void | Promise<void>;
88
- }
@@ -1,32 +0,0 @@
1
- import { Command } from './types.js';
2
- import { getVersion } from '../../utils/version.js';
3
- import { checkForUpdate } from '../../utils/update.js';
4
-
5
- export const updateCommand: Command = {
6
- name: 'update',
7
- description: 'Check for updates and install the latest version',
8
- handler: async (_args, ctx) => {
9
- try {
10
- ctx.addMessage({ role: 'system', content: 'Checking for updates...' });
11
- const current = getVersion();
12
- const info = await checkForUpdate(current);
13
- if (!info.hasUpdate) {
14
- ctx.addMessage({ role: 'system', content: `ZTC is up to date (v${current}).` });
15
- return;
16
- }
17
- ctx.addMessage({ role: 'system', content: `Updating to v${info.latest}...` });
18
- const result = await ctx.shell.run('npm install -g zerg-ztc@latest');
19
- if (result.exitCode === 0) {
20
- ctx.addMessage({ role: 'system', content: `✓ Updated to v${info.latest}. Restart ZTC to use the new version.` });
21
- } else {
22
- ctx.addMessage({
23
- role: 'system',
24
- content: `Update failed (exit ${result.exitCode}).\n${result.stderr || result.stdout || ''}`.trim()
25
- });
26
- }
27
- } catch (err) {
28
- const message = err instanceof Error ? err.message : 'Update failed';
29
- ctx.addMessage({ role: 'system', content: `Update failed: ${message}` });
30
- }
31
- }
32
- };
@@ -1,60 +0,0 @@
1
- import { Agent } from './agent.js';
2
- import { AnthropicBackend, OpenAIBackend, OpenAICompatibleBackend, GeminiBackend, InceptionBackend } from './backends/index.js';
3
- import { getEmulationProfile } from '../emulation/catalog.js';
4
- import { ZTCConfig } from '../config/types.js';
5
- import { CapabilityPolicy } from './runtime/policy.js';
6
-
7
- export interface AgentFactoryOptions {
8
- config: ZTCConfig;
9
- provider?: string;
10
- apiKey?: string;
11
- openaiCompatibleBaseUrl?: string;
12
- emulationId?: string;
13
- apiEndpoint?: string;
14
- skillPrompt?: string;
15
- }
16
-
17
- export function createAgentFromConfig(options: AgentFactoryOptions): Agent | null {
18
- const provider = options.provider || options.config.provider || 'anthropic';
19
- const apiKey = options.apiKey || options.config.apiKey || '';
20
- if (!apiKey) return null;
21
-
22
- const emulationId = options.emulationId || options.config.emulationId;
23
- const emulation = emulationId ? getEmulationProfile(emulationId) : undefined;
24
-
25
- let backend;
26
- switch (provider) {
27
- case 'openai':
28
- backend = new OpenAIBackend({ apiKey });
29
- break;
30
- case 'gemini':
31
- backend = new GeminiBackend({ apiKey });
32
- break;
33
- case 'inception':
34
- backend = new InceptionBackend({ apiKey });
35
- break;
36
- case 'openai_compatible':
37
- backend = new OpenAICompatibleBackend({
38
- apiKey,
39
- baseUrl: options.openaiCompatibleBaseUrl || options.config.openaiCompatibleBaseUrl || 'https://api.openai.com/v1'
40
- });
41
- break;
42
- case 'anthropic':
43
- default:
44
- backend = new AnthropicBackend({ apiKey, apiEndpoint: options.apiEndpoint });
45
- }
46
-
47
- const basePrompt = emulation?.systemPrompt;
48
- const skillPrompt = options.skillPrompt?.trim();
49
- const systemPrompt = skillPrompt
50
- ? [basePrompt, skillPrompt].filter(Boolean).join('\n\n')
51
- : basePrompt;
52
-
53
- return new Agent({
54
- apiKey,
55
- model: options.config.model,
56
- systemPrompt,
57
- backend,
58
- policy: new CapabilityPolicy(options.config.toolPermissions)
59
- });
60
- }
@@ -1,20 +0,0 @@
1
- // Agent module exports
2
- export { Agent, AgentError, type AgentConfig, type EventHandler } from './agent.js';
3
- export {
4
- defaultTools,
5
- getToolDefinitions,
6
- getTool,
7
- executeTool,
8
- type Tool
9
- } from './tools/index.js';
10
- export { AnthropicBackend, OpenAIBackend, OpenAICompatibleBackend, InceptionBackend, GeminiBackend } from './backends/index.js';
11
- export type { AgentBackend, BackendRequest, BackendResponse } from './backends/index.js';
12
- export { AllowAllPolicy } from './runtime/policy.js';
13
- export type { Policy } from './runtime/policy.js';
14
- export { NoopTracer } from './runtime/tracing.js';
15
- export type { Tracer, TraceEvent, TraceEventType } from './runtime/tracing.js';
16
- export { InMemoryStore } from './runtime/memory.js';
17
- export type { MemoryStore } from './runtime/memory.js';
18
- export { InMemorySessionStore } from './runtime/session.js';
19
- export type { SessionStore } from './runtime/session.js';
20
- export { ToolCapability } from './runtime/capabilities.js';
@@ -1,7 +0,0 @@
1
- export enum ToolCapability {
2
- FILE_READ = 'file_read',
3
- FILE_WRITE = 'file_write',
4
- SHELL_EXEC = 'shell_exec',
5
- NETWORK = 'network',
6
- SCREEN_CAPTURE = 'screen_capture'
7
- }
@@ -1,23 +0,0 @@
1
- import { Message } from '../../types.js';
2
-
3
- export interface MemoryStore {
4
- addMessage(message: Message): void;
5
- getRecent(limit: number): Message[];
6
- clear(): void;
7
- }
8
-
9
- export class InMemoryStore implements MemoryStore {
10
- private messages: Message[] = [];
11
-
12
- addMessage(message: Message): void {
13
- this.messages.push(message);
14
- }
15
-
16
- getRecent(limit: number): Message[] {
17
- return this.messages.slice(-limit);
18
- }
19
-
20
- clear(): void {
21
- this.messages = [];
22
- }
23
- }
@@ -1,48 +0,0 @@
1
- import { ToolCapability } from './capabilities.js';
2
-
3
- export interface ToolPolicyRequest {
4
- name: string;
5
- args: Record<string, unknown>;
6
- capabilities: ToolCapability[];
7
- }
8
-
9
- export interface ToolPolicyDecision {
10
- allowed: boolean;
11
- reason?: string;
12
- }
13
-
14
- export interface Policy {
15
- evaluateTool(request: ToolPolicyRequest): ToolPolicyDecision;
16
- }
17
-
18
- export class AllowAllPolicy implements Policy {
19
- evaluateTool(): ToolPolicyDecision {
20
- return { allowed: true };
21
- }
22
- }
23
-
24
- export class CapabilityPolicy implements Policy {
25
- private permissions: Record<string, boolean>;
26
-
27
- constructor(permissions?: Partial<Record<string, boolean>>) {
28
- this.permissions = {
29
- file_read: true,
30
- file_write: true,
31
- shell_exec: true,
32
- network: true,
33
- ...permissions
34
- };
35
- }
36
-
37
- evaluateTool(request: ToolPolicyRequest): ToolPolicyDecision {
38
- for (const capability of request.capabilities) {
39
- if (this.permissions[capability] === false) {
40
- return {
41
- allowed: false,
42
- reason: `Permission denied: ${capability}`
43
- };
44
- }
45
- }
46
- return { allowed: true };
47
- }
48
- }
@@ -1,18 +0,0 @@
1
- import { Session } from '../../types.js';
2
-
3
- export interface SessionStore {
4
- save(session: Session): Promise<void>;
5
- load(id: string): Promise<Session | null>;
6
- }
7
-
8
- export class InMemorySessionStore implements SessionStore {
9
- private sessions = new Map<string, Session>();
10
-
11
- async save(session: Session): Promise<void> {
12
- this.sessions.set(session.id, session);
13
- }
14
-
15
- async load(id: string): Promise<Session | null> {
16
- return this.sessions.get(id) || null;
17
- }
18
- }
@@ -1,23 +0,0 @@
1
- export type TraceEventType =
2
- | 'api_request'
3
- | 'api_response'
4
- | 'tool_start'
5
- | 'tool_end'
6
- | 'tool_error'
7
- | 'policy_denied';
8
-
9
- export interface TraceEvent {
10
- type: TraceEventType;
11
- timestamp: Date;
12
- data?: Record<string, unknown>;
13
- }
14
-
15
- export interface Tracer {
16
- event(event: TraceEvent): void;
17
- }
18
-
19
- export class NoopTracer implements Tracer {
20
- event(): void {
21
- // No-op
22
- }
23
- }
@@ -1,178 +0,0 @@
1
- import { readFile, writeFile, readdir, stat } from 'fs/promises';
2
- import { dirname, resolve } from 'path';
3
- import { Tool, ToolContext } from './types.js';
4
- import { ToolCapability } from '../runtime/capabilities.js';
5
- import { buildSimpleDiff } from '../../utils/diff.js';
6
-
7
- function resolvePath(path: string, context?: ToolContext): string {
8
- const base = context?.cwd || process.cwd();
9
- return resolve(base, path);
10
- }
11
-
12
- // --- File Tools ---
13
-
14
- export const readFileTool: Tool = {
15
- capabilities: [ToolCapability.FILE_READ],
16
- definition: {
17
- name: 'read_file',
18
- description: 'Read the contents of a file at the specified path',
19
- parameters: {
20
- type: 'object',
21
- properties: {
22
- path: {
23
- type: 'string',
24
- description: 'Absolute or relative file path to read'
25
- },
26
- encoding: {
27
- type: 'string',
28
- description: 'File encoding (default: utf-8)',
29
- enum: ['utf-8', 'ascii', 'base64', 'hex']
30
- }
31
- },
32
- required: ['path']
33
- }
34
- },
35
- execute: async (args, context) => {
36
- const path = resolvePath(String(args.path), context);
37
- const encoding = (args.encoding as BufferEncoding) || 'utf-8';
38
-
39
- try {
40
- const content = await readFile(path, { encoding });
41
- const stats = await stat(path);
42
- return JSON.stringify({
43
- path,
44
- size: stats.size,
45
- content: content.slice(0, 50000), // Limit content size
46
- truncated: content.length > 50000
47
- });
48
- } catch (err) {
49
- throw new Error(`Failed to read file: ${(err as Error).message}`);
50
- }
51
- }
52
- };
53
-
54
- export const writeFileTool: Tool = {
55
- capabilities: [ToolCapability.FILE_WRITE],
56
- definition: {
57
- name: 'write_file',
58
- description: 'Write content to a file, creating directories if needed',
59
- parameters: {
60
- type: 'object',
61
- properties: {
62
- path: {
63
- type: 'string',
64
- description: 'File path to write to'
65
- },
66
- content: {
67
- type: 'string',
68
- description: 'Content to write to the file'
69
- },
70
- append: {
71
- type: 'string',
72
- description: 'If "true", append to file instead of overwriting'
73
- }
74
- },
75
- required: ['path', 'content']
76
- }
77
- },
78
- execute: async (args, context) => {
79
- const path = resolvePath(String(args.path), context);
80
- const content = String(args.content);
81
- const append = args.append === 'true';
82
-
83
- try {
84
- // Ensure directory exists
85
- const { mkdir, appendFile } = await import('fs/promises');
86
- await mkdir(dirname(path), { recursive: true });
87
-
88
- let beforeContent = '';
89
- try {
90
- beforeContent = await readFile(path, { encoding: 'utf-8' });
91
- } catch {
92
- beforeContent = '';
93
- }
94
-
95
- if (append) {
96
- await appendFile(path, content, 'utf-8');
97
- } else {
98
- await writeFile(path, content, 'utf-8');
99
- }
100
-
101
- const stats = await stat(path);
102
- const afterContent = await readFile(path, { encoding: 'utf-8' });
103
- const diff = buildSimpleDiff(beforeContent, afterContent);
104
- return JSON.stringify({
105
- path,
106
- size: stats.size,
107
- action: append ? 'appended' : 'written',
108
- diff,
109
- before: beforeContent.slice(0, 5000),
110
- after: afterContent.slice(0, 5000),
111
- truncated: beforeContent.length > 5000 || afterContent.length > 5000
112
- });
113
- } catch (err) {
114
- throw new Error(`Failed to write file: ${(err as Error).message}`);
115
- }
116
- }
117
- };
118
-
119
- export const listDirectoryTool: Tool = {
120
- capabilities: [ToolCapability.FILE_READ],
121
- definition: {
122
- name: 'list_directory',
123
- description: 'List contents of a directory',
124
- parameters: {
125
- type: 'object',
126
- properties: {
127
- path: {
128
- type: 'string',
129
- description: 'Directory path to list'
130
- },
131
- recursive: {
132
- type: 'string',
133
- description: 'If "true", list recursively (max 3 levels)'
134
- }
135
- },
136
- required: ['path']
137
- }
138
- },
139
- execute: async (args, context) => {
140
- const path = resolvePath(String(args.path), context);
141
- const recursive = args.recursive === 'true';
142
-
143
- async function listDir(dir: string, depth = 0): Promise<object[]> {
144
- if (depth > 3) return [];
145
-
146
- const entries = await readdir(dir, { withFileTypes: true });
147
- const results: object[] = [];
148
-
149
- for (const entry of entries.slice(0, 100)) { // Limit entries
150
- const entryPath = resolve(dir, entry.name);
151
- const info: Record<string, unknown> = {
152
- name: entry.name,
153
- type: entry.isDirectory() ? 'directory' : 'file'
154
- };
155
-
156
- if (entry.isFile()) {
157
- const s = await stat(entryPath);
158
- info.size = s.size;
159
- }
160
-
161
- if (recursive && entry.isDirectory() && !entry.name.startsWith('.')) {
162
- info.children = await listDir(entryPath, depth + 1);
163
- }
164
-
165
- results.push(info);
166
- }
167
-
168
- return results;
169
- }
170
-
171
- try {
172
- const entries = await listDir(path);
173
- return JSON.stringify({ path, entries });
174
- } catch (err) {
175
- throw new Error(`Failed to list directory: ${(err as Error).message}`);
176
- }
177
- }
178
- };
@@ -1,52 +0,0 @@
1
- import { Tool, ToolContext } from './types.js';
2
- import { ToolDefinition } from '../../types.js';
3
- import { readFileTool, writeFileTool, listDirectoryTool } from './file.js';
4
- import { runCommandTool } from './shell.js';
5
- import { zergQueryTool } from './zerg.js';
6
- import { searchTool } from './search.js';
7
- import { listSkillsTool } from './skills.js';
8
- import { screenshotTool, listWindowsTool, runAndMonitorTool } from './screenshot.js';
9
-
10
- // --- Tool Registry ---
11
-
12
- export const defaultTools: Tool[] = [
13
- readFileTool,
14
- writeFileTool,
15
- listDirectoryTool,
16
- searchTool,
17
- listSkillsTool,
18
- runCommandTool,
19
- zergQueryTool,
20
- screenshotTool,
21
- listWindowsTool,
22
- runAndMonitorTool
23
- ];
24
-
25
- export function getToolDefinitions(tools: Tool[] = defaultTools): ToolDefinition[] {
26
- return tools.map(t => t.definition);
27
- }
28
-
29
- export function getTool(name: string, tools: Tool[] = defaultTools): Tool | undefined {
30
- return tools.find(t => t.definition.name === name);
31
- }
32
-
33
- export async function executeTool(
34
- name: string,
35
- args: Record<string, unknown>,
36
- tools: Tool[] = defaultTools,
37
- context?: ToolContext
38
- ): Promise<string> {
39
- const tool = getTool(name, tools);
40
- if (!tool) {
41
- throw new Error(`Unknown tool: ${name}`);
42
- }
43
- return tool.execute(args, context);
44
- }
45
-
46
- export { readFileTool, writeFileTool, listDirectoryTool } from './file.js';
47
- export { searchTool } from './search.js';
48
- export { listSkillsTool } from './skills.js';
49
- export { runCommandTool } from './shell.js';
50
- export { zergQueryTool } from './zerg.js';
51
- export { screenshotTool, listWindowsTool, runAndMonitorTool } from './screenshot.js';
52
- export type { Tool } from './types.js';