@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
@@ -0,0 +1,166 @@
1
+ import {
2
+ archiveThread,
3
+ getThread,
4
+ listThreads
5
+ } from "./chunk-7IYL2O7H.js";
6
+ import {
7
+ assertResourceTenant
8
+ } from "./chunk-23UKWXJH.js";
9
+ import {
10
+ jsonOk,
11
+ paginatedOk,
12
+ routeWrap
13
+ } from "./chunk-DTQ7J35Q.js";
14
+ import {
15
+ subscribe
16
+ } from "./chunk-NRX5WHHN.js";
17
+ import {
18
+ getSession
19
+ } from "./chunk-TSR33JMZ.js";
20
+ import {
21
+ listEvents,
22
+ rowToManagedEvent
23
+ } from "./chunk-7JAUY5SG.js";
24
+ import {
25
+ getDb,
26
+ init_client
27
+ } from "./chunk-KQTTKYZY.js";
28
+ import {
29
+ badRequest,
30
+ notFound
31
+ } from "./chunk-EZYKRG4W.js";
32
+
33
+ // src/handlers/threads.ts
34
+ init_client();
35
+ function loadSession(auth, sessionId) {
36
+ const row = getDb().prepare(`SELECT tenant_id FROM sessions WHERE id = ?`).get(sessionId);
37
+ if (!row) throw notFound(`session ${sessionId} not found`);
38
+ assertResourceTenant(auth, row.tenant_id, `session ${sessionId} not found`);
39
+ const session = getSession(sessionId);
40
+ if (!session) throw notFound(`session ${sessionId} not found`);
41
+ return session;
42
+ }
43
+ function handleListThreads(request, sessionId) {
44
+ return routeWrap(request, async ({ auth }) => {
45
+ loadSession(auth, sessionId);
46
+ const url = new URL(request.url);
47
+ const limit = url.searchParams.get("limit");
48
+ const order = url.searchParams.get("order");
49
+ const requestedLimit = limit ? Number(limit) : 50;
50
+ const data = listThreads(sessionId, {
51
+ limit: requestedLimit,
52
+ order: order ?? void 0
53
+ });
54
+ return paginatedOk(data, requestedLimit);
55
+ });
56
+ }
57
+ function handleGetThread(request, sessionId, threadId) {
58
+ return routeWrap(request, async ({ auth }) => {
59
+ loadSession(auth, sessionId);
60
+ const thread = getThread(sessionId, threadId);
61
+ if (!thread) throw notFound(`thread ${threadId} not found`);
62
+ return jsonOk(thread);
63
+ });
64
+ }
65
+ function handleArchiveThread(request, sessionId, threadId) {
66
+ return routeWrap(request, async ({ auth }) => {
67
+ loadSession(auth, sessionId);
68
+ const existing = getThread(sessionId, threadId);
69
+ if (!existing) throw notFound(`thread ${threadId} not found`);
70
+ if (existing.status !== "idle") {
71
+ throw badRequest(`cannot archive thread in status "${existing.status}" \u2014 must be idle`);
72
+ }
73
+ const archived = archiveThread(sessionId, threadId);
74
+ if (!archived) throw notFound(`thread ${threadId} not found`);
75
+ return jsonOk(archived);
76
+ });
77
+ }
78
+ function handleListThreadEvents(request, sessionId, threadId) {
79
+ return routeWrap(request, async ({ auth }) => {
80
+ loadSession(auth, sessionId);
81
+ const thread = getThread(sessionId, threadId);
82
+ if (!thread) throw notFound(`thread ${threadId} not found`);
83
+ const url = new URL(request.url);
84
+ const limit = url.searchParams.get("limit");
85
+ const order = url.searchParams.get("order");
86
+ const afterSeq = url.searchParams.get("after_seq");
87
+ const requestedLimit = limit ? Number(limit) : 50;
88
+ const allEvents = listEvents(sessionId, {
89
+ limit: 500,
90
+ // fetch more than needed since we filter
91
+ order: order ?? "asc",
92
+ afterSeq: afterSeq ? Number(afterSeq) : void 0
93
+ });
94
+ const threadEvents = allEvents.filter((e) => {
95
+ const payload = JSON.parse(e.payload_json);
96
+ return payload.thread_id === threadId || e.type.startsWith("session.thread_");
97
+ }).slice(0, requestedLimit).map(rowToManagedEvent);
98
+ return paginatedOk(threadEvents, requestedLimit);
99
+ });
100
+ }
101
+ function handleStreamThreadEvents(request, sessionId, threadId) {
102
+ return routeWrap(request, async ({ auth }) => {
103
+ loadSession(auth, sessionId);
104
+ const thread = getThread(sessionId, threadId);
105
+ if (!thread) throw notFound(`thread ${threadId} not found`);
106
+ const url = new URL(request.url);
107
+ const lastEventId = request.headers.get("last-event-id");
108
+ const afterSeq = lastEventId ? Number(lastEventId) : Number(url.searchParams.get("after_seq") ?? "0");
109
+ const encoder = new TextEncoder();
110
+ let controller;
111
+ const stream = new ReadableStream({
112
+ start(c) {
113
+ controller = c;
114
+ }
115
+ });
116
+ const write = (payload) => {
117
+ try {
118
+ controller.enqueue(encoder.encode(payload));
119
+ } catch {
120
+ }
121
+ };
122
+ const sub = subscribe(
123
+ sessionId,
124
+ Number.isFinite(afterSeq) ? afterSeq : 0,
125
+ (evt) => {
126
+ if (evt.thread_id === threadId) {
127
+ write(`id: ${evt.seq}
128
+ event: ${evt.type}
129
+ data: ${JSON.stringify(evt)}
130
+
131
+ `);
132
+ }
133
+ }
134
+ );
135
+ const keepalive = setInterval(() => {
136
+ write(`data: {"type":"ping"}
137
+
138
+ `);
139
+ }, 15e3);
140
+ const abort = () => {
141
+ clearInterval(keepalive);
142
+ sub.unsubscribe();
143
+ try {
144
+ controller.close();
145
+ } catch {
146
+ }
147
+ };
148
+ request.signal.addEventListener("abort", abort);
149
+ return new Response(stream, {
150
+ headers: {
151
+ "Content-Type": "text/event-stream",
152
+ "Cache-Control": "no-cache",
153
+ Connection: "keep-alive",
154
+ "X-Accel-Buffering": "no"
155
+ }
156
+ });
157
+ });
158
+ }
159
+
160
+ export {
161
+ handleListThreads,
162
+ handleGetThread,
163
+ handleArchiveThread,
164
+ handleListThreadEvents,
165
+ handleStreamThreadEvents
166
+ };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  markStopping
3
- } from "./chunk-EDUTIJAU.js";
3
+ } from "./chunk-YIY47OVD.js";
4
4
  import {
5
5
  closeDb,
6
6
  init_client,
7
7
  syncDb
8
- } from "./chunk-W3JMIUHV.js";
8
+ } from "./chunk-KQTTKYZY.js";
9
9
  import {
10
10
  getRuntime
11
11
  } from "./chunk-UYTSKFGK.js";
@@ -0,0 +1,50 @@
1
+ // src/dreaming/prompts.ts
2
+ var DREAMING_SYSTEM_PROMPT = `You are a memory curator for an AI agent platform. You review recent agent sessions to identify patterns and improve the agent's memory store.
3
+
4
+ Your job:
5
+ 1. Analyze session transcripts for recurring patterns, mistakes, preferences, and learnings
6
+ 2. Compare against the current memory store contents
7
+ 3. Propose memory updates that will help agents perform better in future sessions
8
+
9
+ Output your proposed changes using the update_memories tool. Each change should have:
10
+ - operation: "create" (new memory), "update" (modify existing), or "delete" (remove outdated)
11
+ - path: the memory file path (e.g., "/preferences/formatting.md", "/patterns/common-errors.md")
12
+ - content: the new content (for create/update)
13
+ - reason: why this change improves agent performance
14
+
15
+ Guidelines:
16
+ - Structure memories as small, focused files (one topic per file)
17
+ - Keep memory files under 100KB
18
+ - Use clear, descriptive paths
19
+ - Don't create memories for one-off events \u2014 focus on patterns
20
+ - Update existing memories when new information refines them
21
+ - Delete memories that are outdated or contradicted by recent sessions
22
+ - Focus on actionable knowledge the agent can use`;
23
+ var UPDATE_MEMORIES_TOOL = {
24
+ name: "update_memories",
25
+ description: "Propose changes to the memory store based on session analysis",
26
+ input_schema: {
27
+ type: "object",
28
+ properties: {
29
+ changes: {
30
+ type: "array",
31
+ items: {
32
+ type: "object",
33
+ properties: {
34
+ operation: { type: "string", enum: ["create", "update", "delete"] },
35
+ path: { type: "string" },
36
+ content: { type: "string" },
37
+ reason: { type: "string" }
38
+ },
39
+ required: ["operation", "path", "reason"]
40
+ }
41
+ }
42
+ },
43
+ required: ["changes"]
44
+ }
45
+ };
46
+
47
+ export {
48
+ DREAMING_SYSTEM_PROMPT,
49
+ UPDATE_MEMORIES_TOOL
50
+ };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  listCredentialsWithTokens
3
- } from "./chunk-HVLYE4S5.js";
3
+ } from "./chunk-7EDLLXFQ.js";
4
4
  import {
5
5
  listEntries
6
- } from "./chunk-VP527YC5.js";
6
+ } from "./chunk-BYIU4WAQ.js";
7
7
 
8
8
  // src/sessions/secrets.ts
9
9
  function loadSessionSecrets(vaultIds) {
@@ -8,17 +8,17 @@ import {
8
8
  jsonOk,
9
9
  paginatedOk,
10
10
  routeWrap
11
- } from "./chunk-T3IGOI6Z.js";
11
+ } from "./chunk-DTQ7J35Q.js";
12
12
  import {
13
13
  forwardToAnthropic,
14
14
  validateAnthropicProxy
15
- } from "./chunk-A46RUKGA.js";
15
+ } from "./chunk-Y4MI27HU.js";
16
16
  import {
17
17
  getProxiedTenantId,
18
18
  isProxied,
19
19
  markProxied,
20
20
  unmarkProxied
21
- } from "./chunk-5U5LRAFJ.js";
21
+ } from "./chunk-MTLM36QD.js";
22
22
  import {
23
23
  archiveAgent,
24
24
  createAgent,
@@ -26,14 +26,14 @@ import {
26
26
  listAgentVersions,
27
27
  listAgents,
28
28
  updateAgent
29
- } from "./chunk-BCIFFAGW.js";
29
+ } from "./chunk-M3752GFZ.js";
30
30
  import {
31
31
  resolveBackend
32
- } from "./chunk-IMPLRDOV.js";
32
+ } from "./chunk-Q2JYAAJO.js";
33
33
  import {
34
34
  getDb,
35
35
  init_client
36
- } from "./chunk-W3JMIUHV.js";
36
+ } from "./chunk-KQTTKYZY.js";
37
37
  import {
38
38
  badRequest,
39
39
  conflict,
@@ -113,6 +113,13 @@ var CreateSchema = z.object({
113
113
  id: z.string(),
114
114
  version: z.number().int().optional()
115
115
  })).optional(),
116
+ multiagent: z.object({
117
+ type: z.literal("coordinator"),
118
+ agents: z.array(z.union([
119
+ z.object({ type: z.literal("agent"), id: z.string(), version: z.number().int().optional() }),
120
+ z.object({ type: z.literal("self") })
121
+ ])).max(20)
122
+ }).optional(),
116
123
  skills: z.array(SkillSchema).max(20).optional(),
117
124
  model_config: ModelConfigSchema.optional(),
118
125
  /** v0.5: required for global admin, ignored for tenant users. */
@@ -150,6 +157,13 @@ var UpdateSchema = z.object({
150
157
  id: z.string(),
151
158
  version: z.number().int().optional()
152
159
  })).optional(),
160
+ multiagent: z.object({
161
+ type: z.literal("coordinator"),
162
+ agents: z.array(z.union([
163
+ z.object({ type: z.literal("agent"), id: z.string(), version: z.number().int().optional() }),
164
+ z.object({ type: z.literal("self") })
165
+ ])).max(20)
166
+ }).nullish(),
153
167
  skills: z.array(SkillSchema).max(20).optional(),
154
168
  model_config: ModelConfigSchema.optional()
155
169
  }).refine((data) => {
@@ -228,9 +242,10 @@ function handleCreateAgent(request) {
228
242
  webhook_url: parsed.data.webhook_url ?? null,
229
243
  webhook_events: parsed.data.webhook_events,
230
244
  webhook_secret: parsed.data.webhook_secret ?? null,
231
- threads_enabled: parsed.data.threads_enabled ?? false,
245
+ threads_enabled: parsed.data.threads_enabled ?? (parsed.data.multiagent ? true : false),
232
246
  confirmation_mode: parsed.data.confirmation_mode ?? false,
233
247
  callable_agents: parsed.data.callable_agents,
248
+ multiagent: parsed.data.multiagent,
234
249
  skills: parsed.data.skills?.map((s) => ({
235
250
  ...s,
236
251
  installed_at: s.installed_at ?? nowIso
@@ -313,6 +328,7 @@ function handleUpdateAgent(request, id) {
313
328
  webhook_secret: parsed.data.webhook_secret,
314
329
  confirmation_mode: parsed.data.confirmation_mode,
315
330
  callable_agents: parsed.data.callable_agents,
331
+ multiagent: parsed.data.multiagent,
316
332
  skills: parsed.data.skills?.map((s) => ({
317
333
  ...s,
318
334
  installed_at: s.installed_at ?? nowIso
@@ -2,19 +2,19 @@ import {
2
2
  getSyncRow,
3
3
  getSyncedRemoteId,
4
4
  upsertSync
5
- } from "./chunk-22OUZJAV.js";
5
+ } from "./chunk-AESA3ARX.js";
6
6
  import {
7
7
  injectMcpAuthHeaders
8
8
  } from "./chunk-DBFPJSOY.js";
9
9
  import {
10
10
  listEntries
11
- } from "./chunk-VP527YC5.js";
11
+ } from "./chunk-BYIU4WAQ.js";
12
12
  import {
13
13
  getEnvironment
14
- } from "./chunk-H6OT5GUL.js";
14
+ } from "./chunk-7APAOJIZ.js";
15
15
  import {
16
16
  getAgent
17
- } from "./chunk-BCIFFAGW.js";
17
+ } from "./chunk-M3752GFZ.js";
18
18
 
19
19
  // src/sync/anthropic.ts
20
20
  import { createHash } from "crypto";
@@ -4,7 +4,7 @@ import {
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/license.ts
10
10
  function handleGetLicense(request) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-GQYSSSVA.js";
3
+ } from "./chunk-UGH5JDXX.js";
4
4
 
5
5
  // src/backends/pi/auth.ts
6
6
  function buildPiAuthEnv() {
@@ -1,7 +1,3 @@
1
- import {
2
- buildClaudeArgs,
3
- buildClaudeAuthEnv
4
- } from "./chunk-YYMUSVUI.js";
5
1
  import {
6
2
  PERMISSION_BRIDGE_DIR,
7
3
  PERMISSION_HOOK_SCRIPT_PATH,
@@ -19,13 +15,17 @@ import {
19
15
  import {
20
16
  createClaudeTranslator
21
17
  } from "./chunk-JFYE5BFI.js";
18
+ import {
19
+ buildClaudeArgs,
20
+ buildClaudeAuthEnv
21
+ } from "./chunk-ANS2TQYT.js";
22
22
  import {
23
23
  CLAUDE_WRAPPER_PATH,
24
24
  installClaudeWrapper
25
25
  } from "./chunk-QBJOYOVF.js";
26
26
  import {
27
27
  getConfig
28
- } from "./chunk-GQYSSSVA.js";
28
+ } from "./chunk-UGH5JDXX.js";
29
29
 
30
30
  // src/backends/claude/index.ts
31
31
  function buildTurn(input) {
@@ -33,7 +33,8 @@ function buildTurn(input) {
33
33
  const argsBase = buildClaudeArgs({
34
34
  agent,
35
35
  claudeSessionId: backendSessionId,
36
- confirmationMode: agent.confirmation_mode
36
+ confirmationMode: agent.confirmation_mode,
37
+ memoryStores: input.memoryStores
37
38
  });
38
39
  const env = buildClaudeAuthEnv();
39
40
  const customTools = agent.tools.filter((t) => t.type === "custom");
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  resolveContainerProvider
3
- } from "./chunk-JRQB3SHR.js";
3
+ } from "./chunk-LT5PRO54.js";
4
4
  import {
5
5
  getEnvironmentRow,
6
6
  updateEnvironmentState
7
- } from "./chunk-H6OT5GUL.js";
7
+ } from "./chunk-7APAOJIZ.js";
8
8
  import {
9
9
  installClaudeWrapper
10
10
  } from "./chunk-QBJOYOVF.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-GQYSSSVA.js";
3
+ } from "./chunk-UGH5JDXX.js";
4
4
 
5
5
  // src/backends/codex/auth.ts
6
6
  function buildCodexAuthEnv() {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  jsonOk,
3
3
  routeWrap
4
- } from "./chunk-T3IGOI6Z.js";
4
+ } from "./chunk-DTQ7J35Q.js";
5
5
 
6
6
  // src/handlers/whoami.ts
7
7
  function handleWhoami(request) {
@@ -1,21 +1,21 @@
1
+ import {
2
+ resolveVaultSecrets
3
+ } from "./chunk-O2X4XBU7.js";
1
4
  import {
2
5
  dockerProvider
3
6
  } from "./chunk-4XXQAVKE.js";
4
- import {
5
- resolveVaultSecrets
6
- } from "./chunk-T3HMVHDG.js";
7
7
  import {
8
8
  appendEvent
9
- } from "./chunk-5MERXOLJ.js";
9
+ } from "./chunk-NRX5WHHN.js";
10
10
  import {
11
11
  getSession,
12
12
  getSessionRow,
13
13
  setSessionSandbox
14
- } from "./chunk-KUWJJD6O.js";
14
+ } from "./chunk-TSR33JMZ.js";
15
15
  import {
16
16
  deleteSprite,
17
17
  listSprites
18
- } from "./chunk-O56RNR7B.js";
18
+ } from "./chunk-VMLXV2H6.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-JRQB3SHR.js";
27
+ } from "./chunk-LT5PRO54.js";
28
28
  import {
29
29
  getEnvironment,
30
30
  getEnvironmentRow,
31
31
  listEnvironments
32
- } from "./chunk-H6OT5GUL.js";
32
+ } from "./chunk-7APAOJIZ.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-BCIFFAGW.js";
43
+ } from "./chunk-M3752GFZ.js";
44
44
  import {
45
45
  resolveBackend
46
- } from "./chunk-IMPLRDOV.js";
46
+ } from "./chunk-Q2JYAAJO.js";
47
47
  import {
48
48
  getConfig
49
- } from "./chunk-GQYSSSVA.js";
49
+ } from "./chunk-UGH5JDXX.js";
50
50
  import {
51
51
  init_clock,
52
52
  nowMs
@@ -216,6 +216,7 @@ async function acquireForFirstTurn(sessionId) {
216
216
  await provisionResources(name2, session.resources, sp);
217
217
  }
218
218
  }
219
+ await mountMemoryStores(name2, sessionId, sp);
219
220
  register({
220
221
  sandboxName: name2,
221
222
  envId: env.id,
@@ -323,6 +324,7 @@ async function acquireForFirstTurn(sessionId) {
323
324
  await provisionResources(name, session.resources, sp);
324
325
  }
325
326
  }
327
+ await mountMemoryStores(name, sessionId, sp);
326
328
  register({
327
329
  sandboxName: name,
328
330
  envId: env.id,
@@ -485,7 +487,13 @@ async function provisionResources(sandboxName, resources, provider) {
485
487
  console.warn(`[lifecycle] skipping file ${r.file_id}: too large`);
486
488
  continue;
487
489
  }
488
- await writeTo(mountTarget, data.toString("utf8"));
490
+ const b64 = data.toString("base64");
491
+ await provider.exec(
492
+ sandboxName,
493
+ ["sh", "-c", 'base64 -d > "$1"', "sh", mountTarget],
494
+ { stdin: b64 }
495
+ );
496
+ await provider.exec(sandboxName, ["chmod", "a-w", mountTarget]);
489
497
  } catch (err) {
490
498
  console.warn(`[lifecycle] failed to provision file resource ${r.file_id}:`, err);
491
499
  }
@@ -517,6 +525,36 @@ async function provisionResources(sandboxName, resources, provider) {
517
525
  }
518
526
  }
519
527
  }
528
+ async function mountMemoryStores(sandboxName, sessionId, provider) {
529
+ const { listResources: listSessionResources } = await import("./db/session-resources.js");
530
+ const { getMemoryStore, listMemories } = await import("./db/memory.js");
531
+ const resources = listSessionResources(sessionId);
532
+ const memStoreResources = resources.filter((r) => r.type === "memory_store" && r.memory_store_id);
533
+ if (memStoreResources.length === 0) return;
534
+ await provider.exec(sandboxName, ["mkdir", "-p", "/mnt/memory"]);
535
+ for (const r of memStoreResources) {
536
+ const store = getMemoryStore(r.memory_store_id);
537
+ if (!store) {
538
+ lcLog(`[lifecycle] memory store not found: ${r.memory_store_id}`);
539
+ continue;
540
+ }
541
+ const storeName = store.name.replace(/[^a-zA-Z0-9_.-]/g, "_");
542
+ const storeDir = `/mnt/memory/${storeName}`;
543
+ await provider.exec(sandboxName, ["mkdir", "-p", storeDir]);
544
+ const memories = listMemories(store.id);
545
+ for (const mem of memories) {
546
+ const memPath = `${storeDir}/${mem.path}`;
547
+ const dir = memPath.substring(0, memPath.lastIndexOf("/"));
548
+ if (dir && dir !== storeDir) {
549
+ await provider.exec(sandboxName, ["mkdir", "-p", dir]);
550
+ }
551
+ await provider.exec(sandboxName, ["sh", "-c", 'cat > "$1"', "sh", memPath], {
552
+ stdin: mem.content
553
+ });
554
+ }
555
+ lcLog(`[lifecycle] ${sessionId} mounted ${memories.length} memories from store "${store.name}" at ${storeDir}`);
556
+ }
557
+ }
520
558
  async function releaseSession(sessionId) {
521
559
  const entry = unregister(sessionId);
522
560
  const row = getSessionRow(sessionId);
@@ -584,6 +622,7 @@ export {
584
622
  replenishWarmPool,
585
623
  fillWarmPools,
586
624
  provisionResources,
625
+ mountMemoryStores,
587
626
  releaseSession,
588
627
  reconcileOrphanSandboxes,
589
628
  reconcileDockerOrphanSandboxes
@@ -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/environments.ts
22
22
  init_drizzle();
@@ -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/credentials.ts
20
20
  init_client();