@agentstep/agent-sdk 0.4.41 → 0.5.1

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 (197) 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 +8 -8
  4. package/dist/backends/claude/wrapper-script.js +1 -1
  5. package/dist/backends/codex/args.js +1 -1
  6. package/dist/backends/codex/auth.js +6 -6
  7. package/dist/backends/codex/index.js +8 -8
  8. package/dist/backends/factory/args.js +1 -1
  9. package/dist/backends/factory/auth.js +6 -6
  10. package/dist/backends/factory/index.js +8 -8
  11. package/dist/backends/gemini/args.js +1 -1
  12. package/dist/backends/gemini/auth.js +6 -6
  13. package/dist/backends/gemini/index.js +8 -8
  14. package/dist/backends/opencode/args.js +1 -1
  15. package/dist/backends/opencode/auth.js +6 -6
  16. package/dist/backends/opencode/index.js +9 -9
  17. package/dist/backends/opencode/mcp.js +1 -1
  18. package/dist/backends/pi/args.js +1 -1
  19. package/dist/backends/pi/auth.js +6 -6
  20. package/dist/backends/pi/index.js +8 -8
  21. package/dist/backends/registry.js +25 -25
  22. package/dist/{chunk-L2RX552S.js → chunk-22OUZJAV.js} +3 -3
  23. package/dist/{chunk-XWWLMJXT.js → chunk-2YFS435Z.js} +6 -15
  24. package/dist/{chunk-W2NHS4IF.js → chunk-2YIMCZJK.js} +15 -19
  25. package/dist/{chunk-WCDWL6ED.js → chunk-2YZOIFVN.js} +49 -0
  26. package/dist/{chunk-2PPB644A.js → chunk-37C5BNVV.js} +1 -1
  27. package/dist/{chunk-RDGOGAQ5.js → chunk-3FLQ7KZP.js} +1 -1
  28. package/dist/{chunk-2RSL5SO7.js → chunk-3NKK4M23.js} +2 -2
  29. package/dist/{chunk-CHDQ3HIR.js → chunk-3S4CGFKJ.js} +5 -9
  30. package/dist/{chunk-H7UKW666.js → chunk-445EL6J5.js} +1 -1
  31. package/dist/{chunk-FP4E3QUS.js → chunk-4LHJJXH3.js} +2 -2
  32. package/dist/{chunk-ZFJPOQSY.js → chunk-4MKBT3KA.js} +69 -30
  33. package/dist/{chunk-ENGKR2JT.js → chunk-56XDLNEW.js} +1 -1
  34. package/dist/{chunk-Y6SFUNGO.js → chunk-57LAR6EM.js} +4 -4
  35. package/dist/{chunk-JZL4L54R.js → chunk-5M47X54D.js} +2 -2
  36. package/dist/{chunk-MHBLVGRF.js → chunk-5MERXOLJ.js} +4 -4
  37. package/dist/{chunk-E7DD7F7J.js → chunk-5U5LRAFJ.js} +2 -2
  38. package/dist/{chunk-MQQ44IGX.js → chunk-63AKPSCV.js} +3 -3
  39. package/dist/{chunk-T5VRE77P.js → chunk-6KWJASEO.js} +1 -1
  40. package/dist/{chunk-EUINGLHA.js → chunk-6RFQCFL2.js} +30 -20
  41. package/dist/{chunk-V5HWHJ4P.js → chunk-74E7GKUG.js} +1 -1
  42. package/dist/{chunk-DU7LSFQQ.js → chunk-7SY65LWY.js} +6 -9
  43. package/dist/{chunk-JCW3ZRES.js → chunk-A46RUKGA.js} +1 -1
  44. package/dist/{chunk-LZFB3HRK.js → chunk-AQB3P5ZP.js} +5 -10
  45. package/dist/{chunk-RP6WQ4IH.js → chunk-B5EY2VJC.js} +3 -3
  46. package/dist/{chunk-ZTH5JRZG.js → chunk-BCIFFAGW.js} +41 -10
  47. package/dist/{chunk-2Z2KAPUL.js → chunk-BJP5BIHE.js} +3 -3
  48. package/dist/{chunk-5EQJOUWM.js → chunk-C35ZTCBP.js} +2 -2
  49. package/dist/{chunk-OXWELRJL.js → chunk-CBPO2P4I.js} +101 -16
  50. package/dist/{chunk-HH4OXSOV.js → chunk-CE366H6Z.js} +5 -5
  51. package/dist/{chunk-C46UG6GQ.js → chunk-CKFJN5XK.js} +1 -1
  52. package/dist/{chunk-YBZJHDSE.js → chunk-COZG53R3.js} +2 -2
  53. package/dist/{chunk-SV2B3P6B.js → chunk-DBFPJSOY.js} +19 -17
  54. package/dist/{chunk-NQVRZAIX.js → chunk-DMMNAQUM.js} +2 -2
  55. package/dist/{chunk-JWH4OIBP.js → chunk-DRNZ24RF.js} +4 -4
  56. package/dist/{chunk-3FDE3BPB.js → chunk-EDUTIJAU.js} +9 -7
  57. package/dist/{chunk-5EKQBD2H.js → chunk-FCUXFLNK.js} +2 -2
  58. package/dist/{chunk-34EB622U.js → chunk-FYBHPBWY.js} +2 -2
  59. package/dist/{chunk-HOIDGDU5.js → chunk-GD3WXIHX.js} +1 -1
  60. package/dist/{chunk-6IYCBW4J.js → chunk-GIUB2OPA.js} +1 -1
  61. package/dist/{chunk-V7MTIMPB.js → chunk-GQYSSSVA.js} +3 -3
  62. package/dist/{chunk-X6IQ57SC.js → chunk-H6OT5GUL.js} +9 -5
  63. package/dist/{chunk-TPPLYCJF.js → chunk-HMOSAXVZ.js} +2 -2
  64. package/dist/{chunk-L5RW66H5.js → chunk-HVLYE4S5.js} +1 -1
  65. package/dist/{chunk-PIJKJNGB.js → chunk-HZZ6ZLKP.js} +4 -4
  66. package/dist/{chunk-AR2TM7CR.js → chunk-I26QP3A3.js} +1 -1
  67. package/dist/{chunk-D2TRWKVQ.js → chunk-I2WVMCYN.js} +80 -2
  68. package/dist/{chunk-JHGJG2Z2.js → chunk-IBYOMAZ3.js} +1 -1
  69. package/dist/{chunk-SUGSHXND.js → chunk-IEZFRNLC.js} +2 -2
  70. package/dist/{chunk-ZMJ4EP4C.js → chunk-ILHIHMO3.js} +7 -2
  71. package/dist/{chunk-FDBR634Z.js → chunk-IMPLRDOV.js} +6 -6
  72. package/dist/{chunk-ZYISLRS6.js → chunk-JWHSUEDE.js} +114 -37
  73. package/dist/{chunk-TH7WJLZC.js → chunk-KGBKIJPF.js} +3 -3
  74. package/dist/{chunk-3NK6YTA5.js → chunk-KUWJJD6O.js} +42 -8
  75. package/dist/{chunk-2I35VGHX.js → chunk-L35CBI7F.js} +2 -2
  76. package/dist/{chunk-KLN6HPYM.js → chunk-L3IACZ72.js} +1 -1
  77. package/dist/{chunk-MXOG5SAO.js → chunk-LIXSR7BG.js} +11 -14
  78. package/dist/{chunk-7GG3FEK2.js → chunk-MCWCRZM4.js} +4 -4
  79. package/dist/{chunk-V66YKIW6.js → chunk-MXMXJYN4.js} +5 -5
  80. package/dist/{chunk-GVPJL3XS.js → chunk-MZYJFU4K.js} +5 -5
  81. package/dist/{chunk-ZMNQ2YJ6.js → chunk-NBYCX6L4.js} +4 -4
  82. package/dist/{chunk-ZQXBHNEZ.js → chunk-NL4UNA53.js} +2 -2
  83. package/dist/{chunk-WQARLGBG.js → chunk-NRXTWATQ.js} +3 -3
  84. package/dist/{chunk-FXLUSECC.js → chunk-O56RNR7B.js} +1 -1
  85. package/dist/{chunk-3IV56JJW.js → chunk-P56WU3UT.js} +3 -2
  86. package/dist/{chunk-NQX7WBA4.js → chunk-PJYCPDV5.js} +14 -9
  87. package/dist/{chunk-R5T4LJSK.js → chunk-PZNAQBHQ.js} +2 -2
  88. package/dist/{chunk-32XS3Y6P.js → chunk-Q4XF3OBK.js} +8 -8
  89. package/dist/{chunk-IU457W7Q.js → chunk-QBJOYOVF.js} +2 -1
  90. package/dist/{chunk-C6AXM3M7.js → chunk-QJ6QQO6D.js} +3 -3
  91. package/dist/{chunk-2GIX4HAT.js → chunk-R6EXYBCT.js} +2 -2
  92. package/dist/{chunk-RVR6C22M.js → chunk-RT5S5KRX.js} +1 -1
  93. package/dist/{chunk-USYY3L7G.js → chunk-T3FQPTOA.js} +2 -2
  94. package/dist/{chunk-5IGBMS2U.js → chunk-T3HMVHDG.js} +1 -1
  95. package/dist/{chunk-RH4GKU52.js → chunk-T3IGOI6Z.js} +18 -3
  96. package/dist/{chunk-DAVYI5H4.js → chunk-T7BHW3CP.js} +23 -23
  97. package/dist/{chunk-QSUGIJWV.js → chunk-TG3S4RVJ.js} +4 -9
  98. package/dist/{chunk-IAF6VMPO.js → chunk-TPMZO6S2.js} +1 -1
  99. package/dist/{chunk-OGJUSGF7.js → chunk-UMRDMOB6.js} +1 -1
  100. package/dist/{chunk-KKCLTWG7.js → chunk-UMVZZQKD.js} +1 -1
  101. package/dist/{chunk-LAVHQCRP.js → chunk-UQ3LKJPM.js} +3 -3
  102. package/dist/{chunk-P26WOAA3.js → chunk-USIMPXUH.js} +1 -1
  103. package/dist/{chunk-Z25I7DRV.js → chunk-V5DH3OAC.js} +10 -5
  104. package/dist/{chunk-N3QIXC2B.js → chunk-VJWNFMMQ.js} +2 -2
  105. package/dist/{chunk-ZVXIZ2JD.js → chunk-VP527YC5.js} +35 -6
  106. package/dist/{chunk-6POQAFEC.js → chunk-W3JMIUHV.js} +1 -1
  107. package/dist/{chunk-V2R7RWVY.js → chunk-WDACZSRU.js} +1 -1
  108. package/dist/{chunk-FOOH6SCB.js → chunk-WU74DV5R.js} +2 -2
  109. package/dist/{chunk-6GP5IKXE.js → chunk-XSNJ7NT2.js} +1 -1
  110. package/dist/{chunk-S7W3KJYH.js → chunk-YYMUSVUI.js} +9 -4
  111. package/dist/{chunk-CREPPDHX.js → chunk-YZZHDZ7B.js} +1 -1
  112. package/dist/{chunk-LMNFIJ6M.js → chunk-ZWC5V2DB.js} +15 -15
  113. package/dist/{chunk-N76ZVITA.js → chunk-ZY2U24QP.js} +24 -14
  114. package/dist/config/index.js +5 -5
  115. package/dist/containers/client.js +6 -6
  116. package/dist/containers/exec.js +6 -6
  117. package/dist/containers/lifecycle.js +37 -37
  118. package/dist/containers/setup.js +9 -9
  119. package/dist/db/agents.js +8 -6
  120. package/dist/db/api_keys.js +5 -5
  121. package/dist/db/audit.js +3 -3
  122. package/dist/db/batch.js +10 -10
  123. package/dist/db/client.js +2 -2
  124. package/dist/db/credentials.js +3 -3
  125. package/dist/db/drizzle.js +4 -4
  126. package/dist/db/environments.js +6 -6
  127. package/dist/db/events.js +5 -5
  128. package/dist/db/files.js +5 -5
  129. package/dist/db/memory.js +5 -5
  130. package/dist/db/migrations.js +1 -1
  131. package/dist/db/proxy.js +5 -5
  132. package/dist/db/schema.js +1 -1
  133. package/dist/db/session-resources.js +5 -5
  134. package/dist/db/sessions.js +8 -7
  135. package/dist/db/sync.js +5 -5
  136. package/dist/db/tenants.js +3 -3
  137. package/dist/db/traces.js +5 -5
  138. package/dist/db/upstream_keys.js +3 -3
  139. package/dist/db/vaults.js +12 -8
  140. package/dist/handlers/agents.js +57 -53
  141. package/dist/handlers/api_keys.js +54 -54
  142. package/dist/handlers/audit.js +54 -54
  143. package/dist/handlers/batch.js +54 -54
  144. package/dist/handlers/credentials.js +54 -54
  145. package/dist/handlers/environments.js +54 -54
  146. package/dist/handlers/events.js +57 -57
  147. package/dist/handlers/files.js +54 -54
  148. package/dist/handlers/index.js +101 -93
  149. package/dist/handlers/license.js +53 -53
  150. package/dist/handlers/memory.js +54 -54
  151. package/dist/handlers/metrics.js +53 -53
  152. package/dist/handlers/models.js +54 -54
  153. package/dist/handlers/openapi.js +3 -3
  154. package/dist/handlers/providers.js +53 -53
  155. package/dist/handlers/resources.js +53 -53
  156. package/dist/handlers/sessions.js +56 -56
  157. package/dist/handlers/settings.js +53 -53
  158. package/dist/handlers/skills-write.js +53 -53
  159. package/dist/handlers/skills.js +54 -54
  160. package/dist/handlers/stream.js +53 -53
  161. package/dist/handlers/tenants.js +54 -54
  162. package/dist/handlers/threads.js +53 -53
  163. package/dist/handlers/traces.js +54 -54
  164. package/dist/handlers/upstream_keys.js +56 -56
  165. package/dist/handlers/vaults.js +57 -53
  166. package/dist/handlers/whoami.js +53 -53
  167. package/dist/http.js +56 -52
  168. package/dist/index.js +58 -58
  169. package/dist/init.js +49 -49
  170. package/dist/lib/model-registry.js +6 -6
  171. package/dist/lib/skills-cache.js +6 -6
  172. package/dist/observability/otlp.js +12 -12
  173. package/dist/observability/redactor.js +8 -8
  174. package/dist/openapi/schemas.js +3 -1
  175. package/dist/openapi/spec.js +2 -2
  176. package/dist/providers/fly.js +5 -5
  177. package/dist/providers/modal.js +5 -5
  178. package/dist/providers/registry.js +1 -1
  179. package/dist/providers/resolve-secrets.js +7 -7
  180. package/dist/providers/sprites.js +7 -7
  181. package/dist/providers/upstream-keys.js +12 -11
  182. package/dist/providers/vercel.js +5 -5
  183. package/dist/proxy/forward.js +6 -6
  184. package/dist/queue/index.js +6 -6
  185. package/dist/sessions/bus.js +10 -10
  186. package/dist/sessions/driver.js +42 -42
  187. package/dist/sessions/grader.js +5 -5
  188. package/dist/sessions/mcp-auth.js +1 -1
  189. package/dist/sessions/secrets.js +8 -8
  190. package/dist/sessions/sweeper.js +38 -38
  191. package/dist/sessions/threads.js +42 -42
  192. package/dist/shutdown.js +39 -39
  193. package/dist/sync/anthropic.js +11 -11
  194. package/dist/sync/container-file-sync.js +6 -6
  195. package/dist/sync/file-sync.js +17 -17
  196. package/package.json +1 -1
  197. /package/dist/{chunk-WPK4ZPMG.js → chunk-JRQB3SHR.js} +0 -0
@@ -7,32 +7,37 @@ function buildCodexArgs(input) {
7
7
  "--skip-git-repo-check"
8
8
  ];
9
9
  if (input.agent.model) {
10
- args.push("--model", input.agent.model);
10
+ const modelId = input.agent.model.id;
11
+ args.push("--model", modelId);
11
12
  const cloudPrefixes = ["claude-", "gpt-", "o1-", "o3-", "o4-", "codex-", "chatgpt-"];
12
- const isOllama = !input.agent.model.includes("/") && !cloudPrefixes.some((p) => input.agent.model.startsWith(p));
13
+ const isOllama = !modelId.includes("/") && !cloudPrefixes.some((p) => modelId.startsWith(p));
13
14
  if (isOllama) {
14
15
  args.push("--oss", "--local-provider", "ollama");
15
16
  }
16
17
  }
17
18
  if (input.agent.mcp_servers) {
18
- for (const [name, server] of Object.entries(input.agent.mcp_servers)) {
19
+ for (const server of input.agent.mcp_servers) {
20
+ const name = server.name;
19
21
  if (server.type) {
20
22
  args.push("-c", `mcp_servers.${name}.type="${server.type}"`);
21
23
  }
22
24
  if (server.url) {
23
25
  args.push("-c", `mcp_servers.${name}.url="${server.url}"`);
24
26
  }
25
- if (typeof server.command === "string") {
26
- args.push("-c", `mcp_servers.${name}.command="${server.command}"`);
27
+ const command = server.command;
28
+ if (typeof command === "string") {
29
+ args.push("-c", `mcp_servers.${name}.command="${command}"`);
27
30
  }
28
- if (server.args && server.args.length > 0) {
31
+ const sArgs = server.args;
32
+ if (sArgs && sArgs.length > 0) {
29
33
  args.push(
30
34
  "-c",
31
- `mcp_servers.${name}.args=${JSON.stringify(server.args)}`
35
+ `mcp_servers.${name}.args=${JSON.stringify(sArgs)}`
32
36
  );
33
37
  }
34
- if (server.headers) {
35
- for (const [hk, hv] of Object.entries(server.headers)) {
38
+ const headers = server.headers;
39
+ if (headers) {
40
+ for (const [hk, hv] of Object.entries(headers)) {
36
41
  args.push("-c", `mcp_servers.${name}.http_headers.${hk}="${hv}"`);
37
42
  }
38
43
  }
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  init_schema,
3
3
  schema_exports
4
- } from "./chunk-ZMJ4EP4C.js";
4
+ } from "./chunk-ILHIHMO3.js";
5
5
  import {
6
6
  getDb,
7
7
  init_client
8
- } from "./chunk-6POQAFEC.js";
8
+ } from "./chunk-W3JMIUHV.js";
9
9
  import {
10
10
  __esm
11
11
  } from "./chunk-2ESYSVXG.js";
@@ -1,32 +1,32 @@
1
1
  import {
2
2
  resolveRemoteSessionId
3
- } from "./chunk-L2RX552S.js";
3
+ } from "./chunk-22OUZJAV.js";
4
4
  import {
5
5
  assertResourceTenant
6
6
  } from "./chunk-23UKWXJH.js";
7
7
  import {
8
8
  authenticateAndIntercept
9
- } from "./chunk-WQARLGBG.js";
9
+ } from "./chunk-NRXTWATQ.js";
10
10
  import {
11
11
  forwardToAnthropic
12
- } from "./chunk-JCW3ZRES.js";
12
+ } from "./chunk-A46RUKGA.js";
13
13
  import {
14
14
  ensureInitialized
15
- } from "./chunk-LMNFIJ6M.js";
15
+ } from "./chunk-ZWC5V2DB.js";
16
16
  import {
17
17
  getProxiedTenantId,
18
18
  isProxied
19
- } from "./chunk-E7DD7F7J.js";
19
+ } from "./chunk-5U5LRAFJ.js";
20
20
  import {
21
21
  subscribe
22
- } from "./chunk-MHBLVGRF.js";
22
+ } from "./chunk-5MERXOLJ.js";
23
23
  import {
24
24
  getSession
25
- } from "./chunk-3NK6YTA5.js";
25
+ } from "./chunk-KUWJJD6O.js";
26
26
  import {
27
27
  getDb,
28
28
  init_client
29
- } from "./chunk-6POQAFEC.js";
29
+ } from "./chunk-W3JMIUHV.js";
30
30
  import {
31
31
  notFound,
32
32
  toResponse
@@ -7,7 +7,8 @@ export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
7
7
  export NODE_COMPILE_CACHE=/tmp/v8-cache
8
8
  mkdir -p /tmp/v8-cache
9
9
  # Install claude CLI if not present
10
- if ! command -v claude >/dev/null 2>&1; then npm install -g @anthropic-ai/claude-code 2>/dev/null; fi
10
+ if ! command -v claude >/dev/null 2>&1; then npm install -g @anthropic-ai/claude-code; fi
11
+ claude --version >&2 2>/dev/null || true
11
12
  # Read env vars from stdin until blank line, save remaining stdin to temp file
12
13
  PROMPT_FILE=$(mktemp)
13
14
  while IFS= read -r line; do [ -z "$line" ] && break; export "$line"; done
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  resolveContainerProvider
3
- } from "./chunk-WPK4ZPMG.js";
3
+ } from "./chunk-JRQB3SHR.js";
4
4
  import {
5
5
  getEnvironmentRow,
6
6
  updateEnvironmentState
7
- } from "./chunk-X6IQ57SC.js";
7
+ } from "./chunk-H6OT5GUL.js";
8
8
  import {
9
9
  installClaudeWrapper
10
- } from "./chunk-IU457W7Q.js";
10
+ } from "./chunk-QBJOYOVF.js";
11
11
  import {
12
12
  init_ids,
13
13
  newId
@@ -9,11 +9,11 @@ import {
9
9
  } from "./chunk-QQDSHL27.js";
10
10
  import {
11
11
  buildFactoryArgs
12
- } from "./chunk-IAF6VMPO.js";
12
+ } from "./chunk-TPMZO6S2.js";
13
13
  import {
14
14
  buildFactoryAuthEnv,
15
15
  validateFactoryRuntime
16
- } from "./chunk-CREPPDHX.js";
16
+ } from "./chunk-YZZHDZ7B.js";
17
17
  import {
18
18
  wrapPromptWithSystem
19
19
  } from "./chunk-FVBDEOTZ.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-V7MTIMPB.js";
3
+ } from "./chunk-GQYSSSVA.js";
4
4
 
5
5
  // src/backends/pi/auth.ts
6
6
  function buildPiAuthEnv() {
@@ -9,10 +9,10 @@ import {
9
9
  import {
10
10
  getDrizzle,
11
11
  init_drizzle
12
- } from "./chunk-R5T4LJSK.js";
12
+ } from "./chunk-PZNAQBHQ.js";
13
13
  import {
14
14
  schema_exports
15
- } from "./chunk-ZMJ4EP4C.js";
15
+ } from "./chunk-ILHIHMO3.js";
16
16
 
17
17
  // src/db/api_keys.ts
18
18
  init_drizzle();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  listEntries
3
- } from "./chunk-ZVXIZ2JD.js";
3
+ } from "./chunk-VP527YC5.js";
4
4
 
5
5
  // src/providers/resolve-secrets.ts
6
6
  var BLOCKED_ENV_KEYS = /* @__PURE__ */ new Set([
@@ -4,13 +4,13 @@ import {
4
4
  } from "./chunk-D2XITRN6.js";
5
5
  import {
6
6
  authenticateAndIntercept
7
- } from "./chunk-WQARLGBG.js";
7
+ } from "./chunk-NRXTWATQ.js";
8
8
  import {
9
9
  checkAndBump
10
10
  } from "./chunk-HVUWXUUI.js";
11
11
  import {
12
12
  ensureInitialized
13
- } from "./chunk-LMNFIJ6M.js";
13
+ } from "./chunk-ZWC5V2DB.js";
14
14
  import {
15
15
  captureException
16
16
  } from "./chunk-3MQ2FWXS.js";
@@ -64,8 +64,23 @@ async function routeWrap(request, handler) {
64
64
  function jsonOk(body, status = 200) {
65
65
  return Response.json(body, { status });
66
66
  }
67
+ function paginatedOk(data, requestedLimit) {
68
+ const hasMore = data.length === requestedLimit;
69
+ const nextPage = hasMore && data.length > 0 ? Buffer.from(data[data.length - 1].id).toString("base64url") : null;
70
+ return jsonOk({ data, next_page: nextPage });
71
+ }
72
+ function decodeCursor(page) {
73
+ if (!page) return void 0;
74
+ try {
75
+ return Buffer.from(page, "base64url").toString("utf8");
76
+ } catch {
77
+ return void 0;
78
+ }
79
+ }
67
80
 
68
81
  export {
69
82
  routeWrap,
70
- jsonOk
83
+ jsonOk,
84
+ paginatedOk,
85
+ decodeCursor
71
86
  };
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-H6TQGV4L.js";
13
13
  import {
14
14
  injectMcpAuthHeaders
15
- } from "./chunk-SV2B3P6B.js";
15
+ } from "./chunk-DBFPJSOY.js";
16
16
  import {
17
17
  incrementRetry,
18
18
  resetRetry,
@@ -21,24 +21,24 @@ import {
21
21
  } from "./chunk-72BKGVBE.js";
22
22
  import {
23
23
  loadSessionSecrets
24
- } from "./chunk-TPPLYCJF.js";
24
+ } from "./chunk-HMOSAXVZ.js";
25
25
  import {
26
26
  isProxied
27
- } from "./chunk-E7DD7F7J.js";
27
+ } from "./chunk-5U5LRAFJ.js";
28
28
  import {
29
29
  acquireForFirstTurn,
30
30
  installSkills,
31
31
  provisionResources,
32
32
  wrapProviderWithSecrets
33
- } from "./chunk-N76ZVITA.js";
33
+ } from "./chunk-ZY2U24QP.js";
34
34
  import {
35
35
  BLOCKED_ENV_KEYS,
36
36
  resolveVaultSecrets
37
- } from "./chunk-5IGBMS2U.js";
37
+ } from "./chunk-T3HMVHDG.js";
38
38
  import {
39
39
  appendEvent,
40
40
  appendEventsBatch
41
- } from "./chunk-MHBLVGRF.js";
41
+ } from "./chunk-5MERXOLJ.js";
42
42
  import {
43
43
  bumpSessionStats,
44
44
  getOutcomeCriteria,
@@ -49,26 +49,26 @@ import {
49
49
  setOutcomeCriteria,
50
50
  updateSessionMutable,
51
51
  updateSessionStatus
52
- } from "./chunk-3NK6YTA5.js";
52
+ } from "./chunk-KUWJJD6O.js";
53
53
  import {
54
54
  listEvents,
55
55
  markUserEventProcessed
56
- } from "./chunk-TH7WJLZC.js";
56
+ } from "./chunk-KGBKIJPF.js";
57
57
  import {
58
58
  getBySession
59
59
  } from "./chunk-EFOIR7R3.js";
60
60
  import {
61
61
  resolveContainerProvider
62
- } from "./chunk-WPK4ZPMG.js";
62
+ } from "./chunk-JRQB3SHR.js";
63
63
  import {
64
64
  getEnvironment
65
- } from "./chunk-X6IQ57SC.js";
65
+ } from "./chunk-H6OT5GUL.js";
66
66
  import {
67
67
  getAgent
68
- } from "./chunk-ZTH5JRZG.js";
68
+ } from "./chunk-BCIFFAGW.js";
69
69
  import {
70
70
  resolveBackend
71
- } from "./chunk-FDBR634Z.js";
71
+ } from "./chunk-IMPLRDOV.js";
72
72
  import {
73
73
  PERMISSION_BRIDGE_PENDING_PATH,
74
74
  PERMISSION_BRIDGE_REQUEST_PATH,
@@ -84,7 +84,7 @@ import {
84
84
  } from "./chunk-XBHDQK4Z.js";
85
85
  import {
86
86
  getConfig
87
- } from "./chunk-V7MTIMPB.js";
87
+ } from "./chunk-GQYSSSVA.js";
88
88
  import {
89
89
  init_clock,
90
90
  nowMs
@@ -259,7 +259,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
259
259
  updateSessionStatus(sessionId, "running");
260
260
  const turnStartMs = nowMs();
261
261
  emit("session.status_running", {}, { at: turnStartMs });
262
- emit("span.model_request_start", { model: agent.model }, { at: turnStartMs });
262
+ emit("span.model_request_start", { model: agent.model.id }, { at: turnStartMs });
263
263
  const promptText = inputs.filter((i) => i.kind === "text").map((i) => i.text).join("\n\n");
264
264
  const toolResults = inputs.filter((i) => i.kind === "tool_result").map((i) => ({
265
265
  custom_tool_use_id: i.custom_tool_use_id,
@@ -277,7 +277,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
277
277
  } catch (err) {
278
278
  const msg = err instanceof ApiError ? err.message : err instanceof Error ? err.message : String(err);
279
279
  const type = err instanceof ApiError ? err.type : "server_error";
280
- emit("span.model_request_end", { model: agent.model, model_usage: null, status: "error" });
280
+ emit("span.model_request_end", { model: agent.model.id, model_usage: null, status: "error" });
281
281
  emit("session.error", { error: { type, message: msg } });
282
282
  emit("session.status_idle", { stop_reason: formatStopReason("error") });
283
283
  updateSessionStatus(sessionId, "idle", "error");
@@ -298,7 +298,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
298
298
  }
299
299
  }
300
300
  }
301
- console.log(`[driver] ${sessionId} executing turn (engine: ${agent.engine}, model: ${agent.model})`);
301
+ console.log(`[driver] ${sessionId} executing turn (engine: ${agent.engine}, model: ${agent.model.id})`);
302
302
  const argv = [backend.wrapperPath, ...turnBuild.argv];
303
303
  const freshSession = getSession(sessionId);
304
304
  if (freshSession?.resources && freshSession.resources.length > 0) {
@@ -324,7 +324,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
324
324
  delete turnBuild.env.ANTHROPIC_API_KEY;
325
325
  }
326
326
  const ollamaCloudPrefixes = ["claude-", "gpt-", "o1-", "o3-", "o4-", "codex-", "chatgpt-", "gemini-"];
327
- const isOllamaModel = !agent.model.includes("/") && !ollamaCloudPrefixes.some((p) => agent.model.startsWith(p));
327
+ const isOllamaModel = !agent.model.id.includes("/") && !ollamaCloudPrefixes.some((p) => agent.model.id.startsWith(p));
328
328
  if (isOllamaModel) {
329
329
  let ollamaHostPort;
330
330
  if (!turnBuild.env.OLLAMA_HOST) {
@@ -424,7 +424,7 @@ ${turnBuild.stdin}`;
424
424
  } catch (err) {
425
425
  runtime.inFlightRuns.delete(sessionId);
426
426
  const msg = err instanceof Error ? err.message : String(err);
427
- emit("span.model_request_end", { model: agent.model, model_usage: null, status: "error" });
427
+ emit("span.model_request_end", { model: agent.model.id, model_usage: null, status: "error" });
428
428
  emit("session.error", { error: { type: "server_error", message: `exec failed: ${msg}` } });
429
429
  emit("session.status_idle", { stop_reason: formatStopReason("error") });
430
430
  updateSessionStatus(sessionId, "idle", "error");
@@ -539,7 +539,7 @@ ${turnBuild.stdin}`;
539
539
  await retryDelay(retry.delayMs);
540
540
  return runTurn(sessionId, inputs, _depth + 1, parentTrace);
541
541
  }
542
- emit("span.model_request_end", { model: agent.model, model_usage: null, status: "error" });
542
+ emit("span.model_request_end", { model: agent.model.id, model_usage: null, status: "error" });
543
543
  const retryStatus = classified.retryable ? "exhausted" : "terminal";
544
544
  emit("session.error", { error: buildErrorPayload(classified, retryStatus) });
545
545
  emit("session.status_idle", { stop_reason: formatStopReason("error") });
@@ -556,7 +556,7 @@ ${turnBuild.stdin}`;
556
556
  if (aborted) {
557
557
  const partial = translator.getTurnResult();
558
558
  emit("span.model_request_end", {
559
- model: agent.model,
559
+ model: agent.model.id,
560
560
  model_usage: partial?.usage ?? null,
561
561
  status: "interrupted"
562
562
  });
@@ -622,7 +622,7 @@ ${turnBuild.stdin}`;
622
622
  if (serverToolResult) {
623
623
  emit(
624
624
  "span.model_request_end",
625
- { model: agent.model, model_usage: result?.usage ?? null, status: "ok" },
625
+ { model: agent.model.id, model_usage: result?.usage ?? null, status: "ok" },
626
626
  { at: now }
627
627
  );
628
628
  emit("session.status_idle", { stop_reason: formatStopReason("custom_tool_call", customToolEventIds) }, { at: now });
@@ -659,7 +659,7 @@ ${turnBuild.stdin}`;
659
659
  }
660
660
  emit(
661
661
  "span.model_request_end",
662
- { model: agent.model, model_usage: result?.usage ?? null, status: "ok" },
662
+ { model: agent.model.id, model_usage: result?.usage ?? null, status: "ok" },
663
663
  { at: now }
664
664
  );
665
665
  const finalEventIds = stopReason === "custom_tool_call" ? listEvents(sessionId, { limit: 20, order: "desc" }).filter((e) => e.type === "agent.custom_tool_use").map((e) => e.id) : void 0;
@@ -691,7 +691,7 @@ ${turnBuild.stdin}`;
691
691
  const evaluation = await runGraderEvaluation(
692
692
  criteria.rubric,
693
693
  lastAgentText,
694
- agent.model
694
+ agent.model.id
695
695
  );
696
696
  if (evaluation.usage.input_tokens || evaluation.usage.output_tokens) {
697
697
  bumpSessionStats(sessionId, {}, {
@@ -4,11 +4,11 @@ import {
4
4
  } from "./chunk-23UKWXJH.js";
5
5
  import {
6
6
  listAudit
7
- } from "./chunk-KLN6HPYM.js";
7
+ } from "./chunk-L3IACZ72.js";
8
8
  import {
9
- jsonOk,
9
+ paginatedOk,
10
10
  routeWrap
11
- } from "./chunk-RH4GKU52.js";
11
+ } from "./chunk-T3IGOI6Z.js";
12
12
  import {
13
13
  badRequest
14
14
  } from "./chunk-EZYKRG4W.js";
@@ -57,12 +57,7 @@ function handleListAudit(request) {
57
57
  createdLte,
58
58
  tenantFilter: tenantFilter(auth)
59
59
  });
60
- return jsonOk({
61
- data,
62
- has_more: data.length === requestedLimit,
63
- first_id: data.length > 0 ? data[0].id : null,
64
- last_id: data.length > 0 ? data[data.length - 1].id : null
65
- });
60
+ return paginatedOk(data, requestedLimit);
66
61
  });
67
62
  }
68
63
 
@@ -11,7 +11,7 @@ function buildFactoryArgs(input) {
11
11
  args.push("--session-id", input.backendSessionId);
12
12
  }
13
13
  if (input.agent.model) {
14
- args.push("--model", input.agent.model);
14
+ args.push("--model", input.agent.model.id);
15
15
  }
16
16
  return args;
17
17
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-V7MTIMPB.js";
3
+ } from "./chunk-GQYSSSVA.js";
4
4
 
5
5
  // src/backends/opencode/auth.ts
6
6
  function buildOpencodeAuthEnv() {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  jsonOk,
3
3
  routeWrap
4
- } from "./chunk-RH4GKU52.js";
4
+ } from "./chunk-T3IGOI6Z.js";
5
5
 
6
6
  // src/handlers/whoami.ts
7
7
  function handleWhoami(request) {
@@ -11,18 +11,18 @@ import {
11
11
  getFileRecord,
12
12
  listFiles,
13
13
  updateFileStoragePath
14
- } from "./chunk-NQVRZAIX.js";
14
+ } from "./chunk-DMMNAQUM.js";
15
15
  import {
16
16
  assertResourceTenant
17
17
  } from "./chunk-23UKWXJH.js";
18
18
  import {
19
19
  jsonOk,
20
20
  routeWrap
21
- } from "./chunk-RH4GKU52.js";
21
+ } from "./chunk-T3IGOI6Z.js";
22
22
  import {
23
23
  getDb,
24
24
  init_client
25
- } from "./chunk-6POQAFEC.js";
25
+ } from "./chunk-W3JMIUHV.js";
26
26
  import {
27
27
  badRequest,
28
28
  notFound
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-V7MTIMPB.js";
3
+ } from "./chunk-GQYSSSVA.js";
4
4
  import {
5
5
  ApiError
6
6
  } from "./chunk-EZYKRG4W.js";
@@ -27,21 +27,26 @@ function isOllamaModel(model) {
27
27
  return !cloudPrefixes.some((p) => model.startsWith(p));
28
28
  }
29
29
  function buildOpencodeConfigEnv(agent, ollamaBaseUrl) {
30
- if (ollamaBaseUrl === void 0 && isOllamaModel(agent.model)) {
30
+ if (ollamaBaseUrl === void 0 && isOllamaModel(agent.model.id)) {
31
31
  ollamaBaseUrl = "http://localhost:11434/v1";
32
32
  }
33
33
  const config = {};
34
- if (agent.mcp_servers && Object.keys(agent.mcp_servers).length > 0) {
35
- config.mcp = mcpConfigToOpencode(agent.mcp_servers);
34
+ if (agent.mcp_servers && agent.mcp_servers.length > 0) {
35
+ const mcpRecord = {};
36
+ for (const s of agent.mcp_servers) {
37
+ const { name, ...rest } = s;
38
+ mcpRecord[name] = rest;
39
+ }
40
+ config.mcp = mcpConfigToOpencode(mcpRecord);
36
41
  }
37
- if (isOllamaModel(agent.model) && ollamaBaseUrl) {
42
+ if (isOllamaModel(agent.model.id) && ollamaBaseUrl) {
38
43
  config.provider = {
39
44
  ollama: {
40
45
  npm: "@ai-sdk/openai-compatible",
41
46
  name: "Ollama (local)",
42
47
  options: { baseURL: ollamaBaseUrl },
43
48
  models: {
44
- [agent.model]: { name: agent.model }
49
+ [agent.model.id]: { name: agent.model.id }
45
50
  }
46
51
  }
47
52
  };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  listEntries
3
- } from "./chunk-ZVXIZ2JD.js";
3
+ } from "./chunk-VP527YC5.js";
4
4
  import {
5
5
  getConfig
6
- } from "./chunk-V7MTIMPB.js";
6
+ } from "./chunk-GQYSSSVA.js";
7
7
 
8
8
  // src/observability/redactor.ts
9
9
  var REDACTED = "[REDACTED]";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-AIBH32FN.js";
5
5
  import {
6
6
  DEFAULT_TENANT_ID
7
- } from "./chunk-AR2TM7CR.js";
7
+ } from "./chunk-I26QP3A3.js";
8
8
  import {
9
9
  init_ids,
10
10
  newId
@@ -17,24 +17,32 @@ import {
17
17
  import {
18
18
  getDrizzle,
19
19
  init_drizzle
20
- } from "./chunk-R5T4LJSK.js";
20
+ } from "./chunk-PZNAQBHQ.js";
21
21
  import {
22
22
  schema_exports
23
- } from "./chunk-ZMJ4EP4C.js";
23
+ } from "./chunk-ILHIHMO3.js";
24
24
 
25
25
  // src/db/vaults.ts
26
26
  init_drizzle();
27
27
  init_ids();
28
28
  init_clock();
29
- import { eq, and, asc, desc } from "drizzle-orm";
29
+ import { eq, and, asc, desc, isNull } from "drizzle-orm";
30
30
  function hydrateVault(row) {
31
+ let metadata = {};
32
+ try {
33
+ metadata = JSON.parse(row.metadata_json || "{}");
34
+ } catch {
35
+ }
31
36
  return {
37
+ type: "vault",
32
38
  id: row.id,
33
39
  agent_id: row.agent_id,
34
40
  name: row.name,
35
41
  display_name: row.name,
42
+ metadata,
36
43
  created_at: toIso(row.created_at),
37
- updated_at: toIso(row.updated_at)
44
+ updated_at: toIso(row.updated_at),
45
+ archived_at: row.archived_at ? toIso(row.archived_at) : null
38
46
  };
39
47
  }
40
48
  function createVault(input) {
@@ -43,8 +51,9 @@ function createVault(input) {
43
51
  const now = nowMs();
44
52
  db.insert(schema_exports.vaults).values({
45
53
  id,
46
- agent_id: input.agent_id,
54
+ agent_id: input.agent_id ?? null,
47
55
  name: input.name,
56
+ metadata_json: JSON.stringify(input.metadata ?? {}),
48
57
  tenant_id: input.tenant_id ?? DEFAULT_TENANT_ID,
49
58
  created_at: now,
50
59
  updated_at: now
@@ -69,6 +78,24 @@ function listVaults(opts) {
69
78
  const rows = where ? db.select().from(schema_exports.vaults).where(where).orderBy(desc(schema_exports.vaults.created_at)).all() : db.select().from(schema_exports.vaults).orderBy(desc(schema_exports.vaults.created_at)).all();
70
79
  return rows.map(hydrateVault);
71
80
  }
81
+ function updateVault(id, fields) {
82
+ const db = getDrizzle();
83
+ const now = nowMs();
84
+ const updates = { updated_at: now };
85
+ if (fields.display_name !== void 0) {
86
+ updates.name = fields.display_name;
87
+ }
88
+ if (fields.metadata !== void 0) {
89
+ updates.metadata_json = JSON.stringify(fields.metadata);
90
+ }
91
+ db.update(schema_exports.vaults).set(updates).where(eq(schema_exports.vaults.id, id)).run();
92
+ return getVault(id);
93
+ }
94
+ function archiveVault(id) {
95
+ const db = getDrizzle();
96
+ const res = db.update(schema_exports.vaults).set({ archived_at: nowMs() }).where(and(eq(schema_exports.vaults.id, id), isNull(schema_exports.vaults.archived_at))).run();
97
+ return res.changes > 0;
98
+ }
72
99
  function deleteVault(id) {
73
100
  const db = getDrizzle();
74
101
  const res = db.delete(schema_exports.vaults).where(eq(schema_exports.vaults.id, id)).run();
@@ -114,6 +141,8 @@ export {
114
141
  createVault,
115
142
  getVault,
116
143
  listVaults,
144
+ updateVault,
145
+ archiveVault,
117
146
  deleteVault,
118
147
  setEntry,
119
148
  getEntry,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_migrations,
3
3
  runMigrations
4
- } from "./chunk-WCDWL6ED.js";
4
+ } from "./chunk-2YZOIFVN.js";
5
5
  import {
6
6
  __esm
7
7
  } from "./chunk-2ESYSVXG.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-V7MTIMPB.js";
3
+ } from "./chunk-GQYSSSVA.js";
4
4
 
5
5
  // src/backends/gemini/auth.ts
6
6
  function buildGeminiAuthEnv() {
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  BatchError,
3
3
  executeBatch
4
- } from "./chunk-7GG3FEK2.js";
4
+ } from "./chunk-MCWCRZM4.js";
5
5
  import {
6
6
  jsonOk,
7
7
  routeWrap
8
- } from "./chunk-RH4GKU52.js";
8
+ } from "./chunk-T3IGOI6Z.js";
9
9
  import {
10
10
  badRequest
11
11
  } from "./chunk-EZYKRG4W.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getDrizzle,
3
3
  init_drizzle
4
- } from "./chunk-R5T4LJSK.js";
4
+ } from "./chunk-PZNAQBHQ.js";
5
5
 
6
6
  // src/db/traces.ts
7
7
  init_drizzle();