@skaile/workspaces 4.33.0 → 4.35.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 +16 -0
- package/README.md +3 -3
- package/dist/{asset-feeds-CZGV7GCG.js → asset-feeds-NL3526ZV.js} +11 -11
- package/dist/{asset-feeds-CZGV7GCG.js.map → asset-feeds-NL3526ZV.js.map} +1 -1
- package/dist/asset-manager/catalog-deployer.js +5 -5
- package/dist/asset-manager/index.js +11 -11
- package/dist/asset-manager/installer.js +8 -8
- package/dist/asset-manager/renderers.js +2 -2
- package/dist/asset-manager/src/index.d.ts +30 -24
- package/dist/asset-manager/src/index.d.ts.map +1 -1
- package/dist/asset-manager/src/renderers.d.ts +2 -2
- package/dist/bridge/drivers/claude-sdk.js +9 -9
- package/dist/bridge/drivers/codex.js +8 -8
- package/dist/bridge/drivers/continue.js +10 -10
- package/dist/bridge/drivers/continue.js.map +1 -1
- package/dist/bridge/drivers/echo.js +2 -2
- package/dist/bridge/drivers/gemini.js +6 -6
- package/dist/bridge/drivers/goose.js +10 -10
- package/dist/bridge/drivers/goose.js.map +1 -1
- package/dist/bridge/drivers/omp.js +3 -3
- package/dist/bridge/drivers/omp.js.map +1 -1
- package/dist/bridge/drivers/opencode.js +11 -11
- package/dist/bridge/drivers/opencode.js.map +1 -1
- package/dist/bridge/drivers/qwen.js +6 -6
- package/dist/bridge/index.js +10 -10
- package/dist/bridge/src/capability-dispatch.d.ts +1 -1
- package/dist/bridge/src/drivers/_subprocess-cli.d.ts +3 -3
- package/dist/bridge/src/drivers/continue.d.ts +1 -1
- package/dist/bridge/src/drivers/gemini.d.ts +3 -3
- package/dist/bridge/src/drivers/goose.d.ts +1 -1
- package/dist/bridge/src/drivers/opencode.d.ts +1 -1
- package/dist/bridge/src/provider-materialize/continue-config-yaml.d.ts +2 -2
- package/dist/bridge/src/provider-materialize/credential-env.d.ts +4 -4
- package/dist/bridge/src/provider-materialize/env-drivers.d.ts +18 -18
- package/dist/bridge/src/provider-materialize/goose-custom-providers.d.ts +1 -1
- package/dist/bridge/src/provider-materialize/opencode-config.d.ts +1 -1
- package/dist/bridge/src/provider-materialize/session-config-home.d.ts +5 -5
- package/dist/bridge/src/registry.d.ts +10 -10
- package/dist/bridge/src/types.d.ts +9 -9
- package/dist/{chunk-AAPFZCQX.js → chunk-24X2GGSC.js} +6 -6
- package/dist/{chunk-AAPFZCQX.js.map → chunk-24X2GGSC.js.map} +1 -1
- package/dist/{chunk-WPISSDEI.js → chunk-3ELIPWCH.js} +6 -6
- package/dist/{chunk-WPISSDEI.js.map → chunk-3ELIPWCH.js.map} +1 -1
- package/dist/{chunk-HL6SZ7Z3.js → chunk-5YXKEM7Q.js} +7 -7
- package/dist/{chunk-HL6SZ7Z3.js.map → chunk-5YXKEM7Q.js.map} +1 -1
- package/dist/{chunk-HXC5VF3L.js → chunk-66A35U4V.js} +36 -35
- package/dist/chunk-66A35U4V.js.map +1 -0
- package/dist/{chunk-ENUCD5MW.js → chunk-75LXFKQR.js} +4 -4
- package/dist/{chunk-ENUCD5MW.js.map → chunk-75LXFKQR.js.map} +1 -1
- package/dist/{chunk-GMXG2JGN.js → chunk-7ERHZQ7O.js} +3 -3
- package/dist/{chunk-GMXG2JGN.js.map → chunk-7ERHZQ7O.js.map} +1 -1
- package/dist/{chunk-JULFGNQN.js → chunk-7HJ6SFFF.js} +3 -3
- package/dist/{chunk-JULFGNQN.js.map → chunk-7HJ6SFFF.js.map} +1 -1
- package/dist/{chunk-DKCFWSVW.js → chunk-7LBPHRRP.js} +3 -3
- package/dist/chunk-7LBPHRRP.js.map +1 -0
- package/dist/{chunk-A7WRTOFI.js → chunk-AKO6XHGV.js} +5 -5
- package/dist/{chunk-A7WRTOFI.js.map → chunk-AKO6XHGV.js.map} +1 -1
- package/dist/{chunk-3C6Q6TCZ.js → chunk-AO7TCPOS.js} +62 -18
- package/dist/chunk-AO7TCPOS.js.map +1 -0
- package/dist/{chunk-54A5QAIV.js → chunk-C3256F2F.js} +2 -2
- package/dist/{chunk-54A5QAIV.js.map → chunk-C3256F2F.js.map} +1 -1
- package/dist/{chunk-2JANXYTJ.js → chunk-DHLE66FV.js} +3 -3
- package/dist/{chunk-2JANXYTJ.js.map → chunk-DHLE66FV.js.map} +1 -1
- package/dist/{chunk-BR2IXOWX.js → chunk-DOF77WEV.js} +6 -6
- package/dist/{chunk-BR2IXOWX.js.map → chunk-DOF77WEV.js.map} +1 -1
- package/dist/{chunk-MENCWIHW.js → chunk-EB4ZTESQ.js} +4 -4
- package/dist/chunk-EB4ZTESQ.js.map +1 -0
- package/dist/{chunk-XUVQSDNV.js → chunk-GKTFGCQZ.js} +3 -3
- package/dist/chunk-GKTFGCQZ.js.map +1 -0
- package/dist/{chunk-GTVQUHBN.js → chunk-GORUF3YZ.js} +10 -10
- package/dist/{chunk-GTVQUHBN.js.map → chunk-GORUF3YZ.js.map} +1 -1
- package/dist/{chunk-ACDHNOT7.js → chunk-IFUQ6XBQ.js} +87 -10
- package/dist/chunk-IFUQ6XBQ.js.map +1 -0
- package/dist/{chunk-6J4WBP3C.js → chunk-IGNY4C6K.js} +21 -21
- package/dist/{chunk-6J4WBP3C.js.map → chunk-IGNY4C6K.js.map} +1 -1
- package/dist/{chunk-I6NZG7WX.js → chunk-J4ANCOQ4.js} +6 -6
- package/dist/chunk-J4ANCOQ4.js.map +1 -0
- package/dist/{chunk-5RHPNNWP.js → chunk-JRIU5GA7.js} +3 -3
- package/dist/{chunk-5RHPNNWP.js.map → chunk-JRIU5GA7.js.map} +1 -1
- package/dist/{chunk-F3HNW354.js → chunk-KIFJWSNC.js} +3 -3
- package/dist/{chunk-F3HNW354.js.map → chunk-KIFJWSNC.js.map} +1 -1
- package/dist/{chunk-DF7C3KZK.js → chunk-LRCSWOZO.js} +14 -14
- package/dist/chunk-LRCSWOZO.js.map +1 -0
- package/dist/{chunk-TAZMDZFP.js → chunk-MTWZ7KHZ.js} +3 -3
- package/dist/{chunk-TAZMDZFP.js.map → chunk-MTWZ7KHZ.js.map} +1 -1
- package/dist/{chunk-QDRQKQOU.js → chunk-N2UGG6WV.js} +3 -3
- package/dist/{chunk-QDRQKQOU.js.map → chunk-N2UGG6WV.js.map} +1 -1
- package/dist/{chunk-4T25XCWX.js → chunk-NVQLE4MK.js} +3 -3
- package/dist/{chunk-4T25XCWX.js.map → chunk-NVQLE4MK.js.map} +1 -1
- package/dist/{chunk-C4JDLXPI.js → chunk-QJOOD3OV.js} +3 -3
- package/dist/{chunk-C4JDLXPI.js.map → chunk-QJOOD3OV.js.map} +1 -1
- package/dist/{chunk-NPS765HV.js → chunk-RHESVS7V.js} +9 -9
- package/dist/{chunk-NPS765HV.js.map → chunk-RHESVS7V.js.map} +1 -1
- package/dist/{chunk-6GSZLKA5.js → chunk-T762W5CI.js} +3 -3
- package/dist/chunk-T762W5CI.js.map +1 -0
- package/dist/{chunk-3ZE7X5Y6.js → chunk-TB3LJ6NA.js} +3 -3
- package/dist/{chunk-3ZE7X5Y6.js.map → chunk-TB3LJ6NA.js.map} +1 -1
- package/dist/{chunk-N7B3LZ7V.js → chunk-TGE33MKN.js} +2 -2
- package/dist/{chunk-N7B3LZ7V.js.map → chunk-TGE33MKN.js.map} +1 -1
- package/dist/{chunk-DRAI3JH5.js → chunk-TGJIX77V.js} +11 -11
- package/dist/chunk-TGJIX77V.js.map +1 -0
- package/dist/{chunk-UWJAJP6T.js → chunk-TTITGVXV.js} +2 -2
- package/dist/{chunk-UWJAJP6T.js.map → chunk-TTITGVXV.js.map} +1 -1
- package/dist/{chunk-N3AH66VX.js → chunk-TUTVTGMG.js} +4 -4
- package/dist/{chunk-N3AH66VX.js.map → chunk-TUTVTGMG.js.map} +1 -1
- package/dist/{chunk-HGPSZXZP.js → chunk-VOXFI3XS.js} +3 -3
- package/dist/{chunk-HGPSZXZP.js.map → chunk-VOXFI3XS.js.map} +1 -1
- package/dist/{chunk-SK36WO2Z.js → chunk-XTOTP7MJ.js} +2 -2
- package/dist/{chunk-SK36WO2Z.js.map → chunk-XTOTP7MJ.js.map} +1 -1
- package/dist/cli/index.js +119 -119
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/src/commands/catalog.d.ts +1 -1
- package/dist/cli/src/commands/integration.d.ts +2 -2
- package/dist/cli/src/commands/plugin/claude-code.d.ts +2 -2
- package/dist/cli/src/commands/plugin/codex.d.ts +2 -2
- package/dist/cli/src/commands/plugin/omp.d.ts +2 -2
- package/dist/cli/src/commands/plugin/types.d.ts +13 -13
- package/dist/cli/src/commands/plugin/types.d.ts.map +1 -1
- package/dist/cli/src/commands/run.d.ts +1 -1
- package/dist/connectors/config.js +3 -3
- package/dist/connectors/index.js +13 -13
- package/dist/connectors/src/connect-failure-carry-over.d.ts +38 -0
- package/dist/connectors/src/connect-failure-carry-over.d.ts.map +1 -0
- package/dist/connectors/src/connector-manager.d.ts +15 -0
- package/dist/connectors/src/connector-manager.d.ts.map +1 -1
- package/dist/connectors/src/index.d.ts +1 -0
- package/dist/connectors/src/index.d.ts.map +1 -1
- package/dist/core/driver-targets.js +1 -1
- package/dist/core/index.js +5 -5
- package/dist/core/runtime-assets.js +3 -3
- package/dist/core/src/driver-targets.d.ts +8 -8
- package/dist/core/src/index.d.ts +8 -2
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/settings.d.ts +1 -1
- package/dist/core/src/workspace-config.d.ts +16 -15
- package/dist/core/src/workspace-config.d.ts.map +1 -1
- package/dist/core/store.js +2 -2
- package/dist/core/workspace-config.js +2 -2
- package/dist/deploy/index.js +5 -5
- package/dist/discovery/index.js +2 -2
- package/dist/{ensure-sources-JGKHWDC4.js → ensure-sources-DVPPPCBS.js} +14 -14
- package/dist/{ensure-sources-JGKHWDC4.js.map → ensure-sources-DVPPPCBS.js.map} +1 -1
- package/dist/factory-assets/connectors/box.js +13 -13
- package/dist/factory-assets/connectors/deploy.js +13 -13
- package/dist/factory-assets/connectors/devserver.js +13 -13
- package/dist/factory-assets/connectors/flow/CONNECTOR.md +2 -2
- package/dist/factory-assets/connectors/flow/adapter.js +13 -13
- package/dist/factory-assets/connectors/flow/engine.js +6 -6
- package/dist/factory-assets/connectors/flow/run-flow.d.ts +1 -1
- package/dist/factory-assets/connectors/flow/run-flow.js +14 -14
- package/dist/factory-assets/connectors/flow/subprompt-runner.d.ts +3 -3
- package/dist/factory-assets/connectors/flow/subprompt-runner.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow.js +13 -13
- package/dist/factory-assets/connectors/git.js +13 -13
- package/dist/factory-assets/connectors/gmail.js +13 -13
- package/dist/factory-assets/connectors/googledrive.js +13 -13
- package/dist/factory-assets/connectors/local.js +13 -13
- package/dist/factory-assets/connectors/mattermost.js +13 -13
- package/dist/factory-assets/connectors/memory.js +13 -13
- package/dist/factory-assets/connectors/minio.js +13 -13
- package/dist/factory-assets/connectors/postgres.js +13 -13
- package/dist/factory-assets/connectors/s3.js +13 -13
- package/dist/factory-assets/connectors/sharepoint.js +13 -13
- package/dist/factory-assets/connectors/sqlite.js +13 -13
- package/dist/factory-assets/connectors/static-server.js +13 -13
- package/dist/factory-assets/connectors/tunnel.js +13 -13
- package/dist/factory-assets/connectors/webdav.js +13 -13
- package/dist/factory-assets/connectors/xstate-store.js +13 -13
- package/dist/factory-assets/connectors/xstate.js +13 -13
- package/dist/{flows-QTUSWYKY.js → flows-X7JFAVRR.js} +8 -8
- package/dist/{flows-QTUSWYKY.js.map → flows-X7JFAVRR.js.map} +1 -1
- package/dist/{helpers-6X4HJKWS.js → helpers-KLO5VUVZ.js} +14 -14
- package/dist/{helpers-6X4HJKWS.js.map → helpers-KLO5VUVZ.js.map} +1 -1
- package/dist/library/index.js +8 -8
- package/dist/{library-publish-MGN3N73A.js → library-publish-X6JGR7K3.js} +18 -18
- package/dist/{library-publish-MGN3N73A.js.map → library-publish-X6JGR7K3.js.map} +1 -1
- package/dist/{open-library-4PFE2CJ7.js → open-library-S2ZFKJUK.js} +16 -16
- package/dist/{open-library-4PFE2CJ7.js.map → open-library-S2ZFKJUK.js.map} +1 -1
- package/dist/{paths-IOOMNHTC.js → paths-OI5IIS22.js} +8 -8
- package/dist/{paths-IOOMNHTC.js.map → paths-OI5IIS22.js.map} +1 -1
- package/dist/plugin-registry/src/targets.d.ts +5 -5
- package/dist/plugin-registry/src/targets.d.ts.map +1 -1
- package/dist/{plugin-store-OIIPB2MQ.js → plugin-store-C67RLSPD.js} +7 -7
- package/dist/{plugin-store-OIIPB2MQ.js.map → plugin-store-C67RLSPD.js.map} +1 -1
- package/dist/{project-MD4HQ62C.js → project-7VOTYB7O.js} +15 -15
- package/dist/{project-MD4HQ62C.js.map → project-7VOTYB7O.js.map} +1 -1
- package/dist/resolver/index.js +5 -5
- package/dist/runner/index.js +18 -18
- package/dist/runner/src/manifest.d.ts +1 -1
- package/dist/runner/src/resources.d.ts.map +1 -1
- package/dist/runner/src/serve.d.ts +47 -1
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/runner/src/session-builder.d.ts +2 -2
- package/dist/runner/src/session-stimulus.d.ts +5 -0
- package/dist/runner/src/session-stimulus.d.ts.map +1 -1
- package/dist/runner/src/session.d.ts +1 -1
- package/dist/runner/src/session.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +11 -11
- package/dist/sdk/bridge.js +10 -10
- package/dist/sdk/core.js +5 -5
- package/dist/sdk/flow.js +6 -6
- package/dist/sdk/index.js +18 -18
- package/dist/sdk/resolver.js +5 -5
- package/dist/sdk/runner.js +18 -18
- package/dist/{setup-PB35G5SG.js → setup-RO3PGJYS.js} +19 -19
- package/dist/{setup-PB35G5SG.js.map → setup-RO3PGJYS.js.map} +1 -1
- package/dist/{skills-DH75K326.js → skills-4YTVHMOH.js} +7 -7
- package/dist/{skills-DH75K326.js.map → skills-4YTVHMOH.js.map} +1 -1
- package/dist/{source-Y5OF6IZU.js → source-ZZLLOP2U.js} +17 -17
- package/dist/{source-Y5OF6IZU.js.map → source-ZZLLOP2U.js.map} +1 -1
- package/dist/{source-manifest-publish-YWFVYTEI.js → source-manifest-publish-7WRQDIXO.js} +19 -19
- package/dist/{source-manifest-publish-YWFVYTEI.js.map → source-manifest-publish-7WRQDIXO.js.map} +1 -1
- package/dist/tui/index.js +18 -18
- package/dist/types/manifests.js +1 -1
- package/dist/types/src/manifests/agent.d.ts +4 -4
- package/dist/types/src/runtime.d.ts +4 -4
- package/dist/workspace-plugin/adapters/mcp.js +7 -7
- package/dist/workspace-plugin/adapters/omp.js +7 -7
- package/dist/workspace-plugin/index.js +1 -1
- package/dist/workspace-plugin/src/plugin.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-3C6Q6TCZ.js.map +0 -1
- package/dist/chunk-6GSZLKA5.js.map +0 -1
- package/dist/chunk-ACDHNOT7.js.map +0 -1
- package/dist/chunk-DF7C3KZK.js.map +0 -1
- package/dist/chunk-DKCFWSVW.js.map +0 -1
- package/dist/chunk-DRAI3JH5.js.map +0 -1
- package/dist/chunk-HXC5VF3L.js.map +0 -1
- package/dist/chunk-I6NZG7WX.js.map +0 -1
- package/dist/chunk-MENCWIHW.js.map +0 -1
- package/dist/chunk-XUVQSDNV.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getProviderPreset, registryCredentialEnv, providerCredentialEnvName, BUILTIN_DRIVER_CATALOG } from './chunk-
|
|
1
|
+
import { getProviderPreset, registryCredentialEnv, providerCredentialEnvName, BUILTIN_DRIVER_CATALOG } from './chunk-MTWZ7KHZ.js';
|
|
2
2
|
import { mergeRegistries, resolveEntryBaseUrl, normalizeEntryBaseUrl, registryEntries, isEntryEnabled, parseModelRef } from './chunk-MJHSLODD.js';
|
|
3
3
|
|
|
4
4
|
// bridge/src/provider-materialize/env-drivers.ts
|
|
@@ -33,7 +33,7 @@ function isStockCatalogEndpoint(entry) {
|
|
|
33
33
|
if (!preset) return false;
|
|
34
34
|
return entryBaseUrl(entry) === normalizeEntryBaseUrl(preset.base_url, entrySurface(entry));
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function harnessProviderName(providerId, entry) {
|
|
37
37
|
const preset = entry.preset ? getProviderPreset(entry.preset) : void 0;
|
|
38
38
|
if (!preset || !isStockCatalogEndpoint(entry)) return providerId;
|
|
39
39
|
return preset.id;
|
|
@@ -60,7 +60,7 @@ function describeBinding(providerId, entry, modelId, providerModelId, warnings)
|
|
|
60
60
|
...providerModelId === void 0 ? {} : { providerModelId },
|
|
61
61
|
...surface ? { surface } : {},
|
|
62
62
|
...baseUrl ? { baseUrl } : {},
|
|
63
|
-
|
|
63
|
+
harnessProviderId: harnessProviderName(providerId, entry),
|
|
64
64
|
warnings
|
|
65
65
|
};
|
|
66
66
|
}
|
|
@@ -102,10 +102,10 @@ function registryModelEntries(session) {
|
|
|
102
102
|
const out = [];
|
|
103
103
|
const seen = /* @__PURE__ */ new Set();
|
|
104
104
|
for (const [providerId, entry] of selectableEntries(session.registry)) {
|
|
105
|
-
const
|
|
105
|
+
const harnessId = harnessProviderName(providerId, entry);
|
|
106
106
|
const label = entry.label ?? providerId;
|
|
107
107
|
for (const [logicalId, providerModelId] of entryModelIds(entry)) {
|
|
108
|
-
const id = `${
|
|
108
|
+
const id = `${harnessId}/${providerModelId}`;
|
|
109
109
|
if (seen.has(id)) continue;
|
|
110
110
|
seen.add(id);
|
|
111
111
|
out.push({ id, name: `${label} ${logicalId}` });
|
|
@@ -119,9 +119,9 @@ function bindSingleProviderEntry(driverId, productName, session) {
|
|
|
119
119
|
assertDriverSpeaksSurface(driverId, productName, binding);
|
|
120
120
|
return binding;
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function harnessModelSelector(binding) {
|
|
123
123
|
if (!binding.providerModelId) return void 0;
|
|
124
|
-
return `${binding.
|
|
124
|
+
return `${binding.harnessProviderId}/${binding.providerModelId}`;
|
|
125
125
|
}
|
|
126
126
|
function continueRoleBinding(session) {
|
|
127
127
|
const binding = resolveRegistryBinding(session);
|
|
@@ -129,13 +129,13 @@ function continueRoleBinding(session) {
|
|
|
129
129
|
return {
|
|
130
130
|
role: "chat",
|
|
131
131
|
providerId: binding.providerId,
|
|
132
|
-
provider: binding.
|
|
132
|
+
provider: binding.harnessProviderId,
|
|
133
133
|
...binding.providerModelId ? { model: binding.providerModelId } : {},
|
|
134
134
|
...binding.baseUrl ? { apiBase: versionedAnthropicBaseUrl(binding.baseUrl, binding.surface) } : {},
|
|
135
135
|
apiKeyEnv: providerCredentialEnvName(binding.providerId)
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
export {
|
|
140
|
-
//# sourceMappingURL=chunk-
|
|
141
|
-
//# sourceMappingURL=chunk-
|
|
139
|
+
export { bindSingleProviderEntry, continueRoleBinding, credentialsForEveryProvider, entryBaseUrl, entryModelIds, entrySurface, harnessModelSelector, harnessProviderName, isStockCatalogEndpoint, registryModelEntries, resolveEnvDriverSession, resolveRegistryBinding, selectableEntries, versionedAnthropicBaseUrl };
|
|
140
|
+
//# sourceMappingURL=chunk-TGJIX77V.js.map
|
|
141
|
+
//# sourceMappingURL=chunk-TGJIX77V.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../bridge/src/provider-materialize/env-drivers.ts"],"names":[],"mappings":";;;;AAyEO,SAAS,uBAAA,CACd,MAAA,EACA,UAAA,GAAiD,OAAA,CAAQ,GAAA,EACvC;AAClB,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,MAAA,CAAO,QAAA,IAAY,eAAA,CAAgB,EAAE,CAAA;AAAA,IAC/C,WAAW,EAAE,GAAG,UAAA,EAAY,GAAG,OAAO,GAAA,EAAI;AAAA,IAC1C,GAAI,OAAO,QAAA,GAAW,EAAE,UAAU,MAAA,CAAO,QAAA,KAAa,EAAC;AAAA,IACvD,GAAI,OAAO,KAAA,GAAQ,EAAE,OAAO,MAAA,CAAO,KAAA,KAAU;AAAC,GAChD;AACF;AA2BO,SAAS,aAAa,KAAA,EAA0D;AACrF,EAAA,IAAI,KAAA,CAAM,OAAA,E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OAAA,CAAQ,OAAA,EAAS,OAAA,CAAQ,OAAO,CAAA,EAAE,GACvE,EAAC;AAAA,IACL,SAAA,EAAW,yBAAA,CAA0B,OAAA,CAAQ,UAAU;AAAA,GACzD;AACF","file":"chunk-TGJIX77V.js","sourcesContent":["/**\n * Registry adapter for the **env-shaped CLI drivers** — Gemini, Qwen, OpenCode,\n * Goose and Continue (§2.3).\n *\n * These harnesses take their endpoint from the environment rather than from a\n * config file, so the adapter's job is three things: resolve which registry\n * entry the session's model selector names, refuse at start when that entry\n * speaks a wire surface the harness cannot, and hand the driver the\n * provider-side model id it must put on the command line.\n *\n * Two pluralities meet here (`BUILTIN_DRIVER_CATALOG.providerPlurality`):\n *\n * - `single` — Gemini and Qwen address exactly one endpoint. The bound entry\n * supplies the credential *and* the base URL, and a surface mismatch is\n * fatal: a Gemini CLI pointed at an `openai-completions` endpoint cannot\n * work, and failing at start names the surface instead of leaving the user\n * with an opaque error mid-turn.\n * - `credentials-n` — OpenCode, Goose and Continue accept every enabled\n * entry's credential at once and select one active model. The credential\n * fan-out is `registryCredentialEnv`; the active model is this module's\n * `<provider>/<model>` binding.\n *\n * Writing the per-endpoint config files those three need for *custom*\n * endpoints (`opencode.json`, Goose `custom_providers/*.json`, Continue\n * `config.yaml`) is the file half, and is deliberately not here.\n *\n * @see PROVIDER-CONFIG-PLAN.md §2.3\n */\n\nimport {\n type AIProviderLlmEntry,\n type AIProviderSurface,\n isEntryEnabled,\n type MergedAIProviderRegistry,\n mergeRegistries,\n normalizeEntryBaseUrl,\n parseModelRef,\n registryEntries,\n resolveEntryBaseUrl,\n} from \"@skaile/workspaces/core/provider-registry\";\nimport type { ModelEntry } from \"../models.js\";\nimport { getProviderPreset } from \"../provider-catalog.js\";\nimport { BUILTIN_DRIVER_CATALOG } from \"../registry.js\";\nimport type { AgentConfig } from \"../types.js\";\nimport { providerCredentialEnvName, registryCredentialEnv } from \"./credential-env.js\";\n\n/**\n * Everything a CLI driver needs to know about this session's AI providers,\n * resolved once from its {@link AgentConfig}.\n */\nexport interface EnvDriverSession {\n /** The merged registry this session may address. Empty when none was configured. */\n registry: MergedAIProviderRegistry;\n /**\n * Environment `credential.ref` lookups resolve against — the process\n * environment widened with `config.env`, which is where the session\n * boundary delivered every resolved `SKAILE_AIP_<ID>_KEY`.\n */\n lookupEnv: Record<string, string | undefined>;\n /** Model selector: `<providerId>/<modelId>`, a bare id, or `@role`. */\n modelRef?: string;\n /** Roles table an `@role` selector resolves through. */\n roles?: Record<string, string>;\n}\n\n/**\n * Resolve the session's providers once, from its {@link AgentConfig}.\n *\n * `config.env` is folded into `lookupEnv` rather than kept apart: it is part\n * of the session's environment, not an extra, and a credential or\n * `*_BASE_URL` delivered there must be visible exactly as the child will see\n * it.\n */\nexport function resolveEnvDriverSession(\n config: AgentConfig,\n processEnv: Record<string, string | undefined> = process.env,\n): EnvDriverSession {\n return {\n registry: config.registry ?? mergeRegistries([]),\n lookupEnv: { ...processEnv, ...config.env },\n ...(config.modelRef ? { modelRef: config.modelRef } : {}),\n ...(config.roles ? { roles: config.roles } : {}),\n };\n}\n\n/** One resolved endpoint + model — everything a driver needs to spawn. */\nexport interface RegistryModelBinding {\n /** Registry id of the selected entry. */\n providerId: string;\n /** The selected entry itself. */\n entry: AIProviderLlmEntry;\n /** Logical model id, after `@role` expansion and before `model_map`. */\n modelId?: string;\n /** Provider-side model id — what goes on the wire / command line. */\n providerModelId?: string;\n /** Wire protocol, from the entry or its preset. */\n surface?: AIProviderSurface;\n /** Resolved endpoint, from the entry, its transport params, or its preset. */\n baseUrl?: string;\n /**\n * The provider name the *harness* knows this endpoint by — a catalog preset\n * id for a stock endpoint, the registry id for anything custom. See\n * {@link harnessProviderName}.\n */\n harnessProviderId: string;\n /** Non-fatal notes from `parseModelRef` (dangling role, disabled provider). */\n warnings: string[];\n}\n\n/** The entry's wire surface: its own, else its preset's. */\nexport function entrySurface(entry: AIProviderLlmEntry): AIProviderSurface | undefined {\n if (entry.surface) return entry.surface;\n return entry.preset ? getProviderPreset(entry.preset)?.surface : undefined;\n}\n\n/**\n * The entry's endpoint: its literal or transport-derived URL, else its\n * preset's literal, in the canonical spelling for its surface\n * (`normalizeEntryBaseUrl`: an `anthropic-messages` endpoint is its host root,\n * so `https://api.anthropic.com/v1` reads as `https://api.anthropic.com`).\n * Transport templates that still carry `{param}` placeholders never come\n * back — `resolveEntryBaseUrl` withholds those, and a preset's template is not\n * a URL.\n *\n * Every adapter reads the endpoint here and only re-spells it for a client\n * that wants something else ({@link versionedAnthropicBaseUrl}).\n */\nexport function entryBaseUrl(entry: AIProviderLlmEntry): string | undefined {\n const resolved =\n resolveEntryBaseUrl(entry) ??\n (entry.preset ? getProviderPreset(entry.preset)?.base_url : undefined);\n return normalizeEntryBaseUrl(resolved, entrySurface(entry));\n}\n\n/**\n * An `anthropic-messages` endpoint spelled for a client that appends only\n * `/messages` — `@ai-sdk/anthropic` (OpenCode) and Continue — rather than\n * `/v1/messages` like the Claude CLI, the Anthropic SDK and Goose. `baseUrl`\n * must already be canonical ({@link entryBaseUrl}); every other surface passes\n * through unchanged.\n */\nexport function versionedAnthropicBaseUrl(\n baseUrl: string,\n surface: AIProviderSurface | undefined,\n): string {\n if (surface !== \"anthropic-messages\") return baseUrl;\n // Append to the path, not the string: a query or fragment stays at the end.\n try {\n const url = new URL(baseUrl);\n url.pathname = `${url.pathname.replace(/\\/+$/, \"\")}/v1`;\n return url.toString();\n } catch {\n return `${baseUrl}/v1`;\n }\n}\n\n/**\n * True when a `credentials-n` harness already knows this endpoint under its\n * own catalog name — the entry names a preset and did not move it somewhere\n * else. Both sides are compared canonically, so `https://api.anthropic.com/v1`\n * is still the `anthropic` preset's endpoint.\n *\n * The one rule both halves of §2.3 read: it decides the name the env half\n * puts on the command line ({@link harnessProviderName}) *and* whether the\n * file half has to describe the endpoint at all. Reading it twice is what\n * keeps `-m <name>/<model>` and the generated provider file talking about the\n * same thing.\n */\nexport function isStockCatalogEndpoint(entry: AIProviderLlmEntry): boolean {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset) return false;\n return entryBaseUrl(entry) === normalizeEntryBaseUrl(preset.base_url, entrySurface(entry));\n}\n\n/**\n * The provider name to give a `credentials-n` harness (`-m <name>/<model>`,\n * `GOOSE_PROVIDER`).\n *\n * A stock catalog endpoint is named by its preset, because that is the name\n * OpenCode's models.dev list and Goose's built-in provider table already use —\n * `prod-claude: {preset: anthropic}` is still Anthropic to them. An entry with\n * an endpoint of its own is named by its registry id: no built-in table knows\n * it, so the id is what its generated provider file is keyed by (the file half\n * of §2.3).\n */\nexport function harnessProviderName(providerId: string, entry: AIProviderLlmEntry): string {\n const preset = entry.preset ? getProviderPreset(entry.preset) : undefined;\n if (!preset || !isStockCatalogEndpoint(entry)) return providerId;\n return preset.id;\n}\n\n/**\n * Enabled `llm`/`embed` entries, in registry order. Also the set the file\n * adapters render (`opencode-config.ts`, `goose-custom-providers.ts`,\n * `continue-config-yaml.ts`): the env half and the file half must agree on\n * which entries exist before they can agree on what to call them.\n */\nexport function selectableEntries(\n registry: MergedAIProviderRegistry,\n): Array<[string, AIProviderLlmEntry]> {\n return registryEntries(registry).filter(\n (pair): pair is [string, AIProviderLlmEntry] =>\n (pair[1].kind === \"llm\" || pair[1].kind === \"embed\") && isEntryEnabled(pair[1]),\n );\n}\n\n/**\n * The provider-side model ids an entry declares, as `[logicalId, providerId]`\n * pairs in declaration order: every `model_map` entry, plus every\n * `capabilities` key the map does not rename.\n */\nexport function entryModelIds(entry: AIProviderLlmEntry): Array<[string, string]> {\n const logicalIds = [\n ...Object.keys(entry.model_map ?? {}),\n ...Object.keys(entry.capabilities ?? {}).filter((id) => !(id in (entry.model_map ?? {}))),\n ];\n return logicalIds.map((id) => [id, entry.model_map?.[id] ?? id]);\n}\n\nfunction describeBinding(\n providerId: string,\n entry: AIProviderLlmEntry,\n modelId: string | undefined,\n providerModelId: string | undefined,\n warnings: string[],\n): RegistryModelBinding {\n const surface = entrySurface(entry);\n const baseUrl = entryBaseUrl(entry);\n return {\n providerId,\n entry,\n ...(modelId === undefined ? {} : { modelId }),\n ...(providerModelId === undefined ? {} : { providerModelId }),\n ...(surface ? { surface } : {}),\n ...(baseUrl ? { baseUrl } : {}),\n harnessProviderId: harnessProviderName(providerId, entry),\n warnings,\n };\n}\n\n/**\n * Resolve the session's endpoint + model.\n *\n * With no selector the first entry in registry order wins and the harness\n * keeps its own default model — exactly what an absent `model` meant before\n * the registry existed. Returns `undefined` when no entry can serve a model\n * (an empty, fully-disabled or voice-only registry).\n */\nexport function resolveRegistryBinding(\n session: EnvDriverSession,\n): RegistryModelBinding | undefined {\n const entries = selectableEntries(session.registry);\n if (entries.length === 0) return undefined;\n\n const selector = session.modelRef?.trim();\n if (!selector) {\n const [providerId, entry] = entries[0];\n return describeBinding(providerId, entry, undefined, undefined, []);\n }\n\n // A selector that is exactly an entry id names the endpoint and nothing\n // else: the harness keeps its own default model. `parseModelRef` would read\n // it as a bare *model* id and fall back to registry order.\n const named = entries.find(([id]) => id === selector);\n if (named) return describeBinding(named[0], named[1], undefined, undefined, []);\n\n const resolved = parseModelRef(selector, session.registry, session.roles);\n if (!resolved) return undefined;\n const match = entries.find(([id]) => id === resolved.providerId);\n if (!match) return undefined;\n return describeBinding(\n match[0],\n match[1],\n resolved.modelId,\n resolved.providerModelId,\n resolved.warnings,\n );\n}\n\n/**\n * Every credential a `credentials-n` harness may use: one variable per\n * enabled registry entry. OpenCode, Goose and Continue have always received\n * *all* of them, not just the selected endpoint's, because they route across\n * providers inside a single session.\n */\nexport function credentialsForEveryProvider(session: EnvDriverSession): Record<string, string> {\n return registryCredentialEnv(session.registry, { env: session.lookupEnv });\n}\n\n/**\n * Throw when the bound entry speaks a wire surface this driver cannot.\n *\n * The message names the offending surface and lists the ones the harness does\n * speak (`BUILTIN_DRIVER_CATALOG[driverId].surfaces`). An entry that declares\n * no surface and names no preset is not judged — there is nothing to compare.\n */\nexport function assertDriverSpeaksSurface(\n driverId: string,\n productName: string,\n binding: RegistryModelBinding,\n): void {\n const supported = BUILTIN_DRIVER_CATALOG[driverId]?.surfaces;\n if (!supported || supported.length === 0) return;\n const surface = binding.surface;\n if (!surface || supported.includes(surface)) return;\n throw new Error(\n `${productName} cannot speak the '${surface}' surface of AI provider entry ` +\n `'${binding.providerId}'. ${productName} speaks: ${supported.join(\", \")}. ` +\n `Point this session's model at an entry with one of those surfaces, ` +\n `or run it on a driver that speaks '${surface}'.`,\n );\n}\n\n/**\n * The models a `credentials-n` harness can be pointed at, straight from the\n * registry: every enabled entry's mapped ids, namespaced the way the harness\n * takes them (`-m <provider>/<model>`).\n *\n * These harnesses have no model-list endpoint of their own — OpenCode reads\n * models.dev, Goose and Continue read their config — so the registry is the\n * only list that describes *this* session's reachable models, and it needs no\n * network call to produce.\n */\nexport function registryModelEntries(session: EnvDriverSession): ModelEntry[] {\n const out: ModelEntry[] = [];\n const seen = new Set<string>();\n for (const [providerId, entry] of selectableEntries(session.registry)) {\n const harnessId = harnessProviderName(providerId, entry);\n const label = entry.label ?? providerId;\n for (const [logicalId, providerModelId] of entryModelIds(entry)) {\n const id = `${harnessId}/${providerModelId}`;\n if (seen.has(id)) continue;\n seen.add(id);\n out.push({ id, name: `${label} ${logicalId}` });\n }\n }\n return out;\n}\n\n/**\n * Resolve the binding and enforce the surface — what a `single`-plurality\n * driver does at start.\n *\n * The registry is authoritative: pointing the driver at an entry it cannot\n * speak throws rather than silently running somewhere else. `undefined` when\n * the session configured no endpoint at all, which leaves the driver on its\n * own native auth.\n */\nexport function bindSingleProviderEntry(\n driverId: string,\n productName: string,\n session: EnvDriverSession,\n): RegistryModelBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n assertDriverSpeaksSurface(driverId, productName, binding);\n return binding;\n}\n\n/**\n * The `<provider>/<model>` selector a `credentials-n` harness takes on its\n * command line (`opencode -m`). `undefined` when no model was selected — the\n * harness then uses its own default rather than being handed a bare provider.\n */\nexport function harnessModelSelector(binding: RegistryModelBinding): string | undefined {\n if (!binding.providerModelId) return undefined;\n return `${binding.harnessProviderId}/${binding.providerModelId}`;\n}\n\n/**\n * Continue's model selection is a **role binding**, not a flag: `cn` has no\n * `--model` option (only `--config <slug>`), and its `config.yaml` binds each\n * model to roles (`chat`, `edit`, `apply`, …). This is the binding for the\n * role a headless `cn -p` turn runs as, and the shape its generated\n * `config.yaml` is rendered from.\n *\n * `apiKeyEnv` is a variable *name*: the secret travels in the child\n * environment, never in a rendered config.\n */\nexport interface ContinueRoleBinding {\n /** Continue role this model serves. A headless prompt is a `chat` turn. */\n role: \"chat\";\n /** Registry id of the entry. */\n providerId: string;\n /** Provider name Continue knows the endpoint by. */\n provider: string;\n /** Provider-side model id. */\n model?: string;\n /** Endpoint, when the entry states one, spelled the way Continue's `apiBase` wants it. */\n apiBase?: string;\n /** Env var holding the credential — the name, never the value. */\n apiKeyEnv: string;\n}\n\n/**\n * Map the session's chosen endpoint onto the Continue role a headless turn\n * runs as. `undefined` when the session configured no endpoint — `cn` then\n * runs against whatever its own `config.yaml` / Hub login provides.\n */\nexport function continueRoleBinding(session: EnvDriverSession): ContinueRoleBinding | undefined {\n const binding = resolveRegistryBinding(session);\n if (!binding) return undefined;\n return {\n role: \"chat\",\n providerId: binding.providerId,\n provider: binding.harnessProviderId,\n ...(binding.providerModelId ? { model: binding.providerModelId } : {}),\n ...(binding.baseUrl\n ? { apiBase: versionedAnthropicBaseUrl(binding.baseUrl, binding.surface) }\n : {}),\n apiKeyEnv: providerCredentialEnvName(binding.providerId),\n };\n}\n"]}
|
|
@@ -52,5 +52,5 @@ function filterRenderCapabilities(caps) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export { dispatchCapability, filterRenderCapabilities, renderFallback };
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
56
|
-
//# sourceMappingURL=chunk-
|
|
55
|
+
//# sourceMappingURL=chunk-TTITGVXV.js.map
|
|
56
|
+
//# sourceMappingURL=chunk-TTITGVXV.js.map
|
|
@@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Hooks} bundle from its\n * `CapabilityRegistry` and threads it through `AgentConfig.capabilities`.\n * Drivers consume the bundle via these helpers without taking a runtime\n * dependency on `@skaile/workspaces/runner` (which would create a circular dep).\n *\n * Three behaviours are layered into a single dispatch path:\n *\n * 1. **Standard tool call** — the LLM invokes a capability; the bridge calls\n * `hooks.invoke()`, awaits the result, and returns it to the LLM.\n * 2. **Fire-and-forget** — when the resolved Capability has `fireAndForget`\n * set, the bridge resolves to `{}` immediately and runs the handler in\n * the background. Background errors are logged but never surfaced to the\n * LLM since the call is already settled.\n * 3. **Render capability** — when the resolved Capability has a non-undefined\n * `render`, the bridge emits `RenderInvokedEvent` to the runner via\n * `hooks.emitRender` and (when `render.fallback` is set) a parallel text\n * event via `hooks.emitText` with simple `{{prop}}` substitution. The\n * placeholder convention follows the v2 spec — top-level keys of `props`\n * only, with optional dotted-path traversal (`{{user.name}}`). The legacy\n * AAP `{{props.x}}` form was retired in Phase 6.\n *\n * @category Capabilities\n * @since 2.0.0\n */\nimport { randomUUID } from \"node:crypto\";\nimport {\n type Capability,\n declaresActivityLabel,\n stripActivityLabel,\n} from \"@skaile/workspaces/types\";\nimport type { BridgeCapabilityHooks } from \"./types.js\";\n\n/**\n * Result of a capability dispatch returned by {@link dispatchCapability}.\n *\n * The bridge feeds `{ result }` back to the LLM tool-use response. For\n * fire-and-forget capabilities `result` is always `{}` and `background` is `true`.\n *\n * @docLink packages/bridge/concepts#capability-dispatch-result\n */\nexport interface CapabilityDispatchResult {\n /** Value returned to the LLM. `{}` for fire-and-forget capabilities. */\n result: unknown;\n /** True when the handler is still running in the background (fire-and-forget). */\n background: boolean;\n /** The per-dispatch call id minted for this invocation (see {@link dispatchCapability}). */\n callId: string;\n}\n\n/**\n * Run a capability invocation through the runner-provided hooks, applying\n * render-event emission and fire-and-forget short-circuit.\n *\n * The result is always shaped for direct return to the LLM. For\n * fire-and-forget capabilities the background promise is fired and any error\n * is logged through `onBackgroundError` (defaulting to a no-op). For all\n * other capabilities the handler is awaited; errors propagate as a rejection\n * so the driver can surface them as tool errors.\n *\n * **Dispatch call id.** Every dispatch mints a fresh `randomUUID()` and uses it\n * for `render_invoked.callId`, `hooks.invoke`'s `callId` and — for client\n * capabilities — the outbound `capability_invoked.callId`. It is deliberately\n * NOT the driver's tool-call id: those are only as unique as the model\n * provider makes them (some backends emit `call_0` on every turn), and the\n * runner's pending-call map is keyed by this id, so a late `capability_result`\n * for a timed-out call must never be able to resolve a later call that reused\n * the provider's id. Drivers map results back to their tool calls through the\n * returned value, never through this id.\n *\n * @param hooks - Capability dispatch bundle from `AgentConfig.capabilities`.\n * @param name - Registered capability name.\n * @param input - Raw tool input from the LLM.\n * @param onBackgroundError - Optional error handler for fire-and-forget failures; receives the dispatch call id.\n * @param signal - Optional abort signal forwarded to the handler.\n * @returns Resolved dispatch result with the LLM-facing value, background flag and dispatch call id.\n * @docLink packages/bridge/concepts#dispatch-capability\n */\nexport async function dispatchCapability(\n hooks: BridgeCapabilityHooks,\n name: string,\n input: unknown,\n onBackgroundError: (err: unknown, callId: string) => void = () => {},\n signal?: AbortSignal,\n): Promise<CapabilityDispatchResult> {\n signal?.throwIfAborted();\n const callId = randomUUID();\n const cap = hooks.resolve(name);\n // The advertised `activity_label` is for the UI only. Strip it before render\n // props and the handler: strict inputs would reject it and external MCP\n // passthrough would forward it. Kept when the capability declares it itself.\n if (!declaresActivityLabel(cap?.inputSchema)) input = stripActivityLabel(input);\n\n // Render emission happens before invocation so clients see the props the\n // LLM passed in even if the handler errors. The runner's gateway forwards\n // the event over the transport.\n if (cap?.render && hooks.emitRender) {\n hooks.emitRender({\n type: \"render_invoked\",\n capabilityName: name,\n props: input,\n callId,\n });\n if (cap.render.fallback && hooks.emitText) {\n const fallback = renderFallback(cap.render.fallback, input);\n hooks.emitText(fallback);\n }\n }\n\n if (cap?.fireAndForget) {\n // Resolve immediately; run handler in background.\n void hooks.invoke(name, input, signal, callId).catch((err) => onBackgroundError(err, callId));\n return { result: {}, background: true, callId };\n }\n\n const result = await hooks.invoke(name, input, signal, callId);\n return { result, background: false, callId };\n}\n\n/**\n * Substitute `{{prop}}` placeholders inside a fallback template using the\n * input record. Top-level keys of `props` resolve directly\n * (`{{name}}` → `props.name`); dotted paths traverse nested records\n * (`{{user.name}}` → `props.user.name`). Missing keys collapse to an empty\n * string; non-record inputs collapse all placeholders.\n *\n * The convention is fixed by the v2 spec (§1, `RenderSpec.fallback`). The\n * legacy AAP form `{{props.x}}` is no longer accepted — author fallbacks\n * with bare keys.\n *\n * Intentionally minimal — full template engines belong in the platform's\n * render layer, not the bridge.\n *\n * @param template - Fallback string from `RenderSpec.fallback` with `{{key}}` placeholders.\n * @param input - LLM tool input object; non-object values collapse all placeholders.\n * @returns Template with all resolvable placeholders replaced.\n * @docLink packages/bridge/concepts#render-fallback\n */\nexport function renderFallback(template: string, input: unknown): string {\n if (!input || typeof input !== \"object\") {\n return template.replace(/\\{\\{\\s*[\\w$.]+\\s*\\}\\}/g, \"\");\n }\n const props = input as Record<string, unknown>;\n return template.replace(/\\{\\{\\s*([\\w$.]+)\\s*\\}\\}/g, (_match, path: string) => {\n const value = readPath(props, path);\n return value === undefined || value === null ? \"\" : String(value);\n });\n}\n\nfunction readPath(obj: Record<string, unknown>, path: string): unknown {\n const parts = path.split(\".\");\n let current: unknown = obj;\n for (const part of parts) {\n if (current === null || current === undefined || typeof current !== \"object\") {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n}\n\n/**\n * Filter a capability list to those marked as render-capable (having a `render` spec).\n *\n * Used by drivers that emit a separate render manifest at registration time.\n * Currently unused in production drivers; reserved for future phases.\n *\n * @param caps - Full capability list to filter.\n * @returns Subset of capabilities with a non-undefined `render` property.\n * @docLink packages/bridge/concepts#filter-render-capabilities\n */\nexport function filterRenderCapabilities(caps: Capability[]): Capability[] {\n return caps.filter((c) => c.render !== undefined);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../bridge/src/capability-dispatch.ts"],"names":[],"mappings":";;;A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UAAA,EAAY,KAAA,EAAO,MAAA,EAAO;AAC7C;AAqBO,SAAS,cAAA,CAAe,UAAkB,KAAA,EAAwB;AACvE,EAAA,IAAI,CAAC,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,EAAU;AACvC,IAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,wBAAA,EAA0B,EAAE,CAAA;AAAA,EACtD;AACA,EAAA,MAAM,KAAA,GAAQ,KAAA;AACd,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,0BAAA,EAA4B,CAAC,QAAQ,IAAA,KAAiB;AAC5E,IAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,KAAA,EAAO,IAAI,CAAA;AAClC,IAAA,OAAO,UAAU,MAAA,IAAa,KAAA,KAAU,IAAA,GAAO,EAAA,GAAK,OAAO,KAAK,CAAA;AAAA,EAClE,CAAC,CAAA;AACH;AAEA,SAAS,QAAA,CAAS,KAA8B,IAAA,EAAuB;AACrE,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC5B,EAAA,IAAI,OAAA,GAAmB,GAAA;AACvB,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,IAAA,IAAI,YAAY,IAAA,IAAQ,OAAA,KAAY,MAAA,IAAa,OAAO,YAAY,QAAA,EAAU;AAC5E,MAAA,OAAO,MAAA;AAAA,IACT;AACA,IAAA,OAAA,GAAW,QAAoC,IAAI,CAAA;AAAA,EACrD;AACA,EAAA,OAAO,OAAA;AACT;AAYO,SAAS,yBAAyB,IAAA,EAAkC;AACzE,EAAA,OAAO,KAAK,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,WAAW,MAAS,CAAA;AAClD","file":"chunk-TTITGVXV.js","sourcesContent":["/**\n * Capability dispatch helpers for bridge drivers.\n *\n * The runner builds a {@link BridgeCapabilityHooks} bundle from its\n * `CapabilityRegistry` and threads it through `AgentConfig.capabilities`.\n * Drivers consume the bundle via these helpers without taking a runtime\n * dependency on `@skaile/workspaces/runner` (which would create a circular dep).\n *\n * Three behaviours are layered into a single dispatch path:\n *\n * 1. **Standard tool call** — the LLM invokes a capability; the bridge calls\n * `hooks.invoke()`, awaits the result, and returns it to the LLM.\n * 2. **Fire-and-forget** — when the resolved Capability has `fireAndForget`\n * set, the bridge resolves to `{}` immediately and runs the handler in\n * the background. Background errors are logged but never surfaced to the\n * LLM since the call is already settled.\n * 3. **Render capability** — when the resolved Capability has a non-undefined\n * `render`, the bridge emits `RenderInvokedEvent` to the runner via\n * `hooks.emitRender` and (when `render.fallback` is set) a parallel text\n * event via `hooks.emitText` with simple `{{prop}}` substitution. The\n * placeholder convention follows the v2 spec — top-level keys of `props`\n * only, with optional dotted-path traversal (`{{user.name}}`). The legacy\n * AAP `{{props.x}}` form was retired in Phase 6.\n *\n * @category Capabilities\n * @since 2.0.0\n */\nimport { randomUUID } from \"node:crypto\";\nimport {\n type Capability,\n declaresActivityLabel,\n stripActivityLabel,\n} from \"@skaile/workspaces/types\";\nimport type { BridgeCapabilityHooks } from \"./types.js\";\n\n/**\n * Result of a capability dispatch returned by {@link dispatchCapability}.\n *\n * The bridge feeds `{ result }` back to the LLM tool-use response. For\n * fire-and-forget capabilities `result` is always `{}` and `background` is `true`.\n *\n * @docLink packages/bridge/concepts#capability-dispatch-result\n */\nexport interface CapabilityDispatchResult {\n /** Value returned to the LLM. `{}` for fire-and-forget capabilities. */\n result: unknown;\n /** True when the handler is still running in the background (fire-and-forget). */\n background: boolean;\n /** The per-dispatch call id minted for this invocation (see {@link dispatchCapability}). */\n callId: string;\n}\n\n/**\n * Run a capability invocation through the runner-provided hooks, applying\n * render-event emission and fire-and-forget short-circuit.\n *\n * The result is always shaped for direct return to the LLM. For\n * fire-and-forget capabilities the background promise is fired and any error\n * is logged through `onBackgroundError` (defaulting to a no-op). For all\n * other capabilities the handler is awaited; errors propagate as a rejection\n * so the driver can surface them as tool errors.\n *\n * **Dispatch call id.** Every dispatch mints a fresh `randomUUID()` and uses it\n * for `render_invoked.callId`, `hooks.invoke`'s `callId` and — for client\n * capabilities — the outbound `capability_invoked.callId`. It is deliberately\n * NOT the driver's tool-call id: those are only as unique as the model\n * provider makes them (some harnesses emit `call_0` on every turn), and the\n * runner's pending-call map is keyed by this id, so a late `capability_result`\n * for a timed-out call must never be able to resolve a later call that reused\n * the provider's id. Drivers map results back to their tool calls through the\n * returned value, never through this id.\n *\n * @param hooks - Capability dispatch bundle from `AgentConfig.capabilities`.\n * @param name - Registered capability name.\n * @param input - Raw tool input from the LLM.\n * @param onBackgroundError - Optional error handler for fire-and-forget failures; receives the dispatch call id.\n * @param signal - Optional abort signal forwarded to the handler.\n * @returns Resolved dispatch result with the LLM-facing value, background flag and dispatch call id.\n * @docLink packages/bridge/concepts#dispatch-capability\n */\nexport async function dispatchCapability(\n hooks: BridgeCapabilityHooks,\n name: string,\n input: unknown,\n onBackgroundError: (err: unknown, callId: string) => void = () => {},\n signal?: AbortSignal,\n): Promise<CapabilityDispatchResult> {\n signal?.throwIfAborted();\n const callId = randomUUID();\n const cap = hooks.resolve(name);\n // The advertised `activity_label` is for the UI only. Strip it before render\n // props and the handler: strict inputs would reject it and external MCP\n // passthrough would forward it. Kept when the capability declares it itself.\n if (!declaresActivityLabel(cap?.inputSchema)) input = stripActivityLabel(input);\n\n // Render emission happens before invocation so clients see the props the\n // LLM passed in even if the handler errors. The runner's gateway forwards\n // the event over the transport.\n if (cap?.render && hooks.emitRender) {\n hooks.emitRender({\n type: \"render_invoked\",\n capabilityName: name,\n props: input,\n callId,\n });\n if (cap.render.fallback && hooks.emitText) {\n const fallback = renderFallback(cap.render.fallback, input);\n hooks.emitText(fallback);\n }\n }\n\n if (cap?.fireAndForget) {\n // Resolve immediately; run handler in background.\n void hooks.invoke(name, input, signal, callId).catch((err) => onBackgroundError(err, callId));\n return { result: {}, background: true, callId };\n }\n\n const result = await hooks.invoke(name, input, signal, callId);\n return { result, background: false, callId };\n}\n\n/**\n * Substitute `{{prop}}` placeholders inside a fallback template using the\n * input record. Top-level keys of `props` resolve directly\n * (`{{name}}` → `props.name`); dotted paths traverse nested records\n * (`{{user.name}}` → `props.user.name`). Missing keys collapse to an empty\n * string; non-record inputs collapse all placeholders.\n *\n * The convention is fixed by the v2 spec (§1, `RenderSpec.fallback`). The\n * legacy AAP form `{{props.x}}` is no longer accepted — author fallbacks\n * with bare keys.\n *\n * Intentionally minimal — full template engines belong in the platform's\n * render layer, not the bridge.\n *\n * @param template - Fallback string from `RenderSpec.fallback` with `{{key}}` placeholders.\n * @param input - LLM tool input object; non-object values collapse all placeholders.\n * @returns Template with all resolvable placeholders replaced.\n * @docLink packages/bridge/concepts#render-fallback\n */\nexport function renderFallback(template: string, input: unknown): string {\n if (!input || typeof input !== \"object\") {\n return template.replace(/\\{\\{\\s*[\\w$.]+\\s*\\}\\}/g, \"\");\n }\n const props = input as Record<string, unknown>;\n return template.replace(/\\{\\{\\s*([\\w$.]+)\\s*\\}\\}/g, (_match, path: string) => {\n const value = readPath(props, path);\n return value === undefined || value === null ? \"\" : String(value);\n });\n}\n\nfunction readPath(obj: Record<string, unknown>, path: string): unknown {\n const parts = path.split(\".\");\n let current: unknown = obj;\n for (const part of parts) {\n if (current === null || current === undefined || typeof current !== \"object\") {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n}\n\n/**\n * Filter a capability list to those marked as render-capable (having a `render` spec).\n *\n * Used by drivers that emit a separate render manifest at registration time.\n * Currently unused in production drivers; reserved for future phases.\n *\n * @param caps - Full capability list to filter.\n * @returns Subset of capabilities with a non-undefined `render` property.\n * @docLink packages/bridge/concepts#filter-render-capabilities\n */\nexport function filterRenderCapabilities(caps: Capability[]): Capability[] {\n return caps.filter((c) => c.render !== undefined);\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getStoreConfig, getStoreToken, storeFetch } from './chunk-
|
|
2
|
-
import { S, logErr, logWarn, logOk, logInfo } from './chunk-
|
|
1
|
+
import { getStoreConfig, getStoreToken, storeFetch } from './chunk-TB3LJ6NA.js';
|
|
2
|
+
import { S, logErr, logWarn, logOk, logInfo } from './chunk-QJOOD3OV.js';
|
|
3
3
|
|
|
4
4
|
// cli/src/store-publisher.ts
|
|
5
5
|
function makeHttpPublisherClient(config = getStoreConfig(), timeoutMs = 2e4) {
|
|
@@ -154,5 +154,5 @@ async function publishToStore(opts) {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
export { bareName, formatNamespaceAvailability, makeHttpPublisherClient, preflightNamespace, publishToStore, refFor };
|
|
157
|
-
//# sourceMappingURL=chunk-
|
|
158
|
-
//# sourceMappingURL=chunk-
|
|
157
|
+
//# sourceMappingURL=chunk-TUTVTGMG.js.map
|
|
158
|
+
//# sourceMappingURL=chunk-TUTVTGMG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/src/store-publisher.ts","../cli/src/commands/publish-core.ts"],"names":[],"mappings":";;;;AA+FO,SAAS,uBAAA,CACd,MAAA,GAAsB,cAAA,EAAe,EACrC,YAAY,GAAA,EACK;AAGjB,EAAA,MAAM,IAAA,GAAO,OACX,IAAA,EACA,IAAA,KACe;AACf,IAAA,MAAM,GAAA,GAAM,MAAM,aAAA,EAAc;AAChC,IAAA,OAAO,UAAA,CAAc,EAAE,GAAG,MAAA,EAAQ,GAAA,EAAI,EAAG,IAAA,EAAM,EAAE,SAAA,EAAW,GAAG,IAAA,EAAM,CAAA;AAAA,EACvE,CAAA;AACA,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,MAAM,IAAA,CAAK,YAAY,CAAA;AAAA,IAC3B,UAAA,EAAY,CAAC,IAAA,KAAS,IAAA,CAAK,mBAAmB,EAAE,MAAA,EAAQ,MAAA,EAAQ,IAAA,EAAM,CAAA;AAAA,IACtE,WAAA,EAAa,MAAM,IAAA,CAAK,iBAAiB,CAAA;AAAA,IACzC,UAAA,EAAY,CAAC,EAAA,KAAO,IAAA,CAAK,CAAA,gBAAA,EA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,GAAA,EAAK;AACZ,MAAA,OAAA;AAAA,QACE,CAAA,kBAAA,EAAqB,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAA,CAAE,IAAI,CAAA,EAAA,EAAK,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,OAC5F;AAAA,IACF;AAAA,EACF;AAEA,EAAA,KAAA,CAAM,CAAA,UAAA,EAAa,SAAA,CAAU,MAAM,CAAA,UAAA,CAAY,CAAA;AAC/C,EAAA,KAAA,MAAW,CAAA,IAAK,SAAA,EAAW,OAAA,CAAQ,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAA;AAC3C,EAAA,OAAO,EAAE,SAAA,EAAU;AACrB","file":"chunk-N3AH66VX.js","sourcesContent":["/**\n * Typed REST client for the AI Asset Store **publisher** surface — the\n * curator-publish flow (`skaile source manifest publish` / `yank`). Thin\n * wrappers over {@link storeFetch}; every method maps 1:1 to an `/api/v1/…`\n * endpoint. The {@link PublisherClient} interface is injectable so the\n * orchestration in `commands/source-manifest-publish.ts` can be unit-tested\n * against a fake without a live store.\n *\n * @docLink cli/dev-guide#store-publisher\n */\n\nimport { getStoreConfig, getStoreToken, type StoreConfig, storeFetch } from \"./store-client.ts\";\n\n/**\n * The publisher REST surface used by the curator-publish flow. Kept minimal —\n * only the endpoints `runPublish` / `runYank` actually call. Response shapes\n * are narrowed to the fields the orchestration reads (the server returns more).\n */\nexport interface PublisherClient {\n /**\n * Identity of the caller. `username` is the Keycloak login (personal-tier\n * namespace); `githubLogin` is the verified GitHub handle when connected —\n * the namespace to publish under when it differs from the login.\n */\n me(): Promise<{ username: string; githubLogin?: string | null }>;\n /** Register (or re-register) a source; returns the created/existing row id. */\n sourcesAdd(body: {\n url: string;\n ref: string;\n sidecarUrl?: string;\n sidecarRef?: string;\n /**\n * Target publisher namespace (the manifest's `publisher`). When it differs\n * from the caller's login username, the store resolves the CLAIMED Publisher\n * for it (the store must already have the claim). Omitted → the store\n * defaults to `@<username>` (personal).\n */\n namespace?: string;\n }): Promise<{ id: string }>;\n /** List sources — used to recover an id when `sourcesAdd` rejects a dup url. */\n sourcesList(): Promise<Array<{ id: string; url: string }>>;\n /** Kick off a source sync; returns the async job id to poll. */\n sourceSync(id: string): Promise<{ jobId: string }>;\n /** Poll a job's terminal status + per-item results. */\n jobGet(\n jobId: string,\n ): Promise<{ status: string; items?: Array<{ label: string; status: string; error?: string }> }>;\n /** Discovered publishable candidates for a synced source. */\n sourceCandidates(id: string): Promise<\n Array<{\n id: string;\n name: string;\n version: string;\n kind: string;\n published: boolean;\n assetRoot: string;\n }>\n >;\n /** Per-asset preview — the discovered file set + resolved candidate metadata. */\n assetPreview(id: string): Promise<{\n discoveredFiles: string[];\n candidate: { name: string; version: string; kind: string; publisherNamespace: string };\n }>;\n /**\n * Publish one asset. `dryRun` returns the would-be `{ manifest }` without\n * launching a job; the normal path returns `{ jobId }`.\n */\n assetPublish(\n id: string,\n body: { ref: string; files: string[] },\n dryRun?: boolean,\n ): Promise<{ jobId?: string; manifest?: unknown }>;\n /** Retract a published asset. Response body is ignored. */\n assetUnpublish(id: string): Promise<unknown>;\n /**\n * Read-only \"can I publish under `@<ns>` right now, and if not, what's the\n * path?\" probe. Backs the `publish --dry-run` namespace status line; its\n * `message` is store-authored and meant to be surfaced verbatim.\n */\n namespaceAvailability(ns: string): Promise<{\n namespace: string;\n status: \"owned-by-you\" | \"claimable-by-you\" | \"reserved\" | \"available\";\n claimMethod?: string;\n message: string;\n }>;\n}\n\n/**\n * Construct the real HTTP-backed {@link PublisherClient}. Every call carries a\n * longer timeout than the default store client because publish/sync trigger\n * server-side clone work.\n *\n * @param config - Store connection config; defaults to {@link getStoreConfig}.\n * @param timeoutMs - Per-request abort timeout (default 20s).\n */\nexport function makeHttpPublisherClient(\n config: StoreConfig = getStoreConfig(),\n timeoutMs = 20_000,\n): PublisherClient {\n // Acquire a fresh Keycloak token per call (device-flow session in\n // ~/.skaile/auth.json, refreshed on demand) rather than a static config.jwt.\n const call = async <T>(\n path: string,\n opts?: { method?: string; body?: unknown; params?: Record<string, string> },\n ): Promise<T> => {\n const jwt = await getStoreToken();\n return storeFetch<T>({ ...config, jwt }, path, { timeoutMs, ...opts });\n };\n return {\n me: () => call(\"/api/v1/me\"),\n sourcesAdd: (body) => call(\"/api/v1/sources\", { method: \"POST\", body }),\n sourcesList: () => call(\"/api/v1/sources\"),\n sourceSync: (id) => call(`/api/v1/sources/${id}/sync`, { method: \"POST\", body: {} }),\n jobGet: (jobId) => call(`/api/v1/jobs/${jobId}`),\n sourceCandidates: (id) => call(`/api/v1/sources/${id}/candidates`),\n assetPreview: (id) => call(`/api/v1/assets/${id}/preview`),\n assetPublish: (id, body, dryRun) =>\n call(`/api/v1/assets/${id}/publish`, {\n method: \"POST\",\n body,\n ...(dryRun ? { params: { dryRun: \"1\" } } : {}),\n }),\n assetUnpublish: (id) => call(`/api/v1/assets/${id}/unpublish`, { method: \"POST\", body: {} }),\n namespaceAvailability: (ns) =>\n call(`/api/v1/namespaces/${encodeURIComponent(ns)}/availability`),\n };\n}\n","/**\n * Shared store-interaction core for the two publish front-ends — the curator\n * sidecar flow (`source manifest publish`) and the first-party library flow\n * (`library publish`). Both differ only in their git side-effects + how they\n * resolve the source repo; the store orchestration below (register → sync →\n * candidates → per-asset preview+publish) is identical.\n *\n * The store REST surface is reached through the injectable {@link PublisherClient}\n * so the orchestration stays unit/integration-testable without a live store.\n *\n * @docLink cli/commands/source#manifest-publish\n */\n\nimport type { SkPublishManifest } from \"@skaile/workspaces/core\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport type { PublisherClient } from \"../store-publisher.ts\";\n\n/**\n * One-line rendering of a namespace-availability probe for a `--dry-run` plan.\n * The `message` is store-authored (identical to what a real publish would echo)\n * — we only prepend a status glyph so the reader sees green/amber/red at a\n * glance without the CLI re-deriving any authorization logic.\n */\nexport function formatNamespaceAvailability(a: {\n status: \"owned-by-you\" | \"claimable-by-you\" | \"reserved\" | \"available\";\n message: string;\n}): string {\n switch (a.status) {\n case \"owned-by-you\":\n case \"available\":\n return `${S.ok(\"✓\")} ${a.message}`;\n case \"claimable-by-you\":\n return `${S.warn(\"!\")} ${a.message}`;\n default:\n return `${S.err(\"✗\")} ${a.message}`;\n }\n}\n\n/**\n * Preflight the target namespace against the store's availability probe BEFORE a\n * publish does any irreversible work (a public git push). Returns `{ ok: false }`\n * with a guided message for `reserved` (not yours) and `claimable-by-you` (must\n * claim first) — the two states a real publish would reject — so the caller can\n * abort with actionable guidance instead of a raw 422 after pushing bytes.\n *\n * The probe is advisory: any failure (offline, older store) returns `{ ok: true }`\n * so the store stays the authority and a valid publish is never blocked.\n */\nexport async function preflightNamespace(\n client: PublisherClient,\n namespace: string,\n): Promise<{ ok: boolean; message?: string }> {\n let a: Awaited<ReturnType<PublisherClient[\"namespaceAvailability\"]>>;\n try {\n a = await client.namespaceAvailability(namespace);\n } catch {\n return { ok: true };\n }\n switch (a.status) {\n case \"owned-by-you\":\n case \"available\":\n return { ok: true };\n case \"claimable-by-you\":\n return {\n ok: false,\n message:\n `@${namespace} isn't yours yet — claim it in the store first` +\n `${a.claimMethod ? ` (${a.claimMethod})` : \"\"}, then re-run. ${a.message}`,\n };\n default: // reserved, or any unrecognized future status (fail safe → block)\n return { ok: false, message: `Cannot publish under @${namespace} — ${a.message}` };\n }\n}\n\n/** One candidate row shape the matcher operates on (kind + name are the key). */\ninterface CandidateLike {\n kind: string;\n name: string;\n}\n\n/**\n * Keep only candidates whose `(kind, name)` pair is declared in the manifest.\n * The backend may merge extra assets from the base repo into the candidate\n * list; a publish only touches what the manifest curated/declared.\n */\nexport function matchCandidatesToManifest<T extends CandidateLike>(\n candidates: T[],\n manifest: SkPublishManifest,\n): T[] {\n const wanted = new Set((manifest.assets ?? []).map((a) => `${a.kind}:${a.name}`));\n return candidates.filter((c) => wanted.has(`${c.kind}:${c.name}`));\n}\n\n/** A canonical ref string `kind:@publisher/name[#version]` for reporting. */\nexport function refFor(kind: string, publisher: string, name: string, version?: string): string {\n const base = `${kind}:@${publisher}/${name}`;\n return version ? `${base}#${version}` : base;\n}\n\n/** The bare asset name from a `kind:@publisher/name#version` ref or a plain name. */\nexport function bareName(ref: string): string {\n const afterKind = ref.includes(\":\") ? ref.slice(ref.indexOf(\":\") + 1) : ref;\n const afterScope = afterKind.includes(\"/\")\n ? afterKind.slice(afterKind.indexOf(\"/\") + 1)\n : afterKind;\n return afterScope.split(\"#\")[0];\n}\n\n/**\n * Poll a job until it leaves `running` or the deadline passes. Returns the last\n * observed state — the caller MUST treat a still-`running` result as a timeout\n * (not success), since it means the deadline was hit before the job finished.\n */\nexport async function pollJob(\n client: PublisherClient,\n jobId: string,\n intervalMs = 1_500,\n timeoutMs = 60_000,\n): Promise<{ status: string; items?: Array<{ label: string; status: string; error?: string }> }> {\n const deadline = Date.now() + timeoutMs;\n let job = await client.jobGet(jobId);\n while (job.status === \"running\" && Date.now() < deadline) {\n await new Promise((r) => setTimeout(r, intervalMs));\n job = await client.jobGet(jobId);\n }\n return job;\n}\n\n/**\n * True when a `sourcesAdd` rejection is a duplicate-URL conflict (the source is\n * already registered) — the only error the publish flow recovers from by looking\n * the existing row up. Every other failure (auth, 5xx, network) must propagate.\n */\nexport function isDupSourceError(err: unknown): boolean {\n const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();\n return /\\b409\\b|conflict|duplicate|already exists|already registered|unique/.test(msg);\n}\n\n/**\n * Register + sync the source, then publish its curated/declared candidates —\n * the store-side steps shared by both publish front-ends. Git side-effects (the\n * sidecar push, or the library commit+push) happen in the caller *before* this;\n * this function is purely store interaction.\n *\n * The sidecar front-end passes `sidecar` (so `sourcesAdd` carries the sidecar\n * pin); the library front-end omits it (the source repo IS the manifest host).\n * `assetName`, when set, narrows publication to the single candidate of that\n * name. Fatal store states (`sourcesAdd` non-dup failure) surface; sync failures\n * and empty candidate sets `process.exit(1)` with the same messages as before.\n */\nexport async function publishToStore(opts: {\n sourceUrl: string;\n ref: string;\n sidecar?: { url: string; ref: string };\n manifest: SkPublishManifest;\n assetName?: string;\n client: PublisherClient;\n}): Promise<{ published: string[] }> {\n const { sourceUrl, ref, sidecar, manifest, assetName, client: pub } = opts;\n\n let sourceId: string;\n try {\n const added = await pub.sourcesAdd({\n url: sourceUrl,\n ref,\n ...(sidecar ? { sidecarUrl: sidecar.url, sidecarRef: sidecar.ref } : {}),\n // Publish under the manifest's declared namespace; the store resolves a\n // claimed Publisher when it differs from the caller's login, else defaults\n // to `@<username>`. Omitted when the manifest carries no publisher.\n ...(manifest.publisher ? { namespace: manifest.publisher } : {}),\n });\n sourceId = added.id;\n } catch (err) {\n // Only a duplicate-url conflict is recoverable (source already registered);\n // auth/5xx/network failures must surface, not silently reuse a stale row.\n if (!isDupSourceError(err)) throw err;\n const rows = await pub.sourcesList();\n const found = rows.find((r) => r.url === sourceUrl);\n if (!found) {\n throw new Error(\n `Source ${sourceUrl} looked already-registered but no owned row matched: ` +\n `${err instanceof Error ? err.message : String(err)}`,\n );\n }\n sourceId = found.id;\n }\n\n const { jobId } = await pub.sourceSync(sourceId);\n const job = await pollJob(pub, jobId);\n if (job.status === \"failed\" || job.status === \"cancelled\") {\n const failed = (job.items ?? []).filter((i) => i.status === \"failed\");\n for (const i of failed) logErr(`sync: ${i.label}: ${i.error ?? \"failed\"}`);\n logErr(`Source sync ${job.status}.`);\n process.exit(1);\n }\n // A still-`running` job means the poll deadline was hit — do NOT proceed on an\n // unfinished sync (it would read incomplete candidates).\n if (job.status === \"running\") {\n logErr(\"Source sync timed out before completing — re-run `publish`, or check the store.\");\n process.exit(1);\n }\n\n let candidates = matchCandidatesToManifest(await pub.sourceCandidates(sourceId), manifest);\n if (assetName) candidates = candidates.filter((c) => c.name === assetName);\n if (candidates.length === 0) {\n logWarn(\"No candidates discovered — check the manifest and the source ref.\");\n process.exit(1);\n }\n\n const published: string[] = [];\n for (const c of candidates) {\n try {\n const preview = await pub.assetPreview(c.id);\n const res = await pub.assetPublish(c.id, { ref, files: preview.discoveredFiles });\n // Publish is async — wait for the job so we only report refs that actually\n // landed, not ones whose import is still in flight or about to fail.\n if (res.jobId) {\n const pubJob = await pollJob(pub, res.jobId);\n if (pubJob.status !== \"succeeded\") {\n const errs = (pubJob.items ?? [])\n .filter((i) => i.status === \"failed\")\n .map((i) => i.error)\n .filter(Boolean);\n logWarn(\n `Publish of ${c.kind}:${c.name} did not succeed (${pubJob.status})` +\n (errs.length ? `: ${errs.join(\"; \")}` : \"\"),\n );\n continue;\n }\n }\n published.push(refFor(c.kind, preview.candidate.publisherNamespace, c.name, c.version));\n } catch (err) {\n logWarn(\n `Failed to publish ${c.kind}:${c.name}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n logOk(`Published ${published.length} asset(s):`);\n for (const r of published) logInfo(` ${r}`);\n return { published };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../cli/src/store-publisher.ts","../cli/src/commands/publish-core.ts"],"names":[],"mappings":";;;;AA+FO,SAAS,uBAAA,CACd,MAAA,GAAsB,cAAA,EAAe,EACrC,YAAY,GAAA,EACK;AAGjB,EAAA,MAAM,IAAA,GAAO,OACX,IAAA,EACA,IAAA,KACe;AACf,IAAA,MAAM,GAAA,GAAM,MAAM,aAAA,EAAc;AAChC,IAAA,OAAO,UAAA,CAAc,EAAE,GAAG,MAAA,EAAQ,GAAA,EAAI,EAAG,IAAA,EAAM,EAAE,SAAA,EAAW,GAAG,IAAA,EAAM,CAAA;AAAA,EACvE,CAAA;AACA,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,MAAM,IAAA,CAAK,YAAY,CAAA;AAAA,IAC3B,UAAA,EAAY,CAAC,IAAA,KAAS,IAAA,CAAK,mBAAmB,EAAE,MAAA,EAAQ,MAAA,EAAQ,IAAA,EAAM,CAAA;AAAA,IACtE,WAAA,EAAa,MAAM,IAAA,CAAK,iBAAiB,CAAA;AAAA,IACzC,UAAA,EAAY,CA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A,CAAE,OAAO,CAAC,CAAA;AAAA,IACxF,SAAS,GAAA,EAAK;AACZ,MAAA,OAAA;AAAA,QACE,CAAA,kBAAA,EAAqB,CAAA,CAAE,IAAI,CAAA,CAAA,EAAI,CAAA,CAAE,IAAI,CAAA,EAAA,EAAK,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,OAC5F;AAAA,IACF;AAAA,EACF;AAEA,EAAA,KAAA,CAAM,CAAA,UAAA,EAAa,SAAA,CAAU,MAAM,CAAA,UAAA,CAAY,CAAA;AAC/C,EAAA,KAAA,MAAW,CAAA,IAAK,SAAA,EAAW,OAAA,CAAQ,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,CAAA;AAC3C,EAAA,OAAO,EAAE,SAAA,EAAU;AACrB","file":"chunk-TUTVTGMG.js","sourcesContent":["/**\n * Typed REST client for the AI Asset Store **publisher** surface — the\n * curator-publish flow (`skaile source manifest publish` / `yank`). Thin\n * wrappers over {@link storeFetch}; every method maps 1:1 to an `/api/v1/…`\n * endpoint. The {@link PublisherClient} interface is injectable so the\n * orchestration in `commands/source-manifest-publish.ts` can be unit-tested\n * against a fake without a live store.\n *\n * @docLink cli/dev-guide#store-publisher\n */\n\nimport { getStoreConfig, getStoreToken, type StoreConfig, storeFetch } from \"./store-client.ts\";\n\n/**\n * The publisher REST surface used by the curator-publish flow. Kept minimal —\n * only the endpoints `runPublish` / `runYank` actually call. Response shapes\n * are narrowed to the fields the orchestration reads (the server returns more).\n */\nexport interface PublisherClient {\n /**\n * Identity of the caller. `username` is the Keycloak login (personal-tier\n * namespace); `githubLogin` is the verified GitHub handle when connected —\n * the namespace to publish under when it differs from the login.\n */\n me(): Promise<{ username: string; githubLogin?: string | null }>;\n /** Register (or re-register) a source; returns the created/existing row id. */\n sourcesAdd(body: {\n url: string;\n ref: string;\n sidecarUrl?: string;\n sidecarRef?: string;\n /**\n * Target publisher namespace (the manifest's `publisher`). When it differs\n * from the caller's login username, the store resolves the CLAIMED Publisher\n * for it (the store must already have the claim). Omitted → the store\n * defaults to `@<username>` (personal).\n */\n namespace?: string;\n }): Promise<{ id: string }>;\n /** List sources — used to recover an id when `sourcesAdd` rejects a dup url. */\n sourcesList(): Promise<Array<{ id: string; url: string }>>;\n /** Kick off a source sync; returns the async job id to poll. */\n sourceSync(id: string): Promise<{ jobId: string }>;\n /** Poll a job's terminal status + per-item results. */\n jobGet(\n jobId: string,\n ): Promise<{ status: string; items?: Array<{ label: string; status: string; error?: string }> }>;\n /** Discovered publishable candidates for a synced source. */\n sourceCandidates(id: string): Promise<\n Array<{\n id: string;\n name: string;\n version: string;\n kind: string;\n published: boolean;\n assetRoot: string;\n }>\n >;\n /** Per-asset preview — the discovered file set + resolved candidate metadata. */\n assetPreview(id: string): Promise<{\n discoveredFiles: string[];\n candidate: { name: string; version: string; kind: string; publisherNamespace: string };\n }>;\n /**\n * Publish one asset. `dryRun` returns the would-be `{ manifest }` without\n * launching a job; the normal path returns `{ jobId }`.\n */\n assetPublish(\n id: string,\n body: { ref: string; files: string[] },\n dryRun?: boolean,\n ): Promise<{ jobId?: string; manifest?: unknown }>;\n /** Retract a published asset. Response body is ignored. */\n assetUnpublish(id: string): Promise<unknown>;\n /**\n * Read-only \"can I publish under `@<ns>` right now, and if not, what's the\n * path?\" probe. Backs the `publish --dry-run` namespace status line; its\n * `message` is store-authored and meant to be surfaced verbatim.\n */\n namespaceAvailability(ns: string): Promise<{\n namespace: string;\n status: \"owned-by-you\" | \"claimable-by-you\" | \"reserved\" | \"available\";\n claimMethod?: string;\n message: string;\n }>;\n}\n\n/**\n * Construct the real HTTP-backed {@link PublisherClient}. Every call carries a\n * longer timeout than the default store client because publish/sync trigger\n * server-side clone work.\n *\n * @param config - Store connection config; defaults to {@link getStoreConfig}.\n * @param timeoutMs - Per-request abort timeout (default 20s).\n */\nexport function makeHttpPublisherClient(\n config: StoreConfig = getStoreConfig(),\n timeoutMs = 20_000,\n): PublisherClient {\n // Acquire a fresh Keycloak token per call (device-flow session in\n // ~/.skaile/auth.json, refreshed on demand) rather than a static config.jwt.\n const call = async <T>(\n path: string,\n opts?: { method?: string; body?: unknown; params?: Record<string, string> },\n ): Promise<T> => {\n const jwt = await getStoreToken();\n return storeFetch<T>({ ...config, jwt }, path, { timeoutMs, ...opts });\n };\n return {\n me: () => call(\"/api/v1/me\"),\n sourcesAdd: (body) => call(\"/api/v1/sources\", { method: \"POST\", body }),\n sourcesList: () => call(\"/api/v1/sources\"),\n sourceSync: (id) => call(`/api/v1/sources/${id}/sync`, { method: \"POST\", body: {} }),\n jobGet: (jobId) => call(`/api/v1/jobs/${jobId}`),\n sourceCandidates: (id) => call(`/api/v1/sources/${id}/candidates`),\n assetPreview: (id) => call(`/api/v1/assets/${id}/preview`),\n assetPublish: (id, body, dryRun) =>\n call(`/api/v1/assets/${id}/publish`, {\n method: \"POST\",\n body,\n ...(dryRun ? { params: { dryRun: \"1\" } } : {}),\n }),\n assetUnpublish: (id) => call(`/api/v1/assets/${id}/unpublish`, { method: \"POST\", body: {} }),\n namespaceAvailability: (ns) =>\n call(`/api/v1/namespaces/${encodeURIComponent(ns)}/availability`),\n };\n}\n","/**\n * Shared store-interaction core for the two publish front-ends — the curator\n * sidecar flow (`source manifest publish`) and the first-party library flow\n * (`library publish`). Both differ only in their git side-effects + how they\n * resolve the source repo; the store orchestration below (register → sync →\n * candidates → per-asset preview+publish) is identical.\n *\n * The store REST surface is reached through the injectable {@link PublisherClient}\n * so the orchestration stays unit/integration-testable without a live store.\n *\n * @docLink cli/commands/source#manifest-publish\n */\n\nimport type { SkPublishManifest } from \"@skaile/workspaces/core\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\nimport type { PublisherClient } from \"../store-publisher.ts\";\n\n/**\n * One-line rendering of a namespace-availability probe for a `--dry-run` plan.\n * The `message` is store-authored (identical to what a real publish would echo)\n * — we only prepend a status glyph so the reader sees green/amber/red at a\n * glance without the CLI re-deriving any authorization logic.\n */\nexport function formatNamespaceAvailability(a: {\n status: \"owned-by-you\" | \"claimable-by-you\" | \"reserved\" | \"available\";\n message: string;\n}): string {\n switch (a.status) {\n case \"owned-by-you\":\n case \"available\":\n return `${S.ok(\"✓\")} ${a.message}`;\n case \"claimable-by-you\":\n return `${S.warn(\"!\")} ${a.message}`;\n default:\n return `${S.err(\"✗\")} ${a.message}`;\n }\n}\n\n/**\n * Preflight the target namespace against the store's availability probe BEFORE a\n * publish does any irreversible work (a public git push). Returns `{ ok: false }`\n * with a guided message for `reserved` (not yours) and `claimable-by-you` (must\n * claim first) — the two states a real publish would reject — so the caller can\n * abort with actionable guidance instead of a raw 422 after pushing bytes.\n *\n * The probe is advisory: any failure (offline, older store) returns `{ ok: true }`\n * so the store stays the authority and a valid publish is never blocked.\n */\nexport async function preflightNamespace(\n client: PublisherClient,\n namespace: string,\n): Promise<{ ok: boolean; message?: string }> {\n let a: Awaited<ReturnType<PublisherClient[\"namespaceAvailability\"]>>;\n try {\n a = await client.namespaceAvailability(namespace);\n } catch {\n return { ok: true };\n }\n switch (a.status) {\n case \"owned-by-you\":\n case \"available\":\n return { ok: true };\n case \"claimable-by-you\":\n return {\n ok: false,\n message:\n `@${namespace} isn't yours yet — claim it in the store first` +\n `${a.claimMethod ? ` (${a.claimMethod})` : \"\"}, then re-run. ${a.message}`,\n };\n default: // reserved, or any unrecognized future status (fail safe → block)\n return { ok: false, message: `Cannot publish under @${namespace} — ${a.message}` };\n }\n}\n\n/** One candidate row shape the matcher operates on (kind + name are the key). */\ninterface CandidateLike {\n kind: string;\n name: string;\n}\n\n/**\n * Keep only candidates whose `(kind, name)` pair is declared in the manifest.\n * The backend may merge extra assets from the base repo into the candidate\n * list; a publish only touches what the manifest curated/declared.\n */\nexport function matchCandidatesToManifest<T extends CandidateLike>(\n candidates: T[],\n manifest: SkPublishManifest,\n): T[] {\n const wanted = new Set((manifest.assets ?? []).map((a) => `${a.kind}:${a.name}`));\n return candidates.filter((c) => wanted.has(`${c.kind}:${c.name}`));\n}\n\n/** A canonical ref string `kind:@publisher/name[#version]` for reporting. */\nexport function refFor(kind: string, publisher: string, name: string, version?: string): string {\n const base = `${kind}:@${publisher}/${name}`;\n return version ? `${base}#${version}` : base;\n}\n\n/** The bare asset name from a `kind:@publisher/name#version` ref or a plain name. */\nexport function bareName(ref: string): string {\n const afterKind = ref.includes(\":\") ? ref.slice(ref.indexOf(\":\") + 1) : ref;\n const afterScope = afterKind.includes(\"/\")\n ? afterKind.slice(afterKind.indexOf(\"/\") + 1)\n : afterKind;\n return afterScope.split(\"#\")[0];\n}\n\n/**\n * Poll a job until it leaves `running` or the deadline passes. Returns the last\n * observed state — the caller MUST treat a still-`running` result as a timeout\n * (not success), since it means the deadline was hit before the job finished.\n */\nexport async function pollJob(\n client: PublisherClient,\n jobId: string,\n intervalMs = 1_500,\n timeoutMs = 60_000,\n): Promise<{ status: string; items?: Array<{ label: string; status: string; error?: string }> }> {\n const deadline = Date.now() + timeoutMs;\n let job = await client.jobGet(jobId);\n while (job.status === \"running\" && Date.now() < deadline) {\n await new Promise((r) => setTimeout(r, intervalMs));\n job = await client.jobGet(jobId);\n }\n return job;\n}\n\n/**\n * True when a `sourcesAdd` rejection is a duplicate-URL conflict (the source is\n * already registered) — the only error the publish flow recovers from by looking\n * the existing row up. Every other failure (auth, 5xx, network) must propagate.\n */\nexport function isDupSourceError(err: unknown): boolean {\n const msg = (err instanceof Error ? err.message : String(err)).toLowerCase();\n return /\\b409\\b|conflict|duplicate|already exists|already registered|unique/.test(msg);\n}\n\n/**\n * Register + sync the source, then publish its curated/declared candidates —\n * the store-side steps shared by both publish front-ends. Git side-effects (the\n * sidecar push, or the library commit+push) happen in the caller *before* this;\n * this function is purely store interaction.\n *\n * The sidecar front-end passes `sidecar` (so `sourcesAdd` carries the sidecar\n * pin); the library front-end omits it (the source repo IS the manifest host).\n * `assetName`, when set, narrows publication to the single candidate of that\n * name. Fatal store states (`sourcesAdd` non-dup failure) surface; sync failures\n * and empty candidate sets `process.exit(1)` with the same messages as before.\n */\nexport async function publishToStore(opts: {\n sourceUrl: string;\n ref: string;\n sidecar?: { url: string; ref: string };\n manifest: SkPublishManifest;\n assetName?: string;\n client: PublisherClient;\n}): Promise<{ published: string[] }> {\n const { sourceUrl, ref, sidecar, manifest, assetName, client: pub } = opts;\n\n let sourceId: string;\n try {\n const added = await pub.sourcesAdd({\n url: sourceUrl,\n ref,\n ...(sidecar ? { sidecarUrl: sidecar.url, sidecarRef: sidecar.ref } : {}),\n // Publish under the manifest's declared namespace; the store resolves a\n // claimed Publisher when it differs from the caller's login, else defaults\n // to `@<username>`. Omitted when the manifest carries no publisher.\n ...(manifest.publisher ? { namespace: manifest.publisher } : {}),\n });\n sourceId = added.id;\n } catch (err) {\n // Only a duplicate-url conflict is recoverable (source already registered);\n // auth/5xx/network failures must surface, not silently reuse a stale row.\n if (!isDupSourceError(err)) throw err;\n const rows = await pub.sourcesList();\n const found = rows.find((r) => r.url === sourceUrl);\n if (!found) {\n throw new Error(\n `Source ${sourceUrl} looked already-registered but no owned row matched: ` +\n `${err instanceof Error ? err.message : String(err)}`,\n );\n }\n sourceId = found.id;\n }\n\n const { jobId } = await pub.sourceSync(sourceId);\n const job = await pollJob(pub, jobId);\n if (job.status === \"failed\" || job.status === \"cancelled\") {\n const failed = (job.items ?? []).filter((i) => i.status === \"failed\");\n for (const i of failed) logErr(`sync: ${i.label}: ${i.error ?? \"failed\"}`);\n logErr(`Source sync ${job.status}.`);\n process.exit(1);\n }\n // A still-`running` job means the poll deadline was hit — do NOT proceed on an\n // unfinished sync (it would read incomplete candidates).\n if (job.status === \"running\") {\n logErr(\"Source sync timed out before completing — re-run `publish`, or check the store.\");\n process.exit(1);\n }\n\n let candidates = matchCandidatesToManifest(await pub.sourceCandidates(sourceId), manifest);\n if (assetName) candidates = candidates.filter((c) => c.name === assetName);\n if (candidates.length === 0) {\n logWarn(\"No candidates discovered — check the manifest and the source ref.\");\n process.exit(1);\n }\n\n const published: string[] = [];\n for (const c of candidates) {\n try {\n const preview = await pub.assetPreview(c.id);\n const res = await pub.assetPublish(c.id, { ref, files: preview.discoveredFiles });\n // Publish is async — wait for the job so we only report refs that actually\n // landed, not ones whose import is still in flight or about to fail.\n if (res.jobId) {\n const pubJob = await pollJob(pub, res.jobId);\n if (pubJob.status !== \"succeeded\") {\n const errs = (pubJob.items ?? [])\n .filter((i) => i.status === \"failed\")\n .map((i) => i.error)\n .filter(Boolean);\n logWarn(\n `Publish of ${c.kind}:${c.name} did not succeed (${pubJob.status})` +\n (errs.length ? `: ${errs.join(\"; \")}` : \"\"),\n );\n continue;\n }\n }\n published.push(refFor(c.kind, preview.candidate.publisherNamespace, c.name, c.version));\n } catch (err) {\n logWarn(\n `Failed to publish ${c.kind}:${c.name}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n logOk(`Published ${published.length} asset(s):`);\n for (const r of published) logInfo(` ${r}`);\n return { published };\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { AssetKindRegistryFrozenError, AssetKindConflictError, AssetKindPatternC
|
|
|
2
2
|
import { decodeSkaileManifest, SKAILE_MANIFEST_FILENAME } from './chunk-P4VHQA4N.js';
|
|
3
3
|
import { parseFrontmatter } from './chunk-2FBPAR2V.js';
|
|
4
4
|
import { isValidAssetName } from './chunk-GEEW6SY2.js';
|
|
5
|
-
import { validatePersona, validateRuleset, validateSkill, validateAgent, validateConnector, validateMcpServer, validateContract, validatePrompt, validatePreset } from './chunk-
|
|
5
|
+
import { validatePersona, validateRuleset, validateSkill, validateAgent, validateConnector, validateMcpServer, validateContract, validatePrompt, validatePreset } from './chunk-TGE33MKN.js';
|
|
6
6
|
import * as fs from 'fs';
|
|
7
7
|
import * as path from 'path';
|
|
8
8
|
import * as yaml from 'js-yaml';
|
|
@@ -2437,5 +2437,5 @@ function validateRequiresSyntax2(requires) {
|
|
|
2437
2437
|
var VERSION = "0.0.0";
|
|
2438
2438
|
|
|
2439
2439
|
export { AGENT_COMPANION_DIRS, AssetKindRegistry, BUILTIN_PROVIDERS, DEFAULT_ATOMIZATION_POLICY, DOMAIN_MD_FILENAME, SEMVER_RE, SKILL_COMPANION_DIRS, SourceConfigSchema, VERSION, agentProvider, assignDomain, barePublisher, buildDomainIndex, buildRequiresGraph, closeOverReferences, computeDeterministicHash, computeDeterministicHashDetailed, connectorProvider, contractProvider, createDefaultRegistry, createNodeAssetFs, decodeManifestSourceConfig, detectCycles, discoverAssetsInTree, discoverAssetsInTreeEntries, discoverFromManifest, extractPathCandidates, extractRequires, extractSlashCommands, isDomainMdPath, isExcludedDevPath, isManifestMode, lintUncoveredReferences, loadMergedSourceConfig, loadMergedSourceConfigFromFile, loadSourceConfig, manifestToSourceConfig, mcpServerProvider, mergeSourceConfigs, parseDomainMd, parseSourceConfig, personaProvider, presetProvider, promptProvider, readManifestSourceConfig, rulesetProvider, scanAssetReferences, scanSlashCommandNames, skillProvider, validateDomains, validateSourceConfig };
|
|
2440
|
-
//# sourceMappingURL=chunk-
|
|
2441
|
-
//# sourceMappingURL=chunk-
|
|
2440
|
+
//# sourceMappingURL=chunk-VOXFI3XS.js.map
|
|
2441
|
+
//# sourceMappingURL=chunk-VOXFI3XS.js.map
|