@inneranimalmedia/agentsam-sdk 2.6.9 → 2.6.11

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 (392) hide show
  1. package/README.md +21 -0
  2. package/TRADEMARKS.md +22 -0
  3. package/apps/README.md +3 -0
  4. package/apps/cad-creator/LICENSE +21 -0
  5. package/apps/cad-creator/README.md +4 -1
  6. package/apps/cad-creator/shared/cad/package.json +1 -1
  7. package/apps/client-cms-editor/LICENSE +21 -0
  8. package/apps/client-cms-editor/README.md +3 -0
  9. package/apps/client-cms-editor/backend/package.json +3 -3
  10. package/apps/client-cms-editor/frontend/package.json +4 -4
  11. package/apps/client-cms-editor/package-lock.json +43 -43
  12. package/apps/client-cms-editor/package.json +3 -3
  13. package/apps/client-cms-editor/reference/harvest/HARVEST_RECEIPT.json +1 -1
  14. package/apps/client-cms-editor/reference/harvest/README.md +1 -1
  15. package/apps/client-cms-editor/reference/harvest/plans/ARCHIVE-INTAKE.md +1 -1
  16. package/apps/client-cms-editor/reference/harvest/plans/HARVEST-INDEX.md +1 -1
  17. package/apps/client-cms-editor/reference/harvest/plans/TOOLING-LAB.md +1 -1
  18. package/apps/client-cms-editor/shared/cms/package.json +2 -2
  19. package/docs/MINI.md +4 -2
  20. package/docs/REPO_FILE_MAP.txt +0 -1
  21. package/docs/SOURCE_ARCHITECTURE.md +1 -1
  22. package/docs/architecture/DUAL_ANALYTICS_PRODUCT.md +140 -0
  23. package/docs/architecture/HOOKS-MODELS-SELF-HOSTING-PLAN.md +199 -0
  24. package/docs/content-studio/REVISION_GATE_2026-09-27.md +1 -1
  25. package/docs/engineering/go-portability/01-product-project-deployment-authority.md +69 -0
  26. package/docs/engineering/provider-internal-renames/01-lane-initialization.md +20 -0
  27. package/docs/engineering/provider-internal-renames/01a-runtime-environment-contract.md +115 -0
  28. package/docs/engineering/provider-internal-renames/02-cfoa.md +57 -0
  29. package/docs/engineering/provider-internal-renames/03-gclioa.md +32 -0
  30. package/docs/engineering/provider-internal-renames/04-goaude.md +50 -0
  31. package/docs/engineering/provider-internal-renames/05-gdrv.md +33 -0
  32. package/docs/engineering/provider-internal-renames/06-verification.md +103 -0
  33. package/docs/engineering/provider-internal-renames/README.md +77 -0
  34. package/docs/engineering/provider-internal-renames/runtime-environment-contract.json +220 -0
  35. package/docs/engineering/test-diagnostics/go-cli-test-hang-20261003.md +49 -0
  36. package/docs/engineering/test-diagnostics/go-skip-deploy-docker-fix.md +90 -0
  37. package/docs/knowledge-service-verification.md +3 -3
  38. package/docs/plans/AGENTSAM-SUSPEND-QUEUE-KNOWLEDGE-RDP-2026-10-03.md +870 -0
  39. package/docs/plans/LOCAL-STUDIO-GRADUATION-2026-09-26.md +9 -9
  40. package/docs/plans/MACHINE-FIRST-APPS-TUI-2026-09-24.md +11 -11
  41. package/docs/plans/RECONCILIATION-2026-09-19.md +6 -6
  42. package/docs/plans/SAM_WORK_PROTOCOL.md +667 -0
  43. package/docs/plans/TOMORROW-EXTENSIVE-TODO-2026-09-26.md +2 -2
  44. package/docs/plans/UNIVERSAL-INGEST-MACHINE-FIRST-2026-09-24.md +3 -3
  45. package/examples/hyperspace-demo/index.html +16 -0
  46. package/examples/hyperspace-demo/package.json +21 -0
  47. package/examples/hyperspace-demo/src/main.tsx +277 -0
  48. package/examples/hyperspace-demo/tsconfig.json +9 -0
  49. package/examples/hyperspace-demo/vite.config.ts +24 -0
  50. package/migrations/d1/0020_agentsam_receipt_catalog.sql +35 -0
  51. package/migrations/runtime/0005_agentsam_hooks.sql +87 -0
  52. package/migrations/runtime/0006_agent_run_suspend_activity.sql +53 -0
  53. package/migrations/runtime/0007_queue_control.sql +40 -0
  54. package/migrations/runtime/0008_agent_run_dependencies.sql +24 -0
  55. package/migrations/runtime/0008_analytics_legacy_bootstrap.sql +43 -0
  56. package/migrations/runtime/0009_analytics_authority.sql +108 -0
  57. package/package.json +45 -14
  58. package/packages/agentsam-brand/README.md +3 -0
  59. package/packages/agentsam-brand/package.json +2 -2
  60. package/packages/agentsam-brand/src/core/v2/compile.js +1 -1
  61. package/packages/agentsam-brand/src/core/v2/schema.js +1 -1
  62. package/packages/agentsam-contracts/dist/adapter.d.ts +22 -0
  63. package/packages/agentsam-contracts/dist/adapter.js +0 -0
  64. package/packages/agentsam-contracts/dist/agent.d.ts +66 -0
  65. package/packages/agentsam-contracts/dist/agent.js +15 -0
  66. package/packages/agentsam-contracts/dist/artifacts.d.ts +70 -0
  67. package/packages/agentsam-contracts/dist/artifacts.js +0 -0
  68. package/packages/agentsam-contracts/dist/authority.d.ts +21 -0
  69. package/packages/agentsam-contracts/dist/authority.js +0 -0
  70. package/packages/agentsam-contracts/dist/context.d.ts +14 -0
  71. package/packages/agentsam-contracts/dist/context.js +0 -0
  72. package/packages/agentsam-contracts/dist/errors.d.ts +121 -0
  73. package/packages/agentsam-contracts/dist/errors.js +5 -0
  74. package/packages/agentsam-contracts/dist/events.d.ts +53 -0
  75. package/packages/agentsam-contracts/dist/events.js +0 -0
  76. package/packages/agentsam-contracts/dist/execution.d.ts +38 -0
  77. package/packages/agentsam-contracts/dist/execution.js +0 -0
  78. package/packages/agentsam-contracts/dist/hooks.d.ts +31 -0
  79. package/packages/agentsam-contracts/dist/hooks.js +0 -0
  80. package/packages/agentsam-contracts/dist/identity.d.ts +15 -0
  81. package/packages/agentsam-contracts/dist/identity.js +0 -0
  82. package/packages/agentsam-contracts/dist/index.d.ts +16 -0
  83. package/packages/agentsam-contracts/dist/index.js +164 -0
  84. package/packages/agentsam-contracts/dist/models.d.ts +9 -0
  85. package/packages/agentsam-contracts/dist/models.js +0 -0
  86. package/packages/agentsam-contracts/dist/providers.d.ts +27 -0
  87. package/packages/agentsam-contracts/dist/providers.js +0 -0
  88. package/packages/agentsam-contracts/dist/repository.d.ts +56 -0
  89. package/packages/agentsam-contracts/dist/repository.js +15 -0
  90. package/packages/agentsam-contracts/dist/run.d.ts +113 -0
  91. package/packages/agentsam-contracts/dist/run.js +132 -0
  92. package/packages/agentsam-contracts/dist/tools.d.ts +82 -0
  93. package/packages/agentsam-contracts/dist/tools.js +0 -0
  94. package/packages/agentsam-contracts/dist/widgets.d.ts +38 -0
  95. package/packages/agentsam-contracts/dist/widgets.js +0 -0
  96. package/packages/agentsam-contracts/package.json +9 -1
  97. package/packages/agentsam-contracts/scripts/build.mjs +1 -1
  98. package/packages/agentsam-contracts/src/agent.ts +78 -3
  99. package/packages/agentsam-contracts/src/errors.ts +19 -10
  100. package/packages/agentsam-contracts/src/index.ts +2 -0
  101. package/packages/agentsam-contracts/src/run.ts +320 -0
  102. package/packages/agentsam-contracts/src/widgets.ts +58 -0
  103. package/packages/agentsam-contracts/test/contracts.test.mjs +1 -1
  104. package/packages/agentsam-contracts/test/run-contract.test.mjs +94 -0
  105. package/packages/agentsam-errors/package.json +11 -3
  106. package/packages/agentsam-errors/protocol/agentsam.error.v2.schema.json +821 -0
  107. package/packages/agentsam-errors/protocol/error-catalog.json +3512 -0
  108. package/packages/agentsam-errors/src/envelope.js +63 -11
  109. package/packages/agentsam-errors/src/error.js +6 -0
  110. package/packages/agentsam-errors/src/fingerprint.js +9 -1
  111. package/packages/agentsam-errors/src/normalize.js +51 -6
  112. package/packages/agentsam-errors/src/recovery.js +9 -35
  113. package/packages/agentsam-errors/src/transport.js +6 -1
  114. package/packages/agentsam-errors/src/vocabulary.js +515 -126
  115. package/packages/agentsam-errors/test/catalog-v2.test.mjs +106 -0
  116. package/packages/agentsam-errors/types/index.d.ts +157 -0
  117. package/packages/agentsam-goap/README.md +3 -0
  118. package/packages/agentsam-goap/package.json +2 -2
  119. package/packages/agentsam-hooks/README.md +206 -0
  120. package/packages/agentsam-hooks/bin/agentsam-hooks.mjs +64 -0
  121. package/packages/agentsam-hooks/bindings/go/command.go +55 -0
  122. package/packages/agentsam-hooks/bindings/go/errors_generated.go +402 -0
  123. package/packages/agentsam-hooks/bindings/go/go.mod +3 -0
  124. package/packages/agentsam-hooks/bindings/go/hooks.go +285 -0
  125. package/packages/agentsam-hooks/bindings/go/hooks_test.go +48 -0
  126. package/packages/agentsam-hooks/bindings/rust/Cargo.toml +11 -0
  127. package/packages/agentsam-hooks/bindings/rust/src/errors_generated.rs +396 -0
  128. package/packages/agentsam-hooks/bindings/rust/src/lib.rs +397 -0
  129. package/packages/agentsam-hooks/package.json +69 -0
  130. package/packages/agentsam-hooks/schema/manifest.json +54 -0
  131. package/packages/agentsam-hooks/scripts/clean-protocol.mjs +17 -0
  132. package/packages/agentsam-hooks/scripts/sync-protocol.mjs +27 -0
  133. package/packages/agentsam-hooks/src/adapters/agents.js +108 -0
  134. package/packages/agentsam-hooks/src/adapters/callback.js +4 -0
  135. package/packages/agentsam-hooks/src/adapters/capability.js +122 -0
  136. package/packages/agentsam-hooks/src/adapters/command.js +104 -0
  137. package/packages/agentsam-hooks/src/adapters/composite.js +31 -0
  138. package/packages/agentsam-hooks/src/adapters/http.js +58 -0
  139. package/packages/agentsam-hooks/src/adapters/lsp.js +116 -0
  140. package/packages/agentsam-hooks/src/adapters/mcp.js +76 -0
  141. package/packages/agentsam-hooks/src/adapters/provider.js +129 -0
  142. package/packages/agentsam-hooks/src/config.js +143 -0
  143. package/packages/agentsam-hooks/src/contracts.js +284 -0
  144. package/packages/agentsam-hooks/src/errors-generated.js +2732 -0
  145. package/packages/agentsam-hooks/src/index.d.ts +209 -0
  146. package/packages/agentsam-hooks/src/index.js +14 -0
  147. package/packages/agentsam-hooks/src/policy.js +34 -0
  148. package/packages/agentsam-hooks/src/runtime.js +312 -0
  149. package/packages/agentsam-hooks/src/store.js +264 -0
  150. package/packages/agentsam-hooks/test/adapters.test.mjs +216 -0
  151. package/packages/agentsam-hooks/test/runtime.test.mjs +258 -0
  152. package/packages/agentsam-knowledge/package.json +1 -1
  153. package/packages/agentsam-knowledge/src/backends/index.js +1 -1
  154. package/packages/agentsam-merch/README.md +62 -0
  155. package/packages/agentsam-merch/bin/agentsam-merch.mjs +16 -0
  156. package/packages/agentsam-merch/package.json +65 -0
  157. package/packages/agentsam-merch/profiles/completeful/dtg-back-large.json +42 -0
  158. package/packages/agentsam-merch/profiles/completeful/laser-engraving.json +39 -0
  159. package/packages/agentsam-merch/profiles/generic/embroidery-digitization.json +22 -0
  160. package/packages/agentsam-merch/schemas/collection-candidate.schema.json +66 -0
  161. package/packages/agentsam-merch/schemas/manufacturing-profile.schema.json +221 -0
  162. package/packages/agentsam-merch/src/adapters-completeful.js +50 -0
  163. package/packages/agentsam-merch/src/cli.js +93 -0
  164. package/packages/agentsam-merch/src/collection-lab.js +60 -0
  165. package/packages/agentsam-merch/src/compatibility.js +501 -0
  166. package/packages/agentsam-merch/src/derivatives.js +112 -0
  167. package/packages/agentsam-merch/src/index.d.ts +316 -0
  168. package/packages/agentsam-merch/src/index.js +46 -0
  169. package/packages/agentsam-merch/src/node/index.d.ts +58 -0
  170. package/packages/agentsam-merch/src/node/index.js +6 -0
  171. package/packages/agentsam-merch/src/node/raster.js +142 -0
  172. package/packages/agentsam-merch/src/node/vector.js +239 -0
  173. package/packages/agentsam-merch/src/product-concepts.js +118 -0
  174. package/packages/agentsam-merch/src/profile-registry.js +104 -0
  175. package/packages/agentsam-merch/src/profile.js +158 -0
  176. package/packages/agentsam-merch/src/transforms.js +215 -0
  177. package/packages/agentsam-merch/test/merch.test.mjs +332 -0
  178. package/packages/agentsam-merch/test/node-transforms.test.mjs +149 -0
  179. package/packages/agentsam-nav/dist/Nav.d.ts +43 -0
  180. package/packages/agentsam-nav/dist/NavCollapsible.d.ts +10 -0
  181. package/packages/agentsam-nav/dist/NavContent.d.ts +2 -0
  182. package/packages/agentsam-nav/dist/NavFooter.d.ts +2 -0
  183. package/packages/agentsam-nav/dist/NavGroup.d.ts +3 -0
  184. package/packages/agentsam-nav/dist/NavHeader.d.ts +2 -0
  185. package/packages/agentsam-nav/dist/NavMenu.d.ts +22 -0
  186. package/packages/agentsam-nav/dist/NavProvider.d.ts +35 -0
  187. package/packages/agentsam-nav/dist/NavTrigger.d.ts +2 -0
  188. package/packages/agentsam-nav/dist/Surfaces.d.ts +41 -0
  189. package/packages/agentsam-nav/dist/browser.d.ts +11 -0
  190. package/packages/agentsam-nav/dist/browser.global.js +172 -0
  191. package/packages/agentsam-nav/dist/browser.js +9688 -0
  192. package/packages/agentsam-nav/dist/contracts.d.ts +76 -0
  193. package/packages/agentsam-nav/dist/index.d.ts +11 -0
  194. package/packages/agentsam-nav/dist/index.js +9689 -0
  195. package/packages/agentsam-nav/dist/legacy.css +83 -0
  196. package/packages/agentsam-nav/dist/shell.css +113 -0
  197. package/packages/agentsam-nav/dist/theme.css +113 -0
  198. package/packages/agentsam-nav/dist/utils.d.ts +1 -0
  199. package/packages/agentsam-nav/package.json +1 -1
  200. package/packages/agentsam-queue-control/README.md +4 -1
  201. package/packages/agentsam-queue-control/package.json +4 -3
  202. package/packages/agentsam-queue-control/schemas/job-envelope.schema.json +111 -11
  203. package/packages/agentsam-queue-control/src/adapters/cloudflare.js +34 -6
  204. package/packages/agentsam-queue-control/src/adapters/memory.js +11 -2
  205. package/packages/agentsam-queue-control/src/adapters/sqlite.js +259 -0
  206. package/packages/agentsam-queue-control/src/contracts.js +207 -3
  207. package/packages/agentsam-queue-control/src/control-plane.js +62 -2
  208. package/packages/agentsam-queue-control/src/index.js +1 -0
  209. package/packages/agentsam-queue-control/test/queue-control.test.mjs +310 -0
  210. package/packages/agentsam-queue-control/test/sqlite-adapter.test.mjs +91 -0
  211. package/packages/agentsam-rapid-rust/README.md +3 -0
  212. package/packages/agentsam-repository/README.md +3 -0
  213. package/packages/agentsam-repository/package.json +1 -1
  214. package/packages/agentsam-vault/package.json +1 -1
  215. package/packages/agentsam-workbench/README.md +43 -0
  216. package/packages/agentsam-workbench/package.json +14 -4
  217. package/packages/agentsam-workbench/src/agent/AgentConversationSurface.tsx +108 -0
  218. package/packages/agentsam-workbench/src/agent/AgentPanel.tsx +25 -8
  219. package/packages/agentsam-workbench/src/agent/AgentRuntimeField.tsx +152 -0
  220. package/packages/agentsam-workbench/src/agent/Composer.tsx +10 -1
  221. package/packages/agentsam-workbench/src/agent/RunMode.ts +26 -0
  222. package/packages/agentsam-workbench/src/agent/Thread.tsx +18 -3
  223. package/packages/agentsam-workbench/src/agent/index.ts +3 -0
  224. package/packages/agentsam-workbench/src/index.ts +4 -0
  225. package/packages/agentsam-workbench/src/manufacturing/PreflightIndicator.tsx +203 -0
  226. package/packages/agentsam-workbench/src/manufacturing/index.ts +2 -0
  227. package/packages/agentsam-workbench/src/manufacturing/loading.ts +147 -0
  228. package/packages/agentsam-workbench/src/widgets/BuiltinWidget.tsx +22 -0
  229. package/packages/agentsam-workbench/src/widgets/CountdownWidget.tsx +68 -0
  230. package/packages/agentsam-workbench/src/widgets/WidgetFrame.tsx +56 -0
  231. package/packages/agentsam-workbench/src/widgets/countdown.ts +25 -0
  232. package/packages/agentsam-workbench/src/widgets/index.ts +6 -0
  233. package/packages/agentsam-workbench/src/widgets/registry.ts +13 -0
  234. package/packages/agentsam-workbench/src/widgets/useCountdown.ts +128 -0
  235. package/packages/agentsam-workbench/src/widgets/widgets.css +102 -0
  236. package/packages/connectors/{cloudflare → cfoa}/package.json +3 -3
  237. package/packages/heuristic-theme/package.json +1 -1
  238. package/packages/identity/README.md +3 -0
  239. package/packages/identity/backend/README.md +3 -0
  240. package/packages/identity/package.json +2 -2
  241. package/packages/identity/src/frontend/auth-portal/README.md +3 -0
  242. package/packages/identity/src/index.js +1 -1
  243. package/packages/identity/src/oauth/README.md +4 -1
  244. package/packages/identity/src/oauth/credentials.js +1 -1
  245. package/packages/identity/src/server/worker-router.js +1 -1
  246. package/packages/identity/tests/google-desktop-identity-login.test.mjs +1 -1
  247. package/packages/identity/tests/lane1-packed-consumer.test.mjs +1 -1
  248. package/packages/identity/tests/oauth-presets-accounts-ssot.test.mjs +1 -1
  249. package/packages/providers/completeful/package.json +1 -1
  250. package/packages/theme-church-site/package.json +2 -2
  251. package/packages/theme-companions-site/package.json +2 -2
  252. package/packages/theme-floors-site/package.json +2 -2
  253. package/packages/theme-fuelnfree-site/package.json +2 -2
  254. package/packages/theme-handyman-site/package.json +2 -2
  255. package/packages/theme-insurance-site/package.json +2 -2
  256. package/packages/theme-scenes/package.json +1 -1
  257. package/packages/theme-shinshu-site/package.json +2 -2
  258. package/packages/work-graph/package.json +1 -1
  259. package/protocol/apps/agentsam.app.v1.schema.json +1 -1
  260. package/protocol/apps/agentsam.host-install.v1.schema.json +1 -1
  261. package/protocol/assets/asset-record.v1.schema.json +1 -1
  262. package/protocol/brand/brandpack.v1.schema.json +1 -1
  263. package/protocol/capabilities/capability-manifest.schema.json +1 -1
  264. package/protocol/capabilities/knowledge-search-input.schema.json +1 -0
  265. package/protocol/credentials/issue.v1.schema.json +1 -1
  266. package/protocol/database/agentsam.schema-pack.v1.schema.json +1 -1
  267. package/protocol/database/connection.v1.schema.json +1 -1
  268. package/protocol/embeddings/embedding-profile.v1.schema.json +1 -1
  269. package/protocol/errors/README.md +36 -0
  270. package/protocol/errors/agentsam.error.v2.schema.json +821 -0
  271. package/protocol/errors/error-catalog.json +3506 -158
  272. package/protocol/errors/error-envelope.schema.json +195 -52
  273. package/protocol/errors/recovery.v1.schema.json +1 -1
  274. package/protocol/features/agentsam.feature.v1.schema.json +1 -1
  275. package/protocol/hooks/README.md +18 -0
  276. package/protocol/hooks/agentsam.hook.output.v1.schema.json +27 -0
  277. package/protocol/hooks/agentsam.hook.receipt.v1.schema.json +61 -0
  278. package/protocol/hooks/agentsam.hook.v1.schema.json +35 -0
  279. package/protocol/hooks/agentsam.hooks.config.v1.schema.json +78 -0
  280. package/protocol/local-engine/benchmark.v1.schema.json +1 -1
  281. package/protocol/local-engine/engine.v1.schema.json +1 -1
  282. package/protocol/models/README.md +3 -0
  283. package/protocol/models/model-inventory-v2.schema.json +1 -1
  284. package/protocol/models/provider-model-snapshot.v1.schema.json +22 -0
  285. package/protocol/receipts/agentsam.receipt.v1.json +95 -0
  286. package/protocol/rpc/v1/errors.proto +1 -0
  287. package/protocol/runtime/agentsam.runtime.v1.schema.json +1 -1
  288. package/protocol/runtime/workspace-fs.v1.schema.json +1 -1
  289. package/protocol/sam/activity.v1.schema.json +1 -1
  290. package/protocol/sam/answer.v1.schema.json +1 -1
  291. package/protocol/sam/calibration.v1.schema.json +1 -1
  292. package/protocol/sam/decision-receipt.v1.schema.json +1 -1
  293. package/protocol/sam/evaluation.v1.schema.json +1 -1
  294. package/protocol/sam/operation.schema.json +1 -1
  295. package/protocol/sam/outcome.v1.schema.json +1 -1
  296. package/protocol/sam/question.v1.schema.json +1 -1
  297. package/protocol/sam/result.schema.json +1 -1
  298. package/protocol/sam/state.v1.schema.json +1 -1
  299. package/protocol/scoring/scorecard.v1.schema.json +1 -1
  300. package/protocol/skills/agentsam.interaction.v1.schema.json +1 -1
  301. package/protocol/skills/agentsam.skill.v1.schema.json +1 -1
  302. package/protocol/theme-refinery/product-metadata.schema.json +1 -1
  303. package/protocol/theme-refinery/receipts/products-registry-batch-20260924.json +6 -6
  304. package/protocol/theme-refinery/receipts/theme-harvest-20260924.json +6 -6
  305. package/protocol/theme-refinery/reconciliation-receipt.schema.json +1 -1
  306. package/protocol/ui/icon.v1.schema.json +1 -1
  307. package/python/README.md +20 -0
  308. package/python/agentsam_sdk/errors/__init__.py +4 -0
  309. package/python/agentsam_sdk/errors/vocabulary.py +2730 -0
  310. package/python/agentsam_sdk/hooks/__init__.py +32 -0
  311. package/python/agentsam_sdk/hooks/adapters.py +132 -0
  312. package/python/agentsam_sdk/hooks/contracts.py +121 -0
  313. package/python/agentsam_sdk/hooks/runtime.py +253 -0
  314. package/python/tests/test_hooks.py +115 -0
  315. package/skills/README.md +3 -0
  316. package/src/acp/agent-executor.js +106 -0
  317. package/src/acp/client.js +316 -0
  318. package/src/acp/dependencies.js +426 -0
  319. package/src/acp/http.js +207 -0
  320. package/src/acp/index.js +22 -0
  321. package/src/acp/runs.js +125 -0
  322. package/src/acp/runtime-selection.js +180 -0
  323. package/src/agent/responses-runner.js +145 -1
  324. package/src/cli/command-catalog.js +4 -0
  325. package/src/cli.js +33 -0
  326. package/src/commands/cheat-sheet.js +1 -0
  327. package/src/commands/cloudflare-login.js +1 -1
  328. package/src/commands/cloudflare.js +2 -2
  329. package/src/commands/connections.js +1 -1
  330. package/src/commands/go.js +76 -6
  331. package/src/commands/hooks.js +260 -0
  332. package/src/commands/merch.js +5 -0
  333. package/src/commands/mini.js +1 -1
  334. package/src/commands/models.js +1 -1
  335. package/src/commands/receipts.js +140 -0
  336. package/src/commands/run.js +253 -0
  337. package/src/commands/shell.js +114 -9
  338. package/src/errors/diagnostic.js +9 -9
  339. package/src/go/container.js +1 -1
  340. package/src/go/contract.js +61 -18
  341. package/src/go/discover.js +0 -4
  342. package/src/go/index.js +13 -1
  343. package/src/go/probe.js +109 -0
  344. package/src/go/{cloudflare.js → providers/cloudflare.js} +36 -136
  345. package/src/go/verify.js +1 -1
  346. package/src/index.js +32 -0
  347. package/src/indexing/ingest/inventory.js +1 -1
  348. package/src/knowledge/service/grpc-codec.js +2 -0
  349. package/src/lib/deploy/local-studio.js +2 -2
  350. package/src/lib/mini/scaffold.js +1 -1
  351. package/src/lib/slash-commands.js +1 -0
  352. package/src/lib/whoami-capabilities.js +1 -1
  353. package/src/local/runtime-store.js +54 -0
  354. package/src/mcp/cloudflare-bundles.js +1 -1
  355. package/src/models/catalog.js +0 -49
  356. package/src/models/inventory-core.js +69 -0
  357. package/src/plugins/index.js +9 -1
  358. package/src/plugins/registry.js +115 -6
  359. package/src/receipts/contract.js +68 -0
  360. package/src/receipts/index.js +20 -0
  361. package/src/receipts/prune.js +64 -0
  362. package/src/receipts/sinks.js +285 -0
  363. package/src/rpc/generated/errors_pb.js +49 -1
  364. package/src/tools/runtime.js +13 -5
  365. package/templates/mini/gadget/app.js +15 -40
  366. package/templates/mini/gadget/index.html +7 -7
  367. package/templates/mini/shared/style.css +1 -1
  368. /package/packages/connectors/{cloudflare → cfoa}/OAUTH_STORAGE_AUDIT.md +0 -0
  369. /package/packages/connectors/{cloudflare → cfoa}/src/api-client.js +0 -0
  370. /package/packages/connectors/{cloudflare → cfoa}/src/capabilities.js +0 -0
  371. /package/packages/connectors/{cloudflare → cfoa}/src/credential.js +0 -0
  372. /package/packages/connectors/{cloudflare → cfoa}/src/families/brand-protection.js +0 -0
  373. /package/packages/connectors/{cloudflare → cfoa}/src/families/keyless.js +0 -0
  374. /package/packages/connectors/{cloudflare → cfoa}/src/families/pages.js +0 -0
  375. /package/packages/connectors/{cloudflare → cfoa}/src/families/scanner.js +0 -0
  376. /package/packages/connectors/{cloudflare → cfoa}/src/families/snippets.js +0 -0
  377. /package/packages/connectors/{cloudflare → cfoa}/src/families/tag-gateway.js +0 -0
  378. /package/packages/connectors/{cloudflare → cfoa}/src/families/tags.js +0 -0
  379. /package/packages/connectors/{cloudflare → cfoa}/src/families/token-validation.js +0 -0
  380. /package/packages/connectors/{cloudflare → cfoa}/src/families/vectorize.js +0 -0
  381. /package/packages/connectors/{cloudflare → cfoa}/src/families/workflows.js +0 -0
  382. /package/packages/connectors/{cloudflare → cfoa}/src/index.js +0 -0
  383. /package/packages/connectors/{cloudflare → cfoa}/src/oauth-persist.js +0 -0
  384. /package/packages/connectors/{cloudflare → cfoa}/src/owner.js +0 -0
  385. /package/packages/connectors/{cloudflare → cfoa}/src/permission-options.js +0 -0
  386. /package/packages/connectors/{cloudflare → cfoa}/src/routes.js +0 -0
  387. /package/packages/connectors/{cloudflare → cfoa}/src/scope-catalog.js +0 -0
  388. /package/packages/connectors/{cloudflare → cfoa}/src/vault.js +0 -0
  389. /package/packages/connectors/{cloudflare → cfoa}/tests/capabilities.test.mjs +0 -0
  390. /package/packages/connectors/{cloudflare → cfoa}/tests/connector.test.mjs +0 -0
  391. /package/packages/connectors/{cloudflare → cfoa}/tests/oauth-persist.test.mjs +0 -0
  392. /package/packages/identity/src/oauth/{google-desktop-exchange.js → goaude.js} +0 -0
@@ -0,0 +1,501 @@
1
+ import {
2
+ mediaKindForFormat,
3
+ normalizeFormat,
4
+ normalizeManufacturingProfile,
5
+ } from "./profile.js";
6
+
7
+ export const COMPATIBILITY_STATUS = Object.freeze({
8
+ READY: "ready",
9
+ READY_WITH_WARNING: "ready_with_warning",
10
+ READY_WITH_TRANSFORM: "ready_with_transform",
11
+ PREPARED_FOR_DIGITIZATION: "prepared_for_digitization",
12
+ NEEDS_VARIANT: "needs_variant",
13
+ UNSUPPORTED: "unsupported",
14
+ });
15
+
16
+ const severity = Object.freeze({
17
+ [COMPATIBILITY_STATUS.READY]: 0,
18
+ [COMPATIBILITY_STATUS.READY_WITH_WARNING]: 1,
19
+ [COMPATIBILITY_STATUS.READY_WITH_TRANSFORM]: 2,
20
+ [COMPATIBILITY_STATUS.PREPARED_FOR_DIGITIZATION]: 3,
21
+ [COMPATIBILITY_STATUS.NEEDS_VARIANT]: 4,
22
+ [COMPATIBILITY_STATUS.UNSUPPORTED]: 5,
23
+ });
24
+
25
+ function addIssue(issues, status, code, message, action = null, meta = null) {
26
+ issues.push(Object.freeze({ status, code, message, action, meta }));
27
+ }
28
+
29
+ function numberOrNull(value) {
30
+ const number = Number(value);
31
+ return Number.isFinite(number) && number > 0 ? number : null;
32
+ }
33
+
34
+ function normalizeAsset(input = {}) {
35
+ const mimeFormat = input.mimeType?.split("/").pop();
36
+ const format = normalizeFormat(input.format || input.extension || mimeFormat);
37
+ const widthPx = numberOrNull(input.widthPx || input.width);
38
+ const heightPx = numberOrNull(input.heightPx || input.height);
39
+ const contentWidthPx =
40
+ numberOrNull(input.contentWidthPx || input.trimmedWidthPx) || widthPx;
41
+ const contentHeightPx =
42
+ numberOrNull(input.contentHeightPx || input.trimmedHeightPx) || heightPx;
43
+
44
+ return Object.freeze({
45
+ ...input,
46
+ format,
47
+ mediaKind: input.mediaKind || mediaKindForFormat(format),
48
+ widthPx,
49
+ heightPx,
50
+ contentWidthPx,
51
+ contentHeightPx,
52
+ bytes: numberOrNull(input.bytes || input.sizeBytes),
53
+ colorSpace: input.colorSpace ? String(input.colorSpace).toLowerCase() : null,
54
+ colorMode: input.colorMode ? String(input.colorMode).toLowerCase() : null,
55
+ hasAlpha: typeof input.hasAlpha === "boolean" ? input.hasAlpha : null,
56
+ transparentBorderDetected: input.transparentBorderDetected === true,
57
+ isAlphaTrimmed: input.isAlphaTrimmed === true,
58
+ hasGradients: input.hasGradients === true,
59
+ hasOpenPaths: input.hasOpenPaths === true,
60
+ hasLiveText: input.hasLiveText === true,
61
+ hasExplicitViewBox:
62
+ typeof input.hasExplicitViewBox === "boolean" ? input.hasExplicitViewBox : null,
63
+ });
64
+ }
65
+
66
+ function targetGeometry(profile, target = {}) {
67
+ const widthIn = numberOrNull(
68
+ target.placementWidthIn ||
69
+ target.printWidthIn ||
70
+ profile.preferredPrintWidthIn,
71
+ );
72
+ const heightIn = numberOrNull(
73
+ target.placementHeightIn ||
74
+ target.printHeightIn ||
75
+ profile.preferredPrintHeightIn,
76
+ );
77
+ return Object.freeze({ widthIn, heightIn });
78
+ }
79
+
80
+ export function calculateEffectivePpi(assetInput, profileInput, target = {}) {
81
+ const asset = normalizeAsset(assetInput);
82
+ const profile = normalizeManufacturingProfile(profileInput);
83
+ if (
84
+ asset.mediaKind !== "raster" ||
85
+ !asset.contentWidthPx ||
86
+ !asset.contentHeightPx
87
+ ) {
88
+ return Object.freeze({
89
+ effectivePpi: null,
90
+ widthPpi: null,
91
+ heightPpi: null,
92
+ widthIn: null,
93
+ heightIn: null,
94
+ basis: null,
95
+ });
96
+ }
97
+
98
+ const { widthIn, heightIn } = targetGeometry(profile, target);
99
+ const widthPpi = widthIn ? asset.contentWidthPx / widthIn : null;
100
+ const heightPpi = heightIn ? asset.contentHeightPx / heightIn : null;
101
+ const samples = [widthPpi, heightPpi].filter((value) => value != null);
102
+ const effectivePpi = samples.length ? Math.min(...samples) : null;
103
+ const basis =
104
+ asset.contentWidthPx !== asset.widthPx ||
105
+ asset.contentHeightPx !== asset.heightPx
106
+ ? "content_bounds"
107
+ : "pixel_bounds";
108
+
109
+ return Object.freeze({
110
+ effectivePpi,
111
+ widthPpi,
112
+ heightPpi,
113
+ widthIn,
114
+ heightIn,
115
+ basis,
116
+ });
117
+ }
118
+
119
+ function resolutionQuality(profile, ppi) {
120
+ if (ppi == null || profile.resolution.readyPpi == null) {
121
+ return Object.freeze({
122
+ band: "unknown",
123
+ readyPpi: profile.resolution.readyPpi,
124
+ minimumPpi: profile.resolution.minimumPpi,
125
+ });
126
+ }
127
+
128
+ if (ppi >= profile.resolution.readyPpi) {
129
+ return Object.freeze({
130
+ band: "ready",
131
+ readyPpi: profile.resolution.readyPpi,
132
+ minimumPpi: profile.resolution.minimumPpi,
133
+ });
134
+ }
135
+
136
+ if (
137
+ profile.resolution.minimumPpi != null &&
138
+ ppi >= profile.resolution.minimumPpi
139
+ ) {
140
+ return Object.freeze({
141
+ band: "warning",
142
+ readyPpi: profile.resolution.readyPpi,
143
+ minimumPpi: profile.resolution.minimumPpi,
144
+ });
145
+ }
146
+
147
+ return Object.freeze({
148
+ band: "fail",
149
+ readyPpi: profile.resolution.readyPpi,
150
+ minimumPpi: profile.resolution.minimumPpi,
151
+ });
152
+ }
153
+
154
+ export function evaluateManufacturingCompatibility(
155
+ assetInput,
156
+ profileInput,
157
+ target = {},
158
+ ) {
159
+ const asset = normalizeAsset(assetInput);
160
+ const profile = normalizeManufacturingProfile(profileInput);
161
+ const issues = [];
162
+
163
+ if (!asset.format || asset.mediaKind === "unknown") {
164
+ addIssue(
165
+ issues,
166
+ COMPATIBILITY_STATUS.UNSUPPORTED,
167
+ "unknown_source_format",
168
+ "The source format cannot be classified safely.",
169
+ );
170
+ }
171
+
172
+ const canAutoVectorize =
173
+ asset.mediaKind === "raster" &&
174
+ profile.allowVector &&
175
+ profile.vectorization.enabled;
176
+
177
+ if (asset.mediaKind === "raster" && !profile.allowRaster) {
178
+ if (canAutoVectorize) {
179
+ addIssue(
180
+ issues,
181
+ COMPATIBILITY_STATUS.READY_WITH_TRANSFORM,
182
+ "raster_requires_vectorization",
183
+ "Build and verify a process-specific vector derivative before production.",
184
+ "vectorize_monochrome",
185
+ {
186
+ preferredTracer: profile.vectorization.preferredTracer,
187
+ outputFormat: profile.vectorization.outputFormat,
188
+ },
189
+ );
190
+ } else {
191
+ addIssue(
192
+ issues,
193
+ COMPATIBILITY_STATUS.NEEDS_VARIANT,
194
+ "raster_not_allowed",
195
+ "This manufacturing profile requires a non-raster production variant.",
196
+ "build_vector_or_process_specific_variant",
197
+ );
198
+ }
199
+ }
200
+
201
+ if (asset.mediaKind === "vector" && !profile.allowVector) {
202
+ if (profile.allowRaster) {
203
+ addIssue(
204
+ issues,
205
+ COMPATIBILITY_STATUS.READY_WITH_TRANSFORM,
206
+ "vector_requires_rasterization",
207
+ `Rasterize the vector master to ${profile.format}.`,
208
+ `rasterize:${profile.format}`,
209
+ );
210
+ } else {
211
+ addIssue(
212
+ issues,
213
+ COMPATIBILITY_STATUS.NEEDS_VARIANT,
214
+ "vector_not_allowed",
215
+ "This manufacturing profile does not accept the source media kind.",
216
+ );
217
+ }
218
+ }
219
+
220
+ if (asset.format && profile.format && asset.format !== profile.format) {
221
+ const targetKind = mediaKindForFormat(profile.format);
222
+ const conversionAllowed =
223
+ (targetKind === "raster" &&
224
+ ["raster", "vector"].includes(asset.mediaKind)) ||
225
+ (targetKind === "vector" &&
226
+ (asset.mediaKind === "vector" || canAutoVectorize));
227
+
228
+ addIssue(
229
+ issues,
230
+ conversionAllowed
231
+ ? COMPATIBILITY_STATUS.READY_WITH_TRANSFORM
232
+ : COMPATIBILITY_STATUS.NEEDS_VARIANT,
233
+ "format_mismatch",
234
+ `Production format is ${profile.format}; source is ${asset.format}.`,
235
+ conversionAllowed
236
+ ? canAutoVectorize && targetKind === "vector"
237
+ ? "vectorize_monochrome"
238
+ : `convert:${profile.format}`
239
+ : "build_process_specific_variant",
240
+ );
241
+ }
242
+
243
+ if (
244
+ asset.mediaKind === "raster" &&
245
+ asset.transparentBorderDetected &&
246
+ !asset.isAlphaTrimmed
247
+ ) {
248
+ addIssue(
249
+ issues,
250
+ profile.autoNormalize.trimAlpha
251
+ ? COMPATIBILITY_STATUS.READY_WITH_TRANSFORM
252
+ : COMPATIBILITY_STATUS.READY_WITH_WARNING,
253
+ "transparent_border_detected",
254
+ "Transparent outer pixels change the visible-artwork geometry.",
255
+ profile.autoNormalize.trimAlpha ? "trim_alpha" : null,
256
+ );
257
+ }
258
+
259
+ if (
260
+ profile.colorSpace &&
261
+ asset.colorSpace &&
262
+ asset.colorSpace !== profile.colorSpace
263
+ ) {
264
+ addIssue(
265
+ issues,
266
+ profile.autoNormalize.colorSpace
267
+ ? COMPATIBILITY_STATUS.READY_WITH_TRANSFORM
268
+ : COMPATIBILITY_STATUS.NEEDS_VARIANT,
269
+ "color_space_mismatch",
270
+ `Convert ${asset.colorSpace} to ${profile.colorSpace}.`,
271
+ profile.autoNormalize.colorSpace
272
+ ? `normalize_color_space:${profile.colorSpace}`
273
+ : "replace_or_convert_color_space",
274
+ );
275
+ }
276
+
277
+ if (profile.colorMode === "monochrome" && asset.colorMode !== "monochrome") {
278
+ addIssue(
279
+ issues,
280
+ canAutoVectorize || asset.mediaKind === "vector"
281
+ ? COMPATIBILITY_STATUS.READY_WITH_TRANSFORM
282
+ : COMPATIBILITY_STATUS.NEEDS_VARIANT,
283
+ "monochrome_required",
284
+ "Create a monochrome production derivative.",
285
+ canAutoVectorize ? "vectorize_monochrome" : "convert_monochrome",
286
+ );
287
+ }
288
+
289
+ if (!profile.allowGradients && asset.mediaKind === "vector" && asset.hasGradients) {
290
+ addIssue(
291
+ issues,
292
+ COMPATIBILITY_STATUS.NEEDS_VARIANT,
293
+ "gradients_not_allowed",
294
+ "Gradients must be simplified for this manufacturing process.",
295
+ "simplify_gradients",
296
+ );
297
+ }
298
+
299
+ if (
300
+ profile.requireClosedPaths &&
301
+ asset.mediaKind === "vector" &&
302
+ asset.hasOpenPaths
303
+ ) {
304
+ addIssue(
305
+ issues,
306
+ COMPATIBILITY_STATUS.NEEDS_VARIANT,
307
+ "closed_paths_required",
308
+ "Open vector paths must be closed before production.",
309
+ "close_paths",
310
+ );
311
+ }
312
+
313
+ if (
314
+ profile.requireViewBox &&
315
+ asset.mediaKind === "vector" &&
316
+ asset.hasExplicitViewBox === false
317
+ ) {
318
+ addIssue(
319
+ issues,
320
+ profile.autoNormalize.svgOptimize
321
+ ? COMPATIBILITY_STATUS.READY_WITH_TRANSFORM
322
+ : COMPATIBILITY_STATUS.NEEDS_VARIANT,
323
+ "viewbox_required",
324
+ "SVG production artwork requires an explicit viewBox.",
325
+ profile.autoNormalize.svgOptimize ? "normalize_svg" : "repair_svg_viewbox",
326
+ );
327
+ }
328
+
329
+ if (
330
+ profile.outlineText &&
331
+ asset.mediaKind === "vector" &&
332
+ asset.hasLiveText
333
+ ) {
334
+ addIssue(
335
+ issues,
336
+ profile.autoNormalize.outlineText
337
+ ? COMPATIBILITY_STATUS.READY_WITH_TRANSFORM
338
+ : COMPATIBILITY_STATUS.NEEDS_VARIANT,
339
+ "outline_text_required",
340
+ "Convert live text to vector outlines.",
341
+ profile.autoNormalize.outlineText ? "outline_text" : "outline_text_manually",
342
+ );
343
+ }
344
+
345
+ if (
346
+ profile.requireAlpha &&
347
+ asset.mediaKind === "raster" &&
348
+ asset.hasAlpha === false
349
+ ) {
350
+ addIssue(
351
+ issues,
352
+ COMPATIBILITY_STATUS.NEEDS_VARIANT,
353
+ "alpha_required",
354
+ "This production profile requires transparent artwork.",
355
+ "build_transparent_variant",
356
+ );
357
+ }
358
+
359
+ const resolution = calculateEffectivePpi(asset, profile, target);
360
+ const quality = resolutionQuality(profile, resolution.effectivePpi);
361
+
362
+ if (quality.band === "warning") {
363
+ addIssue(
364
+ issues,
365
+ COMPATIBILITY_STATUS.READY_WITH_WARNING,
366
+ "soft_resolution",
367
+ `Effective resolution is ${Math.round(
368
+ resolution.effectivePpi,
369
+ )} PPI at the current physical placement; target is ${Math.round(
370
+ quality.readyPpi,
371
+ )} PPI.`,
372
+ null,
373
+ {
374
+ effectivePpi: resolution.effectivePpi,
375
+ readyPpi: quality.readyPpi,
376
+ minimumPpi: quality.minimumPpi,
377
+ },
378
+ );
379
+ } else if (quality.band === "fail") {
380
+ addIssue(
381
+ issues,
382
+ COMPATIBILITY_STATUS.NEEDS_VARIANT,
383
+ "insufficient_resolution",
384
+ `Effective resolution is ${Math.round(
385
+ resolution.effectivePpi,
386
+ )} PPI at the current physical placement; minimum is ${Math.round(
387
+ quality.minimumPpi || quality.readyPpi,
388
+ )} PPI.`,
389
+ "replace_with_higher_resolution_master",
390
+ {
391
+ effectivePpi: resolution.effectivePpi,
392
+ readyPpi: quality.readyPpi,
393
+ minimumPpi: quality.minimumPpi,
394
+ },
395
+ );
396
+ }
397
+
398
+ if (profile.maxBytes && asset.bytes && asset.bytes > profile.maxBytes) {
399
+ addIssue(
400
+ issues,
401
+ COMPATIBILITY_STATUS.READY_WITH_TRANSFORM,
402
+ "file_too_large",
403
+ `Source exceeds the ${profile.maxBytes}-byte profile limit.`,
404
+ "lossless_optimize",
405
+ );
406
+ }
407
+
408
+ let status = issues.reduce(
409
+ (current, issue) =>
410
+ severity[issue.status] > severity[current] ? issue.status : current,
411
+ COMPATIBILITY_STATUS.READY,
412
+ );
413
+
414
+ if (
415
+ ![
416
+ COMPATIBILITY_STATUS.UNSUPPORTED,
417
+ COMPATIBILITY_STATUS.NEEDS_VARIANT,
418
+ ].includes(status) &&
419
+ profile.handoff?.status ===
420
+ COMPATIBILITY_STATUS.PREPARED_FOR_DIGITIZATION
421
+ ) {
422
+ status = COMPATIBILITY_STATUS.PREPARED_FOR_DIGITIZATION;
423
+ }
424
+
425
+ const requirementsVerified = profile.source?.verified !== false;
426
+ const nonBlocking =
427
+ status === COMPATIBILITY_STATUS.READY ||
428
+ status === COMPATIBILITY_STATUS.READY_WITH_WARNING;
429
+
430
+ return Object.freeze({
431
+ profileId: profile.id,
432
+ manufacturer: profile.manufacturer,
433
+ process: profile.process,
434
+ status,
435
+ requirementsVerified,
436
+ productionReady: nonBlocking && requirementsVerified,
437
+ transformReady: status === COMPATIBILITY_STATUS.READY_WITH_TRANSFORM,
438
+ effectivePpi:
439
+ resolution.effectivePpi == null
440
+ ? null
441
+ : Math.round(resolution.effectivePpi * 10) / 10,
442
+ resolution: Object.freeze({
443
+ band: quality.band,
444
+ basis: resolution.basis,
445
+ widthPpi:
446
+ resolution.widthPpi == null
447
+ ? null
448
+ : Math.round(resolution.widthPpi * 10) / 10,
449
+ heightPpi:
450
+ resolution.heightPpi == null
451
+ ? null
452
+ : Math.round(resolution.heightPpi * 10) / 10,
453
+ readyPpi: quality.readyPpi,
454
+ minimumPpi: quality.minimumPpi,
455
+ }),
456
+ target: Object.freeze({
457
+ format: profile.format,
458
+ ppi: profile.ppi,
459
+ printWidthIn: resolution.widthIn,
460
+ printHeightIn: resolution.heightIn,
461
+ }),
462
+ issues: Object.freeze(issues),
463
+ actions: Object.freeze([
464
+ ...new Set(issues.map((issue) => issue.action).filter(Boolean)),
465
+ ]),
466
+ handoff: profile.handoff,
467
+ });
468
+ }
469
+
470
+ export function evaluateCompatibleProducts(asset, products, registry) {
471
+ return products.map((product) => {
472
+ const profile =
473
+ (product.profileId && registry.get(product.profileId)) ||
474
+ registry.select(product.profileContext || product);
475
+ if (!profile) {
476
+ return Object.freeze({
477
+ ...product,
478
+ compatibility: {
479
+ status: COMPATIBILITY_STATUS.UNSUPPORTED,
480
+ productionReady: false,
481
+ issues: [
482
+ {
483
+ code: "profile_not_found",
484
+ message: "No manufacturing profile matched this product.",
485
+ },
486
+ ],
487
+ actions: [],
488
+ },
489
+ });
490
+ }
491
+ return Object.freeze({
492
+ ...product,
493
+ profileId: profile.id,
494
+ compatibility: evaluateManufacturingCompatibility(
495
+ asset,
496
+ profile,
497
+ product.target || product,
498
+ ),
499
+ });
500
+ });
501
+ }
@@ -0,0 +1,112 @@
1
+ import { evaluateManufacturingCompatibility } from "./compatibility.js";
2
+ import { normalizeManufacturingProfile } from "./profile.js";
3
+
4
+ export const DERIVATIVE_ROLE = Object.freeze({
5
+ ORIGINAL: "original/master",
6
+ MANUFACTURING: "manufacturing",
7
+ STOREFRONT: "storefront/gallery",
8
+ THUMBNAIL: "thumbnail",
9
+ SOCIAL: "social",
10
+ MOCKUP: "mockup",
11
+ });
12
+
13
+ export function planMediaDerivatives({
14
+ asset,
15
+ profile,
16
+ target = {},
17
+ storefrontFormat = "webp",
18
+ thumbnailFormat = "webp",
19
+ socialFormat = "jpg",
20
+ mockupFormat = "webp",
21
+ } = {}) {
22
+ const normalizedProfile = normalizeManufacturingProfile(profile);
23
+ const compatibility = evaluateManufacturingCompatibility(asset, normalizedProfile, target);
24
+
25
+ return Object.freeze({
26
+ source: Object.freeze({
27
+ role: DERIVATIVE_ROLE.ORIGINAL,
28
+ preserve: true,
29
+ immutableAuthority: true,
30
+ format: asset?.format || null,
31
+ }),
32
+ manufacturing: Object.freeze({
33
+ role: DERIVATIVE_ROLE.MANUFACTURING,
34
+ preserve: true,
35
+ derivedFrom: DERIVATIVE_ROLE.ORIGINAL,
36
+ format: normalizedProfile.format,
37
+ profileId: normalizedProfile.id,
38
+ compatibility,
39
+ mustNotUseStorefrontDerivative: true,
40
+ }),
41
+ storefront: Object.freeze({
42
+ role: DERIVATIVE_ROLE.STOREFRONT,
43
+ preserve: false,
44
+ derivedFrom: DERIVATIVE_ROLE.ORIGINAL,
45
+ format: storefrontFormat,
46
+ optimizeFor: "delivery",
47
+ }),
48
+ thumbnail: Object.freeze({
49
+ role: DERIVATIVE_ROLE.THUMBNAIL,
50
+ preserve: false,
51
+ derivedFrom: DERIVATIVE_ROLE.ORIGINAL,
52
+ format: thumbnailFormat,
53
+ optimizeFor: "small-ui",
54
+ }),
55
+ social: Object.freeze({
56
+ role: DERIVATIVE_ROLE.SOCIAL,
57
+ preserve: false,
58
+ derivedFrom: DERIVATIVE_ROLE.ORIGINAL,
59
+ format: socialFormat,
60
+ optimizeFor: "social",
61
+ }),
62
+ mockup: Object.freeze({
63
+ role: DERIVATIVE_ROLE.MOCKUP,
64
+ preserve: false,
65
+ derivedFrom: DERIVATIVE_ROLE.ORIGINAL,
66
+ format: mockupFormat,
67
+ optimizeFor: "preview",
68
+ }),
69
+ });
70
+ }
71
+
72
+ export function buildMerchPlan({ design, products = [], registry }) {
73
+ if (!design?.asset) throw new TypeError("design.asset is required");
74
+ if (!registry?.get || !registry?.select) {
75
+ throw new TypeError("a manufacturing profile registry is required");
76
+ }
77
+
78
+ const targets = products.map((product) => {
79
+ const profile =
80
+ (product.profileId && registry.get(product.profileId)) ||
81
+ registry.select(product.profileContext || product);
82
+
83
+ if (!profile) {
84
+ return Object.freeze({
85
+ id: product.id,
86
+ name: product.name || product.id,
87
+ profileId: null,
88
+ status: "unsupported",
89
+ reason: "No manufacturing profile matched.",
90
+ });
91
+ }
92
+
93
+ const derivatives = planMediaDerivatives({
94
+ asset: design.asset,
95
+ profile,
96
+ target: product.target || product,
97
+ });
98
+
99
+ return Object.freeze({
100
+ ...product,
101
+ profileId: profile.id,
102
+ status: derivatives.manufacturing.compatibility.status,
103
+ derivatives,
104
+ });
105
+ });
106
+
107
+ return Object.freeze({
108
+ schemaVersion: "agentsam.merch-plan.v1",
109
+ design: Object.freeze({ ...design }),
110
+ targets: Object.freeze(targets),
111
+ });
112
+ }