@agentstep/agent-sdk 0.5.28 → 0.5.34

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 (209) hide show
  1. package/dist/auth/middleware.js +8 -8
  2. package/dist/backends/claude/args.js +6 -6
  3. package/dist/backends/claude/index.js +11 -11
  4. package/dist/backends/codex/auth.js +6 -6
  5. package/dist/backends/codex/index.js +10 -10
  6. package/dist/backends/factory/auth.js +6 -6
  7. package/dist/backends/factory/index.js +12 -12
  8. package/dist/backends/gemini/auth.js +6 -6
  9. package/dist/backends/gemini/index.js +13 -13
  10. package/dist/backends/opencode/args.js +1 -1
  11. package/dist/backends/opencode/auth.js +6 -6
  12. package/dist/backends/opencode/index.js +14 -14
  13. package/dist/backends/pi/args.js +1 -1
  14. package/dist/backends/pi/auth.js +6 -6
  15. package/dist/backends/pi/index.js +11 -11
  16. package/dist/backends/registry.js +29 -29
  17. package/dist/{chunk-33QZ6KIY.js → chunk-25E64UIV.js} +5 -5
  18. package/dist/{chunk-PZKWZKRP.js → chunk-2KF2TIEY.js} +5 -5
  19. package/dist/{chunk-CXXL77ER.js → chunk-2R4IT7HG.js} +61 -4
  20. package/dist/{chunk-N627DRI6.js → chunk-3EI7IPMI.js} +3 -3
  21. package/dist/{chunk-Z25QQE5Z.js → chunk-3EWEKBVC.js} +4 -4
  22. package/dist/{chunk-V4DEOZFK.js → chunk-3LYNN5VT.js} +5 -5
  23. package/dist/{chunk-LJNLU5PQ.js → chunk-3NUTTKE5.js} +2 -2
  24. package/dist/{chunk-DI5WC2SQ.js → chunk-4EKHW6VS.js} +2 -2
  25. package/dist/{chunk-MZ6HBYGV.js → chunk-65XY7HRS.js} +7 -7
  26. package/dist/{chunk-KHTLT44I.js → chunk-6CODFATQ.js} +3 -3
  27. package/dist/{chunk-US26CY2Y.js → chunk-6EIONZ7F.js} +2 -2
  28. package/dist/chunk-6NEWWPL4.js +210 -0
  29. package/dist/{chunk-TFTJ734B.js → chunk-6NFK5RJX.js} +2 -2
  30. package/dist/chunk-6SD6MC2B.js +29 -0
  31. package/dist/{chunk-ENFWZ2QM.js → chunk-6U6HEVSN.js} +7 -3
  32. package/dist/{chunk-CXIP6H55.js → chunk-75US4UAE.js} +2 -2
  33. package/dist/{chunk-UB7GS7XT.js → chunk-A3FQHVUG.js} +7 -7
  34. package/dist/{chunk-ZP5QO5BR.js → chunk-ABUNDZCE.js} +1 -1
  35. package/dist/{chunk-QCP37SCU.js → chunk-AD2WPGDN.js} +8 -8
  36. package/dist/{chunk-Q62QJXGO.js → chunk-AGIXZFHQ.js} +1 -1
  37. package/dist/{chunk-NKOGWVP3.js → chunk-AUEKXYNE.js} +4 -4
  38. package/dist/{chunk-SKVAM5H2.js → chunk-B3W3E5CS.js} +1 -1
  39. package/dist/chunk-B5RR422E.js +0 -0
  40. package/dist/{chunk-IWI74DWW.js → chunk-BSAF4YJB.js} +51 -14
  41. package/dist/{chunk-CVYNMYIE.js → chunk-CWB2DQN5.js} +3 -3
  42. package/dist/{chunk-4ENK7S24.js → chunk-CXYMVLYK.js} +4 -0
  43. package/dist/{chunk-MNZB2OWP.js → chunk-CZ4N5FJW.js} +2 -2
  44. package/dist/{chunk-R37QM2U4.js → chunk-DF34ESOO.js} +1 -1
  45. package/dist/{chunk-GKNBECPD.js → chunk-DZKBUOYU.js} +2 -2
  46. package/dist/{chunk-CACVB5PH.js → chunk-FCPZF7KJ.js} +1 -1
  47. package/dist/{chunk-FC3UAHXM.js → chunk-FDLQ3IUB.js} +1 -1
  48. package/dist/{chunk-HVCY7DET.js → chunk-FHOJOLXU.js} +2 -2
  49. package/dist/{chunk-5AV732JY.js → chunk-GABMXDZZ.js} +2 -2
  50. package/dist/{chunk-LSMTQBMW.js → chunk-GBBQD6VY.js} +2 -2
  51. package/dist/{chunk-FDL2JHXO.js → chunk-GCT7A5KR.js} +2 -2
  52. package/dist/{chunk-QBZMVYDV.js → chunk-GFZ2WIVH.js} +4 -4
  53. package/dist/{chunk-ANTKOI3K.js → chunk-HHLVVJGT.js} +2 -2
  54. package/dist/{chunk-Z5XQQN7H.js → chunk-HWWFRSAX.js} +4 -4
  55. package/dist/{chunk-KWG7NGYF.js → chunk-I2RVN7CP.js} +4 -4
  56. package/dist/{chunk-JCIAIJFF.js → chunk-IC2ETYU5.js} +3 -3
  57. package/dist/{chunk-3FLQ7KZP.js → chunk-IMJTHYN3.js} +1 -1
  58. package/dist/{chunk-ISGA4AOC.js → chunk-J6ESQUW6.js} +2 -2
  59. package/dist/{chunk-Y3V4COP7.js → chunk-J7F2OFWQ.js} +5 -5
  60. package/dist/{chunk-3V4BPIBU.js → chunk-JDAOTVWV.js} +2 -2
  61. package/dist/{chunk-A4GJADRQ.js → chunk-JF777FWD.js} +2 -2
  62. package/dist/{chunk-IDQKHWWN.js → chunk-JFHYXFAL.js} +1 -1
  63. package/dist/{chunk-WLCI57J6.js → chunk-JIXRTWYL.js} +4 -4
  64. package/dist/{chunk-WG3N6VUA.js → chunk-JN3DHH7Z.js} +11 -11
  65. package/dist/{chunk-FQQ2R6FA.js → chunk-JNSJKHYX.js} +1 -1
  66. package/dist/{chunk-HPL2MQGY.js → chunk-K3LM6O44.js} +6 -6
  67. package/dist/{chunk-7DPZMROX.js → chunk-K5J4IN2S.js} +2 -2
  68. package/dist/{chunk-TJORQTH6.js → chunk-KGOOCFQY.js} +1 -1
  69. package/dist/{chunk-BYUIOMPX.js → chunk-KYKVHH7I.js} +23 -23
  70. package/dist/{chunk-ZM33GAEB.js → chunk-LKHJLSYG.js} +7 -7
  71. package/dist/{chunk-RKPT6O7I.js → chunk-LR6FK2J7.js} +5 -5
  72. package/dist/{chunk-MNW6D7T4.js → chunk-M72ERPMT.js} +1 -1
  73. package/dist/{chunk-IC5ZTBAW.js → chunk-MUARVVXF.js} +3 -3
  74. package/dist/{chunk-RRP4F6XC.js → chunk-NQ6BN7WH.js} +16 -6
  75. package/dist/{chunk-BRULBMRN.js → chunk-NSUVDKNC.js} +3 -3
  76. package/dist/chunk-OANORRFX.js +276 -0
  77. package/dist/{chunk-IS6CQPAQ.js → chunk-OEFJPZYH.js} +3 -3
  78. package/dist/{chunk-4BJTLMHV.js → chunk-OEYLPPID.js} +17 -17
  79. package/dist/{chunk-G6XFFNCQ.js → chunk-P7V3S2T3.js} +18 -18
  80. package/dist/{chunk-P56WU3UT.js → chunk-PDWLVL34.js} +8 -5
  81. package/dist/{chunk-I2WVMCYN.js → chunk-PWLWDWRL.js} +1 -1
  82. package/dist/{chunk-JTGISCYV.js → chunk-QCGIYXN4.js} +1 -1
  83. package/dist/{chunk-YS3W5AQA.js → chunk-REHIJQUD.js} +9 -9
  84. package/dist/{chunk-2K3UO6TC.js → chunk-RES4BCTF.js} +4 -4
  85. package/dist/{chunk-HDLPEXWS.js → chunk-S5CMAWEC.js} +20 -0
  86. package/dist/{chunk-CBPO2P4I.js → chunk-SAI6LBXW.js} +2 -2
  87. package/dist/{chunk-YMKQJY5F.js → chunk-SIO4LO2M.js} +1 -1
  88. package/dist/{chunk-QSRH4XUG.js → chunk-SUEPFZN2.js} +1 -1
  89. package/dist/{chunk-IITCQTBZ.js → chunk-T2PXAQND.js} +1 -1
  90. package/dist/{chunk-D3LKWVPA.js → chunk-TTDMQ54U.js} +2 -2
  91. package/dist/{chunk-GNXIA5WC.js → chunk-TVV7AE3G.js} +2 -2
  92. package/dist/{chunk-5BA36MSQ.js → chunk-UMXXZ6OX.js} +1 -1
  93. package/dist/{chunk-WHTGWLGJ.js → chunk-UTGP4X74.js} +1 -1
  94. package/dist/{chunk-XMZQW5G5.js → chunk-V5RHOS43.js} +8 -8
  95. package/dist/{chunk-Z2AVP3QL.js → chunk-VB6GGRIA.js} +16 -3
  96. package/dist/{chunk-TV6QMCDS.js → chunk-VQM2MCQR.js} +3 -3
  97. package/dist/{chunk-RSXTLOY3.js → chunk-VY5XWTW7.js} +1 -1
  98. package/dist/{chunk-VVCRJ46V.js → chunk-WEUPM3IN.js} +4 -4
  99. package/dist/{chunk-RZHIYTI3.js → chunk-WK33IBKY.js} +10 -1
  100. package/dist/{chunk-QQGXM2OQ.js → chunk-XLMNSDUJ.js} +1 -1
  101. package/dist/{chunk-MAN6OCOP.js → chunk-XXAO5YYL.js} +3 -3
  102. package/dist/{chunk-AZLZOG5N.js → chunk-XYNEAJDF.js} +1 -1
  103. package/dist/{chunk-GSDVHR43.js → chunk-YJCH35J4.js} +5 -3
  104. package/dist/{chunk-T77N7C3M.js → chunk-YKPRNV6J.js} +2 -2
  105. package/dist/chunk-YOZ6WDP3.js +103 -0
  106. package/dist/{chunk-F5SHFZUA.js → chunk-YTBVILAH.js} +1 -1
  107. package/dist/{chunk-IPTEXVQG.js → chunk-Z5IENUYV.js} +3 -3
  108. package/dist/{chunk-KD5Y4XSU.js → chunk-ZACPJA3G.js} +2 -2
  109. package/dist/{chunk-NOHH2ZH7.js → chunk-ZAUWB5DQ.js} +6 -6
  110. package/dist/{chunk-MQSTE4WH.js → chunk-ZBWKJ42J.js} +3 -3
  111. package/dist/{chunk-GBJ3OT4D.js → chunk-ZC7OR65K.js} +7 -5
  112. package/dist/{chunk-2REGK4VO.js → chunk-ZCCHLDLC.js} +11 -11
  113. package/dist/{chunk-7U62OZSD.js → chunk-ZDDMPGN4.js} +2 -2
  114. package/dist/chunk-ZHEE6UTX.js +108 -0
  115. package/dist/config/index.js +5 -5
  116. package/dist/containers/client.js +6 -6
  117. package/dist/containers/exec.js +6 -6
  118. package/dist/containers/lifecycle.js +41 -41
  119. package/dist/containers/setup.js +9 -9
  120. package/dist/db/agents.js +6 -6
  121. package/dist/db/api_keys.js +5 -5
  122. package/dist/db/audit.js +3 -3
  123. package/dist/db/batch.js +10 -10
  124. package/dist/db/client.js +2 -2
  125. package/dist/db/credentials.js +5 -3
  126. package/dist/db/drizzle.js +4 -4
  127. package/dist/db/environments.js +6 -6
  128. package/dist/db/events.js +5 -5
  129. package/dist/db/files.js +5 -5
  130. package/dist/db/memory.js +5 -5
  131. package/dist/db/migrations.js +1 -1
  132. package/dist/db/proxy.js +5 -5
  133. package/dist/db/schema.js +1 -1
  134. package/dist/db/session-resources.js +5 -5
  135. package/dist/db/sessions.js +8 -8
  136. package/dist/db/skills.js +5 -5
  137. package/dist/db/sync.js +5 -5
  138. package/dist/db/tenants.js +3 -3
  139. package/dist/db/threads.js +7 -7
  140. package/dist/db/traces.js +5 -5
  141. package/dist/db/upstream_keys.js +3 -3
  142. package/dist/db/user-profiles.js +17 -0
  143. package/dist/db/vaults.js +6 -6
  144. package/dist/db/work.js +5 -5
  145. package/dist/dreaming/review.js +11 -11
  146. package/dist/handlers/agents.js +58 -57
  147. package/dist/handlers/api_keys.js +59 -58
  148. package/dist/handlers/audit.js +59 -58
  149. package/dist/handlers/batch.js +59 -58
  150. package/dist/handlers/credentials.js +61 -58
  151. package/dist/handlers/enrollment.js +103 -0
  152. package/dist/handlers/environments.js +59 -58
  153. package/dist/handlers/events.js +62 -61
  154. package/dist/handlers/files.js +59 -58
  155. package/dist/handlers/google-compat/index.js +101 -0
  156. package/dist/handlers/google-compat/interactions.js +100 -0
  157. package/dist/handlers/google-compat/types.js +0 -0
  158. package/dist/handlers/index.js +150 -126
  159. package/dist/handlers/license.js +58 -57
  160. package/dist/handlers/memory.js +60 -59
  161. package/dist/handlers/metrics.js +58 -57
  162. package/dist/handlers/models.js +59 -58
  163. package/dist/handlers/openapi.js +3 -3
  164. package/dist/handlers/providers.js +58 -57
  165. package/dist/handlers/resources.js +58 -57
  166. package/dist/handlers/sessions.js +62 -61
  167. package/dist/handlers/settings.js +58 -57
  168. package/dist/handlers/skills-write.js +59 -58
  169. package/dist/handlers/skills.js +59 -58
  170. package/dist/handlers/stream.js +58 -57
  171. package/dist/handlers/tenants.js +59 -58
  172. package/dist/handlers/threads.js +59 -58
  173. package/dist/handlers/traces.js +59 -58
  174. package/dist/handlers/upstream_keys.js +61 -60
  175. package/dist/handlers/user-profiles.js +107 -0
  176. package/dist/handlers/vaults.js +58 -57
  177. package/dist/handlers/whoami.js +58 -57
  178. package/dist/handlers/work.js +59 -58
  179. package/dist/http.js +57 -56
  180. package/dist/index.js +68 -67
  181. package/dist/init.js +54 -53
  182. package/dist/lib/model-registry.js +6 -6
  183. package/dist/lib/skills-cache.js +6 -6
  184. package/dist/observability/otlp.js +12 -12
  185. package/dist/observability/redactor.js +8 -8
  186. package/dist/openapi/schemas.js +1 -1
  187. package/dist/openapi/spec.js +2 -2
  188. package/dist/providers/fly.js +5 -5
  189. package/dist/providers/modal.js +5 -5
  190. package/dist/providers/registry.js +6 -6
  191. package/dist/providers/resolve-secrets.js +7 -7
  192. package/dist/providers/sprites.js +7 -7
  193. package/dist/providers/upstream-keys.js +12 -12
  194. package/dist/providers/vercel.js +5 -5
  195. package/dist/proxy/forward.js +6 -6
  196. package/dist/queue/index.js +6 -6
  197. package/dist/sessions/bus.js +10 -10
  198. package/dist/sessions/driver.js +47 -46
  199. package/dist/sessions/grader.js +5 -5
  200. package/dist/sessions/secrets.js +9 -8
  201. package/dist/sessions/sweeper.js +42 -42
  202. package/dist/sessions/threads.js +55 -47
  203. package/dist/shutdown.js +43 -43
  204. package/dist/sync/anthropic.js +10 -10
  205. package/dist/sync/container-file-sync.js +6 -6
  206. package/dist/sync/file-sync.js +17 -17
  207. package/dist/workers/runner.js +49 -48
  208. package/package.json +1 -1
  209. package/dist/chunk-6KWJASEO.js +0 -21
@@ -5,6 +5,11 @@ import {
5
5
  childSpan,
6
6
  newTrace
7
7
  } from "./chunk-AU4NAQGA.js";
8
+ import {
9
+ buildErrorPayload,
10
+ classifyError,
11
+ init_errors
12
+ } from "./chunk-H6TQGV4L.js";
8
13
  import {
9
14
  injectMcpAuthHeaders
10
15
  } from "./chunk-DBFPJSOY.js";
@@ -16,29 +21,24 @@ import {
16
21
  } from "./chunk-72BKGVBE.js";
17
22
  import {
18
23
  loadSessionSecrets
19
- } from "./chunk-Z2AVP3QL.js";
20
- import {
21
- buildErrorPayload,
22
- classifyError,
23
- init_errors
24
- } from "./chunk-H6TQGV4L.js";
24
+ } from "./chunk-VB6GGRIA.js";
25
25
  import {
26
26
  isProxied
27
- } from "./chunk-GKNBECPD.js";
27
+ } from "./chunk-DZKBUOYU.js";
28
28
  import {
29
29
  acquireForFirstTurn,
30
30
  installSkills,
31
31
  provisionResources,
32
32
  wrapProviderWithSecrets
33
- } from "./chunk-2REGK4VO.js";
33
+ } from "./chunk-ZCCHLDLC.js";
34
34
  import {
35
35
  BLOCKED_ENV_KEYS,
36
36
  resolveVaultSecrets
37
- } from "./chunk-FQQ2R6FA.js";
37
+ } from "./chunk-JNSJKHYX.js";
38
38
  import {
39
39
  appendEvent,
40
40
  appendEventsBatch
41
- } from "./chunk-2K3UO6TC.js";
41
+ } from "./chunk-RES4BCTF.js";
42
42
  import {
43
43
  bumpSessionStats,
44
44
  getOutcomeCriteria,
@@ -49,43 +49,43 @@ import {
49
49
  setOutcomeCriteria,
50
50
  updateSessionMutable,
51
51
  updateSessionStatus
52
- } from "./chunk-GBJ3OT4D.js";
52
+ } from "./chunk-ZC7OR65K.js";
53
53
  import {
54
54
  listEvents,
55
55
  markUserEventProcessed
56
- } from "./chunk-IS6CQPAQ.js";
56
+ } from "./chunk-OEFJPZYH.js";
57
57
  import {
58
58
  getBySession
59
59
  } from "./chunk-EFOIR7R3.js";
60
60
  import {
61
61
  resolveProvider,
62
62
  resolveProviderName
63
- } from "./chunk-QQGXM2OQ.js";
63
+ } from "./chunk-XLMNSDUJ.js";
64
64
  import {
65
65
  getEnvironment
66
- } from "./chunk-BRULBMRN.js";
66
+ } from "./chunk-NSUVDKNC.js";
67
67
  import {
68
68
  getAgent
69
- } from "./chunk-ENFWZ2QM.js";
69
+ } from "./chunk-6U6HEVSN.js";
70
70
  import {
71
71
  resolveBackend
72
- } from "./chunk-XMZQW5G5.js";
73
- import {
74
- PERMISSION_BRIDGE_PENDING_PATH,
75
- PERMISSION_BRIDGE_REQUEST_PATH,
76
- PERMISSION_BRIDGE_RESPONSE_PATH
77
- } from "./chunk-CY6AWCC6.js";
72
+ } from "./chunk-V5RHOS43.js";
78
73
  import {
79
74
  TOOL_BRIDGE_PENDING_PATH,
80
75
  TOOL_BRIDGE_REQUEST_PATH,
81
76
  TOOL_BRIDGE_RESPONSE_PATH
82
77
  } from "./chunk-VRRGSQI7.js";
78
+ import {
79
+ PERMISSION_BRIDGE_PENDING_PATH,
80
+ PERMISSION_BRIDGE_REQUEST_PATH,
81
+ PERMISSION_BRIDGE_RESPONSE_PATH
82
+ } from "./chunk-CY6AWCC6.js";
83
83
  import {
84
84
  resolveToolset
85
85
  } from "./chunk-FX2AEKOV.js";
86
86
  import {
87
87
  getConfig
88
- } from "./chunk-US26CY2Y.js";
88
+ } from "./chunk-6EIONZ7F.js";
89
89
  import {
90
90
  init_clock,
91
91
  nowMs
@@ -139,7 +139,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
139
139
  const backend = resolveBackend(agent.engine);
140
140
  const vaultEntries = [];
141
141
  if (session.vault_ids && session.vault_ids.length > 0) {
142
- const secrets2 = loadSessionSecrets(session.vault_ids);
142
+ const secrets2 = loadSessionSecrets(session.vault_ids, session.user_profile_id);
143
143
  vaultEntries.push(...secrets2.map((s) => ({ key: s.key, value: s.value })));
144
144
  }
145
145
  const hasVaultKeys = vaultEntries.length > 0;
@@ -5,25 +5,25 @@ import {
5
5
  } from "./chunk-23UKWXJH.js";
6
6
  import {
7
7
  kickoffEnvironmentSetup
8
- } from "./chunk-7DPZMROX.js";
8
+ } from "./chunk-K5J4IN2S.js";
9
9
  import {
10
10
  decodeCursor,
11
11
  jsonOk,
12
12
  paginatedOk,
13
13
  routeWrap
14
- } from "./chunk-DI5WC2SQ.js";
14
+ } from "./chunk-4EKHW6VS.js";
15
15
  import {
16
16
  forwardToAnthropic
17
- } from "./chunk-IDQKHWWN.js";
17
+ } from "./chunk-JFHYXFAL.js";
18
18
  import {
19
19
  getProxiedTenantId,
20
20
  isProxied,
21
21
  markProxied,
22
22
  unmarkProxied
23
- } from "./chunk-GKNBECPD.js";
23
+ } from "./chunk-DZKBUOYU.js";
24
24
  import {
25
25
  resolveContainerProvider
26
- } from "./chunk-QQGXM2OQ.js";
26
+ } from "./chunk-XLMNSDUJ.js";
27
27
  import {
28
28
  archiveEnvironment,
29
29
  createEnvironment,
@@ -32,11 +32,11 @@ import {
32
32
  hasSessionsAttached,
33
33
  listEnvironments,
34
34
  updateEnvironment
35
- } from "./chunk-BRULBMRN.js";
35
+ } from "./chunk-NSUVDKNC.js";
36
36
  import {
37
37
  getDb,
38
38
  init_client
39
- } from "./chunk-Q62QJXGO.js";
39
+ } from "./chunk-AGIXZFHQ.js";
40
40
  import {
41
41
  badRequest,
42
42
  conflict,
@@ -4,14 +4,14 @@ import {
4
4
  import {
5
5
  jsonOk,
6
6
  routeWrap
7
- } from "./chunk-DI5WC2SQ.js";
7
+ } from "./chunk-4EKHW6VS.js";
8
8
  import {
9
9
  getProxiedTenantId
10
- } from "./chunk-GKNBECPD.js";
10
+ } from "./chunk-DZKBUOYU.js";
11
11
  import {
12
12
  getSession,
13
13
  updateSessionResources
14
- } from "./chunk-GBJ3OT4D.js";
14
+ } from "./chunk-ZC7OR65K.js";
15
15
  import {
16
16
  countResources,
17
17
  createResource,
@@ -20,11 +20,11 @@ import {
20
20
  init_session_resources,
21
21
  listResources,
22
22
  updateResource
23
- } from "./chunk-FDL2JHXO.js";
23
+ } from "./chunk-GCT7A5KR.js";
24
24
  import {
25
25
  getDb,
26
26
  init_client
27
- } from "./chunk-Q62QJXGO.js";
27
+ } from "./chunk-AGIXZFHQ.js";
28
28
  import {
29
29
  badRequest,
30
30
  notFound
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-US26CY2Y.js";
3
+ } from "./chunk-6EIONZ7F.js";
4
4
 
5
5
  // src/backends/factory/auth.ts
6
6
  function buildFactoryAuthEnv() {
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-AIBH32FN.js";
5
5
  import {
6
6
  DEFAULT_TENANT_ID
7
- } from "./chunk-F5SHFZUA.js";
7
+ } from "./chunk-YTBVILAH.js";
8
8
  import {
9
9
  init_ids,
10
10
  newId
@@ -17,10 +17,10 @@ import {
17
17
  import {
18
18
  getDrizzle,
19
19
  init_drizzle
20
- } from "./chunk-7U62OZSD.js";
20
+ } from "./chunk-ZDDMPGN4.js";
21
21
  import {
22
22
  schema_exports
23
- } from "./chunk-4ENK7S24.js";
23
+ } from "./chunk-CXYMVLYK.js";
24
24
 
25
25
  // src/db/vaults.ts
26
26
  init_drizzle();
@@ -8,17 +8,17 @@ import {
8
8
  jsonOk,
9
9
  paginatedOk,
10
10
  routeWrap
11
- } from "./chunk-DI5WC2SQ.js";
11
+ } from "./chunk-4EKHW6VS.js";
12
12
  import {
13
13
  forwardToAnthropic,
14
14
  validateAnthropicProxy
15
- } from "./chunk-IDQKHWWN.js";
15
+ } from "./chunk-JFHYXFAL.js";
16
16
  import {
17
17
  getProxiedTenantId,
18
18
  isProxied,
19
19
  markProxied,
20
20
  unmarkProxied
21
- } from "./chunk-GKNBECPD.js";
21
+ } from "./chunk-DZKBUOYU.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-ENFWZ2QM.js";
29
+ } from "./chunk-6U6HEVSN.js";
30
30
  import {
31
31
  resolveBackend
32
- } from "./chunk-XMZQW5G5.js";
32
+ } from "./chunk-V5RHOS43.js";
33
33
  import {
34
34
  getDb,
35
35
  init_client
36
- } from "./chunk-Q62QJXGO.js";
36
+ } from "./chunk-AGIXZFHQ.js";
37
37
  import {
38
38
  badRequest,
39
39
  conflict,
@@ -255,6 +255,10 @@ var CreateSchema = z.object({
255
255
  z.object({ type: z.literal("self") })
256
256
  ])).max(20)
257
257
  }).optional(),
258
+ permission_policy: z.object({
259
+ always_allow: z.array(z.string()).optional(),
260
+ always_ask: z.array(z.string()).optional()
261
+ }).optional(),
258
262
  skills: z.array(SkillSchema).max(20).optional(),
259
263
  model_config: ModelConfigSchema.optional(),
260
264
  /** v0.5: required for global admin, ignored for tenant users. */
@@ -301,6 +305,10 @@ var UpdateSchema = z.object({
301
305
  z.object({ type: z.literal("self") })
302
306
  ])).max(20)
303
307
  }).nullish(),
308
+ permission_policy: z.object({
309
+ always_allow: z.array(z.string()).optional(),
310
+ always_ask: z.array(z.string()).optional()
311
+ }).nullish(),
304
312
  skills: z.array(SkillSchema).max(20).optional(),
305
313
  model_config: ModelConfigSchema.optional()
306
314
  }).refine((data) => {
@@ -386,6 +394,7 @@ function handleCreateAgent(request) {
386
394
  confirmation_mode: parsed.data.confirmation_mode ?? false,
387
395
  callable_agents: parsed.data.callable_agents,
388
396
  multiagent: parsed.data.multiagent,
397
+ permission_policy: parsed.data.permission_policy,
389
398
  skills: await resolveSkillInputs(parsed.data.skills, nowIso),
390
399
  model_config: mergedModelConfig,
391
400
  tenant_id: createTenantId
@@ -466,6 +475,7 @@ function handleUpdateAgent(request, id) {
466
475
  confirmation_mode: parsed.data.confirmation_mode,
467
476
  callable_agents: parsed.data.callable_agents,
468
477
  multiagent: parsed.data.multiagent,
478
+ permission_policy: parsed.data.permission_policy,
469
479
  skills: await resolveSkillInputs(parsed.data.skills, nowIso),
470
480
  model_config: mergedModelConfig
471
481
  });
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_TENANT_ID
3
- } from "./chunk-F5SHFZUA.js";
3
+ } from "./chunk-YTBVILAH.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-7U62OZSD.js";
16
+ } from "./chunk-ZDDMPGN4.js";
17
17
  import {
18
18
  schema_exports
19
- } from "./chunk-4ENK7S24.js";
19
+ } from "./chunk-CXYMVLYK.js";
20
20
 
21
21
  // src/db/environments.ts
22
22
  init_drizzle();
@@ -0,0 +1,276 @@
1
+ import {
2
+ jsonOk,
3
+ routeWrap
4
+ } from "./chunk-4EKHW6VS.js";
5
+ import {
6
+ init_ids,
7
+ newId
8
+ } from "./chunk-F4WUVOLE.js";
9
+ import {
10
+ getDb,
11
+ init_client
12
+ } from "./chunk-AGIXZFHQ.js";
13
+ import {
14
+ badRequest,
15
+ notFound
16
+ } from "./chunk-EZYKRG4W.js";
17
+
18
+ // src/handlers/google-compat/interactions.ts
19
+ import { z } from "zod";
20
+ init_client();
21
+ init_ids();
22
+ function ensureTable() {
23
+ const db = getDb();
24
+ db.exec(`
25
+ CREATE TABLE IF NOT EXISTS google_interactions (
26
+ id TEXT PRIMARY KEY,
27
+ session_id TEXT NOT NULL,
28
+ seq INTEGER NOT NULL DEFAULT 1,
29
+ status TEXT NOT NULL DEFAULT 'completed',
30
+ environment_id TEXT,
31
+ created_at TEXT NOT NULL
32
+ )
33
+ `);
34
+ }
35
+ var CreateSchema = z.object({
36
+ model: z.string().optional(),
37
+ agent: z.string().optional(),
38
+ input: z.union([z.string(), z.array(z.unknown())]),
39
+ system_instruction: z.string().optional(),
40
+ tools: z.array(z.unknown()).optional(),
41
+ generation_config: z.record(z.unknown()).optional(),
42
+ previous_interaction_id: z.string().optional(),
43
+ environment: z.union([z.string(), z.object({ type: z.string() }).passthrough()]).optional(),
44
+ stream: z.boolean().optional()
45
+ });
46
+ function handleCreateInteraction(request) {
47
+ return routeWrap(request, async ({ auth }) => {
48
+ ensureTable();
49
+ const body = await request.json().catch(() => null);
50
+ const parsed = CreateSchema.safeParse(body);
51
+ if (!parsed.success) {
52
+ throw badRequest(`invalid body: ${parsed.error.issues.map((i) => i.message).join("; ")}`);
53
+ }
54
+ const data = parsed.data;
55
+ if (!data.model && !data.agent) {
56
+ throw badRequest("either 'model' or 'agent' is required");
57
+ }
58
+ const inputText = typeof data.input === "string" ? data.input : JSON.stringify(data.input);
59
+ const { handleCreateAgent, handleListAgents } = await import("./handlers/agents.js");
60
+ const { handleCreateSession } = await import("./handlers/sessions.js");
61
+ const { handlePostEvents } = await import("./handlers/events.js");
62
+ let agentId;
63
+ let environmentId;
64
+ if (data.previous_interaction_id) {
65
+ const db2 = getDb();
66
+ const prev = db2.prepare(
67
+ `SELECT session_id, environment_id FROM google_interactions WHERE id = ?`
68
+ ).get(data.previous_interaction_id);
69
+ if (!prev) throw notFound(`interaction not found: ${data.previous_interaction_id}`);
70
+ agentId = "";
71
+ environmentId = prev.environment_id ?? void 0;
72
+ const sessionId2 = prev.session_id;
73
+ const eventsReq2 = new Request(request.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/sessions/${sessionId2}/events`), {
74
+ method: "POST",
75
+ headers: request.headers,
76
+ body: JSON.stringify({
77
+ events: [{ type: "user.message", content: [{ type: "text", text: inputText }] }]
78
+ })
79
+ });
80
+ const eventsRes2 = await handlePostEvents(eventsReq2, sessionId2);
81
+ if (!eventsRes2.ok) {
82
+ const err = await eventsRes2.json().catch(() => ({}));
83
+ throw badRequest(err.error?.message || `failed to send message: ${eventsRes2.status}`);
84
+ }
85
+ const result2 = await waitForCompletion(sessionId2);
86
+ const interactionId2 = `int_${newId("sesn").slice(5)}`;
87
+ const prevSeq = db2.prepare(
88
+ `SELECT MAX(seq) as maxSeq FROM google_interactions WHERE session_id = ?`
89
+ ).get(sessionId2);
90
+ const seq = (prevSeq?.maxSeq ?? 0) + 1;
91
+ db2.prepare(
92
+ `INSERT INTO google_interactions (id, session_id, seq, status, environment_id, created_at) VALUES (?, ?, ?, ?, ?, ?)`
93
+ ).run(interactionId2, sessionId2, seq, result2.status, environmentId ?? null, (/* @__PURE__ */ new Date()).toISOString());
94
+ return jsonOk(buildResponse(interactionId2, result2, environmentId));
95
+ }
96
+ const agentName = data.agent || `auto-${(data.model || "gemini-2.5-flash").replace(/[^a-z0-9-]/g, "-")}`;
97
+ const listReq = new Request(request.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/agents?limit=1000`), {
98
+ headers: request.headers
99
+ });
100
+ const listRes = await handleListAgents(listReq);
101
+ const listBody = await listRes.json();
102
+ const existing = listBody.data?.find((a) => a.name === agentName);
103
+ if (existing) {
104
+ agentId = existing.id;
105
+ } else {
106
+ const modelId = data.model || "gemini-2.5-flash";
107
+ const createReq = new Request(request.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/agents`), {
108
+ method: "POST",
109
+ headers: request.headers,
110
+ body: JSON.stringify({
111
+ name: agentName,
112
+ model: { id: modelId },
113
+ system: data.system_instruction ?? null
114
+ })
115
+ });
116
+ const createRes = await handleCreateAgent(createReq);
117
+ if (!createRes.ok) {
118
+ const err = await createRes.json().catch(() => ({}));
119
+ throw badRequest(err.error?.message || `failed to create agent: ${createRes.status}`);
120
+ }
121
+ const created = await createRes.json();
122
+ agentId = created.id;
123
+ }
124
+ const { listEnvironments } = await import("./db/environments.js");
125
+ const envs = listEnvironments({ includeArchived: false, limit: 10 });
126
+ const readyEnv = envs.find((e) => e.state === "ready");
127
+ if (readyEnv) {
128
+ environmentId = readyEnv.id;
129
+ } else {
130
+ const { handleCreateEnvironment } = await import("./handlers/environments.js");
131
+ const envReq = new Request(request.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/environments`), {
132
+ method: "POST",
133
+ headers: request.headers,
134
+ body: JSON.stringify({ name: `google-compat-${Date.now()}` })
135
+ });
136
+ const envRes = await handleCreateEnvironment(envReq);
137
+ if (envRes.ok) {
138
+ const envBody = await envRes.json();
139
+ environmentId = envBody.id;
140
+ }
141
+ }
142
+ if (!environmentId) throw badRequest("no environment available");
143
+ const sessReq = new Request(request.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/sessions`), {
144
+ method: "POST",
145
+ headers: request.headers,
146
+ body: JSON.stringify({
147
+ agent: agentId,
148
+ environment_id: environmentId
149
+ })
150
+ });
151
+ const sessRes = await handleCreateSession(sessReq);
152
+ if (!sessRes.ok) {
153
+ const err = await sessRes.json().catch(() => ({}));
154
+ throw badRequest(err.error?.message || `failed to create session: ${sessRes.status}`);
155
+ }
156
+ const sessBody = await sessRes.json();
157
+ const sessionId = sessBody.id;
158
+ const eventsReq = new Request(request.url.replace(/\/google\/v1beta\/interactions.*/, `/v1/sessions/${sessionId}/events`), {
159
+ method: "POST",
160
+ headers: request.headers,
161
+ body: JSON.stringify({
162
+ events: [{ type: "user.message", content: [{ type: "text", text: inputText }] }]
163
+ })
164
+ });
165
+ const eventsRes = await handlePostEvents(eventsReq, sessionId);
166
+ if (!eventsRes.ok) {
167
+ const err = await eventsRes.json().catch(() => ({}));
168
+ throw badRequest(err.error?.message || `failed to send message: ${eventsRes.status}`);
169
+ }
170
+ const result = await waitForCompletion(sessionId);
171
+ const interactionId = `int_${newId("sesn").slice(5)}`;
172
+ const db = getDb();
173
+ db.prepare(
174
+ `INSERT INTO google_interactions (id, session_id, seq, status, environment_id, created_at) VALUES (?, ?, ?, ?, ?, ?)`
175
+ ).run(interactionId, sessionId, 1, result.status, environmentId ?? null, (/* @__PURE__ */ new Date()).toISOString());
176
+ return jsonOk(buildResponse(interactionId, result, environmentId));
177
+ });
178
+ }
179
+ async function waitForCompletion(sessionId) {
180
+ const { subscribe } = await import("./sessions/bus.js");
181
+ const { listEvents } = await import("./db/events.js");
182
+ return new Promise((resolve) => {
183
+ const steps = [];
184
+ let outputText = "";
185
+ let inputTokens = 0;
186
+ let outputTokens = 0;
187
+ let status = "completed";
188
+ let resolved = false;
189
+ const timeout = setTimeout(() => {
190
+ if (resolved) return;
191
+ resolved = true;
192
+ sub.unsubscribe();
193
+ resolve({
194
+ status: "failed",
195
+ steps,
196
+ usage: { total_input_tokens: inputTokens, total_output_tokens: outputTokens, total_tokens: inputTokens + outputTokens },
197
+ outputText
198
+ });
199
+ }, 5 * 6e4);
200
+ function finish() {
201
+ if (resolved) return;
202
+ resolved = true;
203
+ clearTimeout(timeout);
204
+ sub.unsubscribe();
205
+ resolve({
206
+ status,
207
+ steps,
208
+ usage: { total_input_tokens: inputTokens, total_output_tokens: outputTokens, total_tokens: inputTokens + outputTokens },
209
+ outputText
210
+ });
211
+ }
212
+ function handleEvent(event) {
213
+ if (resolved) return;
214
+ if (event.type === "agent.message") {
215
+ const content = event.content;
216
+ const text = content?.filter((c) => c.type === "text").map((c) => c.text).join("") ?? "";
217
+ if (text) {
218
+ outputText += text;
219
+ steps.push({ type: "model_output", content: [{ type: "text", text }] });
220
+ }
221
+ } else if (event.type === "agent.tool_use") {
222
+ steps.push({
223
+ type: "function_call",
224
+ id: event.tool_use_id ?? "",
225
+ name: event.name ?? "",
226
+ arguments: event.input ?? {}
227
+ });
228
+ } else if (event.type === "agent.tool_result") {
229
+ steps.push({
230
+ type: "code_execution_result",
231
+ call_id: event.tool_use_id ?? "",
232
+ result: JSON.stringify(event.content ?? "")
233
+ });
234
+ } else if (event.type === "agent.custom_tool_use") {
235
+ status = "requires_action";
236
+ steps.push({
237
+ type: "function_call",
238
+ id: event.tool_use_id ?? "",
239
+ name: event.name ?? "",
240
+ arguments: event.input ?? {}
241
+ });
242
+ } else if (event.type === "span.model_request_end") {
243
+ const mu = event.model_usage;
244
+ inputTokens += mu?.input_tokens ?? 0;
245
+ outputTokens += mu?.output_tokens ?? 0;
246
+ } else if (event.type === "session.status_idle") {
247
+ const stopReason = event.stop_reason;
248
+ if (stopReason === "error") status = "failed";
249
+ else if (status !== "requires_action") status = "completed";
250
+ finish();
251
+ } else if (event.type === "session.error") {
252
+ status = "failed";
253
+ }
254
+ }
255
+ const sub = subscribe(sessionId, 0, handleEvent);
256
+ if (resolved) {
257
+ clearTimeout(timeout);
258
+ }
259
+ });
260
+ }
261
+ function buildResponse(id, result, environmentId) {
262
+ const now = (/* @__PURE__ */ new Date()).toISOString();
263
+ return {
264
+ id,
265
+ created: now,
266
+ updated: now,
267
+ status: result.status,
268
+ steps: result.steps,
269
+ usage: result.usage,
270
+ environment_id: environmentId
271
+ };
272
+ }
273
+
274
+ export {
275
+ handleCreateInteraction
276
+ };
@@ -10,14 +10,14 @@ import {
10
10
  import {
11
11
  getDrizzle,
12
12
  init_drizzle
13
- } from "./chunk-7U62OZSD.js";
13
+ } from "./chunk-ZDDMPGN4.js";
14
14
  import {
15
15
  schema_exports
16
- } from "./chunk-4ENK7S24.js";
16
+ } from "./chunk-CXYMVLYK.js";
17
17
  import {
18
18
  getDb,
19
19
  init_client
20
- } from "./chunk-Q62QJXGO.js";
20
+ } from "./chunk-AGIXZFHQ.js";
21
21
 
22
22
  // src/db/events.ts
23
23
  init_client();