@yu_robotics/remote-cli 1.1.13 → 1.1.20
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/client/MessageHandler.d.ts.map +1 -1
- package/dist/client/MessageHandler.js +1 -4
- package/dist/client/MessageHandler.js.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +26 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/executor/ClaudePersistentExecutor.d.ts.map +1 -1
- package/dist/executor/ClaudePersistentExecutor.js +44 -7
- package/dist/executor/ClaudePersistentExecutor.js.map +1 -1
- package/dist/executor/GeminiExecutor.d.ts +9 -16
- package/dist/executor/GeminiExecutor.d.ts.map +1 -1
- package/dist/executor/GeminiExecutor.js +73 -93
- package/dist/executor/GeminiExecutor.js.map +1 -1
- package/dist/executor/acp/AcpClient.d.ts +25 -9
- package/dist/executor/acp/AcpClient.d.ts.map +1 -1
- package/dist/executor/acp/AcpClient.js +124 -34
- package/dist/executor/acp/AcpClient.js.map +1 -1
- package/dist/executor/acp/AcpTypes.d.ts +70 -59
- package/dist/executor/acp/AcpTypes.d.ts.map +1 -1
- package/dist/executor/acp/AcpTypes.js +7 -3
- package/dist/executor/acp/AcpTypes.js.map +1 -1
- package/dist/security/security-guard.d.ts +3 -2
- package/dist/security/security-guard.d.ts.map +1 -1
- package/dist/security/security-guard.js +8 -7
- package/dist/security/security-guard.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,32 +6,25 @@ const SessionManager_1 = require("./acp/SessionManager");
|
|
|
6
6
|
/**
|
|
7
7
|
* IExecutor implementation for Gemini CLI via ACP (Agent Client Protocol).
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Each execute() call spawns a fresh Gemini CLI subprocess (vibe-kanban style).
|
|
10
|
+
* This ensures full isolation between turns — a broken session in one turn
|
|
11
|
+
* cannot affect subsequent turns.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* Callbacks are held as mutable references so the same AcpClient instance can
|
|
17
|
-
* serve multiple sequential execute() calls without being recreated.
|
|
13
|
+
* Conversation history is persisted as JSONL via SessionManager and replayed
|
|
14
|
+
* as context prefix on subsequent calls within the same conversation.
|
|
18
15
|
*/
|
|
19
16
|
class GeminiExecutor {
|
|
20
17
|
directoryGuard;
|
|
21
18
|
currentWorkingDirectory;
|
|
22
19
|
sessionManager;
|
|
23
|
-
active = null;
|
|
24
|
-
isExecuting = false;
|
|
25
20
|
model;
|
|
26
21
|
autoApprove;
|
|
27
22
|
geminiCommand;
|
|
28
23
|
geminiVersion;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
currentOnPlanMode;
|
|
34
|
-
currentAccumulate = () => { };
|
|
24
|
+
/** Stable ID for JSONL history file, survives across spawns. */
|
|
25
|
+
conversationId = null;
|
|
26
|
+
/** Reference to the in-flight AcpClient for abort support. */
|
|
27
|
+
inflightClient = null;
|
|
35
28
|
constructor(directoryGuard, options = {}) {
|
|
36
29
|
this.directoryGuard = directoryGuard;
|
|
37
30
|
this.model = options.model ?? '';
|
|
@@ -43,36 +36,71 @@ class GeminiExecutor {
|
|
|
43
36
|
}
|
|
44
37
|
// ─── IExecutor required ─────────────────────────────────────────────────────
|
|
45
38
|
async execute(prompt, options) {
|
|
46
|
-
//
|
|
39
|
+
// Ensure a stable conversation ID exists for history tracking across spawns
|
|
40
|
+
if (!this.conversationId) {
|
|
41
|
+
this.conversationId = `conv-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
42
|
+
}
|
|
47
43
|
let accumulatedOutput = '';
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
const acpCallbacks = {
|
|
45
|
+
onTextChunk: (text) => {
|
|
46
|
+
accumulatedOutput += text;
|
|
47
|
+
options.onStream?.(text);
|
|
48
|
+
},
|
|
49
|
+
onToolCall: (toolCallId, title, kind) => {
|
|
50
|
+
options.onToolUse?.({ id: toolCallId, name: title, input: { kind } });
|
|
51
|
+
},
|
|
52
|
+
onToolResult: (toolCallId, status, output) => {
|
|
53
|
+
options.onToolResult?.({
|
|
54
|
+
tool_use_id: toolCallId,
|
|
55
|
+
content: output ?? '',
|
|
56
|
+
is_error: status !== 'completed',
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
onPlan: (text) => {
|
|
60
|
+
options.onPlanMode?.(text);
|
|
61
|
+
},
|
|
62
|
+
onPermissionRequest: this.autoApprove ? undefined : async () => 0,
|
|
63
|
+
};
|
|
64
|
+
// Prepend history context for follow-up turns within the same conversation
|
|
65
|
+
const historyContext = this.sessionManager.buildResumeContext(this.conversationId);
|
|
56
66
|
const finalPrompt = historyContext ? `${historyContext}${prompt}` : prompt;
|
|
57
|
-
this.sessionManager.append(
|
|
58
|
-
this.
|
|
67
|
+
this.sessionManager.append(this.conversationId, 'user', prompt);
|
|
68
|
+
const client = new AcpClient_1.AcpClient(this.geminiCommand, this.buildGeminiArgs(), this.currentWorkingDirectory, acpCallbacks);
|
|
69
|
+
this.inflightClient = client;
|
|
59
70
|
try {
|
|
71
|
+
console.log(`[GeminiExecutor] Spawning new ACP client for cwd: ${this.currentWorkingDirectory}`);
|
|
72
|
+
console.log(`[GeminiExecutor] Gemini command: ${this.geminiCommand} ${this.buildGeminiArgs().join(' ')}`);
|
|
73
|
+
await client.initialize();
|
|
74
|
+
const sessionId = await client.newSession(this.currentWorkingDirectory);
|
|
75
|
+
console.log(`[GeminiExecutor] ACP session created: ${sessionId.slice(0, 8)}`);
|
|
76
|
+
if (this.autoApprove) {
|
|
77
|
+
console.log(`[GeminiExecutor] Switching session to YOLO mode...`);
|
|
78
|
+
await client.setSessionMode(sessionId, 'yolo');
|
|
79
|
+
}
|
|
80
|
+
console.log(`[GeminiExecutor] Sending prompt (length=${finalPrompt.length})...`);
|
|
60
81
|
const promptResult = await client.prompt(sessionId, finalPrompt);
|
|
61
|
-
|
|
82
|
+
console.log(`[GeminiExecutor] Prompt completed, stopReason=${promptResult.stopReason}`);
|
|
83
|
+
this.sessionManager.append(this.conversationId, 'assistant', accumulatedOutput);
|
|
62
84
|
return {
|
|
63
85
|
success: promptResult.stopReason !== 'refusal',
|
|
64
86
|
output: accumulatedOutput,
|
|
65
|
-
sessionAbbr:
|
|
87
|
+
sessionAbbr: this.conversationId.slice(0, 8),
|
|
66
88
|
};
|
|
67
89
|
}
|
|
68
90
|
catch (error) {
|
|
91
|
+
console.error(`[GeminiExecutor] ❌ Execute error:`, error);
|
|
92
|
+
const msg = error instanceof Error ? error.message : 'Unknown error';
|
|
93
|
+
const friendlyMsg = msg.includes('ENOENT') || msg.includes('not found')
|
|
94
|
+
? 'Gemini CLI is not installed or not found on PATH. Use /backend to switch to another AI backend.'
|
|
95
|
+
: msg;
|
|
69
96
|
return {
|
|
70
97
|
success: false,
|
|
71
|
-
error:
|
|
98
|
+
error: friendlyMsg,
|
|
72
99
|
};
|
|
73
100
|
}
|
|
74
101
|
finally {
|
|
75
|
-
|
|
102
|
+
client.destroy();
|
|
103
|
+
this.inflightClient = null;
|
|
76
104
|
}
|
|
77
105
|
}
|
|
78
106
|
getCurrentWorkingDirectory() {
|
|
@@ -80,86 +108,38 @@ class GeminiExecutor {
|
|
|
80
108
|
}
|
|
81
109
|
async setWorkingDirectory(targetPath) {
|
|
82
110
|
const resolved = this.directoryGuard.resolveWorkingDirectory(targetPath);
|
|
83
|
-
// Tear down current ACP process — new session will start in new directory
|
|
84
|
-
if (this.active) {
|
|
85
|
-
try {
|
|
86
|
-
this.active.client.sendCancel(this.active.sessionId);
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
// best-effort cancel
|
|
90
|
-
}
|
|
91
|
-
this.active.client.destroy();
|
|
92
|
-
this.active = null;
|
|
93
|
-
}
|
|
94
111
|
this.currentWorkingDirectory = resolved;
|
|
112
|
+
// Changing directory resets the conversation context
|
|
113
|
+
this.conversationId = null;
|
|
95
114
|
}
|
|
96
115
|
resetContext() {
|
|
97
|
-
if (this.
|
|
98
|
-
this.sessionManager.remove(this.
|
|
99
|
-
this.
|
|
116
|
+
if (this.conversationId) {
|
|
117
|
+
this.sessionManager.remove(this.conversationId);
|
|
118
|
+
this.conversationId = null;
|
|
100
119
|
}
|
|
101
|
-
// Note: does NOT destroy the child process — a new ACP session is cheaper than a new process.
|
|
102
|
-
// However since we null active, ensureClient() will create a fresh session (and process,
|
|
103
|
-
// because the old one has no reference anymore).
|
|
104
120
|
}
|
|
105
121
|
async abort() {
|
|
106
|
-
if (!this.
|
|
122
|
+
if (!this.inflightClient)
|
|
107
123
|
return false;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
// ignore
|
|
113
|
-
}
|
|
114
|
-
this.active.client.destroy();
|
|
115
|
-
this.active = null;
|
|
116
|
-
this.isExecuting = false;
|
|
124
|
+
this.inflightClient.destroy();
|
|
125
|
+
this.inflightClient = null;
|
|
117
126
|
return true;
|
|
118
127
|
}
|
|
119
128
|
async destroy() {
|
|
120
|
-
if (this.
|
|
121
|
-
this.
|
|
122
|
-
this.
|
|
129
|
+
if (this.inflightClient) {
|
|
130
|
+
this.inflightClient.destroy();
|
|
131
|
+
this.inflightClient = null;
|
|
123
132
|
}
|
|
124
133
|
}
|
|
125
134
|
// ─── Internal helpers ───────────────────────────────────────────────────────
|
|
126
|
-
async ensureClient() {
|
|
127
|
-
if (this.active)
|
|
128
|
-
return this.active;
|
|
129
|
-
// Build ACP callbacks that forward to the mutable slots
|
|
130
|
-
// Using arrow functions that close over `this` so they always call the
|
|
131
|
-
// currently-set callbacks for the in-flight execute() call.
|
|
132
|
-
const acpCallbacks = {
|
|
133
|
-
onTextChunk: (text) => {
|
|
134
|
-
this.currentAccumulate(text);
|
|
135
|
-
this.currentOnStream?.(text);
|
|
136
|
-
},
|
|
137
|
-
onToolCall: (toolCallId, title, kind) => {
|
|
138
|
-
this.currentOnToolUse?.({ id: toolCallId, name: title, input: { kind } });
|
|
139
|
-
},
|
|
140
|
-
onToolResult: (toolCallId, status, output) => {
|
|
141
|
-
this.currentOnToolResult?.({
|
|
142
|
-
tool_use_id: toolCallId,
|
|
143
|
-
content: output ?? '',
|
|
144
|
-
is_error: status !== 'completed',
|
|
145
|
-
});
|
|
146
|
-
},
|
|
147
|
-
onPlan: (text) => {
|
|
148
|
-
this.currentOnPlanMode?.(text);
|
|
149
|
-
},
|
|
150
|
-
onPermissionRequest: this.autoApprove ? undefined : async () => 0,
|
|
151
|
-
};
|
|
152
|
-
const client = new AcpClient_1.AcpClient(this.geminiCommand, this.buildGeminiArgs(), this.currentWorkingDirectory, acpCallbacks);
|
|
153
|
-
await client.initialize();
|
|
154
|
-
const sessionId = await client.newSession(this.currentWorkingDirectory);
|
|
155
|
-
this.active = { client, sessionId };
|
|
156
|
-
return this.active;
|
|
157
|
-
}
|
|
158
135
|
buildGeminiArgs() {
|
|
159
136
|
const args = ['-y', this.geminiVersion, '--experimental-acp'];
|
|
160
137
|
if (this.model) {
|
|
161
138
|
args.push('--model', this.model);
|
|
162
139
|
}
|
|
140
|
+
if (this.autoApprove) {
|
|
141
|
+
args.push('--yolo');
|
|
142
|
+
}
|
|
163
143
|
return args;
|
|
164
144
|
}
|
|
165
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeminiExecutor.js","sourceRoot":"","sources":["../../src/executor/GeminiExecutor.ts"],"names":[],"mappings":";;;AAEA,+CAA+D;AAC/D,yDAAsD;
|
|
1
|
+
{"version":3,"file":"GeminiExecutor.js","sourceRoot":"","sources":["../../src/executor/GeminiExecutor.ts"],"names":[],"mappings":";;;AAEA,+CAA+D;AAC/D,yDAAsD;AAatD;;;;;;;;;GASG;AACH,MAAa,cAAc;IACjB,cAAc,CAAiB;IAC/B,uBAAuB,CAAS;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AO,EAAE,CAAC;YAC9B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,+EAA+E;IAEvE,eAAe;QACrB,MAAM,IAAI,GAAa,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC;QACxE,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA3JD,wCA2JC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PermissionOption } from './AcpTypes';
|
|
2
2
|
export interface AcpEventCallbacks {
|
|
3
3
|
onTextChunk: (text: string) => void;
|
|
4
4
|
onThoughtChunk?: (text: string) => void;
|
|
@@ -6,17 +6,17 @@ export interface AcpEventCallbacks {
|
|
|
6
6
|
onToolResult?: (toolCallId: string, status: string, output?: string) => void;
|
|
7
7
|
onPlan?: (text: string) => void;
|
|
8
8
|
/** Returns the index of the chosen option (0 = first = typically allow_once). */
|
|
9
|
-
onPermissionRequest?: (title: string, options:
|
|
9
|
+
onPermissionRequest?: (title: string, options: PermissionOption[]) => Promise<number>;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Bidirectional JSON-RPC 2.0 transport for Gemini CLI ACP.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
* -
|
|
16
|
-
* -
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
14
|
+
* Improvements over the previous version (inspired by acpx):
|
|
15
|
+
* - Uses canonical types from @agentclientprotocol/sdk
|
|
16
|
+
* - Multi-stage graceful shutdown: stdin close → SIGTERM → SIGKILL
|
|
17
|
+
* - Explicit sendCancel() for cooperative in-flight cancellation
|
|
18
|
+
* - Strict JSON-RPC message validation before routing
|
|
19
|
+
* - Handles the 'close' event in addition to 'exit' for reliable cleanup
|
|
20
20
|
*/
|
|
21
21
|
export declare class AcpClient {
|
|
22
22
|
private child;
|
|
@@ -25,11 +25,26 @@ export declare class AcpClient {
|
|
|
25
25
|
private callbacks;
|
|
26
26
|
private rl;
|
|
27
27
|
private destroyed;
|
|
28
|
+
private killTimer;
|
|
28
29
|
constructor(geminiCommand: string, geminiArgs: string[], cwd: string, callbacks: AcpEventCallbacks);
|
|
29
30
|
initialize(): Promise<void>;
|
|
30
31
|
newSession(cwd: string): Promise<string>;
|
|
31
|
-
|
|
32
|
+
/** Switch a session to YOLO mode so no per-tool permission requests are sent. */
|
|
33
|
+
setSessionMode(sessionId: string, modeId: string): Promise<void>;
|
|
34
|
+
prompt(sessionId: string, text: string): Promise<{
|
|
35
|
+
stopReason: string;
|
|
36
|
+
}>;
|
|
37
|
+
/**
|
|
38
|
+
* Send a cooperative cancel notification for an in-flight prompt.
|
|
39
|
+
* The agent may still send final updates before replying with stopReason='cancelled'.
|
|
40
|
+
*/
|
|
32
41
|
sendCancel(sessionId: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Graceful multi-stage shutdown (mirrors acpx):
|
|
44
|
+
* 1. Close stdin so the agent sees EOF
|
|
45
|
+
* 2. Send SIGTERM and wait SIGKILL_GRACE_MS
|
|
46
|
+
* 3. If still alive, send SIGKILL
|
|
47
|
+
*/
|
|
33
48
|
destroy(): void;
|
|
34
49
|
private sendRequest;
|
|
35
50
|
private sendNotification;
|
|
@@ -43,5 +58,6 @@ export declare class AcpClient {
|
|
|
43
58
|
private handleSessionUpdate;
|
|
44
59
|
private handlePermissionRequest;
|
|
45
60
|
private rejectAllPending;
|
|
61
|
+
private clearKillTimer;
|
|
46
62
|
}
|
|
47
63
|
//# sourceMappingURL=AcpClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcpClient.d.ts","sourceRoot":"","sources":["../../../src/executor/acp/AcpClient.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"AcpClient.d.ts","sourceRoot":"","sources":["../../../src/executor/acp/AcpClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAYjB,MAAM,YAAY,CAAC;AAKpB,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxE,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7E,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACvF;AAOD;;;;;;;;;GASG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,eAAe,CAAqC;IAC5D,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,EAAE,CAAqB;IAC/B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAA8C;gBAG7D,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAAE,EACpB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,iBAAiB;IAyCxB,UAAU,IAAI,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