@xopcai/xopc 0.0.282 → 0.0.284
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-iPtG94qr.js → activity-store-CwbIMGLY.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Cny5rATT.js → agent-avatar-dicebear-DjiOld-S.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-OyQ8OVZv.js → agent-defaults-settings-panel-D9qP10BK.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-DJeh_Ewo.js → agents-D-bkOuAl.js} +1 -1
- package/dist/gateway/static/root/assets/{api-KMJzMqvZ.js → api-3lphBVuY.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-ZqQKaZEI.js → app-management-settings-panel-B2nwCXxE.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CfXsQkKO.js → appearance-settings-BXO4Ej88.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-k-QnVhKW.js → apps-page-BKwBBwJN.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-BrW53Hap.js → archive-plugin-6ZRqNjla.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DkfFWHiS.js → attachment-load-CmPZalcW.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-preview-renderer-CfEDFYPE.js → attachment-preview-renderer-wzIchDSv.js} +4 -4
- package/dist/gateway/static/root/assets/attachment-process-heavy-Db4nTY5N.js +5 -0
- package/dist/gateway/static/root/assets/{automations-page-e-5we6kD.js → automations-page-Bc3WbK5n.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-DPnlkws1.js → automations-workspace-B2-f9qZu.js} +1 -1
- package/dist/gateway/static/root/assets/binary-plugins-OWR6cxpc.js +2 -0
- package/dist/gateway/static/root/assets/{block-editor-CfeF1OmA.js → block-editor-Ca-tDQXm.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BTIufVbM.js → browser-automation-inputs-Dxy2_p3U.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-DnsuWKRu.js → browser-automations-page-CibQIxpi.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-C8xyhnxx.js → browser-settings-page-Dtn4rMeq.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-CBllOLTT.js → capabilities-settings-panel-DiwtR9MD.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-C-A-VUE2.js → channels-settings-pTdR1q1K.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-status-swr-DMYQNs-J.js → channels-status-swr-Bh-G9mdZ.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-C_Fw1R3A.js → chat-terminal-dock-lbzbSpV3.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-CtsMo3H4.js → connectors-page-BSQ7Hs2w.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-CPFxjTrN.js → date-picker-tYvbTfZT.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-C_5KqzjI.js → dependency-picker-B8yo7-7V.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DLJsC5D6.js → desktop-pet-BUGkGB4-.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BdI1iSgz.js → desktop-pet-settings-DNeVGZNp.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-BnvPLhc9.js → device-pairing-wizard-CYkT7ecp.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-BNS_TkZQ.js → extension-debug-page-CiK0QI2p.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DMSDZ7Mb.js → extension-page-CirPNHJd.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CeGCWMt0.js → extension-settings-page-Baua1_Le.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-Cpmyrr6j.js → gateway-config-swr-Co4hHe0i.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DKOTYUma.js → gateway-settings-CzpSYWex.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DoiPeb65.js → gateway-startup-retry-DBPNJG-e.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-gsdL_Yij.js → heartbeat-settings-DTM_kYpE.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-CbeAdS1T.js → home-page-CSSJvdd6.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-CqjHWl2T.js → image-generation-api-D0rMTumD.js} +1 -1
- package/dist/gateway/static/root/assets/imports-page-XqVVYbAp.js +1 -0
- package/dist/gateway/static/root/assets/{index-enFXJJCU.js → index-C9aQA4Dr.js} +10 -10
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CCLtJ8s8.js → keyboard-shortcuts-settings-CMUaF61L.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DzC6SrXj.js → local-app-workbench-page-CZSgTYuI.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-3LdgP3NO.js → local-apps-page-CHxyT09t.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-1urrBBCQ.js → locale-store-DO6JJ1l2.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DHClKtm6.js → logs-page-z5ktnEzX.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-BaCo9Nuo.js → management-settings-jXbA2S54.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-BZmcFIWa.js → markdown-view-CKInRsDh.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BMjJppvG.js → media-plugins-BaPkSvW7.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BgZRsCkG.js +3 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-hYO2jNhL.js → note-detail-panel-DSaZfkna.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-BT66x22W.js → notes-page-CePEyv_C.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-BCszXX_F.js → page-tabs-CdYemUOu.js} +1 -1
- package/dist/gateway/static/root/assets/pdf-runtime-DU_sMPjG.js +2 -0
- package/dist/gateway/static/root/assets/pdf.worker.min-B4E34YdZ.js +48 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CyM0sanh.js → preview-open-alternatives-DzgF1yYO.js} +1 -1
- package/dist/gateway/static/root/assets/{proactive-page-CVDGA5sB.js → proactive-page-Cy2Gm2f8.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-lXAbj85Z.js → product-open-page-iQ-eW6Aj.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-Bp6TAMPM.js → project-detail-page-BliwYpns.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-UhOIiDcg.js → projects-page-Dm-BqnQn.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-CxQstD00.js → registry-api-DMNudT60.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-DJIkMFT4.js → remote-access-hub-C_XuQ9XR.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BUFCgRdZ.js → runtime-tools-settings-panel-u_wVepf7.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-B01ksA8M.js → schema-form-YdZj2xdI.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-CQOAwPDt.js → sessions-page-Drt1aS2G.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BAUd06_9.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-DvnjZBa3.js → settings-form-section-Bw6xKOX5.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DZRkpbCh.js → settings-page-CV8kVdnE.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-DVaEiAVY.js → setup-status-panel-BHI9e5Tw.js} +1 -1
- package/dist/gateway/static/root/assets/share-preview-page-BHwjHlrV.js +2 -0
- package/dist/gateway/static/root/assets/{shares-settings-XiCqMDAe.js → shares-settings-DOAOjZBQ.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DU0VQpHj.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DRKdb6O5.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-BryVNYll.js → skills-page.utils-DYfaLtts.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-mKFDe6aZ.js → system-settings-panel-CWrWpKV-.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-Cb0RZNcJ.js → task-detail-page-DiPgMmBM.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-Dc5s20V3.js → theme-store-CDc7Wqy5.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-FcI3wKy3.js → tunnel-api-Bmsy-5Fs.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-CDgdtjTC.js → use-autosave-D-FRib85.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-Cnshc-Un.js → user-model-page-DxRaRdA0.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-Ce8cb5mN.js → voice-api-key-field-iQ7EBzII.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-Mk78BrpP.js → voice-config-api-DNMWA2tx.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CacFTtXe.js → work-discovery-overlay-BesuhDlH.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-V-5HuEUq.js → workflow-run-setup-panel-Du81FoCy.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-1OJimIfo.js → workflows-page-CZikdgNw.js} +1 -1
- package/dist/gateway/static/root/index.html +9 -9
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +4 -4
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/oauth/xopc-cloud.js +1 -1
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/cli/command-loaders.js +1 -0
- package/dist/src/cli/command-manifest.js +4 -0
- package/dist/src/cli/commands/agent.js +2 -2
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +3 -3
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/import.d.ts +2 -0
- package/dist/src/cli/commands/import.js +30 -0
- package/dist/src/cli/commands/models.js +2 -2
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/commands/platform.js +1 -1
- package/dist/src/cli/commands/profile.js +1 -1
- package/dist/src/cli/commands/tunnel.js +1 -1
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/cli/extension-cli-register.js +1 -1
- package/dist/src/config/index.js +5 -5
- package/dist/src/config/loader.js +2 -2
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/routes/imports.d.ts +3 -0
- package/dist/src/gateway/hono/routes/imports.js +44 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +2 -2
- package/dist/src/gateway/run-loop.js +1 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service.js +9 -7
- package/dist/src/imports/compatibility.d.ts +7 -0
- package/dist/src/imports/compatibility.js +174 -0
- package/dist/src/imports/contextImport.d.ts +3 -0
- package/dist/src/imports/contextImport.js +56 -0
- package/dist/src/imports/files.d.ts +13 -0
- package/dist/src/imports/files.js +77 -0
- package/dist/src/imports/importService.d.ts +45 -0
- package/dist/src/imports/importService.js +417 -0
- package/dist/src/imports/planner.d.ts +11 -0
- package/dist/src/imports/planner.js +98 -0
- package/dist/src/imports/productImport.d.ts +10 -0
- package/dist/src/imports/productImport.js +148 -0
- package/dist/src/imports/runtime.d.ts +5 -0
- package/dist/src/imports/runtime.js +56 -0
- package/dist/src/imports/scanner.d.ts +14 -0
- package/dist/src/imports/scanner.js +159 -0
- package/dist/src/imports/secrets.d.ts +2 -0
- package/dist/src/imports/secrets.js +9 -0
- package/dist/src/imports/sources.d.ts +37 -0
- package/dist/src/imports/sources.js +75 -0
- package/dist/src/imports/types.d.ts +91 -0
- package/dist/src/imports/types.js +11 -0
- package/dist/src/knowledge-memory/repository.js +4 -2
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/storage/sqlite/import-repository.d.ts +19 -0
- package/dist/src/storage/sqlite/import-repository.js +35 -0
- package/dist/src/storage/sqlite/migrations/174_capability_imports.sql +11 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tasks/home-query-service.js +2 -2
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/work-discovery/service.js +2 -2
- package/dist/src/workflows/service/workflow-run-service.js +2 -2
- package/package.json +4 -3
- package/dist/gateway/static/root/assets/attachment-process-heavy-C5CqLCsX.js +0 -5
- package/dist/gateway/static/root/assets/binary-plugins-CWIswfXA.js +0 -2
- package/dist/gateway/static/root/assets/excel-worksheet-utils-DpdB-DjU.js +0 -1
- package/dist/gateway/static/root/assets/messages-DYFcjtmG.js +0 -3
- package/dist/gateway/static/root/assets/pdf.worker.min-CHFwMXne.mjs +0 -29
- package/dist/gateway/static/root/assets/settings-advanced-gate-CFuqbGI-.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-vz0UK56q.js +0 -2
- package/dist/gateway/static/root/assets/skill-reload-api-C3D8WanU.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CxMWwR6A.js +0 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ImportService } from './importService.js';
|
|
2
|
+
import { type ImportTarget } from './types.js';
|
|
3
|
+
export declare function resolveImportTarget(projectId?: string): ImportTarget;
|
|
4
|
+
export declare function createRuntimeImportService(owner: string, refreshSkills?: () => void | Promise<void>, checkTrust?: (root: string) => boolean): ImportService;
|
|
5
|
+
export declare function recoverCapabilityImports(): Promise<void>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { resolveStateDir } from "../config/paths-state.js";
|
|
2
|
+
import { init_paths, resolveBundledSkillsDir, resolveSkillsDir } from "../config/paths.js";
|
|
3
|
+
import { ProjectService } from "../projects/project-service.js";
|
|
4
|
+
import { resolveWorkspaceSkillsDir } from "../agent/skills/workspace-skills-dir.js";
|
|
5
|
+
import { loadSkills } from "../agent/skills/index.js";
|
|
6
|
+
import { ProjectTrustStore } from "../project-trust/trust-store.js";
|
|
7
|
+
import { ImportError } from "./types.js";
|
|
8
|
+
import { ImportRepository } from "../storage/sqlite/import-repository.js";
|
|
9
|
+
import { canonicalTarget } from "./planner.js";
|
|
10
|
+
import { ImportService } from "./importService.js";
|
|
11
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
12
|
+
//#region src/imports/runtime.ts
|
|
13
|
+
init_paths();
|
|
14
|
+
function resolveImportTarget(projectId) {
|
|
15
|
+
if (!projectId) return { root: canonicalTarget(resolveSkillsDir()) };
|
|
16
|
+
const project = new ProjectService().get(projectId);
|
|
17
|
+
if (!project?.workspaceRoot || !existsSync(project.workspaceRoot)) throw new ImportError("invalid_project", "Project needs an existing workspace");
|
|
18
|
+
return {
|
|
19
|
+
projectId,
|
|
20
|
+
root: canonicalTarget(resolveWorkspaceSkillsDir(project.workspaceRoot))
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function createRuntimeImportService(owner, refreshSkills, checkTrust) {
|
|
24
|
+
return new ImportService({
|
|
25
|
+
owner,
|
|
26
|
+
stateDir: resolveStateDir(),
|
|
27
|
+
refreshSkills,
|
|
28
|
+
isConnected(candidate) {
|
|
29
|
+
if (!candidate.shared) return false;
|
|
30
|
+
const workspaceDir = (candidate.scope === "project" ? new ProjectService().resolveForWorkspacePath(candidate.location)?.project : void 0)?.workspaceRoot;
|
|
31
|
+
return loadSkills({
|
|
32
|
+
workspaceDir,
|
|
33
|
+
workspaceTrust: workspaceDir && (checkTrust ? checkTrust(workspaceDir) : new ProjectTrustStore().get(workspaceDir) === true) ? "trusted" : "untrusted"
|
|
34
|
+
}).skills.some((s) => realpathSync(s.baseDir) === candidate.location);
|
|
35
|
+
},
|
|
36
|
+
validateTarget(target) {
|
|
37
|
+
if (resolveImportTarget(target.projectId).root !== target.root) throw new ImportError("scope_mismatch", "Project target changed; preview again", 409);
|
|
38
|
+
if (target.projectId) {
|
|
39
|
+
const project = new ProjectService().get(target.projectId);
|
|
40
|
+
if (!(checkTrust ? checkTrust(project.workspaceRoot) : new ProjectTrustStore().get(project.workspaceRoot) === true)) throw new ImportError("workspace_untrusted", "Trust this project in project settings before importing", 403);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
reservedNames(target) {
|
|
44
|
+
return loadSkills({
|
|
45
|
+
workspaceDir: target.projectId ? new ProjectService().get(target.projectId)?.workspaceRoot : void 0,
|
|
46
|
+
workspaceTrust: "trusted",
|
|
47
|
+
builtinDir: resolveBundledSkillsDir() ?? void 0
|
|
48
|
+
}).skills.map((s) => s.name);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async function recoverCapabilityImports() {
|
|
53
|
+
for (const owner of ImportRepository.owners()) await createRuntimeImportService(owner).recoverAndClean();
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { createRuntimeImportService, recoverCapabilityImports, resolveImportTarget };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ImportScan, type ImportSource } from './types.js';
|
|
2
|
+
export { IMPORT_SOURCES } from './sources.js';
|
|
3
|
+
export interface ScanInput {
|
|
4
|
+
source: ImportSource;
|
|
5
|
+
root?: string;
|
|
6
|
+
projectRoot?: string;
|
|
7
|
+
home?: string;
|
|
8
|
+
projectOnly?: boolean;
|
|
9
|
+
budget?: {
|
|
10
|
+
bytes: number;
|
|
11
|
+
files: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function scanLocal(input: ScanInput): ImportScan;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { containsSecret } from "./secrets.js";
|
|
2
|
+
import { ImportError } from "./types.js";
|
|
3
|
+
import { IMPORT_LIMITS, digest, readRegularFile, readTree } from "./files.js";
|
|
4
|
+
import { inspectMcp, inspectSkill } from "./compatibility.js";
|
|
5
|
+
import { IMPORT_SOURCES, sourceLayout } from "./sources.js";
|
|
6
|
+
import { basename, join } from "node:path";
|
|
7
|
+
import { existsSync, readdirSync, realpathSync } from "node:fs";
|
|
8
|
+
import { randomUUID } from "node:crypto";
|
|
9
|
+
import { parse as parse$1 } from "smol-toml";
|
|
10
|
+
//#region src/imports/scanner.ts
|
|
11
|
+
function scanResult(source) {
|
|
12
|
+
if (!IMPORT_SOURCES.some((s) => s.id === source)) throw new ImportError("unsupported_source", "Unsupported source");
|
|
13
|
+
return {
|
|
14
|
+
id: randomUUID(),
|
|
15
|
+
createdAt: Date.now(),
|
|
16
|
+
source,
|
|
17
|
+
candidates: [],
|
|
18
|
+
diagnostics: []
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function base(source, scope, location, shared = false) {
|
|
22
|
+
return {
|
|
23
|
+
id: randomUUID(),
|
|
24
|
+
source,
|
|
25
|
+
scope,
|
|
26
|
+
location,
|
|
27
|
+
shared
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function appendMcp(scan, raw, scope, location) {
|
|
31
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return;
|
|
32
|
+
for (const [name, config] of Object.entries(raw)) scan.candidates.push(inspectMcp(base(scan.source, scope, location), name, config));
|
|
33
|
+
}
|
|
34
|
+
function scanLocal(input) {
|
|
35
|
+
const scan = scanResult(input.source);
|
|
36
|
+
const { home, root, layout } = sourceLayout(input.source, input.home, input.root);
|
|
37
|
+
const scopes = (input.projectOnly ? [] : layout.skills).map((s) => ({
|
|
38
|
+
path: join(s.base === "home" ? home : root, s.path),
|
|
39
|
+
scope: "user",
|
|
40
|
+
shared: s.shared
|
|
41
|
+
}));
|
|
42
|
+
if (input.projectRoot) scopes.push({
|
|
43
|
+
path: join(input.projectRoot, layout.projectSkills),
|
|
44
|
+
scope: "project",
|
|
45
|
+
shared: layout.skills.some((s) => s.shared)
|
|
46
|
+
});
|
|
47
|
+
const seen = /* @__PURE__ */ new Set();
|
|
48
|
+
const budget = input.budget ?? {
|
|
49
|
+
bytes: 0,
|
|
50
|
+
files: 0
|
|
51
|
+
};
|
|
52
|
+
const consume = (bytes, files) => {
|
|
53
|
+
budget.bytes += bytes;
|
|
54
|
+
budget.files += files;
|
|
55
|
+
if (budget.bytes > IMPORT_LIMITS.total || budget.files > IMPORT_LIMITS.count) throw new ImportError("limit_exceeded", "Import exceeds batch limits", 413);
|
|
56
|
+
};
|
|
57
|
+
for (const scope of scopes) {
|
|
58
|
+
if (!existsSync(scope.path)) continue;
|
|
59
|
+
let entries;
|
|
60
|
+
try {
|
|
61
|
+
entries = readdirSync(scope.path, { withFileTypes: true });
|
|
62
|
+
} catch {
|
|
63
|
+
scan.diagnostics.push("Unable to read skills directory");
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
68
|
+
const location = join(scope.path, entry.name);
|
|
69
|
+
if (!existsSync(join(location, "SKILL.md"))) continue;
|
|
70
|
+
try {
|
|
71
|
+
const real = realpathSync(location);
|
|
72
|
+
if (seen.has(real)) continue;
|
|
73
|
+
seen.add(real);
|
|
74
|
+
const files = readTree(location);
|
|
75
|
+
consume(files.reduce((n, f) => n + Buffer.byteLength(f.data, "base64"), 0), files.length);
|
|
76
|
+
scan.candidates.push(inspectSkill(base(input.source, scope.scope, real, scope.shared), files));
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (error instanceof ImportError && error.code === "limit_exceeded") throw error;
|
|
79
|
+
scan.diagnostics.push(`${entry.name}: ${error instanceof ImportError ? error.message : "Unable to read skill"}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const configs = [{
|
|
84
|
+
path: join(root, layout.config.path),
|
|
85
|
+
scope: "user"
|
|
86
|
+
}];
|
|
87
|
+
if (input.projectRoot) configs.push({
|
|
88
|
+
path: join(input.projectRoot, layout.projectConfig),
|
|
89
|
+
scope: "project"
|
|
90
|
+
});
|
|
91
|
+
for (const config of configs) {
|
|
92
|
+
if (!existsSync(config.path)) continue;
|
|
93
|
+
try {
|
|
94
|
+
const text = readRegularFile(config.path, 1024 * 1024).toString("utf8");
|
|
95
|
+
const parsed = layout.config.format === "toml" ? parse$1(text) : JSON.parse(text);
|
|
96
|
+
if (!input.projectOnly || config.scope === "project") appendMcp(scan, parsed[layout.config.mcpKey], config.scope, config.path);
|
|
97
|
+
const projects = parsed.projects;
|
|
98
|
+
if (config.scope === "user" && projects && typeof projects === "object" && !Array.isArray(projects)) {
|
|
99
|
+
const paths = Object.keys(projects);
|
|
100
|
+
scan.projectRoots = paths.slice(0, 100);
|
|
101
|
+
if (paths.length > 100) scan.diagnostics.push("Only the first 100 projects were imported.");
|
|
102
|
+
if (input.projectRoot) {
|
|
103
|
+
const project = projects[input.projectRoot];
|
|
104
|
+
appendMcp(scan, project?.[layout.config.mcpKey], "project", config.path);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
} catch {
|
|
108
|
+
scan.diagnostics.push(`${basename(config.path)}: invalid or unreadable configuration`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const addDocument = (path, scope) => {
|
|
112
|
+
if (!existsSync(path)) return;
|
|
113
|
+
try {
|
|
114
|
+
const content = readRegularFile(path, 128 * 1024).toString("utf8").trim();
|
|
115
|
+
if (!content) return;
|
|
116
|
+
consume(Buffer.byteLength(content), 1);
|
|
117
|
+
const blocked = containsSecret(content);
|
|
118
|
+
scan.candidates.push({
|
|
119
|
+
...base(input.source, scope, realpathSync(path)),
|
|
120
|
+
kind: "rule",
|
|
121
|
+
name: basename(path),
|
|
122
|
+
description: "",
|
|
123
|
+
hash: digest(content),
|
|
124
|
+
files: [],
|
|
125
|
+
compatibility: blocked ? "blocked" : "compatible",
|
|
126
|
+
findings: blocked ? ["Document contains probable credentials"] : [],
|
|
127
|
+
requiredEnv: [],
|
|
128
|
+
content: blocked ? void 0 : content
|
|
129
|
+
});
|
|
130
|
+
} catch {
|
|
131
|
+
scan.diagnostics.push(`${basename(path)}: unable to read context document`);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const addInstructions = (directory, groups, scope) => {
|
|
135
|
+
for (const names of groups) {
|
|
136
|
+
const path = names.map((name) => join(directory, name)).find(existsSync);
|
|
137
|
+
if (path) addDocument(path, scope);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const addRules = (directory, scope) => {
|
|
141
|
+
if (!existsSync(directory)) return;
|
|
142
|
+
try {
|
|
143
|
+
for (const entry of readdirSync(directory, { withFileTypes: true }).slice(0, 100)) if (entry.isFile() && entry.name.endsWith(".md")) addDocument(join(directory, entry.name), scope);
|
|
144
|
+
} catch {
|
|
145
|
+
scan.diagnostics.push("Unable to read rules directory");
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
if (!input.projectOnly) {
|
|
149
|
+
addInstructions(root, layout.instructions, "user");
|
|
150
|
+
if (layout.rules) addRules(join(root, layout.rules), "user");
|
|
151
|
+
}
|
|
152
|
+
if (input.projectRoot) {
|
|
153
|
+
addInstructions(input.projectRoot, layout.projectInstructions, "project");
|
|
154
|
+
if (layout.projectRules) addRules(join(input.projectRoot, layout.projectRules), "project");
|
|
155
|
+
}
|
|
156
|
+
return scan;
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
export { IMPORT_SOURCES, scanLocal };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/imports/secrets.ts
|
|
2
|
+
function containsSecret(text) {
|
|
3
|
+
return /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----|\b(?:sk-[a-zA-Z0-9_-]{20,}|gh[pousr]_[a-zA-Z0-9]{20,}|AKIA[A-Z0-9]{16})\b/i.test(text) || /(?:api[_-]?key|access[_-]?token|client[_-]?secret|password|authorization)\s*[=:]\s*["']?(?!\$|<|\{|process\.env|os\.environ)[a-zA-Z0-9_+/.-]{12,}/i.test(text);
|
|
4
|
+
}
|
|
5
|
+
function isCredentialPath(path) {
|
|
6
|
+
return /(^|\/)(\.env(?:\..*)?|auth\.json|credentials[^/]*|id_rsa|id_ed25519)$/i.test(path);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { containsSecret, isCredentialPath };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ImportSource } from './types.js';
|
|
2
|
+
interface SourceLayout {
|
|
3
|
+
id: ImportSource;
|
|
4
|
+
name: string;
|
|
5
|
+
directory: string;
|
|
6
|
+
environment: string;
|
|
7
|
+
skills: Array<{
|
|
8
|
+
base: 'home' | 'root';
|
|
9
|
+
path: string;
|
|
10
|
+
shared: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
projectSkills: string;
|
|
13
|
+
instructions: string[][];
|
|
14
|
+
projectInstructions: string[][];
|
|
15
|
+
rules?: string;
|
|
16
|
+
projectRules?: string;
|
|
17
|
+
config: {
|
|
18
|
+
path: string;
|
|
19
|
+
format: 'json' | 'toml';
|
|
20
|
+
mcpKey: string;
|
|
21
|
+
};
|
|
22
|
+
projectConfig: string;
|
|
23
|
+
}
|
|
24
|
+
/** Product differences live here; readers and destination writers are shared. */
|
|
25
|
+
export declare const IMPORT_SOURCES: readonly SourceLayout[];
|
|
26
|
+
export declare function sourceLayout(source: ImportSource, home?: string, root?: string): {
|
|
27
|
+
layout: SourceLayout;
|
|
28
|
+
home: string;
|
|
29
|
+
root: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function detectImportSources(): {
|
|
32
|
+
id: ImportSource;
|
|
33
|
+
name: string;
|
|
34
|
+
detected: boolean;
|
|
35
|
+
}[];
|
|
36
|
+
export declare function isImportSource(value: string): value is ImportSource;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ImportError } from "./types.js";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
//#region src/imports/sources.ts
|
|
6
|
+
/** Product differences live here; readers and destination writers are shared. */
|
|
7
|
+
const IMPORT_SOURCES = [{
|
|
8
|
+
id: "codex",
|
|
9
|
+
name: "Codex",
|
|
10
|
+
directory: ".codex",
|
|
11
|
+
environment: "CODEX_HOME",
|
|
12
|
+
skills: [{
|
|
13
|
+
base: "home",
|
|
14
|
+
path: ".agents/skills",
|
|
15
|
+
shared: true
|
|
16
|
+
}],
|
|
17
|
+
projectSkills: ".agents/skills",
|
|
18
|
+
instructions: [["AGENTS.override.md", "AGENTS.md"]],
|
|
19
|
+
projectInstructions: [["AGENTS.override.md", "AGENTS.md"]],
|
|
20
|
+
config: {
|
|
21
|
+
path: "config.toml",
|
|
22
|
+
format: "toml",
|
|
23
|
+
mcpKey: "mcp_servers"
|
|
24
|
+
},
|
|
25
|
+
projectConfig: ".codex/config.toml"
|
|
26
|
+
}, {
|
|
27
|
+
id: "claude-code",
|
|
28
|
+
name: "Claude Code",
|
|
29
|
+
directory: ".claude",
|
|
30
|
+
environment: "CLAUDE_CONFIG_DIR",
|
|
31
|
+
skills: [{
|
|
32
|
+
base: "root",
|
|
33
|
+
path: "skills",
|
|
34
|
+
shared: false
|
|
35
|
+
}],
|
|
36
|
+
projectSkills: ".claude/skills",
|
|
37
|
+
instructions: [["CLAUDE.md"]],
|
|
38
|
+
projectInstructions: [
|
|
39
|
+
["CLAUDE.md"],
|
|
40
|
+
[".claude/CLAUDE.md"],
|
|
41
|
+
["CLAUDE.local.md"]
|
|
42
|
+
],
|
|
43
|
+
rules: "rules",
|
|
44
|
+
projectRules: ".claude/rules",
|
|
45
|
+
config: {
|
|
46
|
+
path: "../.claude.json",
|
|
47
|
+
format: "json",
|
|
48
|
+
mcpKey: "mcpServers"
|
|
49
|
+
},
|
|
50
|
+
projectConfig: ".mcp.json"
|
|
51
|
+
}];
|
|
52
|
+
function sourceLayout(source, home, root) {
|
|
53
|
+
const layout = IMPORT_SOURCES.find((s) => s.id === source);
|
|
54
|
+
if (!layout) throw new ImportError("unsupported_source", "Unsupported source");
|
|
55
|
+
return {
|
|
56
|
+
layout,
|
|
57
|
+
home: home ?? homedir(),
|
|
58
|
+
root: root ?? (home ? void 0 : process.env[layout.environment]) ?? join(home ?? homedir(), layout.directory)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function detectImportSources() {
|
|
62
|
+
return IMPORT_SOURCES.map((s) => {
|
|
63
|
+
const { root } = sourceLayout(s.id);
|
|
64
|
+
return {
|
|
65
|
+
id: s.id,
|
|
66
|
+
name: s.name,
|
|
67
|
+
detected: existsSync(root) || existsSync(join(root, s.config.path))
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function isImportSource(value) {
|
|
72
|
+
return IMPORT_SOURCES.some((source) => source.id === value);
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { IMPORT_SOURCES, detectImportSources, isImportSource, sourceLayout };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export type ImportSource = 'codex' | 'claude-code';
|
|
2
|
+
export type ImportScope = 'user' | 'project';
|
|
3
|
+
export type Compatibility = 'compatible' | 'needs_setup' | 'blocked' | 'unsupported';
|
|
4
|
+
export interface ImportFile {
|
|
5
|
+
path: string;
|
|
6
|
+
data: string;
|
|
7
|
+
executable: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface ImportCandidate {
|
|
10
|
+
id: string;
|
|
11
|
+
source: ImportSource;
|
|
12
|
+
kind: 'skill' | 'mcp' | 'rule';
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
scope: ImportScope;
|
|
16
|
+
location: string;
|
|
17
|
+
hash: string;
|
|
18
|
+
compatibility: Compatibility;
|
|
19
|
+
findings: string[];
|
|
20
|
+
files: ImportFile[];
|
|
21
|
+
content?: string;
|
|
22
|
+
mcp?: Record<string, unknown>;
|
|
23
|
+
requiredEnv: string[];
|
|
24
|
+
shared: boolean;
|
|
25
|
+
connected?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface ImportScan {
|
|
28
|
+
id: string;
|
|
29
|
+
createdAt: number;
|
|
30
|
+
source: ImportSource;
|
|
31
|
+
candidates: ImportCandidate[];
|
|
32
|
+
diagnostics: string[];
|
|
33
|
+
projectRoots?: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface ImportTarget {
|
|
36
|
+
projectId?: string;
|
|
37
|
+
root: string;
|
|
38
|
+
}
|
|
39
|
+
export interface ImportAction {
|
|
40
|
+
candidateId: string;
|
|
41
|
+
operation: 'skip' | 'create' | 'rename' | 'replace';
|
|
42
|
+
name: string;
|
|
43
|
+
beforeHash: string | null;
|
|
44
|
+
}
|
|
45
|
+
export interface ImportPlan {
|
|
46
|
+
id: string;
|
|
47
|
+
scanId: string;
|
|
48
|
+
createdAt: number;
|
|
49
|
+
expiresAt: number;
|
|
50
|
+
target: ImportTarget;
|
|
51
|
+
targetRevision: string;
|
|
52
|
+
actions: ImportAction[];
|
|
53
|
+
}
|
|
54
|
+
export interface ImportJobItem {
|
|
55
|
+
action: ImportAction;
|
|
56
|
+
status: 'staged' | 'skipped' | 'publishing' | 'active' | 'rolling_back' | 'rolled_back' | 'failed';
|
|
57
|
+
error?: string;
|
|
58
|
+
afterHash?: string;
|
|
59
|
+
backupPath?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ImportJob {
|
|
62
|
+
id: string;
|
|
63
|
+
plan: ImportPlan;
|
|
64
|
+
createdAt: number;
|
|
65
|
+
expiresAt: number;
|
|
66
|
+
items: ImportJobItem[];
|
|
67
|
+
}
|
|
68
|
+
export declare class ImportError extends Error {
|
|
69
|
+
readonly code: string;
|
|
70
|
+
readonly status: 400 | 403 | 404 | 409 | 413;
|
|
71
|
+
constructor(code: string, message: string, status?: 400 | 403 | 404 | 409 | 413);
|
|
72
|
+
}
|
|
73
|
+
export interface ProductImportResult {
|
|
74
|
+
id: string;
|
|
75
|
+
source: ImportSource;
|
|
76
|
+
createdAt: number;
|
|
77
|
+
skills: number;
|
|
78
|
+
context: number;
|
|
79
|
+
projects: number;
|
|
80
|
+
skipped: number;
|
|
81
|
+
issues: Array<{
|
|
82
|
+
name: string;
|
|
83
|
+
reason: string;
|
|
84
|
+
}>;
|
|
85
|
+
}
|
|
86
|
+
export interface DetectedImportSource {
|
|
87
|
+
id: ImportSource;
|
|
88
|
+
name: string;
|
|
89
|
+
detected: boolean;
|
|
90
|
+
lastImport?: ProductImportResult;
|
|
91
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/imports/types.ts
|
|
2
|
+
var ImportError = class extends Error {
|
|
3
|
+
constructor(code, message, status = 400) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.status = status;
|
|
7
|
+
this.name = "ImportError";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ImportError };
|
|
@@ -142,7 +142,9 @@ function searchKnowledgeItems(input) {
|
|
|
142
142
|
const visible = visibilityClause(input.context);
|
|
143
143
|
const sourceParts = [];
|
|
144
144
|
const sourceValues = [];
|
|
145
|
-
|
|
145
|
+
const importedSource = "COALESCE(json_extract(k.source_json, '$.kind'), '') = 'product_import'";
|
|
146
|
+
if (input.sources?.includes("connector")) sourceParts.push(`(k.record_class = 'source_index' AND NOT (${importedSource}))`);
|
|
147
|
+
if (input.sources?.includes("workspace")) sourceParts.push(`(k.record_class = 'source_index' AND ${importedSource})`);
|
|
146
148
|
const memoryScopes = input.sources?.filter((source) => source !== "connector") ?? [];
|
|
147
149
|
if (memoryScopes.length) {
|
|
148
150
|
sourceParts.push(`(k.record_class = 'memory' AND k.scope_type IN (${memoryScopes.map(() => "?").join(", ")}))`);
|
|
@@ -163,7 +165,7 @@ function searchKnowledgeItems(input) {
|
|
|
163
165
|
ORDER BY rank ASC, k.importance DESC, k.updated_at DESC LIMIT ?`).all(fts, principalId, asOf, asOf, asOf, ...input.recordClass ? [input.recordClass] : [], ...sourceValues, ...visible.values, limit).map(fromRow);
|
|
164
166
|
}
|
|
165
167
|
function knowledgeSourceAllowed(item, sources) {
|
|
166
|
-
if (item.recordClass === "source_index") return sources.includes("connector");
|
|
168
|
+
if (item.recordClass === "source_index") return sources.includes(item.source.kind === "product_import" ? "workspace" : "connector");
|
|
167
169
|
return item.scope.type === "session" ? sources.includes("session") : item.scope.type === "workspace" ? sources.includes("workspace") : item.scope.type === "project" ? sources.includes("project") : false;
|
|
168
170
|
}
|
|
169
171
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getApiKeyFromEnv, init_env_keys } from "../env-keys.js";
|
|
2
1
|
import { init_sync_provider_auth, resolveProviderApiKeyForAgentSync } from "../../auth/sync-provider-auth.js";
|
|
2
|
+
import { getApiKeyFromEnv, init_env_keys } from "../env-keys.js";
|
|
3
3
|
import { getDefaultAuthProfileStore } from "./auth-profile-store.js";
|
|
4
4
|
//#region src/providers/auth-runtime/resolve-auth.ts
|
|
5
5
|
init_env_keys();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __esmMin, __exportAll } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { getAgentDefaultModelRef, init_schema } from "../config/schema.js";
|
|
3
|
+
import { getModelOAuthProviderIds, init_registry } from "../auth/oauth/registry.js";
|
|
4
|
+
import { hasProviderAuthOnDiskSync, init_sync_provider_auth } from "../auth/sync-provider-auth.js";
|
|
3
5
|
import { PROVIDER_ENV_MAP, getApiKeyFromEnv, init_env_keys } from "./env-keys.js";
|
|
4
6
|
import { init_model_ref, splitProviderModelRef } from "./model-ref.js";
|
|
5
7
|
import { ModelRegistry, getModelRegistry, init_model_registry, prewarmModelRegistry, resetModelRegistry } from "./model-registry.js";
|
|
6
|
-
import { getModelOAuthProviderIds, init_registry } from "../auth/oauth/registry.js";
|
|
7
8
|
import { CredentialResolver, hasCredentials, init_credentials } from "../auth/credentials.js";
|
|
8
|
-
import { hasProviderAuthOnDiskSync, init_sync_provider_auth } from "../auth/sync-provider-auth.js";
|
|
9
9
|
import { EXTENSION_PROVIDER_BASE_URL, init_constants } from "./constants.js";
|
|
10
10
|
import { applyOfficialModelMetadataCorrections, getSupplementalModels, init_model_supplements } from "./model-supplements.js";
|
|
11
11
|
import { getProviderRegistry, init_plugin_registry } from "./plugin-registry.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { createLogger } from "../utils/logger/index.js";
|
|
3
3
|
import { init_logger } from "../utils/logger.js";
|
|
4
|
-
import { init_resolve_config_value, resolveConfigValue, resolveHeaders } from "../config/resolve-config-value.js";
|
|
5
4
|
import { resolveModelsJsonPath } from "../config/paths.js";
|
|
5
|
+
import { init_resolve_config_value, resolveConfigValue, resolveHeaders } from "../config/resolve-config-value.js";
|
|
6
6
|
import { getDefaultModelValues, init_models_json, validateModelsConfig } from "../config/models-json.js";
|
|
7
7
|
import { getApiKeyFromEnv, init_env_keys } from "./env-keys.js";
|
|
8
8
|
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
3
2
|
import { getOAuthProviderDefinition, init_registry } from "../auth/oauth/registry.js";
|
|
3
|
+
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
4
4
|
import { XOPC_CLOUD_PROVIDER_ID, init_xopc_cloud_config, resolveXopcModelRouterUrl } from "./xopc-cloud-config.js";
|
|
5
5
|
//#region src/providers/register-runtime-providers.ts
|
|
6
6
|
function registerRuntimeProvider(modelRuntime, source) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ImportJob, ImportPlan, ImportScan, ProductImportResult } from '../../imports/types.js';
|
|
2
|
+
type Records = {
|
|
3
|
+
scan: ImportScan;
|
|
4
|
+
plan: ImportPlan;
|
|
5
|
+
job: ImportJob;
|
|
6
|
+
run: ProductImportResult;
|
|
7
|
+
};
|
|
8
|
+
export declare class ImportRepository {
|
|
9
|
+
readonly owner: string;
|
|
10
|
+
constructor(owner: string);
|
|
11
|
+
get<K extends keyof Records>(kind: K, id: string): Records[K];
|
|
12
|
+
save<K extends keyof Records>(kind: K, value: Records[K], key?: string): void;
|
|
13
|
+
byKey(key: string): ImportJob | undefined;
|
|
14
|
+
latestRuns(): ProductImportResult[];
|
|
15
|
+
static owners(): string[];
|
|
16
|
+
scansBefore(time: number): ImportScan[];
|
|
17
|
+
jobs(limit?: number): ImportJob[];
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { requireXopcDatabase } from "./connection.js";
|
|
2
|
+
import { ImportError } from "../../imports/types.js";
|
|
3
|
+
//#region src/storage/sqlite/import-repository.ts
|
|
4
|
+
var ImportRepository = class {
|
|
5
|
+
constructor(owner) {
|
|
6
|
+
this.owner = owner;
|
|
7
|
+
}
|
|
8
|
+
get(kind, id) {
|
|
9
|
+
const row = requireXopcDatabase().db.prepare("SELECT payload FROM capability_imports WHERE owner = ? AND kind = ? AND id = ?").get(this.owner, kind, id);
|
|
10
|
+
if (!row) throw new ImportError("not_found", "Import record not found", 404);
|
|
11
|
+
return JSON.parse(row.payload);
|
|
12
|
+
}
|
|
13
|
+
save(kind, value, key) {
|
|
14
|
+
requireXopcDatabase().db.prepare(`INSERT INTO capability_imports(id, owner, kind, created_at, payload, idempotency_key)
|
|
15
|
+
VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET payload = excluded.payload WHERE capability_imports.owner = excluded.owner`).run(value.id, this.owner, kind, value.createdAt, JSON.stringify(value), key ?? null);
|
|
16
|
+
}
|
|
17
|
+
byKey(key) {
|
|
18
|
+
const row = requireXopcDatabase().db.prepare("SELECT payload FROM capability_imports WHERE owner = ? AND kind = ? AND idempotency_key = ?").get(this.owner, "job", key);
|
|
19
|
+
return row ? JSON.parse(row.payload) : void 0;
|
|
20
|
+
}
|
|
21
|
+
latestRuns() {
|
|
22
|
+
return requireXopcDatabase().db.prepare("SELECT payload FROM capability_imports WHERE owner = ? AND kind = 'run' ORDER BY created_at DESC LIMIT 100").all(this.owner).map((r) => JSON.parse(r.payload));
|
|
23
|
+
}
|
|
24
|
+
static owners() {
|
|
25
|
+
return requireXopcDatabase().db.prepare("SELECT DISTINCT owner FROM capability_imports").all().map((r) => r.owner);
|
|
26
|
+
}
|
|
27
|
+
scansBefore(time) {
|
|
28
|
+
return requireXopcDatabase().db.prepare("SELECT payload FROM capability_imports WHERE owner = ? AND kind = ? AND created_at < ?").all(this.owner, "scan", time).map((r) => JSON.parse(r.payload));
|
|
29
|
+
}
|
|
30
|
+
jobs(limit = 100) {
|
|
31
|
+
return requireXopcDatabase().db.prepare("SELECT payload FROM capability_imports WHERE owner = ? AND kind = ? ORDER BY created_at DESC LIMIT ?").all(this.owner, "job", limit).map((r) => JSON.parse(r.payload));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { ImportRepository };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
CREATE TABLE capability_imports (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
owner TEXT NOT NULL,
|
|
4
|
+
kind TEXT NOT NULL CHECK (kind IN ('scan', 'plan', 'job', 'run')),
|
|
5
|
+
created_at INTEGER NOT NULL,
|
|
6
|
+
idempotency_key TEXT,
|
|
7
|
+
payload TEXT NOT NULL
|
|
8
|
+
);
|
|
9
|
+
CREATE INDEX capability_imports_owner_kind ON capability_imports(owner, kind, created_at DESC);
|
|
10
|
+
CREATE UNIQUE INDEX capability_imports_idempotency ON capability_imports(owner, idempotency_key)
|
|
11
|
+
WHERE idempotency_key IS NOT NULL;
|
|
@@ -3,7 +3,7 @@ import type { ApplyMigrationsOptions } from './types.js';
|
|
|
3
3
|
/** Baseline schema version applied from schema.sql on first open. */
|
|
4
4
|
export declare const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
|
|
5
5
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
6
|
-
export declare const XOPC_DB_SCHEMA_VERSION =
|
|
6
|
+
export declare const XOPC_DB_SCHEMA_VERSION = 174;
|
|
7
7
|
export declare function resolveMigrationsDir(override?: string): string;
|
|
8
8
|
/**
|
|
9
9
|
* Apply sequential SQL migrations from (currentVersion + 1) through targetVersion.
|
|
@@ -12,7 +12,7 @@ const log = createLogger("Sqlite:Migrations");
|
|
|
12
12
|
/** Baseline schema version applied from schema.sql on first open. */
|
|
13
13
|
const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
|
|
14
14
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
15
|
-
const XOPC_DB_SCHEMA_VERSION =
|
|
15
|
+
const XOPC_DB_SCHEMA_VERSION = 174;
|
|
16
16
|
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
17
17
|
function backupBeforeTaskCutover(db, databasePath) {
|
|
18
18
|
db.exec("PRAGMA wal_checkpoint(FULL)");
|
|
@@ -57,7 +57,7 @@ function applySingleMigration(db, migration) {
|
|
|
57
57
|
* Each step runs in its own transaction and updates schema_meta on success.
|
|
58
58
|
*/
|
|
59
59
|
function applyPendingMigrations(db, options = {}) {
|
|
60
|
-
const targetVersion = options.targetVersion ??
|
|
60
|
+
const targetVersion = options.targetVersion ?? 174;
|
|
61
61
|
let currentVersion = readSchemaVersion(db);
|
|
62
62
|
if (currentVersion > targetVersion) throw new DatabaseSchemaTooNewError(currentVersion, targetVersion);
|
|
63
63
|
if (currentVersion >= targetVersion) return currentVersion;
|
|
@@ -94,7 +94,7 @@ function applyPendingMigrations(db, options = {}) {
|
|
|
94
94
|
}
|
|
95
95
|
/** Inspect schema version without mutating the database. */
|
|
96
96
|
function inspectSchemaMigrationStatus(db, options = {}) {
|
|
97
|
-
const appVersion = options.targetVersion ??
|
|
97
|
+
const appVersion = options.targetVersion ?? 174;
|
|
98
98
|
const dbVersion = readSchemaVersion(db);
|
|
99
99
|
if (dbVersion > appVersion) return {
|
|
100
100
|
dbVersion,
|
|
@@ -19,7 +19,7 @@ const log = createLogger('Sqlite:Migrations');
|
|
|
19
19
|
export const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
|
|
20
20
|
|
|
21
21
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
22
|
-
export const XOPC_DB_SCHEMA_VERSION =
|
|
22
|
+
export const XOPC_DB_SCHEMA_VERSION = 174;
|
|
23
23
|
|
|
24
24
|
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
25
25
|
|