@agentstep/agent-sdk 0.4.29 → 0.4.30

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 (174) hide show
  1. package/dist/auth/middleware.js +7 -7
  2. package/dist/backends/claude/args.js +5 -5
  3. package/dist/backends/claude/index.js +6 -6
  4. package/dist/backends/codex/auth.js +5 -5
  5. package/dist/backends/codex/index.js +6 -6
  6. package/dist/backends/factory/auth.js +5 -5
  7. package/dist/backends/factory/index.js +6 -6
  8. package/dist/backends/gemini/auth.js +5 -5
  9. package/dist/backends/gemini/index.js +6 -6
  10. package/dist/backends/opencode/auth.js +5 -5
  11. package/dist/backends/opencode/index.js +6 -6
  12. package/dist/backends/pi/auth.js +5 -5
  13. package/dist/backends/pi/index.js +6 -6
  14. package/dist/backends/registry.js +17 -17
  15. package/dist/{chunk-TY3HD5I5.js → chunk-2DRBKIGQ.js} +1 -1
  16. package/dist/{chunk-UIVEK3MD.js → chunk-2JKOYBUO.js} +1 -1
  17. package/dist/{chunk-HMBJOI5F.js → chunk-3KLJGU75.js} +17 -14
  18. package/dist/{chunk-ZP5VMV5O.js → chunk-46XURNM7.js} +4 -4
  19. package/dist/{chunk-KOGG7CSN.js → chunk-4B7PQTTS.js} +6 -6
  20. package/dist/{chunk-5GZEX4HV.js → chunk-4C7XJI2V.js} +1 -1
  21. package/dist/{chunk-R5OZHLAD.js → chunk-4PVPM2WC.js} +1 -1
  22. package/dist/{chunk-O45IQUWS.js → chunk-5NBZZZKH.js} +2 -2
  23. package/dist/{chunk-S3SKODVV.js → chunk-5QTDZQ2H.js} +4 -4
  24. package/dist/{chunk-LLYP77OL.js → chunk-65XR7JU6.js} +11 -5
  25. package/dist/{chunk-X2CAT5MN.js → chunk-67D4I5AE.js} +1 -1
  26. package/dist/{chunk-EHCGLMPC.js → chunk-6EQZSMIZ.js} +1 -1
  27. package/dist/{chunk-RZKUB4JQ.js → chunk-6VENJOPG.js} +2 -2
  28. package/dist/{chunk-4GC7D5GD.js → chunk-7DSZOBSQ.js} +2 -2
  29. package/dist/{chunk-VIGJQU6V.js → chunk-7GNSB22P.js} +3 -3
  30. package/dist/{chunk-LMHXLYUV.js → chunk-7UJ2PIXJ.js} +2 -2
  31. package/dist/{chunk-NUINUAXO.js → chunk-7V277COF.js} +2 -2
  32. package/dist/{chunk-4RNCKCDV.js → chunk-AP2N4R6D.js} +1 -1
  33. package/dist/{chunk-NX6SIEN6.js → chunk-AXISFTHX.js} +2 -2
  34. package/dist/{chunk-JDELTTHV.js → chunk-BBYQMNGK.js} +1 -1
  35. package/dist/{chunk-OONL25NZ.js → chunk-BJK4SGWG.js} +2 -2
  36. package/dist/{chunk-4WMYJM36.js → chunk-BKBC43KV.js} +1 -1
  37. package/dist/{chunk-OA3CLTYY.js → chunk-BQOFXJSK.js} +3 -3
  38. package/dist/{chunk-OC2RYYTW.js → chunk-BSVZAXLI.js} +11 -8
  39. package/dist/{chunk-O3Z7JWR7.js → chunk-CL3DUJRJ.js} +7 -4
  40. package/dist/{chunk-WHASPTF3.js → chunk-DL2BACWC.js} +12 -9
  41. package/dist/{chunk-2NAUMCWE.js → chunk-DNV6JZLZ.js} +1 -1
  42. package/dist/{chunk-GQFC44YI.js → chunk-EFCCO74P.js} +8 -5
  43. package/dist/{chunk-EF5QCTEQ.js → chunk-EFDAVLKN.js} +1 -1
  44. package/dist/{chunk-WFIMX3HG.js → chunk-EIR2TG5I.js} +1 -1
  45. package/dist/{chunk-XGUSWFDD.js → chunk-EN3ICYTL.js} +9 -9
  46. package/dist/{chunk-Y2KDIPCT.js → chunk-F3BVYYRX.js} +5 -5
  47. package/dist/{chunk-ZMMDLKR3.js → chunk-FGQFNIRI.js} +3 -3
  48. package/dist/{chunk-DNGLD7VN.js → chunk-FIJTBRZ5.js} +1 -1
  49. package/dist/{chunk-AMWWPUSK.js → chunk-H3O7QBOQ.js} +1 -1
  50. package/dist/{chunk-KZ4AECAK.js → chunk-H62LRJJP.js} +13 -16
  51. package/dist/{chunk-YIVJ3JTW.js → chunk-H7Z4BWRI.js} +2 -2
  52. package/dist/{chunk-I44FSUBC.js → chunk-HA5FIXGQ.js} +1 -1
  53. package/dist/{chunk-NWW4246M.js → chunk-HEDK5J34.js} +1 -1
  54. package/dist/{chunk-M4CTE7EH.js → chunk-HF6HORZZ.js} +2 -2
  55. package/dist/{chunk-EGCAA6KI.js → chunk-HFBC2TOG.js} +2 -2
  56. package/dist/{chunk-DO4WVWW7.js → chunk-IFXD4DH5.js} +1 -1
  57. package/dist/{chunk-ATTHVKNE.js → chunk-JN3G4Y4L.js} +4 -4
  58. package/dist/{chunk-ZQGJKPPY.js → chunk-JSKZXF5J.js} +31 -6
  59. package/dist/{chunk-W26HCKWX.js → chunk-JYUJQHPR.js} +3 -3
  60. package/dist/{chunk-HLNTWWAZ.js → chunk-KA33M67F.js} +2 -2
  61. package/dist/{chunk-T45NOW43.js → chunk-L43UD7PK.js} +1 -1
  62. package/dist/{chunk-ESXH27JB.js → chunk-LOAFGJWC.js} +2 -2
  63. package/dist/{chunk-DT57EZQB.js → chunk-LR4TA74O.js} +15 -15
  64. package/dist/{chunk-MJ5J57UJ.js → chunk-M36DF445.js} +1 -1
  65. package/dist/{chunk-MHQXDTJB.js → chunk-NC4FHDIP.js} +1 -1
  66. package/dist/{chunk-NIOWKTIF.js → chunk-NT2AI5IE.js} +1 -1
  67. package/dist/{chunk-5D5P37FY.js → chunk-NZATVUV2.js} +1 -1
  68. package/dist/{chunk-LYTHR3HC.js → chunk-PFWTQ43U.js} +1 -1
  69. package/dist/{chunk-HGZ6R6ST.js → chunk-QV5WI73T.js} +19 -6
  70. package/dist/{chunk-I5ZA45YL.js → chunk-QWGJS6V6.js} +4 -4
  71. package/dist/{chunk-YCXELHKG.js → chunk-REGPK5NG.js} +1 -1
  72. package/dist/{chunk-NUO56TF7.js → chunk-S5HVHCAK.js} +2 -2
  73. package/dist/{chunk-SXE7H3VK.js → chunk-SLAOS6JN.js} +1 -1
  74. package/dist/{chunk-NXRJ7Z4G.js → chunk-SW75SNDB.js} +1 -1
  75. package/dist/{chunk-JK5TPJHH.js → chunk-SXTHM67U.js} +1 -1
  76. package/dist/{chunk-FJAWIVSD.js → chunk-TRGHIMCR.js} +4 -4
  77. package/dist/{chunk-BMPB7XJH.js → chunk-TRQX5AIZ.js} +4 -4
  78. package/dist/{chunk-JEI7I3EH.js → chunk-TXUUUO5R.js} +2 -2
  79. package/dist/{chunk-ZNQD65DN.js → chunk-TZZMVXFM.js} +4 -4
  80. package/dist/{chunk-JURAGCGR.js → chunk-UF3NB27E.js} +8 -8
  81. package/dist/{chunk-XZOBOKL6.js → chunk-ULJVEN67.js} +3 -3
  82. package/dist/{chunk-UXMCHRGA.js → chunk-ULQOJ3WO.js} +2 -2
  83. package/dist/{chunk-B2JLKTBJ.js → chunk-VC25NYHW.js} +1 -1
  84. package/dist/{chunk-BFXQ3IOS.js → chunk-VMILIALE.js} +18 -15
  85. package/dist/chunk-VUADJZRV.js +212 -0
  86. package/dist/{chunk-ADK2TYO4.js → chunk-WHV4YUQB.js} +1 -1
  87. package/dist/{chunk-OTLXV4RO.js → chunk-WP5EWNGJ.js} +4 -4
  88. package/dist/{chunk-RK3QBYXO.js → chunk-X2EEOO6Q.js} +5 -5
  89. package/dist/{chunk-AQXCXWAZ.js → chunk-XQEMI2MI.js} +1 -1
  90. package/dist/{chunk-OWP537VU.js → chunk-XTTHH5MF.js} +1 -1
  91. package/dist/{chunk-2BDD6OHG.js → chunk-XUNTHJIE.js} +7 -0
  92. package/dist/{chunk-BZ6HFTHU.js → chunk-YGTC5UP5.js} +1 -1
  93. package/dist/{chunk-YGAHGTVZ.js → chunk-YIOKUA23.js} +2 -2
  94. package/dist/{chunk-4DTL7OKD.js → chunk-YTC6ST5T.js} +5 -5
  95. package/dist/config/index.js +4 -4
  96. package/dist/containers/client.js +5 -5
  97. package/dist/containers/exec.js +5 -5
  98. package/dist/containers/lifecycle.js +29 -29
  99. package/dist/containers/setup.js +7 -7
  100. package/dist/db/agents.js +5 -5
  101. package/dist/db/api_keys.js +4 -4
  102. package/dist/db/audit.js +3 -3
  103. package/dist/db/batch.js +9 -9
  104. package/dist/db/client.js +2 -2
  105. package/dist/db/credentials.js +3 -3
  106. package/dist/db/drizzle.js +3 -3
  107. package/dist/db/environments.js +5 -5
  108. package/dist/db/events.js +4 -4
  109. package/dist/db/files.js +4 -4
  110. package/dist/db/memory.js +4 -4
  111. package/dist/db/migrations.js +1 -1
  112. package/dist/db/proxy.js +4 -4
  113. package/dist/db/session-resources.js +4 -4
  114. package/dist/db/sessions.js +6 -6
  115. package/dist/db/sync.js +4 -4
  116. package/dist/db/tenants.js +3 -3
  117. package/dist/db/traces.js +4 -4
  118. package/dist/db/upstream_keys.js +3 -3
  119. package/dist/db/vaults.js +5 -5
  120. package/dist/handlers/agents.js +44 -44
  121. package/dist/handlers/api_keys.js +45 -45
  122. package/dist/handlers/audit.js +45 -45
  123. package/dist/handlers/batch.js +45 -45
  124. package/dist/handlers/credentials.js +45 -45
  125. package/dist/handlers/environments.js +45 -45
  126. package/dist/handlers/events.js +48 -48
  127. package/dist/handlers/files.js +45 -45
  128. package/dist/handlers/index.js +80 -80
  129. package/dist/handlers/license.js +44 -44
  130. package/dist/handlers/memory.js +45 -45
  131. package/dist/handlers/metrics.js +44 -44
  132. package/dist/handlers/models.js +45 -45
  133. package/dist/handlers/providers.js +44 -44
  134. package/dist/handlers/resources.js +44 -44
  135. package/dist/handlers/sessions.js +47 -47
  136. package/dist/handlers/settings.js +44 -44
  137. package/dist/handlers/skills-write.js +44 -44
  138. package/dist/handlers/skills.js +45 -45
  139. package/dist/handlers/stream.js +44 -44
  140. package/dist/handlers/tenants.js +45 -45
  141. package/dist/handlers/threads.js +44 -44
  142. package/dist/handlers/traces.js +45 -45
  143. package/dist/handlers/upstream_keys.js +47 -47
  144. package/dist/handlers/vaults.js +44 -44
  145. package/dist/handlers/whoami.js +44 -44
  146. package/dist/http.js +43 -43
  147. package/dist/index.js +47 -47
  148. package/dist/init.js +40 -40
  149. package/dist/lib/model-registry.js +5 -5
  150. package/dist/lib/skills-cache.js +5 -5
  151. package/dist/observability/otlp.js +11 -11
  152. package/dist/observability/redactor.js +7 -7
  153. package/dist/providers/fly.js +4 -4
  154. package/dist/providers/modal.js +4 -4
  155. package/dist/providers/registry.js +1 -1
  156. package/dist/providers/resolve-secrets.js +6 -6
  157. package/dist/providers/sprites.js +6 -6
  158. package/dist/providers/upstream-keys.js +10 -10
  159. package/dist/providers/vercel.js +4 -4
  160. package/dist/proxy/forward.js +5 -5
  161. package/dist/queue/index.js +5 -5
  162. package/dist/sessions/bus.js +9 -9
  163. package/dist/sessions/driver.js +33 -33
  164. package/dist/sessions/grader.js +4 -4
  165. package/dist/sessions/secrets.js +7 -7
  166. package/dist/sessions/sweeper.js +30 -30
  167. package/dist/sessions/threads.js +33 -33
  168. package/dist/shutdown.js +31 -31
  169. package/dist/sync/anthropic.js +9 -9
  170. package/dist/sync/container-file-sync.js +5 -5
  171. package/dist/sync/file-sync.js +16 -16
  172. package/package.json +1 -1
  173. package/dist/chunk-AE5JQORN.js +0 -131
  174. /package/dist/{chunk-QUJNG4RA.js → chunk-C6JEPQ7T.js} +0 -0
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  listEntries
3
- } from "./chunk-VIGJQU6V.js";
3
+ } from "./chunk-7GNSB22P.js";
4
4
  import {
5
5
  getConfig
6
- } from "./chunk-EF5QCTEQ.js";
6
+ } from "./chunk-EFDAVLKN.js";
7
7
 
8
8
  // src/observability/redactor.ts
9
9
  var REDACTED = "[REDACTED]";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-EF5QCTEQ.js";
3
+ } from "./chunk-EFDAVLKN.js";
4
4
 
5
5
  // src/backends/opencode/auth.ts
6
6
  function buildOpencodeAuthEnv() {
@@ -2,10 +2,10 @@ import {
2
2
  reportUpstreamFailure,
3
3
  reportUpstreamSuccess,
4
4
  resolveAnthropicKey
5
- } from "./chunk-ATTHVKNE.js";
5
+ } from "./chunk-JN3G4Y4L.js";
6
6
  import {
7
7
  resolveRemoteSessionId
8
- } from "./chunk-YGAHGTVZ.js";
8
+ } from "./chunk-YIOKUA23.js";
9
9
  import {
10
10
  assertResourceTenant
11
11
  } from "./chunk-23UKWXJH.js";
@@ -20,45 +20,45 @@ import {
20
20
  listMemoryStores,
21
21
  searchMemories,
22
22
  updateMemory
23
- } from "./chunk-NUINUAXO.js";
23
+ } from "./chunk-7V277COF.js";
24
24
  import {
25
25
  jsonOk,
26
26
  routeWrap
27
- } from "./chunk-ESXH27JB.js";
27
+ } from "./chunk-LOAFGJWC.js";
28
28
  import {
29
29
  forwardToAnthropic
30
- } from "./chunk-T45NOW43.js";
30
+ } from "./chunk-L43UD7PK.js";
31
31
  import {
32
32
  enqueueTurn
33
- } from "./chunk-AQXCXWAZ.js";
33
+ } from "./chunk-XQEMI2MI.js";
34
34
  import {
35
35
  runTurn,
36
36
  writePermissionResponse
37
- } from "./chunk-KZ4AECAK.js";
37
+ } from "./chunk-H62LRJJP.js";
38
38
  import {
39
39
  getProxiedTenantId,
40
40
  isProxied
41
- } from "./chunk-NIOWKTIF.js";
41
+ } from "./chunk-NT2AI5IE.js";
42
42
  import {
43
43
  getActor
44
44
  } from "./chunk-LAWTTG2E.js";
45
45
  import {
46
46
  appendEvent
47
- } from "./chunk-BMPB7XJH.js";
47
+ } from "./chunk-TRQX5AIZ.js";
48
48
  import {
49
49
  bumpSessionStats,
50
50
  getSession,
51
51
  getSessionRow,
52
52
  setOutcomeCriteria,
53
53
  updateSessionMutable
54
- } from "./chunk-I5ZA45YL.js";
54
+ } from "./chunk-QWGJS6V6.js";
55
55
  import {
56
56
  listEvents,
57
57
  rowToManagedEvent
58
- } from "./chunk-O45IQUWS.js";
58
+ } from "./chunk-5NBZZZKH.js";
59
59
  import {
60
60
  getAgent
61
- } from "./chunk-JEI7I3EH.js";
61
+ } from "./chunk-TXUUUO5R.js";
62
62
  import {
63
63
  init_clock,
64
64
  nowMs
@@ -66,7 +66,7 @@ import {
66
66
  import {
67
67
  getDb,
68
68
  init_client
69
- } from "./chunk-5GZEX4HV.js";
69
+ } from "./chunk-4C7XJI2V.js";
70
70
  import {
71
71
  badRequest,
72
72
  notFound
@@ -633,9 +633,12 @@ function handleListEvents(request, sessionId) {
633
633
  const order = url.searchParams.get("order") === "desc" ? "desc" : "asc";
634
634
  const afterSeq = Number(url.searchParams.get("after_seq") ?? url.searchParams.get("page") ?? "0");
635
635
  const rows = listEvents(sessionId, { limit, order, afterSeq });
636
+ const data = rows.map(rowToManagedEvent);
636
637
  return jsonOk({
637
- data: rows.map(rowToManagedEvent),
638
- next_page: rows.length > 0 ? String(rows[rows.length - 1].seq) : null
638
+ data,
639
+ has_more: rows.length === limit,
640
+ first_id: data.length > 0 ? data[0].id : null,
641
+ last_id: data.length > 0 ? data[data.length - 1].id : null
639
642
  });
640
643
  });
641
644
  }
@@ -0,0 +1,212 @@
1
+ import {
2
+ loadVaultForCaller
3
+ } from "./chunk-65XR7JU6.js";
4
+ import {
5
+ jsonOk,
6
+ routeWrap
7
+ } from "./chunk-LOAFGJWC.js";
8
+ import {
9
+ createCredential,
10
+ deleteCredential,
11
+ getCredential,
12
+ listCredentials,
13
+ updateCredential
14
+ } from "./chunk-JSKZXF5J.js";
15
+ import {
16
+ badRequest,
17
+ conflict,
18
+ notFound
19
+ } from "./chunk-EZYKRG4W.js";
20
+
21
+ // src/handlers/credentials.ts
22
+ import { z } from "zod";
23
+ var TokenEndpointAuthSchema = z.object({
24
+ type: z.string().min(1),
25
+ client_secret: z.string().min(1)
26
+ });
27
+ var OAuthRefreshSchema = z.object({
28
+ token_endpoint: z.string().url(),
29
+ client_id: z.string().min(1),
30
+ scope: z.string().optional(),
31
+ refresh_token: z.string().min(1),
32
+ token_endpoint_auth: TokenEndpointAuthSchema.optional()
33
+ });
34
+ var StaticBearerAuthSchema = z.object({
35
+ type: z.literal("static_bearer"),
36
+ mcp_server_url: z.string().url().optional(),
37
+ token: z.string().min(1)
38
+ });
39
+ var McpOauthAuthSchema = z.object({
40
+ type: z.literal("mcp_oauth"),
41
+ mcp_server_url: z.string().url().optional(),
42
+ access_token: z.string().min(1),
43
+ expires_at: z.string().optional(),
44
+ refresh: OAuthRefreshSchema.optional()
45
+ });
46
+ var CreateCredentialSchema = z.object({
47
+ display_name: z.string().min(1).max(200),
48
+ auth: z.discriminatedUnion("type", [StaticBearerAuthSchema, McpOauthAuthSchema]),
49
+ metadata: z.record(z.string()).optional()
50
+ });
51
+ var UpdateStaticBearerAuthSchema = z.object({
52
+ type: z.literal("static_bearer").optional(),
53
+ token: z.string().min(1).optional(),
54
+ mcp_server_url: z.string().url().nullish()
55
+ });
56
+ var UpdateMcpOauthAuthSchema = z.object({
57
+ type: z.literal("mcp_oauth").optional(),
58
+ access_token: z.string().min(1).optional(),
59
+ expires_at: z.string().nullish(),
60
+ refresh: OAuthRefreshSchema.optional()
61
+ });
62
+ var UpdateAuthSchema = z.object({
63
+ type: z.enum(["static_bearer", "mcp_oauth"]).optional(),
64
+ token: z.string().min(1).optional(),
65
+ mcp_server_url: z.string().url().nullish(),
66
+ access_token: z.string().min(1).optional(),
67
+ expires_at: z.string().nullish(),
68
+ refresh: OAuthRefreshSchema.optional()
69
+ }).optional();
70
+ var UpdateCredentialSchema = z.object({
71
+ display_name: z.string().min(1).max(200).optional(),
72
+ auth: UpdateAuthSchema
73
+ });
74
+ function handleCreateCredential(request, vaultId) {
75
+ return routeWrap(request, async ({ auth }) => {
76
+ loadVaultForCaller(auth, vaultId);
77
+ const body = await request.json();
78
+ const parsed = CreateCredentialSchema.safeParse(body);
79
+ if (!parsed.success) throw badRequest(parsed.error.message);
80
+ const { auth: authData } = parsed.data;
81
+ try {
82
+ if (authData.type === "mcp_oauth") {
83
+ const refreshConfig = authData.refresh ? {
84
+ token_endpoint: authData.refresh.token_endpoint,
85
+ client_id: authData.refresh.client_id,
86
+ scope: authData.refresh.scope,
87
+ refresh_token: authData.refresh.refresh_token,
88
+ token_endpoint_auth: authData.refresh.token_endpoint_auth
89
+ } : null;
90
+ const cred2 = createCredential({
91
+ vault_id: vaultId,
92
+ display_name: parsed.data.display_name,
93
+ auth_type: "mcp_oauth",
94
+ token: authData.access_token,
95
+ mcp_server_url: authData.mcp_server_url ?? null,
96
+ expires_at: authData.expires_at ?? null,
97
+ refresh_config: refreshConfig
98
+ });
99
+ return jsonOk(cred2, 201);
100
+ }
101
+ const cred = createCredential({
102
+ vault_id: vaultId,
103
+ display_name: parsed.data.display_name,
104
+ auth_type: "static_bearer",
105
+ token: authData.token,
106
+ mcp_server_url: authData.mcp_server_url ?? null
107
+ });
108
+ return jsonOk(cred, 201);
109
+ } catch (err) {
110
+ const msg = err instanceof Error ? err.message : String(err);
111
+ if (msg.includes("UNIQUE constraint failed") || msg.includes("SQLITE_CONSTRAINT")) {
112
+ throw conflict(
113
+ `Credential "${parsed.data.display_name}" already exists in this vault`
114
+ );
115
+ }
116
+ throw err;
117
+ }
118
+ });
119
+ }
120
+ function handleListCredentials(request, vaultId) {
121
+ return routeWrap(request, async ({ auth, request: req }) => {
122
+ loadVaultForCaller(auth, vaultId);
123
+ const url = new URL(req.url);
124
+ const requestedLimit = Number(url.searchParams.get("limit") || "100");
125
+ const data = listCredentials(vaultId);
126
+ return jsonOk({
127
+ data,
128
+ has_more: data.length === requestedLimit,
129
+ first_id: data.length > 0 ? data[0].id : null,
130
+ last_id: data.length > 0 ? data[data.length - 1].id : null
131
+ });
132
+ });
133
+ }
134
+ function handleGetCredential(request, vaultId, credentialId) {
135
+ return routeWrap(request, async ({ auth }) => {
136
+ loadVaultForCaller(auth, vaultId);
137
+ const cred = getCredential(credentialId);
138
+ if (!cred || cred.vault_id !== vaultId) {
139
+ throw notFound(`credential not found: ${credentialId}`);
140
+ }
141
+ return jsonOk(cred);
142
+ });
143
+ }
144
+ function handleUpdateCredential(request, vaultId, credentialId) {
145
+ return routeWrap(request, async ({ auth }) => {
146
+ loadVaultForCaller(auth, vaultId);
147
+ const existing = getCredential(credentialId);
148
+ if (!existing || existing.vault_id !== vaultId) {
149
+ throw notFound(`credential not found: ${credentialId}`);
150
+ }
151
+ const body = await request.json();
152
+ const parsed = UpdateCredentialSchema.safeParse(body);
153
+ if (!parsed.success) throw badRequest(parsed.error.message);
154
+ try {
155
+ const authData = parsed.data.auth;
156
+ const isMcpOauth = existing.auth.type === "mcp_oauth" || authData?.type === "mcp_oauth";
157
+ if (isMcpOauth && authData) {
158
+ const refreshConfig = authData.refresh ? {
159
+ token_endpoint: authData.refresh.token_endpoint,
160
+ client_id: authData.refresh.client_id,
161
+ scope: authData.refresh.scope,
162
+ refresh_token: authData.refresh.refresh_token,
163
+ token_endpoint_auth: authData.refresh.token_endpoint_auth
164
+ } : void 0;
165
+ const updated2 = updateCredential(credentialId, {
166
+ display_name: parsed.data.display_name,
167
+ auth_type: authData.type,
168
+ token: authData.access_token,
169
+ expires_at: authData.expires_at,
170
+ refresh_config: refreshConfig
171
+ });
172
+ if (!updated2) throw notFound(`credential not found: ${credentialId}`);
173
+ return jsonOk(updated2);
174
+ }
175
+ const updated = updateCredential(credentialId, {
176
+ display_name: parsed.data.display_name,
177
+ auth_type: authData?.type,
178
+ token: authData?.token,
179
+ mcp_server_url: authData?.mcp_server_url
180
+ });
181
+ if (!updated) throw notFound(`credential not found: ${credentialId}`);
182
+ return jsonOk(updated);
183
+ } catch (err) {
184
+ if (err instanceof Error && (err.message.includes("UNIQUE constraint failed") || err.message.includes("SQLITE_CONSTRAINT"))) {
185
+ throw conflict(
186
+ `Credential "${parsed.data.display_name}" already exists in this vault`
187
+ );
188
+ }
189
+ throw err;
190
+ }
191
+ });
192
+ }
193
+ function handleDeleteCredential(request, vaultId, credentialId) {
194
+ return routeWrap(request, async ({ auth }) => {
195
+ loadVaultForCaller(auth, vaultId);
196
+ const existing = getCredential(credentialId);
197
+ if (!existing || existing.vault_id !== vaultId) {
198
+ throw notFound(`credential not found: ${credentialId}`);
199
+ }
200
+ const deleted = deleteCredential(credentialId);
201
+ if (!deleted) throw notFound(`credential not found: ${credentialId}`);
202
+ return jsonOk({ id: credentialId, type: "vault_credential_deleted" });
203
+ });
204
+ }
205
+
206
+ export {
207
+ handleCreateCredential,
208
+ handleListCredentials,
209
+ handleGetCredential,
210
+ handleUpdateCredential,
211
+ handleDeleteCredential
212
+ };
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  getDrizzle,
7
7
  init_drizzle
8
- } from "./chunk-SXE7H3VK.js";
8
+ } from "./chunk-SLAOS6JN.js";
9
9
  import {
10
10
  schema_exports
11
11
  } from "./chunk-LHHBOQUR.js";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  listTraces
3
- } from "./chunk-JK5TPJHH.js";
3
+ } from "./chunk-SXTHM67U.js";
4
4
  import {
5
5
  jsonOk,
6
6
  routeWrap
7
- } from "./chunk-ESXH27JB.js";
7
+ } from "./chunk-LOAFGJWC.js";
8
8
  import {
9
9
  exportTrace
10
- } from "./chunk-Y2KDIPCT.js";
10
+ } from "./chunk-F3BVYYRX.js";
11
11
  import {
12
12
  listEventsByTrace,
13
13
  rowToManagedEvent
14
- } from "./chunk-O45IQUWS.js";
14
+ } from "./chunk-5NBZZZKH.js";
15
15
  import {
16
16
  badRequest,
17
17
  notFound
@@ -4,14 +4,14 @@ import {
4
4
  import {
5
5
  jsonOk,
6
6
  routeWrap
7
- } from "./chunk-ESXH27JB.js";
7
+ } from "./chunk-LOAFGJWC.js";
8
8
  import {
9
9
  getProxiedTenantId
10
- } from "./chunk-NIOWKTIF.js";
10
+ } from "./chunk-NT2AI5IE.js";
11
11
  import {
12
12
  getSession,
13
13
  updateSessionResources
14
- } from "./chunk-I5ZA45YL.js";
14
+ } from "./chunk-QWGJS6V6.js";
15
15
  import {
16
16
  countResources,
17
17
  createResource,
@@ -19,11 +19,11 @@ import {
19
19
  getResource,
20
20
  init_session_resources,
21
21
  listResources
22
- } from "./chunk-R5OZHLAD.js";
22
+ } from "./chunk-4PVPM2WC.js";
23
23
  import {
24
24
  getDb,
25
25
  init_client
26
- } from "./chunk-5GZEX4HV.js";
26
+ } from "./chunk-4C7XJI2V.js";
27
27
  import {
28
28
  badRequest,
29
29
  notFound
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-EF5QCTEQ.js";
3
+ } from "./chunk-EFDAVLKN.js";
4
4
  import {
5
5
  serverBusy
6
6
  } from "./chunk-EZYKRG4W.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-EF5QCTEQ.js";
3
+ } from "./chunk-EFDAVLKN.js";
4
4
 
5
5
  // src/backends/factory/auth.ts
6
6
  function buildFactoryAuthEnv() {
@@ -444,6 +444,13 @@ function runMigrations(db) {
444
444
  UNIQUE(vault_id, display_name)
445
445
  )
446
446
  `);
447
+ const credCols = db.prepare(`PRAGMA table_info(vault_credentials)`).all();
448
+ if (!credCols.some((c) => c.name === "expires_at")) {
449
+ db.exec(`ALTER TABLE vault_credentials ADD COLUMN expires_at TEXT`);
450
+ }
451
+ if (!credCols.some((c) => c.name === "refresh_config_encrypted")) {
452
+ db.exec(`ALTER TABLE vault_credentials ADD COLUMN refresh_config_encrypted TEXT`);
453
+ }
447
454
  const sessCols3 = db.prepare(`PRAGMA table_info(sessions)`).all();
448
455
  if (sessCols3.some((c) => c.name === "sprite_name")) {
449
456
  db.exec(`ALTER TABLE sessions RENAME COLUMN sprite_name TO sandbox_name`);
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  getDb,
15
15
  init_client
16
- } from "./chunk-5GZEX4HV.js";
16
+ } from "./chunk-4C7XJI2V.js";
17
17
 
18
18
  // src/db/upstream_keys.ts
19
19
  init_client();
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getDrizzle,
3
3
  init_drizzle
4
- } from "./chunk-SXE7H3VK.js";
4
+ } from "./chunk-SLAOS6JN.js";
5
5
  import {
6
6
  schema_exports
7
7
  } from "./chunk-LHHBOQUR.js";
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  getDb,
14
14
  init_client
15
- } from "./chunk-5GZEX4HV.js";
15
+ } from "./chunk-4C7XJI2V.js";
16
16
 
17
17
  // src/db/sync.ts
18
18
  init_drizzle();
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-23UKWXJH.js";
7
7
  import {
8
8
  recordAudit
9
- } from "./chunk-MHQXDTJB.js";
9
+ } from "./chunk-NC4FHDIP.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-ESXH27JB.js";
18
+ } from "./chunk-LOAFGJWC.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-ADK2TYO4.js";
26
+ } from "./chunk-WHV4YUQB.js";
27
27
  import {
28
28
  listSessionsByApiKey
29
- } from "./chunk-I5ZA45YL.js";
29
+ } from "./chunk-QWGJS6V6.js";
30
30
  import {
31
31
  getDb,
32
32
  init_client
33
- } from "./chunk-5GZEX4HV.js";
33
+ } from "./chunk-4C7XJI2V.js";
34
34
  import {
35
35
  badRequest,
36
36
  forbidden,
@@ -5,12 +5,12 @@ import {
5
5
  readSetting,
6
6
  writeSetting,
7
7
  writeTokenSetting
8
- } from "../chunk-EF5QCTEQ.js";
9
- import "../chunk-SXE7H3VK.js";
8
+ } from "../chunk-EFDAVLKN.js";
9
+ import "../chunk-SLAOS6JN.js";
10
10
  import "../chunk-LHHBOQUR.js";
11
11
  import "../chunk-HFDLUBWN.js";
12
- import "../chunk-5GZEX4HV.js";
13
- import "../chunk-2BDD6OHG.js";
12
+ import "../chunk-4C7XJI2V.js";
13
+ import "../chunk-XUNTHJIE.js";
14
14
  import "../chunk-2ESYSVXG.js";
15
15
  export {
16
16
  getConfig,
@@ -7,13 +7,13 @@ import {
7
7
  killExecSession,
8
8
  listSprites,
9
9
  restoreCheckpoint
10
- } from "../chunk-YCXELHKG.js";
11
- import "../chunk-EF5QCTEQ.js";
12
- import "../chunk-SXE7H3VK.js";
10
+ } from "../chunk-REGPK5NG.js";
11
+ import "../chunk-EFDAVLKN.js";
12
+ import "../chunk-SLAOS6JN.js";
13
13
  import "../chunk-LHHBOQUR.js";
14
14
  import "../chunk-HFDLUBWN.js";
15
- import "../chunk-5GZEX4HV.js";
16
- import "../chunk-2BDD6OHG.js";
15
+ import "../chunk-4C7XJI2V.js";
16
+ import "../chunk-XUNTHJIE.js";
17
17
  import "../chunk-EZYKRG4W.js";
18
18
  import "../chunk-2ESYSVXG.js";
19
19
  export {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  startExec
3
- } from "../chunk-4RNCKCDV.js";
4
- import "../chunk-EF5QCTEQ.js";
5
- import "../chunk-SXE7H3VK.js";
3
+ } from "../chunk-AP2N4R6D.js";
4
+ import "../chunk-EFDAVLKN.js";
5
+ import "../chunk-SLAOS6JN.js";
6
6
  import "../chunk-LHHBOQUR.js";
7
7
  import "../chunk-HFDLUBWN.js";
8
- import "../chunk-5GZEX4HV.js";
9
- import "../chunk-2BDD6OHG.js";
8
+ import "../chunk-4C7XJI2V.js";
9
+ import "../chunk-XUNTHJIE.js";
10
10
  import "../chunk-EZYKRG4W.js";
11
11
  import "../chunk-2ESYSVXG.js";
12
12
  export {
@@ -6,56 +6,56 @@ import {
6
6
  reconcileOrphanSandboxes,
7
7
  releaseSession,
8
8
  wrapProviderWithSecrets
9
- } from "../chunk-XGUSWFDD.js";
10
- import "../chunk-DO4WVWW7.js";
9
+ } from "../chunk-EN3ICYTL.js";
10
+ import "../chunk-IFXD4DH5.js";
11
11
  import "../chunk-RMZRSYIJ.js";
12
12
  import "../chunk-5ZFOKZGR.js";
13
- import "../chunk-BMPB7XJH.js";
14
- import "../chunk-VIGJQU6V.js";
15
- import "../chunk-I5ZA45YL.js";
16
- import "../chunk-R5OZHLAD.js";
13
+ import "../chunk-TRQX5AIZ.js";
14
+ import "../chunk-7GNSB22P.js";
15
+ import "../chunk-QWGJS6V6.js";
16
+ import "../chunk-4PVPM2WC.js";
17
17
  import "../chunk-AIBH32FN.js";
18
18
  import "../chunk-YPXI7Q2M.js";
19
- import "../chunk-O45IQUWS.js";
20
- import "../chunk-YCXELHKG.js";
19
+ import "../chunk-5NBZZZKH.js";
20
+ import "../chunk-REGPK5NG.js";
21
21
  import "../chunk-EFOIR7R3.js";
22
- import "../chunk-QUJNG4RA.js";
23
- import "../chunk-NUO56TF7.js";
24
- import "../chunk-JEI7I3EH.js";
25
- import "../chunk-JDELTTHV.js";
26
- import "../chunk-KOGG7CSN.js";
27
- import "../chunk-I44FSUBC.js";
22
+ import "../chunk-C6JEPQ7T.js";
23
+ import "../chunk-S5HVHCAK.js";
24
+ import "../chunk-TXUUUO5R.js";
25
+ import "../chunk-BBYQMNGK.js";
26
+ import "../chunk-4B7PQTTS.js";
27
+ import "../chunk-HA5FIXGQ.js";
28
28
  import "../chunk-T5VRE77P.js";
29
- import "../chunk-TY3HD5I5.js";
29
+ import "../chunk-2DRBKIGQ.js";
30
30
  import "../chunk-QYSDP6V5.js";
31
31
  import "../chunk-B6E6BVNK.js";
32
32
  import "../chunk-JDBXIJKG.js";
33
- import "../chunk-DNGLD7VN.js";
33
+ import "../chunk-FIJTBRZ5.js";
34
34
  import "../chunk-3IV56JJW.js";
35
- import "../chunk-B2JLKTBJ.js";
35
+ import "../chunk-VC25NYHW.js";
36
36
  import "../chunk-Z25I7DRV.js";
37
37
  import "../chunk-P7P2NWZD.js";
38
38
  import "../chunk-ETWGCBIQ.js";
39
39
  import "../chunk-SWIP7JBQ.js";
40
- import "../chunk-EHCGLMPC.js";
40
+ import "../chunk-6EQZSMIZ.js";
41
41
  import "../chunk-JHGJG2Z2.js";
42
- import "../chunk-MJ5J57UJ.js";
42
+ import "../chunk-M36DF445.js";
43
43
  import "../chunk-XG4UIGDH.js";
44
44
  import "../chunk-3W6KEDQE.js";
45
45
  import "../chunk-S3JRZFF5.js";
46
- import "../chunk-X2CAT5MN.js";
47
- import "../chunk-NWW4246M.js";
46
+ import "../chunk-67D4I5AE.js";
47
+ import "../chunk-HEDK5J34.js";
48
48
  import "../chunk-M2LUXIXU.js";
49
49
  import "../chunk-CULYZ3VA.js";
50
50
  import "../chunk-E4FQRMHV.js";
51
- import "../chunk-5D5P37FY.js";
51
+ import "../chunk-NZATVUV2.js";
52
52
  import "../chunk-YSUPRYX2.js";
53
53
  import "../chunk-7TSTCMII.js";
54
54
  import "../chunk-QQDSHL27.js";
55
55
  import "../chunk-IAF6VMPO.js";
56
- import "../chunk-OWP537VU.js";
57
- import "../chunk-RZKUB4JQ.js";
58
- import "../chunk-WFIMX3HG.js";
56
+ import "../chunk-XTTHH5MF.js";
57
+ import "../chunk-6VENJOPG.js";
58
+ import "../chunk-EIR2TG5I.js";
59
59
  import "../chunk-FVBDEOTZ.js";
60
60
  import "../chunk-CY6AWCC6.js";
61
61
  import "../chunk-4FDEJHH7.js";
@@ -66,12 +66,12 @@ import {
66
66
  installClaudeWrapper
67
67
  } from "../chunk-IU457W7Q.js";
68
68
  import "../chunk-F4WUVOLE.js";
69
- import "../chunk-EF5QCTEQ.js";
70
- import "../chunk-SXE7H3VK.js";
69
+ import "../chunk-EFDAVLKN.js";
70
+ import "../chunk-SLAOS6JN.js";
71
71
  import "../chunk-LHHBOQUR.js";
72
72
  import "../chunk-HFDLUBWN.js";
73
- import "../chunk-5GZEX4HV.js";
74
- import "../chunk-2BDD6OHG.js";
73
+ import "../chunk-4C7XJI2V.js";
74
+ import "../chunk-XUNTHJIE.js";
75
75
  import "../chunk-EZYKRG4W.js";
76
76
  import "../chunk-XZYIH3AF.js";
77
77
  import "../chunk-2ESYSVXG.js";
@@ -2,19 +2,19 @@ import {
2
2
  SENTINEL_DIR,
3
3
  kickoffEnvironmentSetup,
4
4
  prepareSprite
5
- } from "../chunk-HLNTWWAZ.js";
6
- import "../chunk-QUJNG4RA.js";
7
- import "../chunk-NUO56TF7.js";
8
- import "../chunk-JDELTTHV.js";
5
+ } from "../chunk-KA33M67F.js";
6
+ import "../chunk-C6JEPQ7T.js";
7
+ import "../chunk-S5HVHCAK.js";
8
+ import "../chunk-BBYQMNGK.js";
9
9
  import {
10
10
  CLAUDE_WRAPPER_PATH
11
11
  } from "../chunk-IU457W7Q.js";
12
12
  import "../chunk-F4WUVOLE.js";
13
- import "../chunk-SXE7H3VK.js";
13
+ import "../chunk-SLAOS6JN.js";
14
14
  import "../chunk-LHHBOQUR.js";
15
15
  import "../chunk-HFDLUBWN.js";
16
- import "../chunk-5GZEX4HV.js";
17
- import "../chunk-2BDD6OHG.js";
16
+ import "../chunk-4C7XJI2V.js";
17
+ import "../chunk-XUNTHJIE.js";
18
18
  import "../chunk-2ESYSVXG.js";
19
19
  export {
20
20
  SENTINEL_DIR,