@agentstep/agent-sdk 0.4.41 → 0.5.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 (195) 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 +7 -7
  4. package/dist/backends/codex/args.js +1 -1
  5. package/dist/backends/codex/auth.js +6 -6
  6. package/dist/backends/codex/index.js +8 -8
  7. package/dist/backends/factory/args.js +1 -1
  8. package/dist/backends/factory/auth.js +6 -6
  9. package/dist/backends/factory/index.js +8 -8
  10. package/dist/backends/gemini/args.js +1 -1
  11. package/dist/backends/gemini/auth.js +6 -6
  12. package/dist/backends/gemini/index.js +8 -8
  13. package/dist/backends/opencode/args.js +1 -1
  14. package/dist/backends/opencode/auth.js +6 -6
  15. package/dist/backends/opencode/index.js +9 -9
  16. package/dist/backends/opencode/mcp.js +1 -1
  17. package/dist/backends/pi/args.js +1 -1
  18. package/dist/backends/pi/auth.js +6 -6
  19. package/dist/backends/pi/index.js +8 -8
  20. package/dist/backends/registry.js +24 -24
  21. package/dist/{chunk-L2RX552S.js → chunk-22OUZJAV.js} +3 -3
  22. package/dist/{chunk-PIJKJNGB.js → chunk-24IDJ7LY.js} +4 -4
  23. package/dist/{chunk-WCDWL6ED.js → chunk-2YZOIFVN.js} +49 -0
  24. package/dist/{chunk-RDGOGAQ5.js → chunk-3FLQ7KZP.js} +1 -1
  25. package/dist/{chunk-ZQXBHNEZ.js → chunk-3PA4NXRP.js} +2 -2
  26. package/dist/{chunk-H7UKW666.js → chunk-445EL6J5.js} +1 -1
  27. package/dist/{chunk-2RSL5SO7.js → chunk-4D345E27.js} +2 -2
  28. package/dist/{chunk-2Z2KAPUL.js → chunk-4RDILRIO.js} +3 -3
  29. package/dist/{chunk-MHBLVGRF.js → chunk-5MERXOLJ.js} +4 -4
  30. package/dist/{chunk-E7DD7F7J.js → chunk-5U5LRAFJ.js} +2 -2
  31. package/dist/{chunk-34EB622U.js → chunk-64IQEPSD.js} +2 -2
  32. package/dist/{chunk-ENGKR2JT.js → chunk-6CVQDSTS.js} +1 -1
  33. package/dist/{chunk-T5VRE77P.js → chunk-6KWJASEO.js} +1 -1
  34. package/dist/{chunk-W2NHS4IF.js → chunk-6QZ23WRF.js} +15 -19
  35. package/dist/{chunk-DU7LSFQQ.js → chunk-7SY65LWY.js} +6 -9
  36. package/dist/{chunk-C46UG6GQ.js → chunk-A6VORSKD.js} +1 -1
  37. package/dist/{chunk-3FDE3BPB.js → chunk-AB7MPL3H.js} +6 -6
  38. package/dist/{chunk-RP6WQ4IH.js → chunk-AJL3T5JS.js} +3 -3
  39. package/dist/{chunk-KKCLTWG7.js → chunk-AXBM7HAR.js} +1 -1
  40. package/dist/{chunk-ZTH5JRZG.js → chunk-BCIFFAGW.js} +41 -10
  41. package/dist/{chunk-OXWELRJL.js → chunk-CBPO2P4I.js} +101 -16
  42. package/dist/{chunk-32XS3Y6P.js → chunk-CLSGNQ7J.js} +8 -8
  43. package/dist/{chunk-SV2B3P6B.js → chunk-DBFPJSOY.js} +19 -17
  44. package/dist/{chunk-JWH4OIBP.js → chunk-DJZSPWG2.js} +4 -4
  45. package/dist/{chunk-JZL4L54R.js → chunk-DKLHYSPW.js} +2 -2
  46. package/dist/{chunk-NQVRZAIX.js → chunk-DMMNAQUM.js} +2 -2
  47. package/dist/{chunk-Y6SFUNGO.js → chunk-EOJ66GY7.js} +4 -4
  48. package/dist/{chunk-EUINGLHA.js → chunk-EWIWVXXP.js} +30 -20
  49. package/dist/{chunk-5EKQBD2H.js → chunk-FCUXFLNK.js} +2 -2
  50. package/dist/{chunk-LAVHQCRP.js → chunk-FSQ4HGHX.js} +3 -3
  51. package/dist/{chunk-WQARLGBG.js → chunk-GCQDNUS2.js} +3 -3
  52. package/dist/{chunk-MXOG5SAO.js → chunk-GFSRNOPI.js} +11 -14
  53. package/dist/{chunk-S7W3KJYH.js → chunk-GIMDS46L.js} +9 -4
  54. package/dist/{chunk-FP4E3QUS.js → chunk-GLKWJESP.js} +2 -2
  55. package/dist/{chunk-FDBR634Z.js → chunk-GV6GUSCP.js} +6 -6
  56. package/dist/{chunk-X6IQ57SC.js → chunk-H6OT5GUL.js} +9 -5
  57. package/dist/{chunk-TPPLYCJF.js → chunk-HMOSAXVZ.js} +2 -2
  58. package/dist/{chunk-L5RW66H5.js → chunk-HVLYE4S5.js} +1 -1
  59. package/dist/{chunk-RVR6C22M.js → chunk-HWR2HYQJ.js} +1 -1
  60. package/dist/{chunk-HH4OXSOV.js → chunk-HY3T4YJV.js} +5 -5
  61. package/dist/{chunk-AR2TM7CR.js → chunk-I26QP3A3.js} +1 -1
  62. package/dist/{chunk-D2TRWKVQ.js → chunk-I2WVMCYN.js} +80 -2
  63. package/dist/{chunk-JHGJG2Z2.js → chunk-IBYOMAZ3.js} +1 -1
  64. package/dist/{chunk-SUGSHXND.js → chunk-IEZFRNLC.js} +2 -2
  65. package/dist/{chunk-ZMJ4EP4C.js → chunk-ILHIHMO3.js} +7 -2
  66. package/dist/{chunk-XWWLMJXT.js → chunk-IRW7AYTP.js} +6 -15
  67. package/dist/{chunk-N76ZVITA.js → chunk-JFOHGHW5.js} +9 -9
  68. package/dist/{chunk-DAVYI5H4.js → chunk-JLUCJMAQ.js} +23 -23
  69. package/dist/{chunk-GVPJL3XS.js → chunk-JP7Y3TKK.js} +5 -5
  70. package/dist/{chunk-TH7WJLZC.js → chunk-KGBKIJPF.js} +3 -3
  71. package/dist/{chunk-MQQ44IGX.js → chunk-KKAJC3Z2.js} +3 -3
  72. package/dist/{chunk-3NK6YTA5.js → chunk-KUWJJD6O.js} +42 -8
  73. package/dist/{chunk-2GIX4HAT.js → chunk-L26TVIB6.js} +2 -2
  74. package/dist/{chunk-KLN6HPYM.js → chunk-L3IACZ72.js} +1 -1
  75. package/dist/{chunk-C6AXM3M7.js → chunk-LQP6XGFU.js} +2 -2
  76. package/dist/{chunk-YBZJHDSE.js → chunk-MAJWADF7.js} +2 -2
  77. package/dist/{chunk-7GG3FEK2.js → chunk-MCWCRZM4.js} +4 -4
  78. package/dist/{chunk-JCW3ZRES.js → chunk-MQBMXAPU.js} +1 -1
  79. package/dist/{chunk-CREPPDHX.js → chunk-NDTIDWBE.js} +1 -1
  80. package/dist/{chunk-5EQJOUWM.js → chunk-NHAYKVXG.js} +2 -2
  81. package/dist/{chunk-FXLUSECC.js → chunk-NKQVOAWN.js} +1 -1
  82. package/dist/{chunk-ZYISLRS6.js → chunk-OKT2J4ZB.js} +114 -37
  83. package/dist/{chunk-V5HWHJ4P.js → chunk-OSNMIPHV.js} +1 -1
  84. package/dist/{chunk-ZFJPOQSY.js → chunk-OZFSKR2W.js} +69 -30
  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-LMNFIJ6M.js → chunk-PN3AWRMX.js} +15 -15
  88. package/dist/{chunk-ZMNQ2YJ6.js → chunk-PNZF7HIU.js} +3 -3
  89. package/dist/{chunk-R5T4LJSK.js → chunk-PZNAQBHQ.js} +2 -2
  90. package/dist/{chunk-RH4GKU52.js → chunk-QTXAWC5J.js} +18 -3
  91. package/dist/{chunk-2I35VGHX.js → chunk-R3QHLKJG.js} +2 -2
  92. package/dist/{chunk-OGJUSGF7.js → chunk-R6EEBWM3.js} +1 -1
  93. package/dist/{chunk-V66YKIW6.js → chunk-RYJXSXCV.js} +5 -5
  94. package/dist/{chunk-CHDQ3HIR.js → chunk-S7DFMJR5.js} +5 -9
  95. package/dist/{chunk-V2R7RWVY.js → chunk-STJNO6SL.js} +1 -1
  96. package/dist/{chunk-USYY3L7G.js → chunk-T3FQPTOA.js} +2 -2
  97. package/dist/{chunk-5IGBMS2U.js → chunk-T3HMVHDG.js} +1 -1
  98. package/dist/{chunk-IAF6VMPO.js → chunk-TPMZO6S2.js} +1 -1
  99. package/dist/{chunk-P26WOAA3.js → chunk-TUEBRYPZ.js} +1 -1
  100. package/dist/{chunk-HOIDGDU5.js → chunk-TVODT2UR.js} +1 -1
  101. package/dist/{chunk-Z25I7DRV.js → chunk-V5DH3OAC.js} +10 -5
  102. package/dist/{chunk-ZVXIZ2JD.js → chunk-VP527YC5.js} +35 -6
  103. package/dist/{chunk-6POQAFEC.js → chunk-W3JMIUHV.js} +1 -1
  104. package/dist/{chunk-6IYCBW4J.js → chunk-WEC625LQ.js} +1 -1
  105. package/dist/{chunk-V7MTIMPB.js → chunk-X6QIWZ33.js} +2 -2
  106. package/dist/{chunk-6GP5IKXE.js → chunk-XSNJ7NT2.js} +1 -1
  107. package/dist/{chunk-LZFB3HRK.js → chunk-XTKTIFHC.js} +5 -10
  108. package/dist/{chunk-QSUGIJWV.js → chunk-YMCS6AB7.js} +4 -9
  109. package/dist/{chunk-FOOH6SCB.js → chunk-YXOCKQZU.js} +2 -2
  110. package/dist/{chunk-2PPB644A.js → chunk-Z4LFLXRR.js} +1 -1
  111. package/dist/{chunk-N3QIXC2B.js → chunk-Z6VZYRVN.js} +2 -2
  112. package/dist/config/index.js +5 -5
  113. package/dist/containers/client.js +6 -6
  114. package/dist/containers/exec.js +6 -6
  115. package/dist/containers/lifecycle.js +36 -36
  116. package/dist/containers/setup.js +8 -8
  117. package/dist/db/agents.js +8 -6
  118. package/dist/db/api_keys.js +5 -5
  119. package/dist/db/audit.js +3 -3
  120. package/dist/db/batch.js +10 -10
  121. package/dist/db/client.js +2 -2
  122. package/dist/db/credentials.js +3 -3
  123. package/dist/db/drizzle.js +4 -4
  124. package/dist/db/environments.js +6 -6
  125. package/dist/db/events.js +5 -5
  126. package/dist/db/files.js +5 -5
  127. package/dist/db/memory.js +5 -5
  128. package/dist/db/migrations.js +1 -1
  129. package/dist/db/proxy.js +5 -5
  130. package/dist/db/schema.js +1 -1
  131. package/dist/db/session-resources.js +5 -5
  132. package/dist/db/sessions.js +8 -7
  133. package/dist/db/sync.js +5 -5
  134. package/dist/db/tenants.js +3 -3
  135. package/dist/db/traces.js +5 -5
  136. package/dist/db/upstream_keys.js +3 -3
  137. package/dist/db/vaults.js +12 -8
  138. package/dist/handlers/agents.js +56 -52
  139. package/dist/handlers/api_keys.js +53 -53
  140. package/dist/handlers/audit.js +53 -53
  141. package/dist/handlers/batch.js +53 -53
  142. package/dist/handlers/credentials.js +53 -53
  143. package/dist/handlers/environments.js +53 -53
  144. package/dist/handlers/events.js +56 -56
  145. package/dist/handlers/files.js +53 -53
  146. package/dist/handlers/index.js +100 -92
  147. package/dist/handlers/license.js +52 -52
  148. package/dist/handlers/memory.js +53 -53
  149. package/dist/handlers/metrics.js +52 -52
  150. package/dist/handlers/models.js +53 -53
  151. package/dist/handlers/openapi.js +3 -3
  152. package/dist/handlers/providers.js +52 -52
  153. package/dist/handlers/resources.js +52 -52
  154. package/dist/handlers/sessions.js +55 -55
  155. package/dist/handlers/settings.js +52 -52
  156. package/dist/handlers/skills-write.js +52 -52
  157. package/dist/handlers/skills.js +53 -53
  158. package/dist/handlers/stream.js +52 -52
  159. package/dist/handlers/tenants.js +53 -53
  160. package/dist/handlers/threads.js +52 -52
  161. package/dist/handlers/traces.js +53 -53
  162. package/dist/handlers/upstream_keys.js +55 -55
  163. package/dist/handlers/vaults.js +56 -52
  164. package/dist/handlers/whoami.js +52 -52
  165. package/dist/http.js +55 -51
  166. package/dist/index.js +57 -57
  167. package/dist/init.js +48 -48
  168. package/dist/lib/model-registry.js +6 -6
  169. package/dist/lib/skills-cache.js +6 -6
  170. package/dist/observability/otlp.js +12 -12
  171. package/dist/observability/redactor.js +8 -8
  172. package/dist/openapi/schemas.js +3 -1
  173. package/dist/openapi/spec.js +2 -2
  174. package/dist/providers/fly.js +5 -5
  175. package/dist/providers/modal.js +5 -5
  176. package/dist/providers/registry.js +1 -1
  177. package/dist/providers/resolve-secrets.js +7 -7
  178. package/dist/providers/sprites.js +7 -7
  179. package/dist/providers/upstream-keys.js +12 -11
  180. package/dist/providers/vercel.js +5 -5
  181. package/dist/proxy/forward.js +6 -6
  182. package/dist/queue/index.js +6 -6
  183. package/dist/sessions/bus.js +10 -10
  184. package/dist/sessions/driver.js +41 -41
  185. package/dist/sessions/grader.js +5 -5
  186. package/dist/sessions/mcp-auth.js +1 -1
  187. package/dist/sessions/secrets.js +8 -8
  188. package/dist/sessions/sweeper.js +37 -37
  189. package/dist/sessions/threads.js +41 -41
  190. package/dist/shutdown.js +38 -38
  191. package/dist/sync/anthropic.js +11 -11
  192. package/dist/sync/container-file-sync.js +6 -6
  193. package/dist/sync/file-sync.js +17 -17
  194. package/package.json +1 -1
  195. /package/dist/{chunk-WPK4ZPMG.js → chunk-UE6DNLSV.js} +0 -0
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  getModels
3
- } from "./chunk-C46UG6GQ.js";
3
+ } from "./chunk-A6VORSKD.js";
4
4
  import {
5
5
  jsonOk,
6
6
  routeWrap
7
- } from "./chunk-RH4GKU52.js";
7
+ } from "./chunk-QTXAWC5J.js";
8
8
 
9
9
  // src/handlers/models.ts
10
10
  function handleListModels(request) {
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  jsonOk,
3
3
  routeWrap
4
- } from "./chunk-RH4GKU52.js";
4
+ } from "./chunk-QTXAWC5J.js";
5
5
  import {
6
6
  resolveContainerProvider
7
- } from "./chunk-WPK4ZPMG.js";
7
+ } from "./chunk-UE6DNLSV.js";
8
8
  import {
9
9
  getConfig
10
- } from "./chunk-V7MTIMPB.js";
10
+ } from "./chunk-X6QIWZ33.js";
11
11
 
12
12
  // src/handlers/providers.ts
13
13
  var LOCAL_PROVIDERS = ["docker", "apple-container", "podman"];
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  getSession
3
- } from "./chunk-3NK6YTA5.js";
3
+ } from "./chunk-KUWJJD6O.js";
4
4
  import {
5
5
  appendEvent,
6
6
  appendEventsBatch,
7
7
  listEvents,
8
8
  rowToManagedEvent
9
- } from "./chunk-TH7WJLZC.js";
9
+ } from "./chunk-KGBKIJPF.js";
10
10
  import {
11
11
  getAgent
12
- } from "./chunk-ZTH5JRZG.js";
12
+ } from "./chunk-BCIFFAGW.js";
13
13
  import {
14
14
  getDb,
15
15
  init_client
16
- } from "./chunk-6POQAFEC.js";
16
+ } from "./chunk-W3JMIUHV.js";
17
17
 
18
18
  // src/sessions/bus.ts
19
19
  import { EventEmitter } from "events";
@@ -5,10 +5,10 @@ import {
5
5
  import {
6
6
  getDrizzle,
7
7
  init_drizzle
8
- } from "./chunk-R5T4LJSK.js";
8
+ } from "./chunk-PZNAQBHQ.js";
9
9
  import {
10
10
  schema_exports
11
- } from "./chunk-ZMJ4EP4C.js";
11
+ } from "./chunk-ILHIHMO3.js";
12
12
 
13
13
  // src/db/proxy.ts
14
14
  init_drizzle();
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  markStopping
3
- } from "./chunk-3FDE3BPB.js";
3
+ } from "./chunk-AB7MPL3H.js";
4
4
  import {
5
5
  closeDb,
6
6
  init_client,
7
7
  syncDb
8
- } from "./chunk-6POQAFEC.js";
8
+ } from "./chunk-W3JMIUHV.js";
9
9
  import {
10
10
  getRuntime
11
11
  } from "./chunk-UYTSKFGK.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  routeWrap
3
- } from "./chunk-RH4GKU52.js";
3
+ } from "./chunk-QTXAWC5J.js";
4
4
  import {
5
5
  ApiError
6
6
  } from "./chunk-EZYKRG4W.js";
@@ -10,7 +10,7 @@ function buildPiArgs(input) {
10
10
  args.push("--session", input.backendSessionId);
11
11
  }
12
12
  if (input.agent.model) {
13
- args.push("--model", input.agent.model);
13
+ args.push("--model", input.agent.model.id);
14
14
  }
15
15
  args.push(input.prompt);
16
16
  return args;
@@ -2,10 +2,10 @@ import {
2
2
  reportUpstreamFailure,
3
3
  reportUpstreamSuccess,
4
4
  resolveAnthropicKey
5
- } from "./chunk-PIJKJNGB.js";
5
+ } from "./chunk-24IDJ7LY.js";
6
6
  import {
7
7
  resolveRemoteSessionId
8
- } from "./chunk-L2RX552S.js";
8
+ } from "./chunk-22OUZJAV.js";
9
9
  import {
10
10
  assertResourceTenant
11
11
  } from "./chunk-23UKWXJH.js";
@@ -20,45 +20,46 @@ import {
20
20
  listMemoryStores,
21
21
  searchMemories,
22
22
  updateMemory
23
- } from "./chunk-SUGSHXND.js";
23
+ } from "./chunk-IEZFRNLC.js";
24
24
  import {
25
25
  jsonOk,
26
+ paginatedOk,
26
27
  routeWrap
27
- } from "./chunk-RH4GKU52.js";
28
+ } from "./chunk-QTXAWC5J.js";
28
29
  import {
29
30
  forwardToAnthropic
30
- } from "./chunk-JCW3ZRES.js";
31
+ } from "./chunk-MQBMXAPU.js";
31
32
  import {
32
33
  runTurn,
33
34
  writePermissionResponse
34
- } from "./chunk-DAVYI5H4.js";
35
+ } from "./chunk-JLUCJMAQ.js";
35
36
  import {
36
37
  enqueueTurn
37
- } from "./chunk-2PPB644A.js";
38
+ } from "./chunk-Z4LFLXRR.js";
38
39
  import {
39
40
  getProxiedTenantId,
40
41
  isProxied
41
- } from "./chunk-E7DD7F7J.js";
42
+ } from "./chunk-5U5LRAFJ.js";
42
43
  import {
43
44
  getActor
44
45
  } from "./chunk-LAWTTG2E.js";
45
46
  import {
46
47
  appendEvent
47
- } from "./chunk-MHBLVGRF.js";
48
+ } from "./chunk-5MERXOLJ.js";
48
49
  import {
49
50
  bumpSessionStats,
50
51
  getSession,
51
52
  getSessionRow,
52
53
  setOutcomeCriteria,
53
54
  updateSessionMutable
54
- } from "./chunk-3NK6YTA5.js";
55
+ } from "./chunk-KUWJJD6O.js";
55
56
  import {
56
57
  listEvents,
57
58
  rowToManagedEvent
58
- } from "./chunk-TH7WJLZC.js";
59
+ } from "./chunk-KGBKIJPF.js";
59
60
  import {
60
61
  getAgent
61
- } from "./chunk-ZTH5JRZG.js";
62
+ } from "./chunk-BCIFFAGW.js";
62
63
  import {
63
64
  init_clock,
64
65
  nowMs
@@ -66,7 +67,7 @@ import {
66
67
  import {
67
68
  getDb,
68
69
  init_client
69
- } from "./chunk-6POQAFEC.js";
70
+ } from "./chunk-W3JMIUHV.js";
70
71
  import {
71
72
  badRequest,
72
73
  notFound
@@ -634,12 +635,7 @@ function handleListEvents(request, sessionId) {
634
635
  const afterSeq = Number(url.searchParams.get("after_seq") ?? url.searchParams.get("page") ?? "0");
635
636
  const rows = listEvents(sessionId, { limit, order, afterSeq });
636
637
  const data = rows.map(rowToManagedEvent);
637
- return jsonOk({
638
- data,
639
- has_more: rows.length === limit,
640
- first_id: data.length > 0 ? data[0].id : null,
641
- last_id: data.length > 0 ? data[data.length - 1].id : null
642
- });
638
+ return paginatedOk(data, limit);
643
639
  });
644
640
  }
645
641
 
@@ -2,19 +2,19 @@ import {
2
2
  getSyncRow,
3
3
  getSyncedRemoteId,
4
4
  upsertSync
5
- } from "./chunk-L2RX552S.js";
5
+ } from "./chunk-22OUZJAV.js";
6
6
  import {
7
7
  injectMcpAuthHeaders
8
- } from "./chunk-SV2B3P6B.js";
8
+ } from "./chunk-DBFPJSOY.js";
9
9
  import {
10
10
  listEntries
11
- } from "./chunk-ZVXIZ2JD.js";
11
+ } from "./chunk-VP527YC5.js";
12
12
  import {
13
13
  getEnvironment
14
- } from "./chunk-X6IQ57SC.js";
14
+ } from "./chunk-H6OT5GUL.js";
15
15
  import {
16
16
  getAgent
17
- } from "./chunk-ZTH5JRZG.js";
17
+ } from "./chunk-BCIFFAGW.js";
18
18
 
19
19
  // src/sync/anthropic.ts
20
20
  import { createHash } from "crypto";
@@ -47,10 +47,7 @@ async function syncAgent(agentId, vaultEntries, apiKey) {
47
47
  const agent = getAgent(agentId);
48
48
  if (!agent) throw new Error(`Agent ${agentId} not found`);
49
49
  const agentWithAuth = injectMcpAuthHeaders(agent, vaultEntries);
50
- const mcpArray = agentWithAuth.mcp_servers ? Object.entries(agentWithAuth.mcp_servers).map(([name, config]) => ({
51
- name,
52
- ...config
53
- })) : [];
50
+ const mcpArray = agentWithAuth.mcp_servers ?? [];
54
51
  const tools = agentWithAuth.tools && agentWithAuth.tools.length > 0 ? agentWithAuth.tools : [{ type: "agent_toolset_20260401" }];
55
52
  const agentConfig = {
56
53
  name: agentWithAuth.name,
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  getConfig,
6
6
  readSetting
7
- } from "./chunk-V7MTIMPB.js";
7
+ } from "./chunk-X6QIWZ33.js";
8
8
  import {
9
9
  __commonJS
10
10
  } from "./chunk-2ESYSVXG.js";
@@ -6,29 +6,29 @@ import {
6
6
  reconcileDockerOrphanSandboxes,
7
7
  reconcileOrphanSandboxes,
8
8
  releaseSession
9
- } from "./chunk-N76ZVITA.js";
9
+ } from "./chunk-JFOHGHW5.js";
10
10
  import {
11
11
  appendEvent,
12
12
  dropEmitter
13
- } from "./chunk-MHBLVGRF.js";
13
+ } from "./chunk-5MERXOLJ.js";
14
14
  import {
15
15
  archiveSession,
16
16
  getSessionRow,
17
17
  listIdleSessions,
18
18
  updateSessionStatus
19
- } from "./chunk-3NK6YTA5.js";
19
+ } from "./chunk-KUWJJD6O.js";
20
20
  import {
21
21
  resolveContainerProvider
22
- } from "./chunk-WPK4ZPMG.js";
22
+ } from "./chunk-UE6DNLSV.js";
23
23
  import {
24
24
  getEnvironment
25
- } from "./chunk-X6IQ57SC.js";
25
+ } from "./chunk-H6OT5GUL.js";
26
26
  import {
27
27
  expireWarm
28
28
  } from "./chunk-G7KUVNDY.js";
29
29
  import {
30
30
  getConfig
31
- } from "./chunk-V7MTIMPB.js";
31
+ } from "./chunk-X6QIWZ33.js";
32
32
  import {
33
33
  init_clock,
34
34
  nowMs
@@ -3,21 +3,21 @@ import {
3
3
  } from "./chunk-23UKWXJH.js";
4
4
  import {
5
5
  recordAudit
6
- } from "./chunk-KLN6HPYM.js";
6
+ } from "./chunk-L3IACZ72.js";
7
7
  import {
8
8
  requireFeature
9
9
  } from "./chunk-2N2KL4KM.js";
10
10
  import {
11
11
  jsonOk,
12
12
  routeWrap
13
- } from "./chunk-RH4GKU52.js";
13
+ } from "./chunk-QTXAWC5J.js";
14
14
  import {
15
15
  archiveTenant,
16
16
  createTenant,
17
17
  getTenant,
18
18
  listTenants,
19
19
  renameTenant
20
- } from "./chunk-AR2TM7CR.js";
20
+ } from "./chunk-I26QP3A3.js";
21
21
  import {
22
22
  badRequest,
23
23
  notFound
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  jsonOk,
3
3
  routeWrap
4
- } from "./chunk-RH4GKU52.js";
4
+ } from "./chunk-QTXAWC5J.js";
5
5
 
6
6
  // src/handlers/whoami.ts
7
7
  function handleWhoami(request) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_TENANT_ID
3
- } from "./chunk-AR2TM7CR.js";
3
+ } from "./chunk-I26QP3A3.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-R5T4LJSK.js";
16
+ } from "./chunk-PZNAQBHQ.js";
17
17
  import {
18
18
  schema_exports
19
- } from "./chunk-ZMJ4EP4C.js";
19
+ } from "./chunk-ILHIHMO3.js";
20
20
 
21
21
  // src/db/agents.ts
22
22
  init_drizzle();
@@ -24,14 +24,24 @@ init_ids();
24
24
  init_clock();
25
25
  import { eq, and, isNull, lt, gt, asc, desc } from "drizzle-orm";
26
26
  function hydrate(row, ver) {
27
+ const modelConfig = ver.model_config_json ? JSON.parse(ver.model_config_json) : {};
28
+ const rawMcp = ver.mcp_servers_json ? JSON.parse(ver.mcp_servers_json) : {};
29
+ const mcpServers = Array.isArray(rawMcp) ? rawMcp : Object.entries(rawMcp).map(([name, cfg]) => ({
30
+ name,
31
+ type: "url",
32
+ ...typeof cfg === "string" ? { url: cfg } : cfg
33
+ }));
27
34
  return {
35
+ type: "agent",
28
36
  id: row.id,
29
37
  version: ver.version,
30
38
  name: row.name,
31
- model: ver.model,
39
+ description: row.description ?? "",
40
+ model: { id: ver.model, ...modelConfig.speed ? { speed: modelConfig.speed } : {} },
32
41
  system: ver.system,
33
42
  tools: JSON.parse(ver.tools_json),
34
- mcp_servers: JSON.parse(ver.mcp_servers_json),
43
+ mcp_servers: mcpServers,
44
+ metadata: row.metadata_json ? JSON.parse(row.metadata_json) : {},
35
45
  engine: ver.backend ?? "claude",
36
46
  webhook_url: ver.webhook_url ?? null,
37
47
  webhook_events: ver.webhook_events_json ? JSON.parse(ver.webhook_events_json) : ["session.status_idle", "session.status_running", "session.error"],
@@ -40,10 +50,11 @@ function hydrate(row, ver) {
40
50
  confirmation_mode: Boolean(ver.confirmation_mode),
41
51
  callable_agents: ver.callable_agents_json ? JSON.parse(ver.callable_agents_json) : [],
42
52
  skills: ver.skills_json ? JSON.parse(ver.skills_json) : [],
43
- model_config: ver.model_config_json ? JSON.parse(ver.model_config_json) : {},
53
+ model_config: modelConfig,
44
54
  fallback_json: row.fallback_json ?? null,
45
55
  created_at: toIso(row.created_at),
46
- updated_at: toIso(row.updated_at)
56
+ updated_at: toIso(row.updated_at),
57
+ archived_at: row.archived_at ? new Date(row.archived_at).toISOString() : null
47
58
  };
48
59
  }
49
60
  function createAgent(input) {
@@ -55,6 +66,8 @@ function createAgent(input) {
55
66
  id,
56
67
  current_version: 1,
57
68
  name: input.name,
69
+ description: input.description ?? null,
70
+ metadata_json: JSON.stringify(input.metadata ?? {}),
58
71
  tenant_id: input.tenant_id ?? DEFAULT_TENANT_ID,
59
72
  created_at: now,
60
73
  updated_at: now
@@ -98,7 +111,10 @@ function updateAgent(id, input) {
98
111
  const db = getDrizzle();
99
112
  const existing = getAgent(id);
100
113
  if (!existing) return null;
101
- const existingVer = db.select({ webhook_secret: schema_exports.agentVersions.webhook_secret }).from(schema_exports.agentVersions).where(
114
+ const existingVer = db.select({
115
+ webhook_secret: schema_exports.agentVersions.webhook_secret,
116
+ mcp_servers_json: schema_exports.agentVersions.mcp_servers_json
117
+ }).from(schema_exports.agentVersions).where(
102
118
  and(
103
119
  eq(schema_exports.agentVersions.agent_id, id),
104
120
  eq(schema_exports.agentVersions.version, existing.version)
@@ -111,10 +127,10 @@ function updateAgent(id, input) {
111
127
  tx.insert(schema_exports.agentVersions).values({
112
128
  agent_id: id,
113
129
  version: newVersion,
114
- model: input.model ?? existing.model,
130
+ model: input.model ?? existing.model.id,
115
131
  system: input.system ?? existing.system,
116
132
  tools_json: JSON.stringify(input.tools ?? existing.tools),
117
- mcp_servers_json: JSON.stringify(input.mcp_servers ?? existing.mcp_servers),
133
+ mcp_servers_json: input.mcp_servers ? JSON.stringify(input.mcp_servers) : existingVer?.mcp_servers_json ?? "{}",
118
134
  backend: existing.engine,
119
135
  webhook_url: input.webhook_url !== void 0 ? input.webhook_url : existing.webhook_url,
120
136
  webhook_events_json: JSON.stringify(input.webhook_events ?? existing.webhook_events),
@@ -129,6 +145,8 @@ function updateAgent(id, input) {
129
145
  tx.update(schema_exports.agents).set({
130
146
  current_version: newVersion,
131
147
  name: input.name ?? existing.name,
148
+ description: input.description !== void 0 ? input.description ?? null : existing.description || null,
149
+ metadata_json: input.metadata !== void 0 ? JSON.stringify(input.metadata) : JSON.stringify(existing.metadata),
132
150
  updated_at: now
133
151
  }).where(eq(schema_exports.agents.id, id)).run();
134
152
  });
@@ -139,6 +157,18 @@ function archiveAgent(id) {
139
157
  const res = db.update(schema_exports.agents).set({ archived_at: nowMs() }).where(and(eq(schema_exports.agents.id, id), isNull(schema_exports.agents.archived_at))).run();
140
158
  return res.changes > 0;
141
159
  }
160
+ function listAgentVersions(agentId, opts) {
161
+ const db = getDrizzle();
162
+ const limit = Math.min(Math.max(opts.limit ?? 20, 1), 100);
163
+ const row = db.select().from(schema_exports.agents).where(eq(schema_exports.agents.id, agentId)).get();
164
+ if (!row) return [];
165
+ const conditions = [eq(schema_exports.agentVersions.agent_id, agentId)];
166
+ if (opts.cursor) {
167
+ conditions.push(lt(schema_exports.agentVersions.version, opts.cursor));
168
+ }
169
+ const versions = db.select().from(schema_exports.agentVersions).where(and(...conditions)).orderBy(desc(schema_exports.agentVersions.version)).limit(limit).all();
170
+ return versions.map((ver) => hydrate(row, ver));
171
+ }
142
172
  function listAgents(opts) {
143
173
  const db = getDrizzle();
144
174
  const limit = Math.min(Math.max(opts.limit ?? 20, 1), 100);
@@ -165,5 +195,6 @@ export {
165
195
  getAgent,
166
196
  updateAgent,
167
197
  archiveAgent,
198
+ listAgentVersions,
168
199
  listAgents
169
200
  };
@@ -78,13 +78,27 @@ var ModelConfigSchema = registry.register(
78
78
  var AgentSchema = registry.register(
79
79
  "Agent",
80
80
  z.object({
81
+ type: z.literal("agent"),
81
82
  id: UlidId,
82
83
  version: z.number().int().positive(),
83
84
  name: z.string(),
84
- model: z.string(),
85
+ description: z.string().openapi({ description: "Human-readable description of the agent." }),
86
+ model: z.object({
87
+ id: z.string(),
88
+ speed: z.enum(["standard", "fast"]).optional()
89
+ }).openapi({ description: "Model configuration. `id` is the canonical model identifier." }),
85
90
  system: z.string().nullable(),
86
91
  tools: z.array(ToolConfigSchema),
87
- mcp_servers: z.record(McpServerConfigSchema),
92
+ mcp_servers: z.array(z.object({
93
+ name: z.string(),
94
+ type: z.string(),
95
+ url: z.string().optional()
96
+ }).catchall(z.unknown())).openapi({
97
+ description: "MCP servers configured for this agent. Each entry has a name, type, and optional url."
98
+ }),
99
+ metadata: z.record(z.string()).openapi({
100
+ description: "Key-value metadata attached to the agent. Values must be strings."
101
+ }),
88
102
  engine: z.enum(["claude", "opencode", "codex", "anthropic", "gemini", "factory", "pi"]).openapi({
89
103
  description: "Which agent harness powers this agent. `claude` drives `claude -p`; `opencode` drives sst/opencode-ai's `opencode run`; `gemini` drives Google's `gemini -p`; `factory` drives Factory's `droid exec`; `pi` drives the pi.dev coding agent (`pi --mode json`). Immutable after agent creation."
90
104
  }),
@@ -94,12 +108,22 @@ var AgentSchema = registry.register(
94
108
  webhook_events: z.array(z.string()).openapi({
95
109
  description: "Event types that trigger webhook delivery. Defaults to status + error events."
96
110
  }),
111
+ webhook_signing_enabled: z.boolean().openapi({
112
+ description: "Whether a webhook shared secret is configured. The secret itself is never returned."
113
+ }),
97
114
  threads_enabled: z.boolean().openapi({
98
115
  description: "Whether this agent can spawn sub-agents via the spawn_agent tool."
99
116
  }),
100
117
  confirmation_mode: z.boolean().openapi({
101
118
  description: "Whether this agent requires tool confirmation via user.tool_confirmation events. When true, claude runs with --permission-mode default and a PermissionRequest hook bridges tool approvals to the MA API."
102
119
  }),
120
+ callable_agents: z.array(z.object({
121
+ type: z.literal("agent"),
122
+ id: z.string(),
123
+ version: z.number().int().optional()
124
+ })).openapi({
125
+ description: "Agents that can be called by this agent via the spawn_agent tool."
126
+ }),
103
127
  skills: z.array(AgentSkillSchema).openapi({
104
128
  description: "Skills injected into the container at session start. For Claude backend, written to .claude/skills/<name>/SKILL.md. For all backends, also written to .agents/skills/<name>/SKILL.md. Non-Claude backends also receive skills prepended to the system prompt."
105
129
  }),
@@ -107,17 +131,30 @@ var AgentSchema = registry.register(
107
131
  description: "Model configuration options. 'fast' speed enables fast mode on Claude (claude engine only)."
108
132
  }),
109
133
  created_at: IsoTimestamp,
110
- updated_at: IsoTimestamp
134
+ updated_at: IsoTimestamp,
135
+ archived_at: IsoTimestamp.nullable()
111
136
  })
112
137
  );
113
138
  var CreateAgentRequestSchema = registry.register(
114
139
  "CreateAgentRequest",
115
140
  z.object({
116
141
  name: z.string().min(1).openapi({ example: "my-agent" }),
117
- model: z.string().min(1).openapi({ example: "claude-sonnet-4-6" }),
142
+ model: z.object({ id: z.string().min(1), speed: z.enum(["standard", "fast"]).optional() }).openapi({ description: "Model configuration. `id` is the canonical model identifier.", example: { id: "claude-sonnet-4-6" } }),
143
+ description: z.string().max(2048).optional().openapi({
144
+ description: "Human-readable description of the agent."
145
+ }),
146
+ metadata: z.record(z.string(), z.string().max(512)).optional().openapi({
147
+ description: "Key-value metadata. Max 16 keys, values max 512 chars."
148
+ }),
118
149
  system: z.string().nullish().openapi({ example: "You are a helpful assistant." }),
119
150
  tools: z.array(ToolConfigSchema).optional(),
120
- mcp_servers: z.record(McpServerConfigSchema).optional(),
151
+ mcp_servers: z.array(z.object({
152
+ name: z.string(),
153
+ type: z.string().optional(),
154
+ url: z.string().optional()
155
+ }).catchall(z.unknown())).optional().openapi({
156
+ description: "MCP servers as an array of objects with name, type, and optional url."
157
+ }),
121
158
  engine: z.enum(["claude", "opencode", "codex", "anthropic", "gemini", "factory", "pi"]).optional().openapi({
122
159
  description: "Agent harness. Defaults to `claude`. Opencode agents must set `model` to a `provider/model` string (e.g. `anthropic/claude-sonnet-4-6`) and must NOT declare `tools` \u2014 opencode manages its tool surface internally. Gemini agents require GEMINI_API_KEY. Factory agents require FACTORY_API_KEY. Pi agents (pi.dev) require at least one of ANTHROPIC_API_KEY, OPENAI_API_KEY, or GEMINI_API_KEY.",
123
160
  example: "claude"
@@ -143,7 +180,7 @@ var CreateAgentRequestSchema = registry.register(
143
180
  }).openapi({
144
181
  example: {
145
182
  name: "my-agent",
146
- model: "claude-sonnet-4-6",
183
+ model: { id: "claude-sonnet-4-6" },
147
184
  system: "You are a helpful assistant.",
148
185
  tools: [{ type: "agent_toolset_20260401" }]
149
186
  }
@@ -152,11 +189,28 @@ var CreateAgentRequestSchema = registry.register(
152
189
  var UpdateAgentRequestSchema = registry.register(
153
190
  "UpdateAgentRequest",
154
191
  z.object({
192
+ version: z.number().int().min(1).openapi({
193
+ description: "Current agent version for optimistic concurrency. Must match the agent's current version."
194
+ }),
155
195
  name: z.string().min(1).optional(),
156
- model: z.string().min(1).optional(),
196
+ model: z.object({ id: z.string().min(1), speed: z.enum(["standard", "fast"]).optional() }).optional().openapi({
197
+ description: "Model configuration. `id` is the canonical model identifier."
198
+ }),
199
+ description: z.string().max(2048).optional().openapi({
200
+ description: "Human-readable description of the agent."
201
+ }),
202
+ metadata: z.record(z.string(), z.string().max(512)).optional().openapi({
203
+ description: "Key-value metadata. Max 16 keys, values max 512 chars."
204
+ }),
157
205
  system: z.string().nullish(),
158
206
  tools: z.array(ToolConfigSchema).optional(),
159
- mcp_servers: z.record(McpServerConfigSchema).optional(),
207
+ mcp_servers: z.array(z.object({
208
+ name: z.string(),
209
+ type: z.string().optional(),
210
+ url: z.string().optional()
211
+ }).catchall(z.unknown())).optional().openapi({
212
+ description: "MCP servers as an array of objects with name, type, and optional url."
213
+ }),
160
214
  skills: z.array(AgentSkillSchema).max(20).optional().openapi({
161
215
  description: "Updated skills list. Replaces the existing skills entirely."
162
216
  }),
@@ -198,6 +252,7 @@ var EnvironmentConfigSchema = registry.register(
198
252
  var EnvironmentSchema = registry.register(
199
253
  "Environment",
200
254
  z.object({
255
+ type: z.literal("environment"),
201
256
  id: UlidId,
202
257
  name: z.string(),
203
258
  description: z.string().nullable().openapi({
@@ -254,7 +309,10 @@ var SessionUsageSchema = z.object({
254
309
  input_tokens: z.number().int().nonnegative(),
255
310
  output_tokens: z.number().int().nonnegative(),
256
311
  cache_read_input_tokens: z.number().int().nonnegative(),
257
- cache_creation_input_tokens: z.number().int().nonnegative(),
312
+ cache_creation: z.object({
313
+ ephemeral_5m_input_tokens: z.number().int().nonnegative(),
314
+ ephemeral_1h_input_tokens: z.number().int().nonnegative()
315
+ }),
258
316
  cost_usd: z.number().nonnegative()
259
317
  });
260
318
  var SessionStatusSchema = registry.register(
@@ -265,7 +323,18 @@ var SessionSchema = registry.register(
265
323
  "Session",
266
324
  z.object({
267
325
  id: UlidId,
268
- agent: z.object({ id: UlidId, version: z.number().int().positive() }),
326
+ agent: z.object({
327
+ type: z.literal("agent"),
328
+ id: UlidId,
329
+ version: z.number().int().positive(),
330
+ name: z.string(),
331
+ description: z.string(),
332
+ model: z.object({ id: z.string(), speed: z.enum(["standard", "fast"]).optional() }),
333
+ system: z.string().nullable(),
334
+ tools: z.array(z.record(z.unknown())),
335
+ mcp_servers: z.array(z.record(z.unknown())),
336
+ skills: z.array(z.record(z.unknown()))
337
+ }),
269
338
  environment_id: UlidId,
270
339
  status: SessionStatusSchema,
271
340
  stop_reason: z.union([
@@ -425,11 +494,17 @@ var ManagedEventSchema = registry.register(
425
494
  var VaultSchema = registry.register(
426
495
  "Vault",
427
496
  z.object({
497
+ type: z.literal("vault"),
428
498
  id: UlidId,
429
- agent_id: UlidId,
499
+ agent_id: UlidId.nullable().openapi({ description: "Owning agent ID. Null for unscoped vaults." }),
430
500
  name: z.string(),
501
+ display_name: z.string().openapi({ description: "Anthropic-compatible alias for `name`." }),
502
+ metadata: z.record(z.string()).openapi({
503
+ description: "Key-value metadata attached to the vault. Values must be strings."
504
+ }),
431
505
  created_at: IsoTimestamp,
432
- updated_at: IsoTimestamp
506
+ updated_at: IsoTimestamp,
507
+ archived_at: IsoTimestamp.nullable()
433
508
  })
434
509
  );
435
510
  var VaultEntrySchema = registry.register(
@@ -442,10 +517,21 @@ var VaultEntrySchema = registry.register(
442
517
  var CreateVaultRequestSchema = registry.register(
443
518
  "CreateVaultRequest",
444
519
  z.object({
445
- agent_id: UlidId.openapi({ example: "agent_01ABCDEFG..." }),
520
+ agent_id: UlidId.optional().openapi({ example: "agent_01ABCDEFG...", description: "Owning agent ID. Optional for unscoped vaults." }),
446
521
  name: z.string().min(1).openapi({ example: "my-vault" })
447
522
  })
448
523
  );
524
+ var UpdateVaultRequestSchema = registry.register(
525
+ "UpdateVaultRequest",
526
+ z.object({
527
+ display_name: z.string().min(1).max(255).optional().openapi({
528
+ description: "Update the vault display name."
529
+ }),
530
+ metadata: z.record(z.string().max(512)).optional().openapi({
531
+ description: "Replaces the metadata entirely. Max 16 key-value pairs."
532
+ })
533
+ })
534
+ );
449
535
  var SetVaultEntryRequestSchema = registry.register(
450
536
  "SetVaultEntryRequest",
451
537
  z.object({
@@ -555,9 +641,7 @@ var FileListResponseSchema = registry.register(
555
641
  "FileListResponse",
556
642
  z.object({
557
643
  data: z.array(FileRecordSchema),
558
- has_more: z.boolean().openapi({ description: "Whether there are more results beyond this page." }),
559
- first_id: z.string().nullable().openapi({ description: "ID of the first item in this page." }),
560
- last_id: z.string().nullable().openapi({ description: "ID of the last item in this page." })
644
+ next_page: z.string().nullable().openapi({ description: "Opaque cursor for the next page, or null if no more results." })
561
645
  })
562
646
  );
563
647
  var FileDeletedResponseSchema = registry.register(
@@ -1093,6 +1177,7 @@ export {
1093
1177
  VaultSchema,
1094
1178
  VaultEntrySchema,
1095
1179
  CreateVaultRequestSchema,
1180
+ UpdateVaultRequestSchema,
1096
1181
  SetVaultEntryRequestSchema,
1097
1182
  VaultDeletedResponseSchema,
1098
1183
  VaultEntryDeletedResponseSchema,