@skaile/workspaces 1.10.2 → 1.11.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 (123) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/{asset-feeds-FMV3SJVQ.js → asset-feeds-2DQJNYTO.js} +4 -4
  3. package/dist/{asset-feeds-FMV3SJVQ.js.map → asset-feeds-2DQJNYTO.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 +8 -6
  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.map +1 -1
  17. package/dist/bridge/src/drivers/flow-script.d.ts +3 -2
  18. package/dist/bridge/src/drivers/flow-script.d.ts.map +1 -1
  19. package/dist/bridge/src/types.d.ts +7 -0
  20. package/dist/bridge/src/types.d.ts.map +1 -1
  21. package/dist/{chunk-NQD7INSF.js → chunk-25LDSYP4.js} +4 -4
  22. package/dist/{chunk-NQD7INSF.js.map → chunk-25LDSYP4.js.map} +1 -1
  23. package/dist/{chunk-DEYYRFQU.js → chunk-3EBFDMZC.js} +10 -7
  24. package/dist/chunk-3EBFDMZC.js.map +1 -0
  25. package/dist/{chunk-QHU6TM7D.js → chunk-A7GDV5BV.js} +2 -2
  26. package/dist/{chunk-QHU6TM7D.js.map → chunk-A7GDV5BV.js.map} +1 -1
  27. package/dist/{chunk-ZDRAMXBS.js → chunk-AT3DUOZD.js} +3 -3
  28. package/dist/{chunk-ZDRAMXBS.js.map → chunk-AT3DUOZD.js.map} +1 -1
  29. package/dist/{chunk-GEZMBQ3R.js → chunk-B2RBDYQS.js} +3 -3
  30. package/dist/{chunk-GEZMBQ3R.js.map → chunk-B2RBDYQS.js.map} +1 -1
  31. package/dist/{chunk-TR6E5JOF.js → chunk-D4IYQI4G.js} +6 -6
  32. package/dist/{chunk-TR6E5JOF.js.map → chunk-D4IYQI4G.js.map} +1 -1
  33. package/dist/{chunk-XVWK3VHH.js → chunk-GAA5W4VX.js} +3 -3
  34. package/dist/{chunk-XVWK3VHH.js.map → chunk-GAA5W4VX.js.map} +1 -1
  35. package/dist/{chunk-T5XXWWHT.js → chunk-H5XWVDL4.js} +3 -3
  36. package/dist/{chunk-T5XXWWHT.js.map → chunk-H5XWVDL4.js.map} +1 -1
  37. package/dist/{chunk-4N5XR5DQ.js → chunk-HPGV54O4.js} +12 -3
  38. package/dist/chunk-HPGV54O4.js.map +1 -0
  39. package/dist/{chunk-JLJ3OMHR.js → chunk-MTNGINBO.js} +48 -9
  40. package/dist/chunk-MTNGINBO.js.map +1 -0
  41. package/dist/{chunk-2ZP6KIIQ.js → chunk-SPC3TJPZ.js} +2 -2
  42. package/dist/{chunk-2ZP6KIIQ.js.map → chunk-SPC3TJPZ.js.map} +1 -1
  43. package/dist/{chunk-IFCHOBEF.js → chunk-TEU4LMJB.js} +6 -6
  44. package/dist/{chunk-IFCHOBEF.js.map → chunk-TEU4LMJB.js.map} +1 -1
  45. package/dist/{chunk-2257NSNY.js → chunk-UFGWIXRA.js} +20 -7
  46. package/dist/chunk-UFGWIXRA.js.map +1 -0
  47. package/dist/{chunk-SMWXVW6Z.js → chunk-XZ2ZXULF.js} +4 -4
  48. package/dist/{chunk-SMWXVW6Z.js.map → chunk-XZ2ZXULF.js.map} +1 -1
  49. package/dist/{chunk-EAJWXVQL.js → chunk-YFXTWKCN.js} +5 -5
  50. package/dist/{chunk-EAJWXVQL.js.map → chunk-YFXTWKCN.js.map} +1 -1
  51. package/dist/{chunk-KF3KDVKT.js → chunk-YM5P2P4R.js} +2 -2
  52. package/dist/chunk-YM5P2P4R.js.map +1 -0
  53. package/dist/{chunk-PU3FGN4T.js → chunk-ZBUEGXBO.js} +2 -2
  54. package/dist/{chunk-PU3FGN4T.js.map → chunk-ZBUEGXBO.js.map} +1 -1
  55. package/dist/cli/index.js +29 -29
  56. package/dist/connectors/index.js +3 -3
  57. package/dist/{ensure-sources-OJ5GIRZF.js → ensure-sources-UQRURIW2.js} +4 -4
  58. package/dist/{ensure-sources-OJ5GIRZF.js.map → ensure-sources-UQRURIW2.js.map} +1 -1
  59. package/dist/factory-assets/connectors/box.js +3 -3
  60. package/dist/factory-assets/connectors/deploy.js +3 -3
  61. package/dist/factory-assets/connectors/devserver.js +3 -3
  62. package/dist/factory-assets/connectors/flow/adapter.d.ts +2 -0
  63. package/dist/factory-assets/connectors/flow/adapter.d.ts.map +1 -1
  64. package/dist/factory-assets/connectors/flow/adapter.js +3 -3
  65. package/dist/factory-assets/connectors/flow/engine/flow-manifest.d.ts +6 -0
  66. package/dist/factory-assets/connectors/flow/engine/flow-manifest.d.ts.map +1 -1
  67. package/dist/factory-assets/connectors/flow/engine/types.d.ts +9 -0
  68. package/dist/factory-assets/connectors/flow/engine/types.d.ts.map +1 -1
  69. package/dist/factory-assets/connectors/flow/engine.js +1 -1
  70. package/dist/factory-assets/connectors/flow/prompt-fragments.d.ts.map +1 -1
  71. package/dist/factory-assets/connectors/flow/prompt-fragments.js +1 -1
  72. package/dist/factory-assets/connectors/flow/run-flow.js +4 -4
  73. package/dist/factory-assets/connectors/flow.js +3 -3
  74. package/dist/factory-assets/connectors/git.js +3 -3
  75. package/dist/factory-assets/connectors/gmail.js +3 -3
  76. package/dist/factory-assets/connectors/googledrive.js +3 -3
  77. package/dist/factory-assets/connectors/local.js +3 -3
  78. package/dist/factory-assets/connectors/mattermost.js +3 -3
  79. package/dist/factory-assets/connectors/memory.js +3 -3
  80. package/dist/factory-assets/connectors/minio.js +3 -3
  81. package/dist/factory-assets/connectors/postgres.js +3 -3
  82. package/dist/factory-assets/connectors/s3.js +3 -3
  83. package/dist/factory-assets/connectors/sharepoint.js +3 -3
  84. package/dist/factory-assets/connectors/sqlite.js +3 -3
  85. package/dist/factory-assets/connectors/static-server.js +3 -3
  86. package/dist/factory-assets/connectors/tunnel.js +3 -3
  87. package/dist/factory-assets/connectors/webdav.js +3 -3
  88. package/dist/factory-assets/connectors/xstate-store.js +3 -3
  89. package/dist/factory-assets/connectors/xstate.js +3 -3
  90. package/dist/{flows-RR6R3WBL.js → flows-TIUWM7SZ.js} +3 -3
  91. package/dist/{flows-RR6R3WBL.js.map → flows-TIUWM7SZ.js.map} +1 -1
  92. package/dist/{helpers-PS37RNFV.js → helpers-23SAM2P6.js} +4 -4
  93. package/dist/{helpers-PS37RNFV.js.map → helpers-23SAM2P6.js.map} +1 -1
  94. package/dist/{library-publish-CRG7JLDZ.js → library-publish-5BXJMSIR.js} +7 -7
  95. package/dist/{library-publish-CRG7JLDZ.js.map → library-publish-5BXJMSIR.js.map} +1 -1
  96. package/dist/{open-library-5SRCSBSY.js → open-library-WV7GNUHL.js} +6 -6
  97. package/dist/{open-library-5SRCSBSY.js.map → open-library-WV7GNUHL.js.map} +1 -1
  98. package/dist/{project-SM2VMQOZ.js → project-CDUJVKCN.js} +5 -5
  99. package/dist/{project-SM2VMQOZ.js.map → project-CDUJVKCN.js.map} +1 -1
  100. package/dist/runner/index.js +7 -7
  101. package/dist/runner/src/serve.d.ts +23 -2
  102. package/dist/runner/src/serve.d.ts.map +1 -1
  103. package/dist/sdk/asset-manager.js +1 -1
  104. package/dist/sdk/bridge.js +2 -2
  105. package/dist/sdk/flow.js +1 -1
  106. package/dist/sdk/index.js +7 -7
  107. package/dist/sdk/runner.js +7 -7
  108. package/dist/{setup-M6QZBZSE.js → setup-RN2M4VOG.js} +4 -4
  109. package/dist/{setup-M6QZBZSE.js.map → setup-RN2M4VOG.js.map} +1 -1
  110. package/dist/{source-Y7ZTBG2U.js → source-7JHYBOFS.js} +7 -7
  111. package/dist/{source-Y7ZTBG2U.js.map → source-7JHYBOFS.js.map} +1 -1
  112. package/dist/{source-manifest-publish-SXJ6LF4S.js → source-manifest-publish-II7N6E2P.js} +8 -8
  113. package/dist/{source-manifest-publish-SXJ6LF4S.js.map → source-manifest-publish-II7N6E2P.js.map} +1 -1
  114. package/dist/tui/index.js +7 -7
  115. package/dist/workspace-plugin/adapters/mcp.js +1 -1
  116. package/dist/workspace-plugin/adapters/omp.js +3 -3
  117. package/dist/workspace-plugin/index.js +1 -1
  118. package/package.json +1 -1
  119. package/dist/chunk-2257NSNY.js.map +0 -1
  120. package/dist/chunk-4N5XR5DQ.js.map +0 -1
  121. package/dist/chunk-DEYYRFQU.js.map +0 -1
  122. package/dist/chunk-JLJ3OMHR.js.map +0 -1
  123. package/dist/chunk-KF3KDVKT.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#412](https://github.com/skaile-ai/workspaces/pull/412) [`3b4bde5`](https://github.com/skaile-ai/workspaces/commit/3b4bde5451af0a413ba22afccb7a8e487bae67cd) Thanks [@peteralbert](https://github.com/peteralbert)! - Add mandatory hard approval gates that autonomous mode cannot skip.
8
+
9
+ An approval-gate node may now set `data.approval.mandatory: true` in its flow
10
+ definition. In autonomous mode the runner still parks a mandatory gate at
11
+ `awaiting_approval` and requires a human `applyApproval(approved)` before it can
12
+ `complete` — the `FlowAdapter` rejects a `complete_node` from `running` on a
13
+ mandatory gate, and the orchestrator prompt tells the agent it may not skip it.
14
+ Non-mandatory gates keep the existing auto-skip behavior; the flag defaults to
15
+ absent/false, preserving current behavior exactly.
16
+
17
+ The flag rides the flow definition JSON, so this is additive and not
18
+ wire-visible: no protocol/envelope version bump, no `FlowExecution` shape
19
+ change. `validateFlow` accepts and type-checks the flag. The scripted echo
20
+ driver (`flow-script.ts`) resolves `onRun: "auto"` to `request_approval` on a
21
+ mandatory gate even when autonomous, so hosts can e2e a hard gate
22
+ deterministically.
23
+
24
+ ## 1.10.3
25
+
26
+ ### Patch Changes
27
+
28
+ - [#408](https://github.com/skaile-ai/workspaces/pull/408) [`b0e386f`](https://github.com/skaile-ai/workspaces/commit/b0e386f206f7a53b2d25b6cfb6ff1b4e3f909b19) Thanks [@peteralbert](https://github.com/peteralbert)! - Fix a shared-reference snapshot corruption in `FlowAdapter.mutate()` that could
29
+ drop `state_changed` signals. After a signaling mutation, `lastSignaledExecution`
30
+ aliases the live `execution` object; the next mutation's in-place
31
+ `nodes[x] = {...}` reassignment mutated that "previous" snapshot before
32
+ `computeStimulus` diffed it, so any transition whose only change is a
33
+ non-fast-path field (e.g. an approved-only `approval.decision` flip) compared
34
+ equal and produced no signal — an intermittent missed turn kick.
35
+
36
+ `mutate()` now shallow-clones the top-level snapshot and its `nodes` map before
37
+ running the mutator, so the mutator can no longer corrupt the previously-signaled
38
+ snapshot. No behaviour change for mutations that already signalled. No
39
+ protocol/envelope/flow-contract change.
40
+
41
+ - [#409](https://github.com/skaile-ai/workspaces/pull/409) [`70f0efd`](https://github.com/skaile-ai/workspaces/commit/70f0efdbf65c2803a72fdf084ec45fe8fcd0b4f1) Thanks [@peteralbert](https://github.com/peteralbert)! - Replay live store snapshots to a newly-attached subscriber, fixing cold-spawn
42
+ warmup event loss. Host-op `state_changed` events (flow mutations, shared-state
43
+ changes) fired in the first ~15-20s after a cold `skaile serve` spawn were
44
+ dropped: `sendEvent` is fire-and-forward and the sole `transport.onConnect`
45
+ handler emitted only availability, never state, so anything emitted before the
46
+ host's sync loop attached was lost forever.
47
+
48
+ A second `onConnect` handler now replays the CURRENT snapshot of every live
49
+ state-bearing store (flow stores read the authoritative FlowExecution off the
50
+ adapter; shared-state stores identified by the xstate-store `onStoreChange` hook,
51
+ read via `get`; git/mount/MCP skipped). Snapshots are idempotent latest-wins on
52
+ the host, so a late subscriber converges to the same state an early one holds and
53
+ a reconnect re-applies identical state without divergence. Runs after
54
+ availability so the host learns the stores exist before their state arrives, and
55
+ is consistent with the session_init re-emit paths. No protocol/envelope/
56
+ flow-contract change.
57
+
3
58
  ## 1.10.2
4
59
 
5
60
  ### Patch 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-5SRCSBSY.js'),
67
+ import('./open-library-WV7GNUHL.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-5SRCSBSY.js');
100
+ const { resolveCatalogSource } = await import('./open-library-WV7GNUHL.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-FMV3SJVQ.js.map
205
- //# sourceMappingURL=asset-feeds-FMV3SJVQ.js.map
204
+ //# sourceMappingURL=asset-feeds-2DQJNYTO.js.map
205
+ //# sourceMappingURL=asset-feeds-2DQJNYTO.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,E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AAM,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
+ {"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,CAA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,KAAK,CAAC,CAAA;AAAA,EACZ;AACA,EAAA,OAAO,GAAA;AACT","file":"asset-feeds-2DQJNYTO.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-PU3FGN4T.js';
1
+ export { AssetManager, FACTORY_SOURCE_URL, MissingManifestError, NON_DEPLOYABLE_KINDS, normalizeRepoUrl, parseCanonicalLockKey, parseRefTolerant, softDepName } from '../chunk-ZBUEGXBO.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-KF3KDVKT.js';
5
+ import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-YM5P2P4R.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-KF3KDVKT.js';
3
+ import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-YM5P2P4R.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-XVWK3VHH.js';
1
+ import { SubprocessCliDriver, mapApiKeysToEnv, extractText, extractCost, extractTokens } from '../../chunk-GAA5W4VX.js';
2
2
  import '../../chunk-GAH4YRCI.js';
3
- import { BUILTIN_DRIVER_CATALOG, getBridgeLogger } from '../../chunk-KF3KDVKT.js';
3
+ import { BUILTIN_DRIVER_CATALOG, getBridgeLogger } from '../../chunk-YM5P2P4R.js';
4
4
  import '../../chunk-6E6PKKAD.js';
5
5
  import '../../chunk-JB35MVBN.js';
6
6
  import '../../chunk-NSBPE2FW.js';
@@ -1,5 +1,5 @@
1
1
  import { dispatchCapability } from '../../chunk-RRVQAE5D.js';
2
- import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-KF3KDVKT.js';
2
+ import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-YM5P2P4R.js';
3
3
  import '../../chunk-6E6PKKAD.js';
4
4
  import '../../chunk-JB35MVBN.js';
5
5
  import '../../chunk-NSBPE2FW.js';
@@ -36,12 +36,13 @@ function actionArgs(action) {
36
36
  function summaryFor(d, n) {
37
37
  return d.summary ?? `Scripted output for ${n.id}`;
38
38
  }
39
- function decideFlowAction(state, script) {
39
+ function decideFlowAction(state, script, mandatoryGates = /* @__PURE__ */ new Set()) {
40
40
  if (state.status === "complete" || state.status === "failed" || state.status === "cancelled") {
41
41
  return null;
42
42
  }
43
43
  const dir = (id) => script.nodes?.[id] ?? script.default ?? {};
44
44
  const nodes = Object.values(state.nodes);
45
+ const canAutoComplete = (id) => state.autonomousMode && !mandatoryGates.has(id);
45
46
  for (const n of nodes) {
46
47
  if (n.status === "awaiting_approval" && n.approval?.decision === "approved") {
47
48
  return { op: "complete_node", nodeId: n.id, summary: summaryFor(dir(n.id), n) };
@@ -51,7 +52,7 @@ function decideFlowAction(state, script) {
51
52
  if (n.status !== "running") continue;
52
53
  const d = dir(n.id);
53
54
  const onRun = d.onRun ?? "auto";
54
- const resolved = onRun === "auto" ? state.autonomousMode ? "complete" : "approve" : onRun;
55
+ const resolved = onRun === "auto" ? canAutoComplete(n.id) ? "complete" : "approve" : onRun;
55
56
  if (resolved === "complete") {
56
57
  return { op: "complete_node", nodeId: n.id, summary: summaryFor(d, n) };
57
58
  }
@@ -61,7 +62,7 @@ function decideFlowAction(state, script) {
61
62
  if (resolved === "input") {
62
63
  const lastInput = n.inputHistory[n.inputHistory.length - 1];
63
64
  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
+ return canAutoComplete(n.id) ? { op: "complete_node", nodeId: n.id, summary: summaryFor(d, n) } : { op: "request_approval", nodeId: n.id, summary: summaryFor(d, n) };
65
66
  }
66
67
  return {
67
68
  op: "request_input",
@@ -90,7 +91,7 @@ function decideFlowAction(state, script) {
90
91
  recoverable: true
91
92
  };
92
93
  }
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
+ return canAutoComplete(n.id) ? { op: "complete_node", nodeId: n.id, summary: summaryFor(d, n) } : { op: "request_approval", nodeId: n.id, summary: summaryFor(d, n) };
94
95
  }
95
96
  return { op: "complete_node", nodeId: n.id, summary: summaryFor(d, n) };
96
97
  }
@@ -281,7 +282,8 @@ var EchoDriver = class extends AgentDriver {
281
282
  for (let i = 0; i < MAX_STEPS; i++) {
282
283
  const state = hook.getState();
283
284
  if (!state) break;
284
- const action = decideFlowAction(state, script);
285
+ const mandatoryGates = new Set(hook.mandatoryGates?.() ?? []);
286
+ const action = decideFlowAction(state, script, mandatoryGates);
285
287
  if (!action) break;
286
288
  this.emit("agent-event", {
287
289
  type: "tool_call",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../bridge/src/drivers/flow-script.ts","../../../bridge/src/drivers/echo.ts"],"names":["events"],"mappings":";;;;;;;;AA4FA,IAAM,WAAA,uBAAiD,GAAA,CAAI;AAAA,EACzD,kBAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF,CAAC,CAAA;AAGM,SAAS,aAAa,MAAA,EAA6B;AACxD,EAAA,OAAO,WAAA,CAAY,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA;AAClC;AAGO,SAAS,WAAW,MAAA,EAA6C;AACtE,EAAA,QAAQ,OAAO,EAAA;AAAI,IACjB,KAAK,YAAA;AAAA,IACL,KAAK,WAAA;AACH,MAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,CAAO,MAAA,EAAO;AAAA,IACjC,KAAK,eAAA;AACH,MAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,CAAO,MAAA,EAAQ,OAAA,EAAS,OAAO,OAAA,EAAQ;AAAA,IAC1D,KAAK,kBAAA;AACH,MAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,CAAO,MAAA,EAAQ,OAAA,EAAS,OAAO,OAAA,EAAQ;AAAA,IAC1D,KAAK,eAAA;AACH,MAAA,OAAO,EAAE,QAAQ,MAAA,CAAO,MAAA,EAAQ,QAAQ,MAAA,CAAO,MAAA,EAAQ,MAAA,EAAQ,MAAA,CAAO,MAAA,EAAO;AAAA,IAC/E,KAAK,WAAA;AACH,MAAA,OAAO;AAAA,QACL,QAAQ,MAAA,C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E,oHAAA;AAAA,MACF,KAAA,EAAO;AAAA,KACR,CAAA;AAAA,EACH,CAAA,MAAA,IAAW,OAAA,CAAQ,QAAA,CAAS,YAAY,CAAA,EAAG;AACzC,IAAA,MAAA,CAAO,IAAA,CAAK;AAAA,MACV,IAAA,EAAM,OAAA;AAAA,MACN,KAAA,EACE,yHAAA;AAAA,MACF,KAAA,EAAO;AAAA,KACR,CAAA;AAAA,EACH,CAAA,MAAO;AAEL,IAAA,MAAM,OAAA,GACJ,6BAA6B,cAAc,CAAA,2GAAA,CAAA;AAE7C,IAAA,MAAA,CAAO,IAAA,CAAK,GAAG,aAAA,CAAc,OAAO,CAAC,CAAA;AAAA,EACvC;AAEA,EAAA,OAAO,MAAA;AACT;AAMO,IAAM,gBAAA,GAA8C;AAAA,EACzD,EAAA,EAAI,MAAA;AAAA,EACJ,WAAA,EAAa,sBAAA,CAAuB,IAAA,EAAM,IAAA,IAAQ,iBAAA;AAAA,EAClD,UAAA,EAAY,CAAA;AAAA;AAAA,EAEZ,YAAA,EAAgB,CAAA,CAAA,MAAA,CAAoB,MAAM,IAAI,CAAA;AAAA,EAC9C,QAAQ,OAAO,MAAA,EAAQ,IAAA,KAAS,IAAI,WAAW,MAAM,CAAA;AAAA,EACrD,UAAA,EAAY,OAAO,OAAA,KACjB,IAAI,WAAW,EAAE,GAAA,EAAK,OAAA,CAAQ,GAAA,IAAO,SAAA,EAAW,YAAA,EAAc,OAAA,EAAS,EAAE,UAAA;AAC7E","file":"echo.js","sourcesContent":["/**\n * Scripted-flow decision logic for the echo driver.\n *\n * Pure, deterministic policy that maps a live {@link FlowExecution} snapshot\n * (plus an optional per-node script) to the single next flow-adapter mutation\n * the driver should emit this iteration. The echo driver calls this in a loop\n * per turn (see `echo.ts`), executing each returned action against the\n * runner-injected {@link FlowTestDriverHook} until it yields (`null`) or emits\n * a turn-ending action.\n *\n * The policy mirrors what a real LLM orchestrator would do, but without an\n * LLM: it reacts to state each turn, so a host can drive a flow to `complete`,\n * park it at an approval/input gate, and exercise the reject/recover path\n * simply by applying host mutations (`applyApproval`, `applyInput`, …) between\n * turns. No new protocol, no flow-contract change — it only calls the existing\n * FlowAdapter agent-tool operations.\n *\n * @docLink packages/bridge/drivers#scripted-flow\n * @since 3.6.0\n */\n\nimport type { FlowExecution, NodeExecution } from \"@skaile/workspaces/types\";\n\n/**\n * What the scripted driver should do when a node reaches its decision point.\n *\n * - `auto` (default): follow the flow's `autonomousMode` — `complete_node`\n * when autonomous, else `request_approval`.\n * - `complete`: always `complete_node` (autonomous-style, even if the flow's\n * autonomousMode is false — the adapter allows it only when autonomous, so\n * use with autonomous flows).\n * - `approve`: always `request_approval` (park at an approval gate).\n * - `input`: `request_input` once; after the host applies input, fall back to\n * `auto` behaviour.\n * - `skip`: `skip_node` (optional nodes only).\n * - `fail`: `fail_node`. With `recoverable: false` (default) this is terminal.\n * With `recoverable: true` the node returns to `available`; the driver\n * re-emits the recoverable failure `failCount` times (default 1) and then\n * proceeds as `auto` — it never deadlocks on a recoverable fail.\n */\nexport type OnRun = \"auto\" | \"complete\" | \"approve\" | \"input\" | \"skip\" | \"fail\";\n\n/**\n * What to do when a node returns to `available` after a rejection.\n *\n * - `retry` (default): re-drive it — `start_node` again, then its `onRun`.\n * - `fail`: `fail_node(recoverable: false)` — exercises the terminal path.\n */\nexport type OnReject = \"retry\" | \"fail\";\n\n/** Per-node scripting directive. All fields optional. */\nexport interface FlowNodeDirective {\n onRun?: OnRun;\n onReject?: OnReject;\n /** For `onRun: \"input\"` — the input request shown to the host. */\n input?: { prompt?: string; schema?: unknown };\n /** For `onRun: \"fail\"` — whether the failure is recoverable. Default false. */\n recoverable?: boolean;\n /**\n * For `onRun: \"fail\"` with `recoverable: true` — how many recoverable\n * failures to emit before the node proceeds as `auto`. Default 1. Counted\n * from the node's own `errorHistory`, so the policy stays a pure function of\n * state (no driver-instance bookkeeping) and never deadlocks.\n */\n failCount?: number;\n /** Summary text used for `complete_node` / `request_approval` / failures. */\n summary?: string;\n}\n\n/**\n * A scripted-flow program. Empty (`{}`) means \"canonical policy\": start each\n * available node, then complete (autonomous) or request approval (interactive)\n * — enough to drive the autonomous-complete, approval-gate, and reject/recover\n * scenarios with no per-node scripting at all.\n */\nexport interface FlowScript {\n /** Per-node overrides, keyed by node id. */\n nodes?: Record<string, FlowNodeDirective>;\n /** Fallback directive for any node without its own entry. */\n default?: FlowNodeDirective;\n}\n\n/** A single flow-adapter mutation the driver will execute. */\nexport type FlowAction =\n | { op: \"start_node\"; nodeId: string }\n | { op: \"complete_node\"; nodeId: string; summary: string }\n | { op: \"request_approval\"; nodeId: string; summary: string }\n | { op: \"request_input\"; nodeId: string; prompt: string; schema: string }\n | { op: \"skip_node\"; nodeId: string }\n | { op: \"fail_node\"; nodeId: string; message: string; recoverable: boolean };\n\n/** Ops that end the agent turn (the runner yields until the host acts). */\nconst TURN_ENDING: ReadonlySet<FlowAction[\"op\"]> = new Set([\n \"request_approval\",\n \"request_input\",\n \"fail_node\",\n]);\n\n/** Whether an action ends the turn (driver stops looping after emitting it). */\nexport function isTurnEnding(action: FlowAction): boolean {\n return TURN_ENDING.has(action.op);\n}\n\n/** Map a {@link FlowAction} to the `executeOp` argument bag the adapter expects. */\nexport function actionArgs(action: FlowAction): Record<string, unknown> {\n switch (action.op) {\n case \"start_node\":\n case \"skip_node\":\n return { nodeId: action.nodeId };\n case \"complete_node\":\n return { nodeId: action.nodeId, summary: action.summary };\n case \"request_approval\":\n return { nodeId: action.nodeId, summary: action.summary };\n case \"request_input\":\n return { nodeId: action.nodeId, prompt: action.prompt, schema: action.schema };\n case \"fail_node\":\n return {\n nodeId: action.nodeId,\n message: action.message,\n recoverable: String(action.recoverable),\n };\n }\n}\n\nfunction summaryFor(d: FlowNodeDirective, n: NodeExecution): string {\n return d.summary ?? `Scripted output for ${n.id}`;\n}\n\n/**\n * Decide the single next flow action for the current state, or `null` to yield\n * (nothing to do this iteration — wait for a host mutation).\n *\n * Priority order: resolve approved gates → advance running nodes → start (or\n * skip / terminally-fail) available nodes. Terminal flow states and gates with\n * no decision / input yet yield.\n *\n * Pure — the fail bookkeeping (how many recoverable failures a node has already\n * emitted) is read from the node's own `errorHistory`, so no external counter is\n * needed and a recoverable `fail` directive can never deadlock.\n */\nexport function decideFlowAction(state: FlowExecution, script: FlowScript): FlowAction | null {\n // Terminal flow — never fight a completed/failed/cancelled run.\n if (state.status === \"complete\" || state.status === \"failed\" || state.status === \"cancelled\") {\n return null;\n }\n\n const dir = (id: string): FlowNodeDirective => script.nodes?.[id] ?? script.default ?? {};\n const nodes = Object.values(state.nodes);\n\n // 1. Approved gate → complete.\n for (const n of nodes) {\n if (n.status === \"awaiting_approval\" && n.approval?.decision === \"approved\") {\n return { op: \"complete_node\", nodeId: n.id, summary: summaryFor(dir(n.id), n) };\n }\n }\n\n // 2. Running node → per directive.\n for (const n of nodes) {\n if (n.status !== \"running\") continue;\n const d = dir(n.id);\n const onRun: OnRun = d.onRun ?? \"auto\";\n const resolved: OnRun =\n onRun === \"auto\" ? (state.autonomousMode ? \"complete\" : \"approve\") : onRun;\n\n if (resolved === \"complete\") {\n return { op: \"complete_node\", nodeId: n.id, summary: summaryFor(d, n) };\n }\n if (resolved === \"approve\") {\n return { op: \"request_approval\", nodeId: n.id, summary: summaryFor(d, n) };\n }\n if (resolved === \"input\") {\n const lastInput = n.inputHistory[n.inputHistory.length - 1];\n if (lastInput && lastInput.response !== undefined) {\n // Input already provided — proceed as if `auto`.\n return state.autonomousMode\n ? { op: \"complete_node\", nodeId: n.id, summary: summaryFor(d, n) }\n : { op: \"request_approval\", nodeId: n.id, summary: summaryFor(d, n) };\n }\n return {\n op: \"request_input\",\n nodeId: n.id,\n prompt: d.input?.prompt ?? `Provide input for ${n.id}`,\n schema: JSON.stringify(d.input?.schema ?? { kind: \"text\" }),\n };\n }\n if (resolved === \"fail\") {\n const recoverable = d.recoverable ?? false;\n if (!recoverable) {\n // Terminal fail — the adapter marks node + flow `failed`, so the\n // terminal-status guard above stops any re-fire on later turns.\n return {\n op: \"fail_node\",\n nodeId: n.id,\n message: d.summary ?? `Scripted failure for ${n.id}`,\n recoverable: false,\n };\n }\n // Recoverable fail — emit up to `failCount` times (counting the node's\n // own recorded recoverable errors), then proceed as `auto` so the node\n // is not stranded in a re-drive loop.\n const emitted = n.errorHistory.filter((e) => e.recoverable).length;\n const failCount = Math.max(1, d.failCount ?? 1);\n if (emitted < failCount) {\n return {\n op: \"fail_node\",\n nodeId: n.id,\n message: d.summary ?? `Scripted recoverable failure for ${n.id}`,\n recoverable: true,\n };\n }\n return state.autonomousMode\n ? { op: \"complete_node\", nodeId: n.id, summary: summaryFor(d, n) }\n : { op: \"request_approval\", nodeId: n.id, summary: summaryFor(d, n) };\n }\n // `skip` while running is illegal; complete instead to avoid a deadlock.\n return { op: \"complete_node\", nodeId: n.id, summary: summaryFor(d, n) };\n }\n\n // 3. Available node → terminally-fail (post-reject), skip, or start.\n for (const n of nodes) {\n if (n.status !== \"available\") continue;\n const d = dir(n.id);\n const lastApproval = n.approvalHistory[n.approvalHistory.length - 1];\n if (lastApproval?.decision === \"rejected\" && d.onReject === \"fail\") {\n return {\n op: \"fail_node\",\n nodeId: n.id,\n message: d.summary ?? `Rejected and not recoverable: ${n.id}`,\n recoverable: false,\n };\n }\n if (d.onRun === \"skip\") {\n return { op: \"skip_node\", nodeId: n.id };\n }\n return { op: \"start_node\", nodeId: n.id };\n }\n\n // 4. Nothing actionable — awaiting_approval (no decision), awaiting_input\n // (no response), or fully drained. Yield.\n return null;\n}\n\n/**\n * Parse a `[test-flow]` sentinel body into a {@link FlowScript}. An empty body\n * yields the canonical (empty) script. Malformed JSON is a hard error so tests\n * fail loudly rather than silently running the wrong policy.\n */\nexport function parseFlowScript(body: string): FlowScript {\n const trimmed = body.trim();\n if (trimmed.length === 0) return {};\n const parsed: unknown = JSON.parse(trimmed);\n if (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new Error(\"flow script must be a JSON object\");\n }\n return parsed as FlowScript;\n}\n","import type { DriverTarget } from \"@skaile/workspaces/plugin-registry\";\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport * as z from \"zod\";\nimport { dispatchCapability } from \"../capability-dispatch.js\";\nimport { getBridgeLogger } from \"../logger.js\";\nimport { BUILTIN_DRIVER_CATALOG } from \"../registry.js\";\nimport {\n type AgentConfig,\n AgentDriver,\n type AgentEvent,\n type BridgeCapabilityTool,\n type DriverInfo,\n} from \"../types.js\";\nimport {\n actionArgs,\n type FlowScript,\n decideFlowAction,\n isTurnEnding,\n parseFlowScript,\n} from \"./flow-script.js\";\n\n/**\n * Echo/mock driver for E2E testing in docker mode.\n *\n * Runs inside a real Docker container with real WebSocket transport and\n * session lifecycle, but generates deterministic keyword-triggered responses\n * instead of calling the Anthropic API. This lets E2E tests exercise the\n * full infrastructure (containers, WebSocket, session management, message\n * persistence) without needing real AI credentials.\n *\n * Keyword triggers match the MockAgentClient in\n * `platform/backend/libs/agent-gateway/src/mock-agent-client.ts` — the\n * same test messages (\"test toolcall\", \"test question\", etc.) produce\n * the same events.\n *\n * Enable by setting `SKAILE_AGENT_DRIVER=echo` in the container env,\n * or by passing `{ driver: 'echo' }` in the runner config.\n *\n * @docLink packages/bridge/drivers#echo-driver\n */\nexport class EchoDriver extends AgentDriver {\n readonly driverInfo: DriverInfo = {\n id: \"echo\",\n name: \"Echo (E2E mock)\",\n modelAgnostic: true,\n supportsInBandAbort: false,\n };\n\n private readonly log: Logger = getBridgeLogger(\"echo\");\n private running = false;\n private readonly config: AgentConfig;\n\n /**\n * Scripted-flow mode state (workspaces#396). Enabled by a `[test-flow]`\n * sentinel chat message; once on, orchestrator-prompt turns are driven\n * deterministically against `config.flowTestDriver`. `null` script ⇒ mode\n * off (default echo behaviour, unchanged).\n */\n private flowScript: FlowScript | null = null;\n\n constructor(config: AgentConfig) {\n super();\n this.config = config;\n }\n\n /**\n * Test surface: returns the tool list the LLM would see for this turn.\n * Composition: the registry hooks (Protocol v2) take precedence; legacy\n * `mcpServers` is not enumerated here (the echo driver never exposed MCP\n * tools to the LLM by name).\n */\n listCapabilityTools(): BridgeCapabilityTool[] {\n return this.config.capabilities?.composeTools() ?? [];\n }\n\n /**\n * Test surface: invoke a registered capability through the dispatch\n * helper. Mirrors what a real driver would do when the LLM produced a\n * tool_use for the given name — applies fire-and-forget, render emission,\n * and fallback text. Returns the structured dispatch result so tests can\n * assert immediate-vs-background resolution.\n */\n async invokeCapabilityForTest(\n name: string,\n input: unknown,\n ): Promise<{ result: unknown; background: boolean }> {\n const hooks = this.config.capabilities;\n if (!hooks) throw new Error(\"EchoDriver: no capability hooks configured\");\n const callId = `echo-cap-${Date.now()}`;\n const out = await dispatchCapability(hooks, callId, name, input, (err) =>\n this.log.warn(\"background capability handler failed\", {\n name,\n error: String(err),\n }),\n );\n return out;\n }\n\n async start(): Promise<void> {\n this.running = true;\n this.log.info(\"driver started\");\n }\n\n async prompt(message: string): Promise<void> {\n if (!this.running) return;\n const content = message.toLowerCase();\n this.log.info(\"received prompt\", { preview: message.slice(0, 80), length: message.length });\n\n // Small delay to simulate real agent processing\n await new Promise((resolve) => setTimeout(resolve, 200));\n\n // Scripted-flow test seam (workspaces#396) — a `[test-flow]` sentinel\n // arms deterministic flow driving for this session and (optionally)\n // carries a JSON script. Format: `[test-flow] {json}`; empty body ⇒\n // canonical policy. Must be handled before the flow-turn branch below.\n //\n // Detection is LINE-anchored, not message-anchored (workspaces#401): hosts\n // decorate user messages (e.g. a prepended `<SESSION_MEMBERS>` block and a\n // wake-restoration preamble), so the sentinel is rarely at the start of the\n // composed prompt. We match `[test-flow]` at the start of ANY line (only\n // leading whitespace allowed), which is decoration-independent yet still\n // impossible to arm from ordinary prose — a line must BEGIN with the exact\n // token. The optional JSON script must sit on that same line.\n const flowMatch = /^[ \\t]*\\[test-flow\\][ \\t]*(.*)$/m.exec(message);\n if (flowMatch) {\n let summary: string;\n try {\n this.flowScript = parseFlowScript(flowMatch[1] ?? \"\");\n summary = \"echo[test-flow]: scripted-flow mode armed\";\n } catch (err) {\n this.flowScript = null;\n summary = `echo[test-flow]: invalid script — ${err instanceof Error ? err.message : String(err)}`;\n this.emit(\"agent-event\", { type: \"error\", error: summary, fatal: false });\n }\n for (const event of textAndResult(summary)) this.emit(\"agent-event\", event);\n this.emit(\"agent-event\", { type: \"agent_end\" });\n return;\n }\n\n // Scripted-flow turn — the runner reassembles the orchestrator prompt on\n // every flow turn; when scripted-flow mode is armed and a flow driver hook\n // is present, drive nodes deterministically instead of echoing text.\n if (this.flowScript && this.config.flowTestDriver && isFlowTurn(message)) {\n await this.runScriptedFlowTurn();\n return;\n }\n\n // Phase 7B test seam — explicit capability invocation keyword. Lets E2E\n // tests drive `dispatchCapability` from a chat prompt without a real LLM.\n // Format: `[test-cap:<name>] {json}`. Anything after the closing bracket\n // is parsed as JSON input; on parse error we fall back to `{}`.\n const capMatch = /^\\s*\\[test-cap:([\\w.\\-_]+)\\]\\s*(.*)$/s.exec(message);\n if (capMatch) {\n const name = capMatch[1] ?? \"\";\n const rawInput = (capMatch[2] ?? \"\").trim();\n let input: unknown = {};\n if (rawInput.length > 0) {\n try {\n input = JSON.parse(rawInput);\n } catch (err) {\n this.log.warn(\"test-cap input was not valid JSON; defaulting to {}\", {\n error: String(err),\n preview: rawInput.slice(0, 80),\n });\n }\n }\n const events = await this.runCapabilityKeyword(name, input);\n for (const event of events) {\n this.emit(\"agent-event\", event);\n await new Promise((resolve) => setTimeout(resolve, 20));\n }\n this.emit(\"agent-event\", { type: \"agent_end\" });\n return;\n }\n\n const events = buildEchoEvents(content, message);\n for (const event of events) {\n this.emit(\"agent-event\", event);\n // Small gap between events to let the transport process each one\n await new Promise((resolve) => setTimeout(resolve, 50));\n }\n // Signal turn completion — the runner waits for this before accepting\n // the next prompt. Without it, the runner stays stuck after the first message.\n this.emit(\"agent-event\", { type: \"agent_end\" });\n }\n\n /**\n * Phase 7B helper — drive a single capability through the dispatcher and\n * surface the structured outcome as a result event the LLM-side test code\n * can assert against. Used exclusively by the `[test-cap:<name>]` prompt\n * keyword above; never wired into normal chat flow.\n */\n private async runCapabilityKeyword(name: string, input: unknown): Promise<AgentEvent[]> {\n const events: AgentEvent[] = [];\n if (!this.config.capabilities) {\n return textAndResult(`echo[test-cap]: no capability hooks configured (skipping ${name})`);\n }\n try {\n const out = await this.invokeCapabilityForTest(name, input);\n const summary = `echo[test-cap]: invoked ${name} background=${String(out.background)} result=${safeStringify(out.result)}`;\n events.push(...textAndResult(summary));\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n events.push({\n type: \"error\",\n error: `echo[test-cap]: ${name} failed: ${msg}`,\n fatal: false,\n });\n events.push(...textAndResult(`echo[test-cap]: ${name} errored (${msg})`));\n }\n return events;\n }\n\n /**\n * Scripted-flow turn (workspaces#396). Reads the live flow state via the\n * runner-injected `flowTestDriver` hook and executes the scripted next\n * action(s) until the policy yields or emits a turn-ending action. Each\n * mutation fires the adapter's `onChange` (→ host `state_changed`) and, when\n * the runner wires the stimulus bus, queues the follow-up turn — so the\n * driver advances one step at a time exactly like a real LLM orchestrator.\n */\n private async runScriptedFlowTurn(): Promise<void> {\n const hook = this.config.flowTestDriver;\n const script = this.flowScript;\n if (!hook || !script) {\n this.emit(\"agent-event\", { type: \"agent_end\" });\n return;\n }\n\n const executed: string[] = [];\n // Hard cap — the policy is monotonic, but never let a bug spin forever.\n const MAX_STEPS = 200;\n for (let i = 0; i < MAX_STEPS; i++) {\n const state = hook.getState();\n if (!state) break;\n const action = decideFlowAction(state, script);\n if (!action) break;\n\n this.emit(\"agent-event\", {\n type: \"tool_call\",\n name: action.op,\n tool: { name: action.op },\n input: action.nodeId,\n });\n try {\n await hook.execute(action.op, actionArgs(action));\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n this.log.warn(\"scripted flow op failed\", {\n op: action.op,\n nodeId: action.nodeId,\n error: msg,\n });\n this.emit(\"agent-event\", {\n type: \"error\",\n error: `echo[test-flow]: ${action.op}(${action.nodeId}) failed: ${msg}`,\n fatal: false,\n });\n break;\n }\n this.emit(\"agent-event\", { type: \"tool_execution_end\", toolName: action.op });\n executed.push(`${action.op}(${action.nodeId})`);\n if (isTurnEnding(action)) break;\n }\n\n const summary =\n executed.length > 0\n ? `echo[test-flow]: ${executed.join(\" → \")}`\n : \"echo[test-flow]: no action (yielding to host)\";\n for (const event of textAndResult(summary)) this.emit(\"agent-event\", event);\n this.emit(\"agent-event\", { type: \"agent_end\" });\n }\n\n async abort(): Promise<void> {\n this.log.info(\"abort requested\");\n }\n\n kill(): void {\n this.running = false;\n this.log.info(\"killed\");\n }\n\n async resetSession(): Promise<void> {\n this.log.info(\"session reset\");\n }\n\n get isRunning(): boolean {\n return this.running;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Echo response generation — mirrors MockAgentClient.buildMockEvents\n// ---------------------------------------------------------------------------\n\n/**\n * A flow turn is recognised by the orchestrator prompt's stable header\n * (`buildOrchestratorPrompt` in the flow connector). Detection is header-only —\n * the driver reads live state through the injected hook, never by parsing the\n * prompt body.\n */\nfunction isFlowTurn(message: string): boolean {\n return message.startsWith(\"# Flow Execution Context\");\n}\n\nfunction safeStringify(v: unknown): string {\n try {\n return JSON.stringify(v);\n } catch {\n return String(v);\n }\n}\n\nfunction textAndResult(summary: string): AgentEvent[] {\n return [\n {\n type: \"message_start\",\n message: { role: \"assistant\", content: summary },\n },\n {\n type: \"message_end\",\n message: { role: \"assistant\", content: summary },\n },\n {\n type: \"result\",\n subtype: \"success\",\n summary,\n costUsd: 0,\n },\n ];\n}\n\nfunction buildEchoEvents(content: string, originalPrompt: string): AgentEvent[] {\n const events: AgentEvent[] = [];\n\n if (content.includes(\"test all\")) {\n events.push(\n { type: \"tool_call\", name: \"Read\", tool: { name: \"Read\" }, input: \"prisma/schema.prisma\" },\n { type: \"tool_execution_end\", toolName: \"Read\" },\n {\n type: \"tool_call\",\n name: \"Write\",\n tool: { name: \"Write\" },\n input: \"src/modules/sprint/sprint.service.ts\",\n },\n { type: \"tool_execution_end\", toolName: \"Write\" },\n );\n events.push(\n ...textAndResult(\n \"All operations completed successfully. Created sprint service, updated schema, started dev server, and ran E2E tests.\",\n ),\n );\n } else if (content.includes(\"test toolcall\")) {\n events.push(\n {\n type: \"tool_call\",\n name: \"Read\",\n tool: { name: \"Read\" },\n input: \"platform/prisma/schema.prisma\",\n },\n { type: \"tool_execution_end\", toolName: \"Read\" },\n );\n events.push(\n ...textAndResult(\n \"I've read the schema and found 42 models. The data model looks well-structured.\",\n ),\n );\n } else if (content.includes(\"test question\")) {\n // Emit a message that asks the user a question (the runner normalizer\n // converts this to a `question` AgentEvent for the transport layer)\n events.push(\n ...textAndResult(\n \"The blueprint calls for a relational database. Which engine should I target? \" +\n \"This will affect the Prisma provider, Docker Compose setup, and the connection string.\\n\\n\" +\n \"Options: PostgreSQL, MySQL, SQLite\",\n ),\n );\n } else if (content.includes(\"test error\")) {\n events.push({\n type: \"error\",\n error:\n \"AI provider returned HTTP 429 — rate limit exceeded. The request will be retried automatically in 35 seconds.\",\n fatal: false,\n });\n } else if (content.includes(\"test fatal\")) {\n events.push({\n type: \"error\",\n error:\n \"Session agent was killed by the container runtime (OOM — memory limit 2 GB exceeded). The session cannot continue.\",\n fatal: true,\n });\n } else {\n // Default echo response\n const summary =\n `I received your message: \"${originalPrompt}\". I'm the Skaile AI assistant running in echo mode. ` +\n `This is a deterministic mock response for E2E testing.`;\n events.push(...textAndResult(summary));\n }\n\n return events;\n}\n\n/**\n * `DriverTarget` wrapper for the echo driver. Registered into the plugin\n * registry by `registerBuiltinDrivers()`.\n */\nexport const echoDriverTarget: DriverTarget<AgentConfig> = {\n id: \"echo\",\n displayName: BUILTIN_DRIVER_CATALOG.echo?.name ?? \"Echo (E2E mock)\",\n apiVersion: 1,\n // Drivers take AgentConfig; passthrough — full schema validation is out of scope.\n configSchema: z.custom<AgentConfig>(() => true),\n create: async (config, _ctx) => new EchoDriver(config),\n listModels: async (apiKeys) =>\n new EchoDriver({ cwd: process.cwd(), sessionId: \"model-list\", apiKeys }).listModels(),\n};\n"]}
1
+ {"version":3,"sources":["../../../bridge/src/drivers/flow-script.ts","../../../bridge/src/drivers/echo.ts"],"names":["events"],"mappings":";;;;;;;;AA6FA,IAAM,WAAA,uBAAiD,GAAA,CAAI;AAAA,EACzD,kBAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF,CAAC,CAAA;AAGM,SAAS,aAAa,MAAA,EAA6B;AACxD,EAAA,OAAO,WAAA,CAAY,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA;AAClC;AAGO,SAAS,WAAW,MAAA,EAA6C;AACtE,EAAA,QAAQ,OAAO,EAAA;AAAI,IACjB,KAAK,YAAA;AAAA,IACL,KAAK,WAAA;AACH,MAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,CAAO,MAAA,EAAO;AAAA,IACjC,KAAK,eAAA;AACH,MAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,CAAO,MAAA,EAAQ,OAAA,EAAS,OAAO,OAAA,EAAQ;AAAA,IAC1D,KAAK,kBAAA;AACH,MAAA,OAAO,EAAE,MAAA,EAAQ,MAAA,CAAO,MAAA,EAAQ,OAAA,EAAS,OAAO,OAAA,EAAQ;AAAA,IAC1D,KAAK,eAAA;AACH,MAAA,OAAO,EAAE,QAAQ,MAAA,CAAO,MAAA,EAAQ,QAAQ,MAAA,CAAO,MAAA,EAAQ,MAAA,EAAQ,MAAA,CAAO,MAAA,EAAO;AAAA,IAC/E,KAAK,WAAA;AACH,MAAA,OAAO;AAAA,QACL,QAAQ,MAAA,CAAO,MAAA;AAAA,QACf,SAAS,MAAA,CAAO,OAAA;AAAA,QAChB,WAAA,EAAa,MAAA,CAAO,MAAA,CAAO,WAAW;AAAA,OACxC;AAAA;AAEN;AAEA,SAAS,UAAA,CAAW,GAAsB,CAAA,EAA0B;AAClE,EAAA,OAAO,CAAA,CAAE,OAAA,IAAW,CAAA,oBAAA,EAAuB,CAAA,CAAE,EAAE,CAAA,CAAA;AACjD;AAcO,SAA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MACV,IAAA,EAAM,OAAA;AAAA,MACN,KAAA,EACE,oHAAA;AAAA,MACF,KAAA,EAAO;AAAA,KACR,CAAA;AAAA,EACH,CAAA,MAAA,IAAW,OAAA,CAAQ,QAAA,CAAS,YAAY,CAAA,EAAG;AACzC,IAAA,MAAA,CAAO,IAAA,CAAK;AAAA,MACV,IAAA,EAAM,OAAA;AAAA,MACN,KAAA,EACE,yHAAA;AAAA,MACF,KAAA,EAAO;AAAA,KACR,CAAA;AAAA,EACH,CAAA,MAAO;AAEL,IAAA,MAAM,OAAA,GACJ,6BAA6B,cAAc,CAAA,2GAAA,CAAA;AAE7C,IAAA,MAAA,CAAO,IAAA,CAAK,GAAG,aAAA,CAAc,OAAO,CAAC,CAAA;AAAA,EACvC;AAEA,EAAA,OAAO,MAAA;AACT;AAMO,IAAM,gBAAA,GAA8C;AAAA,EACzD,EAAA,EAAI,MAAA;AAAA,EACJ,WAAA,EAAa,sBAAA,CAAuB,IAAA,EAAM,IAAA,IAAQ,iBAAA;AAAA,EAClD,UAAA,EAAY,CAAA;AAAA;AAAA,EAEZ,YAAA,EAAgB,CAAA,CAAA,MAAA,CAAoB,MAAM,IAAI,CAAA;AAAA,EAC9C,QAAQ,OAAO,MAAA,EAAQ,IAAA,KAAS,IAAI,WAAW,MAAM,CAAA;AAAA,EACrD,UAAA,EAAY,OAAO,OAAA,KACjB,IAAI,WAAW,EAAE,GAAA,EAAK,OAAA,CAAQ,GAAA,IAAO,SAAA,EAAW,YAAA,EAAc,OAAA,EAAS,EAAE,UAAA;AAC7E","file":"echo.js","sourcesContent":["/**\n * Scripted-flow decision logic for the echo driver.\n *\n * Pure, deterministic policy that maps a live {@link FlowExecution} snapshot\n * (plus an optional per-node script) to the single next flow-adapter mutation\n * the driver should emit this iteration. The echo driver calls this in a loop\n * per turn (see `echo.ts`), executing each returned action against the\n * runner-injected {@link FlowTestDriverHook} until it yields (`null`) or emits\n * a turn-ending action.\n *\n * The policy mirrors what a real LLM orchestrator would do, but without an\n * LLM: it reacts to state each turn, so a host can drive a flow to `complete`,\n * park it at an approval/input gate, and exercise the reject/recover path\n * simply by applying host mutations (`applyApproval`, `applyInput`, …) between\n * turns. No new protocol, no flow-contract change — it only calls the existing\n * FlowAdapter agent-tool operations.\n *\n * @docLink packages/bridge/drivers#scripted-flow\n * @since 3.6.0\n */\n\nimport type { FlowExecution, NodeExecution } from \"@skaile/workspaces/types\";\n\n/**\n * What the scripted driver should do when a node reaches its decision point.\n *\n * - `auto` (default): follow the flow's `autonomousMode` — `complete_node`\n * when autonomous, else `request_approval`. A mandatory approval gate always\n * resolves to `request_approval`, even when autonomous (it cannot be skipped).\n * - `complete`: always `complete_node` (autonomous-style, even if the flow's\n * autonomousMode is false — the adapter allows it only when autonomous, so\n * use with autonomous flows).\n * - `approve`: always `request_approval` (park at an approval gate).\n * - `input`: `request_input` once; after the host applies input, fall back to\n * `auto` behaviour.\n * - `skip`: `skip_node` (optional nodes only).\n * - `fail`: `fail_node`. With `recoverable: false` (default) this is terminal.\n * With `recoverable: true` the node returns to `available`; the driver\n * re-emits the recoverable failure `failCount` times (default 1) and then\n * proceeds as `auto` — it never deadlocks on a recoverable fail.\n */\nexport type OnRun = \"auto\" | \"complete\" | \"approve\" | \"input\" | \"skip\" | \"fail\";\n\n/**\n * What to do when a node returns to `available` after a rejection.\n *\n * - `retry` (default): re-drive it — `start_node` again, then its `onRun`.\n * - `fail`: `fail_node(recoverable: false)` — exercises the terminal path.\n */\nexport type OnReject = \"retry\" | \"fail\";\n\n/** Per-node scripting directive. All fields optional. */\nexport interface FlowNodeDirective {\n onRun?: OnRun;\n onReject?: OnReject;\n /** For `onRun: \"input\"` — the input request shown to the host. */\n input?: { prompt?: string; schema?: unknown };\n /** For `onRun: \"fail\"` — whether the failure is recoverable. Default false. */\n recoverable?: boolean;\n /**\n * For `onRun: \"fail\"` with `recoverable: true` — how many recoverable\n * failures to emit before the node proceeds as `auto`. Default 1. Counted\n * from the node's own `errorHistory`, so the policy stays a pure function of\n * state (no driver-instance bookkeeping) and never deadlocks.\n */\n failCount?: number;\n /** Summary text used for `complete_node` / `request_approval` / failures. */\n summary?: string;\n}\n\n/**\n * A scripted-flow program. Empty (`{}`) means \"canonical policy\": start each\n * available node, then complete (autonomous) or request approval (interactive)\n * — enough to drive the autonomous-complete, approval-gate, and reject/recover\n * scenarios with no per-node scripting at all.\n */\nexport interface FlowScript {\n /** Per-node overrides, keyed by node id. */\n nodes?: Record<string, FlowNodeDirective>;\n /** Fallback directive for any node without its own entry. */\n default?: FlowNodeDirective;\n}\n\n/** A single flow-adapter mutation the driver will execute. */\nexport type FlowAction =\n | { op: \"start_node\"; nodeId: string }\n | { op: \"complete_node\"; nodeId: string; summary: string }\n | { op: \"request_approval\"; nodeId: string; summary: string }\n | { op: \"request_input\"; nodeId: string; prompt: string; schema: string }\n | { op: \"skip_node\"; nodeId: string }\n | { op: \"fail_node\"; nodeId: string; message: string; recoverable: boolean };\n\n/** Ops that end the agent turn (the runner yields until the host acts). */\nconst TURN_ENDING: ReadonlySet<FlowAction[\"op\"]> = new Set([\n \"request_approval\",\n \"request_input\",\n \"fail_node\",\n]);\n\n/** Whether an action ends the turn (driver stops looping after emitting it). */\nexport function isTurnEnding(action: FlowAction): boolean {\n return TURN_ENDING.has(action.op);\n}\n\n/** Map a {@link FlowAction} to the `executeOp` argument bag the adapter expects. */\nexport function actionArgs(action: FlowAction): Record<string, unknown> {\n switch (action.op) {\n case \"start_node\":\n case \"skip_node\":\n return { nodeId: action.nodeId };\n case \"complete_node\":\n return { nodeId: action.nodeId, summary: action.summary };\n case \"request_approval\":\n return { nodeId: action.nodeId, summary: action.summary };\n case \"request_input\":\n return { nodeId: action.nodeId, prompt: action.prompt, schema: action.schema };\n case \"fail_node\":\n return {\n nodeId: action.nodeId,\n message: action.message,\n recoverable: String(action.recoverable),\n };\n }\n}\n\nfunction summaryFor(d: FlowNodeDirective, n: NodeExecution): string {\n return d.summary ?? `Scripted output for ${n.id}`;\n}\n\n/**\n * Decide the single next flow action for the current state, or `null` to yield\n * (nothing to do this iteration — wait for a host mutation).\n *\n * Priority order: resolve approved gates → advance running nodes → start (or\n * skip / terminally-fail) available nodes. Terminal flow states and gates with\n * no decision / input yet yield.\n *\n * Pure — the fail bookkeeping (how many recoverable failures a node has already\n * emitted) is read from the node's own `errorHistory`, so no external counter is\n * needed and a recoverable `fail` directive can never deadlock.\n */\nexport function decideFlowAction(\n state: FlowExecution,\n script: FlowScript,\n mandatoryGates: ReadonlySet<string> = new Set(),\n): FlowAction | null {\n // Terminal flow — never fight a completed/failed/cancelled run.\n if (state.status === \"complete\" || state.status === \"failed\" || state.status === \"cancelled\") {\n return null;\n }\n\n const dir = (id: string): FlowNodeDirective => script.nodes?.[id] ?? script.default ?? {};\n const nodes = Object.values(state.nodes);\n // A mandatory gate can never auto-complete — `auto` resolves to `approve`\n // regardless of autonomousMode so the host can drive it deterministically.\n const canAutoComplete = (id: string): boolean => state.autonomousMode && !mandatoryGates.has(id);\n\n // 1. Approved gate → complete.\n for (const n of nodes) {\n if (n.status === \"awaiting_approval\" && n.approval?.decision === \"approved\") {\n return { op: \"complete_node\", nodeId: n.id, summary: summaryFor(dir(n.id), n) };\n }\n }\n\n // 2. Running node → per directive.\n for (const n of nodes) {\n if (n.status !== \"running\") continue;\n const d = dir(n.id);\n const onRun: OnRun = d.onRun ?? \"auto\";\n const resolved: OnRun =\n onRun === \"auto\" ? (canAutoComplete(n.id) ? \"complete\" : \"approve\") : onRun;\n\n if (resolved === \"complete\") {\n return { op: \"complete_node\", nodeId: n.id, summary: summaryFor(d, n) };\n }\n if (resolved === \"approve\") {\n return { op: \"request_approval\", nodeId: n.id, summary: summaryFor(d, n) };\n }\n if (resolved === \"input\") {\n const lastInput = n.inputHistory[n.inputHistory.length - 1];\n if (lastInput && lastInput.response !== undefined) {\n // Input already provided — proceed as if `auto`.\n return canAutoComplete(n.id)\n ? { op: \"complete_node\", nodeId: n.id, summary: summaryFor(d, n) }\n : { op: \"request_approval\", nodeId: n.id, summary: summaryFor(d, n) };\n }\n return {\n op: \"request_input\",\n nodeId: n.id,\n prompt: d.input?.prompt ?? `Provide input for ${n.id}`,\n schema: JSON.stringify(d.input?.schema ?? { kind: \"text\" }),\n };\n }\n if (resolved === \"fail\") {\n const recoverable = d.recoverable ?? false;\n if (!recoverable) {\n // Terminal fail — the adapter marks node + flow `failed`, so the\n // terminal-status guard above stops any re-fire on later turns.\n return {\n op: \"fail_node\",\n nodeId: n.id,\n message: d.summary ?? `Scripted failure for ${n.id}`,\n recoverable: false,\n };\n }\n // Recoverable fail — emit up to `failCount` times (counting the node's\n // own recorded recoverable errors), then proceed as `auto` so the node\n // is not stranded in a re-drive loop.\n const emitted = n.errorHistory.filter((e) => e.recoverable).length;\n const failCount = Math.max(1, d.failCount ?? 1);\n if (emitted < failCount) {\n return {\n op: \"fail_node\",\n nodeId: n.id,\n message: d.summary ?? `Scripted recoverable failure for ${n.id}`,\n recoverable: true,\n };\n }\n return canAutoComplete(n.id)\n ? { op: \"complete_node\", nodeId: n.id, summary: summaryFor(d, n) }\n : { op: \"request_approval\", nodeId: n.id, summary: summaryFor(d, n) };\n }\n // `skip` while running is illegal; complete instead to avoid a deadlock.\n return { op: \"complete_node\", nodeId: n.id, summary: summaryFor(d, n) };\n }\n\n // 3. Available node → terminally-fail (post-reject), skip, or start.\n for (const n of nodes) {\n if (n.status !== \"available\") continue;\n const d = dir(n.id);\n const lastApproval = n.approvalHistory[n.approvalHistory.length - 1];\n if (lastApproval?.decision === \"rejected\" && d.onReject === \"fail\") {\n return {\n op: \"fail_node\",\n nodeId: n.id,\n message: d.summary ?? `Rejected and not recoverable: ${n.id}`,\n recoverable: false,\n };\n }\n if (d.onRun === \"skip\") {\n return { op: \"skip_node\", nodeId: n.id };\n }\n return { op: \"start_node\", nodeId: n.id };\n }\n\n // 4. Nothing actionable — awaiting_approval (no decision), awaiting_input\n // (no response), or fully drained. Yield.\n return null;\n}\n\n/**\n * Parse a `[test-flow]` sentinel body into a {@link FlowScript}. An empty body\n * yields the canonical (empty) script. Malformed JSON is a hard error so tests\n * fail loudly rather than silently running the wrong policy.\n */\nexport function parseFlowScript(body: string): FlowScript {\n const trimmed = body.trim();\n if (trimmed.length === 0) return {};\n const parsed: unknown = JSON.parse(trimmed);\n if (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new Error(\"flow script must be a JSON object\");\n }\n return parsed as FlowScript;\n}\n","import type { DriverTarget } from \"@skaile/workspaces/plugin-registry\";\nimport type { Logger } from \"@skaile/workspaces/types\";\nimport * as z from \"zod\";\nimport { dispatchCapability } from \"../capability-dispatch.js\";\nimport { getBridgeLogger } from \"../logger.js\";\nimport { BUILTIN_DRIVER_CATALOG } from \"../registry.js\";\nimport {\n type AgentConfig,\n AgentDriver,\n type AgentEvent,\n type BridgeCapabilityTool,\n type DriverInfo,\n} from \"../types.js\";\nimport {\n actionArgs,\n type FlowScript,\n decideFlowAction,\n isTurnEnding,\n parseFlowScript,\n} from \"./flow-script.js\";\n\n/**\n * Echo/mock driver for E2E testing in docker mode.\n *\n * Runs inside a real Docker container with real WebSocket transport and\n * session lifecycle, but generates deterministic keyword-triggered responses\n * instead of calling the Anthropic API. This lets E2E tests exercise the\n * full infrastructure (containers, WebSocket, session management, message\n * persistence) without needing real AI credentials.\n *\n * Keyword triggers match the MockAgentClient in\n * `platform/backend/libs/agent-gateway/src/mock-agent-client.ts` — the\n * same test messages (\"test toolcall\", \"test question\", etc.) produce\n * the same events.\n *\n * Enable by setting `SKAILE_AGENT_DRIVER=echo` in the container env,\n * or by passing `{ driver: 'echo' }` in the runner config.\n *\n * @docLink packages/bridge/drivers#echo-driver\n */\nexport class EchoDriver extends AgentDriver {\n readonly driverInfo: DriverInfo = {\n id: \"echo\",\n name: \"Echo (E2E mock)\",\n modelAgnostic: true,\n supportsInBandAbort: false,\n };\n\n private readonly log: Logger = getBridgeLogger(\"echo\");\n private running = false;\n private readonly config: AgentConfig;\n\n /**\n * Scripted-flow mode state (workspaces#396). Enabled by a `[test-flow]`\n * sentinel chat message; once on, orchestrator-prompt turns are driven\n * deterministically against `config.flowTestDriver`. `null` script ⇒ mode\n * off (default echo behaviour, unchanged).\n */\n private flowScript: FlowScript | null = null;\n\n constructor(config: AgentConfig) {\n super();\n this.config = config;\n }\n\n /**\n * Test surface: returns the tool list the LLM would see for this turn.\n * Composition: the registry hooks (Protocol v2) take precedence; legacy\n * `mcpServers` is not enumerated here (the echo driver never exposed MCP\n * tools to the LLM by name).\n */\n listCapabilityTools(): BridgeCapabilityTool[] {\n return this.config.capabilities?.composeTools() ?? [];\n }\n\n /**\n * Test surface: invoke a registered capability through the dispatch\n * helper. Mirrors what a real driver would do when the LLM produced a\n * tool_use for the given name — applies fire-and-forget, render emission,\n * and fallback text. Returns the structured dispatch result so tests can\n * assert immediate-vs-background resolution.\n */\n async invokeCapabilityForTest(\n name: string,\n input: unknown,\n ): Promise<{ result: unknown; background: boolean }> {\n const hooks = this.config.capabilities;\n if (!hooks) throw new Error(\"EchoDriver: no capability hooks configured\");\n const callId = `echo-cap-${Date.now()}`;\n const out = await dispatchCapability(hooks, callId, name, input, (err) =>\n this.log.warn(\"background capability handler failed\", {\n name,\n error: String(err),\n }),\n );\n return out;\n }\n\n async start(): Promise<void> {\n this.running = true;\n this.log.info(\"driver started\");\n }\n\n async prompt(message: string): Promise<void> {\n if (!this.running) return;\n const content = message.toLowerCase();\n this.log.info(\"received prompt\", { preview: message.slice(0, 80), length: message.length });\n\n // Small delay to simulate real agent processing\n await new Promise((resolve) => setTimeout(resolve, 200));\n\n // Scripted-flow test seam (workspaces#396) — a `[test-flow]` sentinel\n // arms deterministic flow driving for this session and (optionally)\n // carries a JSON script. Format: `[test-flow] {json}`; empty body ⇒\n // canonical policy. Must be handled before the flow-turn branch below.\n //\n // Detection is LINE-anchored, not message-anchored (workspaces#401): hosts\n // decorate user messages (e.g. a prepended `<SESSION_MEMBERS>` block and a\n // wake-restoration preamble), so the sentinel is rarely at the start of the\n // composed prompt. We match `[test-flow]` at the start of ANY line (only\n // leading whitespace allowed), which is decoration-independent yet still\n // impossible to arm from ordinary prose — a line must BEGIN with the exact\n // token. The optional JSON script must sit on that same line.\n const flowMatch = /^[ \\t]*\\[test-flow\\][ \\t]*(.*)$/m.exec(message);\n if (flowMatch) {\n let summary: string;\n try {\n this.flowScript = parseFlowScript(flowMatch[1] ?? \"\");\n summary = \"echo[test-flow]: scripted-flow mode armed\";\n } catch (err) {\n this.flowScript = null;\n summary = `echo[test-flow]: invalid script — ${err instanceof Error ? err.message : String(err)}`;\n this.emit(\"agent-event\", { type: \"error\", error: summary, fatal: false });\n }\n for (const event of textAndResult(summary)) this.emit(\"agent-event\", event);\n this.emit(\"agent-event\", { type: \"agent_end\" });\n return;\n }\n\n // Scripted-flow turn — the runner reassembles the orchestrator prompt on\n // every flow turn; when scripted-flow mode is armed and a flow driver hook\n // is present, drive nodes deterministically instead of echoing text.\n if (this.flowScript && this.config.flowTestDriver && isFlowTurn(message)) {\n await this.runScriptedFlowTurn();\n return;\n }\n\n // Phase 7B test seam — explicit capability invocation keyword. Lets E2E\n // tests drive `dispatchCapability` from a chat prompt without a real LLM.\n // Format: `[test-cap:<name>] {json}`. Anything after the closing bracket\n // is parsed as JSON input; on parse error we fall back to `{}`.\n const capMatch = /^\\s*\\[test-cap:([\\w.\\-_]+)\\]\\s*(.*)$/s.exec(message);\n if (capMatch) {\n const name = capMatch[1] ?? \"\";\n const rawInput = (capMatch[2] ?? \"\").trim();\n let input: unknown = {};\n if (rawInput.length > 0) {\n try {\n input = JSON.parse(rawInput);\n } catch (err) {\n this.log.warn(\"test-cap input was not valid JSON; defaulting to {}\", {\n error: String(err),\n preview: rawInput.slice(0, 80),\n });\n }\n }\n const events = await this.runCapabilityKeyword(name, input);\n for (const event of events) {\n this.emit(\"agent-event\", event);\n await new Promise((resolve) => setTimeout(resolve, 20));\n }\n this.emit(\"agent-event\", { type: \"agent_end\" });\n return;\n }\n\n const events = buildEchoEvents(content, message);\n for (const event of events) {\n this.emit(\"agent-event\", event);\n // Small gap between events to let the transport process each one\n await new Promise((resolve) => setTimeout(resolve, 50));\n }\n // Signal turn completion — the runner waits for this before accepting\n // the next prompt. Without it, the runner stays stuck after the first message.\n this.emit(\"agent-event\", { type: \"agent_end\" });\n }\n\n /**\n * Phase 7B helper — drive a single capability through the dispatcher and\n * surface the structured outcome as a result event the LLM-side test code\n * can assert against. Used exclusively by the `[test-cap:<name>]` prompt\n * keyword above; never wired into normal chat flow.\n */\n private async runCapabilityKeyword(name: string, input: unknown): Promise<AgentEvent[]> {\n const events: AgentEvent[] = [];\n if (!this.config.capabilities) {\n return textAndResult(`echo[test-cap]: no capability hooks configured (skipping ${name})`);\n }\n try {\n const out = await this.invokeCapabilityForTest(name, input);\n const summary = `echo[test-cap]: invoked ${name} background=${String(out.background)} result=${safeStringify(out.result)}`;\n events.push(...textAndResult(summary));\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n events.push({\n type: \"error\",\n error: `echo[test-cap]: ${name} failed: ${msg}`,\n fatal: false,\n });\n events.push(...textAndResult(`echo[test-cap]: ${name} errored (${msg})`));\n }\n return events;\n }\n\n /**\n * Scripted-flow turn (workspaces#396). Reads the live flow state via the\n * runner-injected `flowTestDriver` hook and executes the scripted next\n * action(s) until the policy yields or emits a turn-ending action. Each\n * mutation fires the adapter's `onChange` (→ host `state_changed`) and, when\n * the runner wires the stimulus bus, queues the follow-up turn — so the\n * driver advances one step at a time exactly like a real LLM orchestrator.\n */\n private async runScriptedFlowTurn(): Promise<void> {\n const hook = this.config.flowTestDriver;\n const script = this.flowScript;\n if (!hook || !script) {\n this.emit(\"agent-event\", { type: \"agent_end\" });\n return;\n }\n\n const executed: string[] = [];\n // Hard cap — the policy is monotonic, but never let a bug spin forever.\n const MAX_STEPS = 200;\n for (let i = 0; i < MAX_STEPS; i++) {\n const state = hook.getState();\n if (!state) break;\n const mandatoryGates = new Set(hook.mandatoryGates?.() ?? []);\n const action = decideFlowAction(state, script, mandatoryGates);\n if (!action) break;\n\n this.emit(\"agent-event\", {\n type: \"tool_call\",\n name: action.op,\n tool: { name: action.op },\n input: action.nodeId,\n });\n try {\n await hook.execute(action.op, actionArgs(action));\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n this.log.warn(\"scripted flow op failed\", {\n op: action.op,\n nodeId: action.nodeId,\n error: msg,\n });\n this.emit(\"agent-event\", {\n type: \"error\",\n error: `echo[test-flow]: ${action.op}(${action.nodeId}) failed: ${msg}`,\n fatal: false,\n });\n break;\n }\n this.emit(\"agent-event\", { type: \"tool_execution_end\", toolName: action.op });\n executed.push(`${action.op}(${action.nodeId})`);\n if (isTurnEnding(action)) break;\n }\n\n const summary =\n executed.length > 0\n ? `echo[test-flow]: ${executed.join(\" → \")}`\n : \"echo[test-flow]: no action (yielding to host)\";\n for (const event of textAndResult(summary)) this.emit(\"agent-event\", event);\n this.emit(\"agent-event\", { type: \"agent_end\" });\n }\n\n async abort(): Promise<void> {\n this.log.info(\"abort requested\");\n }\n\n kill(): void {\n this.running = false;\n this.log.info(\"killed\");\n }\n\n async resetSession(): Promise<void> {\n this.log.info(\"session reset\");\n }\n\n get isRunning(): boolean {\n return this.running;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Echo response generation — mirrors MockAgentClient.buildMockEvents\n// ---------------------------------------------------------------------------\n\n/**\n * A flow turn is recognised by the orchestrator prompt's stable header\n * (`buildOrchestratorPrompt` in the flow connector). Detection is header-only —\n * the driver reads live state through the injected hook, never by parsing the\n * prompt body.\n */\nfunction isFlowTurn(message: string): boolean {\n return message.startsWith(\"# Flow Execution Context\");\n}\n\nfunction safeStringify(v: unknown): string {\n try {\n return JSON.stringify(v);\n } catch {\n return String(v);\n }\n}\n\nfunction textAndResult(summary: string): AgentEvent[] {\n return [\n {\n type: \"message_start\",\n message: { role: \"assistant\", content: summary },\n },\n {\n type: \"message_end\",\n message: { role: \"assistant\", content: summary },\n },\n {\n type: \"result\",\n subtype: \"success\",\n summary,\n costUsd: 0,\n },\n ];\n}\n\nfunction buildEchoEvents(content: string, originalPrompt: string): AgentEvent[] {\n const events: AgentEvent[] = [];\n\n if (content.includes(\"test all\")) {\n events.push(\n { type: \"tool_call\", name: \"Read\", tool: { name: \"Read\" }, input: \"prisma/schema.prisma\" },\n { type: \"tool_execution_end\", toolName: \"Read\" },\n {\n type: \"tool_call\",\n name: \"Write\",\n tool: { name: \"Write\" },\n input: \"src/modules/sprint/sprint.service.ts\",\n },\n { type: \"tool_execution_end\", toolName: \"Write\" },\n );\n events.push(\n ...textAndResult(\n \"All operations completed successfully. Created sprint service, updated schema, started dev server, and ran E2E tests.\",\n ),\n );\n } else if (content.includes(\"test toolcall\")) {\n events.push(\n {\n type: \"tool_call\",\n name: \"Read\",\n tool: { name: \"Read\" },\n input: \"platform/prisma/schema.prisma\",\n },\n { type: \"tool_execution_end\", toolName: \"Read\" },\n );\n events.push(\n ...textAndResult(\n \"I've read the schema and found 42 models. The data model looks well-structured.\",\n ),\n );\n } else if (content.includes(\"test question\")) {\n // Emit a message that asks the user a question (the runner normalizer\n // converts this to a `question` AgentEvent for the transport layer)\n events.push(\n ...textAndResult(\n \"The blueprint calls for a relational database. Which engine should I target? \" +\n \"This will affect the Prisma provider, Docker Compose setup, and the connection string.\\n\\n\" +\n \"Options: PostgreSQL, MySQL, SQLite\",\n ),\n );\n } else if (content.includes(\"test error\")) {\n events.push({\n type: \"error\",\n error:\n \"AI provider returned HTTP 429 — rate limit exceeded. The request will be retried automatically in 35 seconds.\",\n fatal: false,\n });\n } else if (content.includes(\"test fatal\")) {\n events.push({\n type: \"error\",\n error:\n \"Session agent was killed by the container runtime (OOM — memory limit 2 GB exceeded). The session cannot continue.\",\n fatal: true,\n });\n } else {\n // Default echo response\n const summary =\n `I received your message: \"${originalPrompt}\". I'm the Skaile AI assistant running in echo mode. ` +\n `This is a deterministic mock response for E2E testing.`;\n events.push(...textAndResult(summary));\n }\n\n return events;\n}\n\n/**\n * `DriverTarget` wrapper for the echo driver. Registered into the plugin\n * registry by `registerBuiltinDrivers()`.\n */\nexport const echoDriverTarget: DriverTarget<AgentConfig> = {\n id: \"echo\",\n displayName: BUILTIN_DRIVER_CATALOG.echo?.name ?? \"Echo (E2E mock)\",\n apiVersion: 1,\n // Drivers take AgentConfig; passthrough — full schema validation is out of scope.\n configSchema: z.custom<AgentConfig>(() => true),\n create: async (config, _ctx) => new EchoDriver(config),\n listModels: async (apiKeys) =>\n new EchoDriver({ cwd: process.cwd(), sessionId: \"model-list\", apiKeys }).listModels(),\n};\n"]}
@@ -1,8 +1,8 @@
1
- export { GeminiDriver, GeminiFamilyDriver, geminiDriverTarget } from '../../chunk-NQD7INSF.js';
2
- import '../../chunk-XVWK3VHH.js';
1
+ export { GeminiDriver, GeminiFamilyDriver, geminiDriverTarget } from '../../chunk-25LDSYP4.js';
2
+ import '../../chunk-GAA5W4VX.js';
3
3
  import '../../chunk-BMQKMOQY.js';
4
4
  import '../../chunk-GAH4YRCI.js';
5
- import '../../chunk-KF3KDVKT.js';
5
+ import '../../chunk-YM5P2P4R.js';
6
6
  import '../../chunk-6E6PKKAD.js';
7
7
  import '../../chunk-JB35MVBN.js';
8
8
  import '../../chunk-NSBPE2FW.js';
@@ -1,6 +1,6 @@
1
- import { SubprocessCliDriver, mapApiKeysToEnv, extractText, extractCost, extractTokens } from '../../chunk-XVWK3VHH.js';
1
+ import { SubprocessCliDriver, mapApiKeysToEnv, extractText, extractCost, extractTokens } from '../../chunk-GAA5W4VX.js';
2
2
  import '../../chunk-GAH4YRCI.js';
3
- import { BUILTIN_DRIVER_CATALOG, getBridgeLogger } from '../../chunk-KF3KDVKT.js';
3
+ import { BUILTIN_DRIVER_CATALOG, getBridgeLogger } from '../../chunk-YM5P2P4R.js';
4
4
  import '../../chunk-6E6PKKAD.js';
5
5
  import '../../chunk-JB35MVBN.js';
6
6
  import '../../chunk-NSBPE2FW.js';
@@ -1,5 +1,5 @@
1
1
  import { classifyGenericErrorMessage } from '../../chunk-GAH4YRCI.js';
2
- import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-KF3KDVKT.js';
2
+ import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-YM5P2P4R.js';
3
3
  import '../../chunk-6E6PKKAD.js';
4
4
  import '../../chunk-JB35MVBN.js';
5
5
  import '../../chunk-NSBPE2FW.js';
@@ -1,6 +1,6 @@
1
- import { SubprocessCliDriver, mapApiKeysToEnv, extractText, extractCost, extractTokens } from '../../chunk-XVWK3VHH.js';
1
+ import { SubprocessCliDriver, mapApiKeysToEnv, extractText, extractCost, extractTokens } from '../../chunk-GAA5W4VX.js';
2
2
  import '../../chunk-GAH4YRCI.js';
3
- import { BUILTIN_DRIVER_CATALOG, getBridgeLogger } from '../../chunk-KF3KDVKT.js';
3
+ import { BUILTIN_DRIVER_CATALOG, getBridgeLogger } from '../../chunk-YM5P2P4R.js';
4
4
  import '../../chunk-6E6PKKAD.js';
5
5
  import '../../chunk-JB35MVBN.js';
6
6
  import '../../chunk-NSBPE2FW.js';
@@ -1,8 +1,8 @@
1
- import { GeminiFamilyDriver } from '../../chunk-NQD7INSF.js';
2
- import '../../chunk-XVWK3VHH.js';
1
+ import { GeminiFamilyDriver } from '../../chunk-25LDSYP4.js';
2
+ import '../../chunk-GAA5W4VX.js';
3
3
  import { fetchProviderModels } from '../../chunk-BMQKMOQY.js';
4
4
  import '../../chunk-GAH4YRCI.js';
5
- import { BUILTIN_DRIVER_CATALOG, getBridgeLogger } from '../../chunk-KF3KDVKT.js';
5
+ import { BUILTIN_DRIVER_CATALOG, getBridgeLogger } from '../../chunk-YM5P2P4R.js';
6
6
  import '../../chunk-6E6PKKAD.js';
7
7
  import '../../chunk-JB35MVBN.js';
8
8
  import '../../chunk-NSBPE2FW.js';
@@ -1,9 +1,9 @@
1
- export { BridgeRuntime, EventNormalizer, createRuntime, detectFileChange, detectFileChanges, summarizeToolCall, summarizeToolResult, validateApiKey } from '../chunk-T5XXWWHT.js';
1
+ export { BridgeRuntime, EventNormalizer, createRuntime, detectFileChange, detectFileChanges, summarizeToolCall, summarizeToolResult, validateApiKey } from '../chunk-H5XWVDL4.js';
2
2
  export { CLOUD_SECRET_ENV_KEYS, SUPPORTED_CLOUDS, buildClaudeCloudEnv } from '../chunk-ISQWMBKD.js';
3
3
  export { dispatchCapability, filterRenderCapabilities, renderFallback } from '../chunk-RRVQAE5D.js';
4
4
  export { STATIC_MODELS, fetchProviderModels, getModels, getStaticModels } from '../chunk-BMQKMOQY.js';
5
5
  export { AccountUnavailableError, AuthError, classifyClaudeSdkError, reclassifyAuthAsAccountUnavailable } from '../chunk-GAH4YRCI.js';
6
- export { AgentDriver, BUILTIN_DRIVER_CATALOG, DRIVER_CATALOG, createDriver, getBridgeLogger, listDrivers, listModelsForDriver, registerBuiltinDrivers } from '../chunk-KF3KDVKT.js';
6
+ export { AgentDriver, BUILTIN_DRIVER_CATALOG, DRIVER_CATALOG, createDriver, getBridgeLogger, listDrivers, listModelsForDriver, registerBuiltinDrivers } from '../chunk-YM5P2P4R.js';
7
7
  import '../chunk-6E6PKKAD.js';
8
8
  import '../chunk-JB35MVBN.js';
9
9
  import '../chunk-NSBPE2FW.js';
@@ -1 +1 @@
1
- {"version":3,"file":"echo.d.ts","sourceRoot":"","sources":["../../../../bridge/src/drivers/echo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAMvE,OAAO,EACL,KAAK,WAAW,EAChB,WAAW,EAEX,KAAK,oBAAoB,EACzB,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AASrB;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,UAAW,SAAQ,WAAW;IACzC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAK7B;IAEF,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAmC;IACvD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,MAA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gBAEjC,MAAM,EAAE,WAAW;IAK/B;;;;;OAKG;IACH,mBAAmB,IAAI,oBAAoB,EAAE;IAI7C;;;;;;OAMG;IACG,uBAAuB,CAC3B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,GACb,OAAO,CAAC;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC;IAa9C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmF5C;;;;;OAKG;YACW,oBAAoB;IAqBlC;;;;;;;OAOG;YACW,mBAAmB;IAqD3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,IAAI,IAAI,IAAI;IAKN,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC,IAAI,SAAS,IAAI,OAAO,CAEvB;CACF;AAiHD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,WAAW,CAStD,CAAC"}
@@ -23,7 +23,8 @@ import type { FlowExecution } from "@skaile/workspaces/types";
23
23
  * What the scripted driver should do when a node reaches its decision point.
24
24
  *
25
25
  * - `auto` (default): follow the flow's `autonomousMode` — `complete_node`
26
- * when autonomous, else `request_approval`.
26
+ * when autonomous, else `request_approval`. A mandatory approval gate always
27
+ * resolves to `request_approval`, even when autonomous (it cannot be skipped).
27
28
  * - `complete`: always `complete_node` (autonomous-style, even if the flow's
28
29
  * autonomousMode is false — the adapter allows it only when autonomous, so
29
30
  * use with autonomous flows).
@@ -119,7 +120,7 @@ export declare function actionArgs(action: FlowAction): Record<string, unknown>;
119
120
  * emitted) is read from the node's own `errorHistory`, so no external counter is
120
121
  * needed and a recoverable `fail` directive can never deadlock.
121
122
  */
122
- export declare function decideFlowAction(state: FlowExecution, script: FlowScript): FlowAction | null;
123
+ export declare function decideFlowAction(state: FlowExecution, script: FlowScript, mandatoryGates?: ReadonlySet<string>): FlowAction | null;
123
124
  /**
124
125
  * Parse a `[test-flow]` sentinel body into a {@link FlowScript}. An empty body
125
126
  * yields the canonical (empty) script. Malformed JSON is a hard error so tests