@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
@@ -5,10 +5,10 @@ import {
5
5
  import {
6
6
  getDrizzle,
7
7
  init_drizzle
8
- } from "./chunk-PZNAQBHQ.js";
8
+ } from "./chunk-FILGQF2G.js";
9
9
  import {
10
10
  schema_exports
11
- } from "./chunk-ILHIHMO3.js";
11
+ } from "./chunk-VC5DELR4.js";
12
12
 
13
13
  // src/db/proxy.ts
14
14
  init_drizzle();
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  getConfig,
6
6
  readSetting
7
- } from "./chunk-GQYSSSVA.js";
7
+ } from "./chunk-UGH5JDXX.js";
8
8
  import {
9
9
  __commonJS
10
10
  } from "./chunk-2ESYSVXG.js";
@@ -1,60 +1,60 @@
1
- import {
2
- runTurn
3
- } from "./chunk-T7BHW3CP.js";
4
1
  import {
5
2
  enqueueTurn
6
- } from "./chunk-37C5BNVV.js";
3
+ } from "./chunk-AIAF5ZZA.js";
4
+ import {
5
+ runTurn
6
+ } from "./chunk-7JWW4ZQI.js";
7
7
  import {
8
8
  installOtlpExporter
9
- } from "./chunk-MZYJFU4K.js";
9
+ } from "./chunk-FSVDF57K.js";
10
10
  import {
11
11
  redactAppendInput
12
- } from "./chunk-VJWNFMMQ.js";
12
+ } from "./chunk-TF36SWHG.js";
13
13
  import {
14
14
  createApiKey,
15
15
  listApiKeys
16
- } from "./chunk-T3FQPTOA.js";
16
+ } from "./chunk-BCBDHUFY.js";
17
17
  import {
18
18
  initSentry
19
19
  } from "./chunk-3MQ2FWXS.js";
20
20
  import {
21
21
  installShutdownHandlers
22
- } from "./chunk-FYBHPBWY.js";
22
+ } from "./chunk-335F7KSU.js";
23
23
  import {
24
24
  runSweep
25
- } from "./chunk-EDUTIJAU.js";
25
+ } from "./chunk-YIY47OVD.js";
26
26
  import {
27
27
  fillWarmPools,
28
28
  reconcileDockerOrphanSandboxes,
29
29
  reconcileOrphanSandboxes
30
- } from "./chunk-ZY2U24QP.js";
30
+ } from "./chunk-75XURMV5.js";
31
31
  import {
32
32
  appendEvent,
33
33
  installPayloadRedactor
34
- } from "./chunk-5MERXOLJ.js";
34
+ } from "./chunk-NRX5WHHN.js";
35
35
  import {
36
36
  setSessionSandbox
37
- } from "./chunk-KUWJJD6O.js";
37
+ } from "./chunk-TSR33JMZ.js";
38
38
  import {
39
39
  readEnvValue,
40
40
  upsertEnvLine
41
41
  } from "./chunk-YPXI7Q2M.js";
42
42
  import {
43
43
  getLastUnprocessedUserMessage
44
- } from "./chunk-KGBKIJPF.js";
44
+ } from "./chunk-7JAUY5SG.js";
45
45
  import {
46
46
  getBySession,
47
47
  register
48
48
  } from "./chunk-EFOIR7R3.js";
49
49
  import {
50
50
  resolveContainerProvider
51
- } from "./chunk-JRQB3SHR.js";
51
+ } from "./chunk-LT5PRO54.js";
52
52
  import {
53
53
  getEnvironment
54
- } from "./chunk-H6OT5GUL.js";
54
+ } from "./chunk-7APAOJIZ.js";
55
55
  import {
56
56
  getConfig
57
- } from "./chunk-GQYSSSVA.js";
57
+ } from "./chunk-UGH5JDXX.js";
58
58
  import {
59
59
  init_clock,
60
60
  nowMs
@@ -62,7 +62,7 @@ import {
62
62
  import {
63
63
  getDb,
64
64
  init_client
65
- } from "./chunk-W3JMIUHV.js";
65
+ } from "./chunk-KQTTKYZY.js";
66
66
  import {
67
67
  getRuntime
68
68
  } from "./chunk-UYTSKFGK.js";
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  getSession
3
- } from "./chunk-KUWJJD6O.js";
3
+ } from "./chunk-TSR33JMZ.js";
4
4
  import {
5
5
  appendEvent,
6
6
  appendEventsBatch,
7
7
  listEvents,
8
8
  rowToManagedEvent
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
  getDb,
15
15
  init_client
16
- } from "./chunk-W3JMIUHV.js";
16
+ } from "./chunk-KQTTKYZY.js";
17
17
 
18
18
  // src/sessions/bus.ts
19
19
  import { EventEmitter } from "events";
@@ -2,10 +2,10 @@ import {
2
2
  reportUpstreamFailure,
3
3
  reportUpstreamSuccess,
4
4
  resolveAnthropicKey
5
- } from "./chunk-HZZ6ZLKP.js";
5
+ } from "./chunk-YL6IQUJC.js";
6
6
  import {
7
7
  resolveRemoteSessionId
8
- } from "./chunk-22OUZJAV.js";
8
+ } from "./chunk-AESA3ARX.js";
9
9
  import {
10
10
  assertResourceTenant
11
11
  } from "./chunk-23UKWXJH.js";
@@ -20,46 +20,46 @@ import {
20
20
  listMemoryStores,
21
21
  searchMemories,
22
22
  updateMemory
23
- } from "./chunk-IEZFRNLC.js";
23
+ } from "./chunk-GBLR2CPP.js";
24
24
  import {
25
25
  jsonOk,
26
26
  paginatedOk,
27
27
  routeWrap
28
- } from "./chunk-T3IGOI6Z.js";
28
+ } from "./chunk-DTQ7J35Q.js";
29
29
  import {
30
30
  forwardToAnthropic
31
- } from "./chunk-A46RUKGA.js";
31
+ } from "./chunk-Y4MI27HU.js";
32
+ import {
33
+ enqueueTurn
34
+ } from "./chunk-AIAF5ZZA.js";
32
35
  import {
33
36
  runTurn,
34
37
  writePermissionResponse
35
- } from "./chunk-T7BHW3CP.js";
36
- import {
37
- enqueueTurn
38
- } from "./chunk-37C5BNVV.js";
38
+ } from "./chunk-7JWW4ZQI.js";
39
39
  import {
40
40
  getProxiedTenantId,
41
41
  isProxied
42
- } from "./chunk-5U5LRAFJ.js";
42
+ } from "./chunk-MTLM36QD.js";
43
43
  import {
44
44
  getActor
45
45
  } from "./chunk-LAWTTG2E.js";
46
46
  import {
47
47
  appendEvent
48
- } from "./chunk-5MERXOLJ.js";
48
+ } from "./chunk-NRX5WHHN.js";
49
49
  import {
50
50
  bumpSessionStats,
51
51
  getSession,
52
52
  getSessionRow,
53
53
  setOutcomeCriteria,
54
54
  updateSessionMutable
55
- } from "./chunk-KUWJJD6O.js";
55
+ } from "./chunk-TSR33JMZ.js";
56
56
  import {
57
57
  listEvents,
58
58
  rowToManagedEvent
59
- } from "./chunk-KGBKIJPF.js";
59
+ } from "./chunk-7JAUY5SG.js";
60
60
  import {
61
61
  getAgent
62
- } from "./chunk-BCIFFAGW.js";
62
+ } from "./chunk-M3752GFZ.js";
63
63
  import {
64
64
  init_clock,
65
65
  nowMs
@@ -67,7 +67,7 @@ import {
67
67
  import {
68
68
  getDb,
69
69
  init_client
70
- } from "./chunk-W3JMIUHV.js";
70
+ } from "./chunk-KQTTKYZY.js";
71
71
  import {
72
72
  badRequest,
73
73
  notFound
@@ -423,7 +423,11 @@ var UserCustomToolResult = z.object({
423
423
  var UserDefineOutcome = z.object({
424
424
  type: z.literal("user.define_outcome"),
425
425
  description: z.string().min(1),
426
- rubric: z.string().optional(),
426
+ rubric: z.union([
427
+ z.string(),
428
+ z.object({ type: z.literal("text"), content: z.string() }),
429
+ z.object({ type: z.literal("file"), file_id: z.string() })
430
+ ]).optional(),
427
431
  max_iterations: z.number().int().min(1).max(20).optional()
428
432
  });
429
433
  var UserEvent = z.union([
@@ -589,16 +593,60 @@ function handlePostEvents(request, sessionId) {
589
593
  continue;
590
594
  }
591
595
  if (event.type === "user.define_outcome") {
592
- const { type: _type, ...criteria } = event;
596
+ const { newId: genId } = await import("./util/ids.js");
597
+ const outcomeId = genId("outc");
598
+ let rubricText;
599
+ if (typeof event.rubric === "string") {
600
+ rubricText = event.rubric;
601
+ } else if (event.rubric && event.rubric.type === "text") {
602
+ rubricText = event.rubric.content;
603
+ } else if (event.rubric && event.rubric.type === "file") {
604
+ const { getFile: getFileRow } = await import("./db/files.js");
605
+ const { readFile: readStoredFile } = await import("./files/storage.js");
606
+ const fileRow = getFileRow(event.rubric.file_id);
607
+ if (!fileRow) throw badRequest(`Rubric file not found: ${event.rubric.file_id}`);
608
+ rubricText = readStoredFile(fileRow.storage_path).toString("utf-8");
609
+ } else {
610
+ rubricText = "";
611
+ }
612
+ const maxIterations = event.max_iterations ?? 3;
613
+ const processedAt = nowMs();
614
+ const outcomeData = {
615
+ outcome_id: outcomeId,
616
+ description: event.description,
617
+ rubric: rubricText,
618
+ max_iterations: maxIterations,
619
+ grader_iteration: 0,
620
+ status: "running"
621
+ };
622
+ setOutcomeCriteria(sessionId, outcomeData);
593
623
  const row = appendEvent(sessionId, {
594
624
  type: "user.define_outcome",
595
- payload: criteria,
625
+ payload: {
626
+ outcome_id: outcomeId,
627
+ description: event.description,
628
+ rubric: rubricText,
629
+ max_iterations: maxIterations,
630
+ processed_at: processedAt
631
+ },
596
632
  origin: "user",
597
633
  idempotencyKey: ik,
598
- processedAt: nowMs()
634
+ processedAt
599
635
  });
600
636
  rows.push(row);
601
- setOutcomeCriteria(sessionId, criteria);
637
+ const descRow = appendEvent(sessionId, {
638
+ type: "user.message",
639
+ payload: { content: [{ type: "text", text: event.description }] },
640
+ origin: "user",
641
+ processedAt: null
642
+ });
643
+ const inp = { kind: "text", eventId: descRow.id, text: event.description };
644
+ const currentStatus = getSessionRow(sessionId)?.status ?? "idle";
645
+ if (currentStatus === "running" || sawInterrupt) {
646
+ pushPendingUserInput({ sessionId, input: inp });
647
+ } else {
648
+ pendingForTurn.push(inp);
649
+ }
602
650
  continue;
603
651
  }
604
652
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  listEntries
3
- } from "./chunk-VP527YC5.js";
3
+ } from "./chunk-BYIU4WAQ.js";
4
4
 
5
5
  // src/providers/resolve-secrets.ts
6
6
  var BLOCKED_ENV_KEYS = /* @__PURE__ */ new Set([
@@ -445,6 +445,25 @@ function runMigrations(db) {
445
445
  UNIQUE(vault_id, display_name)
446
446
  )
447
447
  `);
448
+ db.exec(`
449
+ CREATE TABLE IF NOT EXISTS memory_versions (
450
+ id TEXT PRIMARY KEY,
451
+ store_id TEXT NOT NULL,
452
+ memory_id TEXT NOT NULL,
453
+ operation TEXT NOT NULL,
454
+ path TEXT NOT NULL,
455
+ content TEXT,
456
+ content_sha256 TEXT,
457
+ session_id TEXT,
458
+ created_at INTEGER NOT NULL
459
+ )
460
+ `);
461
+ db.exec(`CREATE INDEX IF NOT EXISTS idx_memver_store ON memory_versions(store_id, created_at)`);
462
+ db.exec(`CREATE INDEX IF NOT EXISTS idx_memver_memory ON memory_versions(memory_id, created_at)`);
463
+ const memStoreColsArchive = db.prepare(`PRAGMA table_info(memory_stores)`).all();
464
+ if (!memStoreColsArchive.some((c) => c.name === "archived_at")) {
465
+ db.exec(`ALTER TABLE memory_stores ADD COLUMN archived_at INTEGER`);
466
+ }
448
467
  const credCols = db.prepare(`PRAGMA table_info(vault_credentials)`).all();
449
468
  if (!credCols.some((c) => c.name === "expires_at")) {
450
469
  db.exec(`ALTER TABLE vault_credentials ADD COLUMN expires_at TEXT`);
@@ -484,6 +503,34 @@ function runMigrations(db) {
484
503
  db.exec("UPDATE environments SET updated_at = created_at WHERE updated_at IS NULL");
485
504
  }
486
505
  }
506
+ db.exec(`
507
+ CREATE TABLE IF NOT EXISTS session_threads (
508
+ id TEXT PRIMARY KEY,
509
+ session_id TEXT NOT NULL,
510
+ agent_id TEXT NOT NULL,
511
+ agent_version INTEGER NOT NULL,
512
+ parent_thread_id TEXT,
513
+ status TEXT NOT NULL DEFAULT 'idle',
514
+ stop_reason TEXT,
515
+ usage_input_tokens INTEGER NOT NULL DEFAULT 0,
516
+ usage_output_tokens INTEGER NOT NULL DEFAULT 0,
517
+ usage_cache_read_input_tokens INTEGER NOT NULL DEFAULT 0,
518
+ usage_cache_creation_input_tokens INTEGER NOT NULL DEFAULT 0,
519
+ created_at INTEGER NOT NULL,
520
+ updated_at INTEGER NOT NULL,
521
+ archived_at INTEGER
522
+ )
523
+ `);
524
+ db.exec(`CREATE INDEX IF NOT EXISTS idx_session_threads_session ON session_threads(session_id)`);
525
+ const eventColsThread = db.prepare(`PRAGMA table_info(events)`).all();
526
+ if (!eventColsThread.some((c) => c.name === "thread_id")) {
527
+ db.exec(`ALTER TABLE events ADD COLUMN thread_id TEXT`);
528
+ }
529
+ db.exec(`CREATE INDEX IF NOT EXISTS idx_events_thread ON events(thread_id) WHERE thread_id IS NOT NULL`);
530
+ const avColsMultiagent = db.prepare(`PRAGMA table_info(agent_versions)`).all();
531
+ if (!avColsMultiagent.some((c) => c.name === "multiagent_json")) {
532
+ db.exec(`ALTER TABLE agent_versions ADD COLUMN multiagent_json TEXT`);
533
+ }
487
534
  {
488
535
  const cols = db.prepare("PRAGMA table_info(vaults)").all();
489
536
  const names = new Set(cols.map((c) => c.name));
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  jsonOk,
3
3
  routeWrap
4
- } from "./chunk-T3IGOI6Z.js";
4
+ } from "./chunk-DTQ7J35Q.js";
5
5
  import {
6
6
  resolveContainerProvider
7
- } from "./chunk-JRQB3SHR.js";
7
+ } from "./chunk-LT5PRO54.js";
8
8
  import {
9
9
  getConfig
10
- } from "./chunk-GQYSSSVA.js";
10
+ } from "./chunk-UGH5JDXX.js";
11
11
 
12
12
  // src/handlers/providers.ts
13
13
  var LOCAL_PROVIDERS = ["docker", "apple-container", "podman"];
@@ -1,21 +1,21 @@
1
- import {
2
- piBackend
3
- } from "./chunk-C35ZTCBP.js";
4
1
  import {
5
2
  opencodeBackend
6
- } from "./chunk-63AKPSCV.js";
3
+ } from "./chunk-X4ARJS6I.js";
7
4
  import {
8
- factoryBackend
9
- } from "./chunk-R6EXYBCT.js";
5
+ piBackend
6
+ } from "./chunk-IAKR572X.js";
10
7
  import {
11
8
  geminiBackend
12
- } from "./chunk-5M47X54D.js";
9
+ } from "./chunk-DZGFZMUE.js";
10
+ import {
11
+ factoryBackend
12
+ } from "./chunk-C52BVTYC.js";
13
13
  import {
14
14
  codexBackend
15
- } from "./chunk-L35CBI7F.js";
15
+ } from "./chunk-E35XHOFL.js";
16
16
  import {
17
17
  claudeBackend
18
- } from "./chunk-NBYCX6L4.js";
18
+ } from "./chunk-6KJS42ZL.js";
19
19
 
20
20
  // src/backends/registry.ts
21
21
  var BACKENDS = {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  routeWrap
3
- } from "./chunk-T3IGOI6Z.js";
3
+ } from "./chunk-DTQ7J35Q.js";
4
4
  import {
5
5
  ApiError
6
6
  } from "./chunk-EZYKRG4W.js";
@@ -7,7 +7,7 @@ import {
7
7
  jsonOk,
8
8
  paginatedOk,
9
9
  routeWrap
10
- } from "./chunk-T3IGOI6Z.js";
10
+ } from "./chunk-DTQ7J35Q.js";
11
11
  import {
12
12
  archiveVault,
13
13
  createVault,
@@ -19,14 +19,14 @@ import {
19
19
  listVaults,
20
20
  setEntry,
21
21
  updateVault
22
- } from "./chunk-VP527YC5.js";
22
+ } from "./chunk-BYIU4WAQ.js";
23
23
  import {
24
24
  getAgent
25
- } from "./chunk-BCIFFAGW.js";
25
+ } from "./chunk-M3752GFZ.js";
26
26
  import {
27
27
  getDb,
28
28
  init_client
29
- } from "./chunk-W3JMIUHV.js";
29
+ } from "./chunk-KQTTKYZY.js";
30
30
  import {
31
31
  badRequest,
32
32
  conflict,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readSetting
3
- } from "./chunk-GQYSSSVA.js";
3
+ } from "./chunk-UGH5JDXX.js";
4
4
 
5
5
  // src/lib/skills-cache.ts
6
6
  var DEFAULT_FEED_URL = "https://www.agentstep.com/v1/skills/feed";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  listEntries
3
- } from "./chunk-VP527YC5.js";
3
+ } from "./chunk-BYIU4WAQ.js";
4
4
  import {
5
5
  getConfig
6
- } from "./chunk-GQYSSSVA.js";
6
+ } from "./chunk-UGH5JDXX.js";
7
7
 
8
8
  // src/observability/redactor.ts
9
9
  var REDACTED = "[REDACTED]";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  init_session_resources,
3
3
  session_resources_exports
4
- } from "./chunk-FCUXFLNK.js";
4
+ } from "./chunk-VY6IWBSK.js";
5
5
  import {
6
6
  getAgent
7
- } from "./chunk-BCIFFAGW.js";
7
+ } from "./chunk-M3752GFZ.js";
8
8
  import {
9
9
  DEFAULT_TENANT_ID
10
- } from "./chunk-I26QP3A3.js";
10
+ } from "./chunk-UQZFFG7U.js";
11
11
  import {
12
12
  init_ids,
13
13
  newId
@@ -20,10 +20,10 @@ import {
20
20
  import {
21
21
  getDrizzle,
22
22
  init_drizzle
23
- } from "./chunk-PZNAQBHQ.js";
23
+ } from "./chunk-FILGQF2G.js";
24
24
  import {
25
25
  schema_exports
26
- } from "./chunk-ILHIHMO3.js";
26
+ } from "./chunk-VC5DELR4.js";
27
27
  import {
28
28
  __toCommonJS
29
29
  } from "./chunk-2ESYSVXG.js";
@@ -100,6 +100,15 @@ function hydrateSession(row) {
100
100
  max_tokens: row.max_tokens ?? null,
101
101
  max_wall_duration_ms: row.max_wall_duration_ms ?? null,
102
102
  outcome: row.outcome_criteria_json ? JSON.parse(row.outcome_criteria_json) : null,
103
+ outcome_evaluations: row.outcome_criteria_json ? [JSON.parse(row.outcome_criteria_json)].filter((o) => o.outcome_id).map((o) => ({
104
+ type: "outcome_evaluation",
105
+ outcome_id: o.outcome_id,
106
+ description: o.description ?? "",
107
+ result: o.status === "running" ? "running" : o.status,
108
+ iteration: o.grader_iteration ?? 0,
109
+ completed_at: o.completed_at ?? null,
110
+ explanation: o.explanation ?? ""
111
+ })) : [],
103
112
  resources,
104
113
  vault_ids: row.vault_ids_json ? JSON.parse(row.vault_ids_json) : [],
105
114
  parent_session_id: row.parent_session_id ?? null,
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  getDb,
16
16
  init_client
17
- } from "./chunk-W3JMIUHV.js";
17
+ } from "./chunk-KQTTKYZY.js";
18
18
 
19
19
  // src/db/audit.ts
20
20
  init_client();
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  getDb,
15
15
  init_client
16
- } from "./chunk-W3JMIUHV.js";
16
+ } from "./chunk-KQTTKYZY.js";
17
17
 
18
18
  // src/db/upstream_keys.ts
19
19
  init_client();
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  syncAndCreateSession
3
- } from "./chunk-7SY65LWY.js";
3
+ } from "./chunk-62CZZBEE.js";
4
4
  import {
5
5
  resolveRemoteSessionId,
6
6
  upsertSync
7
- } from "./chunk-22OUZJAV.js";
7
+ } from "./chunk-AESA3ARX.js";
8
8
  import {
9
9
  assertResourceTenant,
10
10
  tenantFilter
@@ -12,18 +12,21 @@ import {
12
12
  import {
13
13
  interruptSession
14
14
  } from "./chunk-DC2UMEQH.js";
15
+ import {
16
+ getMemoryStore
17
+ } from "./chunk-GBLR2CPP.js";
15
18
  import {
16
19
  kickoffEnvironmentSetup
17
- } from "./chunk-QJ6QQO6D.js";
20
+ } from "./chunk-6KQFP32G.js";
18
21
  import {
19
22
  decodeCursor,
20
23
  jsonOk,
21
24
  paginatedOk,
22
25
  routeWrap
23
- } from "./chunk-T3IGOI6Z.js";
26
+ } from "./chunk-DTQ7J35Q.js";
24
27
  import {
25
28
  forwardToAnthropic
26
- } from "./chunk-A46RUKGA.js";
29
+ } from "./chunk-Y4MI27HU.js";
27
30
  import {
28
31
  errors_exports,
29
32
  init_errors
@@ -33,18 +36,18 @@ import {
33
36
  isProxied,
34
37
  markProxied,
35
38
  unmarkProxied
36
- } from "./chunk-5U5LRAFJ.js";
39
+ } from "./chunk-MTLM36QD.js";
37
40
  import {
38
41
  dropActor,
39
42
  getActor
40
43
  } from "./chunk-LAWTTG2E.js";
41
44
  import {
42
45
  releaseSession
43
- } from "./chunk-ZY2U24QP.js";
46
+ } from "./chunk-75XURMV5.js";
44
47
  import {
45
48
  appendEvent,
46
49
  dropEmitter
47
- } from "./chunk-5MERXOLJ.js";
50
+ } from "./chunk-NRX5WHHN.js";
48
51
  import {
49
52
  archiveSession,
50
53
  createSession,
@@ -52,13 +55,13 @@ import {
52
55
  listSessions,
53
56
  updateSessionMutable,
54
57
  updateSessionStatus
55
- } from "./chunk-KUWJJD6O.js";
58
+ } from "./chunk-TSR33JMZ.js";
56
59
  import {
57
60
  getEnvironment
58
- } from "./chunk-H6OT5GUL.js";
61
+ } from "./chunk-7APAOJIZ.js";
59
62
  import {
60
63
  getAgent
61
- } from "./chunk-BCIFFAGW.js";
64
+ } from "./chunk-M3752GFZ.js";
62
65
  import {
63
66
  init_clock,
64
67
  nowMs
@@ -66,7 +69,7 @@ import {
66
69
  import {
67
70
  getDb,
68
71
  init_client
69
- } from "./chunk-W3JMIUHV.js";
72
+ } from "./chunk-KQTTKYZY.js";
70
73
  import {
71
74
  badRequest,
72
75
  notFound
@@ -115,7 +118,7 @@ var AgentRef = z.union([
115
118
  z.object({ id: z.string(), version: z.number().int(), type: z.literal("agent").optional() })
116
119
  ]);
117
120
  var ResourceSchema = z.object({
118
- type: z.enum(["uri", "text", "file", "github_repository"]),
121
+ type: z.enum(["uri", "text", "file", "github_repository", "memory_store"]),
119
122
  uri: z.string().optional(),
120
123
  content: z.string().optional(),
121
124
  file_id: z.string().optional(),
@@ -131,7 +134,11 @@ var ResourceSchema = z.object({
131
134
  name: z.string().optional(),
132
135
  sha: z.string().optional()
133
136
  }).optional(),
134
- authorization_token: z.string().optional()
137
+ authorization_token: z.string().optional(),
138
+ // Memory store resource fields
139
+ memory_store_id: z.string().optional(),
140
+ access: z.enum(["read_only", "read_write"]).optional(),
141
+ instructions: z.string().optional()
135
142
  });
136
143
  var CreateSchema = z.object({
137
144
  agent: AgentRef,
@@ -243,6 +250,20 @@ function handleCreateSession(request) {
243
250
  }
244
251
  }
245
252
  }
253
+ if (data.resources?.length) {
254
+ const memStoreResources = data.resources.filter((r) => r.type === "memory_store");
255
+ if (memStoreResources.length > 8) {
256
+ throw badRequest(`max 8 memory_store resources per session (got ${memStoreResources.length})`);
257
+ }
258
+ for (const r of memStoreResources) {
259
+ if (!r.memory_store_id) {
260
+ throw badRequest(`memory_store resource requires memory_store_id`);
261
+ }
262
+ const store = getMemoryStore(r.memory_store_id);
263
+ if (!store) throw notFound(`memory store not found: ${r.memory_store_id}`);
264
+ if (store.archived_at) throw badRequest(`memory store ${r.memory_store_id} is archived`);
265
+ }
266
+ }
246
267
  if (env.config?.provider === "anthropic") {
247
268
  const { resolveAnthropicKey } = await import("./providers/upstream-keys.js");
248
269
  const resolved = resolveAnthropicKey({ vaultIds: data.vault_ids ?? void 0 });
@@ -342,6 +363,15 @@ function handleCreateSession(request) {
342
363
  if (data.resources?.length) {
343
364
  const { createResource } = await import("./db/session-resources.js");
344
365
  for (const r of data.resources) {
366
+ if (r.type === "memory_store") {
367
+ createResource(session.id, {
368
+ type: "memory_store",
369
+ memory_store_id: r.memory_store_id,
370
+ access: r.access ?? "read_write",
371
+ instructions: r.instructions
372
+ });
373
+ continue;
374
+ }
345
375
  let repoUrl = r.type === "github_repository" ? r.repository_url ?? r.url : r.uri;
346
376
  if (r.type === "github_repository" && r.authorization_token && repoUrl) {
347
377
  try {