@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
@@ -70,6 +70,7 @@ import {
70
70
  UpdateEnvironmentRequestSchema,
71
71
  UpdateMemoryRequestSchema,
72
72
  UpdateSessionRequestSchema,
73
+ UpdateVaultRequestSchema,
73
74
  UpstreamKeyDeletedResponseSchema,
74
75
  UpstreamKeyListResponseSchema,
75
76
  UpstreamKeySchema,
@@ -83,7 +84,7 @@ import {
83
84
  VaultListResponseSchema,
84
85
  VaultSchema,
85
86
  WhoamiResponseSchema
86
- } from "./chunk-OXWELRJL.js";
87
+ } from "./chunk-CBPO2P4I.js";
87
88
  import {
88
89
  registry
89
90
  } from "./chunk-7346CKTF.js";
@@ -212,6 +213,44 @@ registry.registerPath({
212
213
  ...ErrorResponses
213
214
  }
214
215
  });
216
+ registry.registerPath({
217
+ method: "post",
218
+ path: "/v1/agents/{id}/archive",
219
+ tags: ["Agents"],
220
+ summary: "Archive an agent (returns the archived agent)",
221
+ description: "Archives the agent and returns the full agent object with `archived_at` set.",
222
+ security: [{ ApiKey: [] }],
223
+ request: { params: z.object({ id: z.string() }) },
224
+ responses: {
225
+ 200: {
226
+ description: "Agent archived",
227
+ content: { "application/json": { schema: AgentSchema } }
228
+ },
229
+ ...ErrorResponses
230
+ }
231
+ });
232
+ registry.registerPath({
233
+ method: "get",
234
+ path: "/v1/agents/{id}/versions",
235
+ tags: ["Agents"],
236
+ summary: "List agent versions",
237
+ description: "Returns a paginated list of all versions of this agent, ordered by version number descending.",
238
+ security: [{ ApiKey: [] }],
239
+ request: {
240
+ params: z.object({ id: z.string() }),
241
+ query: z.object({
242
+ limit: z.coerce.number().int().min(1).max(100).optional(),
243
+ page: z.string().optional().describe("Cursor for pagination (base64url-encoded version number)")
244
+ })
245
+ },
246
+ responses: {
247
+ 200: {
248
+ description: "A page of agent versions",
249
+ content: { "application/json": { schema: AgentListResponseSchema } }
250
+ },
251
+ ...ErrorResponses
252
+ }
253
+ });
215
254
  registry.registerPath({
216
255
  method: "post",
217
256
  path: "/v1/environments",
@@ -359,7 +398,8 @@ registry.registerPath({
359
398
  agent_id: z.string().optional(),
360
399
  agent_version: z.coerce.number().int().optional(),
361
400
  environment_id: z.string().optional(),
362
- status: SessionStatusSchema.optional(),
401
+ status: SessionStatusSchema.optional().describe("Filter by single status (deprecated, use statuses)"),
402
+ statuses: z.string().optional().describe("Comma-separated or repeated status filter, e.g. statuses=idle,running"),
363
403
  "created_at[gt]": z.string().optional(),
364
404
  "created_at[gte]": z.string().optional(),
365
405
  "created_at[lt]": z.string().optional(),
@@ -754,6 +794,28 @@ registry.registerPath({
754
794
  ...ErrorResponses
755
795
  }
756
796
  });
797
+ registry.registerPath({
798
+ method: "post",
799
+ path: "/v1/vaults/{id}",
800
+ tags: ["Vaults"],
801
+ summary: "Update a vault",
802
+ description: "Updates vault display_name and/or metadata.",
803
+ security: [{ ApiKey: [] }],
804
+ request: {
805
+ params: z.object({ id: z.string() }),
806
+ body: {
807
+ required: true,
808
+ content: { "application/json": { schema: UpdateVaultRequestSchema } }
809
+ }
810
+ },
811
+ responses: {
812
+ 200: {
813
+ description: "Vault updated",
814
+ content: { "application/json": { schema: VaultSchema } }
815
+ },
816
+ ...ErrorResponses
817
+ }
818
+ });
757
819
  registry.registerPath({
758
820
  method: "delete",
759
821
  path: "/v1/vaults/{id}",
@@ -769,6 +831,22 @@ registry.registerPath({
769
831
  ...ErrorResponses
770
832
  }
771
833
  });
834
+ registry.registerPath({
835
+ method: "post",
836
+ path: "/v1/vaults/{id}/archive",
837
+ tags: ["Vaults"],
838
+ summary: "Archive a vault",
839
+ description: "Archives the vault and returns the full vault object with `archived_at` set.",
840
+ security: [{ ApiKey: [] }],
841
+ request: { params: z.object({ id: z.string() }) },
842
+ responses: {
843
+ 200: {
844
+ description: "Vault archived",
845
+ content: { "application/json": { schema: VaultSchema } }
846
+ },
847
+ ...ErrorResponses
848
+ }
849
+ });
772
850
  registry.registerPath({
773
851
  method: "post",
774
852
  path: "/v1/vaults/{id}/credentials",
@@ -11,7 +11,7 @@ function buildGeminiArgs(input) {
11
11
  args.push("--resume", 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
  }
@@ -10,10 +10,10 @@ import {
10
10
  import {
11
11
  getDrizzle,
12
12
  init_drizzle
13
- } from "./chunk-R5T4LJSK.js";
13
+ } from "./chunk-PZNAQBHQ.js";
14
14
  import {
15
15
  schema_exports
16
- } from "./chunk-ZMJ4EP4C.js";
16
+ } from "./chunk-ILHIHMO3.js";
17
17
 
18
18
  // src/db/memory.ts
19
19
  init_drizzle();
@@ -57,6 +57,8 @@ var init_schema = __esm({
57
57
  id: text("id").primaryKey(),
58
58
  current_version: integer("current_version").notNull(),
59
59
  name: text("name").notNull(),
60
+ description: text("description"),
61
+ metadata_json: text("metadata_json").notNull().default("{}"),
60
62
  // v0.4 ALTER TABLE addition:
61
63
  fallback_json: text("fallback_json"),
62
64
  // v0.5 ALTER TABLE addition:
@@ -99,6 +101,7 @@ var init_schema = __esm({
99
101
  // v0.5 ALTER TABLE addition:
100
102
  tenant_id: text("tenant_id"),
101
103
  created_at: integer("created_at").notNull(),
104
+ updated_at: integer("updated_at").notNull(),
102
105
  archived_at: integer("archived_at")
103
106
  });
104
107
  sessions = sqliteTable("sessions", {
@@ -157,12 +160,14 @@ var init_schema = __esm({
157
160
  });
158
161
  vaults = sqliteTable("vaults", {
159
162
  id: text("id").primaryKey(),
160
- agent_id: text("agent_id").notNull(),
163
+ agent_id: text("agent_id"),
161
164
  name: text("name").notNull(),
165
+ metadata_json: text("metadata_json").notNull().default("{}"),
162
166
  // v0.5 ALTER TABLE addition:
163
167
  tenant_id: text("tenant_id"),
164
168
  created_at: integer("created_at").notNull(),
165
- updated_at: integer("updated_at").notNull()
169
+ updated_at: integer("updated_at").notNull(),
170
+ archived_at: integer("archived_at")
166
171
  });
167
172
  vaultEntries = sqliteTable("vault_entries", {
168
173
  vault_id: text("vault_id").notNull(),
@@ -12,15 +12,16 @@ import {
12
12
  listMemories,
13
13
  listMemoryStores,
14
14
  updateMemory
15
- } from "./chunk-SUGSHXND.js";
15
+ } from "./chunk-IEZFRNLC.js";
16
16
  import {
17
17
  jsonOk,
18
+ paginatedOk,
18
19
  routeWrap
19
- } from "./chunk-RH4GKU52.js";
20
+ } from "./chunk-QTXAWC5J.js";
20
21
  import {
21
22
  getDb,
22
23
  init_client
23
- } from "./chunk-6POQAFEC.js";
24
+ } from "./chunk-W3JMIUHV.js";
24
25
  import {
25
26
  badRequest,
26
27
  conflict,
@@ -75,12 +76,7 @@ function handleListMemoryStores(request) {
75
76
  agent_id: agentId,
76
77
  tenantFilter: tenantFilter(auth)
77
78
  });
78
- return jsonOk({
79
- data,
80
- has_more: data.length === requestedLimit,
81
- first_id: data.length > 0 ? data[0].id : null,
82
- last_id: data.length > 0 ? data[data.length - 1].id : null
83
- });
79
+ return paginatedOk(data, requestedLimit);
84
80
  });
85
81
  }
86
82
  function handleGetMemoryStore(request, id) {
@@ -121,12 +117,7 @@ function handleListMemories(request, storeId) {
121
117
  const url = new URL(req.url);
122
118
  const requestedLimit = Number(url.searchParams.get("limit") || "100");
123
119
  const data = listMemories(storeId);
124
- return jsonOk({
125
- data,
126
- has_more: data.length === requestedLimit,
127
- first_id: data.length > 0 ? data[0].id : null,
128
- last_id: data.length > 0 ? data[data.length - 1].id : null
129
- });
120
+ return paginatedOk(data, requestedLimit);
130
121
  });
131
122
  }
132
123
  function handleGetMemory(request, storeId, memId) {
@@ -3,19 +3,19 @@ import {
3
3
  } from "./chunk-4XXQAVKE.js";
4
4
  import {
5
5
  resolveVaultSecrets
6
- } from "./chunk-5IGBMS2U.js";
6
+ } from "./chunk-T3HMVHDG.js";
7
7
  import {
8
8
  appendEvent
9
- } from "./chunk-MHBLVGRF.js";
9
+ } from "./chunk-5MERXOLJ.js";
10
10
  import {
11
11
  getSession,
12
12
  getSessionRow,
13
13
  setSessionSandbox
14
- } from "./chunk-3NK6YTA5.js";
14
+ } from "./chunk-KUWJJD6O.js";
15
15
  import {
16
16
  deleteSprite,
17
17
  listSprites
18
- } from "./chunk-FXLUSECC.js";
18
+ } from "./chunk-NKQVOAWN.js";
19
19
  import {
20
20
  allSessionSandboxes,
21
21
  countInEnv,
@@ -24,12 +24,12 @@ import {
24
24
  } from "./chunk-EFOIR7R3.js";
25
25
  import {
26
26
  resolveContainerProvider
27
- } from "./chunk-WPK4ZPMG.js";
27
+ } from "./chunk-UE6DNLSV.js";
28
28
  import {
29
29
  getEnvironment,
30
30
  getEnvironmentRow,
31
31
  listEnvironments
32
- } from "./chunk-X6IQ57SC.js";
32
+ } from "./chunk-H6OT5GUL.js";
33
33
  import {
34
34
  addWarm,
35
35
  claimWarm,
@@ -40,13 +40,13 @@ import {
40
40
  } from "./chunk-G7KUVNDY.js";
41
41
  import {
42
42
  getAgent
43
- } from "./chunk-ZTH5JRZG.js";
43
+ } from "./chunk-BCIFFAGW.js";
44
44
  import {
45
45
  resolveBackend
46
- } from "./chunk-FDBR634Z.js";
46
+ } from "./chunk-GV6GUSCP.js";
47
47
  import {
48
48
  getConfig
49
- } from "./chunk-V7MTIMPB.js";
49
+ } from "./chunk-X6QIWZ33.js";
50
50
  import {
51
51
  init_clock,
52
52
  nowMs
@@ -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-JFOHGHW5.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-UE6DNLSV.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-GV6GUSCP.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-X6QIWZ33.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, {}, {
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  onAfterCommit
3
- } from "./chunk-MHBLVGRF.js";
3
+ } from "./chunk-5MERXOLJ.js";
4
4
  import {
5
5
  getSessionRow
6
- } from "./chunk-3NK6YTA5.js";
6
+ } from "./chunk-KUWJJD6O.js";
7
7
  import {
8
8
  listEventsByTrace
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
  getConfig
15
- } from "./chunk-V7MTIMPB.js";
15
+ } from "./chunk-X6QIWZ33.js";
16
16
 
17
17
  // src/observability/otlp.ts
18
18
  import { createHash } from "crypto";
@@ -10,14 +10,14 @@ import {
10
10
  import {
11
11
  getDrizzle,
12
12
  init_drizzle
13
- } from "./chunk-R5T4LJSK.js";
13
+ } from "./chunk-PZNAQBHQ.js";
14
14
  import {
15
15
  schema_exports
16
- } from "./chunk-ZMJ4EP4C.js";
16
+ } from "./chunk-ILHIHMO3.js";
17
17
  import {
18
18
  getDb,
19
19
  init_client
20
- } from "./chunk-6POQAFEC.js";
20
+ } from "./chunk-W3JMIUHV.js";
21
21
 
22
22
  // src/db/events.ts
23
23
  init_client();
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  buildOpencodeArgs
3
- } from "./chunk-3IV56JJW.js";
3
+ } from "./chunk-P56WU3UT.js";
4
4
  import {
5
5
  buildOpencodeAuthEnv,
6
6
  validateOpencodeRuntime
7
- } from "./chunk-OGJUSGF7.js";
7
+ } from "./chunk-R6EEBWM3.js";
8
8
  import {
9
9
  buildOpencodeConfigEnv
10
- } from "./chunk-Z25I7DRV.js";
10
+ } from "./chunk-V5DH3OAC.js";
11
11
  import {
12
12
  prepareOpencodeOnSandbox
13
13
  } from "./chunk-P7P2NWZD.js";
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  init_session_resources,
3
3
  session_resources_exports
4
- } from "./chunk-5EKQBD2H.js";
4
+ } from "./chunk-FCUXFLNK.js";
5
+ import {
6
+ getAgent
7
+ } from "./chunk-BCIFFAGW.js";
5
8
  import {
6
9
  DEFAULT_TENANT_ID
7
- } from "./chunk-AR2TM7CR.js";
10
+ } from "./chunk-I26QP3A3.js";
8
11
  import {
9
12
  init_ids,
10
13
  newId
@@ -17,19 +20,19 @@ import {
17
20
  import {
18
21
  getDrizzle,
19
22
  init_drizzle
20
- } from "./chunk-R5T4LJSK.js";
23
+ } from "./chunk-PZNAQBHQ.js";
21
24
  import {
22
25
  schema_exports
23
- } from "./chunk-ZMJ4EP4C.js";
26
+ } from "./chunk-ILHIHMO3.js";
24
27
  import {
25
28
  __toCommonJS
26
29
  } from "./chunk-2ESYSVXG.js";
27
30
 
28
31
  // src/db/sessions.ts
29
32
  init_drizzle();
33
+ import { eq, and, isNull, lt, gt, gte, lte, inArray, sql } from "drizzle-orm";
30
34
  init_ids();
31
35
  init_clock();
32
- import { eq, and, isNull, lt, gt, gte, lte, sql } from "drizzle-orm";
33
36
  function hydrateSession(row) {
34
37
  let resources;
35
38
  try {
@@ -60,10 +63,34 @@ function hydrateSession(row) {
60
63
  } catch {
61
64
  resources = row.resources_json ? JSON.parse(row.resources_json) : [];
62
65
  }
66
+ const agentObj = getAgent(row.agent_id, row.agent_version);
67
+ const agentEmbed = agentObj ? {
68
+ type: "agent",
69
+ id: agentObj.id,
70
+ version: agentObj.version,
71
+ name: agentObj.name,
72
+ description: agentObj.description,
73
+ model: agentObj.model,
74
+ system: agentObj.system,
75
+ tools: agentObj.tools,
76
+ mcp_servers: agentObj.mcp_servers,
77
+ skills: agentObj.skills
78
+ } : {
79
+ type: "agent",
80
+ id: row.agent_id,
81
+ version: row.agent_version,
82
+ name: "",
83
+ description: "",
84
+ model: { id: "" },
85
+ system: null,
86
+ tools: [],
87
+ mcp_servers: [],
88
+ skills: []
89
+ };
63
90
  return {
64
91
  id: row.id,
65
92
  type: "session",
66
- agent: { type: "agent", id: row.agent_id, version: row.agent_version },
93
+ agent: agentEmbed,
67
94
  environment_id: row.environment_id,
68
95
  status: row.status,
69
96
  stop_reason: row.stop_reason,
@@ -87,7 +114,10 @@ function hydrateSession(row) {
87
114
  input_tokens: row.usage_input_tokens,
88
115
  output_tokens: row.usage_output_tokens,
89
116
  cache_read_input_tokens: row.usage_cache_read_input_tokens,
90
- cache_creation_input_tokens: row.usage_cache_creation_input_tokens,
117
+ cache_creation: {
118
+ ephemeral_5m_input_tokens: row.usage_cache_creation_input_tokens,
119
+ ephemeral_1h_input_tokens: 0
120
+ },
91
121
  cost_usd: row.usage_cost_usd
92
122
  },
93
123
  created_at: toIso(row.created_at),
@@ -209,7 +239,11 @@ function listSessions(opts) {
209
239
  if (opts.agent_version != null) conditions.push(eq(schema_exports.sessions.agent_version, opts.agent_version));
210
240
  if (opts.environmentId) conditions.push(eq(schema_exports.sessions.environment_id, opts.environmentId));
211
241
  if (opts.parent_session_id) conditions.push(eq(schema_exports.sessions.parent_session_id, opts.parent_session_id));
212
- if (opts.status) conditions.push(eq(schema_exports.sessions.status, opts.status));
242
+ if (opts.statuses?.length) {
243
+ conditions.push(inArray(schema_exports.sessions.status, opts.statuses));
244
+ } else if (opts.status) {
245
+ conditions.push(eq(schema_exports.sessions.status, opts.status));
246
+ }
213
247
  if (!includeArchived) conditions.push(isNull(schema_exports.sessions.archived_at));
214
248
  if (opts.createdGt != null) conditions.push(gt(schema_exports.sessions.created_at, opts.createdGt));
215
249
  if (opts.createdGte != null) conditions.push(gte(schema_exports.sessions.created_at, opts.createdGte));
@@ -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-NDTIDWBE.js";
17
17
  import {
18
18
  wrapPromptWithSystem
19
19
  } from "./chunk-FVBDEOTZ.js";
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  getDb,
16
16
  init_client
17
- } from "./chunk-6POQAFEC.js";
17
+ } from "./chunk-W3JMIUHV.js";
18
18
 
19
19
  // src/db/audit.ts
20
20
  init_client();
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  resolveContainerProvider
3
- } from "./chunk-WPK4ZPMG.js";
3
+ } from "./chunk-UE6DNLSV.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
10
  } from "./chunk-IU457W7Q.js";
@@ -4,11 +4,11 @@ import {
4
4
  getSources,
5
5
  getStats,
6
6
  searchSkills
7
- } from "./chunk-V5HWHJ4P.js";
7
+ } from "./chunk-OSNMIPHV.js";
8
8
  import {
9
9
  jsonOk,
10
10
  routeWrap
11
- } from "./chunk-RH4GKU52.js";
11
+ } from "./chunk-QTXAWC5J.js";
12
12
 
13
13
  // src/handlers/skills.ts
14
14
  async function handleGetSkillsCatalog(request) {