@agentstep/agent-sdk 0.5.5 → 0.5.7

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 (182) 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 +7 -7
  6. package/dist/backends/factory/auth.js +6 -6
  7. package/dist/backends/factory/index.js +7 -7
  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 +7 -7
  12. package/dist/backends/pi/auth.js +6 -6
  13. package/dist/backends/pi/index.js +7 -7
  14. package/dist/backends/registry.js +18 -18
  15. package/dist/{chunk-KB7MV6VS.js → chunk-2DXEIQMQ.js} +1 -1
  16. package/dist/{chunk-J2SP5UND.js → chunk-2VGJPWZT.js} +4 -4
  17. package/dist/{chunk-5TOLDBBJ.js → chunk-32RP2UX6.js} +5 -5
  18. package/dist/{chunk-A7DBW4MD.js → chunk-34Q6WMIT.js} +3 -3
  19. package/dist/{chunk-PEEKWYYE.js → chunk-3G2FFIVP.js} +1 -1
  20. package/dist/{chunk-H355W724.js → chunk-3HVBY7VD.js} +2 -2
  21. package/dist/{chunk-B374MDPO.js → chunk-3OPG6B65.js} +1 -1
  22. package/dist/{chunk-2GIAAUSW.js → chunk-3TF3YLM2.js} +2 -2
  23. package/dist/{chunk-UKIOGRMN.js → chunk-3UBK2O57.js} +5 -5
  24. package/dist/{chunk-UKCIGI3T.js → chunk-3YDLTEGR.js} +3 -3
  25. package/dist/{chunk-UFAYAE3A.js → chunk-5BNGGJV6.js} +7 -7
  26. package/dist/{chunk-DXRTOMZP.js → chunk-5COWXLGO.js} +1 -1
  27. package/dist/{chunk-SMM7YOM2.js → chunk-5HXT5NSJ.js} +2 -2
  28. package/dist/{chunk-YICDEIRE.js → chunk-5JCCYISE.js} +2 -2
  29. package/dist/{chunk-UKCRJFFC.js → chunk-6BOOQV4Q.js} +3 -3
  30. package/dist/{chunk-W4FZ4HYD.js → chunk-6ERUVF2Y.js} +1 -1
  31. package/dist/{chunk-MFSO7IGE.js → chunk-6SVZD3UA.js} +4 -4
  32. package/dist/{chunk-HRBNDS5T.js → chunk-6Z4YEGYD.js} +1 -1
  33. package/dist/{chunk-YSZLX4WE.js → chunk-73BYGQWA.js} +1 -1
  34. package/dist/{chunk-DQW2QEK5.js → chunk-7POF237O.js} +1 -1
  35. package/dist/{chunk-RA25CUV4.js → chunk-APARWNCM.js} +13 -13
  36. package/dist/chunk-AQLWTYNS.js +250 -0
  37. package/dist/{chunk-JCOR7AIY.js → chunk-ARL7RN6C.js} +2 -2
  38. package/dist/{chunk-BZYAXHRB.js → chunk-AXWZTODF.js} +6 -6
  39. package/dist/{chunk-J6WSFODH.js → chunk-BUQATYS7.js} +2 -2
  40. package/dist/{chunk-X65C4UZH.js → chunk-CZ4IOIWV.js} +4 -4
  41. package/dist/{chunk-C4YHYPOW.js → chunk-D4CBGBKT.js} +5 -5
  42. package/dist/{chunk-ZIZU3B65.js → chunk-DEKWVSQK.js} +1 -1
  43. package/dist/{chunk-ADSZ2OCX.js → chunk-DFUPVJKV.js} +2 -2
  44. package/dist/{chunk-X7Y4TV6O.js → chunk-EFSLGRY2.js} +2 -2
  45. package/dist/{chunk-P7TV5XP4.js → chunk-EGN4TPN5.js} +3 -3
  46. package/dist/{chunk-R6M4V3IG.js → chunk-EXN2NONS.js} +2 -2
  47. package/dist/{chunk-XNEUJKY4.js → chunk-EZBJEV6F.js} +4 -4
  48. package/dist/{chunk-KYLDNVV7.js → chunk-F6DCNXO5.js} +8 -2
  49. package/dist/{chunk-DYRGMJTC.js → chunk-FNFS74EP.js} +2 -2
  50. package/dist/{chunk-HWVBBUL2.js → chunk-G3B2BDUE.js} +1 -1
  51. package/dist/{chunk-AJOG6UYH.js → chunk-G6SI3MDW.js} +1 -1
  52. package/dist/{chunk-ZXJTXNUX.js → chunk-GK7LQNKY.js} +4 -4
  53. package/dist/{chunk-5435RAMR.js → chunk-HIIM7A4Q.js} +1 -1
  54. package/dist/{chunk-GOFQ63N3.js → chunk-IF64USTR.js} +8 -8
  55. package/dist/{chunk-DAKCDGWV.js → chunk-J33REEFH.js} +1 -1
  56. package/dist/{chunk-P5X2DSGQ.js → chunk-KCUHYKIP.js} +3 -3
  57. package/dist/{chunk-PKWN44LF.js → chunk-KKLLTAQQ.js} +4 -4
  58. package/dist/{chunk-UK3ZFCQP.js → chunk-KLCRX63Y.js} +1 -1
  59. package/dist/{chunk-OACMO7AL.js → chunk-KXLPWOI4.js} +12 -12
  60. package/dist/{chunk-64M4Z6HW.js → chunk-LSXVCZN7.js} +1 -1
  61. package/dist/{chunk-P5DSHKKP.js → chunk-M7LFWHA3.js} +34 -21
  62. package/dist/{chunk-LII6JJQT.js → chunk-MAOXZP7E.js} +1 -1
  63. package/dist/{chunk-K2UJFAGD.js → chunk-N33MOUCH.js} +3 -3
  64. package/dist/{chunk-PVVJCRII.js → chunk-N5C3WQWD.js} +1 -1
  65. package/dist/{chunk-C3PD6T4A.js → chunk-NDTZG7NB.js} +1 -1
  66. package/dist/{chunk-P2NWS65Y.js → chunk-NWZPKG3G.js} +2 -2
  67. package/dist/{chunk-TWX2D563.js → chunk-OJUDLJOG.js} +3 -3
  68. package/dist/{chunk-IN3EHQ4Z.js → chunk-PIJJXKMK.js} +3 -3
  69. package/dist/{chunk-7OM5LP3K.js → chunk-PT5FGQZB.js} +1 -1
  70. package/dist/{chunk-B2VM6IRJ.js → chunk-Q2G2QKTZ.js} +15 -15
  71. package/dist/{chunk-IUMA4QRX.js → chunk-QGHWKN2M.js} +1 -1
  72. package/dist/{chunk-2LTNC5C7.js → chunk-RJCLHFWA.js} +2 -2
  73. package/dist/{chunk-3ST3YLED.js → chunk-RNDLMMKI.js} +3 -3
  74. package/dist/{chunk-SZNZZB7J.js → chunk-RNU253MD.js} +1 -0
  75. package/dist/{chunk-CZH5FQSF.js → chunk-S2GD72CC.js} +1 -1
  76. package/dist/{chunk-TXOB3PZH.js → chunk-SCRLGKCC.js} +13 -13
  77. package/dist/{chunk-6ZODIFRZ.js → chunk-T64ECODW.js} +6 -0
  78. package/dist/{chunk-DPR6K7Y4.js → chunk-T6ZXOA2W.js} +5 -5
  79. package/dist/{chunk-JWVVF66Q.js → chunk-T75UYYMI.js} +2 -2
  80. package/dist/{chunk-JP4HHXHY.js → chunk-THVU4BTX.js} +5 -5
  81. package/dist/{chunk-2RIOHWZW.js → chunk-TJ6EX4FW.js} +6 -6
  82. package/dist/{chunk-WOL4EVCE.js → chunk-UI3TCXQC.js} +1 -1
  83. package/dist/{chunk-ZFMAACZT.js → chunk-UKFWI4CL.js} +2 -2
  84. package/dist/{chunk-YTZQ5J6L.js → chunk-UVVDA2AR.js} +3 -3
  85. package/dist/{chunk-C4GMG6IB.js → chunk-V2LLSXMZ.js} +3 -3
  86. package/dist/{chunk-D5E5XJAU.js → chunk-V5SSKSIN.js} +3 -3
  87. package/dist/{chunk-JPONGXV5.js → chunk-VNDSLOHF.js} +2 -2
  88. package/dist/{chunk-5WY3LSCS.js → chunk-VNOEO3ZC.js} +1 -1
  89. package/dist/{chunk-DL7IPOZF.js → chunk-W5GVMKIA.js} +1 -1
  90. package/dist/{chunk-NOJ3ERIN.js → chunk-WZKPK2N2.js} +9 -6
  91. package/dist/{chunk-PUH4LEJZ.js → chunk-X2ER52RZ.js} +1 -1
  92. package/dist/{chunk-DMROEZYE.js → chunk-X7KPF2Y7.js} +4 -4
  93. package/dist/{chunk-64AWIKIO.js → chunk-XENSLGF5.js} +6 -6
  94. package/dist/{chunk-W3YXUIPS.js → chunk-XUODI55L.js} +1 -1
  95. package/dist/{chunk-TC7UW22R.js → chunk-Y3EUEPGQ.js} +2 -2
  96. package/dist/{chunk-IYVGGJMH.js → chunk-YGWFHNLV.js} +2 -2
  97. package/dist/{chunk-FSQ6I3C7.js → chunk-YN2F26NN.js} +2 -2
  98. package/dist/{chunk-P4B4V4SV.js → chunk-Z4DZMNDE.js} +2 -2
  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 +30 -30
  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 +3 -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 +5 -5
  115. package/dist/db/migrations.js +1 -1
  116. package/dist/db/proxy.js +5 -5
  117. package/dist/db/schema.js +1 -1
  118. package/dist/db/session-resources.js +5 -5
  119. package/dist/db/sessions.js +8 -8
  120. package/dist/db/skills.js +5 -5
  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 +45 -45
  129. package/dist/handlers/api_keys.js +46 -46
  130. package/dist/handlers/audit.js +46 -46
  131. package/dist/handlers/batch.js +46 -46
  132. package/dist/handlers/credentials.js +46 -46
  133. package/dist/handlers/environments.js +46 -46
  134. package/dist/handlers/events.js +49 -49
  135. package/dist/handlers/files.js +46 -46
  136. package/dist/handlers/index.js +84 -84
  137. package/dist/handlers/license.js +45 -45
  138. package/dist/handlers/memory.js +47 -47
  139. package/dist/handlers/metrics.js +45 -45
  140. package/dist/handlers/models.js +46 -46
  141. package/dist/handlers/providers.js +45 -45
  142. package/dist/handlers/resources.js +45 -45
  143. package/dist/handlers/sessions.js +49 -49
  144. package/dist/handlers/settings.js +45 -45
  145. package/dist/handlers/skills-write.js +46 -46
  146. package/dist/handlers/skills.js +46 -46
  147. package/dist/handlers/stream.js +45 -45
  148. package/dist/handlers/tenants.js +46 -46
  149. package/dist/handlers/threads.js +46 -46
  150. package/dist/handlers/traces.js +46 -46
  151. package/dist/handlers/upstream_keys.js +48 -48
  152. package/dist/handlers/vaults.js +45 -45
  153. package/dist/handlers/whoami.js +45 -45
  154. package/dist/http.js +44 -44
  155. package/dist/index.js +49 -49
  156. package/dist/init.js +41 -41
  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 +5 -5
  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 +34 -34
  172. package/dist/sessions/grader.js +5 -5
  173. package/dist/sessions/secrets.js +8 -8
  174. package/dist/sessions/sweeper.js +31 -31
  175. package/dist/sessions/threads.js +35 -35
  176. package/dist/shutdown.js +32 -32
  177. package/dist/sync/anthropic.js +10 -10
  178. package/dist/sync/container-file-sync.js +6 -6
  179. package/dist/sync/file-sync.js +17 -17
  180. package/package.json +1 -1
  181. package/dist/chunk-V5EEO7MU.js +0 -129
  182. /package/dist/{chunk-ZJERBDQE.js → chunk-4ACUGMBT.js} +0 -0
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  getDb,
16
16
  init_client
17
- } from "./chunk-W3YXUIPS.js";
17
+ } from "./chunk-XUODI55L.js";
18
18
 
19
19
  // src/db/credentials.ts
20
20
  init_client();
@@ -18,14 +18,14 @@ import {
18
18
  import {
19
19
  buildClaudeArgs,
20
20
  buildClaudeAuthEnv
21
- } from "./chunk-HWVBBUL2.js";
21
+ } from "./chunk-G3B2BDUE.js";
22
22
  import {
23
23
  CLAUDE_WRAPPER_PATH,
24
24
  installClaudeWrapper
25
25
  } from "./chunk-QBJOYOVF.js";
26
26
  import {
27
27
  getConfig
28
- } from "./chunk-P2NWS65Y.js";
28
+ } from "./chunk-NWZPKG3G.js";
29
29
 
30
30
  // src/backends/claude/index.ts
31
31
  function buildTurn(input) {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  resolveContainerProvider
3
- } from "./chunk-ZJERBDQE.js";
3
+ } from "./chunk-4ACUGMBT.js";
4
4
  import {
5
5
  getEnvironmentRow,
6
6
  updateEnvironmentState
7
- } from "./chunk-UKCRJFFC.js";
7
+ } from "./chunk-6BOOQV4Q.js";
8
8
  import {
9
9
  installClaudeWrapper
10
10
  } from "./chunk-QBJOYOVF.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_TENANT_ID
3
- } from "./chunk-64M4Z6HW.js";
3
+ } from "./chunk-LSXVCZN7.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-JWVVF66Q.js";
16
+ } from "./chunk-T75UYYMI.js";
17
17
  import {
18
18
  schema_exports
19
- } from "./chunk-SZNZZB7J.js";
19
+ } from "./chunk-RNU253MD.js";
20
20
 
21
21
  // src/db/environments.ts
22
22
  init_drizzle();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  listEntries
3
- } from "./chunk-TWX2D563.js";
3
+ } from "./chunk-OJUDLJOG.js";
4
4
 
5
5
  // src/providers/resolve-secrets.ts
6
6
  var BLOCKED_ENV_KEYS = /* @__PURE__ */ new Set([
@@ -2,19 +2,19 @@ import {
2
2
  getSyncRow,
3
3
  getSyncedRemoteId,
4
4
  upsertSync
5
- } from "./chunk-3ST3YLED.js";
5
+ } from "./chunk-RNDLMMKI.js";
6
6
  import {
7
7
  injectMcpAuthHeaders
8
8
  } from "./chunk-DBFPJSOY.js";
9
9
  import {
10
10
  listEntries
11
- } from "./chunk-TWX2D563.js";
11
+ } from "./chunk-OJUDLJOG.js";
12
12
  import {
13
13
  getEnvironment
14
- } from "./chunk-UKCRJFFC.js";
14
+ } from "./chunk-6BOOQV4Q.js";
15
15
  import {
16
16
  getAgent
17
- } from "./chunk-P7TV5XP4.js";
17
+ } from "./chunk-EGN4TPN5.js";
18
18
 
19
19
  // src/sync/anthropic.ts
20
20
  import { createHash } from "crypto";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  buildGeminiAuthEnv,
6
6
  validateGeminiRuntime
7
- } from "./chunk-AJOG6UYH.js";
7
+ } from "./chunk-G6SI3MDW.js";
8
8
  import {
9
9
  prepareGeminiOnSandbox
10
10
  } from "./chunk-XG4UIGDH.js";
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  getDb,
15
15
  init_client
16
- } from "./chunk-W3YXUIPS.js";
16
+ } from "./chunk-XUODI55L.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-JWVVF66Q.js";
4
+ } from "./chunk-T75UYYMI.js";
5
5
 
6
6
  // src/db/traces.ts
7
7
  init_drizzle();
@@ -2,10 +2,10 @@ import {
2
2
  reportUpstreamFailure,
3
3
  reportUpstreamSuccess,
4
4
  resolveAnthropicKey
5
- } from "./chunk-DMROEZYE.js";
5
+ } from "./chunk-X7KPF2Y7.js";
6
6
  import {
7
7
  resolveRemoteSessionId
8
- } from "./chunk-3ST3YLED.js";
8
+ } from "./chunk-RNDLMMKI.js";
9
9
  import {
10
10
  assertResourceTenant
11
11
  } from "./chunk-23UKWXJH.js";
@@ -20,46 +20,46 @@ import {
20
20
  listMemoryStores,
21
21
  searchMemories,
22
22
  updateMemory
23
- } from "./chunk-FSQ6I3C7.js";
23
+ } from "./chunk-YN2F26NN.js";
24
24
  import {
25
25
  jsonOk,
26
26
  paginatedOk,
27
27
  routeWrap
28
- } from "./chunk-IYVGGJMH.js";
28
+ } from "./chunk-YGWFHNLV.js";
29
29
  import {
30
30
  forwardToAnthropic
31
- } from "./chunk-DL7IPOZF.js";
31
+ } from "./chunk-W5GVMKIA.js";
32
32
  import {
33
33
  enqueueTurn
34
- } from "./chunk-KB7MV6VS.js";
34
+ } from "./chunk-2DXEIQMQ.js";
35
35
  import {
36
36
  runTurn,
37
37
  writePermissionResponse
38
- } from "./chunk-OACMO7AL.js";
38
+ } from "./chunk-KXLPWOI4.js";
39
39
  import {
40
40
  getProxiedTenantId,
41
41
  isProxied
42
- } from "./chunk-X7Y4TV6O.js";
42
+ } from "./chunk-EFSLGRY2.js";
43
43
  import {
44
44
  getActor
45
45
  } from "./chunk-LAWTTG2E.js";
46
46
  import {
47
47
  appendEvent
48
- } from "./chunk-X65C4UZH.js";
48
+ } from "./chunk-CZ4IOIWV.js";
49
49
  import {
50
50
  bumpSessionStats,
51
51
  getSession,
52
52
  getSessionRow,
53
53
  setOutcomeCriteria,
54
54
  updateSessionMutable
55
- } from "./chunk-5TOLDBBJ.js";
55
+ } from "./chunk-32RP2UX6.js";
56
56
  import {
57
57
  listEvents,
58
58
  rowToManagedEvent
59
- } from "./chunk-K2UJFAGD.js";
59
+ } from "./chunk-N33MOUCH.js";
60
60
  import {
61
61
  getAgent
62
- } from "./chunk-P7TV5XP4.js";
62
+ } from "./chunk-EGN4TPN5.js";
63
63
  import {
64
64
  init_clock,
65
65
  nowMs
@@ -67,7 +67,7 @@ import {
67
67
  import {
68
68
  getDb,
69
69
  init_client
70
- } from "./chunk-W3YXUIPS.js";
70
+ } from "./chunk-XUODI55L.js";
71
71
  import {
72
72
  badRequest,
73
73
  notFound
@@ -0,0 +1,250 @@
1
+ import {
2
+ createSkill,
3
+ createSkillVersion,
4
+ deleteSkill,
5
+ deleteSkillVersion,
6
+ getSkill,
7
+ getSkillVersion,
8
+ listSkillVersions
9
+ } from "./chunk-F6DCNXO5.js";
10
+ import {
11
+ resolveCreateTenant
12
+ } from "./chunk-23UKWXJH.js";
13
+ import {
14
+ decodeCursor,
15
+ jsonOk,
16
+ paginatedOk,
17
+ routeWrap
18
+ } from "./chunk-YGWFHNLV.js";
19
+ import {
20
+ badRequest,
21
+ notFound
22
+ } from "./chunk-EZYKRG4W.js";
23
+
24
+ // src/handlers/skills-write.ts
25
+ import { z } from "zod";
26
+ import { inflateRawSync } from "zlib";
27
+ function extractFromZipRaw(buffer) {
28
+ const files = /* @__PURE__ */ new Map();
29
+ let offset = 0;
30
+ while (offset + 30 <= buffer.length) {
31
+ const sig = buffer.readUInt32LE(offset);
32
+ if (sig !== 67324752) break;
33
+ const compMethod = buffer.readUInt16LE(offset + 8);
34
+ const compSize = buffer.readUInt32LE(offset + 18);
35
+ const uncompSize = buffer.readUInt32LE(offset + 22);
36
+ const nameLen = buffer.readUInt16LE(offset + 26);
37
+ const extraLen = buffer.readUInt16LE(offset + 28);
38
+ const name = buffer.toString("utf8", offset + 30, offset + 30 + nameLen);
39
+ const dataStart = offset + 30 + nameLen + extraLen;
40
+ if (compMethod === 0) {
41
+ files.set(name, buffer.subarray(dataStart, dataStart + uncompSize));
42
+ } else if (compMethod === 8) {
43
+ const compressed = buffer.subarray(dataStart, dataStart + compSize);
44
+ files.set(name, inflateRawSync(compressed));
45
+ }
46
+ offset = dataStart + compSize;
47
+ }
48
+ return files;
49
+ }
50
+ var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
51
+ ".md",
52
+ ".txt",
53
+ ".py",
54
+ ".js",
55
+ ".ts",
56
+ ".tsx",
57
+ ".jsx",
58
+ ".sh",
59
+ ".bash",
60
+ ".json",
61
+ ".yaml",
62
+ ".yml",
63
+ ".html",
64
+ ".css",
65
+ ".xml",
66
+ ".csv",
67
+ ".toml",
68
+ ".cfg",
69
+ ".ini",
70
+ ".sql",
71
+ ".rb",
72
+ ".go",
73
+ ".rs",
74
+ ".c",
75
+ ".h",
76
+ ".cpp",
77
+ ".java",
78
+ ".kt",
79
+ ".swift",
80
+ ".r",
81
+ ".pl",
82
+ ".lua",
83
+ ".env",
84
+ ".gitignore",
85
+ ".dockerfile",
86
+ ".makefile",
87
+ ".cmake",
88
+ ".conf",
89
+ ".properties",
90
+ ".lock"
91
+ ]);
92
+ function isTextFile(name) {
93
+ if (name.endsWith("/")) return false;
94
+ const dotIdx = name.lastIndexOf(".");
95
+ if (dotIdx === -1) return true;
96
+ return TEXT_EXTENSIONS.has(name.substring(dotIdx).toLowerCase());
97
+ }
98
+ function convertZipEntries(raw) {
99
+ const files = /* @__PURE__ */ new Map();
100
+ for (const [name, buf] of raw) {
101
+ if (isTextFile(name)) {
102
+ files.set(name, buf.toString("utf-8"));
103
+ } else {
104
+ files.set(name, "base64:" + buf.toString("base64"));
105
+ }
106
+ }
107
+ return files;
108
+ }
109
+ var CreateSkillSchema = z.object({
110
+ name: z.string().min(1).max(256),
111
+ description: z.string().max(2048).optional(),
112
+ content: z.string().min(1).max(256 * 1024),
113
+ // 256 KB
114
+ tenant_id: z.string().optional()
115
+ });
116
+ var CreateVersionSchema = z.object({
117
+ content: z.string().min(1).max(256 * 1024),
118
+ version: z.string().min(1).max(64).optional()
119
+ });
120
+ function handleCreateSkill(request) {
121
+ return routeWrap(request, async ({ auth }) => {
122
+ const contentType = request.headers.get("content-type") ?? "";
123
+ let name;
124
+ let description;
125
+ let content;
126
+ let filesMap;
127
+ let tenantId;
128
+ if (contentType.includes("multipart/form-data")) {
129
+ const formData = await request.formData();
130
+ name = (formData.get("display_title") ?? "").trim() || "untitled";
131
+ const file = formData.get("files[]") ?? formData.get("files") ?? formData.get("file");
132
+ if (!file || !(file instanceof File)) {
133
+ throw badRequest("Missing file in multipart upload");
134
+ }
135
+ const buffer = Buffer.from(await file.arrayBuffer());
136
+ if (file.name?.toLowerCase().endsWith(".zip")) {
137
+ const rawEntries = extractFromZipRaw(buffer);
138
+ const zipFiles = convertZipEntries(rawEntries);
139
+ const skillEntry = [...zipFiles.entries()].find(
140
+ ([k]) => k.endsWith("SKILL.md") || k.endsWith("skill.md")
141
+ );
142
+ if (!skillEntry) {
143
+ throw badRequest("No SKILL.md found in zip archive");
144
+ }
145
+ content = skillEntry[1];
146
+ const builtFiles = {};
147
+ const prefix = skillEntry[0].substring(0, skillEntry[0].lastIndexOf("/") + 1);
148
+ for (const [path, fileContent] of zipFiles.entries()) {
149
+ if (path.endsWith("/")) continue;
150
+ const relativePath = path.startsWith(prefix) ? path.slice(prefix.length) : path;
151
+ builtFiles[relativePath] = fileContent;
152
+ }
153
+ if (Object.keys(builtFiles).length > 1 || !builtFiles["SKILL.md"]) {
154
+ filesMap = builtFiles;
155
+ }
156
+ } else {
157
+ content = buffer.toString("utf-8");
158
+ }
159
+ tenantId = resolveCreateTenant(auth, void 0);
160
+ } else {
161
+ const body = await request.json().catch(() => null);
162
+ const parsed = CreateSkillSchema.safeParse(body);
163
+ if (!parsed.success) {
164
+ throw badRequest(
165
+ `invalid body: ${parsed.error.issues.map((i) => i.message).join("; ")}`
166
+ );
167
+ }
168
+ name = parsed.data.name;
169
+ description = parsed.data.description;
170
+ content = parsed.data.content;
171
+ tenantId = resolveCreateTenant(auth, parsed.data.tenant_id);
172
+ }
173
+ const skill = createSkill({ name, description, content, files: filesMap, tenantId });
174
+ return jsonOk(skill, 201);
175
+ });
176
+ }
177
+ function handleGetSkill(request, skillId) {
178
+ return routeWrap(request, async () => {
179
+ const skill = getSkill(skillId);
180
+ if (!skill) throw notFound(`skill ${skillId} not found`);
181
+ return jsonOk(skill);
182
+ });
183
+ }
184
+ function handleDeleteSkill(request, skillId) {
185
+ return routeWrap(request, async () => {
186
+ const ok = deleteSkill(skillId);
187
+ if (!ok) throw notFound(`skill ${skillId} not found`);
188
+ return jsonOk({ id: skillId, type: "skill_deleted" });
189
+ });
190
+ }
191
+ function handleCreateSkillVersion(request, skillId) {
192
+ return routeWrap(request, async () => {
193
+ const body = await request.json().catch(() => null);
194
+ const parsed = CreateVersionSchema.safeParse(body);
195
+ if (!parsed.success) {
196
+ throw badRequest(
197
+ `invalid body: ${parsed.error.issues.map((i) => i.message).join("; ")}`
198
+ );
199
+ }
200
+ const sv = createSkillVersion(skillId, {
201
+ content: parsed.data.content,
202
+ version: parsed.data.version
203
+ });
204
+ if (!sv) throw notFound(`skill ${skillId} not found`);
205
+ return jsonOk(sv, 201);
206
+ });
207
+ }
208
+ function handleListSkillVersions(request, skillId) {
209
+ return routeWrap(request, async ({ request: req }) => {
210
+ const skill = getSkill(skillId);
211
+ if (!skill) throw notFound(`skill ${skillId} not found`);
212
+ const url = new URL(req.url);
213
+ const limit = Math.min(
214
+ Math.max(Number(url.searchParams.get("limit") || "20"), 1),
215
+ 100
216
+ );
217
+ const cursor = decodeCursor(url.searchParams.get("after_id"));
218
+ const versions = listSkillVersions(skillId, { limit, cursor });
219
+ return paginatedOk(versions, limit);
220
+ });
221
+ }
222
+ function handleGetSkillVersion(request, skillId, version) {
223
+ return routeWrap(request, async () => {
224
+ const sv = getSkillVersion(skillId, version);
225
+ if (!sv) throw notFound(`skill version ${version} not found`);
226
+ return jsonOk(sv);
227
+ });
228
+ }
229
+ function handleDeleteSkillVersion(request, skillId, version) {
230
+ return routeWrap(request, async () => {
231
+ const result = deleteSkillVersion(skillId, version);
232
+ if (!result.ok) {
233
+ if (result.reason === "cannot delete the current version") {
234
+ throw badRequest(result.reason);
235
+ }
236
+ throw notFound(`skill version ${version} not found`);
237
+ }
238
+ return jsonOk({ skill_id: skillId, version, type: "skill_version_deleted" });
239
+ });
240
+ }
241
+
242
+ export {
243
+ handleCreateSkill,
244
+ handleGetSkill,
245
+ handleDeleteSkill,
246
+ handleCreateSkillVersion,
247
+ handleListSkillVersions,
248
+ handleGetSkillVersion,
249
+ handleDeleteSkillVersion
250
+ };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  markStopping
3
- } from "./chunk-2RIOHWZW.js";
3
+ } from "./chunk-TJ6EX4FW.js";
4
4
  import {
5
5
  closeDb,
6
6
  init_client,
7
7
  syncDb
8
- } from "./chunk-W3YXUIPS.js";
8
+ } from "./chunk-XUODI55L.js";
9
9
  import {
10
10
  getRuntime
11
11
  } from "./chunk-UYTSKFGK.js";
@@ -2,7 +2,7 @@ import {
2
2
  archiveThread,
3
3
  getThread,
4
4
  listThreads
5
- } from "./chunk-A7DBW4MD.js";
5
+ } from "./chunk-34Q6WMIT.js";
6
6
  import {
7
7
  assertResourceTenant
8
8
  } from "./chunk-23UKWXJH.js";
@@ -10,21 +10,21 @@ import {
10
10
  jsonOk,
11
11
  paginatedOk,
12
12
  routeWrap
13
- } from "./chunk-IYVGGJMH.js";
13
+ } from "./chunk-YGWFHNLV.js";
14
14
  import {
15
15
  subscribe
16
- } from "./chunk-X65C4UZH.js";
16
+ } from "./chunk-CZ4IOIWV.js";
17
17
  import {
18
18
  getSession
19
- } from "./chunk-5TOLDBBJ.js";
19
+ } from "./chunk-32RP2UX6.js";
20
20
  import {
21
21
  listEvents,
22
22
  rowToManagedEvent
23
- } from "./chunk-K2UJFAGD.js";
23
+ } from "./chunk-N33MOUCH.js";
24
24
  import {
25
25
  getDb,
26
26
  init_client
27
- } from "./chunk-W3YXUIPS.js";
27
+ } from "./chunk-XUODI55L.js";
28
28
  import {
29
29
  badRequest,
30
30
  notFound
@@ -10,10 +10,10 @@ import {
10
10
  import {
11
11
  getDrizzle,
12
12
  init_drizzle
13
- } from "./chunk-JWVVF66Q.js";
13
+ } from "./chunk-T75UYYMI.js";
14
14
  import {
15
15
  schema_exports
16
- } from "./chunk-SZNZZB7J.js";
16
+ } from "./chunk-RNU253MD.js";
17
17
 
18
18
  // src/db/files.ts
19
19
  init_drizzle();
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  getSession
3
- } from "./chunk-5TOLDBBJ.js";
3
+ } from "./chunk-32RP2UX6.js";
4
4
  import {
5
5
  appendEvent,
6
6
  appendEventsBatch,
7
7
  listEvents,
8
8
  rowToManagedEvent
9
- } from "./chunk-K2UJFAGD.js";
9
+ } from "./chunk-N33MOUCH.js";
10
10
  import {
11
11
  getAgent
12
- } from "./chunk-P7TV5XP4.js";
12
+ } from "./chunk-EGN4TPN5.js";
13
13
  import {
14
14
  getDb,
15
15
  init_client
16
- } from "./chunk-W3YXUIPS.js";
16
+ } from "./chunk-XUODI55L.js";
17
17
 
18
18
  // src/sessions/bus.ts
19
19
  import { EventEmitter } from "events";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-23UKWXJH.js";
7
7
  import {
8
8
  recordAudit
9
- } from "./chunk-PVVJCRII.js";
9
+ } from "./chunk-N5C3WQWD.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-IYVGGJMH.js";
18
+ } from "./chunk-YGWFHNLV.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-P4B4V4SV.js";
26
+ } from "./chunk-Z4DZMNDE.js";
27
27
  import {
28
28
  listSessionsByApiKey
29
- } from "./chunk-5TOLDBBJ.js";
29
+ } from "./chunk-32RP2UX6.js";
30
30
  import {
31
31
  getDb,
32
32
  init_client
33
- } from "./chunk-W3YXUIPS.js";
33
+ } from "./chunk-XUODI55L.js";
34
34
  import {
35
35
  badRequest,
36
36
  forbidden,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfig
3
- } from "./chunk-P2NWS65Y.js";
3
+ } from "./chunk-NWZPKG3G.js";
4
4
 
5
5
  // src/backends/pi/auth.ts
6
6
  function buildPiAuthEnv() {
@@ -4,11 +4,11 @@ import {
4
4
  } from "./chunk-23UKWXJH.js";
5
5
  import {
6
6
  listAudit
7
- } from "./chunk-PVVJCRII.js";
7
+ } from "./chunk-N5C3WQWD.js";
8
8
  import {
9
9
  paginatedOk,
10
10
  routeWrap
11
- } from "./chunk-IYVGGJMH.js";
11
+ } from "./chunk-YGWFHNLV.js";
12
12
  import {
13
13
  badRequest
14
14
  } from "./chunk-EZYKRG4W.js";
@@ -5,10 +5,10 @@ import {
5
5
  import {
6
6
  getDrizzle,
7
7
  init_drizzle
8
- } from "./chunk-JWVVF66Q.js";
8
+ } from "./chunk-T75UYYMI.js";
9
9
  import {
10
10
  schema_exports
11
- } from "./chunk-SZNZZB7J.js";
11
+ } from "./chunk-RNU253MD.js";
12
12
 
13
13
  // src/db/proxy.ts
14
14
  init_drizzle();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_TENANT_ID
3
- } from "./chunk-64M4Z6HW.js";
3
+ } from "./chunk-LSXVCZN7.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-JWVVF66Q.js";
16
+ } from "./chunk-T75UYYMI.js";
17
17
  import {
18
18
  schema_exports
19
- } from "./chunk-SZNZZB7J.js";
19
+ } from "./chunk-RNU253MD.js";
20
20
 
21
21
  // src/db/agents.ts
22
22
  init_drizzle();
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  getModels
3
- } from "./chunk-7OM5LP3K.js";
3
+ } from "./chunk-PT5FGQZB.js";
4
4
  import {
5
5
  jsonOk,
6
6
  routeWrap
7
- } from "./chunk-IYVGGJMH.js";
7
+ } from "./chunk-YGWFHNLV.js";
8
8
 
9
9
  // src/handlers/models.ts
10
10
  function handleListModels(request) {
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  createSession
3
- } from "./chunk-5TOLDBBJ.js";
3
+ } from "./chunk-32RP2UX6.js";
4
4
  import {
5
5
  createEnvironment,
6
6
  deleteEnvironment,
7
7
  getEnvironment
8
- } from "./chunk-UKCRJFFC.js";
8
+ } from "./chunk-6BOOQV4Q.js";
9
9
  import {
10
10
  archiveAgent,
11
11
  createAgent,
12
12
  getAgent
13
- } from "./chunk-P7TV5XP4.js";
13
+ } from "./chunk-EGN4TPN5.js";
14
14
  import {
15
15
  getDrizzle,
16
16
  init_drizzle
17
- } from "./chunk-JWVVF66Q.js";
17
+ } from "./chunk-T75UYYMI.js";
18
18
 
19
19
  // src/db/batch.ts
20
20
  init_drizzle();