zerg-ztc 0.1.10 → 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.
- package/bin/.gitkeep +0 -0
- package/bin/ztc-audio-darwin-arm64 +0 -0
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +63 -2
- package/dist/App.js.map +1 -1
- package/dist/agent/commands/dictation.d.ts +3 -0
- package/dist/agent/commands/dictation.d.ts.map +1 -0
- package/dist/agent/commands/dictation.js +10 -0
- package/dist/agent/commands/dictation.js.map +1 -0
- package/dist/agent/commands/index.d.ts.map +1 -1
- package/dist/agent/commands/index.js +2 -1
- package/dist/agent/commands/index.js.map +1 -1
- package/dist/agent/commands/types.d.ts +7 -0
- package/dist/agent/commands/types.d.ts.map +1 -1
- package/dist/components/InputArea.d.ts +1 -0
- package/dist/components/InputArea.d.ts.map +1 -1
- package/dist/components/InputArea.js +591 -43
- package/dist/components/InputArea.js.map +1 -1
- package/dist/components/SingleMessage.d.ts.map +1 -1
- package/dist/components/SingleMessage.js +157 -7
- package/dist/components/SingleMessage.js.map +1 -1
- package/dist/config/types.d.ts +6 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/ui/views/status_bar.js +2 -2
- package/dist/ui/views/status_bar.js.map +1 -1
- package/dist/utils/dictation.d.ts +46 -0
- package/dist/utils/dictation.d.ts.map +1 -0
- package/dist/utils/dictation.js +409 -0
- package/dist/utils/dictation.js.map +1 -0
- package/dist/utils/dictation_native.d.ts +51 -0
- package/dist/utils/dictation_native.d.ts.map +1 -0
- package/dist/utils/dictation_native.js +236 -0
- package/dist/utils/dictation_native.js.map +1 -0
- package/dist/utils/path_format.d.ts +20 -0
- package/dist/utils/path_format.d.ts.map +1 -0
- package/dist/utils/path_format.js +90 -0
- package/dist/utils/path_format.js.map +1 -0
- package/dist/utils/table.d.ts +38 -0
- package/dist/utils/table.d.ts.map +1 -0
- package/dist/utils/table.js +133 -0
- package/dist/utils/table.js.map +1 -0
- package/dist/utils/tool_trace.d.ts +7 -2
- package/dist/utils/tool_trace.d.ts.map +1 -1
- package/dist/utils/tool_trace.js +156 -51
- package/dist/utils/tool_trace.js.map +1 -1
- package/package.json +5 -1
- package/src/App.tsx +0 -813
- package/src/agent/agent.ts +0 -534
- package/src/agent/backends/anthropic.ts +0 -86
- package/src/agent/backends/gemini.ts +0 -119
- package/src/agent/backends/inception.ts +0 -23
- package/src/agent/backends/index.ts +0 -17
- package/src/agent/backends/openai.ts +0 -23
- package/src/agent/backends/openai_compatible.ts +0 -143
- package/src/agent/backends/types.ts +0 -83
- package/src/agent/commands/clipboard.ts +0 -77
- package/src/agent/commands/config.ts +0 -204
- package/src/agent/commands/debug.ts +0 -23
- package/src/agent/commands/emulation.ts +0 -80
- package/src/agent/commands/execution.ts +0 -9
- package/src/agent/commands/help.ts +0 -20
- package/src/agent/commands/history.ts +0 -13
- package/src/agent/commands/index.ts +0 -46
- package/src/agent/commands/input_mode.ts +0 -22
- package/src/agent/commands/keybindings.ts +0 -40
- package/src/agent/commands/model.ts +0 -11
- package/src/agent/commands/models.ts +0 -116
- package/src/agent/commands/permissions.ts +0 -64
- package/src/agent/commands/retry.ts +0 -9
- package/src/agent/commands/shell.ts +0 -68
- package/src/agent/commands/skills.ts +0 -54
- package/src/agent/commands/status.ts +0 -19
- package/src/agent/commands/types.ts +0 -80
- package/src/agent/commands/update.ts +0 -32
- package/src/agent/factory.ts +0 -60
- package/src/agent/index.ts +0 -20
- package/src/agent/runtime/capabilities.ts +0 -7
- package/src/agent/runtime/memory.ts +0 -23
- package/src/agent/runtime/policy.ts +0 -48
- package/src/agent/runtime/session.ts +0 -18
- package/src/agent/runtime/tracing.ts +0 -23
- package/src/agent/tools/file.ts +0 -178
- package/src/agent/tools/index.ts +0 -52
- package/src/agent/tools/screenshot.ts +0 -821
- package/src/agent/tools/search.ts +0 -138
- package/src/agent/tools/shell.ts +0 -69
- package/src/agent/tools/skills.ts +0 -28
- package/src/agent/tools/types.ts +0 -14
- package/src/agent/tools/zerg.ts +0 -50
- package/src/cli.tsx +0 -163
- package/src/components/ActivityLine.tsx +0 -23
- package/src/components/FullScreen.tsx +0 -79
- package/src/components/Header.tsx +0 -27
- package/src/components/InputArea.tsx +0 -1096
- package/src/components/MessageList.tsx +0 -71
- package/src/components/SingleMessage.tsx +0 -59
- package/src/components/StatusBar.tsx +0 -55
- package/src/components/index.tsx +0 -8
- package/src/config/types.ts +0 -12
- package/src/config.ts +0 -186
- package/src/debug/logger.ts +0 -14
- package/src/emulation/README.md +0 -24
- package/src/emulation/catalog.ts +0 -82
- package/src/emulation/trace_style.ts +0 -8
- package/src/emulation/types.ts +0 -7
- package/src/skills/index.ts +0 -36
- package/src/skills/loader.ts +0 -135
- package/src/skills/registry.ts +0 -6
- package/src/skills/types.ts +0 -10
- package/src/types.ts +0 -84
- package/src/ui/README.md +0 -44
- package/src/ui/core/factory.ts +0 -9
- package/src/ui/core/index.ts +0 -4
- package/src/ui/core/input.ts +0 -38
- package/src/ui/core/input_segments.ts +0 -410
- package/src/ui/core/input_state.ts +0 -17
- package/src/ui/core/layout_yoga.ts +0 -122
- package/src/ui/core/style.ts +0 -38
- package/src/ui/core/types.ts +0 -54
- package/src/ui/ink/index.tsx +0 -1
- package/src/ui/ink/render.tsx +0 -60
- package/src/ui/views/activity_line.ts +0 -33
- package/src/ui/views/app.ts +0 -111
- package/src/ui/views/header.ts +0 -44
- package/src/ui/views/input_area.ts +0 -255
- package/src/ui/views/message_list.ts +0 -443
- package/src/ui/views/status_bar.ts +0 -114
- package/src/ui/vue/index.ts +0 -53
- package/src/ui/web/frame_render.tsx +0 -148
- package/src/ui/web/index.tsx +0 -1
- package/src/ui/web/render.tsx +0 -41
- package/src/utils/clipboard.ts +0 -39
- package/src/utils/clipboard_image.ts +0 -40
- package/src/utils/diff.ts +0 -52
- package/src/utils/image_preview.ts +0 -36
- package/src/utils/models.ts +0 -98
- package/src/utils/path_complete.ts +0 -173
- package/src/utils/shell.ts +0 -72
- package/src/utils/spinner_frames.ts +0 -1
- package/src/utils/spinner_verbs.ts +0 -23
- package/src/utils/tool_summary.ts +0 -56
- package/src/utils/tool_trace.ts +0 -216
- package/src/utils/update.ts +0 -44
- package/src/utils/version.ts +0 -15
- package/src/web/index.html +0 -352
- package/src/web/mirror-favicon.svg +0 -4
- package/src/web/mirror.html +0 -641
- package/src/web/mirror_hook.ts +0 -25
- package/src/web/mirror_server.ts +0 -204
- package/tsconfig.json +0 -22
- package/vite.config.ts +0 -363
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Command } from './types.js';
|
|
2
|
-
|
|
3
|
-
export const debugCommand: Command = {
|
|
4
|
-
name: 'debug',
|
|
5
|
-
description: 'Toggle debug mode (show layout borders)',
|
|
6
|
-
handler: (args, ctx) => {
|
|
7
|
-
const on = args[0] === 'on' || args[0] === '1' || args[0] === 'true';
|
|
8
|
-
const off = args[0] === 'off' || args[0] === '0' || args[0] === 'false';
|
|
9
|
-
|
|
10
|
-
if (on) {
|
|
11
|
-
ctx.setDebug(true);
|
|
12
|
-
ctx.addMessage({ role: 'system', content: '✓ Debug mode enabled' });
|
|
13
|
-
} else if (off) {
|
|
14
|
-
ctx.setDebug(false);
|
|
15
|
-
ctx.addMessage({ role: 'system', content: '✓ Debug mode disabled' });
|
|
16
|
-
} else {
|
|
17
|
-
ctx.addMessage({
|
|
18
|
-
role: 'system',
|
|
19
|
-
content: 'Usage: /debug <on|off>\n\nEnables layout borders for debugging.'
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Command } from './types.js';
|
|
2
|
-
|
|
3
|
-
export const emulationCommand: Command = {
|
|
4
|
-
name: 'emulation',
|
|
5
|
-
description: 'List or select a prompt emulation',
|
|
6
|
-
usage: '<list|show|set> [id]',
|
|
7
|
-
handler: (args, ctx) => {
|
|
8
|
-
const [subCmd, ...rest] = args;
|
|
9
|
-
const value = rest.join(' ').trim();
|
|
10
|
-
|
|
11
|
-
switch (subCmd) {
|
|
12
|
-
case 'list': {
|
|
13
|
-
const profiles = ctx.emulation.list();
|
|
14
|
-
const lines = profiles.map(p => ` ${p.id} - ${p.name}`);
|
|
15
|
-
ctx.addMessage({
|
|
16
|
-
role: 'system',
|
|
17
|
-
content: ['Available emulations:', ...lines].join('\n')
|
|
18
|
-
});
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
case 'show': {
|
|
22
|
-
const id = value || ctx.config.getEmulationId();
|
|
23
|
-
if (!id) {
|
|
24
|
-
ctx.addMessage({
|
|
25
|
-
role: 'system',
|
|
26
|
-
content: 'No emulation selected. Use /emulation list or /emulation set <id>.'
|
|
27
|
-
});
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const profile = ctx.emulation.get(id);
|
|
31
|
-
if (!profile) {
|
|
32
|
-
ctx.addMessage({
|
|
33
|
-
role: 'system',
|
|
34
|
-
content: `Unknown emulation: ${id}`
|
|
35
|
-
});
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
ctx.addMessage({
|
|
39
|
-
role: 'system',
|
|
40
|
-
content: [
|
|
41
|
-
`Emulation: ${profile.name}`,
|
|
42
|
-
`ID: ${profile.id}`,
|
|
43
|
-
profile.description
|
|
44
|
-
].join('\n')
|
|
45
|
-
});
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
case 'set': {
|
|
49
|
-
if (!value) {
|
|
50
|
-
ctx.addMessage({
|
|
51
|
-
role: 'system',
|
|
52
|
-
content: 'Usage: /emulation set <id>'
|
|
53
|
-
});
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const profile = ctx.emulation.get(value);
|
|
57
|
-
if (!profile) {
|
|
58
|
-
ctx.addMessage({
|
|
59
|
-
role: 'system',
|
|
60
|
-
content: `Unknown emulation: ${value}`
|
|
61
|
-
});
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
ctx.config.setEmulationId(profile.id);
|
|
65
|
-
ctx.config.save();
|
|
66
|
-
ctx.reloadAgent();
|
|
67
|
-
ctx.addMessage({
|
|
68
|
-
role: 'system',
|
|
69
|
-
content: `✓ Emulation set: ${profile.name}`
|
|
70
|
-
});
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
default:
|
|
74
|
-
ctx.addMessage({
|
|
75
|
-
role: 'system',
|
|
76
|
-
content: 'Usage: /emulation <list|show|set> [id]'
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Command } from './types.js';
|
|
2
|
-
|
|
3
|
-
export function makeHelpCommand(getCommands: () => Command[]): Command {
|
|
4
|
-
return {
|
|
5
|
-
name: 'help',
|
|
6
|
-
description: 'Show available commands',
|
|
7
|
-
handler: (_, ctx) => {
|
|
8
|
-
const helpText = getCommands()
|
|
9
|
-
.map(c => {
|
|
10
|
-
const usage = c.usage ? ` ${c.usage}` : '';
|
|
11
|
-
return ` /${c.name}${usage}\n ${c.description}`;
|
|
12
|
-
})
|
|
13
|
-
.join('\n\n');
|
|
14
|
-
ctx.addMessage({
|
|
15
|
-
role: 'system',
|
|
16
|
-
content: `Available commands:\n\n${helpText}`
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Command } from './types.js';
|
|
2
|
-
|
|
3
|
-
export const clearCommand: Command = {
|
|
4
|
-
name: 'clear',
|
|
5
|
-
description: 'Clear message history',
|
|
6
|
-
handler: (_, ctx) => {
|
|
7
|
-
ctx.clearMessages();
|
|
8
|
-
ctx.addMessage({
|
|
9
|
-
role: 'system',
|
|
10
|
-
content: 'Message history cleared.'
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { makeHelpCommand } from './help.js';
|
|
2
|
-
import { configCommand } from './config.js';
|
|
3
|
-
import { debugCommand } from './debug.js';
|
|
4
|
-
import { clearCommand } from './history.js';
|
|
5
|
-
import { statusCommand } from './status.js';
|
|
6
|
-
import { exitCommand } from './execution.js';
|
|
7
|
-
import { emulationCommand } from './emulation.js';
|
|
8
|
-
import { shellCommand, cdCommand } from './shell.js';
|
|
9
|
-
import { clipboardCommand } from './clipboard.js';
|
|
10
|
-
import { modelsCommand } from './models.js';
|
|
11
|
-
import { modelCommand } from './model.js';
|
|
12
|
-
import { permissionsCommand } from './permissions.js';
|
|
13
|
-
import { skillsCommand } from './skills.js';
|
|
14
|
-
import { retryCommand } from './retry.js';
|
|
15
|
-
import { inputModeCommand } from './input_mode.js';
|
|
16
|
-
import { keybindingsCommand } from './keybindings.js';
|
|
17
|
-
import { updateCommand } from './update.js';
|
|
18
|
-
import { Command } from './types.js';
|
|
19
|
-
|
|
20
|
-
const commandList: Command[] = [];
|
|
21
|
-
|
|
22
|
-
const helpCommand = makeHelpCommand(() => commandList);
|
|
23
|
-
|
|
24
|
-
commandList.push(
|
|
25
|
-
helpCommand,
|
|
26
|
-
configCommand,
|
|
27
|
-
debugCommand,
|
|
28
|
-
clearCommand,
|
|
29
|
-
statusCommand,
|
|
30
|
-
emulationCommand,
|
|
31
|
-
shellCommand,
|
|
32
|
-
cdCommand,
|
|
33
|
-
clipboardCommand,
|
|
34
|
-
modelsCommand,
|
|
35
|
-
modelCommand,
|
|
36
|
-
permissionsCommand,
|
|
37
|
-
skillsCommand,
|
|
38
|
-
keybindingsCommand,
|
|
39
|
-
updateCommand,
|
|
40
|
-
inputModeCommand,
|
|
41
|
-
retryCommand,
|
|
42
|
-
exitCommand
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
export const commands = commandList;
|
|
46
|
-
export type { Command, CommandContext } from './types.js';
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Command } from './types.js';
|
|
2
|
-
|
|
3
|
-
export const inputModeCommand: Command = {
|
|
4
|
-
name: 'inputmode',
|
|
5
|
-
description: 'Set input mode while an agent is running',
|
|
6
|
-
usage: '<queue|interrupt>',
|
|
7
|
-
handler: (args, ctx) => {
|
|
8
|
-
const mode = (args[0] || '').toLowerCase();
|
|
9
|
-
if (mode !== 'queue' && mode !== 'interrupt') {
|
|
10
|
-
ctx.addMessage({
|
|
11
|
-
role: 'system',
|
|
12
|
-
content: `Current input mode: ${ctx.getInputMode()}\n\nUsage: /inputmode <queue|interrupt>`
|
|
13
|
-
});
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
ctx.setInputMode(mode);
|
|
17
|
-
ctx.addMessage({
|
|
18
|
-
role: 'system',
|
|
19
|
-
content: `✓ Input mode set: ${mode}`
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Command } from './types.js';
|
|
2
|
-
|
|
3
|
-
const lines = [
|
|
4
|
-
'Keybindings (readline-style):',
|
|
5
|
-
'',
|
|
6
|
-
'Movement:',
|
|
7
|
-
' Ctrl+A start of line',
|
|
8
|
-
' Ctrl+E end of line',
|
|
9
|
-
' Ctrl+B move left',
|
|
10
|
-
' Ctrl+F move right',
|
|
11
|
-
' Alt+B word left',
|
|
12
|
-
' Alt+F word right',
|
|
13
|
-
'',
|
|
14
|
-
'Editing:',
|
|
15
|
-
' Ctrl+U kill to start',
|
|
16
|
-
' Ctrl+K kill to end',
|
|
17
|
-
' Ctrl+W kill previous word',
|
|
18
|
-
' Alt+D kill next word',
|
|
19
|
-
' Ctrl+D delete forward',
|
|
20
|
-
' Ctrl+Y yank',
|
|
21
|
-
' Alt+Y yank-pop',
|
|
22
|
-
' Ctrl+T transpose chars',
|
|
23
|
-
' Alt+T transpose words',
|
|
24
|
-
'',
|
|
25
|
-
'History:',
|
|
26
|
-
' Ctrl+P previous',
|
|
27
|
-
' Ctrl+N next',
|
|
28
|
-
' Up/Down arrows also work',
|
|
29
|
-
'',
|
|
30
|
-
'Input mode:',
|
|
31
|
-
' /inputmode queue|interrupt'
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
export const keybindingsCommand: Command = {
|
|
35
|
-
name: 'keybindings',
|
|
36
|
-
description: 'Show keybindings',
|
|
37
|
-
handler: (_args, ctx) => {
|
|
38
|
-
ctx.addMessage({ role: 'system', content: lines.join('\n') });
|
|
39
|
-
}
|
|
40
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Command } from './types.js';
|
|
2
|
-
import { configCommand } from './config.js';
|
|
3
|
-
|
|
4
|
-
export const modelCommand: Command = {
|
|
5
|
-
name: 'model',
|
|
6
|
-
description: 'Alias for /config model',
|
|
7
|
-
usage: '<model-id>',
|
|
8
|
-
handler: (args, ctx) => {
|
|
9
|
-
return configCommand.handler(['model', ...args], ctx);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { Command } from './types.js';
|
|
2
|
-
|
|
3
|
-
const LATEST_TAGS = ['latest', 'current', 'default'];
|
|
4
|
-
|
|
5
|
-
function pickLatestModel(models: string[]): string | null {
|
|
6
|
-
if (!models.length) return null;
|
|
7
|
-
|
|
8
|
-
const tagged = models
|
|
9
|
-
.map(name => ({ name, lower: name.toLowerCase() }))
|
|
10
|
-
.filter(entry => LATEST_TAGS.some(tag => entry.lower.includes(tag)));
|
|
11
|
-
|
|
12
|
-
if (tagged.length > 0) {
|
|
13
|
-
const sorted = tagged.sort((a, b) => {
|
|
14
|
-
const aRank = LATEST_TAGS.findIndex(tag => a.lower.includes(tag));
|
|
15
|
-
const bRank = LATEST_TAGS.findIndex(tag => b.lower.includes(tag));
|
|
16
|
-
if (aRank !== bRank) return aRank - bRank;
|
|
17
|
-
return b.name.localeCompare(a.name);
|
|
18
|
-
});
|
|
19
|
-
return sorted[0].name;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const datePattern = /(\d{4})[.-]?(\d{2})[.-]?(\d{2})/;
|
|
23
|
-
const withDates = models
|
|
24
|
-
.map(name => {
|
|
25
|
-
const match = name.match(datePattern);
|
|
26
|
-
if (!match) return null;
|
|
27
|
-
const dateValue = Number(match[1]) * 10000 + Number(match[2]) * 100 + Number(match[3]);
|
|
28
|
-
return { name, dateValue };
|
|
29
|
-
})
|
|
30
|
-
.filter((entry): entry is { name: string; dateValue: number } => !!entry);
|
|
31
|
-
|
|
32
|
-
if (withDates.length > 0) {
|
|
33
|
-
withDates.sort((a, b) => b.dateValue - a.dateValue || b.name.localeCompare(a.name));
|
|
34
|
-
return withDates[0].name;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const versionPattern = /(\d+(?:\.\d+)+|\d+)/g;
|
|
38
|
-
const withVersions = models
|
|
39
|
-
.map(name => {
|
|
40
|
-
const match = name.match(versionPattern);
|
|
41
|
-
if (!match || match.length === 0) return null;
|
|
42
|
-
const versionValue = parseFloat(match[0]);
|
|
43
|
-
return { name, versionValue };
|
|
44
|
-
})
|
|
45
|
-
.filter((entry): entry is { name: string; versionValue: number } => !!entry);
|
|
46
|
-
|
|
47
|
-
if (withVersions.length > 0) {
|
|
48
|
-
withVersions.sort((a, b) => b.versionValue - a.versionValue || b.name.localeCompare(a.name));
|
|
49
|
-
return withVersions[0].name;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return models.slice().sort((a, b) => b.localeCompare(a))[0];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const modelsCommand: Command = {
|
|
56
|
-
name: 'models',
|
|
57
|
-
description: 'List or set available models for a provider',
|
|
58
|
-
usage: '<list [provider]|latest [provider]|set <model-id>>',
|
|
59
|
-
handler: async (args, ctx) => {
|
|
60
|
-
const subCmd = (args[0] || 'list').toLowerCase();
|
|
61
|
-
|
|
62
|
-
if (subCmd === 'set') {
|
|
63
|
-
const value = args.slice(1).join(' ').trim();
|
|
64
|
-
if (!value) {
|
|
65
|
-
ctx.addMessage({
|
|
66
|
-
role: 'system',
|
|
67
|
-
content: 'Usage: /models set <model-id>'
|
|
68
|
-
});
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
ctx.config.set('model', value);
|
|
72
|
-
await ctx.config.save();
|
|
73
|
-
ctx.reloadAgent();
|
|
74
|
-
ctx.addMessage({ role: 'system', content: `✓ Model updated: ${value}` });
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const provider = args[0] && args[0] !== 'list' && args[0] !== 'latest' ? args[0] : ctx.config.getProvider();
|
|
79
|
-
try {
|
|
80
|
-
const models = await ctx.models.list(provider);
|
|
81
|
-
if (models.length === 0) {
|
|
82
|
-
ctx.addMessage({
|
|
83
|
-
role: 'system',
|
|
84
|
-
content: `No models returned for provider: ${provider}`
|
|
85
|
-
});
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (subCmd === 'latest') {
|
|
89
|
-
const latest = pickLatestModel(models);
|
|
90
|
-
if (!latest) {
|
|
91
|
-
ctx.addMessage({
|
|
92
|
-
role: 'system',
|
|
93
|
-
content: `Unable to determine latest model for ${provider}`
|
|
94
|
-
});
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
ctx.config.set('model', latest);
|
|
98
|
-
await ctx.config.save();
|
|
99
|
-
ctx.reloadAgent();
|
|
100
|
-
ctx.addMessage({ role: 'system', content: `✓ Model updated: ${latest}` });
|
|
101
|
-
} else {
|
|
102
|
-
const lines = models.sort().map(model => ` ${model}`);
|
|
103
|
-
ctx.addMessage({
|
|
104
|
-
role: 'system',
|
|
105
|
-
content: [`Models (${provider}):`, ...lines].join('\n')
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
} catch (err) {
|
|
109
|
-
const message = err instanceof Error ? err.message : 'Unable to list models';
|
|
110
|
-
ctx.addMessage({
|
|
111
|
-
role: 'system',
|
|
112
|
-
content: `Models error: ${message}`
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Command } from './types.js';
|
|
2
|
-
|
|
3
|
-
const ALL_CAPS = ['file_read', 'file_write', 'shell_exec', 'network'] as const;
|
|
4
|
-
|
|
5
|
-
function normalize(value: string): string {
|
|
6
|
-
return value.trim().toLowerCase();
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const permissionsCommand: Command = {
|
|
10
|
-
name: 'permissions',
|
|
11
|
-
description: 'View or update tool permissions',
|
|
12
|
-
usage: '<show|set> [capability] [on|off]',
|
|
13
|
-
handler: async (args, ctx) => {
|
|
14
|
-
const subCmd = normalize(args[0] || 'show');
|
|
15
|
-
const config = ctx.config.get();
|
|
16
|
-
const current = config.toolPermissions || {};
|
|
17
|
-
|
|
18
|
-
if (subCmd === 'show') {
|
|
19
|
-
const lines = ALL_CAPS.map(cap => {
|
|
20
|
-
const value = current[cap];
|
|
21
|
-
const label = value === false ? 'off' : 'on';
|
|
22
|
-
return ` ${cap}: ${label}`;
|
|
23
|
-
});
|
|
24
|
-
ctx.addMessage({
|
|
25
|
-
role: 'system',
|
|
26
|
-
content: ['Tool permissions:', ...lines].join('\n')
|
|
27
|
-
});
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (subCmd === 'set') {
|
|
32
|
-
const cap = normalize(args[1] || '');
|
|
33
|
-
const value = normalize(args[2] || '');
|
|
34
|
-
if (!cap || !ALL_CAPS.includes(cap as typeof ALL_CAPS[number])) {
|
|
35
|
-
ctx.addMessage({
|
|
36
|
-
role: 'system',
|
|
37
|
-
content: `Usage: /permissions set <${ALL_CAPS.join('|')}> <on|off>`
|
|
38
|
-
});
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (value !== 'on' && value !== 'off') {
|
|
42
|
-
ctx.addMessage({
|
|
43
|
-
role: 'system',
|
|
44
|
-
content: 'Usage: /permissions set <capability> <on|off>'
|
|
45
|
-
});
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const next = { ...current, [cap]: value === 'on' };
|
|
49
|
-
ctx.config.set('toolPermissions', next);
|
|
50
|
-
await ctx.config.save();
|
|
51
|
-
ctx.reloadAgent();
|
|
52
|
-
ctx.addMessage({
|
|
53
|
-
role: 'system',
|
|
54
|
-
content: `✓ Permission updated: ${cap} ${value}`
|
|
55
|
-
});
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
ctx.addMessage({
|
|
60
|
-
role: 'system',
|
|
61
|
-
content: 'Usage: /permissions <show|set> [capability] [on|off]'
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Command, ShellResult } from './types.js';
|
|
2
|
-
|
|
3
|
-
function formatShellResult(result: ShellResult): string {
|
|
4
|
-
const lines: string[] = [];
|
|
5
|
-
const stdout = result.stdout.trimEnd();
|
|
6
|
-
const stderr = result.stderr.trimEnd();
|
|
7
|
-
|
|
8
|
-
if (stdout) lines.push(stdout);
|
|
9
|
-
if (stderr) lines.push(stderr);
|
|
10
|
-
if (!stdout && !stderr) lines.push('(no output)');
|
|
11
|
-
|
|
12
|
-
if (result.exitCode !== 0) {
|
|
13
|
-
lines.push(`exit code: ${result.exitCode}`);
|
|
14
|
-
}
|
|
15
|
-
if (result.truncated) {
|
|
16
|
-
lines.push('(output truncated)');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return lines.join('\n');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const shellCommand: Command = {
|
|
23
|
-
name: 'shell',
|
|
24
|
-
description: 'Run a local shell command (or use !command)',
|
|
25
|
-
usage: '<command>',
|
|
26
|
-
handler: async (args, ctx) => {
|
|
27
|
-
const command = args.join(' ').trim();
|
|
28
|
-
if (!command) {
|
|
29
|
-
ctx.addMessage({
|
|
30
|
-
role: 'system',
|
|
31
|
-
content: 'Usage: /shell <command>\n\nExample:\n /shell ls -la\n !pwd'
|
|
32
|
-
});
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
ctx.addMessage({ role: 'system', content: `$ ${command}` });
|
|
37
|
-
try {
|
|
38
|
-
const result = await ctx.shell.run(command);
|
|
39
|
-
ctx.addMessage({ role: 'system', content: formatShellResult(result) });
|
|
40
|
-
} catch (err) {
|
|
41
|
-
const message = err instanceof Error ? err.message : 'Command failed';
|
|
42
|
-
ctx.addMessage({ role: 'system', content: `shell: ${message}` });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const cdCommand: Command = {
|
|
48
|
-
name: 'cd',
|
|
49
|
-
description: 'Change working directory for !/shell commands',
|
|
50
|
-
usage: '[path]',
|
|
51
|
-
handler: async (args, ctx) => {
|
|
52
|
-
const target = args.join(' ').trim();
|
|
53
|
-
if (!target) {
|
|
54
|
-
ctx.addMessage({
|
|
55
|
-
role: 'system',
|
|
56
|
-
content: `cwd: ${ctx.shell.getCwd()}`
|
|
57
|
-
});
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
try {
|
|
61
|
-
const next = await ctx.shell.setCwd(target);
|
|
62
|
-
ctx.addMessage({ role: 'system', content: `cwd: ${next}` });
|
|
63
|
-
} catch (err) {
|
|
64
|
-
const message = err instanceof Error ? err.message : 'Unable to change directory';
|
|
65
|
-
ctx.addMessage({ role: 'system', content: `cd: ${message}` });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Command } from './types.js';
|
|
2
|
-
import { formatSkillList } from '../../skills/index.js';
|
|
3
|
-
|
|
4
|
-
export const skillsCommand: Command = {
|
|
5
|
-
name: 'skills',
|
|
6
|
-
description: 'List or show available skills',
|
|
7
|
-
usage: '<list|show> [id]',
|
|
8
|
-
handler: async (args, ctx) => {
|
|
9
|
-
const subCmd = (args[0] || 'list').toLowerCase();
|
|
10
|
-
const registry = await ctx.skills.list();
|
|
11
|
-
|
|
12
|
-
if (subCmd === 'list') {
|
|
13
|
-
ctx.addMessage({
|
|
14
|
-
role: 'system',
|
|
15
|
-
content: formatSkillList(registry)
|
|
16
|
-
});
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (subCmd === 'show') {
|
|
21
|
-
const id = (args[1] || '').trim();
|
|
22
|
-
if (!id) {
|
|
23
|
-
ctx.addMessage({
|
|
24
|
-
role: 'system',
|
|
25
|
-
content: 'Usage: /skills show <id>'
|
|
26
|
-
});
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const skill = registry.find(entry => entry.id === id);
|
|
30
|
-
if (!skill) {
|
|
31
|
-
ctx.addMessage({
|
|
32
|
-
role: 'system',
|
|
33
|
-
content: `Skill not found: ${id}`
|
|
34
|
-
});
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
ctx.addMessage({
|
|
38
|
-
role: 'system',
|
|
39
|
-
content: [
|
|
40
|
-
`Skill: ${skill.name}`,
|
|
41
|
-
`ID: ${skill.id}`,
|
|
42
|
-
skill.description ? `Description: ${skill.description}` : '',
|
|
43
|
-
skill.instructions
|
|
44
|
-
].filter(Boolean).join('\n')
|
|
45
|
-
});
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
ctx.addMessage({
|
|
50
|
-
role: 'system',
|
|
51
|
-
content: 'Usage: /skills <list|show> [id]'
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Command } from './types.js';
|
|
2
|
-
|
|
3
|
-
export const statusCommand: Command = {
|
|
4
|
-
name: 'status',
|
|
5
|
-
description: 'Show current status',
|
|
6
|
-
handler: (_, ctx) => {
|
|
7
|
-
const hasKey = ctx.config.hasApiKey();
|
|
8
|
-
const config = ctx.config.get();
|
|
9
|
-
ctx.addMessage({
|
|
10
|
-
role: 'system',
|
|
11
|
-
content: [
|
|
12
|
-
'Status:',
|
|
13
|
-
` API Key: ${hasKey ? '✓ configured' : '✗ not set (use /config key <key>)'}`,
|
|
14
|
-
` Model: ${config.model}`,
|
|
15
|
-
` Ready: ${hasKey ? 'Yes' : 'No - need API key'}`
|
|
16
|
-
].join('\n')
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
};
|
|
@@ -1,80 +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 CommandContext {
|
|
57
|
-
addMessage: (msg: Omit<Message, 'id' | 'timestamp'>) => void;
|
|
58
|
-
clearMessages: () => void;
|
|
59
|
-
getMessages: () => Message[];
|
|
60
|
-
setAgentState: (state: AgentState) => void;
|
|
61
|
-
reloadAgent: () => void;
|
|
62
|
-
setDebug: (debug: boolean) => void;
|
|
63
|
-
retry: () => void;
|
|
64
|
-
exit: () => void;
|
|
65
|
-
config: ConfigController;
|
|
66
|
-
emulation: EmulationController;
|
|
67
|
-
shell: ShellController;
|
|
68
|
-
clipboard: ClipboardController;
|
|
69
|
-
models: ModelsController;
|
|
70
|
-
skills: SkillsController;
|
|
71
|
-
getInputMode: () => 'queue' | 'interrupt';
|
|
72
|
-
setInputMode: (mode: 'queue' | 'interrupt') => void;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface Command {
|
|
76
|
-
name: string;
|
|
77
|
-
description: string;
|
|
78
|
-
usage?: string;
|
|
79
|
-
handler: (args: string[], ctx: CommandContext) => void | Promise<void>;
|
|
80
|
-
}
|