@opencorelabs/lucidity 0.6.0 → 0.8.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 (253) hide show
  1. package/README.md +18 -3
  2. package/dist/assets/speech/lucidity-speech +0 -0
  3. package/dist/automations/agent.d.ts.map +1 -1
  4. package/dist/automations/agent.js +2 -0
  5. package/dist/automations/designer.d.ts +1 -1
  6. package/dist/chat/server.d.ts +1 -0
  7. package/dist/chat/server.d.ts.map +1 -1
  8. package/dist/chat/server.js +6 -1
  9. package/dist/coding/conduct.d.ts +1 -22
  10. package/dist/coding/conduct.d.ts.map +1 -1
  11. package/dist/coding/conduct.js +9 -94
  12. package/dist/coding/runCodeTurn.d.ts +3 -16
  13. package/dist/coding/runCodeTurn.d.ts.map +1 -1
  14. package/dist/coding/runCodeTurn.js +157 -165
  15. package/dist/coding/workspaceRegistry.d.ts +24 -0
  16. package/dist/coding/workspaceRegistry.d.ts.map +1 -0
  17. package/dist/coding/workspaceRegistry.js +230 -0
  18. package/dist/coding/worktree.d.ts +11 -14
  19. package/dist/coding/worktree.d.ts.map +1 -1
  20. package/dist/coding/worktree.js +41 -21
  21. package/dist/config.d.ts +2 -0
  22. package/dist/config.d.ts.map +1 -1
  23. package/dist/daemonLease.d.ts +12 -0
  24. package/dist/daemonLease.d.ts.map +1 -0
  25. package/dist/daemonLease.js +32 -0
  26. package/dist/goals/assessment.d.ts +115 -0
  27. package/dist/goals/assessment.d.ts.map +1 -0
  28. package/dist/goals/assessment.js +67 -0
  29. package/dist/goals/notes.d.ts +18 -0
  30. package/dist/goals/notes.d.ts.map +1 -0
  31. package/dist/goals/notes.js +72 -0
  32. package/dist/index.js +63 -15
  33. package/dist/jobs/goals.d.ts +15 -0
  34. package/dist/jobs/goals.d.ts.map +1 -0
  35. package/dist/jobs/goals.js +286 -0
  36. package/dist/jobs/weeklyReview.d.ts.map +1 -1
  37. package/dist/jobs/weeklyReview.js +3 -2
  38. package/dist/queue.d.ts +1 -0
  39. package/dist/queue.d.ts.map +1 -1
  40. package/dist/queue.js +4 -0
  41. package/dist/room/client.d.ts +5 -0
  42. package/dist/room/client.d.ts.map +1 -1
  43. package/dist/room/client.js +124 -107
  44. package/dist/room/computer.d.ts.map +1 -1
  45. package/dist/room/computer.js +2 -0
  46. package/dist/room/durablePublish.d.ts +6 -0
  47. package/dist/room/durablePublish.d.ts.map +1 -0
  48. package/dist/room/durablePublish.js +19 -0
  49. package/dist/room/incidents.d.ts +1 -1
  50. package/dist/room/incidents.d.ts.map +1 -1
  51. package/dist/room/incidents.js +14 -7
  52. package/dist/room/turnQueue.d.ts.map +1 -1
  53. package/dist/room/turnQueue.js +27 -24
  54. package/dist/runtimeStore.d.ts +44 -0
  55. package/dist/runtimeStore.d.ts.map +1 -0
  56. package/dist/runtimeStore.js +188 -0
  57. package/dist/setup/server.js +1 -1
  58. package/dist/turnLog.d.ts +10 -40
  59. package/dist/turnLog.d.ts.map +1 -1
  60. package/dist/turnLog.js +33 -56
  61. package/package.json +4 -4
  62. package/src/automations/agent.ts +2 -0
  63. package/src/chat/server.ts +7 -1
  64. package/src/coding/conduct.ts +10 -147
  65. package/src/coding/runCodeTurn.ts +42 -61
  66. package/src/coding/workspaceRegistry.ts +210 -0
  67. package/src/coding/worktree.ts +44 -20
  68. package/src/config.ts +2 -0
  69. package/src/daemonLease.ts +33 -0
  70. package/src/goals/assessment.ts +106 -0
  71. package/src/goals/notes.ts +88 -0
  72. package/src/index.ts +63 -18
  73. package/src/jobs/goals.ts +384 -0
  74. package/src/jobs/weeklyReview.ts +4 -3
  75. package/src/queue.ts +4 -0
  76. package/src/room/client.ts +85 -80
  77. package/src/room/computer.ts +2 -0
  78. package/src/room/durablePublish.ts +25 -0
  79. package/src/room/incidents.ts +16 -8
  80. package/src/room/turnQueue.ts +26 -27
  81. package/src/runtimeStore.ts +190 -0
  82. package/src/setup/server.ts +1 -1
  83. package/src/turnLog.ts +32 -75
  84. package/vendor/decisions/dist/dayPlan.d.ts +9 -0
  85. package/vendor/decisions/dist/dayPlan.js +82 -0
  86. package/vendor/decisions/dist/index.d.ts +1 -0
  87. package/vendor/decisions/dist/index.js +1 -0
  88. package/vendor/decisions/dist/jev.js +3 -1
  89. package/vendor/decisions/src/dayPlan.ts +80 -0
  90. package/vendor/decisions/src/index.ts +1 -0
  91. package/vendor/decisions/src/jev.ts +3 -1
  92. package/vendor/mcp-server/dist/index.js +2 -0
  93. package/vendor/mcp-server/dist/tools/goals.d.ts +4 -0
  94. package/vendor/mcp-server/dist/tools/goals.d.ts.map +1 -0
  95. package/vendor/mcp-server/dist/tools/goals.js +38 -0
  96. package/vendor/mcp-server/package.json +1 -1
  97. package/vendor/mcp-server/src/index.ts +2 -0
  98. package/vendor/mcp-server/src/tools/goals.ts +62 -0
  99. package/vendor/runtime/README.md +2 -2
  100. package/vendor/runtime/dist/executor/asyncQueue.d.ts +1 -0
  101. package/vendor/runtime/dist/executor/asyncQueue.d.ts.map +1 -1
  102. package/vendor/runtime/dist/executor/asyncQueue.js +3 -0
  103. package/vendor/runtime/dist/executor/claudeAgent.d.ts +1 -1
  104. package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
  105. package/vendor/runtime/dist/executor/claudeAgent.js +25 -10
  106. package/vendor/runtime/dist/executor/codex.d.ts +1 -0
  107. package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
  108. package/vendor/runtime/dist/executor/codex.js +69 -36
  109. package/vendor/runtime/dist/executor/codexProtocol/FunctionCallOutputContentItem.d.ts +4 -1
  110. package/vendor/runtime/dist/executor/codexProtocol/FunctionCallOutputContentItem.d.ts.map +1 -1
  111. package/vendor/runtime/dist/executor/codexProtocol/Personality.d.ts +3 -0
  112. package/vendor/runtime/dist/executor/codexProtocol/Personality.d.ts.map +1 -1
  113. package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts +1 -1
  114. package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts.map +1 -1
  115. package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.d.ts +6 -0
  116. package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.d.ts.map +1 -0
  117. package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.js +2 -0
  118. package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts +5 -0
  119. package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts.map +1 -1
  120. package/vendor/runtime/dist/executor/codexProtocol/v2/Model.d.ts +8 -0
  121. package/vendor/runtime/dist/executor/codexProtocol/v2/Model.d.ts.map +1 -1
  122. package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.d.ts +11 -0
  123. package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.d.ts.map +1 -0
  124. package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.js +2 -0
  125. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts +4 -0
  126. package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts.map +1 -1
  127. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts +2 -0
  128. package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts.map +1 -1
  129. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadResumeParams.d.ts +4 -1
  130. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadResumeParams.d.ts.map +1 -1
  131. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStartParams.d.ts +3 -1
  132. package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStartParams.d.ts.map +1 -1
  133. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStartParams.d.ts +7 -2
  134. package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStartParams.d.ts.map +1 -1
  135. package/vendor/runtime/dist/executor/codexProtocol/v2/UserInput.d.ts +3 -0
  136. package/vendor/runtime/dist/executor/codexProtocol/v2/UserInput.d.ts.map +1 -1
  137. package/vendor/runtime/dist/executor/codexRpc.d.ts +10 -3
  138. package/vendor/runtime/dist/executor/codexRpc.d.ts.map +1 -1
  139. package/vendor/runtime/dist/executor/codexRpc.js +18 -3
  140. package/vendor/runtime/dist/executor/codexSessions.d.ts +30 -0
  141. package/vendor/runtime/dist/executor/codexSessions.d.ts.map +1 -0
  142. package/vendor/runtime/dist/executor/codexSessions.js +88 -0
  143. package/vendor/runtime/dist/executor/health.d.ts +2 -1
  144. package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
  145. package/vendor/runtime/dist/executor/health.js +17 -5
  146. package/vendor/runtime/dist/executor/liveTurns.d.ts +2 -1
  147. package/vendor/runtime/dist/executor/liveTurns.d.ts.map +1 -1
  148. package/vendor/runtime/dist/executor/liveTurns.js +12 -5
  149. package/vendor/runtime/dist/executor/ownership.d.ts +35 -0
  150. package/vendor/runtime/dist/executor/ownership.d.ts.map +1 -0
  151. package/vendor/runtime/dist/executor/ownership.js +99 -0
  152. package/vendor/runtime/dist/executor/providerRouter.d.ts +1 -0
  153. package/vendor/runtime/dist/executor/providerRouter.d.ts.map +1 -1
  154. package/vendor/runtime/dist/executor/providerRouter.js +5 -0
  155. package/vendor/runtime/dist/executor/types.d.ts +4 -0
  156. package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
  157. package/vendor/runtime/dist/harness/index.d.ts +1 -0
  158. package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
  159. package/vendor/runtime/dist/harness/index.js +12 -1
  160. package/vendor/runtime/dist/harness/types.d.ts +2 -1
  161. package/vendor/runtime/dist/harness/types.d.ts.map +1 -1
  162. package/vendor/runtime/dist/index.d.ts +1 -0
  163. package/vendor/runtime/dist/index.d.ts.map +1 -1
  164. package/vendor/runtime/dist/index.js +1 -0
  165. package/vendor/runtime/dist/prompts/dayPlanning.d.ts +44 -0
  166. package/vendor/runtime/dist/prompts/dayPlanning.d.ts.map +1 -0
  167. package/vendor/runtime/dist/prompts/dayPlanning.js +42 -0
  168. package/vendor/runtime/src/executor/asyncQueue.ts +3 -0
  169. package/vendor/runtime/src/executor/claudeAgent.ts +20 -9
  170. package/vendor/runtime/src/executor/codex.ts +76 -44
  171. package/vendor/runtime/src/executor/codexProtocol/FunctionCallOutputContentItem.ts +1 -1
  172. package/vendor/runtime/src/executor/codexProtocol/Personality.ts +3 -0
  173. package/vendor/runtime/src/executor/codexProtocol/PlanType.ts +1 -1
  174. package/vendor/runtime/src/executor/codexProtocol/README.md +2 -2
  175. package/vendor/runtime/src/executor/codexProtocol/v2/CyberAccessProgram.ts +9 -0
  176. package/vendor/runtime/src/executor/codexProtocol/v2/GetAccountRateLimitsResponse.ts +5 -0
  177. package/vendor/runtime/src/executor/codexProtocol/v2/Model.ts +11 -2
  178. package/vendor/runtime/src/executor/codexProtocol/v2/ModelAccessPrograms.ts +13 -0
  179. package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitSnapshot.ts +5 -1
  180. package/vendor/runtime/src/executor/codexProtocol/v2/ReviewStartParams.ts +2 -0
  181. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadResumeParams.ts +5 -1
  182. package/vendor/runtime/src/executor/codexProtocol/v2/ThreadStartParams.ts +4 -1
  183. package/vendor/runtime/src/executor/codexProtocol/v2/TurnStartParams.ts +7 -2
  184. package/vendor/runtime/src/executor/codexProtocol/v2/UserInput.ts +1 -1
  185. package/vendor/runtime/src/executor/codexRpc.ts +22 -4
  186. package/vendor/runtime/src/executor/codexSessions.ts +108 -0
  187. package/vendor/runtime/src/executor/health.ts +16 -6
  188. package/vendor/runtime/src/executor/liveTurns.ts +12 -5
  189. package/vendor/runtime/src/executor/ownership.ts +76 -0
  190. package/vendor/runtime/src/executor/providerRouter.ts +6 -0
  191. package/vendor/runtime/src/executor/types.ts +4 -0
  192. package/vendor/runtime/src/harness/index.ts +12 -1
  193. package/vendor/runtime/src/harness/types.ts +2 -1
  194. package/vendor/runtime/src/index.ts +1 -0
  195. package/vendor/runtime/src/prompts/dayPlanning.ts +46 -0
  196. package/vendor/shared/dist/agentCommands.d.ts +1 -0
  197. package/vendor/shared/dist/agentCommands.d.ts.map +1 -1
  198. package/vendor/shared/dist/cardStudio.d.ts +41 -0
  199. package/vendor/shared/dist/cardStudio.d.ts.map +1 -1
  200. package/vendor/shared/dist/cardStudio.js +13 -3
  201. package/vendor/shared/dist/commandLocal.d.ts.map +1 -1
  202. package/vendor/shared/dist/commandLocal.js +2 -0
  203. package/vendor/shared/dist/commands.d.ts +18 -0
  204. package/vendor/shared/dist/commands.d.ts.map +1 -1
  205. package/vendor/shared/dist/commands.js +2 -0
  206. package/vendor/shared/dist/computer.d.ts +7 -1
  207. package/vendor/shared/dist/computer.d.ts.map +1 -1
  208. package/vendor/shared/dist/computer.js +13 -2
  209. package/vendor/shared/dist/constants.d.ts +3 -3
  210. package/vendor/shared/dist/constants.d.ts.map +1 -1
  211. package/vendor/shared/dist/constants.js +5 -4
  212. package/vendor/shared/dist/dayPlan.d.ts +86 -0
  213. package/vendor/shared/dist/dayPlan.d.ts.map +1 -0
  214. package/vendor/shared/dist/dayPlan.js +46 -0
  215. package/vendor/shared/dist/dayPlanning.d.ts +139 -0
  216. package/vendor/shared/dist/dayPlanning.d.ts.map +1 -0
  217. package/vendor/shared/dist/dayPlanning.js +67 -0
  218. package/vendor/shared/dist/goalNotes.d.ts +4 -0
  219. package/vendor/shared/dist/goalNotes.d.ts.map +1 -0
  220. package/vendor/shared/dist/goalNotes.js +23 -0
  221. package/vendor/shared/dist/goals.d.ts +835 -0
  222. package/vendor/shared/dist/goals.d.ts.map +1 -0
  223. package/vendor/shared/dist/goals.js +198 -0
  224. package/vendor/shared/dist/index.d.ts +5 -0
  225. package/vendor/shared/dist/index.d.ts.map +1 -1
  226. package/vendor/shared/dist/index.js +5 -0
  227. package/vendor/shared/dist/schemas/harness.d.ts +155 -0
  228. package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
  229. package/vendor/shared/dist/schemas/harness.js +8 -0
  230. package/vendor/shared/dist/workspaces.d.ts +138 -0
  231. package/vendor/shared/dist/workspaces.d.ts.map +1 -0
  232. package/vendor/shared/dist/workspaces.js +40 -0
  233. package/vendor/shared/src/agentCommands.ts +1 -0
  234. package/vendor/shared/src/cardStudio.ts +13 -3
  235. package/vendor/shared/src/commandLocal.ts +2 -0
  236. package/vendor/shared/src/commands.ts +2 -0
  237. package/vendor/shared/src/computer.ts +18 -2
  238. package/vendor/shared/src/constants.ts +5 -4
  239. package/vendor/shared/src/dayPlan.ts +81 -0
  240. package/vendor/shared/src/dayPlanning.ts +77 -0
  241. package/vendor/shared/src/goalNotes.ts +23 -0
  242. package/vendor/shared/src/goals.ts +237 -0
  243. package/vendor/shared/src/index.ts +6 -0
  244. package/vendor/shared/src/schemas/harness.ts +8 -0
  245. package/vendor/shared/src/workspaces.ts +48 -0
  246. package/dist/coding/fleetIntegrate.d.ts +0 -37
  247. package/dist/coding/fleetIntegrate.d.ts.map +0 -1
  248. package/dist/coding/fleetIntegrate.js +0 -64
  249. package/dist/coding/openFleetPr.d.ts +0 -41
  250. package/dist/coding/openFleetPr.d.ts.map +0 -1
  251. package/dist/coding/openFleetPr.js +0 -121
  252. package/src/coding/fleetIntegrate.ts +0 -95
  253. package/src/coding/openFleetPr.ts +0 -148
@@ -21,7 +21,9 @@ export type ThreadStartParams = {
21
21
  } | null;
22
22
  serviceName?: string | null;
23
23
  baseInstructions?: string | null;
24
- developerInstructions?: string | null;
24
+ developerInstructions?: string | null; /**
25
+ * @deprecated `friendly` and `pragmatic` no longer select a style.
26
+ */
25
27
  personality?: Personality | null;
26
28
  ephemeral?: boolean | null;
27
29
  sessionStartSource?: ThreadStartSource | null; /**
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadStartParams.d.ts","sourceRoot":"","sources":["../../../../src/executor/codexProtocol/v2/ThreadStartParams.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mB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AE,OAAO,GAAG,IAAI,CAAC;IAAC,kBAAkB,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC,CAAC;;OAE1G;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAA;CAAC,CAAC"}
@@ -8,7 +8,11 @@ import type { SandboxPolicy } from "./SandboxPolicy.js";
8
8
  import type { TurnToolOutput } from "./TurnToolOutput.js";
9
9
  import type { UserInput } from "./UserInput.js";
10
10
  export type TurnStartParams = {
11
- threadId: string;
11
+ threadId: string; /**
12
+ * Replace this thread's disabled plugin IDs.
13
+ * Omitted/null preserves the list; [] clears it.
14
+ */
15
+ disabledPluginIds?: Array<string> | null;
12
16
  clientUserMessageId?: string | null;
13
17
  input: Array<UserInput>; /**
14
18
  * Optional source classification for the caller that starts this turn.
@@ -46,7 +50,8 @@ export type TurnStartParams = {
46
50
  * Override the reasoning summary for this turn and subsequent turns.
47
51
  */
48
52
  summary?: ReasoningSummary | null; /**
49
- * Override the personality for this turn and subsequent turns.
53
+ * @deprecated `friendly` and `pragmatic` no longer select a style.
54
+ * Changing this does not rewrite the thread's existing instructions.
50
55
  */
51
56
  personality?: Personality | null; /**
52
57
  * Optional JSON Schema used to constrain the final assistant message for
@@ -1 +1 @@
1
- {"version":3,"file":"TurnStartParams.d.ts","sourceRoot":"","sources":["../../../../src/executor/codexProtocol/v2/TurnStartParams.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,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AM,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;;;;OAIjC;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;;OAEjC;IACH,MAAM,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC,CAAC;;OAE9B;IACH,OAAO,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC,CAAC;;;OAGhC;IACH,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC;;;OAG/B;IACH,YAAY,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;CAAC,CAAC"}
@@ -10,8 +10,11 @@ export type UserInput = {
10
10
  } | {
11
11
  "type": "image";
12
12
  detail?: ImageDetail;
13
+ } & ({
13
14
  url: string;
14
15
  } | {
16
+ fileId: string;
17
+ }) | {
15
18
  "type": "localImage";
16
19
  detail?: ImageDetail;
17
20
  path: string;
@@ -1 +1 @@
1
- {"version":3,"file":"UserInput.d.ts","sourceRoot":"","sources":["../../../../src/executor/codexProtocol/v2/UserInput.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,MAAM,SAAS,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IACvD;;OAEG;IACH,aAAa,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;CAAE,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;CAAE,GAAG;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;CAAE,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;CAAE,GAAG;IAAE,MAAM,EA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I,EAAE,MAAM,CAAC;CAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { AsyncQueue } from './asyncQueue.js';
2
- export declare const CODEX_RUNTIME_VERSION = "0.153.4";
2
+ export declare const CODEX_RUNTIME_VERSION = "0.160.0";
3
3
  export interface RpcMessage {
4
4
  id?: number | string;
5
5
  method?: string;
@@ -10,11 +10,14 @@ export interface RpcMessage {
10
10
  };
11
11
  }
12
12
  export interface CodexConnection {
13
+ readonly isConnected?: boolean;
13
14
  events: AsyncIterable<RpcMessage>;
14
15
  request<T>(method: string, params: unknown): Promise<T>;
15
16
  respond(id: number | string, result: unknown): void;
16
17
  onRequest?: (message: RpcMessage) => Promise<unknown>;
17
- close(): void;
18
+ /** Completed turns may retain the transport while discarding idle notifications. */
19
+ setIdle?(idle: boolean): void;
20
+ close(): void | Promise<void>;
18
21
  }
19
22
  export declare function codexSubscriptionEnv(): NodeJS.ProcessEnv;
20
23
  /** Bidirectional stdio JSON-RPC. Pending requests fail on timeout or child exit. */
@@ -22,16 +25,20 @@ export declare class CodexRpc implements CodexConnection {
22
25
  readonly events: AsyncQueue<RpcMessage>;
23
26
  onRequest?: (message: RpcMessage) => Promise<unknown>;
24
27
  private child;
28
+ private readonly exited;
25
29
  private sequence;
26
30
  private closed;
31
+ private idle;
32
+ get isConnected(): boolean;
27
33
  private pending;
28
34
  constructor(command?: string, cwd?: string);
29
35
  private write;
36
+ setIdle(idle: boolean): void;
30
37
  notify(method: string, params?: unknown): void;
31
38
  respond(id: number | string, result: unknown): void;
32
39
  request<T>(method: string, params: unknown): Promise<T>;
33
40
  private finish;
34
- close(): void;
41
+ close(): Promise<void>;
35
42
  }
36
43
  export declare function initializeCodex(rpc: CodexConnection): Promise<void>;
37
44
  //# sourceMappingURL=codexRpc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codexRpc.d.ts","sourceRoot":"","sources":["../../src/executor/codexRpc.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MA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);
7
7
  const { version: lucidityVersion } = require('../../package.json');
8
- export const CODEX_RUNTIME_VERSION = '0.153.4';
8
+ export const CODEX_RUNTIME_VERSION = '0.160.0';
9
9
  export function codexSubscriptionEnv() {
10
10
  const env = stripUnsafeEnv(process.env);
11
11
  for (const key of ['OPENAI_API_KEY', 'CODEX_API_KEY', 'OPENAI_BASE_URL'])
@@ -17,8 +17,13 @@ export class CodexRpc {
17
17
  events = new AsyncQueue();
18
18
  onRequest;
19
19
  child;
20
+ exited;
20
21
  sequence = 0;
21
22
  closed = false;
23
+ idle = false;
24
+ get isConnected() {
25
+ return !this.closed;
26
+ }
22
27
  pending = new Map();
23
28
  constructor(command, cwd) {
24
29
  const prefix = command
@@ -38,6 +43,10 @@ export class CodexRpc {
38
43
  env: codexSubscriptionEnv(),
39
44
  stdio: ['pipe', 'pipe', 'pipe'],
40
45
  });
46
+ this.exited = new Promise((resolve) => {
47
+ this.child.once('close', () => resolve());
48
+ this.child.once('error', () => resolve());
49
+ });
41
50
  // Drain stderr without retaining potentially sensitive prompt/config diagnostics.
42
51
  this.child.stderr.on('data', () => { });
43
52
  this.child.stdin.on('error', () => { });
@@ -74,7 +83,7 @@ export class CodexRpc {
74
83
  else
75
84
  pending.resolve(message.result);
76
85
  }
77
- else if (message.method && !this.closed)
86
+ else if (message.method && !this.closed && !this.idle)
78
87
  this.events.push(message);
79
88
  });
80
89
  }
@@ -83,6 +92,11 @@ export class CodexRpc {
83
92
  throw new Error('Codex is disconnected.');
84
93
  this.child.stdin.write(JSON.stringify(value) + '\n');
85
94
  }
95
+ setIdle(idle) {
96
+ this.idle = idle;
97
+ if (idle)
98
+ this.events.discardPending();
99
+ }
86
100
  notify(method, params) {
87
101
  this.write({ method, params });
88
102
  }
@@ -132,8 +146,9 @@ export class CodexRpc {
132
146
  kill.unref();
133
147
  this.child.once('close', () => clearTimeout(kill));
134
148
  }
135
- close() {
149
+ async close() {
136
150
  this.finish(new Error('Codex session closed.'));
151
+ await this.exited;
137
152
  }
138
153
  }
139
154
  export async function initializeCodex(rpc) {
@@ -0,0 +1,30 @@
1
+ import type { CodexConnection } from './codexRpc.js';
2
+ /** Rust maps may arrive in a different order; credentials never become a stored key. */
3
+ export declare function codexBindingFingerprint(value: unknown): string;
4
+ export interface CodexThread {
5
+ thread: {
6
+ id: string;
7
+ };
8
+ model?: string;
9
+ reasoningEffort?: string | null;
10
+ cwd?: string;
11
+ }
12
+ export interface CodexSession {
13
+ rpc: CodexConnection;
14
+ thread: CodexThread;
15
+ fingerprint: string;
16
+ }
17
+ /** Completed threads retain one transport; idle eviction still awaits the native exit. */
18
+ export declare class CodexSessions {
19
+ private readonly limit;
20
+ private readonly idleMs;
21
+ private idle;
22
+ private closing;
23
+ private disposed;
24
+ constructor(limit?: number, idleMs?: number);
25
+ take(id?: string): Promise<CodexSession | undefined>;
26
+ private evict;
27
+ keep(session: CodexSession): Promise<void>;
28
+ dispose(): Promise<void>;
29
+ }
30
+ //# sourceMappingURL=codexSessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codexSessions.d.ts","sourceRoot":"","sources":["../../src/executor/codexSessions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD,wFAAwF;AACxF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAc9D;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AACD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,eAAe,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,0FAA0F;AAC1F,qBAAa,aAAa;IAQtB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IARzB,OAAO,CAAC,IAAI,CAGR;IACJ,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,QAAQ,CAAS;gBAEN,KAAK,SAAI,EACT,MAAM,SAAa;IAGhC,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAgB1D,OAAO,CAAC,KAAK;IAcP,IAAI,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B1C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAK/B"}
@@ -0,0 +1,88 @@
1
+ import { createHash } from 'node:crypto';
2
+ /** Rust maps may arrive in a different order; credentials never become a stored key. */
3
+ export function codexBindingFingerprint(value) {
4
+ const ordered = (value) => Array.isArray(value)
5
+ ? value.map(ordered)
6
+ : value && typeof value === 'object'
7
+ ? Object.fromEntries(Object.entries(value)
8
+ .sort(([a], [b]) => a.localeCompare(b))
9
+ .map(([key, item]) => [key, ordered(item)]))
10
+ : value;
11
+ return createHash('sha256')
12
+ .update(JSON.stringify(ordered(value)))
13
+ .digest('hex');
14
+ }
15
+ /** Completed threads retain one transport; idle eviction still awaits the native exit. */
16
+ export class CodexSessions {
17
+ limit;
18
+ idleMs;
19
+ idle = new Map();
20
+ closing = new Map();
21
+ disposed = false;
22
+ constructor(limit = 2, idleMs = 3 * 60_000) {
23
+ this.limit = limit;
24
+ this.idleMs = idleMs;
25
+ }
26
+ async take(id) {
27
+ if (!id)
28
+ return;
29
+ await this.closing.get(id);
30
+ if (this.disposed)
31
+ throw new Error('Codex is shutting down.');
32
+ const session = this.idle.get(id);
33
+ if (!session)
34
+ return;
35
+ clearTimeout(session.timer);
36
+ this.idle.delete(id);
37
+ if (session.rpc.isConnected === false) {
38
+ await session.rpc.close();
39
+ return;
40
+ }
41
+ session.rpc.setIdle?.(false);
42
+ return session;
43
+ }
44
+ evict(id) {
45
+ const session = this.idle.get(id);
46
+ if (!session)
47
+ return this.closing.get(id) ?? Promise.resolve();
48
+ clearTimeout(session.timer);
49
+ this.idle.delete(id);
50
+ const closing = Promise.resolve()
51
+ .then(() => session.rpc.close())
52
+ .finally(() => {
53
+ if (this.closing.get(id) === closing)
54
+ this.closing.delete(id);
55
+ });
56
+ this.closing.set(id, closing);
57
+ return closing;
58
+ }
59
+ async keep(session) {
60
+ const id = session.thread.thread.id;
61
+ if (this.disposed ||
62
+ session.rpc.isConnected === false ||
63
+ !session.rpc.setIdle ||
64
+ this.limit <= 0) {
65
+ await session.rpc.close();
66
+ return;
67
+ }
68
+ await this.evict(id);
69
+ if (this.disposed) {
70
+ await session.rpc.close();
71
+ return;
72
+ }
73
+ session.rpc.onRequest = undefined;
74
+ session.rpc.setIdle(true);
75
+ const timer = setTimeout(() => {
76
+ void this.evict(id).catch(() => { });
77
+ }, this.idleMs);
78
+ timer.unref();
79
+ this.idle.set(id, { ...session, timer });
80
+ while (this.idle.size > this.limit)
81
+ await this.evict(this.idle.keys().next().value);
82
+ }
83
+ async dispose() {
84
+ this.disposed = true;
85
+ await Promise.all([...this.idle.keys()].map((id) => this.evict(id)));
86
+ await Promise.all(this.closing.values());
87
+ }
88
+ }
@@ -1,6 +1,6 @@
1
1
  import type { ProviderHealth } from '@lucidity/shared';
2
2
  import type { AgentExecutor, ExecutorRunInput } from './types.js';
3
- export declare function providerFailure(error: unknown): Pick<ProviderHealth, 'auth' | 'allowance' | 'problem'>;
3
+ export declare function providerFailure(error: unknown): Pick<ProviderHealth, 'auth' | 'allowance' | 'problem'> | undefined;
4
4
  /** Observes the same adapter used by interactive and scheduled work. No probe inference. */
5
5
  export declare class HealthAwareExecutor implements AgentExecutor {
6
6
  private readonly executor;
@@ -25,6 +25,7 @@ export declare class HealthAwareExecutor implements AgentExecutor {
25
25
  upgrade?: string | undefined;
26
26
  }[]>;
27
27
  commands(input?: Pick<ExecutorRunInput, 'cwd' | 'permissionMode' | 'mcp'>): Promise<import("@lucidity/shared").AgentCommandOption[]>;
28
+ withOwnership<T>(input: ExecutorRunInput, action: () => Promise<T>): Promise<T>;
28
29
  run(input: ExecutorRunInput): Promise<import("./types.js").ExecutorResult>;
29
30
  runStream(input: ExecutorRunInput): AsyncGenerator<import("./types.js").ExecutorStreamEvent, void, unknown>;
30
31
  steer(requestId: string, text: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/executor/health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAElE,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO,GACb,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC,CAmBxD;AAED,4FAA4F;AAC5F,qBAAa,mBAAoB,YAAW,aAAa;IAK3C,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAJrC,QAAQ,CAAC,YAAY,QAAQ;IAC7B,OAAO,CAAC,KAAK,CAA6D;IAC1E,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,KAAK,CAA4D;gBAC5C,QAAQ,EAAE,aAAa;IACpD,IAAI,IAAI,WAEP;IACD,MAAM,IAAI,cAAc;IAGxB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI;IAM9B,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,MAAM;IAOR,MAAM;;;;;;;;;;IAqBN,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,gBAAgB,GAAG,KAAK,CAAC;IAGzE,GAAG,CAAC,KAAK,EAAE,gBAAgB;IAU1B,SAAS,CAAC,KAAK,EAAE,gBAAgB;IAcxC,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAK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+8,8 @@ export function providerFailure(error) {
8
8
  };
9
9
  if (/login|sign.?in|authenticat|oauth|unauthorized|token.*expir|subscription.*auth/i.test(message))
10
10
  return { auth: 'login_required', allowance: 'unknown', problem: 'login' };
11
- return { auth: 'unknown', allowance: 'unknown', problem: 'unavailable' };
11
+ // A failed thread, command, model, or workspace says nothing about account readiness.
12
+ return undefined;
12
13
  }
13
14
  /** Observes the same adapter used by interactive and scheduled work. No probe inference. */
14
15
  export class HealthAwareExecutor {
@@ -39,13 +40,17 @@ export class HealthAwareExecutor {
39
40
  }
40
41
  failed(error, signal) {
41
42
  if (!signal?.aborted &&
42
- !(error instanceof Error && error.name === 'AbortError'))
43
- this.update(providerFailure(error));
43
+ !(error instanceof Error && error.name === 'AbortError')) {
44
+ const failure = providerFailure(error);
45
+ if (failure)
46
+ this.update(failure);
47
+ }
44
48
  }
45
49
  async models() {
46
50
  if (this.check)
47
51
  return this.check;
48
- this.update({ ...this.state, auth: 'checking' });
52
+ if (this.state.auth !== 'authenticated')
53
+ this.update({ ...this.state, auth: 'checking' });
49
54
  this.check = (async () => {
50
55
  try {
51
56
  if (!this.executor.models)
@@ -57,7 +62,11 @@ export class HealthAwareExecutor {
57
62
  return models;
58
63
  }
59
64
  catch (error) {
60
- this.failed(error);
65
+ const failure = providerFailure(error);
66
+ if (failure)
67
+ this.update(failure);
68
+ else if (this.state.auth !== 'authenticated')
69
+ this.update({ auth: 'unknown', allowance: 'unknown', problem: 'unavailable' });
61
70
  throw error;
62
71
  }
63
72
  finally {
@@ -69,6 +78,9 @@ export class HealthAwareExecutor {
69
78
  async commands(input) {
70
79
  return (await this.executor.commands?.(input)) ?? [];
71
80
  }
81
+ withOwnership(input, action) {
82
+ return this.executor.withOwnership ? this.executor.withOwnership(input, action) : action();
83
+ }
72
84
  async run(input) {
73
85
  try {
74
86
  const result = await this.executor.run(input);
@@ -2,6 +2,7 @@ import type { ExecutorRunInput } from './types.js';
2
2
  export declare function abortError(): Error;
3
3
  /** Request-scoped ownership. Control calls never wait behind the work queue. */
4
4
  export declare class LiveTurns {
5
+ private disposed;
5
6
  private turns;
6
7
  open(input: ExecutorRunInput, steer: (text: string) => Promise<void>): {
7
8
  controller: AbortController;
@@ -10,6 +11,6 @@ export declare class LiveTurns {
10
11
  };
11
12
  steer(id: string, text: string): Promise<void>;
12
13
  interrupt(id: string): boolean;
13
- dispose(): void;
14
+ dispose(): Promise<void>;
14
15
  }
15
16
  //# sourceMappingURL=liveTurns.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"liveTurns.d.ts","sourceRoot":"","sources":["../../src/executor/liveTurns.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAgB,UAAU,IAAI,KAAK,CAIlC;AAED,gFAAgF;AAChF,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAGT;IAEJ,IAAI,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;;;;;IA6B9D,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYpD,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAO9B,OAAO,IAAI,IAAI;CAIhB"}
1
+ {"version":3,"file":"liveTurns.d.ts","sourceRoot":"","sources":["../../src/executor/liveTurns.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAgB,UAAU,IAAI,KAAK,CAIlC;AAED,gFAAgF;AAChF,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAGT;IAEJ,IAAI,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;;;;;IAiC9D,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYpD,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAOxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAM/B"}
@@ -7,8 +7,11 @@ export function abortError() {
7
7
  }
8
8
  /** Request-scoped ownership. Control calls never wait behind the work queue. */
9
9
  export class LiveTurns {
10
+ disposed = false;
10
11
  turns = new Map();
11
12
  open(input, steer) {
13
+ if (this.disposed)
14
+ throw new Error('The provider is shutting down.');
12
15
  const id = input.requestId ?? randomUUID();
13
16
  if (id && this.turns.has(id))
14
17
  throw new Error('This request is already running.');
@@ -23,8 +26,9 @@ export class LiveTurns {
23
26
  timedOut = true;
24
27
  abort();
25
28
  }, input.timeoutMs ?? 120_000);
26
- if (id)
27
- this.turns.set(id, { abort, steer });
29
+ let settle;
30
+ const settled = new Promise((resolve) => { settle = resolve; });
31
+ this.turns.set(id, { abort, steer, settled });
28
32
  return {
29
33
  controller,
30
34
  check: () => {
@@ -39,6 +43,7 @@ export class LiveTurns {
39
43
  if (id)
40
44
  this.turns.delete(id);
41
45
  abort();
46
+ settle();
42
47
  },
43
48
  };
44
49
  }
@@ -59,9 +64,11 @@ export class LiveTurns {
59
64
  turn.abort();
60
65
  return true;
61
66
  }
62
- dispose() {
63
- for (const turn of this.turns.values())
67
+ async dispose() {
68
+ this.disposed = true;
69
+ const active = [...this.turns.values()];
70
+ for (const turn of active)
64
71
  turn.abort();
65
- this.turns.clear();
72
+ await Promise.all(active.map((turn) => turn.settled));
66
73
  }
67
74
  }
@@ -0,0 +1,35 @@
1
+ import type { AgentExecutor, ExecutorRunInput } from './types.js';
2
+ /** Shared across providers and callers, including scheduled and local chat work. */
3
+ export declare class ExecutionOwnership {
4
+ private context;
5
+ run<T>(keys: string[], action: () => Promise<T>, signal?: AbortSignal): Promise<T>;
6
+ private owners;
7
+ acquire(keys: string[], signal?: AbortSignal): Promise<() => void>;
8
+ }
9
+ export declare class OwnedExecutor implements AgentExecutor {
10
+ private readonly executor;
11
+ private readonly provider;
12
+ private readonly ownership;
13
+ constructor(executor: AgentExecutor, provider: string, ownership: ExecutionOwnership);
14
+ get name(): string;
15
+ get strictResume(): boolean | undefined;
16
+ private keys;
17
+ withOwnership<T>(input: ExecutorRunInput, action: () => Promise<T>): Promise<T>;
18
+ run(input: ExecutorRunInput): Promise<import("./types.js").ExecutorResult>;
19
+ runStream(input: ExecutorRunInput): AsyncGenerator<import("./types.js").ExecutorStreamEvent, void, any>;
20
+ models(): Promise<{
21
+ id: string;
22
+ label: string;
23
+ efforts: string[];
24
+ resolvedId?: string | undefined;
25
+ description?: string | undefined;
26
+ isDefault?: boolean | undefined;
27
+ defaultEffort?: string | undefined;
28
+ upgrade?: string | undefined;
29
+ }[]>;
30
+ commands(input?: Pick<ExecutorRunInput, 'cwd' | 'permissionMode' | 'mcp'>): Promise<import("@lucidity/shared").AgentCommandOption[]>;
31
+ steer(id: string, text: string): Promise<void>;
32
+ interrupt(id: string): Promise<boolean>;
33
+ dispose(): Promise<void>;
34
+ }
35
+ //# sourceMappingURL=ownership.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ownership.d.ts","sourceRoot":"","sources":["../../src/executor/ownership.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGlE,oFAAoF;AACpF,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAAwC;IAEjD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;IAOxF,OAAO,CAAC,MAAM,CAAoC;IAE5C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;CAoBzE;AAMD,qBAAa,aAAc,YAAW,aAAa;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAAiB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAAU,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAtF,QAAQ,EAAE,aAAa,EAAmB,QAAQ,EAAE,MAAM,EAAmB,SAAS,EAAE,kBAAkB;IACvI,IAAI,IAAI,WAAiC;IACzC,IAAI,YAAY,wBAAyC;IACzD,OAAO,CAAC,IAAI;IAOZ,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAGzE,GAAG,CAAC,KAAK,EAAE,gBAAgB;IAI1B,SAAS,CAAC,KAAK,EAAE,gBAAgB;IAOxC,MAAM;;;;;;;;;;IACN,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,gBAAgB,GAAG,KAAK,CAAC;IACzE,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAC9B,SAAS,CAAC,EAAE,EAAE,MAAM;IACd,OAAO;CACd"}
@@ -0,0 +1,99 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import { realpathSync } from 'node:fs';
3
+ import { resolve } from 'node:path';
4
+ import { abortError } from './liveTurns.js';
5
+ /** Shared across providers and callers, including scheduled and local chat work. */
6
+ export class ExecutionOwnership {
7
+ context = new AsyncLocalStorage();
8
+ async run(keys, action, signal) {
9
+ const held = this.context.getStore() ?? new Set();
10
+ const release = await this.acquire(keys, signal);
11
+ try {
12
+ return await this.context.run(new Set([...held, ...keys]), action);
13
+ }
14
+ finally {
15
+ release();
16
+ }
17
+ }
18
+ owners = new Map();
19
+ async acquire(keys, signal) {
20
+ keys = [...new Set(keys)].filter((key) => !this.context.getStore()?.has(key));
21
+ for (;;) {
22
+ if (signal?.aborted)
23
+ throw abortError();
24
+ const blocked = keys.flatMap((key) => this.owners.get(key) ?? []);
25
+ if (!blocked.length)
26
+ break;
27
+ await new Promise((resolve, reject) => {
28
+ const abort = () => reject(abortError());
29
+ signal?.addEventListener('abort', abort, { once: true });
30
+ Promise.race(blocked).then(resolve, reject).finally(() => signal?.removeEventListener('abort', abort));
31
+ });
32
+ }
33
+ let release;
34
+ const settled = new Promise((resolve) => { release = resolve; });
35
+ for (const key of keys)
36
+ this.owners.set(key, settled);
37
+ return () => {
38
+ for (const key of keys)
39
+ if (this.owners.get(key) === settled)
40
+ this.owners.delete(key);
41
+ release();
42
+ };
43
+ }
44
+ }
45
+ function workspaceKey(path) {
46
+ try {
47
+ return realpathSync(path);
48
+ }
49
+ catch {
50
+ return resolve(path);
51
+ }
52
+ }
53
+ export class OwnedExecutor {
54
+ executor;
55
+ provider;
56
+ ownership;
57
+ constructor(executor, provider, ownership) {
58
+ this.executor = executor;
59
+ this.provider = provider;
60
+ this.ownership = ownership;
61
+ }
62
+ get name() { return this.executor.name; }
63
+ get strictResume() { return this.executor.strictResume; }
64
+ keys(input) {
65
+ const session = input.resume ?? input.sessionId;
66
+ return [
67
+ ...(session ? [`session:${this.provider}:${session}`] : []),
68
+ ...(input.cwd && input.permissionMode && !input.noTools ? [`workspace:${workspaceKey(input.cwd)}`] : []),
69
+ ];
70
+ }
71
+ withOwnership(input, action) {
72
+ return this.ownership.run(this.keys(input), action, input.signal);
73
+ }
74
+ async run(input) {
75
+ const release = await this.ownership.acquire(this.keys(input), input.signal);
76
+ try {
77
+ return await this.executor.run(input);
78
+ }
79
+ finally {
80
+ release();
81
+ }
82
+ }
83
+ async *runStream(input) {
84
+ const release = await this.ownership.acquire(this.keys(input), input.signal);
85
+ try {
86
+ if (!this.executor.runStream)
87
+ throw new Error('This provider cannot stream.');
88
+ yield* this.executor.runStream(input);
89
+ }
90
+ finally {
91
+ release();
92
+ }
93
+ }
94
+ models() { return this.executor.models?.() ?? Promise.resolve([]); }
95
+ commands(input) { return this.executor.commands?.(input) ?? Promise.resolve([]); }
96
+ steer(id, text) { return this.executor.steer?.(id, text) ?? Promise.reject(new Error('Steering is unavailable.')); }
97
+ interrupt(id) { return this.executor.interrupt?.(id) ?? Promise.resolve(false); }
98
+ async dispose() { await this.executor.dispose?.(); }
99
+ }
@@ -19,6 +19,7 @@ export declare class ProviderRouter implements AgentExecutor {
19
19
  effort?: string;
20
20
  });
21
21
  private resolve;
22
+ withOwnership<T>(input: ExecutorRunInput, action: () => Promise<T>): Promise<T>;
22
23
  run(input: ExecutorRunInput): Promise<{
23
24
  sessionId: string | undefined;
24
25
  text: string;
@@ -1 +1 @@
1
- {"version":3,"file":"providerRouter.d.ts","sourceRoot":"","sources":["../../src/executor/providerRouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAGpB,UAAU,UAAU;IAClB,QAAQ,EAAE,aAAa,CAAC;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAErD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAkBvD;AAED,sFAAsF;AACtF,qBAAa,cAAe,YAAW,aAAa;IAIhD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAJ3B,QAAQ,CAAC,IAAI,qBAAqB;IAClC,QAAQ,CAAC,YAAY,QAAQ;gBAEV,SAAS,EAAE,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,EAC/C,QAAQ,EAAE,MAAM;QAC/B,QAAQ,EAAE,aAAa,CAAC;QACxB,KAAK,CA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AE,gBAAgB;;;;;IAgB1B,SAAS,CACd,KAAK,EAAE,gBAAgB,GACtB,aAAa,CAAC,mBAAmB,CAAC;CAmBtC"}
@@ -54,6 +54,11 @@ export class ProviderRouter {
54
54
  },
55
55
  };
56
56
  }
57
+ withOwnership(input, action) {
58
+ const r = this.resolve(input);
59
+ const executor = this.providers[r.provider];
60
+ return executor.withOwnership ? executor.withOwnership(r.input, action) : action();
61
+ }
57
62
  async run(input) {
58
63
  const r = this.resolve(input);
59
64
  const result = await this.providers[r.provider].run(r.input);