@skaile/workspaces 2.9.0 → 3.1.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.
- package/CHANGELOG.md +20 -0
- package/README.md +17 -6
- package/dist/{asset-feeds-EO2QDJ4C.js → asset-feeds-3XCKB542.js} +4 -4
- package/dist/{asset-feeds-EO2QDJ4C.js.map → asset-feeds-3XCKB542.js.map} +1 -1
- package/dist/asset-manager/index.js +1 -1
- package/dist/bridge/drivers/claude-sdk.js +6 -206
- package/dist/bridge/drivers/claude-sdk.js.map +1 -1
- package/dist/bridge/drivers/codex.js +2 -2
- package/dist/bridge/drivers/continue.js +2 -2
- package/dist/bridge/drivers/echo.js +1 -1
- package/dist/bridge/drivers/gemini.js +4 -4
- package/dist/bridge/drivers/goose.js +2 -2
- package/dist/bridge/drivers/omp.js +1 -1
- package/dist/bridge/drivers/opencode.js +2 -2
- package/dist/bridge/drivers/qwen.js +4 -4
- package/dist/bridge/index.js +14 -4
- package/dist/bridge/src/drivers/claude-sdk.d.ts.map +1 -1
- package/dist/bridge/src/drivers/resume-probe.d.ts +54 -0
- package/dist/bridge/src/drivers/resume-probe.d.ts.map +1 -0
- package/dist/bridge/src/drivers/scrub-transcript.d.ts +17 -0
- package/dist/bridge/src/drivers/scrub-transcript.d.ts.map +1 -1
- package/dist/bridge/src/index.d.ts +1 -0
- package/dist/bridge/src/index.d.ts.map +1 -1
- package/dist/bridge/src/models.d.ts +59 -0
- package/dist/bridge/src/models.d.ts.map +1 -1
- package/dist/{chunk-ZR2X4SIG.js → chunk-2U4ISGE2.js} +5 -5
- package/dist/{chunk-ZR2X4SIG.js.map → chunk-2U4ISGE2.js.map} +1 -1
- package/dist/chunk-46LE3GNY.js +296 -0
- package/dist/chunk-46LE3GNY.js.map +1 -0
- package/dist/{chunk-INHE5U74.js → chunk-5QGMEPUX.js} +8 -12
- package/dist/chunk-5QGMEPUX.js.map +1 -0
- package/dist/{chunk-TU7JDHKS.js → chunk-7HXS7WZF.js} +2 -2
- package/dist/{chunk-TU7JDHKS.js.map → chunk-7HXS7WZF.js.map} +1 -1
- package/dist/{chunk-OHLKWUO3.js → chunk-7KFN2EPR.js} +12 -4
- package/dist/chunk-7KFN2EPR.js.map +1 -0
- package/dist/{chunk-YFAED6OB.js → chunk-BENN6MO4.js} +4 -4
- package/dist/{chunk-YFAED6OB.js.map → chunk-BENN6MO4.js.map} +1 -1
- package/dist/{chunk-AGFAOSCZ.js → chunk-F5VREBV2.js} +8 -5
- package/dist/chunk-F5VREBV2.js.map +1 -0
- package/dist/{chunk-L3TS7ZO4.js → chunk-FP7DNGX6.js} +3 -3
- package/dist/{chunk-L3TS7ZO4.js.map → chunk-FP7DNGX6.js.map} +1 -1
- package/dist/{chunk-E5VGAW4E.js → chunk-H26KDA7J.js} +230 -9
- package/dist/chunk-H26KDA7J.js.map +1 -0
- package/dist/{chunk-VNIKF66R.js → chunk-HA2H3FLE.js} +4 -4
- package/dist/{chunk-VNIKF66R.js.map → chunk-HA2H3FLE.js.map} +1 -1
- package/dist/{chunk-5LA4XI4Y.js → chunk-HNR2IT34.js} +27 -13
- package/dist/chunk-HNR2IT34.js.map +1 -0
- package/dist/{chunk-BIKTLLLD.js → chunk-MJ6EME7A.js} +6 -6
- package/dist/{chunk-BIKTLLLD.js.map → chunk-MJ6EME7A.js.map} +1 -1
- package/dist/{chunk-ZXJKWA44.js → chunk-N4GFUWWC.js} +3 -3
- package/dist/{chunk-ZXJKWA44.js.map → chunk-N4GFUWWC.js.map} +1 -1
- package/dist/{chunk-UTHMTZEH.js → chunk-PT2ZUW2E.js} +2 -2
- package/dist/{chunk-UTHMTZEH.js.map → chunk-PT2ZUW2E.js.map} +1 -1
- package/dist/{chunk-XXDQHZJY.js → chunk-PUEHYNBT.js} +3 -3
- package/dist/{chunk-XXDQHZJY.js.map → chunk-PUEHYNBT.js.map} +1 -1
- package/dist/{chunk-HY3MBSNC.js → chunk-QFO4IYBZ.js} +2 -2
- package/dist/{chunk-HY3MBSNC.js.map → chunk-QFO4IYBZ.js.map} +1 -1
- package/dist/{chunk-UAIR3K6X.js → chunk-S5FV6ISY.js} +8 -5
- package/dist/chunk-S5FV6ISY.js.map +1 -0
- package/dist/{chunk-AFUOORJE.js → chunk-TARN55L3.js} +6 -6
- package/dist/{chunk-AFUOORJE.js.map → chunk-TARN55L3.js.map} +1 -1
- package/dist/{chunk-BMQKMOQY.js → chunk-V34ZEXSE.js} +61 -3
- package/dist/chunk-V34ZEXSE.js.map +1 -0
- package/dist/{chunk-QVFCDSRH.js → chunk-VBMY3VCW.js} +3 -3
- package/dist/{chunk-QVFCDSRH.js.map → chunk-VBMY3VCW.js.map} +1 -1
- package/dist/{chunk-XHSS3YHV.js → chunk-X73AMPOT.js} +16 -7
- package/dist/chunk-X73AMPOT.js.map +1 -0
- package/dist/{chunk-4PSDPZUG.js → chunk-ZGTM4BOU.js} +2 -2
- package/dist/{chunk-4PSDPZUG.js.map → chunk-ZGTM4BOU.js.map} +1 -1
- package/dist/cli/index.js +38 -38
- package/dist/connectors/index.js +11 -5
- package/dist/{ensure-sources-6ZOD45TO.js → ensure-sources-AST427RF.js} +4 -4
- package/dist/{ensure-sources-6ZOD45TO.js.map → ensure-sources-AST427RF.js.map} +1 -1
- package/dist/factory-assets/connectors/box.js +11 -5
- package/dist/factory-assets/connectors/deploy.js +11 -5
- package/dist/factory-assets/connectors/devserver.js +11 -5
- package/dist/factory-assets/connectors/flow/CONNECTOR.md +47 -6
- package/dist/factory-assets/connectors/flow/adapter.d.ts +5 -0
- package/dist/factory-assets/connectors/flow/adapter.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/adapter.js +11 -5
- package/dist/factory-assets/connectors/flow/contract/flow.v2.schema.json +0 -6
- package/dist/factory-assets/connectors/flow/contract/normalize.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/contract/schema.d.ts +0 -4
- package/dist/factory-assets/connectors/flow/contract/schema.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/contract.js +2 -2
- package/dist/factory-assets/connectors/flow/engine/bindings.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/engine/node-shape.d.ts +7 -1
- package/dist/factory-assets/connectors/flow/engine/node-shape.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/engine/types.d.ts +12 -12
- package/dist/factory-assets/connectors/flow/engine/types.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/engine.js +3 -3
- package/dist/factory-assets/connectors/flow/index.d.ts +1 -0
- package/dist/factory-assets/connectors/flow/index.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/inline-sub-flow-host.d.ts +3 -0
- package/dist/factory-assets/connectors/flow/inline-sub-flow-host.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/prompt-fragments.d.ts +14 -0
- package/dist/factory-assets/connectors/flow/prompt-fragments.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/prompt-fragments.js +2 -2
- package/dist/factory-assets/connectors/flow/run-flow.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/run-flow.js +12 -6
- package/dist/factory-assets/connectors/flow/subprompt-runner.d.ts +99 -0
- package/dist/factory-assets/connectors/flow/subprompt-runner.d.ts.map +1 -0
- package/dist/factory-assets/connectors/flow.js +11 -5
- package/dist/factory-assets/connectors/git.js +11 -5
- package/dist/factory-assets/connectors/gmail.js +11 -5
- package/dist/factory-assets/connectors/googledrive.js +11 -5
- package/dist/factory-assets/connectors/local.js +11 -5
- package/dist/factory-assets/connectors/mattermost.js +11 -5
- package/dist/factory-assets/connectors/memory.js +11 -5
- package/dist/factory-assets/connectors/minio.js +11 -5
- package/dist/factory-assets/connectors/postgres.js +11 -5
- package/dist/factory-assets/connectors/s3.js +11 -5
- package/dist/factory-assets/connectors/sharepoint.js +11 -5
- package/dist/factory-assets/connectors/sqlite.js +11 -5
- package/dist/factory-assets/connectors/static-server.js +11 -5
- package/dist/factory-assets/connectors/tunnel.js +11 -5
- package/dist/factory-assets/connectors/webdav.js +11 -5
- package/dist/factory-assets/connectors/xstate-store.js +11 -5
- package/dist/factory-assets/connectors/xstate.js +11 -5
- package/dist/{flows-7N5AUUIS.js → flows-LQSVM45J.js} +3 -3
- package/dist/{flows-7N5AUUIS.js.map → flows-LQSVM45J.js.map} +1 -1
- package/dist/{helpers-HWLCANAK.js → helpers-IZDG57TR.js} +4 -4
- package/dist/{helpers-HWLCANAK.js.map → helpers-IZDG57TR.js.map} +1 -1
- package/dist/{library-publish-GSAIZCO3.js → library-publish-XGJ7IOU2.js} +9 -9
- package/dist/{library-publish-GSAIZCO3.js.map → library-publish-XGJ7IOU2.js.map} +1 -1
- package/dist/{open-library-ZB2STYC6.js → open-library-YDS66KLH.js} +8 -8
- package/dist/{open-library-ZB2STYC6.js.map → open-library-YDS66KLH.js.map} +1 -1
- package/dist/{project-EJFCLSHS.js → project-NR53RZOT.js} +5 -5
- package/dist/{project-EJFCLSHS.js.map → project-NR53RZOT.js.map} +1 -1
- package/dist/runner/index.js +15 -15
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +1 -1
- package/dist/sdk/bridge.js +14 -4
- package/dist/sdk/flow.js +3 -3
- package/dist/sdk/index.js +15 -15
- package/dist/sdk/runner.js +15 -15
- package/dist/{setup-RHWARBBB.js → setup-I5SLLHRA.js} +6 -6
- package/dist/{setup-RHWARBBB.js.map → setup-I5SLLHRA.js.map} +1 -1
- package/dist/{source-ILV6ZKWM.js → source-DDZKKQH2.js} +9 -9
- package/dist/{source-ILV6ZKWM.js.map → source-DDZKKQH2.js.map} +1 -1
- package/dist/{source-manifest-publish-QE2IFDRW.js → source-manifest-publish-OTVKHRX3.js} +10 -10
- package/dist/{source-manifest-publish-QE2IFDRW.js.map → source-manifest-publish-OTVKHRX3.js.map} +1 -1
- package/dist/tui/index.js +15 -15
- package/dist/types/src/lifecycle.d.ts +12 -0
- package/dist/types/src/lifecycle.d.ts.map +1 -1
- package/dist/workspace-plugin/adapters/mcp.js +1 -1
- package/dist/workspace-plugin/adapters/omp.js +3 -3
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5LA4XI4Y.js.map +0 -1
- package/dist/chunk-AGFAOSCZ.js.map +0 -1
- package/dist/chunk-BMQKMOQY.js.map +0 -1
- package/dist/chunk-E5VGAW4E.js.map +0 -1
- package/dist/chunk-INHE5U74.js.map +0 -1
- package/dist/chunk-ISQWMBKD.js +0 -74
- package/dist/chunk-ISQWMBKD.js.map +0 -1
- package/dist/chunk-OHLKWUO3.js.map +0 -1
- package/dist/chunk-UAIR3K6X.js.map +0 -1
- package/dist/chunk-XHSS3YHV.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#518](https://github.com/skaile-ai/workspaces/pull/518) [`d08d42c`](https://github.com/skaile-ai/workspaces/commit/d08d42caf15b21fe9f90f03465bf154745f56efa) Thanks [@Frozen666](https://github.com/Frozen666)! - Expose the tier-1 native-resume outcome on the `session_init` ack. When an init requests a tier-1 resume, the runner runs a deadline-bounded filesystem transcript probe and stamps `resumeProbe` (`transcript_found` | `jsonl_lost`) on `SessionInitAckEvent`, letting the platform synchronously downgrade a lost-transcript resume to a DB-backed restoration before the first post-wake turn. Adds `probeResumeTranscript`, `resolveClaudeConfigDir`, and `ResumeProbeOutcome` exports on `@skaile/workspaces/bridge`.
|
|
8
|
+
|
|
9
|
+
## 3.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- [#515](https://github.com/skaile-ai/workspaces/pull/515) [`ff160e9`](https://github.com/skaile-ai/workspaces/commit/ff160e92dc97fce2cfdaae5c75b9add9fc8553dc) Thanks [@peteralbert](https://github.com/peteralbert)! - Remove the inert `control.subagent` and `defaults.subagentMode` fields from the Flow v2 contract.
|
|
14
|
+
|
|
15
|
+
Both were carried through v1 normalization while it was open whether a later node kind would consume them; nothing ever read either. They meant "run this skill in a fresh conversation context" — which is what a `sub-flow` already does, not the single isolated model call a `subprompt` performs — so wiring them to `subprompt` would have silently changed what authored flows do.
|
|
16
|
+
|
|
17
|
+
**Breaking:** both keys are gone from the strict v2 schema, so a v2 document carrying either is now rejected with an authored path. Only the v1 normalizer ever produced them and it no longer does; a v1 document may still carry them and both are dropped. Dropping `subagent_mode` is explicit rather than a deleted key mapping, because `defaults.parameters` is an open passthrough bag — an unmapped key would have survived as `defaults.parameters.subagent_mode`, a rename rather than a removal.
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- [#515](https://github.com/skaile-ai/workspaces/pull/515) [`ff160e9`](https://github.com/skaile-ai/workspaces/commit/ff160e92dc97fce2cfdaae5c75b9add9fc8553dc) Thanks [@peteralbert](https://github.com/peteralbert)! - Activate Flow v2 `subprompt` nodes — the last of the seven Flow v2 kinds. A subprompt is `function`-shaped for everything except how the work is performed and how its output provenance is classified: instead of `NodeExecutor`, it hands its interpolated instruction to a `SubpromptRunner`, whose production implementation (`SessionSubpromptRunner`) constructs a second, isolated `AgentDriver` instance per call — same backend, provider, resolved model, and credentials as the session driver, but no Skaile system prompt, no MCP servers, no connector capabilities, no access to the session conversation, and bounded to a single turn. It does retain the backend's own native tool surface rooted at the session workspace — isolation here is a separate conversation, not a sandbox. `run.model` (`"small" | "default" | "deep"`) resolves through a new pure `resolveModelTier` in `bridge/src/models.ts`: a host-configured override first, then `PROVIDER_MODEL_TIERS`, a new built-in per-provider table of direct provider-API ids (consulted only on the direct API, since a gateway transport renames them) whose every entry is pinned by test to also exist in `STATIC_MODELS`. `default` and an absent tier inherit the session model — the one id known to work for this deployment, already carrying whatever gateway translation the host configured; `small` and `deep` instead raise the new `ModelTierResolutionError` and fail the node, so an explicit request for a cheap or a strong model is never silently served by whichever model the session happened to start with. With no declared output contract the response is prose; with one declared, the response is additionally parsed as JSON and validated through the same `validateConsumedNodeOutput` path every kind uses — there is no corrective reprompt, so a parse or validation failure consumes `control.retries` like any ordinary failure. The reply is carried verbatim as the node's `summary` in both cases, since `fields` reaches a consumer only through an expression binding and `build_handoff` renders a predecessor's summary/artifacts/concerns but never its `fields`. `control.optional`, `control.retries`, and `control.timeoutSec` behave as they do for a `function` node, except that an optional subprompt whose retry budget is exhausted becomes `skipped` rather than `failed` — matching `sub-flow`, because only `complete` and `skipped` satisfy a hard `flow` edge, so leaving it `failed` would permanently block its dependents. A subprompt inside an inline `sub-flow` child reaches the same runner as one in the parent. A subprompt's output is classified `obtainedBy: "agent"` (fixing a provenance hole: a downstream `check` consuming it now always derives `"asserted"`, never `"verified"`). `raceWithTimeout` does not cancel the underlying driver call on timeout — a known, documented cost this change does not address.
|
|
22
|
+
|
|
3
23
|
## 2.9.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -105,11 +105,22 @@ Explicit legacy `type: skill` and exact `type: sub-flow` nodes normalize to
|
|
|
105
105
|
their executable v2 kinds; every other legacy kind remains an inert
|
|
106
106
|
compatibility placeholder with its IDs, parameters, assets, and dependency
|
|
107
107
|
semantics retained.
|
|
108
|
-
The runtime activates `agent`, `
|
|
108
|
+
The runtime activates all seven kinds: `agent`, `subprompt`, `function`,
|
|
109
|
+
`check`, `gate`, `router`, and `sub-flow`.
|
|
109
110
|
Interpolated agent instructions, resolved values, and origins reach the session
|
|
110
|
-
agent through `build_handoff(nodeId)`; function nodes run shell,
|
|
111
|
-
commands in the existing session workspace without a model
|
|
112
|
-
values exported as environment variables
|
|
111
|
+
agent through `build_handoff(nodeId)`; function and check nodes run shell,
|
|
112
|
+
Node, or Python commands in the existing session workspace without a model
|
|
113
|
+
turn, with resolved values exported as environment variables — a check's exit
|
|
114
|
+
status is a pass/fail verdict rather than a plain success/failure. Subprompt
|
|
115
|
+
nodes are `function`-shaped except for how the work runs: a second, isolated
|
|
116
|
+
`AgentDriver` instance per call, with no Skaile system prompt, no MCP servers, no connector capabilities, and no access to the session conversation, bounded to a single turn. It does retain the backend's own native tool surface (a coding backend keeps its file and shell tools, rooted at the session workspace) — isolation here means a separate conversation, not a sandbox, resolving its declared `run.model` tier via a pure
|
|
117
|
+
`resolveModelTier` against per-provider built-in tiers, failing the node
|
|
118
|
+
rather than substituting a model when a tier cannot be served. A declared output contract drives a JSON-response request and
|
|
119
|
+
response parsing through the same consumed-output validation every kind uses;
|
|
120
|
+
there is no corrective reprompt, so a parse or validation failure is an
|
|
121
|
+
ordinary node failure. A subprompt's output is classified agent-obtained, so a
|
|
122
|
+
downstream check always derives "asserted" provenance over it, never
|
|
123
|
+
"verified". Gate nodes
|
|
113
124
|
park immediately through the durable approval state, complete on approval, and
|
|
114
125
|
preserve rejection feedback for revision and a later approval re-request.
|
|
115
126
|
Router nodes evaluate ordered bounded expressions only after admission. The first
|
|
@@ -130,8 +141,8 @@ durable corrective call; deterministic functions fail directly. Unconsumed schem
|
|
|
130
141
|
remain prose-only.
|
|
131
142
|
Skills, connectors, mounts, MCP servers, and knowledge stay reusable
|
|
132
143
|
`run.assets` requirements, and shared refs are deduplicated in the dependency
|
|
133
|
-
graph.
|
|
134
|
-
`sub-flow
|
|
144
|
+
graph. All seven current kinds — `agent`, `subprompt`, `function`, `check`,
|
|
145
|
+
`gate`, `router`, and `sub-flow` — are active.
|
|
135
146
|
`FlowDefinition` is the strict authored-v2 type; parser results use the wider
|
|
136
147
|
`ParsedFlowDefinition` so unknown legacy edge kinds and their metadata can be
|
|
137
148
|
retained inertly without weakening authored validation.
|
|
@@ -65,7 +65,7 @@ async function libraryAssets() {
|
|
|
65
65
|
const domains = [];
|
|
66
66
|
try {
|
|
67
67
|
const [{ openLibraryManager }, { skaileHomeDir }, { getGlobalCacheDir }] = await Promise.all([
|
|
68
|
-
import('./open-library-
|
|
68
|
+
import('./open-library-YDS66KLH.js'),
|
|
69
69
|
import('./library/index.js'),
|
|
70
70
|
import('./core/index.js')
|
|
71
71
|
]);
|
|
@@ -98,7 +98,7 @@ async function libraryAssets() {
|
|
|
98
98
|
async function storeAssets(projectDir) {
|
|
99
99
|
const notes = [];
|
|
100
100
|
try {
|
|
101
|
-
const { resolveCatalogSource } = await import('./open-library-
|
|
101
|
+
const { resolveCatalogSource } = await import('./open-library-YDS66KLH.js');
|
|
102
102
|
const { source, close } = await resolveCatalogSource({ projectDir });
|
|
103
103
|
try {
|
|
104
104
|
const assets = await source.listAssets();
|
|
@@ -202,5 +202,5 @@ function dedupeBySlug(domains) {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
export { gatherAssetFeeds };
|
|
205
|
-
//# sourceMappingURL=asset-feeds-
|
|
206
|
-
//# sourceMappingURL=asset-feeds-
|
|
205
|
+
//# sourceMappingURL=asset-feeds-3XCKB542.js.map
|
|
206
|
+
//# sourceMappingURL=asset-feeds-3XCKB542.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,eAAe,cAAc,IAAA,EAAmC;AAC9D,EAAA,MAAM,MAAkB,EAAC;AACzB,EAAA,WAAA,MAAiB,EAAE,IAAA,EAAM,QAAA,EAAU,MAAK,IAAK,OAAA,CAAQ,IAAI,CAAA,EAAG;AAC1D,IAAA,IAAI,SAAS,kBAAA,EAAoB;AACjC,IAAA,IAAI;AACF,MAAA,MAAM,EAAE,IAAA,EAAK,GAAI,iBAAiB,YAAA,CAAa,QAAA,EAAU,MAAM,CAAC,CAAA;AAChE,MAAA,GAAA,CAAI,IAAA,CAAK,cAAc,OAAA,CAAa,IAAA,CAAA,QAAA,CAAS,MAAM,QAAQ,CAAC,CAAA,EAAG,IAAI,CAAC,CAAA;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A,CAAI,EAAE,IAAI,CAAA;AACf,IAAA,GAAA,CAAI,KAAK,CAAC,CAAA;AAAA,EACZ;AACA,EAAA,OAAO,GAAA;AACT","file":"asset-feeds-EO2QDJ4C.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}. */\nasync function loadDomainMds(root: string): Promise<DomainMd[]> {\n const out: DomainMd[] = [];\n for await (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 */\nasync function stampDomains(\n root: string,\n fallbackSlug: string,\n entries: CatalogEntry[],\n synthesizeFallback = true,\n): Promise<CatalogDomain[]> {\n const domainMds = await 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 = [...(await scanRepo(lib.path, lib.name))];\n domains.push(...(await 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: () => Promise<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 */\nasync function sourceAssets(\n am: AssetManagerLike,\n): Promise<{ 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 = (await 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(...(await 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). Local disk only, 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 */\nasync function factoryAssets(): Promise<{\n entries: CatalogEntry[];\n domains: CatalogDomain[];\n notes: FeedNote[];\n}> {\n const notes: FeedNote[] = [];\n const domains: CatalogDomain[] = [];\n try {\n const entries: CatalogEntry[] = [];\n for (const root of factoryAssetRoots()) {\n const rootEntries = [...(await scanRepo(root, \"skaile-factory\"))];\n domains.push(...(await 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 disk only, 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 = await factoryAssets();\n const src = await 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,eAAe,cAAc,IAAA,EAAmC;AAC9D,EAAA,MAAM,MAAkB,EAAC;AACzB,EAAA,WAAA,MAAiB,EAAE,IAAA,EAAM,QAAA,EAAU,MAAK,IAAK,OAAA,CAAQ,IAAI,CAAA,EAAG;AAC1D,IAAA,IAAI,SAAS,kBAAA,EAAoB;AACjC,IAAA,IAAI;AACF,MAAA,MAAM,EAAE,IAAA,EAAK,GAAI,iBAAiB,YAAA,CAAa,QAAA,EAAU,MAAM,CAAC,CAAA;AAChE,MAAA,GAAA,CAAI,IAAA,CAAK,cAAc,OAAA,CAAa,IAAA,CAAA,QAAA,CAAS,MAAM,QAAQ,CAAC,CAAA,EAAG,IAAI,CAAC,CAAA;AAAA,IACtE,CAAA,CAAA,MAAQ;AAAA,IAAC;AAAA,EACX;AACA,EAAA,OAAO,GAAA;AACT;AAcA,eAAe,YAAA,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A;AACT","file":"asset-feeds-3XCKB542.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}. */\nasync function loadDomainMds(root: string): Promise<DomainMd[]> {\n const out: DomainMd[] = [];\n for await (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 */\nasync function stampDomains(\n root: string,\n fallbackSlug: string,\n entries: CatalogEntry[],\n synthesizeFallback = true,\n): Promise<CatalogDomain[]> {\n const domainMds = await 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 = [...(await scanRepo(lib.path, lib.name))];\n domains.push(...(await 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: () => Promise<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 */\nasync function sourceAssets(\n am: AssetManagerLike,\n): Promise<{ 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 = (await 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(...(await 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). Local disk only, 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 */\nasync function factoryAssets(): Promise<{\n entries: CatalogEntry[];\n domains: CatalogDomain[];\n notes: FeedNote[];\n}> {\n const notes: FeedNote[] = [];\n const domains: CatalogDomain[] = [];\n try {\n const entries: CatalogEntry[] = [];\n for (const root of factoryAssetRoots()) {\n const rootEntries = [...(await scanRepo(root, \"skaile-factory\"))];\n domains.push(...(await 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 disk only, 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 = await factoryAssets();\n const src = await 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, renderMcpServerConfig, softDepName } from '../chunk-
|
|
1
|
+
export { AssetManager, FACTORY_SOURCE_URL, MissingManifestError, NON_DEPLOYABLE_KINDS, normalizeRepoUrl, parseCanonicalLockKey, parseRefTolerant, renderMcpServerConfig, softDepName } from '../chunk-ZGTM4BOU.js';
|
|
2
2
|
import '../chunk-3HVASHBF.js';
|
|
3
3
|
import '../chunk-NU4E7C5I.js';
|
|
4
4
|
import '../chunk-UKJMQZV6.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SUPPORTED_CLOUDS, buildClaudeCloudEnv } from '../../chunk-
|
|
1
|
+
import { scrubPoisonedTranscript, resolveClaudeConfigDir, SUPPORTED_CLOUDS, buildClaudeCloudEnv } from '../../chunk-46LE3GNY.js';
|
|
2
2
|
import { dispatchCapability } from '../../chunk-RRVQAE5D.js';
|
|
3
|
-
import { fetchProviderModels } from '../../chunk-
|
|
3
|
+
import { fetchProviderModels } from '../../chunk-V34ZEXSE.js';
|
|
4
4
|
import { AuthError, classifyClaudeSdkError, reclassifyAuthAsAccountUnavailable, AccountUnavailableError } from '../../chunk-GAH4YRCI.js';
|
|
5
|
-
import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-
|
|
5
|
+
import { BUILTIN_DRIVER_CATALOG, AgentDriver, getBridgeLogger } from '../../chunk-QFO4IYBZ.js';
|
|
6
6
|
import '../../chunk-6E6PKKAD.js';
|
|
7
7
|
import '../../chunk-P43HBWKK.js';
|
|
8
8
|
import '../../chunk-F3HNW354.js';
|
|
@@ -12,19 +12,15 @@ import '../../chunk-UFY2HFLO.js';
|
|
|
12
12
|
import '../../chunk-Q26C5GLO.js';
|
|
13
13
|
import '../../chunk-MENCWIHW.js';
|
|
14
14
|
import '../../chunk-P4VHQA4N.js';
|
|
15
|
-
import
|
|
15
|
+
import '../../chunk-DYMWJAL4.js';
|
|
16
16
|
import '../../chunk-GEEW6SY2.js';
|
|
17
17
|
import '../../chunk-U5POE4BA.js';
|
|
18
18
|
import '../../chunk-7GOCNYUV.js';
|
|
19
19
|
import '../../chunk-NSBPE2FW.js';
|
|
20
20
|
import { spawnSync, spawn } from 'child_process';
|
|
21
|
-
import { readFileSync, existsSync
|
|
21
|
+
import { readFileSync, existsSync } from 'fs';
|
|
22
22
|
import { createRequire } from 'module';
|
|
23
|
-
import { homedir } from 'os';
|
|
24
|
-
import { join } from 'path';
|
|
25
23
|
import * as zNS from 'zod';
|
|
26
|
-
import { readdir, stat, rename, unlink } from 'fs/promises';
|
|
27
|
-
import { pipeline } from 'stream/promises';
|
|
28
24
|
|
|
29
25
|
// bridge/src/drivers/sanitize-assistant-text.ts
|
|
30
26
|
var NS = "(?:[a-z][a-z0-9]*:)?";
|
|
@@ -117,202 +113,6 @@ function streamingSafeSanitize(text) {
|
|
|
117
113
|
}
|
|
118
114
|
return cleaned.replace(/\s+$/, "");
|
|
119
115
|
}
|
|
120
|
-
var STUB_TEXT = "[image removed: unprocessable image data]";
|
|
121
|
-
var STUB_TEXT_OVERSIZED = "[image removed: image too large]";
|
|
122
|
-
var MAX_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
123
|
-
function sniffImageMediaType(base64) {
|
|
124
|
-
let buf;
|
|
125
|
-
try {
|
|
126
|
-
buf = Buffer.from(base64.slice(0, 32), "base64");
|
|
127
|
-
} catch {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
if (buf.length < 4) {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
if (buf[0] === 255 && buf[1] === 216) {
|
|
134
|
-
return "image/jpeg";
|
|
135
|
-
}
|
|
136
|
-
if (buf[0] === 137 && buf[1] === 80 && buf[2] === 78 && buf[3] === 71) {
|
|
137
|
-
return "image/png";
|
|
138
|
-
}
|
|
139
|
-
if (buf[0] === 71 && buf[1] === 73 && buf[2] === 70 && buf[3] === 56) {
|
|
140
|
-
return "image/gif";
|
|
141
|
-
}
|
|
142
|
-
if (buf.length >= 12 && buf[0] === 82 && buf[1] === 73 && buf[2] === 70 && buf[3] === 70 && buf[8] === 87 && buf[9] === 69 && buf[10] === 66 && buf[11] === 80) {
|
|
143
|
-
return "image/webp";
|
|
144
|
-
}
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
function totalChanges(c) {
|
|
148
|
-
return c.corrected + c.stubbed + c.cacheStripped;
|
|
149
|
-
}
|
|
150
|
-
function scrubBlock(block, counters) {
|
|
151
|
-
if (block.type === "tool_result" && Array.isArray(block.content)) {
|
|
152
|
-
return {
|
|
153
|
-
...block,
|
|
154
|
-
content: block.content.map((inner) => scrubBlock(inner, counters))
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
if (block.type === "text" && block.cache_control != null) {
|
|
158
|
-
const text = typeof block.text === "string" ? block.text : "";
|
|
159
|
-
if (text.trim() === "") {
|
|
160
|
-
counters.cacheStripped++;
|
|
161
|
-
const clone = { ...block };
|
|
162
|
-
delete clone.cache_control;
|
|
163
|
-
return clone;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (block.type === "image" && block.source?.type === "base64" && typeof block.source.data === "string") {
|
|
167
|
-
const data = block.source.data;
|
|
168
|
-
if (Math.floor(data.length * 3 / 4) > MAX_IMAGE_BYTES) {
|
|
169
|
-
counters.stubbed++;
|
|
170
|
-
return { type: "text", text: STUB_TEXT_OVERSIZED };
|
|
171
|
-
}
|
|
172
|
-
const sniffed = sniffImageMediaType(data);
|
|
173
|
-
if (sniffed === null) {
|
|
174
|
-
counters.stubbed++;
|
|
175
|
-
return { type: "text", text: STUB_TEXT };
|
|
176
|
-
}
|
|
177
|
-
if (sniffed !== block.source.media_type) {
|
|
178
|
-
counters.corrected++;
|
|
179
|
-
return { ...block, source: { ...block.source, media_type: sniffed } };
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return block;
|
|
183
|
-
}
|
|
184
|
-
async function locateTranscript(configDir, sessionId, timeoutMs) {
|
|
185
|
-
const projectsDir = join(configDir, "projects");
|
|
186
|
-
const entries = await tryWithFsDeadline(
|
|
187
|
-
`readdir ${projectsDir}`,
|
|
188
|
-
() => readdir(projectsDir),
|
|
189
|
-
null,
|
|
190
|
-
timeoutMs
|
|
191
|
-
);
|
|
192
|
-
if (!entries) return null;
|
|
193
|
-
for (const entry of entries) {
|
|
194
|
-
const candidate = join(projectsDir, entry, `${sessionId}.jsonl`);
|
|
195
|
-
const found = await tryWithFsDeadline(
|
|
196
|
-
`stat ${candidate}`,
|
|
197
|
-
async () => (await stat(candidate)).isFile(),
|
|
198
|
-
false,
|
|
199
|
-
timeoutMs
|
|
200
|
-
);
|
|
201
|
-
if (found) return candidate;
|
|
202
|
-
}
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
async function* streamLines(filePath) {
|
|
206
|
-
const stream = createReadStream(filePath, { encoding: "utf8" });
|
|
207
|
-
let pending = "";
|
|
208
|
-
try {
|
|
209
|
-
for await (const chunk of stream) {
|
|
210
|
-
pending += chunk;
|
|
211
|
-
let idx = pending.indexOf("\n");
|
|
212
|
-
while (idx !== -1) {
|
|
213
|
-
yield pending.slice(0, idx);
|
|
214
|
-
pending = pending.slice(idx + 1);
|
|
215
|
-
idx = pending.indexOf("\n");
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
yield pending;
|
|
219
|
-
} finally {
|
|
220
|
-
stream.destroy();
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
function repairLine(line, counters) {
|
|
224
|
-
if (line.trim() === "") return line;
|
|
225
|
-
const eol = line.endsWith("\r") ? "\r" : "";
|
|
226
|
-
const body = eol === "" ? line : line.slice(0, -1);
|
|
227
|
-
let entry;
|
|
228
|
-
try {
|
|
229
|
-
entry = JSON.parse(body);
|
|
230
|
-
} catch {
|
|
231
|
-
return line;
|
|
232
|
-
}
|
|
233
|
-
const content = entry.message?.content;
|
|
234
|
-
if (!Array.isArray(content)) return line;
|
|
235
|
-
const before = totalChanges(counters);
|
|
236
|
-
const scrubbed = content.map((block) => scrubBlock(block, counters));
|
|
237
|
-
if (totalChanges(counters) === before) return line;
|
|
238
|
-
return `${JSON.stringify({ ...entry, message: { ...entry.message, content: scrubbed } })}${eol}`;
|
|
239
|
-
}
|
|
240
|
-
async function scrubPoisonedTranscript(opts) {
|
|
241
|
-
const { configDir, sessionId, log } = opts;
|
|
242
|
-
const timeoutMs = fsDeadlineMs();
|
|
243
|
-
const result = {
|
|
244
|
-
filePath: null,
|
|
245
|
-
corrected: 0,
|
|
246
|
-
stubbed: 0,
|
|
247
|
-
cacheStripped: 0,
|
|
248
|
-
changed: false
|
|
249
|
-
};
|
|
250
|
-
const filePath = await locateTranscript(configDir, sessionId, timeoutMs);
|
|
251
|
-
if (!filePath) {
|
|
252
|
-
log?.warn("scrub-transcript: no transcript found", { configDir, sessionId });
|
|
253
|
-
return result;
|
|
254
|
-
}
|
|
255
|
-
result.filePath = filePath;
|
|
256
|
-
const counters = { corrected: 0, stubbed: 0, cacheStripped: 0 };
|
|
257
|
-
try {
|
|
258
|
-
await withFsDeadline(
|
|
259
|
-
`scan transcript ${filePath}`,
|
|
260
|
-
async () => {
|
|
261
|
-
for await (const line of streamLines(filePath)) repairLine(line, counters);
|
|
262
|
-
},
|
|
263
|
-
timeoutMs
|
|
264
|
-
);
|
|
265
|
-
} catch (err) {
|
|
266
|
-
log?.warn("scrub-transcript: failed to read transcript", {
|
|
267
|
-
filePath,
|
|
268
|
-
error: err instanceof Error ? err.message : String(err)
|
|
269
|
-
});
|
|
270
|
-
return result;
|
|
271
|
-
}
|
|
272
|
-
result.corrected = counters.corrected;
|
|
273
|
-
result.stubbed = counters.stubbed;
|
|
274
|
-
result.cacheStripped = counters.cacheStripped;
|
|
275
|
-
if (totalChanges(counters) === 0) {
|
|
276
|
-
return result;
|
|
277
|
-
}
|
|
278
|
-
const tmpPath = `${filePath}.scrub-tmp`;
|
|
279
|
-
try {
|
|
280
|
-
await withFsDeadline(
|
|
281
|
-
`rewrite transcript ${filePath}`,
|
|
282
|
-
async () => {
|
|
283
|
-
const discard = { corrected: 0, stubbed: 0, cacheStripped: 0 };
|
|
284
|
-
await pipeline(
|
|
285
|
-
(async function* () {
|
|
286
|
-
let first = true;
|
|
287
|
-
for await (const line of streamLines(filePath)) {
|
|
288
|
-
yield first ? repairLine(line, discard) : `
|
|
289
|
-
${repairLine(line, discard)}`;
|
|
290
|
-
first = false;
|
|
291
|
-
}
|
|
292
|
-
})(),
|
|
293
|
-
createWriteStream(tmpPath, { encoding: "utf8" })
|
|
294
|
-
);
|
|
295
|
-
await rename(tmpPath, filePath);
|
|
296
|
-
},
|
|
297
|
-
timeoutMs
|
|
298
|
-
);
|
|
299
|
-
} catch (err) {
|
|
300
|
-
log?.warn("scrub-transcript: failed to rewrite transcript", {
|
|
301
|
-
filePath,
|
|
302
|
-
error: err instanceof Error ? err.message : String(err)
|
|
303
|
-
});
|
|
304
|
-
await tryWithFsDeadline(`unlink ${tmpPath}`, () => unlink(tmpPath), void 0, timeoutMs);
|
|
305
|
-
return result;
|
|
306
|
-
}
|
|
307
|
-
result.changed = true;
|
|
308
|
-
log?.info("scrub-transcript: repaired poisoned transcript", {
|
|
309
|
-
filePath,
|
|
310
|
-
corrected: result.corrected,
|
|
311
|
-
stubbed: result.stubbed,
|
|
312
|
-
cacheStripped: result.cacheStripped
|
|
313
|
-
});
|
|
314
|
-
return result;
|
|
315
|
-
}
|
|
316
116
|
|
|
317
117
|
// bridge/src/drivers/claude-sdk.ts
|
|
318
118
|
var zStatic = zNS.z ?? zNS.default ?? zNS;
|
|
@@ -851,7 +651,7 @@ var ClaudeSdkDriver = class extends AgentDriver {
|
|
|
851
651
|
* the driver config, the process environment, or the `~/.claude` default.
|
|
852
652
|
*/
|
|
853
653
|
resolveClaudeConfigDir() {
|
|
854
|
-
return this.config.env
|
|
654
|
+
return resolveClaudeConfigDir(this.config.env);
|
|
855
655
|
}
|
|
856
656
|
/**
|
|
857
657
|
* Preventively repair the on-disk SDK transcript before a resume.
|