@f5-sales-demo/xcsh 21.15.1 → 21.16.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.15.1",
4
+ "version": "21.16.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",
@@ -61,13 +61,13 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@agentclientprotocol/sdk": "1.3.0",
64
- "@f5-sales-demo/pi-agent-core": "21.15.1",
65
- "@f5-sales-demo/pi-ai": "21.15.1",
66
- "@f5-sales-demo/pi-natives": "21.15.1",
67
- "@f5-sales-demo/pi-resource-management": "21.15.1",
68
- "@f5-sales-demo/pi-tui": "21.15.1",
69
- "@f5-sales-demo/pi-utils": "21.15.1",
70
- "@f5-sales-demo/xcsh-stats": "21.15.1",
64
+ "@f5-sales-demo/pi-agent-core": "21.16.0",
65
+ "@f5-sales-demo/pi-ai": "21.16.0",
66
+ "@f5-sales-demo/pi-natives": "21.16.0",
67
+ "@f5-sales-demo/pi-resource-management": "21.16.0",
68
+ "@f5-sales-demo/pi-tui": "21.16.0",
69
+ "@f5-sales-demo/pi-utils": "21.16.0",
70
+ "@f5-sales-demo/xcsh-stats": "21.16.0",
71
71
  "@mozilla/readability": "^0.6",
72
72
  "@sinclair/typebox": "^0.34",
73
73
  "@xterm/headless": "^6.0",
@@ -46,7 +46,7 @@ export interface ExtensionCapabilities {
46
46
 
47
47
  export const EXTENSION_CAPABILITIES: ExtensionCapabilities = {
48
48
  "version": "0.1.0",
49
- "contractVersion": "2.1.0",
49
+ "contractVersion": "2.2.0",
50
50
  "multiPortDiscovery": true,
51
51
  "protocol": "tool_request/result",
52
52
  "tools": [
@@ -804,7 +804,9 @@ export const EXTENSION_CAPABILITIES: ExtensionCapabilities = {
804
804
  ],
805
805
  "messages": [
806
806
  "chat_request",
807
+ "chat_message_start",
807
808
  "chat_delta",
809
+ "chat_message_end",
808
810
  "chat_done",
809
811
  "chat_error",
810
812
  "chat_stop",
@@ -821,7 +823,7 @@ export const EXTENSION_CAPABILITIES: ExtensionCapabilities = {
821
823
  "media_asset_chunk",
822
824
  "media_asset_error"
823
825
  ],
824
- "description": "User ↔ xcsh chat over the bridge. The extension side panel sends chat_request (with mode and page-context snapshot); xcsh streams chat_delta tokens then a terminal chat_done (with reference links) or chat_error. Chat ids are prefixed \"c-\". Tool calls during a turn use the normal tool_request flow. chat_stop halts a streaming response. chat_tool_notice is emitted by the EXTENSION (the service worker) to the panel as a best-effort UI signal when a tool runs during a turn — it is NOT sent by xcsh; xcsh must not produce it to avoid double-rendering in the panel. Rich media uses chat_media descriptors and bounded media_asset_read/media_asset_chunk exchanges; media_asset_error reports unavailable assets.",
826
+ "description": "User ↔ xcsh chat over the bridge. The extension side panel sends chat_request (with mode and page-context snapshot); xcsh streams ordered assistant items using chat_message_start, correlated chat_delta tokens, and chat_message_end. Each item declares commentary or final_answer phase. Exactly one terminal chat_done (with reference links) or chat_error closes the whole turn. Chat ids are prefixed \"c-\". Tool calls during a turn use the normal tool_request flow. chat_stop halts a streaming response. chat_tool_notice is emitted by the EXTENSION (the service worker) to the panel as a best-effort UI signal when a tool runs during a turn — it is NOT sent by xcsh; xcsh must not produce it to avoid double-rendering in the panel. Rich media uses chat_media descriptors and bounded media_asset_read/media_asset_chunk exchanges; media_asset_error reports unavailable assets.",
825
827
  "promptHints": {
826
828
  "role": "You are xcsh, the AI assistant embedded in the F5 Distributed Cloud (XC) console side panel. The user is viewing a live console page; help them drive automation and understand settings and their purpose.",
827
829
  "grounding": "Every user message carries a page-context snapshot: url/path, title, a trimmed accessibility tree, and — when available — the live XC API resource JSON the page loaded (context.api.body). Treat context.api.body as the authoritative current state of the resource and ground answers in it instead of guessing; respect the truncated flags.",
@@ -839,6 +841,6 @@ export const EXTENSION_CAPABILITIES: ExtensionCapabilities = {
839
841
  }
840
842
  };
841
843
 
842
- export const EXTENSION_CONTRACT_VERSION = "2.1.0";
844
+ export const EXTENSION_CONTRACT_VERSION = "2.2.0";
843
845
 
844
846
  export const EXTENSION_TOOL_NAMES: readonly string[] = ["ping","capabilities","reload","debug_exec","detach","set_bridge_port","navigate","scroll_to","resize_window","tabs_list","tabs_create","tabs_close","click","click_element","click_xy","type_text","form_input","key_press","select_option","label_select","file_upload","read_ax","get_page_text","query_dom","find","wait_for","assert_text","screenshot","read_console","read_network","diag_suspension","diag_bridges","diag_activation","diag_ttft","wait_for_api_response","get_page_context","javascript_tool","browser_batch","set_explain_mode","annotate"];
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": "0.1.0",
3
- "contractVersion": "2.1.0",
3
+ "contractVersion": "2.2.0",
4
4
  "multiPortDiscovery": true,
5
5
  "protocol": "tool_request/result",
6
6
  "tools": [
@@ -758,7 +758,9 @@
758
758
  ],
759
759
  "messages": [
760
760
  "chat_request",
761
+ "chat_message_start",
761
762
  "chat_delta",
763
+ "chat_message_end",
762
764
  "chat_done",
763
765
  "chat_error",
764
766
  "chat_stop",
@@ -775,7 +777,7 @@
775
777
  "media_asset_chunk",
776
778
  "media_asset_error"
777
779
  ],
778
- "description": "User ↔ xcsh chat over the bridge. The extension side panel sends chat_request (with mode and page-context snapshot); xcsh streams chat_delta tokens then a terminal chat_done (with reference links) or chat_error. Chat ids are prefixed \"c-\". Tool calls during a turn use the normal tool_request flow. chat_stop halts a streaming response. chat_tool_notice is emitted by the EXTENSION (the service worker) to the panel as a best-effort UI signal when a tool runs during a turn — it is NOT sent by xcsh; xcsh must not produce it to avoid double-rendering in the panel. Rich media uses chat_media descriptors and bounded media_asset_read/media_asset_chunk exchanges; media_asset_error reports unavailable assets.",
780
+ "description": "User ↔ xcsh chat over the bridge. The extension side panel sends chat_request (with mode and page-context snapshot); xcsh streams ordered assistant items using chat_message_start, correlated chat_delta tokens, and chat_message_end. Each item declares commentary or final_answer phase. Exactly one terminal chat_done (with reference links) or chat_error closes the whole turn. Chat ids are prefixed \"c-\". Tool calls during a turn use the normal tool_request flow. chat_stop halts a streaming response. chat_tool_notice is emitted by the EXTENSION (the service worker) to the panel as a best-effort UI signal when a tool runs during a turn — it is NOT sent by xcsh; xcsh must not produce it to avoid double-rendering in the panel. Rich media uses chat_media descriptors and bounded media_asset_read/media_asset_chunk exchanges; media_asset_error reports unavailable assets.",
779
781
  "promptHints": {
780
782
  "role": "You are xcsh, the AI assistant embedded in the F5 Distributed Cloud (XC) console side panel. The user is viewing a live console page; help them drive automation and understand settings and their purpose.",
781
783
  "grounding": "Every user message carries a page-context snapshot: url/path, title, a trimmed accessibility tree, and — when available — the live XC API resource JSON the page loaded (context.api.body). Treat context.api.body as the authoritative current state of the resource and ground answers in it instead of guessing; respect the truncated flags.",
@@ -1,5 +1,5 @@
1
1
  {
2
- "contractVersion": "2.1.0",
2
+ "contractVersion": "2.2.0",
3
3
  "schemas": {
4
4
  "chat_request": {
5
5
  "type": "object",
@@ -180,11 +180,22 @@
180
180
  }
181
181
  }
182
182
  },
183
+ "chat_message_start": {
184
+ "type": "object",
185
+ "required": ["type", "id", "itemId", "phase"],
186
+ "properties": {
187
+ "type": { "const": "chat_message_start", "type": "string" },
188
+ "id": { "pattern": "^c-", "type": "string" },
189
+ "itemId": { "minLength": 1, "type": "string" },
190
+ "phase": { "enum": ["commentary", "final_answer"], "type": "string" }
191
+ }
192
+ },
183
193
  "chat_delta": {
184
194
  "type": "object",
185
195
  "required": [
186
196
  "type",
187
197
  "id",
198
+ "itemId",
188
199
  "seq",
189
200
  "delta"
190
201
  ],
@@ -197,6 +208,10 @@
197
208
  "pattern": "^c-",
198
209
  "type": "string"
199
210
  },
211
+ "itemId": {
212
+ "minLength": 1,
213
+ "type": "string"
214
+ },
200
215
  "seq": {
201
216
  "type": "number"
202
217
  },
@@ -205,6 +220,16 @@
205
220
  }
206
221
  }
207
222
  },
223
+ "chat_message_end": {
224
+ "type": "object",
225
+ "required": ["type", "id", "itemId", "phase"],
226
+ "properties": {
227
+ "type": { "const": "chat_message_end", "type": "string" },
228
+ "id": { "pattern": "^c-", "type": "string" },
229
+ "itemId": { "minLength": 1, "type": "string" },
230
+ "phase": { "enum": ["commentary", "final_answer"], "type": "string" }
231
+ }
232
+ },
208
233
  "chat_done": {
209
234
  "type": "object",
210
235
  "required": [
@@ -1179,18 +1204,32 @@
1179
1204
  "type": "chat_stop",
1180
1205
  "id": "c-1111"
1181
1206
  },
1207
+ "chat_message_start": {
1208
+ "type": "chat_message_start",
1209
+ "id": "c-1111",
1210
+ "itemId": "c-1111:assistant:0",
1211
+ "phase": "commentary"
1212
+ },
1182
1213
  "chat_delta": {
1183
1214
  "type": "chat_delta",
1184
1215
  "id": "c-1111",
1216
+ "itemId": "c-1111:assistant:0",
1185
1217
  "seq": 0,
1186
1218
  "delta": "This LB "
1187
1219
  },
1188
1220
  "chat_delta_1": {
1189
1221
  "type": "chat_delta",
1190
1222
  "id": "c-1111",
1223
+ "itemId": "c-1111:assistant:0",
1191
1224
  "seq": 1,
1192
1225
  "delta": "routes traffic."
1193
1226
  },
1227
+ "chat_message_end": {
1228
+ "type": "chat_message_end",
1229
+ "id": "c-1111",
1230
+ "itemId": "c-1111:assistant:0",
1231
+ "phase": "commentary"
1232
+ },
1194
1233
  "chat_done": {
1195
1234
  "type": "chat_done",
1196
1235
  "id": "c-1111",
@@ -1,6 +1,6 @@
1
1
  import * as fs from "node:fs";
2
2
  import * as path from "node:path";
3
- import type { AssistantMessage, ImageContent } from "@f5-sales-demo/pi-ai";
3
+ import type { AssistantMessage, AssistantMessagePhase, ImageContent } from "@f5-sales-demo/pi-ai";
4
4
  import { parseModelString } from "../config/model-resolver";
5
5
  import { settings } from "../config/settings";
6
6
  import { DEFAULT_MODEL_ROLE } from "../config/settings-schema";
@@ -29,6 +29,8 @@ import {
29
29
  type ChatErrorReason,
30
30
  type ChatKeepalive,
31
31
  type ChatMedia,
32
+ type ChatMessageEnd,
33
+ type ChatMessageStart,
32
34
  type ChatRequest,
33
35
  type Configure,
34
36
  type ConfigureAck,
@@ -77,7 +79,8 @@ export function shouldSendKeepalive(nowMs: number, lastKeepaliveAt: number): boo
77
79
 
78
80
  interface ActiveChat {
79
81
  id: string;
80
- seq: number;
82
+ items: Map<number, { itemId: string; phase: AssistantMessagePhase; seq: number }>;
83
+ nextItem: number;
81
84
  terminalSent: boolean;
82
85
  unsubscribe: () => void;
83
86
  entryAt: number;
@@ -215,7 +218,8 @@ export class ChatHandler {
215
218
 
216
219
  const chat: ActiveChat = {
217
220
  id,
218
- seq: 0,
221
+ items: new Map(),
222
+ nextItem: 0,
219
223
  terminalSent: false,
220
224
  unsubscribe: () => {},
221
225
  entryAt: Date.now(),
@@ -359,11 +363,44 @@ export class ChatHandler {
359
363
 
360
364
  if (event.type === "message_update" && "assistantMessageEvent" in event) {
361
365
  const ame = event.assistantMessageEvent;
362
- if (ame.type === "text_delta") {
366
+ if (ame.type === "text_start") {
367
+ const item = {
368
+ itemId: `${chat.id}:assistant:${chat.nextItem++}`,
369
+ phase: ame.phase ?? "final_answer",
370
+ seq: 0,
371
+ };
372
+ chat.items.set(ame.contentIndex, item);
373
+ this.#server.send({
374
+ type: "chat_message_start",
375
+ id: chat.id,
376
+ itemId: item.itemId,
377
+ phase: item.phase,
378
+ } satisfies ChatMessageStart);
379
+ } else if (ame.type === "text_delta") {
380
+ let item = chat.items.get(ame.contentIndex);
381
+ if (!item) {
382
+ // Legacy/synthetic streams can omit text_start (and older test or proxy
383
+ // emitters can omit partial entirely). Keep that compatibility path
384
+ // deterministic: missing metadata has final-answer semantics.
385
+ const content = ame.partial?.content?.[ame.contentIndex];
386
+ item = {
387
+ itemId: `${chat.id}:assistant:${chat.nextItem++}`,
388
+ phase: content?.type === "text" && content.phase === "commentary" ? "commentary" : "final_answer",
389
+ seq: 0,
390
+ };
391
+ chat.items.set(ame.contentIndex, item);
392
+ this.#server.send({
393
+ type: "chat_message_start",
394
+ id: chat.id,
395
+ itemId: item.itemId,
396
+ phase: item.phase,
397
+ } satisfies ChatMessageStart);
398
+ }
363
399
  this.#server.send({
364
400
  type: "chat_delta",
365
401
  id: chat.id,
366
- seq: chat.seq++,
402
+ itemId: item.itemId,
403
+ seq: item.seq++,
367
404
  delta: ame.delta,
368
405
  } satisfies ChatDelta);
369
406
  // TTFT Phase 2: first token out — emit the chat-segment spans once, keyed by
@@ -375,6 +412,18 @@ export class ChatHandler {
375
412
  this.#server.send(s);
376
413
  }
377
414
  }
415
+ } else if (ame.type === "text_end") {
416
+ const item = chat.items.get(ame.contentIndex);
417
+ if (item) {
418
+ item.phase = ame.phase ?? item.phase;
419
+ this.#server.send({
420
+ type: "chat_message_end",
421
+ id: chat.id,
422
+ itemId: item.itemId,
423
+ phase: item.phase,
424
+ } satisfies ChatMessageEnd);
425
+ chat.items.delete(ame.contentIndex);
426
+ }
378
427
  } else if (ame.type === "thinking_delta") {
379
428
  // LIVENESS: the model is streaming extended thinking before any visible
380
429
  // token. Emit a throttled chat_keepalive so the panel re-arms its
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Wire protocol types for the Chrome extension chat side window.
3
- * Contract source of truth: capabilities.json v2.1.0.
3
+ * Contract source of truth: capabilities.json v2.2.0.
4
4
  */
5
5
 
6
+ import type { AssistantMessagePhase } from "@f5-sales-demo/pi-ai";
6
7
  // Import the guards + wire types from the PURE leaf modules (not the `../host-tools`
7
8
  // barrel), so this browser-safe contract can be consumed by a lib.dom (React)
8
9
  // TypeScript program without pulling the RpcHostToolBridge's theme/tool-proxy graph.
@@ -198,13 +199,30 @@ export interface MediaAssetRead extends MediaAssetReadRequest {
198
199
  // Outbound messages (xcsh → extension)
199
200
  // ---------------------------------------------------------------------------
200
201
 
202
+ export type { AssistantMessagePhase };
203
+
204
+ export interface ChatMessageStart {
205
+ type: "chat_message_start";
206
+ id: string;
207
+ itemId: string;
208
+ phase: AssistantMessagePhase;
209
+ }
210
+
201
211
  export interface ChatDelta {
202
212
  type: "chat_delta";
203
213
  id: string;
214
+ itemId: string;
204
215
  seq: number;
205
216
  delta: string;
206
217
  }
207
218
 
219
+ export interface ChatMessageEnd {
220
+ type: "chat_message_end";
221
+ id: string;
222
+ itemId: string;
223
+ phase: AssistantMessagePhase;
224
+ }
225
+
208
226
  export interface ChatDone {
209
227
  type: "chat_done";
210
228
  id: string;
@@ -40,6 +40,12 @@ export interface HostProfile {
40
40
  systemPrompt: string;
41
41
  }
42
42
 
43
+ const COMMENTARY_POLICY = `COMMENTARY POLICY:
44
+ - No commentary for trivial no-tool work; answer directly.
45
+ - Before non-trivial tool work, emit one concise commentary sentence describing the immediate action.
46
+ - During long work, report meaningful progress at natural intervals and avoid roughly 60 seconds of unexplained silence.
47
+ - Do not narrate every routine read or command. Keep the final answer self-contained.`;
48
+
43
49
  /**
44
50
  * Chrome-extension self-awareness prompt. Injected when xcsh is serving a browser
45
51
  * chat (not the CLI TUI). Tells the LLM it's in a Chrome side panel alongside the
@@ -48,7 +54,9 @@ export interface HostProfile {
48
54
  export const CHROME_CHAT_SYSTEM_PROMPT = `<system-directive>
49
55
  You are still xcsh, the F5 Distributed Cloud technical coworker defined in your role above; this session is a Chrome side panel alongside the F5 XC console — an additional surface, not a new identity. Keep your xcsh/F5 purpose and adopt this browser context on top of it.
50
56
 
51
- CRITICAL: ALWAYS respond with TEXT FIRST. Do NOT jump straight to tool calls. The user sees a chat panel and expects a conversational text response, not silence while tools run in the background. For questions ("what page am I on?", "what is this?"), answer with text using the page context below — no tools needed. Only use tools when the user explicitly asks you to DO something (create, navigate, click, modify).
57
+ ${COMMENTARY_POLICY}
58
+
59
+ For questions ("what page am I on?", "what is this?"), answer with text using the page context below — no tools needed. Only use tools when the user explicitly asks you to DO something (create, navigate, click, modify).
52
60
 
53
61
  CONTEXT: The user sees a small chat window alongside the F5 XC admin console. You receive page-aware context each turn: the current URL (interpreted as workspace/resource/CRUD operation/namespace), the API resource JSON, and the accessibility tree. USE THIS CONTEXT to answer questions — don't call tools to find information you already have.
54
62
 
@@ -112,7 +120,9 @@ SAFETY:
112
120
  const EXCEL_CHAT_SYSTEM_PROMPT = `<system-directive>
113
121
  You are still xcsh, the F5 Distributed Cloud technical coworker defined in your role above. This session reaches you through a Microsoft Excel task pane instead of the terminal — an additional surface, not a new identity. Help the F5 SE with the OPEN workbook (often demo data, MEDDPICC sheets, account plans, pricing models) using the Excel host tools available to you. Keep your xcsh/F5 purpose AND adopt the Excel context on top of it.
114
122
 
115
- CRITICAL: ALWAYS respond with TEXT FIRST — the user sees a chat pane and expects a conversational reply, not silence while tools run. Answer questions from the data you read; only WRITE to the workbook when the user asks you to.
123
+ ${COMMENTARY_POLICY}
124
+
125
+ Answer questions from the data you read; only WRITE to the workbook when the user asks you to.
116
126
 
117
127
  CONTEXT: Your workspace centers on the open workbook. Think in cells, ranges, and — above all — FORMULAS and their dependencies:
118
128
  - Preserve formula relationships. When you change a cell, let dependent cells recompute; do not overwrite a formula with its current value unless asked.
@@ -143,7 +153,9 @@ BEHAVIOR:
143
153
  const POWERPOINT_CHAT_SYSTEM_PROMPT = `<system-directive>
144
154
  You are still xcsh, the F5 Distributed Cloud technical coworker defined in your role above. This session reaches you through a Microsoft PowerPoint task pane instead of the terminal — an additional surface, not a new identity. Help the F5 SE with the OPEN presentation (often a customer deck, demo walkthrough, or QBR) using the PowerPoint host tools available to you. Keep your xcsh/F5 purpose AND adopt the PowerPoint context on top of it.
145
155
 
146
- CRITICAL: ALWAYS respond with TEXT FIRST — the user sees a chat pane and expects a conversational reply, not silence while tools run. Answer questions from what you read; only edit the deck when the user asks you to.
156
+ ${COMMENTARY_POLICY}
157
+
158
+ Answer questions from what you read; only edit the deck when the user asks you to.
147
159
 
148
160
  CONTEXT: Your workspace centers on the open presentation. Think in slides, shapes, and the slide master:
149
161
  - Conform any new content to the deck's existing template, fonts, and colors — do not introduce a different look.
@@ -172,7 +184,9 @@ BEHAVIOR:
172
184
  const WORD_CHAT_SYSTEM_PROMPT = `<system-directive>
173
185
  You are still xcsh, the F5 Distributed Cloud technical coworker defined in your role above. This session reaches you through a Microsoft Word task pane instead of the terminal — an additional surface, not a new identity. Help the F5 SE with the OPEN document (often a proposal, SOW, discovery write-up, or technical brief) using the Word host tools available to you. Keep your xcsh/F5 purpose AND adopt the Word context on top of it.
174
186
 
175
- CRITICAL: ALWAYS respond with TEXT FIRST — the user sees a chat pane and expects a conversational reply, not silence while tools run. Answer questions from what you read; only edit the document when the user asks you to.
187
+ ${COMMENTARY_POLICY}
188
+
189
+ Answer questions from what you read; only edit the document when the user asks you to.
176
190
 
177
191
  CONTEXT: Your workspace centers on the open document. Think in paragraphs, the current selection, comments, and tracked changes:
178
192
  - Preserve the document's styles and numbering — do not flatten formatting.
@@ -17,17 +17,17 @@ export interface BuildInfo {
17
17
  }
18
18
 
19
19
  export const BUILD_INFO: BuildInfo = {
20
- "version": "21.15.1",
21
- "commit": "7b4768954fc15705b448863605d6c9d07099a309",
22
- "shortCommit": "7b47689",
20
+ "version": "21.16.0",
21
+ "commit": "2ee9c73e64d26cdd744468c74b92968709a8be86",
22
+ "shortCommit": "2ee9c73",
23
23
  "branch": "main",
24
- "tag": "v21.15.1",
25
- "commitDate": "2026-09-06T21:38:52+00:00",
26
- "buildDate": "2026-09-06T22:29:45.915Z",
24
+ "tag": "v21.16.0",
25
+ "commitDate": "2026-09-07T04:11:15+00:00",
26
+ "buildDate": "2026-09-07T05:10:58.140Z",
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/7b4768954fc15705b448863605d6c9d07099a309",
32
- "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.15.1"
31
+ "commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/2ee9c73e64d26cdd744468c74b92968709a8be86",
32
+ "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.16.0"
33
33
  };
@@ -1,4 +1,4 @@
1
1
  // Auto-generated by scripts/generate-extension-capabilities.ts - DO NOT EDIT
2
2
  // Source: src/browser/capabilities.json (the Chrome extension's published contract).
3
3
 
4
- export const EXTENSION_TOOL_REFERENCE = "# Chrome Extension Tool Signatures\n\nGenerated from extension capability contract `2.1.0`.\n\n## annotation\n\n### `annotate`\n\nDraw an overlay annotation (fingerprint/highlight). No-op unless explain mode is on.\n\n- Parameters: `{\"properties\":{\"h\":{\"type\":\"number\"},\"kind\":{\"type\":\"string\"},\"ref\":{\"type\":\"string\"},\"w\":{\"type\":\"number\"},\"x\":{\"type\":\"number\"},\"y\":{\"type\":\"number\"}},\"required\":[\"kind\"],\"type\":\"object\"}`\n- Semantic flags: `{\"requiresExplainMode\":true}`\n\n### `set_explain_mode`\n\nEnter/leave explain mode — the gate for all on-page annotation overlays.\n\n- Parameters: `{\"properties\":{\"enabled\":{\"type\":\"boolean\"}},\"type\":\"object\"}`\n- Semantic flags: `{}`\n\n## interaction\n\n### `click`\n\nDeterministic click of an AX-ref element (layout-engine coords + hit-test).\n\n- Parameters: `{\"properties\":{\"ref\":{\"type\":\"string\"}},\"required\":[\"ref\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `click_element`\n\nClick the element returned by a JS expression (polls; occlusion-safe).\n\n- Parameters: `{\"properties\":{\"js\":{\"type\":\"string\"},\"wait_ms\":{\"type\":\"number\"}},\"required\":[\"js\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `click_xy`\n\nTrusted click at explicit viewport coordinates.\n\n- Parameters: `{\"properties\":{\"x\":{\"type\":\"number\"},\"y\":{\"type\":\"number\"}},\"required\":[\"x\",\"y\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `file_upload`\n\nUpload files (base64 data URIs) to a file input by AX ref.\n\n- Parameters: `{\"properties\":{\"files\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"ref\":{\"type\":\"string\"}},\"required\":[\"ref\",\"files\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `form_input`\n\nSet a form field value by AX ref.\n\n- Parameters: `{\"properties\":{\"ref\":{\"type\":\"string\"},\"value\":{\"type\":\"string\"}},\"required\":[\"ref\",\"value\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `key_press`\n\nDispatch a key press.\n\n- Parameters: `{\"properties\":{\"key\":{\"type\":\"string\"}},\"required\":[\"key\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `label_select`\n\nType into a CDK-portal typeahead and click the matching option.\n\n- Parameters: `{\"properties\":{\"label_value\":{\"type\":\"string\"},\"selector\":{\"type\":\"string\"},\"value\":{\"type\":\"string\"},\"wait_ms\":{\"type\":\"number\"}},\"required\":[\"selector\",\"value\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `select_option`\n\nSelect an option in a native <select> by AX ref.\n\n- Parameters: `{\"properties\":{\"ref\":{\"type\":\"string\"},\"value\":{\"type\":\"string\"}},\"required\":[\"ref\",\"value\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `type_text`\n\nType text into the focused element (trusted input).\n\n- Parameters: `{\"properties\":{\"text\":{\"type\":\"string\"}},\"required\":[\"text\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n## meta\n\n### `capabilities`\n\nReturn this self-describing capability manifest (tools + features + versions).\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `debug_exec`\n\nDiagnostic: probe in-page bridge availability.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `detach`\n\nDetach the debugger from the target tab.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `ping`\n\nLiveness check; returns { ok, version }.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `reload`\n\nReload the extension (re-reads dist/ from disk).\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `set_bridge_port`\n\nSet the WebSocket bridge port (persists across reload; enables multi-session on different ports).\n\n- Parameters: `{\"properties\":{\"port\":{\"type\":\"number\"}},\"required\":[\"port\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n## navigation\n\n### `navigate`\n\nNavigate the console tab to a scoped https URL.\n\n- Parameters: `{\"properties\":{\"url\":{\"type\":\"string\"}},\"required\":[\"url\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `resize_window`\n\nResize the browser window.\n\n- Parameters: `{\"properties\":{\"height\":{\"type\":\"number\"},\"width\":{\"type\":\"number\"}},\"required\":[\"width\",\"height\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `scroll_to`\n\nScroll an AX-ref element into view.\n\n- Parameters: `{\"properties\":{\"ref\":{\"type\":\"string\"}},\"required\":[\"ref\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `tabs_close`\n\nClose a tab by id.\n\n- Parameters: `{\"properties\":{\"tabId\":{\"type\":\"number\"}},\"required\":[\"tabId\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `tabs_create`\n\nOpen a new tab at a scoped URL.\n\n- Parameters: `{\"properties\":{\"url\":{\"type\":\"string\"}},\"required\":[\"url\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `tabs_list`\n\nList scoped console tabs.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{}`\n\n## read\n\n### `assert_text`\n\nAssert an element contains expected text.\n\n- Parameters: `{\"properties\":{\"context\":{\"type\":\"string\"},\"expected\":{\"type\":\"string\"},\"selector\":{\"type\":\"string\"}},\"required\":[\"selector\",\"expected\"],\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `diag_activation`\n\nDiagnostic: per-gate tab-activation readiness timings (bridge/worker/page), cold/warm.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{}`\n\n### `diag_bridges`\n\nList discovered xcsh bridge health without tenant, environment, or session identifiers.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{}`\n\n### `diag_suspension`\n\nDiagnostic: SW-lifecycle event buffer + suspension summary (Phase 0a).\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{}`\n\n### `diag_ttft`\n\nDiagnostic: init→first-token timeline (per-stage ms, total, dominant, cold/warm).\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{}`\n\n### `find`\n\nFind AX nodes matching a locator.\n\n- Parameters: `{\"properties\":{\"selector\":{\"type\":\"string\"}},\"required\":[\"selector\"],\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `get_page_context`\n\nReturn a snapshot of the active console page (url, AX tree, captured XC API body) for chat grounding.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `get_page_text`\n\nReturn the page text.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `query_dom`\n\nDirect DOM.querySelector at wire speed — bypasses Runtime.evaluate for simple CSS selectors.\n\n- Parameters: `{\"properties\":{\"selector\":{\"type\":\"string\"}},\"required\":[\"selector\"],\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `read_ax`\n\nRead the accessibility tree of the page.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `read_console`\n\nRead buffered console messages, optionally filtered by pattern.\n\n- Parameters: `{\"properties\":{\"pattern\":{\"type\":\"string\"}},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `read_network`\n\nRead buffered network events, optionally filtered by pattern.\n\n- Parameters: `{\"properties\":{\"pattern\":{\"type\":\"string\"}},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `screenshot`\n\nCapture a screenshot (base64 PNG).\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `wait_for`\n\nWait for an AX node matching a locator to appear.\n\n- Parameters: `{\"properties\":{\"context\":{\"type\":\"string\"},\"selector\":{\"type\":\"string\"},\"timeoutMs\":{\"type\":\"number\"}},\"required\":[\"selector\"],\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `wait_for_api_response`\n\nWait for a network response whose URL matches a pattern.\n\n- Parameters: `{\"properties\":{\"pattern\":{\"type\":\"string\"},\"timeout_ms\":{\"type\":\"number\"}},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n## script\n\n### `browser_batch`\n\nRun a batch of { tool, params } actions in sequence.\n\n- Parameters: `{\"properties\":{\"actions\":{\"items\":{\"properties\":{\"params\":{},\"tool\":{\"type\":\"string\"}},\"required\":[\"tool\"],\"type\":\"object\"},\"type\":\"array\"}},\"required\":[\"actions\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `javascript_tool`\n\nEvaluate arbitrary JS in the page (length-capped).\n\n- Parameters: `{\"properties\":{\"code\":{\"type\":\"string\"}},\"required\":[\"code\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n";
4
+ export const EXTENSION_TOOL_REFERENCE = "# Chrome Extension Tool Signatures\n\nGenerated from extension capability contract `2.2.0`.\n\n## annotation\n\n### `annotate`\n\nDraw an overlay annotation (fingerprint/highlight). No-op unless explain mode is on.\n\n- Parameters: `{\"properties\":{\"h\":{\"type\":\"number\"},\"kind\":{\"type\":\"string\"},\"ref\":{\"type\":\"string\"},\"w\":{\"type\":\"number\"},\"x\":{\"type\":\"number\"},\"y\":{\"type\":\"number\"}},\"required\":[\"kind\"],\"type\":\"object\"}`\n- Semantic flags: `{\"requiresExplainMode\":true}`\n\n### `set_explain_mode`\n\nEnter/leave explain mode — the gate for all on-page annotation overlays.\n\n- Parameters: `{\"properties\":{\"enabled\":{\"type\":\"boolean\"}},\"type\":\"object\"}`\n- Semantic flags: `{}`\n\n## interaction\n\n### `click`\n\nDeterministic click of an AX-ref element (layout-engine coords + hit-test).\n\n- Parameters: `{\"properties\":{\"ref\":{\"type\":\"string\"}},\"required\":[\"ref\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `click_element`\n\nClick the element returned by a JS expression (polls; occlusion-safe).\n\n- Parameters: `{\"properties\":{\"js\":{\"type\":\"string\"},\"wait_ms\":{\"type\":\"number\"}},\"required\":[\"js\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `click_xy`\n\nTrusted click at explicit viewport coordinates.\n\n- Parameters: `{\"properties\":{\"x\":{\"type\":\"number\"},\"y\":{\"type\":\"number\"}},\"required\":[\"x\",\"y\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `file_upload`\n\nUpload files (base64 data URIs) to a file input by AX ref.\n\n- Parameters: `{\"properties\":{\"files\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"ref\":{\"type\":\"string\"}},\"required\":[\"ref\",\"files\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `form_input`\n\nSet a form field value by AX ref.\n\n- Parameters: `{\"properties\":{\"ref\":{\"type\":\"string\"},\"value\":{\"type\":\"string\"}},\"required\":[\"ref\",\"value\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `key_press`\n\nDispatch a key press.\n\n- Parameters: `{\"properties\":{\"key\":{\"type\":\"string\"}},\"required\":[\"key\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `label_select`\n\nType into a CDK-portal typeahead and click the matching option.\n\n- Parameters: `{\"properties\":{\"label_value\":{\"type\":\"string\"},\"selector\":{\"type\":\"string\"},\"value\":{\"type\":\"string\"},\"wait_ms\":{\"type\":\"number\"}},\"required\":[\"selector\",\"value\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `select_option`\n\nSelect an option in a native <select> by AX ref.\n\n- Parameters: `{\"properties\":{\"ref\":{\"type\":\"string\"},\"value\":{\"type\":\"string\"}},\"required\":[\"ref\",\"value\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `type_text`\n\nType text into the focused element (trusted input).\n\n- Parameters: `{\"properties\":{\"text\":{\"type\":\"string\"}},\"required\":[\"text\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n## meta\n\n### `capabilities`\n\nReturn this self-describing capability manifest (tools + features + versions).\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `debug_exec`\n\nDiagnostic: probe in-page bridge availability.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `detach`\n\nDetach the debugger from the target tab.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `ping`\n\nLiveness check; returns { ok, version }.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `reload`\n\nReload the extension (re-reads dist/ from disk).\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `set_bridge_port`\n\nSet the WebSocket bridge port (persists across reload; enables multi-session on different ports).\n\n- Parameters: `{\"properties\":{\"port\":{\"type\":\"number\"}},\"required\":[\"port\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n## navigation\n\n### `navigate`\n\nNavigate the console tab to a scoped https URL.\n\n- Parameters: `{\"properties\":{\"url\":{\"type\":\"string\"}},\"required\":[\"url\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `resize_window`\n\nResize the browser window.\n\n- Parameters: `{\"properties\":{\"height\":{\"type\":\"number\"},\"width\":{\"type\":\"number\"}},\"required\":[\"width\",\"height\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `scroll_to`\n\nScroll an AX-ref element into view.\n\n- Parameters: `{\"properties\":{\"ref\":{\"type\":\"string\"}},\"required\":[\"ref\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `tabs_close`\n\nClose a tab by id.\n\n- Parameters: `{\"properties\":{\"tabId\":{\"type\":\"number\"}},\"required\":[\"tabId\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `tabs_create`\n\nOpen a new tab at a scoped URL.\n\n- Parameters: `{\"properties\":{\"url\":{\"type\":\"string\"}},\"required\":[\"url\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `tabs_list`\n\nList scoped console tabs.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{}`\n\n## read\n\n### `assert_text`\n\nAssert an element contains expected text.\n\n- Parameters: `{\"properties\":{\"context\":{\"type\":\"string\"},\"expected\":{\"type\":\"string\"},\"selector\":{\"type\":\"string\"}},\"required\":[\"selector\",\"expected\"],\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `diag_activation`\n\nDiagnostic: per-gate tab-activation readiness timings (bridge/worker/page), cold/warm.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{}`\n\n### `diag_bridges`\n\nList discovered xcsh bridge health without tenant, environment, or session identifiers.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{}`\n\n### `diag_suspension`\n\nDiagnostic: SW-lifecycle event buffer + suspension summary (Phase 0a).\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{}`\n\n### `diag_ttft`\n\nDiagnostic: init→first-token timeline (per-stage ms, total, dominant, cold/warm).\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{}`\n\n### `find`\n\nFind AX nodes matching a locator.\n\n- Parameters: `{\"properties\":{\"selector\":{\"type\":\"string\"}},\"required\":[\"selector\"],\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `get_page_context`\n\nReturn a snapshot of the active console page (url, AX tree, captured XC API body) for chat grounding.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `get_page_text`\n\nReturn the page text.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `query_dom`\n\nDirect DOM.querySelector at wire speed — bypasses Runtime.evaluate for simple CSS selectors.\n\n- Parameters: `{\"properties\":{\"selector\":{\"type\":\"string\"}},\"required\":[\"selector\"],\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `read_ax`\n\nRead the accessibility tree of the page.\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `read_console`\n\nRead buffered console messages, optionally filtered by pattern.\n\n- Parameters: `{\"properties\":{\"pattern\":{\"type\":\"string\"}},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `read_network`\n\nRead buffered network events, optionally filtered by pattern.\n\n- Parameters: `{\"properties\":{\"pattern\":{\"type\":\"string\"}},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `screenshot`\n\nCapture a screenshot (base64 PNG).\n\n- Parameters: `{\"properties\":{},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `wait_for`\n\nWait for an AX node matching a locator to appear.\n\n- Parameters: `{\"properties\":{\"context\":{\"type\":\"string\"},\"selector\":{\"type\":\"string\"},\"timeoutMs\":{\"type\":\"number\"}},\"required\":[\"selector\"],\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n### `wait_for_api_response`\n\nWait for a network response whose URL matches a pattern.\n\n- Parameters: `{\"properties\":{\"pattern\":{\"type\":\"string\"},\"timeout_ms\":{\"type\":\"number\"}},\"type\":\"object\"}`\n- Semantic flags: `{\"readOnly\":true}`\n\n## script\n\n### `browser_batch`\n\nRun a batch of { tool, params } actions in sequence.\n\n- Parameters: `{\"properties\":{\"actions\":{\"items\":{\"properties\":{\"params\":{},\"tool\":{\"type\":\"string\"}},\"required\":[\"tool\"],\"type\":\"object\"},\"type\":\"array\"}},\"required\":[\"actions\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n\n### `javascript_tool`\n\nEvaluate arbitrary JS in the page (length-capped).\n\n- Parameters: `{\"properties\":{\"code\":{\"type\":\"string\"}},\"required\":[\"code\"],\"type\":\"object\"}`\n- Semantic flags: `{\"mutates\":true}`\n";
@@ -2,6 +2,7 @@ import type { AgentMessage } from "@f5-sales-demo/pi-agent-core";
2
2
  import { type AssistantMessage, type Context, streamSimple } from "@f5-sales-demo/pi-ai";
3
3
  import { prompt } from "@f5-sales-demo/pi-utils";
4
4
  import btwUserPrompt from "../../prompts/system/btw-user.md" with { type: "text" };
5
+ import { finalAnswerText } from "../../session/final-answer";
5
6
  import { toReasoningEffort } from "../../thinking";
6
7
  import { BtwPanelComponent } from "../components/btw-panel";
7
8
  import type { InteractiveModeContext } from "../types";
@@ -166,13 +167,7 @@ export class BtwController {
166
167
  }
167
168
 
168
169
  #assistantText(message: AssistantMessage): string {
169
- let text = "";
170
- for (const content of message.content) {
171
- if (content.type === "text") {
172
- text += content.text;
173
- }
174
- }
175
- return text.trim();
170
+ return finalAnswerText(message).trim();
176
171
  }
177
172
 
178
173
  #closeActiveRequest(options: { abort: boolean }): void {
@@ -221,6 +221,12 @@ export class EventController {
221
221
  if (this.ctx.streamingComponent && event.message.role === "assistant") {
222
222
  this.ctx.streamingMessage = event.message;
223
223
  this.ctx.streamingComponent.updateContent(this.ctx.streamingMessage);
224
+ if (
225
+ event.assistantMessageEvent.type === "text_end" &&
226
+ event.assistantMessageEvent.phase === "commentary"
227
+ ) {
228
+ this.ctx.streamingAssistantGutter?.setThinkingMode();
229
+ }
224
230
 
225
231
  const thinkingCount = this.ctx.streamingMessage.content.filter(
226
232
  content => content.type === "thinking" && content.thinking.trim(),
@@ -8,6 +8,7 @@
8
8
  import type { AgentMessage, ThinkingLevel } from "@f5-sales-demo/pi-agent-core";
9
9
  import type { AssistantMessage, ImageContent, Model } from "@f5-sales-demo/pi-ai";
10
10
  import type { AgentSession, AgentSessionEvent } from "../session/agent-session";
11
+ import { finalAnswerText } from "../session/final-answer";
11
12
  import type { SessionHeader } from "../session/session-manager";
12
13
 
13
14
  /**
@@ -210,11 +211,8 @@ export async function runPrintMode(session: AgentSession, options: PrintModeOpti
210
211
  if (failed) {
211
212
  process.stderr.write(`${assistantMsg.errorMessage || `Request ${assistantMsg.stopReason}`}\n`);
212
213
  } else {
213
- for (const content of assistantMsg.content) {
214
- if (content.type === "text") {
215
- process.stdout.write(`${content.text}\n`);
216
- }
217
- }
214
+ const text = finalAnswerText(assistantMsg);
215
+ if (text) process.stdout.write(`${text}\n`);
218
216
  }
219
217
  }
220
218
 
@@ -77,6 +77,10 @@ The SE decides what to do; evidence decides what is true. See `<epistemic-integr
77
77
  - (1) Correctness first, (2) Brevity second, (3) Politeness third.
78
78
  - Prefer concise, information-dense writing.
79
79
  - Avoid repeating the user's request or narrating routine tool calls.
80
+ - No commentary for trivial no-tool work: answer directly.
81
+ - Before non-trivial tool work, emit one concise commentary sentence describing the immediate action.
82
+ - During long work, report meaningful progress at natural intervals; avoid roughly 60 seconds of unexplained silence without narrating every routine read or command.
83
+ - Keep the final answer self-contained. Commentary is progress, never the terminal answer.
80
84
  - When producing customer-facing content, maintain a professional tone appropriate to the audience.
81
85
  </communication>
82
86
 
@@ -167,6 +167,7 @@ import {
167
167
  shouldCompact,
168
168
  } from "./compaction";
169
169
  import { DEFAULT_PRUNE_CONFIG, pruneToolOutputs } from "./compaction/pruning";
170
+ import { finalAnswerText } from "./final-answer";
170
171
  import {
171
172
  type BashExecutionMessage,
172
173
  type CompactionSummaryMessage,
@@ -7572,14 +7573,7 @@ export class AgentSession {
7572
7573
 
7573
7574
  if (!lastAssistant) return undefined;
7574
7575
 
7575
- let text = "";
7576
- for (const content of (lastAssistant as AssistantMessage).content) {
7577
- if (content.type === "text") {
7578
- text += content.text;
7579
- }
7580
- }
7581
-
7582
- return text.trim() || undefined;
7576
+ return finalAnswerText(lastAssistant as AssistantMessage).trim() || undefined;
7583
7577
  }
7584
7578
 
7585
7579
  /**
@@ -0,0 +1,15 @@
1
+ import type { AssistantMessage, TextContent } from "@f5-sales-demo/pi-ai";
2
+
3
+ /** Missing phase intentionally follows Codex's final-answer fallback. */
4
+ export function isFinalAnswerContent(content: TextContent): boolean {
5
+ return content.phase !== "commentary";
6
+ }
7
+
8
+ /** Select only terminal answer text; commentary remains available on the message transcript. */
9
+ export function finalAnswerText(message: AssistantMessage): string {
10
+ return message.content
11
+ .filter((content): content is TextContent => content.type === "text" && isFinalAnswerContent(content))
12
+ .map(content => content.text)
13
+ .filter(Boolean)
14
+ .join("\n");
15
+ }