shennian 0.2.4 → 0.2.5
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/dist/bin/shennian.d.ts +0 -1
- package/dist/bin/shennian.js +0 -1
- package/dist/src/agents/adapter.d.ts +0 -1
- package/dist/src/agents/adapter.js +0 -1
- package/dist/src/agents/claude.d.ts +1 -1
- package/dist/src/agents/claude.js +12 -6
- package/dist/src/agents/codex.d.ts +0 -1
- package/dist/src/agents/codex.js +13 -4
- package/dist/src/agents/command-spec.d.ts +28 -3
- package/dist/src/agents/command-spec.js +251 -10
- package/dist/src/agents/cursor.d.ts +0 -1
- package/dist/src/agents/cursor.js +2 -4
- package/dist/src/agents/custom.d.ts +0 -6
- package/dist/src/agents/custom.js +4 -40
- package/dist/src/agents/detect.d.ts +0 -1
- package/dist/src/agents/detect.js +0 -1
- package/dist/src/agents/gemini.d.ts +0 -1
- package/dist/src/agents/gemini.js +7 -3
- package/dist/src/agents/model-registry/cache.d.ts +0 -1
- package/dist/src/agents/model-registry/cache.js +0 -1
- package/dist/src/agents/model-registry/discovery.d.ts +0 -1
- package/dist/src/agents/model-registry/discovery.js +13 -54
- package/dist/src/agents/model-registry/parsers.d.ts +3 -1
- package/dist/src/agents/model-registry/parsers.js +92 -2
- package/dist/src/agents/model-registry/runner.d.ts +2 -7
- package/dist/src/agents/model-registry/runner.js +3 -134
- package/dist/src/agents/model-registry/service.d.ts +0 -1
- package/dist/src/agents/model-registry/service.js +12 -10
- package/dist/src/agents/model-registry/types.d.ts +0 -1
- package/dist/src/agents/model-registry/types.js +0 -1
- package/dist/src/agents/model-registry.d.ts +2 -2
- package/dist/src/agents/model-registry.js +2 -2
- package/dist/src/agents/openclaw.d.ts +0 -1
- package/dist/src/agents/openclaw.js +13 -4
- package/dist/src/agents/pi.d.ts +0 -1
- package/dist/src/agents/pi.js +0 -1
- package/dist/src/commands/agent.d.ts +0 -1
- package/dist/src/commands/agent.js +2 -33
- package/dist/src/commands/daemon.d.ts +6 -1
- package/dist/src/commands/daemon.js +153 -18
- package/dist/src/commands/pair-qr.d.ts +0 -1
- package/dist/src/commands/pair-qr.js +0 -1
- package/dist/src/commands/pair.d.ts +0 -1
- package/dist/src/commands/pair.js +0 -1
- package/dist/src/commands/upgrade.d.ts +0 -1
- package/dist/src/commands/upgrade.js +0 -1
- package/dist/src/config/index.d.ts +0 -1
- package/dist/src/config/index.js +0 -1
- package/dist/src/fs/handler.d.ts +0 -1
- package/dist/src/fs/handler.js +0 -1
- package/dist/src/fs/security.d.ts +0 -1
- package/dist/src/fs/security.js +5 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +33 -7
- package/dist/src/log-reporter.d.ts +0 -1
- package/dist/src/log-reporter.js +2 -20
- package/dist/src/native-fusion/parsers.d.ts +0 -1
- package/dist/src/native-fusion/parsers.js +356 -40
- package/dist/src/native-fusion/service.d.ts +0 -1
- package/dist/src/native-fusion/service.js +14 -5
- package/dist/src/native-fusion/state.d.ts +0 -1
- package/dist/src/native-fusion/state.js +0 -1
- package/dist/src/native-fusion/types.d.ts +0 -1
- package/dist/src/native-fusion/types.js +0 -1
- package/dist/src/region.d.ts +0 -1
- package/dist/src/region.js +0 -1
- package/dist/src/relay/client.d.ts +11 -2
- package/dist/src/relay/client.js +22 -4
- package/dist/src/session/handlers/agents.d.ts +0 -1
- package/dist/src/session/handlers/agents.js +0 -1
- package/dist/src/session/handlers/chat.d.ts +0 -1
- package/dist/src/session/handlers/chat.js +0 -1
- package/dist/src/session/handlers/control.d.ts +0 -1
- package/dist/src/session/handlers/control.js +0 -1
- package/dist/src/session/handlers/fs.d.ts +0 -1
- package/dist/src/session/handlers/fs.js +5 -2
- package/dist/src/session/manager.d.ts +1 -1
- package/dist/src/session/manager.js +23 -4
- package/dist/src/session/store.d.ts +0 -1
- package/dist/src/session/store.js +0 -1
- package/dist/src/session/types.d.ts +0 -1
- package/dist/src/session/types.js +0 -1
- package/dist/src/upgrade/engine.d.ts +0 -1
- package/dist/src/upgrade/engine.js +0 -1
- package/package.json +3 -2
- package/dist/bin/shennian.d.ts.map +0 -1
- package/dist/bin/shennian.js.map +0 -1
- package/dist/src/__experiments__/probe-debug.d.ts +0 -2
- package/dist/src/__experiments__/probe-debug.d.ts.map +0 -1
- package/dist/src/__experiments__/probe-debug.js +0 -66
- package/dist/src/__experiments__/probe-debug.js.map +0 -1
- package/dist/src/__experiments__/probe-final-benchmark.d.ts +0 -3
- package/dist/src/__experiments__/probe-final-benchmark.d.ts.map +0 -1
- package/dist/src/__experiments__/probe-final-benchmark.js +0 -234
- package/dist/src/__experiments__/probe-final-benchmark.js.map +0 -1
- package/dist/src/__experiments__/probe-models-final.d.ts +0 -19
- package/dist/src/__experiments__/probe-models-final.d.ts.map +0 -1
- package/dist/src/__experiments__/probe-models-final.js +0 -250
- package/dist/src/__experiments__/probe-models-final.js.map +0 -1
- package/dist/src/__experiments__/probe-models.d.ts +0 -7
- package/dist/src/__experiments__/probe-models.d.ts.map +0 -1
- package/dist/src/__experiments__/probe-models.js +0 -251
- package/dist/src/__experiments__/probe-models.js.map +0 -1
- package/dist/src/__tests__/agents-e2e.d.ts +0 -21
- package/dist/src/__tests__/agents-e2e.d.ts.map +0 -1
- package/dist/src/__tests__/agents-e2e.js +0 -155
- package/dist/src/__tests__/agents-e2e.js.map +0 -1
- package/dist/src/__tests__/claude-adapter.test.d.ts +0 -2
- package/dist/src/__tests__/claude-adapter.test.d.ts.map +0 -1
- package/dist/src/__tests__/claude-adapter.test.js +0 -75
- package/dist/src/__tests__/claude-adapter.test.js.map +0 -1
- package/dist/src/__tests__/codex-adapter.test.d.ts +0 -2
- package/dist/src/__tests__/codex-adapter.test.d.ts.map +0 -1
- package/dist/src/__tests__/codex-adapter.test.js +0 -281
- package/dist/src/__tests__/codex-adapter.test.js.map +0 -1
- package/dist/src/__tests__/config.test.d.ts +0 -2
- package/dist/src/__tests__/config.test.d.ts.map +0 -1
- package/dist/src/__tests__/config.test.js +0 -60
- package/dist/src/__tests__/config.test.js.map +0 -1
- package/dist/src/__tests__/cursor-adapter.test.d.ts +0 -2
- package/dist/src/__tests__/cursor-adapter.test.d.ts.map +0 -1
- package/dist/src/__tests__/cursor-adapter.test.js +0 -69
- package/dist/src/__tests__/cursor-adapter.test.js.map +0 -1
- package/dist/src/__tests__/custom-agent-flow.test.d.ts +0 -2
- package/dist/src/__tests__/custom-agent-flow.test.d.ts.map +0 -1
- package/dist/src/__tests__/custom-agent-flow.test.js +0 -244
- package/dist/src/__tests__/custom-agent-flow.test.js.map +0 -1
- package/dist/src/__tests__/daemon-autostart.test.d.ts +0 -2
- package/dist/src/__tests__/daemon-autostart.test.d.ts.map +0 -1
- package/dist/src/__tests__/daemon-autostart.test.js +0 -60
- package/dist/src/__tests__/daemon-autostart.test.js.map +0 -1
- package/dist/src/__tests__/e2e-relay.d.ts +0 -19
- package/dist/src/__tests__/e2e-relay.d.ts.map +0 -1
- package/dist/src/__tests__/e2e-relay.js +0 -400
- package/dist/src/__tests__/e2e-relay.js.map +0 -1
- package/dist/src/__tests__/fs-handler.test.d.ts +0 -2
- package/dist/src/__tests__/fs-handler.test.d.ts.map +0 -1
- package/dist/src/__tests__/fs-handler.test.js +0 -19
- package/dist/src/__tests__/fs-handler.test.js.map +0 -1
- package/dist/src/__tests__/model-discovery.test.d.ts +0 -2
- package/dist/src/__tests__/model-discovery.test.d.ts.map +0 -1
- package/dist/src/__tests__/model-discovery.test.js +0 -47
- package/dist/src/__tests__/model-discovery.test.js.map +0 -1
- package/dist/src/__tests__/model-switching.test.d.ts +0 -2
- package/dist/src/__tests__/model-switching.test.d.ts.map +0 -1
- package/dist/src/__tests__/model-switching.test.js +0 -292
- package/dist/src/__tests__/model-switching.test.js.map +0 -1
- package/dist/src/__tests__/native-fusion-parsers.test.d.ts +0 -2
- package/dist/src/__tests__/native-fusion-parsers.test.d.ts.map +0 -1
- package/dist/src/__tests__/native-fusion-parsers.test.js +0 -253
- package/dist/src/__tests__/native-fusion-parsers.test.js.map +0 -1
- package/dist/src/__tests__/native-fusion-service.test.d.ts +0 -2
- package/dist/src/__tests__/native-fusion-service.test.d.ts.map +0 -1
- package/dist/src/__tests__/native-fusion-service.test.js +0 -157
- package/dist/src/__tests__/native-fusion-service.test.js.map +0 -1
- package/dist/src/__tests__/native-session-sync.test.d.ts +0 -2
- package/dist/src/__tests__/native-session-sync.test.d.ts.map +0 -1
- package/dist/src/__tests__/native-session-sync.test.js +0 -198
- package/dist/src/__tests__/native-session-sync.test.js.map +0 -1
- package/dist/src/__tests__/pair-qr.test.d.ts +0 -2
- package/dist/src/__tests__/pair-qr.test.d.ts.map +0 -1
- package/dist/src/__tests__/pair-qr.test.js +0 -13
- package/dist/src/__tests__/pair-qr.test.js.map +0 -1
- package/dist/src/__tests__/pi-context.test.d.ts +0 -2
- package/dist/src/__tests__/pi-context.test.d.ts.map +0 -1
- package/dist/src/__tests__/pi-context.test.js +0 -261
- package/dist/src/__tests__/pi-context.test.js.map +0 -1
- package/dist/src/__tests__/session-manager.test.d.ts +0 -2
- package/dist/src/__tests__/session-manager.test.d.ts.map +0 -1
- package/dist/src/__tests__/session-manager.test.js +0 -685
- package/dist/src/__tests__/session-manager.test.js.map +0 -1
- package/dist/src/__tests__/session-store.test.d.ts +0 -2
- package/dist/src/__tests__/session-store.test.d.ts.map +0 -1
- package/dist/src/__tests__/session-store.test.js +0 -106
- package/dist/src/__tests__/session-store.test.js.map +0 -1
- package/dist/src/agents/adapter.d.ts.map +0 -1
- package/dist/src/agents/adapter.js.map +0 -1
- package/dist/src/agents/claude.d.ts.map +0 -1
- package/dist/src/agents/claude.js.map +0 -1
- package/dist/src/agents/codex.d.ts.map +0 -1
- package/dist/src/agents/codex.js.map +0 -1
- package/dist/src/agents/command-spec.d.ts.map +0 -1
- package/dist/src/agents/command-spec.js.map +0 -1
- package/dist/src/agents/cursor.d.ts.map +0 -1
- package/dist/src/agents/cursor.js.map +0 -1
- package/dist/src/agents/custom.d.ts.map +0 -1
- package/dist/src/agents/custom.js.map +0 -1
- package/dist/src/agents/detect.d.ts.map +0 -1
- package/dist/src/agents/detect.js.map +0 -1
- package/dist/src/agents/gemini.d.ts.map +0 -1
- package/dist/src/agents/gemini.js.map +0 -1
- package/dist/src/agents/model-registry/cache.d.ts.map +0 -1
- package/dist/src/agents/model-registry/cache.js.map +0 -1
- package/dist/src/agents/model-registry/discovery.d.ts.map +0 -1
- package/dist/src/agents/model-registry/discovery.js.map +0 -1
- package/dist/src/agents/model-registry/parsers.d.ts.map +0 -1
- package/dist/src/agents/model-registry/parsers.js.map +0 -1
- package/dist/src/agents/model-registry/runner.d.ts.map +0 -1
- package/dist/src/agents/model-registry/runner.js.map +0 -1
- package/dist/src/agents/model-registry/service.d.ts.map +0 -1
- package/dist/src/agents/model-registry/service.js.map +0 -1
- package/dist/src/agents/model-registry/types.d.ts.map +0 -1
- package/dist/src/agents/model-registry/types.js.map +0 -1
- package/dist/src/agents/model-registry.d.ts.map +0 -1
- package/dist/src/agents/model-registry.js.map +0 -1
- package/dist/src/agents/openclaw.d.ts.map +0 -1
- package/dist/src/agents/openclaw.js.map +0 -1
- package/dist/src/agents/pi.d.ts.map +0 -1
- package/dist/src/agents/pi.js.map +0 -1
- package/dist/src/commands/agent.d.ts.map +0 -1
- package/dist/src/commands/agent.js.map +0 -1
- package/dist/src/commands/daemon.d.ts.map +0 -1
- package/dist/src/commands/daemon.js.map +0 -1
- package/dist/src/commands/pair-qr.d.ts.map +0 -1
- package/dist/src/commands/pair-qr.js.map +0 -1
- package/dist/src/commands/pair.d.ts.map +0 -1
- package/dist/src/commands/pair.js.map +0 -1
- package/dist/src/commands/upgrade.d.ts.map +0 -1
- package/dist/src/commands/upgrade.js.map +0 -1
- package/dist/src/config/index.d.ts.map +0 -1
- package/dist/src/config/index.js.map +0 -1
- package/dist/src/fs/handler.d.ts.map +0 -1
- package/dist/src/fs/handler.js.map +0 -1
- package/dist/src/fs/multimodal.d.ts +0 -5
- package/dist/src/fs/multimodal.d.ts.map +0 -1
- package/dist/src/fs/multimodal.js +0 -39
- package/dist/src/fs/multimodal.js.map +0 -1
- package/dist/src/fs/security.d.ts.map +0 -1
- package/dist/src/fs/security.js.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/log-reporter.d.ts.map +0 -1
- package/dist/src/log-reporter.js.map +0 -1
- package/dist/src/native-fusion/parsers.d.ts.map +0 -1
- package/dist/src/native-fusion/parsers.js.map +0 -1
- package/dist/src/native-fusion/service.d.ts.map +0 -1
- package/dist/src/native-fusion/service.js.map +0 -1
- package/dist/src/native-fusion/state.d.ts.map +0 -1
- package/dist/src/native-fusion/state.js.map +0 -1
- package/dist/src/native-fusion/types.d.ts.map +0 -1
- package/dist/src/native-fusion/types.js.map +0 -1
- package/dist/src/native-sync/discover.d.ts +0 -6
- package/dist/src/native-sync/discover.d.ts.map +0 -1
- package/dist/src/native-sync/discover.js +0 -69
- package/dist/src/native-sync/discover.js.map +0 -1
- package/dist/src/native-sync/parsers.d.ts +0 -3
- package/dist/src/native-sync/parsers.d.ts.map +0 -1
- package/dist/src/native-sync/parsers.js +0 -373
- package/dist/src/native-sync/parsers.js.map +0 -1
- package/dist/src/native-sync/service.d.ts +0 -16
- package/dist/src/native-sync/service.d.ts.map +0 -1
- package/dist/src/native-sync/service.js +0 -95
- package/dist/src/native-sync/service.js.map +0 -1
- package/dist/src/native-sync/state.d.ts +0 -6
- package/dist/src/native-sync/state.d.ts.map +0 -1
- package/dist/src/native-sync/state.js +0 -34
- package/dist/src/native-sync/state.js.map +0 -1
- package/dist/src/native-sync/types.d.ts +0 -23
- package/dist/src/native-sync/types.d.ts.map +0 -1
- package/dist/src/native-sync/types.js +0 -4
- package/dist/src/native-sync/types.js.map +0 -1
- package/dist/src/region.d.ts.map +0 -1
- package/dist/src/region.js.map +0 -1
- package/dist/src/relay/client.d.ts.map +0 -1
- package/dist/src/relay/client.js.map +0 -1
- package/dist/src/session/handlers/agents.d.ts.map +0 -1
- package/dist/src/session/handlers/agents.js.map +0 -1
- package/dist/src/session/handlers/chat.d.ts.map +0 -1
- package/dist/src/session/handlers/chat.js.map +0 -1
- package/dist/src/session/handlers/control.d.ts.map +0 -1
- package/dist/src/session/handlers/control.js.map +0 -1
- package/dist/src/session/handlers/fs.d.ts.map +0 -1
- package/dist/src/session/handlers/fs.js.map +0 -1
- package/dist/src/session/handlers/queue.d.ts +0 -4
- package/dist/src/session/handlers/queue.d.ts.map +0 -1
- package/dist/src/session/handlers/queue.js +0 -66
- package/dist/src/session/handlers/queue.js.map +0 -1
- package/dist/src/session/manager.d.ts.map +0 -1
- package/dist/src/session/manager.js.map +0 -1
- package/dist/src/session/store.d.ts.map +0 -1
- package/dist/src/session/store.js.map +0 -1
- package/dist/src/session/types.d.ts.map +0 -1
- package/dist/src/session/types.js.map +0 -1
- package/dist/src/upgrade/engine.d.ts.map +0 -1
- package/dist/src/upgrade/engine.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/bin/shennian.d.ts
CHANGED
package/dist/bin/shennian.js
CHANGED
|
@@ -33,4 +33,3 @@ export declare function registerAgent(type: AgentType, factory: () => AgentAdapt
|
|
|
33
33
|
export declare function unregisterAgent(type: AgentType): void;
|
|
34
34
|
export declare function createAgent(type: AgentType): AgentAdapter | null;
|
|
35
35
|
export declare function getRegisteredAgents(): AgentType[];
|
|
36
|
-
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AgentAdapter } from './adapter.js';
|
|
2
|
+
export declare function normalizeClaudeModelId(modelId?: string | null): string;
|
|
2
3
|
export declare class ClaudeAdapter extends AgentAdapter {
|
|
3
4
|
readonly type: "claude";
|
|
4
5
|
private process;
|
|
@@ -22,4 +23,3 @@ export declare class ClaudeAdapter extends AgentAdapter {
|
|
|
22
23
|
private emitEvent;
|
|
23
24
|
private killProcess;
|
|
24
25
|
}
|
|
25
|
-
//# sourceMappingURL=claude.d.ts.map
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
1
|
import { createInterface } from 'node:readline';
|
|
3
2
|
import { randomUUID } from 'node:crypto';
|
|
4
3
|
import { AgentAdapter, registerAgent } from './adapter.js';
|
|
4
|
+
import { resolveBuiltinCommand, spawnResolvedCommand } from './command-spec.js';
|
|
5
|
+
export function normalizeClaudeModelId(modelId) {
|
|
6
|
+
const trimmed = modelId?.trim();
|
|
7
|
+
return trimmed || 'default';
|
|
8
|
+
}
|
|
5
9
|
export class ClaudeAdapter extends AgentAdapter {
|
|
6
10
|
type = 'claude';
|
|
7
11
|
process = null;
|
|
@@ -27,9 +31,7 @@ export class ClaudeAdapter extends AgentAdapter {
|
|
|
27
31
|
if (process.getuid?.() !== 0) {
|
|
28
32
|
args.push('--dangerously-skip-permissions');
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
args.push('--model', modelId);
|
|
32
|
-
}
|
|
34
|
+
args.push('--model', normalizeClaudeModelId(modelId));
|
|
33
35
|
if (this.agentSessionId) {
|
|
34
36
|
args.push('--resume', this.agentSessionId);
|
|
35
37
|
}
|
|
@@ -50,7 +52,12 @@ export class ClaudeAdapter extends AgentAdapter {
|
|
|
50
52
|
await this.killProcess();
|
|
51
53
|
}
|
|
52
54
|
spawnAndParse(args) {
|
|
53
|
-
const
|
|
55
|
+
const spec = resolveBuiltinCommand('claude');
|
|
56
|
+
if (!spec) {
|
|
57
|
+
this.emit('error', new Error('Command "claude" not found. Is Claude Code CLI installed?'));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const proc = spawnResolvedCommand(spec, args, {
|
|
54
61
|
cwd: this.workDir ?? undefined,
|
|
55
62
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
56
63
|
env: { ...process.env },
|
|
@@ -225,4 +232,3 @@ export class ClaudeAdapter extends AgentAdapter {
|
|
|
225
232
|
}
|
|
226
233
|
}
|
|
227
234
|
registerAgent('claude', () => new ClaudeAdapter());
|
|
228
|
-
//# sourceMappingURL=claude.js.map
|
package/dist/src/agents/codex.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @arch docs/architecture/cli/agent-adapters.md
|
|
2
2
|
// @test src/__tests__/codex-adapter.test.ts
|
|
3
|
-
import { spawn } from 'node:child_process';
|
|
4
3
|
import { createInterface } from 'node:readline';
|
|
5
4
|
import { randomUUID } from 'node:crypto';
|
|
6
5
|
import { AgentAdapter, registerAgent } from './adapter.js';
|
|
6
|
+
import { resolveBuiltinCommand, spawnResolvedCommand } from './command-spec.js';
|
|
7
7
|
export class CodexAdapter extends AgentAdapter {
|
|
8
8
|
type = 'codex';
|
|
9
9
|
process = null;
|
|
@@ -69,7 +69,12 @@ export class CodexAdapter extends AgentAdapter {
|
|
|
69
69
|
await this.killProcess();
|
|
70
70
|
}
|
|
71
71
|
spawnCodex(args) {
|
|
72
|
-
const
|
|
72
|
+
const spec = resolveBuiltinCommand('codex');
|
|
73
|
+
if (!spec) {
|
|
74
|
+
this.emit('error', new Error('Command "codex" not found. Is OpenAI Codex CLI installed?'));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const proc = spawnResolvedCommand(spec, args, {
|
|
73
78
|
cwd: this.workDir ?? undefined,
|
|
74
79
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
75
80
|
env: { ...process.env },
|
|
@@ -111,7 +116,12 @@ export class CodexAdapter extends AgentAdapter {
|
|
|
111
116
|
});
|
|
112
117
|
}
|
|
113
118
|
spawnAppServer() {
|
|
114
|
-
const
|
|
119
|
+
const spec = resolveBuiltinCommand('codex');
|
|
120
|
+
if (!spec) {
|
|
121
|
+
this.emit('error', new Error('Command "codex" not found. Is OpenAI Codex CLI installed?'));
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const proc = spawnResolvedCommand(spec, ['app-server', '--listen', 'stdio://'], {
|
|
115
125
|
cwd: this.workDir ?? undefined,
|
|
116
126
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
117
127
|
env: { ...process.env, NO_COLOR: '1' },
|
|
@@ -782,4 +792,3 @@ function looksLikeFatalCodexStderr(stderr) {
|
|
|
782
792
|
].some((pattern) => pattern.test(stderr));
|
|
783
793
|
}
|
|
784
794
|
registerAgent('codex', () => new CodexAdapter());
|
|
785
|
-
//# sourceMappingURL=codex.js.map
|
|
@@ -1,11 +1,36 @@
|
|
|
1
|
+
import { type ChildProcess, type SpawnOptions, type SpawnSyncOptions } from 'node:child_process';
|
|
1
2
|
import type { BuiltinAgentType } from '@shennian/wire';
|
|
2
3
|
export type CommandSpec = {
|
|
3
4
|
command: string;
|
|
4
5
|
args: string[];
|
|
5
6
|
display: string;
|
|
6
7
|
};
|
|
8
|
+
export type ResolvedCommandKind = 'native' | 'cmd-shim' | 'wsl-bridge';
|
|
9
|
+
export type ResolvedCommandSpec = CommandSpec & {
|
|
10
|
+
kind: ResolvedCommandKind;
|
|
11
|
+
path: string;
|
|
12
|
+
};
|
|
13
|
+
type LaunchSpec = {
|
|
14
|
+
command: string;
|
|
15
|
+
args: string[];
|
|
16
|
+
cwd?: string;
|
|
17
|
+
};
|
|
7
18
|
export declare function resetCommandSpecCache(): void;
|
|
19
|
+
export declare function getProcessPlatform(): NodeJS.Platform;
|
|
20
|
+
export declare function windowsPathToWsl(input: string): string | undefined;
|
|
8
21
|
export declare function commandExists(command: string): boolean;
|
|
9
|
-
export declare function resolveBuiltinCommand(type: BuiltinAgentType):
|
|
10
|
-
export declare function
|
|
11
|
-
|
|
22
|
+
export declare function resolveBuiltinCommand(type: BuiltinAgentType): ResolvedCommandSpec | null;
|
|
23
|
+
export declare function buildLaunchSpec(spec: ResolvedCommandSpec, runtimeArgs: string[], cwd?: string): LaunchSpec;
|
|
24
|
+
export declare function spawnResolvedCommand(spec: ResolvedCommandSpec, runtimeArgs: string[], options?: Omit<SpawnOptions, 'cwd'> & {
|
|
25
|
+
cwd?: string;
|
|
26
|
+
}): ChildProcess;
|
|
27
|
+
export declare function spawnResolvedCommandSync(spec: ResolvedCommandSpec, runtimeArgs: string[], options?: Omit<SpawnSyncOptions, 'cwd'> & {
|
|
28
|
+
cwd?: string;
|
|
29
|
+
}): import("child_process").SpawnSyncReturns<string | NonSharedBuffer>;
|
|
30
|
+
export declare function parseCommandString(command: string): string[];
|
|
31
|
+
export declare function buildCommandStringLaunchSpec(commandString: string, runtimeArgs: string[], cwd?: string): LaunchSpec;
|
|
32
|
+
export declare function spawnCommandString(commandString: string, runtimeArgs: string[], options?: Omit<SpawnOptions, 'cwd'> & {
|
|
33
|
+
cwd?: string;
|
|
34
|
+
}): ChildProcess;
|
|
35
|
+
export declare function getCommandVersion(spec: ResolvedCommandSpec, flag?: string): string | undefined;
|
|
36
|
+
export {};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// @arch docs/architecture/cli/windows-agent-launch.md
|
|
2
|
+
// @test src/__tests__/command-spec.test.ts
|
|
3
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
4
|
+
import path from 'node:path';
|
|
2
5
|
const BUILTIN_COMMANDS = {
|
|
3
6
|
claude: [
|
|
4
7
|
{ command: 'claude', args: [], display: 'claude' },
|
|
@@ -22,33 +25,272 @@ const BUILTIN_COMMANDS = {
|
|
|
22
25
|
};
|
|
23
26
|
const availabilityCache = new Map();
|
|
24
27
|
const resolvedCache = new Map();
|
|
28
|
+
const pathLookupCache = new Map();
|
|
29
|
+
const wslAvailabilityCache = new Map();
|
|
25
30
|
export function resetCommandSpecCache() {
|
|
26
31
|
availabilityCache.clear();
|
|
27
32
|
resolvedCache.clear();
|
|
33
|
+
pathLookupCache.clear();
|
|
34
|
+
wslAvailabilityCache.clear();
|
|
28
35
|
}
|
|
29
|
-
export function
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
export function getProcessPlatform() {
|
|
37
|
+
return process.platform;
|
|
38
|
+
}
|
|
39
|
+
function splitLines(text) {
|
|
40
|
+
return text
|
|
41
|
+
.split(/\r?\n/)
|
|
42
|
+
.map((line) => line.trim())
|
|
43
|
+
.filter(Boolean);
|
|
44
|
+
}
|
|
45
|
+
function lookupCommandPaths(command) {
|
|
46
|
+
if (pathLookupCache.has(command)) {
|
|
47
|
+
return pathLookupCache.get(command) ?? [];
|
|
32
48
|
}
|
|
33
|
-
const lookup =
|
|
49
|
+
const lookup = getProcessPlatform() === 'win32' ? 'where' : 'which';
|
|
34
50
|
const result = spawnSync(lookup, [command], {
|
|
35
|
-
|
|
51
|
+
encoding: 'utf-8',
|
|
52
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
36
53
|
timeout: 3000,
|
|
37
54
|
});
|
|
38
|
-
const
|
|
55
|
+
const paths = result.status === 0 ? splitLines(result.stdout ?? '') : [];
|
|
56
|
+
pathLookupCache.set(command, paths);
|
|
57
|
+
return paths;
|
|
58
|
+
}
|
|
59
|
+
function getWindowsShellPath() {
|
|
60
|
+
return process.env.ComSpec || 'cmd.exe';
|
|
61
|
+
}
|
|
62
|
+
function isWindowsNativeBinary(filePath) {
|
|
63
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
64
|
+
return ext === '.exe' || ext === '.com';
|
|
65
|
+
}
|
|
66
|
+
function isWindowsCmdShim(filePath) {
|
|
67
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
68
|
+
return ext === '.cmd' || ext === '.bat';
|
|
69
|
+
}
|
|
70
|
+
function quoteCmdArg(text) {
|
|
71
|
+
return `"${text.replace(/"/g, '""')}"`;
|
|
72
|
+
}
|
|
73
|
+
function quotePosixArg(text) {
|
|
74
|
+
return `'${text.replace(/'/g, `'\\''`)}'`;
|
|
75
|
+
}
|
|
76
|
+
export function windowsPathToWsl(input) {
|
|
77
|
+
if (!input)
|
|
78
|
+
return undefined;
|
|
79
|
+
const normalized = input.replace(/\//g, '\\');
|
|
80
|
+
const driveMatch = normalized.match(/^([A-Za-z]):\\(.*)$/);
|
|
81
|
+
if (driveMatch) {
|
|
82
|
+
const [, drive, rest] = driveMatch;
|
|
83
|
+
const suffix = rest.replace(/\\/g, '/');
|
|
84
|
+
return `/mnt/${drive.toLowerCase()}/${suffix}`;
|
|
85
|
+
}
|
|
86
|
+
if (normalized.startsWith('\\\\wsl$\\')) {
|
|
87
|
+
const remainder = normalized.replace(/^\\\\wsl\$\\[^\\]+\\?/, '');
|
|
88
|
+
return `/${remainder.replace(/\\/g, '/')}`;
|
|
89
|
+
}
|
|
90
|
+
if (input.startsWith('/'))
|
|
91
|
+
return input;
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
function resolveArbitraryWindowsCommand(command) {
|
|
95
|
+
const normalized = command.trim();
|
|
96
|
+
if (!normalized) {
|
|
97
|
+
throw new Error('Command string is empty');
|
|
98
|
+
}
|
|
99
|
+
const hasExplicitPath = /[\\/]/.test(normalized) || /^[A-Za-z]:/.test(normalized);
|
|
100
|
+
if (hasExplicitPath) {
|
|
101
|
+
if (isWindowsCmdShim(normalized))
|
|
102
|
+
return { kind: 'cmd-shim', path: normalized };
|
|
103
|
+
return { kind: 'direct', path: normalized };
|
|
104
|
+
}
|
|
105
|
+
const paths = lookupCommandPaths(normalized);
|
|
106
|
+
const native = paths.find(isWindowsNativeBinary);
|
|
107
|
+
if (native)
|
|
108
|
+
return { kind: 'direct', path: native };
|
|
109
|
+
const shim = paths.find(isWindowsCmdShim);
|
|
110
|
+
if (shim)
|
|
111
|
+
return { kind: 'cmd-shim', path: shim };
|
|
112
|
+
return { kind: 'direct', path: normalized };
|
|
113
|
+
}
|
|
114
|
+
function canUseWslBridge(command) {
|
|
115
|
+
if (wslAvailabilityCache.has(command)) {
|
|
116
|
+
return wslAvailabilityCache.get(command) ?? false;
|
|
117
|
+
}
|
|
118
|
+
const wslPath = lookupCommandPaths('wsl.exe')[0] ?? lookupCommandPaths('wsl')[0];
|
|
119
|
+
if (!wslPath) {
|
|
120
|
+
wslAvailabilityCache.set(command, false);
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
const result = spawnSync(wslPath, ['-e', 'sh', '-lc', `command -v ${quotePosixArg(command)} >/dev/null 2>&1`], {
|
|
124
|
+
stdio: 'ignore',
|
|
125
|
+
timeout: 5000,
|
|
126
|
+
});
|
|
127
|
+
const ok = result.status === 0;
|
|
128
|
+
wslAvailabilityCache.set(command, ok);
|
|
129
|
+
return ok;
|
|
130
|
+
}
|
|
131
|
+
export function commandExists(command) {
|
|
132
|
+
if (availabilityCache.has(command)) {
|
|
133
|
+
return availabilityCache.get(command) ?? false;
|
|
134
|
+
}
|
|
135
|
+
const exists = lookupCommandPaths(command).length > 0 || (getProcessPlatform() === 'win32' && canUseWslBridge(command));
|
|
39
136
|
availabilityCache.set(command, exists);
|
|
40
137
|
return exists;
|
|
41
138
|
}
|
|
139
|
+
function resolveWindowsBuiltinCommand(candidate) {
|
|
140
|
+
const paths = lookupCommandPaths(candidate.command);
|
|
141
|
+
const native = paths.find(isWindowsNativeBinary);
|
|
142
|
+
if (native) {
|
|
143
|
+
return { ...candidate, kind: 'native', path: native };
|
|
144
|
+
}
|
|
145
|
+
const shim = paths.find(isWindowsCmdShim);
|
|
146
|
+
if (shim) {
|
|
147
|
+
return { ...candidate, kind: 'cmd-shim', path: shim };
|
|
148
|
+
}
|
|
149
|
+
if (canUseWslBridge(candidate.command)) {
|
|
150
|
+
const wslPath = lookupCommandPaths('wsl.exe')[0] ?? lookupCommandPaths('wsl')[0];
|
|
151
|
+
if (wslPath) {
|
|
152
|
+
return { ...candidate, kind: 'wsl-bridge', path: wslPath };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
42
157
|
export function resolveBuiltinCommand(type) {
|
|
43
158
|
if (resolvedCache.has(type)) {
|
|
44
159
|
return resolvedCache.get(type) ?? null;
|
|
45
160
|
}
|
|
46
|
-
const resolved = BUILTIN_COMMANDS[type]
|
|
161
|
+
const resolved = BUILTIN_COMMANDS[type]
|
|
162
|
+
.map((candidate) => {
|
|
163
|
+
if (getProcessPlatform() === 'win32') {
|
|
164
|
+
return resolveWindowsBuiltinCommand(candidate);
|
|
165
|
+
}
|
|
166
|
+
const commandPath = lookupCommandPaths(candidate.command)[0];
|
|
167
|
+
return commandPath ? { ...candidate, kind: 'native', path: commandPath } : null;
|
|
168
|
+
})
|
|
169
|
+
.find(Boolean) ?? null;
|
|
47
170
|
resolvedCache.set(type, resolved);
|
|
48
171
|
return resolved;
|
|
49
172
|
}
|
|
173
|
+
export function buildLaunchSpec(spec, runtimeArgs, cwd) {
|
|
174
|
+
if (spec.kind === 'native') {
|
|
175
|
+
return {
|
|
176
|
+
command: spec.path,
|
|
177
|
+
args: [...spec.args, ...runtimeArgs],
|
|
178
|
+
cwd,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (spec.kind === 'cmd-shim') {
|
|
182
|
+
const commandLine = [spec.path, ...spec.args, ...runtimeArgs].map(quoteCmdArg).join(' ');
|
|
183
|
+
return {
|
|
184
|
+
command: getWindowsShellPath(),
|
|
185
|
+
args: ['/d', '/s', '/c', `"${commandLine}"`],
|
|
186
|
+
cwd,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const wslCwd = cwd ? windowsPathToWsl(cwd) : undefined;
|
|
190
|
+
if (cwd && !wslCwd) {
|
|
191
|
+
throw new Error(`Cannot map Windows path to WSL workDir: ${cwd}`);
|
|
192
|
+
}
|
|
193
|
+
const shellCommand = [
|
|
194
|
+
wslCwd ? `cd ${quotePosixArg(wslCwd)}` : '',
|
|
195
|
+
`exec ${[spec.command, ...spec.args, ...runtimeArgs].map(quotePosixArg).join(' ')}`,
|
|
196
|
+
].filter(Boolean).join(' && ');
|
|
197
|
+
return {
|
|
198
|
+
command: spec.path,
|
|
199
|
+
args: ['-e', 'sh', '-lc', shellCommand],
|
|
200
|
+
cwd: undefined,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
export function spawnResolvedCommand(spec, runtimeArgs, options = {}) {
|
|
204
|
+
const launch = buildLaunchSpec(spec, runtimeArgs, options.cwd);
|
|
205
|
+
return spawn(launch.command, launch.args, {
|
|
206
|
+
...options,
|
|
207
|
+
cwd: launch.cwd,
|
|
208
|
+
...(getProcessPlatform() === 'win32' && spec.kind === 'cmd-shim'
|
|
209
|
+
? { windowsVerbatimArguments: true }
|
|
210
|
+
: {}),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
export function spawnResolvedCommandSync(spec, runtimeArgs, options = {}) {
|
|
214
|
+
const launch = buildLaunchSpec(spec, runtimeArgs, options.cwd);
|
|
215
|
+
return spawnSync(launch.command, launch.args, {
|
|
216
|
+
...options,
|
|
217
|
+
cwd: launch.cwd,
|
|
218
|
+
...(getProcessPlatform() === 'win32' && spec.kind === 'cmd-shim'
|
|
219
|
+
? { windowsVerbatimArguments: true }
|
|
220
|
+
: {}),
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
export function parseCommandString(command) {
|
|
224
|
+
const args = [];
|
|
225
|
+
let current = '';
|
|
226
|
+
let inSingle = false;
|
|
227
|
+
let inDouble = false;
|
|
228
|
+
for (const ch of command) {
|
|
229
|
+
if (ch === "'" && !inDouble) {
|
|
230
|
+
inSingle = !inSingle;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (ch === '"' && !inSingle) {
|
|
234
|
+
inDouble = !inDouble;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (ch === ' ' && !inSingle && !inDouble) {
|
|
238
|
+
if (current) {
|
|
239
|
+
args.push(current);
|
|
240
|
+
current = '';
|
|
241
|
+
}
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
current += ch;
|
|
245
|
+
}
|
|
246
|
+
if (current)
|
|
247
|
+
args.push(current);
|
|
248
|
+
return args;
|
|
249
|
+
}
|
|
250
|
+
export function buildCommandStringLaunchSpec(commandString, runtimeArgs, cwd) {
|
|
251
|
+
const parts = parseCommandString(commandString);
|
|
252
|
+
const bin = parts[0];
|
|
253
|
+
if (!bin) {
|
|
254
|
+
throw new Error('Command string is empty');
|
|
255
|
+
}
|
|
256
|
+
const baseArgs = parts.slice(1);
|
|
257
|
+
if (getProcessPlatform() !== 'win32') {
|
|
258
|
+
return {
|
|
259
|
+
command: bin,
|
|
260
|
+
args: [...baseArgs, ...runtimeArgs],
|
|
261
|
+
cwd,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
const invocation = resolveArbitraryWindowsCommand(bin);
|
|
265
|
+
if (invocation.kind === 'cmd-shim') {
|
|
266
|
+
return {
|
|
267
|
+
command: getWindowsShellPath(),
|
|
268
|
+
args: ['/d', '/s', '/c', `"${[invocation.path, ...baseArgs, ...runtimeArgs].map(quoteCmdArg).join(' ')}"`],
|
|
269
|
+
cwd,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
command: invocation.path,
|
|
274
|
+
args: [...baseArgs, ...runtimeArgs],
|
|
275
|
+
cwd,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
export function spawnCommandString(commandString, runtimeArgs, options = {}) {
|
|
279
|
+
const launch = buildCommandStringLaunchSpec(commandString, runtimeArgs, options.cwd);
|
|
280
|
+
const parts = parseCommandString(commandString);
|
|
281
|
+
const invocation = getProcessPlatform() === 'win32' && parts[0]
|
|
282
|
+
? resolveArbitraryWindowsCommand(parts[0])
|
|
283
|
+
: null;
|
|
284
|
+
return spawn(launch.command, launch.args, {
|
|
285
|
+
...options,
|
|
286
|
+
cwd: launch.cwd,
|
|
287
|
+
...(getProcessPlatform() === 'win32' && invocation?.kind === 'cmd-shim'
|
|
288
|
+
? { windowsVerbatimArguments: true }
|
|
289
|
+
: {}),
|
|
290
|
+
});
|
|
291
|
+
}
|
|
50
292
|
export function getCommandVersion(spec, flag = '--version') {
|
|
51
|
-
const result =
|
|
293
|
+
const result = spawnResolvedCommandSync(spec, [flag], {
|
|
52
294
|
encoding: 'utf-8',
|
|
53
295
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
54
296
|
timeout: 5000,
|
|
@@ -59,4 +301,3 @@ export function getCommandVersion(spec, flag = '--version') {
|
|
|
59
301
|
const match = text.match(/\d+\.\d+[\w.-]*/);
|
|
60
302
|
return match?.[0];
|
|
61
303
|
}
|
|
62
|
-
//# sourceMappingURL=command-spec.js.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// @arch docs/architecture/cli/agent-adapters.md
|
|
2
2
|
// @test src/__tests__/cursor-adapter.test.ts
|
|
3
|
-
import { spawn } from 'node:child_process';
|
|
4
3
|
import { createInterface } from 'node:readline';
|
|
5
4
|
import { randomUUID } from 'node:crypto';
|
|
6
5
|
import { AgentAdapter, registerAgent } from './adapter.js';
|
|
7
|
-
import { resolveBuiltinCommand } from './command-spec.js';
|
|
6
|
+
import { resolveBuiltinCommand, spawnResolvedCommand } from './command-spec.js';
|
|
8
7
|
export class CursorAdapter extends AgentAdapter {
|
|
9
8
|
type = 'cursor';
|
|
10
9
|
process = null;
|
|
@@ -58,7 +57,7 @@ export class CursorAdapter extends AgentAdapter {
|
|
|
58
57
|
this.emit('error', new Error('Cursor Agent CLI not found. Expected "agent" or "cursor agent".'));
|
|
59
58
|
return;
|
|
60
59
|
}
|
|
61
|
-
const proc =
|
|
60
|
+
const proc = spawnResolvedCommand(spec, args, {
|
|
62
61
|
cwd: this.workDir ?? undefined,
|
|
63
62
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
64
63
|
env: { ...process.env },
|
|
@@ -247,4 +246,3 @@ export class CursorAdapter extends AgentAdapter {
|
|
|
247
246
|
}
|
|
248
247
|
}
|
|
249
248
|
registerAgent('cursor', () => new CursorAdapter());
|
|
250
|
-
//# sourceMappingURL=cursor.js.map
|
|
@@ -26,11 +26,5 @@ export declare class CustomAgentAdapter extends AgentAdapter {
|
|
|
26
26
|
private attachOutputHandlers;
|
|
27
27
|
private handleProtocolEvent;
|
|
28
28
|
private emitEvent;
|
|
29
|
-
/**
|
|
30
|
-
* Splits `this.command` into argv, supporting quoted strings.
|
|
31
|
-
* e.g. `python /path/to/agent.py` → ['python', '/path/to/agent.py']
|
|
32
|
-
*/
|
|
33
|
-
private buildCommandArgs;
|
|
34
29
|
}
|
|
35
30
|
export declare function registerCustomAgent(name: string, entry: CustomAgentEntry): void;
|
|
36
|
-
//# sourceMappingURL=custom.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @arch docs/architecture/cli/agent-adapters.md#custom-agents
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
2
|
import { createInterface } from 'node:readline';
|
|
4
3
|
import { randomUUID } from 'node:crypto';
|
|
5
4
|
import { AgentAdapter, registerAgent } from './adapter.js';
|
|
5
|
+
import { spawnCommandString } from './command-spec.js';
|
|
6
6
|
export class CustomAgentAdapter extends AgentAdapter {
|
|
7
7
|
type;
|
|
8
8
|
command;
|
|
@@ -65,15 +65,14 @@ export class CustomAgentAdapter extends AgentAdapter {
|
|
|
65
65
|
// ─── Spawn mode ───────────────────────────────────────────────────────────
|
|
66
66
|
async runSpawn(text, modelId) {
|
|
67
67
|
await this.killSpawnProcess();
|
|
68
|
-
const args = this.
|
|
69
|
-
args.push('/run', '--workdir', this.workDir ?? process.cwd());
|
|
68
|
+
const args = ['/run', '--workdir', this.workDir ?? process.cwd()];
|
|
70
69
|
if (this.sessionId)
|
|
71
70
|
args.push('--session', this.sessionId);
|
|
72
71
|
if (this.agentSessionId)
|
|
73
72
|
args.push('--resume', this.agentSessionId);
|
|
74
73
|
if (modelId)
|
|
75
74
|
args.push('--model', modelId);
|
|
76
|
-
const proc =
|
|
75
|
+
const proc = spawnCommandString(this.command, args, {
|
|
77
76
|
cwd: this.workDir ?? undefined,
|
|
78
77
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
79
78
|
env: { ...process.env },
|
|
@@ -99,9 +98,7 @@ export class CustomAgentAdapter extends AgentAdapter {
|
|
|
99
98
|
}
|
|
100
99
|
// ─── Stdio mode ───────────────────────────────────────────────────────────
|
|
101
100
|
async startStdioProcess() {
|
|
102
|
-
const
|
|
103
|
-
args.push('/start', '--workdir', this.workDir ?? process.cwd());
|
|
104
|
-
const proc = spawn(args[0], args.slice(1), {
|
|
101
|
+
const proc = spawnCommandString(this.command, ['/start', '--workdir', this.workDir ?? process.cwd()], {
|
|
105
102
|
cwd: this.workDir ?? undefined,
|
|
106
103
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
107
104
|
env: { ...process.env },
|
|
@@ -206,41 +203,8 @@ export class CustomAgentAdapter extends AgentAdapter {
|
|
|
206
203
|
const event = { ...partial, runId: this.runId, seq: this.seq++ };
|
|
207
204
|
this.emit('agentEvent', event);
|
|
208
205
|
}
|
|
209
|
-
// ─── Helpers ──────────────────────────────────────────────────────────────
|
|
210
|
-
/**
|
|
211
|
-
* Splits `this.command` into argv, supporting quoted strings.
|
|
212
|
-
* e.g. `python /path/to/agent.py` → ['python', '/path/to/agent.py']
|
|
213
|
-
*/
|
|
214
|
-
buildCommandArgs() {
|
|
215
|
-
const args = [];
|
|
216
|
-
let current = '';
|
|
217
|
-
let inSingle = false;
|
|
218
|
-
let inDouble = false;
|
|
219
|
-
for (const ch of this.command) {
|
|
220
|
-
if (ch === "'" && !inDouble) {
|
|
221
|
-
inSingle = !inSingle;
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
if (ch === '"' && !inSingle) {
|
|
225
|
-
inDouble = !inDouble;
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
if (ch === ' ' && !inSingle && !inDouble) {
|
|
229
|
-
if (current) {
|
|
230
|
-
args.push(current);
|
|
231
|
-
current = '';
|
|
232
|
-
}
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
current += ch;
|
|
236
|
-
}
|
|
237
|
-
if (current)
|
|
238
|
-
args.push(current);
|
|
239
|
-
return args;
|
|
240
|
-
}
|
|
241
206
|
}
|
|
242
207
|
export function registerCustomAgent(name, entry) {
|
|
243
208
|
const agentType = `custom:${name}`;
|
|
244
209
|
registerAgent(agentType, () => new CustomAgentAdapter(name, entry));
|
|
245
210
|
}
|
|
246
|
-
//# sourceMappingURL=custom.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
1
|
import { createInterface } from 'node:readline';
|
|
3
2
|
import { randomUUID } from 'node:crypto';
|
|
4
3
|
import { AgentAdapter, registerAgent } from './adapter.js';
|
|
4
|
+
import { resolveBuiltinCommand, spawnResolvedCommand } from './command-spec.js';
|
|
5
5
|
function num(v) {
|
|
6
6
|
return typeof v === 'number' && Number.isFinite(v) ? v : undefined;
|
|
7
7
|
}
|
|
@@ -64,7 +64,12 @@ export class GeminiAdapter extends AgentAdapter {
|
|
|
64
64
|
await this.killProcess();
|
|
65
65
|
}
|
|
66
66
|
spawnAndParse(args) {
|
|
67
|
-
const
|
|
67
|
+
const spec = resolveBuiltinCommand('gemini');
|
|
68
|
+
if (!spec) {
|
|
69
|
+
this.emit('error', new Error('Command "gemini" not found. Is Gemini CLI installed?'));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const proc = spawnResolvedCommand(spec, args, {
|
|
68
73
|
cwd: this.workDir ?? undefined,
|
|
69
74
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
70
75
|
env: { ...process.env },
|
|
@@ -165,4 +170,3 @@ export class GeminiAdapter extends AgentAdapter {
|
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
registerAgent('gemini', () => new GeminiAdapter());
|
|
168
|
-
//# sourceMappingURL=gemini.js.map
|
|
@@ -2,4 +2,3 @@ import { type CacheEntry, type CacheFile } from './types.js';
|
|
|
2
2
|
export declare function readCache(): CacheFile;
|
|
3
3
|
export declare function writeCache(cache: CacheFile): void;
|
|
4
4
|
export declare function isCacheFresh(entry: CacheEntry | undefined, version?: string): boolean;
|
|
5
|
-
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -2,4 +2,3 @@ import type { ModelInfo } from '@shennian/wire';
|
|
|
2
2
|
import type { DetectedAgent } from '../detect.js';
|
|
3
3
|
import { type DiscoveryContext } from './types.js';
|
|
4
4
|
export declare function discoverModelsForAgent(agent: DetectedAgent, context: DiscoveryContext): Promise<ModelInfo[]>;
|
|
5
|
-
//# sourceMappingURL=discovery.d.ts.map
|