@skaile/workspaces 4.9.3 → 4.9.4
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 +12 -0
- package/dist/{asset-feeds-74HE5Q7W.js → asset-feeds-WHWQJOAQ.js} +4 -4
- package/dist/{asset-feeds-74HE5Q7W.js.map → asset-feeds-WHWQJOAQ.js.map} +1 -1
- package/dist/asset-manager/index.js +1 -1
- package/dist/{chunk-6L2WH2LS.js → chunk-3BDWW7OE.js} +6 -6
- package/dist/{chunk-6L2WH2LS.js.map → chunk-3BDWW7OE.js.map} +1 -1
- package/dist/{chunk-LN4M7WMX.js → chunk-5HZWDH3L.js} +5 -5
- package/dist/{chunk-LN4M7WMX.js.map → chunk-5HZWDH3L.js.map} +1 -1
- package/dist/{chunk-XZYZOCPK.js → chunk-7F4FGEMI.js} +3 -3
- package/dist/{chunk-XZYZOCPK.js.map → chunk-7F4FGEMI.js.map} +1 -1
- package/dist/{chunk-JU736VOI.js → chunk-HRVXHRL4.js} +222 -36
- package/dist/chunk-HRVXHRL4.js.map +1 -0
- package/dist/{chunk-2KVFAWUA.js → chunk-OIXSGSKM.js} +3 -3
- package/dist/{chunk-2KVFAWUA.js.map → chunk-OIXSGSKM.js.map} +1 -1
- package/dist/{chunk-WXECUQC6.js → chunk-PROIKXJR.js} +3 -3
- package/dist/{chunk-WXECUQC6.js.map → chunk-PROIKXJR.js.map} +1 -1
- package/dist/{chunk-VLRP35H4.js → chunk-R5NALZHK.js} +6 -6
- package/dist/{chunk-VLRP35H4.js.map → chunk-R5NALZHK.js.map} +1 -1
- package/dist/{chunk-O33RRDO5.js → chunk-SPAG2BWG.js} +2 -2
- package/dist/{chunk-O33RRDO5.js.map → chunk-SPAG2BWG.js.map} +1 -1
- package/dist/{chunk-7ZWLVXQN.js → chunk-TXXPJ5CQ.js} +2 -2
- package/dist/{chunk-7ZWLVXQN.js.map → chunk-TXXPJ5CQ.js.map} +1 -1
- package/dist/{chunk-RL7O3OZQ.js → chunk-US3NCUQF.js} +3 -3
- package/dist/{chunk-RL7O3OZQ.js.map → chunk-US3NCUQF.js.map} +1 -1
- package/dist/{chunk-LMS54WVA.js → chunk-YMHRKIMQ.js} +3 -3
- package/dist/{chunk-LMS54WVA.js.map → chunk-YMHRKIMQ.js.map} +1 -1
- package/dist/cli/index.js +28 -28
- package/dist/connectors/index.js +1 -1
- package/dist/{ensure-sources-VTIIEJBO.js → ensure-sources-QOQSDYIW.js} +4 -4
- package/dist/{ensure-sources-VTIIEJBO.js.map → ensure-sources-QOQSDYIW.js.map} +1 -1
- package/dist/factory-assets/connectors/box.js +1 -1
- package/dist/factory-assets/connectors/deploy.js +1 -1
- package/dist/factory-assets/connectors/devserver.js +1 -1
- package/dist/factory-assets/connectors/flow/adapter.js +1 -1
- package/dist/factory-assets/connectors/flow/run-flow.js +2 -2
- package/dist/factory-assets/connectors/flow.js +1 -1
- package/dist/factory-assets/connectors/git/CONNECTOR.md +7 -1
- package/dist/factory-assets/connectors/git/driver.d.ts +60 -10
- package/dist/factory-assets/connectors/git/driver.d.ts.map +1 -1
- package/dist/factory-assets/connectors/git.js +1 -1
- package/dist/factory-assets/connectors/gmail.js +1 -1
- package/dist/factory-assets/connectors/googledrive.js +1 -1
- package/dist/factory-assets/connectors/local.js +1 -1
- package/dist/factory-assets/connectors/mattermost.js +1 -1
- package/dist/factory-assets/connectors/memory.js +1 -1
- package/dist/factory-assets/connectors/minio.js +1 -1
- package/dist/factory-assets/connectors/postgres.js +1 -1
- package/dist/factory-assets/connectors/s3.js +1 -1
- package/dist/factory-assets/connectors/sharepoint.js +1 -1
- package/dist/factory-assets/connectors/sqlite.js +1 -1
- package/dist/factory-assets/connectors/static-server.js +1 -1
- package/dist/factory-assets/connectors/tunnel.js +1 -1
- package/dist/factory-assets/connectors/webdav.js +1 -1
- package/dist/factory-assets/connectors/xstate-store.js +1 -1
- package/dist/factory-assets/connectors/xstate.js +1 -1
- package/dist/{helpers-JJ4OLUVW.js → helpers-HGDWKXLE.js} +4 -4
- package/dist/{helpers-JJ4OLUVW.js.map → helpers-HGDWKXLE.js.map} +1 -1
- package/dist/{library-publish-IA76SB6X.js → library-publish-6QYWX635.js} +6 -6
- package/dist/{library-publish-IA76SB6X.js.map → library-publish-6QYWX635.js.map} +1 -1
- package/dist/{open-library-F24FIE65.js → open-library-R74XCRPC.js} +5 -5
- package/dist/{open-library-F24FIE65.js.map → open-library-R74XCRPC.js.map} +1 -1
- package/dist/{project-OGJSXBAC.js → project-OFUZ5D3S.js} +5 -5
- package/dist/{project-OGJSXBAC.js.map → project-OFUZ5D3S.js.map} +1 -1
- package/dist/runner/index.js +4 -4
- package/dist/sdk/asset-manager.js +1 -1
- package/dist/sdk/index.js +4 -4
- package/dist/sdk/runner.js +4 -4
- package/dist/{setup-3IIIW3QM.js → setup-OYXGVHBF.js} +5 -5
- package/dist/{setup-3IIIW3QM.js.map → setup-OYXGVHBF.js.map} +1 -1
- package/dist/{source-HBEZDIWE.js → source-MEQTWW3S.js} +6 -6
- package/dist/{source-HBEZDIWE.js.map → source-MEQTWW3S.js.map} +1 -1
- package/dist/{source-manifest-publish-G7ZAYFMH.js → source-manifest-publish-EPPOGSLD.js} +7 -7
- package/dist/{source-manifest-publish-G7ZAYFMH.js.map → source-manifest-publish-EPPOGSLD.js.map} +1 -1
- package/dist/tui/index.js +4 -4
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-JU736VOI.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logErr } from './chunk-
|
|
1
|
+
import { logErr } from './chunk-OIXSGSKM.js';
|
|
2
2
|
import { flowKindProvider } from './chunk-AOE4KOMJ.js';
|
|
3
3
|
import { knowledgeKindProvider } from './chunk-7LHSC2DS.js';
|
|
4
4
|
import { createDefaultRegistry } from './chunk-M5H4DWIA.js';
|
|
@@ -103,5 +103,5 @@ async function openLibraryManager() {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export { LocalCatalogDisabledError, createFullRegistry, openCatalogSource, openLibrary, openLibraryManager, resolveCatalogSource };
|
|
106
|
-
//# sourceMappingURL=chunk-
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
106
|
+
//# sourceMappingURL=chunk-7F4FGEMI.js.map
|
|
107
|
+
//# sourceMappingURL=chunk-7F4FGEMI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../cli/src/open-registry.ts","../cli/src/open-library.ts"],"names":["source"],"mappings":";;;;;;AA2BO,SAAS,kBAAA,GAAwC;AACtD,EAAA,MAAM,WAAW,qBAAA,EAAsB;AACvC,EAAA,QAAA,CAAS,SAAS,gBAAgB,CAAA;AAClC,EAAA,QAAA,CAAS,SAAS,qBAAqB,CAAA;AACvC,EAAA,OAAO,QAAA;AACT;;;ACfO,IAAM,yBAAA,GAAN,cAAwC,KAAA,CAAM;AAAA,EACnD,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AAAA,EACd;AACF;AASA,eAAsB,WAAA,GAAc;AAClC,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,UAAA,EAAW,GAAI,MAAM,OAAO,oBAA4B,CAAA;AAChE,IAAA,OAAO,IAAI,UAAA,CAAW,EAAE,YAAA,EAAc,kBAAA,IAAsB,CAAA;AAAA,EAC9D,SAAS,GAAA,EAAK;AACZ,IAAA,MAAA,CAAO,CAAA,2BAAA,EAA8B,eAAe,KAAA,GAAQ,GAAA,CAAI,UAAU,MAAA,CAAO,GAAG,CAAC,CAAA,CAAE,CAAA;AACvF,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF;AAqBA,eAAsB,kBAAkB,IAAA,EAQtC;AACA,EAAA,MAAM,EAAE,eAAe,mBAAA,EAAqB,iBAAA,EAAmB,mBAAkB,GAAI,MAAM,OACzF,oBACF,CAAA;AAC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AM,SACJ,GAAA,CAAI,OAAA,CAAQ,OAAA,KAAY,MAAA,GACpB,IAAI,iBAAA,CAAkB,EAAE,OAAA,EAAS,UAAA,EAAY,CAAA,GAC7C,IAAI,oBAAoB,EAAE,OAAA,EAAS,YAAY,CAAA;AACrD,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,MAAM;AAAA,EAAC,CAAA,EAAE;AACnC;AASA,eAAsB,kBAAA,GAInB;AACD,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,oBAA4B,CAAA;AACpE,EAAA,MAAM,OAAA,GAAU,MAAM,WAAA,EAAY;AAClC,EAAA,MAAM,OAAA,GAAU,IAAI,cAAA,CAAe,OAAO,CAAA;AAC1C,EAAA,OAAO,EAAE,OAAA,EAAS,OAAA,EAAS,OAAO,MAAM,OAAA,CAAQ,OAAM,EAAE;AAC1D","file":"chunk-XZYZOCPK.js","sourcesContent":["/**\n * open-registry.ts — shared helper to create a full AssetKindRegistry.\n *\n * Bootstraps the registry with all built-in providers (9 core + preset)\n * from @skaile/discovery, plus the extension kind providers (flow from\n * @skaile/workspaces/factory-assets/connectors/flow/engine, knowledge from @skaile/library).\n *\n * This is the single registration point for the CLI. All code paths\n * that need a registry (source sync, lib-status, etc.) should use this.\n */\n\nimport type { AssetKindRegistry } from \"@skaile/workspaces/discovery\";\nimport { createDefaultRegistry } from \"@skaile/workspaces/discovery\";\nimport { flowKindProvider } from \"@skaile/workspaces/factory-assets/connectors/flow/engine\";\nimport { knowledgeKindProvider } from \"@skaile/workspaces/library\";\n\n/**\n * Create a fully-configured AssetKindRegistry with all known providers.\n *\n * Registers:\n * - 9 core kinds (skill, agent, connector, mount, mcp-server, contract, prompt, persona, ruleset)\n * - preset (composition entity)\n * - flow (extension, from @skaile/workspaces/factory-assets/connectors/flow/engine)\n * - knowledge (extension, from @skaile/library)\n *\n * @returns An unfrozen registry (auto-freezes on first read)\n */\nexport function createFullRegistry(): AssetKindRegistry {\n const registry = createDefaultRegistry();\n registry.register(flowKindProvider);\n registry.register(knowledgeKindProvider);\n return registry;\n}\n","/**\n * open-library.ts — shared helpers to open the LocalIndex and the configured\n * Catalog source.\n *\n * Lazy-loads the `@skaile/workspaces/library` subpath and returns the\n * LocalIndex instance (backed by `@libsql/client`; runs on Node and Bun).\n * The catalog-source helper reads\n * `~/.skaile/config.yaml` (and project-level overlay if `projectDir` is given)\n * to decide between {@link RemoteCatalogSource} (default — points at\n * `https://skaile.store`) and a {@link LocalCatalogSource} bound to the most\n * recent local library registered via `skaile source add`.\n */\n\nimport { logErr } from \"./helpers.ts\";\nimport { createFullRegistry } from \"./open-registry.ts\";\n\n/** Thrown by {@link openCatalogSource} when `catalog.url` is the `local` sentinel. */\nexport class LocalCatalogDisabledError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"LocalCatalogDisabledError\";\n }\n}\n\n/**\n * Open the LocalIndex with the full kind registry. Exits with code 1\n * if the library directory cannot be created.\n *\n * @returns A `LocalIndex` instance ready for use.\n * @docLink cli/dev-guide#open-library\n */\nexport async function openLibrary() {\n try {\n const { LocalIndex } = await import(\"@skaile/workspaces/library\");\n return new LocalIndex({ kindRegistry: createFullRegistry() });\n } catch (err) {\n logErr(`Could not open LocalIndex: ${err instanceof Error ? err.message : String(err)}`);\n process.exit(1);\n }\n}\n\n/**\n * Resolve the configured **remote** Catalog source for the CLI.\n *\n * Reads `~/.skaile/config.yaml` (plus the optional project-level overlay) and\n * returns a {@link RemoteCatalogSource} pointing at `catalog.url` (default:\n * `https://skaile.store`). The `cache_ttl: 0` config flag flips the source\n * into air-gapped mode: network reads are disabled, only `skaile update`\n * performs refreshes.\n *\n * **Local-mode rejection.** If the resolved config has `catalog.url: local`\n * this helper throws — callers wanting the dispatched local-or-remote source\n * must use {@link resolveCatalogSource}. Remote-only consumers like\n * `skaile update --catalog-only` rely on this strict behaviour.\n *\n * @param opts - Project directory (overlays project config) and explicit overrides.\n * @returns A configured {@link RemoteCatalogSource}.\n * @throws When `catalog.url` is the `local` sentinel.\n * @docLink cli/dev-guide#open-library\n */\nexport async function openCatalogSource(opts?: {\n projectDir?: string;\n baseUrlOverride?: string;\n /** Override the user-config path for tests. */\n userConfigFile?: string;\n}): Promise<\n | import(\"@skaile/workspaces/library\").RemoteCatalogSource\n | import(\"@skaile/workspaces/library\").RestCatalogSource\n> {\n const { resolveConfig, RemoteCatalogSource, RestCatalogSource, isLocalCatalogUrl } = await import(\n \"@skaile/workspaces/library\"\n );\n const cfg = resolveConfig({\n projectDir: opts?.projectDir,\n userConfigFile: opts?.userConfigFile,\n });\n const baseUrl = opts?.baseUrlOverride ?? cfg.catalog.url;\n if (isLocalCatalogUrl(baseUrl)) {\n throw new LocalCatalogDisabledError(\n \"catalog.url is set to 'local' — remote catalog is disabled. \" +\n \"Use `skaile source add <path>` + `skaile source sync` for local sources, \" +\n \"or set `catalog.url: https://skaile.store` in ~/.skaile/config.yaml.\",\n );\n }\n const cacheTtlMs = cfg.catalog.cache_ttl * 1000;\n if (cfg.catalog.framing === \"rest\") {\n return new RestCatalogSource({ baseUrl, cacheTtlMs });\n }\n return new RemoteCatalogSource({ baseUrl, cacheTtlMs });\n}\n\n/**\n * Resolved catalog source plus a close handle for releasing any underlying\n * resources (e.g. the `LocalIndex` SQLite connection in local mode).\n *\n * Callers MUST invoke `close()` when done — typically in a `finally` block.\n * For remote-mode sources `close()` is a no-op, but the contract is uniform\n * so consumers don't have to branch.\n *\n * @docLink cli/dev-guide#open-library\n */\nexport interface ResolvedCatalogSource {\n /** The {@link ICatalogSource} ready for use. */\n source: import(\"@skaile/workspaces/library\").ICatalogSource;\n /** Release any underlying resources (SQLite handle in local mode). */\n close(): void;\n}\n\n/**\n * Resolve the configured Catalog source — local or remote — based on\n * `~/.skaile/config.yaml`.\n *\n * Dispatch:\n * - `catalog.url: local` → opens {@link LocalIndex}, picks the most recently\n * registered local library whose `path` still exists on disk, and returns a\n * {@link LocalCatalogSource} bound to that library. Throws if no usable\n * local library is registered.\n * - any URL → returns {@link RemoteCatalogSource} (same as\n * {@link openCatalogSource}).\n *\n * The returned `close()` releases the underlying `LocalIndex` SQLite handle\n * in local mode (no-op in remote mode). Callers MUST invoke it — typically in\n * a `finally` block — to satisfy `library/CLAUDE.md` § \"Notes for Consumers\".\n *\n * @param opts - Project directory (overlays project config) and explicit overrides.\n * @returns A `ResolvedCatalogSource` carrying the source and a close handle.\n * @throws When `local` is configured but no usable local library is registered.\n * @docLink cli/dev-guide#open-library\n */\nexport async function resolveCatalogSource(opts?: {\n projectDir?: string;\n baseUrlOverride?: string;\n /** Override the user-config path for tests. */\n userConfigFile?: string;\n}): Promise<ResolvedCatalogSource> {\n const {\n resolveConfig,\n RemoteCatalogSource,\n RestCatalogSource,\n LocalCatalogSource,\n isLocalCatalogUrl,\n } = await import(\"@skaile/workspaces/library\");\n const cfg = resolveConfig({\n projectDir: opts?.projectDir,\n userConfigFile: opts?.userConfigFile,\n });\n const baseUrl = opts?.baseUrlOverride ?? cfg.catalog.url;\n\n if (isLocalCatalogUrl(baseUrl)) {\n const fs = await import(\"node:fs\");\n const library = await openLibrary();\n try {\n const sources = await library.listSources();\n type LibraryRow = (typeof sources)[number];\n // Type-narrow: `path` is required for local libraries after the filter.\n const usable = sources\n .filter(\n (s): s is LibraryRow & { path: string } =>\n s.backend === \"local\" && typeof s.path === \"string\" && s.path.length > 0,\n )\n .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());\n\n if (usable.length === 0) {\n throw new Error(\n \"catalog.url is set to 'local' but no local library is registered. \" +\n \"Run `skaile source add <path>` first, then `skaile source sync`.\",\n );\n }\n\n // Prefer the most recently added library whose path still exists.\n const present = usable.find((s) => fs.existsSync(s.path));\n if (!present) {\n const head = usable[0];\n throw new Error(\n `catalog.url is set to 'local' but every registered local library has a missing path on disk. ` +\n `Most recent: ${head.path} (library ${head.id}). ` +\n `Re-register with \\`skaile source add <existing-path>\\` or run \\`skaile source list\\` to inspect.`,\n );\n }\n\n const source = new LocalCatalogSource(\n library,\n present.id,\n present.path,\n createFullRegistry(),\n );\n return { source, close: () => library.close() };\n } catch (err) {\n // Release the handle on any failure during dispatch — otherwise the\n // SQLite WAL state leaks for the lifetime of the process.\n library.close();\n throw err;\n }\n }\n\n const cacheTtlMs = cfg.catalog.cache_ttl * 1000;\n const source =\n cfg.catalog.framing === \"rest\"\n ? new RestCatalogSource({ baseUrl, cacheTtlMs })\n : new RemoteCatalogSource({ baseUrl, cacheTtlMs });\n return { source, close: () => {} };\n}\n\n/**\n * Open the LibraryManager bound to the active LocalIndex.\n * Caller owns lifetime — must call `close()` (returned helper closes the\n * underlying LocalIndex).\n *\n * @docLink cli/dev-guide#open-library\n */\nexport async function openLibraryManager(): Promise<{\n manager: import(\"@skaile/workspaces/library\").LibraryManager;\n library: import(\"@skaile/workspaces/library\").LocalIndex;\n close: () => void;\n}> {\n const { LibraryManager } = await import(\"@skaile/workspaces/library\");\n const library = await openLibrary();\n const manager = new LibraryManager(library);\n return { manager, library, close: () => library.close() };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../cli/src/open-registry.ts","../cli/src/open-library.ts"],"names":["source"],"mappings":";;;;;;AA2BO,SAAS,kBAAA,GAAwC;AACtD,EAAA,MAAM,WAAW,qBAAA,EAAsB;AACvC,EAAA,QAAA,CAAS,SAAS,gBAAgB,CAAA;AAClC,EAAA,QAAA,CAAS,SAAS,qBAAqB,CAAA;AACvC,EAAA,OAAO,QAAA;AACT;;;ACfO,IAAM,yBAAA,GAAN,cAAwC,KAAA,CAAM;AAAA,EACnD,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AAAA,EACd;AACF;AASA,eAAsB,WAAA,GAAc;AAClC,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,UAAA,EAAW,GAAI,MAAM,OAAO,oBAA4B,CAAA;AAChE,IAAA,OAAO,IAAI,UAAA,CAAW,EAAE,YAAA,EAAc,k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AAA,CAAQ,EAAA;AAAA,QACR,OAAA,CAAQ,IAAA;AAAA,QACR,kBAAA;AAAmB,OACrB;AACA,MAAA,OAAO,EAAE,MAAA,EAAAA,OAAAA,EAAQ,OAAO,MAAM,OAAA,CAAQ,OAAM,EAAE;AAAA,IAChD,SAAS,GAAA,EAAK;AAGZ,MAAA,OAAA,CAAQ,KAAA,EAAM;AACd,MAAA,MAAM,GAAA;AAAA,IACR;AAAA,EACF;AAEA,EAAA,MAAM,UAAA,GAAa,GAAA,CAAI,OAAA,CAAQ,SAAA,GAAY,GAAA;AAC3C,EAAA,MAAM,SACJ,GAAA,CAAI,OAAA,CAAQ,OAAA,KAAY,MAAA,GACpB,IAAI,iBAAA,CAAkB,EAAE,OAAA,EAAS,UAAA,EAAY,CAAA,GAC7C,IAAI,oBAAoB,EAAE,OAAA,EAAS,YAAY,CAAA;AACrD,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,MAAM;AAAA,EAAC,CAAA,EAAE;AACnC;AASA,eAAsB,kBAAA,GAInB;AACD,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,MAAM,OAAO,oBAA4B,CAAA;AACpE,EAAA,MAAM,OAAA,GAAU,MAAM,WAAA,EAAY;AAClC,EAAA,MAAM,OAAA,GAAU,IAAI,cAAA,CAAe,OAAO,CAAA;AAC1C,EAAA,OAAO,EAAE,OAAA,EAAS,OAAA,EAAS,OAAO,MAAM,OAAA,CAAQ,OAAM,EAAE;AAC1D","file":"chunk-7F4FGEMI.js","sourcesContent":["/**\n * open-registry.ts — shared helper to create a full AssetKindRegistry.\n *\n * Bootstraps the registry with all built-in providers (9 core + preset)\n * from @skaile/discovery, plus the extension kind providers (flow from\n * @skaile/workspaces/factory-assets/connectors/flow/engine, knowledge from @skaile/library).\n *\n * This is the single registration point for the CLI. All code paths\n * that need a registry (source sync, lib-status, etc.) should use this.\n */\n\nimport type { AssetKindRegistry } from \"@skaile/workspaces/discovery\";\nimport { createDefaultRegistry } from \"@skaile/workspaces/discovery\";\nimport { flowKindProvider } from \"@skaile/workspaces/factory-assets/connectors/flow/engine\";\nimport { knowledgeKindProvider } from \"@skaile/workspaces/library\";\n\n/**\n * Create a fully-configured AssetKindRegistry with all known providers.\n *\n * Registers:\n * - 9 core kinds (skill, agent, connector, mount, mcp-server, contract, prompt, persona, ruleset)\n * - preset (composition entity)\n * - flow (extension, from @skaile/workspaces/factory-assets/connectors/flow/engine)\n * - knowledge (extension, from @skaile/library)\n *\n * @returns An unfrozen registry (auto-freezes on first read)\n */\nexport function createFullRegistry(): AssetKindRegistry {\n const registry = createDefaultRegistry();\n registry.register(flowKindProvider);\n registry.register(knowledgeKindProvider);\n return registry;\n}\n","/**\n * open-library.ts — shared helpers to open the LocalIndex and the configured\n * Catalog source.\n *\n * Lazy-loads the `@skaile/workspaces/library` subpath and returns the\n * LocalIndex instance (backed by `@libsql/client`; runs on Node and Bun).\n * The catalog-source helper reads\n * `~/.skaile/config.yaml` (and project-level overlay if `projectDir` is given)\n * to decide between {@link RemoteCatalogSource} (default — points at\n * `https://skaile.store`) and a {@link LocalCatalogSource} bound to the most\n * recent local library registered via `skaile source add`.\n */\n\nimport { logErr } from \"./helpers.ts\";\nimport { createFullRegistry } from \"./open-registry.ts\";\n\n/** Thrown by {@link openCatalogSource} when `catalog.url` is the `local` sentinel. */\nexport class LocalCatalogDisabledError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"LocalCatalogDisabledError\";\n }\n}\n\n/**\n * Open the LocalIndex with the full kind registry. Exits with code 1\n * if the library directory cannot be created.\n *\n * @returns A `LocalIndex` instance ready for use.\n * @docLink cli/dev-guide#open-library\n */\nexport async function openLibrary() {\n try {\n const { LocalIndex } = await import(\"@skaile/workspaces/library\");\n return new LocalIndex({ kindRegistry: createFullRegistry() });\n } catch (err) {\n logErr(`Could not open LocalIndex: ${err instanceof Error ? err.message : String(err)}`);\n process.exit(1);\n }\n}\n\n/**\n * Resolve the configured **remote** Catalog source for the CLI.\n *\n * Reads `~/.skaile/config.yaml` (plus the optional project-level overlay) and\n * returns a {@link RemoteCatalogSource} pointing at `catalog.url` (default:\n * `https://skaile.store`). The `cache_ttl: 0` config flag flips the source\n * into air-gapped mode: network reads are disabled, only `skaile update`\n * performs refreshes.\n *\n * **Local-mode rejection.** If the resolved config has `catalog.url: local`\n * this helper throws — callers wanting the dispatched local-or-remote source\n * must use {@link resolveCatalogSource}. Remote-only consumers like\n * `skaile update --catalog-only` rely on this strict behaviour.\n *\n * @param opts - Project directory (overlays project config) and explicit overrides.\n * @returns A configured {@link RemoteCatalogSource}.\n * @throws When `catalog.url` is the `local` sentinel.\n * @docLink cli/dev-guide#open-library\n */\nexport async function openCatalogSource(opts?: {\n projectDir?: string;\n baseUrlOverride?: string;\n /** Override the user-config path for tests. */\n userConfigFile?: string;\n}): Promise<\n | import(\"@skaile/workspaces/library\").RemoteCatalogSource\n | import(\"@skaile/workspaces/library\").RestCatalogSource\n> {\n const { resolveConfig, RemoteCatalogSource, RestCatalogSource, isLocalCatalogUrl } = await import(\n \"@skaile/workspaces/library\"\n );\n const cfg = resolveConfig({\n projectDir: opts?.projectDir,\n userConfigFile: opts?.userConfigFile,\n });\n const baseUrl = opts?.baseUrlOverride ?? cfg.catalog.url;\n if (isLocalCatalogUrl(baseUrl)) {\n throw new LocalCatalogDisabledError(\n \"catalog.url is set to 'local' — remote catalog is disabled. \" +\n \"Use `skaile source add <path>` + `skaile source sync` for local sources, \" +\n \"or set `catalog.url: https://skaile.store` in ~/.skaile/config.yaml.\",\n );\n }\n const cacheTtlMs = cfg.catalog.cache_ttl * 1000;\n if (cfg.catalog.framing === \"rest\") {\n return new RestCatalogSource({ baseUrl, cacheTtlMs });\n }\n return new RemoteCatalogSource({ baseUrl, cacheTtlMs });\n}\n\n/**\n * Resolved catalog source plus a close handle for releasing any underlying\n * resources (e.g. the `LocalIndex` SQLite connection in local mode).\n *\n * Callers MUST invoke `close()` when done — typically in a `finally` block.\n * For remote-mode sources `close()` is a no-op, but the contract is uniform\n * so consumers don't have to branch.\n *\n * @docLink cli/dev-guide#open-library\n */\nexport interface ResolvedCatalogSource {\n /** The {@link ICatalogSource} ready for use. */\n source: import(\"@skaile/workspaces/library\").ICatalogSource;\n /** Release any underlying resources (SQLite handle in local mode). */\n close(): void;\n}\n\n/**\n * Resolve the configured Catalog source — local or remote — based on\n * `~/.skaile/config.yaml`.\n *\n * Dispatch:\n * - `catalog.url: local` → opens {@link LocalIndex}, picks the most recently\n * registered local library whose `path` still exists on disk, and returns a\n * {@link LocalCatalogSource} bound to that library. Throws if no usable\n * local library is registered.\n * - any URL → returns {@link RemoteCatalogSource} (same as\n * {@link openCatalogSource}).\n *\n * The returned `close()` releases the underlying `LocalIndex` SQLite handle\n * in local mode (no-op in remote mode). Callers MUST invoke it — typically in\n * a `finally` block — to satisfy `library/CLAUDE.md` § \"Notes for Consumers\".\n *\n * @param opts - Project directory (overlays project config) and explicit overrides.\n * @returns A `ResolvedCatalogSource` carrying the source and a close handle.\n * @throws When `local` is configured but no usable local library is registered.\n * @docLink cli/dev-guide#open-library\n */\nexport async function resolveCatalogSource(opts?: {\n projectDir?: string;\n baseUrlOverride?: string;\n /** Override the user-config path for tests. */\n userConfigFile?: string;\n}): Promise<ResolvedCatalogSource> {\n const {\n resolveConfig,\n RemoteCatalogSource,\n RestCatalogSource,\n LocalCatalogSource,\n isLocalCatalogUrl,\n } = await import(\"@skaile/workspaces/library\");\n const cfg = resolveConfig({\n projectDir: opts?.projectDir,\n userConfigFile: opts?.userConfigFile,\n });\n const baseUrl = opts?.baseUrlOverride ?? cfg.catalog.url;\n\n if (isLocalCatalogUrl(baseUrl)) {\n const fs = await import(\"node:fs\");\n const library = await openLibrary();\n try {\n const sources = await library.listSources();\n type LibraryRow = (typeof sources)[number];\n // Type-narrow: `path` is required for local libraries after the filter.\n const usable = sources\n .filter(\n (s): s is LibraryRow & { path: string } =>\n s.backend === \"local\" && typeof s.path === \"string\" && s.path.length > 0,\n )\n .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());\n\n if (usable.length === 0) {\n throw new Error(\n \"catalog.url is set to 'local' but no local library is registered. \" +\n \"Run `skaile source add <path>` first, then `skaile source sync`.\",\n );\n }\n\n // Prefer the most recently added library whose path still exists.\n const present = usable.find((s) => fs.existsSync(s.path));\n if (!present) {\n const head = usable[0];\n throw new Error(\n `catalog.url is set to 'local' but every registered local library has a missing path on disk. ` +\n `Most recent: ${head.path} (library ${head.id}). ` +\n `Re-register with \\`skaile source add <existing-path>\\` or run \\`skaile source list\\` to inspect.`,\n );\n }\n\n const source = new LocalCatalogSource(\n library,\n present.id,\n present.path,\n createFullRegistry(),\n );\n return { source, close: () => library.close() };\n } catch (err) {\n // Release the handle on any failure during dispatch — otherwise the\n // SQLite WAL state leaks for the lifetime of the process.\n library.close();\n throw err;\n }\n }\n\n const cacheTtlMs = cfg.catalog.cache_ttl * 1000;\n const source =\n cfg.catalog.framing === \"rest\"\n ? new RestCatalogSource({ baseUrl, cacheTtlMs })\n : new RemoteCatalogSource({ baseUrl, cacheTtlMs });\n return { source, close: () => {} };\n}\n\n/**\n * Open the LibraryManager bound to the active LocalIndex.\n * Caller owns lifetime — must call `close()` (returned helper closes the\n * underlying LocalIndex).\n *\n * @docLink cli/dev-guide#open-library\n */\nexport async function openLibraryManager(): Promise<{\n manager: import(\"@skaile/workspaces/library\").LibraryManager;\n library: import(\"@skaile/workspaces/library\").LocalIndex;\n close: () => void;\n}> {\n const { LibraryManager } = await import(\"@skaile/workspaces/library\");\n const library = await openLibrary();\n const manager = new LibraryManager(library);\n return { manager, library, close: () => library.close() };\n}\n"]}
|
|
@@ -1749,6 +1749,32 @@ async function ensureTrackingRefspec(branch, cwd) {
|
|
|
1749
1749
|
}
|
|
1750
1750
|
await git(["config", "--add", "remote.origin.fetch", wanted], cwd);
|
|
1751
1751
|
}
|
|
1752
|
+
async function dropTrackingRefspec(branch, cwd) {
|
|
1753
|
+
const name = branch.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1754
|
+
await gitOrNull(
|
|
1755
|
+
[
|
|
1756
|
+
"config",
|
|
1757
|
+
"--unset-all",
|
|
1758
|
+
"remote.origin.fetch",
|
|
1759
|
+
`^\\+?refs/heads/${name}:refs/remotes/origin/${name}$`
|
|
1760
|
+
],
|
|
1761
|
+
cwd
|
|
1762
|
+
);
|
|
1763
|
+
}
|
|
1764
|
+
async function isAncestor(ancestor, descendant, cwd) {
|
|
1765
|
+
return await gitOrNull(["merge-base", "--is-ancestor", ancestor, descendant], cwd) !== null;
|
|
1766
|
+
}
|
|
1767
|
+
async function originTrackingRef(branch, cwd) {
|
|
1768
|
+
const ref = `refs/remotes/origin/${branch}`;
|
|
1769
|
+
return await gitOrNull(["rev-parse", "--verify", "--quiet", ref], cwd) === null ? null : ref;
|
|
1770
|
+
}
|
|
1771
|
+
async function setSessionUpstream(branch, cwd) {
|
|
1772
|
+
await git(["config", `branch.${branch}.remote`, "origin"], cwd);
|
|
1773
|
+
await git(["config", `branch.${branch}.merge`, `refs/heads/${branch}`], cwd);
|
|
1774
|
+
}
|
|
1775
|
+
function cLocaleEnv() {
|
|
1776
|
+
return { ...process.env, LC_ALL: "C", LANGUAGE: "" };
|
|
1777
|
+
}
|
|
1752
1778
|
async function readGitSyncStatus(cwd, baseBranch) {
|
|
1753
1779
|
const branchRaw = await gitOrNull(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
|
|
1754
1780
|
const branch = branchRaw && branchRaw !== "HEAD" ? branchRaw : null;
|
|
@@ -1878,6 +1904,9 @@ var GitConnector = class extends AbstractConnector {
|
|
|
1878
1904
|
const authUrl = this.authUrl(state);
|
|
1879
1905
|
await this.prepareCheckout(targetDir, url, branch, authUrl, declaration.access, started);
|
|
1880
1906
|
if (session.enabled && !session.isMain && session.slug) {
|
|
1907
|
+
if (declaration.mount?.exposeAccessToken !== true) {
|
|
1908
|
+
await this.rebakeRemoteAuth(targetDir, state);
|
|
1909
|
+
}
|
|
1881
1910
|
await this.checkoutSessionBranch(state, session, targetDir);
|
|
1882
1911
|
}
|
|
1883
1912
|
if (sync.fetchIntervalSec > 0) {
|
|
@@ -1917,8 +1946,13 @@ var GitConnector = class extends AbstractConnector {
|
|
|
1917
1946
|
}
|
|
1918
1947
|
if (state.sessionBranchFetch === "failed") {
|
|
1919
1948
|
state.sessionBranchFetch = await this.trackSessionBranch(state.activeBranch, targetDir);
|
|
1920
|
-
if (state.sessionBranchFetch === "fetched"
|
|
1921
|
-
|
|
1949
|
+
if (state.sessionBranchFetch === "fetched") {
|
|
1950
|
+
if (state.sessionBranchCreated) {
|
|
1951
|
+
await this.adoptOriginSessionBranch(state.activeBranch, targetDir);
|
|
1952
|
+
} else {
|
|
1953
|
+
await this.reconcileLocalSessionBranch(state, state.activeBranch, targetDir);
|
|
1954
|
+
await syncSubmodules(targetDir, this.log);
|
|
1955
|
+
}
|
|
1922
1956
|
}
|
|
1923
1957
|
}
|
|
1924
1958
|
await ensureSkaileExcluded(targetDir, this.log);
|
|
@@ -2040,6 +2074,9 @@ var GitConnector = class extends AbstractConnector {
|
|
|
2040
2074
|
if (await localBranchExists(sessionBranch, targetDir)) {
|
|
2041
2075
|
await gitLocalCheckout([sessionBranch], targetDir);
|
|
2042
2076
|
this.log.info("reusing existing local session branch", { sessionBranch });
|
|
2077
|
+
if (state.sessionBranchFetch === "fetched") {
|
|
2078
|
+
await this.reconcileLocalSessionBranch(state, sessionBranch, targetDir);
|
|
2079
|
+
}
|
|
2043
2080
|
} else {
|
|
2044
2081
|
let originHasBranch = false;
|
|
2045
2082
|
try {
|
|
@@ -2063,6 +2100,7 @@ var GitConnector = class extends AbstractConnector {
|
|
|
2063
2100
|
if (created && state.lifecycle.publishOnCreate) {
|
|
2064
2101
|
try {
|
|
2065
2102
|
await git(["push", "-u", "origin", sessionBranch], targetDir, 6e4);
|
|
2103
|
+
await this.recordPushedSessionBranch(sessionBranch, targetDir);
|
|
2066
2104
|
this.log.info("published new session branch", { sessionBranch });
|
|
2067
2105
|
} catch (err) {
|
|
2068
2106
|
this.log.warn("publish-on-create push failed; deferring to lifecycle push", {
|
|
@@ -2073,36 +2111,47 @@ var GitConnector = class extends AbstractConnector {
|
|
|
2073
2111
|
}
|
|
2074
2112
|
}
|
|
2075
2113
|
/**
|
|
2076
|
-
*
|
|
2077
|
-
*
|
|
2078
|
-
* normal case for a new session, and any other failure
|
|
2079
|
-
*
|
|
2114
|
+
* Fetch the session branch into `refs/remotes/origin/<sessionBranch>` and,
|
|
2115
|
+
* when origin has it, map it with a fetch refspec. Never throws: a missing
|
|
2116
|
+
* remote branch is the normal case for a new session, and any other failure
|
|
2117
|
+
* leaves the checkout as it was (the caller creates the branch from the base).
|
|
2080
2118
|
*
|
|
2081
|
-
*
|
|
2082
|
-
*
|
|
2119
|
+
* The refspec is added only once origin has the branch, and removed when
|
|
2120
|
+
* origin does not have it: a configured refspec for a missing branch makes
|
|
2121
|
+
* every plain `git fetch origin` fail. Runs on every connect, so it also
|
|
2122
|
+
* repairs a checkout cloned before the refspec existed.
|
|
2083
2123
|
*/
|
|
2084
2124
|
async trackSessionBranch(sessionBranch, targetDir) {
|
|
2085
|
-
|
|
2086
|
-
await ensureTrackingRefspec(sessionBranch, targetDir);
|
|
2087
|
-
} catch (err) {
|
|
2088
|
-
this.log.warn("could not add session-branch fetch refspec", {
|
|
2089
|
-
sessionBranch,
|
|
2090
|
-
error: redactUrlAuth(err instanceof Error ? err.message : String(err))
|
|
2091
|
-
});
|
|
2092
|
-
}
|
|
2125
|
+
let outcome;
|
|
2093
2126
|
try {
|
|
2094
2127
|
await runGit([...gitPrefix(targetDir), "fetch", "origin", trackingRefspec(sessionBranch)], {
|
|
2095
2128
|
cwd: targetDir,
|
|
2096
2129
|
timeout: 6e4,
|
|
2097
|
-
env:
|
|
2130
|
+
env: cLocaleEnv()
|
|
2098
2131
|
});
|
|
2099
|
-
|
|
2132
|
+
outcome = "fetched";
|
|
2100
2133
|
} catch (err) {
|
|
2101
2134
|
const message = redactUrlAuth(err instanceof Error ? err.message : String(err));
|
|
2102
|
-
if (
|
|
2103
|
-
|
|
2104
|
-
|
|
2135
|
+
if (!/couldn't find remote ref/i.test(message)) {
|
|
2136
|
+
this.log.warn("session-branch fetch failed", { sessionBranch, error: message });
|
|
2137
|
+
return "failed";
|
|
2138
|
+
}
|
|
2139
|
+
outcome = "absent";
|
|
2140
|
+
}
|
|
2141
|
+
try {
|
|
2142
|
+
if (outcome === "fetched") {
|
|
2143
|
+
await ensureTrackingRefspec(sessionBranch, targetDir);
|
|
2144
|
+
} else {
|
|
2145
|
+
await dropTrackingRefspec(sessionBranch, targetDir);
|
|
2146
|
+
await gitOrNull(["update-ref", "-d", `refs/remotes/origin/${sessionBranch}`], targetDir);
|
|
2147
|
+
}
|
|
2148
|
+
} catch (err) {
|
|
2149
|
+
this.log.warn("could not update session-branch fetch refspec", {
|
|
2150
|
+
sessionBranch,
|
|
2151
|
+
error: redactUrlAuth(err instanceof Error ? err.message : String(err))
|
|
2152
|
+
});
|
|
2105
2153
|
}
|
|
2154
|
+
return outcome;
|
|
2106
2155
|
}
|
|
2107
2156
|
/**
|
|
2108
2157
|
* Re-point a session branch that this connect cut from the base at
|
|
@@ -2124,25 +2173,101 @@ var GitConnector = class extends AbstractConnector {
|
|
|
2124
2173
|
}
|
|
2125
2174
|
}
|
|
2126
2175
|
/**
|
|
2127
|
-
*
|
|
2128
|
-
*
|
|
2129
|
-
*
|
|
2130
|
-
*
|
|
2176
|
+
* Line up a reused local session branch (checked out) with
|
|
2177
|
+
* `origin/<sessionBranch>` after a successful fetch. Never rewrites local
|
|
2178
|
+
* history and never throws:
|
|
2179
|
+
* - local is an ancestor of origin → fast-forward (another node pushed
|
|
2180
|
+
* newer work);
|
|
2181
|
+
* - local has commits that origin does not have → keep them and log a
|
|
2182
|
+
* warning; when origin also has commits that local lacks (diverged),
|
|
2183
|
+
* merge origin in with {@link integrateOriginSessionBranch};
|
|
2184
|
+
* - origin has no such branch → nothing to do.
|
|
2185
|
+
* In the first two cases the upstream is set to `origin/<sessionBranch>`.
|
|
2131
2186
|
*/
|
|
2132
|
-
async
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2187
|
+
async reconcileLocalSessionBranch(state, sessionBranch, targetDir) {
|
|
2188
|
+
const originRef = await originTrackingRef(sessionBranch, targetDir);
|
|
2189
|
+
if (originRef === null) return;
|
|
2190
|
+
try {
|
|
2191
|
+
await setSessionUpstream(sessionBranch, targetDir);
|
|
2192
|
+
if (await isAncestor("HEAD", originRef, targetDir)) {
|
|
2193
|
+
const before = await git(["rev-parse", "HEAD"], targetDir);
|
|
2194
|
+
await git(["merge", "--ff-only", originRef], targetDir, 6e4);
|
|
2195
|
+
if (await git(["rev-parse", "HEAD"], targetDir) !== before) {
|
|
2196
|
+
this.log.info("session branch fast-forwarded to origin", { sessionBranch });
|
|
2197
|
+
}
|
|
2198
|
+
return;
|
|
2199
|
+
}
|
|
2200
|
+
const { ahead, behind } = await countAheadBehind(targetDir, originRef);
|
|
2201
|
+
this.log.warn("local session branch has commits not on origin; kept", {
|
|
2202
|
+
sessionBranch,
|
|
2203
|
+
ahead,
|
|
2204
|
+
behind
|
|
2205
|
+
});
|
|
2206
|
+
if (behind > 0) await this.integrateOriginSessionBranch(state, targetDir, sessionBranch);
|
|
2207
|
+
} catch (err) {
|
|
2208
|
+
this.log.warn("could not line up the local session branch with origin", {
|
|
2209
|
+
sessionBranch,
|
|
2210
|
+
error: redactUrlAuth(err instanceof Error ? err.message : String(err))
|
|
2211
|
+
});
|
|
2136
2212
|
}
|
|
2213
|
+
}
|
|
2214
|
+
/**
|
|
2215
|
+
* Merge `origin/<branch>` into the checked-out session branch when origin
|
|
2216
|
+
* holds commits that the local branch lacks (another node or the agent
|
|
2217
|
+
* pushed, or an older driver rewrote the local branch). A merge, never a
|
|
2218
|
+
* rebase: the commits on origin are published. After this, a push of the
|
|
2219
|
+
* branch is a fast-forward and needs no force. Never throws; a merge that
|
|
2220
|
+
* cannot complete is aborted, and the push that follows fails as before.
|
|
2221
|
+
*/
|
|
2222
|
+
async integrateOriginSessionBranch(s, cwd, branch = s.activeBranch) {
|
|
2223
|
+
const originRef = await originTrackingRef(branch, cwd);
|
|
2224
|
+
if (originRef === null || await isAncestor(originRef, "HEAD", cwd)) return;
|
|
2137
2225
|
try {
|
|
2138
|
-
await
|
|
2226
|
+
await gitCommitting(["merge", "--no-edit", originRef], cwd, 6e4);
|
|
2227
|
+
this.log.info("merged origin session branch", { branch });
|
|
2139
2228
|
} catch (err) {
|
|
2140
|
-
this.log.warn("
|
|
2141
|
-
branch
|
|
2229
|
+
this.log.warn("merge of origin session branch failed", {
|
|
2230
|
+
branch,
|
|
2142
2231
|
error: redactUrlAuth(err instanceof Error ? err.message : String(err))
|
|
2143
2232
|
});
|
|
2233
|
+
await this.resolveConflictsOrAbort(s, cwd, "merge");
|
|
2144
2234
|
}
|
|
2235
|
+
}
|
|
2236
|
+
/**
|
|
2237
|
+
* After a successful push of a session branch: map it with a fetch refspec
|
|
2238
|
+
* and point `refs/remotes/origin/<branch>` at the pushed tip. The push ran
|
|
2239
|
+
* before the refspec existed (a refspec for a branch that origin does not
|
|
2240
|
+
* have yet would break `git fetch origin`), so git did not update the
|
|
2241
|
+
* tracking ref itself. With both, `@{upstream}` resolves and the platform's
|
|
2242
|
+
* hibernate save gate sees `ahead` 0. Never throws.
|
|
2243
|
+
*/
|
|
2244
|
+
async recordPushedSessionBranch(branch, cwd) {
|
|
2245
|
+
try {
|
|
2246
|
+
await ensureTrackingRefspec(branch, cwd);
|
|
2247
|
+
await git(["update-ref", `refs/remotes/origin/${branch}`, `refs/heads/${branch}`], cwd);
|
|
2248
|
+
} catch (err) {
|
|
2249
|
+
this.log.warn("could not record the pushed session branch", {
|
|
2250
|
+
branch,
|
|
2251
|
+
error: redactUrlAuth(err instanceof Error ? err.message : String(err))
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
/**
|
|
2256
|
+
* Push the active branch. A session branch first gets any commits that are
|
|
2257
|
+
* only on `origin/<branch>` merged in, so the push is a fast-forward and
|
|
2258
|
+
* never needs a force. It is pushed with `-u` and then recorded (see
|
|
2259
|
+
* {@link recordPushedSessionBranch}), so `@{upstream}` resolves — the
|
|
2260
|
+
* platform's hibernate save gate reads exactly that. The base branch keeps
|
|
2261
|
+
* its plain push.
|
|
2262
|
+
*/
|
|
2263
|
+
async pushActiveBranch(s, cwd) {
|
|
2264
|
+
if (s.activeBranch === s.branch) {
|
|
2265
|
+
await git(["push", "origin", s.activeBranch], cwd, 6e4);
|
|
2266
|
+
return;
|
|
2267
|
+
}
|
|
2268
|
+
await this.integrateOriginSessionBranch(s, cwd);
|
|
2145
2269
|
await git(["push", "-u", "origin", s.activeBranch], cwd, 6e4);
|
|
2270
|
+
await this.recordPushedSessionBranch(s.activeBranch, cwd);
|
|
2146
2271
|
}
|
|
2147
2272
|
/**
|
|
2148
2273
|
* Attempt to create `sessionBranch` anchored on `session.fromRef`. Returns
|
|
@@ -3056,7 +3181,7 @@ var GitConnector = class extends AbstractConnector {
|
|
|
3056
3181
|
s.fetchInFlight = true;
|
|
3057
3182
|
void this.runPeriodicFetch(s, mountPath).catch((err) => {
|
|
3058
3183
|
this.log.debug("periodic fetch failed", {
|
|
3059
|
-
error: err instanceof Error ? err.message : String(err)
|
|
3184
|
+
error: redactUrlAuth(err instanceof Error ? err.message : String(err))
|
|
3060
3185
|
});
|
|
3061
3186
|
}).finally(() => {
|
|
3062
3187
|
s.fetchInFlight = false;
|
|
@@ -3065,9 +3190,17 @@ var GitConnector = class extends AbstractConnector {
|
|
|
3065
3190
|
}
|
|
3066
3191
|
/** One periodic-fetch tick. Bails out at each resumption point once disconnected. */
|
|
3067
3192
|
async runPeriodicFetch(s, mountPath) {
|
|
3068
|
-
await
|
|
3193
|
+
await this.fetchOrigin(s, mountPath);
|
|
3069
3194
|
if (s.disposed) return;
|
|
3070
3195
|
if (s.sync.autoRebase && s.activeBranch !== s.branch) {
|
|
3196
|
+
const onOrigin = await this.trackSessionBranch(s.activeBranch, mountPath);
|
|
3197
|
+
if (s.disposed) return;
|
|
3198
|
+
if (onOrigin !== "absent") {
|
|
3199
|
+
await this.mergeBaseIntoSessionBranch(s, mountPath);
|
|
3200
|
+
if (s.disposed) return;
|
|
3201
|
+
await syncSubmodules(mountPath, this.log);
|
|
3202
|
+
return;
|
|
3203
|
+
}
|
|
3071
3204
|
try {
|
|
3072
3205
|
await gitCommitting(["rebase", `origin/${s.branch}`], mountPath, 6e4);
|
|
3073
3206
|
} catch (err) {
|
|
@@ -3085,6 +3218,59 @@ var GitConnector = class extends AbstractConnector {
|
|
|
3085
3218
|
await syncSubmodules(mountPath, this.log);
|
|
3086
3219
|
}
|
|
3087
3220
|
}
|
|
3221
|
+
/**
|
|
3222
|
+
* `git fetch origin` for the periodic tick. When origin no longer has a
|
|
3223
|
+
* branch that a session refspec names (for example a session branch deleted
|
|
3224
|
+
* after a merge, or one from an earlier session on this checkout), that
|
|
3225
|
+
* refspec fails the whole fetch. Drop it and fetch again. The base branch
|
|
3226
|
+
* refspec is never dropped.
|
|
3227
|
+
*/
|
|
3228
|
+
async fetchOrigin(s, mountPath) {
|
|
3229
|
+
for (let attempt = 0; ; attempt++) {
|
|
3230
|
+
try {
|
|
3231
|
+
await runGit([...gitPrefix(mountPath), "fetch", "origin"], {
|
|
3232
|
+
cwd: mountPath,
|
|
3233
|
+
timeout: 6e4,
|
|
3234
|
+
env: cLocaleEnv()
|
|
3235
|
+
});
|
|
3236
|
+
return;
|
|
3237
|
+
} catch (err) {
|
|
3238
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3239
|
+
const missing = /couldn't find remote ref refs\/heads\/(\S+)/.exec(message)?.[1];
|
|
3240
|
+
if (missing === void 0 || missing === s.branch || !isValidGitRefOrSha(missing)) {
|
|
3241
|
+
throw err;
|
|
3242
|
+
}
|
|
3243
|
+
if (attempt >= 3) throw err;
|
|
3244
|
+
this.log.info("branch not on origin; dropping its fetch refspec", { branch: missing });
|
|
3245
|
+
await dropTrackingRefspec(missing, mountPath);
|
|
3246
|
+
await gitOrNull(["update-ref", "-d", `refs/remotes/origin/${missing}`], mountPath);
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
/**
|
|
3251
|
+
* Merge `origin/<base>` into a published session branch (periodic tick with
|
|
3252
|
+
* `autoRebase`). No-op when the base is already contained. Conflicts are
|
|
3253
|
+
* handled like the merge on close: keep "ours" (the session branch) and
|
|
3254
|
+
* save "theirs" as `.conflict` files.
|
|
3255
|
+
*/
|
|
3256
|
+
async mergeBaseIntoSessionBranch(s, mountPath) {
|
|
3257
|
+
const baseRef = `origin/${s.branch}`;
|
|
3258
|
+
if (await isAncestor(baseRef, "HEAD", mountPath)) return;
|
|
3259
|
+
try {
|
|
3260
|
+
await gitCommitting(["merge", "--no-edit", baseRef], mountPath, 6e4);
|
|
3261
|
+
this.log.info("merged base into published session branch", {
|
|
3262
|
+
branch: s.activeBranch,
|
|
3263
|
+
base: s.branch
|
|
3264
|
+
});
|
|
3265
|
+
} catch (err) {
|
|
3266
|
+
this.log.warn("merge of base into session branch failed", {
|
|
3267
|
+
branch: s.activeBranch,
|
|
3268
|
+
base: s.branch,
|
|
3269
|
+
error: redactUrlAuth(err instanceof Error ? err.message : String(err))
|
|
3270
|
+
});
|
|
3271
|
+
await this.resolveConflictsOrAbort(s, mountPath, "merge");
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3088
3274
|
// ── Conflict resolution ──────────────────────────────────────────────────
|
|
3089
3275
|
/**
|
|
3090
3276
|
* Attempt to resolve merge/rebase conflicts by keeping "ours" and copying
|
|
@@ -11245,5 +11431,5 @@ function describeFlowOperations() {
|
|
|
11245
11431
|
}
|
|
11246
11432
|
|
|
11247
11433
|
export { AbstractConnector, BUILTIN_CONNECTOR_CATALOG, BoxConnector, ClassifierSubpromptRunner, ConnectorManager, DeployConnector, DevServerConnector, FlowAdapter, GitConnector, GmailConnector, GoogleDriveConnector, LocalConnector, LogBuffer, MAX_REARM_MS, MIN_REFRESH_DELAY_MS, ManagedGitconfigCollisionError, MattermostConnector, MemoryConnector, MinIOConnector, NO_ACTIVE_FLOW_ERROR, PortPool, PostgresConnector, REFRESH_LEAD_MS, S3Connector, SQLiteConnector, SessionInlineSubFlowRunner, SessionNodeExecutor, SessionSubpromptRunner, SharePointConnector, StaticServerConnector, TunnelConnector, WebDAVConnector, XStateConnector, XStateStoreConnector, __test, atomicReplaceCredential, buildConnectorPromptSection, buildConnectorToolDefs, buildFlowPromptEvent, buildFlowToolDefs, buildLazyFlowToolDefs, buildLazySdkFlowTools, buildSdkConnectorTools, buildSdkFlowTools, classifierQuestion, classifyConnectError, createConnector, createConnector10, createConnector11, createConnector12, createConnector13, createConnector14, createConnector15, createConnector16, createConnector17, createConnector18, createConnector19, createConnector2, createConnector20, createConnector3, createConnector4, createConnector5, createConnector6, createConnector7, createConnector8, createConnector9, createFsWatcher, createWorktree, defaultSpawn, describeFlowOperations, driveOrchestratorTurn, ensureDirMode, ensureFleetMounted, ensureRefreshAttemptStamp, findGitRoot, findMissingPackages, getConnector, installNpmPackages, isFleetManaged, isPackageResolvable, listConnectors, listWorktrees, readGitSyncStatus, registerBuiltinConnectors, removeMountBlock, removeUnavailableMountBlock, renderCredentialHelperScript, tryGetConnector, worktreeRegistry, writeHelperScript, writeMountBlock, writeUnavailableMountBlock };
|
|
11248
|
-
//# sourceMappingURL=chunk-
|
|
11249
|
-
//# sourceMappingURL=chunk-
|
|
11434
|
+
//# sourceMappingURL=chunk-HRVXHRL4.js.map
|
|
11435
|
+
//# sourceMappingURL=chunk-HRVXHRL4.js.map
|