yepanywhere 0.6.0 → 0.6.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.
Files changed (225) hide show
  1. package/bundled/@yep-anywhere/shared/dist/app-types.d.ts +25 -0
  2. package/bundled/@yep-anywhere/shared/dist/app-types.d.ts.map +1 -1
  3. package/bundled/@yep-anywhere/shared/dist/app-types.js.map +1 -1
  4. package/bundled/@yep-anywhere/shared/dist/codex-schema/session.d.ts +179 -14
  5. package/bundled/@yep-anywhere/shared/dist/codex-schema/session.d.ts.map +1 -1
  6. package/bundled/@yep-anywhere/shared/dist/codex-schema/session.js +89 -0
  7. package/bundled/@yep-anywhere/shared/dist/codex-schema/session.js.map +1 -1
  8. package/bundled/@yep-anywhere/shared/dist/codex-tool-correlation.d.ts +25 -0
  9. package/bundled/@yep-anywhere/shared/dist/codex-tool-correlation.d.ts.map +1 -0
  10. package/bundled/@yep-anywhere/shared/dist/codex-tool-correlation.js +52 -0
  11. package/bundled/@yep-anywhere/shared/dist/codex-tool-correlation.js.map +1 -0
  12. package/bundled/@yep-anywhere/shared/dist/codex-web-run.d.ts +46 -0
  13. package/bundled/@yep-anywhere/shared/dist/codex-web-run.d.ts.map +1 -0
  14. package/bundled/@yep-anywhere/shared/dist/codex-web-run.js +14 -0
  15. package/bundled/@yep-anywhere/shared/dist/codex-web-run.js.map +1 -0
  16. package/bundled/@yep-anywhere/shared/dist/git-status.d.ts +29 -6
  17. package/bundled/@yep-anywhere/shared/dist/git-status.d.ts.map +1 -1
  18. package/bundled/@yep-anywhere/shared/dist/git-status.js +1 -6
  19. package/bundled/@yep-anywhere/shared/dist/git-status.js.map +1 -1
  20. package/bundled/@yep-anywhere/shared/dist/index.d.ts +7 -2
  21. package/bundled/@yep-anywhere/shared/dist/index.d.ts.map +1 -1
  22. package/bundled/@yep-anywhere/shared/dist/index.js +2 -0
  23. package/bundled/@yep-anywhere/shared/dist/index.js.map +1 -1
  24. package/bundled/@yep-anywhere/shared/dist/server-capabilities.d.ts +248 -0
  25. package/bundled/@yep-anywhere/shared/dist/server-capabilities.d.ts.map +1 -0
  26. package/bundled/@yep-anywhere/shared/dist/server-capabilities.js +251 -0
  27. package/bundled/@yep-anywhere/shared/dist/server-capabilities.js.map +1 -0
  28. package/bundled/@yep-anywhere/shared/dist/tool-display-actions.d.ts +26 -0
  29. package/bundled/@yep-anywhere/shared/dist/tool-display-actions.d.ts.map +1 -0
  30. package/bundled/@yep-anywhere/shared/dist/tool-display-actions.js +9 -0
  31. package/bundled/@yep-anywhere/shared/dist/tool-display-actions.js.map +1 -0
  32. package/bundled/@yep-anywhere/shared/package.json +1 -1
  33. package/client-dist/assets/de-BNhVdIq4.js +6 -0
  34. package/client-dist/assets/es-Csn9n24J.js +6 -0
  35. package/client-dist/assets/fr-DKx4tSpo.js +6 -0
  36. package/client-dist/assets/index-1y2h7U7U.js +582 -0
  37. package/client-dist/assets/index-Cn_ZDP6u.css +1 -0
  38. package/client-dist/assets/ja-DAkhkwQZ.js +6 -0
  39. package/client-dist/assets/zh-CN-B7lY0cc6.js +6 -0
  40. package/client-dist/index.html +2 -2
  41. package/dist/app.d.ts.map +1 -1
  42. package/dist/app.js.map +1 -1
  43. package/dist/codex/codeModeExec.d.ts +30 -0
  44. package/dist/codex/codeModeExec.d.ts.map +1 -0
  45. package/dist/codex/codeModeExec.js +419 -0
  46. package/dist/codex/codeModeExec.js.map +1 -0
  47. package/dist/codex/displayActions.d.ts +48 -0
  48. package/dist/codex/displayActions.d.ts.map +1 -0
  49. package/dist/codex/displayActions.js +674 -0
  50. package/dist/codex/displayActions.js.map +1 -0
  51. package/dist/codex/normalization.d.ts +10 -7
  52. package/dist/codex/normalization.d.ts.map +1 -1
  53. package/dist/codex/normalization.js +179 -502
  54. package/dist/codex/normalization.js.map +1 -1
  55. package/dist/codex/webRun.d.ts +42 -0
  56. package/dist/codex/webRun.d.ts.map +1 -0
  57. package/dist/codex/webRun.js +199 -0
  58. package/dist/codex/webRun.js.map +1 -0
  59. package/dist/indexes/SessionIndexService.d.ts +1 -1
  60. package/dist/indexes/SessionIndexService.d.ts.map +1 -1
  61. package/dist/indexes/SessionIndexService.js +16 -4
  62. package/dist/indexes/SessionIndexService.js.map +1 -1
  63. package/dist/routes/git-status.d.ts.map +1 -1
  64. package/dist/routes/git-status.js +70 -0
  65. package/dist/routes/git-status.js.map +1 -1
  66. package/dist/routes/project-queue.d.ts.map +1 -1
  67. package/dist/routes/project-queue.js.map +1 -1
  68. package/dist/routes/public-shares.d.ts +1 -1
  69. package/dist/routes/public-shares.d.ts.map +1 -1
  70. package/dist/routes/public-shares.js +4 -6
  71. package/dist/routes/public-shares.js.map +1 -1
  72. package/dist/routes/session-metadata-patch.d.ts +24 -0
  73. package/dist/routes/session-metadata-patch.d.ts.map +1 -0
  74. package/dist/routes/session-metadata-patch.js +119 -0
  75. package/dist/routes/session-metadata-patch.js.map +1 -0
  76. package/dist/routes/session-project-routing.d.ts +25 -0
  77. package/dist/routes/session-project-routing.d.ts.map +1 -0
  78. package/dist/routes/session-project-routing.js +32 -0
  79. package/dist/routes/session-project-routing.js.map +1 -0
  80. package/dist/routes/session-provider-resolution.d.ts +28 -0
  81. package/dist/routes/session-provider-resolution.d.ts.map +1 -0
  82. package/dist/routes/session-provider-resolution.js +22 -0
  83. package/dist/routes/session-provider-resolution.js.map +1 -0
  84. package/dist/routes/session-queue-summaries.d.ts +21 -0
  85. package/dist/routes/session-queue-summaries.d.ts.map +1 -0
  86. package/dist/routes/session-queue-summaries.js +79 -0
  87. package/dist/routes/session-queue-summaries.js.map +1 -0
  88. package/dist/routes/session-recovered-queue.d.ts +43 -0
  89. package/dist/routes/session-recovered-queue.d.ts.map +1 -0
  90. package/dist/routes/session-recovered-queue.js +132 -0
  91. package/dist/routes/session-recovered-queue.js.map +1 -0
  92. package/dist/routes/session-thinking-options.d.ts +12 -0
  93. package/dist/routes/session-thinking-options.d.ts.map +1 -0
  94. package/dist/routes/session-thinking-options.js +7 -0
  95. package/dist/routes/session-thinking-options.js.map +1 -0
  96. package/dist/routes/sessions.d.ts.map +1 -1
  97. package/dist/routes/sessions.js +110 -409
  98. package/dist/routes/sessions.js.map +1 -1
  99. package/dist/routes/settings-parsers.d.ts +37 -0
  100. package/dist/routes/settings-parsers.d.ts.map +1 -0
  101. package/dist/routes/settings-parsers.js +896 -0
  102. package/dist/routes/settings-parsers.js.map +1 -0
  103. package/dist/routes/settings.d.ts.map +1 -1
  104. package/dist/routes/settings.js +4 -894
  105. package/dist/routes/settings.js.map +1 -1
  106. package/dist/routes/version.d.ts +0 -2
  107. package/dist/routes/version.d.ts.map +1 -1
  108. package/dist/routes/version.js +8 -10
  109. package/dist/routes/version.js.map +1 -1
  110. package/dist/sdk/cli-detection.d.ts +15 -1
  111. package/dist/sdk/cli-detection.d.ts.map +1 -1
  112. package/dist/sdk/cli-detection.js +159 -28
  113. package/dist/sdk/cli-detection.js.map +1 -1
  114. package/dist/sdk/messageQueue.d.ts +5 -0
  115. package/dist/sdk/messageQueue.d.ts.map +1 -1
  116. package/dist/sdk/messageQueue.js +21 -0
  117. package/dist/sdk/messageQueue.js.map +1 -1
  118. package/dist/sdk/providers/codex-model-catalog.d.ts +34 -0
  119. package/dist/sdk/providers/codex-model-catalog.d.ts.map +1 -0
  120. package/dist/sdk/providers/codex-model-catalog.js +378 -0
  121. package/dist/sdk/providers/codex-model-catalog.js.map +1 -0
  122. package/dist/sdk/providers/codex-notification-guards.d.ts +15 -0
  123. package/dist/sdk/providers/codex-notification-guards.d.ts.map +1 -0
  124. package/dist/sdk/providers/codex-notification-guards.js +159 -0
  125. package/dist/sdk/providers/codex-notification-guards.js.map +1 -0
  126. package/dist/sdk/providers/codex-protocol/generated/ImageGenerationItem.d.ts +9 -0
  127. package/dist/sdk/providers/codex-protocol/generated/ImageGenerationItem.d.ts.map +1 -0
  128. package/dist/sdk/providers/codex-protocol/generated/ImageGenerationItem.js +3 -0
  129. package/dist/sdk/providers/codex-protocol/generated/ImageGenerationItem.js.map +1 -0
  130. package/dist/sdk/providers/codex-protocol/generated/MultiAgentMode.d.ts +5 -5
  131. package/dist/sdk/providers/codex-protocol/generated/MultiAgentMode.d.ts.map +1 -1
  132. package/dist/sdk/providers/codex-protocol/generated/ResponseItem.d.ts +1 -0
  133. package/dist/sdk/providers/codex-protocol/generated/ResponseItem.d.ts.map +1 -1
  134. package/dist/sdk/providers/codex-protocol/generated/ThreadId.d.ts +5 -0
  135. package/dist/sdk/providers/codex-protocol/generated/ThreadId.d.ts.map +1 -1
  136. package/dist/sdk/providers/codex-protocol/generated/WebSearchItem.d.ts +7 -0
  137. package/dist/sdk/providers/codex-protocol/generated/WebSearchItem.d.ts.map +1 -0
  138. package/dist/sdk/providers/codex-protocol/generated/WebSearchItem.js +3 -0
  139. package/dist/sdk/providers/codex-protocol/generated/WebSearchItem.js.map +1 -0
  140. package/dist/sdk/providers/codex-protocol/generated/v2/AskForApproval.d.ts +1 -1
  141. package/dist/sdk/providers/codex-protocol/generated/v2/AskForApproval.d.ts.map +1 -1
  142. package/dist/sdk/providers/codex-protocol/generated/v2/CapabilityRootLocation.d.ts +3 -0
  143. package/dist/sdk/providers/codex-protocol/generated/v2/CapabilityRootLocation.d.ts.map +1 -1
  144. package/dist/sdk/providers/codex-protocol/generated/v2/CodexErrorInfo.d.ts +1 -1
  145. package/dist/sdk/providers/codex-protocol/generated/v2/CodexErrorInfo.d.ts.map +1 -1
  146. package/dist/sdk/providers/codex-protocol/generated/v2/McpToolCallAppContext.d.ts +3 -0
  147. package/dist/sdk/providers/codex-protocol/generated/v2/McpToolCallAppContext.d.ts.map +1 -1
  148. package/dist/sdk/providers/codex-protocol/generated/v2/Thread.d.ts +13 -0
  149. package/dist/sdk/providers/codex-protocol/generated/v2/Thread.d.ts.map +1 -1
  150. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadExtra.d.ts +5 -0
  151. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadExtra.d.ts.map +1 -0
  152. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadExtra.js +3 -0
  153. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadExtra.js.map +1 -0
  154. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadForkParams.d.ts +7 -0
  155. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadForkParams.d.ts.map +1 -1
  156. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadHistoryMode.d.ts +2 -0
  157. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadHistoryMode.d.ts.map +1 -0
  158. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadHistoryMode.js +3 -0
  159. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadHistoryMode.js.map +1 -0
  160. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadItem.d.ts +5 -13
  161. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadItem.d.ts.map +1 -1
  162. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackParams.d.ts +3 -0
  163. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackParams.d.ts.map +1 -1
  164. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartParams.d.ts +10 -0
  165. package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartParams.d.ts.map +1 -1
  166. package/dist/sdk/providers/codex-protocol/generated/v2/Turn.d.ts +3 -0
  167. package/dist/sdk/providers/codex-protocol/generated/v2/Turn.d.ts.map +1 -1
  168. package/dist/sdk/providers/codex-summary-helpers.d.ts +41 -0
  169. package/dist/sdk/providers/codex-summary-helpers.d.ts.map +1 -0
  170. package/dist/sdk/providers/codex-summary-helpers.js +207 -0
  171. package/dist/sdk/providers/codex-summary-helpers.js.map +1 -0
  172. package/dist/sdk/providers/codex.d.ts +0 -25
  173. package/dist/sdk/providers/codex.d.ts.map +1 -1
  174. package/dist/sdk/providers/codex.js +160 -703
  175. package/dist/sdk/providers/codex.js.map +1 -1
  176. package/dist/sdk/providers/opencode-models.d.ts +17 -0
  177. package/dist/sdk/providers/opencode-models.d.ts.map +1 -0
  178. package/dist/sdk/providers/opencode-models.js +83 -0
  179. package/dist/sdk/providers/opencode-models.js.map +1 -0
  180. package/dist/sdk/providers/opencode.d.ts +1 -9
  181. package/dist/sdk/providers/opencode.d.ts.map +1 -1
  182. package/dist/sdk/providers/opencode.js +1 -82
  183. package/dist/sdk/providers/opencode.js.map +1 -1
  184. package/dist/sdk/types.d.ts +3 -1
  185. package/dist/sdk/types.d.ts.map +1 -1
  186. package/dist/services/ProjectQueueService.d.ts.map +1 -1
  187. package/dist/services/ProjectQueueService.js +3 -1
  188. package/dist/services/ProjectQueueService.js.map +1 -1
  189. package/dist/sessions/claude-summary.d.ts.map +1 -1
  190. package/dist/sessions/claude-summary.js +13 -1
  191. package/dist/sessions/claude-summary.js.map +1 -1
  192. package/dist/sessions/codex-reader.d.ts +0 -2
  193. package/dist/sessions/codex-reader.d.ts.map +1 -1
  194. package/dist/sessions/codex-reader.js +46 -84
  195. package/dist/sessions/codex-reader.js.map +1 -1
  196. package/dist/sessions/codex-user-turn-provenance.d.ts +40 -0
  197. package/dist/sessions/codex-user-turn-provenance.d.ts.map +1 -0
  198. package/dist/sessions/codex-user-turn-provenance.js +165 -0
  199. package/dist/sessions/codex-user-turn-provenance.js.map +1 -0
  200. package/dist/sessions/normalization.d.ts.map +1 -1
  201. package/dist/sessions/normalization.js +80 -51
  202. package/dist/sessions/normalization.js.map +1 -1
  203. package/dist/sessions/pagination.d.ts +6 -0
  204. package/dist/sessions/pagination.d.ts.map +1 -1
  205. package/dist/sessions/pagination.js +42 -2
  206. package/dist/sessions/pagination.js.map +1 -1
  207. package/dist/subscriptions.d.ts.map +1 -1
  208. package/dist/subscriptions.js +1 -0
  209. package/dist/subscriptions.js.map +1 -1
  210. package/dist/supervisor/Process.d.ts +12 -0
  211. package/dist/supervisor/Process.d.ts.map +1 -1
  212. package/dist/supervisor/Process.js +178 -22
  213. package/dist/supervisor/Process.js.map +1 -1
  214. package/dist/supervisor/Supervisor.d.ts +5 -1
  215. package/dist/supervisor/Supervisor.d.ts.map +1 -1
  216. package/dist/supervisor/Supervisor.js +47 -0
  217. package/dist/supervisor/Supervisor.js.map +1 -1
  218. package/package.json +2 -2
  219. package/client-dist/assets/de-CHMDbVD5.js +0 -6
  220. package/client-dist/assets/es-CK8MPF_C.js +0 -6
  221. package/client-dist/assets/fr-49PXQiUL.js +0 -6
  222. package/client-dist/assets/index-B-09fVut.js +0 -557
  223. package/client-dist/assets/index-uJnfvD1f.css +0 -1
  224. package/client-dist/assets/ja-CrCGPmoH.js +0 -6
  225. package/client-dist/assets/zh-CN-AFJxv5ke.js +0 -6
@@ -1,19 +1,20 @@
1
+ import { createCodexCodeModeGroupInput, extractCodexCodeModeCalls, extractCodexCodeModeTextOutput, } from "./codeModeExec.js";
2
+ import { analyzeCodexCommand, stripOuterQuotes, toToolDisplayActions, unwrapCodexShellLauncherCommand, } from "./displayActions.js";
3
+ import { parseCodexWebRunOutput } from "./webRun.js";
1
4
  export const CODEX_TOOL_NAME_ALIASES = {
2
5
  shell_command: "Bash",
3
6
  exec_command: "Bash",
4
7
  write_stdin: "WriteStdin",
8
+ // A detached code-mode script cell is polled with `wait`; it shares the
9
+ // shell-session presentation ("waiting for output") with stdin polls.
10
+ wait: "WriteStdin",
5
11
  update_plan: "UpdatePlan",
6
12
  apply_patch: "Edit",
7
13
  web_search_call: "WebSearch",
8
14
  search_query: "WebSearch",
15
+ // Code-mode flattening of the namespaced `web.run` browsing tool.
16
+ web__run: "Web",
9
17
  };
10
- const SHELL_EXECUTABLES = new Set(["bash", "sh", "zsh", "dash"]);
11
- const POWERSHELL_EXECUTABLES = new Set([
12
- "pwsh",
13
- "pwsh.exe",
14
- "powershell",
15
- "powershell.exe",
16
- ]);
17
18
  const INLINE_IMAGE_DATA_URL_PREFIX_RE = /^data:(image\/[a-z0-9.+-]+)(?:;[^,]*)?,/i;
18
19
  const INLINE_IMAGE_DATA_URL_GLOBAL_RE = /data:image\/[a-z0-9.+-]+(?:;[a-z0-9=.+-]+)*,[A-Za-z0-9+/=_-]+/gi;
19
20
  export function parseCodexToolArguments(argumentsText) {
@@ -52,21 +53,44 @@ export function normalizeCodexToolInvocation(toolName, input) {
52
53
  if (!command) {
53
54
  return { toolName: "Bash", input: normalizedInput };
54
55
  }
55
- const normalizedCommand = unwrapShellLauncherCommand(command);
56
- const readShellInfo = parseReadShellCommand(normalizedCommand);
57
- if (readShellInfo) {
58
- return {
59
- toolName: "Read",
60
- input: createReadToolInput(readShellInfo),
61
- readShellInfo,
62
- };
63
- }
64
- const grepInput = parseRipgrepCommand(normalizedCommand);
65
- if (grepInput) {
66
- return {
67
- toolName: "Grep",
68
- input: grepInput,
69
- };
56
+ const normalizedCommand = unwrapCodexShellLauncherCommand(command);
57
+ const workingDirectory = isRecord(normalizedInput)
58
+ ? (getStringField(normalizedInput, "workdir") ??
59
+ getStringField(normalizedInput, "cwd"))
60
+ : undefined;
61
+ const commandAnalysis = analyzeCodexCommand(command, workingDirectory);
62
+ const displayActions = commandAnalysis
63
+ ? toToolDisplayActions(commandAnalysis.actions)
64
+ : undefined;
65
+ if (commandAnalysis?.actions.length === 1) {
66
+ const action = commandAnalysis.actions[0];
67
+ if (action?.kind === "read") {
68
+ const readShellInfo = {
69
+ filePath: action.filePath,
70
+ ...(action.startLine !== undefined
71
+ ? { startLine: action.startLine }
72
+ : {}),
73
+ ...(action.endLine !== undefined ? { endLine: action.endLine } : {}),
74
+ stripLineNumbers: action.stripLineNumbers,
75
+ };
76
+ return {
77
+ toolName: "Read",
78
+ input: createReadToolInput(readShellInfo),
79
+ displayActions,
80
+ readShellInfo,
81
+ };
82
+ }
83
+ if (action?.kind === "search") {
84
+ return {
85
+ toolName: "Grep",
86
+ input: {
87
+ pattern: action.query,
88
+ output_mode: "content",
89
+ ...(action.path ? { path: action.path } : {}),
90
+ },
91
+ displayActions,
92
+ };
93
+ }
70
94
  }
71
95
  const writeShellInfo = parseHeredocWriteShellCommand(normalizedCommand);
72
96
  if (writeShellInfo) {
@@ -76,49 +100,36 @@ export function normalizeCodexToolInvocation(toolName, input) {
76
100
  writeShellInfo,
77
101
  };
78
102
  }
79
- return { toolName: "Bash", input: normalizedInput };
103
+ return {
104
+ toolName: "Bash",
105
+ input: normalizedInput,
106
+ ...(displayActions ? { displayActions } : {}),
107
+ };
80
108
  }
81
- export function normalizeCodexCommandActionInvocation(command, commandActions) {
82
- if (!Array.isArray(commandActions) || commandActions.length !== 1) {
83
- return null;
84
- }
85
- const action = commandActions[0];
86
- if (!isRecord(action)) {
87
- return null;
88
- }
89
- const actionType = getStringField(action, "type");
90
- if (actionType === "read") {
91
- const path = getStringField(action, "path");
92
- if (!path) {
93
- return null;
109
+ export function normalizeCodexCustomToolInvocation(rawToolName, rawInput) {
110
+ const codeModeCalls = rawToolName === "exec" ? extractCodexCodeModeCalls(rawInput) : [];
111
+ if (codeModeCalls.length === 1) {
112
+ const nestedCall = codeModeCalls[0];
113
+ if (nestedCall) {
114
+ return normalizeCodexToolInvocation(canonicalizeCodexToolName(nestedCall.toolName), nestedCall.input);
94
115
  }
95
- const commandReadInfo = parseReadShellCommand(unwrapShellLauncherCommand(command));
96
- const readShellInfo = {
97
- ...(commandReadInfo ?? { stripLineNumbers: false }),
98
- filePath: path,
99
- };
100
- return {
101
- toolName: "Read",
102
- input: createReadToolInput(readShellInfo),
103
- readShellInfo,
104
- };
105
116
  }
106
- if (actionType === "search") {
107
- const query = getStringField(action, "query");
108
- if (!query) {
109
- return null;
110
- }
111
- const input = {
112
- pattern: query,
113
- output_mode: "content",
117
+ if (codeModeCalls.length > 1 && typeof rawInput === "string") {
118
+ const normalizedCalls = codeModeCalls.map((call) => normalizeCodexToolInvocation(canonicalizeCodexToolName(call.toolName), call.input));
119
+ const displayActions = normalizedCalls.every((call) => call.displayActions && call.displayActions.length > 0)
120
+ ? normalizedCalls.flatMap((call) => call.displayActions ?? [])
121
+ : undefined;
122
+ return {
123
+ toolName: "Exec",
124
+ input: createCodexCodeModeGroupInput(rawInput, codeModeCalls),
125
+ ...(displayActions ? { displayActions } : {}),
114
126
  };
115
- const path = getStringField(action, "path");
116
- if (path) {
117
- input.path = path;
118
- }
119
- return { toolName: "Grep", input };
120
127
  }
121
- return null;
128
+ const canonicalToolName = canonicalizeCodexToolName(rawToolName);
129
+ const normalizedInput = canonicalToolName === "Edit" && typeof rawInput === "string"
130
+ ? { _rawPatch: rawInput }
131
+ : rawInput;
132
+ return normalizeCodexToolInvocation(canonicalToolName, normalizedInput);
122
133
  }
123
134
  export function normalizeCodexToolOutputWithContext(output, context) {
124
135
  const normalized = normalizeCodexToolOutput(output);
@@ -160,12 +171,61 @@ export function normalizeCodexToolOutputWithContext(output, context) {
160
171
  }
161
172
  }
162
173
  else if (context?.toolName === "Bash") {
163
- const bashContent = extractCodexShellOutputContent(content);
174
+ let bashContent = extractCodexShellOutputContent(content);
175
+ let bashExitCode = exitCode;
176
+ const chunk = parseCodexUnifiedExecChunkOutput(bashContent);
177
+ if (chunk) {
178
+ bashContent = chunk.output;
179
+ if (chunk.exitCode !== undefined) {
180
+ bashExitCode = chunk.exitCode;
181
+ isError = chunk.exitCode !== 0;
182
+ }
183
+ }
164
184
  structured = createBashToolResult(interrupted ? "" : bashContent, isError, backgroundTaskId, interrupted,
165
185
  // Carry a recoverable exit code so reloaded (function_call_output-only)
166
186
  // Bash results match the live-stream structured result. Equivalence is a
167
187
  // contract — see topics/stream-persisted-render-parity.md.
168
- exitCode);
188
+ bashExitCode,
189
+ // Command runtime, from the chunk record or the shell envelope (spec:
190
+ // topics/provider-output-contract.md § Command execution metadata).
191
+ chunk?.durationSeconds ?? extractWallTimeSecondsFromText(content));
192
+ }
193
+ else if (context?.toolName === "WriteStdin") {
194
+ const chunk = parseCodexUnifiedExecChunkOutput(content);
195
+ if (chunk) {
196
+ content = chunk.output;
197
+ // Raw chunk fields pass through; normalized command metadata and a
198
+ // stdout alias ride alongside so renderers need no chunk knowledge.
199
+ structured = {
200
+ ...chunk.record,
201
+ stdout: chunk.output,
202
+ ...(chunk.exitCode !== undefined ? { exitCode: chunk.exitCode } : {}),
203
+ ...(chunk.durationSeconds !== undefined
204
+ ? { durationSeconds: chunk.durationSeconds }
205
+ : {}),
206
+ };
207
+ if (chunk.exitCode !== undefined) {
208
+ isError = chunk.exitCode !== 0;
209
+ }
210
+ }
211
+ }
212
+ else if (context?.toolName === "Web") {
213
+ const webRun = parseCodexWebRunOutput(content);
214
+ if (webRun) {
215
+ structured = webRun.result;
216
+ content = webRun.contentText;
217
+ // The envelope's "Script completed" confirms the browse ran; page text
218
+ // that merely contains "Error:" must not mark the call failed.
219
+ isError = false;
220
+ }
221
+ }
222
+ else if (context?.toolName === "Edit" && context.patchApplyResult) {
223
+ const patchOutput = context.patchApplyResult.success
224
+ ? context.patchApplyResult.stdout
225
+ : context.patchApplyResult.stderr || context.patchApplyResult.stdout;
226
+ if (patchOutput)
227
+ content = patchOutput;
228
+ isError = !context.patchApplyResult.success;
169
229
  }
170
230
  return { content, structured, isError };
171
231
  }
@@ -229,350 +289,6 @@ function extractBashCommand(input) {
229
289
  }
230
290
  return "";
231
291
  }
232
- function tokenizeShellCommand(command) {
233
- const tokens = [];
234
- let current = "";
235
- let quote = null;
236
- let escaping = false;
237
- for (let i = 0; i < command.length; i++) {
238
- const char = command[i];
239
- if (!char)
240
- continue;
241
- if (escaping) {
242
- current += char;
243
- escaping = false;
244
- continue;
245
- }
246
- if (quote) {
247
- if (char === quote) {
248
- quote = null;
249
- }
250
- else if (quote === '"' &&
251
- char === "\\" &&
252
- shouldEscapeShellChar(command[i + 1])) {
253
- escaping = true;
254
- }
255
- else {
256
- current += char;
257
- }
258
- continue;
259
- }
260
- if (char === "\\" && shouldEscapeShellChar(command[i + 1])) {
261
- escaping = true;
262
- continue;
263
- }
264
- if (char === "'" || char === '"') {
265
- quote = char;
266
- continue;
267
- }
268
- if (/\s/.test(char)) {
269
- if (current.length > 0) {
270
- tokens.push(current);
271
- current = "";
272
- }
273
- continue;
274
- }
275
- current += char;
276
- }
277
- if (current.length > 0) {
278
- tokens.push(current);
279
- }
280
- return tokens;
281
- }
282
- function getExecutableName(token) {
283
- const normalized = token.replace(/\\/g, "/");
284
- return (normalized.split("/").pop() || token).toLowerCase();
285
- }
286
- function isShellExecutable(token) {
287
- return SHELL_EXECUTABLES.has(getExecutableName(token));
288
- }
289
- function isPowerShellExecutable(token) {
290
- const executableName = getExecutableName(token);
291
- return (POWERSHELL_EXECUTABLES.has(executableName) ||
292
- executableName.endsWith("pwsh.exe") ||
293
- executableName.endsWith("powershell.exe"));
294
- }
295
- function shouldEscapeShellChar(next) {
296
- return (next !== undefined &&
297
- (/\s/.test(next) || next === "\\" || next === "'" || next === '"'));
298
- }
299
- function getShellLauncherPrefixLength(tokens) {
300
- if (tokens.length < 3) {
301
- return 0;
302
- }
303
- const first = tokens[0] || "";
304
- const second = tokens[1] || "";
305
- const third = tokens[2] || "";
306
- // /usr/bin/env bash -lc "command"
307
- if (getExecutableName(first) === "env" &&
308
- isShellExecutable(second) &&
309
- third === "-lc" &&
310
- tokens.length >= 4) {
311
- return 3;
312
- }
313
- // /bin/bash -lc "command"
314
- if (isShellExecutable(first) && second === "-lc" && tokens.length >= 3) {
315
- return 2;
316
- }
317
- if (isPowerShellExecutable(first)) {
318
- for (let i = 1; i < tokens.length - 1; i++) {
319
- const token = tokens[i]?.toLowerCase();
320
- if (token === "-command" || token === "-c") {
321
- return i + 1;
322
- }
323
- }
324
- }
325
- return 0;
326
- }
327
- function unwrapShellLauncherCommand(command) {
328
- let normalized = command.trim();
329
- // Allow nested wrappers, e.g. `bash -lc "env bash -lc \"...\""`
330
- for (let i = 0; i < 3; i++) {
331
- const tokens = tokenizeShellCommand(normalized);
332
- const launcherPrefixLength = getShellLauncherPrefixLength(tokens);
333
- if (launcherPrefixLength === 0 || tokens.length <= launcherPrefixLength) {
334
- break;
335
- }
336
- normalized = tokens.slice(launcherPrefixLength).join(" ").trim();
337
- }
338
- return normalized;
339
- }
340
- function parseLineRangeToken(token) {
341
- const match = token.match(/^(\d+)(?:,(\d+))?p$/);
342
- if (!match?.[1])
343
- return null;
344
- const startLine = Number.parseInt(match[1], 10);
345
- const endLine = match[2] ? Number.parseInt(match[2], 10) : startLine;
346
- if (!Number.isFinite(startLine) || !Number.isFinite(endLine)) {
347
- return null;
348
- }
349
- return {
350
- startLine,
351
- endLine: Math.max(startLine, endLine),
352
- };
353
- }
354
- function parseReadShellCommand(command) {
355
- const tokens = tokenizeShellCommand(command);
356
- if (tokens.length === 0)
357
- return null;
358
- if (tokens[0] === "cat" && tokens.length === 2) {
359
- const filePath = tokens[1];
360
- if (!filePath || filePath.startsWith("-")) {
361
- return null;
362
- }
363
- return {
364
- filePath,
365
- stripLineNumbers: false,
366
- };
367
- }
368
- if (tokens[0] === "sed" && tokens[1] === "-n" && tokens.length === 4) {
369
- const range = parseLineRangeToken(tokens[2] ?? "");
370
- const filePath = tokens[3];
371
- if (!range || !filePath || filePath.startsWith("-")) {
372
- return null;
373
- }
374
- return {
375
- filePath,
376
- startLine: range.startLine,
377
- endLine: range.endLine,
378
- stripLineNumbers: false,
379
- };
380
- }
381
- const isNlSedCommand = tokens[0] === "nl" &&
382
- tokens[1] === "-ba" &&
383
- tokens[3] === "|" &&
384
- tokens[4] === "sed" &&
385
- tokens[5] === "-n" &&
386
- tokens.length === 7;
387
- if (isNlSedCommand) {
388
- const filePath = tokens[2];
389
- const range = parseLineRangeToken(tokens[6] ?? "");
390
- if (!filePath || !range)
391
- return null;
392
- return {
393
- filePath,
394
- startLine: range.startLine,
395
- endLine: range.endLine,
396
- stripLineNumbers: true,
397
- };
398
- }
399
- const powershellRead = parsePowerShellGetContentCommand(tokens);
400
- if (powershellRead) {
401
- return powershellRead;
402
- }
403
- return null;
404
- }
405
- function parsePowerShellGetContentCommand(tokens) {
406
- const command = tokens[0]?.toLowerCase();
407
- if (command !== "get-content") {
408
- return null;
409
- }
410
- // Compound commands aren't simple reads. A single pipe into Select-Object is
411
- // handled below (Codex emits `Get-Content … | Select-Object -Skip -First` for
412
- // partial reads, the PowerShell analogue of `sed -n`).
413
- if (tokens.some((token) => token === "&&" || token === ";")) {
414
- return null;
415
- }
416
- const pipeIndex = tokens.indexOf("|");
417
- const getContentTokens = pipeIndex === -1 ? tokens : tokens.slice(0, pipeIndex);
418
- let selectWindow = null;
419
- if (pipeIndex !== -1) {
420
- selectWindow = parseSelectObjectWindow(tokens.slice(pipeIndex + 1));
421
- if (!selectWindow) {
422
- return null;
423
- }
424
- }
425
- const flagsWithValue = new Set([
426
- "-credential",
427
- "-delimiter",
428
- "-encoding",
429
- "-erroraction",
430
- "-exclude",
431
- "-filter",
432
- "-include",
433
- "-readcount",
434
- "-stream",
435
- ]);
436
- let filePath = "";
437
- let totalCount;
438
- for (let i = 1; i < getContentTokens.length; i++) {
439
- const token = getContentTokens[i];
440
- if (!token)
441
- continue;
442
- const normalized = token.toLowerCase();
443
- if (normalized === "-path" || normalized === "-literalpath") {
444
- const next = getContentTokens[i + 1];
445
- if (!next || next.startsWith("-")) {
446
- return null;
447
- }
448
- filePath = next;
449
- i += 1;
450
- continue;
451
- }
452
- if (normalized.startsWith("-path:")) {
453
- filePath = token.slice("-path:".length);
454
- continue;
455
- }
456
- if (normalized.startsWith("-literalpath:")) {
457
- filePath = token.slice("-literalpath:".length);
458
- continue;
459
- }
460
- if (normalized === "-totalcount" || normalized === "-head") {
461
- const next = getContentTokens[i + 1];
462
- const parsed = next ? Number.parseInt(next, 10) : Number.NaN;
463
- if (!Number.isFinite(parsed) || parsed < 0) {
464
- return null;
465
- }
466
- totalCount = parsed;
467
- i += 1;
468
- continue;
469
- }
470
- if (normalized.startsWith("-totalcount:")) {
471
- const parsed = Number.parseInt(token.slice("-totalcount:".length), 10);
472
- if (!Number.isFinite(parsed) || parsed < 0) {
473
- return null;
474
- }
475
- totalCount = parsed;
476
- continue;
477
- }
478
- if (normalized.startsWith("-head:")) {
479
- const parsed = Number.parseInt(token.slice("-head:".length), 10);
480
- if (!Number.isFinite(parsed) || parsed < 0) {
481
- return null;
482
- }
483
- totalCount = parsed;
484
- continue;
485
- }
486
- if (flagsWithValue.has(normalized)) {
487
- i += 1;
488
- continue;
489
- }
490
- if (token.startsWith("-")) {
491
- continue;
492
- }
493
- if (!filePath) {
494
- filePath = token;
495
- }
496
- }
497
- filePath = stripOuterQuotes(filePath);
498
- if (!filePath || filePath.startsWith("-")) {
499
- return null;
500
- }
501
- if (selectWindow) {
502
- const startLine = selectWindow.skip + 1;
503
- return {
504
- filePath,
505
- startLine,
506
- ...(selectWindow.first !== undefined && selectWindow.first > 0
507
- ? { endLine: selectWindow.skip + selectWindow.first }
508
- : {}),
509
- stripLineNumbers: false,
510
- };
511
- }
512
- return {
513
- filePath,
514
- ...(totalCount !== undefined && totalCount > 0
515
- ? { startLine: 1, endLine: totalCount }
516
- : {}),
517
- stripLineNumbers: false,
518
- };
519
- }
520
- // Parses the tail of a `Get-Content … | Select-Object …` pipeline. Only the
521
- // line-window flags `-Skip`/`-First` (and their inline `-Skip:N` forms) are
522
- // recognized; any other token disqualifies the pipeline so we don't mislabel a
523
- // real transform as a read.
524
- function parseSelectObjectWindow(tokens) {
525
- if (tokens[0]?.toLowerCase() !== "select-object") {
526
- return null;
527
- }
528
- let skip;
529
- let first;
530
- for (let i = 1; i < tokens.length; i++) {
531
- const token = tokens[i];
532
- if (!token)
533
- continue;
534
- const normalized = token.toLowerCase();
535
- if (normalized === "-skip" || normalized === "-first") {
536
- const next = tokens[i + 1];
537
- const parsed = next ? Number.parseInt(next, 10) : Number.NaN;
538
- if (!Number.isFinite(parsed) || parsed < 0) {
539
- return null;
540
- }
541
- if (normalized === "-skip") {
542
- skip = parsed;
543
- }
544
- else {
545
- first = parsed;
546
- }
547
- i += 1;
548
- continue;
549
- }
550
- if (normalized.startsWith("-skip:") || normalized.startsWith("-first:")) {
551
- const prefixLength = normalized.startsWith("-skip:")
552
- ? "-skip:".length
553
- : "-first:".length;
554
- const parsed = Number.parseInt(token.slice(prefixLength), 10);
555
- if (!Number.isFinite(parsed) || parsed < 0) {
556
- return null;
557
- }
558
- if (normalized.startsWith("-skip:")) {
559
- skip = parsed;
560
- }
561
- else {
562
- first = parsed;
563
- }
564
- continue;
565
- }
566
- return null;
567
- }
568
- if (skip === undefined && first === undefined) {
569
- return null;
570
- }
571
- return {
572
- skip: skip ?? 0,
573
- ...(first !== undefined ? { first } : {}),
574
- };
575
- }
576
292
  function parseHeredocWriteShellCommand(command) {
577
293
  const normalized = command.replace(/\r\n/g, "\n").trimEnd();
578
294
  const lines = normalized.split("\n");
@@ -635,90 +351,6 @@ function createWriteToolInput(writeInfo) {
635
351
  content: writeInfo.content,
636
352
  };
637
353
  }
638
- function parseRipgrepCommand(command) {
639
- const tokens = tokenizeShellCommand(command);
640
- if (tokens[0] !== "rg" || tokens.length < 2) {
641
- return null;
642
- }
643
- if (tokens.some((token) => token === "|" || token === "&&" || token === ";")) {
644
- return null;
645
- }
646
- const flagsWithValue = new Set([
647
- "-g",
648
- "--glob",
649
- "-e",
650
- "--regexp",
651
- "-f",
652
- "--file",
653
- "-m",
654
- "--max-count",
655
- "-A",
656
- "--after-context",
657
- "-B",
658
- "--before-context",
659
- "-C",
660
- "--context",
661
- "-t",
662
- "--type",
663
- "-T",
664
- "--type-not",
665
- ]);
666
- let pattern = "";
667
- const searchPaths = [];
668
- for (let i = 1; i < tokens.length; i++) {
669
- const token = tokens[i];
670
- if (!token)
671
- continue;
672
- if (token === "--") {
673
- const rest = tokens.slice(i + 1).filter(Boolean);
674
- if (!pattern && rest[0]) {
675
- pattern = rest[0];
676
- }
677
- if (pattern) {
678
- searchPaths.push(...rest.slice(1));
679
- }
680
- break;
681
- }
682
- if (token === "-e" || token === "--regexp") {
683
- const next = tokens[i + 1];
684
- if (next && !pattern) {
685
- pattern = next;
686
- }
687
- i += 1;
688
- continue;
689
- }
690
- if (flagsWithValue.has(token)) {
691
- i += 1;
692
- continue;
693
- }
694
- if (token.startsWith("--glob=") || token.startsWith("--regexp=")) {
695
- if (token.startsWith("--regexp=") && !pattern) {
696
- pattern = token.slice("--regexp=".length);
697
- }
698
- continue;
699
- }
700
- if (token.startsWith("-")) {
701
- continue;
702
- }
703
- if (!pattern) {
704
- pattern = token;
705
- }
706
- else {
707
- searchPaths.push(token);
708
- }
709
- }
710
- if (!pattern) {
711
- return null;
712
- }
713
- const input = {
714
- pattern,
715
- output_mode: "content",
716
- };
717
- if (searchPaths.length > 0) {
718
- input.path = searchPaths.join(" ");
719
- }
720
- return input;
721
- }
722
354
  function isRecord(value) {
723
355
  return !!value && typeof value === "object" && !Array.isArray(value);
724
356
  }
@@ -800,6 +432,10 @@ function extractSessionIdFromText(output) {
800
432
  return Number.parseInt(taskId, 10);
801
433
  }
802
434
  function normalizeCodexToolOutput(output) {
435
+ const codeModeText = extractCodexCodeModeTextOutput(output);
436
+ if (codeModeText !== undefined) {
437
+ return normalizeCodexToolOutput(codeModeText);
438
+ }
803
439
  if (typeof output === "string") {
804
440
  let structured;
805
441
  let isError = false;
@@ -951,6 +587,57 @@ function formatByteSize(bytes) {
951
587
  return `${Math.round(bytes / 1024)}\u202fkb`;
952
588
  return `${Math.round((bytes / (1024 * 1024)) * 10) / 10}\u202fmb`;
953
589
  }
590
+ const UNIFIED_EXEC_CHUNK_MARKERS = [
591
+ "chunk_id",
592
+ "session_id",
593
+ "wall_time_seconds",
594
+ "original_token_count",
595
+ ];
596
+ /**
597
+ * Recognize a unified-exec result record printed as a tool output — the
598
+ * shape `tools.exec_command`/`wait` return for detached shell sessions:
599
+ * `{"chunk_id":…,"wall_time_seconds":…,"exit_code":…,"output":"…"}`.
600
+ * The embedded `output` is the command's real text; showing the raw JSON
601
+ * hides it. Anything not exactly one such object fails closed.
602
+ */
603
+ function parseCodexUnifiedExecChunkOutput(content) {
604
+ const body = extractCodexShellOutputContent(content).trim();
605
+ if (!body.startsWith("{") || !body.endsWith("}"))
606
+ return undefined;
607
+ let parsed;
608
+ try {
609
+ parsed = JSON.parse(body);
610
+ }
611
+ catch {
612
+ return undefined;
613
+ }
614
+ if (!isRecord(parsed) || typeof parsed.output !== "string")
615
+ return undefined;
616
+ if (!UNIFIED_EXEC_CHUNK_MARKERS.some((marker) => marker in parsed)) {
617
+ return undefined;
618
+ }
619
+ const exitCode = parsed.exit_code;
620
+ const durationSeconds = parsed.wall_time_seconds;
621
+ return {
622
+ ...(typeof exitCode === "number" && Number.isFinite(exitCode)
623
+ ? { exitCode }
624
+ : {}),
625
+ ...(typeof durationSeconds === "number" && Number.isFinite(durationSeconds)
626
+ ? { durationSeconds }
627
+ : {}),
628
+ output: parsed.output,
629
+ record: parsed,
630
+ };
631
+ }
632
+ /** Command runtime from the shell envelope: "Wall time[:] 30.0 seconds". */
633
+ function extractWallTimeSecondsFromText(content) {
634
+ const match = content.match(/(?:^|\n)\s*Wall time:?\s+([\d.]+)\s*seconds?\b/i);
635
+ if (!match?.[1]) {
636
+ return undefined;
637
+ }
638
+ const parsed = Number.parseFloat(match[1]);
639
+ return Number.isFinite(parsed) ? parsed : undefined;
640
+ }
954
641
  function extractCodexShellOutputContent(content) {
955
642
  const normalized = content.replace(/\r\n/g, "\n");
956
643
  const inlineMarker = "Output:\n";
@@ -965,7 +652,7 @@ function extractCodexShellOutputContent(content) {
965
652
  const rawOutput = normalized.slice(markerIndex + marker.length);
966
653
  return rawOutput.startsWith("\n") ? rawOutput.slice(1) : rawOutput;
967
654
  }
968
- function createBashToolResult(output, isError, backgroundTaskId, interrupted = false, exitCode) {
655
+ function createBashToolResult(output, isError, backgroundTaskId, interrupted = false, exitCode, durationSeconds) {
969
656
  return {
970
657
  stdout: interrupted || isError ? "" : output,
971
658
  stderr: interrupted ? "" : isError ? output : "",
@@ -973,6 +660,7 @@ function createBashToolResult(output, isError, backgroundTaskId, interrupted = f
973
660
  isImage: false,
974
661
  ...(backgroundTaskId ? { backgroundTaskId } : {}),
975
662
  ...(exitCode !== undefined ? { exitCode } : {}),
663
+ ...(durationSeconds !== undefined ? { durationSeconds } : {}),
976
664
  };
977
665
  }
978
666
  function normalizeRipgrepOutput(output, pattern) {
@@ -1106,15 +794,4 @@ function countContentLines(content) {
1106
794
  }
1107
795
  return lines.length;
1108
796
  }
1109
- function stripOuterQuotes(value) {
1110
- if (value.length < 2) {
1111
- return value;
1112
- }
1113
- const first = value[0];
1114
- const last = value[value.length - 1];
1115
- if ((first === "'" && last === "'") || (first === '"' && last === '"')) {
1116
- return value.slice(1, -1);
1117
- }
1118
- return value;
1119
- }
1120
797
  //# sourceMappingURL=normalization.js.map