@f5-sales-demo/xcsh 21.13.0 → 21.13.2

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
@@ -36,6 +36,19 @@
36
36
 
37
37
  ### Fixed
38
38
 
39
+ - Preserved MCP `structuredContent` through the shared tool bridge, avoided duplicate verbatim
40
+ payloads, and rendered every text block. Semantically ported from
41
+ [can1357/oh-my-pi#10523](https://github.com/can1357/oh-my-pi/pull/10523)
42
+ ([#3721](https://github.com/f5-sales-demo/xcsh/issues/3721)).
43
+ - Detached retained truncated output windows from oversized JavaScriptCore backing strings while
44
+ preserving byte-exact output and zero-copy unchanged paths. Semantically ported from
45
+ [can1357/oh-my-pi#10550](https://github.com/can1357/oh-my-pi/pull/10550)
46
+ ([#3721](https://github.com/f5-sales-demo/xcsh/issues/3721)).
47
+ - Resolved user-configured environment references by exact case across config values, model
48
+ registry credentials, and LiteLLM YAML while preserving literal, command-backed, and unresolved
49
+ all-caps behavior. Semantically ported from
50
+ [can1357/oh-my-pi#7362](https://github.com/can1357/oh-my-pi/pull/7362)
51
+ ([#3711](https://github.com/f5-sales-demo/xcsh/issues/3711)).
39
52
  - Hardened provider and compaction boundaries by obfuscating every provider-visible string,
40
53
  preserving opaque reasoning, protecting side requests and adversarial summary tags, and restoring
41
54
  unconfigured credential-shaped values byte-exact at trusted local tool boundaries. Semantically
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@f5-sales-demo/xcsh",
4
- "version": "21.13.0",
4
+ "version": "21.13.2",
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.13.0",
65
- "@f5-sales-demo/pi-ai": "21.13.0",
66
- "@f5-sales-demo/pi-natives": "21.13.0",
67
- "@f5-sales-demo/pi-resource-management": "21.13.0",
68
- "@f5-sales-demo/pi-tui": "21.13.0",
69
- "@f5-sales-demo/pi-utils": "21.13.0",
70
- "@f5-sales-demo/xcsh-stats": "21.13.0",
64
+ "@f5-sales-demo/pi-agent-core": "21.13.2",
65
+ "@f5-sales-demo/pi-ai": "21.13.2",
66
+ "@f5-sales-demo/pi-natives": "21.13.2",
67
+ "@f5-sales-demo/pi-resource-management": "21.13.2",
68
+ "@f5-sales-demo/pi-tui": "21.13.2",
69
+ "@f5-sales-demo/pi-utils": "21.13.2",
70
+ "@f5-sales-demo/xcsh-stats": "21.13.2",
71
71
  "@mozilla/readability": "^0.6",
72
72
  "@sinclair/typebox": "^0.34",
73
73
  "@xterm/headless": "^6.0",
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import * as fs from "node:fs";
17
17
  import * as path from "node:path";
18
- import { $env, isEnoent, logger, readProviderFromModelsYml } from "@f5-sales-demo/pi-utils";
18
+ import { $env, $envExact, isEnoent, logger, readProviderFromModelsYml } from "@f5-sales-demo/pi-utils";
19
19
  import { hardenAgentConfigFileSync, writeAgentConfigFileSync } from "./agent-config-file";
20
20
  import { DEFAULT_MODEL_ROLE } from "./settings-schema";
21
21
 
@@ -143,7 +143,7 @@ export function readLiteLLMConfig(modelsPath: string): LiteLLMConfig | undefined
143
143
  if (!apiKey) {
144
144
  resolvedApiKey = $env.LITELLM_API_KEY;
145
145
  } else if (apiKey.kind === "envVar") {
146
- resolvedApiKey = process.env[apiKey.name] ?? $env.LITELLM_API_KEY;
146
+ resolvedApiKey = $envExact(apiKey.name) ?? $env.LITELLM_API_KEY;
147
147
  } else if (apiKey.kind === "shellSecret") {
148
148
  resolvedApiKey = $env.LITELLM_API_KEY;
149
149
  } else {
@@ -28,7 +28,7 @@ import {
28
28
  unregisterCustomApis,
29
29
  unregisterOAuthProviders,
30
30
  } from "@f5-sales-demo/pi-ai";
31
- import { $env, isRecord, logger } from "@f5-sales-demo/pi-utils";
31
+ import { $env, $envExact, isRecord, logger } from "@f5-sales-demo/pi-utils";
32
32
  import { type Static, Type } from "@sinclair/typebox";
33
33
  import { type ConfigError, ConfigFile } from "../config";
34
34
  import { hasLiteLLMEnv, probeAndUpgradeLiteLLMConfig, startupHealthCheck } from "../config/auto-config";
@@ -475,7 +475,7 @@ type LlamaCppDiscoveredServerMetadata = {
475
475
  * Checks environment variable first, then treats as literal.
476
476
  */
477
477
  export function resolveApiKeyConfig(keyConfig: string): string | undefined {
478
- const envValue = Bun.env[keyConfig];
478
+ const envValue = $envExact(keyConfig);
479
479
  if (envValue) return envValue;
480
480
  return keyConfig;
481
481
  }
@@ -488,7 +488,7 @@ const ENV_VAR_NAME_RE = /^[A-Z][A-Z0-9]*(?:_[A-Z][A-Z0-9]*)+$/;
488
488
  * names to prevent sending literal names like "LITELLM_API_KEY" as Bearer tokens.
489
489
  */
490
490
  export function resolveYamlApiKeyConfig(keyConfig: string): string | undefined {
491
- const envValue = Bun.env[keyConfig];
491
+ const envValue = $envExact(keyConfig);
492
492
  if (envValue) return envValue;
493
493
  if (ENV_VAR_NAME_RE.test(keyConfig)) return undefined;
494
494
  return keyConfig;
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
  import { executeShell } from "@f5-sales-demo/pi-natives";
8
+ import { $envExact } from "@f5-sales-demo/pi-utils";
8
9
 
9
10
  /**
10
11
  * Matches strings that look like environment variable names: ALL_CAPS_WITH_UNDERSCORES.
@@ -33,7 +34,7 @@ export async function resolveConfigValue(config: string): Promise<string | undef
33
34
  if (config.startsWith("!")) {
34
35
  return await executeCommand(config);
35
36
  }
36
- const envValue = process.env[config];
37
+ const envValue = $envExact(config);
37
38
  if (envValue) return envValue;
38
39
  // Reject unresolved env var names to prevent sending literal names as API keys.
39
40
  // Actual literal API keys (sk-ant-..., UUIDs, etc.) won't match this pattern.
@@ -10,7 +10,7 @@ import { HerdrClient } from "../../../herdr/client";
10
10
  * blocked indicator.
11
11
  *
12
12
  * Transport: herdr injects `HERDR_SOCKET_PATH` into every pane, so state is
13
- * reported over herdr's protocol-18 JSONL socket via the shared `HerdrClient`
13
+ * reported over herdr's protocol-19 JSONL socket via the shared `HerdrClient`
14
14
  * (see `../../../herdr/client`) — the same client `herdr-terminal` uses. Each
15
15
  * request reconnects independently, validates the `ping` protocol version
16
16
  * before the first real request, and awaits herdr's typed response before
@@ -91,7 +91,7 @@ function getHerdrClient(socketPath: string): HerdrClient {
91
91
  }
92
92
 
93
93
  /**
94
- * Send one JSON-RPC request to herdr over its protocol-18 socket and await the
94
+ * Send one JSON-RPC request to herdr over its protocol-19 socket and await the
95
95
  * typed response. Every failure path (transport error, timeout, protocol
96
96
  * mismatch) is reported via `onError` without throwing, so a dead or
97
97
  * incompatible herdr never disturbs the agent.
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { connect } from "node:net";
3
3
 
4
- export const HERDR_PROTOCOL_VERSION = 18;
4
+ export const HERDR_PROTOCOL_VERSION = 19;
5
5
  const DEFAULT_TIMEOUT_MS = 5_000;
6
6
  const MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
7
7
 
@@ -19,7 +19,7 @@ function isRecord(value: unknown): value is Record<string, unknown> {
19
19
  return typeof value === "object" && value !== null && !Array.isArray(value);
20
20
  }
21
21
 
22
- /** Typed, one-request-per-connection client for Herdr's protocol-18 JSONL socket. */
22
+ /** Typed, one-request-per-connection client for Herdr's protocol-19 JSONL socket. */
23
23
  export class HerdrClient {
24
24
  private protocolChecked = false;
25
25
 
@@ -103,7 +103,7 @@ export class HerdrClient {
103
103
  });
104
104
  socket.once("end", () => {
105
105
  if (settled) return;
106
- // Protocol 18 permits the final response to be terminated by EOF. The
106
+ // Protocol 19 permits the final response to be terminated by EOF. The
107
107
  // server normally emits JSONL, but older/current transports may omit the
108
108
  // trailing newline when they close a one-shot connection.
109
109
  try {
@@ -17,17 +17,17 @@ export interface BuildInfo {
17
17
  }
18
18
 
19
19
  export const BUILD_INFO: BuildInfo = {
20
- "version": "21.13.0",
21
- "commit": "f145dca692ca83c8fc510f963b41b2dabe7e3a3c",
22
- "shortCommit": "f145dca",
20
+ "version": "21.13.2",
21
+ "commit": "bf16480aef2d385477ce939f77c2ef68009ebcec",
22
+ "shortCommit": "bf16480",
23
23
  "branch": "main",
24
- "tag": "v21.13.0",
25
- "commitDate": "2026-09-06T05:26:13+00:00",
26
- "buildDate": "2026-09-06T06:14:49.211Z",
24
+ "tag": "v21.13.2",
25
+ "commitDate": "2026-09-06T14:18:28+00:00",
26
+ "buildDate": "2026-09-06T15:06:52.801Z",
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/f145dca692ca83c8fc510f963b41b2dabe7e3a3c",
32
- "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.13.0"
31
+ "commitUrl": "https://github.com/f5-sales-demo/xcsh/commit/bf16480aef2d385477ce939f77c2ef68009ebcec",
32
+ "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.13.2"
33
33
  };
package/src/mcp/render.ts CHANGED
@@ -54,7 +54,11 @@ export function renderMCPResult(
54
54
  theme: Theme,
55
55
  args?: Record<string, unknown>,
56
56
  ): Component {
57
- const textContent = result.content?.find(c => c.type === "text")?.text ?? "";
57
+ const textContent = (result.content ?? [])
58
+ .filter(block => block.type === "text")
59
+ .map(block => block.text ?? "")
60
+ .filter(text => text.length > 0)
61
+ .join("\n\n");
58
62
  const trimmedOutput = textContent.trimEnd();
59
63
 
60
64
  return {
@@ -100,6 +100,31 @@ function formatMCPContent(content: MCPContent[]): string {
100
100
  return parts.join("\n\n");
101
101
  }
102
102
 
103
+ function formatStructuredContent(structured: Record<string, unknown>): string {
104
+ try {
105
+ const json = JSON.stringify(structured, null, 2);
106
+ return typeof json === "string" ? `\`\`\`json\n${json}\n\`\`\`` : "";
107
+ } catch {
108
+ return "";
109
+ }
110
+ }
111
+
112
+ /** Avoid duplicating a spec-compliant server's back-compatible text echo. */
113
+ function structuredContentAlreadyInText(structured: Record<string, unknown>, content: MCPContent[]): boolean {
114
+ for (const item of content) {
115
+ if (item.type !== "text") continue;
116
+ const text = typeof item.text === "string" ? item.text.trim() : "";
117
+ if (!text) continue;
118
+ try {
119
+ const fenced = /^```(?:json)?[ \t]*\r?\n([\s\S]*?)\r?\n```$/i.exec(text);
120
+ if (Bun.deepEquals(JSON.parse(fenced?.[1] ?? text), structured)) return true;
121
+ } catch {
122
+ // Non-JSON acknowledgement text cannot duplicate the structured payload.
123
+ }
124
+ }
125
+ return false;
126
+ }
127
+
103
128
  /** Build a CustomToolResult from a callTool response. */
104
129
  function buildResult(
105
130
  result: MCPToolCallResult,
@@ -108,12 +133,19 @@ function buildResult(
108
133
  provider?: string,
109
134
  providerName?: string,
110
135
  ): CustomToolResult<MCPToolDetails> {
111
- const text = formatMCPContent(result.content);
136
+ const content = result.content ?? [];
137
+ let text = formatMCPContent(content);
138
+ if (result.structuredContent !== undefined && !structuredContentAlreadyInText(result.structuredContent, content)) {
139
+ const structuredText = formatStructuredContent(result.structuredContent);
140
+ if (structuredText) {
141
+ text = text ? `${text}\n\n${structuredText}` : structuredText;
142
+ }
143
+ }
112
144
  const details: MCPToolDetails = {
113
145
  serverName,
114
146
  mcpToolName,
115
147
  isError: result.isError,
116
- rawContent: result.content,
148
+ rawContent: content,
117
149
  provider,
118
150
  providerName,
119
151
  };
package/src/mcp/types.ts CHANGED
@@ -201,8 +201,13 @@ export type MCPContent = MCPTextContent | MCPImageContent | MCPResourceContent;
201
201
 
202
202
  /** tools/call response */
203
203
  export interface MCPToolCallResult {
204
- content: MCPContent[];
204
+ content?: MCPContent[];
205
205
  isError?: boolean;
206
+ /**
207
+ * Machine-readable payload channel from the MCP 2025-06-18 tools result
208
+ * schema. The bridge also surfaces it through model-visible text content.
209
+ */
210
+ structuredContent?: Record<string, unknown>;
206
211
  }
207
212
 
208
213
  // =============================================================================
@@ -49,6 +49,7 @@ import {
49
49
  modelsAreEqual,
50
50
  parseRateLimitReason,
51
51
  } from "@f5-sales-demo/pi-ai";
52
+ import { getRetryAfterMsFromErrorText } from "@f5-sales-demo/pi-ai/utils/retry-after";
52
53
  import { killTree, MacOSPowerAssertion } from "@f5-sales-demo/pi-natives";
53
54
  import {
54
55
  abortableSleep,
@@ -6248,10 +6249,8 @@ export class AgentSession {
6248
6249
 
6249
6250
  #parseRetryAfterMsFromError(errorMessage: string): number | undefined {
6250
6251
  const now = Date.now();
6251
- const retryAfterMsMatch = /retry-after-ms\s*[:=]\s*(\d+)/i.exec(errorMessage);
6252
- if (retryAfterMsMatch) {
6253
- return Math.max(0, Number(retryAfterMsMatch[1]));
6254
- }
6252
+ const bodyHint = getRetryAfterMsFromErrorText(errorMessage);
6253
+ if (bodyHint !== undefined) return bodyHint;
6255
6254
 
6256
6255
  const retryAfterMatch = /retry-after\s*[:=]\s*([^\s,;]+)/i.exec(errorMessage);
6257
6256
  if (retryAfterMatch) {
@@ -25,6 +25,7 @@ import {
25
25
  getOpenAIResponsesHistoryItems,
26
26
  getOpenAIResponsesHistoryPayload,
27
27
  normalizeResponsesToolCallId,
28
+ stripOpenAIResponsesOutputOnlyStatusesForReplay,
28
29
  } from "@f5-sales-demo/pi-ai/utils";
29
30
  import { logger, prompt } from "@f5-sales-demo/pi-utils";
30
31
  import compactionShortSummaryPrompt from "../../prompts/compaction/compaction-short-summary.md" with { type: "text" };
@@ -833,7 +834,7 @@ function buildOpenAiNativeHistory(
833
834
  msgIndex++;
834
835
  }
835
836
 
836
- return input;
837
+ return stripOpenAIResponsesOutputOnlyStatusesForReplay(input);
837
838
  }
838
839
 
839
840
  async function requestOpenAiRemoteCompaction(
@@ -1,4 +1,5 @@
1
1
  import { sanitizeText } from "@f5-sales-demo/pi-natives";
2
+ import { materializeString } from "@f5-sales-demo/pi-utils";
2
3
  import { formatBytes } from "../tools/render-utils";
3
4
  import { sanitizeWithImagePassthrough } from "../utils/image-passthrough";
4
5
 
@@ -200,7 +201,7 @@ export function truncateLine(
200
201
  maxChars: number = DEFAULT_MAX_COLUMN,
201
202
  ): { text: string; wasTruncated: boolean } {
202
203
  if (line.length <= maxChars) return { text: line, wasTruncated: false };
203
- return { text: `${line.slice(0, maxChars)}…`, wasTruncated: true };
204
+ return { text: materializeString(`${line.slice(0, maxChars)}…`), wasTruncated: true };
204
205
  }
205
206
 
206
207
  // =============================================================================
@@ -308,7 +309,7 @@ export function truncateHead(content: string, options: TruncationOptions = {}):
308
309
  if (includedLines >= maxLines && bytesUsed <= maxBytes) truncatedBy = "lines";
309
310
 
310
311
  return {
311
- content: content.slice(0, cutIndex),
312
+ content: materializeString(content.slice(0, cutIndex)),
312
313
  truncated: true,
313
314
  truncatedBy,
314
315
  totalLines,
@@ -414,7 +415,7 @@ export function truncateTail(content: string, options: TruncationOptions = {}):
414
415
  if (includedLines >= maxLines && bytesUsed <= maxBytes) truncatedBy = "lines";
415
416
 
416
417
  return {
417
- content: content.slice(startIndex),
418
+ content: materializeString(content.slice(startIndex)),
418
419
  truncated: true,
419
420
  truncatedBy,
420
421
  totalLines,