@skaile/workspaces 0.26.0 → 0.28.1
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 +65 -0
- package/dist/{asset-feeds-WMVTI7KW.js → asset-feeds-2V7LZIG7.js} +17 -10
- package/dist/asset-feeds-2V7LZIG7.js.map +1 -0
- package/dist/asset-manager/index.js +7 -7
- package/dist/asset-manager/installer.js +6 -6
- package/dist/bridge/drivers/claude-sdk.js +2 -2
- package/dist/bridge/drivers/codex.js +1 -1
- package/dist/bridge/drivers/continue.d.ts +2 -0
- package/dist/bridge/drivers/continue.js +103 -0
- package/dist/bridge/drivers/continue.js.map +1 -0
- package/dist/bridge/drivers/echo.js +1 -1
- package/dist/bridge/drivers/gemini.d.ts +2 -0
- package/dist/bridge/drivers/gemini.js +10 -0
- package/dist/bridge/drivers/gemini.js.map +1 -0
- package/dist/bridge/drivers/goose.d.ts +2 -0
- package/dist/bridge/drivers/goose.js +88 -0
- package/dist/bridge/drivers/goose.js.map +1 -0
- package/dist/bridge/drivers/omp.js +1 -1
- package/dist/bridge/drivers/opencode.d.ts +2 -0
- package/dist/bridge/drivers/opencode.js +99 -0
- package/dist/bridge/drivers/opencode.js.map +1 -0
- package/dist/bridge/drivers/qwen.d.ts +2 -0
- package/dist/bridge/drivers/qwen.js +57 -0
- package/dist/bridge/drivers/qwen.js.map +1 -0
- package/dist/bridge/index.js +3 -3
- package/dist/bridge/src/drivers/_subprocess-cli.d.ts +136 -0
- package/dist/bridge/src/drivers/_subprocess-cli.d.ts.map +1 -0
- package/dist/bridge/src/drivers/continue.d.ts +43 -0
- package/dist/bridge/src/drivers/continue.d.ts.map +1 -0
- package/dist/bridge/src/drivers/gemini.d.ts +55 -0
- package/dist/bridge/src/drivers/gemini.d.ts.map +1 -0
- package/dist/bridge/src/drivers/goose.d.ts +42 -0
- package/dist/bridge/src/drivers/goose.d.ts.map +1 -0
- package/dist/bridge/src/drivers/opencode.d.ts +43 -0
- package/dist/bridge/src/drivers/opencode.d.ts.map +1 -0
- package/dist/bridge/src/drivers/qwen.d.ts +39 -0
- package/dist/bridge/src/drivers/qwen.d.ts.map +1 -0
- package/dist/bridge/src/registry.d.ts.map +1 -1
- package/dist/{chunk-XGLGS5B4.js → chunk-2NOE4AGD.js} +3 -3
- package/dist/{chunk-XGLGS5B4.js.map → chunk-2NOE4AGD.js.map} +1 -1
- package/dist/{chunk-Z5DI7PDG.js → chunk-3QQSSRYN.js} +29 -5
- package/dist/chunk-3QQSSRYN.js.map +1 -0
- package/dist/chunk-5RBPPBEK.js +110 -0
- package/dist/chunk-5RBPPBEK.js.map +1 -0
- package/dist/chunk-5V5KZQIC.js +445 -0
- package/dist/chunk-5V5KZQIC.js.map +1 -0
- package/dist/{chunk-23M4XZQW.js → chunk-AKSR434V.js} +3 -3
- package/dist/{chunk-23M4XZQW.js.map → chunk-AKSR434V.js.map} +1 -1
- package/dist/{chunk-WD4LP66U.js → chunk-BSVLAHHH.js} +34 -17
- package/dist/chunk-BSVLAHHH.js.map +1 -0
- package/dist/{chunk-7OBGSR7O.js → chunk-BZ2JU7IP.js} +4 -4
- package/dist/{chunk-7OBGSR7O.js.map → chunk-BZ2JU7IP.js.map} +1 -1
- package/dist/{chunk-ZYDE52WE.js → chunk-DGM74UP4.js} +3 -3
- package/dist/{chunk-ZYDE52WE.js.map → chunk-DGM74UP4.js.map} +1 -1
- package/dist/{chunk-QHXS3YDV.js → chunk-FBVUGRTU.js} +5 -5
- package/dist/{chunk-QHXS3YDV.js.map → chunk-FBVUGRTU.js.map} +1 -1
- package/dist/{chunk-C32BRO2W.js → chunk-FWHOU3CX.js} +3 -3
- package/dist/{chunk-C32BRO2W.js.map → chunk-FWHOU3CX.js.map} +1 -1
- package/dist/{chunk-WSZAFRQL.js → chunk-GYPA2Q7F.js} +6 -5
- package/dist/chunk-GYPA2Q7F.js.map +1 -0
- package/dist/{chunk-KL2MQ6WI.js → chunk-M4KLIEIJ.js} +3 -3
- package/dist/{chunk-KL2MQ6WI.js.map → chunk-M4KLIEIJ.js.map} +1 -1
- package/dist/{chunk-RTAIGPTF.js → chunk-MIH45XPY.js} +100 -147
- package/dist/chunk-MIH45XPY.js.map +1 -0
- package/dist/{chunk-BKF3UFF4.js → chunk-SF4GWVR5.js} +4 -4
- package/dist/{chunk-BKF3UFF4.js.map → chunk-SF4GWVR5.js.map} +1 -1
- package/dist/{chunk-PY7AQRGH.js → chunk-U5L6F5NZ.js} +6 -6
- package/dist/{chunk-PY7AQRGH.js.map → chunk-U5L6F5NZ.js.map} +1 -1
- package/dist/{chunk-BQRRBGDE.js → chunk-UAW7VRAL.js} +2 -2
- package/dist/{chunk-BQRRBGDE.js.map → chunk-UAW7VRAL.js.map} +1 -1
- package/dist/{chunk-4SQ6Y6U7.js → chunk-UBCZVONU.js} +3 -3
- package/dist/{chunk-4SQ6Y6U7.js.map → chunk-UBCZVONU.js.map} +1 -1
- package/dist/{chunk-YRU4WB6Y.js → chunk-UIZKIUC6.js} +3 -3
- package/dist/{chunk-YRU4WB6Y.js.map → chunk-UIZKIUC6.js.map} +1 -1
- package/dist/{chunk-YDTW4GT6.js → chunk-XHBPQ7QP.js} +5 -5
- package/dist/{chunk-YDTW4GT6.js.map → chunk-XHBPQ7QP.js.map} +1 -1
- package/dist/chunk-Z3XXKR5E.js +88 -0
- package/dist/chunk-Z3XXKR5E.js.map +1 -0
- package/dist/{chunk-45H3UO2R.js → chunk-ZEKWHJBB.js} +52 -2
- package/dist/chunk-ZEKWHJBB.js.map +1 -0
- package/dist/cli/index.js +220 -117
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/src/asset-feeds.d.ts +14 -1
- package/dist/cli/src/asset-feeds.d.ts.map +1 -1
- package/dist/cli/src/commands/library-cmd.d.ts.map +1 -1
- package/dist/cli/src/commands/manage.d.ts +46 -23
- package/dist/cli/src/commands/manage.d.ts.map +1 -1
- package/dist/cli/src/helpers.d.ts +10 -1
- package/dist/cli/src/helpers.d.ts.map +1 -1
- package/dist/connectors/config.js +6 -6
- package/dist/connectors/index.js +8 -8
- package/dist/core/index.js +5 -5
- package/dist/core/runtime-assets.js +2 -2
- package/dist/core/src/workspace-config.d.ts +10 -1
- package/dist/core/src/workspace-config.d.ts.map +1 -1
- package/dist/core/workspace-config.js +1 -1
- package/dist/deploy/index.js +5 -5
- package/dist/{ensure-sources-CVULUVH4.js → ensure-sources-BNSRO5G7.js} +11 -10
- package/dist/ensure-sources-BNSRO5G7.js.map +1 -0
- package/dist/factory-assets/connectors/deploy.js +8 -8
- package/dist/factory-assets/connectors/devserver.js +8 -8
- package/dist/factory-assets/connectors/flow/adapter.js +8 -8
- package/dist/factory-assets/connectors/flow/engine.js +5 -5
- package/dist/factory-assets/connectors/flow/run-flow.js +9 -9
- package/dist/factory-assets/connectors/flow.js +8 -8
- package/dist/factory-assets/connectors/git.js +8 -8
- package/dist/factory-assets/connectors/gmail.js +8 -8
- package/dist/factory-assets/connectors/googledrive.js +8 -8
- package/dist/factory-assets/connectors/local.js +8 -8
- package/dist/factory-assets/connectors/mattermost.js +8 -8
- package/dist/factory-assets/connectors/memory.js +8 -8
- package/dist/factory-assets/connectors/minio.js +8 -8
- package/dist/factory-assets/connectors/postgres.js +8 -8
- package/dist/factory-assets/connectors/s3.js +8 -8
- package/dist/factory-assets/connectors/sharepoint.js +8 -8
- package/dist/factory-assets/connectors/sqlite.js +8 -8
- package/dist/factory-assets/connectors/static-server.js +8 -8
- package/dist/factory-assets/connectors/tunnel.js +8 -8
- package/dist/factory-assets/connectors/webdav.js +8 -8
- package/dist/factory-assets/connectors/xstate-store.js +8 -8
- package/dist/factory-assets/connectors/xstate.js +8 -8
- package/dist/{flows-JZFJD5IN.js → flows-L3GHQD7F.js} +4 -4
- package/dist/{flows-JZFJD5IN.js.map → flows-L3GHQD7F.js.map} +1 -1
- package/dist/helpers-F4NZ66VD.js +4 -0
- package/dist/{helpers-LTN3HMD3.js.map → helpers-F4NZ66VD.js.map} +1 -1
- package/dist/library/index.js +8 -7
- package/dist/library/install.d.ts +2 -0
- package/dist/library/install.js +16 -0
- package/dist/library/install.js.map +1 -0
- package/dist/library/src/index.d.ts +2 -2
- package/dist/library/src/index.d.ts.map +1 -1
- package/dist/library/src/install/index.d.ts +3 -0
- package/dist/library/src/install/index.d.ts.map +1 -0
- package/dist/library/src/library.d.ts +20 -20
- package/dist/library/src/library.d.ts.map +1 -1
- package/dist/library/src/local/db.d.ts.map +1 -1
- package/dist/library/src/local/library.d.ts +6 -6
- package/dist/library/src/local/library.d.ts.map +1 -1
- package/dist/library/src/local/local-catalog-source.d.ts +1 -1
- package/dist/library/src/local/schema.d.ts +9 -9
- package/dist/library/src/local/schema.d.ts.map +1 -1
- package/dist/library/src/preset/apply.d.ts +9 -9
- package/dist/library/src/preset/apply.d.ts.map +1 -1
- package/dist/library/src/preset/resolve-item.d.ts +1 -1
- package/dist/library/src/workspace-config.d.ts +11 -8
- package/dist/library/src/workspace-config.d.ts.map +1 -1
- package/dist/{open-library-WYASW4BH.js → open-library-3VJY74LQ.js} +12 -11
- package/dist/{open-library-WYASW4BH.js.map → open-library-3VJY74LQ.js.map} +1 -1
- package/dist/{paths-BMW6JYW6.js → paths-CE66L3AL.js} +8 -8
- package/dist/{paths-BMW6JYW6.js.map → paths-CE66L3AL.js.map} +1 -1
- package/dist/{plugin-store-O5VR45CA.js → plugin-store-GL5VKYUA.js} +7 -7
- package/dist/{plugin-store-O5VR45CA.js.map → plugin-store-GL5VKYUA.js.map} +1 -1
- package/dist/runner/index.js +14 -14
- package/dist/runner/src/serve.d.ts.map +1 -1
- package/dist/sdk/asset-manager.js +7 -7
- package/dist/sdk/bridge.js +3 -3
- package/dist/sdk/core.js +5 -5
- package/dist/sdk/flow.js +5 -5
- package/dist/sdk/index.js +14 -14
- package/dist/sdk/runner.js +14 -14
- package/dist/{setup-YNLFR5GB.js → setup-4YMN2BDU.js} +10 -10
- package/dist/{setup-YNLFR5GB.js.map → setup-4YMN2BDU.js.map} +1 -1
- package/dist/{store-client-CENBEASX.js → store-client-BCP5LCAZ.js} +8 -8
- package/dist/{store-client-CENBEASX.js.map → store-client-BCP5LCAZ.js.map} +1 -1
- package/dist/tui/index.js +14 -14
- package/dist/workspace-plugin/adapters/mcp.js +3 -3
- package/dist/workspace-plugin/adapters/omp.js +3 -3
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +37 -1
- package/dist/asset-feeds-WMVTI7KW.js.map +0 -1
- package/dist/chunk-45H3UO2R.js.map +0 -1
- package/dist/chunk-RTAIGPTF.js.map +0 -1
- package/dist/chunk-WD4LP66U.js.map +0 -1
- package/dist/chunk-WSZAFRQL.js.map +0 -1
- package/dist/chunk-Z5DI7PDG.js.map +0 -1
- package/dist/ensure-sources-CVULUVH4.js.map +0 -1
- package/dist/helpers-LTN3HMD3.js +0 -4
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { readManifestSourceConfig, discoverAssetsInTree } from './chunk-JIQLLZ65.js';
|
|
2
|
+
import { installFromManifest } from './chunk-Z3XXKR5E.js';
|
|
2
3
|
import { parseAssetRef } from './chunk-IEJ5IOC3.js';
|
|
3
4
|
import { PresetManifestSchema } from './chunk-QDJKE557.js';
|
|
4
5
|
import { __export } from './chunk-NSBPE2FW.js';
|
|
5
6
|
import * as crypto from 'crypto';
|
|
6
|
-
import { createHash } from 'crypto';
|
|
7
7
|
import * as fs11 from 'fs';
|
|
8
8
|
import * as path4 from 'path';
|
|
9
|
-
import { resolve, join, sep, dirname, isAbsolute } from 'path';
|
|
10
9
|
import { eq, like, and } from 'drizzle-orm';
|
|
11
10
|
import * as z2 from 'zod';
|
|
12
11
|
import * as os from 'os';
|
|
@@ -15,7 +14,6 @@ import { createClient } from '@libsql/client';
|
|
|
15
14
|
import { drizzle } from 'drizzle-orm/libsql';
|
|
16
15
|
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
|
|
17
16
|
import { spawnSync } from 'child_process';
|
|
18
|
-
import { rm, mkdir, writeFile } from 'fs/promises';
|
|
19
17
|
|
|
20
18
|
// library/src/library.ts
|
|
21
19
|
var KNOWN_ASSET_KINDS = [
|
|
@@ -52,25 +50,25 @@ var InstanceNotFoundError = class extends LibraryError {
|
|
|
52
50
|
this.name = "InstanceNotFoundError";
|
|
53
51
|
}
|
|
54
52
|
};
|
|
55
|
-
var
|
|
53
|
+
var AssignmentNotFoundError = class extends LibraryError {
|
|
56
54
|
constructor(id) {
|
|
57
|
-
super(`
|
|
58
|
-
this.name = "
|
|
55
|
+
super(`Assignment not found: ${id}`, "ASSIGNMENT_NOT_FOUND");
|
|
56
|
+
this.name = "AssignmentNotFoundError";
|
|
59
57
|
}
|
|
60
58
|
};
|
|
61
|
-
var
|
|
59
|
+
var DuplicateAssignmentError = class extends LibraryError {
|
|
62
60
|
constructor(workspaceId, instanceId) {
|
|
63
61
|
super(
|
|
64
|
-
`Workspace "${workspaceId}" already
|
|
65
|
-
"
|
|
62
|
+
`Workspace "${workspaceId}" already has instance "${instanceId}" assigned`,
|
|
63
|
+
"DUPLICATE_ASSIGNMENT"
|
|
66
64
|
);
|
|
67
|
-
this.name = "
|
|
65
|
+
this.name = "DuplicateAssignmentError";
|
|
68
66
|
}
|
|
69
67
|
};
|
|
70
68
|
var InstanceHasConsumersError = class extends LibraryError {
|
|
71
69
|
constructor(instanceId, count) {
|
|
72
70
|
super(
|
|
73
|
-
`Instance "${instanceId}" has ${count} active
|
|
71
|
+
`Instance "${instanceId}" has ${count} active assignment(s). Use { cascade: true } to force delete.`,
|
|
74
72
|
"INSTANCE_HAS_CONSUMERS"
|
|
75
73
|
);
|
|
76
74
|
this.name = "InstanceHasConsumersError";
|
|
@@ -101,7 +99,7 @@ var CatalogConfigSchema = z2.object({
|
|
|
101
99
|
var LibraryConfigSchema = z2.object({
|
|
102
100
|
/** Library storage directory. Default: ~/.skaile/libraries */
|
|
103
101
|
dir: z2.string().optional(),
|
|
104
|
-
/** Default pin policy for new instances/
|
|
102
|
+
/** Default pin policy for new instances/assignments. */
|
|
105
103
|
pin_policy: z2.enum(PIN_POLICIES).optional()
|
|
106
104
|
});
|
|
107
105
|
var SkaileConfigSchema = z2.object({
|
|
@@ -200,9 +198,9 @@ function saveConfig(filePath, config) {
|
|
|
200
198
|
var schema_exports = {};
|
|
201
199
|
__export(schema_exports, {
|
|
202
200
|
assetDefinitions: () => assetDefinitions,
|
|
201
|
+
assignments: () => assignments,
|
|
203
202
|
instances: () => instances,
|
|
204
|
-
libraries: () => libraries
|
|
205
|
-
subscriptions: () => subscriptions
|
|
203
|
+
libraries: () => libraries
|
|
206
204
|
});
|
|
207
205
|
var libraries = sqliteTable("libraries", {
|
|
208
206
|
/** UUID primary key. */
|
|
@@ -258,12 +256,12 @@ var instances = sqliteTable("instances", {
|
|
|
258
256
|
createdBy: text("created_by"),
|
|
259
257
|
sourceCommitSha: text("source_commit_sha")
|
|
260
258
|
});
|
|
261
|
-
var
|
|
259
|
+
var assignments = sqliteTable("assignments", {
|
|
262
260
|
id: text("id").primaryKey(),
|
|
263
261
|
workspaceId: text("workspace_id").notNull(),
|
|
264
262
|
instanceId: text("instance_id").notNull(),
|
|
265
263
|
pinPolicy: text("pin_policy").notNull(),
|
|
266
|
-
|
|
264
|
+
assignedAt: text("assigned_at").notNull()
|
|
267
265
|
});
|
|
268
266
|
var SKAILE_HOME_ENV = "SKAILE_HOME";
|
|
269
267
|
function getSidecarRoot() {
|
|
@@ -419,16 +417,16 @@ CREATE TABLE IF NOT EXISTS instances (
|
|
|
419
417
|
);
|
|
420
418
|
CREATE INDEX IF NOT EXISTS idx_instances_def_ref ON instances(def_ref);
|
|
421
419
|
|
|
422
|
-
CREATE TABLE IF NOT EXISTS
|
|
420
|
+
CREATE TABLE IF NOT EXISTS assignments (
|
|
423
421
|
id TEXT PRIMARY KEY,
|
|
424
422
|
workspace_id TEXT NOT NULL,
|
|
425
423
|
instance_id TEXT NOT NULL REFERENCES instances(id) ON DELETE CASCADE,
|
|
426
424
|
pin_policy TEXT NOT NULL,
|
|
427
|
-
|
|
425
|
+
assigned_at TEXT NOT NULL
|
|
428
426
|
);
|
|
429
|
-
CREATE UNIQUE INDEX IF NOT EXISTS
|
|
430
|
-
ON
|
|
431
|
-
CREATE INDEX IF NOT EXISTS
|
|
427
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_assignments_ws_instance
|
|
428
|
+
ON assignments(workspace_id, instance_id);
|
|
429
|
+
CREATE INDEX IF NOT EXISTS idx_assignments_instance_id ON assignments(instance_id);
|
|
432
430
|
`;
|
|
433
431
|
async function legacySourcesPresent(client) {
|
|
434
432
|
const rs = await client.execute(
|
|
@@ -508,6 +506,26 @@ async function runLibrariesMigration(client) {
|
|
|
508
506
|
stmts.push({ sql: `DROP TABLE sources;` });
|
|
509
507
|
await client.batch(stmts);
|
|
510
508
|
}
|
|
509
|
+
async function legacySubscriptionsPresent(client) {
|
|
510
|
+
const rs = await client.execute(
|
|
511
|
+
"SELECT name FROM sqlite_master WHERE type='table' AND name='subscriptions'"
|
|
512
|
+
);
|
|
513
|
+
return rs.rows.length > 0;
|
|
514
|
+
}
|
|
515
|
+
async function assignmentsPresent(client) {
|
|
516
|
+
const rs = await client.execute(
|
|
517
|
+
"SELECT name FROM sqlite_master WHERE type='table' AND name='assignments'"
|
|
518
|
+
);
|
|
519
|
+
return rs.rows.length > 0;
|
|
520
|
+
}
|
|
521
|
+
async function runAssignmentsMigration(client) {
|
|
522
|
+
await client.batch([
|
|
523
|
+
{ sql: "ALTER TABLE subscriptions RENAME TO assignments;" },
|
|
524
|
+
{ sql: "ALTER TABLE assignments RENAME COLUMN subscribed_at TO assigned_at;" },
|
|
525
|
+
{ sql: "DROP INDEX IF EXISTS idx_subs_ws_instance;" },
|
|
526
|
+
{ sql: "DROP INDEX IF EXISTS idx_subs_instance_id;" }
|
|
527
|
+
]);
|
|
528
|
+
}
|
|
511
529
|
function assertNoLegacyLibDb(newDbPath) {
|
|
512
530
|
if (fs11.existsSync(newDbPath)) return;
|
|
513
531
|
const parent = path4.dirname(newDbPath);
|
|
@@ -547,6 +565,9 @@ async function createLibraryDb(dbPath) {
|
|
|
547
565
|
if (await legacySourcesPresent(client) && !await librariesPresent(client)) {
|
|
548
566
|
await runLibrariesMigration(client);
|
|
549
567
|
}
|
|
568
|
+
if (await legacySubscriptionsPresent(client) && !await assignmentsPresent(client)) {
|
|
569
|
+
await runAssignmentsMigration(client);
|
|
570
|
+
}
|
|
550
571
|
await client.executeMultiple(DDL);
|
|
551
572
|
if (await librariesPresent(client)) {
|
|
552
573
|
const storeRows = await client.execute({
|
|
@@ -571,85 +592,6 @@ async function createLibraryDb(dbPath) {
|
|
|
571
592
|
const db = drizzle(client, { schema: schema_exports });
|
|
572
593
|
return { db, close: () => client.close() };
|
|
573
594
|
}
|
|
574
|
-
function assertSafeManifestPath(installPath, p) {
|
|
575
|
-
const bad = () => {
|
|
576
|
-
throw new Error(`unsafe path in manifest: ${p}`);
|
|
577
|
-
};
|
|
578
|
-
if (!p || p.length === 0) bad();
|
|
579
|
-
if (isAbsolute(p) || p.startsWith("/") || p.startsWith("\\")) bad();
|
|
580
|
-
const segments = p.split(/[/\\]/);
|
|
581
|
-
if (segments.some((s) => s === "..")) bad();
|
|
582
|
-
const resolved = resolve(installPath, p);
|
|
583
|
-
if (resolved !== installPath && !resolved.startsWith(installPath + sep)) bad();
|
|
584
|
-
}
|
|
585
|
-
function assertSafeRefComponent(kind, value) {
|
|
586
|
-
const hasControlChar = [...value].some((c) => c.charCodeAt(0) < 32);
|
|
587
|
-
if (!value || value.startsWith(".") || /[/\\]/.test(value) || hasControlChar) {
|
|
588
|
-
throw new Error(`unsafe ref ${kind} component in manifest: '${value}'`);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
async function installFromManifest(opts) {
|
|
592
|
-
const { manifest, libraryRoot } = opts;
|
|
593
|
-
const fetcher = opts.fetcher ?? (await import('./source-fetch-github-QN4LLTL5.js')).fetchAssetFilesFromGitHub;
|
|
594
|
-
let parsed;
|
|
595
|
-
try {
|
|
596
|
-
parsed = parseAssetRef(manifest.ref);
|
|
597
|
-
} catch (e) {
|
|
598
|
-
throw new Error(`invalid ref: ${manifest.ref}: ${e instanceof Error ? e.message : String(e)}`);
|
|
599
|
-
}
|
|
600
|
-
const publisher = parsed.publisher;
|
|
601
|
-
const name = parsed.name;
|
|
602
|
-
const version = parsed.pin;
|
|
603
|
-
if (!publisher) throw new Error(`invalid ref: ${manifest.ref} (missing publisher)`);
|
|
604
|
-
if (!version) throw new Error(`invalid ref: ${manifest.ref} (missing version pin)`);
|
|
605
|
-
assertSafeRefComponent("publisher", publisher);
|
|
606
|
-
assertSafeRefComponent("name", name);
|
|
607
|
-
assertSafeRefComponent("version", version);
|
|
608
|
-
const root = resolve(libraryRoot);
|
|
609
|
-
const installPath = resolve(join(root, `@${publisher}`, name, version));
|
|
610
|
-
if (installPath !== root && !installPath.startsWith(root + sep)) {
|
|
611
|
-
throw new Error(
|
|
612
|
-
`unsafe install path: ref '${manifest.ref}' resolves outside the library root`
|
|
613
|
-
);
|
|
614
|
-
}
|
|
615
|
-
for (const f of manifest.files) {
|
|
616
|
-
assertSafeManifestPath(installPath, f.path);
|
|
617
|
-
}
|
|
618
|
-
const paths = manifest.files.map((f) => f.path);
|
|
619
|
-
const bytes = await fetcher({
|
|
620
|
-
url: manifest.source.url,
|
|
621
|
-
commitSha: manifest.source.commitSha,
|
|
622
|
-
paths
|
|
623
|
-
});
|
|
624
|
-
for (const f of manifest.files) {
|
|
625
|
-
assertSafeManifestPath(installPath, f.path);
|
|
626
|
-
const buf = bytes[f.path];
|
|
627
|
-
if (!buf) throw new Error(`fetcher returned no bytes for ${f.path}`);
|
|
628
|
-
const actual = createHash("sha256").update(buf).digest("hex");
|
|
629
|
-
if (actual !== f.sha256) {
|
|
630
|
-
throw new Error(`hash mismatch for ${f.path}: expected ${f.sha256}, got ${actual}`);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
const sortedLines = manifest.files.slice().sort((a, b) => a.path.localeCompare(b.path)).map((e) => `${e.path}:${e.sha256}
|
|
634
|
-
`).join("");
|
|
635
|
-
const actualComposite = createHash("sha256").update(sortedLines, "utf-8").digest("hex");
|
|
636
|
-
if (actualComposite !== manifest.sha256) {
|
|
637
|
-
throw new Error(`composite hash mismatch: expected ${manifest.sha256}, got ${actualComposite}`);
|
|
638
|
-
}
|
|
639
|
-
await rm(installPath, { recursive: true, force: true });
|
|
640
|
-
try {
|
|
641
|
-
for (const f of manifest.files) {
|
|
642
|
-
const target = join(installPath, f.path);
|
|
643
|
-
await mkdir(dirname(target), { recursive: true });
|
|
644
|
-
await writeFile(target, bytes[f.path]);
|
|
645
|
-
}
|
|
646
|
-
} catch (e) {
|
|
647
|
-
await rm(installPath, { recursive: true, force: true }).catch(() => {
|
|
648
|
-
});
|
|
649
|
-
throw e;
|
|
650
|
-
}
|
|
651
|
-
return { installPath };
|
|
652
|
-
}
|
|
653
595
|
|
|
654
596
|
// library/src/local/library.ts
|
|
655
597
|
function escapeLikePrefix(prefix) {
|
|
@@ -713,13 +655,13 @@ function rowToInstance(row) {
|
|
|
713
655
|
sourceCommitSha: row.sourceCommitSha ?? void 0
|
|
714
656
|
};
|
|
715
657
|
}
|
|
716
|
-
function
|
|
658
|
+
function rowToAssignment(row) {
|
|
717
659
|
return {
|
|
718
660
|
id: row.id,
|
|
719
661
|
workspaceId: row.workspaceId,
|
|
720
662
|
instanceId: row.instanceId,
|
|
721
663
|
pinPolicy: row.pinPolicy,
|
|
722
|
-
|
|
664
|
+
assignedAt: new Date(row.assignedAt)
|
|
723
665
|
};
|
|
724
666
|
}
|
|
725
667
|
var LocalIndex = class {
|
|
@@ -1041,42 +983,42 @@ var LocalIndex = class {
|
|
|
1041
983
|
const db = await this.ensureDb();
|
|
1042
984
|
const existing = await db.select().from(instances).where(eq(instances.id, id)).get();
|
|
1043
985
|
if (!existing) throw new InstanceNotFoundError(id);
|
|
1044
|
-
const consumers = await db.select().from(
|
|
986
|
+
const consumers = await db.select().from(assignments).where(eq(assignments.instanceId, id)).all();
|
|
1045
987
|
if (consumers.length > 0 && !opts?.cascade) {
|
|
1046
988
|
throw new InstanceHasConsumersError(id, consumers.length);
|
|
1047
989
|
}
|
|
1048
990
|
await db.delete(instances).where(eq(instances.id, id)).run();
|
|
1049
991
|
}
|
|
1050
|
-
// --
|
|
1051
|
-
async
|
|
992
|
+
// -- Assignments ---------------------------------------------------------
|
|
993
|
+
async assign(workspaceId, instanceId, pin) {
|
|
1052
994
|
const db = await this.ensureDb();
|
|
1053
995
|
const instance = await db.select().from(instances).where(eq(instances.id, instanceId)).get();
|
|
1054
996
|
if (!instance) throw new InstanceNotFoundError(instanceId);
|
|
1055
|
-
const existing = await db.select().from(
|
|
997
|
+
const existing = await db.select().from(assignments).where(
|
|
1056
998
|
and(
|
|
1057
|
-
eq(
|
|
1058
|
-
eq(
|
|
999
|
+
eq(assignments.workspaceId, workspaceId),
|
|
1000
|
+
eq(assignments.instanceId, instanceId)
|
|
1059
1001
|
)
|
|
1060
1002
|
).get();
|
|
1061
|
-
if (existing) throw new
|
|
1003
|
+
if (existing) throw new DuplicateAssignmentError(workspaceId, instanceId);
|
|
1062
1004
|
const id = crypto.randomUUID();
|
|
1063
1005
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1064
|
-
await db.insert(
|
|
1065
|
-
return { id, workspaceId, instanceId, pinPolicy: pin,
|
|
1006
|
+
await db.insert(assignments).values({ id, workspaceId, instanceId, pinPolicy: pin, assignedAt: now }).run();
|
|
1007
|
+
return { id, workspaceId, instanceId, pinPolicy: pin, assignedAt: new Date(now) };
|
|
1066
1008
|
}
|
|
1067
|
-
async
|
|
1009
|
+
async unassign(assignmentId) {
|
|
1068
1010
|
const db = await this.ensureDb();
|
|
1069
|
-
const existing = await db.select().from(
|
|
1070
|
-
if (!existing) throw new
|
|
1071
|
-
await db.delete(
|
|
1011
|
+
const existing = await db.select().from(assignments).where(eq(assignments.id, assignmentId)).get();
|
|
1012
|
+
if (!existing) throw new AssignmentNotFoundError(assignmentId);
|
|
1013
|
+
await db.delete(assignments).where(eq(assignments.id, assignmentId)).run();
|
|
1072
1014
|
}
|
|
1073
|
-
async
|
|
1015
|
+
async listAssignments(workspaceId) {
|
|
1074
1016
|
const db = await this.ensureDb();
|
|
1075
|
-
return (await db.select().from(
|
|
1017
|
+
return (await db.select().from(assignments).where(eq(assignments.workspaceId, workspaceId)).all()).map(rowToAssignment);
|
|
1076
1018
|
}
|
|
1077
1019
|
async getConsumptionGraph(instanceId) {
|
|
1078
1020
|
const db = await this.ensureDb();
|
|
1079
|
-
return (await db.select().from(
|
|
1021
|
+
return (await db.select().from(assignments).where(eq(assignments.instanceId, instanceId)).all()).map(rowToAssignment);
|
|
1080
1022
|
}
|
|
1081
1023
|
};
|
|
1082
1024
|
|
|
@@ -1588,8 +1530,8 @@ var WorkspaceConfigV2Schema = z2.object({
|
|
|
1588
1530
|
library: LibrarySectionSchema.optional(),
|
|
1589
1531
|
presets_applied: z2.array(PresetAppliedSchema).optional()
|
|
1590
1532
|
});
|
|
1591
|
-
var
|
|
1592
|
-
|
|
1533
|
+
var LockAssignmentSchema = z2.object({
|
|
1534
|
+
assignment_id: z2.string().uuid(),
|
|
1593
1535
|
instance_id: z2.string().uuid(),
|
|
1594
1536
|
def_ref: z2.string(),
|
|
1595
1537
|
resolved_version: z2.string(),
|
|
@@ -1608,7 +1550,7 @@ var PresetExpandedSchema = z2.object({
|
|
|
1608
1550
|
var LockFileSchema = z2.object({
|
|
1609
1551
|
version: z2.literal(2),
|
|
1610
1552
|
generated_at: z2.string(),
|
|
1611
|
-
|
|
1553
|
+
assignments: z2.array(LockAssignmentSchema).default([]),
|
|
1612
1554
|
requires_graph: z2.array(RequiresEdgeSchema).default([]),
|
|
1613
1555
|
presets_expanded: z2.array(PresetExpandedSchema).default([])
|
|
1614
1556
|
});
|
|
@@ -1645,6 +1587,17 @@ function loadLockFile(dir) {
|
|
|
1645
1587
|
if (!fs11.existsSync(filePath)) return null;
|
|
1646
1588
|
const content = fs11.readFileSync(filePath, "utf-8");
|
|
1647
1589
|
const raw = parse(content);
|
|
1590
|
+
if (raw !== null && !("assignments" in raw) && "subscriptions" in raw) {
|
|
1591
|
+
const legacySubs = raw["subscriptions"];
|
|
1592
|
+
raw["assignments"] = Array.isArray(legacySubs) ? legacySubs.map((s) => {
|
|
1593
|
+
if (s !== null && typeof s === "object" && "subscription_id" in s && !("assignment_id" in s)) {
|
|
1594
|
+
const { subscription_id, ...rest } = s;
|
|
1595
|
+
return { assignment_id: subscription_id, ...rest };
|
|
1596
|
+
}
|
|
1597
|
+
return s;
|
|
1598
|
+
}) : [];
|
|
1599
|
+
delete raw["subscriptions"];
|
|
1600
|
+
}
|
|
1648
1601
|
return LockFileSchema.parse(raw);
|
|
1649
1602
|
}
|
|
1650
1603
|
function saveLockFile(dir, lock) {
|
|
@@ -1663,7 +1616,7 @@ function createEmptyLockFile() {
|
|
|
1663
1616
|
return {
|
|
1664
1617
|
version: 2,
|
|
1665
1618
|
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1666
|
-
|
|
1619
|
+
assignments: [],
|
|
1667
1620
|
requires_graph: [],
|
|
1668
1621
|
presets_expanded: []
|
|
1669
1622
|
};
|
|
@@ -3333,9 +3286,9 @@ async function applyPreset(presetRef, manifest, inputs, opts) {
|
|
|
3333
3286
|
const pinPolicy = opts.pinPolicy ?? "minor-track";
|
|
3334
3287
|
const depthError = validateNestingDepth(presetRef, depth);
|
|
3335
3288
|
if (depthError) {
|
|
3336
|
-
return { instances: [],
|
|
3289
|
+
return { instances: [], assignments: [], errors: [depthError] };
|
|
3337
3290
|
}
|
|
3338
|
-
const result = { instances: [],
|
|
3291
|
+
const result = { instances: [], assignments: [], errors: [] };
|
|
3339
3292
|
const itemResults = /* @__PURE__ */ new Map();
|
|
3340
3293
|
for (const item of manifest.items) {
|
|
3341
3294
|
const itemResult = await applyItemImpl(
|
|
@@ -3352,7 +3305,7 @@ async function applyPreset(presetRef, manifest, inputs, opts) {
|
|
|
3352
3305
|
if (item.id && itemResult.instances.length > 0) {
|
|
3353
3306
|
itemResults.set(item.id, itemResult.instances[0]);
|
|
3354
3307
|
}
|
|
3355
|
-
result.
|
|
3308
|
+
result.assignments.push(...itemResult.assignments);
|
|
3356
3309
|
}
|
|
3357
3310
|
return result;
|
|
3358
3311
|
}
|
|
@@ -3361,7 +3314,7 @@ async function applyPresetFromData(presetRef, data, inputs, opts) {
|
|
|
3361
3314
|
if (!parseResult.ok || !parseResult.preset) {
|
|
3362
3315
|
return {
|
|
3363
3316
|
instances: [],
|
|
3364
|
-
|
|
3317
|
+
assignments: [],
|
|
3365
3318
|
errors: parseResult.errors.map((e) => `Parse: ${e}`)
|
|
3366
3319
|
};
|
|
3367
3320
|
}
|
|
@@ -3376,34 +3329,34 @@ async function applyItemImpl(presetRef, item, inputs, opts, depth, pinPolicy, it
|
|
|
3376
3329
|
if (!target) {
|
|
3377
3330
|
return {
|
|
3378
3331
|
instances: [],
|
|
3379
|
-
|
|
3332
|
+
assignments: [],
|
|
3380
3333
|
errors: [
|
|
3381
3334
|
`Cross-item ref "#${resolved.targetId}" not yet resolved (items must be ordered)`
|
|
3382
3335
|
]
|
|
3383
3336
|
};
|
|
3384
3337
|
}
|
|
3385
|
-
return { instances: [target],
|
|
3338
|
+
return { instances: [target], assignments: [], errors: [] };
|
|
3386
3339
|
}
|
|
3387
3340
|
case "library-instance": {
|
|
3388
3341
|
if (!resolved.instance) {
|
|
3389
3342
|
return {
|
|
3390
3343
|
instances: [],
|
|
3391
|
-
|
|
3344
|
+
assignments: [],
|
|
3392
3345
|
errors: [`Library instance "${resolved.instanceId}" not found`]
|
|
3393
3346
|
};
|
|
3394
3347
|
}
|
|
3395
3348
|
try {
|
|
3396
|
-
const
|
|
3397
|
-
return { instances: [resolved.instance],
|
|
3349
|
+
const asgn = await library.assign(opts.workspaceId, resolved.instanceId, pinPolicy);
|
|
3350
|
+
return { instances: [resolved.instance], assignments: [asgn], errors: [] };
|
|
3398
3351
|
} catch {
|
|
3399
|
-
return { instances: [resolved.instance],
|
|
3352
|
+
return { instances: [resolved.instance], assignments: [], errors: [] };
|
|
3400
3353
|
}
|
|
3401
3354
|
}
|
|
3402
3355
|
case "nested-preset": {
|
|
3403
3356
|
if (!opts.loadPreset) {
|
|
3404
3357
|
return {
|
|
3405
3358
|
instances: [],
|
|
3406
|
-
|
|
3359
|
+
assignments: [],
|
|
3407
3360
|
errors: [`Cannot resolve nested preset "${resolved.presetRef}" \u2014 no loader provided`]
|
|
3408
3361
|
};
|
|
3409
3362
|
}
|
|
@@ -3411,13 +3364,13 @@ async function applyItemImpl(presetRef, item, inputs, opts, depth, pinPolicy, it
|
|
|
3411
3364
|
if (!nestedData) {
|
|
3412
3365
|
return {
|
|
3413
3366
|
instances: [],
|
|
3414
|
-
|
|
3367
|
+
assignments: [],
|
|
3415
3368
|
errors: [`Nested preset "${resolved.presetRef}" not found`]
|
|
3416
3369
|
};
|
|
3417
3370
|
}
|
|
3418
3371
|
const parseResult = parsePreset(nestedData);
|
|
3419
3372
|
if (!parseResult.ok || !parseResult.preset) {
|
|
3420
|
-
return { instances: [],
|
|
3373
|
+
return { instances: [], assignments: [], errors: parseResult.errors };
|
|
3421
3374
|
}
|
|
3422
3375
|
const nestedInputs = {
|
|
3423
3376
|
...item.inputs ?? {},
|
|
@@ -3429,7 +3382,7 @@ async function applyItemImpl(presetRef, item, inputs, opts, depth, pinPolicy, it
|
|
|
3429
3382
|
});
|
|
3430
3383
|
return {
|
|
3431
3384
|
instances: nestedResult.instances,
|
|
3432
|
-
|
|
3385
|
+
assignments: nestedResult.assignments,
|
|
3433
3386
|
errors: nestedResult.errors
|
|
3434
3387
|
};
|
|
3435
3388
|
}
|
|
@@ -3442,12 +3395,12 @@ async function applyItemImpl(presetRef, item, inputs, opts, depth, pinPolicy, it
|
|
|
3442
3395
|
const secretPhs = item.placeholders.filter((ph) => isSecretPlaceholder(ph));
|
|
3443
3396
|
const validation = validateAllPlaceholders(nonSecretPhs, itemInputs);
|
|
3444
3397
|
if (!validation.valid) {
|
|
3445
|
-
return { instances: [],
|
|
3398
|
+
return { instances: [], assignments: [], errors: validation.errors };
|
|
3446
3399
|
}
|
|
3447
3400
|
validatedValues = validation.values;
|
|
3448
3401
|
const secretValidation = validateAllPlaceholders(secretPhs, itemInputs);
|
|
3449
3402
|
if (!secretValidation.valid) {
|
|
3450
|
-
return { instances: [],
|
|
3403
|
+
return { instances: [], assignments: [], errors: secretValidation.errors };
|
|
3451
3404
|
}
|
|
3452
3405
|
for (const [key, value] of Object.entries(secretValidation.values)) {
|
|
3453
3406
|
secretValues[key] = String(value);
|
|
@@ -3470,7 +3423,7 @@ async function applyItemImpl(presetRef, item, inputs, opts, depth, pinPolicy, it
|
|
|
3470
3423
|
} catch (err) {
|
|
3471
3424
|
return {
|
|
3472
3425
|
instances: [],
|
|
3473
|
-
|
|
3426
|
+
assignments: [],
|
|
3474
3427
|
errors: [
|
|
3475
3428
|
`Secret storage failed for "${item.ref}": ${err instanceof Error ? err.message : String(err)}`
|
|
3476
3429
|
]
|
|
@@ -3485,17 +3438,17 @@ async function applyItemImpl(presetRef, item, inputs, opts, depth, pinPolicy, it
|
|
|
3485
3438
|
credentialRef: interpolated.credentialRef,
|
|
3486
3439
|
createdBy: opts.createdBy ?? `preset:${presetRef}`
|
|
3487
3440
|
});
|
|
3488
|
-
const
|
|
3441
|
+
const assignments2 = [];
|
|
3489
3442
|
try {
|
|
3490
|
-
const
|
|
3491
|
-
|
|
3443
|
+
const asgn = await library.assign(opts.workspaceId, instance.id, pinPolicy);
|
|
3444
|
+
assignments2.push(asgn);
|
|
3492
3445
|
} catch {
|
|
3493
3446
|
}
|
|
3494
|
-
return { instances: [instance],
|
|
3447
|
+
return { instances: [instance], assignments: assignments2, errors: [] };
|
|
3495
3448
|
} catch (err) {
|
|
3496
3449
|
return {
|
|
3497
3450
|
instances: [],
|
|
3498
|
-
|
|
3451
|
+
assignments: [],
|
|
3499
3452
|
errors: [
|
|
3500
3453
|
`Instance creation failed for "${item.ref}": ${err instanceof Error ? err.message : String(err)}`
|
|
3501
3454
|
]
|
|
@@ -3614,6 +3567,6 @@ function deepEqual(a, b) {
|
|
|
3614
3567
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
3615
3568
|
}
|
|
3616
3569
|
|
|
3617
|
-
export { CatalogCache, CatalogConfigSchema, CatalogHttpError,
|
|
3618
|
-
//# sourceMappingURL=chunk-
|
|
3619
|
-
//# sourceMappingURL=chunk-
|
|
3570
|
+
export { AssignmentNotFoundError, CatalogCache, CatalogConfigSchema, CatalogHttpError, DuplicateAssignmentError, DuplicateLibraryNameError, GitSyncDriver, InstanceHasConsumersError, InstanceNotFoundError, InterpolationError, KNOWN_ASSET_KINDS, KnowledgeManifestSchema, LIBRARY_BACKENDS, LIBRARY_OWNERSHIPS, LIBRARY_STRUCTURES, LOCAL_CATALOG_URL, LibraryConfigSchema, LibraryError, LibraryInstanceRefSchema, LibraryManager, LibrarySectionSchema, LibrarySyncError, LocalCatalogSource, LocalIndex, LocalSyncDriver, LockAssignmentSchema, LockFileSchema, OfflineError, OperationNotPermittedError, PIN_POLICIES, PinPolicySchema, PresetAppliedSchema, PresetExpandedSchema, RemoteCatalogSource, RequiresEdgeSchema, RestCatalogSource, SidecarGit, SkaileConfigSchema, SourceNotFoundError, TarballHashMismatchError, UserLibraryNotFoundError, WorkspaceConfigV2Schema, applyNonStructuralUpgrade, applyPreset, applyPresetFromData, classifyRef, createEmptyLockFile, deriveSlug, detectChanges, detectNestedPresetRefs, detectWorkspaceVersion, evaluateUpgrade, extractLibraryInstanceId, extractReferencedKeys, filterKey, getConfigDefaults, getDefaultValue, getSidecarRoot, getStoreManifestsDir, getStoreRoot, hasInterpolationTokens, interpolate, isLocalCatalogUrl, isSecretPlaceholder, knowledgeKindProvider, listSidecarSlugsOnDisk, loadLockFile, loadWorkspaceV2, migrateSidecarsToStoreIfNeeded, migrateWorkspaceConfig, parsePreset, parsePresetYaml, parseWorkspaceV2, projectConfigPath, queryInstancePickerChoices, resolveAllItems, resolveConfig, resolveIndexPath, resolveItem, resolveLibraryDir, resolvePin, resolveSidecarPaths, saveConfig, saveLockFile, saveWorkspaceV2, sha256Hex, skaileHomeDir, storeSecrets, trpcGetUrl, userConfigPath, validateAllPlaceholders, validateKnowledge, validateNestingDepth, validatePlaceholder, writeManifestIfMissing };
|
|
3571
|
+
//# sourceMappingURL=chunk-MIH45XPY.js.map
|
|
3572
|
+
//# sourceMappingURL=chunk-MIH45XPY.js.map
|