@robota-sdk/agent-cli 3.0.0-beta.54 → 3.0.0-beta.55
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 +48 -17
- package/dist/node/bin.js +4 -2
- package/dist/node/chunk-2JAZDNYT.js +246 -0
- package/dist/node/chunk-H3NRW5FW.js +4372 -0
- package/dist/node/index.cjs +2572 -682
- package/dist/node/index.d.cts +55 -3
- package/dist/node/index.d.ts +55 -3
- package/dist/node/index.js +12 -1
- package/dist/node/subagents/child-process-subagent-worker.d.ts +2 -0
- package/dist/node/subagents/child-process-subagent-worker.js +123 -0
- package/package.json +17 -10
- package/dist/node/chunk-ASBCJDLC.js +0 -2648
package/dist/node/index.d.cts
CHANGED
|
@@ -1,13 +1,65 @@
|
|
|
1
|
+
import { IProviderDefinition, IProviderConfig } from '@robota-sdk/agent-core';
|
|
2
|
+
import { ICommandModule, IBackgroundTaskRunner, ISubagentRunner, IInProcessSubagentRunnerDeps, ISubagentWorktreeAdapter, ISubagentJobStart, ISubagentJobHandle, TSubagentRunnerFactory, ISubagentWorktreePrepareRequest, IPreparedSubagentWorktree } from '@robota-sdk/agent-sdk';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* CLI entry point — parses arguments, creates provider, and starts the Ink TUI.
|
|
3
6
|
*
|
|
4
|
-
* CLI
|
|
7
|
+
* CLI composes provider definitions. SDK owns everything else
|
|
5
8
|
* (config, context, session, tools).
|
|
6
9
|
*/
|
|
10
|
+
|
|
7
11
|
/**
|
|
8
12
|
* Main CLI orchestration function.
|
|
9
13
|
*/
|
|
10
|
-
|
|
14
|
+
interface IStartCliOptions {
|
|
15
|
+
commandModules?: readonly ICommandModule[];
|
|
16
|
+
providerDefinitions?: readonly IProviderDefinition[];
|
|
17
|
+
}
|
|
18
|
+
declare function startCli(options?: IStartCliOptions): Promise<void>;
|
|
19
|
+
|
|
20
|
+
interface IManagedShellProcessRunnerOptions {
|
|
21
|
+
killGraceMs?: number;
|
|
22
|
+
}
|
|
23
|
+
declare function createManagedShellProcessRunner(options?: IManagedShellProcessRunnerOptions): IBackgroundTaskRunner;
|
|
24
|
+
|
|
25
|
+
interface IChildProcessSubagentRunnerOptions {
|
|
26
|
+
providerConfig?: IProviderConfig;
|
|
27
|
+
workerPath?: string;
|
|
28
|
+
execArgv?: string[];
|
|
29
|
+
killGraceMs?: number;
|
|
30
|
+
env?: NodeJS.ProcessEnv;
|
|
31
|
+
worktreeIsolation?: boolean;
|
|
32
|
+
worktreeAdapter?: ISubagentWorktreeAdapter;
|
|
33
|
+
logsDir?: string;
|
|
34
|
+
}
|
|
35
|
+
declare function createChildProcessSubagentRunnerFactory(options?: IChildProcessSubagentRunnerOptions): TSubagentRunnerFactory;
|
|
36
|
+
declare class ChildProcessSubagentRunner implements ISubagentRunner {
|
|
37
|
+
private readonly deps;
|
|
38
|
+
private readonly workerPath;
|
|
39
|
+
private readonly execArgv?;
|
|
40
|
+
private readonly killGraceMs;
|
|
41
|
+
private readonly providerConfig?;
|
|
42
|
+
private readonly env?;
|
|
43
|
+
private readonly logsDir?;
|
|
44
|
+
constructor(deps: IInProcessSubagentRunnerDeps, options?: IChildProcessSubagentRunnerOptions);
|
|
45
|
+
start(job: ISubagentJobStart): ISubagentJobHandle;
|
|
46
|
+
private createStartPayload;
|
|
47
|
+
private resolveTranscriptPath;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface IGitWorktreeIsolationAdapterOptions {
|
|
51
|
+
worktreeDir?: string;
|
|
52
|
+
branchPrefix?: string;
|
|
53
|
+
}
|
|
54
|
+
declare function createGitWorktreeIsolationAdapter(options?: IGitWorktreeIsolationAdapterOptions): ISubagentWorktreeAdapter;
|
|
55
|
+
declare class GitWorktreeIsolationAdapter implements ISubagentWorktreeAdapter {
|
|
56
|
+
private readonly worktreeDir;
|
|
57
|
+
private readonly branchPrefix;
|
|
58
|
+
constructor(options?: IGitWorktreeIsolationAdapterOptions);
|
|
59
|
+
prepare(request: ISubagentWorktreePrepareRequest): IPreparedSubagentWorktree;
|
|
60
|
+
isClean(worktree: IPreparedSubagentWorktree): boolean;
|
|
61
|
+
remove(worktree: IPreparedSubagentWorktree): void;
|
|
62
|
+
}
|
|
11
63
|
|
|
12
64
|
/**
|
|
13
65
|
* CLI-specific types for terminal I/O abstraction.
|
|
@@ -33,4 +85,4 @@ interface ITerminalOutput {
|
|
|
33
85
|
spinner(message: string): ISpinner;
|
|
34
86
|
}
|
|
35
87
|
|
|
36
|
-
export { type ISpinner, type ITerminalOutput, startCli };
|
|
88
|
+
export { ChildProcessSubagentRunner, GitWorktreeIsolationAdapter, type IChildProcessSubagentRunnerOptions, type IGitWorktreeIsolationAdapterOptions, type IManagedShellProcessRunnerOptions, type ISpinner, type ITerminalOutput, createChildProcessSubagentRunnerFactory, createGitWorktreeIsolationAdapter, createManagedShellProcessRunner, startCli };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,13 +1,65 @@
|
|
|
1
|
+
import { IProviderDefinition, IProviderConfig } from '@robota-sdk/agent-core';
|
|
2
|
+
import { ICommandModule, IBackgroundTaskRunner, ISubagentRunner, IInProcessSubagentRunnerDeps, ISubagentWorktreeAdapter, ISubagentJobStart, ISubagentJobHandle, TSubagentRunnerFactory, ISubagentWorktreePrepareRequest, IPreparedSubagentWorktree } from '@robota-sdk/agent-sdk';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* CLI entry point — parses arguments, creates provider, and starts the Ink TUI.
|
|
3
6
|
*
|
|
4
|
-
* CLI
|
|
7
|
+
* CLI composes provider definitions. SDK owns everything else
|
|
5
8
|
* (config, context, session, tools).
|
|
6
9
|
*/
|
|
10
|
+
|
|
7
11
|
/**
|
|
8
12
|
* Main CLI orchestration function.
|
|
9
13
|
*/
|
|
10
|
-
|
|
14
|
+
interface IStartCliOptions {
|
|
15
|
+
commandModules?: readonly ICommandModule[];
|
|
16
|
+
providerDefinitions?: readonly IProviderDefinition[];
|
|
17
|
+
}
|
|
18
|
+
declare function startCli(options?: IStartCliOptions): Promise<void>;
|
|
19
|
+
|
|
20
|
+
interface IManagedShellProcessRunnerOptions {
|
|
21
|
+
killGraceMs?: number;
|
|
22
|
+
}
|
|
23
|
+
declare function createManagedShellProcessRunner(options?: IManagedShellProcessRunnerOptions): IBackgroundTaskRunner;
|
|
24
|
+
|
|
25
|
+
interface IChildProcessSubagentRunnerOptions {
|
|
26
|
+
providerConfig?: IProviderConfig;
|
|
27
|
+
workerPath?: string;
|
|
28
|
+
execArgv?: string[];
|
|
29
|
+
killGraceMs?: number;
|
|
30
|
+
env?: NodeJS.ProcessEnv;
|
|
31
|
+
worktreeIsolation?: boolean;
|
|
32
|
+
worktreeAdapter?: ISubagentWorktreeAdapter;
|
|
33
|
+
logsDir?: string;
|
|
34
|
+
}
|
|
35
|
+
declare function createChildProcessSubagentRunnerFactory(options?: IChildProcessSubagentRunnerOptions): TSubagentRunnerFactory;
|
|
36
|
+
declare class ChildProcessSubagentRunner implements ISubagentRunner {
|
|
37
|
+
private readonly deps;
|
|
38
|
+
private readonly workerPath;
|
|
39
|
+
private readonly execArgv?;
|
|
40
|
+
private readonly killGraceMs;
|
|
41
|
+
private readonly providerConfig?;
|
|
42
|
+
private readonly env?;
|
|
43
|
+
private readonly logsDir?;
|
|
44
|
+
constructor(deps: IInProcessSubagentRunnerDeps, options?: IChildProcessSubagentRunnerOptions);
|
|
45
|
+
start(job: ISubagentJobStart): ISubagentJobHandle;
|
|
46
|
+
private createStartPayload;
|
|
47
|
+
private resolveTranscriptPath;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface IGitWorktreeIsolationAdapterOptions {
|
|
51
|
+
worktreeDir?: string;
|
|
52
|
+
branchPrefix?: string;
|
|
53
|
+
}
|
|
54
|
+
declare function createGitWorktreeIsolationAdapter(options?: IGitWorktreeIsolationAdapterOptions): ISubagentWorktreeAdapter;
|
|
55
|
+
declare class GitWorktreeIsolationAdapter implements ISubagentWorktreeAdapter {
|
|
56
|
+
private readonly worktreeDir;
|
|
57
|
+
private readonly branchPrefix;
|
|
58
|
+
constructor(options?: IGitWorktreeIsolationAdapterOptions);
|
|
59
|
+
prepare(request: ISubagentWorktreePrepareRequest): IPreparedSubagentWorktree;
|
|
60
|
+
isClean(worktree: IPreparedSubagentWorktree): boolean;
|
|
61
|
+
remove(worktree: IPreparedSubagentWorktree): void;
|
|
62
|
+
}
|
|
11
63
|
|
|
12
64
|
/**
|
|
13
65
|
* CLI-specific types for terminal I/O abstraction.
|
|
@@ -33,4 +85,4 @@ interface ITerminalOutput {
|
|
|
33
85
|
spinner(message: string): ISpinner;
|
|
34
86
|
}
|
|
35
87
|
|
|
36
|
-
export { type ISpinner, type ITerminalOutput, startCli };
|
|
88
|
+
export { ChildProcessSubagentRunner, GitWorktreeIsolationAdapter, type IChildProcessSubagentRunnerOptions, type IGitWorktreeIsolationAdapterOptions, type IManagedShellProcessRunnerOptions, type ISpinner, type ITerminalOutput, createChildProcessSubagentRunnerFactory, createGitWorktreeIsolationAdapter, createManagedShellProcessRunner, startCli };
|
package/dist/node/index.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ChildProcessSubagentRunner,
|
|
3
|
+
GitWorktreeIsolationAdapter,
|
|
4
|
+
createChildProcessSubagentRunnerFactory,
|
|
5
|
+
createGitWorktreeIsolationAdapter,
|
|
6
|
+
createManagedShellProcessRunner,
|
|
2
7
|
startCli
|
|
3
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-H3NRW5FW.js";
|
|
9
|
+
import "./chunk-2JAZDNYT.js";
|
|
4
10
|
export {
|
|
11
|
+
ChildProcessSubagentRunner,
|
|
12
|
+
GitWorktreeIsolationAdapter,
|
|
13
|
+
createChildProcessSubagentRunnerFactory,
|
|
14
|
+
createGitWorktreeIsolationAdapter,
|
|
15
|
+
createManagedShellProcessRunner,
|
|
5
16
|
startCli
|
|
6
17
|
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderFromProfile,
|
|
3
|
+
isSubagentWorkerParentMessage
|
|
4
|
+
} from "../chunk-2JAZDNYT.js";
|
|
5
|
+
|
|
6
|
+
// src/subagents/child-process-subagent-worker.ts
|
|
7
|
+
import {
|
|
8
|
+
createDefaultTools,
|
|
9
|
+
createSubagentLogger,
|
|
10
|
+
createSubagentSession
|
|
11
|
+
} from "@robota-sdk/agent-sdk";
|
|
12
|
+
var CANCEL_EXIT_CODE = 130;
|
|
13
|
+
var NOOP_TERMINAL = {
|
|
14
|
+
write: () => {
|
|
15
|
+
},
|
|
16
|
+
writeLine: () => {
|
|
17
|
+
},
|
|
18
|
+
writeMarkdown: () => {
|
|
19
|
+
},
|
|
20
|
+
writeError: () => {
|
|
21
|
+
},
|
|
22
|
+
prompt: () => Promise.resolve(""),
|
|
23
|
+
select: () => Promise.resolve(0),
|
|
24
|
+
spinner: () => ({ stop: () => {
|
|
25
|
+
}, update: () => {
|
|
26
|
+
} })
|
|
27
|
+
};
|
|
28
|
+
var session = null;
|
|
29
|
+
var cancelled = false;
|
|
30
|
+
var running = Promise.resolve();
|
|
31
|
+
function sendChildMessage(message) {
|
|
32
|
+
if (process.send) {
|
|
33
|
+
process.send(message);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function runInitialPrompt(payload) {
|
|
37
|
+
try {
|
|
38
|
+
const provider = createProviderFromProfile(payload.providerProfile, payload.request.model);
|
|
39
|
+
const sessionLogger = payload.logsDir ? createSubagentLogger(payload.request.parentSessionId, payload.jobId, payload.logsDir) : void 0;
|
|
40
|
+
session = createSubagentSession({
|
|
41
|
+
agentDefinition: payload.agentDefinition,
|
|
42
|
+
parentConfig: payload.parentConfig,
|
|
43
|
+
parentContext: payload.parentContext,
|
|
44
|
+
parentTools: createDefaultTools(),
|
|
45
|
+
provider,
|
|
46
|
+
terminal: NOOP_TERMINAL,
|
|
47
|
+
sessionId: payload.jobId,
|
|
48
|
+
...sessionLogger ? { sessionLogger } : {},
|
|
49
|
+
permissionMode: payload.permissionMode,
|
|
50
|
+
hooks: payload.parentConfig.hooks,
|
|
51
|
+
onTextDelta: (delta) => sendChildMessage({ type: "text_delta", delta }),
|
|
52
|
+
onToolExecution: forwardToolExecution
|
|
53
|
+
});
|
|
54
|
+
const output = await session.run(payload.request.prompt);
|
|
55
|
+
if (cancelled) {
|
|
56
|
+
sendChildMessage({ type: "cancelled", reason: "Subagent worker cancelled" });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
sendChildMessage({ type: "result", output });
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (cancelled) {
|
|
62
|
+
sendChildMessage({ type: "cancelled", reason: "Subagent worker cancelled" });
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
66
|
+
sendChildMessage({ type: "error", message });
|
|
67
|
+
} finally {
|
|
68
|
+
setImmediate(() => process.exit(cancelled ? CANCEL_EXIT_CODE : 0));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function forwardToolExecution(event) {
|
|
72
|
+
if (event.type === "start") {
|
|
73
|
+
sendChildMessage({ type: "tool_start", toolName: event.toolName, toolArgs: event.toolArgs });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
sendChildMessage({ type: "tool_end", toolName: event.toolName, success: event.success ?? true });
|
|
77
|
+
}
|
|
78
|
+
function runFollowUp(prompt) {
|
|
79
|
+
if (session === null) {
|
|
80
|
+
sendChildMessage({ type: "error", message: "Subagent worker has not started" });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
running = running.then(async () => {
|
|
84
|
+
try {
|
|
85
|
+
await session?.run(prompt);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
88
|
+
sendChildMessage({ type: "error", message });
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async function cancelWorker(reason) {
|
|
93
|
+
cancelled = true;
|
|
94
|
+
session?.abort();
|
|
95
|
+
sendChildMessage({ type: "cancelled", reason });
|
|
96
|
+
await session?.shutdown({ reason: "other" }).catch(() => void 0);
|
|
97
|
+
setTimeout(() => process.exit(CANCEL_EXIT_CODE), 0);
|
|
98
|
+
}
|
|
99
|
+
process.on("message", (message) => {
|
|
100
|
+
if (!isSubagentWorkerParentMessage(message)) {
|
|
101
|
+
sendChildMessage({ type: "error", message: "Malformed subagent worker parent message" });
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
switch (message.type) {
|
|
105
|
+
case "start":
|
|
106
|
+
running = running.then(() => runInitialPrompt(message.payload));
|
|
107
|
+
break;
|
|
108
|
+
case "send":
|
|
109
|
+
runFollowUp(message.prompt);
|
|
110
|
+
break;
|
|
111
|
+
case "cancel":
|
|
112
|
+
void cancelWorker(message.reason);
|
|
113
|
+
break;
|
|
114
|
+
default:
|
|
115
|
+
sendChildMessage({ type: "error", message: "Unhandled subagent worker parent message" });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
process.on("disconnect", () => {
|
|
119
|
+
cancelled = true;
|
|
120
|
+
session?.abort();
|
|
121
|
+
void session?.shutdown({ reason: "other" }).catch(() => void 0);
|
|
122
|
+
});
|
|
123
|
+
sendChildMessage({ type: "ready" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robota-sdk/agent-cli",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.55",
|
|
4
4
|
"description": "AI coding assistant CLI built on Robota SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -29,14 +29,17 @@
|
|
|
29
29
|
"bugs": {
|
|
30
30
|
"url": "https://github.com/woojubb/robota/issues"
|
|
31
31
|
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=22.0.0"
|
|
34
|
+
},
|
|
32
35
|
"files": [
|
|
33
36
|
"dist"
|
|
34
37
|
],
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@robota-sdk/agent-sessions": "3.0.0-beta.
|
|
39
|
+
"@robota-sdk/agent-sessions": "3.0.0-beta.55",
|
|
37
40
|
"chalk": "^5.3.0",
|
|
38
41
|
"cli-highlight": "^2.1.0",
|
|
39
|
-
"ink": "^
|
|
42
|
+
"ink": "^7.0.1",
|
|
40
43
|
"ink-select-input": "^6.2.0",
|
|
41
44
|
"ink-spinner": "^5.0.0",
|
|
42
45
|
"ink-text-input": "^6.0.0",
|
|
@@ -44,12 +47,16 @@
|
|
|
44
47
|
"marked-terminal": "^7.3.0",
|
|
45
48
|
"react": "19.2.4",
|
|
46
49
|
"string-width": "^8.2.0",
|
|
47
|
-
"@robota-sdk/agent-core": "3.0.0-beta.
|
|
48
|
-
"@robota-sdk/agent-provider-
|
|
49
|
-
"@robota-sdk/agent-
|
|
50
|
-
"@robota-sdk/agent-
|
|
50
|
+
"@robota-sdk/agent-core": "3.0.0-beta.55",
|
|
51
|
+
"@robota-sdk/agent-provider-gemma": "3.0.0-beta.55",
|
|
52
|
+
"@robota-sdk/agent-provider-anthropic": "3.0.0-beta.55",
|
|
53
|
+
"@robota-sdk/agent-sdk": "3.0.0-beta.55",
|
|
54
|
+
"@robota-sdk/agent-transport-headless": "3.0.0-beta.55",
|
|
55
|
+
"@robota-sdk/agent-command-agent": "3.0.0-beta.55",
|
|
56
|
+
"@robota-sdk/agent-provider-openai": "3.0.0-beta.55"
|
|
51
57
|
},
|
|
52
58
|
"devDependencies": {
|
|
59
|
+
"@homebridge/node-pty-prebuilt-multiarch": "^0.13.1",
|
|
53
60
|
"@types/marked": "^6.0.0",
|
|
54
61
|
"@types/react": "^19.2.14",
|
|
55
62
|
"ink-testing-library": "^4.0.0",
|
|
@@ -64,9 +71,9 @@
|
|
|
64
71
|
"access": "public"
|
|
65
72
|
},
|
|
66
73
|
"scripts": {
|
|
67
|
-
"build": "tsup src/index.ts src/bin.ts --format esm,cjs --dts --out-dir dist/node --clean && rm -f dist/node/bin.cjs dist/node/bin.d.cts",
|
|
68
|
-
"build:js": "tsup src/index.ts src/bin.ts --format esm,cjs --out-dir dist/node --clean && rm -f dist/node/bin.cjs",
|
|
69
|
-
"build:types": "tsup src/index.ts src/bin.ts --format esm,cjs --dts-only --out-dir dist/node && rm -f dist/node/bin.d.cts",
|
|
74
|
+
"build": "tsup src/index.ts src/bin.ts src/subagents/child-process-subagent-worker.ts --format esm,cjs --dts --out-dir dist/node --clean && rm -f dist/node/bin.cjs dist/node/bin.d.cts dist/node/subagents/child-process-subagent-worker.cjs dist/node/subagents/child-process-subagent-worker.d.cts",
|
|
75
|
+
"build:js": "tsup src/index.ts src/bin.ts src/subagents/child-process-subagent-worker.ts --format esm,cjs --out-dir dist/node --clean && rm -f dist/node/bin.cjs dist/node/subagents/child-process-subagent-worker.cjs",
|
|
76
|
+
"build:types": "tsup src/index.ts src/bin.ts src/subagents/child-process-subagent-worker.ts --format esm,cjs --dts-only --out-dir dist/node && rm -f dist/node/bin.d.cts dist/node/subagents/child-process-subagent-worker.d.cts",
|
|
70
77
|
"dev": "tsx --env-file=.env src/bin.ts",
|
|
71
78
|
"start": "node --env-file=.env dist/node/bin.js",
|
|
72
79
|
"test": "vitest run --passWithNoTests",
|