tenjin-cli 0.1.0-alpha.30 → 0.1.0-alpha.31

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 (172) hide show
  1. package/README.md +65 -116
  2. package/dist/{_esm-CE7KNONL.js → _esm-MEXZI5DL.js} +4 -4
  3. package/dist/{alive-3J3CHOQP.js → alive-J64H46HI.js} +14 -4
  4. package/dist/{chunk-O2FRQ2L2.js → chunk-27EPWVOY.js} +4 -64
  5. package/dist/chunk-27EPWVOY.js.map +1 -0
  6. package/dist/{chunk-OSYTBCUC.js → chunk-2XLC3AEX.js} +16 -14
  7. package/dist/{chunk-OSYTBCUC.js.map → chunk-2XLC3AEX.js.map} +1 -1
  8. package/dist/chunk-3623BLPV.js +184 -0
  9. package/dist/chunk-3623BLPV.js.map +1 -0
  10. package/dist/chunk-3UCIG4TG.js +65 -0
  11. package/dist/chunk-3UCIG4TG.js.map +1 -0
  12. package/dist/{chunk-PAYV4XUA.js → chunk-4ZZO6ULA.js} +2 -2
  13. package/dist/{chunk-VUFAK2LW.js → chunk-5C32RLTA.js} +2 -2
  14. package/dist/{chunk-VUFAK2LW.js.map → chunk-5C32RLTA.js.map} +1 -1
  15. package/dist/{chunk-YHKXNYTB.js → chunk-5K5W4S66.js} +2 -2
  16. package/dist/{chunk-3O2BQIF6.js → chunk-5MARFNSB.js} +273 -482
  17. package/dist/chunk-5MARFNSB.js.map +1 -0
  18. package/dist/{chunk-HPWO4O6S.js → chunk-6E5R45ZO.js} +2 -2
  19. package/dist/{chunk-JMM6YE7J.js → chunk-77TCKDEC.js} +125 -312
  20. package/dist/chunk-77TCKDEC.js.map +1 -0
  21. package/dist/{chunk-LFZJM56J.js → chunk-7Q5FDF65.js} +2 -2
  22. package/dist/chunk-7WEQQJLG.js +68 -0
  23. package/dist/chunk-7WEQQJLG.js.map +1 -0
  24. package/dist/{chunk-AWFUPKTM.js → chunk-7WU4OPLP.js} +12 -6
  25. package/dist/{chunk-AWFUPKTM.js.map → chunk-7WU4OPLP.js.map} +1 -1
  26. package/dist/{chunk-AEG2PXBP.js → chunk-7ZRL2LBQ.js} +3 -3
  27. package/dist/{chunk-IOODYAXL.js → chunk-AGZ7PJKY.js} +6 -4
  28. package/dist/{chunk-IOODYAXL.js.map → chunk-AGZ7PJKY.js.map} +1 -1
  29. package/dist/{chunk-VFMQTSXG.js → chunk-B7HUUJOK.js} +3 -3
  30. package/dist/{chunk-EL56RW2J.js → chunk-BL3332HQ.js} +7 -7
  31. package/dist/{chunk-5LJCEMFD.js → chunk-D65GNPS3.js} +35 -27
  32. package/dist/{chunk-5LJCEMFD.js.map → chunk-D65GNPS3.js.map} +1 -1
  33. package/dist/{chunk-P7LABKCW.js → chunk-DOQGNFHM.js} +33 -2
  34. package/dist/{chunk-P7LABKCW.js.map → chunk-DOQGNFHM.js.map} +1 -1
  35. package/dist/{chunk-OK2TDZQU.js → chunk-FW75G2W4.js} +7 -5
  36. package/dist/chunk-FW75G2W4.js.map +1 -0
  37. package/dist/chunk-GA7JETVM.js +150 -0
  38. package/dist/chunk-GA7JETVM.js.map +1 -0
  39. package/dist/{chunk-6W5GYG3W.js → chunk-I3EQFHCD.js} +48 -1
  40. package/dist/chunk-I3EQFHCD.js.map +1 -0
  41. package/dist/{chunk-EBVIKMCH.js → chunk-JKKAIPTU.js} +2 -2
  42. package/dist/{chunk-N35E6CM2.js → chunk-K3I7C2MO.js} +6 -6
  43. package/dist/{chunk-KYFZTGMC.js → chunk-K72RURN3.js} +5 -3
  44. package/dist/{chunk-KYFZTGMC.js.map → chunk-K72RURN3.js.map} +1 -1
  45. package/dist/{chunk-RAULEAZ6.js → chunk-KXQ4UIP7.js} +3 -3
  46. package/dist/{chunk-VZGAONSJ.js → chunk-KXVP2VKA.js} +5 -5
  47. package/dist/chunk-LEFIX6RS.js +100 -0
  48. package/dist/chunk-LEFIX6RS.js.map +1 -0
  49. package/dist/{chunk-TTBKWWTV.js → chunk-MNXS2U45.js} +246 -83
  50. package/dist/chunk-MNXS2U45.js.map +1 -0
  51. package/dist/{chunk-AWQPGIR6.js → chunk-NEFNKLBE.js} +5 -5
  52. package/dist/chunk-OHRR5OYM.js +63 -0
  53. package/dist/chunk-OHRR5OYM.js.map +1 -0
  54. package/dist/{chunk-U6YQ6FRI.js → chunk-P4NH7OUK.js} +31 -11
  55. package/dist/chunk-P4NH7OUK.js.map +1 -0
  56. package/dist/chunk-QSCPK4F5.js +145 -0
  57. package/dist/chunk-QSCPK4F5.js.map +1 -0
  58. package/dist/chunk-QXP3Z3JN.js +131 -0
  59. package/dist/chunk-QXP3Z3JN.js.map +1 -0
  60. package/dist/{chunk-YFQOA5AU.js → chunk-R5LCN54M.js} +4 -4
  61. package/dist/{chunk-KHE6L6TD.js → chunk-UKY4CHNC.js} +92 -10
  62. package/dist/chunk-UKY4CHNC.js.map +1 -0
  63. package/dist/{chunk-QUVVWYJW.js → chunk-UQUOVWBG.js} +8 -6
  64. package/dist/{chunk-QUVVWYJW.js.map → chunk-UQUOVWBG.js.map} +1 -1
  65. package/dist/{chunk-HE2MS4QO.js → chunk-V6BSF6OC.js} +17 -13
  66. package/dist/{chunk-HE2MS4QO.js.map → chunk-V6BSF6OC.js.map} +1 -1
  67. package/dist/{chunk-WVUSXNIE.js → chunk-WJXLQXJY.js} +6 -2
  68. package/dist/{chunk-WVUSXNIE.js.map → chunk-WJXLQXJY.js.map} +1 -1
  69. package/dist/{chunk-NZIP4PA2.js → chunk-WK7F3B2E.js} +2 -2
  70. package/dist/chunk-XQJXNMSB.js +23 -0
  71. package/dist/chunk-XQJXNMSB.js.map +1 -0
  72. package/dist/chunk-Y527D4TV.js +56 -0
  73. package/dist/chunk-Y527D4TV.js.map +1 -0
  74. package/dist/{chunk-SPAVAYSW.js → chunk-YFPY4ONH.js} +6 -4
  75. package/dist/{chunk-SPAVAYSW.js.map → chunk-YFPY4ONH.js.map} +1 -1
  76. package/dist/{chunk-WO5BJNIB.js → chunk-YVFXE7RR.js} +9 -129
  77. package/dist/chunk-YVFXE7RR.js.map +1 -0
  78. package/dist/clack-EZ7TDWQU.js +19 -0
  79. package/dist/claude-cli-2YKABJJZ.js +31 -0
  80. package/dist/{cli-O5SN7ZJ4.js → cli-D5OE3URZ.js} +128 -56
  81. package/dist/{cli-O5SN7ZJ4.js.map → cli-D5OE3URZ.js.map} +1 -1
  82. package/dist/codex-event-PPNVRRDH.js +16 -0
  83. package/dist/codex-host-2RJOJW2B.js +28 -0
  84. package/dist/codex-install-UUZ6QMBQ.js +221 -0
  85. package/dist/codex-install-UUZ6QMBQ.js.map +1 -0
  86. package/dist/{config-OJQI27LT.js → config-ZD4OB2DO.js} +18 -12
  87. package/dist/{doctor-IQQJHGGM.js → doctor-KBR34Q4B.js} +48 -37
  88. package/dist/doctor-KBR34Q4B.js.map +1 -0
  89. package/dist/{fund-WEV6DMTD.js → fund-5ITKQGYF.js} +38 -31
  90. package/dist/{fund-WEV6DMTD.js.map → fund-5ITKQGYF.js.map} +1 -1
  91. package/dist/hook-command-4TYCHHRL.js +39 -0
  92. package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
  93. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +3 -2
  94. package/dist/hosts/claude/tenjin/hooks/hooks.json +4 -1
  95. package/dist/hosts/claude/tenjin/hooks/register.tsx +589 -0
  96. package/dist/hosts/claude/tenjin/types/index.d.ts +41 -0
  97. package/dist/hosts/codex/.agents/plugins/marketplace.json +20 -0
  98. package/dist/hosts/codex/tenjin/.codex-plugin/plugin.json +16 -0
  99. package/dist/hosts/codex/tenjin/.mcp.json +12 -0
  100. package/dist/hosts/codex/tenjin/hooks/hooks.json +52 -0
  101. package/dist/hosts-FWZOV26H.js +216 -0
  102. package/dist/hosts-FWZOV26H.js.map +1 -0
  103. package/dist/index.js +5 -5
  104. package/dist/{install-TUCRF32I.js → install-XWGE4Q7L.js} +38 -21
  105. package/dist/{install-identity-WHPNMNMQ.js → install-identity-K7EJIQFP.js} +11 -7
  106. package/dist/{install-wallet-MA27FTQ5.js → install-wallet-XQ6XFZV4.js} +27 -23
  107. package/dist/{install-wallet-MA27FTQ5.js.map → install-wallet-XQ6XFZV4.js.map} +1 -1
  108. package/dist/{mcp-QML7ZMPH.js → mcp-3LIJSSJB.js} +184 -58
  109. package/dist/mcp-3LIJSSJB.js.map +1 -0
  110. package/dist/{package-LGKYOEPV.js → package-ZKQFDWLE.js} +2 -2
  111. package/dist/{pay-2C2UBBXJ.js → pay-WHBERZ3W.js} +27 -23
  112. package/dist/{payments-C44QUFXU.js → payments-KVICEKD2.js} +14 -10
  113. package/dist/{payments-C44QUFXU.js.map → payments-KVICEKD2.js.map} +1 -1
  114. package/dist/plugin-registration-5TIA564H.js +54 -0
  115. package/dist/plugin-registration-5TIA564H.js.map +1 -0
  116. package/dist/{send-KVJX4XIR.js → send-7G7Y7DLN.js} +25 -19
  117. package/dist/{send-KVJX4XIR.js.map → send-7G7Y7DLN.js.map} +1 -1
  118. package/dist/{status-S7C3WMSH.js → status-OF7RH5HM.js} +26 -21
  119. package/dist/{status-S7C3WMSH.js.map → status-OF7RH5HM.js.map} +1 -1
  120. package/dist/{status-line-YR2T5HC4.js → status-line-XOUE6MPL.js} +10 -6
  121. package/dist/{status-line-YR2T5HC4.js.map → status-line-XOUE6MPL.js.map} +1 -1
  122. package/dist/{uninstall-HY6LKIIT.js → uninstall-JXUAFNDB.js} +30 -21
  123. package/dist/{uninstall-HY6LKIIT.js.map → uninstall-JXUAFNDB.js.map} +1 -1
  124. package/dist/update-ZKUERSO2.js +44 -0
  125. package/dist/update-ZKUERSO2.js.map +1 -0
  126. package/dist/{usdc-JK4RRFFQ.js → usdc-OGOGEHV2.js} +7 -6
  127. package/dist/usdc-OGOGEHV2.js.map +1 -0
  128. package/dist/{viemAdapter-By13KInL-X2VY6CY3.js → viemAdapter-By13KInL-S3DA7DFW.js} +2 -2
  129. package/dist/viemAdapter-By13KInL-S3DA7DFW.js.map +1 -0
  130. package/dist/{wallet-PD2IMZDU.js → wallet-2HA6W4R4.js} +24 -20
  131. package/dist/wallet-2HA6W4R4.js.map +1 -0
  132. package/docs/agent-permissions.md +21 -5
  133. package/package.json +1 -1
  134. package/dist/chunk-3O2BQIF6.js.map +0 -1
  135. package/dist/chunk-6W5GYG3W.js.map +0 -1
  136. package/dist/chunk-JMM6YE7J.js.map +0 -1
  137. package/dist/chunk-KHE6L6TD.js.map +0 -1
  138. package/dist/chunk-O2FRQ2L2.js.map +0 -1
  139. package/dist/chunk-OK2TDZQU.js.map +0 -1
  140. package/dist/chunk-TTBKWWTV.js.map +0 -1
  141. package/dist/chunk-U6YQ6FRI.js.map +0 -1
  142. package/dist/chunk-WO5BJNIB.js.map +0 -1
  143. package/dist/doctor-IQQJHGGM.js.map +0 -1
  144. package/dist/hook-command-D2P3ILRV.js +0 -32
  145. package/dist/mcp-QML7ZMPH.js.map +0 -1
  146. package/dist/update-OJV22LR3.js +0 -36
  147. /package/dist/{_esm-CE7KNONL.js.map → _esm-MEXZI5DL.js.map} +0 -0
  148. /package/dist/{alive-3J3CHOQP.js.map → alive-J64H46HI.js.map} +0 -0
  149. /package/dist/{chunk-PAYV4XUA.js.map → chunk-4ZZO6ULA.js.map} +0 -0
  150. /package/dist/{chunk-YHKXNYTB.js.map → chunk-5K5W4S66.js.map} +0 -0
  151. /package/dist/{chunk-HPWO4O6S.js.map → chunk-6E5R45ZO.js.map} +0 -0
  152. /package/dist/{chunk-LFZJM56J.js.map → chunk-7Q5FDF65.js.map} +0 -0
  153. /package/dist/{chunk-AEG2PXBP.js.map → chunk-7ZRL2LBQ.js.map} +0 -0
  154. /package/dist/{chunk-VFMQTSXG.js.map → chunk-B7HUUJOK.js.map} +0 -0
  155. /package/dist/{chunk-EL56RW2J.js.map → chunk-BL3332HQ.js.map} +0 -0
  156. /package/dist/{chunk-EBVIKMCH.js.map → chunk-JKKAIPTU.js.map} +0 -0
  157. /package/dist/{chunk-N35E6CM2.js.map → chunk-K3I7C2MO.js.map} +0 -0
  158. /package/dist/{chunk-RAULEAZ6.js.map → chunk-KXQ4UIP7.js.map} +0 -0
  159. /package/dist/{chunk-VZGAONSJ.js.map → chunk-KXVP2VKA.js.map} +0 -0
  160. /package/dist/{chunk-AWQPGIR6.js.map → chunk-NEFNKLBE.js.map} +0 -0
  161. /package/dist/{chunk-YFQOA5AU.js.map → chunk-R5LCN54M.js.map} +0 -0
  162. /package/dist/{chunk-NZIP4PA2.js.map → chunk-WK7F3B2E.js.map} +0 -0
  163. /package/dist/{config-OJQI27LT.js.map → clack-EZ7TDWQU.js.map} +0 -0
  164. /package/dist/{hook-command-D2P3ILRV.js.map → claude-cli-2YKABJJZ.js.map} +0 -0
  165. /package/dist/{install-TUCRF32I.js.map → codex-event-PPNVRRDH.js.map} +0 -0
  166. /package/dist/{install-identity-WHPNMNMQ.js.map → codex-host-2RJOJW2B.js.map} +0 -0
  167. /package/dist/{package-LGKYOEPV.js.map → config-ZD4OB2DO.js.map} +0 -0
  168. /package/dist/{pay-2C2UBBXJ.js.map → hook-command-4TYCHHRL.js.map} +0 -0
  169. /package/dist/{update-OJV22LR3.js.map → install-XWGE4Q7L.js.map} +0 -0
  170. /package/dist/{usdc-JK4RRFFQ.js.map → install-identity-K7EJIQFP.js.map} +0 -0
  171. /package/dist/{viemAdapter-By13KInL-X2VY6CY3.js.map → package-ZKQFDWLE.js.map} +0 -0
  172. /package/dist/{wallet-PD2IMZDU.js.map → pay-WHBERZ3W.js.map} +0 -0
@@ -1,35 +1,39 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ codexRouterEvent,
4
+ codexSession
5
+ } from "./chunk-OHRR5OYM.js";
2
6
  import {
3
7
  isPublicAddress
4
- } from "./chunk-EBVIKMCH.js";
8
+ } from "./chunk-JKKAIPTU.js";
5
9
  import {
6
10
  UNREACHABLE_BACKOFF_MS,
7
11
  clearRouterMemo,
8
12
  readRouterMemo,
9
13
  requestToolAccess,
10
14
  writeRouterMemo
11
- } from "./chunk-RAULEAZ6.js";
15
+ } from "./chunk-KXQ4UIP7.js";
12
16
  import {
13
17
  readSpendSummary,
14
18
  spentOf
15
- } from "./chunk-NZIP4PA2.js";
19
+ } from "./chunk-WK7F3B2E.js";
16
20
  import {
17
21
  ChoicesSchema,
18
22
  OfferSpecSchema,
19
23
  ROUTER_PATH,
20
24
  requestDecision
21
- } from "./chunk-KHE6L6TD.js";
25
+ } from "./chunk-UKY4CHNC.js";
22
26
  import {
23
27
  launchedByPlugin,
24
28
  requestToolName
25
- } from "./chunk-WVUSXNIE.js";
29
+ } from "./chunk-WJXLQXJY.js";
26
30
  import {
27
31
  FEE_REQUIRED,
28
32
  depositSentence,
29
33
  firstNoticeFor,
30
34
  isFeeRequired,
31
35
  unpaidSentence
32
- } from "./chunk-PAYV4XUA.js";
36
+ } from "./chunk-4ZZO6ULA.js";
33
37
  import {
34
38
  evaluateSpendPolicy
35
39
  } from "./chunk-2SNUOHAT.js";
@@ -51,36 +55,42 @@ import {
51
55
  sessionDir,
52
56
  wasOffered,
53
57
  writeProgress
54
- } from "./chunk-U6YQ6FRI.js";
58
+ } from "./chunk-P4NH7OUK.js";
55
59
  import {
56
60
  routerSettings
57
- } from "./chunk-SPAVAYSW.js";
61
+ } from "./chunk-YFPY4ONH.js";
58
62
  import {
59
63
  sessionServedByPlugin
60
- } from "./chunk-6W5GYG3W.js";
64
+ } from "./chunk-I3EQFHCD.js";
61
65
  import {
62
66
  proxyVariable
63
67
  } from "./chunk-S4SAZ7OD.js";
64
68
  import {
65
69
  composeUserAgent
66
- } from "./chunk-IOODYAXL.js";
70
+ } from "./chunk-AGZ7PJKY.js";
67
71
  import {
68
72
  resolveContextSettings
69
- } from "./chunk-AWFUPKTM.js";
73
+ } from "./chunk-7WU4OPLP.js";
74
+ import {
75
+ parseUsdToAtomic,
76
+ toMoney
77
+ } from "./chunk-Y527D4TV.js";
70
78
  import {
71
79
  external_exports,
72
- isSameDeployment,
73
80
  loadRawConfig,
74
- parseUsdToAtomic,
75
81
  resolveExperimentalBazaar,
76
- resolveSettings,
77
- toMoney
78
- } from "./chunk-WO5BJNIB.js";
82
+ resolveSettings
83
+ } from "./chunk-YVFXE7RR.js";
84
+ import {
85
+ isSameDeployment
86
+ } from "./chunk-XQJXNMSB.js";
87
+ import {
88
+ rememberingBalanceReader
89
+ } from "./chunk-27EPWVOY.js";
79
90
  import {
80
- rememberingBalanceReader,
81
91
  writeFileAtomic,
82
92
  writeFileAtomicExclusive
83
- } from "./chunk-O2FRQ2L2.js";
93
+ } from "./chunk-7WEQQJLG.js";
84
94
  import {
85
95
  walletPath
86
96
  } from "./chunk-SJLTEINJ.js";
@@ -93,6 +103,50 @@ import { homedir } from "node:os";
93
103
  import { open } from "node:fs/promises";
94
104
  import { isIP } from "node:net";
95
105
  import { dirname, join } from "node:path";
106
+
107
+ // src/router/codex-history.ts
108
+ function record(value) {
109
+ return value !== null && typeof value === "object" && !Array.isArray(value);
110
+ }
111
+ function parseCodexHistory(raw, session) {
112
+ const messages = [];
113
+ const seen = /* @__PURE__ */ new Set();
114
+ let owned = false;
115
+ for (const line of raw.split("\n")) {
116
+ if (!line.trim()) continue;
117
+ let row;
118
+ try {
119
+ row = JSON.parse(line);
120
+ } catch {
121
+ return null;
122
+ }
123
+ if (!record(row) || !record(row.payload)) continue;
124
+ const p = row.payload;
125
+ if (row.type === "session_meta") {
126
+ if (owned || p.id !== session || p.session_id !== session || p.thread_source !== "user" || p.parent_thread_id != null)
127
+ return null;
128
+ owned = true;
129
+ continue;
130
+ }
131
+ if (!owned) return null;
132
+ if (row.type === "compacted" || p.type === "context_compacted" || p.type === "compaction" || p.type === "compaction_completed")
133
+ return null;
134
+ if (row.type !== "event_msg" || p.type !== "item_completed") continue;
135
+ if (p.thread_id !== session || !record(p.item)) return null;
136
+ const item = p.item;
137
+ if (item.type === "ContextCompaction" || item.type === "Compaction") return null;
138
+ const user = item.type === "UserMessage";
139
+ if (!user && !(item.type === "AgentMessage" && item.phase === "final_answer")) continue;
140
+ if (typeof item.id !== "string" || !Array.isArray(item.content)) return null;
141
+ if (seen.has(item.id)) continue;
142
+ seen.add(item.id);
143
+ const text = item.content.filter(record).filter((b) => b.type === (user ? "text" : "Text") && typeof b.text === "string").map((b) => b.text).join("\n");
144
+ if (text.trim()) messages.push({ role: user ? "user" : "assistant", text });
145
+ }
146
+ return owned && messages.some((m) => m.role === "user") ? messages : null;
147
+ }
148
+
149
+ // src/router/context.ts
96
150
  var MAX_HISTORY = 6;
97
151
  var MAX_PACKET_BYTES = 16 * 1024;
98
152
  var MAX_MESSAGE_CHARS = 16e3;
@@ -189,10 +243,10 @@ function isLocalTarget(raw) {
189
243
  if (LOCAL_NAME.test(host)) return true;
190
244
  return isIP(host) !== 0 && !isPublicAddress(host);
191
245
  }
192
- async function buildPromptPacket(transcriptPath, sessionId, prompt) {
246
+ async function buildPromptPacket(transcriptPath, sessionId, prompt, harness = "claude") {
193
247
  const trimmed = prompt.trim();
194
248
  const text = trimmed.length > 0 ? trimmed : "(empty prompt)";
195
- const read = await readHistory(transcriptPath, { sessionId });
249
+ const read = await readHistory(transcriptPath, { sessionId, harness });
196
250
  return {
197
251
  current: { role: "user", text },
198
252
  history: read ?? [],
@@ -201,10 +255,10 @@ async function buildPromptPacket(transcriptPath, sessionId, prompt) {
201
255
  };
202
256
  }
203
257
  async function buildNativePacket(transcriptPath, sessionId, pending, opts = {}) {
204
- const { agentId, nativeOutcome } = opts;
258
+ const { agentId, nativeOutcome, harness = "claude" } = opts;
205
259
  const subject = subjectOf(pending);
206
- const read = await readHistory(transcriptPath, { sessionId });
207
- const own = agentId === void 0 ? null : await readHistory(subagentTranscriptPath(transcriptPath, sessionId, agentId), {
260
+ const read = await readHistory(transcriptPath, { sessionId, harness });
261
+ const own = agentId === void 0 || harness === "codex" ? null : await readHistory(subagentTranscriptPath(transcriptPath, sessionId, agentId), {
208
262
  sessionId,
209
263
  agentId
210
264
  });
@@ -250,6 +304,7 @@ async function readHistory(path, scope) {
250
304
  await file.close();
251
305
  }
252
306
  try {
307
+ if (scope.harness === "codex") return tail ? null : parseCodexHistory(raw, scope.sessionId);
253
308
  const messages = parseRows(raw, scope);
254
309
  if (tail && !messages.some((message) => message.role === "user")) {
255
310
  if (scope.agentId === void 0) return null;
@@ -379,11 +434,23 @@ var digest = (value) => createHash("sha256").update(value).digest("hex");
379
434
  function specPath(dataDir, id) {
380
435
  return join2(dataDir, SPECS_DIR, `${digest(id)}.json`);
381
436
  }
437
+ var SHOWN_KEY = "shown";
438
+ function shownInputField(spec) {
439
+ if (spec.output === "media") return null;
440
+ const held = spec.holds?.WebSearch ?? spec.holds?.WebFetch;
441
+ if (held !== void 0) return held;
442
+ const properties = spec.input.properties;
443
+ if (properties === null || typeof properties !== "object") return null;
444
+ const isString = (name) => properties[name]?.type === "string";
445
+ const required = Array.isArray(spec.input.required) ? spec.input.required.filter((name) => typeof name === "string") : [];
446
+ return required.find(isString) ?? Object.keys(properties).find(isString) ?? null;
447
+ }
382
448
  async function storeSpecs(dataDir, specs) {
383
449
  if (specs === void 0 || specs.length === 0) return;
384
450
  for (const spec of specs) {
385
451
  try {
386
- await writeFileAtomic(specPath(dataDir, spec.id), JSON.stringify(spec), {
452
+ const kept = { ...spec, [SHOWN_KEY]: shownInputField(spec) };
453
+ await writeFileAtomic(specPath(dataDir, spec.id), JSON.stringify(kept), {
387
454
  mode: 384,
388
455
  dirMode: 448
389
456
  });
@@ -399,7 +466,9 @@ async function readSpec(dataDir, id) {
399
466
  try {
400
467
  const stat = await file.stat();
401
468
  if (Date.now() - stat.mtimeMs > SPEC_TTL_MS || stat.size > MAX_SPEC_BYTES) return null;
402
- const parsed = OfferSpecSchema.safeParse(JSON.parse(await file.readFile("utf8")));
469
+ const kept = JSON.parse(await file.readFile("utf8"));
470
+ delete kept[SHOWN_KEY];
471
+ const parsed = OfferSpecSchema.safeParse(kept);
403
472
  return parsed.success && parsed.data.id === id ? parsed.data : null;
404
473
  } catch {
405
474
  return null;
@@ -485,13 +554,13 @@ async function settleSpecPayment(dataDir, id, left, now = Date.now()) {
485
554
  return;
486
555
  }
487
556
  const at = new Date(now).toISOString();
488
- const record = left.amountAtomic > 0n ? {
557
+ const record2 = left.amountAtomic > 0n ? {
489
558
  state: "paid",
490
559
  at,
491
560
  amountAtomic: left.amountAtomic.toString(),
492
561
  ...left.txHash !== void 0 ? { txHash: left.txHash } : {}
493
562
  } : { state: "possibly_paid", at };
494
- await writeFileAtomic(path, JSON.stringify(record), { mode: 384, dirMode: 448 }).catch(
563
+ await writeFileAtomic(path, JSON.stringify(record2), { mode: 384, dirMode: 448 }).catch(
495
564
  () => void 0
496
565
  );
497
566
  }
@@ -636,29 +705,47 @@ function spawnPrefetch(job) {
636
705
  child.on("error", () => void 0);
637
706
  child.unref();
638
707
  }
639
- function docsUrl(endpoint, query, baseUrl) {
708
+ function onDeployment(value, baseUrl) {
640
709
  let url;
641
710
  let base;
642
711
  try {
643
- url = new URL(endpoint);
712
+ url = new URL(value);
644
713
  base = new URL(baseUrl);
645
714
  } catch {
646
715
  return null;
647
716
  }
648
717
  if (url.username !== "" || url.password !== "") return null;
649
- if (!isSameDeployment(url.origin, base.origin)) return null;
718
+ return isSameDeployment(url.origin, base.origin) ? url : null;
719
+ }
720
+ function docsUrl(endpoint, query, baseUrl) {
721
+ const url = onDeployment(endpoint, baseUrl);
722
+ if (url === null) return null;
650
723
  url.searchParams.set("query", query.slice(0, DOCS_QUERY_MAX));
651
724
  return url.toString();
652
725
  }
726
+ function augmentTarget(offer, query, baseUrl) {
727
+ if (offer.delivery === "offer") return null;
728
+ if (offer.delivery === "augment") {
729
+ if (offer.augmentUrl === void 0) return null;
730
+ return onDeployment(offer.augmentUrl, baseUrl)?.toString() ?? null;
731
+ }
732
+ return docsUrl(offer.endpoint, query, baseUrl);
733
+ }
653
734
  async function startAugment(call, offer, baseUrl, deps) {
654
735
  if (call.toolUseId === void 0) return false;
655
- const url = docsUrl(offer.endpoint, call.query, baseUrl);
736
+ const url = augmentTarget(offer, call.query, baseUrl);
656
737
  if (url === null) return false;
657
738
  const now = deps.now?.() ?? Date.now();
658
739
  if (!await claimQuery(deps.dataDir, call.sessionId, call.agentId, call.query, now)) {
659
740
  return false;
660
741
  }
661
- const out = await markAugment(deps.dataDir, call.sessionId, call.toolUseId, offer.provider, now);
742
+ const out = await markAugment(
743
+ deps.dataDir,
744
+ call.sessionId,
745
+ call.toolUseId,
746
+ { provider: offer.provider, ...offer.label !== void 0 ? { label: offer.label } : {} },
747
+ now
748
+ );
662
749
  if (out === null) return false;
663
750
  try {
664
751
  (deps.prefetch ?? spawnPrefetch)({ url, out, userAgent: composeUserAgent() });
@@ -684,12 +771,15 @@ async function finishAugment(call, deps) {
684
771
  return {
685
772
  updatedToolOutput: {
686
773
  ...call.search.raw,
687
- results: [docsLine(marker.provider || "library", text), ...call.search.results]
774
+ results: [
775
+ docsLine(marker.label ?? `${marker.provider || "library"} docs`, text),
776
+ ...call.search.results
777
+ ]
688
778
  }
689
779
  };
690
780
  }
691
- function docsLine(provider, text) {
692
- return `Tenjin router added ${provider} docs for this search (free). If they don't cover it, use the web results below.
781
+ function docsLine(name, text) {
782
+ return `Tenjin router added ${name} for this search (free). If they don't cover it, use the web results below.
693
783
 
694
784
  ${text}`;
695
785
  }
@@ -910,19 +1000,19 @@ function promptSkipReason(prompt) {
910
1000
  }
911
1001
  var HINT_SOURCE = "Tenjin router (installed by the user)";
912
1002
  var BARE_CALL_RE = /(?<![\w$])request\(\{/g;
913
- function toolNamed(hint, env = process.env) {
914
- return hint.replace(BARE_CALL_RE, `${requestToolName(env)}({`);
1003
+ function toolNamed(hint, host = "claude", env = process.env) {
1004
+ return hint.replace(BARE_CALL_RE, `${requestToolName(host, env)}({`);
915
1005
  }
916
- function attributed(hint) {
917
- return `${HINT_SOURCE}: ${toolNamed(hint)}`;
1006
+ function attributed(hint, host) {
1007
+ return `${HINT_SOURCE}: ${toolNamed(hint, host)}`;
918
1008
  }
919
1009
  var ONE_BLOCK = "If this does not cover it, make your own call again: you will not be redirected twice in a row for the same search or URL.";
920
1010
  var ONE_BLOCK_QUESTION = "If this does not cover it, ask your question again: you will not be redirected twice in a row for the same question.";
921
1011
  function savedPdfHint(path) {
922
1012
  return `${HINT_SOURCE}: WebFetch's summary cannot read a PDF, but it saved this one whole to ${path}. Read that file for its text, free (pass pages, such as "1-10", for a long one).`;
923
1013
  }
924
- function shortfallOffer(tool, hint) {
925
- return `${HINT_SOURCE}: your ${tool} call came back short. Optional: ${toolNamed(hint)}`;
1014
+ function shortfallOffer(tool, hint, host) {
1015
+ return `${HINT_SOURCE}: your ${tool} call came back short. Optional: ${toolNamed(hint, host)}`;
926
1016
  }
927
1017
  var NEAR_EMPTY_BYTES = 64;
928
1018
  function shortfallOf(event) {
@@ -1026,7 +1116,7 @@ async function spendShortfall(decision, deps, deadline) {
1026
1116
  async function vetOffer(offer, deps, deadline, canAskUser) {
1027
1117
  const shortfall = await spendShortfall(termsOf(offer), deps, deadline);
1028
1118
  if (shortfall === null) {
1029
- const note = await overCapNote(offer.hint, deps, canAskUser);
1119
+ const note = await overCapNote(offer, deps, canAskUser);
1030
1120
  return { offer: note === null ? offer : { ...offer, hint: `${offer.hint} ${note}` } };
1031
1121
  }
1032
1122
  if (offer.action === "discovered" && canAskUser) {
@@ -1036,10 +1126,24 @@ async function vetOffer(offer, deps, deadline, canAskUser) {
1036
1126
  }
1037
1127
  var LISTED_PRICE_RE = /about \$(\d+(?:\.\d+)?)(?= per call|: request\(| \(price can vary)|\$(\d+(?:\.\d+)?)(?=\): request\(| via https?:\/\/)/g;
1038
1128
  var QUOTED_RE = /"(?:[^"\\]|\\.)*"/g;
1039
- async function overCapNote(hint, deps, canAskUser) {
1040
- const listed = [...hint.replace(QUOTED_RE, '""').matchAll(LISTED_PRICE_RE)].map(
1041
- (match) => match[1] ?? match[2]
1042
- );
1129
+ function listedPrices(offer) {
1130
+ if (offer.specs !== void 0) {
1131
+ return offer.specs.filter((spec) => spec.id !== offer.id).map((spec) => BigInt(spec.priceAtomic));
1132
+ }
1133
+ return [...offer.hint.replace(QUOTED_RE, '""').matchAll(LISTED_PRICE_RE)].flatMap((match) => {
1134
+ try {
1135
+ return [BigInt(parseUsdToAtomic(match[1] ?? match[2]))];
1136
+ } catch {
1137
+ return [];
1138
+ }
1139
+ });
1140
+ }
1141
+ function listedUsd(atomic) {
1142
+ const [whole, fraction = ""] = toMoney(atomic.toString()).usd.split(".");
1143
+ return `${whole}.${fraction.padEnd(2, "0")}`;
1144
+ }
1145
+ async function overCapNote(offer, deps, canAskUser) {
1146
+ const listed = listedPrices(offer);
1043
1147
  if (listed.length === 0) return null;
1044
1148
  let cap;
1045
1149
  try {
@@ -1047,26 +1151,16 @@ async function overCapNote(hint, deps, canAskUser) {
1047
1151
  } catch {
1048
1152
  return null;
1049
1153
  }
1050
- const over = [
1051
- ...new Set(
1052
- listed.filter((usd) => {
1053
- try {
1054
- return BigInt(parseUsdToAtomic(usd)) > cap;
1055
- } catch {
1056
- return false;
1057
- }
1058
- })
1059
- )
1060
- ];
1154
+ const over = [...new Set(listed.filter((atomic) => atomic > cap).map(listedUsd))];
1061
1155
  if (over.length === 0) return null;
1062
1156
  const prices = over.map((usd) => `$${usd}`).join(" and ");
1063
1157
  const which = over.length > 1 ? "those services" : "that service";
1064
- return `Note: ${prices} ${over.length > 1 ? "are" : "is"} above this machine's automatic per-call limit ($${toMoney(cap.toString()).usd}), so request returns needs_approval for ${which}; ` + (canAskUser ? "prefer one within the limit, or ask the user first." : "use one within the limit.");
1158
+ return `Note: ${prices} ${over.length > 1 ? "are" : "is"} above this machine's automatic per-call limit ($${toMoney(cap.toString()).usd}), so request returns needs_approval for ${which}; ` + (canAskUser ? "prefer one within the limit." : "use one within the limit.");
1065
1159
  }
1066
1160
  async function walletAddress(dataDir) {
1067
1161
  try {
1068
- const record = JSON.parse(await readFile(walletPath(dataDir), "utf8"));
1069
- const address = record?.address;
1162
+ const record2 = JSON.parse(await readFile(walletPath(dataDir), "utf8"));
1163
+ const address = record2?.address;
1070
1164
  return typeof address === "string" && /^0x[0-9a-fA-F]{40}$/.test(address) ? address : null;
1071
1165
  } catch {
1072
1166
  return null;
@@ -1083,12 +1177,12 @@ function hookContext(deps) {
1083
1177
  };
1084
1178
  }
1085
1179
  async function runPromptHook(raw, deps) {
1086
- const event = decodeEvent(raw);
1180
+ const event = eventOf(raw, deps);
1087
1181
  if (event?.kind !== "prompt") return { response: null };
1088
1182
  return offerOnUserText(event, event.prompt, "UserPromptSubmit", deps);
1089
1183
  }
1090
1184
  async function runAnswerHook(raw, deps) {
1091
- const event = decodeEvent(raw);
1185
+ const event = eventOf(raw, deps);
1092
1186
  if (event?.kind !== "answer" || event.answers === null) return { response: null };
1093
1187
  return offerOnUserText(event, event.answers, "PostToolUse", deps);
1094
1188
  }
@@ -1098,7 +1192,10 @@ async function offerOnUserText(event, text, hookEventName, deps) {
1098
1192
  const router = await routerFor(event.cwd, deps);
1099
1193
  if (router === null) return { response: null };
1100
1194
  const sealed = seal(
1101
- scoped(await buildPromptPacket(event.transcriptPath, event.sessionId, text), router.settings)
1195
+ scoped(
1196
+ await buildPromptPacket(event.transcriptPath, event.sessionId, text, hostOf(deps)),
1197
+ router.settings
1198
+ )
1102
1199
  );
1103
1200
  const footer = await openFooter(deps, event.sessionId, "prompt");
1104
1201
  const deadline = gateDeadline(deps);
@@ -1116,7 +1213,7 @@ async function offerOnUserText(event, text, hookEventName, deps) {
1116
1213
  return {
1117
1214
  action: outcome.action,
1118
1215
  id: outcome.id,
1119
- ...injection(hookEventName, attributed(vetted.offer.hint))
1216
+ ...injection(hookEventName, attributed(vetted.offer.hint, hostOf(deps)))
1120
1217
  };
1121
1218
  }
1122
1219
  function injection(hookEventName, line) {
@@ -1153,7 +1250,8 @@ async function routeNativeCall(event, pending, deps, opts = {}) {
1153
1250
  scoped(
1154
1251
  await buildNativePacket(event.transcriptPath, event.sessionId, pending, {
1155
1252
  ...event.agentId !== void 0 ? { agentId: event.agentId } : {},
1156
- ...nativeOutcome !== void 0 ? { nativeOutcome } : {}
1253
+ ...nativeOutcome !== void 0 ? { nativeOutcome } : {},
1254
+ harness: hostOf(deps)
1157
1255
  }),
1158
1256
  router.settings
1159
1257
  )
@@ -1209,20 +1307,34 @@ async function routeNativeCall(event, pending, deps, opts = {}) {
1209
1307
  return { offer: vetted.offer };
1210
1308
  }
1211
1309
  async function runNativeHook(raw, deps) {
1212
- const event = decodeEvent(raw);
1310
+ const event = eventOf(raw, deps);
1213
1311
  if (event?.kind !== "native" || event.pending === null) return { response: null };
1214
1312
  const target = redirectTarget(event.pending);
1313
+ const targets = [...new Set((event.targets ?? [event.pending]).map(redirectTarget))];
1314
+ const session = localSession(event.sessionId, deps);
1315
+ const claim = (t) => claimRedirect(deps.dataDir, session, event.agentId, t, deps.now?.());
1215
1316
  const routed = await routeNativeCall(event, event.pending, deps, {
1216
1317
  passFree: true,
1217
- repeated: async () => !await claimRedirect(deps.dataDir, event.sessionId, event.agentId, target, deps.now?.()),
1218
- redirected: () => redirectClaimed(deps.dataDir, event.sessionId, event.agentId, target, deps.now?.())
1318
+ repeated: async () => {
1319
+ if (!await claim(target)) return true;
1320
+ await Promise.all(targets.filter((t) => t !== target).map(claim));
1321
+ return false;
1322
+ },
1323
+ redirected: async () => {
1324
+ for (const t of targets) {
1325
+ if (await redirectClaimed(deps.dataDir, session, event.agentId, t, deps.now?.())) {
1326
+ return true;
1327
+ }
1328
+ }
1329
+ return false;
1330
+ }
1219
1331
  });
1220
1332
  if (routed.offer === null) return routed.outcome;
1221
1333
  if (routed.free === true) {
1222
1334
  const { pending } = event;
1223
1335
  const augmenting = pending.tool === "WebSearch" && await startAugment(
1224
1336
  {
1225
- sessionId: event.sessionId,
1337
+ sessionId: session,
1226
1338
  query: pending.query,
1227
1339
  ...event.agentId !== void 0 ? { agentId: event.agentId } : {},
1228
1340
  ...event.toolUseId !== void 0 ? { toolUseId: event.toolUseId } : {}
@@ -1240,11 +1352,32 @@ async function runNativeHook(raw, deps) {
1240
1352
  };
1241
1353
  }
1242
1354
  if (event.toolUseId !== void 0) {
1243
- await markOffered(deps.dataDir, event.sessionId, event.toolUseId, deps.now?.());
1355
+ await markOffered(
1356
+ deps.dataDir,
1357
+ session,
1358
+ event.toolUseId,
1359
+ offeredTerms(routed.offer),
1360
+ deps.now?.()
1361
+ );
1244
1362
  }
1245
- return redirect(routed.offer);
1363
+ return redirect(
1364
+ routed.offer,
1365
+ hostOf(deps),
1366
+ event.rest === void 0 ? ONE_BLOCK : `${ONE_BLOCK} ${restSentence(event.rest)}`
1367
+ );
1368
+ }
1369
+ function restSentence(rest) {
1370
+ return `Nothing else in this web.run call ran either; to run the rest as written, call web.run again with exactly ${JSON.stringify(rest)}`;
1371
+ }
1372
+ function offeredTerms(offer) {
1373
+ const label = (offer.action === "execute" ? offer.label : void 0) ?? offer.specs?.find((spec) => spec.id === offer.id)?.label;
1374
+ return {
1375
+ offerId: offer.id,
1376
+ ...label !== void 0 ? { label } : {},
1377
+ priceAtomic: termsOf(offer).providerPriceAtomic
1378
+ };
1246
1379
  }
1247
- function redirect(offer, oneBlock = ONE_BLOCK) {
1380
+ function redirect(offer, host, oneBlock = ONE_BLOCK) {
1248
1381
  return {
1249
1382
  response: {
1250
1383
  hookSpecificOutput: {
@@ -1253,7 +1386,7 @@ function redirect(offer, oneBlock = ONE_BLOCK) {
1253
1386
  // THE SERVER'S LINE, attributed and tool-named, then this client's one
1254
1387
  // sentence. The line already carries the id and the exact search, URL
1255
1388
  // or question that was denied.
1256
- permissionDecisionReason: `${attributed(offer.hint)} ${oneBlock}`
1389
+ permissionDecisionReason: `${attributed(offer.hint, host)} ${oneBlock}`
1257
1390
  }
1258
1391
  },
1259
1392
  action: offer.action,
@@ -1261,7 +1394,7 @@ function redirect(offer, oneBlock = ONE_BLOCK) {
1261
1394
  };
1262
1395
  }
1263
1396
  async function runAskHook(raw, deps) {
1264
- const event = decodeEvent(raw);
1397
+ const event = eventOf(raw, deps);
1265
1398
  if (event?.kind !== "ask" || event.pending === null) return { response: null };
1266
1399
  const target = redirectTarget(event.pending);
1267
1400
  const routed = await routeNativeCall(event, event.pending, deps, {
@@ -1275,14 +1408,23 @@ async function runAskHook(raw, deps) {
1275
1408
  if (routed.free === true) {
1276
1409
  return { response: null, action: routed.offer.action, id: routed.offer.id, free: true };
1277
1410
  }
1278
- return redirect(routed.offer, ONE_BLOCK_QUESTION);
1411
+ if (event.toolUseId !== void 0) {
1412
+ await markOffered(
1413
+ deps.dataDir,
1414
+ localSession(event.sessionId, deps),
1415
+ event.toolUseId,
1416
+ offeredTerms(routed.offer),
1417
+ deps.now?.()
1418
+ );
1419
+ }
1420
+ return redirect(routed.offer, hostOf(deps), ONE_BLOCK_QUESTION);
1279
1421
  }
1280
1422
  async function runShortfallHook(raw, deps) {
1281
- const event = decodeEvent(raw);
1423
+ const event = eventOf(raw, deps);
1282
1424
  if (event?.kind !== "shortfall") return { response: null };
1283
1425
  const augment = await finishAugment(
1284
1426
  {
1285
- sessionId: event.sessionId,
1427
+ sessionId: localSession(event.sessionId, deps),
1286
1428
  search: event.search,
1287
1429
  ...event.toolUseId !== void 0 ? { toolUseId: event.toolUseId } : {}
1288
1430
  },
@@ -1319,7 +1461,12 @@ async function offerOnShortfall(event, deps, docsJustMissed = false) {
1319
1461
  const { nativeOutcome, pending, eventName } = event;
1320
1462
  if (nativeOutcome === null) return { response: null };
1321
1463
  if (pending === null) return { response: null };
1322
- if (event.toolUseId !== void 0 && await wasOffered(deps.dataDir, event.sessionId, event.toolUseId, deps.now?.())) {
1464
+ if (event.toolUseId !== void 0 && await wasOffered(
1465
+ deps.dataDir,
1466
+ localSession(event.sessionId, deps),
1467
+ event.toolUseId,
1468
+ deps.now?.()
1469
+ )) {
1323
1470
  return { response: null, nativeOutcome, alreadyOffered: true };
1324
1471
  }
1325
1472
  const routed = await routeNativeCall(event, pending, deps, { nativeOutcome });
@@ -1332,7 +1479,7 @@ async function offerOnShortfall(event, deps, docsJustMissed = false) {
1332
1479
  hookEventName: eventName,
1333
1480
  // THE SERVER'S LINE, attributed and framed as the option it is. It
1334
1481
  // already carries the id and the exact search or URL that came back short.
1335
- additionalContext: shortfallOffer(event.tool, routed.offer.hint)
1482
+ additionalContext: shortfallOffer(event.tool, routed.offer.hint, hostOf(deps))
1336
1483
  }
1337
1484
  },
1338
1485
  nativeOutcome,
@@ -1341,7 +1488,7 @@ async function offerOnShortfall(event, deps, docsJustMissed = false) {
1341
1488
  };
1342
1489
  }
1343
1490
  async function runDelegationHook(raw, deps) {
1344
- const event = decodeEvent(raw);
1491
+ const event = eventOf(raw, deps);
1345
1492
  if (event?.kind !== "delegation") return { response: null };
1346
1493
  const { task } = event;
1347
1494
  if (task === null || task.trim().length === 0) return { response: null };
@@ -1393,6 +1540,7 @@ ${delegationOffer(outcome.hint)}`
1393
1540
  };
1394
1541
  }
1395
1542
  async function openFooter(deps, sessionId, operation) {
1543
+ sessionId = localSession(sessionId, deps);
1396
1544
  const now = () => deps.now?.() ?? Date.now();
1397
1545
  const directory = sessionDir(deps.dataDir, sessionId);
1398
1546
  const callId = newCallId();
@@ -1456,6 +1604,7 @@ async function decide({ packet }, deps, config, sessionId, deadline) {
1456
1604
  ctx: hookContext(deps),
1457
1605
  baseUrl,
1458
1606
  acceptsBazaar: resolveExperimentalBazaar(config).value === "on",
1607
+ harness: hostOf(deps),
1459
1608
  timeoutMs: Math.max(0, deadline - now),
1460
1609
  ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {},
1461
1610
  ...route !== null ? { route } : {}
@@ -1536,6 +1685,15 @@ async function routerFor(cwd, deps) {
1536
1685
  function scoped(packet, router) {
1537
1686
  return router.context.value === "turn" ? { ...packet, history: [] } : packet;
1538
1687
  }
1688
+ function hostOf(deps) {
1689
+ return deps.harness ?? "claude";
1690
+ }
1691
+ function eventOf(raw, deps) {
1692
+ return hostOf(deps) === "codex" ? codexRouterEvent(raw) : decodeEvent(raw);
1693
+ }
1694
+ function localSession(sessionId, deps) {
1695
+ return hostOf(deps) === "codex" ? codexSession(sessionId) : sessionId;
1696
+ }
1539
1697
 
1540
1698
  // src/router/hook-command.ts
1541
1699
  var MAX_EVENT_BYTES = 1e6;
@@ -1545,8 +1703,13 @@ async function runHookCommand(kind, io, deps) {
1545
1703
  try {
1546
1704
  const raw = await (deps.readEvent ?? readStdin)();
1547
1705
  const event = JSON.parse(raw);
1548
- if (!launchedByPlugin(deps.env) && await sessionServedByPlugin(deps.dataDir, event)) return;
1549
- response = await runHookKind(kind, event, deps);
1706
+ if (deps.harness === "codex") {
1707
+ const { codexResponse } = await import("./codex-event-PPNVRRDH.js");
1708
+ response = codexResponse(await runHookKind(kind, event, deps));
1709
+ } else {
1710
+ if (!launchedByPlugin(deps.env) && await sessionServedByPlugin(deps.dataDir, event)) return;
1711
+ response = await runHookKind(kind, event, deps);
1712
+ }
1550
1713
  } catch {
1551
1714
  response = null;
1552
1715
  }
@@ -1602,4 +1765,4 @@ export {
1602
1765
  runHookCommand,
1603
1766
  runHookKind
1604
1767
  };
1605
- //# sourceMappingURL=chunk-TTBKWWTV.js.map
1768
+ //# sourceMappingURL=chunk-MNXS2U45.js.map