@skaile/workspaces 3.2.0 → 3.3.0

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 (157) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/dist/{asset-feeds-25DVAGVD.js → asset-feeds-AGAH5OHC.js} +5 -5
  3. package/dist/{asset-feeds-25DVAGVD.js.map → asset-feeds-AGAH5OHC.js.map} +1 -1
  4. package/dist/asset-manager/catalog-deployer.js +1 -1
  5. package/dist/asset-manager/index.js +2 -2
  6. package/dist/asset-manager/installer.js +1 -1
  7. package/dist/bridge/drivers/claude-sdk.js +2 -2
  8. package/dist/bridge/drivers/codex.js +1 -1
  9. package/dist/bridge/drivers/continue.js +2 -2
  10. package/dist/bridge/drivers/echo.js +1 -1
  11. package/dist/bridge/drivers/gemini.js +3 -3
  12. package/dist/bridge/drivers/goose.js +2 -2
  13. package/dist/bridge/drivers/omp.js +1 -1
  14. package/dist/bridge/drivers/opencode.js +2 -2
  15. package/dist/bridge/drivers/qwen.js +3 -3
  16. package/dist/bridge/index.js +3 -3
  17. package/dist/{chunk-F5YPDCN6.js → chunk-33GWB3RB.js} +2 -2
  18. package/dist/{chunk-F5YPDCN6.js.map → chunk-33GWB3RB.js.map} +1 -1
  19. package/dist/{chunk-3IGXVTOS.js → chunk-3KEJ2HJY.js} +3 -3
  20. package/dist/{chunk-3IGXVTOS.js.map → chunk-3KEJ2HJY.js.map} +1 -1
  21. package/dist/{chunk-ST4RC2JF.js → chunk-4GJLRYMB.js} +2 -2
  22. package/dist/{chunk-ST4RC2JF.js.map → chunk-4GJLRYMB.js.map} +1 -1
  23. package/dist/{chunk-EYBGQJNF.js → chunk-5FLEP4X6.js} +98 -28
  24. package/dist/chunk-5FLEP4X6.js.map +1 -0
  25. package/dist/{chunk-57RFYEVM.js → chunk-6OMKIPIE.js} +18 -5
  26. package/dist/chunk-6OMKIPIE.js.map +1 -0
  27. package/dist/{chunk-XL7ZDZ4O.js → chunk-BOH6AG6Q.js} +7 -31
  28. package/dist/chunk-BOH6AG6Q.js.map +1 -0
  29. package/dist/{chunk-RW4I42MW.js → chunk-E5S2WGTS.js} +132 -13
  30. package/dist/chunk-E5S2WGTS.js.map +1 -0
  31. package/dist/{chunk-F5VREBV2.js → chunk-ELPR5XBG.js} +40 -3
  32. package/dist/chunk-ELPR5XBG.js.map +1 -0
  33. package/dist/{chunk-IMA5H7AG.js → chunk-EP7VBFMN.js} +6 -6
  34. package/dist/{chunk-IMA5H7AG.js.map → chunk-EP7VBFMN.js.map} +1 -1
  35. package/dist/{chunk-FLBDLF3I.js → chunk-HGFKNJA5.js} +6 -4
  36. package/dist/chunk-HGFKNJA5.js.map +1 -0
  37. package/dist/{chunk-FP7DNGX6.js → chunk-I7MKEZ6J.js} +3 -3
  38. package/dist/{chunk-FP7DNGX6.js.map → chunk-I7MKEZ6J.js.map} +1 -1
  39. package/dist/{chunk-HA2H3FLE.js → chunk-KPZZI2KG.js} +3 -3
  40. package/dist/{chunk-HA2H3FLE.js.map → chunk-KPZZI2KG.js.map} +1 -1
  41. package/dist/{chunk-DPFSO4T2.js → chunk-MJ77WSJC.js} +4 -4
  42. package/dist/{chunk-DPFSO4T2.js.map → chunk-MJ77WSJC.js.map} +1 -1
  43. package/dist/{chunk-2U4ISGE2.js → chunk-O6B3ZZ5S.js} +4 -4
  44. package/dist/{chunk-2U4ISGE2.js.map → chunk-O6B3ZZ5S.js.map} +1 -1
  45. package/dist/{chunk-CO4DNTIL.js → chunk-OD3ABXUO.js} +2 -2
  46. package/dist/{chunk-CO4DNTIL.js.map → chunk-OD3ABXUO.js.map} +1 -1
  47. package/dist/{chunk-CTCCFKZV.js → chunk-PRKLFKNC.js} +3 -3
  48. package/dist/{chunk-CTCCFKZV.js.map → chunk-PRKLFKNC.js.map} +1 -1
  49. package/dist/{chunk-ZAP2BDHG.js → chunk-QVZA2MDT.js} +2 -2
  50. package/dist/chunk-QVZA2MDT.js.map +1 -0
  51. package/dist/{chunk-DEW2G3QZ.js → chunk-RRCNMURJ.js} +9 -9
  52. package/dist/{chunk-DEW2G3QZ.js.map → chunk-RRCNMURJ.js.map} +1 -1
  53. package/dist/{chunk-K5OKE4G2.js → chunk-S6GKHEMN.js} +6 -6
  54. package/dist/{chunk-K5OKE4G2.js.map → chunk-S6GKHEMN.js.map} +1 -1
  55. package/dist/{chunk-QFO4IYBZ.js → chunk-VT6HDD2L.js} +2 -2
  56. package/dist/{chunk-QFO4IYBZ.js.map → chunk-VT6HDD2L.js.map} +1 -1
  57. package/dist/cli/index.js +314 -293
  58. package/dist/cli/index.js.map +1 -1
  59. package/dist/cli/src/commands/complete-resolvers.d.ts +4 -0
  60. package/dist/cli/src/commands/complete-resolvers.d.ts.map +1 -1
  61. package/dist/cli/src/commands/flow.d.ts +8 -4
  62. package/dist/cli/src/commands/flow.d.ts.map +1 -1
  63. package/dist/cli/src/commands/run.d.ts.map +1 -1
  64. package/dist/cli/src/commands/validate.d.ts.map +1 -1
  65. package/dist/cli/src/flow-discovery.d.ts +39 -13
  66. package/dist/cli/src/flow-discovery.d.ts.map +1 -1
  67. package/dist/cli/src/paths.d.ts +21 -7
  68. package/dist/cli/src/paths.d.ts.map +1 -1
  69. package/dist/connectors/config.js +1 -1
  70. package/dist/connectors/index.js +7 -7
  71. package/dist/core/discovery.js +1 -1
  72. package/dist/core/index.js +1 -1
  73. package/dist/core/src/discovery.d.ts +4 -1
  74. package/dist/core/src/discovery.d.ts.map +1 -1
  75. package/dist/deploy/index.js +1 -1
  76. package/dist/{ensure-sources-YOJ5HOCL.js → ensure-sources-L2276FYP.js} +5 -5
  77. package/dist/{ensure-sources-YOJ5HOCL.js.map → ensure-sources-L2276FYP.js.map} +1 -1
  78. package/dist/factory-assets/connectors/box.js +7 -7
  79. package/dist/factory-assets/connectors/deploy.js +7 -7
  80. package/dist/factory-assets/connectors/devserver.js +7 -7
  81. package/dist/factory-assets/connectors/flow/CONNECTOR.md +20 -7
  82. package/dist/factory-assets/connectors/flow/adapter.d.ts.map +1 -1
  83. package/dist/factory-assets/connectors/flow/adapter.js +7 -7
  84. package/dist/factory-assets/connectors/flow/engine/index.d.ts +1 -0
  85. package/dist/factory-assets/connectors/flow/engine/index.d.ts.map +1 -1
  86. package/dist/factory-assets/connectors/flow/engine/loader.d.ts +63 -9
  87. package/dist/factory-assets/connectors/flow/engine/loader.d.ts.map +1 -1
  88. package/dist/factory-assets/connectors/flow/engine/node-shape.d.ts +56 -0
  89. package/dist/factory-assets/connectors/flow/engine/node-shape.d.ts.map +1 -1
  90. package/dist/factory-assets/connectors/flow/engine.js +3 -3
  91. package/dist/factory-assets/connectors/flow/prompt-fragments.d.ts +4 -0
  92. package/dist/factory-assets/connectors/flow/prompt-fragments.d.ts.map +1 -1
  93. package/dist/factory-assets/connectors/flow/prompt-fragments.js +2 -2
  94. package/dist/factory-assets/connectors/flow/run-flow.d.ts.map +1 -1
  95. package/dist/factory-assets/connectors/flow/run-flow.js +8 -8
  96. package/dist/factory-assets/connectors/flow.js +7 -7
  97. package/dist/factory-assets/connectors/git.js +7 -7
  98. package/dist/factory-assets/connectors/gmail.js +7 -7
  99. package/dist/factory-assets/connectors/googledrive.js +7 -7
  100. package/dist/factory-assets/connectors/local.js +7 -7
  101. package/dist/factory-assets/connectors/mattermost.js +7 -7
  102. package/dist/factory-assets/connectors/memory.js +7 -7
  103. package/dist/factory-assets/connectors/minio.js +7 -7
  104. package/dist/factory-assets/connectors/postgres.js +7 -7
  105. package/dist/factory-assets/connectors/s3.js +7 -7
  106. package/dist/factory-assets/connectors/sharepoint.js +7 -7
  107. package/dist/factory-assets/connectors/sqlite.js +7 -7
  108. package/dist/factory-assets/connectors/static-server.js +7 -7
  109. package/dist/factory-assets/connectors/tunnel.js +7 -7
  110. package/dist/factory-assets/connectors/webdav.js +7 -7
  111. package/dist/factory-assets/connectors/xstate-store.js +7 -7
  112. package/dist/factory-assets/connectors/xstate.js +7 -7
  113. package/dist/{flows-7KUZGZ77.js → flows-7CZKSC64.js} +4 -4
  114. package/dist/{flows-7KUZGZ77.js.map → flows-7CZKSC64.js.map} +1 -1
  115. package/dist/{helpers-YNZ5SWNX.js → helpers-ZWHB5JHQ.js} +5 -5
  116. package/dist/{helpers-YNZ5SWNX.js.map → helpers-ZWHB5JHQ.js.map} +1 -1
  117. package/dist/library/index.js +1 -1
  118. package/dist/library/install.js +1 -1
  119. package/dist/{library-publish-JBZ2TEQI.js → library-publish-CVYFMVGR.js} +9 -9
  120. package/dist/{library-publish-JBZ2TEQI.js.map → library-publish-CVYFMVGR.js.map} +1 -1
  121. package/dist/{open-library-H2LAGVTM.js → open-library-XB65LU3M.js} +8 -8
  122. package/dist/{open-library-H2LAGVTM.js.map → open-library-XB65LU3M.js.map} +1 -1
  123. package/dist/{paths-ZLX4ITAQ.js → paths-B52KTS7N.js} +4 -4
  124. package/dist/{paths-ZLX4ITAQ.js.map → paths-B52KTS7N.js.map} +1 -1
  125. package/dist/{plugin-store-YIMNH2FH.js → plugin-store-EOP3S7OU.js} +3 -3
  126. package/dist/{plugin-store-YIMNH2FH.js.map → plugin-store-EOP3S7OU.js.map} +1 -1
  127. package/dist/{project-WBIYBTN3.js → project-E5LKCE7R.js} +6 -6
  128. package/dist/{project-WBIYBTN3.js.map → project-E5LKCE7R.js.map} +1 -1
  129. package/dist/resolver/index.js +1 -1
  130. package/dist/runner/index.js +10 -10
  131. package/dist/sdk/asset-manager.js +2 -2
  132. package/dist/sdk/bridge.js +3 -3
  133. package/dist/sdk/core.js +1 -1
  134. package/dist/sdk/flow.js +3 -3
  135. package/dist/sdk/index.js +10 -10
  136. package/dist/sdk/resolver.js +1 -1
  137. package/dist/sdk/runner.js +10 -10
  138. package/dist/{setup-I5SLLHRA.js → setup-XI7TCIGF.js} +5 -5
  139. package/dist/{setup-I5SLLHRA.js.map → setup-XI7TCIGF.js.map} +1 -1
  140. package/dist/{skills-HGVH6UTA.js → skills-5PJ6YVM7.js} +3 -3
  141. package/dist/{skills-HGVH6UTA.js.map → skills-5PJ6YVM7.js.map} +1 -1
  142. package/dist/{source-UCMNKSA2.js → source-7BNREKGK.js} +9 -9
  143. package/dist/{source-UCMNKSA2.js.map → source-7BNREKGK.js.map} +1 -1
  144. package/dist/{source-manifest-publish-BZ777MH5.js → source-manifest-publish-JGMHNADH.js} +10 -10
  145. package/dist/{source-manifest-publish-BZ777MH5.js.map → source-manifest-publish-JGMHNADH.js.map} +1 -1
  146. package/dist/tui/index.js +10 -10
  147. package/dist/workspace-plugin/adapters/mcp.js +2 -2
  148. package/dist/workspace-plugin/adapters/omp.js +7 -7
  149. package/dist/workspace-plugin/index.js +1 -1
  150. package/package.json +1 -1
  151. package/dist/chunk-57RFYEVM.js.map +0 -1
  152. package/dist/chunk-EYBGQJNF.js.map +0 -1
  153. package/dist/chunk-F5VREBV2.js.map +0 -1
  154. package/dist/chunk-FLBDLF3I.js.map +0 -1
  155. package/dist/chunk-RW4I42MW.js.map +0 -1
  156. package/dist/chunk-XL7ZDZ4O.js.map +0 -1
  157. package/dist/chunk-ZAP2BDHG.js.map +0 -1
@@ -1,12 +1,12 @@
1
- import { makeHttpPublisherClient, refFor, publishToStore, bareName } from './chunk-CTCCFKZV.js';
2
- import { sourceClonePath, resolveSourceArg } from './chunk-K5OKE4G2.js';
1
+ import { makeHttpPublisherClient, refFor, publishToStore, bareName } from './chunk-PRKLFKNC.js';
2
+ import { sourceClonePath, resolveSourceArg } from './chunk-S6GKHEMN.js';
3
3
  import { isStoreAuthenticated } from './chunk-AM5LFRXJ.js';
4
- import './chunk-DPFSO4T2.js';
5
- import { logErr, S, logInfo, logOk, logWarn } from './chunk-3IGXVTOS.js';
6
- import './chunk-EYBGQJNF.js';
4
+ import './chunk-MJ77WSJC.js';
5
+ import { logErr, S, logInfo, logOk, logWarn } from './chunk-3KEJ2HJY.js';
6
+ import './chunk-5FLEP4X6.js';
7
7
  import './chunk-B4J6TV4G.js';
8
- import './chunk-F5VREBV2.js';
9
- import './chunk-CO4DNTIL.js';
8
+ import './chunk-ELPR5XBG.js';
9
+ import './chunk-OD3ABXUO.js';
10
10
  import './chunk-3HVASHBF.js';
11
11
  import './chunk-NU4E7C5I.js';
12
12
  import './chunk-UKJMQZV6.js';
@@ -17,7 +17,7 @@ import './chunk-CGYEHQOX.js';
17
17
  import './chunk-P43HBWKK.js';
18
18
  import './chunk-F3HNW354.js';
19
19
  import './chunk-K5GBV4SA.js';
20
- import './chunk-ZAP2BDHG.js';
20
+ import './chunk-QVZA2MDT.js';
21
21
  import './chunk-UFY2HFLO.js';
22
22
  import { sourceCacheKey } from './chunk-Q26C5GLO.js';
23
23
  import './chunk-MENCWIHW.js';
@@ -229,5 +229,5 @@ async function runYank(arg, opts, client) {
229
229
  }
230
230
 
231
231
  export { getSidecarRepo, normalizePublishedManifest, pushSidecarManifest, runPublish, runYank, saveSidecarRepo };
232
- //# sourceMappingURL=source-manifest-publish-BZ777MH5.js.map
233
- //# sourceMappingURL=source-manifest-publish-BZ777MH5.js.map
232
+ //# sourceMappingURL=source-manifest-publish-JGMHNADH.js.map
233
+ //# sourceMappingURL=source-manifest-publish-JGMHNADH.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../cli/src/commands/source-manifest-publish.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAM,yBAAA,GAA4B,sBAAA;AAW3B,SAAS,0BAAA,CACd,UACA,SAAA,EACmB;AACnB,EAAA,MAAM,UAAU,QAAA,CAAS,MAAA,IAAU,EAAC,EAAG,GAAA,CAAI,CAAC,CAAA,KAAM;AAChD,IAAA,MAAM,EAAE,SAAA,EAAW,KAAA,EAAO,GAAG,MAAK,GAAI,CAAA;AACtC,IAAA,OAAO,IAAA;AAAA,EACT,CAAC,CAAA;AACD,EAAA,OAAO,EAAE,GAAG,QAAA,EAAU,SAAA,EAAW,WAAW,MAAA,EAAO;AACrD;AAWA,SAAS,YAAA,GAAuB;AAC9B,EAAA,MAAM,OAAO,OAAA,CAAQ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B,IAAA,IAAI;AACF,MAAA,MAAM,GAAA,CAAI,cAAA,CAAe,CAAA,CAAE,EAAE,CAAA;AAC7B,MAAA,MAAA,CAAO,KAAK,CAAA,EAAG,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAA,CAAE,IAAI,CAAA,CAAE,CAAA;AAAA,IACnC,SAAS,GAAA,EAAK;AACZ,MAAA,OAAA;AAAA,QACE,CAAA,eAAA,EAAkB,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAA,CAAE,IAAI,CAAA,EAAA,EAAK,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,OACzF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,KAAA,CAAM,CAAA,OAAA,EAAU,MAAA,CAAO,MAAM,CAAA,UAAA,CAAY,CAAA;AACzC,EAAA,KAAA,MAAW,CAAA,IAAK,MAAA,EAAQ,OAAA,CAAQ,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAA;AAC1C","file":"source-manifest-publish-BZ777MH5.js","sourcesContent":["/**\n * `skaile source manifest publish` / `yank` — the curator-publish flow. Takes a\n * locally-curated sidecar manifest (over a foreign public GitHub repo) and:\n *\n * 1. Pushes the curated `skaile.manifest.yaml` to the curator's OWN public\n * \"sidecar\" repo (bytes stay in the foreign source; the sidecar holds only\n * the manifest pointing at it).\n * 2. Registers the foreign source + the sidecar (url + pinned commit) with the\n * store, syncs it, and publishes each curated asset.\n *\n * `yank` is the inverse: unpublish each currently-published asset of the source.\n *\n * The store REST surface is reached through the injectable {@link PublisherClient}\n * (default HTTP client); git side-effects go through an injectable `spawn`. Both\n * seams keep the pure helpers + orchestration unit/integration-testable without a\n * live store or a real remote.\n *\n * @docLink cli/commands/source#manifest-publish\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport {\n decodeSkaileManifest,\n encodeSkaileManifest,\n type SkPublishManifest,\n sourceCacheKey,\n} from \"@skaile/workspaces/core\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport { makeHttpPublisherClient, type PublisherClient } from \"../store-publisher.ts\";\nimport { isStoreAuthenticated } from \"../store-client.ts\";\nimport { bareName, publishToStore, refFor } from \"./publish-core.ts\";\nimport { sourceClonePath } from \"./source.ts\";\nimport { resolveSourceArg } from \"./source-manifest.ts\";\n\n/** The fixed filename a sidecar repo carries at its root. */\nconst SIDECAR_MANIFEST_FILENAME = \"skaile.manifest.yaml\";\n\n/** Injectable spawn contract — the subset of `spawnSync` these helpers use. */\ntype SpawnLike = typeof spawnSync;\n\n/**\n * Return a copy of `manifest` normalized for publication under `namespace`:\n * the top-level `publisher` is set to `namespace` and every per-asset\n * `publisher` override is removed so all assets inherit the top-level one.\n * Pure — the input is not mutated.\n */\nexport function normalizePublishedManifest(\n manifest: SkPublishManifest,\n namespace: string,\n): SkPublishManifest {\n const assets = (manifest.assets ?? []).map((a) => {\n const { publisher: _drop, ...rest } = a;\n return rest;\n });\n return { ...manifest, publisher: namespace, assets };\n}\n\n// ── Sidecar-repo association (~/.skaile/settings.json) ────────────────────────\n\n/**\n * Path to the user settings file — the same `~/.skaile/settings.json` the store\n * client reads tokens from. Resolves the `.skaile` root exactly as `getStoreRoot`\n * does (`SKAILE_HOME` when set — it IS the `.skaile` dir — else `~/.skaile`), so\n * the sidecar association lives beside the store manifests under one convention\n * and tests isolate through the same `SKAILE_HOME` seam.\n */\nfunction settingsFile(): string {\n const root = process.env.SKAILE_HOME ?? join(homedir(), \".skaile\");\n return join(root, \"settings.json\");\n}\n\nfunction readSettings(): Record<string, any> {\n const file = settingsFile();\n if (!existsSync(file)) return {};\n try {\n return JSON.parse(readFileSync(file, \"utf-8\"));\n } catch {\n return {};\n }\n}\n\n/**\n * The sidecar repo URL previously associated with a source `slug`, if any.\n * Reads `settings.sidecarRepos?.[slug]?.repo`.\n */\nexport function getSidecarRepo(slug: string): string | undefined {\n const settings = readSettings();\n return settings.sidecarRepos?.[slug]?.repo;\n}\n\n/**\n * Persist the sidecar repo URL for a source `slug`, preserving every other\n * settings key. Stored as an object (`{ repo }`) so a `path` (or other fields)\n * can be added later without a schema migration.\n */\nexport function saveSidecarRepo(slug: string, repo: string): void {\n const file = settingsFile();\n mkdirSync(dirname(file), { recursive: true });\n const settings = readSettings();\n const sidecarRepos = { ...(settings.sidecarRepos ?? {}) };\n sidecarRepos[slug] = { ...(sidecarRepos[slug] ?? {}), repo };\n settings.sidecarRepos = sidecarRepos;\n writeFileSync(file, JSON.stringify(settings, null, 2), \"utf-8\");\n}\n\n// ── Sidecar push ──────────────────────────────────────────────────────────────\n\n/**\n * Run a git command in `cwd` via the injected spawn, throwing with the captured\n * stderr on failure. Returns trimmed stdout.\n */\nfunction git(spawn: SpawnLike, cwd: string, args: string[]): string {\n const res = spawn(\"git\", [\"-C\", cwd, ...args], { encoding: \"utf-8\" });\n if (res.status !== 0) {\n const stderr = (res.stderr ?? \"\").toString().trim();\n throw new Error(`git ${args.join(\" \")} failed: ${stderr || `exit ${res.status}`}`);\n }\n return (res.stdout ?? \"\").toString().trim();\n}\n\n/**\n * Clone the curator's sidecar repo, write the curated manifest at its root, and\n * commit + push. Returns the pushed commit sha (used to pin the store source).\n *\n * Idempotent re-publish: when the manifest is unchanged `git commit` fails with\n * \"nothing to commit\" — we swallow that and return the current HEAD so a no-op\n * re-run still yields a valid pin. Any push/auth failure surfaces as a thrown\n * Error carrying git's stderr.\n */\nexport function pushSidecarManifest(opts: {\n sidecarRepoUrl: string;\n manifestText: string;\n spawn?: SpawnLike;\n}): { commitSha: string } {\n const spawn = opts.spawn ?? spawnSync;\n // Dedicated dir next to the source clone cache; wipe any stale clone first so\n // a re-publish always starts from a clean shallow checkout of the remote.\n const cloneDir = `${sourceClonePath(sourceCacheKey(opts.sidecarRepoUrl))}-sidecar-push`;\n rmSync(cloneDir, { recursive: true, force: true });\n mkdirSync(dirname(cloneDir), { recursive: true });\n\n // The clone is scratch — always remove it afterwards (success or failure) so a\n // failed push never leaves a stale checkout in the cache dir.\n try {\n const cloneRes = spawn(\"git\", [\"clone\", \"--depth\", \"1\", opts.sidecarRepoUrl, cloneDir], {\n encoding: \"utf-8\",\n });\n if (cloneRes.status !== 0) {\n const stderr = (cloneRes.stderr ?? \"\").toString().trim();\n throw new Error(\n `git clone ${opts.sidecarRepoUrl} failed: ${stderr || `exit ${cloneRes.status}`}`,\n );\n }\n\n writeFileSync(join(cloneDir, SIDECAR_MANIFEST_FILENAME), opts.manifestText, \"utf-8\");\n git(spawn, cloneDir, [\"add\", SIDECAR_MANIFEST_FILENAME]);\n\n // Fixed bot identity via -c so the commit succeeds regardless of the curator's\n // git config (the sidecar push is a machine action, not authored work).\n const commitRes = spawn(\n \"git\",\n [\n \"-C\",\n cloneDir,\n \"-c\",\n \"user.email=publish@skaile.store\",\n \"-c\",\n \"user.name=skaile\",\n \"commit\",\n \"-m\",\n \"chore(sidecar): publish curated manifest\",\n ],\n { encoding: \"utf-8\" },\n );\n if (commitRes.status !== 0) {\n const out = `${commitRes.stdout ?? \"\"}${commitRes.stderr ?? \"\"}`;\n // Nothing changed → idempotent re-publish; keep the existing HEAD.\n if (!/nothing to commit/i.test(out)) {\n throw new Error(`git commit failed: ${out.trim() || `exit ${commitRes.status}`}`);\n }\n } else {\n // `push origin HEAD` (not a bare `push`) so a fresh sidecar repo with an\n // unborn/renamed default branch still gets its branch created on the remote.\n git(spawn, cloneDir, [\"push\", \"origin\", \"HEAD\"]);\n }\n\n return { commitSha: git(spawn, cloneDir, [\"rev-parse\", \"HEAD\"]) };\n } finally {\n rmSync(cloneDir, { recursive: true, force: true });\n }\n}\n\n// ── Orchestration ───────────────────────────────────────────────────────────\n\n/**\n * `source manifest publish <src>` — publish a curated sidecar manifest to the\n * store. See the module header for the full flow. Store calls go through\n * `client` (default HTTP); git side-effects through `spawn` (default\n * `spawnSync`). The auth gate is enforced only for the default HTTP client so\n * injected fakes bypass it.\n */\nexport async function runPublish(\n arg: string,\n opts: {\n projectDir: string;\n as?: string;\n sidecarRepo?: string;\n ref?: string;\n dryRun?: boolean;\n },\n client?: PublisherClient,\n spawn: SpawnLike = spawnSync,\n): Promise<void> {\n const injected = client !== undefined;\n const pub = client ?? makeHttpPublisherClient();\n\n const { url, slug, manifestFile } = resolveSourceArg(arg, opts.projectDir);\n\n if (!existsSync(manifestFile)) {\n logErr(\n `No curated manifest for \"${slug}\" at ${S.dim(manifestFile)} — ` +\n \"run `skaile source manifest init` first.\",\n );\n process.exit(1);\n }\n\n const { manifest, diagnostics } = decodeSkaileManifest(readFileSync(manifestFile, \"utf-8\"));\n if (diagnostics.some((d) => d.severity === \"error\")) {\n for (const d of diagnostics.filter((x) => x.severity === \"error\")) {\n logErr(`${d.code}: ${d.message}`);\n }\n logErr(\n \"The curated manifest has errors — fix them with `skaile source manifest edit` / \" +\n \"`verify` before publishing.\",\n );\n process.exit(1);\n }\n\n // A real publish makes store calls (+ `me()` when `--as` is omitted), so it\n // needs a token. `--dry-run` is an offline preview: never gate it on auth.\n const authed = injected || isStoreAuthenticated();\n if (!opts.dryRun && !authed) {\n logErr(\"Not signed in — run `skaile store login` first.\");\n process.exit(1);\n }\n\n // Namespace: `--as` wins; else the caller's verified identity. Prefer the\n // GitHub handle (`githubLogin`) over the store login (`username`) — for a user\n // whose login differs from their GitHub handle the login namespace may be\n // reserved (matches the CLI's `resolveLibraryPublisher` precedence). In an\n // unauthenticated dry-run we cannot call `me()`, so show a placeholder.\n let namespace: string;\n if (opts.as) namespace = opts.as;\n else if (authed) {\n const me = await pub.me();\n // `||` not `??`: an empty-string githubLogin (partially-connected account) is\n // not a usable namespace — fall back to the login rather than publish under \"\".\n namespace = me.githubLogin || me.username;\n } else namespace = \"<your store username>\";\n\n const normalized = normalizePublishedManifest(manifest, namespace);\n const publishedText = encodeSkaileManifest(normalized);\n\n const wouldBeRefs = (normalized.assets ?? []).map((a) =>\n refFor(a.kind, namespace, a.name, a.version ?? normalized.version),\n );\n\n if (opts.dryRun) {\n const sidecar = opts.sidecarRepo ?? getSidecarRepo(slug) ?? \"<none — pass --sidecar-repo>\";\n logInfo(`Publish plan for ${S.bold(slug)}:`);\n logInfo(` namespace: ${namespace}`);\n logInfo(` sidecar repo: ${sidecar}`);\n logInfo(` source ref: ${opts.ref ?? \"main\"}`);\n logInfo(` would publish ${wouldBeRefs.length} asset(s):`);\n for (const r of wouldBeRefs) logInfo(` ${r}`);\n return;\n }\n\n const sidecarRepoUrl = opts.sidecarRepo ?? getSidecarRepo(slug);\n if (!sidecarRepoUrl) {\n logErr(\n \"No sidecar repo associated with this source. Pass \" +\n `${S.cmd(\"--sidecar-repo https://github.com/<you>/<repo>\")} — it must be a ` +\n \"PUBLIC GitHub repo you own; the curated manifest is committed there and the \" +\n \"store pins to that commit.\",\n );\n process.exit(1);\n }\n if (opts.sidecarRepo) saveSidecarRepo(slug, sidecarRepoUrl);\n\n const { commitSha } = pushSidecarManifest({ sidecarRepoUrl, manifestText: publishedText, spawn });\n logOk(`Pushed curated manifest to ${S.dim(sidecarRepoUrl)} @ ${commitSha.slice(0, 10)}.`);\n\n // The FOREIGN repo's ref to ingest (branch/sha). Defaults to `main`.\n const sourceRef = opts.ref ?? \"main\";\n\n const { published } = await publishToStore({\n sourceUrl: url,\n ref: sourceRef,\n sidecar: { url: sidecarRepoUrl, ref: commitSha },\n manifest: normalized,\n client: pub,\n });\n\n if (published.length > 0) {\n logInfo(`Consumers can now install them with \\`skaile add ${published[0]}\\`.`);\n }\n}\n\n/**\n * `source manifest yank <src>` — unpublish the source's published assets (all,\n * or the single asset matching `opts.asset`'s name). Auth-gated like publish.\n */\nexport async function runYank(\n arg: string,\n opts: { projectDir: string; asset?: string },\n client?: PublisherClient,\n): Promise<void> {\n const injected = client !== undefined;\n const pub = client ?? makeHttpPublisherClient();\n\n const { url, slug } = resolveSourceArg(arg, opts.projectDir);\n\n if (!injected && !isStoreAuthenticated()) {\n logErr(\"Not signed in — run `skaile store login` first.\");\n process.exit(1);\n }\n\n const rows = await pub.sourcesList();\n const source = rows.find((r) => r.url === url);\n if (!source) {\n logErr(`Source \"${slug}\" is not registered in the store — nothing to yank.`);\n process.exit(1);\n }\n\n // Optionally narrow to a single asset by name (accept a bare name or a ref).\n const targetName = opts.asset ? bareName(opts.asset) : undefined;\n const candidates = (await pub.sourceCandidates(source.id)).filter(\n (c) => c.published && (!targetName || c.name === targetName),\n );\n if (candidates.length === 0) {\n logWarn(\"No published assets matched — nothing to yank.\");\n return;\n }\n\n const yanked: string[] = [];\n for (const c of candidates) {\n try {\n await pub.assetUnpublish(c.id);\n yanked.push(`${c.kind}:${c.name}`);\n } catch (err) {\n logWarn(\n `Failed to yank ${c.kind}:${c.name}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n logOk(`Yanked ${yanked.length} asset(s):`);\n for (const r of yanked) logInfo(` ${r}`);\n}\n"]}
1
+ {"version":3,"sources":["../cli/src/commands/source-manifest-publish.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,IAAM,yBAAA,GAA4B,sBAAA;AAW3B,SAAS,0BAAA,CACd,UACA,SAAA,EACmB;AACnB,EAAA,MAAM,UAAU,QAAA,CAAS,MAAA,IAAU,EAAC,EAAG,GAAA,CAAI,CAAC,CAAA,KAAM;AAChD,IAAA,MAAM,EAAE,SAAA,EAAW,KAAA,EAAO,GAAG,MAAK,GAAI,CAAA;AACtC,IAAA,OAAO,IAAA;AAAA,EACT,CAAC,CAAA;AACD,EAAA,OAAO,EAAE,GAAG,QAAA,EAAU,SAAA,EAAW,WAAW,MAAA,EAAO;AACrD;AAWA,SAAS,YAAA,GAAuB;AAC9B,EAAA,MAAM,OAAO,OAAA,CAAQ,GAAA,CAAI,eAAe,IAAA,CAAK,OAAA,IAAW,SAAS,CAAA;AACjE,EAAA,OAAO,I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AAA;AAC7B,MAAA,MAAA,CAAO,KAAK,CAAA,EAAG,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAA,CAAE,IAAI,CAAA,CAAE,CAAA;AAAA,IACnC,SAAS,GAAA,EAAK;AACZ,MAAA,OAAA;AAAA,QACE,CAAA,eAAA,EAAkB,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAA,CAAE,IAAI,CAAA,EAAA,EAAK,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,OACzF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,KAAA,CAAM,CAAA,OAAA,EAAU,MAAA,CAAO,MAAM,CAAA,UAAA,CAAY,CAAA;AACzC,EAAA,KAAA,MAAW,CAAA,IAAK,MAAA,EAAQ,OAAA,CAAQ,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAA;AAC1C","file":"source-manifest-publish-JGMHNADH.js","sourcesContent":["/**\n * `skaile source manifest publish` / `yank` — the curator-publish flow. Takes a\n * locally-curated sidecar manifest (over a foreign public GitHub repo) and:\n *\n * 1. Pushes the curated `skaile.manifest.yaml` to the curator's OWN public\n * \"sidecar\" repo (bytes stay in the foreign source; the sidecar holds only\n * the manifest pointing at it).\n * 2. Registers the foreign source + the sidecar (url + pinned commit) with the\n * store, syncs it, and publishes each curated asset.\n *\n * `yank` is the inverse: unpublish each currently-published asset of the source.\n *\n * The store REST surface is reached through the injectable {@link PublisherClient}\n * (default HTTP client); git side-effects go through an injectable `spawn`. Both\n * seams keep the pure helpers + orchestration unit/integration-testable without a\n * live store or a real remote.\n *\n * @docLink cli/commands/source#manifest-publish\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport {\n decodeSkaileManifest,\n encodeSkaileManifest,\n type SkPublishManifest,\n sourceCacheKey,\n} from \"@skaile/workspaces/core\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport { makeHttpPublisherClient, type PublisherClient } from \"../store-publisher.ts\";\nimport { isStoreAuthenticated } from \"../store-client.ts\";\nimport { bareName, publishToStore, refFor } from \"./publish-core.ts\";\nimport { sourceClonePath } from \"./source.ts\";\nimport { resolveSourceArg } from \"./source-manifest.ts\";\n\n/** The fixed filename a sidecar repo carries at its root. */\nconst SIDECAR_MANIFEST_FILENAME = \"skaile.manifest.yaml\";\n\n/** Injectable spawn contract — the subset of `spawnSync` these helpers use. */\ntype SpawnLike = typeof spawnSync;\n\n/**\n * Return a copy of `manifest` normalized for publication under `namespace`:\n * the top-level `publisher` is set to `namespace` and every per-asset\n * `publisher` override is removed so all assets inherit the top-level one.\n * Pure — the input is not mutated.\n */\nexport function normalizePublishedManifest(\n manifest: SkPublishManifest,\n namespace: string,\n): SkPublishManifest {\n const assets = (manifest.assets ?? []).map((a) => {\n const { publisher: _drop, ...rest } = a;\n return rest;\n });\n return { ...manifest, publisher: namespace, assets };\n}\n\n// ── Sidecar-repo association (~/.skaile/settings.json) ────────────────────────\n\n/**\n * Path to the user settings file — the same `~/.skaile/settings.json` the store\n * client reads tokens from. Resolves the `.skaile` root exactly as `getStoreRoot`\n * does (`SKAILE_HOME` when set — it IS the `.skaile` dir — else `~/.skaile`), so\n * the sidecar association lives beside the store manifests under one convention\n * and tests isolate through the same `SKAILE_HOME` seam.\n */\nfunction settingsFile(): string {\n const root = process.env.SKAILE_HOME ?? join(homedir(), \".skaile\");\n return join(root, \"settings.json\");\n}\n\nfunction readSettings(): Record<string, any> {\n const file = settingsFile();\n if (!existsSync(file)) return {};\n try {\n return JSON.parse(readFileSync(file, \"utf-8\"));\n } catch {\n return {};\n }\n}\n\n/**\n * The sidecar repo URL previously associated with a source `slug`, if any.\n * Reads `settings.sidecarRepos?.[slug]?.repo`.\n */\nexport function getSidecarRepo(slug: string): string | undefined {\n const settings = readSettings();\n return settings.sidecarRepos?.[slug]?.repo;\n}\n\n/**\n * Persist the sidecar repo URL for a source `slug`, preserving every other\n * settings key. Stored as an object (`{ repo }`) so a `path` (or other fields)\n * can be added later without a schema migration.\n */\nexport function saveSidecarRepo(slug: string, repo: string): void {\n const file = settingsFile();\n mkdirSync(dirname(file), { recursive: true });\n const settings = readSettings();\n const sidecarRepos = { ...(settings.sidecarRepos ?? {}) };\n sidecarRepos[slug] = { ...(sidecarRepos[slug] ?? {}), repo };\n settings.sidecarRepos = sidecarRepos;\n writeFileSync(file, JSON.stringify(settings, null, 2), \"utf-8\");\n}\n\n// ── Sidecar push ──────────────────────────────────────────────────────────────\n\n/**\n * Run a git command in `cwd` via the injected spawn, throwing with the captured\n * stderr on failure. Returns trimmed stdout.\n */\nfunction git(spawn: SpawnLike, cwd: string, args: string[]): string {\n const res = spawn(\"git\", [\"-C\", cwd, ...args], { encoding: \"utf-8\" });\n if (res.status !== 0) {\n const stderr = (res.stderr ?? \"\").toString().trim();\n throw new Error(`git ${args.join(\" \")} failed: ${stderr || `exit ${res.status}`}`);\n }\n return (res.stdout ?? \"\").toString().trim();\n}\n\n/**\n * Clone the curator's sidecar repo, write the curated manifest at its root, and\n * commit + push. Returns the pushed commit sha (used to pin the store source).\n *\n * Idempotent re-publish: when the manifest is unchanged `git commit` fails with\n * \"nothing to commit\" — we swallow that and return the current HEAD so a no-op\n * re-run still yields a valid pin. Any push/auth failure surfaces as a thrown\n * Error carrying git's stderr.\n */\nexport function pushSidecarManifest(opts: {\n sidecarRepoUrl: string;\n manifestText: string;\n spawn?: SpawnLike;\n}): { commitSha: string } {\n const spawn = opts.spawn ?? spawnSync;\n // Dedicated dir next to the source clone cache; wipe any stale clone first so\n // a re-publish always starts from a clean shallow checkout of the remote.\n const cloneDir = `${sourceClonePath(sourceCacheKey(opts.sidecarRepoUrl))}-sidecar-push`;\n rmSync(cloneDir, { recursive: true, force: true });\n mkdirSync(dirname(cloneDir), { recursive: true });\n\n // The clone is scratch — always remove it afterwards (success or failure) so a\n // failed push never leaves a stale checkout in the cache dir.\n try {\n const cloneRes = spawn(\"git\", [\"clone\", \"--depth\", \"1\", opts.sidecarRepoUrl, cloneDir], {\n encoding: \"utf-8\",\n });\n if (cloneRes.status !== 0) {\n const stderr = (cloneRes.stderr ?? \"\").toString().trim();\n throw new Error(\n `git clone ${opts.sidecarRepoUrl} failed: ${stderr || `exit ${cloneRes.status}`}`,\n );\n }\n\n writeFileSync(join(cloneDir, SIDECAR_MANIFEST_FILENAME), opts.manifestText, \"utf-8\");\n git(spawn, cloneDir, [\"add\", SIDECAR_MANIFEST_FILENAME]);\n\n // Fixed bot identity via -c so the commit succeeds regardless of the curator's\n // git config (the sidecar push is a machine action, not authored work).\n const commitRes = spawn(\n \"git\",\n [\n \"-C\",\n cloneDir,\n \"-c\",\n \"user.email=publish@skaile.store\",\n \"-c\",\n \"user.name=skaile\",\n \"commit\",\n \"-m\",\n \"chore(sidecar): publish curated manifest\",\n ],\n { encoding: \"utf-8\" },\n );\n if (commitRes.status !== 0) {\n const out = `${commitRes.stdout ?? \"\"}${commitRes.stderr ?? \"\"}`;\n // Nothing changed → idempotent re-publish; keep the existing HEAD.\n if (!/nothing to commit/i.test(out)) {\n throw new Error(`git commit failed: ${out.trim() || `exit ${commitRes.status}`}`);\n }\n } else {\n // `push origin HEAD` (not a bare `push`) so a fresh sidecar repo with an\n // unborn/renamed default branch still gets its branch created on the remote.\n git(spawn, cloneDir, [\"push\", \"origin\", \"HEAD\"]);\n }\n\n return { commitSha: git(spawn, cloneDir, [\"rev-parse\", \"HEAD\"]) };\n } finally {\n rmSync(cloneDir, { recursive: true, force: true });\n }\n}\n\n// ── Orchestration ───────────────────────────────────────────────────────────\n\n/**\n * `source manifest publish <src>` — publish a curated sidecar manifest to the\n * store. See the module header for the full flow. Store calls go through\n * `client` (default HTTP); git side-effects through `spawn` (default\n * `spawnSync`). The auth gate is enforced only for the default HTTP client so\n * injected fakes bypass it.\n */\nexport async function runPublish(\n arg: string,\n opts: {\n projectDir: string;\n as?: string;\n sidecarRepo?: string;\n ref?: string;\n dryRun?: boolean;\n },\n client?: PublisherClient,\n spawn: SpawnLike = spawnSync,\n): Promise<void> {\n const injected = client !== undefined;\n const pub = client ?? makeHttpPublisherClient();\n\n const { url, slug, manifestFile } = resolveSourceArg(arg, opts.projectDir);\n\n if (!existsSync(manifestFile)) {\n logErr(\n `No curated manifest for \"${slug}\" at ${S.dim(manifestFile)} — ` +\n \"run `skaile source manifest init` first.\",\n );\n process.exit(1);\n }\n\n const { manifest, diagnostics } = decodeSkaileManifest(readFileSync(manifestFile, \"utf-8\"));\n if (diagnostics.some((d) => d.severity === \"error\")) {\n for (const d of diagnostics.filter((x) => x.severity === \"error\")) {\n logErr(`${d.code}: ${d.message}`);\n }\n logErr(\n \"The curated manifest has errors — fix them with `skaile source manifest edit` / \" +\n \"`verify` before publishing.\",\n );\n process.exit(1);\n }\n\n // A real publish makes store calls (+ `me()` when `--as` is omitted), so it\n // needs a token. `--dry-run` is an offline preview: never gate it on auth.\n const authed = injected || isStoreAuthenticated();\n if (!opts.dryRun && !authed) {\n logErr(\"Not signed in — run `skaile store login` first.\");\n process.exit(1);\n }\n\n // Namespace: `--as` wins; else the caller's verified identity. Prefer the\n // GitHub handle (`githubLogin`) over the store login (`username`) — for a user\n // whose login differs from their GitHub handle the login namespace may be\n // reserved (matches the CLI's `resolveLibraryPublisher` precedence). In an\n // unauthenticated dry-run we cannot call `me()`, so show a placeholder.\n let namespace: string;\n if (opts.as) namespace = opts.as;\n else if (authed) {\n const me = await pub.me();\n // `||` not `??`: an empty-string githubLogin (partially-connected account) is\n // not a usable namespace — fall back to the login rather than publish under \"\".\n namespace = me.githubLogin || me.username;\n } else namespace = \"<your store username>\";\n\n const normalized = normalizePublishedManifest(manifest, namespace);\n const publishedText = encodeSkaileManifest(normalized);\n\n const wouldBeRefs = (normalized.assets ?? []).map((a) =>\n refFor(a.kind, namespace, a.name, a.version ?? normalized.version),\n );\n\n if (opts.dryRun) {\n const sidecar = opts.sidecarRepo ?? getSidecarRepo(slug) ?? \"<none — pass --sidecar-repo>\";\n logInfo(`Publish plan for ${S.bold(slug)}:`);\n logInfo(` namespace: ${namespace}`);\n logInfo(` sidecar repo: ${sidecar}`);\n logInfo(` source ref: ${opts.ref ?? \"main\"}`);\n logInfo(` would publish ${wouldBeRefs.length} asset(s):`);\n for (const r of wouldBeRefs) logInfo(` ${r}`);\n return;\n }\n\n const sidecarRepoUrl = opts.sidecarRepo ?? getSidecarRepo(slug);\n if (!sidecarRepoUrl) {\n logErr(\n \"No sidecar repo associated with this source. Pass \" +\n `${S.cmd(\"--sidecar-repo https://github.com/<you>/<repo>\")} — it must be a ` +\n \"PUBLIC GitHub repo you own; the curated manifest is committed there and the \" +\n \"store pins to that commit.\",\n );\n process.exit(1);\n }\n if (opts.sidecarRepo) saveSidecarRepo(slug, sidecarRepoUrl);\n\n const { commitSha } = pushSidecarManifest({ sidecarRepoUrl, manifestText: publishedText, spawn });\n logOk(`Pushed curated manifest to ${S.dim(sidecarRepoUrl)} @ ${commitSha.slice(0, 10)}.`);\n\n // The FOREIGN repo's ref to ingest (branch/sha). Defaults to `main`.\n const sourceRef = opts.ref ?? \"main\";\n\n const { published } = await publishToStore({\n sourceUrl: url,\n ref: sourceRef,\n sidecar: { url: sidecarRepoUrl, ref: commitSha },\n manifest: normalized,\n client: pub,\n });\n\n if (published.length > 0) {\n logInfo(`Consumers can now install them with \\`skaile add ${published[0]}\\`.`);\n }\n}\n\n/**\n * `source manifest yank <src>` — unpublish the source's published assets (all,\n * or the single asset matching `opts.asset`'s name). Auth-gated like publish.\n */\nexport async function runYank(\n arg: string,\n opts: { projectDir: string; asset?: string },\n client?: PublisherClient,\n): Promise<void> {\n const injected = client !== undefined;\n const pub = client ?? makeHttpPublisherClient();\n\n const { url, slug } = resolveSourceArg(arg, opts.projectDir);\n\n if (!injected && !isStoreAuthenticated()) {\n logErr(\"Not signed in — run `skaile store login` first.\");\n process.exit(1);\n }\n\n const rows = await pub.sourcesList();\n const source = rows.find((r) => r.url === url);\n if (!source) {\n logErr(`Source \"${slug}\" is not registered in the store — nothing to yank.`);\n process.exit(1);\n }\n\n // Optionally narrow to a single asset by name (accept a bare name or a ref).\n const targetName = opts.asset ? bareName(opts.asset) : undefined;\n const candidates = (await pub.sourceCandidates(source.id)).filter(\n (c) => c.published && (!targetName || c.name === targetName),\n );\n if (candidates.length === 0) {\n logWarn(\"No published assets matched — nothing to yank.\");\n return;\n }\n\n const yanked: string[] = [];\n for (const c of candidates) {\n try {\n await pub.assetUnpublish(c.id);\n yanked.push(`${c.kind}:${c.name}`);\n } catch (err) {\n logWarn(\n `Failed to yank ${c.kind}:${c.name}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n logOk(`Yanked ${yanked.length} asset(s):`);\n for (const r of yanked) logInfo(` ${r}`);\n}\n"]}
package/dist/tui/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createAgentSession } from '../chunk-DEW2G3QZ.js';
2
- import '../chunk-F5YPDCN6.js';
1
+ import { createAgentSession } from '../chunk-RRCNMURJ.js';
2
+ import '../chunk-33GWB3RB.js';
3
3
  import '../chunk-X5YPJV4N.js';
4
4
  import '../chunk-W3UDISS2.js';
5
5
  import '../chunk-O7SG5PC2.js';
@@ -7,30 +7,30 @@ import '../chunk-7QBNJTTQ.js';
7
7
  import '../chunk-GTS2FODO.js';
8
8
  import '../chunk-WQ7DE5UC.js';
9
9
  import '../chunk-32NA4TVC.js';
10
- import '../chunk-XL7ZDZ4O.js';
10
+ import '../chunk-BOH6AG6Q.js';
11
11
  import '../chunk-4R6DROGN.js';
12
12
  import '../chunk-CZZRDYT4.js';
13
13
  import '../chunk-BEAIJRVF.js';
14
14
  import '../chunk-HNBWU5RA.js';
15
- import '../chunk-RW4I42MW.js';
15
+ import '../chunk-E5S2WGTS.js';
16
16
  import { loadConnectorDeclarations } from '../chunk-ZNIHTT22.js';
17
- import '../chunk-HA2H3FLE.js';
17
+ import '../chunk-KPZZI2KG.js';
18
18
  import '../chunk-46LE3GNY.js';
19
19
  import '../chunk-RRVQAE5D.js';
20
20
  import '../chunk-V34ZEXSE.js';
21
21
  import '../chunk-GAH4YRCI.js';
22
- import '../chunk-QFO4IYBZ.js';
22
+ import '../chunk-VT6HDD2L.js';
23
23
  import '../chunk-6E6PKKAD.js';
24
24
  import '../chunk-IFGTRL2I.js';
25
- import '../chunk-EYBGQJNF.js';
25
+ import '../chunk-5FLEP4X6.js';
26
26
  import '../chunk-B4J6TV4G.js';
27
- import '../chunk-FLBDLF3I.js';
28
- import '../chunk-F5VREBV2.js';
27
+ import '../chunk-HGFKNJA5.js';
28
+ import '../chunk-ELPR5XBG.js';
29
29
  import '../chunk-D4VHBAJC.js';
30
30
  import { resolveSettings } from '../chunk-P43HBWKK.js';
31
31
  import '../chunk-F3HNW354.js';
32
32
  import '../chunk-K5GBV4SA.js';
33
- import '../chunk-ZAP2BDHG.js';
33
+ import '../chunk-QVZA2MDT.js';
34
34
  import '../chunk-UFY2HFLO.js';
35
35
  import { resolveAgentDir } from '../chunk-Q26C5GLO.js';
36
36
  import '../chunk-MENCWIHW.js';
@@ -1,5 +1,5 @@
1
1
  import { mountList, mountSync, mountStatus, mountRead, connectorList, connectorRead, connectorWrite, connectorSearch, connectorExec, connectorLoadSkill, connectorDescribe } from '../../chunk-26L2B6P6.js';
2
- import { flowList, flowShow, flowListSessions, flowGetSession, flowFindFlowForSession } from '../../chunk-ST4RC2JF.js';
2
+ import { flowList, flowShow, flowListSessions, flowGetSession, flowFindFlowForSession } from '../../chunk-4GJLRYMB.js';
3
3
  import { sessionList, sessionGet } from '../../chunk-R6O6YWU7.js';
4
4
  import { skillList, skillListDomains, skillShow, skillSearch, skillCheckRequirements, skillGetPreamble } from '../../chunk-MWFYXUFK.js';
5
5
  import '../../chunk-BK3WL3QK.js';
@@ -10,7 +10,7 @@ import '../../chunk-BEAIJRVF.js';
10
10
  import '../../chunk-P43HBWKK.js';
11
11
  import '../../chunk-F3HNW354.js';
12
12
  import '../../chunk-K5GBV4SA.js';
13
- import '../../chunk-ZAP2BDHG.js';
13
+ import '../../chunk-QVZA2MDT.js';
14
14
  import '../../chunk-UFY2HFLO.js';
15
15
  import '../../chunk-Q26C5GLO.js';
16
16
  import '../../chunk-MENCWIHW.js';
@@ -74,7 +74,7 @@ function buildOmpToolSet(plugin) {
74
74
  description: "List all available flow definitions from ai-assets.",
75
75
  parameters: {},
76
76
  handler: async () => {
77
- const { flowList } = await import('../../flows-7KUZGZ77.js');
77
+ const { flowList } = await import('../../flows-7CZKSC64.js');
78
78
  return (await flowList(plugin.projectDir)).content[0].text;
79
79
  }
80
80
  },
@@ -83,7 +83,7 @@ function buildOmpToolSet(plugin) {
83
83
  description: "List past flow run sessions for this workspace.",
84
84
  parameters: {},
85
85
  handler: async () => {
86
- const { flowListSessions } = await import('../../flows-7KUZGZ77.js');
86
+ const { flowListSessions } = await import('../../flows-7CZKSC64.js');
87
87
  return (await flowListSessions(plugin.projectDir)).content[0].text;
88
88
  }
89
89
  },
@@ -92,7 +92,7 @@ function buildOmpToolSet(plugin) {
92
92
  description: "List all skills in the ai-assets catalog.",
93
93
  parameters: { domain: { type: "string", optional: true } },
94
94
  handler: async ({ domain }) => {
95
- const { skillList } = await import('../../skills-HGVH6UTA.js');
95
+ const { skillList } = await import('../../skills-5PJ6YVM7.js');
96
96
  return (await skillList(plugin.projectDir, domain)).content[0].text;
97
97
  }
98
98
  },
@@ -101,7 +101,7 @@ function buildOmpToolSet(plugin) {
101
101
  description: "Search skills by name, description, or keywords.",
102
102
  parameters: { query: { type: "string" } },
103
103
  handler: async ({ query }) => {
104
- const { skillSearch } = await import('../../skills-HGVH6UTA.js');
104
+ const { skillSearch } = await import('../../skills-5PJ6YVM7.js');
105
105
  return (await skillSearch(plugin.projectDir, query)).content[0].text;
106
106
  }
107
107
  },
@@ -110,7 +110,7 @@ function buildOmpToolSet(plugin) {
110
110
  description: "Show the full SKILL.md content for a skill.",
111
111
  parameters: { skill_id: { type: "string" } },
112
112
  handler: async ({ skill_id }) => {
113
- const { skillShow } = await import('../../skills-HGVH6UTA.js');
113
+ const { skillShow } = await import('../../skills-5PJ6YVM7.js');
114
114
  return (await skillShow(plugin.projectDir, skill_id)).content[0].text;
115
115
  }
116
116
  },
@@ -201,7 +201,7 @@ async function handleSlashCommand(plugin, group, args) {
201
201
  }
202
202
  }
203
203
  async function handleFlowCommand(plugin, sub, rest) {
204
- const { flowList, flowShow, flowListSessions, flowGetSession } = await import('../../flows-7KUZGZ77.js');
204
+ const { flowList, flowShow, flowListSessions, flowGetSession } = await import('../../flows-7CZKSC64.js');
205
205
  if (!sub || sub === "list") return (await flowList(plugin.projectDir)).content[0].text;
206
206
  if (sub === "show" && rest[0])
207
207
  return (await flowShow(plugin.projectDir, rest[0])).content[0].text;
@@ -230,7 +230,7 @@ async function handleConnectorCommand(plugin, sub, rest) {
230
230
  return "Usage: /connector list | read <id> <path> | exec <id> <op> [json-args] | describe <id>";
231
231
  }
232
232
  async function handleSkillCommand(plugin, sub, rest) {
233
- const { skillList, skillShow, skillSearch } = await import('../../skills-HGVH6UTA.js');
233
+ const { skillList, skillShow, skillSearch } = await import('../../skills-5PJ6YVM7.js');
234
234
  if (sub === "run" && rest[0])
235
235
  return (await skillShow(plugin.projectDir, rest[0])).content[0].text;
236
236
  if (!sub || sub === "list") return (await skillList(plugin.projectDir, rest[0])).content[0].text;
@@ -1,4 +1,4 @@
1
- export { PluginStore, WorkspacePlugin, buildClaudePluginFiles, resolveProjectDir } from '../chunk-F5YPDCN6.js';
1
+ export { PluginStore, WorkspacePlugin, buildClaudePluginFiles, resolveProjectDir } from '../chunk-33GWB3RB.js';
2
2
  export { err, ok, okJson } from '../chunk-X5YPJV4N.js';
3
3
  import '../chunk-U5POE4BA.js';
4
4
  import '../chunk-7GOCNYUV.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skaile/workspaces",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Skaile workspaces runtime — types, core, bridge, runner, store, connectors, and supporting layers as one publishable package",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.3.9",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../cli/src/paths.ts"],"names":[],"mappings":";;;;;;;AAOA,IAAM,WAAW,IAAA,CAAK,OAAA,CAAQ,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AAW5D,SAAS,iBAAiB,IAAA,EAA6B;AACrD,EAAA,IAAI,GAAA,GAAM,IAAA;AACV,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,CAAA,EAAG,CAAA,EAAA,EAAK;AAC1B,IAAA,IAAI,EAAA,CAAG,WAAW,IAAA,CAAK,IAAA,CAAK,KAAK,YAAY,CAAC,GAAG,OAAO,GAAA;AACxD,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,OAAA,CAAQ,GAAG,CAAA;AAC/B,IAAA,IAAI,WAAW,GAAA,EAAK;AACpB,IAAA,GAAA,GAAM,MAAA;AAAA,EACR;AACA,EAAA,OAAO,IAAA;AACT;AAYO,IAAM,aAAA,GAA+B,iBAAiB,QAAQ;AAc9D,IAAM,YAAA,GACX,iBAAA,EAAkB,CAAE,CAAC,CAAA,IAAK,IAAA,CAAK,IAAA,CAAK,EAAA,CAAG,OAAA,EAAQ,EAAG,SAAA,EAAW,WAAW;AAoBnE,SAAS,eAAA,GAA4B;AAC1C,EAAA,MAAM,KAAA,GAAkB,CAAC,GAAG,iBAAA,EAAmB,CAAA;AAG/C,EAAA,KAAA,CAAM,IAAA,CAAK,mBAAmB,CAAA;AAC9B,EAAA,OAAO,CAAC,GAAG,IAAI,GAAA,CAAI,KAAK,CAAC,CAAA,CAAE,MAAA,CAAO,CAAC,CAAA,KAAM,EAAA,CAAG,UAAA,CAAW,CAAC,CAAC,CAAA;AAC3D","file":"chunk-57RFYEVM.js","sourcesContent":["import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { factoryAssetRoots } from \"@skaile/workspaces/core\";\nimport { resolveLibraryDir } from \"@skaile/workspaces/library\";\n\nconst __ownDir = path.dirname(fileURLToPath(import.meta.url));\n\n/**\n * Walk up from `from` looking for the monorepo marker (`biome.json`, the\n * repo-root shared tooling config). Returns the matching directory or `null`\n * when none is found within eight levels — the latter is the typical case when\n * `@skaile/workspaces` has been installed via `npm i` without a skaile-dev\n * workspace context. Used only to gate dev-only commands (e.g.\n * `serve --compile-test`); first-party content is located via\n * {@link aiResourceRoots}, not this.\n */\nfunction findMonorepoRoot(from: string): string | null {\n let dir = from;\n for (let i = 0; i < 8; i++) {\n if (fs.existsSync(path.join(dir, \"biome.json\"))) return dir;\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/**\n * Absolute path to the monorepo root, or `null` when the CLI is running\n * outside the skaile-dev workspace (typical for `npm i -g` installs).\n *\n * Consumers that only make sense inside the workspace (e.g.\n * `skaile serve --compile-test`) MUST check for `null` and report a\n * \"monorepo-only feature\" error before proceeding.\n *\n * @docLink cli/dev-guide#paths\n */\nexport const MONOREPO_ROOT: string | null = findMonorepoRoot(__ownDir);\n\n/**\n * Default content root used by path display and the `validate` command.\n *\n * The primary first-party `factory-assets/` root resolved through the shared\n * `factoryAssetRoots()` helper — the `SKAILE_FACTORY_ASSETS_DIR` override when\n * set, else the in-repo source during dev / bundled `dist/factory-assets/` after\n * `npm i`. Falls back to `~/.skaile/libraries/` — the user-library directory\n * managed by `skaile library add` — when the package cannot be located.\n * Consumers `fs.existsSync` first and degrade to \"no skills / flows discovered\".\n *\n * @docLink cli/dev-guide#paths\n */\nexport const AI_RESOURCES: string =\n factoryAssetRoots()[0] ?? path.join(os.homedir(), \".skaile\", \"libraries\");\n\n/**\n * All content roots that skill / flow discovery should walk, in priority order,\n * filtered to those that exist on disk and de-duplicated.\n *\n * - The first-party `factory-assets/` roots from the shared `factoryAssetRoots()`\n * helper — the `SKAILE_FACTORY_ASSETS_DIR` override layer (when set) ahead of\n * the bundled tree (in-repo source in dev, `dist/factory-assets/` after\n * install). No monorepo special-case.\n * - The user-library dir `~/.skaile/libraries/`.\n *\n * Order is significant: `findSkills` / flow discovery dedupe first-root-wins, so\n * the env override shadows the bundled tree on a name clash.\n *\n * This is the discovery surface used by `findSkills`, flow discovery, and the\n * completion resolvers.\n *\n * @docLink cli/dev-guide#paths\n */\nexport function aiResourceRoots(): string[] {\n const roots: string[] = [...factoryAssetRoots()];\n // resolveLibraryDir honors SKAILE_LIBRARIES_DIR (the authoring side does too),\n // so a custom-dir library is visible to discovery instead of being missed.\n roots.push(resolveLibraryDir());\n return [...new Set(roots)].filter((r) => fs.existsSync(r));\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../factory-assets/connectors/flow/engine/bindings.ts","../factory-assets/connectors/flow/engine/router-settlement.ts","../factory-assets/connectors/flow/engine/engine.ts","../factory-assets/connectors/flow/engine/output-schema.ts","../factory-assets/connectors/flow/engine/node-deadline.ts","../factory-assets/connectors/flow/engine/node-attempts.ts","../factory-assets/connectors/flow/engine/optional-failure.ts","../factory-assets/connectors/flow/engine/check-provenance.ts","../factory-assets/connectors/flow/engine/flow-manifest.ts","../factory-assets/connectors/flow/engine/flow-kind-provider.ts","../factory-assets/connectors/flow/engine/loader.ts"],"names":["path","z","process","parseYaml"],"mappings":";;;;;;;;;;AAWO,SAAS,0BAAA,CACd,MACA,SAAA,EACuB;AACvB,EAAA,MAAM,QAAwC,EAAC;AAC/C,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAK,KAAA,EAAO;AAC7B,IAAA,MAAM,QAAA,GAAW,SAAA,CAAU,GAAA,CAAI,IAAA,CAAK,EAAE,CAAA;AACtC,IAAA,MAAM,MAAA,GACJ,QAAA,EAAU,MAAA,KAAW,UAAA,IAAc,QAAA,CAAS,MAAA,EAAQ,MAAA,GA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IAChD;AAAA,EACF;AACA,EAAA,OAAO,CAAC,GAAG,IAAA,CAAK,MAAA,EAAQ,CAAA;AAC1B","file":"chunk-EYBGQJNF.js","sourcesContent":["import {\n resolveFlowBindings,\n stableFlowJson,\n type BindingOrigin,\n type FlowExpressionContext,\n type ResolvedNodeBindings,\n} from \"../contract/expression.js\";\nimport { isAgentNode, isSubpromptNode, nodeBindings } from \"./node-shape.js\";\nimport type { FlowDefinition, FlowNode, NodeExecutionSnapshot } from \"./types.js\";\n\n/** Build the bounded expression context from immutable definition and snapshot state. */\nexport function buildFlowExpressionContext(\n flow: FlowDefinition,\n snapshots: Map<string, NodeExecutionSnapshot>,\n): FlowExpressionContext {\n const nodes: FlowExpressionContext[\"nodes\"] = {};\n for (const node of flow.nodes) {\n const snapshot = snapshots.get(node.id);\n const output =\n snapshot?.status === \"complete\" && snapshot.output?.fields\n ? { fields: snapshot.output.fields }\n : undefined;\n nodes[node.id] = { status: snapshot?.status ?? \"not_started\", output };\n }\n return {\n flow: { input: flow.defaults?.run_input ?? {} },\n defaults: flow.defaults,\n nodes,\n };\n}\n\n/**\n * Classify what one producer node's output counts as for a downstream binding.\n *\n * Transitive by induction, in a single lookup: a producer's persisted\n * `inputOrigins` were themselves classified under this rule when it ran, so\n * they already carry any taint from its own ancestors — no graph walk. Absent\n * origins read as `\"agent\"` (fail-closed): a snapshot persisted before the\n * field existed cannot prove the node's inputs were clean, and this label is\n * one a human approver acts on. `{}` — a node that bound nothing — is\n * `\"runtime\"`.\n */\nexport function producerOutputObtainedBy(\n producer: FlowNode,\n snapshot: NodeExecutionSnapshot | undefined,\n): \"agent\" | \"runtime\" {\n // A subprompt's output is model-generated the same as an agent's, even though\n // the runtime (not the session agent) makes the call — so a downstream check\n // must derive \"asserted\", never \"verified\", over it. See engine/check-provenance.ts.\n if (isAgentNode(producer) || isSubpromptNode(producer)) return \"agent\";\n const inputOrigins = snapshot?.inputOrigins;\n if (!inputOrigins) return \"agent\";\n const tainted = Object.values(inputOrigins).some((origins) =>\n // A hydrated snapshot is host-supplied and only shape-checked as JSON, so a\n // malformed entry is unreadable rather than clean — fail closed, never throw.\n Array.isArray(origins) ? origins.some((origin) => origin?.obtainedBy === \"agent\") : true,\n );\n return tainted ? \"agent\" : \"runtime\";\n}\n\n/** Resolve one node's named inputs and derive their runtime/agent origins. */\nexport function resolveNodeBindings(\n flow: FlowDefinition,\n node: FlowNode,\n snapshots: Map<string, NodeExecutionSnapshot>,\n flowInputOrigins: Record<string, BindingOrigin[]> = {},\n): ResolvedNodeBindings {\n const origins = Object.fromEntries(\n flow.nodes.map((producer) => [\n producer.id,\n producerOutputObtainedBy(producer, snapshots.get(producer.id)),\n ]),\n ) as Record<string, \"agent\" | \"runtime\">;\n return resolveFlowBindings(\n nodeBindings(node),\n buildFlowExpressionContext(flow, snapshots),\n origins,\n flowInputOrigins,\n );\n}\n\n/** Interpolate named, already-resolved binding values into an agent instruction. */\nexport function interpolateNodeInstruction(\n instruction: string,\n values: Record<string, unknown>,\n): string {\n return instruction.replace(/\\$\\{([A-Za-z_][A-Za-z0-9_-]*)\\}/g, (_placeholder, name: string) => {\n if (!Object.hasOwn(values, name)) {\n throw new Error(`Node instruction binding ${name} is missing`);\n }\n const value = values[name];\n return typeof value === \"string\" ? value : stableFlowJson(value);\n });\n}\n","import type { NodeOutput } from \"@skaile/workspaces/types\";\nimport { evaluateFlowExpression, FlowExpressionError } from \"../contract/expression.js\";\nimport { buildFlowExpressionContext } from \"./bindings.js\";\nimport { isRouterNode } from \"./node-shape.js\";\nimport type { FlowDefinition, FlowNode, NodeExecutionSnapshot } from \"./types.js\";\n\nconst ROUTER_SELECTION_MARKER = \"\\n\\n[skaile:flow-router-selection:\";\n\n/** One deterministic router choice being settled in the current atomic batch. */\nexport interface RouterSettlement {\n routerNodeId: string;\n selectedTarget: string | null;\n}\n\n/** Internal result of evaluating one already-admitted router. */\nexport type RouterSelection =\n | { selectedTarget: string | null }\n | { unresolved: \"not-ready\" | \"no-match\" };\n\nfunction pendingProducerOutput(\n flow: FlowDefinition,\n snapshots: Map<string, NodeExecutionSnapshot>,\n missingPath: string | undefined,\n): boolean {\n if (!missingPath) return false;\n const segments = missingPath.split(\".\");\n if (\n segments.length < 5 ||\n segments[0] !== \"nodes\" ||\n segments[2] !== \"output\" ||\n segments[3] !== \"fields\"\n ) {\n return false;\n }\n const producer = flow.nodes.find(({ id }) => id === segments[1]);\n if (!producer?.contract?.output?.fields) return false;\n // Only a producer that can still produce is worth waiting for — a terminal\n // one never will, and calling it \"pending\" parks the router forever.\n return ![\"complete\", \"skipped\", \"failed\"].includes(\n snapshots.get(producer.id)?.status ?? \"not_started\",\n );\n}\n\n/** Evaluate ordered routes for a router whose availability was already established. */\nexport function evaluateRouterSelection(\n flow: FlowDefinition,\n router: FlowNode,\n snapshots: Map<string, NodeExecutionSnapshot>,\n): RouterSelection {\n if (!isRouterNode(router)) return { unresolved: \"no-match\" };\n const context = buildFlowExpressionContext(flow, snapshots);\n for (const route of router.run.routes) {\n try {\n if (evaluateFlowExpression(route.when, context)) {\n return { selectedTarget: route.target };\n }\n } catch (error) {\n if (\n error instanceof FlowExpressionError &&\n pendingProducerOutput(flow, snapshots, error.missingPath)\n ) {\n return { unresolved: \"not-ready\" };\n }\n throw error;\n }\n }\n return { unresolved: \"no-match\" };\n}\n\n/** Encode a router choice in the existing durable node-output envelope. */\nexport function routerSelectionOutput(selectedTarget: string | null): NodeOutput {\n const summary =\n selectedTarget === null\n ? \"Router completed without selecting a target.\"\n : `Router selected ${selectedTarget}.`;\n return {\n summary: `${summary}${ROUTER_SELECTION_MARKER}${JSON.stringify(selectedTarget)}]`,\n artifacts: [],\n };\n}\n\nfunction routeTargets(router: FlowNode): string[] {\n if (!isRouterNode(router)) return [];\n return [...new Set(router.run.routes.flatMap(({ target }) => (target === null ? [] : [target])))];\n}\n\ninterface RouterOwnershipIndex {\n routers: FlowNode[];\n outgoing: Map<string, string[]>;\n}\n\n/** Index router-to-router ownership through route targets and hard-flow descendants. */\nfunction routerOwnershipIndex(\n flow: FlowDefinition,\n snapshots: Map<string, NodeExecutionSnapshot>,\n): RouterOwnershipIndex {\n const routers = flow.nodes.filter(\n (node) =>\n isRouterNode(node) &&\n ![\"complete\", \"failed\", \"skipped\"].includes(snapshots.get(node.id)?.status ?? \"not_started\"),\n );\n const routerIds = new Set(routers.map(({ id }) => id));\n const hardOutgoing = new Map<string, string[]>();\n for (const edge of flow.edges) {\n if (edge.type !== \"flow\") continue;\n const targets = hardOutgoing.get(edge.source) ?? [];\n targets.push(edge.target);\n hardOutgoing.set(edge.source, targets);\n }\n\n const outgoing = new Map<string, string[]>();\n for (const router of routers) {\n const owned = new Set<string>();\n const visited = new Set<string>();\n const queue = routeTargets(router);\n for (let index = 0; index < queue.length; index++) {\n const nodeId = queue[index];\n if (visited.has(nodeId)) continue;\n visited.add(nodeId);\n if (routerIds.has(nodeId)) owned.add(nodeId);\n queue.push(...(hardOutgoing.get(nodeId) ?? []));\n }\n outgoing.set(router.id, [...owned]);\n }\n return { routers, outgoing };\n}\n\n/**\n * Return every member of each source router-ownership SCC.\n *\n * Route ownership is deliberately not a dependency arc and may cycle even though hard flow is\n * acyclic. Source SCC members are ungated so normal hard-edge/precondition admission and ordered\n * decidability select the settlement frontier. Ordinary parent components remain ahead of nested\n * children, while self-targeting and mutually targeting routers cannot deadlock admission. The\n * graph is preindexed and both SCC passes are iterative.\n */\nfunction routerOwnershipSourceComponents(\n flow: FlowDefinition,\n snapshots: Map<string, NodeExecutionSnapshot>,\n): string[][] {\n const { routers, outgoing } = routerOwnershipIndex(flow, snapshots);\n const reverse = new Map<string, string[]>();\n for (const router of routers) reverse.set(router.id, []);\n for (const [source, targets] of outgoing) {\n for (const target of targets) reverse.get(target)?.push(source);\n }\n\n const visited = new Set<string>();\n const finished: string[] = [];\n for (const router of routers) {\n if (visited.has(router.id)) continue;\n const stack: Array<{ nodeId: string; exiting: boolean }> = [\n { nodeId: router.id, exiting: false },\n ];\n while (stack.length > 0) {\n const frame = stack.pop();\n if (!frame) break;\n if (frame.exiting) {\n finished.push(frame.nodeId);\n continue;\n }\n if (visited.has(frame.nodeId)) continue;\n visited.add(frame.nodeId);\n stack.push({ nodeId: frame.nodeId, exiting: true });\n const targets = outgoing.get(frame.nodeId) ?? [];\n for (let index = targets.length - 1; index >= 0; index--) {\n if (!visited.has(targets[index])) {\n stack.push({ nodeId: targets[index], exiting: false });\n }\n }\n }\n }\n\n const componentByRouter = new Map<string, number>();\n const components: string[][] = [];\n for (let index = finished.length - 1; index >= 0; index--) {\n const start = finished[index];\n if (componentByRouter.has(start)) continue;\n const componentId = components.length;\n const component: string[] = [];\n const stack = [start];\n componentByRouter.set(start, componentId);\n while (stack.length > 0) {\n const nodeId = stack.pop();\n if (!nodeId) break;\n component.push(nodeId);\n for (const source of reverse.get(nodeId) ?? []) {\n if (componentByRouter.has(source)) continue;\n componentByRouter.set(source, componentId);\n stack.push(source);\n }\n }\n components.push(component);\n }\n\n const incomingComponents = new Set<number>();\n for (const [source, targets] of outgoing) {\n const sourceComponent = componentByRouter.get(source);\n for (const target of targets) {\n const targetComponent = componentByRouter.get(target);\n if (\n sourceComponent !== undefined &&\n targetComponent !== undefined &&\n sourceComponent !== targetComponent\n ) {\n incomingComponents.add(targetComponent);\n }\n }\n }\n\n const definitionOrder = new Map(flow.nodes.map((node, index) => [node.id, index]));\n const sourceComponents = components.filter(\n (_, componentId) => !incomingComponents.has(componentId),\n );\n for (const component of sourceComponents) {\n component.sort(\n (left, right) =>\n (definitionOrder.get(left) ?? Number.MAX_SAFE_INTEGER) -\n (definitionOrder.get(right) ?? Number.MAX_SAFE_INTEGER),\n );\n }\n return sourceComponents.sort(\n (left, right) =>\n (definitionOrder.get(left[0]) ?? Number.MAX_SAFE_INTEGER) -\n (definitionOrder.get(right[0]) ?? Number.MAX_SAFE_INTEGER),\n );\n}\n\n/** Decode and validate a completed router's engine-owned selection summary. */\nexport function persistedRouterSelection(\n router: FlowNode,\n snapshot: NodeExecutionSnapshot | undefined,\n): { selectedTarget: string | null } | undefined {\n if (!isRouterNode(router) || snapshot?.status !== \"complete\") return undefined;\n const summary = snapshot.output?.summary;\n const markerIndex = summary?.lastIndexOf(ROUTER_SELECTION_MARKER) ?? -1;\n if (!summary || markerIndex < 0 || !summary.endsWith(\"]\")) return undefined;\n let selectedTarget: unknown;\n try {\n selectedTarget = JSON.parse(summary.slice(markerIndex + ROUTER_SELECTION_MARKER.length, -1));\n } catch {\n return undefined;\n }\n if (\n selectedTarget !== null &&\n (typeof selectedTarget !== \"string\" || !routeTargets(router).includes(selectedTarget))\n ) {\n return undefined;\n }\n if (selectedTarget === null && !router.run.routes.some(({ target }) => target === null)) {\n return undefined;\n }\n return summary === routerSelectionOutput(selectedTarget).summary ? { selectedTarget } : undefined;\n}\n\nfunction edgeKey(source: string, target: string): string {\n return `${source}\\u0000${target}`;\n}\n\n/**\n * Plan exclusive branch skips for all known router choices as one coordinated settlement.\n *\n * Only hard `flow` edges participate. The graph is indexed once, then each distinct losing\n * target performs a linear adjacency walk; optional and parallel edges can neither spread nor\n * preserve exclusivity. A selected route, a still-live unsettled router, shared convergence, or\n * an incoming hard predecessor outside the losing region protects that node and its descendants.\n */\nexport function planRouterSkips(\n flow: FlowDefinition,\n snapshots: Map<string, NodeExecutionSnapshot>,\n settlements: readonly RouterSettlement[],\n): string[] {\n const routers = flow.nodes.filter(isRouterNode);\n const currentSelections = new Map(\n settlements.map(({ routerNodeId, selectedTarget }) => [routerNodeId, selectedTarget]),\n );\n const knownSelections = new Map<string, string | null>();\n for (const router of routers) {\n if (currentSelections.has(router.id)) {\n knownSelections.set(router.id, currentSelections.get(router.id) ?? null);\n continue;\n }\n const persisted = persistedRouterSelection(router, snapshots.get(router.id));\n if (persisted) knownSelections.set(router.id, persisted.selectedTarget);\n }\n\n const outgoing = new Map<string, string[]>();\n const incoming = new Map<string, string[]>();\n for (const edge of flow.edges) {\n if (edge.type !== \"flow\") continue;\n const targets = outgoing.get(edge.source) ?? [];\n targets.push(edge.target);\n outgoing.set(edge.source, targets);\n const sources = incoming.get(edge.target) ?? [];\n sources.push(edge.source);\n incoming.set(edge.target, sources);\n }\n\n const losingRoots = new Set<string>();\n const selectedRoots = new Set<string>();\n const losingRouteEdges = new Set<string>();\n for (const router of routers) {\n if (!knownSelections.has(router.id)) continue;\n const selectedTarget = knownSelections.get(router.id) ?? null;\n if (selectedTarget !== null) selectedRoots.add(selectedTarget);\n for (const target of routeTargets(router)) {\n if (target === selectedTarget) continue;\n losingRoots.add(target);\n losingRouteEdges.add(edgeKey(router.id, target));\n }\n }\n\n const candidateOrigins = new Map<string, Set<string>>();\n for (const root of losingRoots) {\n const visited = new Set<string>();\n const queue = [root];\n for (let index = 0; index < queue.length; index++) {\n const nodeId = queue[index];\n if (visited.has(nodeId)) continue;\n visited.add(nodeId);\n const origins = candidateOrigins.get(nodeId) ?? new Set<string>();\n origins.add(root);\n candidateOrigins.set(nodeId, origins);\n for (const target of outgoing.get(nodeId) ?? []) queue.push(target);\n }\n }\n const candidates = new Set(candidateOrigins.keys());\n\n const protectionQueue = [...selectedRoots];\n for (const [nodeId, origins] of candidateOrigins) {\n if (origins.size >= 2) protectionQueue.push(nodeId);\n for (const source of incoming.get(nodeId) ?? []) {\n if (candidates.has(source)) continue;\n if (losingRouteEdges.has(edgeKey(source, nodeId))) continue;\n if ([\"failed\", \"skipped\"].includes(snapshots.get(source)?.status ?? \"not_started\")) continue;\n protectionQueue.push(nodeId);\n break;\n }\n }\n\n const unknownSelections = new Map<string, string[]>();\n for (const router of routers) {\n if (knownSelections.has(router.id)) continue;\n const status = snapshots.get(router.id)?.status ?? \"not_started\";\n if (status === \"failed\" || status === \"skipped\") continue;\n const targets = routeTargets(router);\n unknownSelections.set(router.id, targets);\n if (!candidates.has(router.id)) protectionQueue.push(...targets);\n }\n\n const protectedNodes = new Set<string>();\n for (let index = 0; index < protectionQueue.length; index++) {\n const nodeId = protectionQueue[index];\n if (protectedNodes.has(nodeId)) continue;\n protectedNodes.add(nodeId);\n protectionQueue.push(...(outgoing.get(nodeId) ?? []));\n protectionQueue.push(...(unknownSelections.get(nodeId) ?? []));\n }\n\n return flow.nodes.flatMap((node) =>\n candidates.has(node.id) && !protectedNodes.has(node.id) ? [node.id] : [],\n );\n}\n\n/**\n * Return every possible target branch gated by an unsettled router.\n *\n * Gating follows hard `flow` descendants only. A selected route, shared convergence, or another\n * live hard predecessor protects a node, matching settlement pruning without mutating snapshots.\n */\nexport function unsettledRouterBranchIds(\n flow: FlowDefinition,\n snapshots: Map<string, NodeExecutionSnapshot>,\n): Set<string> {\n const unsettled = flow.nodes.filter(\n (node) =>\n isRouterNode(node) &&\n ![\"complete\", \"failed\", \"skipped\"].includes(snapshots.get(node.id)?.status ?? \"not_started\"),\n );\n const branches = new Set(\n planRouterSkips(\n flow,\n snapshots,\n unsettled.map(({ id }) => ({ routerNodeId: id, selectedTarget: null })),\n ),\n );\n for (const component of routerOwnershipSourceComponents(flow, snapshots)) {\n for (const routerId of component) branches.delete(routerId);\n }\n return branches;\n}\n\n/**\n * Return one actually available, decidable router per source ownership component.\n *\n * Every source-component member remains ungated for normal admission. Within a settlement wave,\n * definition order chooses the first member that is both available and decidable; unresolved or\n * blocked peers cannot starve it. Limiting each component to one choice prevents a router from\n * completing atomically after that same wave makes its branch losing. Independent source\n * components can still settle together.\n */\nexport function availableRouterFrontier(\n flow: FlowDefinition,\n snapshots: Map<string, NodeExecutionSnapshot>,\n): FlowNode[] {\n const nodesById = new Map(flow.nodes.map((node) => [node.id, node]));\n return routerOwnershipSourceComponents(flow, snapshots).flatMap((component) => {\n for (const routerId of component) {\n const node = nodesById.get(routerId);\n if (!node || snapshots.get(routerId)?.status !== \"available\") continue;\n if (\"unresolved\" in evaluateRouterSelection(flow, node, snapshots)) continue;\n return [node];\n }\n return [];\n });\n}\n","import type {\n FlowDefinition,\n FlowEdge,\n FlowNode,\n FlowState,\n NodeExecutionSnapshot,\n NodePreconditionFailure,\n NodeState,\n NodeStatus,\n} from \"./types.js\";\nimport { evaluateFlowExpression, type FlowExpressionContext } from \"../contract/expression.js\";\nimport { buildFlowExpressionContext } from \"./bindings.js\";\nimport {\n isActiveRuntimeNode,\n isRouterNode,\n nodeIsOptional,\n nodeLabel,\n nodeSkillId,\n} from \"./node-shape.js\";\nimport {\n evaluateRouterSelection,\n planRouterSkips,\n unsettledRouterBranchIds,\n} from \"./router-settlement.js\";\n\n// ---------------------------------------------------------------------------\n// Core engine — stateless, pure functions\n// ---------------------------------------------------------------------------\n\n/** Return nodes with state owned by the current runtime. */\nfunction activeRuntimeNodes(flow: FlowDefinition): FlowNode[] {\n return flow.nodes.filter(isActiveRuntimeNode);\n}\n\n/** Evaluate every authored admission condition without mutating runtime state. */\nfunction failedPreconditions(\n node: FlowNode,\n context: FlowExpressionContext,\n): NodePreconditionFailure[] {\n const failures: NodePreconditionFailure[] = [];\n for (const requirement of node.contract?.requires ?? []) {\n const message = requirement.message ?? `Precondition failed: ${requirement.expr}`;\n try {\n if (!evaluateFlowExpression(requirement.expr, context)) {\n failures.push({ expression: requirement.expr, message, reason: \"false\" });\n }\n } catch (error) {\n failures.push({\n expression: requirement.expr,\n message,\n reason: \"error\",\n detail: error instanceof Error ? error.message : \"Flow expression evaluation failed\",\n });\n }\n }\n return failures;\n}\n\n/** Build adjacency: target → sources[] (incoming edges per node) */\nfunction buildIncoming(edges: FlowEdge[]): Map<string, FlowEdge[]> {\n const map = new Map<string, FlowEdge[]>();\n for (const edge of edges) {\n if (!map.has(edge.target)) map.set(edge.target, []);\n map.get(edge.target)!.push(edge);\n }\n return map;\n}\n\n/** Build adjacency: source → targets[] (outgoing edges per node) */\nfunction buildOutgoing(edges: FlowEdge[]): Map<string, FlowEdge[]> {\n const map = new Map<string, FlowEdge[]>();\n for (const edge of edges) {\n if (!map.has(edge.source)) map.set(edge.source, []);\n map.get(edge.source)!.push(edge);\n }\n return map;\n}\n\n/** Result of resolving one available router against the current expression context. */\nexport interface RouterResolution {\n /** First matching route target. `null` means every branch loses. */\n selectedTarget: string | null;\n /** Exclusive nodes belonging only to unselected route targets, in definition order. */\n skippedNodeIds: string[];\n}\n\n/** Available router that cannot make a deterministic choice from the current snapshot. */\nexport interface UnresolvedRouterResolution {\n /** Why the router remains available for a later drain pass. */\n unresolved: \"not-ready\" | \"no-match\";\n}\n\n/**\n * Resolve the first matching route for a router that is currently available.\n *\n * Route conditions use the same bounded context as node preconditions and bindings. Resolution\n * is deliberately separate from state computation: unavailable routers return `undefined`\n * without evaluating any route. Losing route targets and their exclusive downstream paths are\n * returned for the caller to mark skipped. Exclusivity follows hard `flow` edges only and keeps\n * selected routes, unsettled-router targets, shared convergence, and externally reachable nodes\n * live. A declared producer output that is not complete yet returns a retryable unresolved result;\n * malformed expressions still throw their path-bearing evaluator error.\n *\n * @param flow - Parsed flow containing the router and branch graph.\n * @param routerNodeId - Router execution identity.\n * @param snapshots - Current node snapshots used for admission and expression values.\n * @returns The selected target and losing nodes, an unresolved reason while available but not\n * decidable, or `undefined` while the router is unavailable.\n */\nexport function resolveAvailableRouter(\n flow: FlowDefinition,\n routerNodeId: string,\n snapshots: Map<string, NodeExecutionSnapshot>,\n): RouterResolution | UnresolvedRouterResolution | undefined {\n const router = flow.nodes.find((node) => node.id === routerNodeId);\n if (!router || !isRouterNode(router)) return undefined;\n const state = computeFlowStateFromSnapshots(flow, snapshots);\n if (!state.available.includes(routerNodeId)) return undefined;\n\n const selected = evaluateRouterSelection(flow, router, snapshots);\n if (\"unresolved\" in selected) return selected;\n\n return {\n selectedTarget: selected.selectedTarget,\n skippedNodeIds: planRouterSkips(flow, snapshots, [\n { routerNodeId, selectedTarget: selected.selectedTarget },\n ]),\n };\n}\n\n/**\n * Compute the full {@link FlowState} from a flow definition and caller-supplied node ID sets.\n *\n * This is the primary engine function. It is stateless and side-effect-free — calling it\n * twice with the same arguments always returns an equivalent result.\n *\n * Edge semantics applied during computation:\n * - `'flow'` — hard dependency: target cannot start until source is `complete` or `skipped`.\n * - `'parallel'` — soft dependency: target may run while source is still running.\n * - `'optional'` — advisory: target can start regardless of source state.\n *\n * A node is `available` when every incoming `'flow'`-type edge has a complete or skipped source\n * and every authored precondition evaluates true.\n * A node is `not_started` when at least one hard predecessor is still pending.\n * The flow is `done` when every non-optional node is `complete` or `skipped`.\n *\n * This set-based overload has statuses but no completed output fields. Use\n * {@link computeFlowStateFromSnapshots} when a precondition reads node output.\n *\n * Prefer {@link computeFlowStateFromSnapshots} for callers that track full `NodeExecution`\n * state (interaction statuses such as `awaiting_approval`, `awaiting_input`, `failed`).\n *\n * @param flow - The parsed flow definition.\n * @param completedIds - Set of node IDs that have finished successfully.\n * @param runningIds - Set of node IDs currently executing. Defaults to an empty set.\n * @param skippedIds - Set of node IDs that were explicitly skipped. Skipped nodes count\n * as satisfied for downstream dependency checks. Defaults to an empty set.\n * @returns A {@link FlowState} describing every active runtime node.\n * @docLink packages/flow-engine/concepts#compute-flow-state\n */\nexport function computeFlowState(\n flow: FlowDefinition,\n completedIds: Set<string>,\n runningIds: Set<string> = new Set(),\n skippedIds: Set<string> = new Set(),\n): FlowState {\n const nodes = activeRuntimeNodes(flow);\n const incoming = buildIncoming(flow.edges);\n const snapshots = new Map<string, NodeExecutionSnapshot>();\n for (const node of nodes) {\n const status: NodeStatus = completedIds.has(node.id)\n ? \"complete\"\n : runningIds.has(node.id)\n ? \"running\"\n : skippedIds.has(node.id)\n ? \"skipped\"\n : \"not_started\";\n snapshots.set(node.id, { status });\n }\n const gatedBranches = unsettledRouterBranchIds(flow, snapshots);\n const context = buildFlowExpressionContext(flow, snapshots);\n\n const nodeStates: NodeState[] = nodes.map((node) => {\n const optional = nodeIsOptional(node);\n const skillId = nodeSkillId(node);\n const label = nodeLabel(node);\n\n if (completedIds.has(node.id)) {\n return {\n nodeId: node.id,\n skillId,\n label,\n status: \"complete\",\n optional,\n canRun: false,\n blockers: [],\n failedPreconditions: [],\n };\n }\n if (runningIds.has(node.id)) {\n return {\n nodeId: node.id,\n skillId,\n label,\n status: \"running\",\n optional,\n canRun: false,\n blockers: [],\n failedPreconditions: [],\n };\n }\n if (skippedIds.has(node.id)) {\n return {\n nodeId: node.id,\n skillId,\n label,\n status: \"skipped\",\n optional,\n canRun: false,\n blockers: [],\n failedPreconditions: [],\n };\n }\n\n if (gatedBranches.has(node.id)) {\n return {\n nodeId: node.id,\n skillId,\n label,\n status: \"not_started\",\n optional,\n canRun: false,\n blockers: [],\n failedPreconditions: [],\n };\n }\n\n const edges = incoming.get(node.id) ?? [];\n\n // Hard blockers: flow-type edges whose source is neither complete nor skipped\n const hardBlockers = edges\n .filter((e) => e.type === \"flow\")\n .filter((e) => !completedIds.has(e.source) && !skippedIds.has(e.source))\n .map((e) => e.source);\n\n const preconditionFailures = failedPreconditions(node, context);\n const canRun = hardBlockers.length === 0 && preconditionFailures.length === 0;\n\n let status: NodeStatus;\n if (!canRun) {\n status = \"not_started\";\n } else {\n status = \"available\";\n }\n\n return {\n nodeId: node.id,\n skillId,\n label,\n status,\n optional,\n canRun,\n blockers: hardBlockers,\n failedPreconditions: preconditionFailures,\n };\n });\n\n const _stateMap = new Map(nodeStates.map((s) => [s.nodeId, s]));\n\n const available = nodeStates.filter((s) => s.status === \"available\").map((s) => s.nodeId);\n const completed = nodeStates.filter((s) => s.status === \"complete\").map((s) => s.nodeId);\n const focus = nodeStates\n .filter(\n (s) =>\n s.status === \"running\" || s.status === \"awaiting_approval\" || s.status === \"awaiting_input\",\n )\n .map((s) => s.nodeId);\n\n // Flow is done when all required nodes are complete or skipped\n const requiredNodes = nodes.filter((n) => !nodeIsOptional(n));\n const done = requiredNodes.every((n) => completedIds.has(n.id) || skippedIds.has(n.id));\n\n return { flowId: flow.id, nodes: nodeStates, available, completed, focus, done };\n}\n\n/**\n * Snapshot-based variant of {@link computeFlowState}.\n *\n * Accepts a map of `NodeExecutionSnapshot` values carrying the current status and\n * interaction metadata for every node the caller knows about. Nodes absent from the\n * map are treated as `not_started`.\n *\n * This is the preferred API for the turn-based runner, which has a full `FlowExecution`\n * and needs to convey richer statuses (`awaiting_approval`, `awaiting_input`, `failed`)\n * back to the engine so downstream availability is computed correctly.\n *\n * Engine semantics:\n * - A node is `available` when all its incoming `'flow'`-type predecessors are `complete`\n * or `skipped`. Any other upstream status — including `awaiting_approval`,\n * `awaiting_input`, and `failed` — is treated as blocking. Every authored precondition\n * must also evaluate true against the snapshot expression context.\n * - Optionality is **not** a term here: `failed` blocks whether or not the node is optional.\n * An optional node's dependents proceed because an optional node never reaches a terminal\n * `failed` in the first place — its exhausted failure resolves to `skipped`\n * (`resolveTerminalFailureStatus`), which passes. The one exception is a router, which\n * stays `failed` even when optional.\n * - The flow is `done` when every non-optional node is `complete` or `skipped`. A single\n * required node stuck in `failed` keeps `done` false.\n *\n * @param flow - The parsed flow definition.\n * @param snapshots - Map from node ID to its current {@link NodeExecutionSnapshot}.\n * Missing entries default to `not_started` with no interaction metadata.\n * @returns A {@link FlowState} describing every active runtime node,\n * including interaction fields (`approval`, `input`, `output`, `error`) copied\n * from the matching snapshot.\n * @docLink packages/flow-engine/concepts#compute-flow-state-from-snapshots\n */\nexport function computeFlowStateFromSnapshots(\n flow: FlowDefinition,\n snapshots: Map<string, NodeExecutionSnapshot>,\n): FlowState {\n const nodes = activeRuntimeNodes(flow);\n const incoming = buildIncoming(flow.edges);\n const gatedBranches = unsettledRouterBranchIds(flow, snapshots);\n const context = buildFlowExpressionContext(flow, snapshots);\n\n /** Resolve the effective status for a node — defaulting to `not_started`. */\n const statusFor = (nodeId: string): NodeStatus => snapshots.get(nodeId)?.status ?? \"not_started\";\n\n /** A predecessor \"passes\" when it is complete or skipped. */\n const passed = (nodeId: string): boolean => {\n const s = statusFor(nodeId);\n return s === \"complete\" || s === \"skipped\";\n };\n\n const nodeStates: NodeState[] = nodes.map((node) => {\n const snapshot = snapshots.get(node.id);\n const optional = nodeIsOptional(node);\n const skillId = nodeSkillId(node);\n const label = nodeLabel(node);\n const status = snapshot?.status ?? \"not_started\";\n\n const edges = incoming.get(node.id) ?? [];\n const flowPreds = edges.filter((e) => e.type === \"flow\");\n const hardBlockers = flowPreds.filter((e) => !passed(e.source)).map((e) => e.source);\n\n const isAdmissionState = status === \"not_started\" || status === \"available\";\n const preconditionFailures = isAdmissionState ? failedPreconditions(node, context) : [];\n\n // Recompute admission in both directions after fresh start or hydrate.\n let effectiveStatus: NodeStatus = status;\n if (isAdmissionState && gatedBranches.has(node.id)) {\n effectiveStatus = \"not_started\";\n } else if (isAdmissionState) {\n effectiveStatus =\n hardBlockers.length === 0 && preconditionFailures.length === 0\n ? \"available\"\n : \"not_started\";\n }\n\n return {\n nodeId: node.id,\n skillId,\n label,\n status: effectiveStatus,\n optional,\n canRun:\n hardBlockers.length === 0 &&\n preconditionFailures.length === 0 &&\n effectiveStatus === \"available\",\n blockers: hardBlockers,\n failedPreconditions: preconditionFailures,\n approval: snapshot?.approval,\n input: snapshot?.input,\n output: snapshot?.output,\n error: snapshot?.error,\n };\n });\n\n const available = nodeStates.filter((s) => s.status === \"available\").map((s) => s.nodeId);\n const completed = nodeStates.filter((s) => s.status === \"complete\").map((s) => s.nodeId);\n const focus = nodeStates\n .filter(\n (s) =>\n s.status === \"running\" || s.status === \"awaiting_approval\" || s.status === \"awaiting_input\",\n )\n .map((s) => s.nodeId);\n\n const requiredNodes = nodes.filter((n) => !nodeIsOptional(n));\n const done = requiredNodes.every((n) => {\n const s = statusFor(n.id);\n return s === \"complete\" || s === \"skipped\";\n });\n\n return { flowId: flow.id, nodes: nodeStates, available, completed, focus, done };\n}\n\n/**\n * Returns `true` when the given status prevents downstream nodes from starting.\n *\n * Only `'complete'` and `'skipped'` satisfy a hard (`'flow'`-type) edge dependency.\n * All other statuses — including `'awaiting_approval'`, `'awaiting_input'`, and\n * `'failed'` — are considered blocking.\n *\n * Use this helper in the FlowAdapter and the turn-based orchestrator instead of\n * hard-coding the two-value whitelist inline.\n *\n * @param status - The {@link NodeStatus} to evaluate.\n * @returns `true` if the status prevents dependents from becoming `available`.\n * @docLink packages/flow-engine/concepts#is-blocking\n */\nexport function isBlocking(status: NodeStatus): boolean {\n return status !== \"complete\" && status !== \"skipped\";\n}\n\n/**\n * Returns the IDs of nodes that become newly `available` after a specific node completes.\n *\n * More efficient than recomputing the full {@link FlowState} when only the downstream\n * impact of a single completion is needed. Only the direct successors of `justCompleted`\n * are evaluated — the rest of the graph is untouched.\n *\n * @param flow - The parsed flow definition.\n * @param justCompleted - ID of the node that just finished (will be added to the\n * effective completed set before evaluating successors).\n * @param completedIds - Set of node IDs already known to be complete before this call.\n * @param skippedIds - Set of node IDs that were explicitly skipped. Defaults to an empty set.\n * @returns Array of node IDs whose hard dependencies are now fully satisfied and that\n * were not already available before `justCompleted` finished. Unlike executable-node-filtered\n * helpers, this walks raw edge targets and does not filter by node type — if a `group`,\n * `sub-flow`, or `router` node is a direct successor, its ID can appear here. Callers that\n * dispatch these IDs are responsible for filtering inert nodes.\n * @docLink packages/flow-engine/concepts#resolve-next-nodes\n */\nexport function resolveNextNodes(\n flow: FlowDefinition,\n justCompleted: string,\n completedIds: Set<string>,\n skippedIds: Set<string> = new Set(),\n): string[] {\n const outgoing = buildOutgoing(flow.edges);\n const incoming = buildIncoming(flow.edges);\n const candidates = (outgoing.get(justCompleted) ?? []).map((e) => e.target);\n\n const nextCompleted = new Set([...completedIds, justCompleted]);\n const result: string[] = [];\n\n for (const candidateId of candidates) {\n const edges = incoming.get(candidateId) ?? [];\n const hardBlockers = edges\n .filter((e) => e.type === \"flow\")\n .filter((e) => !nextCompleted.has(e.source) && !skippedIds.has(e.source));\n if (hardBlockers.length === 0) {\n result.push(candidateId);\n }\n }\n\n return result;\n}\n\n/**\n * Returns the IDs of optional nodes that have not yet started and can be safely skipped.\n *\n * A node is skippable when it is:\n * 1. Not yet complete (absent from `completedIds`).\n * 2. Marked `optional` (`FlowNode.data.optional === true`).\n * 3. Not connected via a `'flow'`-type edge to any non-optional downstream node\n * (i.e. skipping it cannot starve a required node of a hard dependency).\n *\n * The runner may call this to present the user with a list of nodes they can bypass\n * without breaking the flow's required path.\n *\n * @param flow - The parsed flow definition.\n * @param completedIds - Set of node IDs that have already completed (excluded from results).\n * @returns Array of node IDs that are safe to skip at this point in the execution.\n * @docLink packages/flow-engine/concepts#compute-skippable\n */\nexport function computeSkippable(flow: FlowDefinition, completedIds: Set<string>): string[] {\n const nodes = activeRuntimeNodes(flow);\n const outgoing = buildOutgoing(flow.edges);\n\n return nodes\n .filter((n) => !completedIds.has(n.id))\n .filter(nodeIsOptional)\n .filter((n) => {\n // A node is skippable if none of its outgoing flow-type edges go to a required node\n const deps = (outgoing.get(n.id) ?? []).filter((e) => e.type === \"flow\");\n return deps.every((e) => {\n const target = flow.nodes.find((t) => t.id === e.target);\n return target ? nodeIsOptional(target) : false;\n });\n })\n .map((n) => n.id);\n}\n","import * as z from \"zod\";\nimport { collectFlowBindingExpressions, inspectFlowExpression } from \"../contract/expression.js\";\nimport type { FlowDefinition, FlowNode } from \"./types.js\";\n\n/** Result of validating fields at a producer's consumed-output boundary. */\nexport interface NodeOutputValidationResult {\n /** Whether the fields may be exposed to downstream consumers. */\n valid: boolean;\n /** Stable, path-bearing failures. Empty when validation is not required. */\n issues: string[];\n}\n\nfunction consumerExpressions(node: FlowNode): string[] {\n const expressions = (node.contract?.requires ?? []).map(({ expr }) => expr);\n expressions.push(...collectFlowBindingExpressions(node.contract?.input));\n if (node.run?.kind === \"router\") {\n expressions.push(...node.run.routes.map(({ when }) => when));\n }\n return expressions;\n}\n\nfunction readsProducerOutput(node: FlowNode, producerId: string): boolean {\n return consumerExpressions(node).some((expression) =>\n inspectFlowExpression(expression, false).some(({ path }) =>\n path.startsWith(`nodes.${producerId}.output.fields.`),\n ),\n );\n}\n\n/**\n * Return a producer's declared fields schema only when another node reads it.\n *\n * Consumption is deliberately limited to preconditions, named bindings, and\n * router conditions. Status reads and unreferenced declarations remain prose-only.\n */\nexport function getConsumedOutputSchema(\n flow: FlowDefinition,\n producerId: string,\n): Record<string, unknown> | undefined {\n const producer = flow.nodes.find(({ id }) => id === producerId);\n const schema = producer?.contract?.output?.fields;\n if (!schema) return undefined;\n return flow.nodes.some(\n (consumer) => consumer.id !== producerId && readsProducerOutput(consumer, producerId),\n )\n ? schema\n : undefined;\n}\n\n/** Validate proposed fields only when a downstream deterministic consumer requires them. */\nexport function validateConsumedNodeOutput(\n flow: FlowDefinition,\n producerId: string,\n fields: Record<string, unknown> | undefined,\n): NodeOutputValidationResult {\n const schema = getConsumedOutputSchema(flow, producerId);\n if (!schema) return { valid: true, issues: [] };\n\n try {\n const validator = z.fromJSONSchema(schema as Parameters<typeof z.fromJSONSchema>[0]);\n const parsed = validator.safeParse(fields ?? {});\n if (parsed.success) return { valid: true, issues: [] };\n return {\n valid: false,\n issues: parsed.error.issues\n .map((issue) => {\n const suffix = issue.path.map(String).join(\".\");\n return `fields${suffix ? `.${suffix}` : \"\"}: ${issue.message}`;\n })\n .sort(),\n };\n } catch (error) {\n return {\n valid: false,\n issues: [\n `fields: invalid authored JSON Schema: ${\n error instanceof Error ? error.message : String(error)\n }`,\n ],\n };\n }\n}\n","/**\n * Pure derived-deadline arithmetic for `control.timeoutSec`.\n *\n * \"Active execution only\" is the scope every node-timeout ruling shares: the\n * clock runs from `startedAt` but stops counting while the node was parked\n * for a human decision. Rather than persist a separate \"paused\" duration,\n * this module recomputes the deadline on demand from `startedAt` plus the\n * already-durable `approvalHistory` / `inputHistory` — so it is correct\n * immediately after `hydrate()` or a reconnect with no extra wiring, and a\n * live timer is never the source of truth.\n *\n * @docLink packages/flow-engine/concepts#node-deadline\n */\n\nimport type { NodeExecution } from \"@skaile/workspaces/types\";\n\n/** Milliseconds spent parked in a resolved approval/input wait since `sinceMs`. */\nfunction pausedIntervalMs(execution: NodeExecution, sinceMs: number): number {\n let total = 0;\n for (const approval of execution.approvalHistory) {\n const startMs = Date.parse(approval.requestedAt);\n if (!Number.isFinite(startMs) || startMs < sinceMs) continue;\n if (!approval.decidedAt) continue; // still open — status wouldn't be \"running\" here\n const endMs = Date.parse(approval.decidedAt);\n if (Number.isFinite(endMs) && endMs > startMs) total += endMs - startMs;\n }\n for (const input of execution.inputHistory) {\n const startMs = Date.parse(input.requestedAt);\n if (!Number.isFinite(startMs) || startMs < sinceMs) continue;\n if (!input.providedAt) continue;\n const endMs = Date.parse(input.providedAt);\n if (Number.isFinite(endMs) && endMs > startMs) total += endMs - startMs;\n }\n return total;\n}\n\n/**\n * Milliseconds remaining before `execution`'s active-execution deadline, given\n * `timeoutSec`. Negative once the deadline has passed. `undefined` when no\n * timeout applies — `timeoutSec` is unset, or the node has no `startedAt` to\n * measure from (e.g. it hasn't actually started).\n *\n * Active time is wall-clock since `startedAt` minus every *resolved*\n * approval/input interval recorded at or after that `startedAt` (an\n * interval opened before a retry's fresh `startedAt` never counts against\n * the new attempt; a still-open interval never counts because the node\n * would not be `running` while parked).\n *\n * @param execution - Current node snapshot. Only `startedAt`, `approvalHistory`,\n * and `inputHistory` are read.\n * @param timeoutSec - Authored `control.timeoutSec`, or `undefined` for no timeout.\n * @param nowMs - Caller-supplied wall clock (`Date.now()` in production, injectable\n * for tests).\n * @docLink packages/flow-engine/concepts#remaining-active-execution-ms\n */\nexport function remainingActiveExecutionMs(\n execution: NodeExecution,\n timeoutSec: number | undefined,\n nowMs: number,\n): number | undefined {\n if (timeoutSec === undefined || !execution.startedAt) return undefined;\n const startedAtMs = Date.parse(execution.startedAt);\n if (!Number.isFinite(startedAtMs)) return undefined;\n const pausedMs = pausedIntervalMs(execution, startedAtMs);\n const deadlineMs = startedAtMs + timeoutSec * 1000 + pausedMs;\n return deadlineMs - nowMs;\n}\n\n/**\n * Whether `execution` has exceeded its derived active-execution deadline.\n * `false` when no timeout applies. Convenience wrapper over\n * {@link remainingActiveExecutionMs} for call sites that only need the\n * boolean.\n *\n * @docLink packages/flow-engine/concepts#is-active-execution-expired\n */\nexport function isActiveExecutionExpired(\n execution: NodeExecution,\n timeoutSec: number | undefined,\n nowMs: number,\n): boolean {\n const remaining = remainingActiveExecutionMs(execution, timeoutSec, nowMs);\n return remaining !== undefined && remaining <= 0;\n}\n","/**\n * Pure bookkeeping for `NodeExecution.outputHistory` and the bounded\n * automatic-retry budget derived from `control.retries`.\n *\n * `retries: N` means the first attempt plus N automatic retries — so an\n * automatic retry remains available while fewer than N attempts have\n * already failed. The budget is derived from `outputHistory` itself (a\n * count of prior `'failed'` entries) rather than a separate durable\n * counter, so it composes for free with hydration and needs no new field.\n *\n * The manual `retryNode` operator override never pushes an entry here (it\n * only flips `status` back to `available`). The agent's own\n * `doFailNode(recoverable: true)` self-retry DOES push an entry — every\n * actual start closes out an attempt — but marks it `selfRetry` so\n * `countFailedAttempts` excludes it: neither self-retry nor the manual\n * override consumes the automatic budget this module tracks.\n *\n * @docLink packages/flow-engine/concepts#node-attempts\n */\n\nimport type {\n CheckEvidence,\n NodeError,\n NodeExecutionAttempt,\n NodeOutput,\n} from \"@skaile/workspaces/types\";\n\n/** Next 1-based attempt number given the attempts already recorded. */\nexport function nextAttemptNumber(history: NodeExecutionAttempt[] | undefined): number {\n if (!history || history.length === 0) return 1;\n return Math.max(...history.map((entry) => entry.attempt)) + 1;\n}\n\n/** Rarely-set trailing facts about one appended attempt. */\nexport interface AppendAttemptOptions {\n /** True for the agent's own `doFailNode(recoverable: true)` self-retry: the\n * entry still records a genuine start-to-failure attempt, but is excluded\n * from {@link countFailedAttempts} so it never consumes the automatic\n * `control.retries` budget. */\n selfRetry?: boolean;\n /** Derived check evidence, when this attempt belongs to a `check` node that\n * actually produced a verdict (pass or fail). Omit for every other node\n * kind and for a check's infrastructure failure, which produced no verdict\n * to attach. */\n check?: CheckEvidence;\n}\n\n/**\n * Appends one terminal attempt to `history`, numbered `max(attempt) + 1`.\n * Never mutates `history` — returns a fresh array so callers can assign it\n * straight onto a cloned `NodeExecution`.\n *\n * @param history - Existing attempt history, oldest first (or `undefined`).\n * @param result - True outcome of this attempt — independent of any\n * compatibility status degrade the caller applies separately (e.g. an\n * optional node's failed execution still records `'failed'` here even\n * though its `NodeExecution.status` becomes `'skipped'`).\n * @param startedAtIso - This attempt's actual start time.\n * @param completedAtIso - This attempt's terminal outcome time.\n * @param options - See {@link AppendAttemptOptions}. Both fields default to absent.\n * @docLink packages/flow-engine/concepts#append-attempt\n */\nexport function appendAttempt(\n history: NodeExecutionAttempt[] | undefined,\n result: NodeExecutionAttempt[\"result\"],\n startedAtIso: string,\n completedAtIso: string,\n output: NodeOutput | undefined,\n error: NodeError | undefined,\n options: AppendAttemptOptions = {},\n): NodeExecutionAttempt[] {\n const attempt: NodeExecutionAttempt = {\n attempt: nextAttemptNumber(history),\n result,\n startedAt: startedAtIso,\n completedAt: completedAtIso,\n ...(output !== undefined ? { output } : {}),\n ...(error !== undefined ? { error } : {}),\n ...(options.selfRetry ? { selfRetry: true } : {}),\n ...(options.check !== undefined ? { check: options.check } : {}),\n };\n return [...(history ?? []), attempt];\n}\n\n/**\n * Count of attempts in `history` whose true outcome was `'failed'`,\n * excluding self-retry entries (see {@link appendAttempt}) — this feeds only\n * the automatic-retry budget, which self-retry sits outside of.\n */\nexport function countFailedAttempts(history: NodeExecutionAttempt[] | undefined): number {\n if (!history) return 0;\n return history.filter((entry) => entry.result === \"failed\" && !entry.selfRetry).length;\n}\n\n/**\n * Whether an automatic retry remains, given how many attempts have already\n * failed and the authored `control.retries` budget. `retries: N` allows the\n * first attempt plus N automatic retries — so a retry remains available\n * while `priorFailedAttempts < N`. No `retries` (or `0`) means no automatic\n * retry ever.\n *\n * @docLink packages/flow-engine/concepts#has-automatic-retry-budget\n */\nexport function hasAutomaticRetryBudget(\n priorFailedAttempts: number,\n retries: number | undefined,\n): boolean {\n if (!retries) return false;\n return priorFailedAttempts < retries;\n}\n","/**\n * The single statement of the rule that decides an exhausted failure's\n * terminal status.\n *\n * Previously each terminal-failure write site restated the rule and only two\n * of them implemented it, so `control.optional` meant different things per\n * node kind. Every such site now routes through here.\n *\n * @docLink packages/flow-engine/concepts#optional-failure\n */\n\nimport { isRouterNode, nodeIsOptional } from \"./node-shape.js\";\nimport type { FlowNode } from \"./types.js\";\n\n/**\n * Terminal status for a node whose execution failed with no retry budget left.\n *\n * Invariant: an optional node never ends terminally `failed`. Only `complete`\n * and `skipped` satisfy a hard `flow` edge (see `isBlocking`), so leaving one\n * `failed` stalls every dependent at the node the author called expendable.\n *\n * A router is the deliberate exception: a `skipped` router leaves the gated\n * set (`unsettledRouterBranchIds`) while satisfying every outgoing hard edge,\n * so skipping it admits *all* of its branches instead of selecting one.\n */\nexport function resolveTerminalFailureStatus(node: FlowNode): \"failed\" | \"skipped\" {\n return nodeIsOptional(node) && !isRouterNode(node) ? \"skipped\" : \"failed\";\n}\n","/**\n * Pure derivation of a `check` node's evidence payload — what was compared,\n * where each value came from, and whether that makes the verdict\n * runtime-`\"verified\"` or agent-`\"asserted\"`.\n *\n * Ruling: re-running a check is not required to reproduce the same answer,\n * so there is no snapshot materialization, no hashing, and no reproducibility\n * guarantee here — this module records integrity of *what was observed*, not\n * a promise that observing it again would agree. Provenance is derived\n * exclusively from {@link BindingOrigin.obtainedBy}, the flow engine's\n * existing (and only) provenance mechanism, so it can never be influenced by\n * how a flow author names a binding. That label is transitive before it\n * arrives here — a deterministic node that carries an agent's value forward\n * stays agent-obtained — so this module compares origins as given and makes\n * no one-hop caveat.\n *\n * The claim is that provenance cannot be asserted by flow *configuration*.\n * It is not a claim against a caller holding the read-write connector handle:\n * taint now derives from persisted `NodeExecution.inputOrigins`, which the\n * `hydrate` op writes verbatim. Such a caller could already forge `output`\n * itself, so this widens no existing trust boundary.\n *\n * No I/O and no clock: `observedAt` is supplied by the caller so this stays\n * trivially testable and replayable.\n *\n * @docLink packages/flow-engine/concepts#check-provenance\n */\n\nimport type {\n BindingOrigin,\n CheckComparedValue,\n CheckEvidence,\n CheckInputCurrency,\n CheckProvenance,\n} from \"@skaile/workspaces/types\";\nimport type { ResolvedNodeBindings } from \"../contract/expression.js\";\n\n/** The check's process facts, captured alongside its verdict so a persisted attempt is self-describing. */\nexport interface CheckProcessRecord {\n runtime: \"shell\" | \"node\" | \"python\";\n command: string;\n cwd?: string;\n successExit: number[];\n exitStatus: number;\n passed: boolean;\n}\n\nconst FLOW_LOCAL_SOURCES = new Set<BindingOrigin[\"source\"]>([\"literal\", \"default\", \"flow-input\"]);\n\n/**\n * Derive one check's evidence from its already-resolved bindings and its\n * process outcome. `provenance` and `inputs` are computed only from\n * `bindings.origins` — never from `bindings.values` or their names — so\n * authoring a binding literally named `provenance` or `verified` cannot\n * influence the verdict.\n *\n * `provenance` is `\"verified\"` iff every origin of every compared value has\n * `obtainedBy: \"runtime\"`, `\"asserted\"` if any does not, and **absent** when\n * there are no compared values — neither label is honest about an empty set.\n * `obtainedBy` is already transitive when it reaches here (see\n * `producerOutputObtainedBy`), so `\"verified\"` means no agent-produced value\n * contributed anywhere in the ancestry, not merely one hop back.\n * `inputs` is `\"live\"` — the floor for any check that runs a process —\n * unless there is at least one compared value and every one of them has\n * origins that are all `literal`/`default`/`flow-input`, in which case it is\n * `\"flow-local\"`.\n */\nexport function deriveCheckEvidence(\n bindings: ResolvedNodeBindings,\n process: CheckProcessRecord,\n observedAt: string,\n): CheckEvidence {\n const values: CheckComparedValue[] = Object.entries(bindings.values).map(([name, value]) => {\n const origins = bindings.origins[name] ?? [];\n const obtainedBy = origins.some((origin) => origin.obtainedBy === \"agent\")\n ? \"agent\"\n : \"runtime\";\n return { name, value, origins, obtainedBy };\n });\n const provenance: CheckProvenance | undefined =\n values.length === 0\n ? undefined\n : values.every((compared) => compared.obtainedBy === \"runtime\")\n ? \"verified\"\n : \"asserted\";\n const inputs: CheckInputCurrency =\n values.length > 0 &&\n values.every((compared) =>\n compared.origins.every((origin) => FLOW_LOCAL_SOURCES.has(origin.source)),\n )\n ? \"flow-local\"\n : \"live\";\n return {\n values,\n ...(provenance !== undefined ? { provenance } : {}),\n inputs,\n observedAt,\n ...process,\n };\n}\n","/**\n * Flow manifest schema and validation.\n *\n * Moved from @skaile/workspaces/types/manifests/flow.ts in Phase 1.7.3.\n * This is now the canonical location for flow manifest validation.\n */\n\nimport * as z from \"zod\";\n\n// ---------------------------------------------------------------------------\n// Validation result (inline — avoids importing from types/manifests/_shared)\n// ---------------------------------------------------------------------------\n\nexport interface ManifestValidationSuccess<T> {\n ok: true;\n data: T;\n}\n\nexport interface ManifestValidationFailure {\n ok: false;\n errors: Array<{ path: string; message: string }>;\n}\n\nexport type ManifestValidationResult<T> = ManifestValidationSuccess<T> | ManifestValidationFailure;\n\n// ---------------------------------------------------------------------------\n// Schema\n// ---------------------------------------------------------------------------\n\nconst FlowNodeSchema = z.looseObject({\n id: z.string().min(1),\n skill: z.string().optional(),\n type: z.string().optional(),\n label: z.string().optional(),\n description: z.string().optional(),\n data: z\n .looseObject({\n optional: z.boolean().optional(),\n // Mandatory approval gate — autonomous mode cannot skip it.\n approval: z.looseObject({ mandatory: z.boolean().optional() }).optional(),\n })\n .refine((d) => !(d.optional === true && d.approval?.mandatory === true), {\n // A mandatory gate can never be skipped, so optional+mandatory is a\n // contradiction — reject it rather than silently letting mandatory win.\n message: \"a node cannot be both optional and a mandatory approval gate\",\n })\n .optional(),\n});\n\nconst FlowEdgeSchema = z.looseObject({\n id: z.string().optional(),\n source: z.string().min(1),\n target: z.string().min(1),\n condition: z.string().optional(),\n});\n\nexport const FlowManifestSchema = z.looseObject({\n id: z.string().min(1),\n version: z.string().optional(),\n name: z.string().min(1),\n description: z.string().optional(),\n metadata: z\n .looseObject({\n tags: z.array(z.string()).optional(),\n stage: z.string().optional(),\n icon: z.string().optional(),\n category: z.string().optional(),\n onboarding: z.record(z.string(), z.unknown()).optional(),\n })\n .optional(),\n globals: z.record(z.string(), z.unknown()).optional(),\n modes: z.record(z.string(), z.unknown()).optional(),\n tier_presets: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),\n artifact_handoff: z.unknown().optional(),\n entry: z.string().optional(),\n nodes: z.array(FlowNodeSchema).optional(),\n edges: z.array(FlowEdgeSchema).optional(),\n});\n\nexport type FlowManifest = z.infer<typeof FlowManifestSchema>;\n\n// ---------------------------------------------------------------------------\n// Validation\n// ---------------------------------------------------------------------------\n\nexport function validateFlow(data: unknown): ManifestValidationResult<FlowManifest> {\n const result = FlowManifestSchema.safeParse(data);\n if (result.success) {\n return { ok: true, data: result.data };\n }\n return {\n ok: false,\n errors: result.error.issues.map((issue) => ({\n path: issue.path.join(\".\"),\n message: issue.message,\n })),\n };\n}\n","/**\n * Flow asset kind provider.\n *\n * Exported from @skaile/workspaces/factory-assets/connectors/flow/engine for explicit registration\n * by the CLI at bootstrap. Discovery does NOT auto-include this provider\n * (discovery must stay a leaf — no flow-engine imports).\n *\n * Implements IAssetKindProvider with flow-specific:\n * - Discovery patterns: *.flow.yaml, *.flow.json\n * - Manifest validation via FlowManifestSchema\n * - Requires extraction: nodes[].run.assets plus legacy skill/sub-flow references\n * - File filter: just the manifest file (flows are single-file)\n */\n\nimport * as path from \"node:path\";\nimport type {\n AssetKindFileFilter,\n AssetKindRequiresEdge,\n IAssetKindProvider,\n} from \"@skaile/workspaces/plugins\";\nimport { validateFlow } from \"./flow-manifest.js\";\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\nexport const flowKindProvider: IAssetKindProvider = {\n kind: \"flow\",\n displayName: \"Flow\",\n providerVersion: \"1.1.0\",\n discoveryPatterns: [\"**/*.flow.yaml\", \"**/*.flow.json\"],\n\n matchesPath(relativePath: string): boolean {\n return relativePath.endsWith(\".flow.yaml\") || relativePath.endsWith(\".flow.json\");\n },\n\n validateManifest(data: unknown) {\n return validateFlow(data);\n },\n\n defaultFileFilter(manifestPath: string): AssetKindFileFilter {\n return {\n assetRoot: path.dirname(manifestPath),\n files: [path.basename(manifestPath)],\n };\n },\n\n extractRequires(assetRef: string, manifest: Record<string, unknown>): AssetKindRequiresEdge[] {\n const edges: AssetKindRequiresEdge[] = [];\n const seen = new Set<string>();\n const add = (to: string, field: string): void => {\n if (seen.has(to)) return;\n seen.add(to);\n edges.push({ from: assetRef, to, field });\n };\n\n const nodes = manifest.nodes;\n if (Array.isArray(nodes)) {\n for (const node of nodes) {\n if (typeof node !== \"object\" || node === null) continue;\n const n = node as Record<string, unknown>;\n const data = (\n typeof n.data === \"object\" && n.data !== null ? (n.data as Record<string, unknown>) : {}\n ) as Record<string, unknown>;\n const run =\n typeof n.run === \"object\" && n.run !== null ? (n.run as Record<string, unknown>) : {};\n\n if (Array.isArray(run.assets)) {\n for (const asset of run.assets) {\n if (typeof asset === \"string\") add(asset, \"nodes[].run.assets\");\n }\n }\n\n if (run.kind === \"sub-flow\" && typeof run.flow === \"string\") {\n const flowRef = run.flow.startsWith(\"flow:\") ? run.flow : `flow:${run.flow}`;\n add(flowRef, \"nodes[].run.flow\");\n }\n\n const skill = typeof data.skill === \"string\" ? data.skill : n.skill;\n if (typeof skill === \"string\") {\n add(skill, \"nodes[].data.skill\");\n }\n\n const subFlow = typeof data.flow === \"string\" ? data.flow : n.flow;\n if (typeof subFlow === \"string\") {\n add(subFlow.startsWith(\"flow:\") ? subFlow : `flow:${subFlow}`, \"nodes[].data.flow\");\n }\n }\n }\n\n return edges;\n },\n};\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { assetSearchDirs } from \"@skaile/workspaces/core\";\nimport { parse as parseYaml } from \"yaml\";\nimport { parseFlowDefinition } from \"../contract/normalize.js\";\nimport type { FlowDefinition } from \"./types.js\";\n\n/**\n * Load a single {@link FlowDefinition} from a YAML or JSON file on disk.\n *\n * Format detection is based on file extension:\n * - `.yaml` / `.yml` — parsed with the `yaml` library.\n * - Everything else — parsed as JSON.\n *\n * @param filePath - Absolute path to the flow file.\n * @returns The parsed {@link FlowDefinition}.\n * @throws {Error} If the file does not exist, cannot be read, or fails to parse.\n * @docLink packages/flow-engine/concepts#flow-loading\n */\nexport function loadFlow(filePath: string): FlowDefinition {\n const raw = fs.readFileSync(filePath, \"utf-8\");\n const ext = path.extname(filePath).toLowerCase();\n const authored = ext === \".yaml\" || ext === \".yml\" ? parseYaml(raw) : JSON.parse(raw);\n const parsed = parseFlowDefinition(authored);\n if (!parsed.ok) {\n const details = parsed.errors\n .map((issue) => ` ${issue.path || \"<root>\"}: ${issue.message}`)\n .join(\"\\n\");\n throw new Error(`Invalid flow definition:\\n${details}`);\n }\n return parsed.data;\n}\n\n/**\n * Load all `*.flow.yaml` and legacy `*.flow.json` / `*.json` flow files from a directory.\n *\n * Files that fail to parse are skipped with a warning written to `stderr` — they do not\n * cause the function to throw. Files whose name starts with `_` are skipped entirely\n * (treated as drafts or disabled flows). Files missing the required `id`, `nodes`, or\n * `edges` fields are also discarded silently.\n *\n * @param dirPath - Absolute path to the directory to scan.\n * @returns Array of successfully parsed {@link FlowDefinition} objects. Empty if the\n * directory does not exist or contains no valid flow files.\n * @docLink packages/flow-engine/concepts#flow-loading\n */\nexport function loadFlowsFromDir(dirPath: string): FlowDefinition[] {\n if (!fs.existsSync(dirPath)) return [];\n\n const files = fs.readdirSync(dirPath).filter((f) => {\n if (f.startsWith(\"_\")) return false;\n return f.endsWith(\".flow.yaml\") || f.endsWith(\".flow.json\") || f.endsWith(\".json\");\n });\n\n const flows: FlowDefinition[] = [];\n\n for (const file of files) {\n try {\n const def = loadFlow(path.join(dirPath, file));\n if (def.id && def.nodes && def.edges) {\n flows.push(def);\n }\n } catch (err) {\n process.stderr.write(`[agent-flow-engine] skipping ${file}: ${(err as Error).message}\\n`);\n }\n }\n\n return flows;\n}\n\n/**\n * Discover and load all flow definitions from every domain under an `ai-assets` root.\n *\n * Walks the top-level subdirectories of `aiResourcesRoot`, looks for a `flows/`\n * subdirectory inside each domain, and delegates to {@link loadFlowsFromDir} for\n * each one found. Files prefixed with `_` are skipped (draft/disabled).\n *\n * @param aiResourcesRoot - Absolute path to the `ai-assets/` directory (or equivalent\n * resource root). Typically the `ai-assets/` folder at the monorepo root.\n * @returns Flat array of all successfully parsed {@link FlowDefinition} objects across\n * all domains. Empty if the root directory does not exist.\n * @docLink packages/flow-engine/concepts#flow-loading\n */\nexport function loadAllFlows(aiResourcesRoot: string): FlowDefinition[] {\n if (!fs.existsSync(aiResourcesRoot)) return [];\n\n // `assetSearchDirs` covers both the flat (`<root>/flows/`) and domain-nested\n // (`<root>/<domain>/flows/`) layouts via the one shared layout primitive.\n // De-dupe by id (first dir wins) so a root that happens to define a flow in\n // both layouts surfaces it once.\n const byId = new Map<string, FlowDefinition>();\n for (const { dir } of assetSearchDirs(aiResourcesRoot, \"flows\")) {\n for (const flow of loadFlowsFromDir(dir)) {\n if (!byId.has(flow.id)) byId.set(flow.id, flow);\n }\n }\n return [...byId.values()];\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../factory-assets/connectors/flow/engine/node-shape.ts"],"names":[],"mappings":";AAGO,SAAS,YAAY,IAAA,EAAyB;AACnD,EAAA,OAAO,IAAA,CAAK,IAAA,KAAS,OAAA,IAAW,IAAA,CAAK,KAAK,IAAA,KAAS,OAAA;AACrD;AAGO,SAAS,eACd,IAAA,EACyF;AACzF,EAAA,OAAO,IAAA,CAAK,KAAK,IAAA,KAAS,UAAA;AAC5B;AAGO,SAAS,YACd,IAAA,EACsF;AACtF,EAAA,OAAO,IAAA,CAAK,KAAK,IAAA,KAAS,OAAA;AAC5B;AAGO,SAAS,gBACd,IAAA,EAC0F;AAC1F,EAAA,OAAO,IAAA,CAAK,KAAK,IAAA,KAAS,WAAA;AAC5B;AAGO,SAAS,2BAA2B,IAAA,EAAoC;AAC7E,EAAA,OAAO,IAAA,KAAS,UAAU,OAAA,GAAU,UAAA;AACtC;AAGO,SAAS,WACd,IAAA,EACqF;AACrF,EAAA,OAAO,IAAA,CAAK,KAAK,IAAA,KAAS,MAAA;AAC5B;AAGO,SAAS,aACd,IAAA,EACuF;AACvF,EAAA,OAAO,IAAA,CAAK,KAAK,IAAA,KAAS,QAAA;AAC5B;AAGO,SAAS,cACd,IAAA,EACyF;AACzF,EAAA,OAAO,IAAA,CAAK,KAAK,IAAA,KAAS,UAAA;AAC5B;AAGO,SAAS,oBA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A,CAAK,MAAA,CAAO,OAAO,CAAC,KAAA,KAA2B,OAAO,KAAA,KAAU,QAAQ,IAC7E,EAAC;AACL,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,IAAA,KAAS,OAAA,IAAW,IAAA,CAAK,IAAA,EAAM,KAAA,GAAQ,CAAA,MAAA,EAAS,IAAA,CAAK,IAAA,CAAK,KAAK,CAAA,CAAA,GAAK,MAAA;AACvF,EAAA,OAAO,KAAA,GAAQ,CAAC,KAAA,EAAO,GAAG,YAAY,CAAA,GAAI,YAAA;AAC5C;AAGO,SAAS,aAAa,IAAA,EAAyC;AACpE,EAAA,IAAI,IAAA,CAAK,QAAA,EAAU,KAAA,EAAO,OAAO,KAAK,QAAA,CAAS,KAAA;AAC/C,EAAA,OAAO,IAAA,CAAK,IAAA,EAAM,UAAA,IAAc,EAAC;AACnC;AAGO,SAAS,gBAAgB,IAAA,EAAoC;AAClE,EAAA,OAAO,IAAA,CAAK,GAAA,EAAK,IAAA,KAAS,OAAA,IAAW,IAAA,CAAK,KAAK,IAAA,KAAS,WAAA,GACpD,IAAA,CAAK,GAAA,CAAI,WAAA,GACT,MAAA;AACN;AAGO,SAAS,aAAa,IAAA,EAA+C;AAC1E,EAAA,OAAO,IAAA,CAAK,QAAA,IAAY,IAAA,CAAK,OAAA,IAAW,EAAC;AAC3C","file":"chunk-F5VREBV2.js","sourcesContent":["import type { FlowDefinition, FlowNode } from \"./types.js\";\n\n/** Returns whether a node is executable by the currently active agent-turn runtime. */\nexport function isAgentNode(node: FlowNode): boolean {\n return node.type === \"skill\" || node.run?.kind === \"agent\";\n}\n\n/** Returns whether a node executes deterministically through NodeExecutor. */\nexport function isFunctionNode(\n node: FlowNode,\n): node is FlowNode & { run: Extract<NonNullable<FlowNode[\"run\"]>, { kind: \"function\" }> } {\n return node.run?.kind === \"function\";\n}\n\n/** Returns whether a node is a deterministic pass/fail verdict evaluated by the runtime. */\nexport function isCheckNode(\n node: FlowNode,\n): node is FlowNode & { run: Extract<NonNullable<FlowNode[\"run\"]>, { kind: \"check\" }> } {\n return node.run?.kind === \"check\";\n}\n\n/** Returns whether a node is a runtime-owned, isolated model call evaluated outside the session conversation. */\nexport function isSubpromptNode(\n node: FlowNode,\n): node is FlowNode & { run: Extract<NonNullable<FlowNode[\"run\"]>, { kind: \"subprompt\" }> } {\n return node.run?.kind === \"subprompt\";\n}\n\n/** Capitalized label for error/summary text — shared by every deterministic-node message site. */\nexport function deterministicNodeKindLabel(kind: \"function\" | \"check\"): string {\n return kind === \"check\" ? \"Check\" : \"Function\";\n}\n\n/** Returns whether a node is a runtime-owned human decision point. */\nexport function isGateNode(\n node: FlowNode,\n): node is FlowNode & { run: Extract<NonNullable<FlowNode[\"run\"]>, { kind: \"gate\" }> } {\n return node.run?.kind === \"gate\";\n}\n\n/** Returns whether a node deterministically selects one declared branch in the engine. */\nexport function isRouterNode(\n node: FlowNode,\n): node is FlowNode & { run: Extract<NonNullable<FlowNode[\"run\"]>, { kind: \"router\" }> } {\n return node.run?.kind === \"router\";\n}\n\n/** Returns whether a node delegates once to an inline child flow. */\nexport function isSubFlowNode(\n node: FlowNode,\n): node is FlowNode & { run: Extract<NonNullable<FlowNode[\"run\"]>, { kind: \"sub-flow\" }> } {\n return node.run?.kind === \"sub-flow\";\n}\n\n/** Returns whether the current runtime owns the node's execution state. */\nexport function isActiveRuntimeNode(node: FlowNode): boolean {\n return (\n isAgentNode(node) ||\n isFunctionNode(node) ||\n isCheckNode(node) ||\n isSubpromptNode(node) ||\n isGateNode(node) ||\n isRouterNode(node) ||\n isSubFlowNode(node)\n );\n}\n\n/** @deprecated Use {@link isActiveRuntimeNode}; gates are active but nobody executes them. */\nexport const isExecutableNode = isActiveRuntimeNode;\n\n/** Returns the node's optional policy across strict v2 and legacy definitions. */\nexport function nodeIsOptional(node: FlowNode): boolean {\n return node.control?.optional ?? node.data?.optional ?? false;\n}\n\n/** Returns the node's mandatory approval policy across strict v2 and legacy definitions. */\nexport function nodeRequiresApproval(node: FlowNode): boolean {\n return node.gate?.approval === \"mandatory\" || node.data?.approval?.mandatory === true;\n}\n\n/** Returns the first declared skill requirement without making it the node identity. */\nexport function nodeSkillId(node: FlowNode): string {\n if (node.type === \"skill\") return node.data?.skill ?? node.id;\n const skillAsset = node.run?.assets?.find((asset) => asset.startsWith(\"skill:\"));\n return skillAsset?.slice(\"skill:\".length).replace(/#.*$/, \"\") ?? node.id;\n}\n\n/** Returns the user-facing node label across strict v2 and legacy definitions. */\nexport function nodeLabel(node: FlowNode): string {\n return node.label ?? node.data?.label ?? nodeSkillId(node);\n}\n\n/** Returns strict v2 run assets or the equivalent legacy declarations. */\nexport function nodeAssets(node: FlowNode): string[] {\n if (node.run?.assets) return node.run.assets;\n const legacyAssets = Array.isArray(node.data?.assets)\n ? node.data.assets.filter((asset): asset is string => typeof asset === \"string\")\n : [];\n const skill = node.type === \"skill\" && node.data?.skill ? `skill:${node.data.skill}` : undefined;\n return skill ? [skill, ...legacyAssets] : legacyAssets;\n}\n\n/** Returns the binding values already supplied at the node boundary. */\nexport function nodeBindings(node: FlowNode): Record<string, unknown> {\n if (node.contract?.input) return node.contract.input;\n return node.data?.parameters ?? {};\n}\n\n/** Returns the first-class instruction for a strict v2 agent or subprompt node. */\nexport function nodeInstruction(node: FlowNode): string | undefined {\n return node.run?.kind === \"agent\" || node.run?.kind === \"subprompt\"\n ? node.run.instruction\n : undefined;\n}\n\n/** Returns run-scoped defaults across strict v2 and legacy definitions. */\nexport function flowDefaults(flow: FlowDefinition): Record<string, unknown> {\n return flow.defaults ?? flow.globals ?? {};\n}\n"]}