@skaile/workspaces 1.9.0 → 1.10.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 (118) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/dist/{asset-feeds-SS336LXB.js → asset-feeds-FMV3SJVQ.js} +4 -4
  3. package/dist/{asset-feeds-SS336LXB.js.map → asset-feeds-FMV3SJVQ.js.map} +1 -1
  4. package/dist/asset-manager/index.js +1 -1
  5. package/dist/bridge/drivers/claude-sdk.js +1 -1
  6. package/dist/bridge/drivers/codex.js +1 -1
  7. package/dist/bridge/drivers/continue.js +2 -2
  8. package/dist/bridge/drivers/echo.js +201 -1
  9. package/dist/bridge/drivers/echo.js.map +1 -1
  10. package/dist/bridge/drivers/gemini.js +3 -3
  11. package/dist/bridge/drivers/goose.js +2 -2
  12. package/dist/bridge/drivers/omp.js +1 -1
  13. package/dist/bridge/drivers/opencode.js +2 -2
  14. package/dist/bridge/drivers/qwen.js +3 -3
  15. package/dist/bridge/index.js +2 -2
  16. package/dist/bridge/src/drivers/echo.d.ts +16 -0
  17. package/dist/bridge/src/drivers/echo.d.ts.map +1 -1
  18. package/dist/bridge/src/drivers/flow-script.d.ts +129 -0
  19. package/dist/bridge/src/drivers/flow-script.d.ts.map +1 -0
  20. package/dist/bridge/src/types.d.ts +32 -1
  21. package/dist/bridge/src/types.d.ts.map +1 -1
  22. package/dist/{chunk-4DFBHEXQ.js → chunk-2257NSNY.js} +96 -17
  23. package/dist/chunk-2257NSNY.js.map +1 -0
  24. package/dist/{chunk-MWZGGCMF.js → chunk-2ZP6KIIQ.js} +2 -2
  25. package/dist/{chunk-MWZGGCMF.js.map → chunk-2ZP6KIIQ.js.map} +1 -1
  26. package/dist/{chunk-NKTFEV7Q.js → chunk-6XQ5QG63.js} +4 -4
  27. package/dist/{chunk-NKTFEV7Q.js.map → chunk-6XQ5QG63.js.map} +1 -1
  28. package/dist/{chunk-TNSCHS4I.js → chunk-APHTT5GE.js} +2 -2
  29. package/dist/{chunk-TNSCHS4I.js.map → chunk-APHTT5GE.js.map} +1 -1
  30. package/dist/{chunk-UNJGSISX.js → chunk-DEBMR6MK.js} +3 -3
  31. package/dist/{chunk-UNJGSISX.js.map → chunk-DEBMR6MK.js.map} +1 -1
  32. package/dist/{chunk-UQ5FK2AB.js → chunk-FRD4NU3W.js} +3 -3
  33. package/dist/{chunk-UQ5FK2AB.js.map → chunk-FRD4NU3W.js.map} +1 -1
  34. package/dist/{chunk-GKPUN2YQ.js → chunk-GEZMBQ3R.js} +3 -3
  35. package/dist/{chunk-GKPUN2YQ.js.map → chunk-GEZMBQ3R.js.map} +1 -1
  36. package/dist/{chunk-TJNEKDWS.js → chunk-IFCHOBEF.js} +6 -6
  37. package/dist/{chunk-TJNEKDWS.js.map → chunk-IFCHOBEF.js.map} +1 -1
  38. package/dist/{chunk-HKX5VSWQ.js → chunk-LVQO4X4U.js} +3 -3
  39. package/dist/{chunk-HKX5VSWQ.js.map → chunk-LVQO4X4U.js.map} +1 -1
  40. package/dist/{chunk-QY47VHNI.js → chunk-PU3FGN4T.js} +2 -2
  41. package/dist/{chunk-QY47VHNI.js.map → chunk-PU3FGN4T.js.map} +1 -1
  42. package/dist/{chunk-OMBYBUOF.js → chunk-SMWXVW6Z.js} +3 -3
  43. package/dist/{chunk-OMBYBUOF.js.map → chunk-SMWXVW6Z.js.map} +1 -1
  44. package/dist/{chunk-R5UMZEBH.js → chunk-TR6E5JOF.js} +6 -6
  45. package/dist/{chunk-R5UMZEBH.js.map → chunk-TR6E5JOF.js.map} +1 -1
  46. package/dist/{chunk-DTZ7JUZY.js → chunk-YNEJXDCZ.js} +250 -195
  47. package/dist/chunk-YNEJXDCZ.js.map +1 -0
  48. package/dist/{chunk-5DC744E3.js → chunk-ZDRAMXBS.js} +3 -3
  49. package/dist/{chunk-5DC744E3.js.map → chunk-ZDRAMXBS.js.map} +1 -1
  50. package/dist/cli/index.js +27 -27
  51. package/dist/connectors/index.js +1 -1
  52. package/dist/connectors/src/connector-prompt.d.ts +23 -0
  53. package/dist/connectors/src/connector-prompt.d.ts.map +1 -1
  54. package/dist/connectors/src/credential-helper-script.d.ts +8 -5
  55. package/dist/connectors/src/credential-helper-script.d.ts.map +1 -1
  56. package/dist/connectors/src/index.d.ts +1 -1
  57. package/dist/connectors/src/index.d.ts.map +1 -1
  58. package/dist/connectors/src/managed-gitconfig.d.ts +4 -2
  59. package/dist/connectors/src/managed-gitconfig.d.ts.map +1 -1
  60. package/dist/{ensure-sources-ELLWRQAT.js → ensure-sources-OJ5GIRZF.js} +4 -4
  61. package/dist/{ensure-sources-ELLWRQAT.js.map → ensure-sources-OJ5GIRZF.js.map} +1 -1
  62. package/dist/factory-assets/connectors/box.js +1 -1
  63. package/dist/factory-assets/connectors/deploy.js +1 -1
  64. package/dist/factory-assets/connectors/devserver.js +1 -1
  65. package/dist/factory-assets/connectors/flow/adapter.js +1 -1
  66. package/dist/factory-assets/connectors/flow/run-flow.js +2 -2
  67. package/dist/factory-assets/connectors/flow.js +1 -1
  68. package/dist/factory-assets/connectors/git/driver.d.ts.map +1 -1
  69. package/dist/factory-assets/connectors/git.js +1 -1
  70. package/dist/factory-assets/connectors/gmail.js +1 -1
  71. package/dist/factory-assets/connectors/googledrive.js +1 -1
  72. package/dist/factory-assets/connectors/local.js +1 -1
  73. package/dist/factory-assets/connectors/mattermost.js +1 -1
  74. package/dist/factory-assets/connectors/memory.js +1 -1
  75. package/dist/factory-assets/connectors/minio.js +1 -1
  76. package/dist/factory-assets/connectors/postgres.js +1 -1
  77. package/dist/factory-assets/connectors/s3.js +1 -1
  78. package/dist/factory-assets/connectors/sharepoint.js +1 -1
  79. package/dist/factory-assets/connectors/sqlite.js +1 -1
  80. package/dist/factory-assets/connectors/static-server.js +1 -1
  81. package/dist/factory-assets/connectors/tunnel.js +1 -1
  82. package/dist/factory-assets/connectors/webdav.js +1 -1
  83. package/dist/factory-assets/connectors/xstate-store.js +1 -1
  84. package/dist/factory-assets/connectors/xstate.js +1 -1
  85. package/dist/{helpers-7Y4DTFR6.js → helpers-PS37RNFV.js} +4 -4
  86. package/dist/{helpers-7Y4DTFR6.js.map → helpers-PS37RNFV.js.map} +1 -1
  87. package/dist/{library-publish-7AH63NKA.js → library-publish-CRG7JLDZ.js} +6 -6
  88. package/dist/{library-publish-7AH63NKA.js.map → library-publish-CRG7JLDZ.js.map} +1 -1
  89. package/dist/{open-library-J2PRSM3J.js → open-library-5SRCSBSY.js} +5 -5
  90. package/dist/{open-library-J2PRSM3J.js.map → open-library-5SRCSBSY.js.map} +1 -1
  91. package/dist/{project-CSNHUQFK.js → project-SM2VMQOZ.js} +5 -5
  92. package/dist/{project-CSNHUQFK.js.map → project-SM2VMQOZ.js.map} +1 -1
  93. package/dist/run-group-engine/index.js.map +1 -1
  94. package/dist/run-group-engine/src/rollup.d.ts +5 -3
  95. package/dist/run-group-engine/src/rollup.d.ts.map +1 -1
  96. package/dist/runner/index.js +5 -5
  97. package/dist/runner/src/serve.d.ts.map +1 -1
  98. package/dist/runner/src/session-capability-wiring.d.ts +49 -0
  99. package/dist/runner/src/session-capability-wiring.d.ts.map +1 -0
  100. package/dist/runner/src/session-resource-handlers.d.ts +1 -2
  101. package/dist/runner/src/session-resource-handlers.d.ts.map +1 -1
  102. package/dist/sdk/asset-manager.js +1 -1
  103. package/dist/sdk/bridge.js +2 -2
  104. package/dist/sdk/index.js +5 -5
  105. package/dist/sdk/runner.js +5 -5
  106. package/dist/{setup-ETGRXSZG.js → setup-H3WCLOEH.js} +4 -4
  107. package/dist/{setup-ETGRXSZG.js.map → setup-H3WCLOEH.js.map} +1 -1
  108. package/dist/{source-4YG45QO6.js → source-Y7ZTBG2U.js} +6 -6
  109. package/dist/{source-4YG45QO6.js.map → source-Y7ZTBG2U.js.map} +1 -1
  110. package/dist/{source-manifest-publish-RFU4YBC6.js → source-manifest-publish-SXJ6LF4S.js} +7 -7
  111. package/dist/{source-manifest-publish-RFU4YBC6.js.map → source-manifest-publish-SXJ6LF4S.js.map} +1 -1
  112. package/dist/tui/index.js +5 -5
  113. package/dist/types/src/run-group.d.ts +2 -2
  114. package/dist/types/src/run-group.d.ts.map +1 -1
  115. package/dist/workspace-plugin/index.js +1 -1
  116. package/package.json +1 -1
  117. package/dist/chunk-4DFBHEXQ.js.map +0 -1
  118. package/dist/chunk-DTZ7JUZY.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,86 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#400](https://github.com/skaile-ai/workspaces/pull/400) [`cdda9fc`](https://github.com/skaile-ai/workspaces/commit/cdda9fc9501d6e1381943c45a17a2031ddc401ea) Thanks [@peteralbert](https://github.com/peteralbert)! - Fix claude-sdk flow integration so real-agent flow runs work end-to-end
8
+ (workspaces#399). Three gaps closed:
9
+
10
+ 1. **`op:start` now kicks the first turn.** The `create-start` connector_mutate
11
+ branch called `createActiveFlow` and returned without waking the agent —
12
+ `connect()` seeds state but never mutates, so nothing signaled the stimulus
13
+ bus. It now signals a `flow_started` stimulus, so `driveTurn` reassembles the
14
+ `# Flow Execution Context` orchestrator prompt and drives turn 1 for every
15
+ driver (fire-and-forget, so the mutate ack doesn't block on a long/gated
16
+ turn). This is the contract's "emit initial state, kick first turn".
17
+
18
+ 2. **Flow-adapter agent tools are now callable by the claude-sdk agent.** New
19
+ `buildSdkFlowTools` exposes the flow connector's agent operations
20
+ (`start_node`, `complete_node`, `request_approval`, `request_input`,
21
+ `skip_node`, `fail_node`, plus the read ops) as first-class MCP tools
22
+ (`mcp__skaile-flow__<op>`), injected in `createActiveFlow`. Previously the
23
+ generic connector server emitted no per-op tools and omitted `connector_exec`
24
+ under shell access, so the agent could not discover or invoke the tools the
25
+ orchestrator prompt told it to call. Host-only ops (`applyApproval`,
26
+ `cancel`, `start`, …) are intentionally excluded.
27
+
28
+ 3. **Orchestrator prompt is injected on flow turns.** Follows from (1): the
29
+ start turn and every host/user-message-driven turn now go through
30
+ `buildOrchestratorPrompt` instead of a plain chat prompt.
31
+
32
+ No protocol/envelope/flow-contract change. Hosts consume this by bumping
33
+ `@skaile/workspaces`; `op:start` now emitting an initial `state_changed` and
34
+ kicking a turn is additive (idempotent latest-wins persistence) and does not
35
+ affect the eager-persist or start-then-hydrate paths.
36
+
37
+ - [#398](https://github.com/skaile-ai/workspaces/pull/398) [`2b95465`](https://github.com/skaile-ai/workspaces/commit/2b9546558968d5d60f79096b0c3a9f80f856fd5e) Thanks [@peteralbert](https://github.com/peteralbert)! - Add a deterministic, no-LLM **scripted-flow mode** to the echo driver so host
38
+ e2e suites can drive flows end-to-end (autonomous run to `complete`, approval
39
+ gate resume, reject/recover) without spending model tokens or relying on model
40
+ nondeterminism. A `[test-flow]` sentinel chat message arms the mode (optionally
41
+ carrying a JSON per-node script); orchestrator turns are then driven by a
42
+ reactive policy over live flow state via a runner-injected `flowTestDriver`
43
+ hook. It emits only the existing FlowAdapter agent tools — no new protocol,
44
+ envelope, or flow-contract change. See `docs/flow-execution.md` → "Testing: The
45
+ Scripted Flow Driver".
46
+
47
+ Also fixes the lost initial `op:start` snapshot: `createActiveFlow` now emits
48
+ the initial `state_changed` right after registering the state listener, so
49
+ hosts receive the starting flow state before any mutation (idempotent
50
+ latest-wins, so a duplicate is harmless).
51
+
52
+ ### Patch Changes
53
+
54
+ - [#394](https://github.com/skaile-ai/workspaces/pull/394) [`d917573`](https://github.com/skaile-ai/workspaces/commit/d917573aac96de247ee35762a3f42fd29f0fef38) Thanks [@peteralbert](https://github.com/peteralbert)! - Run-group contract doc clarifications (no behavior change): `maxBudget` /
55
+ `costCurrency` are decimals in the host's reporting currency (Skaile
56
+ platform v1 records USD), not hard-coded EUR; `rollup` TSDoc now states
57
+ explicitly that `cancelled` groups never reactivate.
58
+
59
+ ## 1.9.1
60
+
61
+ ### Patch Changes
62
+
63
+ - [#391](https://github.com/skaile-ai/workspaces/pull/391) [`48e77a7`](https://github.com/skaile-ai/workspaces/commit/48e77a7a9b81b23a4b01766cd63340caf4660c6c) Thanks [@Frozen666](https://github.com/Frozen666)! - Let the Tier-2 git credential self-heal recover an empty or missing credentials file: the helper now treats emptiness as a refresh trigger, and `atomicReplaceCredential` upserts instead of throwing.
64
+
65
+ - [#388](https://github.com/skaile-ai/workspaces/pull/388) [`e8ca12c`](https://github.com/skaile-ai/workspaces/commit/e8ca12c74a3ca0386880b665560f9d7ce4f7f7d5) Thanks [@Frozen666](https://github.com/Frozen666)! - fix(serve): wire the capability surface on every `session_init`, not just the create branch
66
+
67
+ The remote capability invoker and the `runner.*` capabilities were registered only inside
68
+ `buildSessionFromInit`'s create branch. An env-mode session (no `skaile.yaml` — the broker
69
+ container shape) is built eagerly at boot, so it already has a session by the time
70
+ `session_init` arrives and never entered that branch: `host.refresh_credential` threw for
71
+ lack of an invoker (so `auth: backend` wire connectors could mint but never refresh),
72
+ platform hot-plug dispatches (`runner.attach_instance` / `runner.add_mcp_server` /
73
+ `runner.lifecycle`) failed, and the tier-1 resume `capabilitySignature` drifted from the
74
+ docker shape.
75
+
76
+ The wiring now lives in `session-capability-wiring.ts` and runs on every `session_init`
77
+ regardless of which branch built the session. It is idempotent (`setRemoteInvoker` replaces,
78
+ `register` is overwrite-by-name) and its handlers close over getters, so they follow a
79
+ subsequent wire-fallback recreate rather than pinning the disposed session. No behaviour
80
+ change on the docker/provisioned path.
81
+
82
+ - [#392](https://github.com/skaile-ai/workspaces/pull/392) [`a4b80cf`](https://github.com/skaile-ai/workspaces/commit/a4b80cf1ee453632eddd78ca64968d444b2d0936) Thanks [@Frozen666](https://github.com/Frozen666)! - Demote the serve.ts `[serve] debug query=` diagnostic from info to debug so the platform's ~10s config/mcp polls no longer flood the per-session logs.db.
83
+
3
84
  ## 1.9.0
4
85
 
5
86
  ### Minor Changes
@@ -64,7 +64,7 @@ async function libraryAssets() {
64
64
  const domains = [];
65
65
  try {
66
66
  const [{ openLibraryManager }, { skaileHomeDir }, { getGlobalCacheDir }] = await Promise.all([
67
- import('./open-library-J2PRSM3J.js'),
67
+ import('./open-library-5SRCSBSY.js'),
68
68
  import('./library/index.js'),
69
69
  import('./core/index.js')
70
70
  ]);
@@ -97,7 +97,7 @@ async function libraryAssets() {
97
97
  async function storeAssets(projectDir) {
98
98
  const notes = [];
99
99
  try {
100
- const { resolveCatalogSource } = await import('./open-library-J2PRSM3J.js');
100
+ const { resolveCatalogSource } = await import('./open-library-5SRCSBSY.js');
101
101
  const { source, close } = await resolveCatalogSource({ projectDir });
102
102
  try {
103
103
  const assets = await source.listAssets();
@@ -201,5 +201,5 @@ function dedupeBySlug(domains) {
201
201
  }
202
202
 
203
203
  export { gatherAssetFeeds };
204
- //# sourceMappingURL=asset-feeds-SS336LXB.js.map
205
- //# sourceMappingURL=asset-feeds-SS336LXB.js.map
204
+ //# sourceMappingURL=asset-feeds-FMV3SJVQ.js.map
205
+ //# sourceMappingURL=asset-feeds-FMV3SJVQ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../cli/src/asset-feeds.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAqFA,SAAS,QAAQ,CAAA,EAAmB;AAClC,EAAA,OAAO,CAAA,CAAE,KAAA,CAAW,IAAA,CAAA,GAAG,CAAA,CAAE,KAAK,GAAG,CAAA;AACnC;AAGA,SAAS,cAAc,IAAA,EAA0B;AAC/C,EAAA,MAAM,MAAkB,EAAC;AACzB,EAAA,KAAA,MAAW,EAAE,IAAA,EAAM,QAAA,EAAU,MAAK,IAAK,OAAA,CAAQ,IAAI,CAAA,EAAG;AACpD,IAAA,IAAI,SAAS,kBAAA,EAAoB;AACjC,IAAA,IAAI;AACF,MAAA,MAAM,EAAE,IAAA,EAAK,GAAI,iBAAiB,YAAA,CAAa,QAAA,EAAU,MAAM,CAAC,CAAA;AAChE,MAAA,GAAA,CAAI,IAAA,CAAK,cAAc,OAAA,CAAa,IAAA,CAAA,QAAA,CAAS,MAAM,QAAQ,CAAC,CAAA,EAAG,IAAI,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AAA;AAAA,EACZ;AACA,EAAA,OAAO,GAAA;AACT","file":"asset-feeds-SS336LXB.js","sourcesContent":["/**\n * asset-feeds.ts — gather installable assets from every feed the manage TUI\n * surfaces.\n *\n * Four feeds, normalized into `CatalogEntry`:\n * - **Project sources** — `skaile.yaml` `sources:` entries (scanned via\n * `AssetManager.search()`; the new `sources:` field is merged into the\n * legacy repositories map in `AssetManager.loadConfig`).\n * - **Local libraries** — user authoring places from `LocalIndex` (filesystem\n * scan of each library's `path`).\n * - **Factory assets** — the bundled first-party `factory-assets` tree\n * (`factoryAssetRoots()`), scanned from disk. Always present; no network.\n * - **Remote store** — the configured catalog source when `catalog.url` is\n * not `local`. Failures are non-fatal — they surface as notes.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n type AssetKind,\n type CatalogDomain,\n type CatalogEntry,\n factoryAssetRoots,\n parseFrontmatter,\n scanRepo,\n walkDir,\n} from \"@skaile/workspaces/core\";\nimport {\n assignDomain,\n buildDomainIndex,\n DOMAIN_MD_FILENAME,\n type DomainMd,\n parseDomainMd,\n} from \"@skaile/workspaces/discovery\";\n\n/** One non-fatal note returned to the caller for surfacing in the UI. */\nexport interface FeedNote {\n feed: \"sources\" | \"libraries\" | \"store\" | \"factory\";\n message: string;\n}\n\n/**\n * Which feed an asset came from. This is the top-level grouping axis in the\n * manage TUI (\"where is this skill coming from?\") and is intentionally distinct\n * from `publisher` (asset-intrinsic identity): the same publisher can legitimately\n * appear under more than one origin (e.g. a github repo you added as a `source`\n * that is also listed in the remote `store`).\n */\nexport type AssetOrigin = \"source\" | \"library\" | \"factory\" | \"store\";\n\n/** A catalog entry tagged with the feed it was gathered from. */\nexport interface OriginEntry {\n origin: AssetOrigin;\n entry: CatalogEntry;\n /**\n * Second-level grouping label for the manage tree. Defaults (when unset) to the\n * entry's `publisher`; the source feed sets it to the source's short repo name\n * so the Sources band groups by source — \"which repo did this come from\" — not\n * by the asset-intrinsic publisher.\n */\n group?: string;\n}\n\nexport interface AssetFeedResult {\n entries: OriginEntry[];\n /**\n * Display-only domain metadata, keyed (by the consumer) on `slug`. Populated\n * from the store's `catalog.listDomains` when the connected catalog source\n * exposes it; empty otherwise. The manage TUI joins `entry.domainSlug` → a\n * domain for grouping headers, descriptions, and relation badges.\n */\n domains: CatalogDomain[];\n notes: FeedNote[];\n}\n\n// ── Domain stamping (on-disk feeds) ──────────────────────────────────────────\n//\n// `scanRepo` (the source / library / factory scan path) does not read the\n// `DOMAIN.md` sidecars, so its entries arrive with no `domainSlug` and render\n// flat under their publisher band. We re-derive the grouping here from the\n// root's `DOMAIN.md` files (the same sidecars the remote store computes\n// server-side), and fall back to the repo/source name for any entry no domain\n// claims so it still groups instead of landing in the synthetic \"no domain\" pile.\n\n/** Repo-relative POSIX path (DOMAIN.md slugs are matched whole-segment, `/`-joined). */\nfunction toPosix(p: string): string {\n return p.split(path.sep).join(\"/\");\n}\n\n/** Parse every `DOMAIN.md` sidecar under `root` into a {@link DomainMd}. */\nfunction loadDomainMds(root: string): DomainMd[] {\n const out: DomainMd[] = [];\n for (const { path: filePath, name } of walkDir(root)) {\n if (name !== DOMAIN_MD_FILENAME) continue;\n try {\n const { data } = parseFrontmatter(readFileSync(filePath, \"utf8\"));\n out.push(parseDomainMd(toPosix(path.relative(root, filePath)), data));\n } catch {}\n }\n return out;\n}\n\n/**\n * Stamp `domainSlug` onto every entry scanned from `root` using the root's\n * `DOMAIN.md` sidecars. Returns the `CatalogDomain` registry for the real\n * domains, plus a synthetic fallback domain when any entry used the fallback.\n * Mutates `entries` in place (sets `entry.domainSlug`).\n *\n * `synthesizeFallback` (default true): entries no domain claims fall back to\n * `fallbackSlug` (the repo/source name). Pass `false` when the caller already\n * groups these entries one level up (e.g. the source feed groups by source\n * node) — unmatched entries then get no domain (`\"\"`) and hang directly under\n * that parent, instead of nesting under a same-named fallback domain.\n */\nfunction stampDomains(\n root: string,\n fallbackSlug: string,\n entries: CatalogEntry[],\n synthesizeFallback = true,\n): CatalogDomain[] {\n const domainMds = loadDomainMds(root);\n const assignables = entries.map((entry) => ({\n entry,\n ref: `${entry.kind}:${entry.name}`,\n relativePath: toPosix(path.relative(root, entry.source)),\n }));\n\n let usedFallback = false;\n for (const a of assignables) {\n const slug = assignDomain(a.relativePath, domainMds);\n if (slug) a.entry.domainSlug = slug;\n else if (synthesizeFallback) {\n a.entry.domainSlug = fallbackSlug;\n usedFallback = true;\n } else a.entry.domainSlug = \"\";\n }\n\n const { index } = buildDomainIndex(assignables, domainMds);\n const catalog: CatalogDomain[] = Object.values(index).map((d) => ({\n slug: d.slug,\n title: d.title,\n ...(d.description ? { description: d.description } : {}),\n ...(d.relation ? { relation: d.relation } : {}),\n ...(d.order !== undefined ? { order: d.order } : {}),\n ...(d.recommended[0] ? { recommendedRef: d.recommended[0] } : {}),\n }));\n if (usedFallback) catalog.push({ slug: fallbackSlug, title: fallbackSlug });\n return catalog;\n}\n\n/**\n * Pull assets from local libraries (the authoring places under\n * `~/.skaile/libraries/<name>/`, not the `~/.skaile/cache/sources/` cache). Each\n * library's `path` is scanned with `scanRepo` and grouped under the bare library\n * name (`group: <name>`) so the manage TUI shows a clean `<name>` band — no\n * `library:` prefix and no redundant same-named fallback domain (mirrors the\n * source feed).\n */\nasync function libraryAssets(): Promise<{\n entries: OriginEntry[];\n domains: CatalogDomain[];\n notes: FeedNote[];\n}> {\n const notes: FeedNote[] = [];\n const domains: CatalogDomain[] = [];\n try {\n const [{ openLibraryManager }, { skaileHomeDir }, { getGlobalCacheDir }] = await Promise.all([\n import(\"./open-library.ts\"),\n import(\"@skaile/workspaces/library\"),\n import(\"@skaile/workspaces/core\"),\n ]);\n const { manager, close } = await openLibraryManager();\n try {\n // Authoring libraries are the rows that are NOT source clones. index.db\n // rows predating the cache migration still carry the legacy\n // ~/.skaile/sources path, so exclude both roots.\n const newRoot = getGlobalCacheDir();\n const legacyRoot = path.join(skaileHomeDir(), \"sources\");\n const libs = (await manager.listLibraries()).filter(\n (l) => !l.path.startsWith(newRoot) && !l.path.startsWith(legacyRoot),\n );\n const entries: OriginEntry[] = [];\n for (const lib of libs) {\n if (!existsSync(lib.path)) continue;\n // Scan + group under the bare library name. `synthesizeFallback: false`\n // (as the source feed does) keeps domainless assets directly under the\n // library band instead of a redundant same-named fallback domain.\n const libEntries = [...scanRepo(lib.path, lib.name)];\n domains.push(...stampDomains(lib.path, lib.name, libEntries, false));\n for (const entry of libEntries) entries.push({ origin: \"library\", entry, group: lib.name });\n }\n return { entries, domains, notes };\n } finally {\n close();\n }\n } catch (err) {\n notes.push({\n feed: \"libraries\",\n message: err instanceof Error ? err.message : String(err),\n });\n return { entries: [], domains, notes };\n }\n}\n\n/**\n * Pull a (best-effort) snapshot of the connected remote store catalog.\n *\n * - Returns no entries when the resolved catalog is local-only or the host\n * is unreachable (the failure becomes a note, not an exception).\n * - Maps `CatalogAsset` → `CatalogEntry`, carrying `publisher`, `repo`, and\n * `category` straight through and using `source = \"store://<id>\"`; per-file\n * `source` paths are not available for remote assets so the canonical ref is\n * a stable placeholder.\n */\nasync function storeAssets(projectDir: string): Promise<{\n entries: CatalogEntry[];\n domains: CatalogDomain[];\n notes: FeedNote[];\n}> {\n const notes: FeedNote[] = [];\n try {\n const { resolveCatalogSource } = await import(\"./open-library.ts\");\n const { source, close } = await resolveCatalogSource({ projectDir });\n try {\n const assets = await source.listAssets();\n const entries: CatalogEntry[] = assets.map((a) => ({\n name: a.name,\n kind: (a.kind as AssetKind) ?? \"skill\",\n description: a.description ?? \"\",\n source: `store://${a.id}`,\n publisher: a.publisher,\n repo: a.repo,\n domainSlug: a.domainSlug,\n category: a.category,\n version: a.version,\n requires: [],\n dependencies: [],\n }));\n // Domains are optional on the catalog source — only the store backend\n // (post Part 4 `catalog.listDomains`) exposes them. Duck-type the call so\n // older sources and the local catalog degrade to no domains, not an error.\n const domains = await loadDomains(source);\n return { entries, domains, notes };\n } finally {\n close();\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n // Local-only catalog throws a recognizable message — silence it; absence\n // is the user's choice, not an error.\n if (!/local/i.test(msg)) {\n notes.push({ feed: \"store\", message: msg });\n }\n return { entries: [], domains: [], notes };\n }\n}\n\n/** Optional `listDomains` capability — returns `[]` when the source lacks it. */\nasync function loadDomains(source: unknown): Promise<CatalogDomain[]> {\n const fn = (source as { listDomains?: () => Promise<CatalogDomain[]> }).listDomains;\n if (typeof fn !== \"function\") return [];\n const domains = await fn.call(source);\n return Array.isArray(domains) ? domains : [];\n}\n\n/** The slice of `AssetManager` the source feed needs (kept narrow for tests). */\ninterface AssetManagerLike {\n search: () => CatalogEntry[];\n searchRepoRoots: () => { repoName: string; root: string }[];\n}\n\n/**\n * Project-source feed: leans on `AssetManager.search()`, which now merges\n * `skaile.yaml`'s `sources:` field into the repositories map, then stamps\n * `DOMAIN.md`-derived domain grouping onto the scanned entries via\n * `searchRepoRoots()`.\n */\nfunction sourceAssets(am: AssetManagerLike): { entries: OriginEntry[]; domains: CatalogDomain[] } {\n // The bundled factory tree is injected into the repositories map as an implicit\n // source, so `am.search()` returns it too. It has its own `factory` origin band,\n // so drop it here — otherwise the same first-party skills list twice under Sources.\n const factoryPrefixes = factoryAssetRoots().map((r) => (r.endsWith(path.sep) ? r : r + path.sep));\n const isFactoryPath = (p: string) =>\n factoryPrefixes.some((fp) => p === fp.slice(0, -1) || p.startsWith(fp));\n\n const all = am.search().filter((e) => !isFactoryPath(e.source));\n const entries: OriginEntry[] = [];\n const domains: CatalogDomain[] = [];\n // Group each source's entries under the source node (its short repo name), not\n // the publisher: under Sources the navigational question is \"which repo did\n // this come from\". Each entry's `source` (absolute manifest path) lives under\n // exactly one declared root, so group + stamp by prefix. The cache slug is\n // URL-keyed `github.com/<org>/<repo>` — take the trailing segment.\n for (const { repoName, root } of am.searchRepoRoots()) {\n if (isFactoryPath(root)) continue;\n const prefix = root.endsWith(path.sep) ? root : root + path.sep;\n const owned = all.filter((e) => e.source === root || e.source.startsWith(prefix));\n if (owned.length === 0) continue;\n const sourceName = repoName.split(\"/\").pop() || repoName;\n // No synthetic fallback domain — the source node already groups these, so a\n // same-named fallback would just nest the source under itself.\n domains.push(...stampDomains(root, sourceName, owned, false));\n for (const entry of owned) entries.push({ origin: \"source\", entry, group: sourceName });\n }\n return { entries, domains };\n}\n\n/**\n * Factory-asset feed: scan the bundled first-party `factory-assets` tree(s)\n * resolved by `factoryAssetRoots()` (the `SKAILE_FACTORY_ASSETS_DIR` override\n * layer ahead of the bundled tree). Synchronous, no network — the entries are\n * the built-in skills / connectors / bundles that ship with `@skaile/workspaces`.\n * `factoryAssetRoots()` already dedupes, so the env override pointing at the\n * bundled dir collapses to one root.\n */\nfunction factoryAssets(): { entries: CatalogEntry[]; domains: CatalogDomain[]; notes: FeedNote[] } {\n const notes: FeedNote[] = [];\n const domains: CatalogDomain[] = [];\n try {\n const entries: CatalogEntry[] = [];\n for (const root of factoryAssetRoots()) {\n const rootEntries = [...scanRepo(root, \"skaile-factory\")];\n domains.push(...stampDomains(root, \"skaile-factory\", rootEntries));\n entries.push(...rootEntries);\n }\n return { entries, domains, notes };\n } catch (err) {\n notes.push({\n feed: \"factory\",\n message: err instanceof Error ? err.message : String(err),\n });\n return { entries: [], domains, notes };\n }\n}\n\n/** Tag a flat entry list with a single origin. */\nfunction tag(origin: AssetOrigin, entries: CatalogEntry[]): OriginEntry[] {\n return entries.map((entry) => ({ origin, entry }));\n}\n\n/**\n * Run all feeds and return a single normalized result.\n *\n * Feeds run in parallel where possible — the store fetch is the slow one\n * (one HTTP call) and is fired alongside the local library walk. The factory\n * scan is local + synchronous, so it runs inline.\n */\nexport async function gatherAssetFeeds(\n am: AssetManagerLike,\n projectDir: string,\n): Promise<AssetFeedResult> {\n const [libs, store] = await Promise.all([libraryAssets(), storeAssets(projectDir)]);\n const factory = factoryAssets();\n const src = sourceAssets(am);\n return {\n entries: [\n ...src.entries,\n ...libs.entries,\n ...tag(\"factory\", factory.entries),\n ...tag(\"store\", store.entries),\n ],\n // Store domains first (server-curated), then the on-disk feeds; dedupe by\n // slug, first-wins, so a store-served domain shadows a same-slug local one.\n domains: dedupeBySlug([...store.domains, ...src.domains, ...libs.domains, ...factory.domains]),\n notes: [...libs.notes, ...store.notes, ...factory.notes],\n };\n}\n\n/** First-wins dedupe of a domain list by `slug`. */\nfunction dedupeBySlug(domains: CatalogDomain[]): CatalogDomain[] {\n const seen = new Set<string>();\n const out: CatalogDomain[] = [];\n for (const d of domains) {\n if (seen.has(d.slug)) continue;\n seen.add(d.slug);\n out.push(d);\n }\n return out;\n}\n"]}
1
+ {"version":3,"sources":["../cli/src/asset-feeds.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAqFA,SAAS,QAAQ,CAAA,EAAmB;AAClC,EAAA,OAAO,CAAA,CAAE,KAAA,CAAW,IAAA,CAAA,GAAG,CAAA,CAAE,KAAK,GAAG,CAAA;AACnC;AAGA,SAAS,cAAc,IAAA,EAA0B;AAC/C,EAAA,MAAM,MAAkB,EAAC;AACzB,EAAA,KAAA,MAAW,EAAE,IAAA,EAAM,QAAA,EAAU,MAAK,IAAK,OAAA,CAAQ,IAAI,CAAA,EAAG;AACpD,IAAA,IAAI,SAAS,kBAAA,EAAoB;AACjC,IAAA,IAAI;AACF,MAAA,MAAM,EAAE,IAAA,EAAK,GAAI,iBAAiB,YAAA,CAAa,QAAA,EAAU,MAAM,CAAC,CAAA;AAChE,MAAA,GAAA,CAAI,IAAA,CAAK,cAAc,OAAA,CAAa,IAAA,CAAA,QAAA,CAAS,MAAM,QAAQ,CAAC,CAAA,EAAG,IAAI,CAAC,CAAA;AAAA,IACtE,CAAA,CAAA,MAAQ;AAAA,IAAC;AAAA,EACX;AACA,EAAA,OAAO,GAAA;AACT;AAcA,SAAS,YAAA,CACP,IAAA,EACA,YAAA,EACA,OAAA,EACA,qBAAqB,IAAA,EACJ;AACjB,EAAA,MAAM,SAAA,GAAY,cAAc,IAAI,CAAA;AACpC,EAAA,MAAM,WAAA,GAAc,OAAA,CAA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C,CAAC,CAAA;AAClF,EAAA,MAAM,UAAU,aAAA,EAAc;AAC9B,EAAA,MAAM,GAAA,GAAM,aAAa,EAAE,CAAA;AAC3B,EAAA,OAAO;AAAA,IACL,OAAA,EAAS;AAAA,MACP,GAAG,GAAA,CAAI,OAAA;AAAA,MACP,GAAG,IAAA,CAAK,OAAA;AAAA,MACR,GAAG,GAAA,CAAI,SAAA,EAAW,OAAA,CAAQ,OAAO,CAAA;AAAA,MACjC,GAAG,GAAA,CAAI,OAAA,EAAS,KAAA,CAAM,OAAO;AAAA,KAC/B;AAAA;AAAA;AAAA,IAGA,OAAA,EAAS,YAAA,CAAa,CAAC,GAAG,MAAM,OAAA,EAAS,GAAG,GAAA,CAAI,OAAA,EAAS,GAAG,IAAA,CAAK,OAAA,EAAS,GAAG,OAAA,CAAQ,OAAO,CAAC,CAAA;AAAA,IAC7F,KAAA,EAAO,CAAC,GAAG,IAAA,CAAK,KAAA,EAAO,GAAG,KAAA,CAAM,KAAA,EAAO,GAAG,OAAA,CAAQ,KAAK;AAAA,GACzD;AACF;AAGA,SAAS,aAAa,OAAA,EAA2C;AAC/D,EAAA,MAAM,IAAA,uBAAW,GAAA,EAAY;AAC7B,EAAA,MAAM,MAAuB,EAAC;AAC9B,EAAA,KAAA,MAAW,KAAK,OAAA,EAAS;AACvB,IAAA,IAAI,IAAA,CAAK,GAAA,CAAI,CAAA,CAAE,IAAI,CAAA,EAAG;AACtB,IAAA,IAAA,CAAK,GAAA,CAAI,EAAE,IAAI,CAAA;AACf,IAAA,GAAA,CAAI,KAAK,CAAC,CAAA;AAAA,EACZ;AACA,EAAA,OAAO,GAAA;AACT","file":"asset-feeds-FMV3SJVQ.js","sourcesContent":["/**\n * asset-feeds.ts — gather installable assets from every feed the manage TUI\n * surfaces.\n *\n * Four feeds, normalized into `CatalogEntry`:\n * - **Project sources** — `skaile.yaml` `sources:` entries (scanned via\n * `AssetManager.search()`; the new `sources:` field is merged into the\n * legacy repositories map in `AssetManager.loadConfig`).\n * - **Local libraries** — user authoring places from `LocalIndex` (filesystem\n * scan of each library's `path`).\n * - **Factory assets** — the bundled first-party `factory-assets` tree\n * (`factoryAssetRoots()`), scanned from disk. Always present; no network.\n * - **Remote store** — the configured catalog source when `catalog.url` is\n * not `local`. Failures are non-fatal — they surface as notes.\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n type AssetKind,\n type CatalogDomain,\n type CatalogEntry,\n factoryAssetRoots,\n parseFrontmatter,\n scanRepo,\n walkDir,\n} from \"@skaile/workspaces/core\";\nimport {\n assignDomain,\n buildDomainIndex,\n DOMAIN_MD_FILENAME,\n type DomainMd,\n parseDomainMd,\n} from \"@skaile/workspaces/discovery\";\n\n/** One non-fatal note returned to the caller for surfacing in the UI. */\nexport interface FeedNote {\n feed: \"sources\" | \"libraries\" | \"store\" | \"factory\";\n message: string;\n}\n\n/**\n * Which feed an asset came from. This is the top-level grouping axis in the\n * manage TUI (\"where is this skill coming from?\") and is intentionally distinct\n * from `publisher` (asset-intrinsic identity): the same publisher can legitimately\n * appear under more than one origin (e.g. a github repo you added as a `source`\n * that is also listed in the remote `store`).\n */\nexport type AssetOrigin = \"source\" | \"library\" | \"factory\" | \"store\";\n\n/** A catalog entry tagged with the feed it was gathered from. */\nexport interface OriginEntry {\n origin: AssetOrigin;\n entry: CatalogEntry;\n /**\n * Second-level grouping label for the manage tree. Defaults (when unset) to the\n * entry's `publisher`; the source feed sets it to the source's short repo name\n * so the Sources band groups by source — \"which repo did this come from\" — not\n * by the asset-intrinsic publisher.\n */\n group?: string;\n}\n\nexport interface AssetFeedResult {\n entries: OriginEntry[];\n /**\n * Display-only domain metadata, keyed (by the consumer) on `slug`. Populated\n * from the store's `catalog.listDomains` when the connected catalog source\n * exposes it; empty otherwise. The manage TUI joins `entry.domainSlug` → a\n * domain for grouping headers, descriptions, and relation badges.\n */\n domains: CatalogDomain[];\n notes: FeedNote[];\n}\n\n// ── Domain stamping (on-disk feeds) ──────────────────────────────────────────\n//\n// `scanRepo` (the source / library / factory scan path) does not read the\n// `DOMAIN.md` sidecars, so its entries arrive with no `domainSlug` and render\n// flat under their publisher band. We re-derive the grouping here from the\n// root's `DOMAIN.md` files (the same sidecars the remote store computes\n// server-side), and fall back to the repo/source name for any entry no domain\n// claims so it still groups instead of landing in the synthetic \"no domain\" pile.\n\n/** Repo-relative POSIX path (DOMAIN.md slugs are matched whole-segment, `/`-joined). */\nfunction toPosix(p: string): string {\n return p.split(path.sep).join(\"/\");\n}\n\n/** Parse every `DOMAIN.md` sidecar under `root` into a {@link DomainMd}. */\nfunction loadDomainMds(root: string): DomainMd[] {\n const out: DomainMd[] = [];\n for (const { path: filePath, name } of walkDir(root)) {\n if (name !== DOMAIN_MD_FILENAME) continue;\n try {\n const { data } = parseFrontmatter(readFileSync(filePath, \"utf8\"));\n out.push(parseDomainMd(toPosix(path.relative(root, filePath)), data));\n } catch {}\n }\n return out;\n}\n\n/**\n * Stamp `domainSlug` onto every entry scanned from `root` using the root's\n * `DOMAIN.md` sidecars. Returns the `CatalogDomain` registry for the real\n * domains, plus a synthetic fallback domain when any entry used the fallback.\n * Mutates `entries` in place (sets `entry.domainSlug`).\n *\n * `synthesizeFallback` (default true): entries no domain claims fall back to\n * `fallbackSlug` (the repo/source name). Pass `false` when the caller already\n * groups these entries one level up (e.g. the source feed groups by source\n * node) — unmatched entries then get no domain (`\"\"`) and hang directly under\n * that parent, instead of nesting under a same-named fallback domain.\n */\nfunction stampDomains(\n root: string,\n fallbackSlug: string,\n entries: CatalogEntry[],\n synthesizeFallback = true,\n): CatalogDomain[] {\n const domainMds = loadDomainMds(root);\n const assignables = entries.map((entry) => ({\n entry,\n ref: `${entry.kind}:${entry.name}`,\n relativePath: toPosix(path.relative(root, entry.source)),\n }));\n\n let usedFallback = false;\n for (const a of assignables) {\n const slug = assignDomain(a.relativePath, domainMds);\n if (slug) a.entry.domainSlug = slug;\n else if (synthesizeFallback) {\n a.entry.domainSlug = fallbackSlug;\n usedFallback = true;\n } else a.entry.domainSlug = \"\";\n }\n\n const { index } = buildDomainIndex(assignables, domainMds);\n const catalog: CatalogDomain[] = Object.values(index).map((d) => ({\n slug: d.slug,\n title: d.title,\n ...(d.description ? { description: d.description } : {}),\n ...(d.relation ? { relation: d.relation } : {}),\n ...(d.order !== undefined ? { order: d.order } : {}),\n ...(d.recommended[0] ? { recommendedRef: d.recommended[0] } : {}),\n }));\n if (usedFallback) catalog.push({ slug: fallbackSlug, title: fallbackSlug });\n return catalog;\n}\n\n/**\n * Pull assets from local libraries (the authoring places under\n * `~/.skaile/libraries/<name>/`, not the `~/.skaile/cache/sources/` cache). Each\n * library's `path` is scanned with `scanRepo` and grouped under the bare library\n * name (`group: <name>`) so the manage TUI shows a clean `<name>` band — no\n * `library:` prefix and no redundant same-named fallback domain (mirrors the\n * source feed).\n */\nasync function libraryAssets(): Promise<{\n entries: OriginEntry[];\n domains: CatalogDomain[];\n notes: FeedNote[];\n}> {\n const notes: FeedNote[] = [];\n const domains: CatalogDomain[] = [];\n try {\n const [{ openLibraryManager }, { skaileHomeDir }, { getGlobalCacheDir }] = await Promise.all([\n import(\"./open-library.ts\"),\n import(\"@skaile/workspaces/library\"),\n import(\"@skaile/workspaces/core\"),\n ]);\n const { manager, close } = await openLibraryManager();\n try {\n // Authoring libraries are the rows that are NOT source clones. index.db\n // rows predating the cache migration still carry the legacy\n // ~/.skaile/sources path, so exclude both roots.\n const newRoot = getGlobalCacheDir();\n const legacyRoot = path.join(skaileHomeDir(), \"sources\");\n const libs = (await manager.listLibraries()).filter(\n (l) => !l.path.startsWith(newRoot) && !l.path.startsWith(legacyRoot),\n );\n const entries: OriginEntry[] = [];\n for (const lib of libs) {\n if (!existsSync(lib.path)) continue;\n // Scan + group under the bare library name. `synthesizeFallback: false`\n // (as the source feed does) keeps domainless assets directly under the\n // library band instead of a redundant same-named fallback domain.\n const libEntries = [...scanRepo(lib.path, lib.name)];\n domains.push(...stampDomains(lib.path, lib.name, libEntries, false));\n for (const entry of libEntries) entries.push({ origin: \"library\", entry, group: lib.name });\n }\n return { entries, domains, notes };\n } finally {\n close();\n }\n } catch (err) {\n notes.push({\n feed: \"libraries\",\n message: err instanceof Error ? err.message : String(err),\n });\n return { entries: [], domains, notes };\n }\n}\n\n/**\n * Pull a (best-effort) snapshot of the connected remote store catalog.\n *\n * - Returns no entries when the resolved catalog is local-only or the host\n * is unreachable (the failure becomes a note, not an exception).\n * - Maps `CatalogAsset` → `CatalogEntry`, carrying `publisher`, `repo`, and\n * `category` straight through and using `source = \"store://<id>\"`; per-file\n * `source` paths are not available for remote assets so the canonical ref is\n * a stable placeholder.\n */\nasync function storeAssets(projectDir: string): Promise<{\n entries: CatalogEntry[];\n domains: CatalogDomain[];\n notes: FeedNote[];\n}> {\n const notes: FeedNote[] = [];\n try {\n const { resolveCatalogSource } = await import(\"./open-library.ts\");\n const { source, close } = await resolveCatalogSource({ projectDir });\n try {\n const assets = await source.listAssets();\n const entries: CatalogEntry[] = assets.map((a) => ({\n name: a.name,\n kind: (a.kind as AssetKind) ?? \"skill\",\n description: a.description ?? \"\",\n source: `store://${a.id}`,\n publisher: a.publisher,\n repo: a.repo,\n domainSlug: a.domainSlug,\n category: a.category,\n version: a.version,\n requires: [],\n dependencies: [],\n }));\n // Domains are optional on the catalog source — only the store backend\n // (post Part 4 `catalog.listDomains`) exposes them. Duck-type the call so\n // older sources and the local catalog degrade to no domains, not an error.\n const domains = await loadDomains(source);\n return { entries, domains, notes };\n } finally {\n close();\n }\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n // Local-only catalog throws a recognizable message — silence it; absence\n // is the user's choice, not an error.\n if (!/local/i.test(msg)) {\n notes.push({ feed: \"store\", message: msg });\n }\n return { entries: [], domains: [], notes };\n }\n}\n\n/** Optional `listDomains` capability — returns `[]` when the source lacks it. */\nasync function loadDomains(source: unknown): Promise<CatalogDomain[]> {\n const fn = (source as { listDomains?: () => Promise<CatalogDomain[]> }).listDomains;\n if (typeof fn !== \"function\") return [];\n const domains = await fn.call(source);\n return Array.isArray(domains) ? domains : [];\n}\n\n/** The slice of `AssetManager` the source feed needs (kept narrow for tests). */\ninterface AssetManagerLike {\n search: () => CatalogEntry[];\n searchRepoRoots: () => { repoName: string; root: string }[];\n}\n\n/**\n * Project-source feed: leans on `AssetManager.search()`, which now merges\n * `skaile.yaml`'s `sources:` field into the repositories map, then stamps\n * `DOMAIN.md`-derived domain grouping onto the scanned entries via\n * `searchRepoRoots()`.\n */\nfunction sourceAssets(am: AssetManagerLike): { entries: OriginEntry[]; domains: CatalogDomain[] } {\n // The bundled factory tree is injected into the repositories map as an implicit\n // source, so `am.search()` returns it too. It has its own `factory` origin band,\n // so drop it here — otherwise the same first-party skills list twice under Sources.\n const factoryPrefixes = factoryAssetRoots().map((r) => (r.endsWith(path.sep) ? r : r + path.sep));\n const isFactoryPath = (p: string) =>\n factoryPrefixes.some((fp) => p === fp.slice(0, -1) || p.startsWith(fp));\n\n const all = am.search().filter((e) => !isFactoryPath(e.source));\n const entries: OriginEntry[] = [];\n const domains: CatalogDomain[] = [];\n // Group each source's entries under the source node (its short repo name), not\n // the publisher: under Sources the navigational question is \"which repo did\n // this come from\". Each entry's `source` (absolute manifest path) lives under\n // exactly one declared root, so group + stamp by prefix. The cache slug is\n // URL-keyed `github.com/<org>/<repo>` — take the trailing segment.\n for (const { repoName, root } of am.searchRepoRoots()) {\n if (isFactoryPath(root)) continue;\n const prefix = root.endsWith(path.sep) ? root : root + path.sep;\n const owned = all.filter((e) => e.source === root || e.source.startsWith(prefix));\n if (owned.length === 0) continue;\n const sourceName = repoName.split(\"/\").pop() || repoName;\n // No synthetic fallback domain — the source node already groups these, so a\n // same-named fallback would just nest the source under itself.\n domains.push(...stampDomains(root, sourceName, owned, false));\n for (const entry of owned) entries.push({ origin: \"source\", entry, group: sourceName });\n }\n return { entries, domains };\n}\n\n/**\n * Factory-asset feed: scan the bundled first-party `factory-assets` tree(s)\n * resolved by `factoryAssetRoots()` (the `SKAILE_FACTORY_ASSETS_DIR` override\n * layer ahead of the bundled tree). Synchronous, no network — the entries are\n * the built-in skills / connectors / bundles that ship with `@skaile/workspaces`.\n * `factoryAssetRoots()` already dedupes, so the env override pointing at the\n * bundled dir collapses to one root.\n */\nfunction factoryAssets(): { entries: CatalogEntry[]; domains: CatalogDomain[]; notes: FeedNote[] } {\n const notes: FeedNote[] = [];\n const domains: CatalogDomain[] = [];\n try {\n const entries: CatalogEntry[] = [];\n for (const root of factoryAssetRoots()) {\n const rootEntries = [...scanRepo(root, \"skaile-factory\")];\n domains.push(...stampDomains(root, \"skaile-factory\", rootEntries));\n entries.push(...rootEntries);\n }\n return { entries, domains, notes };\n } catch (err) {\n notes.push({\n feed: \"factory\",\n message: err instanceof Error ? err.message : String(err),\n });\n return { entries: [], domains, notes };\n }\n}\n\n/** Tag a flat entry list with a single origin. */\nfunction tag(origin: AssetOrigin, entries: CatalogEntry[]): OriginEntry[] {\n return entries.map((entry) => ({ origin, entry }));\n}\n\n/**\n * Run all feeds and return a single normalized result.\n *\n * Feeds run in parallel where possible — the store fetch is the slow one\n * (one HTTP call) and is fired alongside the local library walk. The factory\n * scan is local + synchronous, so it runs inline.\n */\nexport async function gatherAssetFeeds(\n am: AssetManagerLike,\n projectDir: string,\n): Promise<AssetFeedResult> {\n const [libs, store] = await Promise.all([libraryAssets(), storeAssets(projectDir)]);\n const factory = factoryAssets();\n const src = sourceAssets(am);\n return {\n entries: [\n ...src.entries,\n ...libs.entries,\n ...tag(\"factory\", factory.entries),\n ...tag(\"store\", store.entries),\n ],\n // Store domains first (server-curated), then the on-disk feeds; dedupe by\n // slug, first-wins, so a store-served domain shadows a same-slug local one.\n domains: dedupeBySlug([...store.domains, ...src.domains, ...libs.domains, ...factory.domains]),\n notes: [...libs.notes, ...store.notes, ...factory.notes],\n };\n}\n\n/** First-wins dedupe of a domain list by `slug`. */\nfunction dedupeBySlug(domains: CatalogDomain[]): CatalogDomain[] {\n const seen = new Set<string>();\n const out: CatalogDomain[] = [];\n for (const d of domains) {\n if (seen.has(d.slug)) continue;\n seen.add(d.slug);\n out.push(d);\n }\n return out;\n}\n"]}
@@ -1,4 +1,4 @@
1
- export { AssetManager, FACTORY_SOURCE_URL, MissingManifestError, NON_DEPLOYABLE_KINDS, normalizeRepoUrl, parseCanonicalLockKey, parseRefTolerant, softDepName } from '../chunk-QY47VHNI.js';
1
+ export { AssetManager, FACTORY_SOURCE_URL, MissingManifestError, NON_DEPLOYABLE_KINDS, normalizeRepoUrl, parseCanonicalLockKey, parseRefTolerant, softDepName } from '../chunk-PU3FGN4T.js';
2
2
  import '../chunk-MWE7DEGC.js';
3
3
  import '../chunk-MZV6WCF3.js';
4
4
  import '../chunk-JXT46QFC.js';
@@ -2,7 +2,7 @@ import { SUPPORTED_CLOUDS, buildClaudeCloudEnv } from '../../chunk-ISQWMBKD.js';
2
2
  import { dispatchCapability } from '../../chunk-RRVQAE5D.js';
3
3
  import { fetchProviderModels } from '../../chunk-BMQKMOQY.js';
4
4
  import { AuthError, classifyClaudeSdkError, reclassifyAuthAsAccountUnavailable, AccountUnavailableError } from '../../chunk-GAH4YRCI.js';
5
- import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-TNSCHS4I.js';
5
+ import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-APHTT5GE.js';
6
6
  import '../../chunk-6E6PKKAD.js';
7
7
  import '../../chunk-JB35MVBN.js';
8
8
  import '../../chunk-NSBPE2FW.js';
@@ -1,6 +1,6 @@
1
1
  import { fetchProviderModels } from '../../chunk-BMQKMOQY.js';
2
2
  import { classifyGenericErrorMessage } from '../../chunk-GAH4YRCI.js';
3
- import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-TNSCHS4I.js';
3
+ import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-APHTT5GE.js';
4
4
  import '../../chunk-6E6PKKAD.js';
5
5
  import '../../chunk-JB35MVBN.js';
6
6
  import '../../chunk-NSBPE2FW.js';
@@ -1,6 +1,6 @@
1
- import { SubprocessCliDriver, mapApiKeysToEnv, extractText, extractCost, extractTokens } from '../../chunk-UQ5FK2AB.js';
1
+ import { SubprocessCliDriver, mapApiKeysToEnv, extractText, extractCost, extractTokens } from '../../chunk-FRD4NU3W.js';
2
2
  import '../../chunk-GAH4YRCI.js';
3
- import { BUILTIN_DRIVER_CATALOG, getBridgeLogger } from '../../chunk-TNSCHS4I.js';
3
+ import { BUILTIN_DRIVER_CATALOG, getBridgeLogger } from '../../chunk-APHTT5GE.js';
4
4
  import '../../chunk-6E6PKKAD.js';
5
5
  import '../../chunk-JB35MVBN.js';
6
6
  import '../../chunk-NSBPE2FW.js';
@@ -1,10 +1,129 @@
1
1
  import { dispatchCapability } from '../../chunk-RRVQAE5D.js';
2
- import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-TNSCHS4I.js';
2
+ import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-APHTT5GE.js';
3
3
  import '../../chunk-6E6PKKAD.js';
4
4
  import '../../chunk-JB35MVBN.js';
5
5
  import '../../chunk-NSBPE2FW.js';
6
6
  import * as z from 'zod';
7
7
 
8
+ // bridge/src/drivers/flow-script.ts
9
+ var TURN_ENDING = /* @__PURE__ */ new Set([
10
+ "request_approval",
11
+ "request_input",
12
+ "fail_node"
13
+ ]);
14
+ function isTurnEnding(action) {
15
+ return TURN_ENDING.has(action.op);
16
+ }
17
+ function actionArgs(action) {
18
+ switch (action.op) {
19
+ case "start_node":
20
+ case "skip_node":
21
+ return { nodeId: action.nodeId };
22
+ case "complete_node":
23
+ return { nodeId: action.nodeId, summary: action.summary };
24
+ case "request_approval":
25
+ return { nodeId: action.nodeId, summary: action.summary };
26
+ case "request_input":
27
+ return { nodeId: action.nodeId, prompt: action.prompt, schema: action.schema };
28
+ case "fail_node":
29
+ return {
30
+ nodeId: action.nodeId,
31
+ message: action.message,
32
+ recoverable: String(action.recoverable)
33
+ };
34
+ }
35
+ }
36
+ function summaryFor(d, n) {
37
+ return d.summary ?? `Scripted output for ${n.id}`;
38
+ }
39
+ function decideFlowAction(state, script) {
40
+ if (state.status === "complete" || state.status === "failed" || state.status === "cancelled") {
41
+ return null;
42
+ }
43
+ const dir = (id) => script.nodes?.[id] ?? script.default ?? {};
44
+ const nodes = Object.values(state.nodes);
45
+ for (const n of nodes) {
46
+ if (n.status === "awaiting_approval" && n.approval?.decision === "approved") {
47
+ return { op: "complete_node", nodeId: n.id, summary: summaryFor(dir(n.id), n) };
48
+ }
49
+ }
50
+ for (const n of nodes) {
51
+ if (n.status !== "running") continue;
52
+ const d = dir(n.id);
53
+ const onRun = d.onRun ?? "auto";
54
+ const resolved = onRun === "auto" ? state.autonomousMode ? "complete" : "approve" : onRun;
55
+ if (resolved === "complete") {
56
+ return { op: "complete_node", nodeId: n.id, summary: summaryFor(d, n) };
57
+ }
58
+ if (resolved === "approve") {
59
+ return { op: "request_approval", nodeId: n.id, summary: summaryFor(d, n) };
60
+ }
61
+ if (resolved === "input") {
62
+ const lastInput = n.inputHistory[n.inputHistory.length - 1];
63
+ if (lastInput && lastInput.response !== void 0) {
64
+ return state.autonomousMode ? { op: "complete_node", nodeId: n.id, summary: summaryFor(d, n) } : { op: "request_approval", nodeId: n.id, summary: summaryFor(d, n) };
65
+ }
66
+ return {
67
+ op: "request_input",
68
+ nodeId: n.id,
69
+ prompt: d.input?.prompt ?? `Provide input for ${n.id}`,
70
+ schema: JSON.stringify(d.input?.schema ?? { kind: "text" })
71
+ };
72
+ }
73
+ if (resolved === "fail") {
74
+ const recoverable = d.recoverable ?? false;
75
+ if (!recoverable) {
76
+ return {
77
+ op: "fail_node",
78
+ nodeId: n.id,
79
+ message: d.summary ?? `Scripted failure for ${n.id}`,
80
+ recoverable: false
81
+ };
82
+ }
83
+ const emitted = n.errorHistory.filter((e) => e.recoverable).length;
84
+ const failCount = Math.max(1, d.failCount ?? 1);
85
+ if (emitted < failCount) {
86
+ return {
87
+ op: "fail_node",
88
+ nodeId: n.id,
89
+ message: d.summary ?? `Scripted recoverable failure for ${n.id}`,
90
+ recoverable: true
91
+ };
92
+ }
93
+ return state.autonomousMode ? { op: "complete_node", nodeId: n.id, summary: summaryFor(d, n) } : { op: "request_approval", nodeId: n.id, summary: summaryFor(d, n) };
94
+ }
95
+ return { op: "complete_node", nodeId: n.id, summary: summaryFor(d, n) };
96
+ }
97
+ for (const n of nodes) {
98
+ if (n.status !== "available") continue;
99
+ const d = dir(n.id);
100
+ const lastApproval = n.approvalHistory[n.approvalHistory.length - 1];
101
+ if (lastApproval?.decision === "rejected" && d.onReject === "fail") {
102
+ return {
103
+ op: "fail_node",
104
+ nodeId: n.id,
105
+ message: d.summary ?? `Rejected and not recoverable: ${n.id}`,
106
+ recoverable: false
107
+ };
108
+ }
109
+ if (d.onRun === "skip") {
110
+ return { op: "skip_node", nodeId: n.id };
111
+ }
112
+ return { op: "start_node", nodeId: n.id };
113
+ }
114
+ return null;
115
+ }
116
+ function parseFlowScript(body) {
117
+ const trimmed = body.trim();
118
+ if (trimmed.length === 0) return {};
119
+ const parsed = JSON.parse(trimmed);
120
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
121
+ throw new Error("flow script must be a JSON object");
122
+ }
123
+ return parsed;
124
+ }
125
+
126
+ // bridge/src/drivers/echo.ts
8
127
  var EchoDriver = class extends AgentDriver {
9
128
  driverInfo = {
10
129
  id: "echo",
@@ -15,6 +134,13 @@ var EchoDriver = class extends AgentDriver {
15
134
  log = getBridgeLogger("echo");
16
135
  running = false;
17
136
  config;
137
+ /**
138
+ * Scripted-flow mode state (workspaces#396). Enabled by a `[test-flow]`
139
+ * sentinel chat message; once on, orchestrator-prompt turns are driven
140
+ * deterministically against `config.flowTestDriver`. `null` script ⇒ mode
141
+ * off (default echo behaviour, unchanged).
142
+ */
143
+ flowScript = null;
18
144
  constructor(config) {
19
145
  super();
20
146
  this.config = config;
@@ -60,6 +186,25 @@ var EchoDriver = class extends AgentDriver {
60
186
  const content = message.toLowerCase();
61
187
  this.log.info("received prompt", { preview: message.slice(0, 80), length: message.length });
62
188
  await new Promise((resolve) => setTimeout(resolve, 200));
189
+ const flowMatch = /^\s*\[test-flow\]\s*(.*)$/s.exec(message);
190
+ if (flowMatch) {
191
+ let summary;
192
+ try {
193
+ this.flowScript = parseFlowScript(flowMatch[1] ?? "");
194
+ summary = "echo[test-flow]: scripted-flow mode armed";
195
+ } catch (err) {
196
+ this.flowScript = null;
197
+ summary = `echo[test-flow]: invalid script \u2014 ${err instanceof Error ? err.message : String(err)}`;
198
+ this.emit("agent-event", { type: "error", error: summary, fatal: false });
199
+ }
200
+ for (const event of textAndResult(summary)) this.emit("agent-event", event);
201
+ this.emit("agent-event", { type: "agent_end" });
202
+ return;
203
+ }
204
+ if (this.flowScript && this.config.flowTestDriver && isFlowTurn(message)) {
205
+ await this.runScriptedFlowTurn();
206
+ return;
207
+ }
63
208
  const capMatch = /^\s*\[test-cap:([\w.\-_]+)\]\s*(.*)$/s.exec(message);
64
209
  if (capMatch) {
65
210
  const name = capMatch[1] ?? "";
@@ -116,6 +261,58 @@ var EchoDriver = class extends AgentDriver {
116
261
  }
117
262
  return events;
118
263
  }
264
+ /**
265
+ * Scripted-flow turn (workspaces#396). Reads the live flow state via the
266
+ * runner-injected `flowTestDriver` hook and executes the scripted next
267
+ * action(s) until the policy yields or emits a turn-ending action. Each
268
+ * mutation fires the adapter's `onChange` (→ host `state_changed`) and, when
269
+ * the runner wires the stimulus bus, queues the follow-up turn — so the
270
+ * driver advances one step at a time exactly like a real LLM orchestrator.
271
+ */
272
+ async runScriptedFlowTurn() {
273
+ const hook = this.config.flowTestDriver;
274
+ const script = this.flowScript;
275
+ if (!hook || !script) {
276
+ this.emit("agent-event", { type: "agent_end" });
277
+ return;
278
+ }
279
+ const executed = [];
280
+ const MAX_STEPS = 200;
281
+ for (let i = 0; i < MAX_STEPS; i++) {
282
+ const state = hook.getState();
283
+ if (!state) break;
284
+ const action = decideFlowAction(state, script);
285
+ if (!action) break;
286
+ this.emit("agent-event", {
287
+ type: "tool_call",
288
+ name: action.op,
289
+ tool: { name: action.op },
290
+ input: action.nodeId
291
+ });
292
+ try {
293
+ await hook.execute(action.op, actionArgs(action));
294
+ } catch (err) {
295
+ const msg = err instanceof Error ? err.message : String(err);
296
+ this.log.warn("scripted flow op failed", {
297
+ op: action.op,
298
+ nodeId: action.nodeId,
299
+ error: msg
300
+ });
301
+ this.emit("agent-event", {
302
+ type: "error",
303
+ error: `echo[test-flow]: ${action.op}(${action.nodeId}) failed: ${msg}`,
304
+ fatal: false
305
+ });
306
+ break;
307
+ }
308
+ this.emit("agent-event", { type: "tool_execution_end", toolName: action.op });
309
+ executed.push(`${action.op}(${action.nodeId})`);
310
+ if (isTurnEnding(action)) break;
311
+ }
312
+ const summary = executed.length > 0 ? `echo[test-flow]: ${executed.join(" \u2192 ")}` : "echo[test-flow]: no action (yielding to host)";
313
+ for (const event of textAndResult(summary)) this.emit("agent-event", event);
314
+ this.emit("agent-event", { type: "agent_end" });
315
+ }
119
316
  async abort() {
120
317
  this.log.info("abort requested");
121
318
  }
@@ -130,6 +327,9 @@ var EchoDriver = class extends AgentDriver {
130
327
  return this.running;
131
328
  }
132
329
  };
330
+ function isFlowTurn(message) {
331
+ return message.startsWith("# Flow Execution Context");
332
+ }
133
333
  function safeStringify(v) {
134
334
  try {
135
335
  return JSON.stringify(v);