@agentstep/agent-sdk 0.5.10 → 0.5.12

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 (218) hide show
  1. package/dist/auth/middleware.js +8 -8
  2. package/dist/backends/claude/args.js +6 -6
  3. package/dist/backends/claude/index.js +12 -12
  4. package/dist/backends/claude/wrapper-script.js +1 -1
  5. package/dist/backends/codex/auth.js +6 -6
  6. package/dist/backends/codex/index.js +14 -14
  7. package/dist/backends/codex/setup.js +2 -2
  8. package/dist/backends/codex/wrapper-script.js +1 -1
  9. package/dist/backends/factory/auth.js +6 -6
  10. package/dist/backends/factory/index.js +16 -16
  11. package/dist/backends/factory/setup.js +2 -2
  12. package/dist/backends/factory/wrapper-script.js +1 -1
  13. package/dist/backends/gemini/auth.js +6 -6
  14. package/dist/backends/gemini/index.js +12 -12
  15. package/dist/backends/gemini/setup.js +2 -2
  16. package/dist/backends/gemini/wrapper-script.js +1 -1
  17. package/dist/backends/opencode/auth.js +6 -6
  18. package/dist/backends/opencode/index.js +14 -14
  19. package/dist/backends/opencode/setup.js +2 -2
  20. package/dist/backends/opencode/wrapper-script.js +1 -1
  21. package/dist/backends/pi/auth.js +6 -6
  22. package/dist/backends/pi/index.js +14 -14
  23. package/dist/backends/pi/setup.js +2 -2
  24. package/dist/backends/pi/wrapper-script.js +1 -1
  25. package/dist/backends/registry.js +36 -36
  26. package/dist/{chunk-ZEDULYKX.js → chunk-2IISXUVF.js} +1 -1
  27. package/dist/{chunk-34Q6WMIT.js → chunk-2Z56TPBL.js} +3 -3
  28. package/dist/{chunk-WCLMAQR4.js → chunk-3DRK36FB.js} +5 -5
  29. package/dist/{chunk-2PTWIZX6.js → chunk-3NNU7TQ4.js} +8 -8
  30. package/dist/{chunk-NFGCFN57.js → chunk-3UK3IF27.js} +6 -6
  31. package/dist/chunk-4ANV3AH3.js +65 -0
  32. package/dist/{chunk-RNU253MD.js → chunk-4ENK7S24.js} +21 -2
  33. package/dist/{chunk-IFZ7EXMG.js → chunk-4EVT4MFD.js} +1 -1
  34. package/dist/{chunk-7POF237O.js → chunk-4MKJB6U2.js} +1 -1
  35. package/dist/{chunk-WKPUTJGD.js → chunk-5LDBCBOR.js} +1 -1
  36. package/dist/{chunk-ZIMK4TPI.js → chunk-6PIL2RJD.js} +2 -2
  37. package/dist/{chunk-6TRWB7CE.js → chunk-6X3G5SAS.js} +41 -18
  38. package/dist/{chunk-LVSQULRG.js → chunk-7ASUTNKE.js} +2 -2
  39. package/dist/{chunk-KJENLSJT.js → chunk-7BT6V4CH.js} +20 -18
  40. package/dist/{chunk-5COWXLGO.js → chunk-7D55V4XP.js} +1 -1
  41. package/dist/{chunk-KYDOZBD5.js → chunk-7NZ46LIO.js} +29 -28
  42. package/dist/{chunk-4QBWHZKQ.js → chunk-7SO7O6RV.js} +2 -2
  43. package/dist/{chunk-4JPJ3ZIV.js → chunk-7Z6LTBYQ.js} +5 -5
  44. package/dist/{chunk-NVTDXBGV.js → chunk-APKELBCA.js} +1 -1
  45. package/dist/{chunk-YSUPRYX2.js → chunk-AQHYCRTO.js} +1 -1
  46. package/dist/{chunk-GUD3MOP7.js → chunk-B3UOTIOI.js} +9 -9
  47. package/dist/{chunk-2OFGWHZB.js → chunk-B5JUCPYW.js} +1 -1
  48. package/dist/{chunk-LJSD6G6K.js → chunk-BQ5MWNWN.js} +3 -3
  49. package/dist/{chunk-SKRIZPPF.js → chunk-BYJRL4IQ.js} +6 -6
  50. package/dist/{chunk-56KP3SAI.js → chunk-C3ZPWUDE.js} +2 -2
  51. package/dist/{chunk-LSXVCZN7.js → chunk-CD2FQVQR.js} +1 -1
  52. package/dist/{chunk-6BOOQV4Q.js → chunk-CFLMIJ2C.js} +3 -3
  53. package/dist/{chunk-6BRG2NJL.js → chunk-CGGGCKSK.js} +4 -4
  54. package/dist/{chunk-QYSDP6V5.js → chunk-CMOU2OFW.js} +1 -1
  55. package/dist/chunk-D2GADI73.js +253 -0
  56. package/dist/{chunk-75C3KFST.js → chunk-D3TY7PMJ.js} +5 -5
  57. package/dist/{chunk-RTZNJDEL.js → chunk-DAIEVD4O.js} +4 -4
  58. package/dist/{chunk-BGNQXT4T.js → chunk-DDF2CRA3.js} +2 -2
  59. package/dist/{chunk-DQ5VMD3Z.js → chunk-FCKUWBUL.js} +2 -2
  60. package/dist/{chunk-YFGBTXID.js → chunk-FV2XE3DX.js} +2 -2
  61. package/dist/{chunk-73BYGQWA.js → chunk-G7Y5YGLE.js} +1 -1
  62. package/dist/{chunk-PXOL34HI.js → chunk-HE3IEIKM.js} +3 -3
  63. package/dist/{chunk-WKMRBRJQ.js → chunk-HH23DOBB.js} +1 -1
  64. package/dist/{chunk-HCORTMQH.js → chunk-HHS6EHSG.js} +4 -4
  65. package/dist/{chunk-6T4DKZYW.js → chunk-ISXWS5Y4.js} +8 -8
  66. package/dist/{chunk-QBJOYOVF.js → chunk-J6T3W6RY.js} +15 -0
  67. package/dist/{chunk-CXDNTVCM.js → chunk-JK2GXKOQ.js} +5 -5
  68. package/dist/{chunk-A4BGGHRC.js → chunk-JXU6SA6S.js} +42 -1
  69. package/dist/{chunk-37Y556D5.js → chunk-KHICXOTH.js} +3 -3
  70. package/dist/chunk-KJ2GJLPQ.js +39 -0
  71. package/dist/{chunk-BUQATYS7.js → chunk-KNWM237Q.js} +2 -2
  72. package/dist/{chunk-RNDLMMKI.js → chunk-LOWHDHDD.js} +3 -3
  73. package/dist/{chunk-6SVZD3UA.js → chunk-M4OF5D4K.js} +4 -4
  74. package/dist/{chunk-CZPWZ5A5.js → chunk-M7SYXJBT.js} +1 -1
  75. package/dist/{chunk-IBO36HUU.js → chunk-MQBNN4KH.js} +1 -1
  76. package/dist/{chunk-32RP2UX6.js → chunk-MTB7SCZ5.js} +5 -5
  77. package/dist/{chunk-LEVIKSPQ.js → chunk-MTRTBT7L.js} +1 -1
  78. package/dist/{chunk-TARFRZ44.js → chunk-N5F5OUUZ.js} +3 -3
  79. package/dist/{chunk-M2LUXIXU.js → chunk-NMZMRH3E.js} +1 -1
  80. package/dist/{chunk-KGTWD46T.js → chunk-NWIMPG4M.js} +1 -1
  81. package/dist/chunk-OGA7KDQZ.js +37 -0
  82. package/dist/chunk-ONEKY3CM.js +146 -0
  83. package/dist/{chunk-SUFGP47L.js → chunk-ONS32E65.js} +28 -20
  84. package/dist/{chunk-XG4UIGDH.js → chunk-PAQ2JFVD.js} +1 -1
  85. package/dist/{chunk-N5C3WQWD.js → chunk-PDUQCDIO.js} +1 -1
  86. package/dist/{chunk-DSNNEER4.js → chunk-PJTGQVKB.js} +1 -1
  87. package/dist/{chunk-SAUR463Z.js → chunk-PLSXDJT4.js} +6 -5
  88. package/dist/{chunk-NL4EKSFA.js → chunk-PPI76YVT.js} +2 -2
  89. package/dist/{chunk-N33MOUCH.js → chunk-PRWWTLPR.js} +3 -3
  90. package/dist/{chunk-T75UYYMI.js → chunk-PVFGDKXO.js} +2 -2
  91. package/dist/{chunk-PIJJXKMK.js → chunk-PXMTLKUJ.js} +3 -3
  92. package/dist/chunk-PZ5EGY64.js +37 -0
  93. package/dist/{chunk-6ERUVF2Y.js → chunk-QB7JAMWG.js} +1 -1
  94. package/dist/{chunk-IY3KO2BC.js → chunk-QS544PN6.js} +4 -4
  95. package/dist/{chunk-GBGXSRZX.js → chunk-R5LXEIOJ.js} +9 -9
  96. package/dist/{chunk-OJUDLJOG.js → chunk-REY2YZ5X.js} +3 -3
  97. package/dist/{chunk-4IEDAORR.js → chunk-RFK4W5PZ.js} +1 -1
  98. package/dist/{chunk-NOG7ZJJA.js → chunk-RLLVP37Q.js} +1 -1
  99. package/dist/{chunk-HV7M7UUY.js → chunk-S5NB47IR.js} +6 -6
  100. package/dist/{chunk-3XGUMXGR.js → chunk-SXR4HQZY.js} +2 -2
  101. package/dist/{chunk-YN2F26NN.js → chunk-T3CXZ2BE.js} +2 -2
  102. package/dist/{chunk-MF3J7WTR.js → chunk-TN34IN7S.js} +16 -13
  103. package/dist/{chunk-XUODI55L.js → chunk-U3QU5AVC.js} +1 -1
  104. package/dist/{chunk-PNJRIMKJ.js → chunk-UB5WVCY4.js} +3 -3
  105. package/dist/{chunk-P7P2NWZD.js → chunk-URNG7ZX2.js} +1 -1
  106. package/dist/{chunk-3TF3YLM2.js → chunk-UROFA6OZ.js} +2 -2
  107. package/dist/{chunk-T5P54I7S.js → chunk-UTQRPXTL.js} +9 -8
  108. package/dist/{chunk-Y3EUEPGQ.js → chunk-UWHV7EJG.js} +2 -2
  109. package/dist/chunk-UY3VT3HQ.js +39 -0
  110. package/dist/{chunk-5LXMEHQX.js → chunk-VG2TYPZ4.js} +18 -2
  111. package/dist/{chunk-EZBJEV6F.js → chunk-VTH56ERA.js} +4 -4
  112. package/dist/{chunk-Z4DZMNDE.js → chunk-W6QYWXOZ.js} +2 -2
  113. package/dist/{chunk-3WZGFAV4.js → chunk-WKGJQIRC.js} +4 -3
  114. package/dist/{chunk-EGN4TPN5.js → chunk-WT3SEE34.js} +3 -3
  115. package/dist/{chunk-CZ4IOIWV.js → chunk-X23OAFFE.js} +4 -4
  116. package/dist/{chunk-E4FQRMHV.js → chunk-XJYR5HE3.js} +18 -0
  117. package/dist/{chunk-X3IXLDWQ.js → chunk-XSRIFWHR.js} +2 -2
  118. package/dist/{chunk-SS5IC3XV.js → chunk-Y6BFKPNB.js} +1 -1
  119. package/dist/{chunk-EFSLGRY2.js → chunk-YCL5RHEC.js} +2 -2
  120. package/dist/{chunk-LGVD2IGL.js → chunk-YD67W6DW.js} +9 -9
  121. package/dist/{chunk-J3XIGC3L.js → chunk-YE47YUGE.js} +6 -6
  122. package/dist/{chunk-F6DCNXO5.js → chunk-YEJFXJHR.js} +2 -2
  123. package/dist/{chunk-ZV6Y5VOD.js → chunk-YUVQQCT4.js} +15 -15
  124. package/dist/{chunk-T64ECODW.js → chunk-YUZFNAG6.js} +21 -0
  125. package/dist/{chunk-OWG6UV4S.js → chunk-YWAMRRAX.js} +10 -10
  126. package/dist/config/index.js +5 -5
  127. package/dist/containers/client.js +6 -6
  128. package/dist/containers/exec.js +6 -6
  129. package/dist/containers/lifecycle.js +48 -48
  130. package/dist/containers/setup.js +10 -9
  131. package/dist/db/agents.js +6 -6
  132. package/dist/db/api_keys.js +5 -5
  133. package/dist/db/audit.js +3 -3
  134. package/dist/db/batch.js +10 -10
  135. package/dist/db/client.js +2 -2
  136. package/dist/db/credentials.js +3 -3
  137. package/dist/db/drizzle.js +4 -4
  138. package/dist/db/environments.js +6 -6
  139. package/dist/db/events.js +5 -5
  140. package/dist/db/files.js +5 -5
  141. package/dist/db/memory.js +5 -5
  142. package/dist/db/migrations.js +1 -1
  143. package/dist/db/proxy.js +5 -5
  144. package/dist/db/schema.js +5 -3
  145. package/dist/db/session-resources.js +5 -5
  146. package/dist/db/sessions.js +8 -8
  147. package/dist/db/skills.js +5 -5
  148. package/dist/db/sync.js +5 -5
  149. package/dist/db/tenants.js +3 -3
  150. package/dist/db/threads.js +7 -7
  151. package/dist/db/traces.js +5 -5
  152. package/dist/db/upstream_keys.js +3 -3
  153. package/dist/db/vaults.js +6 -6
  154. package/dist/db/work.js +33 -0
  155. package/dist/dreaming/review.js +11 -11
  156. package/dist/handlers/agents.js +64 -64
  157. package/dist/handlers/api_keys.js +65 -65
  158. package/dist/handlers/audit.js +65 -65
  159. package/dist/handlers/batch.js +65 -65
  160. package/dist/handlers/credentials.js +65 -65
  161. package/dist/handlers/environments.js +65 -65
  162. package/dist/handlers/events.js +68 -68
  163. package/dist/handlers/files.js +65 -65
  164. package/dist/handlers/index.js +141 -120
  165. package/dist/handlers/license.js +64 -64
  166. package/dist/handlers/memory.js +66 -66
  167. package/dist/handlers/metrics.js +64 -64
  168. package/dist/handlers/models.js +65 -65
  169. package/dist/handlers/providers.js +64 -64
  170. package/dist/handlers/resources.js +64 -64
  171. package/dist/handlers/sessions.js +68 -68
  172. package/dist/handlers/settings.js +64 -64
  173. package/dist/handlers/skills-write.js +67 -65
  174. package/dist/handlers/skills.js +65 -65
  175. package/dist/handlers/stream.js +64 -64
  176. package/dist/handlers/tenants.js +65 -65
  177. package/dist/handlers/threads.js +65 -65
  178. package/dist/handlers/traces.js +65 -65
  179. package/dist/handlers/ui.d.ts +6 -0
  180. package/dist/handlers/ui.d.ts.map +1 -0
  181. package/dist/handlers/ui.js +1 -1
  182. package/dist/handlers/upstream_keys.js +67 -67
  183. package/dist/handlers/vaults.js +64 -64
  184. package/dist/handlers/whoami.js +64 -64
  185. package/dist/handlers/work.js +114 -0
  186. package/dist/http.js +63 -63
  187. package/dist/index.js +84 -73
  188. package/dist/init.js +60 -60
  189. package/dist/lib/model-registry.js +6 -6
  190. package/dist/lib/skills-cache.js +6 -6
  191. package/dist/observability/otlp.js +12 -12
  192. package/dist/observability/redactor.js +8 -8
  193. package/dist/providers/daytona.js +1 -1
  194. package/dist/providers/fly.js +7 -6
  195. package/dist/providers/modal.js +5 -5
  196. package/dist/providers/registry.js +15 -3
  197. package/dist/providers/resolve-secrets.js +7 -7
  198. package/dist/providers/sprites.js +7 -7
  199. package/dist/providers/upstream-keys.js +12 -12
  200. package/dist/providers/vercel.js +5 -5
  201. package/dist/proxy/forward.js +6 -6
  202. package/dist/queue/index.js +6 -6
  203. package/dist/sessions/bus.js +10 -10
  204. package/dist/sessions/driver.js +53 -53
  205. package/dist/sessions/grader.js +5 -5
  206. package/dist/sessions/secrets.js +8 -8
  207. package/dist/sessions/sweeper.js +49 -49
  208. package/dist/sessions/threads.js +54 -54
  209. package/dist/shutdown.js +50 -50
  210. package/dist/sync/anthropic.js +10 -10
  211. package/dist/sync/container-file-sync.js +6 -6
  212. package/dist/sync/file-sync.js +17 -17
  213. package/dist/workers/runner.js +85 -0
  214. package/package.json +1 -1
  215. package/dist/chunk-3W6KEDQE.js +0 -20
  216. package/dist/chunk-JDBXIJKG.js +0 -20
  217. package/dist/chunk-QQDSHL27.js +0 -22
  218. package/dist/chunk-SWIP7JBQ.js +0 -22
@@ -1,6 +1,13 @@
1
1
  import {
2
2
  parseNDJSONLines
3
3
  } from "./chunk-PJZ5TQYW.js";
4
+ import {
5
+ childSpan,
6
+ newTrace
7
+ } from "./chunk-AU4NAQGA.js";
8
+ import {
9
+ injectMcpAuthHeaders
10
+ } from "./chunk-DBFPJSOY.js";
4
11
  import {
5
12
  incrementRetry,
6
13
  resetRetry,
@@ -9,14 +16,7 @@ import {
9
16
  } from "./chunk-72BKGVBE.js";
10
17
  import {
11
18
  loadSessionSecrets
12
- } from "./chunk-Y3EUEPGQ.js";
13
- import {
14
- childSpan,
15
- newTrace
16
- } from "./chunk-AU4NAQGA.js";
17
- import {
18
- injectMcpAuthHeaders
19
- } from "./chunk-DBFPJSOY.js";
19
+ } from "./chunk-UWHV7EJG.js";
20
20
  import {
21
21
  buildErrorPayload,
22
22
  classifyError,
@@ -24,21 +24,21 @@ import {
24
24
  } from "./chunk-H6TQGV4L.js";
25
25
  import {
26
26
  isProxied
27
- } from "./chunk-EFSLGRY2.js";
27
+ } from "./chunk-YCL5RHEC.js";
28
28
  import {
29
29
  acquireForFirstTurn,
30
30
  installSkills,
31
31
  provisionResources,
32
32
  wrapProviderWithSecrets
33
- } from "./chunk-MF3J7WTR.js";
33
+ } from "./chunk-TN34IN7S.js";
34
34
  import {
35
35
  BLOCKED_ENV_KEYS,
36
36
  resolveVaultSecrets
37
- } from "./chunk-6ERUVF2Y.js";
37
+ } from "./chunk-QB7JAMWG.js";
38
38
  import {
39
39
  appendEvent,
40
40
  appendEventsBatch
41
- } from "./chunk-CZ4IOIWV.js";
41
+ } from "./chunk-X23OAFFE.js";
42
42
  import {
43
43
  bumpSessionStats,
44
44
  getOutcomeCriteria,
@@ -49,26 +49,27 @@ import {
49
49
  setOutcomeCriteria,
50
50
  updateSessionMutable,
51
51
  updateSessionStatus
52
- } from "./chunk-32RP2UX6.js";
52
+ } from "./chunk-MTB7SCZ5.js";
53
53
  import {
54
54
  listEvents,
55
55
  markUserEventProcessed
56
- } from "./chunk-N33MOUCH.js";
56
+ } from "./chunk-PRWWTLPR.js";
57
57
  import {
58
58
  getBySession
59
59
  } from "./chunk-EFOIR7R3.js";
60
60
  import {
61
- resolveContainerProvider
62
- } from "./chunk-A4BGGHRC.js";
61
+ resolveProvider,
62
+ resolveProviderName
63
+ } from "./chunk-JXU6SA6S.js";
63
64
  import {
64
65
  getEnvironment
65
- } from "./chunk-6BOOQV4Q.js";
66
+ } from "./chunk-CFLMIJ2C.js";
66
67
  import {
67
68
  getAgent
68
- } from "./chunk-EGN4TPN5.js";
69
+ } from "./chunk-WT3SEE34.js";
69
70
  import {
70
71
  resolveBackend
71
- } from "./chunk-GBGXSRZX.js";
72
+ } from "./chunk-R5LXEIOJ.js";
72
73
  import {
73
74
  PERMISSION_BRIDGE_PENDING_PATH,
74
75
  PERMISSION_BRIDGE_REQUEST_PATH,
@@ -84,7 +85,7 @@ import {
84
85
  } from "./chunk-FX2AEKOV.js";
85
86
  import {
86
87
  getConfig
87
- } from "./chunk-3WZGFAV4.js";
88
+ } from "./chunk-WKGJQIRC.js";
88
89
  import {
89
90
  init_clock,
90
91
  nowMs
@@ -236,7 +237,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
236
237
  if (newSkills.length > 0) {
237
238
  console.log(`[driver] ${sessionId} injecting ${newSkills.length} new skill(s)...`);
238
239
  const envRow = getEnvironment(session.environment_id);
239
- const baseProvider = await resolveContainerProvider(envRow?.config?.provider);
240
+ const baseProvider = await resolveProvider({ envConfigProvider: envRow?.config?.provider });
240
241
  const sp = wrapProviderWithSecrets(baseProvider, postAcquireSecrets);
241
242
  await installSkills(sandboxName, sp, newSkills, agent.engine);
242
243
  console.log(`[driver] ${sessionId} skills injected`);
@@ -245,7 +246,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
245
246
  const freshSession2 = getSession(sessionId);
246
247
  if (freshSession2?.resources && freshSession2.resources.length > 0) {
247
248
  const envRow = getEnvironment(session.environment_id);
248
- const baseProvider = await resolveContainerProvider(envRow?.config?.provider);
249
+ const baseProvider = await resolveProvider({ envConfigProvider: envRow?.config?.provider });
249
250
  const sp = wrapProviderWithSecrets(baseProvider, postAcquireSecrets);
250
251
  await provisionResources(sandboxName, freshSession2.resources, sp);
251
252
  }
@@ -308,7 +309,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
308
309
  }
309
310
  if (agent.engine === "codex") {
310
311
  const envRow = getEnvironment(session.environment_id);
311
- const provName = envRow?.config?.provider ?? "docker";
312
+ const provName = resolveProviderName({ envConfigProvider: envRow?.config?.provider });
312
313
  const firecrackerProviders = /* @__PURE__ */ new Set(["sprites", "fly", "apple-firecracker"]);
313
314
  if (firecrackerProviders.has(provName)) {
314
315
  const faIdx = turnBuild.argv.indexOf("--full-auto");
@@ -352,7 +353,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
352
353
  let ollamaHostPort;
353
354
  if (!turnBuild.env.OLLAMA_HOST) {
354
355
  const envRow = getEnvironment(session.environment_id);
355
- const provName = envRow?.config?.provider ?? "docker";
356
+ const provName = resolveProviderName({ envConfigProvider: envRow?.config?.provider });
356
357
  if (provName === "docker" || provName === "podman") {
357
358
  ollamaHostPort = "host.docker.internal:11434";
358
359
  } else if (provName === "apple-container" || provName === "apple-firecracker") {
@@ -392,7 +393,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
392
393
 
393
394
  ${turnBuild.stdin}`;
394
395
  const env = getEnvironment(session.environment_id);
395
- const provider = await resolveContainerProvider(env?.config?.provider);
396
+ const provider = await resolveProvider({ envConfigProvider: env?.config?.provider });
396
397
  const poolEntry = getBySession(sessionId);
397
398
  const secrets = poolEntry?.vaultSecrets ?? (session.vault_ids?.length ? resolveVaultSecrets(session.vault_ids) : void 0);
398
399
  const tools = resolveToolset(agent.tools);
@@ -666,7 +667,7 @@ ${turnBuild.stdin}`;
666
667
  if (sprName) {
667
668
  const responseJson = JSON.stringify({ content: [{ type: "text", text: serverToolResult.text }] });
668
669
  const envForSession = getEnvironment(session.environment_id);
669
- const providerForReentry = await resolveContainerProvider(envForSession?.config?.provider);
670
+ const providerForReentry = await resolveProvider({ envConfigProvider: envForSession?.config?.provider });
670
671
  const reentrySecrets = getBySession(sessionId)?.vaultSecrets;
671
672
  await providerForReentry.exec(
672
673
  sprName,
@@ -867,7 +868,7 @@ async function writePermissionResponse(sessionId, result, denyMessage) {
867
868
  return;
868
869
  }
869
870
  const env = getEnvironment(row.environment_id);
870
- const provider = await resolveContainerProvider(env?.config?.provider);
871
+ const provider = await resolveProvider({ envConfigProvider: env?.config?.provider });
871
872
  const permSecrets = getBySession(sessionId)?.vaultSecrets;
872
873
  const response = JSON.stringify({
873
874
  result,
@@ -936,7 +937,7 @@ async function writeToolBridgeResponse(sessionId, content) {
936
937
  return;
937
938
  }
938
939
  const env = getEnvironment(row.environment_id);
939
- const provider = await resolveContainerProvider(env?.config?.provider);
940
+ const provider = await resolveProvider({ envConfigProvider: env?.config?.provider });
940
941
  const bridgeSecrets = getBySession(sessionId)?.vaultSecrets;
941
942
  const response = JSON.stringify({ content });
942
943
  try {
@@ -8,14 +8,14 @@ import {
8
8
  import {
9
9
  jsonOk,
10
10
  routeWrap
11
- } from "./chunk-DQ5VMD3Z.js";
11
+ } from "./chunk-FCKUWBUL.js";
12
12
  import {
13
13
  snapshotApiMetrics
14
14
  } from "./chunk-D2XITRN6.js";
15
15
  import {
16
16
  getDb,
17
17
  init_client
18
- } from "./chunk-XUODI55L.js";
18
+ } from "./chunk-U3QU5AVC.js";
19
19
  import {
20
20
  badRequest
21
21
  } from "./chunk-EZYKRG4W.js";
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  onAfterCommit
3
- } from "./chunk-CZ4IOIWV.js";
3
+ } from "./chunk-X23OAFFE.js";
4
4
  import {
5
5
  getSessionRow
6
- } from "./chunk-32RP2UX6.js";
6
+ } from "./chunk-MTB7SCZ5.js";
7
7
  import {
8
8
  listEventsByTrace
9
- } from "./chunk-N33MOUCH.js";
9
+ } from "./chunk-PRWWTLPR.js";
10
10
  import {
11
11
  getAgent
12
- } from "./chunk-EGN4TPN5.js";
12
+ } from "./chunk-WT3SEE34.js";
13
13
  import {
14
14
  getConfig
15
- } from "./chunk-3WZGFAV4.js";
15
+ } from "./chunk-WKGJQIRC.js";
16
16
 
17
17
  // src/observability/otlp.ts
18
18
  import { createHash } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-3WZGFAV4.js";
3
+ } from "./chunk-WKGJQIRC.js";
4
4
  import {
5
5
  ApiError
6
6
  } from "./chunk-EZYKRG4W.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  installFactoryWrapper
3
- } from "./chunk-QQDSHL27.js";
3
+ } from "./chunk-KJ2GJLPQ.js";
4
4
 
5
5
  // src/backends/factory/setup.ts
6
6
  var SENTINEL_NAME = ".claude-agents-factory-installed";
@@ -1,19 +1,19 @@
1
+ import {
2
+ buildCodexArgs
3
+ } from "./chunk-PJYCPDV5.js";
4
+ import {
5
+ buildCodexAuthEnv,
6
+ validateCodexRuntime
7
+ } from "./chunk-MQBNN4KH.js";
1
8
  import {
2
9
  prepareCodexOnSandbox
3
- } from "./chunk-M2LUXIXU.js";
10
+ } from "./chunk-NMZMRH3E.js";
4
11
  import {
5
12
  createCodexTranslator
6
13
  } from "./chunk-CULYZ3VA.js";
7
14
  import {
8
15
  CODEX_WRAPPER_PATH
9
- } from "./chunk-E4FQRMHV.js";
10
- import {
11
- buildCodexArgs
12
- } from "./chunk-PJYCPDV5.js";
13
- import {
14
- buildCodexAuthEnv,
15
- validateCodexRuntime
16
- } from "./chunk-IBO36HUU.js";
16
+ } from "./chunk-XJYR5HE3.js";
17
17
  import {
18
18
  wrapPromptWithSystem
19
19
  } from "./chunk-YE2RMJY7.js";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  jsonOk,
6
6
  routeWrap
7
- } from "./chunk-DQ5VMD3Z.js";
7
+ } from "./chunk-FCKUWBUL.js";
8
8
 
9
9
  // src/handlers/license.ts
10
10
  function handleGetLicense(request) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  forwardToAnthropic
3
- } from "./chunk-WKPUTJGD.js";
3
+ } from "./chunk-5LDBCBOR.js";
4
4
  import {
5
5
  isAnthropicApiKey,
6
6
  isPassthroughAllowedPath
@@ -8,10 +8,10 @@ import {
8
8
  import {
9
9
  findByRawKey,
10
10
  hydratePermissions
11
- } from "./chunk-Z4DZMNDE.js";
11
+ } from "./chunk-W6QYWXOZ.js";
12
12
  import {
13
13
  getConfig
14
- } from "./chunk-3WZGFAV4.js";
14
+ } from "./chunk-WKGJQIRC.js";
15
15
  import {
16
16
  unauthorized
17
17
  } from "./chunk-EZYKRG4W.js";
@@ -1,3 +1,7 @@
1
+ import {
2
+ buildClaudeArgs,
3
+ buildClaudeAuthEnv
4
+ } from "./chunk-Y6BFKPNB.js";
1
5
  import {
2
6
  PERMISSION_BRIDGE_DIR,
3
7
  PERMISSION_HOOK_SCRIPT_PATH,
@@ -15,17 +19,13 @@ import {
15
19
  import {
16
20
  createClaudeTranslator
17
21
  } from "./chunk-D6RQPBRG.js";
18
- import {
19
- buildClaudeArgs,
20
- buildClaudeAuthEnv
21
- } from "./chunk-SS5IC3XV.js";
22
22
  import {
23
23
  CLAUDE_WRAPPER_PATH,
24
24
  installClaudeWrapper
25
- } from "./chunk-QBJOYOVF.js";
25
+ } from "./chunk-J6T3W6RY.js";
26
26
  import {
27
27
  getConfig
28
- } from "./chunk-3WZGFAV4.js";
28
+ } from "./chunk-WKGJQIRC.js";
29
29
 
30
30
  // src/backends/claude/index.ts
31
31
  function buildTurn(input) {
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  jsonOk,
3
3
  routeWrap
4
- } from "./chunk-DQ5VMD3Z.js";
4
+ } from "./chunk-FCKUWBUL.js";
5
5
  import {
6
6
  readSetting,
7
7
  writeSetting
8
- } from "./chunk-3WZGFAV4.js";
8
+ } from "./chunk-WKGJQIRC.js";
9
9
  import {
10
10
  badRequest
11
11
  } from "./chunk-EZYKRG4W.js";
@@ -10,7 +10,7 @@ import {
10
10
  import {
11
11
  getDb,
12
12
  init_client
13
- } from "./chunk-XUODI55L.js";
13
+ } from "./chunk-U3QU5AVC.js";
14
14
 
15
15
  // src/db/tenants.ts
16
16
  init_client();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_TENANT_ID
3
- } from "./chunk-LSXVCZN7.js";
3
+ } from "./chunk-CD2FQVQR.js";
4
4
  import {
5
5
  init_ids,
6
6
  newId
@@ -13,10 +13,10 @@ import {
13
13
  import {
14
14
  getDrizzle,
15
15
  init_drizzle
16
- } from "./chunk-T75UYYMI.js";
16
+ } from "./chunk-PVFGDKXO.js";
17
17
  import {
18
18
  schema_exports
19
- } from "./chunk-RNU253MD.js";
19
+ } from "./chunk-4ENK7S24.js";
20
20
 
21
21
  // src/db/environments.ts
22
22
  init_drizzle();
@@ -7,7 +7,7 @@ import {
7
7
  jsonOk,
8
8
  paginatedOk,
9
9
  routeWrap
10
- } from "./chunk-DQ5VMD3Z.js";
10
+ } from "./chunk-FCKUWBUL.js";
11
11
  import {
12
12
  archiveVault,
13
13
  createVault,
@@ -19,14 +19,14 @@ import {
19
19
  listVaults,
20
20
  setEntry,
21
21
  updateVault
22
- } from "./chunk-OJUDLJOG.js";
22
+ } from "./chunk-REY2YZ5X.js";
23
23
  import {
24
24
  getAgent
25
- } from "./chunk-EGN4TPN5.js";
25
+ } from "./chunk-WT3SEE34.js";
26
26
  import {
27
27
  getDb,
28
28
  init_client
29
- } from "./chunk-XUODI55L.js";
29
+ } from "./chunk-U3QU5AVC.js";
30
30
  import {
31
31
  badRequest,
32
32
  conflict,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  installPiWrapper
3
- } from "./chunk-JDBXIJKG.js";
3
+ } from "./chunk-OGA7KDQZ.js";
4
4
 
5
5
  // src/backends/pi/setup.ts
6
6
  var SENTINEL_NAME = ".claude-agents-pi-installed";
@@ -0,0 +1,253 @@
1
+ import {
2
+ init_ids,
3
+ newId
4
+ } from "./chunk-F4WUVOLE.js";
5
+ import {
6
+ init_clock,
7
+ nowMs,
8
+ toIso
9
+ } from "./chunk-HFDLUBWN.js";
10
+ import {
11
+ getDrizzle,
12
+ init_drizzle
13
+ } from "./chunk-PVFGDKXO.js";
14
+ import {
15
+ schema_exports
16
+ } from "./chunk-4ENK7S24.js";
17
+
18
+ // src/db/work.ts
19
+ init_drizzle();
20
+ init_ids();
21
+ init_clock();
22
+ import { eq, and, sql } from "drizzle-orm";
23
+ var LEASE_TTL_MS = 6e4;
24
+ function hydrate(row) {
25
+ const metadata = row.metadata_json ? JSON.parse(row.metadata_json) : {};
26
+ return {
27
+ type: "work",
28
+ id: row.id,
29
+ environment_id: row.environment_id,
30
+ state: row.state,
31
+ data: { type: "session", id: row.session_id },
32
+ metadata,
33
+ worker_id: row.worker_id ?? null,
34
+ created_at: toIso(row.created_at),
35
+ acknowledged_at: row.acknowledged_at ? toIso(row.acknowledged_at) : null,
36
+ started_at: row.started_at ? toIso(row.started_at) : null,
37
+ latest_heartbeat_at: row.latest_heartbeat_at ? toIso(row.latest_heartbeat_at) : null,
38
+ stop_requested_at: row.stop_requested_at ? toIso(row.stop_requested_at) : null,
39
+ stopped_at: row.stopped_at ? toIso(row.stopped_at) : null
40
+ };
41
+ }
42
+ function createWorkItem(envId, sessionId, opts) {
43
+ const db = getDrizzle();
44
+ const id = newId("work");
45
+ const now = nowMs();
46
+ db.insert(schema_exports.workItems).values({
47
+ id,
48
+ environment_id: envId,
49
+ session_id: sessionId,
50
+ state: "queued",
51
+ inputs_json: opts?.inputsJson ?? null,
52
+ metadata_json: "{}",
53
+ tenant_id: opts?.tenantId ?? null,
54
+ created_at: now
55
+ }).run();
56
+ return getWorkItem(id);
57
+ }
58
+ function getWorkItem(id) {
59
+ const db = getDrizzle();
60
+ const row = db.select().from(schema_exports.workItems).where(eq(schema_exports.workItems.id, id)).get();
61
+ return row ? hydrate(row) : void 0;
62
+ }
63
+ function getWorkItemInputs(id) {
64
+ const db = getDrizzle();
65
+ const row = db.select({ inputs_json: schema_exports.workItems.inputs_json }).from(schema_exports.workItems).where(eq(schema_exports.workItems.id, id)).get();
66
+ return row?.inputs_json ?? null;
67
+ }
68
+ function listWorkItems(envId, opts) {
69
+ const db = getDrizzle();
70
+ const limit = Math.min(Math.max(opts?.limit ?? 20, 1), 100);
71
+ const conditions = [
72
+ eq(schema_exports.workItems.environment_id, envId)
73
+ ];
74
+ if (opts?.state) {
75
+ conditions.push(eq(schema_exports.workItems.state, opts.state));
76
+ }
77
+ if (opts?.cursor) {
78
+ conditions.push(sql`${schema_exports.workItems.created_at} < (SELECT created_at FROM work_items WHERE id = ${opts.cursor})`);
79
+ }
80
+ const rows = db.select().from(schema_exports.workItems).where(and(...conditions)).orderBy(sql`${schema_exports.workItems.created_at} DESC`).limit(limit).all();
81
+ return rows.map(hydrate);
82
+ }
83
+ function pollWorkItem(envId, workerId) {
84
+ const db = getDrizzle();
85
+ const now = nowMs();
86
+ db.run(
87
+ sql`UPDATE work_items
88
+ SET state = 'queued', worker_id = NULL, lease_expires_at = NULL
89
+ WHERE state IN ('pending', 'active')
90
+ AND lease_expires_at IS NOT NULL
91
+ AND lease_expires_at < ${now}`
92
+ );
93
+ const leaseExpires = now + LEASE_TTL_MS;
94
+ const wid = workerId ?? null;
95
+ const result = db.run(
96
+ sql`UPDATE work_items
97
+ SET state = 'pending',
98
+ worker_id = ${wid},
99
+ lease_expires_at = ${leaseExpires}
100
+ WHERE id = (
101
+ SELECT id FROM work_items
102
+ WHERE environment_id = ${envId} AND state = 'queued'
103
+ ORDER BY created_at ASC LIMIT 1
104
+ )
105
+ AND state = 'queued'`
106
+ );
107
+ if (result.changes === 0) return null;
108
+ const rows = db.all(
109
+ sql`SELECT * FROM work_items
110
+ WHERE environment_id = ${envId}
111
+ AND state = 'pending'
112
+ AND lease_expires_at = ${leaseExpires}
113
+ AND worker_id IS ${wid}
114
+ ORDER BY created_at ASC LIMIT 1`
115
+ );
116
+ if (rows.length === 0) return null;
117
+ return hydrate(rows[0]);
118
+ }
119
+ function ackWorkItem(id, workerId) {
120
+ const db = getDrizzle();
121
+ const now = nowMs();
122
+ const leaseExpires = now + LEASE_TTL_MS;
123
+ const conditions = [eq(schema_exports.workItems.id, id), eq(schema_exports.workItems.state, "pending")];
124
+ const res = db.update(schema_exports.workItems).set({
125
+ state: "active",
126
+ worker_id: workerId ?? void 0,
127
+ acknowledged_at: now,
128
+ started_at: now,
129
+ lease_expires_at: leaseExpires
130
+ }).where(and(...conditions)).run();
131
+ if (res.changes === 0) return void 0;
132
+ return getWorkItem(id);
133
+ }
134
+ function heartbeatWorkItem(id) {
135
+ const db = getDrizzle();
136
+ const item = getWorkItem(id);
137
+ if (!item) return void 0;
138
+ const now = nowMs();
139
+ if (item.state === "completed" || item.state === "failed") {
140
+ return {
141
+ type: "work_heartbeat",
142
+ last_heartbeat: toIso(now),
143
+ lease_extended: false,
144
+ state: item.state,
145
+ ttl_seconds: 0
146
+ };
147
+ }
148
+ const leaseExpires = now + LEASE_TTL_MS;
149
+ db.update(schema_exports.workItems).set({
150
+ latest_heartbeat_at: now,
151
+ lease_expires_at: leaseExpires
152
+ }).where(eq(schema_exports.workItems.id, id)).run();
153
+ return {
154
+ type: "work_heartbeat",
155
+ last_heartbeat: toIso(now),
156
+ lease_extended: true,
157
+ state: item.state,
158
+ ttl_seconds: LEASE_TTL_MS / 1e3
159
+ };
160
+ }
161
+ function completeWorkItem(id, state) {
162
+ const db = getDrizzle();
163
+ const now = nowMs();
164
+ const res = db.update(schema_exports.workItems).set({
165
+ state,
166
+ stopped_at: now,
167
+ lease_expires_at: null
168
+ }).where(eq(schema_exports.workItems.id, id)).run();
169
+ if (res.changes === 0) return void 0;
170
+ return getWorkItem(id);
171
+ }
172
+ function stopWorkItem(id, force) {
173
+ const db = getDrizzle();
174
+ const now = nowMs();
175
+ if (force) {
176
+ const res = db.update(schema_exports.workItems).set({
177
+ state: "failed",
178
+ stop_requested_at: now,
179
+ stopped_at: now,
180
+ lease_expires_at: null
181
+ }).where(eq(schema_exports.workItems.id, id)).run();
182
+ if (res.changes === 0) return void 0;
183
+ } else {
184
+ const res = db.update(schema_exports.workItems).set({ stop_requested_at: now }).where(eq(schema_exports.workItems.id, id)).run();
185
+ if (res.changes === 0) return void 0;
186
+ }
187
+ return getWorkItem(id);
188
+ }
189
+ function updateWorkItemMetadata(id, metadata) {
190
+ const db = getDrizzle();
191
+ const item = getWorkItem(id);
192
+ if (!item) return void 0;
193
+ const merged = { ...item.metadata };
194
+ for (const [key, value] of Object.entries(metadata)) {
195
+ if (value === null) {
196
+ delete merged[key];
197
+ } else {
198
+ merged[key] = value;
199
+ }
200
+ }
201
+ db.update(schema_exports.workItems).set({ metadata_json: JSON.stringify(merged) }).where(eq(schema_exports.workItems.id, id)).run();
202
+ return getWorkItem(id);
203
+ }
204
+ function getWorkQueueStats(envId) {
205
+ const db = getDrizzle();
206
+ const rows = db.all(
207
+ sql`SELECT state, COUNT(*) as cnt
208
+ FROM work_items
209
+ WHERE environment_id = ${envId}
210
+ GROUP BY state`
211
+ );
212
+ const counts = {};
213
+ for (const row of rows) {
214
+ counts[row.state] = row.cnt;
215
+ }
216
+ const depth = counts["queued"] ?? 0;
217
+ const pending = (counts["pending"] ?? 0) + (counts["active"] ?? 0);
218
+ const oldestRow = db.all(
219
+ sql`SELECT MIN(created_at) as oldest
220
+ FROM work_items
221
+ WHERE environment_id = ${envId} AND state = 'queued'`
222
+ );
223
+ const oldestQueuedAt = oldestRow[0]?.oldest ? toIso(oldestRow[0].oldest) : null;
224
+ const workerRows = db.all(
225
+ sql`SELECT COUNT(DISTINCT worker_id) as cnt
226
+ FROM work_items
227
+ WHERE environment_id = ${envId}
228
+ AND state IN ('pending', 'active')
229
+ AND worker_id IS NOT NULL`
230
+ );
231
+ const workersPollling = workerRows[0]?.cnt ?? 0;
232
+ return {
233
+ type: "work_queue_stats",
234
+ depth,
235
+ pending,
236
+ workers_polling: workersPollling > 0 ? workersPollling : null,
237
+ oldest_queued_at: oldestQueuedAt
238
+ };
239
+ }
240
+
241
+ export {
242
+ createWorkItem,
243
+ getWorkItem,
244
+ getWorkItemInputs,
245
+ listWorkItems,
246
+ pollWorkItem,
247
+ ackWorkItem,
248
+ heartbeatWorkItem,
249
+ completeWorkItem,
250
+ stopWorkItem,
251
+ updateWorkItemMetadata,
252
+ getWorkQueueStats
253
+ };
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-23UKWXJH.js";
7
7
  import {
8
8
  recordAudit
9
- } from "./chunk-N5C3WQWD.js";
9
+ } from "./chunk-PDUQCDIO.js";
10
10
  import {
11
11
  COMMUNITY_LIMITS,
12
12
  hasFeature,
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  jsonOk,
17
17
  routeWrap
18
- } from "./chunk-DQ5VMD3Z.js";
18
+ } from "./chunk-FCKUWBUL.js";
19
19
  import {
20
20
  createApiKey,
21
21
  getApiKeyById,
@@ -23,14 +23,14 @@ import {
23
23
  listApiKeys,
24
24
  revokeApiKey,
25
25
  updateApiKeyPermissions
26
- } from "./chunk-Z4DZMNDE.js";
26
+ } from "./chunk-W6QYWXOZ.js";
27
27
  import {
28
28
  listSessionsByApiKey
29
- } from "./chunk-32RP2UX6.js";
29
+ } from "./chunk-MTB7SCZ5.js";
30
30
  import {
31
31
  getDb,
32
32
  init_client
33
- } from "./chunk-XUODI55L.js";
33
+ } from "./chunk-U3QU5AVC.js";
34
34
  import {
35
35
  badRequest,
36
36
  forbidden,