@f5-sales-demo/xcsh 21.14.1 → 21.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -40,6 +40,12 @@
40
40
 
41
41
  ### Fixed
42
42
 
43
+ - Prevented malformed task `submit_result` data, non-string write content, and invalid renderer path
44
+ values from crashing task, read, write, edit, inspect-image, or browser output. Semantically
45
+ ported from [can1357/oh-my-pi#1989](https://github.com/can1357/oh-my-pi/pull/1989),
46
+ [#4497](https://github.com/can1357/oh-my-pi/pull/4497), and
47
+ [#4529](https://github.com/can1357/oh-my-pi/pull/4529)
48
+ ([#3743](https://github.com/f5-sales-demo/xcsh/issues/3743)).
43
49
  - Preserved MCP `structuredContent` through the shared tool bridge, avoided duplicate verbatim
44
50
  payloads, and rendered every text block. Semantically ported from
45
51
  [can1357/oh-my-pi#10523](https://github.com/can1357/oh-my-pi/pull/10523)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@f5-sales-demo/xcsh",
4
- "version": "21.14.1",
4
+ "version": "21.15.1",
5
5
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
6
6
  "homepage": "https://github.com/f5-sales-demo/xcsh",
7
7
  "author": "Can Boluk",
@@ -61,13 +61,13 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@agentclientprotocol/sdk": "1.3.0",
64
- "@f5-sales-demo/pi-agent-core": "21.14.1",
65
- "@f5-sales-demo/pi-ai": "21.14.1",
66
- "@f5-sales-demo/pi-natives": "21.14.1",
67
- "@f5-sales-demo/pi-resource-management": "21.14.1",
68
- "@f5-sales-demo/pi-tui": "21.14.1",
69
- "@f5-sales-demo/pi-utils": "21.14.1",
70
- "@f5-sales-demo/xcsh-stats": "21.14.1",
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",
71
71
  "@mozilla/readability": "^0.6",
72
72
  "@sinclair/typebox": "^0.34",
73
73
  "@xterm/headless": "^6.0",
@@ -92,15 +92,15 @@ export interface EditToolDetails {
92
92
  // ═══════════════════════════════════════════════════════════════════════════
93
93
 
94
94
  interface EditRenderArgs {
95
- path?: string;
96
- file_path?: string;
95
+ path?: unknown;
96
+ file_path?: unknown;
97
97
  oldText?: string;
98
98
  newText?: string;
99
99
  patch?: string;
100
100
  all?: boolean;
101
101
  // Patch mode fields
102
102
  op?: Operation;
103
- rename?: string;
103
+ rename?: unknown;
104
104
  diff?: string;
105
105
  /**
106
106
  * Computed preview diff (used when tool args don't include a diff, e.g. hashline mode).
@@ -154,8 +154,8 @@ interface FormattedStreamingEdit {
154
154
  }
155
155
 
156
156
  /** Extract file path from an edit entry's path (handles chunk's file:selector format). */
157
- function filePathFromEditEntry(p: string | undefined): string | undefined {
158
- if (!p) return undefined;
157
+ function filePathFromEditEntry(p: unknown): string | undefined {
158
+ if (typeof p !== "string" || !p) return undefined;
159
159
  const ci = /^[a-zA-Z]:[/\\]/.test(p) ? p.indexOf(":", 2) : p.indexOf(":");
160
160
  return ci === -1 ? p : p.slice(0, ci);
161
161
  }
@@ -441,8 +441,15 @@ export const editToolRenderer = {
441
441
 
442
442
  // Extract path from first edit entry when top-level path is absent (new schema)
443
443
  const firstEdit = Array.isArray(args.edits) && args.edits.length > 0 ? args.edits[0] : undefined;
444
- const rawPath = args.file_path || args.path || (firstEdit as any)?.path || "";
445
- const rename = args.rename || (firstEdit as any)?.rename;
444
+ const rawPath =
445
+ typeof args.file_path === "string"
446
+ ? args.file_path
447
+ : typeof args.path === "string"
448
+ ? args.path
449
+ : (filePathFromEditEntry((firstEdit as { path?: unknown } | undefined)?.path) ?? "");
450
+ const rename =
451
+ (typeof args.rename === "string" ? args.rename : undefined) ??
452
+ filePathFromEditEntry((firstEdit as { rename?: unknown } | undefined)?.rename);
446
453
  const op = args.op || (firstEdit as any)?.op;
447
454
  const { description } = formatEditDescription(rawPath, uiTheme, { rename });
448
455
  const spinner =
@@ -498,9 +505,17 @@ function renderSingleFileResult(
498
505
  ): Component {
499
506
  const details = result.details;
500
507
  const isError = result.isError ?? (details && "isError" in details ? details.isError : false);
501
- const rawPath = args?.file_path || args?.path || (details && "path" in details ? details.path : "") || "";
508
+ const detailPath = details && "path" in details && typeof details.path === "string" ? details.path : undefined;
509
+ const rawPath =
510
+ typeof args?.file_path === "string"
511
+ ? args.file_path
512
+ : typeof args?.path === "string"
513
+ ? args.path
514
+ : (detailPath ?? "");
502
515
  const op = args?.op || details?.op;
503
- const rename = args?.rename || details?.move;
516
+ const rename =
517
+ (typeof args?.rename === "string" ? args.rename : undefined) ??
518
+ (details && "move" in details && typeof details.move === "string" ? details.move : undefined);
504
519
  const { language } = formatEditDescription(rawPath, uiTheme, { rename });
505
520
 
506
521
  const metadataLine =
@@ -150,6 +150,9 @@ export default function herdrReporter(pi: ExtensionAPI): void {
150
150
  // Retains the fixed reason while an interactive prompt awaits the user, so an
151
151
  // agent_end duplicate cannot erase herdr's stored blocked message.
152
152
  let promptBlockedReason: string | undefined;
153
+ // Once the normalized contract is observed it is authoritative. The legacy
154
+ // event mappings remain only for older hosts that load this bundled extension.
155
+ let normalizedPhasesObserved = false;
153
156
  // Last session ref already delivered, so repeated lifecycle events do not
154
157
  // re-send an unchanged ref every turn.
155
158
  let lastSessionRefKey: string | undefined;
@@ -263,9 +266,9 @@ export default function herdrReporter(pi: ExtensionAPI): void {
263
266
  return enqueue(() => sendToHerdrSocket(socketPath, METADATA_METHOD, frame, onError));
264
267
  };
265
268
 
266
- const setPhaseLabel = (label: string): Promise<void> =>
269
+ const setPhaseLabel = (label: string, state: "idle" | "working" | "blocked" = "working"): Promise<void> =>
267
270
  reportMetadata({
268
- state_labels: { working: label },
271
+ state_labels: { [state]: label },
269
272
  ttl_ms: PHASE_LABEL_TTL_MS,
270
273
  });
271
274
 
@@ -353,7 +356,7 @@ export default function herdrReporter(pi: ExtensionAPI): void {
353
356
  // in case the active session file changed (e.g. after /new, /resume, or /fork).
354
357
  pi.on("agent_start", async (_event, ctx) => {
355
358
  clearSettledTurnReconcile();
356
- await report("working");
359
+ if (!normalizedPhasesObserved) await report("working");
357
360
  await reportSession(ctx);
358
361
  });
359
362
 
@@ -361,35 +364,51 @@ export default function herdrReporter(pi: ExtensionAPI): void {
361
364
  // This is also the first point where a lazily-created session file is certain
362
365
  // to exist, so it is the backstop for capturing the resume ref.
363
366
  pi.on("agent_end", async (_event, ctx) => {
364
- await report(promptBlockedReason ? "blocked" : "idle", promptBlockedReason);
367
+ if (!normalizedPhasesObserved) await report(promptBlockedReason ? "blocked" : "idle", promptBlockedReason);
365
368
  await reportSession(ctx);
366
369
  });
367
370
 
368
371
  // Reconcile completion after the UI has had a chance to clear its streaming
369
372
  // flag. This is deliberately non-blocking so it cannot delay the next turn.
370
373
  pi.on("turn_end", (_event, ctx) => {
371
- scheduleSettledTurnReconcile(ctx);
374
+ if (!normalizedPhasesObserved) scheduleSettledTurnReconcile(ctx);
372
375
  });
373
376
 
374
377
  // An interactive prompt (permission gate, ask tool, confirm/input) is
375
378
  // awaiting the user: that is herdr's "needs attention" (blocked) state.
376
379
  pi.on("user_prompt_start", async event => {
377
380
  promptBlockedReason = getPromptBlockedReason(event.kind);
378
- void report("blocked", promptBlockedReason);
379
- await clearPhaseLabel();
381
+ if (!normalizedPhasesObserved) {
382
+ void report("blocked", promptBlockedReason);
383
+ await clearPhaseLabel();
384
+ }
380
385
  });
381
386
 
382
387
  pi.on("user_prompt_end", async (_event, ctx) => {
383
388
  promptBlockedReason = undefined;
384
- await report(ctx.isIdle() ? "idle" : "working");
389
+ if (!normalizedPhasesObserved) await report(ctx.isIdle() ? "idle" : "working");
385
390
  await reportSession(ctx);
386
- if (!ctx.isIdle()) {
391
+ if (!normalizedPhasesObserved && !ctx.isIdle()) {
387
392
  await setPhaseLabel("tool");
388
393
  }
389
394
  });
390
395
 
396
+ pi.on("turn_phase", async (event, ctx) => {
397
+ normalizedPhasesObserved = true;
398
+ const state =
399
+ event.phase === "awaiting_user"
400
+ ? "blocked"
401
+ : event.phase === "submitting" || event.phase === "thinking" || event.phase === "tool_call"
402
+ ? "working"
403
+ : "idle";
404
+ await report(state, event.phase === "awaiting_user" ? "user input required" : undefined);
405
+ await setPhaseLabel(event.phase, state);
406
+ await reportSession(ctx);
407
+ });
408
+
391
409
  // Transient phase-label metadata (thinking / tool / retry / cleanup):
392
410
  pi.on("message_update", async event => {
411
+ if (normalizedPhasesObserved) return;
393
412
  if (event.assistantMessageEvent.type === "thinking_start") {
394
413
  await setPhaseLabel("thinking");
395
414
  } else if (event.assistantMessageEvent.type === "thinking_end") {
@@ -398,26 +417,32 @@ export default function herdrReporter(pi: ExtensionAPI): void {
398
417
  });
399
418
 
400
419
  pi.on("tool_execution_start", async () => {
420
+ if (normalizedPhasesObserved) return;
401
421
  await setPhaseLabel("tool");
402
422
  });
403
423
 
404
424
  pi.on("tool_execution_end", async () => {
425
+ if (normalizedPhasesObserved) return;
405
426
  await clearPhaseLabel();
406
427
  });
407
428
 
408
429
  pi.on("auto_retry_start", async () => {
430
+ if (normalizedPhasesObserved) return;
409
431
  await setPhaseLabel("retry");
410
432
  });
411
433
 
412
434
  pi.on("auto_retry_end", async () => {
435
+ if (normalizedPhasesObserved) return;
413
436
  await clearPhaseLabel();
414
437
  });
415
438
 
416
439
  pi.on("auto_compaction_start", async () => {
440
+ if (normalizedPhasesObserved) return;
417
441
  await setPhaseLabel("cleanup");
418
442
  });
419
443
 
420
444
  pi.on("auto_compaction_end", async () => {
445
+ if (normalizedPhasesObserved) return;
421
446
  await clearPhaseLabel();
422
447
  });
423
448
 
@@ -46,6 +46,7 @@ import type {
46
46
  SessionEntry,
47
47
  SessionManager,
48
48
  } from "../../session/session-manager";
49
+ import type { NormalizedTurnPhase } from "../../session/turn-phase";
49
50
  import type {
50
51
  BashToolDetails,
51
52
  BashToolInput,
@@ -63,6 +64,7 @@ import type { SlashCommandInfo } from "../slash-commands";
63
64
 
64
65
  export type { AppKeybinding, KeybindingsManager } from "../../config/keybindings";
65
66
  export type { ExecOptions, ExecResult } from "../../exec/exec";
67
+ export type { NormalizedTurnPhase } from "../../session/turn-phase";
66
68
  export type { AgentToolResult, AgentToolUpdateCallback };
67
69
 
68
70
  // ============================================================================
@@ -560,6 +562,13 @@ export interface UserPromptEndEvent {
560
562
  kind: UserPromptKind;
561
563
  }
562
564
 
565
+ /** Provider-neutral, payload-free turn status shared by the TUI and external reporters. */
566
+ export interface TurnPhaseEvent {
567
+ type: "turn_phase";
568
+ phase: NormalizedTurnPhase;
569
+ turnId: number;
570
+ }
571
+
563
572
  /** Fired when a tool starts executing */
564
573
  export interface ToolExecutionStartEvent {
565
574
  type: "tool_execution_start";
@@ -838,6 +847,7 @@ export type ExtensionEvent =
838
847
  | MessageEndEvent
839
848
  | UserPromptStartEvent
840
849
  | UserPromptEndEvent
850
+ | TurnPhaseEvent
841
851
  | ToolExecutionStartEvent
842
852
  | ToolExecutionUpdateEvent
843
853
  | ToolExecutionEndEvent
@@ -1034,6 +1044,7 @@ export interface ExtensionAPI {
1034
1044
  on(event: "message_end", handler: ExtensionHandler<MessageEndEvent>): void;
1035
1045
  on(event: "user_prompt_start", handler: ExtensionHandler<UserPromptStartEvent>): void;
1036
1046
  on(event: "user_prompt_end", handler: ExtensionHandler<UserPromptEndEvent>): void;
1047
+ on(event: "turn_phase", handler: ExtensionHandler<TurnPhaseEvent>): void;
1037
1048
  on(event: "tool_execution_start", handler: ExtensionHandler<ToolExecutionStartEvent>): void;
1038
1049
  on(event: "tool_execution_update", handler: ExtensionHandler<ToolExecutionUpdateEvent>): void;
1039
1050
  on(event: "tool_execution_end", handler: ExtensionHandler<ToolExecutionEndEvent>): void;
@@ -17,17 +17,17 @@ export interface BuildInfo {
17
17
  }
18
18
 
19
19
  export const BUILD_INFO: BuildInfo = {
20
- "version": "21.14.1",
21
- "commit": "66c1fc7bceccd9f8fa1b2aee69a3c08cd7aed25a",
22
- "shortCommit": "66c1fc7",
20
+ "version": "21.15.1",
21
+ "commit": "7b4768954fc15705b448863605d6c9d07099a309",
22
+ "shortCommit": "7b47689",
23
23
  "branch": "main",
24
- "tag": "v21.14.1",
25
- "commitDate": "2026-09-06T17:46:30+00:00",
26
- "buildDate": "2026-09-06T19:00:27.042Z",
24
+ "tag": "v21.15.1",
25
+ "commitDate": "2026-09-06T21:38:52+00:00",
26
+ "buildDate": "2026-09-06T22:29:45.915Z",
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/66c1fc7bceccd9f8fa1b2aee69a3c08cd7aed25a",
32
- "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.14.1"
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"
33
33
  };
@@ -14,7 +14,7 @@ export const EMBEDDED_DOCS: Readonly<Record<string, string>> = {
14
14
  "en/architecture-contribution/storage-artifacts.mdx": "---\ntitle: \"Storage, blobs, and artifacts\"\ndescription: \"Trace configuration roots, session JSONL, binary blobs, text artifacts, scan caches, and move semantics.\"\nsidebar:\n order: 2\n label: \"Storage and artifacts\"\n---\n\nxcsh separates append-only conversation state from large or generated payloads. Session JSON Lines (JSONL) preserves the event graph; blob and artifact stores keep bulky data addressable without inflating every session entry.\n\n## How are stored values allocated and resolved?\n\nStorage helpers choose user or project roots, allocate collision-resistant identifiers, and record names separately from content addresses. Text artifacts remain inspectable; binary blobs are externalized and referenced by uniform resource locator (URL)-like identifiers. URL handlers validate the scheme and authority before opening the backing object.\n\n## How do resume, fork, and move treat state?\n\nResume rebuilds context from the selected session leaf. Forking creates a new branch without rewriting the source branch. Moves must update the session reference and its dependent stored values as one operation or leave the original valid; partial copies are not a successful move.\n\n## How is filesystem discovery cached?\n\nThe scan cache partitions keys by root and discovery options, evicts by freshness policy, and uses a short empty-result recheck so a newly created configuration file is noticed. Mutating code owns invalidation. A new consumer must define its cache key, freshness need, and invalidation points explicitly.\n\nRead `packages/coding-agent/src/session` for the append-only event graph and `packages/coding-agent/src/discovery` for the scan cache.\n",
15
15
  "en/architecture-contribution/tool-runtime.mdx": "---\ntitle: \"Tool runtime\"\ndescription: \"Trace Bash, notebook, deferred-action, custom-tool, context, and task-agent execution boundaries.\"\nsidebar:\n order: 3\n label: \"Tool runtime\"\n---\n\nThe agent loop sees a common tool contract, but each runtime owns its validation, cancellation, output, and side effects.\n\n## How do shell and notebook work execute?\n\nThe Bash tool validates the request, launches through the configured shell boundary, streams bounded output, and spills oversized results to an artifact. Notebook editing changes cell structure; kernel execution is a separate Python gateway operation with its own environment and Multipurpose Internet Mail Extensions (MIME) rendering.\n\n## How are deferred actions resolved?\n\nDeferred actions are pushed onto a last-in, first-out stack and resolved only at the runtime checkpoint that owns them. Custom tools use the host application programming interface (API) to register actions; they must pair cancellation and cleanup with any external resource they create.\n\n## How are commands and task agents discovered?\n\nSlash-command templates and agent definitions are discovered from normalized user, project, plugin, and bundled providers. Precedence resolves duplicate identifiers before execution. Argument expansion produces prompt input; it must not bypass tool policy or agent execution guardrails.\n\nRead `packages/coding-agent/src/tools/bash.ts` for the shell boundary, `packages/coding-agent/src/tools/notebook.ts` for cell editing, and `packages/coding-agent/src/slash-commands/builtin-registry.ts` for command discovery.\n",
16
16
  "en/architecture-contribution/tui-runtime.mdx": "---\ntitle: \"TUI runtime\"\ndescription: \"Trace component contracts, differential rendering, terminal input, modal UI, and custom tool renderers.\"\nsidebar:\n order: 8\n label: \"TUI runtime\"\n---\n\nThe terminal user interface (TUI) renders session and runtime state through components. Components return terminal cells and semantic styles; the renderer computes a differential update instead of repainting unrelated rows.\n\n## How are input and rendering routed?\n\nTerminal decoding turns bytes and escape sequences into key events. Focused overlays receive input before the prompt editor and global actions. State changes schedule a render, layout produces the next frame, and the diff layer emits only changed terminal regions.\n\n## How do I extend interactive surfaces?\n\nExtensions can open a modal through `ctx.ui.custom` only when an interactive UI host exists. Custom tools may provide renderers for calls and results while preserving a plain-text representation for headless clients. A renderer must not become the only copy of durable tool output.\n\nRead `packages/tui/src` for the component and rendering contracts, and `packages/coding-agent/src/tui` for the session-aware components built on them.\n",
17
- "en/architecture-contribution/upstream-pi.mdx": "---\ntitle: \"Relationship to pi\"\ndescription: \"Understand what xcsh inherits from pi and where the project deliberately specializes.\"\nsidebar:\n order: 9\n label: \"Relationship to pi\"\n---\n\nxcsh is derived from the open-source pi coding agent and adds F5 Distributed Cloud resource workflows, integrations, packaging, and project-specific governance.\n\n## Which upstream range was reviewed?\n\nThe last proven sync with `can1357/oh-my-pi` was `d350ea60e` on April 9, 2026. The security-first\naudit reviewed the divergent line through the frozen tip `b2f25dbfe1` on September 5, 2026.\nBecause the repositories no longer share a usable linear history, accepted changes are semantic\nports with adapted regressions rather than merges or ancestry-based cherry-picks.\n\n## Which changes were accepted?\n\nThe four implementation waves accepted these upstream pull requests:\n\n| Wave | Upstream pull requests | xcsh delivery |\n| --- | --- | --- |\n| Provider and prompt security | #2147, the opaque-thinking portion of #3239, #7067, and #8727 | #3710 |\n| Configuration and execution security | #7362 and #5636 | #3720 |\n| Core runtime | #7743, #10415, #10523, #10325, and #10550 | #3723 |\n| Terminal and platform | #10613, #10997, #10492, #9233, and #7634 | #3724 |\n\nThese ports protect provider-bound secrets and compaction boundaries, enforce exact-case\nenvironment references and complete protocol tails, repair Responses replay and shared MCP\nresults, improve rate-limit and retained-string behavior, chain directory completion, extend\npower assertions across supported platforms, and harden stats persistence and network exposure.\nThe source pull requests remain attributable to `can1357/oh-my-pi`; the xcsh deliveries link the\nexact commits and regression evidence.\n\n## Where does xcsh deliberately diverge?\n\nxcsh retains its own:\n\n- F5-scoped packages, prompts-as-files, tool factories, and capability discovery;\n- SQLite multi-credential storage, multi-account authentication, and provider routing;\n- MCP, SSH, F5 Distributed Cloud, Office, and browser integrations;\n- Bun-first runtime, session semantics, release pipeline, branding, and governance.\n\nPublic interfaces use prerelease clean breaks. In this wave,\n`MacOSPowerAssertion`/`MacOSPowerAssertionOptions` became\n`PowerAssertion`/`PowerAssertionOptions` without aliases, and `power.sleepPrevention` was added with\nan `idle` default.\n\n## What remains excluded or deferred?\n\nUpstream workflows, branding, release machinery, generated model catalogs, compatibility shims,\nnew packages, and large unrelated subsystems are excluded. The security-scan subsystem in #7048\nand the native minimizer in #2176 remain deferred. The range-dashboard optimization in #9327 and\nearendil-works/pi-only fullscreen transcript, mouse, clipboard, and renderer subsystems also remain\noutside this campaign. Commits after either frozen source tip require a later audit.\n\n## How do I decide where a fix belongs?\n\nTrace the affected module and compare it with the pinned upstream lineage. A generic agent-loop\ndefect may belong upstream; an xcsh resource command, integration, or packaging change belongs\nhere.\n\n## How do I preserve attribution?\n\nKeep upstream license notices and document imported changes. Avoid copying a patch blindly across\ndiverged modules; port the behavior with tests against the current xcsh architecture.\n",
17
+ "en/architecture-contribution/upstream-pi.mdx": "---\ntitle: \"Relationship to pi\"\ndescription: \"Understand what xcsh inherits from pi and where the project deliberately specializes.\"\nsidebar:\n order: 9\n label: \"Relationship to pi\"\n---\n\nxcsh is derived from the open-source pi coding agent and adds F5 Distributed Cloud resource workflows, integrations, packaging, and project-specific governance.\n\n## Which upstream range was reviewed?\n\nThe last proven sync with `can1357/oh-my-pi` was `d350ea60e` on April 9, 2026. The first-pass\nsecurity and shared-runtime audit reviewed the divergent line through `b2f25dbfe1` on September 5,\n2026. The second-pass TUI and renderer audit extends that lineage through the frozen tip\n`6d3bc569d16cd7351073eaa767caed51021befbb` on September 6, 2026.\nBecause the repositories no longer share a usable linear history, accepted changes are semantic\nports with adapted regressions rather than merges or ancestry-based cherry-picks.\n\n## Which changes were accepted?\n\nThe four implementation waves accepted these upstream pull requests:\n\n| Wave | Upstream pull requests | xcsh delivery |\n| --- | --- | --- |\n| Provider and prompt security | #2147, the opaque-thinking portion of #3239, #7067, and #8727 | #3710 |\n| Configuration and execution security | #7362 and #5636 | #3720 |\n| Core runtime | #7743, #10415, #10523, #10325, and #10550 | #3723 |\n| Terminal and platform | #10613, #10997, #10492, #9233, and #7634 | #3724 |\n| TUI and renderer crash containment | #1989, #4497, #4529, #2047, #5837, and #6788 | #3743 |\n\nThese ports protect provider-bound secrets and compaction boundaries, enforce exact-case\nenvironment references and complete protocol tails, repair Responses replay and shared MCP\nresults, improve rate-limit and retained-string behavior, chain directory completion, extend\npower assertions across supported platforms, and harden stats persistence and network exposure.\nThe source pull requests remain attributable to `can1357/oh-my-pi`; the xcsh deliveries link the\nexact commits and regression evidence.\n\nThe second-pass renderer work normalizes malformed task result data, accepts only strings at path\nboundaries, bounds ANSI-heavy rows before width measurement, and treats terminal disconnect\ncleanup as best effort before SIGHUP. Upstream #5438 is equivalent because `Container.render()`\nalready isolates child-render exceptions; its richer fallback display remains deferred.\n\n## Where does xcsh deliberately diverge?\n\nxcsh retains its own:\n\n- F5-scoped packages, prompts-as-files, tool factories, and capability discovery;\n- SQLite multi-credential storage, multi-account authentication, and provider routing;\n- MCP, SSH, F5 Distributed Cloud, Office, and browser integrations;\n- Bun-first runtime, session semantics, release pipeline, branding, and governance.\n\nPublic interfaces use prerelease clean breaks. In this wave,\n`MacOSPowerAssertion`/`MacOSPowerAssertionOptions` became\n`PowerAssertion`/`PowerAssertionOptions` without aliases, and `power.sleepPrevention` was added with\nan `idle` default.\n\n## What remains excluded or deferred?\n\nUpstream workflows, branding, release machinery, generated model catalogs, compatibility shims,\nnew packages, and large unrelated subsystems are excluded. The security-scan subsystem in #7048\nand the native minimizer in #2176 remain deferred. The range-dashboard optimization in #9327 and\nearendil-works/pi-only fullscreen transcript, mouse, clipboard, and renderer subsystems also remain\noutside this campaign. MCP, OpenCode, Herdr, #10625, and #10491 are explicitly excluded from the\nsecond-pass batch. Commits after the frozen source tip require a later audit.\n\n## How do I decide where a fix belongs?\n\nTrace the affected module and compare it with the pinned upstream lineage. A generic agent-loop\ndefect may belong upstream; an xcsh resource command, integration, or packaging change belongs\nhere.\n\n## How do I preserve attribution?\n\nKeep upstream license notices and document imported changes. Avoid copying a patch blindly across\ndiverged modules; port the behavior with tests against the current xcsh architecture.\n",
18
18
  "en/automate-extend/extensions-custom-tools.mdx": "---\ntitle: \"Build extensions and custom tools\"\ndescription: \"Add TypeScript behavior, slash commands, providers, or schema-validated tools.\"\nsidebar:\n order: 3\n label: \"Build extensions and custom tools\"\n---\n\nExtensions load TypeScript behavior with `--extension` or `--hook`; project discovery can also load extensions, tools, hooks, commands, and rules under `.xcsh/`.\n\n## How do I test an extension boundary?\n\nLoad one explicit file with `-e <PATH>` and disable discovery with `--no-extensions`. Confirm its registered command or tool, then test shutdown and error handling.\n\n## Where do hooks and rules belong?\n\nHooks observe or alter lifecycle events; rules add durable instructions. Keep each rule narrow and each hook deterministic. Use `--no-rules` to prove whether a rule changes the result.\n",
19
19
  "en/automate-extend/headless-protocols.mdx": "---\ntitle: \"Headless modes\"\ndescription: \"Integrate xcsh with scripts through print, JSON, JSON-RPC, agent client protocol, manager, and worker modes.\"\nsidebar:\n order: 1\n label: \"Headless modes\"\n---\n\nHeadless integrations select `json`, `rpc`, or `acp` with `--mode`: a JavaScript Object Notation (JSON) event stream, JSON remote procedure call (RPC), or the agent client protocol (ACP). Each mode has a different framing contract; consumers must parse that protocol rather than decorated terminal text.\n\n## How do I start with the smallest surface?\n\n```bash\nxcsh --mode json --no-session --no-tools -p \"Return one sentence\"\n```\n\nCapture stdout as protocol data and stderr as diagnostics. Pin the xcsh version in automation and test framing against the exact release.\n\n## When do I use the software development kit (SDK) instead?\n\nUse the SDK when the host process needs in-memory session control, tool registration, or provider events. See [SDK automation](./sdk/).\n",
20
20
  "en/automate-extend/hooks-rules.mdx": "---\ntitle: \"Apply hooks and rules\"\ndescription: \"Choose event-driven mutation or declarative prompt guidance and understand discovery precedence.\"\nsidebar:\n order: 4\n label: \"Hooks and rules\"\n---\n\nRules contribute normalized instructions to the prompt. Hooks execute code at named lifecycle events. Use rules for guidance that does not need side effects; use a hook only when an event must inspect, transform, or reject runtime data.\n\n## How are rules discovered and classified?\n\nRule providers scan project and user roots, parse frontmatter, normalize identifiers, then deduplicate by precedence. Classification separates ordinary rulebook entries, always-apply guidance, and time-to-self-reflect material. The `rule://` handler resolves the final normalized item rather than reading an arbitrary path.\n\n## What determines hook execution order?\n\nA hook module exports handlers for supported events. Discovery determines the module set, and registration order determines sequential mutation when more than one handler sees the same payload. A thrown error follows the event's propagation contract; it is not converted into a successful empty result.\n\n## How do I test the hook boundary?\n\nExercise each of these separately:\n\n1. Discovery, so the module set is the one you expect.\n2. The exact event, with a representative payload.\n3. Mutation ordering, with more than one handler registered.\n4. Cancellation.\n5. A handler that throws.\n\nInterface calls made by hooks require an interactive host, so a headless integration must not assume a modal interface exists.\n",
@@ -9,6 +9,7 @@ import type { StatusLinePreset, StatusLineSegmentId, StatusLineSeparatorStyle }
9
9
  import { theme } from "../../modes/theme/theme";
10
10
  import type { AgentSession } from "../../session/agent-session";
11
11
  import { calculatePromptTokens } from "../../session/compaction/compaction";
12
+ import type { NormalizedTurnPhase } from "../../session/turn-phase";
12
13
  import type { EventBus } from "../../utils/event-bus";
13
14
  import * as git from "../../utils/git";
14
15
  import { queryGitStatus } from "../../utils/gitstatus";
@@ -67,6 +68,7 @@ export class StatusLineComponent implements Component {
67
68
  // chord is pending. Populated by the InputController's ChordDispatcher
68
69
  // callbacks; rendered as a dim right-aligned segment in the top border.
69
70
  #chordPending: string | null = null;
71
+ #turnPhase: NormalizedTurnPhase = "idle";
70
72
 
71
73
  // Git status caching (1s TTL)
72
74
  #cachedGitStatus: {
@@ -149,6 +151,12 @@ export class StatusLineComponent implements Component {
149
151
  this.#onStatusChanged?.();
150
152
  }
151
153
 
154
+ setTurnPhase(phase: NormalizedTurnPhase): void {
155
+ if (this.#turnPhase === phase) return;
156
+ this.#turnPhase = phase;
157
+ this.#onStatusChanged?.();
158
+ }
159
+
152
160
  setHookStatus(key: string, text: string | undefined): void {
153
161
  if (text === undefined) {
154
162
  this.#hookStatuses.delete(key);
@@ -521,6 +529,12 @@ export class StatusLineComponent implements Component {
521
529
  });
522
530
  }
523
531
 
532
+ rightParts.push({
533
+ content: theme.fg("dim", this.#turnPhase),
534
+ bg: defaultBg,
535
+ fg: defaultFg,
536
+ });
537
+
524
538
  // Chord-pending indicator: rightmost segment, dim style. Appended last
525
539
  // so it visually sits at the far right of the top border (after any
526
540
  // background-jobs indicator). Swallowed by truncation-from-right in the
@@ -124,9 +124,12 @@ export class EventController {
124
124
  }
125
125
 
126
126
  subscribeToAgent(): void {
127
- this.ctx.unsubscribe = this.ctx.session.subscribe(async (event: AgentSessionEvent) => {
128
- await this.handleEvent(event);
129
- });
127
+ this.ctx.unsubscribe = this.ctx.session.subscribe(
128
+ async (event: AgentSessionEvent) => {
129
+ await this.handleEvent(event);
130
+ },
131
+ { waitForTurnSettlement: true },
132
+ );
130
133
  }
131
134
 
132
135
  async handleEvent(event: AgentSessionEvent): Promise<void> {
@@ -138,6 +141,11 @@ export class EventController {
138
141
  this.ctx.updateEditorTopBorder();
139
142
 
140
143
  switch (event.type) {
144
+ case "turn_phase":
145
+ this.ctx.statusLine.setTurnPhase(event.phase);
146
+ this.ctx.ui.requestRender();
147
+ break;
148
+
141
149
  case "agent_start":
142
150
  this.#lastIntent = undefined;
143
151
  this.#readToolCallArgs.clear();
@@ -661,7 +661,7 @@ export class ExtensionUiController {
661
661
  * when it resolves. Fire-and-forget: reporting must never disturb the prompt.
662
662
  */
663
663
  #emitPromptSignal(type: "user_prompt_start" | "user_prompt_end", kind: UserPromptKind): void {
664
- this.ctx.session.extensionRunner?.emit({ type, kind }).catch(() => {});
664
+ this.ctx.session.notifyUserPrompt(type === "user_prompt_start" ? "start" : "end", kind);
665
665
  }
666
666
 
667
667
  showHookSelector(
@@ -25,6 +25,7 @@ import {
25
25
  import { DebugSelectorComponent } from "../../debug";
26
26
  import { disableProvider, enableProvider } from "../../discovery";
27
27
  import { clearXcshPluginRootsCache, resolveActiveProjectRegistryPath } from "../../discovery/helpers";
28
+ import type { UserPromptKind } from "../../extensibility/extensions/types";
28
29
  import {
29
30
  formatMarketplaceRefreshWarning,
30
31
  getInstalledPluginsRegistryPath,
@@ -113,6 +114,20 @@ class LoginPromptCancelled extends Error {}
113
114
  export class SelectorController {
114
115
  constructor(private ctx: InteractiveModeContext) {}
115
116
 
117
+ #emitPromptSignal(type: "user_prompt_start" | "user_prompt_end", kind: UserPromptKind): void {
118
+ this.ctx.session.extensionRunner?.emit({ type, kind }).catch(() => {});
119
+ }
120
+
121
+ #beginPromptSignal(kind: UserPromptKind): () => void {
122
+ let open = true;
123
+ this.#emitPromptSignal("user_prompt_start", kind);
124
+ return () => {
125
+ if (!open) return;
126
+ open = false;
127
+ this.#emitPromptSignal("user_prompt_end", kind);
128
+ };
129
+ }
130
+
116
131
  async #refreshOAuthProviderAuthState(): Promise<void> {
117
132
  const oauthProviders = getOAuthProviders().filter(provider => !provider.loginOnly);
118
133
  await Promise.all(
@@ -127,17 +142,23 @@ export class SelectorController {
127
142
  * Shows a selector component in place of the editor.
128
143
  * @param create Factory that receives a `done` callback and returns the component and focus target
129
144
  */
130
- showSelector(create: (done: () => void) => { component: Component; focus: Component }): void {
145
+ showSelector(
146
+ create: (done: () => void) => { component: Component; focus: Component },
147
+ promptKind?: UserPromptKind,
148
+ ): void {
149
+ let endPrompt: (() => void) | undefined;
131
150
  const done = () => {
132
151
  this.ctx.editorContainer.clear();
133
152
  this.ctx.editorContainer.addChild(this.ctx.editor);
134
153
  this.ctx.ui.setFocus(this.ctx.editor);
154
+ endPrompt?.();
135
155
  };
136
156
  const { component, focus } = create(done);
137
157
  this.ctx.editorContainer.clear();
138
158
  this.ctx.editorContainer.addChild(component);
139
159
  this.ctx.ui.setFocus(focus);
140
160
  this.ctx.ui.requestRender();
161
+ if (promptKind) endPrompt = this.#beginPromptSignal(promptKind);
141
162
  }
142
163
 
143
164
  showSettingsSelector(): void {
@@ -600,7 +621,8 @@ export class SelectorController {
600
621
  this.ctx.editorContainer.addChild(input);
601
622
  this.ctx.ui.setFocus(input);
602
623
  this.ctx.ui.requestRender();
603
- return promise;
624
+ const endPrompt = this.#beginPromptSignal("input");
625
+ return promise.finally(endPrompt);
604
626
  }
605
627
 
606
628
  async #showLoginRecovery(
@@ -1274,6 +1296,7 @@ export class SelectorController {
1274
1296
  const useManualInput =
1275
1297
  CALLBACK_SERVER_PROVIDERS.has(providerId as OAuthProvider) || providerId === "openai-codex";
1276
1298
  const shouldOpenBrowser = providerId !== "openai-codex" || openAICodexMethod === "browser";
1299
+ let endAuthorizationWait: (() => void) | undefined;
1277
1300
  const loginCallbacks = {
1278
1301
  method: openAICodexMethod,
1279
1302
  onAuth: (info: {
@@ -1299,6 +1322,7 @@ export class SelectorController {
1299
1322
  }
1300
1323
  this.ctx.ui.requestRender();
1301
1324
  if (shouldOpenBrowser) this.ctx.openInBrowser(info.openUrl ?? info.url);
1325
+ endAuthorizationWait ??= this.#beginPromptSignal("input");
1302
1326
  },
1303
1327
  onPrompt: async (prompt: OAuthPrompt) => {
1304
1328
  this.ctx.chatContainer.addChild(new Spacer(1));
@@ -1333,7 +1357,8 @@ export class SelectorController {
1333
1357
  this.ctx.editorContainer.addChild(codeInput);
1334
1358
  this.ctx.ui.setFocus(codeInput);
1335
1359
  this.ctx.ui.requestRender();
1336
- return promise;
1360
+ const endPrompt = this.#beginPromptSignal("input");
1361
+ return promise.finally(endPrompt);
1337
1362
  },
1338
1363
  onProgress: (message: string) => {
1339
1364
  this.ctx.chatContainer.addChild(new Text(theme.fg("dim", message), 1, 0));
@@ -1412,6 +1437,7 @@ export class SelectorController {
1412
1437
  if (useManualInput) {
1413
1438
  manualInput.clear(`Manual OAuth input cleared for ${providerId}`);
1414
1439
  }
1440
+ endAuthorizationWait?.();
1415
1441
  }
1416
1442
  }
1417
1443
 
@@ -1448,25 +1474,31 @@ export class SelectorController {
1448
1474
  let accessToken = await authStorage.getApiKey("google-vertex");
1449
1475
  if (!accessToken) {
1450
1476
  this.ctx.showStatus("Authenticating Corporate Vertex with the authorized Google enterprise flow…");
1451
- await authStorage.login("google-vertex", {
1452
- onAuth: info => {
1453
- presentAuthLink(this.ctx.chatContainer, info.url);
1454
- if (isHeadlessTerminal(runtime.environment)) {
1455
- this.ctx.chatContainer.addChild(new Text(theme.fg("dim", VERTEX_MANUAL_LOGIN_TIP), 1, 0));
1456
- } else {
1457
- this.ctx.openInBrowser(info.url);
1458
- }
1459
- this.ctx.ui.requestRender();
1460
- },
1461
- onPrompt: prompt =>
1462
- this.#promptLoginValue({
1463
- message: prompt.message,
1464
- placeholder: prompt.placeholder,
1465
- allowEmpty: prompt.allowEmpty,
1466
- }),
1467
- onProgress: message => this.ctx.showStatus(message),
1468
- onManualCodeInput: () => this.ctx.oauthManualInput.waitForInput("google-vertex"),
1469
- });
1477
+ let endAuthorizationWait: (() => void) | undefined;
1478
+ try {
1479
+ await authStorage.login("google-vertex", {
1480
+ onAuth: info => {
1481
+ presentAuthLink(this.ctx.chatContainer, info.url);
1482
+ if (isHeadlessTerminal(runtime.environment)) {
1483
+ this.ctx.chatContainer.addChild(new Text(theme.fg("dim", VERTEX_MANUAL_LOGIN_TIP), 1, 0));
1484
+ } else {
1485
+ this.ctx.openInBrowser(info.url);
1486
+ }
1487
+ this.ctx.ui.requestRender();
1488
+ endAuthorizationWait ??= this.#beginPromptSignal("input");
1489
+ },
1490
+ onPrompt: prompt =>
1491
+ this.#promptLoginValue({
1492
+ message: prompt.message,
1493
+ placeholder: prompt.placeholder,
1494
+ allowEmpty: prompt.allowEmpty,
1495
+ }),
1496
+ onProgress: message => this.ctx.showStatus(message),
1497
+ onManualCodeInput: () => this.ctx.oauthManualInput.waitForInput("google-vertex"),
1498
+ });
1499
+ } finally {
1500
+ endAuthorizationWait?.();
1501
+ }
1470
1502
  accessToken = await authStorage.getApiKey("google-vertex");
1471
1503
  if (!accessToken) throw new Error("Vertex OAuth authentication did not return an access token");
1472
1504
  }
@@ -1575,40 +1607,43 @@ export class SelectorController {
1575
1607
  }
1576
1608
  }
1577
1609
 
1578
- this.showSelector(done => {
1579
- let selector: OAuthSelectorComponent;
1580
- selector = new OAuthSelectorComponent(
1581
- mode,
1582
- this.ctx.session.modelRegistry.authStorage,
1583
- async (selectedProviderId: string) => {
1584
- selector.stopValidation();
1585
- done();
1586
- if (mode === "login") {
1587
- await this.#handleOAuthLogin(selectedProviderId);
1588
- } else {
1589
- await this.#handleOAuthLogout(selectedProviderId);
1590
- }
1591
- },
1592
- () => {
1593
- selector.stopValidation();
1594
- done();
1595
- this.ctx.ui.requestRender();
1596
- },
1597
- {
1598
- validateAuth: async (selectedProviderId: string) => {
1599
- const apiKey = await this.ctx.session.modelRegistry.getApiKeyForProvider(
1600
- selectedProviderId,
1601
- this.ctx.session.sessionId,
1602
- );
1603
- return !!apiKey;
1610
+ this.showSelector(
1611
+ done => {
1612
+ let selector: OAuthSelectorComponent;
1613
+ selector = new OAuthSelectorComponent(
1614
+ mode,
1615
+ this.ctx.session.modelRegistry.authStorage,
1616
+ async (selectedProviderId: string) => {
1617
+ selector.stopValidation();
1618
+ done();
1619
+ if (mode === "login") {
1620
+ await this.#handleOAuthLogin(selectedProviderId);
1621
+ } else {
1622
+ await this.#handleOAuthLogout(selectedProviderId);
1623
+ }
1604
1624
  },
1605
- requestRender: () => {
1625
+ () => {
1626
+ selector.stopValidation();
1627
+ done();
1606
1628
  this.ctx.ui.requestRender();
1607
1629
  },
1608
- },
1609
- );
1610
- return { component: selector, focus: selector };
1611
- });
1630
+ {
1631
+ validateAuth: async (selectedProviderId: string) => {
1632
+ const apiKey = await this.ctx.session.modelRegistry.getApiKeyForProvider(
1633
+ selectedProviderId,
1634
+ this.ctx.session.sessionId,
1635
+ );
1636
+ return !!apiKey;
1637
+ },
1638
+ requestRender: () => {
1639
+ this.ctx.ui.requestRender();
1640
+ },
1641
+ },
1642
+ );
1643
+ return { component: selector, focus: selector };
1644
+ },
1645
+ mode === "login" ? "select" : undefined,
1646
+ );
1612
1647
  }
1613
1648
 
1614
1649
  showDebugSelector(): void {