@f5-sales-demo/xcsh 21.13.1 → 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,14 @@
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)).
39
47
  - Resolved user-configured environment references by exact case across config values, model
40
48
  registry credentials, and LiteLLM YAML while preserving literal, command-backed, and unresolved
41
49
  all-caps behavior. Semantically ported from
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.1",
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.1",
65
- "@f5-sales-demo/pi-ai": "21.13.1",
66
- "@f5-sales-demo/pi-natives": "21.13.1",
67
- "@f5-sales-demo/pi-resource-management": "21.13.1",
68
- "@f5-sales-demo/pi-tui": "21.13.1",
69
- "@f5-sales-demo/pi-utils": "21.13.1",
70
- "@f5-sales-demo/xcsh-stats": "21.13.1",
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",
@@ -17,17 +17,17 @@ export interface BuildInfo {
17
17
  }
18
18
 
19
19
  export const BUILD_INFO: BuildInfo = {
20
- "version": "21.13.1",
21
- "commit": "453dbf35d835d58bb787748bbcaad10da15ea4d3",
22
- "shortCommit": "453dbf3",
20
+ "version": "21.13.2",
21
+ "commit": "bf16480aef2d385477ce939f77c2ef68009ebcec",
22
+ "shortCommit": "bf16480",
23
23
  "branch": "main",
24
- "tag": "v21.13.1",
25
- "commitDate": "2026-09-06T12:50:33+00:00",
26
- "buildDate": "2026-09-06T13:43:28.028Z",
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/453dbf35d835d58bb787748bbcaad10da15ea4d3",
32
- "releaseUrl": "https://github.com/f5-sales-demo/xcsh/releases/tag/v21.13.1"
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,