@stigmer/server 3.22.1 → 3.23.1-dev.20260923075205

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 (329) hide show
  1. package/dist/artifactstorage/artifact-storage.d.ts +29 -31
  2. package/dist/artifactstorage/artifact-storage.d.ts.map +1 -1
  3. package/dist/artifactstorage/artifact-storage.js +5 -7
  4. package/dist/artifactstorage/artifact-storage.js.map +1 -1
  5. package/dist/artifactstorage/r2-storage.d.ts +12 -7
  6. package/dist/artifactstorage/r2-storage.d.ts.map +1 -1
  7. package/dist/artifactstorage/r2-storage.js +6 -14
  8. package/dist/artifactstorage/r2-storage.js.map +1 -1
  9. package/dist/authorization/authorizer.d.ts +4 -8
  10. package/dist/authorization/authorizer.d.ts.map +1 -1
  11. package/dist/authorization/authorizer.js +5 -9
  12. package/dist/authorization/authorizer.js.map +1 -1
  13. package/dist/authorization/derived-tuples.d.ts.map +1 -1
  14. package/dist/authorization/derived-tuples.js +10 -25
  15. package/dist/authorization/derived-tuples.js.map +1 -1
  16. package/dist/authorization/evaluator.d.ts +7 -8
  17. package/dist/authorization/evaluator.d.ts.map +1 -1
  18. package/dist/authorization/evaluator.js +4 -20
  19. package/dist/authorization/evaluator.js.map +1 -1
  20. package/dist/authorization/list-read-scope.d.ts.map +1 -1
  21. package/dist/authorization/list-read-scope.js +5 -9
  22. package/dist/authorization/list-read-scope.js.map +1 -1
  23. package/dist/authorization/model/agent.d.ts.map +1 -1
  24. package/dist/authorization/model/agent.js +4 -5
  25. package/dist/authorization/model/agent.js.map +1 -1
  26. package/dist/authorization/model/agent_instance.d.ts.map +1 -1
  27. package/dist/authorization/model/agent_instance.js +2 -2
  28. package/dist/authorization/model/agent_instance.js.map +1 -1
  29. package/dist/authorization/model/mcp_server.d.ts.map +1 -1
  30. package/dist/authorization/model/mcp_server.js +2 -2
  31. package/dist/authorization/model/mcp_server.js.map +1 -1
  32. package/dist/authorization/model/plugin.d.ts.map +1 -1
  33. package/dist/authorization/model/plugin.js +3 -4
  34. package/dist/authorization/model/plugin.js.map +1 -1
  35. package/dist/authorization/model/rewrite.d.ts +8 -10
  36. package/dist/authorization/model/rewrite.d.ts.map +1 -1
  37. package/dist/authorization/model/rewrite.js +0 -3
  38. package/dist/authorization/model/rewrite.js.map +1 -1
  39. package/dist/authorization/model/skill.d.ts.map +1 -1
  40. package/dist/authorization/model/skill.js +2 -2
  41. package/dist/authorization/model/skill.js.map +1 -1
  42. package/dist/authorization/model/workflow.d.ts.map +1 -1
  43. package/dist/authorization/model/workflow.js +2 -2
  44. package/dist/authorization/model/workflow.js.map +1 -1
  45. package/dist/authorization/model/workflow_instance.d.ts.map +1 -1
  46. package/dist/authorization/model/workflow_instance.js +2 -2
  47. package/dist/authorization/model/workflow_instance.js.map +1 -1
  48. package/dist/authorization/organization-directory.d.ts.map +1 -1
  49. package/dist/authorization/organization-directory.js +2 -3
  50. package/dist/authorization/organization-directory.js.map +1 -1
  51. package/dist/authorization/store-test-kit.d.ts +0 -6
  52. package/dist/authorization/store-test-kit.d.ts.map +1 -1
  53. package/dist/authorization/store-test-kit.js +16 -62
  54. package/dist/authorization/store-test-kit.js.map +1 -1
  55. package/dist/authorization/tuples.d.ts +13 -32
  56. package/dist/authorization/tuples.d.ts.map +1 -1
  57. package/dist/authorization/tuples.js +3 -11
  58. package/dist/authorization/tuples.js.map +1 -1
  59. package/dist/boot/compose.d.ts.map +1 -1
  60. package/dist/boot/compose.js +49 -24
  61. package/dist/boot/compose.js.map +1 -1
  62. package/dist/boot/config.d.ts +4 -3
  63. package/dist/boot/config.d.ts.map +1 -1
  64. package/dist/boot/config.js.map +1 -1
  65. package/dist/boot/skill-transfer-origin.d.ts +52 -0
  66. package/dist/boot/skill-transfer-origin.d.ts.map +1 -0
  67. package/dist/boot/skill-transfer-origin.js +54 -0
  68. package/dist/boot/skill-transfer-origin.js.map +1 -0
  69. package/dist/domain/agent/controller.d.ts.map +1 -1
  70. package/dist/domain/agent/controller.js +4 -4
  71. package/dist/domain/agent/controller.js.map +1 -1
  72. package/dist/domain/agentchannel/controller.d.ts.map +1 -1
  73. package/dist/domain/agentchannel/controller.js +3 -1
  74. package/dist/domain/agentchannel/controller.js.map +1 -1
  75. package/dist/domain/agentexecution/controller.d.ts.map +1 -1
  76. package/dist/domain/agentexecution/controller.js +3 -1
  77. package/dist/domain/agentexecution/controller.js.map +1 -1
  78. package/dist/domain/agentinstance/controller.d.ts.map +1 -1
  79. package/dist/domain/agentinstance/controller.js +3 -4
  80. package/dist/domain/agentinstance/controller.js.map +1 -1
  81. package/dist/domain/agentshare/constants.d.ts +6 -11
  82. package/dist/domain/agentshare/constants.d.ts.map +1 -1
  83. package/dist/domain/agentshare/constants.js +8 -16
  84. package/dist/domain/agentshare/constants.js.map +1 -1
  85. package/dist/domain/agentshare/controller.d.ts.map +1 -1
  86. package/dist/domain/agentshare/controller.js +3 -1
  87. package/dist/domain/agentshare/controller.js.map +1 -1
  88. package/dist/domain/agentshare/steps.d.ts +18 -25
  89. package/dist/domain/agentshare/steps.d.ts.map +1 -1
  90. package/dist/domain/agentshare/steps.js +41 -142
  91. package/dist/domain/agentshare/steps.js.map +1 -1
  92. package/dist/domain/environment/controller.d.ts.map +1 -1
  93. package/dist/domain/environment/controller.js +2 -3
  94. package/dist/domain/environment/controller.js.map +1 -1
  95. package/dist/domain/executioncontext/controller.d.ts.map +1 -1
  96. package/dist/domain/executioncontext/controller.js +2 -1
  97. package/dist/domain/executioncontext/controller.js.map +1 -1
  98. package/dist/domain/mcpserver/controller.d.ts.map +1 -1
  99. package/dist/domain/mcpserver/controller.js +3 -4
  100. package/dist/domain/mcpserver/controller.js.map +1 -1
  101. package/dist/domain/plugin/controller.d.ts +3 -7
  102. package/dist/domain/plugin/controller.d.ts.map +1 -1
  103. package/dist/domain/plugin/controller.js +9 -11
  104. package/dist/domain/plugin/controller.js.map +1 -1
  105. package/dist/domain/plugin/push.d.ts +7 -5
  106. package/dist/domain/plugin/push.d.ts.map +1 -1
  107. package/dist/domain/plugin/push.js +8 -14
  108. package/dist/domain/plugin/push.js.map +1 -1
  109. package/dist/domain/schedule/controller.d.ts.map +1 -1
  110. package/dist/domain/schedule/controller.js +3 -1
  111. package/dist/domain/schedule/controller.js.map +1 -1
  112. package/dist/domain/session/controller.d.ts.map +1 -1
  113. package/dist/domain/session/controller.js +3 -2
  114. package/dist/domain/session/controller.js.map +1 -1
  115. package/dist/domain/skill/constants.d.ts +26 -3
  116. package/dist/domain/skill/constants.d.ts.map +1 -1
  117. package/dist/domain/skill/constants.js +26 -3
  118. package/dist/domain/skill/constants.js.map +1 -1
  119. package/dist/domain/skill/controller.d.ts +6 -11
  120. package/dist/domain/skill/controller.d.ts.map +1 -1
  121. package/dist/domain/skill/controller.js +33 -24
  122. package/dist/domain/skill/controller.js.map +1 -1
  123. package/dist/domain/skill/push.d.ts +2 -2
  124. package/dist/domain/skill/push.d.ts.map +1 -1
  125. package/dist/domain/skill/push.js +2 -2
  126. package/dist/domain/skill/push.js.map +1 -1
  127. package/dist/domain/skill/transfer/handler.d.ts +17 -9
  128. package/dist/domain/skill/transfer/handler.d.ts.map +1 -1
  129. package/dist/domain/skill/transfer/handler.js +19 -8
  130. package/dist/domain/skill/transfer/handler.js.map +1 -1
  131. package/dist/domain/skill/transfer/slots.d.ts +26 -41
  132. package/dist/domain/skill/transfer/slots.d.ts.map +1 -1
  133. package/dist/domain/skill/transfer/slots.js +80 -87
  134. package/dist/domain/skill/transfer/slots.js.map +1 -1
  135. package/dist/domain/skill/transfer/staging.d.ts +48 -0
  136. package/dist/domain/skill/transfer/staging.d.ts.map +1 -0
  137. package/dist/domain/skill/transfer/staging.js +127 -0
  138. package/dist/domain/skill/transfer/staging.js.map +1 -0
  139. package/dist/domain/workflow/agent-call-references.d.ts +54 -0
  140. package/dist/domain/workflow/agent-call-references.d.ts.map +1 -0
  141. package/dist/domain/workflow/agent-call-references.js +97 -0
  142. package/dist/domain/workflow/agent-call-references.js.map +1 -0
  143. package/dist/domain/workflow/controller.d.ts.map +1 -1
  144. package/dist/domain/workflow/controller.js +14 -6
  145. package/dist/domain/workflow/controller.js.map +1 -1
  146. package/dist/domain/workflow/registry/data/task-kind-registry.json +1 -1
  147. package/dist/domain/workflow/validation/task-config-constraints.d.ts +10 -1
  148. package/dist/domain/workflow/validation/task-config-constraints.d.ts.map +1 -1
  149. package/dist/domain/workflow/validation/task-config-constraints.js +3 -2
  150. package/dist/domain/workflow/validation/task-config-constraints.js.map +1 -1
  151. package/dist/domain/workflowexecution/controller.d.ts.map +1 -1
  152. package/dist/domain/workflowexecution/controller.js +4 -2
  153. package/dist/domain/workflowexecution/controller.js.map +1 -1
  154. package/dist/domain/workflowinstance/controller.d.ts.map +1 -1
  155. package/dist/domain/workflowinstance/controller.js +3 -4
  156. package/dist/domain/workflowinstance/controller.js.map +1 -1
  157. package/dist/extensions/authorization-queries.d.ts +6 -5
  158. package/dist/extensions/authorization-queries.d.ts.map +1 -1
  159. package/dist/extensions/list-read-scope.d.ts +1 -1
  160. package/dist/extensions/resource-authorization.d.ts +3 -2
  161. package/dist/extensions/resource-authorization.d.ts.map +1 -1
  162. package/dist/index.d.ts +1 -1
  163. package/dist/index.d.ts.map +1 -1
  164. package/dist/index.js.map +1 -1
  165. package/dist/pipeline/apiresource-meta.d.ts +12 -3
  166. package/dist/pipeline/apiresource-meta.d.ts.map +1 -1
  167. package/dist/pipeline/apiresource-meta.js +21 -10
  168. package/dist/pipeline/apiresource-meta.js.map +1 -1
  169. package/dist/pipeline/steps/authorization-tuples.d.ts +9 -3
  170. package/dist/pipeline/steps/authorization-tuples.d.ts.map +1 -1
  171. package/dist/pipeline/steps/authorization-tuples.js +9 -11
  172. package/dist/pipeline/steps/authorization-tuples.js.map +1 -1
  173. package/dist/pipeline/steps/references.d.ts +178 -20
  174. package/dist/pipeline/steps/references.d.ts.map +1 -1
  175. package/dist/pipeline/steps/references.js +344 -43
  176. package/dist/pipeline/steps/references.js.map +1 -1
  177. package/dist/pipeline/steps/resolve-artifact-source.d.ts +11 -8
  178. package/dist/pipeline/steps/resolve-artifact-source.d.ts.map +1 -1
  179. package/dist/pipeline/steps/resolve-artifact-source.js +8 -4
  180. package/dist/pipeline/steps/resolve-artifact-source.js.map +1 -1
  181. package/dist/query/search/controller.js +0 -1
  182. package/dist/query/search/controller.js.map +1 -1
  183. package/dist/query/search/criteria.d.ts +1 -5
  184. package/dist/query/search/criteria.d.ts.map +1 -1
  185. package/dist/query/search/criteria.js +3 -13
  186. package/dist/query/search/criteria.js.map +1 -1
  187. package/dist/query/search/handler.d.ts +5 -4
  188. package/dist/query/search/handler.d.ts.map +1 -1
  189. package/dist/query/search/handler.js +7 -6
  190. package/dist/query/search/handler.js.map +1 -1
  191. package/dist/query/search/query-store.d.ts.map +1 -1
  192. package/dist/query/search/query-store.js +0 -2
  193. package/dist/query/search/query-store.js.map +1 -1
  194. package/dist/store/interface.d.ts +3 -6
  195. package/dist/store/interface.d.ts.map +1 -1
  196. package/dist/store/interface.js.map +1 -1
  197. package/dist/store/postgres/migrations.d.ts +3 -1
  198. package/dist/store/postgres/migrations.d.ts.map +1 -1
  199. package/dist/store/postgres/migrations.js +35 -1
  200. package/dist/store/postgres/migrations.js.map +1 -1
  201. package/dist/store/postgres/store.d.ts.map +1 -1
  202. package/dist/store/postgres/store.js +4 -9
  203. package/dist/store/postgres/store.js.map +1 -1
  204. package/dist/store/public-visibility-retired.d.ts +67 -0
  205. package/dist/store/public-visibility-retired.d.ts.map +1 -0
  206. package/dist/store/public-visibility-retired.js +55 -0
  207. package/dist/store/public-visibility-retired.js.map +1 -0
  208. package/dist/store/sqlite/migrations.d.ts +3 -1
  209. package/dist/store/sqlite/migrations.d.ts.map +1 -1
  210. package/dist/store/sqlite/migrations.js +36 -1
  211. package/dist/store/sqlite/migrations.js.map +1 -1
  212. package/dist/store/sqlite/store.d.ts.map +1 -1
  213. package/dist/store/sqlite/store.js +4 -8
  214. package/dist/store/sqlite/store.js.map +1 -1
  215. package/package.json +6 -6
  216. package/src/artifactstorage/__tests__/artifact-storage.test.ts +36 -33
  217. package/src/artifactstorage/__tests__/r2-storage.test.ts +11 -13
  218. package/src/artifactstorage/artifact-storage.ts +37 -33
  219. package/src/artifactstorage/r2-storage.ts +6 -15
  220. package/src/authorization/README.md +24 -26
  221. package/src/authorization/__tests__/authorizer.test.ts +10 -9
  222. package/src/authorization/__tests__/derived-tuples.test.ts +4 -11
  223. package/src/authorization/__tests__/evaluator.test.ts +14 -73
  224. package/src/authorization/__tests__/facts.test.ts +2 -2
  225. package/src/authorization/__tests__/fixtures/fga/agent-instance-creation.fga.yaml +19 -27
  226. package/src/authorization/__tests__/fixtures/fga/blueprint-private-visibility.fga.yaml +6 -98
  227. package/src/authorization/__tests__/fixtures/fga/default-instance-inheritance.fga.yaml +4 -61
  228. package/src/authorization/__tests__/fixtures/fga/mcp-server-authoring.fga.yaml +1 -15
  229. package/src/authorization/__tests__/fixtures/fga/org-admin-owner-inheritance.fga.yaml +1 -21
  230. package/src/authorization/__tests__/fixtures/fga/platform-visibility.fga.yaml +1 -25
  231. package/src/authorization/__tests__/fixtures/fga/workflow-execution-sharing.fga.yaml +1 -3
  232. package/src/authorization/__tests__/list-read-scope.test.ts +18 -17
  233. package/src/authorization/__tests__/store-tests.test.ts +2 -6
  234. package/src/authorization/__tests__/tuples.test.ts +12 -11
  235. package/src/authorization/authorizer.ts +4 -9
  236. package/src/authorization/derived-tuples.ts +14 -31
  237. package/src/authorization/evaluator.ts +8 -44
  238. package/src/authorization/list-read-scope.ts +5 -11
  239. package/src/authorization/model/agent.ts +2 -5
  240. package/src/authorization/model/agent_instance.ts +0 -2
  241. package/src/authorization/model/mcp_server.ts +0 -2
  242. package/src/authorization/model/plugin.ts +1 -4
  243. package/src/authorization/model/rewrite.ts +8 -13
  244. package/src/authorization/model/skill.ts +0 -2
  245. package/src/authorization/model/workflow.ts +0 -2
  246. package/src/authorization/model/workflow_instance.ts +0 -2
  247. package/src/authorization/organization-directory.ts +1 -3
  248. package/src/authorization/store-test-kit.ts +16 -75
  249. package/src/authorization/tuples.ts +16 -39
  250. package/src/boot/__tests__/skill-transfer-origin.test.ts +72 -0
  251. package/src/boot/compose.ts +62 -25
  252. package/src/boot/config.ts +4 -3
  253. package/src/boot/skill-transfer-origin.ts +76 -0
  254. package/src/domain/agent/__tests__/agent.test.ts +11 -4
  255. package/src/domain/agent/controller.ts +7 -7
  256. package/src/domain/agentchannel/__tests__/agentchannel.test.ts +223 -48
  257. package/src/domain/agentchannel/controller.ts +6 -1
  258. package/src/domain/agentexecution/controller.ts +6 -1
  259. package/src/domain/agentinstance/controller.ts +6 -12
  260. package/src/domain/agentshare/__tests__/agentshare.test.ts +196 -172
  261. package/src/domain/agentshare/__tests__/create-authorization.test.ts +16 -31
  262. package/src/domain/agentshare/constants.ts +14 -26
  263. package/src/domain/agentshare/controller.ts +6 -1
  264. package/src/domain/agentshare/steps.ts +41 -194
  265. package/src/domain/environment/controller.ts +5 -8
  266. package/src/domain/executioncontext/controller.ts +5 -1
  267. package/src/domain/mcpserver/__tests__/mcpserver.test.ts +115 -28
  268. package/src/domain/mcpserver/__tests__/oauth-handshake.test.ts +53 -18
  269. package/src/domain/mcpserver/controller.ts +6 -12
  270. package/src/domain/plugin/controller.ts +16 -25
  271. package/src/domain/plugin/push.ts +8 -16
  272. package/src/domain/schedule/controller.ts +6 -1
  273. package/src/domain/session/controller.ts +12 -4
  274. package/src/domain/skill/__tests__/skill.test.ts +5 -3
  275. package/src/domain/skill/__tests__/slots.test.ts +113 -60
  276. package/src/domain/skill/__tests__/staging.test.ts +304 -0
  277. package/src/domain/skill/constants.ts +28 -3
  278. package/src/domain/skill/controller.ts +44 -42
  279. package/src/domain/skill/push.ts +3 -3
  280. package/src/domain/skill/transfer/handler.ts +33 -15
  281. package/src/domain/skill/transfer/slots.ts +89 -100
  282. package/src/domain/skill/transfer/staging.ts +191 -0
  283. package/src/domain/workflow/__tests__/agent-call-references.test.ts +222 -0
  284. package/src/domain/workflow/agent-call-references.ts +157 -0
  285. package/src/domain/workflow/controller.ts +28 -10
  286. package/src/domain/workflow/registry/data/task-kind-registry.json +1 -1
  287. package/src/domain/workflow/validation/task-config-constraints.ts +7 -3
  288. package/src/domain/workflowexecution/controller.ts +7 -2
  289. package/src/domain/workflowinstance/controller.ts +6 -12
  290. package/src/extensions/__tests__/built-in-authorization-composed.test.ts +32 -19
  291. package/src/extensions/__tests__/extension-composition.test.ts +4 -4
  292. package/src/extensions/__tests__/list-read-scope-composed.test.ts +9 -6
  293. package/src/extensions/authorization-queries.ts +6 -5
  294. package/src/extensions/list-read-scope.ts +1 -1
  295. package/src/extensions/resource-authorization.ts +3 -5
  296. package/src/index.ts +0 -1
  297. package/src/pipeline/__tests__/supports-visibility.test.ts +112 -0
  298. package/src/pipeline/apiresource-meta.ts +21 -10
  299. package/src/pipeline/steps/__tests__/authorization-tuples.test.ts +18 -31
  300. package/src/pipeline/steps/__tests__/references.test.ts +703 -0
  301. package/src/pipeline/steps/authorization-tuples.ts +9 -11
  302. package/src/pipeline/steps/references.ts +578 -70
  303. package/src/pipeline/steps/resolve-artifact-source.ts +20 -13
  304. package/src/query/search/__tests__/criteria.test.ts +0 -4
  305. package/src/query/search/__tests__/query-store.test.ts +11 -40
  306. package/src/query/search/controller.ts +0 -1
  307. package/src/query/search/criteria.ts +0 -14
  308. package/src/query/search/handler.ts +6 -7
  309. package/src/query/search/query-store.ts +0 -2
  310. package/src/store/__tests__/public-visibility-retired.test.ts +127 -0
  311. package/src/store/__tests__/store-contract.ts +6 -51
  312. package/src/store/interface.ts +3 -6
  313. package/src/store/postgres/__tests__/migrations.test.ts +187 -6
  314. package/src/store/postgres/__tests__/store-contract.test.ts +0 -2
  315. package/src/store/postgres/migrations.ts +48 -1
  316. package/src/store/postgres/store.ts +4 -11
  317. package/src/store/public-visibility-retired.ts +119 -0
  318. package/src/store/sqlite/__tests__/migrations.test.ts +191 -5
  319. package/src/store/sqlite/migrations.ts +45 -1
  320. package/src/store/sqlite/store.ts +4 -10
  321. package/src/transport/registry/__tests__/lanes.test.ts +1 -1
  322. package/dist/pipeline/steps/visibility-gates.d.ts +0 -27
  323. package/dist/pipeline/steps/visibility-gates.d.ts.map +0 -1
  324. package/dist/pipeline/steps/visibility-gates.js +0 -139
  325. package/dist/pipeline/steps/visibility-gates.js.map +0 -1
  326. package/src/authorization/__tests__/fixtures/fga/cross-org-share-creation.fga.yaml +0 -98
  327. package/src/authorization/__tests__/fixtures/fga/public-visibility-setter.fga.yaml +0 -52
  328. package/src/pipeline/steps/__tests__/visibility-gates.test.ts +0 -187
  329. package/src/pipeline/steps/visibility-gates.ts +0 -174
@@ -2,6 +2,7 @@ import { SKILL_ARTIFACTS_PATH_PREFIX } from "../../../transport/constants.js";
2
2
  import { DOWNLOAD_KEY_PREFIX, UPLOADS_SEGMENT } from "../constants.js";
3
3
  import { ArtifactNotFoundError } from "../storage/artifact-storage.js";
4
4
  import { SizeMismatchError, SlotConsumedError, SlotUnknownError, } from "./slots.js";
5
+ import { stagingKeyOf } from "./staging.js";
5
6
  /**
6
7
  * Renders the capability URL for a minted reference against the lane's
7
8
  * externally-reachable base URL.
@@ -9,9 +10,13 @@ import { SizeMismatchError, SlotConsumedError, SlotUnknownError, } from "./slots
9
10
  export function uploadUrl(baseUrl, ref) {
10
11
  return `${trimTrailingSlash(baseUrl)}${SKILL_ARTIFACTS_PATH_PREFIX}${UPLOADS_SEGMENT}${ref}`;
11
12
  }
12
- /** Renders the download URL for an artifact storage key. */
13
- export function downloadUrl(baseUrl, storageKey) {
14
- return `${trimTrailingSlash(baseUrl)}${SKILL_ARTIFACTS_PATH_PREFIX}/${storageKey}`;
13
+ /**
14
+ * The lane's download origin: the local skill driver's serve URL, so that
15
+ * `${serveUrl}/${storageKey}` (LocalArtifactStorage.getSignedUrl's shape)
16
+ * is exactly the GET route this handler dispatches.
17
+ */
18
+ export function transferServeUrl(baseUrl) {
19
+ return `${trimTrailingSlash(baseUrl)}${SKILL_ARTIFACTS_PATH_PREFIX}`;
15
20
  }
16
21
  function trimTrailingSlash(url) {
17
22
  return url.endsWith("/") ? url.slice(0, -1) : url;
@@ -51,17 +56,23 @@ async function handleUpload(request, response, slots, ref, logger) {
51
56
  writeText(response, 405, "method not allowed");
52
57
  return;
53
58
  }
59
+ // Deliberately one shape for "malformed", "never existed" and "expired":
60
+ // distinguishing them would let an unauthorized caller probe which
61
+ // tokens were once valid.
62
+ const unknown = () => writeText(response, 404, "upload reference unknown or expired — request a new upload URL");
63
+ const key = stagingKeyOf(ref);
64
+ if (key === undefined) {
65
+ unknown();
66
+ return;
67
+ }
54
68
  try {
55
- await slots.receive(ref, request);
69
+ await slots.receive(key, request);
56
70
  response.statusCode = 204;
57
71
  response.end();
58
72
  }
59
73
  catch (error) {
60
74
  if (error instanceof SlotUnknownError) {
61
- // Deliberately the same shape for "never existed" and "expired":
62
- // distinguishing them would let an unauthorized caller probe which
63
- // tokens were once valid.
64
- writeText(response, 404, "upload reference unknown or expired — request a new upload URL");
75
+ unknown();
65
76
  }
66
77
  else if (error instanceof SlotConsumedError) {
67
78
  writeText(response, 409, "upload reference already used — request a new upload URL");
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../../src/domain/skill/transfer/handler.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAE9E,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAGpB;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,GAAW;IACpD,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,2BAA2B,GAAG,eAAe,GAAG,GAAG,EAAE,CAAC;AAC/F,CAAC;AAED,4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AAI,IAAI,CAAC,CAAC;AAC5B,CAAC"}
@@ -7,72 +7,57 @@ export declare class SlotUnknownError extends Error {
7
7
  export declare class SlotConsumedError extends Error {
8
8
  constructor();
9
9
  }
10
- /** Go errSlotEmpty — minted but never (successfully) uploaded to. */
11
- export declare class SlotEmptyError extends Error {
12
- constructor();
13
- }
14
- /** Go errSizeMismatch — the body disagreed with the minted declaration. */
10
+ /** Go errSizeMismatch — the body disagreed with the reserved declaration. */
15
11
  export declare class SizeMismatchError extends Error {
16
12
  constructor(received: number, declared: number);
17
13
  }
18
14
  export declare class UploadSlots {
19
- private readonly slots;
20
- private readonly stagingDir;
15
+ private readonly root;
16
+ private readonly stagingPrefix;
21
17
  private readonly ttlMs;
22
18
  private readonly maxSize;
19
+ private readonly slots;
20
+ private readonly stagingDir;
23
21
  /** Injectable for expiry tests, mirroring Go's `now` field. */
24
22
  private readonly now;
25
23
  /**
26
- * Creates the registry and prepares the staging directory. Any file
27
- * already present is an orphan from a previous process (the registry
28
- * that knew about it died with that process), so the directory is
29
- * emptied — this is also the crash-recovery story for uploads that
30
- * never reached their push.
24
+ * Creates the registry over `root` (the local blob driver's root) and
25
+ * prepares the staging directory `root/stagingPrefix`. Any file already
26
+ * present is an orphan from a previous process (the registry that knew
27
+ * about it died with that process), so the directory is emptied — this
28
+ * is also the crash-recovery story for uploads that never reached their
29
+ * push.
31
30
  */
32
- constructor(stagingDir: string, ttlMs: number, maxSize: number, now?: () => number);
31
+ constructor(root: string, stagingPrefix: string, ttlMs: number, maxSize: number, now?: () => number);
33
32
  /**
34
- * Reserves an upload slot for an artifact of declaredSize bytes and
35
- * returns its single-use reference + TTL. The caller has already
33
+ * Reserves an upload slot for an artifact of declaredSize bytes at the
34
+ * staging key; returns the TTL granted. The caller has already
36
35
  * authorized the request and validated declaredSize against the skill
37
- * size limit; this guard is the registry's own invariant.
36
+ * size limit; the bound here is the registry's own invariant.
38
37
  */
39
- mint(declaredSize: number): {
40
- ref: string;
38
+ reserve(key: string, declaredSize: number): {
41
39
  ttlMs: number;
42
40
  };
43
41
  /**
44
42
  * Streams an upload's body into the slot's staging file. The body must
45
- * match the size declared at mint time exactly: a shorter body means a
43
+ * match the size declared at reservation exactly: a shorter body means a
46
44
  * truncated transfer, a longer one means the client lied — both reject
47
45
  * rather than staging bytes that would fail (or worse, surprise)
48
- * validation later. The staged file only becomes consumable once this
49
- * resolves.
50
- */
51
- receive(ref: string, body: Readable): Promise<void>;
52
- /**
53
- * Returns the staged bytes for ref and retires the slot — an upload
54
- * reference is strictly single-use. Push calls this when it sees
55
- * artifact_upload_ref; whatever happens downstream (validation failure
56
- * included), the slot is gone and the client must re-mint to retry.
46
+ * validation later. The staged file only becomes readable through the
47
+ * driver once this resolves.
57
48
  */
58
- consume(ref: string): Promise<Uint8Array>;
49
+ receive(key: string, body: Readable): Promise<void>;
59
50
  /**
60
- * Drops expired slots and their staged files. Called from mint, which
61
- * bounds the registry: it can hold at most the slots minted within one
51
+ * Drops expired slots and their staged files. Called from reserve, which
52
+ * bounds the registry: it can hold at most the slots reserved within one
62
53
  * TTL window.
63
54
  */
64
55
  private sweep;
65
56
  /**
66
- * The staging file name for a reference. Public since O5: the local
67
- * driver's presigned-PUT arm maps refs onto driver staging keys
68
- * (boot/compose.ts), and that mapping must come from HERE — a
69
- * re-declared "<ref>.zip" in the composition would drift from stagePath
70
- * with nothing to catch it.
71
- */
72
- stagedFileName(ref: string): string;
73
- /**
74
- * Maps a reference to its staging file. refs are server-generated hex
75
- * (never client-supplied paths), so simple joining is safe.
57
+ * Maps a staging key to its file: the key resolved under the driver's
58
+ * root, which is how the driver's download(key) will look for it. The
59
+ * key must carry the staging prefix and a plain hex file name — anything
60
+ * else is a caller bug, refused before it touches the filesystem.
76
61
  */
77
62
  private stagePath;
78
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"slots.d.ts","sourceRoot":"","sources":["../../../../src/domain/skill/transfer/slots.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,QAA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"mappings":"AA8BA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,4DAA4D;AAC5D,qBAAa,gBAAiB,SAAQ,KAAK;;CAK1C;AAED,+DAA+D;AAC/D,qBAAa,iBAAkB,SAAQ,KAAK;;CAK3C;AAED,6EAA6E;AAC7E,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAM/C;AAgBD,qBAAa,WAAW;IAepB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAjB1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2B;IACjD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,+DAA+D;IAC/D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IAEnC;;;;;;;OAOG;gBAEgB,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAChC,GAAG,GAAE,MAAM,MAAiB;IAQ9B;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAmB7D;;;;;;;OAOG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAoDzD;;;;OAIG;IACH,OAAO,CAAC,KAAK;IAUb;;;;;OAKG;IACH,OAAO,CAAC,SAAS;CAUlB"}
@@ -1,9 +1,18 @@
1
1
  /**
2
- * Skill artifact upload slots — ports pkg/domain/skill/transfer/slots.go.
3
- * The in-memory registry of single-use upload capabilities plus the
4
- * staging directory their bytes land in (#675).
2
+ * Skill artifact upload slots — the local blob driver's staging mechanism,
3
+ * ported from pkg/domain/skill/transfer/slots.go: an in-memory registry of
4
+ * single-use upload capabilities plus the staging files their bytes land
5
+ * in (#675).
5
6
  *
6
- * In-memory is deliberate: the OSS server is single-instance (the same
7
+ * A slot is keyed by the STAGING KEY the domain names (`skills/staging/
8
+ * <hex>.zip`, transfer/staging.ts), and its file is that key resolved
9
+ * under the blob driver's root — so the driver's own download(key) reads
10
+ * what the lane received and its delete(key) retires the bytes, exactly
11
+ * as a bucket driver's would. The registry therefore knows nothing of
12
+ * consumption: it reserves, receives, and sweeps; the domain reads and
13
+ * deletes through the driver, one path for every backend.
14
+ *
15
+ * In-memory is deliberate: the local driver is single-instance (the same
7
16
  * assumption the in-process router transport and SQLite store already
8
17
  * make), and a slot is worthless across restarts anyway — its bytes live
9
18
  * in the staging directory, which is swept on boot.
@@ -11,17 +20,14 @@
11
20
  * Sentinel error classes replace Go's sentinel error values so the HTTP
12
21
  * handler maps registry failures onto honest status codes without string
13
22
  * matching; their message texts are Go's, verbatim (they ride wire-visible
14
- * copy: push's "artifact_upload_ref not usable: %v" and the handler's 400
15
- * body).
23
+ * copy: the handler's 404, 409 and 400 bodies).
16
24
  *
17
25
  * Proven by __tests__/slots.test.ts (injected clock for expiry) and the
18
26
  * conformance suite's transfer-lane tests.
19
27
  */
20
- import { randomBytes } from "node:crypto";
21
28
  import fs from "node:fs";
22
29
  import path from "node:path";
23
30
  import { pipeline } from "node:stream/promises";
24
- import { REF_BYTE_LEN, REF_PREFIX } from "../constants.js";
25
31
  /** Go errSlotUnknown — never existed, expired, or swept. */
26
32
  export class SlotUnknownError extends Error {
27
33
  constructor() {
@@ -36,71 +42,79 @@ export class SlotConsumedError extends Error {
36
42
  this.name = "SlotConsumedError";
37
43
  }
38
44
  }
39
- /** Go errSlotEmpty — minted but never (successfully) uploaded to. */
40
- export class SlotEmptyError extends Error {
41
- constructor() {
42
- super("upload reference has no uploaded bytes");
43
- this.name = "SlotEmptyError";
44
- }
45
- }
46
- /** Go errSizeMismatch — the body disagreed with the minted declaration. */
45
+ /** Go errSizeMismatch — the body disagreed with the reserved declaration. */
47
46
  export class SizeMismatchError extends Error {
48
47
  constructor(received, declared) {
49
48
  super(`upload size mismatch: received ${received} bytes, declared ${declared}`);
50
49
  this.name = "SizeMismatchError";
51
50
  }
52
51
  }
52
+ /**
53
+ * The one file-name shape a staging key may carry past its prefix: the
54
+ * domain's hex reference plus the archive suffix. Keys are server-minted,
55
+ * never client-supplied, so this is an invariant check, not input
56
+ * validation — a violation is a programming error and throws.
57
+ */
58
+ const STAGED_FILE_NAME = /^[0-9a-f]+\.zip$/;
53
59
  export class UploadSlots {
54
- slots = new Map();
55
- stagingDir;
60
+ root;
61
+ stagingPrefix;
56
62
  ttlMs;
57
63
  maxSize;
64
+ slots = new Map();
65
+ stagingDir;
58
66
  /** Injectable for expiry tests, mirroring Go's `now` field. */
59
67
  now;
60
68
  /**
61
- * Creates the registry and prepares the staging directory. Any file
62
- * already present is an orphan from a previous process (the registry
63
- * that knew about it died with that process), so the directory is
64
- * emptied — this is also the crash-recovery story for uploads that
65
- * never reached their push.
69
+ * Creates the registry over `root` (the local blob driver's root) and
70
+ * prepares the staging directory `root/stagingPrefix`. Any file already
71
+ * present is an orphan from a previous process (the registry that knew
72
+ * about it died with that process), so the directory is emptied — this
73
+ * is also the crash-recovery story for uploads that never reached their
74
+ * push.
66
75
  */
67
- constructor(stagingDir, ttlMs, maxSize, now = Date.now) {
68
- fs.rmSync(stagingDir, { recursive: true, force: true });
69
- fs.mkdirSync(stagingDir, { recursive: true, mode: 0o700 });
70
- this.stagingDir = stagingDir;
76
+ constructor(root, stagingPrefix, ttlMs, maxSize, now = Date.now) {
77
+ this.root = root;
78
+ this.stagingPrefix = stagingPrefix;
71
79
  this.ttlMs = ttlMs;
72
80
  this.maxSize = maxSize;
81
+ this.stagingDir = path.join(root, stagingPrefix);
82
+ fs.rmSync(this.stagingDir, { recursive: true, force: true });
83
+ fs.mkdirSync(this.stagingDir, { recursive: true, mode: 0o700 });
73
84
  this.now = now;
74
85
  }
75
86
  /**
76
- * Reserves an upload slot for an artifact of declaredSize bytes and
77
- * returns its single-use reference + TTL. The caller has already
87
+ * Reserves an upload slot for an artifact of declaredSize bytes at the
88
+ * staging key; returns the TTL granted. The caller has already
78
89
  * authorized the request and validated declaredSize against the skill
79
- * size limit; this guard is the registry's own invariant.
90
+ * size limit; the bound here is the registry's own invariant.
80
91
  */
81
- mint(declaredSize) {
92
+ reserve(key, declaredSize) {
82
93
  if (declaredSize <= 0 || declaredSize > this.maxSize) {
83
94
  throw new Error(`declared size ${declaredSize} outside (0, ${this.maxSize}]`);
84
95
  }
85
- const ref = REF_PREFIX + randomBytes(REF_BYTE_LEN).toString("hex");
96
+ this.stagePath(key);
97
+ if (this.slots.has(key)) {
98
+ throw new Error(`staging key ${key} is already reserved`);
99
+ }
86
100
  this.sweep();
87
- this.slots.set(ref, {
101
+ this.slots.set(key, {
88
102
  declaredSize,
89
103
  expiresAtMs: this.now() + this.ttlMs,
90
104
  uploaded: false,
91
105
  });
92
- return { ref, ttlMs: this.ttlMs };
106
+ return { ttlMs: this.ttlMs };
93
107
  }
94
108
  /**
95
109
  * Streams an upload's body into the slot's staging file. The body must
96
- * match the size declared at mint time exactly: a shorter body means a
110
+ * match the size declared at reservation exactly: a shorter body means a
97
111
  * truncated transfer, a longer one means the client lied — both reject
98
112
  * rather than staging bytes that would fail (or worse, surprise)
99
- * validation later. The staged file only becomes consumable once this
100
- * resolves.
113
+ * validation later. The staged file only becomes readable through the
114
+ * driver once this resolves.
101
115
  */
102
- async receive(ref, body) {
103
- const slot = this.slots.get(ref);
116
+ async receive(key, body) {
117
+ const slot = this.slots.get(key);
104
118
  if (slot === undefined || this.now() > slot.expiresAtMs) {
105
119
  throw new SlotUnknownError();
106
120
  }
@@ -108,9 +122,16 @@ export class UploadSlots {
108
122
  throw new SlotConsumedError();
109
123
  }
110
124
  const declared = slot.declaredSize;
111
- const filePath = this.stagePath(ref);
125
+ const filePath = this.stagePath(key);
112
126
  let written = 0;
113
127
  try {
128
+ // The driver's delete(key) prunes directories it empties, so the
129
+ // staging directory may be gone between two uploads; recreate it
130
+ // rather than fail the second one.
131
+ await fs.promises.mkdir(path.dirname(filePath), {
132
+ recursive: true,
133
+ mode: 0o700,
134
+ });
114
135
  // Consume at most declared+1 bytes: seeing the extra byte proves the
115
136
  // body exceeds the declaration without buffering an unbounded stream
116
137
  // (Go's io.LimitReader(declared+1) + written != declared check).
@@ -128,7 +149,7 @@ export class UploadSlots {
128
149
  }
129
150
  // Re-check after the write: the slot may have expired mid-upload
130
151
  // (Go re-checks under the lock for the same reason).
131
- const current = this.slots.get(ref);
152
+ const current = this.slots.get(key);
132
153
  if (current === undefined || this.now() > current.expiresAtMs) {
133
154
  await fs.promises.rm(filePath, { force: true });
134
155
  throw new SlotUnknownError();
@@ -136,62 +157,34 @@ export class UploadSlots {
136
157
  current.uploaded = true;
137
158
  }
138
159
  /**
139
- * Returns the staged bytes for ref and retires the slot — an upload
140
- * reference is strictly single-use. Push calls this when it sees
141
- * artifact_upload_ref; whatever happens downstream (validation failure
142
- * included), the slot is gone and the client must re-mint to retry.
143
- */
144
- async consume(ref) {
145
- const slot = this.slots.get(ref);
146
- if (slot === undefined || this.now() > slot.expiresAtMs) {
147
- throw new SlotUnknownError();
148
- }
149
- if (!slot.uploaded) {
150
- throw new SlotEmptyError();
151
- }
152
- this.slots.delete(ref);
153
- const filePath = this.stagePath(ref);
154
- try {
155
- const data = await fs.promises.readFile(filePath);
156
- return data;
157
- }
158
- catch (error) {
159
- throw new Error(`failed to read staged artifact: ${error instanceof Error ? error.message : String(error)}`);
160
- }
161
- finally {
162
- await fs.promises.rm(filePath, { force: true });
163
- }
164
- }
165
- /**
166
- * Drops expired slots and their staged files. Called from mint, which
167
- * bounds the registry: it can hold at most the slots minted within one
160
+ * Drops expired slots and their staged files. Called from reserve, which
161
+ * bounds the registry: it can hold at most the slots reserved within one
168
162
  * TTL window.
169
163
  */
170
164
  sweep() {
171
165
  const nowMs = this.now();
172
- for (const [ref, slot] of this.slots) {
166
+ for (const [key, slot] of this.slots) {
173
167
  if (nowMs > slot.expiresAtMs) {
174
- this.slots.delete(ref);
175
- fs.rmSync(this.stagePath(ref), { force: true });
168
+ this.slots.delete(key);
169
+ fs.rmSync(this.stagePath(key), { force: true });
176
170
  }
177
171
  }
178
172
  }
179
173
  /**
180
- * The staging file name for a reference. Public since O5: the local
181
- * driver's presigned-PUT arm maps refs onto driver staging keys
182
- * (boot/compose.ts), and that mapping must come from HERE — a
183
- * re-declared "<ref>.zip" in the composition would drift from stagePath
184
- * with nothing to catch it.
174
+ * Maps a staging key to its file: the key resolved under the driver's
175
+ * root, which is how the driver's download(key) will look for it. The
176
+ * key must carry the staging prefix and a plain hex file name — anything
177
+ * else is a caller bug, refused before it touches the filesystem.
185
178
  */
186
- stagedFileName(ref) {
187
- return `${ref}.zip`;
188
- }
189
- /**
190
- * Maps a reference to its staging file. refs are server-generated hex
191
- * (never client-supplied paths), so simple joining is safe.
192
- */
193
- stagePath(ref) {
194
- return path.join(this.stagingDir, this.stagedFileName(ref));
179
+ stagePath(key) {
180
+ if (!key.startsWith(this.stagingPrefix)) {
181
+ throw new Error(`staging key ${key} is outside ${this.stagingPrefix}`);
182
+ }
183
+ const fileName = key.slice(this.stagingPrefix.length);
184
+ if (!STAGED_FILE_NAME.test(fileName)) {
185
+ throw new Error(`staging key ${key} does not name a staged archive`);
186
+ }
187
+ return path.join(this.root, key);
195
188
  }
196
189
  }
197
190
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"slots.js","sourceRoot":"","sources":["../../../../src/domain/skill/transfer/slots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAA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aAAa,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,eAAe,GAAG,iCAAiC,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;CACF;AAED;;;;GAIG;AACH,SAAS,UAAU,CACjB,KAAa,EACb,OAAgC;IAEhC,OAAO,KAAK,SAAS,CAAC,EACpB,MAA6B;QAE7B,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YACjC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;gBACnB,OAAO;YACT,CAAC;YACD,MAAM,KAAK,GACT,KAAK,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;YACnE,SAAS,IAAI,KAAK,CAAC,MAAM,CAAC;YAC1B,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACtB,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { ArtifactStorage } from "../../../artifactstorage/artifact-storage.js";
2
+ import type { Logger } from "../../../boot/logger.js";
3
+ /** A fresh upload reference: the prefix and 128 random bits, hex. */
4
+ export declare function newUploadRef(): string;
5
+ /**
6
+ * The staging key a reference's bytes land under, or undefined when the
7
+ * reference is not one this server could have minted. Refs arrive from
8
+ * clients (the push request, the lane's URL path), so the shape is
9
+ * checked before it becomes a storage key.
10
+ */
11
+ export declare function stagingKeyOf(ref: string): string | undefined;
12
+ /**
13
+ * The reference for a staging key this module minted. Keys reach here from
14
+ * the domain's own mint, never from a client, so a foreign shape is a
15
+ * programming error and throws.
16
+ */
17
+ export declare function uploadRefOf(stagingKey: string): string;
18
+ /** What createArtifactUploadUrl hands the client. */
19
+ export interface StagedUpload {
20
+ /** The single-use reference the push presents. */
21
+ readonly ref: string;
22
+ /** Accepts one HTTP PUT of exactly the declared byte count. */
23
+ readonly url: string;
24
+ /** How long the reference and the URL stay valid. */
25
+ readonly ttlMs: number;
26
+ }
27
+ /** What getArtifactDownloadUrl hands the client. */
28
+ export interface DownloadCapability {
29
+ readonly url: string;
30
+ /** The floor of the URL's validity (DOWNLOAD_URL_TTL_MS). */
31
+ readonly ttlMs: number;
32
+ }
33
+ /** The staging port both archive kinds (skills, plugins) push through. */
34
+ export interface ArchiveStaging {
35
+ /** Mints a reference and the URL its bytes are PUT to. */
36
+ mint(declaredSizeBytes: number): Promise<StagedUpload>;
37
+ /**
38
+ * Reads the staged bytes for a reference and retires it. Throws
39
+ * SlotUnknownError when the driver holds nothing under the reference;
40
+ * any other failure is the driver's and propagates as an infrastructure
41
+ * fault.
42
+ */
43
+ consume(ref: string): Promise<Uint8Array>;
44
+ /** A time-limited download URL for a stored archive key. */
45
+ downloadUrl(storageKey: string): Promise<DownloadCapability>;
46
+ }
47
+ export declare function newArchiveStaging(driver: ArtifactStorage, logger: Logger): ArchiveStaging;
48
+ //# sourceMappingURL=staging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staging.d.ts","sourceRoot":"","sources":["../../../../src/domain/skill/transfer/staging.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAEpF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AA4BtD,qEAAqE;AACrE,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK5D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,oDAAoD;AACpD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,0EAA0E;AAC1E,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACvD;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1C,4DAA4D;IAC5D,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC9D;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,GACb,cAAc,CA8DhB"}