@agentstep/agent-sdk 0.5.2 → 0.5.4

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 (183) 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 +7 -7
  4. package/dist/backends/codex/auth.js +6 -6
  5. package/dist/backends/codex/index.js +13 -13
  6. package/dist/backends/factory/auth.js +6 -6
  7. package/dist/backends/factory/index.js +10 -10
  8. package/dist/backends/gemini/auth.js +6 -6
  9. package/dist/backends/gemini/index.js +7 -7
  10. package/dist/backends/opencode/auth.js +6 -6
  11. package/dist/backends/opencode/index.js +9 -9
  12. package/dist/backends/pi/auth.js +6 -6
  13. package/dist/backends/pi/index.js +7 -7
  14. package/dist/backends/registry.js +26 -26
  15. package/dist/{chunk-VY6IWBSK.js → chunk-2GIAAUSW.js} +20 -3
  16. package/dist/{chunk-TF36SWHG.js → chunk-2LTNC5C7.js} +2 -2
  17. package/dist/{chunk-LW4OCFIP.js → chunk-2RIOHWZW.js} +6 -6
  18. package/dist/{chunk-AESA3ARX.js → chunk-3ST3YLED.js} +3 -3
  19. package/dist/{chunk-C52BVTYC.js → chunk-5435RAMR.js} +4 -4
  20. package/dist/{chunk-TSR33JMZ.js → chunk-5TOLDBBJ.js} +5 -5
  21. package/dist/{chunk-P4OCCRQW.js → chunk-5WY3LSCS.js} +1 -1
  22. package/dist/{chunk-Q2JYAAJO.js → chunk-64AWIKIO.js} +10 -10
  23. package/dist/{chunk-UQZFFG7U.js → chunk-64M4Z6HW.js} +1 -1
  24. package/dist/{chunk-P4NU74SP.js → chunk-6ZODIFRZ.js} +38 -0
  25. package/dist/{chunk-MV42BTU3.js → chunk-7OM5LP3K.js} +1 -1
  26. package/dist/{chunk-7IYL2O7H.js → chunk-A7DBW4MD.js} +3 -3
  27. package/dist/{chunk-4236UQNZ.js → chunk-ADSZ2OCX.js} +2 -2
  28. package/dist/{chunk-Z6OPLBPQ.js → chunk-AJOG6UYH.js} +1 -1
  29. package/dist/{chunk-YDP3YA5D.js → chunk-B2VM6IRJ.js} +15 -15
  30. package/dist/{chunk-IAKR572X.js → chunk-B374MDPO.js} +1 -1
  31. package/dist/{chunk-5UTTNXNJ.js → chunk-BZYAXHRB.js} +6 -6
  32. package/dist/{chunk-X4ARJS6I.js → chunk-C3PD6T4A.js} +4 -4
  33. package/dist/{chunk-5YGYUGDQ.js → chunk-C4GMG6IB.js} +3 -3
  34. package/dist/{chunk-PICGSLMG.js → chunk-C4YHYPOW.js} +5 -5
  35. package/dist/{chunk-5EFY6UGV.js → chunk-CZH5FQSF.js} +1 -1
  36. package/dist/{chunk-L2DCOJTQ.js → chunk-D5E5XJAU.js} +3 -3
  37. package/dist/{chunk-TE6KCRPP.js → chunk-DAKCDGWV.js} +1 -1
  38. package/dist/{chunk-ACPP4KN7.js → chunk-DDHJHSIR.js} +3 -3
  39. package/dist/{chunk-Y4MI27HU.js → chunk-DL7IPOZF.js} +1 -1
  40. package/dist/{chunk-YL6IQUJC.js → chunk-DMROEZYE.js} +4 -4
  41. package/dist/{chunk-ZEJOFHR7.js → chunk-DPR6K7Y4.js} +24 -6
  42. package/dist/{chunk-G4DTLYOD.js → chunk-DQW2QEK5.js} +1 -1
  43. package/dist/{chunk-7EDLLXFQ.js → chunk-DXRTOMZP.js} +13 -3
  44. package/dist/{chunk-GZZHVIEG.js → chunk-DYRGMJTC.js} +2 -2
  45. package/dist/{chunk-GBLR2CPP.js → chunk-FSQ6I3C7.js} +37 -2
  46. package/dist/{chunk-Z46R47QX.js → chunk-GOFQ63N3.js} +8 -8
  47. package/dist/{chunk-RZOCX57A.js → chunk-H355W724.js} +2 -2
  48. package/dist/{chunk-DZGFZMUE.js → chunk-HRBNDS5T.js} +1 -1
  49. package/dist/{chunk-ANS2TQYT.js → chunk-HWVBBUL2.js} +1 -1
  50. package/dist/{chunk-6TJBZXD4.js → chunk-IUMA4QRX.js} +1 -1
  51. package/dist/{chunk-6URMGCAC.js → chunk-IYVGGJMH.js} +2 -2
  52. package/dist/{chunk-5525T7PL.js → chunk-J2SP5UND.js} +4 -4
  53. package/dist/{chunk-6L4AGHAV.js → chunk-J6WSFODH.js} +10 -18
  54. package/dist/{chunk-PQKIXSEP.js → chunk-JCOR7AIY.js} +2 -2
  55. package/dist/{chunk-3VPTHB7I.js → chunk-JPONGXV5.js} +2 -2
  56. package/dist/{chunk-FILGQF2G.js → chunk-JWVVF66Q.js} +2 -2
  57. package/dist/{chunk-7JAUY5SG.js → chunk-K2UJFAGD.js} +3 -3
  58. package/dist/{chunk-AIAF5ZZA.js → chunk-KB7MV6VS.js} +1 -1
  59. package/dist/chunk-KYLDNVV7.js +176 -0
  60. package/dist/{chunk-7XIAKW75.js → chunk-LII6JJQT.js} +1 -1
  61. package/dist/{chunk-GEC3NFYO.js → chunk-MFSO7IGE.js} +4 -4
  62. package/dist/{chunk-IZ5TUMCF.js → chunk-NOJ3ERIN.js} +50 -17
  63. package/dist/{chunk-LA6IFUVR.js → chunk-OACMO7AL.js} +15 -15
  64. package/dist/{chunk-UGH5JDXX.js → chunk-P2NWS65Y.js} +2 -2
  65. package/dist/{chunk-BCBDHUFY.js → chunk-P4B4V4SV.js} +2 -2
  66. package/dist/{chunk-4B5H2MFO.js → chunk-P5DSHKKP.js} +16 -10
  67. package/dist/{chunk-WFRHLTKI.js → chunk-P5X2DSGQ.js} +3 -3
  68. package/dist/{chunk-M3752GFZ.js → chunk-P7TV5XP4.js} +3 -3
  69. package/dist/{chunk-A2W3USEZ.js → chunk-PEEKWYYE.js} +1 -1
  70. package/dist/{chunk-6WUYI3DJ.js → chunk-PKWN44LF.js} +4 -4
  71. package/dist/{chunk-VMLXV2H6.js → chunk-PUH4LEJZ.js} +1 -1
  72. package/dist/{chunk-TWH4UH6G.js → chunk-PVVJCRII.js} +1 -1
  73. package/dist/{chunk-SQZPJFBF.js → chunk-R6M4V3IG.js} +2 -2
  74. package/dist/{chunk-P6LESAPO.js → chunk-RA25CUV4.js} +29 -15
  75. package/dist/{chunk-6KJS42ZL.js → chunk-SMM7YOM2.js} +2 -2
  76. package/dist/{chunk-VC5DELR4.js → chunk-SZNZZB7J.js} +23 -1
  77. package/dist/{chunk-YEWYRPN4.js → chunk-T7NQMCDT.js} +35 -4
  78. package/dist/{chunk-4A4F4L4H.js → chunk-TC7UW22R.js} +2 -2
  79. package/dist/{chunk-BYIU4WAQ.js → chunk-TWX2D563.js} +3 -3
  80. package/dist/{chunk-CA76BJWL.js → chunk-TXOB3PZH.js} +13 -13
  81. package/dist/{chunk-IBUFLAAJ.js → chunk-UFAYAE3A.js} +7 -7
  82. package/dist/{chunk-WRLCJNQF.js → chunk-UK3ZFCQP.js} +1 -1
  83. package/dist/{chunk-UJW3I3TX.js → chunk-UKCIGI3T.js} +3 -3
  84. package/dist/{chunk-7APAOJIZ.js → chunk-UKCRJFFC.js} +3 -3
  85. package/dist/{chunk-FSVDF57K.js → chunk-UKIOGRMN.js} +5 -5
  86. package/dist/chunk-V5EEO7MU.js +129 -0
  87. package/dist/{chunk-KQTTKYZY.js → chunk-W3YXUIPS.js} +1 -1
  88. package/dist/{chunk-O2X4XBU7.js → chunk-W4FZ4HYD.js} +1 -1
  89. package/dist/{chunk-E35XHOFL.js → chunk-WOL4EVCE.js} +7 -7
  90. package/dist/{chunk-NRX5WHHN.js → chunk-X65C4UZH.js} +4 -4
  91. package/dist/{chunk-MTLM36QD.js → chunk-X7Y4TV6O.js} +2 -2
  92. package/dist/{chunk-BLTCDZ3O.js → chunk-XNEUJKY4.js} +4 -4
  93. package/dist/{chunk-6KQFP32G.js → chunk-YICDEIRE.js} +2 -2
  94. package/dist/{chunk-UAEVL47I.js → chunk-YSZLX4WE.js} +1 -1
  95. package/dist/{chunk-FWJOTEVY.js → chunk-YTZQ5J6L.js} +13 -3
  96. package/dist/{chunk-P4VJADXA.js → chunk-ZFMAACZT.js} +2 -2
  97. package/dist/{chunk-6DPJVMEC.js → chunk-ZIZU3B65.js} +1 -1
  98. package/dist/{chunk-ZFGG62JW.js → chunk-ZXJTXNUX.js} +4 -4
  99. package/dist/config/index.js +5 -5
  100. package/dist/containers/client.js +6 -6
  101. package/dist/containers/exec.js +6 -6
  102. package/dist/containers/lifecycle.js +38 -38
  103. package/dist/containers/setup.js +8 -8
  104. package/dist/db/agents.js +6 -6
  105. package/dist/db/api_keys.js +5 -5
  106. package/dist/db/audit.js +3 -3
  107. package/dist/db/batch.js +10 -10
  108. package/dist/db/client.js +2 -2
  109. package/dist/db/credentials.js +5 -3
  110. package/dist/db/drizzle.js +4 -4
  111. package/dist/db/environments.js +6 -6
  112. package/dist/db/events.js +5 -5
  113. package/dist/db/files.js +5 -5
  114. package/dist/db/memory.js +11 -7
  115. package/dist/db/migrations.js +1 -1
  116. package/dist/db/proxy.js +5 -5
  117. package/dist/db/schema.js +5 -1
  118. package/dist/db/session-resources.js +9 -7
  119. package/dist/db/sessions.js +8 -8
  120. package/dist/db/skills.js +27 -0
  121. package/dist/db/sync.js +5 -5
  122. package/dist/db/tenants.js +3 -3
  123. package/dist/db/threads.js +7 -7
  124. package/dist/db/traces.js +5 -5
  125. package/dist/db/upstream_keys.js +3 -3
  126. package/dist/db/vaults.js +6 -6
  127. package/dist/dreaming/review.js +11 -11
  128. package/dist/handlers/agents.js +54 -54
  129. package/dist/handlers/api_keys.js +55 -55
  130. package/dist/handlers/audit.js +55 -55
  131. package/dist/handlers/batch.js +55 -55
  132. package/dist/handlers/credentials.js +57 -55
  133. package/dist/handlers/environments.js +55 -55
  134. package/dist/handlers/events.js +58 -58
  135. package/dist/handlers/files.js +55 -55
  136. package/dist/handlers/index.js +125 -106
  137. package/dist/handlers/license.js +54 -54
  138. package/dist/handlers/memory.js +61 -57
  139. package/dist/handlers/metrics.js +54 -54
  140. package/dist/handlers/models.js +55 -55
  141. package/dist/handlers/providers.js +54 -54
  142. package/dist/handlers/resources.js +58 -56
  143. package/dist/handlers/sessions.js +58 -58
  144. package/dist/handlers/settings.js +54 -54
  145. package/dist/handlers/skills-write.js +68 -56
  146. package/dist/handlers/skills.js +55 -55
  147. package/dist/handlers/stream.js +54 -54
  148. package/dist/handlers/tenants.js +55 -55
  149. package/dist/handlers/threads.js +55 -55
  150. package/dist/handlers/traces.js +55 -55
  151. package/dist/handlers/upstream_keys.js +57 -57
  152. package/dist/handlers/vaults.js +54 -54
  153. package/dist/handlers/whoami.js +54 -54
  154. package/dist/http.js +53 -53
  155. package/dist/index.js +62 -62
  156. package/dist/init.js +50 -50
  157. package/dist/lib/model-registry.js +6 -6
  158. package/dist/lib/skills-cache.js +6 -6
  159. package/dist/observability/otlp.js +12 -12
  160. package/dist/observability/redactor.js +8 -8
  161. package/dist/providers/fly.js +5 -5
  162. package/dist/providers/modal.js +5 -5
  163. package/dist/providers/registry.js +1 -1
  164. package/dist/providers/resolve-secrets.js +7 -7
  165. package/dist/providers/sprites.js +7 -7
  166. package/dist/providers/upstream-keys.js +12 -12
  167. package/dist/providers/vercel.js +6 -6
  168. package/dist/proxy/forward.js +6 -6
  169. package/dist/queue/index.js +6 -6
  170. package/dist/sessions/bus.js +10 -10
  171. package/dist/sessions/driver.js +43 -43
  172. package/dist/sessions/grader.js +5 -5
  173. package/dist/sessions/secrets.js +8 -8
  174. package/dist/sessions/sweeper.js +39 -39
  175. package/dist/sessions/threads.js +45 -45
  176. package/dist/shutdown.js +40 -40
  177. package/dist/sync/anthropic.js +10 -10
  178. package/dist/sync/container-file-sync.js +24 -6
  179. package/dist/sync/file-sync.js +17 -17
  180. package/package.json +1 -1
  181. package/dist/chunk-WDAFSCYQ.js +0 -31
  182. package/dist/{chunk-LT5PRO54.js → chunk-ZJERBDQE.js} +0 -0
  183. package/dist/{dist-S64ZABZX.js → dist-EY25RQ2S.js} +3 -3
@@ -1,32 +1,32 @@
1
1
  import {
2
2
  resolveRemoteSessionId
3
- } from "./chunk-AESA3ARX.js";
3
+ } from "./chunk-3ST3YLED.js";
4
4
  import {
5
5
  assertResourceTenant
6
6
  } from "./chunk-23UKWXJH.js";
7
7
  import {
8
8
  authenticateAndIntercept
9
- } from "./chunk-WFRHLTKI.js";
9
+ } from "./chunk-P5X2DSGQ.js";
10
10
  import {
11
11
  forwardToAnthropic
12
- } from "./chunk-Y4MI27HU.js";
12
+ } from "./chunk-DL7IPOZF.js";
13
13
  import {
14
14
  ensureInitialized
15
- } from "./chunk-YDP3YA5D.js";
15
+ } from "./chunk-B2VM6IRJ.js";
16
16
  import {
17
17
  getProxiedTenantId,
18
18
  isProxied
19
- } from "./chunk-MTLM36QD.js";
19
+ } from "./chunk-X7Y4TV6O.js";
20
20
  import {
21
21
  subscribe
22
- } from "./chunk-NRX5WHHN.js";
22
+ } from "./chunk-X65C4UZH.js";
23
23
  import {
24
24
  getSession
25
- } from "./chunk-TSR33JMZ.js";
25
+ } from "./chunk-5TOLDBBJ.js";
26
26
  import {
27
27
  getDb,
28
28
  init_client
29
- } from "./chunk-KQTTKYZY.js";
29
+ } from "./chunk-W3YXUIPS.js";
30
30
  import {
31
31
  notFound,
32
32
  toResponse
@@ -4,11 +4,11 @@ import {
4
4
  getSources,
5
5
  getStats,
6
6
  searchSkills
7
- } from "./chunk-TE6KCRPP.js";
7
+ } from "./chunk-DAKCDGWV.js";
8
8
  import {
9
9
  jsonOk,
10
10
  routeWrap
11
- } from "./chunk-6URMGCAC.js";
11
+ } from "./chunk-IYVGGJMH.js";
12
12
 
13
13
  // src/handlers/skills.ts
14
14
  async function handleGetSkillsCatalog(request) {
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  buildGeminiAuthEnv,
6
6
  validateGeminiRuntime
7
- } from "./chunk-Z6OPLBPQ.js";
7
+ } from "./chunk-AJOG6UYH.js";
8
8
  import {
9
9
  prepareGeminiOnSandbox
10
10
  } from "./chunk-XG4UIGDH.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-XBHDQK4Z.js";
7
7
  import {
8
8
  getConfig
9
- } from "./chunk-UGH5JDXX.js";
9
+ } from "./chunk-P2NWS65Y.js";
10
10
 
11
11
  // src/backends/claude/args.ts
12
12
  function buildClaudeArgs(input) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-UGH5JDXX.js";
3
+ } from "./chunk-P2NWS65Y.js";
4
4
 
5
5
  // src/backends/codex/auth.ts
6
6
  function buildCodexAuthEnv() {
@@ -4,13 +4,13 @@ import {
4
4
  } from "./chunk-D2XITRN6.js";
5
5
  import {
6
6
  authenticateAndIntercept
7
- } from "./chunk-WFRHLTKI.js";
7
+ } from "./chunk-P5X2DSGQ.js";
8
8
  import {
9
9
  checkAndBump
10
10
  } from "./chunk-HVUWXUUI.js";
11
11
  import {
12
12
  ensureInitialized
13
- } from "./chunk-YDP3YA5D.js";
13
+ } from "./chunk-B2VM6IRJ.js";
14
14
  import {
15
15
  captureException
16
16
  } from "./chunk-3MQ2FWXS.js";
@@ -7,7 +7,7 @@ import {
7
7
  jsonOk,
8
8
  paginatedOk,
9
9
  routeWrap
10
- } from "./chunk-6URMGCAC.js";
10
+ } from "./chunk-IYVGGJMH.js";
11
11
  import {
12
12
  archiveVault,
13
13
  createVault,
@@ -19,14 +19,14 @@ import {
19
19
  listVaults,
20
20
  setEntry,
21
21
  updateVault
22
- } from "./chunk-BYIU4WAQ.js";
22
+ } from "./chunk-TWX2D563.js";
23
23
  import {
24
24
  getAgent
25
- } from "./chunk-M3752GFZ.js";
25
+ } from "./chunk-P7TV5XP4.js";
26
26
  import {
27
27
  getDb,
28
28
  init_client
29
- } from "./chunk-KQTTKYZY.js";
29
+ } from "./chunk-W3YXUIPS.js";
30
30
  import {
31
31
  badRequest,
32
32
  conflict,
@@ -10,10 +10,10 @@ import {
10
10
  import {
11
11
  getDrizzle,
12
12
  init_drizzle
13
- } from "./chunk-FILGQF2G.js";
13
+ } from "./chunk-JWVVF66Q.js";
14
14
  import {
15
15
  schema_exports
16
- } from "./chunk-VC5DELR4.js";
16
+ } from "./chunk-SZNZZB7J.js";
17
17
 
18
18
  // src/db/files.ts
19
19
  init_drizzle();
@@ -96,15 +96,11 @@ function listFiles(opts) {
96
96
  WHERE f.scope_id = ${opts.scope_id} AND f2.id IS NULL${cursorClause}
97
97
  ORDER BY f.id DESC LIMIT ${limit + 1}`
98
98
  );
99
- const has_more2 = rows2.length > limit;
100
- if (has_more2) rows2.pop();
99
+ const hasMore2 = rows2.length > limit;
100
+ if (hasMore2) rows2.pop();
101
101
  const records2 = rows2.map(hydrate);
102
- return {
103
- data: records2,
104
- has_more: has_more2,
105
- first_id: records2.length > 0 ? records2[0].id : null,
106
- last_id: records2.length > 0 ? records2[records2.length - 1].id : null
107
- };
102
+ const nextPage2 = hasMore2 && records2.length > 0 ? Buffer.from(records2[records2.length - 1].id).toString("base64url") : null;
103
+ return { data: records2, next_page: nextPage2 };
108
104
  }
109
105
  let cursorCondition;
110
106
  if (opts?.after_id) {
@@ -114,15 +110,11 @@ function listFiles(opts) {
114
110
  }
115
111
  const query = cursorCondition ? db.select().from(schema_exports.files).where(cursorCondition).orderBy(desc(schema_exports.files.id)).limit(limit + 1) : db.select().from(schema_exports.files).orderBy(desc(schema_exports.files.id)).limit(limit + 1);
116
112
  const rows = query.all();
117
- const has_more = rows.length > limit;
118
- if (has_more) rows.pop();
113
+ const hasMore = rows.length > limit;
114
+ if (hasMore) rows.pop();
119
115
  const records = rows.map(hydrate);
120
- return {
121
- data: records,
122
- has_more,
123
- first_id: records.length > 0 ? records[0].id : null,
124
- last_id: records.length > 0 ? records[records.length - 1].id : null
125
- };
116
+ const nextPage = hasMore && records.length > 0 ? Buffer.from(records[records.length - 1].id).toString("base64url") : null;
117
+ return { data: records, next_page: nextPage };
126
118
  }
127
119
  function countFilesForScope(scopeId) {
128
120
  const db = getDrizzle();
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  markStopping
3
- } from "./chunk-LW4OCFIP.js";
3
+ } from "./chunk-2RIOHWZW.js";
4
4
  import {
5
5
  closeDb,
6
6
  init_client,
7
7
  syncDb
8
- } from "./chunk-KQTTKYZY.js";
8
+ } from "./chunk-W3YXUIPS.js";
9
9
  import {
10
10
  getRuntime
11
11
  } from "./chunk-UYTSKFGK.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  jsonOk,
3
3
  routeWrap
4
- } from "./chunk-6URMGCAC.js";
4
+ } from "./chunk-IYVGGJMH.js";
5
5
  import {
6
6
  readSetting,
7
7
  writeSetting
8
- } from "./chunk-UGH5JDXX.js";
8
+ } from "./chunk-P2NWS65Y.js";
9
9
  import {
10
10
  badRequest
11
11
  } from "./chunk-EZYKRG4W.js";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  init_schema,
3
3
  schema_exports
4
- } from "./chunk-VC5DELR4.js";
4
+ } from "./chunk-SZNZZB7J.js";
5
5
  import {
6
6
  getDb,
7
7
  init_client
8
- } from "./chunk-KQTTKYZY.js";
8
+ } from "./chunk-W3YXUIPS.js";
9
9
  import {
10
10
  __esm
11
11
  } from "./chunk-2ESYSVXG.js";
@@ -10,14 +10,14 @@ import {
10
10
  import {
11
11
  getDrizzle,
12
12
  init_drizzle
13
- } from "./chunk-FILGQF2G.js";
13
+ } from "./chunk-JWVVF66Q.js";
14
14
  import {
15
15
  schema_exports
16
- } from "./chunk-VC5DELR4.js";
16
+ } from "./chunk-SZNZZB7J.js";
17
17
  import {
18
18
  getDb,
19
19
  init_client
20
- } from "./chunk-KQTTKYZY.js";
20
+ } from "./chunk-W3YXUIPS.js";
21
21
 
22
22
  // src/db/events.ts
23
23
  init_client();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-UGH5JDXX.js";
3
+ } from "./chunk-P2NWS65Y.js";
4
4
  import {
5
5
  serverBusy
6
6
  } from "./chunk-EZYKRG4W.js";
@@ -0,0 +1,176 @@
1
+ import {
2
+ init_ids,
3
+ newId
4
+ } from "./chunk-F4WUVOLE.js";
5
+ import {
6
+ init_clock,
7
+ nowMs,
8
+ toIso
9
+ } from "./chunk-HFDLUBWN.js";
10
+ import {
11
+ getDrizzle,
12
+ init_drizzle
13
+ } from "./chunk-JWVVF66Q.js";
14
+ import {
15
+ schema_exports
16
+ } from "./chunk-SZNZZB7J.js";
17
+
18
+ // src/db/skills.ts
19
+ init_drizzle();
20
+ init_ids();
21
+ init_clock();
22
+ import { eq, and, isNull, lt, desc } from "drizzle-orm";
23
+ function hydrateSkill(row) {
24
+ return {
25
+ type: "skill",
26
+ id: row.id,
27
+ name: row.name,
28
+ description: row.description ?? "",
29
+ current_version: row.current_version ?? "1.0.0",
30
+ created_at: toIso(row.created_at),
31
+ updated_at: toIso(row.updated_at),
32
+ archived_at: row.archived_at ? toIso(row.archived_at) : null
33
+ };
34
+ }
35
+ function hydrateSkillVersion(row) {
36
+ return {
37
+ type: "skill_version",
38
+ id: row.id,
39
+ skill_id: row.skill_id,
40
+ version: row.version,
41
+ content: row.content,
42
+ created_at: toIso(row.created_at)
43
+ };
44
+ }
45
+ function createSkill(input) {
46
+ const db = getDrizzle();
47
+ const id = newId("skill");
48
+ const versionId = newId("sklv");
49
+ const now = nowMs();
50
+ const version = "1.0.0";
51
+ db.transaction((tx) => {
52
+ tx.insert(schema_exports.skills).values({
53
+ id,
54
+ name: input.name,
55
+ description: input.description ?? null,
56
+ current_version: version,
57
+ tenant_id: input.tenantId ?? null,
58
+ created_at: now,
59
+ updated_at: now
60
+ }).run();
61
+ tx.insert(schema_exports.skillVersions).values({
62
+ id: versionId,
63
+ skill_id: id,
64
+ version,
65
+ content: input.content,
66
+ created_at: now
67
+ }).run();
68
+ });
69
+ return getSkill(id);
70
+ }
71
+ function getSkill(id) {
72
+ const db = getDrizzle();
73
+ const row = db.select().from(schema_exports.skills).where(eq(schema_exports.skills.id, id)).get();
74
+ if (!row) return void 0;
75
+ return hydrateSkill(row);
76
+ }
77
+ function listSkills(opts) {
78
+ const db = getDrizzle();
79
+ const limit = Math.min(Math.max(opts?.limit ?? 20, 1), 100);
80
+ const includeArchived = opts?.includeArchived ?? false;
81
+ const conditions = [];
82
+ if (!includeArchived) conditions.push(isNull(schema_exports.skills.archived_at));
83
+ if (opts?.cursor) {
84
+ conditions.push(lt(schema_exports.skills.id, opts.cursor));
85
+ }
86
+ if (opts?.tenantId != null) {
87
+ conditions.push(eq(schema_exports.skills.tenant_id, opts.tenantId));
88
+ }
89
+ const where = conditions.length ? and(...conditions) : void 0;
90
+ const rows = where ? db.select().from(schema_exports.skills).where(where).orderBy(desc(schema_exports.skills.id)).limit(limit).all() : db.select().from(schema_exports.skills).orderBy(desc(schema_exports.skills.id)).limit(limit).all();
91
+ return rows.map((r) => hydrateSkill(r));
92
+ }
93
+ function deleteSkill(id) {
94
+ const db = getDrizzle();
95
+ let deleted = false;
96
+ db.transaction((tx) => {
97
+ tx.delete(schema_exports.skillVersions).where(eq(schema_exports.skillVersions.skill_id, id)).run();
98
+ const res = tx.delete(schema_exports.skills).where(eq(schema_exports.skills.id, id)).run();
99
+ deleted = res.changes > 0;
100
+ });
101
+ return deleted;
102
+ }
103
+ function autoIncrement(current) {
104
+ const parts = current.split(".");
105
+ if (parts.length !== 3) return `${current}.1`;
106
+ const patch = parseInt(parts[2], 10);
107
+ return `${parts[0]}.${parts[1]}.${isNaN(patch) ? 1 : patch + 1}`;
108
+ }
109
+ function createSkillVersion(skillId, input) {
110
+ const db = getDrizzle();
111
+ const skill = db.select().from(schema_exports.skills).where(eq(schema_exports.skills.id, skillId)).get();
112
+ if (!skill) return void 0;
113
+ const version = input.version ?? autoIncrement(skill.current_version ?? "1.0.0");
114
+ const id = newId("sklv");
115
+ const now = nowMs();
116
+ db.transaction((tx) => {
117
+ tx.insert(schema_exports.skillVersions).values({
118
+ id,
119
+ skill_id: skillId,
120
+ version,
121
+ content: input.content,
122
+ created_at: now
123
+ }).run();
124
+ tx.update(schema_exports.skills).set({ current_version: version, updated_at: now }).where(eq(schema_exports.skills.id, skillId)).run();
125
+ });
126
+ return getSkillVersion(skillId, version);
127
+ }
128
+ function getSkillVersion(skillId, version) {
129
+ const db = getDrizzle();
130
+ const row = db.select().from(schema_exports.skillVersions).where(
131
+ and(
132
+ eq(schema_exports.skillVersions.skill_id, skillId),
133
+ eq(schema_exports.skillVersions.version, version)
134
+ )
135
+ ).get();
136
+ if (!row) return void 0;
137
+ return hydrateSkillVersion(row);
138
+ }
139
+ function listSkillVersions(skillId, opts) {
140
+ const db = getDrizzle();
141
+ const limit = Math.min(Math.max(opts?.limit ?? 20, 1), 100);
142
+ const conditions = [eq(schema_exports.skillVersions.skill_id, skillId)];
143
+ if (opts?.cursor) {
144
+ conditions.push(lt(schema_exports.skillVersions.id, opts.cursor));
145
+ }
146
+ const rows = db.select().from(schema_exports.skillVersions).where(and(...conditions)).orderBy(desc(schema_exports.skillVersions.created_at)).limit(limit).all();
147
+ return rows.map(
148
+ (r) => hydrateSkillVersion(r)
149
+ );
150
+ }
151
+ function deleteSkillVersion(skillId, version) {
152
+ const db = getDrizzle();
153
+ const skill = db.select().from(schema_exports.skills).where(eq(schema_exports.skills.id, skillId)).get();
154
+ if (!skill) return { ok: false, reason: "skill not found" };
155
+ if (skill.current_version === version) {
156
+ return { ok: false, reason: "cannot delete the current version" };
157
+ }
158
+ const res = db.delete(schema_exports.skillVersions).where(
159
+ and(
160
+ eq(schema_exports.skillVersions.skill_id, skillId),
161
+ eq(schema_exports.skillVersions.version, version)
162
+ )
163
+ ).run();
164
+ return { ok: res.changes > 0 };
165
+ }
166
+
167
+ export {
168
+ createSkill,
169
+ getSkill,
170
+ listSkills,
171
+ deleteSkill,
172
+ createSkillVersion,
173
+ getSkillVersion,
174
+ listSkillVersions,
175
+ deleteSkillVersion
176
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-UGH5JDXX.js";
3
+ } from "./chunk-P2NWS65Y.js";
4
4
 
5
5
  // src/backends/factory/auth.ts
6
6
  function buildFactoryAuthEnv() {
@@ -2,19 +2,19 @@ import {
2
2
  getSyncRow,
3
3
  getSyncedRemoteId,
4
4
  upsertSync
5
- } from "./chunk-AESA3ARX.js";
5
+ } from "./chunk-3ST3YLED.js";
6
6
  import {
7
7
  injectMcpAuthHeaders
8
8
  } from "./chunk-DBFPJSOY.js";
9
9
  import {
10
10
  listEntries
11
- } from "./chunk-BYIU4WAQ.js";
11
+ } from "./chunk-TWX2D563.js";
12
12
  import {
13
13
  getEnvironment
14
- } from "./chunk-7APAOJIZ.js";
14
+ } from "./chunk-UKCRJFFC.js";
15
15
  import {
16
16
  getAgent
17
- } from "./chunk-M3752GFZ.js";
17
+ } from "./chunk-P7TV5XP4.js";
18
18
 
19
19
  // src/sync/anthropic.ts
20
20
  import { createHash } from "crypto";
@@ -8,17 +8,17 @@ import {
8
8
  jsonOk,
9
9
  paginatedOk,
10
10
  routeWrap
11
- } from "./chunk-6URMGCAC.js";
11
+ } from "./chunk-IYVGGJMH.js";
12
12
  import {
13
13
  forwardToAnthropic,
14
14
  validateAnthropicProxy
15
- } from "./chunk-Y4MI27HU.js";
15
+ } from "./chunk-DL7IPOZF.js";
16
16
  import {
17
17
  getProxiedTenantId,
18
18
  isProxied,
19
19
  markProxied,
20
20
  unmarkProxied
21
- } from "./chunk-MTLM36QD.js";
21
+ } from "./chunk-X7Y4TV6O.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-M3752GFZ.js";
29
+ } from "./chunk-P7TV5XP4.js";
30
30
  import {
31
31
  resolveBackend
32
- } from "./chunk-Q2JYAAJO.js";
32
+ } from "./chunk-64AWIKIO.js";
33
33
  import {
34
34
  getDb,
35
35
  init_client
36
- } from "./chunk-KQTTKYZY.js";
36
+ } from "./chunk-W3YXUIPS.js";
37
37
  import {
38
38
  badRequest,
39
39
  conflict,
@@ -60,13 +60,19 @@ function assertProxiedAgentTenant(auth, id) {
60
60
  if (proxied === void 0) return;
61
61
  assertResourceTenant(auth, proxied, `agent ${id} not found`);
62
62
  }
63
- var SkillSchema = z.object({
63
+ var InlineSkillSchema = z.object({
64
64
  name: z.string().min(1),
65
65
  source: z.string().min(1),
66
66
  content: z.string().min(1).max(256 * 1024),
67
67
  // 256KB per skill
68
68
  installed_at: z.string().optional()
69
69
  });
70
+ var RefSkillSchema = z.object({
71
+ skill_id: z.string().min(1),
72
+ type: z.enum(["custom", "anthropic"]).optional(),
73
+ version: z.string().optional()
74
+ });
75
+ var SkillSchema = z.union([InlineSkillSchema, RefSkillSchema]);
70
76
  var ToolSchema = z.union([
71
77
  z.object({
72
78
  type: z.literal("agent_toolset_20260401"),
@@ -83,6 +89,35 @@ var ToolSchema = z.union([
83
89
  var ModelConfigSchema = z.object({
84
90
  speed: z.enum(["standard", "fast"]).optional()
85
91
  });
92
+ async function resolveSkillInputs(skills, nowIso) {
93
+ if (!skills) return void 0;
94
+ const resolved = [];
95
+ for (const s of skills) {
96
+ if ("skill_id" in s && s.skill_id) {
97
+ const { getSkill: dbGetSkill, getSkillVersion: dbGetSkillVersion } = await import("./db/skills.js");
98
+ const dbSkill = dbGetSkill(s.skill_id);
99
+ if (!dbSkill) throw badRequest(`skill ${s.skill_id} not found`);
100
+ const version = s.version ?? dbSkill.current_version;
101
+ const sv = dbGetSkillVersion(s.skill_id, version);
102
+ if (!sv) throw badRequest(`skill version ${version} not found for skill ${s.skill_id}`);
103
+ resolved.push({
104
+ name: dbSkill.name,
105
+ source: `skill:${s.skill_id}@${version}`,
106
+ content: sv.content,
107
+ installed_at: nowIso
108
+ });
109
+ } else {
110
+ const inline = s;
111
+ resolved.push({
112
+ name: inline.name,
113
+ source: inline.source,
114
+ content: inline.content,
115
+ installed_at: inline.installed_at ?? nowIso
116
+ });
117
+ }
118
+ }
119
+ return resolved;
120
+ }
86
121
  var CreateSchema = z.object({
87
122
  name: z.string().min(1),
88
123
  model: z.object({ id: z.string().min(1), speed: z.enum(["standard", "fast"]).optional() }),
@@ -129,7 +164,9 @@ var CreateSchema = z.object({
129
164
  return Object.keys(data.metadata).length <= 16;
130
165
  }, "metadata exceeds 16 key limit").refine((data) => {
131
166
  if (!data.skills) return true;
132
- const total = data.skills.reduce((sum, s) => sum + s.content.length, 0);
167
+ const total = data.skills.reduce((sum, s) => {
168
+ return sum + (s.content?.length ?? 0);
169
+ }, 0);
133
170
  return total <= 1024 * 1024;
134
171
  }, "Total skills content exceeds 1MB limit");
135
172
  var UpdateSchema = z.object({
@@ -171,7 +208,9 @@ var UpdateSchema = z.object({
171
208
  return Object.keys(data.metadata).length <= 16;
172
209
  }, "metadata exceeds 16 key limit").refine((data) => {
173
210
  if (!data.skills) return true;
174
- const total = data.skills.reduce((sum, s) => sum + s.content.length, 0);
211
+ const total = data.skills.reduce((sum, s) => {
212
+ return sum + (s.content?.length ?? 0);
213
+ }, 0);
175
214
  return total <= 1024 * 1024;
176
215
  }, "Total skills content exceeds 1MB limit");
177
216
  function handleCreateAgent(request) {
@@ -246,10 +285,7 @@ function handleCreateAgent(request) {
246
285
  confirmation_mode: parsed.data.confirmation_mode ?? false,
247
286
  callable_agents: parsed.data.callable_agents,
248
287
  multiagent: parsed.data.multiagent,
249
- skills: parsed.data.skills?.map((s) => ({
250
- ...s,
251
- installed_at: s.installed_at ?? nowIso
252
- })),
288
+ skills: await resolveSkillInputs(parsed.data.skills, nowIso),
253
289
  model_config: mergedModelConfig,
254
290
  tenant_id: createTenantId
255
291
  });
@@ -329,10 +365,7 @@ function handleUpdateAgent(request, id) {
329
365
  confirmation_mode: parsed.data.confirmation_mode,
330
366
  callable_agents: parsed.data.callable_agents,
331
367
  multiagent: parsed.data.multiagent,
332
- skills: parsed.data.skills?.map((s) => ({
333
- ...s,
334
- installed_at: s.installed_at ?? nowIso
335
- })),
368
+ skills: await resolveSkillInputs(parsed.data.skills, nowIso),
336
369
  model_config: mergedModelConfig
337
370
  });
338
371
  if (!updated) throw notFound(`agent ${id} not found`);