rackmind-cli 0.1.2
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/README.md +179 -0
- package/bin/rackmind.js +6 -0
- package/dist/ai/client.d.ts +71 -0
- package/dist/ai/client.d.ts.map +1 -0
- package/dist/ai/client.js +198 -0
- package/dist/ai/client.js.map +1 -0
- package/dist/ai/system-prompt.d.ts +20 -0
- package/dist/ai/system-prompt.d.ts.map +1 -0
- package/dist/ai/system-prompt.js +169 -0
- package/dist/ai/system-prompt.js.map +1 -0
- package/dist/ai/tool-executor.d.ts +27 -0
- package/dist/ai/tool-executor.d.ts.map +1 -0
- package/dist/ai/tool-executor.js +184 -0
- package/dist/ai/tool-executor.js.map +1 -0
- package/dist/ai/tools.d.ts +7 -0
- package/dist/ai/tools.d.ts.map +1 -0
- package/dist/ai/tools.js +203 -0
- package/dist/ai/tools.js.map +1 -0
- package/dist/commands/config.d.ts +21 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +169 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/connect.d.ts +7 -0
- package/dist/commands/connect.d.ts.map +1 -0
- package/dist/commands/connect.js +117 -0
- package/dist/commands/connect.js.map +1 -0
- package/dist/commands/containers.d.ts +5 -0
- package/dist/commands/containers.d.ts.map +1 -0
- package/dist/commands/containers.js +83 -0
- package/dist/commands/containers.js.map +1 -0
- package/dist/commands/exec.d.ts +5 -0
- package/dist/commands/exec.d.ts.map +1 -0
- package/dist/commands/exec.js +133 -0
- package/dist/commands/exec.js.map +1 -0
- package/dist/commands/lifecycle.d.ts +7 -0
- package/dist/commands/lifecycle.d.ts.map +1 -0
- package/dist/commands/lifecycle.js +213 -0
- package/dist/commands/lifecycle.js.map +1 -0
- package/dist/commands/logs.d.ts +5 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +117 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/report.d.ts +6 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +203 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/servers.d.ts +17 -0
- package/dist/commands/servers.d.ts.map +1 -0
- package/dist/commands/servers.js +116 -0
- package/dist/commands/servers.js.map +1 -0
- package/dist/commands/status.d.ts +5 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +174 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/vms.d.ts +5 -0
- package/dist/commands/vms.d.ts.map +1 -0
- package/dist/commands/vms.js +83 -0
- package/dist/commands/vms.js.map +1 -0
- package/dist/config/crypto.d.ts +20 -0
- package/dist/config/crypto.d.ts.map +1 -0
- package/dist/config/crypto.js +78 -0
- package/dist/config/crypto.js.map +1 -0
- package/dist/config/index.d.ts +21 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +158 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/types.d.ts +263 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +83 -0
- package/dist/config/types.js.map +1 -0
- package/dist/globals.d.ts +22 -0
- package/dist/globals.d.ts.map +1 -0
- package/dist/globals.js +43 -0
- package/dist/globals.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +399 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive/App.d.ts +3 -0
- package/dist/interactive/App.d.ts.map +1 -0
- package/dist/interactive/App.js +103 -0
- package/dist/interactive/App.js.map +1 -0
- package/dist/interactive/components/Header.d.ts +8 -0
- package/dist/interactive/components/Header.d.ts.map +1 -0
- package/dist/interactive/components/Header.js +20 -0
- package/dist/interactive/components/Header.js.map +1 -0
- package/dist/interactive/components/InputBar.d.ts +9 -0
- package/dist/interactive/components/InputBar.d.ts.map +1 -0
- package/dist/interactive/components/InputBar.js +89 -0
- package/dist/interactive/components/InputBar.js.map +1 -0
- package/dist/interactive/components/MessageList.d.ts +9 -0
- package/dist/interactive/components/MessageList.d.ts.map +1 -0
- package/dist/interactive/components/MessageList.js +28 -0
- package/dist/interactive/components/MessageList.js.map +1 -0
- package/dist/interactive/components/Spinner.d.ts +7 -0
- package/dist/interactive/components/Spinner.d.ts.map +1 -0
- package/dist/interactive/components/Spinner.js +19 -0
- package/dist/interactive/components/Spinner.js.map +1 -0
- package/dist/interactive/components/StatusBar.d.ts +10 -0
- package/dist/interactive/components/StatusBar.d.ts.map +1 -0
- package/dist/interactive/components/StatusBar.js +7 -0
- package/dist/interactive/components/StatusBar.js.map +1 -0
- package/dist/interactive/components/StreamingMessage.d.ts +7 -0
- package/dist/interactive/components/StreamingMessage.d.ts.map +1 -0
- package/dist/interactive/components/StreamingMessage.js +9 -0
- package/dist/interactive/components/StreamingMessage.js.map +1 -0
- package/dist/interactive/components/ToolIndicator.d.ts +7 -0
- package/dist/interactive/components/ToolIndicator.d.ts.map +1 -0
- package/dist/interactive/components/ToolIndicator.js +10 -0
- package/dist/interactive/components/ToolIndicator.js.map +1 -0
- package/dist/interactive/components/ToolOutput.d.ts +8 -0
- package/dist/interactive/components/ToolOutput.d.ts.map +1 -0
- package/dist/interactive/components/ToolOutput.js +9 -0
- package/dist/interactive/components/ToolOutput.js.map +1 -0
- package/dist/interactive/components/WelcomeScreen.d.ts +9 -0
- package/dist/interactive/components/WelcomeScreen.d.ts.map +1 -0
- package/dist/interactive/components/WelcomeScreen.js +8 -0
- package/dist/interactive/components/WelcomeScreen.js.map +1 -0
- package/dist/interactive/launch.d.ts +6 -0
- package/dist/interactive/launch.d.ts.map +1 -0
- package/dist/interactive/launch.js +30 -0
- package/dist/interactive/launch.js.map +1 -0
- package/dist/interactive/slashCommands.d.ts +13 -0
- package/dist/interactive/slashCommands.d.ts.map +1 -0
- package/dist/interactive/slashCommands.js +102 -0
- package/dist/interactive/slashCommands.js.map +1 -0
- package/dist/interactive/useRackMind.d.ts +30 -0
- package/dist/interactive/useRackMind.d.ts.map +1 -0
- package/dist/interactive/useRackMind.js +241 -0
- package/dist/interactive/useRackMind.js.map +1 -0
- package/dist/oneshot/run.d.ts +2 -0
- package/dist/oneshot/run.d.ts.map +1 -0
- package/dist/oneshot/run.js +195 -0
- package/dist/oneshot/run.js.map +1 -0
- package/dist/server/client.d.ts +89 -0
- package/dist/server/client.d.ts.map +1 -0
- package/dist/server/client.js +239 -0
- package/dist/server/client.js.map +1 -0
- package/dist/server/proxmox.d.ts +160 -0
- package/dist/server/proxmox.d.ts.map +1 -0
- package/dist/server/proxmox.js +219 -0
- package/dist/server/proxmox.js.map +1 -0
- package/dist/server/ssh.d.ts +80 -0
- package/dist/server/ssh.d.ts.map +1 -0
- package/dist/server/ssh.js +262 -0
- package/dist/server/ssh.js.map +1 -0
- package/dist/utils/ascii.d.ts +3 -0
- package/dist/utils/ascii.d.ts.map +1 -0
- package/dist/utils/ascii.js +16 -0
- package/dist/utils/ascii.js.map +1 -0
- package/dist/utils/format.d.ts +7 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +20 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/history.d.ts +23 -0
- package/dist/utils/history.d.ts.map +1 -0
- package/dist/utils/history.js +107 -0
- package/dist/utils/history.js.map +1 -0
- package/dist/utils/logger.d.ts +9 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +51 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/markdown.d.ts +12 -0
- package/dist/utils/markdown.d.ts.map +1 -0
- package/dist/utils/markdown.js +76 -0
- package/dist/utils/markdown.js.map +1 -0
- package/dist/utils/prompt.d.ts +25 -0
- package/dist/utils/prompt.d.ts.map +1 -0
- package/dist/utils/prompt.js +133 -0
- package/dist/utils/prompt.js.map +1 -0
- package/dist/utils/retry.d.ts +37 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +122 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/shutdown.d.ts +22 -0
- package/dist/utils/shutdown.d.ts.map +1 -0
- package/dist/utils/shutdown.js +94 -0
- package/dist/utils/shutdown.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 +150 -0
- package/dist/utils/table.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/ai/system-prompt.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,sEAAsE;AACtE,8EAA8E;AAC9E,8EAA8E;AAC9E,kFAAkF;AAClF,8EAA8E;AAI9E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E,SAAS,WAAW,CAAC,KAAa;IAC9B,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9B,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACxC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7C,CAAC;AAED,SAAS,YAAY,CAAC,OAAe;IACjC,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,aAAa,CAAC;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,GAAG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andInput {
|
|
3
|
+
command: string;
|
|
4
|
+
}
|
|
5
|
+
interface ExecuteCommandInContainerInput {
|
|
6
|
+
vmid: number;
|
|
7
|
+
command: string;
|
|
8
|
+
}
|
|
9
|
+
interface VmidInput {
|
|
10
|
+
vmid: number;
|
|
11
|
+
}
|
|
12
|
+
type ToolInput = ExecuteCommandInput | ExecuteCommandInContainerInput | VmidInput | Record<string, never>;
|
|
13
|
+
export interface ToolResult {
|
|
14
|
+
/** The string content to send back to Claude */
|
|
15
|
+
content: string;
|
|
16
|
+
/** Whether the tool call encountered an error */
|
|
17
|
+
isError: boolean;
|
|
18
|
+
/** Human-readable label for the tool execution (shown to user) */
|
|
19
|
+
label: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Execute a tool call and return the result.
|
|
23
|
+
* Catches all errors and returns them as error results rather than throwing.
|
|
24
|
+
*/
|
|
25
|
+
export declare function executeTool(toolName: string, input: ToolInput, client: ServerClient): Promise<ToolResult>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=tool-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-executor.d.ts","sourceRoot":"","sources":["../../src/ai/tool-executor.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAOxD,UAAU,mBAAmB;IACzB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,8BAA8B;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,SAAS;IACf,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,SAAS,GACR,mBAAmB,GACnB,8BAA8B,GAC9B,SAAS,GACT,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAM5B,MAAM,WAAW,UAAU;IACvB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;CACjB;AAMD;;;GAGG;AACH,wBAAsB,WAAW,CAC7B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,YAAY,GACrB,OAAO,CAAC,UAAU,CAAC,CA+DrB"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Tool executor — dispatches AI tool calls to ServerClient methods
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Maps tool names from Claude's function calling to actual ServerClient
|
|
5
|
+
// operations. Returns serialized results for the tool_result message.
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
import { logger } from '../utils/logger.js';
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Executor
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
/**
|
|
12
|
+
* Execute a tool call and return the result.
|
|
13
|
+
* Catches all errors and returns them as error results rather than throwing.
|
|
14
|
+
*/
|
|
15
|
+
export async function executeTool(toolName, input, client) {
|
|
16
|
+
logger.info('Executing tool', { toolName, input });
|
|
17
|
+
try {
|
|
18
|
+
switch (toolName) {
|
|
19
|
+
case 'execute_command':
|
|
20
|
+
return await executeCommand(input, client);
|
|
21
|
+
case 'execute_command_in_container':
|
|
22
|
+
return await executeCommandInContainer(input, client);
|
|
23
|
+
case 'get_container_status':
|
|
24
|
+
return await getContainerStatus(input, client);
|
|
25
|
+
case 'get_vm_status':
|
|
26
|
+
return await getVmStatus(input, client);
|
|
27
|
+
case 'get_node_status':
|
|
28
|
+
return await getNodeStatus(client);
|
|
29
|
+
case 'list_containers':
|
|
30
|
+
return await listContainers(client);
|
|
31
|
+
case 'list_vms':
|
|
32
|
+
return await listVms(client);
|
|
33
|
+
case 'start_container':
|
|
34
|
+
return await startContainer(input, client);
|
|
35
|
+
case 'stop_container':
|
|
36
|
+
return await stopContainer(input, client);
|
|
37
|
+
case 'restart_container':
|
|
38
|
+
return await restartContainer(input, client);
|
|
39
|
+
case 'start_vm':
|
|
40
|
+
return await startVm(input, client);
|
|
41
|
+
case 'stop_vm':
|
|
42
|
+
return await stopVm(input, client);
|
|
43
|
+
case 'restart_vm':
|
|
44
|
+
return await restartVm(input, client);
|
|
45
|
+
default:
|
|
46
|
+
return {
|
|
47
|
+
content: `Unknown tool: ${toolName}`,
|
|
48
|
+
isError: true,
|
|
49
|
+
label: `Unknown tool: ${toolName}`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
55
|
+
logger.error('Tool execution failed', { toolName, error: message });
|
|
56
|
+
return {
|
|
57
|
+
content: `Error: ${message}`,
|
|
58
|
+
isError: true,
|
|
59
|
+
label: `${toolName} (failed)`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
// Individual tool handlers
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
async function executeCommand(input, client) {
|
|
67
|
+
const result = await client.execOnHost(input.command);
|
|
68
|
+
const output = [
|
|
69
|
+
result.stdout ? `stdout:\n${result.stdout}` : '',
|
|
70
|
+
result.stderr ? `stderr:\n${result.stderr}` : '',
|
|
71
|
+
`exit code: ${result.exitCode ?? 'unknown'}`,
|
|
72
|
+
]
|
|
73
|
+
.filter(Boolean)
|
|
74
|
+
.join('\n');
|
|
75
|
+
return {
|
|
76
|
+
content: output,
|
|
77
|
+
isError: result.exitCode !== 0,
|
|
78
|
+
label: `ssh: ${input.command}`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async function executeCommandInContainer(input, client) {
|
|
82
|
+
const result = await client.execInContainer(input.vmid, input.command);
|
|
83
|
+
const output = [
|
|
84
|
+
result.stdout ? `stdout:\n${result.stdout}` : '',
|
|
85
|
+
result.stderr ? `stderr:\n${result.stderr}` : '',
|
|
86
|
+
`exit code: ${result.exitCode ?? 'unknown'}`,
|
|
87
|
+
]
|
|
88
|
+
.filter(Boolean)
|
|
89
|
+
.join('\n');
|
|
90
|
+
return {
|
|
91
|
+
content: output,
|
|
92
|
+
isError: result.exitCode !== 0,
|
|
93
|
+
label: `pct exec ${input.vmid}: ${input.command}`,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async function getContainerStatus(input, client) {
|
|
97
|
+
const status = await client.getContainerStatus(input.vmid);
|
|
98
|
+
return {
|
|
99
|
+
content: JSON.stringify(status, null, 2),
|
|
100
|
+
isError: false,
|
|
101
|
+
label: `get container ${input.vmid} status`,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async function getVmStatus(input, client) {
|
|
105
|
+
const status = await client.getVMStatus(input.vmid);
|
|
106
|
+
return {
|
|
107
|
+
content: JSON.stringify(status, null, 2),
|
|
108
|
+
isError: false,
|
|
109
|
+
label: `get VM ${input.vmid} status`,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
async function getNodeStatus(client) {
|
|
113
|
+
const status = await client.getNodeStatus();
|
|
114
|
+
return {
|
|
115
|
+
content: JSON.stringify(status, null, 2),
|
|
116
|
+
isError: false,
|
|
117
|
+
label: 'get node status',
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
async function listContainers(client) {
|
|
121
|
+
const containers = await client.listContainers();
|
|
122
|
+
return {
|
|
123
|
+
content: JSON.stringify(containers, null, 2),
|
|
124
|
+
isError: false,
|
|
125
|
+
label: `list containers (${containers.length} found)`,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
async function listVms(client) {
|
|
129
|
+
const vms = await client.listVMs();
|
|
130
|
+
return {
|
|
131
|
+
content: JSON.stringify(vms, null, 2),
|
|
132
|
+
isError: false,
|
|
133
|
+
label: `list VMs (${vms.length} found)`,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
async function startContainer(input, client) {
|
|
137
|
+
const taskId = await client.startContainer(input.vmid);
|
|
138
|
+
return {
|
|
139
|
+
content: `Container ${input.vmid} start initiated. Task ID: ${taskId}`,
|
|
140
|
+
isError: false,
|
|
141
|
+
label: `start container ${input.vmid}`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async function stopContainer(input, client) {
|
|
145
|
+
const taskId = await client.stopContainer(input.vmid);
|
|
146
|
+
return {
|
|
147
|
+
content: `Container ${input.vmid} stop initiated. Task ID: ${taskId}`,
|
|
148
|
+
isError: false,
|
|
149
|
+
label: `stop container ${input.vmid}`,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async function restartContainer(input, client) {
|
|
153
|
+
const taskId = await client.restartContainer(input.vmid);
|
|
154
|
+
return {
|
|
155
|
+
content: `Container ${input.vmid} restart initiated. Task ID: ${taskId}`,
|
|
156
|
+
isError: false,
|
|
157
|
+
label: `restart container ${input.vmid}`,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
async function startVm(input, client) {
|
|
161
|
+
const taskId = await client.startVM(input.vmid);
|
|
162
|
+
return {
|
|
163
|
+
content: `VM ${input.vmid} start initiated. Task ID: ${taskId}`,
|
|
164
|
+
isError: false,
|
|
165
|
+
label: `start VM ${input.vmid}`,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
async function stopVm(input, client) {
|
|
169
|
+
const taskId = await client.stopVM(input.vmid);
|
|
170
|
+
return {
|
|
171
|
+
content: `VM ${input.vmid} stop initiated. Task ID: ${taskId}`,
|
|
172
|
+
isError: false,
|
|
173
|
+
label: `stop VM ${input.vmid}`,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
async function restartVm(input, client) {
|
|
177
|
+
const taskId = await client.restartVM(input.vmid);
|
|
178
|
+
return {
|
|
179
|
+
content: `VM ${input.vmid} restart initiated. Task ID: ${taskId}`,
|
|
180
|
+
isError: false,
|
|
181
|
+
label: `restart VM ${input.vmid}`,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=tool-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-executor.js","sourceRoot":"","sources":["../../src/ai/tool-executor.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,mEAAmE;AACnE,8EAA8E;AAC9E,wEAAwE;AACxE,sEAAsE;AACtE,8EAA8E;AAG9E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAsC5C,8EAA8E;AAC9E,WAAW;AACX,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC7B,QAAgB,EAChB,KAAgB,EAChB,MAAoB;IAEpB,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAEnD,IAAI,CAAC;QACD,QAAQ,QAAQ,EAAE,CAAC;YACf,KAAK,iBAAiB;gBAClB,OAAO,MAAM,cAAc,CAAC,KAA4B,EAAE,MAAM,CAAC,CAAC;YAEtE,KAAK,8BAA8B;gBAC/B,OAAO,MAAM,yBAAyB,CAClC,KAAuC,EACvC,MAAM,CACT,CAAC;YAEN,KAAK,sBAAsB;gBACvB,OAAO,MAAM,kBAAkB,CAAC,KAAkB,EAAE,MAAM,CAAC,CAAC;YAEhE,KAAK,eAAe;gBAChB,OAAO,MAAM,WAAW,CAAC,KAAkB,EAAE,MAAM,CAAC,CAAC;YAEzD,KAAK,iBAAiB;gBAClB,OAAO,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;YAEvC,KAAK,iBAAiB;gBAClB,OAAO,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;YAExC,KAAK,UAAU;gBACX,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;YAEjC,KAAK,iBAAiB;gBAClB,OAAO,MAAM,cAAc,CAAC,KAAkB,EAAE,MAAM,CAAC,CAAC;YAE5D,KAAK,gBAAgB;gBACjB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YAAY,KAAK,CAAC,IAAI,EAAE;KAClC,CAAC;AACN,CAAC;AAED,KAAK,UAAU,MAAM,CAAC,KAAgB,EAAE,MAAoB;IACxD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO;QACH,OAAO,EAAE,MAAM,KAAK,CAAC,IAAI,6BAA6B,MAAM,EAAE;QAC9D,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,WAAW,KAAK,CAAC,IAAI,EAAE;KACjC,CAAC;AACN,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,KAAgB,EAAE,MAAoB;IAC3D,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClD,OAAO;QACH,OAAO,EAAE,MAAM,KAAK,CAAC,IAAI,gCAAgC,MAAM,EAAE;QACjE,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,cAAc,KAAK,CAAC,IAAI,EAAE;KACpC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type Anthropic from '@anthropic-ai/sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Tool definitions for Claude function calling.
|
|
4
|
+
* These describe what Claude can do to interact with the Proxmox server.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getToolDefinitions(): Anthropic.Messages.Tool[];
|
|
7
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/ai/tools.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,CA2M9D"}
|
package/dist/ai/tools.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// AI tool definitions — tools that Claude can invoke during a conversation
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Each tool maps to a ServerClient method. The tool use loop in the AI module
|
|
5
|
+
// sends tool results back to Claude until it produces a final text response.
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
/**
|
|
8
|
+
* Tool definitions for Claude function calling.
|
|
9
|
+
* These describe what Claude can do to interact with the Proxmox server.
|
|
10
|
+
*/
|
|
11
|
+
export function getToolDefinitions() {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
name: 'execute_command',
|
|
15
|
+
description: 'Execute a shell command on the Proxmox host via SSH. ' +
|
|
16
|
+
'Use this for system administration tasks like checking logs, ' +
|
|
17
|
+
'managing services, inspecting disk usage, network config, etc. ' +
|
|
18
|
+
'Commands run as the configured SSH user (typically root).',
|
|
19
|
+
input_schema: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
command: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
description: 'The shell command to execute on the Proxmox host',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
required: ['command'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'execute_command_in_container',
|
|
32
|
+
description: 'Execute a shell command inside a specific LXC container. ' +
|
|
33
|
+
'Uses `pct exec` under the hood. Use this when the user asks about ' +
|
|
34
|
+
'something running inside a container, or wants to manage a container ' +
|
|
35
|
+
'from the inside (check logs, services, packages, etc.).',
|
|
36
|
+
input_schema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
vmid: {
|
|
40
|
+
type: 'number',
|
|
41
|
+
description: 'The VMID of the LXC container',
|
|
42
|
+
},
|
|
43
|
+
command: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: 'The shell command to execute inside the container',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ['vmid', 'command'],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'get_container_status',
|
|
53
|
+
description: 'Get detailed status of a specific LXC container including CPU, memory, ' +
|
|
54
|
+
'disk usage, network I/O, and uptime. Use this when the user asks about ' +
|
|
55
|
+
'a specific container.',
|
|
56
|
+
input_schema: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
vmid: {
|
|
60
|
+
type: 'number',
|
|
61
|
+
description: 'The VMID of the LXC container',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
required: ['vmid'],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'get_vm_status',
|
|
69
|
+
description: 'Get detailed status of a specific QEMU virtual machine including CPU, ' +
|
|
70
|
+
'memory, disk usage, network I/O, and uptime.',
|
|
71
|
+
input_schema: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
properties: {
|
|
74
|
+
vmid: {
|
|
75
|
+
type: 'number',
|
|
76
|
+
description: 'The VMID of the QEMU VM',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
required: ['vmid'],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'get_node_status',
|
|
84
|
+
description: 'Get resource usage for the Proxmox node itself — CPU, memory, disk, ' +
|
|
85
|
+
'and uptime. Use this when the user asks about the host/node/server health.',
|
|
86
|
+
input_schema: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {},
|
|
89
|
+
required: [],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'list_containers',
|
|
94
|
+
description: 'Refresh the list of all LXC containers on the node. Returns VMID, name, ' +
|
|
95
|
+
'status, CPU count, memory, disk, and network stats for each container.',
|
|
96
|
+
input_schema: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
properties: {},
|
|
99
|
+
required: [],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'list_vms',
|
|
104
|
+
description: 'Refresh the list of all QEMU virtual machines on the node. Returns VMID, ' +
|
|
105
|
+
'name, status, CPU count, memory, disk, and network stats for each VM.',
|
|
106
|
+
input_schema: {
|
|
107
|
+
type: 'object',
|
|
108
|
+
properties: {},
|
|
109
|
+
required: [],
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'start_container',
|
|
114
|
+
description: 'Start a stopped LXC container. This is a destructive action — ' +
|
|
115
|
+
'confirm with the user before calling.',
|
|
116
|
+
input_schema: {
|
|
117
|
+
type: 'object',
|
|
118
|
+
properties: {
|
|
119
|
+
vmid: {
|
|
120
|
+
type: 'number',
|
|
121
|
+
description: 'The VMID of the LXC container to start',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
required: ['vmid'],
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'stop_container',
|
|
129
|
+
description: 'Stop a running LXC container. This is a DESTRUCTIVE action that will ' +
|
|
130
|
+
'halt all processes in the container. Always confirm with the user first.',
|
|
131
|
+
input_schema: {
|
|
132
|
+
type: 'object',
|
|
133
|
+
properties: {
|
|
134
|
+
vmid: {
|
|
135
|
+
type: 'number',
|
|
136
|
+
description: 'The VMID of the LXC container to stop',
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
required: ['vmid'],
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'restart_container',
|
|
144
|
+
description: 'Restart (reboot) a running LXC container. This will briefly interrupt ' +
|
|
145
|
+
'all services. Confirm with the user before calling.',
|
|
146
|
+
input_schema: {
|
|
147
|
+
type: 'object',
|
|
148
|
+
properties: {
|
|
149
|
+
vmid: {
|
|
150
|
+
type: 'number',
|
|
151
|
+
description: 'The VMID of the LXC container to restart',
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
required: ['vmid'],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'start_vm',
|
|
159
|
+
description: 'Start a stopped QEMU VM. Confirm with the user before calling.',
|
|
160
|
+
input_schema: {
|
|
161
|
+
type: 'object',
|
|
162
|
+
properties: {
|
|
163
|
+
vmid: {
|
|
164
|
+
type: 'number',
|
|
165
|
+
description: 'The VMID of the QEMU VM to start',
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
required: ['vmid'],
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: 'stop_vm',
|
|
173
|
+
description: 'Stop a running QEMU VM. This is a DESTRUCTIVE action. ' +
|
|
174
|
+
'Always confirm with the user first.',
|
|
175
|
+
input_schema: {
|
|
176
|
+
type: 'object',
|
|
177
|
+
properties: {
|
|
178
|
+
vmid: {
|
|
179
|
+
type: 'number',
|
|
180
|
+
description: 'The VMID of the QEMU VM to stop',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
required: ['vmid'],
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: 'restart_vm',
|
|
188
|
+
description: 'Restart (reboot) a running QEMU VM. Will briefly interrupt all services. ' +
|
|
189
|
+
'Confirm with the user before calling.',
|
|
190
|
+
input_schema: {
|
|
191
|
+
type: 'object',
|
|
192
|
+
properties: {
|
|
193
|
+
vmid: {
|
|
194
|
+
type: 'number',
|
|
195
|
+
description: 'The VMID of the QEMU VM to restart',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
required: ['vmid'],
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/ai/tools.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,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V,IAAI,EAAE,QAAiB;gBACvB,UAAU,EAAE;oBACR,IAAI,EAAE;wBACF,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,0CAA0C;qBAC1D;iBACJ;gBACD,QAAQ,EAAE,CAAC,MAAM,CAAC;aACrB;SACJ;QACD;YACI,IAAI,EAAE,UAAU;YAChB,WAAW,EAAE,gEAAgE;YAC7E,YAAY,EAAE;gBACV,IAAI,EAAE,QAAiB;gBACvB,UAAU,EAAE;oBACR,IAAI,EAAE;wBACF,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,kCAAkC;qBAClD;iBACJ;gBACD,QAAQ,EAAE,CAAC,MAAM,CAAC;aACrB;SACJ;QACD;YACI,IAAI,EAAE,SAAS;YACf,WAAW,EACP,wDAAwD;gBACxD,qCAAqC;YACzC,YAAY,EAAE;gBACV,IAAI,EAAE,QAAiB;gBACvB,UAAU,EAAE;oBACR,IAAI,EAAE;wBACF,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,iCAAiC;qBACjD;iBACJ;gBACD,QAAQ,EAAE,CAAC,MAAM,CAAC;aACrB;SACJ;QACD;YACI,IAAI,EAAE,YAAY;YAClB,WAAW,EACP,2EAA2E;gBAC3E,uCAAuC;YAC3C,YAAY,EAAE;gBACV,IAAI,EAAE,QAAiB;gBACvB,UAAU,EAAE;oBACR,IAAI,EAAE;wBACF,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,oCAAoC;qBACpD;iBACJ;gBACD,QAAQ,EAAE,CAAC,MAAM,CAAC;aACrB;SACJ;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display the current configuration.
|
|
3
|
+
*/
|
|
4
|
+
export declare function configShowCommand(): void;
|
|
5
|
+
/**
|
|
6
|
+
* Set a preference value.
|
|
7
|
+
*/
|
|
8
|
+
export declare function configSetCommand(key: string, value: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Reset all preferences to defaults.
|
|
11
|
+
*/
|
|
12
|
+
export declare function configResetCommand(): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Set or update the Anthropic API key.
|
|
15
|
+
*/
|
|
16
|
+
export declare function configSetApiKeyCommand(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Print the config file path.
|
|
19
|
+
*/
|
|
20
|
+
export declare function configPathCommand(): void;
|
|
21
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAuDA;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAyDxC;AAMD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CA8CjE;AAMD;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAcxD;AAMD;;GAEG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAqB5D;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// rackmind config — view and edit CLI configuration
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Subcommands:
|
|
5
|
+
// rackmind config — show current config (read-only)
|
|
6
|
+
// rackmind config set <k> <v> — set a preference value
|
|
7
|
+
// rackmind config reset — restore default preferences
|
|
8
|
+
// rackmind config set-api-key — set the Anthropic API key
|
|
9
|
+
// rackmind config path — print the config file path
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import { readConfig, writeConfig, getAnthropicApiKey, setAnthropicApiKey, getConfigPath, } from '../config/index.js';
|
|
13
|
+
import { getDefaultPreferences } from '../config/types.js';
|
|
14
|
+
import { formatError, formatSuccess, formatKeyValue, formatWarning } from '../utils/format.js';
|
|
15
|
+
import { promptSecret, promptConfirm } from '../utils/prompt.js';
|
|
16
|
+
import { logger } from '../utils/logger.js';
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Valid preference keys and their types
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
const PREFERENCE_KEYS = {
|
|
21
|
+
model: {
|
|
22
|
+
description: 'AI model to use (e.g., claude-sonnet-4-5)',
|
|
23
|
+
type: 'string',
|
|
24
|
+
},
|
|
25
|
+
theme: {
|
|
26
|
+
description: 'Color theme: dark or light',
|
|
27
|
+
type: 'string',
|
|
28
|
+
validate: (v) => v === 'dark' || v === 'light',
|
|
29
|
+
},
|
|
30
|
+
confirmDestructive: {
|
|
31
|
+
description: 'Require confirmation for destructive actions (true/false)',
|
|
32
|
+
type: 'boolean',
|
|
33
|
+
},
|
|
34
|
+
timestampMessages: {
|
|
35
|
+
description: 'Show timestamps on messages (true/false)',
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// Show config
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
/**
|
|
43
|
+
* Display the current configuration.
|
|
44
|
+
*/
|
|
45
|
+
export function configShowCommand() {
|
|
46
|
+
const config = readConfig();
|
|
47
|
+
const hasApiKey = Boolean(getAnthropicApiKey());
|
|
48
|
+
process.stderr.write(chalk.cyan.bold('\nRackMind Configuration\n'));
|
|
49
|
+
process.stderr.write(chalk.dim('-'.repeat(50) + '\n\n'));
|
|
50
|
+
// Config file path
|
|
51
|
+
process.stderr.write(formatKeyValue('Config file', getConfigPath()) + '\n');
|
|
52
|
+
process.stderr.write(formatKeyValue('Version', config.version) + '\n\n');
|
|
53
|
+
// API key
|
|
54
|
+
process.stderr.write(chalk.bold('API Key\n'));
|
|
55
|
+
if (hasApiKey) {
|
|
56
|
+
const key = getAnthropicApiKey();
|
|
57
|
+
const masked = key.slice(0, 10) + '...' + key.slice(-4);
|
|
58
|
+
process.stderr.write(formatKeyValue(' Anthropic', chalk.green(masked)) + '\n');
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
process.stderr.write(formatKeyValue(' Anthropic', chalk.yellow('not configured')) + '\n');
|
|
62
|
+
}
|
|
63
|
+
process.stderr.write('\n');
|
|
64
|
+
// Active server
|
|
65
|
+
process.stderr.write(chalk.bold('Server\n'));
|
|
66
|
+
process.stderr.write(formatKeyValue(' Active', config.activeServer ?? chalk.dim('none')) + '\n');
|
|
67
|
+
process.stderr.write(formatKeyValue(' Total profiles', String(Object.keys(config.servers).length)) + '\n');
|
|
68
|
+
process.stderr.write('\n');
|
|
69
|
+
// Preferences
|
|
70
|
+
process.stderr.write(chalk.bold('Preferences\n'));
|
|
71
|
+
process.stderr.write(formatKeyValue(' model', config.preferences.model) + '\n');
|
|
72
|
+
process.stderr.write(formatKeyValue(' theme', config.preferences.theme) + '\n');
|
|
73
|
+
process.stderr.write(formatKeyValue(' confirmDestructive', config.preferences.confirmDestructive ? 'true' : 'false') + '\n');
|
|
74
|
+
process.stderr.write(formatKeyValue(' timestampMessages', config.preferences.timestampMessages ? 'true' : 'false') + '\n');
|
|
75
|
+
process.stderr.write('\n');
|
|
76
|
+
// Help text
|
|
77
|
+
process.stderr.write(chalk.dim('Use `rackmind config set <key> <value>` to change a setting.\n'));
|
|
78
|
+
process.stderr.write(chalk.dim('Use `rackmind config set-api-key` to update your API key.\n\n'));
|
|
79
|
+
}
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Set preference
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
/**
|
|
84
|
+
* Set a preference value.
|
|
85
|
+
*/
|
|
86
|
+
export function configSetCommand(key, value) {
|
|
87
|
+
const prefKey = PREFERENCE_KEYS[key];
|
|
88
|
+
if (!prefKey) {
|
|
89
|
+
process.stderr.write(formatError(`Unknown preference key: "${key}"\n\nValid keys:\n` +
|
|
90
|
+
Object.entries(PREFERENCE_KEYS)
|
|
91
|
+
.map(([k, v]) => ` ${chalk.bold(k)} - ${v.description}`)
|
|
92
|
+
.join('\n')) + '\n');
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
// Validate value
|
|
96
|
+
if (prefKey.type === 'boolean') {
|
|
97
|
+
if (value !== 'true' && value !== 'false') {
|
|
98
|
+
process.stderr.write(formatError(`Value for "${key}" must be "true" or "false", got "${value}"`) + '\n');
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (prefKey.validate && !prefKey.validate(value)) {
|
|
103
|
+
process.stderr.write(formatError(`Invalid value "${value}" for "${key}". ${prefKey.description}`) + '\n');
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
// Update config
|
|
107
|
+
const config = readConfig();
|
|
108
|
+
const prefKeyTyped = key;
|
|
109
|
+
if (prefKey.type === 'boolean') {
|
|
110
|
+
config.preferences[prefKeyTyped] = value === 'true';
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
config.preferences[prefKeyTyped] = value;
|
|
114
|
+
}
|
|
115
|
+
writeConfig(config);
|
|
116
|
+
logger.info('Config preference updated', { key, value });
|
|
117
|
+
process.stderr.write(formatSuccess(`Set ${chalk.bold(key)} = ${value}`) + '\n');
|
|
118
|
+
}
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
// Reset preferences
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
/**
|
|
123
|
+
* Reset all preferences to defaults.
|
|
124
|
+
*/
|
|
125
|
+
export async function configResetCommand() {
|
|
126
|
+
const confirmed = await promptConfirm('Reset all preferences to defaults?', false);
|
|
127
|
+
if (!confirmed) {
|
|
128
|
+
process.stderr.write(chalk.dim('Cancelled.\n'));
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const config = readConfig();
|
|
132
|
+
config.preferences = getDefaultPreferences();
|
|
133
|
+
writeConfig(config);
|
|
134
|
+
logger.info('Config preferences reset to defaults');
|
|
135
|
+
process.stderr.write(formatSuccess('Preferences reset to defaults.') + '\n');
|
|
136
|
+
}
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
// Set API key
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
/**
|
|
141
|
+
* Set or update the Anthropic API key.
|
|
142
|
+
*/
|
|
143
|
+
export async function configSetApiKeyCommand() {
|
|
144
|
+
const existing = getAnthropicApiKey();
|
|
145
|
+
if (existing) {
|
|
146
|
+
const masked = existing.slice(0, 10) + '...' + existing.slice(-4);
|
|
147
|
+
process.stderr.write(chalk.dim(`Current key: ${masked}\n`));
|
|
148
|
+
}
|
|
149
|
+
const apiKey = await promptSecret('Enter your Anthropic API key');
|
|
150
|
+
if (!apiKey) {
|
|
151
|
+
process.stderr.write(formatError('No API key provided.') + '\n');
|
|
152
|
+
process.exit(1);
|
|
153
|
+
}
|
|
154
|
+
if (!apiKey.startsWith('sk-ant-')) {
|
|
155
|
+
process.stderr.write(formatWarning('API key does not start with "sk-ant-". Saving anyway.\n'));
|
|
156
|
+
}
|
|
157
|
+
setAnthropicApiKey(apiKey);
|
|
158
|
+
process.stderr.write(formatSuccess('API key saved and encrypted.') + '\n');
|
|
159
|
+
}
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
// Config path
|
|
162
|
+
// ---------------------------------------------------------------------------
|
|
163
|
+
/**
|
|
164
|
+
* Print the config file path.
|
|
165
|
+
*/
|
|
166
|
+
export function configPathCommand() {
|
|
167
|
+
process.stdout.write(getConfigPath() + '\n');
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=config.js.map
|