@jini-ai/db 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/LICENSE.pglite-socket +176 -0
- package/NOTICE.md +27 -0
- package/README.md +210 -0
- package/dist/core/artifact-naming.d.ts +34 -0
- package/dist/core/artifact-naming.js +34 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.js +10 -0
- package/dist/core/messages.d.ts +43 -0
- package/dist/core/messages.js +26 -0
- package/dist/core/pg-types.d.ts +22 -0
- package/dist/core/pg-types.js +26 -0
- package/dist/core/ports.d.ts +70 -0
- package/dist/core/ports.js +22 -0
- package/dist/core/row-values.d.ts +32 -0
- package/dist/core/row-values.js +42 -0
- package/dist/core/socket.d.ts +8 -0
- package/dist/core/socket.js +8 -0
- package/dist/kernel/dialect.d.ts +83 -0
- package/dist/kernel/dialect.js +191 -0
- package/dist/kernel/index.d.ts +15 -0
- package/dist/kernel/index.js +15 -0
- package/dist/kernel/kernel-core.d.ts +43 -0
- package/dist/kernel/kernel-core.js +98 -0
- package/dist/kernel/ops.d.ts +48 -0
- package/dist/kernel/ops.js +49 -0
- package/dist/kernel/pg-types.d.ts +22 -0
- package/dist/kernel/pg-types.js +26 -0
- package/dist/kernel/pglite/dialect.d.ts +11 -0
- package/dist/kernel/pglite/dialect.js +88 -0
- package/dist/kernel/pglite/driver.d.ts +30 -0
- package/dist/kernel/pglite/driver.js +47 -0
- package/dist/kernel/pglite/index.d.ts +5 -0
- package/dist/kernel/pglite/index.js +5 -0
- package/dist/kernel/pglite/ops.d.ts +39 -0
- package/dist/kernel/pglite/ops.js +78 -0
- package/dist/kernel/port.d.ts +82 -0
- package/dist/kernel/port.js +11 -0
- package/dist/kernel/postgres/driver.d.ts +23 -0
- package/dist/kernel/postgres/driver.js +42 -0
- package/dist/kernel/postgres/index.d.ts +5 -0
- package/dist/kernel/postgres/index.js +5 -0
- package/dist/kernel/postgres/ops.d.ts +12 -0
- package/dist/kernel/postgres/ops.js +46 -0
- package/dist/kernel/postgres/pglite-socket.d.ts +23 -0
- package/dist/kernel/postgres/pglite-socket.js +52 -0
- package/dist/kernel/postgres-lock.d.ts +8 -0
- package/dist/kernel/postgres-lock.js +10 -0
- package/dist/kernel/schema-scope.d.ts +14 -0
- package/dist/kernel/schema-scope.js +20 -0
- package/dist/kernel/schema-shape.d.ts +26 -0
- package/dist/kernel/schema-shape.js +83 -0
- package/dist/kernel/socket.d.ts +8 -0
- package/dist/kernel/socket.js +8 -0
- package/dist/kernel/sqlite/driver.d.ts +71 -0
- package/dist/kernel/sqlite/driver.js +132 -0
- package/dist/kernel/sqlite/index.d.ts +4 -0
- package/dist/kernel/sqlite/index.js +4 -0
- package/dist/kernel/sqlite/ops.d.ts +12 -0
- package/dist/kernel/sqlite/ops.js +40 -0
- package/dist/kernel/store-copy.d.ts +82 -0
- package/dist/kernel/store-copy.js +240 -0
- package/dist/kernel/turn-lock.d.ts +21 -0
- package/dist/kernel/turn-lock.js +42 -0
- package/dist/kernel/typegen.d.ts +13 -0
- package/dist/kernel/typegen.js +76 -0
- package/dist/migrate/checksum.d.ts +11 -0
- package/dist/migrate/checksum.js +14 -0
- package/dist/migrate/index.d.ts +8 -0
- package/dist/migrate/index.js +8 -0
- package/dist/migrate/runner.d.ts +33 -0
- package/dist/migrate/runner.js +126 -0
- package/dist/migrate/step.d.ts +37 -0
- package/dist/migrate/step.js +31 -0
- package/dist/pglite/dialect.d.ts +11 -0
- package/dist/pglite/dialect.js +88 -0
- package/dist/pglite/driver.d.ts +30 -0
- package/dist/pglite/driver.js +46 -0
- package/dist/pglite/index.d.ts +5 -0
- package/dist/pglite/index.js +4 -0
- package/dist/pglite/ops.d.ts +39 -0
- package/dist/pglite/ops.js +78 -0
- package/dist/pglite/owner.d.ts +107 -0
- package/dist/pglite/owner.js +359 -0
- package/dist/pglite/socket-server.d.ts +38 -0
- package/dist/pglite/socket-server.js +375 -0
- package/dist/pglite/types.d.ts +9 -0
- package/dist/pglite/types.js +2 -0
- package/dist/postgres/driver.d.ts +23 -0
- package/dist/postgres/driver.js +41 -0
- package/dist/postgres/index.d.ts +3 -0
- package/dist/postgres/index.js +3 -0
- package/dist/postgres/ops.d.ts +12 -0
- package/dist/postgres/ops.js +46 -0
- package/dist/postgres/pglite-socket.d.ts +23 -0
- package/dist/postgres/pglite-socket.js +51 -0
- package/dist/postgres/types.d.ts +53 -0
- package/dist/postgres/types.js +14 -0
- package/dist/sqlite/db-ops.d.ts +59 -0
- package/dist/sqlite/db-ops.js +82 -0
- package/dist/sqlite/driver.d.ts +71 -0
- package/dist/sqlite/driver.js +132 -0
- package/dist/sqlite/index.d.ts +9 -0
- package/dist/sqlite/index.js +4 -0
- package/dist/sqlite/inspect.d.ts +60 -0
- package/dist/sqlite/inspect.js +153 -0
- package/dist/sqlite/open.d.ts +58 -0
- package/dist/sqlite/open.js +43 -0
- package/dist/sqlite/ops.d.ts +12 -0
- package/dist/sqlite/ops.js +40 -0
- package/dist/sqlite/restore-types.d.ts +42 -0
- package/dist/sqlite/restore-types.js +2 -0
- package/dist/sqlite/sync-types.d.ts +34 -0
- package/dist/sqlite/sync-types.js +2 -0
- package/dist/sqlite/types.d.ts +37 -0
- package/dist/sqlite/types.js +8 -0
- package/dist/tools/database-catalog.d.ts +61 -0
- package/dist/tools/database-catalog.js +201 -0
- package/dist/tools/destination-port.d.ts +27 -0
- package/dist/tools/destination-port.js +2 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.js +11 -0
- package/dist/tools/plan-store.d.ts +61 -0
- package/dist/tools/plan-store.js +39 -0
- package/dist/tools/read-tools.d.ts +53 -0
- package/dist/tools/read-tools.js +97 -0
- package/dist/tools/registration.d.ts +18 -0
- package/dist/tools/registration.js +10 -0
- package/dist/tools/restore-points.d.ts +125 -0
- package/dist/tools/restore-points.js +54 -0
- package/dist/tools/surface-port.d.ts +43 -0
- package/dist/tools/surface-port.js +2 -0
- package/dist/tools/timeline.d.ts +63 -0
- package/dist/tools/timeline.js +46 -0
- package/dist/tools/transfer-catalog.d.ts +25 -0
- package/dist/tools/transfer-catalog.js +59 -0
- package/dist/tools/transfer-tools.d.ts +82 -0
- package/dist/tools/transfer-tools.js +346 -0
- package/dist/transfer/copy-engine.d.ts +129 -0
- package/dist/transfer/copy-engine.js +233 -0
- package/dist/transfer/index.d.ts +9 -0
- package/dist/transfer/index.js +9 -0
- package/dist/transfer/internal-ddl.d.ts +23 -0
- package/dist/transfer/internal-ddl.js +119 -0
- package/dist/transfer/plan.d.ts +28 -0
- package/dist/transfer/plan.js +19 -0
- package/dist/transfer/postgres-ddl.d.ts +36 -0
- package/dist/transfer/postgres-ddl.js +16 -0
- package/dist/transfer/postgres-target.d.ts +65 -0
- package/dist/transfer/postgres-target.js +95 -0
- package/dist/transfer/sqlite-source.d.ts +78 -0
- package/dist/transfer/sqlite-source.js +79 -0
- package/dist/transfer/table-catalog.d.ts +44 -0
- package/dist/transfer/table-catalog.js +109 -0
- package/dist/transfer/types.d.ts +47 -0
- package/dist/transfer/types.js +2 -0
- package/package.json +184 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
const DEFAULT_PLAN_TTL_MS = 10 * 60 * 1000;
|
|
3
|
+
/** Each plan holds a whole database snapshot, so only a couple are kept. */
|
|
4
|
+
const DEFAULT_MAX_PLANS = 2;
|
|
5
|
+
export class DatabaseTransferPlanStore {
|
|
6
|
+
plans = new Map();
|
|
7
|
+
now;
|
|
8
|
+
constructor(_required = {}, optional = {}) {
|
|
9
|
+
this.now = optional.now ?? Date.now;
|
|
10
|
+
}
|
|
11
|
+
/** @complexity O(plans held), at most {@link DEFAULT_MAX_PLANS}. */
|
|
12
|
+
save(input, _optional = {}) {
|
|
13
|
+
const nowMs = this.now();
|
|
14
|
+
for (const [id, plan] of this.plans) {
|
|
15
|
+
if (plan.expiresAtMs <= nowMs)
|
|
16
|
+
this.plans.delete(id);
|
|
17
|
+
}
|
|
18
|
+
while (this.plans.size >= DEFAULT_MAX_PLANS) {
|
|
19
|
+
const oldest = this.plans.keys().next().value;
|
|
20
|
+
if (oldest === undefined)
|
|
21
|
+
break;
|
|
22
|
+
this.plans.delete(oldest);
|
|
23
|
+
}
|
|
24
|
+
const plan = { ...input.content, planId: randomUUID(), principalId: input.principalId, workspaceId: input.workspaceId, expiresAtMs: nowMs + DEFAULT_PLAN_TTL_MS };
|
|
25
|
+
this.plans.set(plan.planId, plan);
|
|
26
|
+
return plan;
|
|
27
|
+
}
|
|
28
|
+
/** Single-use: a taken plan is gone whether or not it is still valid. */
|
|
29
|
+
take(input, _optional = {}) {
|
|
30
|
+
const plan = this.plans.get(input.planId);
|
|
31
|
+
if (!plan || plan.principalId !== input.principalId || plan.workspaceId !== input.workspaceId)
|
|
32
|
+
return { ok: false, code: "PLAN_NOT_FOUND" };
|
|
33
|
+
this.plans.delete(input.planId);
|
|
34
|
+
if (plan.expiresAtMs <= this.now())
|
|
35
|
+
return { ok: false, code: "PLAN_EXPIRED" };
|
|
36
|
+
return { ok: true, plan };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=plan-store.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Portable DB read/restore-point handlers; migration gateways stay host-owned. See docs/decisions/DR-001-bounded-operational-timeline.md. */
|
|
2
|
+
import { type ToolRegistration } from "@jini-ai/core";
|
|
3
|
+
import { type Clock } from "@jini-ai/core/primitives";
|
|
4
|
+
import { type DbMessages } from "../core/messages.js";
|
|
5
|
+
import { type LedgerReadPort } from "./timeline.js";
|
|
6
|
+
import { type RestorePointListPort, type RestorePointSavePort } from "./restore-points.js";
|
|
7
|
+
import { type InputReaders } from "./registration.js";
|
|
8
|
+
export interface DatabasePermissionRequest {
|
|
9
|
+
principalId: string;
|
|
10
|
+
permission: string;
|
|
11
|
+
entityType: string;
|
|
12
|
+
}
|
|
13
|
+
export interface DatabaseReadToolPorts {
|
|
14
|
+
workspaceId: string;
|
|
15
|
+
readers: InputReaders;
|
|
16
|
+
requirePermission(request: DatabasePermissionRequest): Promise<void>;
|
|
17
|
+
introspection: {
|
|
18
|
+
getHealth(): Promise<unknown>;
|
|
19
|
+
getSchemaState(): Promise<unknown>;
|
|
20
|
+
listPendingMigrations(): Promise<unknown>;
|
|
21
|
+
};
|
|
22
|
+
ledger: LedgerReadPort;
|
|
23
|
+
restorePoints: RestorePointListPort & RestorePointSavePort;
|
|
24
|
+
dbOps: {
|
|
25
|
+
getCapabilities(): Promise<{
|
|
26
|
+
restorePoint: {
|
|
27
|
+
costClass: "cheap" | "expensive" | "unavailable";
|
|
28
|
+
kind: string;
|
|
29
|
+
};
|
|
30
|
+
}>;
|
|
31
|
+
captureRestorePoint(input: {
|
|
32
|
+
scopeId: string;
|
|
33
|
+
}): Promise<{
|
|
34
|
+
artifactRef: string;
|
|
35
|
+
watermarkAtCapture: number;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
clock: Clock;
|
|
39
|
+
idGen: {
|
|
40
|
+
newId(): string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Binds six authorized read/restore-point handlers and their host-facing catalog copy.
|
|
45
|
+
* @param ports Host effects; construction performs no I/O and retains the ports by reference.
|
|
46
|
+
* @param _optional.messages Catalog and unavailable-capture prose; defaults to neutral copy.
|
|
47
|
+
* @returns Registrations; permission, cost and capture failures propagate from handler execution.
|
|
48
|
+
* @complexity O(1) fixed registrations and space, plus message text length.
|
|
49
|
+
*/
|
|
50
|
+
export declare function createDatabaseReadTools(ports: DatabaseReadToolPorts, _optional?: {
|
|
51
|
+
messages?: DbMessages;
|
|
52
|
+
}): ToolRegistration[];
|
|
53
|
+
//# sourceMappingURL=read-tools.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** Portable DB read/restore-point handlers; migration gateways stay host-owned. See docs/decisions/DR-001-bounded-operational-timeline.md. */
|
|
2
|
+
import { ToolInputError } from "@jini-ai/core";
|
|
3
|
+
import { nowIso } from "@jini-ai/core/primitives";
|
|
4
|
+
import { defaultDbMessages } from "../core/messages.js";
|
|
5
|
+
import { getDatabaseAgentToolCatalog } from "./database-catalog.js";
|
|
6
|
+
import { getTimeline } from "./timeline.js";
|
|
7
|
+
import { createRestorePoint as createDatabaseRestorePoint, listRestorePoints } from "./restore-points.js";
|
|
8
|
+
import { registrations } from "./registration.js";
|
|
9
|
+
/**
|
|
10
|
+
* Binds six authorized read/restore-point handlers and their host-facing catalog copy.
|
|
11
|
+
* @param ports Host effects; construction performs no I/O and retains the ports by reference.
|
|
12
|
+
* @param _optional.messages Catalog and unavailable-capture prose; defaults to neutral copy.
|
|
13
|
+
* @returns Registrations; permission, cost and capture failures propagate from handler execution.
|
|
14
|
+
* @complexity O(1) fixed registrations and space, plus message text length.
|
|
15
|
+
*/
|
|
16
|
+
export function createDatabaseReadTools(ports, _optional = {}) {
|
|
17
|
+
const messages = _optional.messages ?? defaultDbMessages;
|
|
18
|
+
const { noInput: requireNoInput, isRecord, optionalString, optionalNumber, optionalBoolean } = ports.readers;
|
|
19
|
+
const handlers = {
|
|
20
|
+
database_query_timeline: async (ctx) => {
|
|
21
|
+
if (ctx.input !== undefined && !isRecord(ctx.input))
|
|
22
|
+
throw new ToolInputError({ message: "input must be an object" });
|
|
23
|
+
const input = isRecord(ctx.input) ? ctx.input : {};
|
|
24
|
+
await ports.requirePermission({ principalId: ctx.principal.id, permission: "database.read", entityType: "database-ledger" });
|
|
25
|
+
return getTimeline({
|
|
26
|
+
ledger: ports.ledger,
|
|
27
|
+
filter: {
|
|
28
|
+
kind: optionalString(input, "kind"),
|
|
29
|
+
outcome: optionalString(input, "outcome"),
|
|
30
|
+
fromDate: optionalString(input, "fromDate"),
|
|
31
|
+
toDate: optionalString(input, "toDate"),
|
|
32
|
+
cursor: optionalString(input, "cursor"),
|
|
33
|
+
limit: optionalNumber(input, "limit"),
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
database_list_restore_points: async (ctx) => {
|
|
38
|
+
requireNoInput(ctx.input);
|
|
39
|
+
await ports.requirePermission({ principalId: ctx.principal.id, permission: "database.read", entityType: "restore-point" });
|
|
40
|
+
return listRestorePoints({ repo: ports.restorePoints });
|
|
41
|
+
},
|
|
42
|
+
database_get_health: async (ctx) => {
|
|
43
|
+
requireNoInput(ctx.input);
|
|
44
|
+
await ports.requirePermission({ principalId: ctx.principal.id, permission: "database.read", entityType: "database" });
|
|
45
|
+
return ports.introspection.getHealth();
|
|
46
|
+
},
|
|
47
|
+
database_get_schema_state: async (ctx) => {
|
|
48
|
+
requireNoInput(ctx.input);
|
|
49
|
+
await ports.requirePermission({ principalId: ctx.principal.id, permission: "database.read", entityType: "database" });
|
|
50
|
+
return ports.introspection.getSchemaState();
|
|
51
|
+
},
|
|
52
|
+
database_list_pending_migrations: async (ctx) => {
|
|
53
|
+
requireNoInput(ctx.input);
|
|
54
|
+
await ports.requirePermission({ principalId: ctx.principal.id, permission: "database.read", entityType: "database" });
|
|
55
|
+
return ports.introspection.listPendingMigrations();
|
|
56
|
+
},
|
|
57
|
+
backup_create_restore_point: async (ctx) => {
|
|
58
|
+
if (ctx.input !== undefined && !isRecord(ctx.input))
|
|
59
|
+
throw new ToolInputError({ message: "input must be an object" });
|
|
60
|
+
const input = isRecord(ctx.input) ? ctx.input : {};
|
|
61
|
+
const costAck = optionalBoolean(input, "costAck");
|
|
62
|
+
// `createRestorePoint` (restore-points.ts) has no authorize() call of its own — the real HTTP
|
|
63
|
+
// route (`routes/admin/database/restore-points.ts`) authorizes inline before calling it, so
|
|
64
|
+
// this handler does the identical inline check.
|
|
65
|
+
await ports.requirePermission({ principalId: ctx.principal.id, permission: "backup.create", entityType: "restore-point" });
|
|
66
|
+
const capabilities = await ports.dbOps.getCapabilities();
|
|
67
|
+
let captured;
|
|
68
|
+
const summary = await createDatabaseRestorePoint({
|
|
69
|
+
costClass: capabilities.restorePoint.costClass,
|
|
70
|
+
costAck: costAck ?? false,
|
|
71
|
+
capture: async () => {
|
|
72
|
+
captured = await ports.dbOps.captureRestorePoint({ scopeId: ports.workspaceId });
|
|
73
|
+
return captured;
|
|
74
|
+
},
|
|
75
|
+
}, { messages });
|
|
76
|
+
await ports.restorePoints.save({
|
|
77
|
+
restorePointId: summary.id,
|
|
78
|
+
idempotencyKey: ports.idGen.newId(),
|
|
79
|
+
// Always 'manual' — an agent call is never the system's own pre-migration/template-upgrade
|
|
80
|
+
// auto-snapshot, regardless of what a caller might ask for, so provenance in the ledger can
|
|
81
|
+
// never be mislabeled (see `features/database/agent-tools.ts`'s own schema comment).
|
|
82
|
+
trigger: "manual",
|
|
83
|
+
createdAt: nowIso({ clock: ports.clock }),
|
|
84
|
+
createdBy: ctx.principal.id,
|
|
85
|
+
costClass: summary.costClass,
|
|
86
|
+
kind: summary.kind,
|
|
87
|
+
watermarkAtCapture: captured?.watermarkAtCapture ?? null,
|
|
88
|
+
artifactRef: captured?.artifactRef,
|
|
89
|
+
});
|
|
90
|
+
return { restorePoint: summary };
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
// Classified from the lifted handlers: five repository reads and one capture + persisted record.
|
|
94
|
+
const risks = new Map(Object.keys(handlers).map(id => [id, id === "backup_create_restore_point" ? "mutates-durable-state" : "none"]));
|
|
95
|
+
return registrations({ catalog: getDatabaseAgentToolCatalog({}, { messages }), handlers, risks });
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=read-tools.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Tool registration contracts; the host retains its independent derived-risk tripwire. */
|
|
2
|
+
import type { AgentToolDefinition, ToolHandler, ToolRegistration } from "@jini-ai/core";
|
|
3
|
+
export interface InputReaders {
|
|
4
|
+
inputRecord(input: unknown): Record<string, unknown>;
|
|
5
|
+
string(input: Record<string, unknown>, key: string): string;
|
|
6
|
+
noInput(input: unknown): void;
|
|
7
|
+
isRecord(input: unknown): input is Record<string, unknown>;
|
|
8
|
+
optionalString(input: Record<string, unknown>, key: string): string | undefined;
|
|
9
|
+
optionalNumber(input: Record<string, unknown>, key: string): number | undefined;
|
|
10
|
+
optionalBoolean(input: Record<string, unknown>, key: string): boolean | undefined;
|
|
11
|
+
}
|
|
12
|
+
/** Descriptors keep the catalog bytes. Read-only follows the supplied independently classified handler map. */
|
|
13
|
+
export declare function registrations({ catalog, handlers, risks }: {
|
|
14
|
+
catalog: readonly AgentToolDefinition[];
|
|
15
|
+
handlers: Record<string, ToolHandler>;
|
|
16
|
+
risks: ReadonlyMap<string, string>;
|
|
17
|
+
}, _optional?: {}): ToolRegistration[];
|
|
18
|
+
//# sourceMappingURL=registration.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Descriptors keep the catalog bytes. Read-only follows the supplied independently classified handler map. */
|
|
2
|
+
export function registrations({ catalog, handlers, risks }, _optional = {}) {
|
|
3
|
+
return Object.entries(handlers).map(([id, handler]) => {
|
|
4
|
+
const entry = catalog.find(entry => entry.name === id);
|
|
5
|
+
if (!entry?.inputSchema || risks.get(id) !== entry.sideEffects)
|
|
6
|
+
throw new Error(`database tool contract/risk mismatch: ${id}`);
|
|
7
|
+
return { descriptor: { id, description: entry.description, inputSchema: entry.inputSchema, readOnly: risks.get(id) === "none" }, handler, policy: { authorize: () => "allow" } };
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=registration.js.map
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { type DbMessages } from "../core/messages.js";
|
|
2
|
+
/**
|
|
3
|
+
* @file `backup_create_restore_point`.
|
|
4
|
+
*
|
|
5
|
+
* Purpose:
|
|
6
|
+
* Mints a restore point independent of any migration, subject to the same cost-acknowledgment
|
|
7
|
+
* discipline `db-ops.getCapabilities` requires everywhere restore points are taken: `cheap`
|
|
8
|
+
* mints freely, `expensive` requires an explicit `costAck`, `unavailable` refuses outright with no
|
|
9
|
+
* override ("no attestation override").
|
|
10
|
+
*
|
|
11
|
+
* How it relates to the project:
|
|
12
|
+
* `capture` is injected so this module never touches a dialect adapter directly — the caller
|
|
13
|
+
* (the `db-ops` SQLite/Postgres adapter) performs the actual online-backup/`pg_dump` and reports
|
|
14
|
+
* back `{artifactRef, watermarkAtCapture}`; this module owns only the cost-gate decision and the
|
|
15
|
+
* resulting `restore_points` summary shape.
|
|
16
|
+
*
|
|
17
|
+
* Architectural role:
|
|
18
|
+
* `features/database` domain logic. Depends only on the injected `capture` callback.
|
|
19
|
+
* See docs/decisions/DR-002-restore-point-precondition.md.
|
|
20
|
+
*/
|
|
21
|
+
export type RestorePointCostClass = "cheap" | "expensive" | "unavailable";
|
|
22
|
+
/** Thrown when an `expensive` restore point is requested without an explicit cost acknowledgment. */
|
|
23
|
+
export declare class ValidationError extends Error {
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
/** Thrown when a restore point is requested on a site whose `db-ops` adapter reports `costClass: 'unavailable'`. */
|
|
27
|
+
export declare class RestorePointUnavailableError extends Error {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
export interface RestorePointSummary {
|
|
31
|
+
id: string;
|
|
32
|
+
costClass: RestorePointCostClass;
|
|
33
|
+
kind: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Mints a restore point, gated on cost acknowledgment.
|
|
37
|
+
* @param _optional.messages Replaces the unavailable-refusal prose without changing the cost gate.
|
|
38
|
+
* @throws RestorePointUnavailableError or ValidationError before capture; capture errors propagate.
|
|
39
|
+
*
|
|
40
|
+
* @complexity O(1) plus one `capture()` call (the adapter owns the actual snapshot cost).
|
|
41
|
+
* @overallScore 100
|
|
42
|
+
*/
|
|
43
|
+
export declare function createRestorePoint(required: {
|
|
44
|
+
costClass: RestorePointCostClass;
|
|
45
|
+
costAck?: boolean;
|
|
46
|
+
capture: () => Promise<{
|
|
47
|
+
artifactRef: string;
|
|
48
|
+
watermarkAtCapture: number;
|
|
49
|
+
}>;
|
|
50
|
+
}, _optional?: {
|
|
51
|
+
messages?: Pick<DbMessages, "restorePointUnavailable">;
|
|
52
|
+
}): Promise<RestorePointSummary>;
|
|
53
|
+
/**
|
|
54
|
+
* Admin-UI backend-gap closure (design-spec.md §3.8/§4.8) — the `restore_points` table's missing
|
|
55
|
+
* read side, added alongside `createRestorePoint` above without changing that certified function's
|
|
56
|
+
* behavior or contract.
|
|
57
|
+
*/
|
|
58
|
+
/** One persisted `restore_points` row, as rendered to the Database/Recovery restore-points list
|
|
59
|
+
* (design-spec.md §3.2/§4.2's shared column set). */
|
|
60
|
+
export interface RestorePointRecord {
|
|
61
|
+
id: string;
|
|
62
|
+
trigger: string;
|
|
63
|
+
costClass: string;
|
|
64
|
+
kind: string;
|
|
65
|
+
watermarkAtCapture: number | null;
|
|
66
|
+
createdAt: string;
|
|
67
|
+
/** 2026-07-16: was captured (`DbOpsPort.captureRestorePoint()`) but silently dropped before
|
|
68
|
+
* persistence — `list()` never surfaced it, so `features/recovery`'s restore ceremony had no
|
|
69
|
+
* way to know which file to restore from (see `features/recovery/gated-hooks.ts`'s
|
|
70
|
+
* `buildRestoreHooks` file history). Required, not optional: every real row has one (the
|
|
71
|
+
* `restore_points` table's own column is `NOT NULL`); an empty string for a not-yet-migrated
|
|
72
|
+
* legacy row is a defensive fallback at the read adapter, not a valid new-row state. */
|
|
73
|
+
artifactRef: string;
|
|
74
|
+
}
|
|
75
|
+
export interface RestorePointListPort {
|
|
76
|
+
list(): Promise<RestorePointRecord[]>;
|
|
77
|
+
}
|
|
78
|
+
/** Widens `recovery/restore-points.ts`'s `CreateRestorePointRepoPort.save()` shape with the
|
|
79
|
+
* optional descriptive fields `routes/admin/database/restore-points.ts`'s create route persists
|
|
80
|
+
* (the real `SqliteRestorePointsRepo.save()` already accepts all of these; this port just names
|
|
81
|
+
* the subset a route composing `database/restore-points.ts`'s `createRestorePoint` needs). Declared
|
|
82
|
+
* independently rather than importing/extending `CreateRestorePointRepoPort` so this file keeps
|
|
83
|
+
* `features/recovery` at arm's length (the same "no shared import, kept decoupled" convention
|
|
84
|
+
* this package's own `write-service.ts`-adjacent files already use). */
|
|
85
|
+
export interface RestorePointSavePort {
|
|
86
|
+
save(row: {
|
|
87
|
+
restorePointId: string;
|
|
88
|
+
idempotencyKey: string;
|
|
89
|
+
trigger: string;
|
|
90
|
+
createdAt: string;
|
|
91
|
+
createdBy: string;
|
|
92
|
+
costClass?: string;
|
|
93
|
+
kind?: string;
|
|
94
|
+
watermarkAtCapture?: number | null;
|
|
95
|
+
artifactRef?: string | undefined;
|
|
96
|
+
}): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
/** Same narrow shape as `recovery/restore-points.ts`'s `CreateRestorePointRepoPort.findByIdempotencyKey`
|
|
99
|
+
* ( `(site_id, idempotency_key)` lookup), declared independently here for the identical
|
|
100
|
+
* "keep `features/recovery` at arm's length" reason `RestorePointSavePort` above documents. Both
|
|
101
|
+
* concrete repos backing this route (`SqliteRestorePointsRepo`, `InMemoryRestorePointsRepo`) already
|
|
102
|
+
* implement this method; only the route's own dependency type was narrower.
|
|
103
|
+
* See docs/decisions/DR-002-restore-point-precondition.md.
|
|
104
|
+
*/
|
|
105
|
+
export interface RestorePointIdempotencyLookupPort {
|
|
106
|
+
findByIdempotencyKey(key: string): Promise<{
|
|
107
|
+
restorePointId: string;
|
|
108
|
+
idempotencyKey: string;
|
|
109
|
+
} | null>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Lists every restore point recorded for this site, newest-first (the port's own contract —
|
|
113
|
+
* `db/sqlite/database-journal-repo.ts`'s `SqliteRestorePointsRepo.list()` already orders this
|
|
114
|
+
* way; this function does not re-sort, matching `getTimeline`'s "the port owns the actual query
|
|
115
|
+
* shape" precedent).
|
|
116
|
+
*
|
|
117
|
+
* @complexity O(1) plus one `RestorePointListPort.list()` call.
|
|
118
|
+
* @overallScore 100
|
|
119
|
+
*/
|
|
120
|
+
export declare function listRestorePoints(required: {
|
|
121
|
+
repo: RestorePointListPort;
|
|
122
|
+
}, _optional?: Record<string, never>): Promise<{
|
|
123
|
+
items: RestorePointRecord[];
|
|
124
|
+
}>;
|
|
125
|
+
//# sourceMappingURL=restore-points.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { defaultDbMessages } from "../core/messages.js";
|
|
3
|
+
/** Thrown when an `expensive` restore point is requested without an explicit cost acknowledgment. */
|
|
4
|
+
export class ValidationError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "ValidationError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Thrown when a restore point is requested on a site whose `db-ops` adapter reports `costClass: 'unavailable'`. */
|
|
11
|
+
export class RestorePointUnavailableError extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "RestorePointUnavailableError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Mints a restore point, gated on cost acknowledgment.
|
|
19
|
+
* @param _optional.messages Replaces the unavailable-refusal prose without changing the cost gate.
|
|
20
|
+
* @throws RestorePointUnavailableError or ValidationError before capture; capture errors propagate.
|
|
21
|
+
*
|
|
22
|
+
* @complexity O(1) plus one `capture()` call (the adapter owns the actual snapshot cost).
|
|
23
|
+
* @overallScore 100
|
|
24
|
+
*/
|
|
25
|
+
export async function createRestorePoint(required, _optional = {}) {
|
|
26
|
+
const { costClass, costAck = false, capture } = required;
|
|
27
|
+
const messages = _optional.messages ?? defaultDbMessages;
|
|
28
|
+
if (costClass === "unavailable") {
|
|
29
|
+
throw new RestorePointUnavailableError(
|
|
30
|
+
// See docs/decisions/DR-002-restore-point-precondition.md for the invariant behind this refusal; keep external identifiers out of caller-facing messages.
|
|
31
|
+
messages.restorePointUnavailable);
|
|
32
|
+
}
|
|
33
|
+
if (costClass === "expensive" && !costAck) {
|
|
34
|
+
throw new ValidationError(
|
|
35
|
+
// See docs/decisions/DR-002-restore-point-precondition.md for the invariant behind this refusal; keep external identifiers out of caller-facing messages.
|
|
36
|
+
"an 'expensive' restore point requires an explicit costAck; the confirmer must acknowledge the cost/disk estimate first");
|
|
37
|
+
}
|
|
38
|
+
await capture();
|
|
39
|
+
return { id: randomUUID(), costClass, kind: "file-snapshot" };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Lists every restore point recorded for this site, newest-first (the port's own contract —
|
|
43
|
+
* `db/sqlite/database-journal-repo.ts`'s `SqliteRestorePointsRepo.list()` already orders this
|
|
44
|
+
* way; this function does not re-sort, matching `getTimeline`'s "the port owns the actual query
|
|
45
|
+
* shape" precedent).
|
|
46
|
+
*
|
|
47
|
+
* @complexity O(1) plus one `RestorePointListPort.list()` call.
|
|
48
|
+
* @overallScore 100
|
|
49
|
+
*/
|
|
50
|
+
export async function listRestorePoints(required, _optional = {}) {
|
|
51
|
+
const items = await required.repo.list();
|
|
52
|
+
return { items };
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=restore-points.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Structural surface protocol: transport, confirmation policy and builders belong to the consumer. */
|
|
2
|
+
import type { SurfaceEmission, SurfaceEmitter } from "@jini-ai/core";
|
|
3
|
+
import type { DatabaseTransferPlan } from "./plan-store.js";
|
|
4
|
+
export type SurfaceMessage = {
|
|
5
|
+
status: "received";
|
|
6
|
+
params: Record<string, unknown>;
|
|
7
|
+
} | {
|
|
8
|
+
status: "expired" | "abandoned";
|
|
9
|
+
};
|
|
10
|
+
export interface SurfaceExchange {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
send(emission: SurfaceEmission): Promise<void>;
|
|
13
|
+
receive(): Promise<SurfaceMessage>;
|
|
14
|
+
close(): void;
|
|
15
|
+
}
|
|
16
|
+
export interface TransferSurfacePorts {
|
|
17
|
+
open(binding: {
|
|
18
|
+
toolId: string;
|
|
19
|
+
principalId: string;
|
|
20
|
+
}, emit: SurfaceEmitter): SurfaceExchange;
|
|
21
|
+
/** Must close the exchange after receiving/classifying a decision, including errors. */
|
|
22
|
+
resolveDecision(exchange: SurfaceExchange, emission: SurfaceEmission): Promise<{
|
|
23
|
+
confirmed: true;
|
|
24
|
+
} | {
|
|
25
|
+
confirmed: false;
|
|
26
|
+
reason: "declined" | "expired" | "abandoned";
|
|
27
|
+
}>;
|
|
28
|
+
/** Must close in finally; outcome-delivery failures cannot replace a settled result. */
|
|
29
|
+
askThenReport<T>(exchange: SurfaceExchange, emission: SurfaceEmission, handle: (answer: SurfaceMessage) => Promise<{
|
|
30
|
+
result: T;
|
|
31
|
+
outcome?: SurfaceEmission;
|
|
32
|
+
}>): Promise<T>;
|
|
33
|
+
confirmation(plan: DatabaseTransferPlan, exchangeId: string): SurfaceEmission;
|
|
34
|
+
destinationForm(exchangeId: string): SurfaceEmission;
|
|
35
|
+
destinationOutcome(input: {
|
|
36
|
+
exchangeId: string;
|
|
37
|
+
state: "failure" | "success";
|
|
38
|
+
message: string;
|
|
39
|
+
}): SurfaceEmission;
|
|
40
|
+
readonly dismissedParam: string;
|
|
41
|
+
readonly addressField: string;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=surface-port.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file the Timeline read
|
|
3
|
+
* model.
|
|
4
|
+
*
|
|
5
|
+
* Purpose:
|
|
6
|
+
* Renders the never-brick ledger (migrations, snapshots, index provisions, template upgrades,
|
|
7
|
+
* restores, interrupted migrations) as a filterable, cursor-paginated read surface. This module
|
|
8
|
+
* is deliberately read-only by construction — no raw-row-edit, SQL-console, or DB-first-mode
|
|
9
|
+
* export may ever exist here; that is a permanent category error against this codebase's
|
|
10
|
+
* write-chokepoint/authorize/append-only-revision model ("Why Database, not Database").
|
|
11
|
+
*
|
|
12
|
+
* How it relates to the project:
|
|
13
|
+
* `LedgerReadPort` is implemented by the sidecar ops-journal adapter; this module
|
|
14
|
+
* has no knowledge of that adapter's database details.
|
|
15
|
+
*
|
|
16
|
+
* Architectural role:
|
|
17
|
+
* `features/database` domain logic. Depends only on the injected `LedgerReadPort`.
|
|
18
|
+
* See docs/decisions/DR-001-bounded-operational-timeline.md.
|
|
19
|
+
*/
|
|
20
|
+
/** One row of the append-only `database_ledger`, as rendered to the Timeline UI. See docs/decisions/DR-001-bounded-operational-timeline.md. */
|
|
21
|
+
export interface LedgerRow {
|
|
22
|
+
id: string;
|
|
23
|
+
kind: string;
|
|
24
|
+
/** ISO-8601 UTC. */
|
|
25
|
+
createdAt: string;
|
|
26
|
+
restorePointId: string | null;
|
|
27
|
+
outcome: string;
|
|
28
|
+
}
|
|
29
|
+
export interface LedgerReadPort {
|
|
30
|
+
query(filter: {
|
|
31
|
+
kind?: string | undefined;
|
|
32
|
+
fromDate?: string | undefined;
|
|
33
|
+
toDate?: string | undefined;
|
|
34
|
+
outcome?: string | undefined;
|
|
35
|
+
cursor?: string | null | undefined;
|
|
36
|
+
limit: number;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
items: LedgerRow[];
|
|
39
|
+
nextCursor: string | null;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns a filtered, cursor-paginated page of the Timeline ledger.
|
|
44
|
+
*
|
|
45
|
+
* @complexity O(1) plus one `LedgerReadPort.query()` call (the port owns the actual scan/index
|
|
46
|
+
* cost).
|
|
47
|
+
* @overallScore 100
|
|
48
|
+
*/
|
|
49
|
+
export declare function getTimeline(required: {
|
|
50
|
+
ledger: LedgerReadPort;
|
|
51
|
+
filter?: {
|
|
52
|
+
kind?: string | undefined;
|
|
53
|
+
fromDate?: string | undefined;
|
|
54
|
+
toDate?: string | undefined;
|
|
55
|
+
outcome?: string | undefined;
|
|
56
|
+
cursor?: string | undefined;
|
|
57
|
+
limit?: number | undefined;
|
|
58
|
+
};
|
|
59
|
+
}, _optional?: Record<string, never>): Promise<{
|
|
60
|
+
items: LedgerRow[];
|
|
61
|
+
nextCursor: string | null;
|
|
62
|
+
}>;
|
|
63
|
+
//# sourceMappingURL=timeline.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file the Timeline read
|
|
3
|
+
* model.
|
|
4
|
+
*
|
|
5
|
+
* Purpose:
|
|
6
|
+
* Renders the never-brick ledger (migrations, snapshots, index provisions, template upgrades,
|
|
7
|
+
* restores, interrupted migrations) as a filterable, cursor-paginated read surface. This module
|
|
8
|
+
* is deliberately read-only by construction — no raw-row-edit, SQL-console, or DB-first-mode
|
|
9
|
+
* export may ever exist here; that is a permanent category error against this codebase's
|
|
10
|
+
* write-chokepoint/authorize/append-only-revision model ("Why Database, not Database").
|
|
11
|
+
*
|
|
12
|
+
* How it relates to the project:
|
|
13
|
+
* `LedgerReadPort` is implemented by the sidecar ops-journal adapter; this module
|
|
14
|
+
* has no knowledge of that adapter's database details.
|
|
15
|
+
*
|
|
16
|
+
* Architectural role:
|
|
17
|
+
* `features/database` domain logic. Depends only on the injected `LedgerReadPort`.
|
|
18
|
+
* See docs/decisions/DR-001-bounded-operational-timeline.md.
|
|
19
|
+
*/
|
|
20
|
+
/** The server-side row cap — no raw/unbounded query surface is ever offered. See docs/decisions/DR-001-bounded-operational-timeline.md. */
|
|
21
|
+
const MAX_TIMELINE_PAGE_SIZE = 200;
|
|
22
|
+
const DEFAULT_TIMELINE_PAGE_SIZE = 50;
|
|
23
|
+
/** Thrown when a caller requests a page size above the server's bound. */
|
|
24
|
+
class TimelineValidationError extends Error {
|
|
25
|
+
constructor(message) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = "TimelineValidationError";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns a filtered, cursor-paginated page of the Timeline ledger.
|
|
32
|
+
*
|
|
33
|
+
* @complexity O(1) plus one `LedgerReadPort.query()` call (the port owns the actual scan/index
|
|
34
|
+
* cost).
|
|
35
|
+
* @overallScore 100
|
|
36
|
+
*/
|
|
37
|
+
export async function getTimeline(required, _optional = {}) {
|
|
38
|
+
const { ledger, filter = {} } = required;
|
|
39
|
+
const limit = filter.limit ?? DEFAULT_TIMELINE_PAGE_SIZE;
|
|
40
|
+
if (limit > MAX_TIMELINE_PAGE_SIZE) {
|
|
41
|
+
// See docs/decisions/DR-001-bounded-operational-timeline.md for the invariant behind this refusal; keep external identifiers out of caller-facing messages.
|
|
42
|
+
throw new TimelineValidationError(`requested limit ${limit} exceeds the server cap of ${MAX_TIMELINE_PAGE_SIZE}`);
|
|
43
|
+
}
|
|
44
|
+
return ledger.query({ ...filter, limit });
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=timeline.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AgentToolDefinition } from "@jini-ai/core";
|
|
2
|
+
import type { TransferNaming } from "../transfer/types.js";
|
|
3
|
+
export declare const DOMAIN = "database-transfer";
|
|
4
|
+
export declare const PLAN_TOOL_ID = "database_transfer_plan";
|
|
5
|
+
export declare const STATUS_TOOL_ID = "database_transfer_status";
|
|
6
|
+
/** Owner-only: in no built-in role but the owner's `*`. */
|
|
7
|
+
export declare const RUN_PERMISSION = "database-transfer.run";
|
|
8
|
+
export declare const SNAPSHOT_SCOPE_ID = "database-transfer";
|
|
9
|
+
/** Postgres 14, the oldest this copy is tested against. */
|
|
10
|
+
export declare const MIN_SERVER_VERSION_NUM = 140000;
|
|
11
|
+
import { type DbTransferMessages } from "../core/messages.js";
|
|
12
|
+
/**
|
|
13
|
+
* Builds fresh catalog metadata using host naming and replaceable model-facing messages.
|
|
14
|
+
* Naming defaults describe a generic source; they never choose a persisted schema or marker.
|
|
15
|
+
* @returns Four tool definitions with unchanged IDs, permissions, schemas and risk classifications.
|
|
16
|
+
* @complexity O(1) entries and space, plus O(n) description text for n naming/message characters.
|
|
17
|
+
* @example getDatabaseTransferAgentToolCatalog({}, { naming, messages: defaultDbMessages })
|
|
18
|
+
*/
|
|
19
|
+
export declare function getDatabaseTransferAgentToolCatalog(_required: Record<string, never>, { naming, messages }?: {
|
|
20
|
+
naming?: Pick<TransferNaming, "defaultSchema" | "schemaPrefix">;
|
|
21
|
+
messages?: DbTransferMessages;
|
|
22
|
+
}): AgentToolDefinition[];
|
|
23
|
+
/** Default display catalog; registrations render the actual host naming instead. */
|
|
24
|
+
export declare const databaseTransferAgentToolCatalog: AgentToolDefinition[];
|
|
25
|
+
//# sourceMappingURL=transfer-catalog.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const SET_DESTINATION_TOOL_ID = "database_transfer_set_destination";
|
|
2
|
+
const DATABASE_TRANSFER_RUN_TOOL_ID = "database_transfer_run";
|
|
3
|
+
export const DOMAIN = "database-transfer";
|
|
4
|
+
export const PLAN_TOOL_ID = "database_transfer_plan";
|
|
5
|
+
export const STATUS_TOOL_ID = "database_transfer_status";
|
|
6
|
+
const NO_INPUT_SCHEMA = { type: "object", additionalProperties: false, properties: {} };
|
|
7
|
+
/** Owner-only: in no built-in role but the owner's `*`. */
|
|
8
|
+
export const RUN_PERMISSION = "database-transfer.run";
|
|
9
|
+
export const SNAPSHOT_SCOPE_ID = "database-transfer";
|
|
10
|
+
/** Postgres 14, the oldest this copy is tested against. */
|
|
11
|
+
export const MIN_SERVER_VERSION_NUM = 140000;
|
|
12
|
+
import { defaultDbMessages } from "../core/messages.js";
|
|
13
|
+
/**
|
|
14
|
+
* Builds fresh catalog metadata using host naming and replaceable model-facing messages.
|
|
15
|
+
* Naming defaults describe a generic source; they never choose a persisted schema or marker.
|
|
16
|
+
* @returns Four tool definitions with unchanged IDs, permissions, schemas and risk classifications.
|
|
17
|
+
* @complexity O(1) entries and space, plus O(n) description text for n naming/message characters.
|
|
18
|
+
* @example getDatabaseTransferAgentToolCatalog({}, { naming, messages: defaultDbMessages })
|
|
19
|
+
*/
|
|
20
|
+
export function getDatabaseTransferAgentToolCatalog(_required, { naming = { defaultSchema: "app", schemaPrefix: "app_" }, messages = defaultDbMessages } = {}) {
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
name: PLAN_TOOL_ID,
|
|
24
|
+
description: messages.plan({ naming }),
|
|
25
|
+
sideEffects: "none",
|
|
26
|
+
authorization: { permission: RUN_PERMISSION },
|
|
27
|
+
inputSchema: NO_INPUT_SCHEMA,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: SET_DESTINATION_TOOL_ID,
|
|
31
|
+
description: messages.setDestination,
|
|
32
|
+
sideEffects: "mutates-durable-state",
|
|
33
|
+
authorization: { permission: RUN_PERMISSION },
|
|
34
|
+
inputSchema: NO_INPUT_SCHEMA,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: STATUS_TOOL_ID,
|
|
38
|
+
description: messages.status,
|
|
39
|
+
sideEffects: "none",
|
|
40
|
+
authorization: { permission: RUN_PERMISSION },
|
|
41
|
+
inputSchema: NO_INPUT_SCHEMA,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: DATABASE_TRANSFER_RUN_TOOL_ID,
|
|
45
|
+
description: messages.run,
|
|
46
|
+
sideEffects: "mutates-durable-state",
|
|
47
|
+
authorization: { permission: RUN_PERMISSION },
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: "object",
|
|
50
|
+
additionalProperties: false,
|
|
51
|
+
required: ["planId"],
|
|
52
|
+
properties: { planId: { type: "string", description: messages.planIdDescription } },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
/** Default display catalog; registrations render the actual host naming instead. */
|
|
58
|
+
export const databaseTransferAgentToolCatalog = getDatabaseTransferAgentToolCatalog({});
|
|
59
|
+
//# sourceMappingURL=transfer-catalog.js.map
|