@f5-sales-demo/xcsh 21.25.0 → 21.27.1
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/package.json +9 -9
- package/src/async/job-manager.ts +48 -16
- package/src/cli/args.ts +9 -1
- package/src/cli/flag-spec.ts +5 -0
- package/src/cli.ts +1 -0
- package/src/commands/remote-control.ts +29 -0
- package/src/config/model-registry.ts +4 -3
- package/src/debug/index.ts +10 -2
- package/src/edit/index.ts +12 -1
- package/src/edit/modes/hashline.ts +5 -3
- package/src/edit/modes/patch.ts +3 -1
- package/src/edit/renderer.ts +2 -0
- package/src/exec/bash-executor.ts +23 -12
- package/src/exec/shell-output-filter.ts +39 -0
- package/src/extensibility/extensions/bundled/sandbox-guard.ts +32 -3
- package/src/extensibility/extensions/runner.ts +2 -0
- package/src/extensibility/extensions/types.ts +9 -0
- package/src/extensibility/extensions/wrapper.ts +32 -12
- package/src/internal-urls/build-info.generated.ts +8 -8
- package/src/internal-urls/docs-index.generated.ts +1 -1
- package/src/lsp/index.ts +101 -88
- package/src/main.ts +13 -1
- package/src/modes/components/question-flow.ts +324 -0
- package/src/modes/components/settings-browser.ts +22 -4
- package/src/modes/components/settings-editors.ts +67 -14
- package/src/modes/components/settings-selector.ts +23 -5
- package/src/modes/controllers/command-controller.ts +34 -4
- package/src/modes/controllers/event-controller.ts +1 -1
- package/src/modes/controllers/extension-ui-controller.ts +80 -1
- package/src/modes/interactive-mode.ts +191 -24
- package/src/modes/types.ts +11 -4
- package/src/prompts/system/remote-voice-context.md +6 -0
- package/src/prompts/system/remote-voice-delegation.md +9 -0
- package/src/prompts/system/remote-voice-input.md +3 -0
- package/src/prompts/system/remote-voice-mode-end.md +3 -0
- package/src/prompts/system/remote-voice-mode-start.md +9 -0
- package/src/prompts/system/remote-voice-tail.md +1 -0
- package/src/prompts/system/remote-voice.md +3 -0
- package/src/remote-control/ACCEPTANCE.md +427 -0
- package/src/remote-control/IMPLEMENTATION.md +2682 -0
- package/src/remote-control/LICENSE +201 -0
- package/src/remote-control/NOTICE.md +179 -0
- package/src/remote-control/PARITY.md +1119 -0
- package/src/remote-control/auth.ts +60 -0
- package/src/remote-control/bridge.ts +118 -0
- package/src/remote-control/clients.ts +154 -0
- package/src/remote-control/control.ts +222 -0
- package/src/remote-control/discovery.ts +156 -0
- package/src/remote-control/enrollment.ts +148 -0
- package/src/remote-control/errors.ts +8 -0
- package/src/remote-control/file-changes.ts +39 -0
- package/src/remote-control/history-page.ts +87 -0
- package/src/remote-control/history.ts +559 -0
- package/src/remote-control/host.ts +393 -0
- package/src/remote-control/interactions.ts +290 -0
- package/src/remote-control/ipc.ts +128 -0
- package/src/remote-control/metadata.ts +77 -0
- package/src/remote-control/pairing.ts +79 -0
- package/src/remote-control/process.ts +180 -0
- package/src/remote-control/protocol-methods.json +192 -0
- package/src/remote-control/relay.ts +197 -0
- package/src/remote-control/router.ts +521 -0
- package/src/remote-control/session-voice-history.ts +98 -0
- package/src/remote-control/session.ts +1577 -0
- package/src/remote-control/timeline.ts +125 -0
- package/src/remote-control/trace-client.ts +25 -0
- package/src/remote-control/trace-collector.ts +97 -0
- package/src/remote-control/trace-report.ts +59 -0
- package/src/remote-control/trace-runtime.ts +46 -0
- package/src/remote-control/trace.ts +291 -0
- package/src/remote-control/voice-call.ts +157 -0
- package/src/remote-control/voice-delegation.ts +26 -0
- package/src/remote-control/voice-handoff.ts +198 -0
- package/src/remote-control/voice-history.ts +60 -0
- package/src/remote-control/voice-input.ts +54 -0
- package/src/remote-control/voice-legacy.ts +57 -0
- package/src/remote-control/voice-persona.ts +143 -0
- package/src/remote-control/voice-protocol.ts +270 -0
- package/src/remote-control/voice-socket.ts +72 -0
- package/src/remote-control/voice-standalone.ts +145 -0
- package/src/remote-control/voice-timeline.ts +182 -0
- package/src/remote-control/voice.ts +889 -0
- package/src/sandbox/containment.ts +3 -1
- package/src/sandbox/enforce.ts +6 -0
- package/src/sandbox/remote-permissions.ts +78 -0
- package/src/sandbox/session-fence.ts +10 -1
- package/src/sdk.ts +29 -0
- package/src/session/agent-session.ts +636 -244
- package/src/session/messages.ts +2 -1
- package/src/session/question-types.ts +56 -0
- package/src/session/realtime-context.ts +48 -0
- package/src/session/session-manager.ts +32 -7
- package/src/session/session-transitions.ts +94 -0
- package/src/session/streaming-output.ts +64 -11
- package/src/session/user-interactions.ts +186 -0
- package/src/slash-commands/builtin-registry.ts +10 -0
- package/src/slash-commands/export-command.ts +17 -1
- package/src/tools/ask.ts +30 -373
- package/src/tools/bash.ts +89 -29
- package/src/tools/context.ts +25 -1
- package/src/tools/execution-metadata.ts +42 -0
- package/src/tools/file-mutations.ts +133 -0
- package/src/tools/output-meta.ts +17 -8
- package/src/tools/tool-errors.ts +8 -5
- package/src/tools/write.ts +41 -26
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5-sales-demo/xcsh",
|
|
4
|
-
"version": "21.
|
|
4
|
+
"version": "21.27.1",
|
|
5
5
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
6
6
|
"homepage": "https://github.com/f5-sales-demo/xcsh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"lint": "biome lint .",
|
|
40
40
|
"check:bundle": "bun scripts/check-bundle.ts",
|
|
41
41
|
"pretest": "bun ../../scripts/check-installed-dependencies.ts && bun ../../scripts/ensure-dev-native.ts",
|
|
42
|
-
"test": "bun run generate-build-info && bun scripts/bun-test-guarded.ts --max-concurrency
|
|
42
|
+
"test": "bun run generate-build-info && bun scripts/bun-test-guarded.ts --max-concurrency=2",
|
|
43
43
|
"bench:routing-matrix": "bun scripts/bench-routing-matrix.ts",
|
|
44
44
|
"bench:copy-selector": "bun scripts/bench-copy-selector.ts",
|
|
45
45
|
"fix": "biome check --write --unsafe . && bun run format-prompts && bun run generate-docs-index && bun run generate-api-spec-index && bun run generate-build-info",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
65
|
-
"@f5-sales-demo/pi-agent-core": "21.
|
|
66
|
-
"@f5-sales-demo/pi-ai": "21.
|
|
67
|
-
"@f5-sales-demo/pi-natives": "21.
|
|
68
|
-
"@f5-sales-demo/pi-resource-management": "21.
|
|
69
|
-
"@f5-sales-demo/pi-tui": "21.
|
|
70
|
-
"@f5-sales-demo/pi-utils": "21.
|
|
71
|
-
"@f5-sales-demo/xcsh-stats": "21.
|
|
65
|
+
"@f5-sales-demo/pi-agent-core": "21.27.1",
|
|
66
|
+
"@f5-sales-demo/pi-ai": "21.27.1",
|
|
67
|
+
"@f5-sales-demo/pi-natives": "21.27.1",
|
|
68
|
+
"@f5-sales-demo/pi-resource-management": "21.27.1",
|
|
69
|
+
"@f5-sales-demo/pi-tui": "21.27.1",
|
|
70
|
+
"@f5-sales-demo/pi-utils": "21.27.1",
|
|
71
|
+
"@f5-sales-demo/xcsh-stats": "21.27.1",
|
|
72
72
|
"@mozilla/readability": "^0.6",
|
|
73
73
|
"@sinclair/typebox": "0.34.52",
|
|
74
74
|
"@xterm/headless": "^6.0",
|
package/src/async/job-manager.ts
CHANGED
|
@@ -11,21 +11,29 @@ export interface AsyncJob {
|
|
|
11
11
|
type: "bash" | "task";
|
|
12
12
|
status: "running" | "completed" | "failed" | "cancelled";
|
|
13
13
|
startTime: number;
|
|
14
|
+
ownerId?: string;
|
|
14
15
|
label: string;
|
|
15
16
|
abortController: AbortController;
|
|
16
17
|
promise: Promise<void>;
|
|
17
18
|
resultText?: string;
|
|
19
|
+
/** Latest structured executor facts, retained for the durable completion message. */
|
|
20
|
+
resultDetails?: Record<string, unknown>;
|
|
18
21
|
errorText?: string;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
export interface AsyncJobManagerOptions {
|
|
22
25
|
onJobComplete: (jobId: string, text: string, job?: AsyncJob) => void | Promise<void>;
|
|
26
|
+
getOwnerId?: () => string | undefined;
|
|
27
|
+
onJobCancelled?: (job: AsyncJob) => void | Promise<void>;
|
|
28
|
+
onJobProgress?: (jobId: string, details?: Record<string, unknown>) => void | Promise<void>;
|
|
23
29
|
maxRunningJobs?: number;
|
|
24
30
|
retentionMs?: number;
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
interface AsyncJobDelivery {
|
|
28
34
|
jobId: string;
|
|
35
|
+
job: AsyncJob;
|
|
36
|
+
cancelled: boolean;
|
|
29
37
|
text: string;
|
|
30
38
|
attempt: number;
|
|
31
39
|
nextAttemptAt: number;
|
|
@@ -50,7 +58,10 @@ export class AsyncJobManager {
|
|
|
50
58
|
readonly #suppressedDeliveries = new Set<string>();
|
|
51
59
|
readonly #watchedJobs = new Set<string>();
|
|
52
60
|
readonly #evictionTimers = new Map<string, NodeJS.Timeout>();
|
|
61
|
+
readonly #onJobCancelled: AsyncJobManagerOptions["onJobCancelled"];
|
|
62
|
+
readonly #getOwnerId: AsyncJobManagerOptions["getOwnerId"];
|
|
53
63
|
readonly #onJobComplete: AsyncJobManagerOptions["onJobComplete"];
|
|
64
|
+
readonly #onJobProgress: AsyncJobManagerOptions["onJobProgress"];
|
|
54
65
|
readonly #maxRunningJobs: number;
|
|
55
66
|
readonly #retentionMs: number;
|
|
56
67
|
#deliveryLoop: Promise<void> | undefined;
|
|
@@ -58,6 +69,9 @@ export class AsyncJobManager {
|
|
|
58
69
|
|
|
59
70
|
constructor(options: AsyncJobManagerOptions) {
|
|
60
71
|
this.#onJobComplete = options.onJobComplete;
|
|
72
|
+
this.#onJobCancelled = options.onJobCancelled;
|
|
73
|
+
this.#getOwnerId = options.getOwnerId;
|
|
74
|
+
this.#onJobProgress = options.onJobProgress;
|
|
61
75
|
this.#maxRunningJobs = Math.max(1, Math.floor(options.maxRunningJobs ?? DEFAULT_MAX_RUNNING_JOBS));
|
|
62
76
|
this.#retentionMs = Math.max(0, Math.floor(options.retentionMs ?? DEFAULT_RETENTION_MS));
|
|
63
77
|
}
|
|
@@ -92,15 +106,18 @@ export class AsyncJobManager {
|
|
|
92
106
|
type,
|
|
93
107
|
status: "running",
|
|
94
108
|
startTime,
|
|
109
|
+
ownerId: this.#getOwnerId?.(),
|
|
95
110
|
label,
|
|
96
111
|
abortController,
|
|
97
112
|
promise: Promise.resolve(),
|
|
98
113
|
};
|
|
99
114
|
|
|
100
115
|
const reportProgress = async (text: string, details?: Record<string, unknown>): Promise<void> => {
|
|
101
|
-
if (
|
|
116
|
+
if (details) job.resultDetails = details;
|
|
102
117
|
try {
|
|
103
|
-
|
|
118
|
+
const notified = this.#onJobProgress?.(id, details);
|
|
119
|
+
if (notified) await notified;
|
|
120
|
+
await options?.onProgress?.(text, details);
|
|
104
121
|
} catch (error) {
|
|
105
122
|
logger.warn("Async job progress callback failed", {
|
|
106
123
|
jobId: id,
|
|
@@ -113,6 +130,7 @@ export class AsyncJobManager {
|
|
|
113
130
|
const text = await run({ jobId: id, signal: abortController.signal, reportProgress });
|
|
114
131
|
if (job.status === "cancelled") {
|
|
115
132
|
job.resultText = text;
|
|
133
|
+
this.#enqueueDelivery(id, text, true);
|
|
116
134
|
this.#scheduleEviction(id);
|
|
117
135
|
return;
|
|
118
136
|
}
|
|
@@ -123,6 +141,7 @@ export class AsyncJobManager {
|
|
|
123
141
|
} catch (error) {
|
|
124
142
|
if (job.status === "cancelled") {
|
|
125
143
|
job.errorText = error instanceof Error ? error.message : String(error);
|
|
144
|
+
this.#enqueueDelivery(id, job.errorText, true);
|
|
126
145
|
this.#scheduleEviction(id);
|
|
127
146
|
return;
|
|
128
147
|
}
|
|
@@ -144,7 +163,6 @@ export class AsyncJobManager {
|
|
|
144
163
|
if (job.status !== "running") return false;
|
|
145
164
|
job.status = "cancelled";
|
|
146
165
|
job.abortController.abort();
|
|
147
|
-
this.#scheduleEviction(id);
|
|
148
166
|
return true;
|
|
149
167
|
}
|
|
150
168
|
|
|
@@ -216,7 +234,7 @@ export class AsyncJobManager {
|
|
|
216
234
|
this.#deliveries.splice(
|
|
217
235
|
0,
|
|
218
236
|
this.#deliveries.length,
|
|
219
|
-
...this.#deliveries.filter(delivery => !this.isDeliverySuppressed(delivery.jobId)),
|
|
237
|
+
...this.#deliveries.filter(delivery => delivery.cancelled || !this.isDeliverySuppressed(delivery.jobId)),
|
|
220
238
|
);
|
|
221
239
|
return before - this.#deliveries.length;
|
|
222
240
|
}
|
|
@@ -225,7 +243,6 @@ export class AsyncJobManager {
|
|
|
225
243
|
for (const job of this.getRunningJobs()) {
|
|
226
244
|
job.status = "cancelled";
|
|
227
245
|
job.abortController.abort();
|
|
228
|
-
this.#scheduleEviction(job.id);
|
|
229
246
|
}
|
|
230
247
|
}
|
|
231
248
|
|
|
@@ -278,13 +295,17 @@ export class AsyncJobManager {
|
|
|
278
295
|
return drained;
|
|
279
296
|
}
|
|
280
297
|
|
|
298
|
+
#jobIdInUse(id: string): boolean {
|
|
299
|
+
return this.#jobs.has(id) || this.#deliveries.some(delivery => delivery.jobId === id);
|
|
300
|
+
}
|
|
301
|
+
|
|
281
302
|
#resolveJobId(preferredId?: string): string {
|
|
282
303
|
preferredId = preferredId?.trim();
|
|
283
304
|
if (!preferredId) {
|
|
284
305
|
let candidate = 1;
|
|
285
306
|
while (true) {
|
|
286
307
|
const id = `bg_${candidate}`;
|
|
287
|
-
if (!this.#
|
|
308
|
+
if (!this.#jobIdInUse(id)) {
|
|
288
309
|
return id;
|
|
289
310
|
}
|
|
290
311
|
candidate += 1;
|
|
@@ -292,11 +313,11 @@ export class AsyncJobManager {
|
|
|
292
313
|
}
|
|
293
314
|
|
|
294
315
|
const base = preferredId.trim();
|
|
295
|
-
if (!this.#
|
|
316
|
+
if (!this.#jobIdInUse(base)) return base;
|
|
296
317
|
|
|
297
318
|
let suffix = 2;
|
|
298
319
|
let candidate = `${base}-${suffix}`;
|
|
299
|
-
while (this.#
|
|
320
|
+
while (this.#jobIdInUse(candidate)) {
|
|
300
321
|
suffix += 1;
|
|
301
322
|
candidate = `${base}-${suffix}`;
|
|
302
323
|
}
|
|
@@ -335,13 +356,18 @@ export class AsyncJobManager {
|
|
|
335
356
|
return this.#suppressedDeliveries.has(jobId) || this.#watchedJobs.has(jobId);
|
|
336
357
|
}
|
|
337
358
|
|
|
338
|
-
#enqueueDelivery(jobId: string, text: string): void {
|
|
359
|
+
#enqueueDelivery(jobId: string, text: string, cancelled = false): void {
|
|
360
|
+
if (cancelled && !this.#onJobCancelled) return;
|
|
361
|
+
const job = this.#jobs.get(jobId);
|
|
362
|
+
if (!job) return;
|
|
339
363
|
// Skip delivery if already acknowledged
|
|
340
|
-
if (this.isDeliverySuppressed(jobId)) {
|
|
364
|
+
if (!cancelled && this.isDeliverySuppressed(jobId)) {
|
|
341
365
|
return;
|
|
342
366
|
}
|
|
343
367
|
this.#deliveries.push({
|
|
344
368
|
jobId,
|
|
369
|
+
job,
|
|
370
|
+
cancelled,
|
|
345
371
|
text,
|
|
346
372
|
attempt: 0,
|
|
347
373
|
nextAttemptAt: Date.now(),
|
|
@@ -366,10 +392,15 @@ export class AsyncJobManager {
|
|
|
366
392
|
});
|
|
367
393
|
}
|
|
368
394
|
|
|
395
|
+
#removeDelivery(delivery: AsyncJobDelivery): void {
|
|
396
|
+
const index = this.#deliveries.indexOf(delivery);
|
|
397
|
+
if (index >= 0) this.#deliveries.splice(index, 1);
|
|
398
|
+
}
|
|
399
|
+
|
|
369
400
|
async #runDeliveryLoop(): Promise<void> {
|
|
370
401
|
while (this.#deliveries.length > 0) {
|
|
371
402
|
const delivery = this.#deliveries[0];
|
|
372
|
-
if (this.isDeliverySuppressed(delivery.jobId)) {
|
|
403
|
+
if (!delivery.cancelled && this.isDeliverySuppressed(delivery.jobId)) {
|
|
373
404
|
this.#deliveries.shift();
|
|
374
405
|
continue;
|
|
375
406
|
}
|
|
@@ -381,20 +412,21 @@ export class AsyncJobManager {
|
|
|
381
412
|
continue;
|
|
382
413
|
}
|
|
383
414
|
// Check again after sleep
|
|
384
|
-
if (this.isDeliverySuppressed(delivery.jobId)) {
|
|
415
|
+
if (!delivery.cancelled && this.isDeliverySuppressed(delivery.jobId)) {
|
|
385
416
|
this.#deliveries.shift();
|
|
386
417
|
continue;
|
|
387
418
|
}
|
|
388
419
|
|
|
389
420
|
try {
|
|
390
|
-
|
|
391
|
-
this.#
|
|
421
|
+
if (delivery.cancelled) await this.#onJobCancelled?.(delivery.job);
|
|
422
|
+
else await this.#onJobComplete(delivery.jobId, delivery.text, delivery.job);
|
|
423
|
+
this.#removeDelivery(delivery);
|
|
392
424
|
} catch (error) {
|
|
393
425
|
delivery.attempt += 1;
|
|
394
426
|
delivery.lastError = error instanceof Error ? error.message : String(error);
|
|
395
427
|
delivery.nextAttemptAt = Date.now() + this.#getRetryDelay(delivery.attempt);
|
|
396
|
-
this.#
|
|
397
|
-
if (!this.isDeliverySuppressed(delivery.jobId)) {
|
|
428
|
+
this.#removeDelivery(delivery);
|
|
429
|
+
if (delivery.cancelled || !this.isDeliverySuppressed(delivery.jobId)) {
|
|
398
430
|
this.#deliveries.push(delivery);
|
|
399
431
|
}
|
|
400
432
|
logger.warn("Async job completion delivery failed", {
|
package/src/cli/args.ts
CHANGED
|
@@ -55,6 +55,8 @@ export interface Args {
|
|
|
55
55
|
hooks?: string[];
|
|
56
56
|
extensions?: string[];
|
|
57
57
|
noExtensions?: boolean;
|
|
58
|
+
/** Trusted built-in extensions to retain while --no-extensions disables discovery. */
|
|
59
|
+
bundledExtensions?: string[];
|
|
58
60
|
pluginDirs?: string[];
|
|
59
61
|
print?: boolean;
|
|
60
62
|
export?: string;
|
|
@@ -195,6 +197,9 @@ const APPLY: Record<LaunchFlagName, (result: Args, value: string | true) => void
|
|
|
195
197
|
"no-extensions": r => {
|
|
196
198
|
r.noExtensions = true;
|
|
197
199
|
},
|
|
200
|
+
"bundled-extension": (r, v) => {
|
|
201
|
+
r.bundledExtensions = [...(r.bundledExtensions ?? []), v as string];
|
|
202
|
+
},
|
|
198
203
|
"no-skills": r => {
|
|
199
204
|
r.noSkills = true;
|
|
200
205
|
},
|
|
@@ -235,11 +240,12 @@ export interface LaunchBootstrapArgs {
|
|
|
235
240
|
hooks: string[];
|
|
236
241
|
extensions: string[];
|
|
237
242
|
noExtensions?: boolean;
|
|
243
|
+
bundledExtensions: string[];
|
|
238
244
|
pluginDirs: string[];
|
|
239
245
|
preExtensionExit: boolean;
|
|
240
246
|
}
|
|
241
247
|
|
|
242
|
-
const BOOTSTRAP_VALUE_FLAGS = new Set(["allow-path", "hook", "extension", "plugin-dir"]);
|
|
248
|
+
const BOOTSTRAP_VALUE_FLAGS = new Set(["allow-path", "hook", "extension", "bundled-extension", "plugin-dir"]);
|
|
243
249
|
const PRE_EXTENSION_EXITS = new Set(["version", "list-models", "export"]);
|
|
244
250
|
|
|
245
251
|
/**
|
|
@@ -254,6 +260,7 @@ export function scanLaunchBootstrapArgs(args: readonly string[]): LaunchBootstra
|
|
|
254
260
|
allowPath: [],
|
|
255
261
|
hooks: [],
|
|
256
262
|
extensions: [],
|
|
263
|
+
bundledExtensions: [],
|
|
257
264
|
pluginDirs: [],
|
|
258
265
|
preExtensionExit: false,
|
|
259
266
|
};
|
|
@@ -286,6 +293,7 @@ export function scanLaunchBootstrapArgs(args: readonly string[]): LaunchBootstra
|
|
|
286
293
|
if (name === "allow-path") result.allowPath.push(value);
|
|
287
294
|
if (name === "hook") result.hooks.push(value);
|
|
288
295
|
if (name === "extension") result.extensions.push(value);
|
|
296
|
+
if (name === "bundled-extension") result.bundledExtensions.push(value);
|
|
289
297
|
if (name === "plugin-dir") result.pluginDirs.push(value);
|
|
290
298
|
}
|
|
291
299
|
}
|
package/src/cli/flag-spec.ts
CHANGED
|
@@ -99,6 +99,11 @@ export const LAUNCH_FLAGS = defineFlags({
|
|
|
99
99
|
arity: "boolean",
|
|
100
100
|
description: "Disable extension discovery (explicit -e paths still work)",
|
|
101
101
|
},
|
|
102
|
+
"bundled-extension": {
|
|
103
|
+
arity: "repeatable-value",
|
|
104
|
+
description: "Load a named trusted bundled extension while discovery is disabled",
|
|
105
|
+
hidden: true,
|
|
106
|
+
},
|
|
102
107
|
"no-skills": { arity: "boolean", description: "Disable skills discovery and loading" },
|
|
103
108
|
skills: {
|
|
104
109
|
arity: "value",
|
package/src/cli.ts
CHANGED
|
@@ -50,6 +50,7 @@ if (Bun.stringWidth("\x1b[0m\x1b]8;;\x07") !== 0) {
|
|
|
50
50
|
process.title = APP_NAME;
|
|
51
51
|
|
|
52
52
|
const commands: CommandEntry[] = [
|
|
53
|
+
{ name: "remote-control", load: () => import("./commands/remote-control").then(m => m.default) },
|
|
53
54
|
{ name: "apply", load: () => import("./commands/apply").then(m => m.default) },
|
|
54
55
|
{ name: "launch", load: () => import("./commands/launch").then(m => m.default) },
|
|
55
56
|
{ name: "agents", load: () => import("./commands/agents").then(m => m.default) },
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Args, Command, Flags } from "@f5-sales-demo/pi-utils/cli";
|
|
2
|
+
import { runRemoteControl } from "../remote-control/control";
|
|
3
|
+
export default class RemoteControl extends Command {
|
|
4
|
+
static description = "Native remote interoperability preview: enable, disable, status, pair, clients, revoke";
|
|
5
|
+
static args = {
|
|
6
|
+
action: Args.string({ required: true, description: "enable | disable | status | pair | clients | revoke" }),
|
|
7
|
+
clientId: Args.string({ description: "Client identity to revoke (from clients output)" }),
|
|
8
|
+
};
|
|
9
|
+
static flags = {
|
|
10
|
+
json: Flags.boolean({ description: "Machine-readable status" }),
|
|
11
|
+
cursor: Flags.string({ description: "Client-list pagination cursor" }),
|
|
12
|
+
limit: Flags.integer({ description: "Client-list page size (1–100)" }),
|
|
13
|
+
order: Flags.string({ description: "Client-list order", options: ["asc", "desc"] }),
|
|
14
|
+
};
|
|
15
|
+
async run(): Promise<void> {
|
|
16
|
+
const { args, flags } = await this.parse(RemoteControl);
|
|
17
|
+
if (!args.action) throw new Error("A remote action is required");
|
|
18
|
+
if (args.clientId && args.action !== "revoke") throw new Error("A client identity applies only to revoke");
|
|
19
|
+
if (args.action !== "clients" && (flags.cursor != null || flags.limit != null || flags.order != null))
|
|
20
|
+
throw new Error("Pagination flags apply only to clients");
|
|
21
|
+
const result = await runRemoteControl(args.action, {
|
|
22
|
+
clientId: args.clientId,
|
|
23
|
+
cursor: flags.cursor,
|
|
24
|
+
limit: flags.limit,
|
|
25
|
+
order: flags.order as "asc" | "desc" | undefined,
|
|
26
|
+
});
|
|
27
|
+
if (result !== undefined) process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1068,7 +1068,7 @@ export class ModelRegistry {
|
|
|
1068
1068
|
|
|
1069
1069
|
this.#addImplicitDiscoverableProviders(configuredProviders);
|
|
1070
1070
|
const builtInModels = this.#applyHardcodedModelPolicies(this.#loadBuiltInModels(overrides));
|
|
1071
|
-
const cachedDiscoveries = this.#applyHardcodedModelPolicies(this.#loadCachedDiscoverableModels());
|
|
1071
|
+
const cachedDiscoveries = this.#applyHardcodedModelPolicies(this.#loadCachedDiscoverableModels(), true);
|
|
1072
1072
|
const resolvedDefaults = this.#mergeResolvedModels(builtInModels, cachedDiscoveries);
|
|
1073
1073
|
const withConfigModels = this.#mergeCustomModels(resolvedDefaults, this.#customModelOverlays);
|
|
1074
1074
|
// Merge runtime extension models so they survive refresh() cycles
|
|
@@ -1395,6 +1395,7 @@ export class ModelRegistry {
|
|
|
1395
1395
|
}
|
|
1396
1396
|
: model;
|
|
1397
1397
|
}),
|
|
1398
|
+
true,
|
|
1398
1399
|
);
|
|
1399
1400
|
this.#models = this.#models.filter(
|
|
1400
1401
|
model => !refreshed.has(model.provider) || this.#providerDiscoveryStates.get(model.provider)?.status !== "ok",
|
|
@@ -2091,11 +2092,11 @@ export class ModelRegistry {
|
|
|
2091
2092
|
return applyModelOverride(model, override);
|
|
2092
2093
|
});
|
|
2093
2094
|
}
|
|
2094
|
-
#applyHardcodedModelPolicies(models: Model<Api>[]): Model<Api>[] {
|
|
2095
|
+
#applyHardcodedModelPolicies(models: Model<Api>[], preserveDiscoveredThinking = false): Model<Api>[] {
|
|
2095
2096
|
// Discovery caches contain provider-advertised metadata, which can lag the
|
|
2096
2097
|
// bundled corrections. Reapply generated-model policy before a cached entry
|
|
2097
2098
|
// replaces its bundled peer; explicit user overrides still run afterward.
|
|
2098
|
-
applyGeneratedModelPolicies(models);
|
|
2099
|
+
applyGeneratedModelPolicies(models, { preserveDiscoveredThinking });
|
|
2099
2100
|
return models.map(model => {
|
|
2100
2101
|
if (model.id !== "gpt-5.4" || model.provider === "github-copilot") {
|
|
2101
2102
|
return model;
|
package/src/debug/index.ts
CHANGED
|
@@ -537,9 +537,17 @@ export class DebugSelectorComponent extends HookSelectorComponent {
|
|
|
537
537
|
const stat = await fs.lstat(artifactsDir);
|
|
538
538
|
if (!stat.isDirectory() || stat.isSymbolicLink()) return undefined;
|
|
539
539
|
const resolved = await fs.realpath(artifactsDir);
|
|
540
|
-
|
|
540
|
+
// `/var` resolves to `/private/var` on macOS even when the requested
|
|
541
|
+
// artifact directory itself is not a symlink. Compare canonical parent
|
|
542
|
+
// identity so that alias does not reject a valid local target, while
|
|
543
|
+
// retaining the requested path in the review and launcher contract.
|
|
544
|
+
const canonicalExpected = path.join(
|
|
545
|
+
await fs.realpath(path.dirname(artifactsDir)),
|
|
546
|
+
path.basename(artifactsDir),
|
|
547
|
+
);
|
|
548
|
+
if (resolved !== canonicalExpected) return undefined;
|
|
541
549
|
return {
|
|
542
|
-
path:
|
|
550
|
+
path: artifactsDir,
|
|
543
551
|
revision: `${stat.dev}:${stat.ino}:${stat.mtimeMs}`,
|
|
544
552
|
description: `Directory · device ${stat.dev} · inode ${stat.ino}`,
|
|
545
553
|
};
|
package/src/edit/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ import hashlineDescription from "../prompts/tools/hashline.md" with { type: "tex
|
|
|
18
18
|
import patchDescription from "../prompts/tools/patch.md" with { type: "text" };
|
|
19
19
|
import replaceDescription from "../prompts/tools/replace.md" with { type: "text" };
|
|
20
20
|
import type { ToolSession } from "../tools";
|
|
21
|
+
import { captureFileExecution } from "../tools/file-mutations";
|
|
21
22
|
import { VimTool, vimSchema } from "../tools/vim";
|
|
22
23
|
import { type EditMode, normalizeEditMode, resolveEditMode } from "../utils/edit-mode";
|
|
23
24
|
import type { VimToolDetails } from "../vim/types";
|
|
@@ -231,6 +232,9 @@ async function executePerFile(
|
|
|
231
232
|
|
|
232
233
|
export class EditTool implements AgentTool<TInput> {
|
|
233
234
|
readonly name = "edit";
|
|
235
|
+
get executionKind(): "fileChange" | undefined {
|
|
236
|
+
return this.mode === "vim" ? undefined : "fileChange";
|
|
237
|
+
}
|
|
234
238
|
readonly label = "Edit";
|
|
235
239
|
readonly nonAbortable = true;
|
|
236
240
|
readonly concurrency = "exclusive";
|
|
@@ -282,7 +286,14 @@ export class EditTool implements AgentTool<TInput> {
|
|
|
282
286
|
throw new Error(modeDefinition.invalidParamsMessage);
|
|
283
287
|
}
|
|
284
288
|
|
|
285
|
-
|
|
289
|
+
if (this.mode === "vim")
|
|
290
|
+
return modeDefinition.execute(this, params, signal, getLspBatchRequest(context?.toolCall), onUpdate);
|
|
291
|
+
const captured = await captureFileExecution(snapshot =>
|
|
292
|
+
modeDefinition.execute(this, params, signal, getLspBatchRequest(context?.toolCall), partial =>
|
|
293
|
+
onUpdate?.({ ...partial, details: { diff: "", ...partial.details, execution: snapshot() } }),
|
|
294
|
+
),
|
|
295
|
+
);
|
|
296
|
+
return { ...captured, details: { diff: "", ...captured.details } };
|
|
286
297
|
}
|
|
287
298
|
|
|
288
299
|
#getModeDefinition(): EditModeDefinition {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { recordFileMove, recordFileMutation, recordFileRename } from "../../tools/file-mutations";
|
|
1
2
|
/**
|
|
2
3
|
* Hashline edit mode — a line-addressable edit format using text hashes.
|
|
3
4
|
*
|
|
@@ -1228,7 +1229,7 @@ export async function executeHashlineSingle(
|
|
|
1228
1229
|
|
|
1229
1230
|
if (deleteFile) {
|
|
1230
1231
|
if (sourceExists) {
|
|
1231
|
-
await sourceFile.unlink();
|
|
1232
|
+
await recordFileMutation(absolutePath, () => sourceFile.unlink());
|
|
1232
1233
|
}
|
|
1233
1234
|
invalidateFsScanAfterDelete(absolutePath);
|
|
1234
1235
|
return {
|
|
@@ -1249,7 +1250,7 @@ export async function executeHashlineSingle(
|
|
|
1249
1250
|
if (parentDir && parentDir !== ".") {
|
|
1250
1251
|
await fs.mkdir(parentDir, { recursive: true });
|
|
1251
1252
|
}
|
|
1252
|
-
await fs.rename(absolutePath, resolvedMove);
|
|
1253
|
+
await recordFileRename(absolutePath, resolvedMove, () => fs.rename(absolutePath, resolvedMove));
|
|
1253
1254
|
invalidateFsScanAfterRename(absolutePath, resolvedMove);
|
|
1254
1255
|
return {
|
|
1255
1256
|
content: [{ type: "text", text: `Moved ${path} to ${move}` }],
|
|
@@ -1330,7 +1331,8 @@ export async function executeHashlineSingle(
|
|
|
1330
1331
|
dst === writePath ? beginDeferredDiagnosticsForPath(writePath) : undefined,
|
|
1331
1332
|
);
|
|
1332
1333
|
if (resolvedMove && resolvedMove !== absolutePath) {
|
|
1333
|
-
await sourceFile.unlink();
|
|
1334
|
+
await recordFileMutation(absolutePath, () => sourceFile.unlink());
|
|
1335
|
+
recordFileMove(absolutePath, resolvedMove);
|
|
1334
1336
|
invalidateFsScanAfterRename(absolutePath, resolvedMove);
|
|
1335
1337
|
} else {
|
|
1336
1338
|
invalidateFsScanAfterWrite(absolutePath);
|
package/src/edit/modes/patch.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { recordFileMove, recordFileMutation } from "../../tools/file-mutations";
|
|
1
2
|
/**
|
|
2
3
|
* Patch application logic for the edit tool.
|
|
3
4
|
*
|
|
@@ -1663,7 +1664,7 @@ class LspFileSystem implements FileSystem {
|
|
|
1663
1664
|
}
|
|
1664
1665
|
|
|
1665
1666
|
async delete(path: string): Promise<void> {
|
|
1666
|
-
await this.#getFile(path).unlink();
|
|
1667
|
+
await recordFileMutation(path, () => this.#getFile(path).unlink());
|
|
1667
1668
|
}
|
|
1668
1669
|
|
|
1669
1670
|
async mkdir(path: string): Promise<void> {
|
|
@@ -1735,6 +1736,7 @@ export async function executePatchSingle(
|
|
|
1735
1736
|
allowFuzzy,
|
|
1736
1737
|
});
|
|
1737
1738
|
|
|
1739
|
+
if (result.change.newPath) recordFileMove(resolvedPath, result.change.newPath);
|
|
1738
1740
|
if (resolvedRename) {
|
|
1739
1741
|
invalidateFsScanAfterRename(resolvedPath, resolvedRename);
|
|
1740
1742
|
} else if (result.change.type === "delete") {
|
package/src/edit/renderer.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { RenderResultOptions } from "../extensibility/custom-tools/types";
|
|
|
8
8
|
import type { FileDiagnosticsResult } from "../lsp";
|
|
9
9
|
import { renderDiff as renderDiffColored } from "../modes/components/diff";
|
|
10
10
|
import { getLanguageFromPath, type Theme } from "../modes/theme/theme";
|
|
11
|
+
import type { FileExecutionDetails } from "../tools/execution-metadata";
|
|
11
12
|
import type { OutputMeta } from "../tools/output-meta";
|
|
12
13
|
import {
|
|
13
14
|
formatDiagnostics,
|
|
@@ -71,6 +72,7 @@ export interface EditToolPerFileResult {
|
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
export interface EditToolDetails {
|
|
75
|
+
execution?: FileExecutionDetails;
|
|
74
76
|
/** Unified diff of the changes made */
|
|
75
77
|
diff: string;
|
|
76
78
|
/** Line number of the first change in the new file (for editor navigation) */
|
|
@@ -10,6 +10,7 @@ import type { ContainmentFence } from "../sandbox/containment";
|
|
|
10
10
|
import { OutputSink } from "../session/streaming-output";
|
|
11
11
|
import { getOrCreateSnapshot } from "../utils/shell-snapshot";
|
|
12
12
|
import { NON_INTERACTIVE_ENV } from "./non-interactive-env";
|
|
13
|
+
import { ShellOutputFilter } from "./shell-output-filter";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* The fence as the napi boundary wants it: plain mutable arrays, or absent for unrestricted.
|
|
@@ -117,19 +118,23 @@ export async function executeBash(command: string, options?: BashExecutorOptions
|
|
|
117
118
|
|
|
118
119
|
// CWD capture sentinels — used to detect directory changes from cd commands.
|
|
119
120
|
// Only appended for persistent shell sessions (one-shot shells don't persist CWD).
|
|
120
|
-
const
|
|
121
|
-
const
|
|
121
|
+
const frameId = Bun.randomUUIDv7();
|
|
122
|
+
const CWD_SENTINEL_START = `__xcsh_${frameId}_cwd__:`;
|
|
123
|
+
const CWD_SENTINEL_END = `:__xcsh_${frameId}_cwd_end__`;
|
|
122
124
|
// Exit-code capture sentinel — the persistent shell's own exit code reflects
|
|
123
125
|
// the trailing printf (always 0), so the user command's actual exit status
|
|
124
126
|
// must be captured in-band before another command replaces it. Without this
|
|
125
127
|
// sentinel, subprocess failures like `false`, `ls /nonexistent`, or `(exit 3)`
|
|
126
128
|
// silently report success.
|
|
127
|
-
const EXIT_SENTINEL_START =
|
|
128
|
-
const EXIT_SENTINEL_END =
|
|
129
|
+
const EXIT_SENTINEL_START = `__xcsh_${frameId}_exit__:`;
|
|
130
|
+
const EXIT_SENTINEL_END = `:__xcsh_${frameId}_exit_end__`;
|
|
129
131
|
|
|
132
|
+
const outputFilter = new ShellOutputFilter(CWD_SENTINEL_START, `${EXIT_SENTINEL_END}\n`, text =>
|
|
133
|
+
options?.onChunk?.(text),
|
|
134
|
+
);
|
|
130
135
|
// Create output sink for truncation and artifact handling
|
|
131
136
|
const sink = new OutputSink({
|
|
132
|
-
onChunk: options?.onChunk,
|
|
137
|
+
onChunk: options?.onChunk ? text => outputFilter.push(text) : undefined,
|
|
133
138
|
artifactPath: options?.artifactPath,
|
|
134
139
|
artifactId: options?.artifactId,
|
|
135
140
|
// Throttle the streaming preview callback to avoid saturating the
|
|
@@ -138,6 +143,12 @@ export async function executeBash(command: string, options?: BashExecutorOptions
|
|
|
138
143
|
maskSecrets: options?.maskSecrets,
|
|
139
144
|
});
|
|
140
145
|
|
|
146
|
+
const dump = async (notice?: string) => {
|
|
147
|
+
const result = await sink.dump(notice);
|
|
148
|
+
outputFilter.finish();
|
|
149
|
+
return result;
|
|
150
|
+
};
|
|
151
|
+
|
|
141
152
|
// sink.push() is synchronous — buffer management, counters, and onChunk
|
|
142
153
|
// all run inline. File writes (artifact path) are handled asynchronously
|
|
143
154
|
// inside the sink. No promise chain needed.
|
|
@@ -149,7 +160,7 @@ export async function executeBash(command: string, options?: BashExecutorOptions
|
|
|
149
160
|
return {
|
|
150
161
|
exitCode: undefined,
|
|
151
162
|
cancelled: true,
|
|
152
|
-
...(await
|
|
163
|
+
...(await dump("Command cancelled")),
|
|
153
164
|
};
|
|
154
165
|
}
|
|
155
166
|
|
|
@@ -251,7 +262,7 @@ export async function executeBash(command: string, options?: BashExecutorOptions
|
|
|
251
262
|
return {
|
|
252
263
|
exitCode: undefined,
|
|
253
264
|
cancelled: true,
|
|
254
|
-
...(await
|
|
265
|
+
...(await dump(`Command exceeded hard timeout after ${Math.round(hardTimeoutMs / 1000)} seconds`)),
|
|
255
266
|
};
|
|
256
267
|
}
|
|
257
268
|
|
|
@@ -264,7 +275,7 @@ export async function executeBash(command: string, options?: BashExecutorOptions
|
|
|
264
275
|
return {
|
|
265
276
|
exitCode: undefined,
|
|
266
277
|
cancelled: true,
|
|
267
|
-
...(await
|
|
278
|
+
...(await dump(annotation)),
|
|
268
279
|
};
|
|
269
280
|
}
|
|
270
281
|
|
|
@@ -274,7 +285,7 @@ export async function executeBash(command: string, options?: BashExecutorOptions
|
|
|
274
285
|
return {
|
|
275
286
|
exitCode: undefined,
|
|
276
287
|
cancelled: true,
|
|
277
|
-
...(await
|
|
288
|
+
...(await dump("Command cancelled")),
|
|
278
289
|
};
|
|
279
290
|
}
|
|
280
291
|
|
|
@@ -282,7 +293,7 @@ export async function executeBash(command: string, options?: BashExecutorOptions
|
|
|
282
293
|
// result. Exit sentinel override is the authoritative exit code for
|
|
283
294
|
// persistent shell sessions — `winner.result.exitCode` would otherwise
|
|
284
295
|
// be the trailing printf's exit code (always 0).
|
|
285
|
-
const dumpResult = await
|
|
296
|
+
const dumpResult = await dump();
|
|
286
297
|
let newCwd: string | undefined;
|
|
287
298
|
let overrideExitCode: number | undefined;
|
|
288
299
|
if (shellSession) {
|
|
@@ -311,11 +322,11 @@ export async function executeBash(command: string, options?: BashExecutorOptions
|
|
|
311
322
|
// Strip both sentinel lines from displayed output.
|
|
312
323
|
const afterLine = dumpResult.output.indexOf("\n", stripEndIdx);
|
|
313
324
|
const stripEnd = afterLine === -1 ? dumpResult.output.length : afterLine + 1;
|
|
314
|
-
const strippedBytes = stripEnd
|
|
325
|
+
const strippedBytes = Buffer.byteLength(dumpResult.output.slice(cwdIdx, stripEnd));
|
|
315
326
|
dumpResult.output = dumpResult.output.slice(0, cwdIdx) + dumpResult.output.slice(stripEnd);
|
|
316
327
|
dumpResult.totalBytes = Math.max(0, dumpResult.totalBytes - strippedBytes);
|
|
317
328
|
dumpResult.totalLines = Math.max(0, dumpResult.totalLines - linesRemoved);
|
|
318
|
-
dumpResult.outputBytes = dumpResult.output
|
|
329
|
+
dumpResult.outputBytes = Buffer.byteLength(dumpResult.output);
|
|
319
330
|
dumpResult.outputLines = Math.max(0, dumpResult.outputLines - linesRemoved);
|
|
320
331
|
}
|
|
321
332
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Removes an invocation-specific shell metadata frame from streamed output. */
|
|
2
|
+
export class ShellOutputFilter {
|
|
3
|
+
#pending = "";
|
|
4
|
+
#metadata = false;
|
|
5
|
+
#closed = false;
|
|
6
|
+
constructor(
|
|
7
|
+
readonly start: string,
|
|
8
|
+
readonly end: string,
|
|
9
|
+
readonly emit: (text: string) => void,
|
|
10
|
+
) {
|
|
11
|
+
if (!start || !end) throw new Error("Shell metadata delimiters must not be empty");
|
|
12
|
+
}
|
|
13
|
+
push(text: string): void {
|
|
14
|
+
if (this.#closed) return;
|
|
15
|
+
this.#pending += text;
|
|
16
|
+
while (this.#pending) {
|
|
17
|
+
const delimiter = this.#metadata ? this.end : this.start;
|
|
18
|
+
const index = this.#pending.indexOf(delimiter);
|
|
19
|
+
if (index >= 0) {
|
|
20
|
+
if (!this.#metadata && index) this.emit(this.#pending.slice(0, index));
|
|
21
|
+
this.#pending = this.#pending.slice(index + delimiter.length);
|
|
22
|
+
this.#metadata = !this.#metadata;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
let keep = Math.min(this.#pending.length, delimiter.length - 1);
|
|
26
|
+
while (keep && !this.#pending.endsWith(delimiter.slice(0, keep))) keep--;
|
|
27
|
+
const ready = this.#pending.length - keep;
|
|
28
|
+
if (!this.#metadata && ready) this.emit(this.#pending.slice(0, ready));
|
|
29
|
+
this.#pending = this.#pending.slice(ready);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
finish(): void {
|
|
34
|
+
if (this.#closed) return;
|
|
35
|
+
this.#closed = true;
|
|
36
|
+
if (!this.#metadata && this.#pending) this.emit(this.#pending);
|
|
37
|
+
this.#pending = "";
|
|
38
|
+
}
|
|
39
|
+
}
|