@f5-sales-demo/xcsh 21.18.0 → 21.19.0
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5-sales-demo/xcsh",
|
|
4
|
-
"version": "21.
|
|
4
|
+
"version": "21.19.0",
|
|
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",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@agentclientprotocol/sdk": "1.3.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.19.0",
|
|
66
|
+
"@f5-sales-demo/pi-ai": "21.19.0",
|
|
67
|
+
"@f5-sales-demo/pi-natives": "21.19.0",
|
|
68
|
+
"@f5-sales-demo/pi-resource-management": "21.19.0",
|
|
69
|
+
"@f5-sales-demo/pi-tui": "21.19.0",
|
|
70
|
+
"@f5-sales-demo/pi-utils": "21.19.0",
|
|
71
|
+
"@f5-sales-demo/xcsh-stats": "21.19.0",
|
|
72
72
|
"@mozilla/readability": "^0.6",
|
|
73
73
|
"@sinclair/typebox": "^0.34",
|
|
74
74
|
"@xterm/headless": "^6.0",
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
1
2
|
import * as path from "node:path";
|
|
3
|
+
import type { AssistantMessage } from "@f5-sales-demo/pi-ai";
|
|
2
4
|
import type { ExtensionAPI, ExtensionContext, UserPromptKind } from "@f5-sales-demo/xcsh";
|
|
3
5
|
import { HerdrClient } from "../../../herdr/client";
|
|
6
|
+
import { finalAnswerText } from "../../../session/final-answer";
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* herdr integration (bundled, default-on).
|
|
@@ -10,7 +13,7 @@ import { HerdrClient } from "../../../herdr/client";
|
|
|
10
13
|
* blocked indicator.
|
|
11
14
|
*
|
|
12
15
|
* Transport: herdr injects `HERDR_SOCKET_PATH` into every pane, so state is
|
|
13
|
-
* reported over
|
|
16
|
+
* reported over Herdr's supported JSONL socket protocol via the shared `HerdrClient`
|
|
14
17
|
* (see `../../../herdr/client`) — the same client `herdr-terminal` uses. Each
|
|
15
18
|
* request reconnects independently, validates the `ping` protocol version
|
|
16
19
|
* before the first real request, and awaits herdr's typed response before
|
|
@@ -62,9 +65,13 @@ const METADATA_METHOD = "pane.report_metadata";
|
|
|
62
65
|
const SESSION_METHOD = "pane.report_agent_session";
|
|
63
66
|
const HEARTBEAT_METHOD = "pane.report_agent_heartbeat";
|
|
64
67
|
const RELEASE_METHOD = "pane.release_agent";
|
|
68
|
+
const TURN_REPORT_METHOD = "agent.turn.report";
|
|
65
69
|
const SOCKET_TIMEOUT_MS = 2000;
|
|
66
70
|
const HEARTBEAT_INTERVAL_MS = 10_000;
|
|
67
71
|
const PHASE_LABEL_TTL_MS = 60_000;
|
|
72
|
+
const RESULT_MAX_CHARS = 80;
|
|
73
|
+
const SEMANTIC_RESULT_MAX_BYTES = 8_000;
|
|
74
|
+
const TURN_ENTRY_TYPE = "herdr.semantic-turn";
|
|
68
75
|
const SETTLED_TURN_RECONCILE_DELAY_MS = 25;
|
|
69
76
|
const PROMPT_BLOCKED_REASONS = {
|
|
70
77
|
select: "selection required",
|
|
@@ -79,6 +86,60 @@ function getPromptBlockedReason(kind: unknown): string {
|
|
|
79
86
|
return "user input required";
|
|
80
87
|
}
|
|
81
88
|
|
|
89
|
+
function boundedResult(message: AssistantMessage | undefined): string | undefined {
|
|
90
|
+
if (message?.stopReason !== "stop") return undefined;
|
|
91
|
+
const result = finalAnswerText(message).replaceAll(/\s+/g, " ").trim().slice(0, RESULT_MAX_CHARS).trim();
|
|
92
|
+
return result || undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function boundedSemanticResult(message: AssistantMessage | undefined): string {
|
|
96
|
+
if (message?.stopReason !== "stop") return "";
|
|
97
|
+
let result = finalAnswerText(message).trim();
|
|
98
|
+
while (Buffer.byteLength(result) > SEMANTIC_RESULT_MAX_BYTES) result = result.slice(0, -1);
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
interface PersistedTurn {
|
|
103
|
+
sessionId: string;
|
|
104
|
+
turnId: string;
|
|
105
|
+
generation: number;
|
|
106
|
+
eventRevision?: number;
|
|
107
|
+
state?: "starting" | "working" | "waiting_input" | "completed" | "failed" | "cancelled" | "interrupted";
|
|
108
|
+
result?: string;
|
|
109
|
+
reason?: string;
|
|
110
|
+
resultDigest?: string;
|
|
111
|
+
delivered?: boolean;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function persistedTurns(ctx: ExtensionContext): PersistedTurn[] {
|
|
115
|
+
try {
|
|
116
|
+
const entries = ctx.sessionManager?.getEntries?.() as unknown[] | undefined;
|
|
117
|
+
return (entries ?? []).flatMap(entry => {
|
|
118
|
+
if (typeof entry !== "object" || entry === null) return [];
|
|
119
|
+
const record = entry as Record<string, unknown>;
|
|
120
|
+
if (record.type !== "custom" || record.customType !== TURN_ENTRY_TYPE) return [];
|
|
121
|
+
if (typeof record.data !== "object" || record.data === null) return [];
|
|
122
|
+
const turn = record.data as Record<string, unknown>;
|
|
123
|
+
if (typeof turn.sessionId !== "string" || typeof turn.turnId !== "string") return [];
|
|
124
|
+
return [
|
|
125
|
+
{
|
|
126
|
+
sessionId: turn.sessionId,
|
|
127
|
+
turnId: turn.turnId,
|
|
128
|
+
generation: typeof turn.generation === "number" ? turn.generation : 0,
|
|
129
|
+
eventRevision: typeof turn.eventRevision === "number" ? turn.eventRevision : undefined,
|
|
130
|
+
state: typeof turn.state === "string" ? (turn.state as PersistedTurn["state"]) : undefined,
|
|
131
|
+
result: typeof turn.result === "string" ? turn.result : undefined,
|
|
132
|
+
reason: typeof turn.reason === "string" ? turn.reason : undefined,
|
|
133
|
+
resultDigest: typeof turn.resultDigest === "string" ? turn.resultDigest : undefined,
|
|
134
|
+
delivered: turn.delivered === true,
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
});
|
|
138
|
+
} catch {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
82
143
|
// Reused across calls for the life of the extension so `ensureProtocol()`'s
|
|
83
144
|
// `ping` validation happens at most once per socket path, not once per frame.
|
|
84
145
|
let cachedClient: HerdrClient | undefined;
|
|
@@ -91,7 +152,7 @@ function getHerdrClient(socketPath: string): HerdrClient {
|
|
|
91
152
|
}
|
|
92
153
|
|
|
93
154
|
/**
|
|
94
|
-
* Send one JSON-RPC request to
|
|
155
|
+
* Send one JSON-RPC request to Herdr over its negotiated socket and await the
|
|
95
156
|
* typed response. Every failure path (transport error, timeout, protocol
|
|
96
157
|
* mismatch) is reported via `onError` without throwing, so a dead or
|
|
97
158
|
* incompatible herdr never disturbs the agent.
|
|
@@ -153,13 +214,19 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
153
214
|
// Once the normalized contract is observed it is authoritative. The legacy
|
|
154
215
|
// event mappings remain only for older hosts that load this bundled extension.
|
|
155
216
|
let normalizedPhasesObserved = false;
|
|
217
|
+
let currentTurnId = 0;
|
|
218
|
+
let lastNormalizedEventKey: string | undefined;
|
|
219
|
+
let pendingSuccessfulResult: string | undefined;
|
|
220
|
+
let pendingSemanticResult = "";
|
|
221
|
+
let activeSemanticTurn: PersistedTurn | undefined;
|
|
222
|
+
let semanticRevision = 0;
|
|
156
223
|
// Last session ref already delivered, so repeated lifecycle events do not
|
|
157
224
|
// re-send an unchanged ref every turn.
|
|
158
225
|
let lastSessionRefKey: string | undefined;
|
|
159
226
|
// Herdr only anchors a new full-lifecycle authority after the first session
|
|
160
227
|
// reference identifies how the session began. XCSH creates that reference
|
|
161
228
|
// lazily, so retain the startup marker until there is a concrete ref to send.
|
|
162
|
-
let pendingSessionStartSource: "startup" | undefined = "startup";
|
|
229
|
+
let pendingSessionStartSource: "startup" | "new" | "resume" | "fork" | undefined = "startup";
|
|
163
230
|
// `agent_end` is the primary completion signal. Keep one deferred check from
|
|
164
231
|
// `turn_end` as well: some interactive UI paths render the completed response
|
|
165
232
|
// before their agent-end extension callback has drained. The check consults
|
|
@@ -174,13 +241,22 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
174
241
|
// Serializes frames: herdr compares `seq` across all methods for this source,
|
|
175
242
|
// so frames must reach it in the order they were generated.
|
|
176
243
|
let queue: Promise<void> = Promise.resolve();
|
|
244
|
+
let latestContext: ExtensionContext | undefined;
|
|
245
|
+
let trackingWarningShown = false;
|
|
177
246
|
|
|
178
247
|
pi.setLabel(HERDR_AGENT_LABEL);
|
|
179
248
|
|
|
180
249
|
const onError = (err: unknown): void => {
|
|
250
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
181
251
|
pi.logger.debug("herdr report failed", {
|
|
182
|
-
error:
|
|
252
|
+
error: message,
|
|
183
253
|
});
|
|
254
|
+
const ui = (latestContext as { ui?: ExtensionContext["ui"] } | undefined)?.ui;
|
|
255
|
+
ui?.setStatus("herdr-tracking", "Herdr tracking degraded");
|
|
256
|
+
if (!trackingWarningShown) {
|
|
257
|
+
trackingWarningShown = true;
|
|
258
|
+
ui?.notify(`Herdr semantic tracking is degraded: ${message}`, "warning");
|
|
259
|
+
}
|
|
184
260
|
};
|
|
185
261
|
|
|
186
262
|
/** Chain a frame onto the tail of the send queue. Never rejects. */
|
|
@@ -203,6 +279,80 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
203
279
|
);
|
|
204
280
|
};
|
|
205
281
|
|
|
282
|
+
const reportSemanticTurn = (
|
|
283
|
+
state: "starting" | "working" | "waiting_input" | "completed" | "failed" | "cancelled" | "interrupted",
|
|
284
|
+
options: { result?: string; reason?: string } = {},
|
|
285
|
+
): Promise<void> => {
|
|
286
|
+
const executionId = process.env.HERDR_EXECUTION_ID;
|
|
287
|
+
if (!executionId || !activeSemanticTurn) return Promise.resolve();
|
|
288
|
+
const revision = ++semanticRevision;
|
|
289
|
+
const event: PersistedTurn = {
|
|
290
|
+
...activeSemanticTurn,
|
|
291
|
+
eventRevision: revision,
|
|
292
|
+
state,
|
|
293
|
+
...(options.result === undefined
|
|
294
|
+
? {}
|
|
295
|
+
: { result: options.result, resultDigest: createHash("sha256").update(options.result).digest("hex") }),
|
|
296
|
+
...(options.reason === undefined ? {} : { reason: options.reason }),
|
|
297
|
+
};
|
|
298
|
+
pi.appendEntry(TURN_ENTRY_TYPE, { ...event, delivered: false });
|
|
299
|
+
return deliverSemanticEvent(event);
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const deliverSemanticEvent = (event: PersistedTurn): Promise<void> => {
|
|
303
|
+
const socketPath = process.env.HERDR_SOCKET_PATH;
|
|
304
|
+
const executionId = process.env.HERDR_EXECUTION_ID;
|
|
305
|
+
if (!socketPath || !executionId || event.eventRevision === undefined || event.state === undefined) {
|
|
306
|
+
return Promise.resolve();
|
|
307
|
+
}
|
|
308
|
+
const frame = {
|
|
309
|
+
execution_id: executionId,
|
|
310
|
+
pane_id: paneId,
|
|
311
|
+
producer: HERDR_AGENT_LABEL,
|
|
312
|
+
session_id: event.sessionId,
|
|
313
|
+
turn_id: event.turnId,
|
|
314
|
+
generation: event.generation,
|
|
315
|
+
event_revision: event.eventRevision,
|
|
316
|
+
state: event.state,
|
|
317
|
+
...(event.result === undefined ? {} : { result: event.result, result_digest: event.resultDigest }),
|
|
318
|
+
...(event.reason === undefined ? {} : { reason: event.reason }),
|
|
319
|
+
};
|
|
320
|
+
return enqueue(async () => {
|
|
321
|
+
const client = getHerdrClient(socketPath);
|
|
322
|
+
try {
|
|
323
|
+
await client.ensureProtocol();
|
|
324
|
+
if (!client.hasCapability("agent_turn_journal")) {
|
|
325
|
+
onError(new Error("Herdr does not advertise agent_turn_journal; semantic tracking is degraded"));
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
await client.request<Record<string, unknown>>(TURN_REPORT_METHOD, frame);
|
|
329
|
+
pi.appendEntry(TURN_ENTRY_TYPE, { ...event, delivered: true });
|
|
330
|
+
(latestContext as { ui?: ExtensionContext["ui"] } | undefined)?.ui?.setStatus("herdr-tracking", undefined);
|
|
331
|
+
} catch (err) {
|
|
332
|
+
onError(err);
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
const beginSemanticTurn = async (ctx: ExtensionContext): Promise<void> => {
|
|
338
|
+
const sessionId = ctx.sessionManager?.getSessionId?.();
|
|
339
|
+
if (typeof sessionId !== "string" || !sessionId) return;
|
|
340
|
+
activeSemanticTurn = { sessionId, turnId: randomUUID(), generation: 0 };
|
|
341
|
+
semanticRevision = 0;
|
|
342
|
+
pendingSemanticResult = "";
|
|
343
|
+
pi.appendEntry(TURN_ENTRY_TYPE, { ...activeSemanticTurn, eventRevision: 0 });
|
|
344
|
+
await reportSemanticTurn("starting");
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
const finishSemanticTurn = async (
|
|
348
|
+
state: "completed" | "failed" | "cancelled" | "interrupted",
|
|
349
|
+
options: { result?: string; reason?: string } = {},
|
|
350
|
+
): Promise<void> => {
|
|
351
|
+
if (!activeSemanticTurn) return;
|
|
352
|
+
await reportSemanticTurn(state, options);
|
|
353
|
+
activeSemanticTurn = undefined;
|
|
354
|
+
};
|
|
355
|
+
|
|
206
356
|
const report = (state: "idle" | "working" | "blocked", message?: string): Promise<void> =>
|
|
207
357
|
send(REPORT_METHOD, {
|
|
208
358
|
pane_id: paneId,
|
|
@@ -289,11 +439,12 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
289
439
|
// agent_start, and a ref missed there would otherwise be lost until the next
|
|
290
440
|
// turn — long enough for a restart to lose the pane. Unchanged refs are
|
|
291
441
|
// suppressed, so the extra call sites cost nothing on the wire.
|
|
292
|
-
const reportSession = (ctx: ExtensionContext): Promise<void> => {
|
|
442
|
+
const reportSession = (ctx: ExtensionContext, sessionStartSource?: "new" | "resume" | "fork"): Promise<void> => {
|
|
293
443
|
const socketPath = process.env.HERDR_SOCKET_PATH;
|
|
294
444
|
if (!socketPath) {
|
|
295
445
|
return Promise.resolve();
|
|
296
446
|
}
|
|
447
|
+
if (sessionStartSource !== undefined) pendingSessionStartSource = sessionStartSource;
|
|
297
448
|
let sessionRef: Record<string, unknown> | undefined;
|
|
298
449
|
try {
|
|
299
450
|
const file = ctx.sessionManager?.getSessionFile?.();
|
|
@@ -313,7 +464,7 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
313
464
|
return Promise.resolve();
|
|
314
465
|
}
|
|
315
466
|
const refKey = JSON.stringify(sessionRef);
|
|
316
|
-
if (refKey === lastSessionRefKey) {
|
|
467
|
+
if (refKey === lastSessionRefKey && sessionStartSource === undefined) {
|
|
317
468
|
return Promise.resolve();
|
|
318
469
|
}
|
|
319
470
|
lastSessionRefKey = refKey;
|
|
@@ -347,9 +498,53 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
347
498
|
|
|
348
499
|
// Announce presence and session identity as soon as the session is initialized.
|
|
349
500
|
pi.on("session_start", async (_event, ctx) => {
|
|
501
|
+
latestContext = ctx;
|
|
350
502
|
startHeartbeat();
|
|
351
503
|
await report("idle");
|
|
352
504
|
await reportSession(ctx);
|
|
505
|
+
const persisted = persistedTurns(ctx);
|
|
506
|
+
const byRevision = new Map<string, PersistedTurn>();
|
|
507
|
+
for (const event of persisted) {
|
|
508
|
+
if (event.eventRevision !== undefined && event.state !== undefined) {
|
|
509
|
+
byRevision.set(`${event.sessionId}:${event.turnId}:${event.generation}:${event.eventRevision}`, event);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
const events = [...byRevision.values()];
|
|
513
|
+
for (const event of events.filter(event => !event.delivered)) await deliverSemanticEvent(event);
|
|
514
|
+
const last = events.at(-1);
|
|
515
|
+
const terminal = last && ["completed", "failed", "cancelled", "interrupted"].includes(last.state ?? "");
|
|
516
|
+
if (last && !terminal) {
|
|
517
|
+
activeSemanticTurn = last;
|
|
518
|
+
semanticRevision = last.eventRevision ?? 0;
|
|
519
|
+
await finishSemanticTurn("interrupted", { reason: "XCSH restarted before semantic settlement" });
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
pi.on("before_agent_start", async (_event, ctx) => {
|
|
524
|
+
latestContext = ctx;
|
|
525
|
+
if (!activeSemanticTurn) await beginSemanticTurn(ctx);
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
pi.on("session_before_switch", async () => {
|
|
529
|
+
await finishSemanticTurn("interrupted", { reason: "XCSH switched sessions before semantic settlement" });
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
pi.on("session_before_branch", async () => {
|
|
533
|
+
await finishSemanticTurn("interrupted", { reason: "XCSH forked before semantic settlement" });
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
pi.on("session_switch", async (event, ctx) => {
|
|
537
|
+
latestContext = ctx;
|
|
538
|
+
currentTurnId = 0;
|
|
539
|
+
lastNormalizedEventKey = undefined;
|
|
540
|
+
await reportSession(ctx, event.reason);
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
pi.on("session_branch", async (_event, ctx) => {
|
|
544
|
+
latestContext = ctx;
|
|
545
|
+
currentTurnId = 0;
|
|
546
|
+
lastNormalizedEventKey = undefined;
|
|
547
|
+
await reportSession(ctx, "fork");
|
|
353
548
|
});
|
|
354
549
|
|
|
355
550
|
// Busy while the agent loop is streaming a response. Re-report session identity
|
|
@@ -364,6 +559,12 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
364
559
|
// This is also the first point where a lazily-created session file is certain
|
|
365
560
|
// to exist, so it is the backstop for capturing the resume ref.
|
|
366
561
|
pi.on("agent_end", async (_event, ctx) => {
|
|
562
|
+
const messages = _event.messages;
|
|
563
|
+
const lastAssistant = [...messages]
|
|
564
|
+
.reverse()
|
|
565
|
+
.find((message): message is AssistantMessage => message.role === "assistant");
|
|
566
|
+
pendingSuccessfulResult = boundedResult(lastAssistant);
|
|
567
|
+
pendingSemanticResult = boundedSemanticResult(lastAssistant);
|
|
367
568
|
if (!normalizedPhasesObserved) await report(promptBlockedReason ? "blocked" : "idle", promptBlockedReason);
|
|
368
569
|
await reportSession(ctx);
|
|
369
570
|
});
|
|
@@ -395,6 +596,14 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
395
596
|
|
|
396
597
|
pi.on("turn_phase", async (event, ctx) => {
|
|
397
598
|
normalizedPhasesObserved = true;
|
|
599
|
+
if (event.turnId < currentTurnId) return;
|
|
600
|
+
const eventKey = `${event.turnId}:${event.phase}`;
|
|
601
|
+
if (eventKey === lastNormalizedEventKey) return;
|
|
602
|
+
if (event.turnId > currentTurnId) {
|
|
603
|
+
currentTurnId = event.turnId;
|
|
604
|
+
pendingSuccessfulResult = undefined;
|
|
605
|
+
}
|
|
606
|
+
lastNormalizedEventKey = eventKey;
|
|
398
607
|
const state =
|
|
399
608
|
event.phase === "awaiting_user"
|
|
400
609
|
? "blocked"
|
|
@@ -402,7 +611,39 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
402
611
|
? "working"
|
|
403
612
|
: "idle";
|
|
404
613
|
await report(state, event.phase === "awaiting_user" ? "user input required" : undefined);
|
|
405
|
-
|
|
614
|
+
const turnStatus =
|
|
615
|
+
event.phase === "idle"
|
|
616
|
+
? "completed"
|
|
617
|
+
: event.phase === "error"
|
|
618
|
+
? "failed"
|
|
619
|
+
: event.phase === "cancelled"
|
|
620
|
+
? "cancelled"
|
|
621
|
+
: event.phase === "awaiting_user"
|
|
622
|
+
? "waiting_input"
|
|
623
|
+
: "working";
|
|
624
|
+
await reportMetadata({
|
|
625
|
+
state_labels: { [state]: event.phase },
|
|
626
|
+
tokens: {
|
|
627
|
+
xcsh_turn_id: String(event.turnId),
|
|
628
|
+
xcsh_turn_status: turnStatus,
|
|
629
|
+
xcsh_result: event.phase === "idle" ? (pendingSuccessfulResult ?? null) : null,
|
|
630
|
+
},
|
|
631
|
+
ttl_ms: PHASE_LABEL_TTL_MS,
|
|
632
|
+
});
|
|
633
|
+
if (event.phase === "idle") {
|
|
634
|
+
await finishSemanticTurn("completed", { result: pendingSemanticResult });
|
|
635
|
+
} else if (event.phase === "error") {
|
|
636
|
+
await finishSemanticTurn("failed", { reason: "XCSH turn failed" });
|
|
637
|
+
} else if (event.phase === "cancelled") {
|
|
638
|
+
await finishSemanticTurn("cancelled", { reason: "XCSH turn cancelled" });
|
|
639
|
+
} else if (event.phase === "awaiting_user") {
|
|
640
|
+
await reportSemanticTurn("waiting_input", { reason: "user input required" });
|
|
641
|
+
} else {
|
|
642
|
+
await reportSemanticTurn("working");
|
|
643
|
+
}
|
|
644
|
+
if (event.phase === "idle" || event.phase === "error" || event.phase === "cancelled") {
|
|
645
|
+
pendingSuccessfulResult = undefined;
|
|
646
|
+
}
|
|
406
647
|
await reportSession(ctx);
|
|
407
648
|
});
|
|
408
649
|
|
|
@@ -447,9 +688,10 @@ export default function herdrReporter(pi: ExtensionAPI): void {
|
|
|
447
688
|
});
|
|
448
689
|
|
|
449
690
|
// Relinquish pane authority so herdr stops showing xcsh once we exit.
|
|
450
|
-
pi.on("session_shutdown", () => {
|
|
691
|
+
pi.on("session_shutdown", async () => {
|
|
451
692
|
stopHeartbeat();
|
|
452
|
-
|
|
693
|
+
await finishSemanticTurn("interrupted", { reason: "XCSH shut down before semantic settlement" });
|
|
694
|
+
await send(RELEASE_METHOD, {
|
|
453
695
|
pane_id: paneId,
|
|
454
696
|
source: HERDR_SOURCE,
|
|
455
697
|
agent: HERDR_AGENT_LABEL,
|
package/src/herdr/client.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { connect } from "node:net";
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const HERDR_PROTOCOL_MIN_VERSION = 19;
|
|
5
|
+
export const HERDR_PROTOCOL_MAX_VERSION = 20;
|
|
5
6
|
const DEFAULT_TIMEOUT_MS = 5_000;
|
|
6
7
|
const MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
|
|
7
8
|
|
|
@@ -19,9 +20,11 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
|
|
19
20
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
/** Typed, one-request-per-connection client for Herdr
|
|
23
|
+
/** Typed, one-request-per-connection client for supported Herdr JSONL protocols. */
|
|
23
24
|
export class HerdrClient {
|
|
24
25
|
private protocolChecked = false;
|
|
26
|
+
private negotiatedProtocol: number | undefined;
|
|
27
|
+
private capabilities: Readonly<Record<string, unknown>> = {};
|
|
25
28
|
|
|
26
29
|
constructor(
|
|
27
30
|
readonly socketPath: string,
|
|
@@ -32,16 +35,36 @@ export class HerdrClient {
|
|
|
32
35
|
|
|
33
36
|
async ensureProtocol(): Promise<void> {
|
|
34
37
|
if (this.protocolChecked) return;
|
|
35
|
-
const pong = await this.requestRaw<{
|
|
36
|
-
|
|
38
|
+
const pong = await this.requestRaw<{
|
|
39
|
+
type: string;
|
|
40
|
+
protocol: number;
|
|
41
|
+
version: string;
|
|
42
|
+
capabilities?: Record<string, unknown>;
|
|
43
|
+
}>("ping", {});
|
|
44
|
+
if (
|
|
45
|
+
pong.type !== "pong" ||
|
|
46
|
+
!Number.isInteger(pong.protocol) ||
|
|
47
|
+
pong.protocol < HERDR_PROTOCOL_MIN_VERSION ||
|
|
48
|
+
pong.protocol > HERDR_PROTOCOL_MAX_VERSION
|
|
49
|
+
) {
|
|
37
50
|
throw new HerdrProtocolError(
|
|
38
|
-
`Herdr protocol mismatch:
|
|
51
|
+
`Herdr protocol mismatch: supported ${HERDR_PROTOCOL_MIN_VERSION}-${HERDR_PROTOCOL_MAX_VERSION}, received ${String(pong.protocol)}`,
|
|
39
52
|
"protocol_mismatch",
|
|
40
53
|
);
|
|
41
54
|
}
|
|
55
|
+
this.negotiatedProtocol = pong.protocol;
|
|
56
|
+
this.capabilities = isRecord(pong.capabilities) ? Object.freeze({ ...pong.capabilities }) : {};
|
|
42
57
|
this.protocolChecked = true;
|
|
43
58
|
}
|
|
44
59
|
|
|
60
|
+
get protocolVersion(): number | undefined {
|
|
61
|
+
return this.negotiatedProtocol;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
hasCapability(name: string): boolean {
|
|
65
|
+
return this.capabilities[name] === true;
|
|
66
|
+
}
|
|
67
|
+
|
|
45
68
|
async request<T extends Record<string, unknown>>(method: string, params: Record<string, unknown>): Promise<T> {
|
|
46
69
|
await this.ensureProtocol();
|
|
47
70
|
return this.requestRaw<T>(method, params);
|
|
@@ -17,17 +17,17 @@ export interface BuildInfo {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const BUILD_INFO: BuildInfo = {
|
|
20
|
-
"version": "21.
|
|
21
|
-
"commit": "
|
|
22
|
-
"shortCommit": "
|
|
20
|
+
"version": "21.19.0",
|
|
21
|
+
"commit": "d6ee0a02bee64b4deefa70ca26b25806055a526c",
|
|
22
|
+
"shortCommit": "d6ee0a0",
|
|
23
23
|
"branch": "main",
|
|
24
|
-
"tag": "v21.
|
|
25
|
-
"commitDate": "2026-09-
|
|
26
|
-
"buildDate": "2026-09-
|
|
24
|
+
"tag": "v21.19.0",
|
|
25
|
+
"commitDate": "2026-09-08T17:45:15+00:00",
|
|
26
|
+
"buildDate": "2026-09-08T18:51:12.735Z",
|
|
27
27
|
"dirty": true,
|
|
28
28
|
"prNumber": "",
|
|
29
29
|
"repoUrl": "https://github.com/f5-sales-demo/xcsh",
|
|
30
30
|
"repoSlug": "f5-sales-demo/xcsh",
|
|
31
|
-
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/
|
|
32
|
-
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.
|
|
31
|
+
"commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/d6ee0a02bee64b4deefa70ca26b25806055a526c",
|
|
32
|
+
"releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.19.0"
|
|
33
33
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// Auto-generated by scripts/generate-docs-index.ts - DO NOT EDIT
|
|
2
2
|
|
|
3
|
-
export const EMBEDDED_DOC_FILENAMES: readonly string[] = ["en/architecture-contribution/agent-session-runtime.mdx","en/architecture-contribution/build-release.mdx","en/architecture-contribution/extension-discovery.mdx","en/architecture-contribution/index.mdx","en/architecture-contribution/native-development.mdx","en/architecture-contribution/native-runtime.mdx","en/architecture-contribution/prompt-authoring.mdx","en/architecture-contribution/provider-streaming.mdx","en/architecture-contribution/storage-artifacts.mdx","en/architecture-contribution/tool-runtime.mdx","en/architecture-contribution/tui-runtime.mdx","en/architecture-contribution/upstream-pi.mdx","en/automate-extend/extensions-custom-tools.mdx","en/automate-extend/headless-protocols.mdx","en/automate-extend/hooks-rules.mdx","en/automate-extend/index.mdx","en/automate-extend/mcp-configuration.mdx","en/automate-extend/mcp-quickstart.mdx","en/automate-extend/mcp-runtime-authoring.mdx","en/automate-extend/plugins-marketplaces.mdx","en/automate-extend/sdk.mdx","en/automate-extend/skills.mdx","en/configure-secure/environment-reference.mdx","en/configure-secure/index.mdx","en/configure-secure/providers-routing.mdx","en/configure-secure/sandbox-boundaries.mdx","en/configure-secure/secrets-obfuscation.mdx","en/configure-secure/settings-files.mdx","en/f5-distributed-cloud/api-catalog.mdx","en/f5-distributed-cloud/console-automation.mdx","en/f5-distributed-cloud/contexts-namespaces.mdx","en/f5-distributed-cloud/create-apply-update.mdx","en/f5-distributed-cloud/get-export-delete.mdx","en/f5-distributed-cloud/index.mdx","en/f5-distributed-cloud/manifest-fundamentals.mdx","en/f5-distributed-cloud/validate-diff.mdx","en/getting-started/f5-xc-connection.mdx","en/getting-started/first-manifest.mdx","en/getting-started/index.mdx","en/getting-started/installation.mdx","en/getting-started/model-authentication.mdx","en/getting-started/quickstart.mdx","en/index.mdx","en/integrations-deployment/chrome.mdx","en/integrations-deployment/containers.mdx","en/integrations-deployment/herdr.mdx","en/integrations-deployment/index.mdx","en/integrations-deployment/office.mdx","en/integrations-deployment/vscode.mdx","en/reference-troubleshooting/cli-reference.mdx","en/reference-troubleshooting/configuration-schema.mdx","en/reference-troubleshooting/diagnostics.mdx","en/reference-troubleshooting/index.mdx","en/reference-troubleshooting/slash-keybindings.mdx","en/use-xcsh/agent-loop.mdx","en/use-xcsh/built-in-tools.mdx","en/use-xcsh/execution-modes.mdx","en/use-xcsh/index.mdx","en/use-xcsh/interactive-tui.mdx","en/use-xcsh/planning-agents.mdx","en/use-xcsh/sessions-memory.mdx","en/use-xcsh/tui-navigation.mdx"];
|
|
3
|
+
export const EMBEDDED_DOC_FILENAMES: readonly string[] = ["en/architecture-contribution/agent-session-runtime.mdx","en/architecture-contribution/build-release.mdx","en/architecture-contribution/extension-discovery.mdx","en/architecture-contribution/herdr-gap-closing-plan.mdx","en/architecture-contribution/index.mdx","en/architecture-contribution/native-development.mdx","en/architecture-contribution/native-runtime.mdx","en/architecture-contribution/prompt-authoring.mdx","en/architecture-contribution/provider-streaming.mdx","en/architecture-contribution/storage-artifacts.mdx","en/architecture-contribution/tool-runtime.mdx","en/architecture-contribution/tui-runtime.mdx","en/architecture-contribution/upstream-pi.mdx","en/automate-extend/extensions-custom-tools.mdx","en/automate-extend/headless-protocols.mdx","en/automate-extend/hooks-rules.mdx","en/automate-extend/index.mdx","en/automate-extend/mcp-configuration.mdx","en/automate-extend/mcp-quickstart.mdx","en/automate-extend/mcp-runtime-authoring.mdx","en/automate-extend/plugins-marketplaces.mdx","en/automate-extend/sdk.mdx","en/automate-extend/skills.mdx","en/configure-secure/environment-reference.mdx","en/configure-secure/index.mdx","en/configure-secure/providers-routing.mdx","en/configure-secure/sandbox-boundaries.mdx","en/configure-secure/secrets-obfuscation.mdx","en/configure-secure/settings-files.mdx","en/f5-distributed-cloud/api-catalog.mdx","en/f5-distributed-cloud/console-automation.mdx","en/f5-distributed-cloud/contexts-namespaces.mdx","en/f5-distributed-cloud/create-apply-update.mdx","en/f5-distributed-cloud/get-export-delete.mdx","en/f5-distributed-cloud/index.mdx","en/f5-distributed-cloud/manifest-fundamentals.mdx","en/f5-distributed-cloud/validate-diff.mdx","en/getting-started/f5-xc-connection.mdx","en/getting-started/first-manifest.mdx","en/getting-started/index.mdx","en/getting-started/installation.mdx","en/getting-started/model-authentication.mdx","en/getting-started/quickstart.mdx","en/index.mdx","en/integrations-deployment/chrome.mdx","en/integrations-deployment/containers.mdx","en/integrations-deployment/herdr.mdx","en/integrations-deployment/index.mdx","en/integrations-deployment/office.mdx","en/integrations-deployment/vscode.mdx","en/reference-troubleshooting/cli-reference.mdx","en/reference-troubleshooting/configuration-schema.mdx","en/reference-troubleshooting/diagnostics.mdx","en/reference-troubleshooting/index.mdx","en/reference-troubleshooting/slash-keybindings.mdx","en/use-xcsh/agent-loop.mdx","en/use-xcsh/built-in-tools.mdx","en/use-xcsh/execution-modes.mdx","en/use-xcsh/index.mdx","en/use-xcsh/interactive-tui.mdx","en/use-xcsh/planning-agents.mdx","en/use-xcsh/sessions-memory.mdx","en/use-xcsh/tui-navigation.mdx"];
|
|
4
4
|
|
|
5
5
|
export const EMBEDDED_DOCS: Readonly<Record<string, string>> = {
|
|
6
6
|
"en/architecture-contribution/agent-session-runtime.mdx": "---\ntitle: \"Agent loop and sessions\"\ndescription: \"Trace a user message through model selection, tool calls, append-only session state, compaction, and rendering.\"\nsidebar:\n order: 1\n label: \"Agent loop and sessions\"\n---\n\nThe command-line interface (CLI) parses arguments, resolves configuration and providers, creates a session, streams model events, dispatches tools, and renders the resulting entries.\n\n```text\nuser message\n -> cli.ts parse argv, resolve config and providers\n -> session factory create or resume the session\n -> provider stream AssistantMessageEvent deltas\n -> tool dispatch execute, append result, loop\n -> session JSONL append-only record\n -> renderer view of the appended state\n```\n\n## How do I trace a behavior?\n\nStart at `packages/coding-agent/src/cli.ts`, follow the session factory and event handlers, then inspect the persisted JSON Lines (JSONL) rather than relying only on terminal rendering. Provider and tool tests should assert the event sequence that caused the visible result.\n\n## Where does compaction act?\n\nCompaction transforms older conversation context before the next model turn; it does not rewrite the original session evidence. Test both the summary and subsequent message construction.\n",
|
|
7
7
|
"en/architecture-contribution/build-release.mdx": "---\ntitle: \"Build and release xcsh\"\ndescription: \"Set up the monorepo, run TypeScript and Rust checks, and understand signed multi-channel releases.\"\nsidebar:\n order: 11\n label: \"Build and release xcsh\"\n---\n\nThe repository is a Bun workspace with a Rust native layer. Follow `AGENTS.md`, `CONTRIBUTING.md`, and `DEVELOPING.md` before editing.\n\n## How do I prepare a contribution?\n\nCreate a detailed issue, branch from current `origin/main` in an isolated worktree, and run `bun install --frozen-lockfile`. Write a failing focused test for code behavior, implement the smallest fix, then run the package and repository checks.\n\n## Which checks matter before a pull request?\n\nRun each gate before you open the pull request:\n\n1. `bun run check` for formatting, linting, and types.\n2. `bun run test` for the package suites.\n3. `python3 scripts/check_docs_quality.py` when an English MDX file changed.\n4. The secret and personally identifiable information (PII) scans.\n5. The repository review gate.\n\nInspect the complete diff, then deliver only through a linked pull request.\n\n## How are releases produced?\n\nProtected workflows build and verify binaries, npm packages, Homebrew artifacts, containers, and downstream apt packaging. Contributors do not publish those channels manually.\n",
|
|
8
8
|
"en/architecture-contribution/extension-discovery.mdx": "---\ntitle: \"Extension discovery architecture\"\ndescription: \"Choose between skills, commands, tools, hooks, extensions, plugins, MCP, and SDK embedding.\"\nsidebar:\n order: 5\n label: \"Extension discovery\"\n---\n\nThe TypeScript runtime owns the agent loop, configuration, discovery, protocols, and most tools. The native Rust addon supplies performance-sensitive terminal, filesystem, and platform operations behind typed bindings.\n\n## How are capabilities discovered?\n\nDiscovery providers scan bundled, user, project, plugin, and compatible manifest roots, normalize candidates into capability items, and deduplicate stable identifiers by precedence. Extension entry resolution and dynamic module loading happen only after metadata discovery.\n\nInvalid frontmatter, manifests, or module factories produce diagnostics at their own layer so one bad optional capability does not masquerade as an empty catalog.\n\n## Where should a change go?\n\nPrefer a public extension, skill, plugin, Model Context Protocol (MCP) server, or software development kit (SDK) application programming interface (API) for optional behavior. Change the native layer only when a measured platform or performance requirement cannot be met in TypeScript.\n\n## How do I validate a boundary change?\n\nRun focused TypeScript tests for the caller and Rust tests for the native implementation, then build the addon and exercise the public command. Do not expose a native detail as a public contract accidentally.\n\nRead `packages/coding-agent/src/discovery` for the provider scan and deduplication, and `packages/coding-agent/src/capability` for the normalized capability items.\n",
|
|
9
|
+
"en/architecture-contribution/herdr-gap-closing-plan.mdx": "---\ntitle: \"Herdr native signaling gap-closing plan\"\ndescription: \"Plan native XCSH semantic-turn signaling through Herdr to durable Control Manager acceptance without treating process exit as success.\"\nsidebar:\n order: 3\n label: \"Herdr signaling plan\"\n---\n\n**Status: PLAN COMPLETE; XCSH FEATURE INCOMPLETE.** This is an implementation and acceptance plan, not evidence that the feature is implemented, installed, or accepted. Every required work package and closure gate remains open until its stated evidence is attached. Deferring a required item leaves the feature incomplete.\n\n## Current delivery checklist\n\n- [x] Plan reviewed and XCSH issue [#3768](https://github.com/f5-sales-demo/xcsh/issues/3768) created.\n- [x] XCSH protocol 19–20 negotiation, capability gate, persisted turn UUID, semantic producer, and focused unit tests implemented in the review worktree.\n- [x] Herdr tracked execution and semantic-journal source implemented with focused integration coverage and a passing local `just check`.\n- [ ] XCSH and Herdr changes committed, reviewed, CI-green, and merged under each repository's governance.\n- [ ] Reproducible release artifacts identify source SHA, hash, protocol, and capabilities.\n- [ ] Released artifacts installed through the supported update path with rollback recorded.\n- [ ] Control Manager native XCSH consumer and required-child aggregation implemented by its separate owner.\n- [ ] Real Manager-to-Herdr-to-XCSH success/failure/wait/cancel/reconnect/cleanup/restart UAT passes through durable result acknowledgment.\n- [ ] Overall feature accepted. This box cannot be checked by completing this worker or by deferring any required box above.\n\n## What is proven now?\n\n| Area | Evidence | Current conclusion |\n| --- | --- | --- |\n| XCSH producer | The review worktree contains uncommitted reporter changes and 52 previously passing focused tests. | Unit-only partial work. Its 80-character result preview is display metadata, not a durable semantic result. It is not installed or end-to-end tested. |\n| Protocol compatibility | `packages/coding-agent/src/herdr/client.ts` pins protocol 19 and requires exact equality. Installed `/usr/local/bin/herdr` reports `herdr 0.9.4`; `herdr api schema` reports protocol 20. | Current installed reporting is incompatible and can fail silently because reporter errors are nonfatal. Release blocker. |\n| Herdr execution tracking | Installed Herdr exposes native `execution start/get/list/wait/cancel`. Current source persists bounded output, revisions, process states, duplicate admission, and restart loss. | Authoritative process evidence, but process exit is not successful semantic turn completion. |\n| XCSH identity | Sessions persist and support `--continue`, `--resume`, and `--fork`; `TurnPhaseEvent.turnId` is a process-local counter. | Session continuation exists, but turn identity is not stable across restart/reconnect. |\n| Herdr XCSH resume | Current Herdr source accepts `(herdr:xcsh, xcsh)` path/ID references and plans `xcsh --resume=<value>`. | The prior source allow-list gap is closed. Installed-build provenance and live resume/fork remain unproven. |\n| Control Manager | Current source has a durable journal/outbox/direct acknowledgment, generations, and response correlation for existing worker types. | Durable primitives exist, but `WORK_KINDS` lacks XCSH, as do a native XCSH consumer and feature-level required-gate aggregation. |\n| Live acceptance | No workload, install, restart, or activation was performed for this planning task. | End-to-end parity is unproven and the feature remains incomplete. |\n\nThe installed Herdr binary inspected during planning had SHA-256 `c14df84087d3cd28e30c80d652c7fe42b73039497b771d454c9b1b69d36ceda`. A hash identifies that artifact but does not prove its source revision; closure requires reproducible build provenance.\n\n## Which invariants define parity?\n\nThree planes remain separate:\n\n1. **Herdr tracked execution** owns process admission, pane visibility, output drainage, exit/signal, cancellation request, and restart loss. It never translates exit zero, TUI idle, output silence, pane cleanup, or shutdown into semantic success.\n2. **XCSH semantic turns** own start, progress, waiting for input/approval, successful completion with bounded result, failure, cancellation, interruption, and continuation/fork identity.\n3. **Control Manager acceptance** owns durable task state, required-child aggregation, replay, supersession, delivery acknowledgment, and correlation of a visible response with the accepted result.\n\nCanonical identity is `(producer, session_id, turn_id, generation)`. The native persisted XCSH session supplies `session_id`. XCSH creates and persists `turn_id` before the first event and retains it across reconnect. `generation` distinguishes deliberate continuation/retry that supersedes older work. Pane/execution IDs are provenance, not semantic identity.\nManager task association must be validated against server-owned pane/execution context; a free-form client task ID is not trusted alone.\n\nEvents have a monotonic sequence/revision, state, timestamp, and optional bounded safe payload. Exact replay with the same identity, revision, and digest is idempotent; changed content at the same revision conflicts; older revisions cannot regress state. Terminal state is immutable, while a new generation may explicitly supersede it.\nRestart replays persisted events; unrecoverable active work becomes `interrupted`/`lost`, never `completed`.\n\n## What do statuses mean?\n\n| State | UI and Manager meaning | Required evidence |\n| --- | --- | --- |\n| `starting` | Turn identity is durable; work has not begun. | Created once before model/tool work. |\n| `working` | Turn is actively progressing. | May emit rate-limited progress or enter a wait. |\n| `waiting_input` | Human input/approval is required; neither failure nor completion. | Bounded safe reason; resumes to working or terminates by cancel/failure. |\n| `completed` | Native semantic settlement succeeded with a bounded result. | Emitted only after agent-end settlement, never inferred from idle/exit. |\n| `failed` | Semantic turn ended unsuccessfully. | Bounded safe reason; partial output cannot appear as success. |\n| `cancelled` | Requested cancellation reached terminal semantic state. | A cancellation request alone is not terminal evidence. |\n| `interrupted` / `lost` | Outcome cannot be proven. | Never success; requires continuation/retry or operator resolution. |\n| execution `exited` | Host process stopped; output drained or marked incomplete. | Process-only evidence, displayed separately from turn/task outcome. |\n\nUI surfaces show process state, semantic turn state, and feature acceptance independently. Display metadata may mirror safe status but is never an authoritative completion input.\n\n## Which ordered work packages close the gaps?\n\n1. **WP0 — Governed baselines and issue records (each project).** Preserve this worktree, base future implementation on current authoritative branches, and create issue-ready owner records from this plan. Record revisions, artifact identity, schemas, and acceptance criteria. Gate: clean isolated worktrees and approved issue links.\n2. **WP1 — Capability/protocol negotiation (XCSH, Herdr review).** Replace exact protocol 19 with an explicit supported range/set and capability discovery. Support 20 only after schema review; reject unknown versions visibly. Gate semantic calls on capability, not guesses. Dependency: WP0. Tests: supported 19/20 fixtures, old/future/malformed responses, visible failure.\n3. **WP2 — Durable turn identity (XCSH).** Persist a stable turn ID before work; retain it across reconnect/resume; allocate a new turn for a new prompt and distinct lineage for fork; define generations. Dependency: WP0. Tests: persistence, resume, fork, pre-event crash, collision.\n4. **WP3 — Durable semantic-turn contract (Herdr).** Add a supported report/query/wait API and journal for native agent turns. Persist identity, revision, state, bounded result/reason, digest, timestamps, and server-resolved provenance. Enforce idempotency, conflicts, monotonicity, terminal immutability, redaction, retention, replay, and restart loss. Dependencies: WP1/WP2 contract.\n Gate: Herdr tests and published schema/capability.\n5. **WP4 — Complete producer (XCSH).** Wire native lifecycle settlement—not rendering, idle, or shutdown—to WP3. Emit every semantic state with persisted identity. Keep short metadata as presentation only. Surface permanent delivery failure and use bounded ordered retry for transient failure. Dependencies: WP1–WP3. Gate: lifecycle/contract tests including forbidden false-success paths.\n6. **WP5 — Continuation/reconciliation (XCSH and Herdr).** Prove resume by path/ID, fork lineage, continuation after pane/process loss, output-drain ordering, and terminal reconciliation. Bind turns to admitted execution without making exit semantic. Dependencies: WP2–WP4. Gate: cross-process tests and installed provenance for the resume allow-list.\n7. **WP6 — Native XCSH worker and aggregate gates (Control Manager).** Add `xcsh` work kind through native Herdr execution; consume semantic revisions; persist accepted revision/digest; preserve all states; route cancel; continue the same session. Reuse durable journal/outbox/inbox and response correlation. Add required child/checklist gates so missing or deferred requirements keep parents incomplete.\n Do not require a wrapper/control-report workaround. Dependencies: WP3–WP5.\n Gate: mapping, replay, supersession, conflict, acknowledgment, and aggregation tests.\n8. **WP7 — Reproducible staged integration (all owners).** Pin source SHAs, produce versioned artifacts/checksums/schemas, then test in an isolated non-default Herdr environment and disposable Manager database. Dependencies: WP1–WP6. Gate: full matrix below with scrubbed retained evidence.\n9. **WP8 — Controlled activation/live acceptance (operations).** In an authorized maintenance window, verify no active work, install versioned artifacts, verify SHA/version/protocol/capabilities, restart only intended services, and run bounded live UAT. Roll back recorded binaries/config/data snapshot on health, replay, or mapping failure. Dependency: WP7.\n Gate: deployed identity plus live acknowledgment. No activation occurred here.\n\n## What end-to-end tests are required?\n\nEvery scenario traverses **Control Manager request → Herdr tracked execution → XCSH semantic events → Herdr durable turn journal → Manager journal/outbox/direct acknowledgment → correlated Manager response**, asserting semantic and process state separately.\n\n| Scenario | Required assertion |\n| --- | --- |\n| Simple success | Stable identity reaches `completed`; bounded result/digest survive pane cleanup and are acknowledged once. Exit remains separate. |\n| Failure | Native failure reaches `failed`; output or exit zero cannot convert it to success. |\n| Input/approval wait | Wait stays nonterminal through idle, resumes on the same turn, then completes/fails; parent remains incomplete while waiting. |\n| Cancellation | Request, signal, and terminal semantic cancellation are distinct; no completion appears. |\n| Continuation | Same session, new turn/generation; prior result remains queryable and is not redelivered. |\n| Reconnect | Disconnect before acknowledgment causes replay; exact duplicate is idempotent and correlated response arrives once. |\n| Pane cleanup | Cleanup preserves execution, semantic result, Manager journal, and pending acknowledgment. |\n| Component restart | Restart each component at defined cut points; terminal data replays and unrecoverable active work becomes interrupted/lost. Record retention/tombstone limits. |\n| Duplicate/conflict/order | Exact duplicate succeeds idempotently; changed digest at same revision conflicts; stale events cannot regress state; newer generation supersedes without erasing audit. |\n| Resume/fork | Resume path/ID retains session identity; fork has distinct lineage and cannot collide. |\n| Protocol mismatch | Supported capabilities work; unsupported/missing capability fails visibly before tracking is claimed. |\n| Aggregate completion | Only all-required evidence permits acceptance; failed, waiting, missing, or deferred required items keep it incomplete. Optional items do not block/reopen core. |\n\nUnit tests use deterministic clocks, persistence reopen, injected disconnects, and schema fixtures. Integration uses real local binaries with temporary state. Staged UAT uses an isolated Herdr environment before default. Live evidence records artifact hashes, capabilities, execution/session/turn IDs, revisions/digests, acknowledgments, and aggregate status without secrets/full transcripts.\n\n## How is completion gated?\n\n- **Plan deliverable done:** this reviewable plan. This is the only completed stage now.\n- **Implementation ready:** all required owner changes merged at recorded SHAs; no required item open/deferred.\n- **Tested:** unit, integration, durability, and negative tests pass against those SHAs.\n- **Installed:** deployed paths, hashes, schema, and capabilities match tested artifacts.\n- **Live verified:** full live matrix passes through durable acknowledgment, with rollback available.\n- **Overall feature accepted:** every required preceding gate has evidence. Any missing/deferred required item forces `INCOMPLETE`; a worker turn, plan, process, PR, or optimistic checklist cannot override it.\n\nManager computes parent status from required child/gate records, rejects `accepted` when evidence is absent, and reports exact blockers in UI/API. A completed planning worker turn means only that this plan was delivered.\n\nExternal phone rendering/audio-playback receipts are a separate optional enhancement explicitly deferred by the requester. They do not block or reopen accepted core Manager delivery, and cannot substitute for XCSH end-to-end evidence.\n\n## What decisions and risks need review?\n\n- **Recommended:** first-class durable Herdr semantic-turn journal; metadata cannot carry results, ordering, or restart guarantees.\n- **Recommended:** explicit capabilities and supported protocol set/range; accepting every newer version risks schema misinterpretation.\n- **Recommended:** server-bind task identity through execution/pane provenance and correlate Manager generation; do not trust free-form producer identity.\n- **Recommended:** immutable terminal events and new generations for continuation/retry.\n- **Risk:** current Herdr source is a dirty development worktree and installed binary lacks source provenance. Do not promote inspection to deployed evidence.\n- **Risk:** nonfatal reporter errors preserve XCSH use but hide tracking loss. Show degraded tracking and fail Manager acceptance closed.\n- **Risk:** retention/restart timing creates evidence gaps. Persist truncation/completeness/loss markers and block acceptance when evidence is missing.\n- **Risk:** cancellation races completion. Serialize final revision acceptance; audit later conflicts without changing the accepted result.\n",
|
|
9
10
|
"en/architecture-contribution/index.mdx": "---\ntitle: \"Architecture and contribution\"\ndescription: \"Understand xcsh internals, its pi lineage, native layer, extension boundaries, and contribution/release process.\"\nsidebar:\n order: 0\n label: \"Overview\"\n---\n\nUse these pages when changing xcsh itself rather than operating it.\n\n## Which implementation boundary matters?\n\n- [Agent loop and sessions](./agent-session-runtime/)\n- [Storage, blobs, and artifacts](./storage-artifacts/)\n- [Tool runtime](./tool-runtime/)\n- [Provider streaming](./provider-streaming/)\n- [Extension discovery](./extension-discovery/)\n- [Native runtime](./native-runtime/)\n- [Native development](./native-development/)\n- [Terminal user interface (TUI) runtime](./tui-runtime/)\n- [Relationship to upstream pi](./upstream-pi/)\n- [Prompt authoring](./prompt-authoring/)\n- [Build, test, contribute, and release](./build-release/)\n",
|
|
10
11
|
"en/architecture-contribution/native-development.mdx": "---\ntitle: \"Develop the native layer\"\ndescription: \"Choose native work deliberately, add a binding, build variants, test cancellation, and debug loader failures.\"\nsidebar:\n order: 7\n label: \"Native development\"\n---\n\nPort code to Rust only for measured performance, platform integration, or resource-control needs. Keep orchestration and product policy in TypeScript.\n\n## How do I add or change a native export?\n\nDefine the Rust implementation and Node-application programming interface (API) signature, expose it from the Rust package, update TypeScript declarations and wrappers, then extend validation and contract tests. Preserve the JavaScript fallback when the public contract requires one; otherwise fail explicitly when the addon is unavailable.\n\n## How do I build target variants?\n\nThe build pipeline selects target triples and optional hardware variants, compiles release artifacts, and packages names the loader can resolve. Environment flags affect the build target or diagnostics, not the public API. Test the ordinary target plus any variant whose resolution order changed.\n\n## How do I diagnose loading and cancellation?\n\nStart with the resolved candidate list, platform identity, file permissions, and `validateNative` mismatch. For asynchronous work, test cancellation before start, during execution, and after completion; a cancellation token must never resolve the same task twice.\n\nChange `crates/pi-natives/src` and `packages/natives` together; a signature that exists on only one side fails at load rather than at build.\n",
|
|
11
12
|
"en/architecture-contribution/native-runtime.mdx": "---\ntitle: \"Native runtime architecture\"\ndescription: \"Understand TypeScript wrappers, addon loading, Rust Node-API exports, binary selection, and binding validation.\"\nsidebar:\n order: 6\n label: \"Native runtime\"\n---\n\nThe public TypeScript layer owns ergonomic types and fallbacks. The loader selects a platform-specific addon, validates its exports, and exposes Rust Node-application programming interface (API) implementations for performance-sensitive work.\n\n## How is an addon selected and validated?\n\nResolution considers operating system, CPU architecture, and supported hardware variants before trying packaged and extracted binary candidates. Embedded binaries are materialized in a controlled cache. `validateNative` checks the runtime surface so a mismatched binary fails near loading instead of at an unrelated call.\n\n## How do I keep bindings synchronized?\n\nModule augmentation describes native exports to TypeScript, wrappers translate public inputs and outputs, and Rust functions implement the Node-API boundary. Synchronous and asynchronous variants must agree on names, data conversions, error shapes, and cancellation. Update all three layers and their contract tests together.\n\n## Which subsystems does the addon cover?\n\nThe addon covers terminal and pseudo-terminal (PTY) processes, filesystem scanning and text search, media/system utilities, and cancellable task primitives. Data crossing Node-API must have an explicit encoding and ownership rule; native tasks must release resources on both completion and cancellation.\n\n`PowerAssertion.start(options?)` returns an idempotently stoppable session handle. Its\n`PowerAssertionOptions` fields are `reason`, `idle`, `display`, `system`, and `user`; an omitted set\nof mode flags defaults to idle-sleep prevention. The implementation uses IOKit on macOS, login1\nand best-effort ScreenSaver inhibition on Linux, and a dedicated execution-state thread on Windows.\n\nRead `packages/natives` for the TypeScript wrappers and loader, and `crates/pi-natives/src` for the Rust implementations.\n",
|
|
@@ -48,7 +49,7 @@ export const EMBEDDED_DOCS: Readonly<Record<string, string>> = {
|
|
|
48
49
|
"en/index.mdx": "---\ntitle: xcsh\ndescription: Independent open-source agentic shell for terminal work and F5 Distributed Cloud workflows.\ntemplate: splash\neditUrl: false\nhero:\n tagline: An agentic shell for terminal work, extensible automation, and reviewable F5 Distributed Cloud resource workflows.\n image:\n html: '<img src=\"/xcsh/images/xcsh-workflow.svg\" alt=\"Prompt, tools, and F5 Distributed Cloud workflow\" width=\"560\" height=\"360\" />'\n actions:\n - text: Install xcsh\n link: /xcsh/en/getting-started/installation/\n icon: right-arrow\n variant: primary\n - text: Run the quickstart\n link: /xcsh/en/getting-started/quickstart/\n icon: rocket\nsidebar:\n hidden: true\n order: 0\nhead:\n - tag: style\n content: >-\n .hero img { width: min(100%, 35rem); height: auto; filter: drop-shadow(0 1rem 2.5rem color-mix(in srgb, var(--sl-color-accent) 28%, transparent)); }\n .hero h1 { text-wrap: balance; }\n---\n\nxcsh combines an interactive coding agent with deterministic F5 Distributed Cloud resource commands. It is an independent open-source project, not an F5 product.\n\n## Where should I start?\n\n- New installation: [install xcsh](./getting-started/installation/), then run the [quickstart](./getting-started/quickstart/).\n- F5 Distributed Cloud change: select a [context and namespace](./f5-distributed-cloud/contexts-namespaces/), then [validate and diff](./f5-distributed-cloud/validate-diff/).\n- Existing session: review the [interactive shell](./use-xcsh/interactive-tui/) and [session controls](./use-xcsh/sessions-memory/).\n- Automation: choose a [headless mode](./automate-extend/headless-protocols/) or use the [software development kit (SDK)](./automate-extend/sdk/).\n",
|
|
49
50
|
"en/integrations-deployment/chrome.mdx": "---\ntitle: \"Chrome\"\ndescription: \"Use the xcsh Chrome extension and native host with an isolated automation profile.\"\nsidebar:\n order: 3\n label: \"Chrome\"\n---\n\nThe Chrome integration connects xcsh to a browser session for supported console automation. The installed `xcsh chrome --help` output is the command authority.\n\n## What is the safe operating boundary?\n\nUse a dedicated profile and an authorized target. Confirm the visible account, uniform resource locator (URL), and object before an action that changes state. Prefer deterministic F5 Distributed Cloud resource commands whenever they cover the same operation.\n\n## Which Chrome capabilities does xcsh expose?\n\nThe `chrome` command inspects and arranges browser sessions, and `chrome-host` runs the native messaging host that connects the extension to the executable. Page-level interaction is driven by the browser tool inside a session rather than by a subcommand, so scope it with `--tools` in the same way as any other tool.\n",
|
|
50
51
|
"en/integrations-deployment/containers.mdx": "---\ntitle: \"Containers\"\ndescription: \"Run the published multi-architecture Alpine image with explicit mounts and credentials.\"\nsidebar:\n order: 4\n label: \"Containers\"\n---\n\nThe published container packages xcsh for process isolation and repeatable deployment. It does not grant cloud credentials or filesystem access by itself.\n\n## How do I verify an image?\n\n```bash\ndocker pull ghcr.io/f5-sales-demo/xcsh:latest\ndocker run --rm ghcr.io/f5-sales-demo/xcsh:latest --version\n```\n\nPin a version tag or digest for automation. Mount only the task directory and inject credentials through the runtime's secret mechanism.\n\n## What must remain outside the image?\n\nKeep user contexts, provider tokens, and writable session data in explicit mounts or secret stores. Do not bake them into a derived layer.\n",
|
|
51
|
-
"en/integrations-deployment/herdr.mdx": "---\ntitle: \"Integrate with Herdr\"\ndescription: \"Understand Herdr workspace launch, terminal actions, protocol negotiation, and isolation.\"\nsidebar:\n order: 5\n label: \"Herdr\"\n---\n\nHerdr support is optional and host-dependent. When the host does not provide it, xcsh terminal operation is unaffected.\n\n## How is the host protocol negotiated?\n\nThe integration checks the available socket protocol and media or graphics capabilities before it requests a workspace. Missing negotiation support leaves ordinary xcsh terminal operation intact.\n\n## How is a conversation-owned workspace launched?\n\nA workspace is tied to the conversation identity supplied at startup. Terminal-management actions create or address panes within that workspace, and lifecycle reporting stays anchored to the same startup context. Do not reuse an unrelated workspace merely because its socket is reachable.\n\n## How do I recover from socket failure?\n\nConnection and framing failures surface as integration diagnostics. The client must not open an inbound listener as a fallback. Close conversation-owned resources through the supported lifecycle and preserve unrelated Herdr workspaces.\n",
|
|
52
|
+
"en/integrations-deployment/herdr.mdx": "---\ntitle: \"Integrate with Herdr\"\ndescription: \"Understand Herdr workspace launch, terminal actions, protocol negotiation, and isolation.\"\nsidebar:\n order: 5\n label: \"Herdr\"\n---\n\nHerdr support is optional and host-dependent. When the host does not provide it, xcsh terminal operation is unaffected.\n\n## How is the host protocol negotiated?\n\nThe integration checks the available socket protocol and media or graphics capabilities before it requests a workspace. Missing negotiation support leaves ordinary xcsh terminal operation intact.\n\n## How is a conversation-owned workspace launched?\n\nA workspace is tied to the conversation identity supplied at startup. Terminal-management actions create or address panes within that workspace, and lifecycle reporting stays anchored to the same startup context. Do not reuse an unrelated workspace merely because its socket is reachable.\n\n## How do I recover from socket failure?\n\nConnection and framing failures surface as integration diagnostics. The client must not open an inbound listener as a fallback. Close conversation-owned resources through the supported lifecycle and preserve unrelated Herdr workspaces.\n\n## What lifecycle state does xcsh publish?\n\nXCSH publishes native turn phases rather than inferring completion from terminal idleness or process exit. With Herdr protocol 20 and the advertised `agent_turn_journal` capability, a tracked execution publishes a persisted session/turn identity and a bounded semantic result to Herdr's durable journal. The existing 80-character metadata preview remains display-only and is never completion evidence.\nCommentary, prompt content, tool data, and failed or cancelled partial output are excluded.\n\nSession shutdown releases pane authority. It does not convert an unfinished turn into a successful completion.\n\nThe verified contract is:\n\n| Concern | XCSH signal | Herdr disposition |\n| --- | --- | --- |\n| Session start and identity | Persisted native session ID/path | Herdr resume reference plus stable semantic session identity. |\n| Turn start/progress | Persisted UUID and normalized `turn_phase` | `starting`/`working` journal events with producer revision and server revision. |\n| Waiting for input/approval | `awaiting_user` and closed prompt kind | `waiting_input` with fixed safe reason; private prompt content is excluded. |\n| Successful completion | Settlement-aware `idle` after `agent_end` | `completed` with at most 8,000 UTF-8 bytes and a matching SHA-256 digest. |\n| Failure/cancellation | `error` or `cancelled` | Distinct terminal state and bounded safe reason; no partial result. |\n| Resume/fork | Session events and persisted custom turn entries | Resume preserves identity; unfinished recovered work becomes `interrupted`; fork has separate session lineage. |\n| Reconnect/order | Serialized queue and persisted event revision | Exact duplicates are idempotent; stale/conflicting revisions fail; terminal state is immutable. |\n| Application exit | `session_shutdown` | Active turn becomes `interrupted`, then pane authority is released; never success. |\n\nXCSH implementation is tracked by [issue #3768](https://github.com/f5-sales-demo/xcsh/issues/3768). The complete cross-project work packages and acceptance gates are in [Herdr native signaling gap-closing plan](../architecture-contribution/herdr-gap-closing-plan).\n\nHerdr lifecycle reconciliation is tracked by issue #5 in the F5 Herdr fork. Current source already recognizes the exact `(\"herdr:xcsh\", \"xcsh\")` resume pair; deployed build provenance and live resume/fork acceptance remain required before feature acceptance.\n",
|
|
52
53
|
"en/integrations-deployment/index.mdx": "---\ntitle: \"Integrations and deployment\"\ndescription: \"Deploy xcsh in containers and connect the editor, browser, Office, and Herdr surfaces.\"\nsidebar:\n order: 0\n label: \"Overview\"\n---\n\nChoose an integration by host, authority, and lifecycle boundary.\n\n## Which integration fits?\n\n- [Containers](./containers/) for an isolated packaged runtime.\n- [VS Code](./vscode/), [Chrome](./chrome/), [Office](./office/), or [Herdr](./herdr/) only when that companion surface is installed and the task needs it.\n",
|
|
53
54
|
"en/integrations-deployment/office.mdx": "---\ntitle: \"Microsoft Office task pane\"\ndescription: \"Serve or sideload the embedded task pane for Excel, Word, and PowerPoint.\"\nsidebar:\n order: 2\n label: \"Microsoft Office task pane\"\n---\n\nThe Office pane packages an xcsh sidebar for supported Excel, Word, and PowerPoint hosts. `xcsh office --help` describes the installed serve, print, and sideload actions.\n\n## Who owns the test surface?\n\nPackage tests own pane components, bridge messages, and host-independent state. Office-host integration tests own document application programming interfaces (APIs), sideloading, and task-pane lifecycle. A change that crosses the bridge requires both suites; a passing browser-style component test does not prove Word, Excel, or PowerPoint host behavior.\n\n## What must be running?\n\nThe pane build and its local bridge server must match the xcsh version used for the session. One active sidebar binds to one server session at a time.\n\n## Which host steps vary by platform?\n\nRibbon placement, the sideload mechanism, and trust prompts differ across Office on Windows, Office on macOS, and Office on the web. Read the sideload action from `xcsh office --help`, then follow the Microsoft sideloading procedure for the specific host you are targeting.\n",
|
|
54
55
|
"en/integrations-deployment/vscode.mdx": "---\ntitle: \"VS Code\"\ndescription: \"Use the companion VS Code integration with the same xcsh model and session foundation.\"\nsidebar:\n order: 1\n label: \"VS Code\"\n---\n\nThe companion VS Code extension embeds an xcsh conversation in an editor workspace. Its extension manifest and source repository define the supported commands and distribution channel.\n\n## What carries over from the terminal?\n\nProvider configuration, model selection, session concepts, and workspace file boundaries follow the xcsh runtime. Open the intended workspace before starting a conversation.\n\n## Which behavior should I validate in the terminal?\n\nEditor menus and command palette entries belong to the extension host and change with its release. Reproduce runtime behavior with the command-line interface (CLI) first:\n\n1. Run the same prompt with `xcsh -p` in the workspace directory.\n2. Compare the model, provider, and tool set reported there with the editor session.\n3. Inspect the persisted session file rather than the editor transcript when an exact sequence matters.\n\nA difference between the two points at extension configuration, not at the agent loop.\n",
|