@co0ontty/wand 4.57.0 → 4.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/dist/build-info.json +3 -3
  2. package/dist/ensure-node-pty-helper.d.ts +0 -1
  3. package/dist/ensure-node-pty-helper.js +0 -5
  4. package/dist/git-quick-commit.js +18 -19
  5. package/dist/github-connector.d.ts +11 -5
  6. package/dist/github-connector.js +105 -33
  7. package/dist/missions.d.ts +1 -1
  8. package/dist/missions.js +17 -4
  9. package/dist/server-file-routes.js +43 -2
  10. package/dist/server-github-routes.js +50 -53
  11. package/dist/server-mission-routes.js +11 -10
  12. package/dist/server-task-routes.d.ts +14 -2
  13. package/dist/server-task-routes.js +248 -84
  14. package/dist/server-workspace-routes.js +90 -16
  15. package/dist/server.js +2 -20
  16. package/dist/storage.d.ts +23 -6
  17. package/dist/storage.js +130 -53
  18. package/dist/structured-exec-host.d.ts +13 -2
  19. package/dist/structured-exec-host.js +71 -36
  20. package/dist/structured-exec-pump.d.ts +1 -1
  21. package/dist/structured-exec-pump.js +14 -8
  22. package/dist/task-types.d.ts +15 -0
  23. package/dist/terminal-daemon-client.d.ts +2 -0
  24. package/dist/terminal-daemon-client.js +7 -1
  25. package/dist/terminal-daemon-server.js +17 -18
  26. package/dist/tui/ipc-server.js +3 -1
  27. package/dist/types.d.ts +1 -0
  28. package/dist/wand-task-sync.d.ts +9 -0
  29. package/dist/wand-task-sync.js +50 -0
  30. package/dist/web-ui/content/scripts.js +85 -85
  31. package/dist/web-ui/content/styles.css +1 -1
  32. package/dist/web-ui/embedded-assets.js +2 -2
  33. package/dist/ws-broadcast.js +5 -1
  34. package/package.json +2 -3
  35. package/dist/taskboard-bridge.d.ts +0 -11
  36. package/dist/taskboard-bridge.js +0 -371
  37. package/vendor/codex-taskboard/LICENSE +0 -201
  38. package/vendor/codex-taskboard/dist/web/assets/AiChat-BNn4VJ5a.js +0 -12
  39. package/vendor/codex-taskboard/dist/web/assets/GanttView-D8wnfGrG.css +0 -1
  40. package/vendor/codex-taskboard/dist/web/assets/GanttView-rGWhuEX9.js +0 -39
  41. package/vendor/codex-taskboard/dist/web/assets/abnfDiagram-N423BO3Z-DbFG6lbA.js +0 -1
  42. package/vendor/codex-taskboard/dist/web/assets/arc-BjSQqbzd.js +0 -1
  43. package/vendor/codex-taskboard/dist/web/assets/architecture-TIHT7OUA-C9-t8p4o.js +0 -1
  44. package/vendor/codex-taskboard/dist/web/assets/architectureDiagram-T3A2C74G-Db4kJZwO.js +0 -36
  45. package/vendor/codex-taskboard/dist/web/assets/array-BifhSqXX.js +0 -1
  46. package/vendor/codex-taskboard/dist/web/assets/blockDiagram-VBNYF7ZC-C-BywuWV.js +0 -132
  47. package/vendor/codex-taskboard/dist/web/assets/c4Diagram-5PPSVZJV-Dq-80rjP.js +0 -10
  48. package/vendor/codex-taskboard/dist/web/assets/channel-C7mnz8Xc.js +0 -1
  49. package/vendor/codex-taskboard/dist/web/assets/chunk-2GRJ4B5K-B2G57us9.js +0 -1
  50. package/vendor/codex-taskboard/dist/web/assets/chunk-2Q5K7J3B-C1jixKkw.js +0 -1
  51. package/vendor/codex-taskboard/dist/web/assets/chunk-3NCLNEKW-DVGIRib_.js +0 -1
  52. package/vendor/codex-taskboard/dist/web/assets/chunk-4I5QYGJK-kNoGFqr0.js +0 -1
  53. package/vendor/codex-taskboard/dist/web/assets/chunk-5RXB4S5H-4iv6-xM6.js +0 -231
  54. package/vendor/codex-taskboard/dist/web/assets/chunk-5VM5RSS4-ZNzvKenW.js +0 -15
  55. package/vendor/codex-taskboard/dist/web/assets/chunk-6Q2QTUOP-1J34vxHr.js +0 -88
  56. package/vendor/codex-taskboard/dist/web/assets/chunk-7BUUIJ7U-Bb538aSH.js +0 -1
  57. package/vendor/codex-taskboard/dist/web/assets/chunk-7Z6QIM7H-CDQpQlxX.js +0 -10
  58. package/vendor/codex-taskboard/dist/web/assets/chunk-GF5L2VYU-Dg92oHHl.js +0 -206
  59. package/vendor/codex-taskboard/dist/web/assets/chunk-I66GZJ75-Bk8_gFs2.js +0 -125
  60. package/vendor/codex-taskboard/dist/web/assets/chunk-J7OUQ5F2-CJRcenlr.js +0 -2
  61. package/vendor/codex-taskboard/dist/web/assets/chunk-JQJVKLGR-BLBV_Sus.js +0 -156
  62. package/vendor/codex-taskboard/dist/web/assets/chunk-JWPE2WC7-DVXcaiue.js +0 -1
  63. package/vendor/codex-taskboard/dist/web/assets/chunk-KBJHAD2P-Da9Yjz0p.js +0 -1
  64. package/vendor/codex-taskboard/dist/web/assets/chunk-KEIR6QF5-Dj-OpFgW.js +0 -161
  65. package/vendor/codex-taskboard/dist/web/assets/chunk-NSK5VX7P-Cb56tnGK.js +0 -2
  66. package/vendor/codex-taskboard/dist/web/assets/chunk-QR6OTTB3-BwoszTxn.js +0 -62
  67. package/vendor/codex-taskboard/dist/web/assets/chunk-RYQCIY6F-D_L2RdcQ.js +0 -1
  68. package/vendor/codex-taskboard/dist/web/assets/chunk-UBXNYLIW-YX5mN8cl.js +0 -1
  69. package/vendor/codex-taskboard/dist/web/assets/chunk-W5SLKNZC-DlOLhhDO.js +0 -1
  70. package/vendor/codex-taskboard/dist/web/assets/chunk-WRU74C26-B7SBmP0K.js +0 -70
  71. package/vendor/codex-taskboard/dist/web/assets/chunk-XXDRQBXY-BuE3VzE_.js +0 -1
  72. package/vendor/codex-taskboard/dist/web/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +0 -1
  73. package/vendor/codex-taskboard/dist/web/assets/chunk-ZIRB5QZD-C6fEPe3t.js +0 -32
  74. package/vendor/codex-taskboard/dist/web/assets/classDiagram-JCYQIIEL-KIdCVvbA.js +0 -1
  75. package/vendor/codex-taskboard/dist/web/assets/classDiagram-v2-OCEON4UE-KIdCVvbA.js +0 -1
  76. package/vendor/codex-taskboard/dist/web/assets/cose-bilkent-JH36ORCC-BzQvy5TC.js +0 -1
  77. package/vendor/codex-taskboard/dist/web/assets/cynefin-VYW2F7L2-D1_5O1XR.js +0 -1
  78. package/vendor/codex-taskboard/dist/web/assets/cynefinDiagram-MW4NZA55-DOW_U5QN.js +0 -62
  79. package/vendor/codex-taskboard/dist/web/assets/cytoscape.esm-DnGd5Fuo.js +0 -321
  80. package/vendor/codex-taskboard/dist/web/assets/dagre-VZM6K2ZE-0Dntc3NT.js +0 -4
  81. package/vendor/codex-taskboard/dist/web/assets/dagre-dpRSp0QF.js +0 -1
  82. package/vendor/codex-taskboard/dist/web/assets/defaultLocale-C8Fc0cco.js +0 -1
  83. package/vendor/codex-taskboard/dist/web/assets/diagram-7IWD3JNH-D7GleYAM.js +0 -30
  84. package/vendor/codex-taskboard/dist/web/assets/diagram-B4RE2ZJO-DCXTe6q5.js +0 -3
  85. package/vendor/codex-taskboard/dist/web/assets/diagram-LBJQPF4R-ZFJyXEXl.js +0 -24
  86. package/vendor/codex-taskboard/dist/web/assets/diagram-Q27KOJAE-DUGCuGd9.js +0 -24
  87. package/vendor/codex-taskboard/dist/web/assets/diagram-UB23O5K3-DRmp4Nng.js +0 -41
  88. package/vendor/codex-taskboard/dist/web/assets/dist-D9sYb5Oa.js +0 -1
  89. package/vendor/codex-taskboard/dist/web/assets/ebnfDiagram-BXEA7PRR-CkKoaf7T.js +0 -1
  90. package/vendor/codex-taskboard/dist/web/assets/erDiagram-JOGREHBK-nBX5z4R4.js +0 -85
  91. package/vendor/codex-taskboard/dist/web/assets/eventmodeling-45OFAUF4-pexmK65N.js +0 -1
  92. package/vendor/codex-taskboard/dist/web/assets/flowDiagram-UKHOOZJN-aroohRbL.js +0 -1
  93. package/vendor/codex-taskboard/dist/web/assets/ganttDiagram-PKOTCBZU-BOJWUTXa.js +0 -292
  94. package/vendor/codex-taskboard/dist/web/assets/gitGraph-TEB2WS4Q-DxnuhSZU.js +0 -1
  95. package/vendor/codex-taskboard/dist/web/assets/gitGraphDiagram-DS77QQ5N-Cte975TC.js +0 -106
  96. package/vendor/codex-taskboard/dist/web/assets/graphlib-DS17s2tU.js +0 -1
  97. package/vendor/codex-taskboard/dist/web/assets/index-Docmx4uQ.css +0 -1
  98. package/vendor/codex-taskboard/dist/web/assets/index-Du07lEGz.js +0 -121
  99. package/vendor/codex-taskboard/dist/web/assets/info-DKCQHKI2-DOTjgYxk.js +0 -1
  100. package/vendor/codex-taskboard/dist/web/assets/infoDiagram-6WML65LV-SpyV9UJd.js +0 -2
  101. package/vendor/codex-taskboard/dist/web/assets/init-D6jRqBbL.js +0 -1
  102. package/vendor/codex-taskboard/dist/web/assets/ishikawaDiagram-WSZJBQD7-T0PZwoUZ.js +0 -70
  103. package/vendor/codex-taskboard/dist/web/assets/journeyDiagram-NVQOT4AX-B88b8UgX.js +0 -139
  104. package/vendor/codex-taskboard/dist/web/assets/kanban-definition-27J2QSJJ-CIlfNnl_.js +0 -89
  105. package/vendor/codex-taskboard/dist/web/assets/katex-B7rAX3Vi.js +0 -257
  106. package/vendor/codex-taskboard/dist/web/assets/line-fWrwPZhB.js +0 -1
  107. package/vendor/codex-taskboard/dist/web/assets/linear-B7l8qgEw.js +0 -1
  108. package/vendor/codex-taskboard/dist/web/assets/map-BaFkSB1l.js +0 -1
  109. package/vendor/codex-taskboard/dist/web/assets/mermaid-parser.core-C5gls2nC.js +0 -7
  110. package/vendor/codex-taskboard/dist/web/assets/mermaid.core-POz2Xcvr.js +0 -11
  111. package/vendor/codex-taskboard/dist/web/assets/mindmap-definition-FAOFIHXS-BM0-egZ5.js +0 -96
  112. package/vendor/codex-taskboard/dist/web/assets/ordinal-hYBb2elL.js +0 -1
  113. package/vendor/codex-taskboard/dist/web/assets/packet-7NZHBO7P-DQZzyVos.js +0 -1
  114. package/vendor/codex-taskboard/dist/web/assets/path-BWPyau1x.js +0 -1
  115. package/vendor/codex-taskboard/dist/web/assets/pegDiagram-VL7TDLO6-B8aEwl-7.js +0 -1
  116. package/vendor/codex-taskboard/dist/web/assets/pie-RZYD4A2V-DRUflilR.js +0 -1
  117. package/vendor/codex-taskboard/dist/web/assets/pieDiagram-7S7Q4E2Y-0cDDxlua.js +0 -39
  118. package/vendor/codex-taskboard/dist/web/assets/purify.es-Bwt4ulIK.js +0 -3
  119. package/vendor/codex-taskboard/dist/web/assets/quadrantDiagram-CIZ2JOQS-CBgb0YZ0.js +0 -7
  120. package/vendor/codex-taskboard/dist/web/assets/radar-I7S5WNFK-tRocoKxq.js +0 -1
  121. package/vendor/codex-taskboard/dist/web/assets/railroad-3IZDKUUU-DaS4ZlX_.js +0 -1
  122. package/vendor/codex-taskboard/dist/web/assets/railroad-abnf-AHOZXSZD-BN1T5dBT.js +0 -1
  123. package/vendor/codex-taskboard/dist/web/assets/railroad-ebnf-EBAXGLYW-Cuf8qyKs.js +0 -1
  124. package/vendor/codex-taskboard/dist/web/assets/railroad-peg-LSFZ7HO6-B511_EYq.js +0 -1
  125. package/vendor/codex-taskboard/dist/web/assets/railroadDiagram-AXF67PYL-QtPo-JZb.js +0 -1
  126. package/vendor/codex-taskboard/dist/web/assets/requirementDiagram-LRYGKXZP-CuBIF85r.js +0 -84
  127. package/vendor/codex-taskboard/dist/web/assets/rolldown-runtime-QTnfLwEv.js +0 -1
  128. package/vendor/codex-taskboard/dist/web/assets/rough.esm-CSKSodPl.js +0 -1
  129. package/vendor/codex-taskboard/dist/web/assets/sankeyDiagram-W5VNT64P-CRA-b_za.js +0 -40
  130. package/vendor/codex-taskboard/dist/web/assets/sequenceDiagram-SI44F4Z6-CoddVWwY.js +0 -162
  131. package/vendor/codex-taskboard/dist/web/assets/sizeCapture-X5ZJPWSS-B0uUizjq.js +0 -1
  132. package/vendor/codex-taskboard/dist/web/assets/src-_wZywoZs.js +0 -1
  133. package/vendor/codex-taskboard/dist/web/assets/stateDiagram-OKZ733FA-D8DMM2ln.js +0 -1
  134. package/vendor/codex-taskboard/dist/web/assets/stateDiagram-v2-UEYNNEHI-CVp0eYAS.js +0 -1
  135. package/vendor/codex-taskboard/dist/web/assets/swimlanes-SLNWSIFB-C1fC7EFu.js +0 -2
  136. package/vendor/codex-taskboard/dist/web/assets/swimlanesDiagram-ULZ7WXOC-CPd58Xso.js +0 -8
  137. package/vendor/codex-taskboard/dist/web/assets/timeline-definition-Z64GVDOM-BUBv8aKP.js +0 -120
  138. package/vendor/codex-taskboard/dist/web/assets/treeView-QDETBFTQ-C-Bve2kY.js +0 -1
  139. package/vendor/codex-taskboard/dist/web/assets/treemap-6X3UGDF4-BcphHDdV.js +0 -1
  140. package/vendor/codex-taskboard/dist/web/assets/vennDiagram-T6HMQDX7-0wQnwAyA.js +0 -34
  141. package/vendor/codex-taskboard/dist/web/assets/wardley-OPB4EBWU-CJZ4BevB.js +0 -1
  142. package/vendor/codex-taskboard/dist/web/assets/wardleyDiagram-T6FBY63Y-U9nwPrkN.js +0 -78
  143. package/vendor/codex-taskboard/dist/web/assets/xychartDiagram-ELKLHX3M-CyCqnzgE.js +0 -7
  144. package/vendor/codex-taskboard/dist/web/codex-agent-logo.png +0 -0
  145. package/vendor/codex-taskboard/dist/web/codex-app-icon.png +0 -0
  146. package/vendor/codex-taskboard/dist/web/favicon.svg +0 -7
  147. package/vendor/codex-taskboard/dist/web/index.html +0 -20
  148. package/vendor/codex-taskboard/server/ai-chat-catalog.mjs +0 -1031
  149. package/vendor/codex-taskboard/server/ai-chat-process.mjs +0 -462
  150. package/vendor/codex-taskboard/server/ai-chat.mjs +0 -1237
  151. package/vendor/codex-taskboard/server/ai-turn-owner.mjs +0 -39
  152. package/vendor/codex-taskboard/server/app.mjs +0 -3211
  153. package/vendor/codex-taskboard/server/cloud-config.mjs +0 -188
  154. package/vendor/codex-taskboard/server/cloud-proxy.mjs +0 -310
  155. package/vendor/codex-taskboard/server/codex-app-server.mjs +0 -376
  156. package/vendor/codex-taskboard/server/codex-slash-commands-0.139.0.json +0 -62
  157. package/vendor/codex-taskboard/server/database.mjs +0 -2845
  158. package/vendor/codex-taskboard/server/index.mjs +0 -41
  159. package/vendor/codex-taskboard/server/jira-config.mjs +0 -181
  160. package/vendor/codex-taskboard/server/jira-integration.mjs +0 -487
  161. package/vendor/codex-taskboard/server/project-summary.mjs +0 -159
  162. package/vendor/codex-taskboard/shared/api-fields.mjs +0 -163
  163. package/vendor/codex-taskboard/shared/codex-environment.mjs +0 -5
  164. package/vendor/codex-taskboard/shared/codex-executable.mjs +0 -77
  165. package/vendor/codex-taskboard/shared/codex-permissions.mjs +0 -9
  166. package/vendor/codex-taskboard/shared/composer-reference.d.mts +0 -19
  167. package/vendor/codex-taskboard/shared/composer-reference.mjs +0 -90
  168. package/vendor/codex-taskboard/shared/domain.mjs +0 -34
  169. package/vendor/codex-taskboard/shared/executable-command.mjs +0 -13
  170. package/vendor/codex-taskboard/shared/process-tree.mjs +0 -27
  171. package/vendor/codex-taskboard/shared/task-input.mjs +0 -308
  172. package/vendor/codex-taskboard/shared/task-records.mjs +0 -199
  173. package/vendor/codex-taskboard/shared/task-relations.mjs +0 -55
  174. package/vendor/codex-taskboard/shared/taskboard-automation.mjs +0 -277
  175. package/vendor/codex-taskboard/skills/manage-taskboard/SKILL.md +0 -45
  176. package/vendor/codex-taskboard/skills/manage-taskboard/agents/openai.yaml +0 -4
  177. package/vendor/codex-taskboard/skills/manage-taskboard/references/cli.md +0 -211
@@ -1,462 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- import { fileURLToPath } from "node:url";
3
-
4
- import { withoutTaskboardLauncherEnvironment } from "../shared/codex-environment.mjs";
5
- import { resolveCodexPermissions } from "../shared/codex-permissions.mjs";
6
- import { signalProcessTree } from "../shared/process-tree.mjs";
7
-
8
- const VISIBLE_TEXT_LIMIT = 65_536;
9
- const STDERR_LIMIT = 65_536;
10
- const MAX_CODEX_JSONL_LINE_BYTES = 16 * 1024 * 1024;
11
- const SKILL_MARKER = "\uFFFC";
12
- const TURN_OWNER_PATH = fileURLToPath(new URL("./ai-turn-owner.mjs", import.meta.url));
13
- const ITEM_TYPES = new Set([
14
- "agent_message",
15
- "command_execution",
16
- "file_change",
17
- "mcp_tool_call",
18
- "web_search",
19
- "todo_list",
20
- "error",
21
- ]);
22
-
23
- function cappedText(value) {
24
- return typeof value === "string" ? value.slice(0, VISIBLE_TEXT_LIMIT) : "";
25
- }
26
-
27
- function errorMessage(value) {
28
- if (typeof value === "string") return cappedText(value);
29
- if (value && typeof value === "object") return cappedText(value.message);
30
- return "";
31
- }
32
-
33
- function detailText(value) {
34
- if (value === undefined || value === null) return "";
35
- if (typeof value === "string") return cappedText(value);
36
- try {
37
- return cappedText(JSON.stringify(value));
38
- } catch {
39
- return "";
40
- }
41
- }
42
-
43
- function itemStatus(rawType, item) {
44
- if (typeof item.status === "string") return cappedText(item.status);
45
- return rawType.slice("item.".length);
46
- }
47
-
48
- function normalizedItem(rawType, item) {
49
- const status = itemStatus(rawType, item);
50
- const itemId = cappedText(item.id);
51
- const baseData = {
52
- status,
53
- ...(itemId ? { itemId } : {}),
54
- };
55
-
56
- if (item.type === "agent_message") {
57
- return {
58
- kind: "event",
59
- type: item.type,
60
- role: "assistant",
61
- content: cappedText(item.text),
62
- data: baseData,
63
- };
64
- }
65
-
66
- if (item.type === "command_execution") {
67
- const command = cappedText(item.command);
68
- const output = cappedText(item.aggregated_output);
69
- return {
70
- kind: "event",
71
- type: item.type,
72
- role: "activity",
73
- content: command,
74
- data: {
75
- ...baseData,
76
- command,
77
- ...(output ? { output } : {}),
78
- ...(Number.isInteger(item.exit_code) ? { exitCode: item.exit_code } : {}),
79
- },
80
- };
81
- }
82
-
83
- if (item.type === "file_change") {
84
- const changes = Array.isArray(item.changes)
85
- ? item.changes.map((change) => ({
86
- path: cappedText(change?.path),
87
- kind: cappedText(change?.kind),
88
- })).filter((change) => change.path)
89
- : [];
90
- const content = cappedText(changes.map((change) => change.path).join("\n"));
91
- return {
92
- kind: "event",
93
- type: item.type,
94
- role: "activity",
95
- content,
96
- data: {
97
- ...baseData,
98
- files: cappedText(changes.map((change) => change.path).join("\n")).split("\n").filter(Boolean),
99
- ...(changes.length > 0 ? { detail: detailText(changes) } : {}),
100
- },
101
- };
102
- }
103
-
104
- if (item.type === "mcp_tool_call") {
105
- const server = cappedText(item.server);
106
- const tool = cappedText(item.tool);
107
- const detail = detailText({
108
- ...(item.arguments !== undefined ? { arguments: item.arguments } : {}),
109
- ...(item.result !== undefined ? { result: item.result } : {}),
110
- ...(item.error !== undefined ? { error: item.error } : {}),
111
- });
112
- return {
113
- kind: "event",
114
- type: item.type,
115
- role: item.error ? "error" : "activity",
116
- content: cappedText([server, tool].filter(Boolean).join(".")),
117
- data: {
118
- ...baseData,
119
- ...(server ? { server } : {}),
120
- ...(tool ? { tool } : {}),
121
- ...(detail && detail !== "{}" ? { detail } : {}),
122
- },
123
- };
124
- }
125
-
126
- if (item.type === "web_search") {
127
- const query = cappedText(item.query);
128
- return {
129
- kind: "event",
130
- type: item.type,
131
- role: "activity",
132
- content: query,
133
- data: { ...baseData, ...(query ? { query } : {}) },
134
- };
135
- }
136
-
137
- if (item.type === "todo_list") {
138
- const items = Array.isArray(item.items)
139
- ? item.items.map((todo) => ({
140
- text: cappedText(todo?.text),
141
- ...(typeof todo?.completed === "boolean" ? { completed: todo.completed } : {}),
142
- })).filter((todo) => todo.text)
143
- : [];
144
- return {
145
- kind: "event",
146
- type: item.type,
147
- role: "activity",
148
- content: cappedText(items.map((todo) => todo.text).join("\n")),
149
- data: {
150
- ...baseData,
151
- ...(items.length > 0 ? { detail: detailText(items) } : {}),
152
- },
153
- };
154
- }
155
-
156
- const message = errorMessage(item.message ?? item.error);
157
- const completedNotice = rawType === "item.completed" && status === "completed";
158
- return {
159
- kind: "event",
160
- type: item.type,
161
- role: completedNotice ? "activity" : "error",
162
- content: message,
163
- data: completedNotice ? { ...baseData, status: "warning" } : baseData,
164
- };
165
- }
166
-
167
- export function buildCodexArgs(thread, addDirectories, imagePaths = []) {
168
- const permission = resolveCodexPermissions(thread.sandbox);
169
- const args = [
170
- "exec",
171
- "--json",
172
- "--color",
173
- "never",
174
- "-C",
175
- thread.origin.workspacePath,
176
- "-s",
177
- permission.sandbox,
178
- "-c",
179
- `approval_policy="${permission.approvalPolicy}"`,
180
- ];
181
- if (permission.reviewer) {
182
- args.push("-c", `approvals_reviewer="${permission.reviewer}"`);
183
- }
184
- for (const directory of addDirectories) {
185
- args.push("--add-dir", directory);
186
- }
187
- if (thread.model) {
188
- args.push("-m", thread.model);
189
- }
190
- if (thread.reasoningEffort) {
191
- args.push("-c", `model_reasoning_effort="${thread.reasoningEffort}"`);
192
- }
193
- if (thread.codexThreadId) {
194
- args.push("resume");
195
- for (const imagePath of imagePaths) {
196
- args.push("-i", imagePath);
197
- }
198
- args.push(thread.codexThreadId, "-");
199
- } else {
200
- for (const imagePath of imagePaths) {
201
- args.push("-i", imagePath);
202
- }
203
- args.push("-");
204
- }
205
- return args;
206
- }
207
-
208
- export function buildCodexPrompt(thread, { message, skills, attachmentPaths }, skillPath) {
209
- const selectedSkills = skills ?? [];
210
- const turnAttachmentPaths = attachmentPaths ?? [];
211
- let selectedSkillIndex = 0;
212
- const userMessage = message.replaceAll(SKILL_MARKER, () => {
213
- const skill = selectedSkills[selectedSkillIndex];
214
- selectedSkillIndex += 1;
215
- return `[$${skill.id}](${skill.path})`;
216
- });
217
- const context = [
218
- `project_id: ${thread.origin.projectId}`,
219
- `project_name: ${thread.origin.projectName}`,
220
- `workspace_path: ${thread.origin.workspacePath}`,
221
- ];
222
- if (thread.origin.issueIdentifier) {
223
- context.push(`issue_identifier: ${thread.origin.issueIdentifier}`);
224
- }
225
- if (turnAttachmentPaths.length > 0) {
226
- context.push(
227
- "turn_attachment_paths:",
228
- ...turnAttachmentPaths.map((attachmentPath) => `- ${attachmentPath}`),
229
- );
230
- }
231
- context.push(
232
- "This is private server-owned context. Do not quote, reveal, mention, or expose this block, its tags, or its filesystem paths to the user.",
233
- );
234
-
235
- return [
236
- `[$manage-taskboard](${skillPath}) e-taskboard`,
237
- "",
238
- "<taskboard_context>",
239
- ...context,
240
- "</taskboard_context>",
241
- "",
242
- "<user_message>",
243
- userMessage,
244
- "</user_message>",
245
- ].join("\n");
246
- }
247
-
248
- export function normalizeCodexEvent(raw) {
249
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
250
-
251
- if (raw.type === "thread.started") {
252
- if (
253
- typeof raw.thread_id !== "string"
254
- || raw.thread_id.length === 0
255
- || raw.thread_id.length > 256
256
- || raw.thread_id.includes("\0")
257
- ) {
258
- return null;
259
- }
260
- return { kind: "thread.started", threadId: raw.thread_id };
261
- }
262
-
263
- if (raw.type === "turn.started") {
264
- return {
265
- kind: "event",
266
- type: raw.type,
267
- role: "activity",
268
- content: "",
269
- data: { status: "started" },
270
- };
271
- }
272
-
273
- if (raw.type === "turn.completed") {
274
- const usage = {};
275
- for (const key of ["input_tokens", "cached_input_tokens", "output_tokens"]) {
276
- if (Number.isFinite(raw.usage?.[key])) usage[key] = raw.usage[key];
277
- }
278
- return {
279
- kind: "event",
280
- type: raw.type,
281
- role: "activity",
282
- content: "",
283
- data: {
284
- status: "completed",
285
- ...(Object.keys(usage).length > 0 ? { usage } : {}),
286
- },
287
- };
288
- }
289
-
290
- if (raw.type === "turn.failed") {
291
- return {
292
- kind: "event",
293
- type: raw.type,
294
- role: "error",
295
- content: errorMessage(raw.error ?? raw.message),
296
- data: { status: "failed" },
297
- };
298
- }
299
-
300
- if (raw.type === "error") {
301
- return {
302
- kind: "event",
303
- type: raw.type,
304
- role: "activity",
305
- content: errorMessage(raw.message ?? raw.error),
306
- data: { status: "warning" },
307
- };
308
- }
309
-
310
- if (
311
- raw.type !== "item.started"
312
- && raw.type !== "item.updated"
313
- && raw.type !== "item.completed"
314
- ) {
315
- return null;
316
- }
317
- if (!raw.item || typeof raw.item !== "object" || !ITEM_TYPES.has(raw.item.type)) {
318
- return null;
319
- }
320
- return normalizedItem(raw.type, raw.item);
321
- }
322
-
323
- export function spawnCodexTurn({
324
- executable,
325
- args,
326
- prompt,
327
- env,
328
- onRawEvent,
329
- maxLineBytes = MAX_CODEX_JSONL_LINE_BYTES,
330
- }) {
331
- const child = spawn(process.execPath, [TURN_OWNER_PATH, executable, JSON.stringify(args)], {
332
- detached: true,
333
- env: withoutTaskboardLauncherEnvironment(env),
334
- stdio: ["pipe", "pipe", "pipe", "pipe"],
335
- windowsHide: true,
336
- });
337
-
338
- let stdoutChunks = [];
339
- let stdoutLength = 0;
340
- let stderrBuffer = Buffer.alloc(0);
341
- let settled = false;
342
- let fatalError = null;
343
- let stdoutEnded = false;
344
- let resolveCompletion;
345
- let rejectCompletion;
346
-
347
- const completion = new Promise((resolve, reject) => {
348
- resolveCompletion = resolve;
349
- rejectCompletion = reject;
350
- });
351
-
352
- function terminateProcessGroup() {
353
- signalProcessTree(child, "SIGKILL");
354
- }
355
-
356
- function rejectWithDiagnostic(error) {
357
- if (settled || fatalError) return;
358
- fatalError = error instanceof Error ? error : new Error(String(error));
359
- terminateProcessGroup();
360
- }
361
-
362
- function consumeLine(line) {
363
- if (fatalError) return;
364
- if (line.length > maxLineBytes) {
365
- rejectWithDiagnostic(new Error(`Codex JSONL line exceeded ${maxLineBytes} bytes`));
366
- return;
367
- }
368
- if (line.at(-1) === 13) line = line.subarray(0, -1);
369
- if (line.toString("utf8").trim() === "") return;
370
- let raw;
371
- try {
372
- raw = JSON.parse(line.toString("utf8"));
373
- } catch {
374
- rejectWithDiagnostic(new Error("Codex emitted malformed JSONL"));
375
- return;
376
- }
377
- try {
378
- onRawEvent(raw);
379
- } catch (error) {
380
- rejectWithDiagnostic(error);
381
- }
382
- }
383
-
384
- function consumeChunk(chunk) {
385
- if (settled) return;
386
- const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
387
- let offset = 0;
388
- while (offset < bytes.length && !settled && !fatalError) {
389
- const newline = bytes.indexOf(10, offset);
390
- if (newline === -1) {
391
- const remainder = bytes.subarray(offset);
392
- if (stdoutLength + remainder.length > maxLineBytes) {
393
- rejectWithDiagnostic(new Error(`Codex JSONL line exceeded ${maxLineBytes} bytes`));
394
- return;
395
- }
396
- stdoutChunks.push(remainder);
397
- stdoutLength += remainder.length;
398
- return;
399
- }
400
- const segment = bytes.subarray(offset, newline);
401
- const lineLength = stdoutLength + segment.length;
402
- if (lineLength > maxLineBytes) {
403
- rejectWithDiagnostic(new Error(`Codex JSONL line exceeded ${maxLineBytes} bytes`));
404
- return;
405
- }
406
- if (segment.length > 0) stdoutChunks.push(segment);
407
- const line = stdoutChunks.length === 0
408
- ? segment
409
- : stdoutChunks.length === 1
410
- ? stdoutChunks[0]
411
- : Buffer.concat(stdoutChunks, lineLength);
412
- stdoutChunks = [];
413
- stdoutLength = 0;
414
- consumeLine(line);
415
- offset = newline + 1;
416
- }
417
- }
418
-
419
- function finishStdout() {
420
- if (stdoutEnded) return;
421
- stdoutEnded = true;
422
- if (!fatalError && stdoutLength > 0) {
423
- const line = stdoutChunks.length === 1
424
- ? stdoutChunks[0]
425
- : Buffer.concat(stdoutChunks, stdoutLength);
426
- stdoutChunks = [];
427
- stdoutLength = 0;
428
- consumeLine(line);
429
- }
430
- }
431
-
432
- child.stdout.on("data", consumeChunk);
433
- child.stdout.on("end", finishStdout);
434
- child.stderr.on("data", (chunk) => {
435
- if (stderrBuffer.length >= STDERR_LIMIT) return;
436
- const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
437
- stderrBuffer = Buffer.concat([
438
- stderrBuffer,
439
- bytes.subarray(0, STDERR_LIMIT - stderrBuffer.length),
440
- ]);
441
- });
442
- child.on("error", rejectWithDiagnostic);
443
- child.on("exit", () => child.stdio[3].destroy());
444
- child.on("close", (exitCode, signal) => {
445
- finishStdout();
446
- if (settled) return;
447
- settled = true;
448
- if (fatalError) {
449
- if (stderrBuffer.length > 0) {
450
- fatalError.stderr = stderrBuffer.toString("utf8");
451
- }
452
- rejectCompletion(fatalError);
453
- return;
454
- }
455
- resolveCompletion({ exitCode, signal });
456
- });
457
- child.stdin.on("error", () => {});
458
- child.stdio[3].on("error", () => {});
459
- child.stdin.end(prompt);
460
-
461
- return { child, completion };
462
- }