@agentstep/agent-sdk 0.5.1 → 0.5.3

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 (186) hide show
  1. package/dist/auth/middleware.js +8 -8
  2. package/dist/backends/claude/args.js +7 -7
  3. package/dist/backends/claude/index.js +11 -11
  4. package/dist/backends/codex/auth.js +6 -6
  5. package/dist/backends/codex/index.js +11 -11
  6. package/dist/backends/factory/auth.js +6 -6
  7. package/dist/backends/factory/index.js +13 -13
  8. package/dist/backends/gemini/auth.js +6 -6
  9. package/dist/backends/gemini/index.js +11 -11
  10. package/dist/backends/opencode/auth.js +6 -6
  11. package/dist/backends/opencode/index.js +15 -15
  12. package/dist/backends/pi/auth.js +6 -6
  13. package/dist/backends/pi/index.js +13 -13
  14. package/dist/backends/registry.js +30 -30
  15. package/dist/backends/shared/wrap-prompt.js +1 -1
  16. package/dist/{chunk-4LHJJXH3.js → chunk-23CUQSLR.js} +2 -2
  17. package/dist/{chunk-57LAR6EM.js → chunk-2FKWZKV2.js} +4 -4
  18. package/dist/chunk-2YPJLPTR.js +166 -0
  19. package/dist/{chunk-FYBHPBWY.js → chunk-335F7KSU.js} +2 -2
  20. package/dist/chunk-3LUY2POB.js +50 -0
  21. package/dist/{chunk-HMOSAXVZ.js → chunk-4A4F4L4H.js} +2 -2
  22. package/dist/{chunk-JWHSUEDE.js → chunk-5NCA624D.js} +23 -7
  23. package/dist/{chunk-7SY65LWY.js → chunk-62CZZBEE.js} +4 -4
  24. package/dist/{chunk-GD3WXIHX.js → chunk-65XQ72BF.js} +1 -1
  25. package/dist/{chunk-RT5S5KRX.js → chunk-6DPJVMEC.js} +1 -1
  26. package/dist/{chunk-NBYCX6L4.js → chunk-6KJS42ZL.js} +7 -6
  27. package/dist/{chunk-QJ6QQO6D.js → chunk-6KQFP32G.js} +2 -2
  28. package/dist/{chunk-GIUB2OPA.js → chunk-6TJBZXD4.js} +1 -1
  29. package/dist/{chunk-UMVZZQKD.js → chunk-6ZM7XNH3.js} +1 -1
  30. package/dist/{chunk-ZY2U24QP.js → chunk-75XURMV5.js} +51 -12
  31. package/dist/{chunk-H6OT5GUL.js → chunk-7APAOJIZ.js} +3 -3
  32. package/dist/{chunk-HVLYE4S5.js → chunk-7EDLLXFQ.js} +1 -1
  33. package/dist/chunk-7IYL2O7H.js +185 -0
  34. package/dist/{chunk-KGBKIJPF.js → chunk-7JAUY5SG.js} +3 -3
  35. package/dist/{chunk-T7BHW3CP.js → chunk-7JWW4ZQI.js} +70 -24
  36. package/dist/{chunk-YZZHDZ7B.js → chunk-7XIAKW75.js} +1 -1
  37. package/dist/{chunk-USIMPXUH.js → chunk-A2W3USEZ.js} +1 -1
  38. package/dist/{chunk-WU74DV5R.js → chunk-A7AXD5AM.js} +2 -2
  39. package/dist/chunk-ACPP4KN7.js +164 -0
  40. package/dist/{chunk-22OUZJAV.js → chunk-AESA3ARX.js} +3 -3
  41. package/dist/{chunk-37C5BNVV.js → chunk-AIAF5ZZA.js} +1 -1
  42. package/dist/{chunk-YYMUSVUI.js → chunk-ANS2TQYT.js} +3 -3
  43. package/dist/{chunk-T3FQPTOA.js → chunk-BCBDHUFY.js} +2 -2
  44. package/dist/{chunk-COZG53R3.js → chunk-BCBRLP33.js} +2 -2
  45. package/dist/{chunk-MCWCRZM4.js → chunk-BLTCDZ3O.js} +4 -4
  46. package/dist/{chunk-VP527YC5.js → chunk-BYIU4WAQ.js} +3 -3
  47. package/dist/{chunk-R6EXYBCT.js → chunk-C52BVTYC.js} +8 -8
  48. package/dist/{chunk-DMMNAQUM.js → chunk-C5GVKLNS.js} +10 -18
  49. package/dist/{chunk-B5EY2VJC.js → chunk-C7BU4RX6.js} +3 -3
  50. package/dist/{chunk-T3IGOI6Z.js → chunk-DTQ7J35Q.js} +2 -2
  51. package/dist/{chunk-5M47X54D.js → chunk-DZGFZMUE.js} +5 -5
  52. package/dist/{chunk-3NKK4M23.js → chunk-E2OYBE5D.js} +2 -2
  53. package/dist/{chunk-L35CBI7F.js → chunk-E35XHOFL.js} +5 -5
  54. package/dist/{chunk-CE366H6Z.js → chunk-EHMKMOXH.js} +5 -5
  55. package/dist/{chunk-3S4CGFKJ.js → chunk-EQ32JFKT.js} +3 -3
  56. package/dist/{chunk-PZNAQBHQ.js → chunk-FILGQF2G.js} +2 -2
  57. package/dist/{chunk-MZYJFU4K.js → chunk-FSVDF57K.js} +5 -5
  58. package/dist/{chunk-XSNJ7NT2.js → chunk-G4DTLYOD.js} +1 -1
  59. package/dist/{chunk-IEZFRNLC.js → chunk-GBLR2CPP.js} +107 -9
  60. package/dist/{chunk-C35ZTCBP.js → chunk-IAKR572X.js} +8 -8
  61. package/dist/{chunk-W3JMIUHV.js → chunk-KQTTKYZY.js} +1 -1
  62. package/dist/{chunk-LIXSR7BG.js → chunk-LHFEBLOE.js} +7 -7
  63. package/dist/{chunk-BCIFFAGW.js → chunk-M3752GFZ.js} +15 -5
  64. package/dist/{chunk-5U5LRAFJ.js → chunk-MTLM36QD.js} +2 -2
  65. package/dist/{chunk-CKFJN5XK.js → chunk-MV42BTU3.js} +1 -1
  66. package/dist/{chunk-ZWC5V2DB.js → chunk-NJ6KNTZR.js} +17 -17
  67. package/dist/{chunk-5MERXOLJ.js → chunk-NRX5WHHN.js} +4 -4
  68. package/dist/{chunk-2YIMCZJK.js → chunk-NUOCXBFP.js} +68 -20
  69. package/dist/{chunk-T3HMVHDG.js → chunk-O2X4XBU7.js} +1 -1
  70. package/dist/{chunk-2YZOIFVN.js → chunk-P4NU74SP.js} +47 -0
  71. package/dist/{chunk-BJP5BIHE.js → chunk-PGJSOKPH.js} +3 -3
  72. package/dist/{chunk-IMPLRDOV.js → chunk-Q2JYAAJO.js} +9 -9
  73. package/dist/{chunk-56XDLNEW.js → chunk-RJDYM2HR.js} +1 -1
  74. package/dist/{chunk-4MKBT3KA.js → chunk-T6F4TFHD.js} +4 -4
  75. package/dist/{chunk-74E7GKUG.js → chunk-TE6KCRPP.js} +1 -1
  76. package/dist/{chunk-VJWNFMMQ.js → chunk-TF36SWHG.js} +2 -2
  77. package/dist/{chunk-KUWJJD6O.js → chunk-TSR33JMZ.js} +14 -5
  78. package/dist/{chunk-L3IACZ72.js → chunk-TWH4UH6G.js} +1 -1
  79. package/dist/{chunk-445EL6J5.js → chunk-UAEVL47I.js} +1 -1
  80. package/dist/{chunk-6RFQCFL2.js → chunk-UALRSWXY.js} +44 -14
  81. package/dist/{chunk-GQYSSSVA.js → chunk-UGH5JDXX.js} +2 -2
  82. package/dist/{chunk-I26QP3A3.js → chunk-UQZFFG7U.js} +1 -1
  83. package/dist/{chunk-Q4XF3OBK.js → chunk-UYP3VGYB.js} +8 -8
  84. package/dist/{chunk-ILHIHMO3.js → chunk-VC5DELR4.js} +37 -2
  85. package/dist/{chunk-O56RNR7B.js → chunk-VMLXV2H6.js} +1 -1
  86. package/dist/{chunk-FCUXFLNK.js → chunk-VY6IWBSK.js} +17 -4
  87. package/dist/{chunk-NL4UNA53.js → chunk-VYY4RHIF.js} +2 -2
  88. package/dist/{chunk-NRXTWATQ.js → chunk-WFRHLTKI.js} +3 -3
  89. package/dist/{chunk-UMRDMOB6.js → chunk-WRLCJNQF.js} +1 -1
  90. package/dist/{chunk-DRNZ24RF.js → chunk-WXMEJVLS.js} +4 -4
  91. package/dist/{chunk-63AKPSCV.js → chunk-X4ARJS6I.js} +10 -10
  92. package/dist/{chunk-MXMXJYN4.js → chunk-XXGVNVPI.js} +5 -5
  93. package/dist/{chunk-A46RUKGA.js → chunk-Y4MI27HU.js} +1 -1
  94. package/dist/{chunk-TG3S4RVJ.js → chunk-Y7NMJ662.js} +2 -2
  95. package/dist/{chunk-FVBDEOTZ.js → chunk-YE2RMJY7.js} +18 -4
  96. package/dist/{chunk-EDUTIJAU.js → chunk-YIY47OVD.js} +6 -6
  97. package/dist/{chunk-HZZ6ZLKP.js → chunk-YL6IQUJC.js} +4 -4
  98. package/dist/{chunk-WDACZSRU.js → chunk-Z6OPLBPQ.js} +1 -1
  99. package/dist/{chunk-UQ3LKJPM.js → chunk-ZG3PHDZJ.js} +3 -3
  100. package/dist/{chunk-2YFS435Z.js → chunk-ZGI6YG2G.js} +42 -4
  101. package/dist/config/index.js +5 -5
  102. package/dist/containers/client.js +6 -6
  103. package/dist/containers/exec.js +6 -6
  104. package/dist/containers/lifecycle.js +44 -42
  105. package/dist/containers/setup.js +8 -8
  106. package/dist/db/agents.js +6 -6
  107. package/dist/db/api_keys.js +5 -5
  108. package/dist/db/audit.js +3 -3
  109. package/dist/db/batch.js +10 -10
  110. package/dist/db/client.js +2 -2
  111. package/dist/db/credentials.js +3 -3
  112. package/dist/db/drizzle.js +4 -4
  113. package/dist/db/environments.js +6 -6
  114. package/dist/db/events.js +5 -5
  115. package/dist/db/files.js +5 -5
  116. package/dist/db/memory.js +13 -5
  117. package/dist/db/migrations.js +1 -1
  118. package/dist/db/proxy.js +5 -5
  119. package/dist/db/schema.js +5 -1
  120. package/dist/db/session-resources.js +5 -5
  121. package/dist/db/sessions.js +8 -8
  122. package/dist/db/sync.js +5 -5
  123. package/dist/db/tenants.js +3 -3
  124. package/dist/db/threads.js +27 -0
  125. package/dist/db/traces.js +5 -5
  126. package/dist/db/upstream_keys.js +3 -3
  127. package/dist/db/vaults.js +6 -6
  128. package/dist/dreaming/prompts.js +9 -0
  129. package/dist/dreaming/review.js +22 -0
  130. package/dist/handlers/agents.js +58 -58
  131. package/dist/handlers/api_keys.js +59 -59
  132. package/dist/handlers/audit.js +59 -59
  133. package/dist/handlers/batch.js +59 -59
  134. package/dist/handlers/credentials.js +59 -59
  135. package/dist/handlers/environments.js +59 -59
  136. package/dist/handlers/events.js +62 -62
  137. package/dist/handlers/files.js +59 -59
  138. package/dist/handlers/index.js +158 -143
  139. package/dist/handlers/license.js +58 -58
  140. package/dist/handlers/memory.js +65 -59
  141. package/dist/handlers/metrics.js +58 -58
  142. package/dist/handlers/models.js +59 -59
  143. package/dist/handlers/providers.js +58 -58
  144. package/dist/handlers/resources.js +58 -58
  145. package/dist/handlers/sessions.js +62 -61
  146. package/dist/handlers/settings.js +58 -58
  147. package/dist/handlers/skills-write.js +58 -58
  148. package/dist/handlers/skills.js +59 -59
  149. package/dist/handlers/stream.js +58 -58
  150. package/dist/handlers/tenants.js +59 -59
  151. package/dist/handlers/threads.js +69 -60
  152. package/dist/handlers/traces.js +59 -59
  153. package/dist/handlers/upstream_keys.js +61 -61
  154. package/dist/handlers/vaults.js +58 -58
  155. package/dist/handlers/whoami.js +58 -58
  156. package/dist/http.js +57 -57
  157. package/dist/index.js +71 -66
  158. package/dist/init.js +54 -54
  159. package/dist/lib/model-registry.js +6 -6
  160. package/dist/lib/skills-cache.js +6 -6
  161. package/dist/observability/otlp.js +12 -12
  162. package/dist/observability/redactor.js +8 -8
  163. package/dist/providers/fly.js +5 -5
  164. package/dist/providers/modal.js +5 -5
  165. package/dist/providers/registry.js +1 -1
  166. package/dist/providers/resolve-secrets.js +7 -7
  167. package/dist/providers/sprites.js +7 -7
  168. package/dist/providers/upstream-keys.js +12 -12
  169. package/dist/providers/vercel.js +6 -6
  170. package/dist/proxy/forward.js +6 -6
  171. package/dist/queue/index.js +6 -6
  172. package/dist/sessions/bus.js +10 -10
  173. package/dist/sessions/driver.js +47 -47
  174. package/dist/sessions/grader.js +5 -5
  175. package/dist/sessions/secrets.js +8 -8
  176. package/dist/sessions/sweeper.js +43 -43
  177. package/dist/sessions/threads.js +120 -54
  178. package/dist/shutdown.js +44 -44
  179. package/dist/sync/anthropic.js +10 -10
  180. package/dist/sync/container-file-sync.js +24 -6
  181. package/dist/sync/file-sync.js +17 -17
  182. package/dist/sync/memory-sync.js +79 -0
  183. package/package.json +1 -1
  184. package/dist/chunk-AQB3P5ZP.js +0 -48
  185. package/dist/{chunk-JRQB3SHR.js → chunk-LT5PRO54.js} +0 -0
  186. package/dist/{dist-EY25RQ2S.js → dist-S64ZABZX.js} +3 -3
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  createSession
3
- } from "./chunk-KUWJJD6O.js";
3
+ } from "./chunk-TSR33JMZ.js";
4
4
  import {
5
5
  createEnvironment,
6
6
  deleteEnvironment,
7
7
  getEnvironment
8
- } from "./chunk-H6OT5GUL.js";
8
+ } from "./chunk-7APAOJIZ.js";
9
9
  import {
10
10
  archiveAgent,
11
11
  createAgent,
12
12
  getAgent
13
- } from "./chunk-BCIFFAGW.js";
13
+ } from "./chunk-M3752GFZ.js";
14
14
  import {
15
15
  getDrizzle,
16
16
  init_drizzle
17
- } from "./chunk-PZNAQBHQ.js";
17
+ } from "./chunk-FILGQF2G.js";
18
18
 
19
19
  // src/db/batch.ts
20
20
  init_drizzle();
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-AIBH32FN.js";
5
5
  import {
6
6
  DEFAULT_TENANT_ID
7
- } from "./chunk-I26QP3A3.js";
7
+ } from "./chunk-UQZFFG7U.js";
8
8
  import {
9
9
  init_ids,
10
10
  newId
@@ -17,10 +17,10 @@ import {
17
17
  import {
18
18
  getDrizzle,
19
19
  init_drizzle
20
- } from "./chunk-PZNAQBHQ.js";
20
+ } from "./chunk-FILGQF2G.js";
21
21
  import {
22
22
  schema_exports
23
- } from "./chunk-ILHIHMO3.js";
23
+ } from "./chunk-VC5DELR4.js";
24
24
 
25
25
  // src/db/vaults.ts
26
26
  init_drizzle();
@@ -1,3 +1,10 @@
1
+ import {
2
+ buildFactoryArgs
3
+ } from "./chunk-TPMZO6S2.js";
4
+ import {
5
+ buildFactoryAuthEnv,
6
+ validateFactoryRuntime
7
+ } from "./chunk-7XIAKW75.js";
1
8
  import {
2
9
  prepareFactoryOnSandbox
3
10
  } from "./chunk-YSUPRYX2.js";
@@ -7,16 +14,9 @@ import {
7
14
  import {
8
15
  FACTORY_WRAPPER_PATH
9
16
  } from "./chunk-QQDSHL27.js";
10
- import {
11
- buildFactoryArgs
12
- } from "./chunk-TPMZO6S2.js";
13
- import {
14
- buildFactoryAuthEnv,
15
- validateFactoryRuntime
16
- } from "./chunk-YZZHDZ7B.js";
17
17
  import {
18
18
  wrapPromptWithSystem
19
- } from "./chunk-FVBDEOTZ.js";
19
+ } from "./chunk-YE2RMJY7.js";
20
20
  import {
21
21
  ApiError
22
22
  } from "./chunk-EZYKRG4W.js";
@@ -10,10 +10,10 @@ import {
10
10
  import {
11
11
  getDrizzle,
12
12
  init_drizzle
13
- } from "./chunk-PZNAQBHQ.js";
13
+ } from "./chunk-FILGQF2G.js";
14
14
  import {
15
15
  schema_exports
16
- } from "./chunk-ILHIHMO3.js";
16
+ } from "./chunk-VC5DELR4.js";
17
17
 
18
18
  // src/db/files.ts
19
19
  init_drizzle();
@@ -96,15 +96,11 @@ function listFiles(opts) {
96
96
  WHERE f.scope_id = ${opts.scope_id} AND f2.id IS NULL${cursorClause}
97
97
  ORDER BY f.id DESC LIMIT ${limit + 1}`
98
98
  );
99
- const has_more2 = rows2.length > limit;
100
- if (has_more2) rows2.pop();
99
+ const hasMore2 = rows2.length > limit;
100
+ if (hasMore2) rows2.pop();
101
101
  const records2 = rows2.map(hydrate);
102
- return {
103
- data: records2,
104
- has_more: has_more2,
105
- first_id: records2.length > 0 ? records2[0].id : null,
106
- last_id: records2.length > 0 ? records2[records2.length - 1].id : null
107
- };
102
+ const nextPage2 = hasMore2 && records2.length > 0 ? Buffer.from(records2[records2.length - 1].id).toString("base64url") : null;
103
+ return { data: records2, next_page: nextPage2 };
108
104
  }
109
105
  let cursorCondition;
110
106
  if (opts?.after_id) {
@@ -114,15 +110,11 @@ function listFiles(opts) {
114
110
  }
115
111
  const query = cursorCondition ? db.select().from(schema_exports.files).where(cursorCondition).orderBy(desc(schema_exports.files.id)).limit(limit + 1) : db.select().from(schema_exports.files).orderBy(desc(schema_exports.files.id)).limit(limit + 1);
116
112
  const rows = query.all();
117
- const has_more = rows.length > limit;
118
- if (has_more) rows.pop();
113
+ const hasMore = rows.length > limit;
114
+ if (hasMore) rows.pop();
119
115
  const records = rows.map(hydrate);
120
- return {
121
- data: records,
122
- has_more,
123
- first_id: records.length > 0 ? records[0].id : null,
124
- last_id: records.length > 0 ? records[records.length - 1].id : null
125
- };
116
+ const nextPage = hasMore && records.length > 0 ? Buffer.from(records[records.length - 1].id).toString("base64url") : null;
117
+ return { data: records, next_page: nextPage };
126
118
  }
127
119
  function countFilesForScope(scopeId) {
128
120
  const db = getDrizzle();
@@ -3,21 +3,21 @@ import {
3
3
  } from "./chunk-23UKWXJH.js";
4
4
  import {
5
5
  recordAudit
6
- } from "./chunk-L3IACZ72.js";
6
+ } from "./chunk-TWH4UH6G.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-T3IGOI6Z.js";
13
+ } from "./chunk-DTQ7J35Q.js";
14
14
  import {
15
15
  archiveTenant,
16
16
  createTenant,
17
17
  getTenant,
18
18
  listTenants,
19
19
  renameTenant
20
- } from "./chunk-I26QP3A3.js";
20
+ } from "./chunk-UQZFFG7U.js";
21
21
  import {
22
22
  badRequest,
23
23
  notFound
@@ -4,13 +4,13 @@ import {
4
4
  } from "./chunk-D2XITRN6.js";
5
5
  import {
6
6
  authenticateAndIntercept
7
- } from "./chunk-NRXTWATQ.js";
7
+ } from "./chunk-WFRHLTKI.js";
8
8
  import {
9
9
  checkAndBump
10
10
  } from "./chunk-HVUWXUUI.js";
11
11
  import {
12
12
  ensureInitialized
13
- } from "./chunk-ZWC5V2DB.js";
13
+ } from "./chunk-NJ6KNTZR.js";
14
14
  import {
15
15
  captureException
16
16
  } from "./chunk-3MQ2FWXS.js";
@@ -1,22 +1,22 @@
1
- import {
2
- createGeminiTranslator
3
- } from "./chunk-S3JRZFF5.js";
4
1
  import {
5
2
  buildGeminiArgs
6
3
  } from "./chunk-IBYOMAZ3.js";
7
4
  import {
8
5
  buildGeminiAuthEnv,
9
6
  validateGeminiRuntime
10
- } from "./chunk-WDACZSRU.js";
7
+ } from "./chunk-Z6OPLBPQ.js";
11
8
  import {
12
9
  prepareGeminiOnSandbox
13
10
  } from "./chunk-XG4UIGDH.js";
11
+ import {
12
+ createGeminiTranslator
13
+ } from "./chunk-S3JRZFF5.js";
14
14
  import {
15
15
  GEMINI_WRAPPER_PATH
16
16
  } from "./chunk-3W6KEDQE.js";
17
17
  import {
18
18
  wrapPromptWithSystem
19
- } from "./chunk-FVBDEOTZ.js";
19
+ } from "./chunk-YE2RMJY7.js";
20
20
  import {
21
21
  ApiError
22
22
  } from "./chunk-EZYKRG4W.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  getModels
3
- } from "./chunk-CKFJN5XK.js";
3
+ } from "./chunk-MV42BTU3.js";
4
4
  import {
5
5
  jsonOk,
6
6
  routeWrap
7
- } from "./chunk-T3IGOI6Z.js";
7
+ } from "./chunk-DTQ7J35Q.js";
8
8
 
9
9
  // src/handlers/models.ts
10
10
  function handleListModels(request) {
@@ -1,22 +1,22 @@
1
+ import {
2
+ createCodexTranslator
3
+ } from "./chunk-CULYZ3VA.js";
1
4
  import {
2
5
  buildCodexArgs
3
6
  } from "./chunk-PJYCPDV5.js";
4
7
  import {
5
8
  buildCodexAuthEnv,
6
9
  validateCodexRuntime
7
- } from "./chunk-GIUB2OPA.js";
10
+ } from "./chunk-6TJBZXD4.js";
8
11
  import {
9
12
  prepareCodexOnSandbox
10
13
  } from "./chunk-M2LUXIXU.js";
11
- import {
12
- createCodexTranslator
13
- } from "./chunk-CULYZ3VA.js";
14
14
  import {
15
15
  CODEX_WRAPPER_PATH
16
16
  } from "./chunk-E4FQRMHV.js";
17
17
  import {
18
18
  wrapPromptWithSystem
19
- } from "./chunk-FVBDEOTZ.js";
19
+ } from "./chunk-YE2RMJY7.js";
20
20
  import {
21
21
  ApiError
22
22
  } from "./chunk-EZYKRG4W.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-23UKWXJH.js";
7
7
  import {
8
8
  recordAudit
9
- } from "./chunk-L3IACZ72.js";
9
+ } from "./chunk-TWH4UH6G.js";
10
10
  import {
11
11
  COMMUNITY_LIMITS,
12
12
  hasFeature,
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  jsonOk,
17
17
  routeWrap
18
- } from "./chunk-T3IGOI6Z.js";
18
+ } from "./chunk-DTQ7J35Q.js";
19
19
  import {
20
20
  createApiKey,
21
21
  getApiKeyById,
@@ -23,14 +23,14 @@ import {
23
23
  listApiKeys,
24
24
  revokeApiKey,
25
25
  updateApiKeyPermissions
26
- } from "./chunk-T3FQPTOA.js";
26
+ } from "./chunk-BCBDHUFY.js";
27
27
  import {
28
28
  listSessionsByApiKey
29
- } from "./chunk-KUWJJD6O.js";
29
+ } from "./chunk-TSR33JMZ.js";
30
30
  import {
31
31
  getDb,
32
32
  init_client
33
- } from "./chunk-W3JMIUHV.js";
33
+ } from "./chunk-KQTTKYZY.js";
34
34
  import {
35
35
  badRequest,
36
36
  forbidden,
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  loadVaultForCaller
3
- } from "./chunk-4MKBT3KA.js";
3
+ } from "./chunk-T6F4TFHD.js";
4
4
  import {
5
5
  jsonOk,
6
6
  paginatedOk,
7
7
  routeWrap
8
- } from "./chunk-T3IGOI6Z.js";
8
+ } from "./chunk-DTQ7J35Q.js";
9
9
  import {
10
10
  createCredential,
11
11
  deleteCredential,
12
12
  getCredential,
13
13
  listCredentials,
14
14
  updateCredential
15
- } from "./chunk-HVLYE4S5.js";
15
+ } from "./chunk-7EDLLXFQ.js";
16
16
  import {
17
17
  badRequest,
18
18
  conflict,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  init_schema,
3
3
  schema_exports
4
- } from "./chunk-ILHIHMO3.js";
4
+ } from "./chunk-VC5DELR4.js";
5
5
  import {
6
6
  getDb,
7
7
  init_client
8
- } from "./chunk-W3JMIUHV.js";
8
+ } from "./chunk-KQTTKYZY.js";
9
9
  import {
10
10
  __esm
11
11
  } from "./chunk-2ESYSVXG.js";
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  onAfterCommit
3
- } from "./chunk-5MERXOLJ.js";
3
+ } from "./chunk-NRX5WHHN.js";
4
4
  import {
5
5
  getSessionRow
6
- } from "./chunk-KUWJJD6O.js";
6
+ } from "./chunk-TSR33JMZ.js";
7
7
  import {
8
8
  listEventsByTrace
9
- } from "./chunk-KGBKIJPF.js";
9
+ } from "./chunk-7JAUY5SG.js";
10
10
  import {
11
11
  getAgent
12
- } from "./chunk-BCIFFAGW.js";
12
+ } from "./chunk-M3752GFZ.js";
13
13
  import {
14
14
  getConfig
15
- } from "./chunk-GQYSSSVA.js";
15
+ } from "./chunk-UGH5JDXX.js";
16
16
 
17
17
  // src/observability/otlp.ts
18
18
  import { createHash } from "crypto";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getDrizzle,
3
3
  init_drizzle
4
- } from "./chunk-PZNAQBHQ.js";
4
+ } from "./chunk-FILGQF2G.js";
5
5
 
6
6
  // src/db/traces.ts
7
7
  init_drizzle();
@@ -10,27 +10,43 @@ import {
10
10
  import {
11
11
  getDrizzle,
12
12
  init_drizzle
13
- } from "./chunk-PZNAQBHQ.js";
13
+ } from "./chunk-FILGQF2G.js";
14
14
  import {
15
15
  schema_exports
16
- } from "./chunk-ILHIHMO3.js";
16
+ } from "./chunk-VC5DELR4.js";
17
17
 
18
18
  // src/db/memory.ts
19
19
  init_drizzle();
20
20
  init_ids();
21
21
  init_clock();
22
22
  import { createHash } from "crypto";
23
- import { eq, and, asc, desc, like, or, sql } from "drizzle-orm";
23
+ import { eq, and, asc, desc, like, or, sql, lt } from "drizzle-orm";
24
24
  function hydrateStore(row) {
25
25
  return {
26
26
  id: row.id,
27
27
  name: row.name,
28
28
  description: row.description,
29
29
  agent_id: row.agent_id,
30
+ archived_at: row.archived_at ? toIso(row.archived_at) : null,
30
31
  created_at: toIso(row.created_at),
31
32
  updated_at: toIso(row.updated_at)
32
33
  };
33
34
  }
35
+ function hydrateVersion(row) {
36
+ const v = {
37
+ type: "memory_version",
38
+ id: row.id,
39
+ memory_store_id: row.store_id,
40
+ memory_id: row.memory_id,
41
+ path: row.path,
42
+ operation: row.operation,
43
+ created_at: toIso(row.created_at)
44
+ };
45
+ if (row.content != null) v.content = row.content;
46
+ if (row.content_sha256 != null) v.content_sha256 = row.content_sha256;
47
+ if (row.session_id != null) v.session_id = row.session_id;
48
+ return v;
49
+ }
34
50
  function hydrateMemory(row) {
35
51
  return {
36
52
  id: row.id,
@@ -90,11 +106,13 @@ function deleteMemoryStore(id) {
90
106
  const res = db.delete(schema_exports.memoryStores).where(eq(schema_exports.memoryStores.id, id)).run();
91
107
  return res.changes > 0;
92
108
  }
93
- function createOrUpsertMemory(storeId, path, content) {
109
+ function createOrUpsertMemory(storeId, path, content, sessionId) {
94
110
  const db = getDrizzle();
95
111
  const hash = sha256(content);
96
112
  const now = nowMs();
97
113
  const id = newId("mem");
114
+ const existing = getMemoryByPath(storeId, path);
115
+ const isUpdate = !!existing;
98
116
  db.insert(schema_exports.memories).values({
99
117
  id,
100
118
  store_id: storeId,
@@ -111,7 +129,17 @@ function createOrUpsertMemory(storeId, path, content) {
111
129
  updated_at: now
112
130
  }
113
131
  }).run();
114
- return getMemoryByPath(storeId, path);
132
+ const memory = getMemoryByPath(storeId, path);
133
+ createMemoryVersion({
134
+ storeId,
135
+ memoryId: memory.id,
136
+ operation: isUpdate ? "update" : "create",
137
+ path,
138
+ content,
139
+ contentSha256: hash,
140
+ sessionId
141
+ });
142
+ return memory;
115
143
  }
116
144
  function getMemory(id) {
117
145
  const db = getDrizzle();
@@ -143,7 +171,7 @@ function searchMemories(storeId, query) {
143
171
  ).orderBy(asc(schema_exports.memories.path)).all();
144
172
  return rows.map(hydrateMemory);
145
173
  }
146
- function updateMemory(id, content, preconditionSha256) {
174
+ function updateMemory(id, content, preconditionSha256, sessionId) {
147
175
  const db = getDrizzle();
148
176
  const existing = getMemory(id);
149
177
  if (!existing) return { memory: null, conflict: false };
@@ -153,11 +181,77 @@ function updateMemory(id, content, preconditionSha256) {
153
181
  const hash = sha256(content);
154
182
  const now = nowMs();
155
183
  db.update(schema_exports.memories).set({ content, content_sha256: hash, updated_at: now }).where(eq(schema_exports.memories.id, id)).run();
156
- return { memory: getMemory(id), conflict: false };
184
+ const memory = getMemory(id);
185
+ createMemoryVersion({
186
+ storeId: existing.store_id,
187
+ memoryId: id,
188
+ operation: "update",
189
+ path: existing.path,
190
+ content,
191
+ contentSha256: hash,
192
+ sessionId
193
+ });
194
+ return { memory, conflict: false };
157
195
  }
158
- function deleteMemory(id) {
196
+ function deleteMemory(id, sessionId) {
159
197
  const db = getDrizzle();
198
+ const existing = getMemory(id);
160
199
  const res = db.delete(schema_exports.memories).where(eq(schema_exports.memories.id, id)).run();
200
+ if (res.changes > 0 && existing) {
201
+ createMemoryVersion({
202
+ storeId: existing.store_id,
203
+ memoryId: id,
204
+ operation: "delete",
205
+ path: existing.path,
206
+ sessionId
207
+ });
208
+ }
209
+ return res.changes > 0;
210
+ }
211
+ function createMemoryVersion(opts) {
212
+ const db = getDrizzle();
213
+ const id = newId("memver");
214
+ const now = nowMs();
215
+ db.insert(schema_exports.memoryVersions).values({
216
+ id,
217
+ store_id: opts.storeId,
218
+ memory_id: opts.memoryId,
219
+ operation: opts.operation,
220
+ path: opts.path,
221
+ content: opts.content ?? null,
222
+ content_sha256: opts.contentSha256 ?? null,
223
+ session_id: opts.sessionId ?? null,
224
+ created_at: now
225
+ }).run();
226
+ return id;
227
+ }
228
+ function listMemoryVersions(storeId, opts) {
229
+ const db = getDrizzle();
230
+ const limit = opts?.limit ?? 100;
231
+ const conditions = [eq(schema_exports.memoryVersions.store_id, storeId)];
232
+ if (opts?.memoryId) {
233
+ conditions.push(eq(schema_exports.memoryVersions.memory_id, opts.memoryId));
234
+ }
235
+ if (opts?.cursor) {
236
+ conditions.push(lt(schema_exports.memoryVersions.id, opts.cursor));
237
+ }
238
+ const rows = db.select().from(schema_exports.memoryVersions).where(and(...conditions)).orderBy(desc(schema_exports.memoryVersions.created_at), desc(schema_exports.memoryVersions.id)).limit(limit).all();
239
+ return rows.map(hydrateVersion);
240
+ }
241
+ function getMemoryVersion(storeId, versionId) {
242
+ const db = getDrizzle();
243
+ const row = db.select().from(schema_exports.memoryVersions).where(
244
+ and(
245
+ eq(schema_exports.memoryVersions.store_id, storeId),
246
+ eq(schema_exports.memoryVersions.id, versionId)
247
+ )
248
+ ).get();
249
+ return row ? hydrateVersion(row) : void 0;
250
+ }
251
+ function archiveMemoryStore(id) {
252
+ const db = getDrizzle();
253
+ const now = nowMs();
254
+ const res = db.update(schema_exports.memoryStores).set({ archived_at: now, updated_at: now }).where(eq(schema_exports.memoryStores.id, id)).run();
161
255
  return res.changes > 0;
162
256
  }
163
257
 
@@ -172,5 +266,9 @@ export {
172
266
  listMemories,
173
267
  searchMemories,
174
268
  updateMemory,
175
- deleteMemory
269
+ deleteMemory,
270
+ createMemoryVersion,
271
+ listMemoryVersions,
272
+ getMemoryVersion,
273
+ archiveMemoryStore
176
274
  };
@@ -1,10 +1,3 @@
1
- import {
2
- buildPiArgs
3
- } from "./chunk-6KWJASEO.js";
4
- import {
5
- buildPiAuthEnv,
6
- validatePiRuntime
7
- } from "./chunk-RT5S5KRX.js";
8
1
  import {
9
2
  preparePiOnSandbox
10
3
  } from "./chunk-QYSDP6V5.js";
@@ -14,9 +7,16 @@ import {
14
7
  import {
15
8
  PI_WRAPPER_PATH
16
9
  } from "./chunk-JDBXIJKG.js";
10
+ import {
11
+ buildPiArgs
12
+ } from "./chunk-6KWJASEO.js";
13
+ import {
14
+ buildPiAuthEnv,
15
+ validatePiRuntime
16
+ } from "./chunk-6DPJVMEC.js";
17
17
  import {
18
18
  wrapPromptWithSystem
19
- } from "./chunk-FVBDEOTZ.js";
19
+ } from "./chunk-YE2RMJY7.js";
20
20
  import {
21
21
  ApiError
22
22
  } from "./chunk-EZYKRG4W.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  init_migrations,
3
3
  runMigrations
4
- } from "./chunk-2YZOIFVN.js";
4
+ } from "./chunk-P4NU74SP.js";
5
5
  import {
6
6
  __esm
7
7
  } from "./chunk-2ESYSVXG.js";
@@ -5,25 +5,25 @@ import {
5
5
  } from "./chunk-23UKWXJH.js";
6
6
  import {
7
7
  kickoffEnvironmentSetup
8
- } from "./chunk-QJ6QQO6D.js";
8
+ } from "./chunk-6KQFP32G.js";
9
9
  import {
10
10
  decodeCursor,
11
11
  jsonOk,
12
12
  paginatedOk,
13
13
  routeWrap
14
- } from "./chunk-T3IGOI6Z.js";
14
+ } from "./chunk-DTQ7J35Q.js";
15
15
  import {
16
16
  forwardToAnthropic
17
- } from "./chunk-A46RUKGA.js";
17
+ } from "./chunk-Y4MI27HU.js";
18
18
  import {
19
19
  getProxiedTenantId,
20
20
  isProxied,
21
21
  markProxied,
22
22
  unmarkProxied
23
- } from "./chunk-5U5LRAFJ.js";
23
+ } from "./chunk-MTLM36QD.js";
24
24
  import {
25
25
  resolveContainerProvider
26
- } from "./chunk-JRQB3SHR.js";
26
+ } from "./chunk-LT5PRO54.js";
27
27
  import {
28
28
  archiveEnvironment,
29
29
  createEnvironment,
@@ -32,11 +32,11 @@ import {
32
32
  hasSessionsAttached,
33
33
  listEnvironments,
34
34
  updateEnvironment
35
- } from "./chunk-H6OT5GUL.js";
35
+ } from "./chunk-7APAOJIZ.js";
36
36
  import {
37
37
  getDb,
38
38
  init_client
39
- } from "./chunk-W3JMIUHV.js";
39
+ } from "./chunk-KQTTKYZY.js";
40
40
  import {
41
41
  badRequest,
42
42
  conflict,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_TENANT_ID
3
- } from "./chunk-I26QP3A3.js";
3
+ } from "./chunk-UQZFFG7U.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-PZNAQBHQ.js";
16
+ } from "./chunk-FILGQF2G.js";
17
17
  import {
18
18
  schema_exports
19
- } from "./chunk-ILHIHMO3.js";
19
+ } from "./chunk-VC5DELR4.js";
20
20
 
21
21
  // src/db/agents.ts
22
22
  init_drizzle();
@@ -31,6 +31,13 @@ function hydrate(row, ver) {
31
31
  type: "url",
32
32
  ...typeof cfg === "string" ? { url: cfg } : cfg
33
33
  }));
34
+ const multiagent = ver.multiagent_json ? JSON.parse(ver.multiagent_json) : void 0;
35
+ let threadsEnabled = Boolean(ver.threads_enabled);
36
+ let callableAgents = ver.callable_agents_json ? JSON.parse(ver.callable_agents_json) : [];
37
+ if (multiagent) {
38
+ threadsEnabled = true;
39
+ callableAgents = multiagent.agents.filter((a) => a.type === "agent").map((a) => ({ type: "agent", id: a.id, version: a.version }));
40
+ }
34
41
  return {
35
42
  type: "agent",
36
43
  id: row.id,
@@ -46,9 +53,10 @@ function hydrate(row, ver) {
46
53
  webhook_url: ver.webhook_url ?? null,
47
54
  webhook_events: ver.webhook_events_json ? JSON.parse(ver.webhook_events_json) : ["session.status_idle", "session.status_running", "session.error"],
48
55
  webhook_signing_enabled: ver.webhook_secret != null && ver.webhook_secret.length > 0,
49
- threads_enabled: Boolean(ver.threads_enabled),
56
+ threads_enabled: threadsEnabled,
50
57
  confirmation_mode: Boolean(ver.confirmation_mode),
51
- callable_agents: ver.callable_agents_json ? JSON.parse(ver.callable_agents_json) : [],
58
+ callable_agents: callableAgents,
59
+ multiagent,
52
60
  skills: ver.skills_json ? JSON.parse(ver.skills_json) : [],
53
61
  model_config: modelConfig,
54
62
  fallback_json: row.fallback_json ?? null,
@@ -86,6 +94,7 @@ function createAgent(input) {
86
94
  threads_enabled: input.threads_enabled ? 1 : 0,
87
95
  confirmation_mode: input.confirmation_mode ? 1 : 0,
88
96
  callable_agents_json: input.callable_agents?.length ? JSON.stringify(input.callable_agents) : null,
97
+ multiagent_json: input.multiagent ? JSON.stringify(input.multiagent) : null,
89
98
  skills_json: JSON.stringify(input.skills ?? []),
90
99
  model_config_json: JSON.stringify(input.model_config ?? {}),
91
100
  created_at: now
@@ -138,6 +147,7 @@ function updateAgent(id, input) {
138
147
  threads_enabled: input.threads_enabled !== void 0 ? input.threads_enabled ? 1 : 0 : existing.threads_enabled ? 1 : 0,
139
148
  confirmation_mode: input.confirmation_mode !== void 0 ? input.confirmation_mode ? 1 : 0 : existing.confirmation_mode ? 1 : 0,
140
149
  callable_agents_json: input.callable_agents !== void 0 ? input.callable_agents.length ? JSON.stringify(input.callable_agents) : null : existing.callable_agents.length ? JSON.stringify(existing.callable_agents) : null,
150
+ multiagent_json: input.multiagent !== void 0 ? input.multiagent ? JSON.stringify(input.multiagent) : null : existing.multiagent ? JSON.stringify(existing.multiagent) : null,
141
151
  skills_json: JSON.stringify(input.skills ?? existing.skills),
142
152
  model_config_json: JSON.stringify(input.model_config !== void 0 ? input.model_config : existing.model_config),
143
153
  created_at: now