@mnmal-ai/substrate 1.0.0-beta.1 → 1.0.0-beta.2
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/README.md +1 -1
- package/dist/{boot-store-BMQUbHKv.js → boot-store-DpnnxRpR.js} +6 -6
- package/dist/{cli-DModIbnN.js → cli-COS16L1Z.js} +100 -41
- package/dist/{errors-Cmkp1qxf.d.ts → errors-CuCMwPpb.d.ts} +3 -1
- package/dist/{plugin-CEOhrEme.js → plugin-DWagHKxm.js} +2 -2
- package/dist/proposals-bootstrap.js +2 -2
- package/dist/proposals.d.ts +1 -1
- package/dist/proposals.js +1 -1
- package/dist/recall-bootstrap.js +2 -2
- package/dist/recall.js +2 -2
- package/dist/{repl-BvDZy-Ut.js → repl-C8ZgDrQ7.js} +1 -1
- package/dist/{run-BT123RV1.js → run-D-4sXpTu.js} +3 -3
- package/dist/sdk.d.ts +2 -2
- package/dist/sdk.js +2 -2
- package/dist/{src-CKSJ13p8.js → src-C0ylwQFC.js} +16 -5
- package/dist/{src-CW7eRDss.js → src-D1PgjgUg.js} +3 -3
- package/dist/{src-DmjwFMu8.js → src-Db3XI_pn.js} +1 -1
- package/dist/{src-BMD2OE--.js → src-DxD3iktO.js} +30 -12
- package/dist/substrate-admin.js +1 -1
- package/dist/substrate.js +1 -1
- package/dist/testing.js +2 -2
- package/package.json +19 -19
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ A plugin package declares `@mnmal-ai/substrate` as a peer dependency and as a de
|
|
|
22
22
|
| Subcommand | Purpose |
|
|
23
23
|
|---|---|
|
|
24
24
|
| `substrate serve` | Boot the HTTP server (default port 3100) |
|
|
25
|
-
| `substrate mcp` | stdio MCP server; reads `SUBSTRATE_URL`, and `SUBSTRATE_MCP_TOOLS` (csv
|
|
25
|
+
| `substrate mcp` | stdio MCP server; reads `SUBSTRATE_URL`, and `SUBSTRATE_MCP_TOOLS` (csv of tool names, `core` or `all`; `core` is query, mutate, schema, recall, run, whoami; unset means `all` until 1.0.0-beta.3, then `core`) |
|
|
26
26
|
| `substrate init [dir] [flags]` | Scaffold a runtime directory (interactive; `--yes` for scripted use) |
|
|
27
27
|
| `substrate ask <question…>` | Ask a natural-language question (needs `substrate-nl`) |
|
|
28
28
|
| `substrate run <script.mts>` | Run a script against a signed, guarded client and print one JSON report |
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { A as isReservedAutoCrudField,
|
|
1
|
+
import { A as isReservedAutoCrudField, Gt as WS_REASON_SERVER_RESTART, Ht as parseAuthConfig, It as HttpBridgeClient, Rt as buildContext, Vn as DEFAULT_FILTER_WRITE_LIMITS, Z as MemoryEdgesStore, _ as AUDIT_EVENT_TYPE, a as composeFromManifests, bt as registerExtensionOperator, c as MemoryDataset, et as effectiveFilterOperators, g as buildAuditRow, h as SYSTEM_TYPE_DEFS, i as PluginLoadError, n as kernelMigrationTracking, o as DEFAULT_NAMESPACE, r as mountKernelRoute, s as compose, t as composeKernelPlugins, u as isStoreProfileName, vt as getExtensionOperator, xt as unregisterExtensionOperator, yt as listExtensionOperators } from "./src-C0ylwQFC.js";
|
|
2
2
|
import { a as adminClaimCapabilities, d as resolveDefaultKidPath, l as resolveAdminCredential, n as trimTrailingSlashes, r as ADMIN_CAPABILITIES, s as makeAuthorizationProvider, t as parsePositiveInt, u as resolveDefaultKeyPath } from "./env-utils-s25Z1YSA.js";
|
|
3
3
|
import { D as isActiveAdminKeyRow, E as describeGrant, L as encodeList, M as grantEntryError, T as SYSTEM_NAMESPACE, v as grantEntriesConfer } from "./src-DmiUWOLp.js";
|
|
4
4
|
import { r as FRAMES_JSON_MIME, s as decodeStreamFrames, u as withIdleTimeout } from "./src-B_kHkbsr.js";
|
|
5
5
|
import { C as diagnose, S as DIAGNOSE_CHECKS, T as substrateFetch, _ as SKIPPABLE_STEPS, b as planOnboarding, h as CURRENT_MARK, i as tokenAudience, v as STEP_MARKS, x as requiredOutstanding, y as currentStep } from "./src-FXO5JPyk.js";
|
|
6
|
-
import { b as runMigrations, g as deriveListIndexMigration, h as assertTablesLayout, n as PgEdgesStore, p as assertNotMigrating, r as PgDataset, t as PgIdempotencyStore, v as pendingMigrations, y as runDerivedMigrations } from "./src-
|
|
7
|
-
import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore } from "./src-
|
|
8
|
-
import { et as memberKey } from "./plugin-
|
|
6
|
+
import { b as runMigrations, g as deriveListIndexMigration, h as assertTablesLayout, n as PgEdgesStore, p as assertNotMigrating, r as PgDataset, t as PgIdempotencyStore, v as pendingMigrations, y as runDerivedMigrations } from "./src-DxD3iktO.js";
|
|
7
|
+
import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore } from "./src-D1PgjgUg.js";
|
|
8
|
+
import { et as memberKey } from "./plugin-DWagHKxm.js";
|
|
9
9
|
import { existsSync, linkSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { homedir } from "node:os";
|
|
11
11
|
import { basename, dirname, join, resolve } from "node:path";
|
|
@@ -1753,7 +1753,7 @@ async function closeQuietly(sql) {
|
|
|
1753
1753
|
|
|
1754
1754
|
//#endregion
|
|
1755
1755
|
//#region package.json
|
|
1756
|
-
var version = "1.0.0-beta.
|
|
1756
|
+
var version = "1.0.0-beta.2";
|
|
1757
1757
|
|
|
1758
1758
|
//#endregion
|
|
1759
1759
|
//#region src/plugin-manifest.ts
|
|
@@ -2267,7 +2267,7 @@ var FastifySubstrateServer = class {
|
|
|
2267
2267
|
port
|
|
2268
2268
|
});
|
|
2269
2269
|
const info = this.fastify.addresses()[0];
|
|
2270
|
-
if (
|
|
2270
|
+
if (info === void 0 || typeof info === "string") {
|
|
2271
2271
|
const match = /:(\d+)$/.exec(address);
|
|
2272
2272
|
return {
|
|
2273
2273
|
address: host,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { _ as AUDIT_EVENT_TYPE, g as buildAuditRow, it as saveSweepState, m as runInviteSweep, mn as validateHardDeleteEnv, nt as loadSweepState, rt as runSweep, u as isStoreProfileName, v as INVITE_TYPE } from "./src-
|
|
1
|
+
import { _ as AUDIT_EVENT_TYPE, g as buildAuditRow, it as saveSweepState, m as runInviteSweep, mn as validateHardDeleteEnv, nt as loadSweepState, rt as runSweep, u as isStoreProfileName, v as INVITE_TYPE } from "./src-C0ylwQFC.js";
|
|
2
2
|
import { n as trimTrailingSlashes, s as makeAuthorizationProvider } from "./env-utils-s25Z1YSA.js";
|
|
3
3
|
import { L as encodeList, T as SYSTEM_NAMESPACE, f as coversNamespace, m as grantedIn, p as grantOf } from "./src-DmiUWOLp.js";
|
|
4
4
|
import { B as EXPR_AGGREGATES, H as EXPR_LIMITS, V as EXPR_FUNCTIONS, z as DATE_UNITS } from "./src-B_kHkbsr.js";
|
|
5
|
-
import { X as AdminCliError, _ as version, a as MS_PER_DAY, c as parseEnv, d as redactStoreSpec, h as startSentinelClient, m as runDeferredIndexBuilds, n as resolvePluginDir, o as parseBridgeCreds, p as reportUnguardedIndexBuilds, s as parseBridges, t as bootStore, v as openPgDataset } from "./boot-store-
|
|
5
|
+
import { X as AdminCliError, _ as version, a as MS_PER_DAY, c as parseEnv, d as redactStoreSpec, h as startSentinelClient, m as runDeferredIndexBuilds, n as resolvePluginDir, o as parseBridgeCreds, p as reportUnguardedIndexBuilds, s as parseBridges, t as bootStore, v as openPgDataset } from "./boot-store-DpnnxRpR.js";
|
|
6
6
|
import { T as substrateFetch, a as SubstrateClient, d as NetworkError, i as tokenAudience, n as resolveAgentCapabilities, p as AdminBackfillError, r as noRedirectFetch, t as createClientFromEnv, u as AuthError } from "./src-FXO5JPyk.js";
|
|
7
7
|
import { n as runScript, t as DEFAULT_MAX_WRITES } from "./script-ByQ9pzhC.js";
|
|
8
|
-
import { D as tryWithPgAdvisoryLock } from "./src-
|
|
9
|
-
import { n as PgLexicalStore, r as PgEmbeddingsStore } from "./src-
|
|
8
|
+
import { D as tryWithPgAdvisoryLock } from "./src-DxD3iktO.js";
|
|
9
|
+
import { n as PgLexicalStore, r as PgEmbeddingsStore } from "./src-D1PgjgUg.js";
|
|
10
10
|
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
11
11
|
import { homedir, hostname, tmpdir } from "node:os";
|
|
12
12
|
import { basename, dirname, join, resolve } from "node:path";
|
|
@@ -2165,7 +2165,7 @@ async function runInit(argv) {
|
|
|
2165
2165
|
return 1;
|
|
2166
2166
|
}
|
|
2167
2167
|
if (!config.yes) try {
|
|
2168
|
-
const { runRepl } = await import("./repl-
|
|
2168
|
+
const { runRepl } = await import("./repl-C8ZgDrQ7.js");
|
|
2169
2169
|
config = await runRepl(config);
|
|
2170
2170
|
} catch (err) {
|
|
2171
2171
|
if (err.message?.includes("User force closed")) return 130;
|
|
@@ -2644,6 +2644,7 @@ const CONVENTIONS = [
|
|
|
2644
2644
|
"- In one `mutate` call the single-frame keys commit together or not at all, and an array under one key is one transaction. Send unrelated writes as separate calls.",
|
|
2645
2645
|
"- `createdAt`, `updatedAt`, `createdBy` and `updatedBy` are server-set: never send them; read them through `_metadata`.",
|
|
2646
2646
|
"- `whoami` says which identity this session reads and writes as.",
|
|
2647
|
+
"- If an admin tool (propose_type, propose_field, propose_index, drop_namespace, drop_type) or ask is missing from your tools, set SUBSTRATE_MCP_TOOLS=all (or core,<name>) in the MCP server env.",
|
|
2647
2648
|
"- With a shell, `substrate run <script.mts>` runs many reads and writes in one call and returns one small report (GET /substrate/v1/onboard, `instructions.codeMode`)."
|
|
2648
2649
|
].join("\n");
|
|
2649
2650
|
/** The MCP `instructions` text: the conventions, then this server's types as of session start. */
|
|
@@ -2719,22 +2720,22 @@ const payloadSchema = (example) => z.unknown().transform((raw, ctx) => {
|
|
|
2719
2720
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
2720
2721
|
ctx.addIssue({
|
|
2721
2722
|
code: "custom",
|
|
2722
|
-
message: "payload must decode to a JSON object"
|
|
2723
|
+
message: "payload must decode to a JSON object — e.g. { \"default/Todo\": { \"params\": { \"limit\": 5 }, \"fields\": { \"id\": true } } }"
|
|
2723
2724
|
});
|
|
2724
2725
|
return z.NEVER;
|
|
2725
2726
|
}
|
|
2726
2727
|
return parsed;
|
|
2727
|
-
} catch {
|
|
2728
|
+
} catch (err) {
|
|
2728
2729
|
ctx.addIssue({
|
|
2729
2730
|
code: "custom",
|
|
2730
|
-
message:
|
|
2731
|
+
message: `payload must be valid JSON (${err.message})`
|
|
2731
2732
|
});
|
|
2732
2733
|
return z.NEVER;
|
|
2733
2734
|
}
|
|
2734
2735
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
2735
2736
|
ctx.addIssue({
|
|
2736
2737
|
code: "custom",
|
|
2737
|
-
message: "payload must be an object or a JSON string decoding to an object"
|
|
2738
|
+
message: "payload must be an object or a JSON string decoding to an object — e.g. { \"default/Todo\": { \"params\": { \"limit\": 5 }, \"fields\": { \"id\": true } } }"
|
|
2738
2739
|
});
|
|
2739
2740
|
return z.NEVER;
|
|
2740
2741
|
}
|
|
@@ -2904,12 +2905,51 @@ function createQueryHandler(endpoint) {
|
|
|
2904
2905
|
}
|
|
2905
2906
|
};
|
|
2906
2907
|
}
|
|
2908
|
+
/** The refusal codes that mean the frame's params do not fit the type. */
|
|
2909
|
+
const SHAPE_CODES = /* @__PURE__ */ new Set([
|
|
2910
|
+
"unknown_field",
|
|
2911
|
+
"missing_required_field",
|
|
2912
|
+
"invalid_enum_value",
|
|
2913
|
+
"invalid_field_type"
|
|
2914
|
+
]);
|
|
2915
|
+
/** The type a generated mutation key writes, or null for any other key. */
|
|
2916
|
+
function typeOfOp(key) {
|
|
2917
|
+
const slash = key.indexOf("/");
|
|
2918
|
+
if (slash < 1) return null;
|
|
2919
|
+
const m = /^(create|update|upsert|delete)(Many)?([A-Z][A-Za-z0-9_]*)$/.exec(key.slice(slash + 1));
|
|
2920
|
+
return m?.[3] === void 0 ? null : {
|
|
2921
|
+
ns: key.slice(0, slash),
|
|
2922
|
+
type: m[3]
|
|
2923
|
+
};
|
|
2924
|
+
}
|
|
2925
|
+
/** Each shape-refused type's write contract, keyed `<ns>/<Type>`; undefined when there is none. */
|
|
2926
|
+
async function shapeContracts(endpoint, errors) {
|
|
2927
|
+
const types = /* @__PURE__ */ new Map();
|
|
2928
|
+
for (const e of errors) {
|
|
2929
|
+
if (e.code === void 0 || !SHAPE_CODES.has(e.code)) continue;
|
|
2930
|
+
const t = typeof e.path?.[0] === "string" ? typeOfOp(e.path[0]) : null;
|
|
2931
|
+
if (t !== null) types.set(`${t.ns}/${t.type}`, t);
|
|
2932
|
+
}
|
|
2933
|
+
const found = (await Promise.all([...types].map(async ([key, { ns, type }]) => {
|
|
2934
|
+
try {
|
|
2935
|
+
return [key, await getSubstrate(endpoint, `/substrate/v1/schema/${encodeURIComponent(ns)}/${encodeURIComponent(type)}?shape=fields`)];
|
|
2936
|
+
} catch {
|
|
2937
|
+
return null;
|
|
2938
|
+
}
|
|
2939
|
+
}))).filter((f) => f !== null);
|
|
2940
|
+
return found.length === 0 ? void 0 : Object.fromEntries(found);
|
|
2941
|
+
}
|
|
2907
2942
|
function createMutateHandler(endpoint) {
|
|
2908
2943
|
return async (args) => {
|
|
2909
2944
|
const payload = frameOf(args);
|
|
2910
2945
|
if (payload === void 0) return errorResult(MISSING_PAYLOAD);
|
|
2911
2946
|
try {
|
|
2912
|
-
|
|
2947
|
+
const envelope = await postSubstrate(endpoint, "/substrate/v1/mutate", payload);
|
|
2948
|
+
const contract = await shapeContracts(endpoint, envelope.errors ?? []);
|
|
2949
|
+
return okResult(contract === void 0 ? envelope : {
|
|
2950
|
+
...envelope,
|
|
2951
|
+
contract
|
|
2952
|
+
});
|
|
2913
2953
|
} catch (err) {
|
|
2914
2954
|
return errorResult(toMessage(err));
|
|
2915
2955
|
}
|
|
@@ -3037,16 +3077,16 @@ function createMcpServer(endpoint, options = {}) {
|
|
|
3037
3077
|
{
|
|
3038
3078
|
name: "schema",
|
|
3039
3079
|
config: {
|
|
3040
|
-
description: "
|
|
3080
|
+
description: "Schema lookup. No args: every namespace's types as `field: type` lines. `namespace`: one namespace. `namespace` + `type`: that type's write contract ({ fields, mutations }); read it before a create/update, since undeclared fields are refused (`unknown_field`). Compact answers name generated CRUD instead of repeating fields; `mutationRefs` explains. `full: true` with no namespace: the whole federated schema plus the expression catalogue (large).",
|
|
3041
3081
|
inputSchema: {
|
|
3042
|
-
namespace: z.string().min(1).optional().describe("
|
|
3043
|
-
type: z.string().min(1).optional().describe("
|
|
3082
|
+
namespace: z.string().min(1).optional().describe("e.g. \"notes\""),
|
|
3083
|
+
type: z.string().min(1).optional().describe("e.g. \"Todo\"; needs `namespace`"),
|
|
3044
3084
|
shape: z.enum([
|
|
3045
3085
|
"compact",
|
|
3046
3086
|
"full",
|
|
3047
3087
|
"fields"
|
|
3048
|
-
]).optional().describe("
|
|
3049
|
-
full: z.boolean().optional().describe("
|
|
3088
|
+
]).optional().describe("Type contract: \"compact\" (default), \"fields\" (fields + mutation names) or \"full\" (every block inlined)"),
|
|
3089
|
+
full: z.boolean().optional().describe("No namespace: the whole federated schema")
|
|
3050
3090
|
}
|
|
3051
3091
|
},
|
|
3052
3092
|
handler: createSchemaHandler(endpoint)
|
|
@@ -3054,7 +3094,7 @@ function createMcpServer(endpoint, options = {}) {
|
|
|
3054
3094
|
{
|
|
3055
3095
|
name: "query",
|
|
3056
3096
|
config: {
|
|
3057
|
-
description: "Query
|
|
3097
|
+
description: "Query. payload maps <ns>/<Type> keys (any namespaces) to { params, fields }; `schema` lists expression functions. Walks: `_walk: { in: \"ns/Type.field\" }` follows a reference backwards (overview: `←Type.field`), `out: \"field\"` forwards; it filters in `where`, nests rows in `fields`, aggregates in `fields._agg`. E.g. orders with an item over 50, with item count: { \"shop/Order\": { \"params\": { \"where\": { \"_walk\": { \"in\": \"shop/Item.order\", \"where\": { \"price\": { \"gt\": 50 } } } } }, \"fields\": { \"_agg\": { \"items\": { \"in\": \"shop/Item.order\", \"count\": true } } } } }. `quantifier`: \"any\" (default), \"none\", \"all\"; `pick`: { latest | max | min: field }. An \"any\" walk binds `as: \"L\"`, read later as { \"$ref\": \"L.price\", \"times\": 1.25 } (`$.f` seed row, `_agg.<n>` aggregate; `times`/`plus` scale, `plus` on a date shifts ms). `_agg`: count, avg/sum/min/max: field, latest: { by, value }; in `where` it compares: { \"_agg\": {...}, \"gte\": 3 }. Params: `count: true`; `aggregate: { n: { sum: \"price\" } }`, per group with `groupBy: { day: { dateTrunc: [{ \"lit\": \"day\" }, \"seenAt\"] } }`, `having`, `offset`; `select: { m: { sub: [\"_agg.x\", \"price\"] } }` adds a value, sortable in `orderBy`. An expression is a field name, a literal, { \"lit\": \"text\" } or { \"fn\": [args] }. Walks are query-only.",
|
|
3058
3098
|
inputSchema: frameInputSchema("Query frame. Example: { \"default/Todo\": { \"params\": { \"limit\": 20 }, \"fields\": { \"id\": true, \"title\": true } } }")
|
|
3059
3099
|
},
|
|
3060
3100
|
handler: createQueryHandler(endpoint)
|
|
@@ -3062,7 +3102,7 @@ function createMcpServer(endpoint, options = {}) {
|
|
|
3062
3102
|
{
|
|
3063
3103
|
name: "mutate",
|
|
3064
3104
|
config: {
|
|
3065
|
-
description: "
|
|
3105
|
+
description: "Mutate. payload maps <ns>/<mutation> keys to { params, fields } or an array of them. An array under one key is one transaction. Single-frame keys share one transaction on one tx scope and are refused across two; a single-frame key beside an array is not rolled back with it, so writes that must land together go in one array. A shape-refused write returns its type contract as `contract`.",
|
|
3066
3106
|
inputSchema: frameInputSchema("Mutation frame. Single: { \"default/createTodo\": { \"params\": { \"title\": \"...\" }, \"fields\": { \"id\": true } } }. Batched atomic: { \"default/updateTodo\": [ { \"params\": { \"id\": \"1\", \"done\": true }, \"fields\": { \"id\": true } }, { \"params\": { \"id\": \"2\", \"done\": true }, \"fields\": { \"id\": true } } ] }. By filter: { \"default/updateManyTodo\": { \"params\": { \"where\": { \"done\": { \"eq\": false } }, \"set\": { \"done\": true } }, \"fields\": { \"count\": true, \"ids\": true, \"idsTruncated\": true } } }; deleteMany<Type> takes only \"where\".")
|
|
3067
3107
|
},
|
|
3068
3108
|
handler: createMutateHandler(endpoint)
|
|
@@ -3070,16 +3110,16 @@ function createMcpServer(endpoint, options = {}) {
|
|
|
3070
3110
|
{
|
|
3071
3111
|
name: "run",
|
|
3072
3112
|
config: {
|
|
3073
|
-
description: "
|
|
3113
|
+
description: "Sandboxed script for 3+ dependent calls (paging, joins, read-driven writes). `script`: a module exporting default `async (s) => result`; type syntax is stripped. `s`: kid, mode, args, query(frame) (throws if refused), queryAll(key, { params, fields }), byShortId(key, n | n[], fields?), recall({ query, namespace, type, k?, where?, row? }), schema(ns?, type?), mutate(frame), log(). Modes: \"read\" (default; refuses mutate), \"dry-run\" (records, sends nothing), \"write\". Dry-run, check report.mutations, then write. Return ids/counts.",
|
|
3074
3114
|
inputSchema: {
|
|
3075
|
-
script: z.string().min(1).describe("
|
|
3076
|
-
args: z.record(z.string(), z.unknown()).optional().describe("Passed
|
|
3115
|
+
script: z.string().min(1).describe("e.g. export default async (s) => (await s.queryAll('ns/Todo', {})).length"),
|
|
3116
|
+
args: z.record(z.string(), z.unknown()).optional().describe("Passed as s.args"),
|
|
3077
3117
|
mode: z.enum([
|
|
3078
3118
|
"read",
|
|
3079
3119
|
"dry-run",
|
|
3080
3120
|
"write"
|
|
3081
|
-
]).optional().describe("Default \"read\"
|
|
3082
|
-
maxWrites: z.number().int().nonnegative().optional().describe("Write mode:
|
|
3121
|
+
]).optional().describe("Default \"read\""),
|
|
3122
|
+
maxWrites: z.number().int().nonnegative().optional().describe("Write mode: max mutate frames, default 50")
|
|
3083
3123
|
}
|
|
3084
3124
|
},
|
|
3085
3125
|
handler: createRunHandler()
|
|
@@ -3180,7 +3220,7 @@ function createMcpServer(endpoint, options = {}) {
|
|
|
3180
3220
|
{
|
|
3181
3221
|
name: "whoami",
|
|
3182
3222
|
config: {
|
|
3183
|
-
description: "
|
|
3223
|
+
description: "Who this session is authenticated as: { authEnabled, identity: { id, grants } | null }. Ask before concluding a credential works: reads can succeed anonymously. authEnabled false: the server verifies nothing. identity null with authEnabled true: your key never arrived (SUBSTRATE_AGENT_KEY_ID / SUBSTRATE_AGENT_KEY_PATH).",
|
|
3184
3224
|
inputSchema: {}
|
|
3185
3225
|
},
|
|
3186
3226
|
handler: async () => {
|
|
@@ -3202,16 +3242,16 @@ function createMcpServer(endpoint, options = {}) {
|
|
|
3202
3242
|
{
|
|
3203
3243
|
name: "recall",
|
|
3204
3244
|
config: {
|
|
3205
|
-
description: "Semantic
|
|
3245
|
+
description: "Semantic search: top-k records by similarity to `query`; hits carry `id` + handle fields. As a query frame, recall/Hit takes the text in params.to.",
|
|
3206
3246
|
inputSchema: {
|
|
3207
|
-
query: z.string().min(1).describe("
|
|
3208
|
-
k: z.number().int().min(1).max(100).optional().describe("
|
|
3209
|
-
namespace: z.string().optional().describe("
|
|
3210
|
-
type: z.string().min(1).describe("
|
|
3211
|
-
threshold: z.number().optional().describe("
|
|
3212
|
-
lexicalThreshold: z.number().optional().describe("
|
|
3213
|
-
where: z.record(z.string(), z.unknown()).optional().describe("
|
|
3214
|
-
rowFields: z.union([z.record(z.string(), z.literal(true)), z.literal(true)]).optional().describe("
|
|
3247
|
+
query: z.string().min(1).describe("Search text"),
|
|
3248
|
+
k: z.number().int().min(1).max(100).optional().describe("Default 10"),
|
|
3249
|
+
namespace: z.string().optional().describe("Required (no default)"),
|
|
3250
|
+
type: z.string().min(1).describe("e.g. \"Note\""),
|
|
3251
|
+
threshold: z.number().optional().describe("Min similarity 0..1"),
|
|
3252
|
+
lexicalThreshold: z.number().optional().describe("Keyword-only hit floor"),
|
|
3253
|
+
where: z.record(z.string(), z.unknown()).optional().describe("field -> { eq } | { in: [...] }; null matches missing"),
|
|
3254
|
+
rowFields: z.union([z.record(z.string(), z.literal(true)), z.literal(true)]).optional().describe("{ field: true } adds fields; true = whole row")
|
|
3215
3255
|
}
|
|
3216
3256
|
},
|
|
3217
3257
|
handler: async (input) => {
|
|
@@ -3225,21 +3265,37 @@ function createMcpServer(endpoint, options = {}) {
|
|
|
3225
3265
|
];
|
|
3226
3266
|
const allowed = resolveToolAllowlist(options.tools, TOOLS.map((t) => t.name));
|
|
3227
3267
|
for (const t of TOOLS) {
|
|
3228
|
-
if (
|
|
3268
|
+
if (!allowed.has(t.name)) continue;
|
|
3229
3269
|
server.registerTool(t.name, t.config, t.handler);
|
|
3230
3270
|
}
|
|
3231
3271
|
return server;
|
|
3232
3272
|
}
|
|
3273
|
+
/** The tools a worker agent needs; the admin tools and `ask` are opt-in. */
|
|
3274
|
+
const CORE_TOOLS = [
|
|
3275
|
+
"query",
|
|
3276
|
+
"mutate",
|
|
3277
|
+
"schema",
|
|
3278
|
+
"recall",
|
|
3279
|
+
"run",
|
|
3280
|
+
"whoami"
|
|
3281
|
+
];
|
|
3233
3282
|
/**
|
|
3234
|
-
* Parse SUBSTRATE_MCP_TOOLS
|
|
3235
|
-
* throws: a typo that silently registered nothing
|
|
3236
|
-
* has no such tool", which is a worse failure than
|
|
3283
|
+
* Parse SUBSTRATE_MCP_TOOLS: tool names and the presets `core` and `all`
|
|
3284
|
+
* (the default while unset or blank). An unknown name throws: a typo that silently registered nothing
|
|
3285
|
+
* would read as "this server has no such tool", which is a worse failure than
|
|
3286
|
+
* refusing to start.
|
|
3237
3287
|
*/
|
|
3238
3288
|
function resolveToolAllowlist(raw, known) {
|
|
3239
|
-
if (raw === void 0 || raw.trim() === "") return
|
|
3240
|
-
const names =
|
|
3241
|
-
for (const n of
|
|
3242
|
-
|
|
3289
|
+
if (raw === void 0 || raw.trim() === "") return new Set(known);
|
|
3290
|
+
const names = /* @__PURE__ */ new Set();
|
|
3291
|
+
for (const n of raw.split(",").map((t) => t.trim())) {
|
|
3292
|
+
if (n === "") continue;
|
|
3293
|
+
if (n === "core") for (const t of CORE_TOOLS) names.add(t);
|
|
3294
|
+
else if (n === "all") for (const t of known) names.add(t);
|
|
3295
|
+
else if (known.includes(n)) names.add(n);
|
|
3296
|
+
else throw new Error(`SUBSTRATE_MCP_TOOLS: unknown tool '${n}'. Valid names: core, all, ${[...known].sort().join(", ")}`);
|
|
3297
|
+
}
|
|
3298
|
+
return names;
|
|
3243
3299
|
}
|
|
3244
3300
|
/** The overview for the session's instructions, or null when the server is slow or down. */
|
|
3245
3301
|
async function fetchOverview(endpoint) {
|
|
@@ -3254,6 +3310,7 @@ async function fetchOverview(endpoint) {
|
|
|
3254
3310
|
async function runMcp() {
|
|
3255
3311
|
const endpoint = process.env.SUBSTRATE_URL ?? "http://localhost:3100";
|
|
3256
3312
|
configureAgentAuth(process.env, endpoint);
|
|
3313
|
+
if (!process.env.SUBSTRATE_MCP_TOOLS?.trim()) console.error("substrate mcp: deprecated: SUBSTRATE_MCP_TOOLS is unset, so every tool is registered. From 1.0.0-beta.3 the default is core (query, mutate, schema, recall, run, whoami). Set SUBSTRATE_MCP_TOOLS=all to keep the admin tools and ask, or core to opt in now.");
|
|
3257
3314
|
const server = createMcpServer(endpoint, {
|
|
3258
3315
|
...process.env.SUBSTRATE_MCP_TOOLS === void 0 ? {} : { tools: process.env.SUBSTRATE_MCP_TOOLS },
|
|
3259
3316
|
instructions: buildInstructions(await fetchOverview(endpoint))
|
|
@@ -3290,7 +3347,9 @@ Usage:
|
|
|
3290
3347
|
Subcommands:
|
|
3291
3348
|
serve Boot the Substrate HTTP server (default port 3100).
|
|
3292
3349
|
mcp Boot the stdio MCP server. Reads SUBSTRATE_URL, and
|
|
3293
|
-
SUBSTRATE_MCP_TOOLS (csv
|
|
3350
|
+
SUBSTRATE_MCP_TOOLS (csv of tool names, core or all;
|
|
3351
|
+
core: query, mutate, schema, recall, run, whoami; default
|
|
3352
|
+
all, deprecated: core from 1.0.0-beta.3).
|
|
3294
3353
|
init [dir] [flags] Scaffold a new Substrate runtime directory. Interactive by
|
|
3295
3354
|
default; pass --yes for non-interactive scripted use.
|
|
3296
3355
|
federate <verb> Federation onboarding: enroll / join / check.
|
|
@@ -54,6 +54,8 @@ declare class ResolverFrameError extends Error {
|
|
|
54
54
|
}
|
|
55
55
|
/** `filter_too_broad`: a by-filter write on `<namespace>/<type>` matched more than `maxMatch` rows. */
|
|
56
56
|
declare function filterTooBroad(namespace: string, type: string, maxMatch: number): ResolverFrameError;
|
|
57
|
+
/** A miss on an id that is not UUID-shaped is usually a shortId sent where the UUID belongs. */
|
|
58
|
+
declare function idHint(value: unknown): string;
|
|
57
59
|
/**
|
|
58
60
|
* Thrown by a write-path resolver when a crossRef declaring `onMissing: 'reject'`
|
|
59
61
|
* references a target that does not exist (or has been tombstoned). Extends
|
|
@@ -167,4 +169,4 @@ declare function isResolverFrameError(err: unknown): err is ResolverFrameError;
|
|
|
167
169
|
*/
|
|
168
170
|
declare function isRestrictViolation(err: unknown): err is RestrictViolation;
|
|
169
171
|
//#endregion
|
|
170
|
-
export {
|
|
172
|
+
export { isAuthCause as C, isRestrictViolation as E, idHint as S, isResolverFrameError as T, WALKS_NEED_PARTITIONED as _, NamespaceMismatch as a, WALK_UNSUPPORTED_REF as b, ROW_POLICY_BLOCKS_WALK as c, RestrictViolation as d, STORE_BUSY as f, WALKS_IN_SUBSCRIPTION as g, WALKS_IN_MUTATION as h, MissingReferentError as i, ReservedField as l, VALUE_OUT_OF_RANGE as m, BridgeUnreachableError as n, QUERY_TIMEOUT as o, UnsupportedFilterError as p, FILTER_TOO_BROAD as r, REGEX_BUDGET_EXCEEDED as s, BatchElementError as t, ResolverFrameError as u, WALKS_UNSUPPORTED_STORE as v, isBatchElementError as w, filterTooBroad as x, WALK_BUDGET_EXCEEDED as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Bt as jsonResponse, Rt as buildContext, tt as applyObligations, wn as ResolverFrameError } from "./src-
|
|
1
|
+
import { Bt as jsonResponse, Rt as buildContext, tt as applyObligations, wn as ResolverFrameError } from "./src-C0ylwQFC.js";
|
|
2
2
|
import "./src-B_kHkbsr.js";
|
|
3
|
-
import { w as queryTimeoutError } from "./src-
|
|
3
|
+
import { w as queryTimeoutError } from "./src-DxD3iktO.js";
|
|
4
4
|
import { Worker } from "node:worker_threads";
|
|
5
5
|
|
|
6
6
|
//#region ../../plugins/substrate-recall/src/candidate-selection.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as createNoopPubSub, t as createProposalsPlugin } from "./src-
|
|
1
|
+
import { qn as defineBootstrap } from "./src-C0ylwQFC.js";
|
|
2
|
+
import { n as createNoopPubSub, t as createProposalsPlugin } from "./src-Db3XI_pn.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region ../../plugins/substrate-proposals/src/bootstrap.ts
|
package/dist/proposals.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { kn as OnDelete, kt as Dataset, x as CoordinatorPlugin } from "./schema-aIkY8sR3.js";
|
|
2
|
-
import { u as ResolverFrameError } from "./errors-
|
|
2
|
+
import { u as ResolverFrameError } from "./errors-CuCMwPpb.js";
|
|
3
3
|
//#region ../../plugins/substrate-proposals/src/config.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Multi-instance invalidation transport used by the plugin to broadcast
|
package/dist/proposals.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as ProposalError, n as createNoopPubSub, r as storageSettled, t as createProposalsPlugin } from "./src-
|
|
1
|
+
import { i as ProposalError, n as createNoopPubSub, r as storageSettled, t as createProposalsPlugin } from "./src-Db3XI_pn.js";
|
|
2
2
|
|
|
3
3
|
export { ProposalError, createNoopPubSub, createProposalsPlugin, storageSettled };
|
package/dist/recall-bootstrap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { qn as defineBootstrap } from "./src-C0ylwQFC.js";
|
|
2
2
|
import { t as FakeEmbedder } from "./fake-DdXtb-m8.js";
|
|
3
|
-
import { t as createRecallPlugin } from "./plugin-
|
|
3
|
+
import { t as createRecallPlugin } from "./plugin-DWagHKxm.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
//#region ../../packages/substrate-embedder/src/types.ts
|
package/dist/recall.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore, t as RECALL_VERSION } from "./src-
|
|
2
|
-
import { $ as CLUSTERER_BACKEND_VERSION, A as CLUSTER_MEMBER_FIELDS, C as EmbedSourceRegistry, D as makeReembed, E as makeEmbedPostWrite, F as unknownParams, G as DEFAULT_CRYSTALLISE_CONFIG, H as CRYSTALLISE_IN_FLIGHT_CODE, I as handleRecallRequest, J as runClusterer, K as handleCrystallise, L as RRF_K, M as recallRouteHandler, N as checkParams, O as crystalliseRouteHandler, P as unknownParamMessage, Q as CLUSTERER_BACKEND, R as armRanks, S as createEmbedStats, T as embedRowReporting, U as createCrystalliseGuard, X as l2normalize, _ as EMBEDDINGS_FETCH_MAX_REFS, a as REINDEX_MAX_LIMIT, b as handleLexicalCoverage, c as SALIENCE_BOOST_MAX_TARGETS, d as embeddingsMigration, et as memberKey, f as recallMcpTool, g as embeddingsFetchRouteHandler, h as embeddingSimilarOperator, i as REINDEX_DEFAULT_LIMIT, j as buildClusterSurface, k as CLUSTER_FIELDS, l as lexicalMigration, m as makeLexicalPostWrite, n as salienceBoostRouteHandler, nt as validateSelector, o as handleReindex, p as makeLexicalClassify, q as validateCrystalliseInput, r as reindexRouteHandler, s as validateReindexInput, t as createRecallPlugin, tt as SELECT_CANDIDATES_MAX_LIMIT, u as recallClustersMigration, v as embedStatsRouteHandler, w as embedAndStore, x as validateLexicalCoverageInput, y as handleEmbedStatsRequest, z as fuseByRank } from "./plugin-
|
|
1
|
+
import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore, t as RECALL_VERSION } from "./src-D1PgjgUg.js";
|
|
2
|
+
import { $ as CLUSTERER_BACKEND_VERSION, A as CLUSTER_MEMBER_FIELDS, C as EmbedSourceRegistry, D as makeReembed, E as makeEmbedPostWrite, F as unknownParams, G as DEFAULT_CRYSTALLISE_CONFIG, H as CRYSTALLISE_IN_FLIGHT_CODE, I as handleRecallRequest, J as runClusterer, K as handleCrystallise, L as RRF_K, M as recallRouteHandler, N as checkParams, O as crystalliseRouteHandler, P as unknownParamMessage, Q as CLUSTERER_BACKEND, R as armRanks, S as createEmbedStats, T as embedRowReporting, U as createCrystalliseGuard, X as l2normalize, _ as EMBEDDINGS_FETCH_MAX_REFS, a as REINDEX_MAX_LIMIT, b as handleLexicalCoverage, c as SALIENCE_BOOST_MAX_TARGETS, d as embeddingsMigration, et as memberKey, f as recallMcpTool, g as embeddingsFetchRouteHandler, h as embeddingSimilarOperator, i as REINDEX_DEFAULT_LIMIT, j as buildClusterSurface, k as CLUSTER_FIELDS, l as lexicalMigration, m as makeLexicalPostWrite, n as salienceBoostRouteHandler, nt as validateSelector, o as handleReindex, p as makeLexicalClassify, q as validateCrystalliseInput, r as reindexRouteHandler, s as validateReindexInput, t as createRecallPlugin, tt as SELECT_CANDIDATES_MAX_LIMIT, u as recallClustersMigration, v as embedStatsRouteHandler, w as embedAndStore, x as validateLexicalCoverageInput, y as handleEmbedStatsRequest, z as fuseByRank } from "./plugin-DWagHKxm.js";
|
|
3
3
|
|
|
4
4
|
export { CLUSTERER_BACKEND, CLUSTERER_BACKEND_VERSION, CLUSTER_FIELDS, CLUSTER_MEMBER_FIELDS, CRYSTALLISE_IN_FLIGHT_CODE, DEFAULT_CRYSTALLISE_CONFIG, EMBEDDINGS_FETCH_MAX_REFS, EmbedSourceRegistry, InMemoryClusterStore, InMemoryEmbeddingsStore, InMemoryLexicalStore, PgClusterStore, PgEmbeddingsStore, PgLexicalStore, RECALL_VERSION, REINDEX_DEFAULT_LIMIT, REINDEX_MAX_LIMIT, RRF_K, SALIENCE_BOOST_MAX_TARGETS, SELECT_CANDIDATES_MAX_LIMIT, armRanks, buildClusterSurface, checkParams, createCrystalliseGuard, createEmbedStats, createRecallPlugin, crystalliseRouteHandler, embedAndStore, embedRowReporting, embedStatsRouteHandler, embeddingSimilarOperator, embeddingsFetchRouteHandler, embeddingsMigration, fuseByRank, handleCrystallise, handleEmbedStatsRequest, handleLexicalCoverage, handleRecallRequest, handleReindex, l2normalize, lexicalMigration, makeEmbedPostWrite, makeLexicalClassify, makeLexicalPostWrite, makeReembed, memberKey, recallClustersMigration, recallMcpTool, recallRouteHandler, reindexRouteHandler, runClusterer, salienceBoostRouteHandler, unknownParamMessage, unknownParams, validateCrystalliseInput, validateLexicalCoverageInput, validateReindexInput, validateSelector };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as parsePositive, i as DEFAULT_SIZING, n as defaultPluginsForPersona, r as parsePort, t as KNOWN_PLUGINS } from "./cli-
|
|
1
|
+
import { a as parsePositive, i as DEFAULT_SIZING, n as defaultPluginsForPersona, r as parsePort, t as KNOWN_PLUGINS } from "./cli-COS16L1Z.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { _ as AUDIT_EVENT_TYPE, g as buildAuditRow } from "./src-
|
|
1
|
+
import { _ as AUDIT_EVENT_TYPE, g as buildAuditRow } from "./src-C0ylwQFC.js";
|
|
2
2
|
import { n as trimTrailingSlashes } from "./env-utils-s25Z1YSA.js";
|
|
3
3
|
import { I as decodeList, L as encodeList, M as grantEntryError, g as checkUpdatable, h as checkRevocable, y as newlyGranted } from "./src-DmiUWOLp.js";
|
|
4
4
|
import "./src-B_kHkbsr.js";
|
|
5
|
-
import { A as REVOKE_EXIT_CODES, B as listActiveAdminKeys, C as runRegisterViaRoute, D as formatBootstrapOutput, E as formatDoctorReport, F as BootstrapError, G as ARGV_SPEC, H as describeAdminTarget, I as CLI_ACTOR_KID, J as USAGE, K as validateArgv, L as base64Url, M as runKeyListViaRoute, N as runKeyPatchViaRoute, O as parseBootstrapArgs, P as ACTOR_HINT, R as forUpdate, S as runRegister, T as doctorCommand, U as resolveAdminAuth, V as readKeyById, W as resolveAdminTarget, X as AdminCliError, Y as argvError, Z as pgNoticeOptions, _ as version, b as formatRegisterOutput, c as parseEnv, f as registeredTypes, g as loadPluginsFromDir, i as EnvConfigError, j as UPDATE_EXIT_CODES, k as runBootstrap, l as refuseContractViolation, n as resolvePluginDir, q as RESTART_NOTE, r as BINARY_CONTRACT_VERSION, t as bootStore, u as buildDeferredIndexes, v as openPgDataset, w as grantLines, x as parseRegisterArgs, y as onboardCommand, z as generateAdminKeypair } from "./boot-store-
|
|
5
|
+
import { A as REVOKE_EXIT_CODES, B as listActiveAdminKeys, C as runRegisterViaRoute, D as formatBootstrapOutput, E as formatDoctorReport, F as BootstrapError, G as ARGV_SPEC, H as describeAdminTarget, I as CLI_ACTOR_KID, J as USAGE, K as validateArgv, L as base64Url, M as runKeyListViaRoute, N as runKeyPatchViaRoute, O as parseBootstrapArgs, P as ACTOR_HINT, R as forUpdate, S as runRegister, T as doctorCommand, U as resolveAdminAuth, V as readKeyById, W as resolveAdminTarget, X as AdminCliError, Y as argvError, Z as pgNoticeOptions, _ as version, b as formatRegisterOutput, c as parseEnv, f as registeredTypes, g as loadPluginsFromDir, i as EnvConfigError, j as UPDATE_EXIT_CODES, k as runBootstrap, l as refuseContractViolation, n as resolvePluginDir, q as RESTART_NOTE, r as BINARY_CONTRACT_VERSION, t as bootStore, u as buildDeferredIndexes, v as openPgDataset, w as grantLines, x as parseRegisterArgs, y as onboardCommand, z as generateAdminKeypair } from "./boot-store-DpnnxRpR.js";
|
|
6
6
|
import { T as substrateFetch } from "./src-FXO5JPyk.js";
|
|
7
|
-
import { C as detectLayout, E as parseSourceBody, S as UUID_REGEX, T as copyRows, _ as isDerivedMigration, a as seqName, c as loadTypeTable, d as MIGRATE_STORE_MARKER_TABLE, f as PLAIN_SCHEMA_NAME, l as typeTableRef, m as assertStoreSchema, o as ensureTypeTable, x as UUID_CHECK_MIGRATION } from "./src-
|
|
7
|
+
import { C as detectLayout, E as parseSourceBody, S as UUID_REGEX, T as copyRows, _ as isDerivedMigration, a as seqName, c as loadTypeTable, d as MIGRATE_STORE_MARKER_TABLE, f as PLAIN_SCHEMA_NAME, l as typeTableRef, m as assertStoreSchema, o as ensureTypeTable, x as UUID_CHECK_MIGRATION } from "./src-DxD3iktO.js";
|
|
8
8
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { dirname } from "node:path";
|
|
10
10
|
import { createHash, randomUUID } from "node:crypto";
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $ as VirtualMutationDef, $t as WalkAgg, A as KernelLifecycleContext, An as OnMissing, At as DatasetRegistry, B as NamespaceTypeDef, Bn as WriteRow, Bt as IndexPlan, C as EmbedSourceContext, Cn as CanDeleteResult, Ct as RowFilterObligation, D as FilterOperatorDef, Dn as EdgeWriteInput, Dt as ConditionalUpdateResult, E as EngineInput, En as EdgeRef, Et as AggFn, F as KernelRouteClaim, Fn as IdentityKind, Ft as FilterCapabilities, G as Registry, Gt as ReadParams, H as PluginRouteContext, Ht as OrderByClause, I as McpToolRegistration, In as ROW_METADATA_FIELDS, It as FilterWriteLimits, J as RegistryEntryInput, Jt as StorageReport, K as RegistryBase, Kt as ReadResult, L as NamespaceConfig, Ln as Row, Lt as FilterWriteOptions, M as KernelMigrationContext, Mn as CLIENT_SUPPLIED_SERVER_FIELD, Mt as DropResult, N as KernelNamespaceContribution, Nn as ClientSuppliedServerFieldError, Nt as FieldKind, O as FrameEntry, On as EdgesStore, Ot as DEFAULT_FILTER_WRITE_LIMITS, P as KernelPlugin, Pn as Id, Pt as FieldPredicate, Q as ScheduledTaskContext, Qt as UpdateFieldRef, R as NamespaceDefinition, Rn as RowMetadata, Rt as FilterWriteResult, S as DropParticipant, Sn as FunctionSig, St as ResolverReturn, T as EngineHandle, Tn as EdgePatch, Tt as WriteEvent, U as PostWriteHook, Ut as PoolStats, V as PluginLifecycleContext, Vn as assertNoRepeatedIds, Vt as NestedSelection, W as QualifiedFrame, Wt as PromotionEvent, X as RegistryEntryResolver, Xt as TypeIndexState, Y as RegistryEntryKind, Yt as TxScopeHandles, Z as ScheduledTask, Zt as TypeStorageReport, _ as naturalOrderOf, _n as EXPR_AGGREGATES, _t as PolicyDecision, a as FieldDefCrossRef, an as WriteOptions, at as RequestObserver, b as CommittedWritesHook, bn as Expr, bt as Resolver, c as FieldDefStruct, cn as ResolveObservation, ct as SubstrateRequest, d as OrderedBy, dn as RuntimeErrors, dt as TlsConfig, en as WalkAggOperand, et as VirtualTypeDef, f as PackEnvelope, fn as RuntimeMetrics, ft as AfterTxWork, g as isColumnField, gn as DATE_UNITS, gt as Policy, h as TypeSchema, hn as ArgType, ht as Obligation, i as FieldDef, in as WhereClause, it as RequestObservation, j as KernelMigration, jn as ActorIdentity, jt as DeleteResult, k as IndexDecl, kn as OnDelete, kt as Dataset, l as FieldInput, ln as ResolverStat, lt as SubstrateResponse, m as Schema, mn as TypeStats, mt as Identity, n as Dropped, nn as WalkNode, nt as HttpMethod, o as FieldDefList, on as WriteResult, ot as RuntimeOp, p as PlanClause, pn as SlowRequest, pt as AutoCrudVerb, q as RegistryEntry, qt as RefOperand, r as EnvelopeShape, rn as WalkPick, rt as PluginRouter, s as FieldDefScalar, sn as ProcessStat, st as StartOpts, t as DEFAULT_ORDERED_BY, tn as WalkAggPredicate, tt as HttpHandler, u as MutationSchema, un as RuntimeErrorEntry, ut as SubstrateServer, v as BatchResolver, vn as EXPR_FUNCTIONS, vt as PolicyProbeContext, w as EncodeContext, wn as Edge, wt as TypedResolver, x as CoordinatorPlugin, xn as ExprType, xt as ResolverArgs, y as CommittedWriteBatch, yn as EXPR_LIMITS, yt as RequestContext, z as NamespaceInstallContext, zn as RowMetadataField, zt as FrameAgg } from "./schema-aIkY8sR3.js";
|
|
2
2
|
import { i as BridgeFrame, n as BridgeCredential, r as BridgeCredentialStore, t as BridgeClient } from "./bridge-DnToJedN.js";
|
|
3
|
-
import { C as
|
|
3
|
+
import { C as isAuthCause, E as isRestrictViolation, S as idHint, T as isResolverFrameError, _ as WALKS_NEED_PARTITIONED, a as NamespaceMismatch, b as WALK_UNSUPPORTED_REF, c as ROW_POLICY_BLOCKS_WALK, d as RestrictViolation, f as STORE_BUSY, g as WALKS_IN_SUBSCRIPTION, h as WALKS_IN_MUTATION, i as MissingReferentError, l as ReservedField, m as VALUE_OUT_OF_RANGE, n as BridgeUnreachableError, o as QUERY_TIMEOUT, p as UnsupportedFilterError, r as FILTER_TOO_BROAD, s as REGEX_BUDGET_EXCEEDED, t as BatchElementError, u as ResolverFrameError, v as WALKS_UNSUPPORTED_STORE, w as isBatchElementError, x as filterTooBroad, y as WALK_BUDGET_EXCEEDED } from "./errors-CuCMwPpb.js";
|
|
4
4
|
import { a as WsResponseFrame, c as ResolveTarget, d as TargetState, f as IdempotencyStore, i as WsRequestFrame, l as SweepDeps, n as WS_REASON_SERVER_RESTART, o as WsResponseKind, r as WS_REASON_SUBSCRIPTION_OVERLOADED, s as BridgeRegistry, t as WS_CODE_SUBSCRIPTION_UNSUPPORTED_FRAME, u as SweepState } from "./ws-DW8ng02H.js";
|
|
5
5
|
import { $ as NlJudgeAction, A as and, B as SYSTEM_NAMESPACE, C as flattenGrant, D as parseGrantEntries, E as intersectGrants, F as TokenProviderOpts, G as resolveAdminCredential, H as isActiveAdminKeyRow, I as adminClaimCapabilities, J as NlAggregate, K as resolveDefaultKeyPath, L as isEncryptedKey, M as or, N as ADMIN_CAPABILITIES, O as decodeList, P as DEFAULT_CAPABILITIES, Q as NlFieldPhrase, R as makeAuthorizationProvider, S as expandFlat, T as grantIsUniform, U as AdminCredential, V as describeGrant, W as AdminEnv, X as NlAskResult, Y as NlAskRequest, Z as NlEvidence, _ as newlyGrantedPairs, _t as NLVocabularyHint, a as denyAll, at as NlOutcome, b as capabilitiesFor, c as requireIdentity, ct as NlPackValueRef, d as KeyUpdateRefusal, dt as NlServedPack, et as NlJudgeChoice, f as checkRevocable, ft as NlTrailEvent, g as newlyGranted, gt as NLResult, h as grantEntriesConfer, ht as NLBase, i as allowVerbs, it as NlNamespaceRulings, j as not, k as encodeList, l as requireNamespace, lt as NlParseStatus, m as grantCovers, mt as NlWireEvent, n as row, nt as NlJudgedStatus, o as denyVerbs, ot as NlPackField, p as checkUpdatable, pt as NlValueAlias, q as resolveDefaultKidPath, r as allowAll, rt as NlNamespacePack, s as requireCapability, st as NlPackType, t as applyRowFilters, tt as NlJudgeStep, u as KeyMutationRefusal, ut as NlParsedData, v as revokedAtIso, vt as Query, w as grantEntryError, x as encodeGrant, y as Grant, z as makeTokenProvider } from "./row-D0If4qif.js";
|
|
6
6
|
//#region ../../packages/substrate-types/src/assert-never.d.ts
|
|
@@ -895,4 +895,4 @@ export declare function resolveEntityId(dataset: Dataset, type: string, input: I
|
|
|
895
895
|
*/
|
|
896
896
|
export declare function resolveEntityRow(dataset: Dataset, type: string, input: Id): Promise<Row | null>;
|
|
897
897
|
//#endregion
|
|
898
|
-
export { ADMIN_CAPABILITIES, ActorIdentity, type AdminCredential, type AdminEnv, AfterTxWork, AggFn, ArgType, AutoCrudVerb, BatchElementError, BatchResolver, BridgeClient, BridgeCredential, BridgeCredentialStore, BridgeFrame, BridgeRegistry, BridgeUnreachableError, CLIENT_SUPPLIED_SERVER_FIELD, CanDeleteResult, ClientSuppliedServerFieldError, CommittedWriteBatch, CommittedWritesHook, ConditionalUpdateResult, CoordinatorPlugin, type CrossRefFieldOptions, DATE_UNITS, DEFAULT_CAPABILITIES, DEFAULT_FILTER_WRITE_LIMITS, DEFAULT_ORDERED_BY, Dataset, DatasetRegistry, type DateFieldOptions, type DefineNamespaceOptions, DeleteResult, type DeleteRowArgs, type DeleteRowResult, DropParticipant, DropResult, Dropped, EXPR_AGGREGATES, EXPR_FUNCTIONS, EXPR_LIMITS, Edge, EdgePatch, EdgeRef, EdgeWriteInput, EdgesStore, EmbedSourceContext, EncodeContext, EngineHandle, EngineInput, EnvelopeShape, Expr, ExprType, FILTER_TOO_BROAD, FieldDef, FieldDefCrossRef, FieldDefList, FieldDefScalar, FieldDefStruct, FieldInput, FieldKind, FieldPredicate, FilterCapabilities, FilterOperatorDef, FilterWriteLimits, type FilterWriteMutationResult, FilterWriteOptions, FilterWriteResult, FrameAgg, FrameEntry, FunctionSig, type Grant, HttpHandler, HttpMethod, Id, IdempotencyStore, Identity, IdentityKind, IndexDecl, IndexPlan, type JsonFieldOptions, KernelLifecycleContext, KernelMigration, KernelMigrationContext, KernelNamespaceContribution, KernelPlugin, KernelRouteClaim, type KeyMutationRefusal, type KeyUpdateRefusal, type ListFieldOptions, McpToolRegistration, MissingReferentError, MutationSchema, NLBase, NLResult, NLVocabularyHint, NamespaceConfig, NamespaceDefinition, NamespaceInstallContext, NamespaceMismatch, NamespaceTypeDef, NestedSelection, NlAggregate, NlAskRequest, NlAskResult, NlEvidence, NlFieldPhrase, NlJudgeAction, NlJudgeChoice, NlJudgeStep, NlJudgedStatus, NlNamespacePack, NlNamespaceRulings, NlOutcome, NlPackField, NlPackType, NlPackValueRef, NlParseStatus, NlParsedData, NlServedPack, NlTrailEvent, NlValueAlias, NlWireEvent, Obligation, OnDelete, OnMissing, OrderByClause, OrderedBy, PackEnvelope, PlanClause, PluginLifecycleContext, PluginRouteContext, PluginRouter, Policy, PolicyDecision, PolicyProbeContext, PoolStats, PostWriteHook, ProcessStat, PromotionEvent, QUERY_TIMEOUT, QualifiedFrame, Query, REGEX_BUDGET_EXCEEDED, ROW_METADATA_FIELDS, ROW_POLICY_BLOCKS_WALK, ReadParams, ReadResult, RefOperand, Registry, RegistryBase, RegistryEntry, RegistryEntryInput, RegistryEntryKind, RegistryEntryResolver, RequestContext, RequestObservation, RequestObserver, ReservedField, ResolveObservation, ResolveTarget, Resolver, ResolverArgs, ResolverFrameError, ResolverReturn, ResolverStat, RestrictViolation, Row, RowFilterObligation, RowMetadata, RowMetadataField, RuntimeErrorEntry, RuntimeErrors, RuntimeMetrics, RuntimeOp, STORE_BUSY, SYSTEM_NAMESPACE, type ScalarFieldOptions, ScheduledTask, ScheduledTaskContext, Schema, SlowRequest, StartOpts, StorageReport, type StructFieldOptions, SubstrateRequest, SubstrateResponse, SubstrateServer, SweepDeps, SweepState, TargetState, TlsConfig, type TokenProviderOpts, TxScopeHandles, TypeIndexState, type TypeInput, TypeSchema, TypeStats, TypeStorageReport, TypedResolver, UnsupportedFilterError, UpdateFieldRef, type UpdateResolverOptions, VALUE_OUT_OF_RANGE, VirtualMutationDef, VirtualTypeDef, WALKS_IN_MUTATION, WALKS_IN_SUBSCRIPTION, WALKS_NEED_PARTITIONED, WALKS_UNSUPPORTED_STORE, WALK_BUDGET_EXCEEDED, WALK_UNSUPPORTED_REF, WS_CODE_SUBSCRIPTION_UNSUPPORTED_FRAME, WS_REASON_SERVER_RESTART, WS_REASON_SUBSCRIPTION_OVERLOADED, WalkAgg, WalkAggOperand, WalkAggPredicate, WalkNode, WalkPick, WhereClause, WriteEvent, WriteOptions, WriteResult, WriteRow, WsRequestFrame, WsResponseFrame, WsResponseKind, adminClaimCapabilities, allowAll, allowVerbs, and, applyRowFilters, assertNoRepeatedIds, capabilitiesFor, checkRevocable, checkUpdatable, decodeList, denyAll, denyVerbs, describeGrant, encodeGrant, encodeList, expandFlat, filterTooBroad, flattenGrant, grantCovers, grantEntriesConfer, grantEntryError, grantIsUniform, intersectGrants, isActiveAdminKeyRow, isAuthCause, isBatchElementError, isColumnField, isEncryptedKey, isResolverFrameError, isRestrictViolation, makeAuthorizationProvider, makeTokenProvider, naturalOrderOf, newlyGranted, newlyGrantedPairs, not, or, parseGrantEntries, requireCapability, requireIdentity, requireNamespace, resolveAdminCredential, resolveDefaultKeyPath, resolveDefaultKidPath, revokedAtIso, row };
|
|
898
|
+
export { ADMIN_CAPABILITIES, ActorIdentity, type AdminCredential, type AdminEnv, AfterTxWork, AggFn, ArgType, AutoCrudVerb, BatchElementError, BatchResolver, BridgeClient, BridgeCredential, BridgeCredentialStore, BridgeFrame, BridgeRegistry, BridgeUnreachableError, CLIENT_SUPPLIED_SERVER_FIELD, CanDeleteResult, ClientSuppliedServerFieldError, CommittedWriteBatch, CommittedWritesHook, ConditionalUpdateResult, CoordinatorPlugin, type CrossRefFieldOptions, DATE_UNITS, DEFAULT_CAPABILITIES, DEFAULT_FILTER_WRITE_LIMITS, DEFAULT_ORDERED_BY, Dataset, DatasetRegistry, type DateFieldOptions, type DefineNamespaceOptions, DeleteResult, type DeleteRowArgs, type DeleteRowResult, DropParticipant, DropResult, Dropped, EXPR_AGGREGATES, EXPR_FUNCTIONS, EXPR_LIMITS, Edge, EdgePatch, EdgeRef, EdgeWriteInput, EdgesStore, EmbedSourceContext, EncodeContext, EngineHandle, EngineInput, EnvelopeShape, Expr, ExprType, FILTER_TOO_BROAD, FieldDef, FieldDefCrossRef, FieldDefList, FieldDefScalar, FieldDefStruct, FieldInput, FieldKind, FieldPredicate, FilterCapabilities, FilterOperatorDef, FilterWriteLimits, type FilterWriteMutationResult, FilterWriteOptions, FilterWriteResult, FrameAgg, FrameEntry, FunctionSig, type Grant, HttpHandler, HttpMethod, Id, IdempotencyStore, Identity, IdentityKind, IndexDecl, IndexPlan, type JsonFieldOptions, KernelLifecycleContext, KernelMigration, KernelMigrationContext, KernelNamespaceContribution, KernelPlugin, KernelRouteClaim, type KeyMutationRefusal, type KeyUpdateRefusal, type ListFieldOptions, McpToolRegistration, MissingReferentError, MutationSchema, NLBase, NLResult, NLVocabularyHint, NamespaceConfig, NamespaceDefinition, NamespaceInstallContext, NamespaceMismatch, NamespaceTypeDef, NestedSelection, NlAggregate, NlAskRequest, NlAskResult, NlEvidence, NlFieldPhrase, NlJudgeAction, NlJudgeChoice, NlJudgeStep, NlJudgedStatus, NlNamespacePack, NlNamespaceRulings, NlOutcome, NlPackField, NlPackType, NlPackValueRef, NlParseStatus, NlParsedData, NlServedPack, NlTrailEvent, NlValueAlias, NlWireEvent, Obligation, OnDelete, OnMissing, OrderByClause, OrderedBy, PackEnvelope, PlanClause, PluginLifecycleContext, PluginRouteContext, PluginRouter, Policy, PolicyDecision, PolicyProbeContext, PoolStats, PostWriteHook, ProcessStat, PromotionEvent, QUERY_TIMEOUT, QualifiedFrame, Query, REGEX_BUDGET_EXCEEDED, ROW_METADATA_FIELDS, ROW_POLICY_BLOCKS_WALK, ReadParams, ReadResult, RefOperand, Registry, RegistryBase, RegistryEntry, RegistryEntryInput, RegistryEntryKind, RegistryEntryResolver, RequestContext, RequestObservation, RequestObserver, ReservedField, ResolveObservation, ResolveTarget, Resolver, ResolverArgs, ResolverFrameError, ResolverReturn, ResolverStat, RestrictViolation, Row, RowFilterObligation, RowMetadata, RowMetadataField, RuntimeErrorEntry, RuntimeErrors, RuntimeMetrics, RuntimeOp, STORE_BUSY, SYSTEM_NAMESPACE, type ScalarFieldOptions, ScheduledTask, ScheduledTaskContext, Schema, SlowRequest, StartOpts, StorageReport, type StructFieldOptions, SubstrateRequest, SubstrateResponse, SubstrateServer, SweepDeps, SweepState, TargetState, TlsConfig, type TokenProviderOpts, TxScopeHandles, TypeIndexState, type TypeInput, TypeSchema, TypeStats, TypeStorageReport, TypedResolver, UnsupportedFilterError, UpdateFieldRef, type UpdateResolverOptions, VALUE_OUT_OF_RANGE, VirtualMutationDef, VirtualTypeDef, WALKS_IN_MUTATION, WALKS_IN_SUBSCRIPTION, WALKS_NEED_PARTITIONED, WALKS_UNSUPPORTED_STORE, WALK_BUDGET_EXCEEDED, WALK_UNSUPPORTED_REF, WS_CODE_SUBSCRIPTION_UNSUPPORTED_FRAME, WS_REASON_SERVER_RESTART, WS_REASON_SUBSCRIPTION_OVERLOADED, WalkAgg, WalkAggOperand, WalkAggPredicate, WalkNode, WalkPick, WhereClause, WriteEvent, WriteOptions, WriteResult, WriteRow, WsRequestFrame, WsResponseFrame, WsResponseKind, adminClaimCapabilities, allowAll, allowVerbs, and, applyRowFilters, assertNoRepeatedIds, capabilitiesFor, checkRevocable, checkUpdatable, decodeList, denyAll, denyVerbs, describeGrant, encodeGrant, encodeList, expandFlat, filterTooBroad, flattenGrant, grantCovers, grantEntriesConfer, grantEntryError, grantIsUniform, idHint, intersectGrants, isActiveAdminKeyRow, isAuthCause, isBatchElementError, isColumnField, isEncryptedKey, isResolverFrameError, isRestrictViolation, makeAuthorizationProvider, makeTokenProvider, naturalOrderOf, newlyGranted, newlyGrantedPairs, not, or, parseGrantEntries, requireCapability, requireIdentity, requireNamespace, resolveAdminCredential, resolveDefaultKeyPath, resolveDefaultKidPath, revokedAtIso, row };
|
package/dist/sdk.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $t as isColumnField, A as isReservedAutoCrudField, An as WALKS_IN_SUBSCRIPTION, B as createResolver, Bn as
|
|
1
|
+
import { $t as isColumnField, A as isReservedAutoCrudField, An as WALKS_IN_SUBSCRIPTION, B as createResolver, Bn as isRestrictViolation, Bt as jsonResponse, C as makeCtx, Cn as ReservedField, D as RESERVED_AUTOCRUD_FIELDS, Dn as UnsupportedFilterError, E as selectAll, En as STORE_BUSY, F as createResolverWithEdges, Fn as filterTooBroad, G as listResolver, Gn as canonicalize, Gt as WS_REASON_SERVER_RESTART, H as updateResolver, Hn as CLIENT_SUPPLIED_SERVER_FIELD, I as installAutoCrud, In as idHint, J as resolveIdentity, Jt as normaliseVocabValues, K as getResolver, Kn as BootstrapConfigError, Kt as WS_REASON_SUBSCRIPTION_OVERLOADED, L as deleteManyResolver, Ln as isAuthCause, Lt as JSON_HEADERS, M as field, Mn as WALKS_UNSUPPORTED_STORE, N as AutoCrudNameCollisionError, Nn as WALK_BUDGET_EXCEEDED, O as RESERVED_AUTOCRUD_FIELD_NAMES, On as VALUE_OUT_OF_RANGE, P as autoCrudOptionsOf, Pn as WALK_UNSUPPORTED_REF, Qt as DEFAULT_ORDERED_BY, R as updateManyResolver, Rn as isBatchElementError, S as EngineQueryError, Sn as ROW_POLICY_BLOCKS_WALK, T as queryOne, Tn as RestrictViolation, U as applyUpdatePatch, Un as ROW_METADATA_FIELDS, V as deleteResolver, Vn as DEFAULT_FILTER_WRITE_LIMITS, Vt as parseJsonBody, W as deleteRow, Wn as assertNoRepeatedIds, Wt as WS_CODE_SUBSCRIPTION_UNSUPPORTED_FRAME, X as resolveEntityRow, Xt as storedVocabSpellings, Y as resolveEntityId, Yt as normaliseVocabWhere, Zt as vocabImplication, _n as FILTER_TOO_BROAD, an as normaliseMetadataWhere, b as assertOrderedBy, bn as QUERY_TIMEOUT, cn as ISO_INSTANT_FORM, dn as isIsoTimestamp, en as naturalOrderOf, fn as normalizeIsoTimestamp, gn as BridgeUnreachableError, hn as BatchElementError, in as normaliseMetadataOrderBy, j as reservedMetadataFieldMessage, jn as WALKS_NEED_PARTITIONED, k as RESERVED_METADATA_FIELD_NAMES, kn as WALKS_IN_MUTATION, ln as isImpossibleIsoTimestamp, mn as validateHardDeleteEnv, nn as METADATA_AUTHOR_FIELDS, on as normaliseWalkNode, pn as assertHardDeleteAllowed, q as UnattributedWriteError, qn as defineBootstrap, qt as canonicalVocabValue, rn as METADATA_FILTER_FIELDS, sn as createKeyedMutex, tn as RegistryBase, un as isIsoInstant, vn as MissingReferentError, w as queryAll, wn as ResolverFrameError, x as defineNamespace, xn as REGEX_BUDGET_EXCEEDED, y as assertIndexDecl, yn as NamespaceMismatch, z as purgeResolver, zn as isResolverFrameError, zt as error400 } from "./src-C0ylwQFC.js";
|
|
2
2
|
import { a as adminClaimCapabilities, c as makeTokenProvider, d as resolveDefaultKidPath, i as DEFAULT_CAPABILITIES, l as resolveAdminCredential, n as trimTrailingSlashes, o as isEncryptedKey, r as ADMIN_CAPABILITIES, s as makeAuthorizationProvider, t as parsePositiveInt, u as resolveDefaultKeyPath } from "./env-utils-s25Z1YSA.js";
|
|
3
3
|
import { A as expandFlat, C as not, D as isActiveAdminKeyRow, E as describeGrant, F as parseGrantEntries, I as decodeList, L as encodeList, M as grantEntryError, N as grantIsUniform, O as capabilitiesFor, P as intersectGrants, S as and, T as SYSTEM_NAMESPACE, _ as grantCovers, a as denyAll, b as newlyGrantedPairs, c as requireIdentity, d as confersAnywhere, f as coversNamespace, g as checkUpdatable, h as checkRevocable, i as allowVerbs, j as flattenGrant, k as encodeGrant, l as requireNamespace, m as grantedIn, n as row, o as denyVerbs, p as grantOf, r as allowAll, s as requireCapability, t as applyRowFilters, u as allCapabilities, v as grantEntriesConfer, w as or, x as revokedAtIso, y as newlyGranted } from "./src-DmiUWOLp.js";
|
|
4
4
|
import { B as EXPR_AGGREGATES, F as isInt32, H as EXPR_LIMITS, I as parseInt64, L as stringifyJson, M as formatQualifiedKey, N as parseQualifiedKey, P as isInt16, R as stringifyJsonExact, U as assertNever, V as EXPR_FUNCTIONS, z as DATE_UNITS } from "./src-B_kHkbsr.js";
|
|
5
5
|
|
|
6
|
-
export { ADMIN_CAPABILITIES, AutoCrudNameCollisionError, BatchElementError, BootstrapConfigError, BridgeUnreachableError, CLIENT_SUPPLIED_SERVER_FIELD, DATE_UNITS, DEFAULT_CAPABILITIES, DEFAULT_FILTER_WRITE_LIMITS, DEFAULT_ORDERED_BY, EXPR_AGGREGATES, EXPR_FUNCTIONS, EXPR_LIMITS, EngineQueryError, FILTER_TOO_BROAD, ISO_INSTANT_FORM, JSON_HEADERS, METADATA_AUTHOR_FIELDS, METADATA_FILTER_FIELDS, MissingReferentError, NamespaceMismatch, QUERY_TIMEOUT, REGEX_BUDGET_EXCEEDED, RESERVED_AUTOCRUD_FIELDS, RESERVED_AUTOCRUD_FIELD_NAMES, RESERVED_METADATA_FIELD_NAMES, ROW_METADATA_FIELDS, ROW_POLICY_BLOCKS_WALK, RegistryBase, ReservedField, ResolverFrameError, RestrictViolation, STORE_BUSY, SYSTEM_NAMESPACE, UnattributedWriteError, UnsupportedFilterError, VALUE_OUT_OF_RANGE, WALKS_IN_MUTATION, WALKS_IN_SUBSCRIPTION, WALKS_NEED_PARTITIONED, WALKS_UNSUPPORTED_STORE, WALK_BUDGET_EXCEEDED, WALK_UNSUPPORTED_REF, WS_CODE_SUBSCRIPTION_UNSUPPORTED_FRAME, WS_REASON_SERVER_RESTART, WS_REASON_SUBSCRIPTION_OVERLOADED, adminClaimCapabilities, allCapabilities, allowAll, allowVerbs, and, applyRowFilters, applyUpdatePatch, assertHardDeleteAllowed, assertIndexDecl, assertNever, assertNoRepeatedIds, assertOrderedBy, autoCrudOptionsOf, canonicalVocabValue, canonicalize, capabilitiesFor, checkRevocable, checkUpdatable, confersAnywhere, coversNamespace, createKeyedMutex, createResolver, createResolverWithEdges, decodeList, defineBootstrap, defineNamespace, deleteManyResolver, deleteResolver, deleteRow, denyAll, denyVerbs, describeGrant, encodeGrant, encodeList, error400, expandFlat, field, filterTooBroad, flattenGrant, formatQualifiedKey, getResolver, grantCovers, grantEntriesConfer, grantEntryError, grantIsUniform, grantOf, grantedIn, installAutoCrud, intersectGrants, isActiveAdminKeyRow, isAuthCause, isBatchElementError, isColumnField, isEncryptedKey, isImpossibleIsoTimestamp, isInt16, isInt32, isIsoInstant, isIsoTimestamp, isReservedAutoCrudField, isResolverFrameError, isRestrictViolation, jsonResponse, listResolver, makeAuthorizationProvider, makeCtx, makeTokenProvider, naturalOrderOf, newlyGranted, newlyGrantedPairs, normaliseMetadataOrderBy, normaliseMetadataWhere, normaliseVocabValues, normaliseVocabWhere, normaliseWalkNode, normalizeIsoTimestamp, not, or, parseGrantEntries, parseInt64, parseJsonBody, parsePositiveInt, parseQualifiedKey, purgeResolver, queryAll, queryOne, requireCapability, requireIdentity, requireNamespace, reservedMetadataFieldMessage, resolveAdminCredential, resolveDefaultKeyPath, resolveDefaultKidPath, resolveEntityId, resolveEntityRow, resolveIdentity, revokedAtIso, row, selectAll, storedVocabSpellings, stringifyJson, stringifyJsonExact, trimTrailingSlashes, updateManyResolver, updateResolver, validateHardDeleteEnv, vocabImplication };
|
|
6
|
+
export { ADMIN_CAPABILITIES, AutoCrudNameCollisionError, BatchElementError, BootstrapConfigError, BridgeUnreachableError, CLIENT_SUPPLIED_SERVER_FIELD, DATE_UNITS, DEFAULT_CAPABILITIES, DEFAULT_FILTER_WRITE_LIMITS, DEFAULT_ORDERED_BY, EXPR_AGGREGATES, EXPR_FUNCTIONS, EXPR_LIMITS, EngineQueryError, FILTER_TOO_BROAD, ISO_INSTANT_FORM, JSON_HEADERS, METADATA_AUTHOR_FIELDS, METADATA_FILTER_FIELDS, MissingReferentError, NamespaceMismatch, QUERY_TIMEOUT, REGEX_BUDGET_EXCEEDED, RESERVED_AUTOCRUD_FIELDS, RESERVED_AUTOCRUD_FIELD_NAMES, RESERVED_METADATA_FIELD_NAMES, ROW_METADATA_FIELDS, ROW_POLICY_BLOCKS_WALK, RegistryBase, ReservedField, ResolverFrameError, RestrictViolation, STORE_BUSY, SYSTEM_NAMESPACE, UnattributedWriteError, UnsupportedFilterError, VALUE_OUT_OF_RANGE, WALKS_IN_MUTATION, WALKS_IN_SUBSCRIPTION, WALKS_NEED_PARTITIONED, WALKS_UNSUPPORTED_STORE, WALK_BUDGET_EXCEEDED, WALK_UNSUPPORTED_REF, WS_CODE_SUBSCRIPTION_UNSUPPORTED_FRAME, WS_REASON_SERVER_RESTART, WS_REASON_SUBSCRIPTION_OVERLOADED, adminClaimCapabilities, allCapabilities, allowAll, allowVerbs, and, applyRowFilters, applyUpdatePatch, assertHardDeleteAllowed, assertIndexDecl, assertNever, assertNoRepeatedIds, assertOrderedBy, autoCrudOptionsOf, canonicalVocabValue, canonicalize, capabilitiesFor, checkRevocable, checkUpdatable, confersAnywhere, coversNamespace, createKeyedMutex, createResolver, createResolverWithEdges, decodeList, defineBootstrap, defineNamespace, deleteManyResolver, deleteResolver, deleteRow, denyAll, denyVerbs, describeGrant, encodeGrant, encodeList, error400, expandFlat, field, filterTooBroad, flattenGrant, formatQualifiedKey, getResolver, grantCovers, grantEntriesConfer, grantEntryError, grantIsUniform, grantOf, grantedIn, idHint, installAutoCrud, intersectGrants, isActiveAdminKeyRow, isAuthCause, isBatchElementError, isColumnField, isEncryptedKey, isImpossibleIsoTimestamp, isInt16, isInt32, isIsoInstant, isIsoTimestamp, isReservedAutoCrudField, isResolverFrameError, isRestrictViolation, jsonResponse, listResolver, makeAuthorizationProvider, makeCtx, makeTokenProvider, naturalOrderOf, newlyGranted, newlyGrantedPairs, normaliseMetadataOrderBy, normaliseMetadataWhere, normaliseVocabValues, normaliseVocabWhere, normaliseWalkNode, normalizeIsoTimestamp, not, or, parseGrantEntries, parseInt64, parseJsonBody, parsePositiveInt, parseQualifiedKey, purgeResolver, queryAll, queryOne, requireCapability, requireIdentity, requireNamespace, reservedMetadataFieldMessage, resolveAdminCredential, resolveDefaultKeyPath, resolveDefaultKidPath, resolveEntityId, resolveEntityRow, resolveIdentity, revokedAtIso, row, selectAll, storedVocabSpellings, stringifyJson, stringifyJsonExact, trimTrailingSlashes, updateManyResolver, updateResolver, validateHardDeleteEnv, vocabImplication };
|
|
@@ -154,6 +154,11 @@ var ResolverFrameError = class extends Error {
|
|
|
154
154
|
function filterTooBroad(namespace, type, maxMatch) {
|
|
155
155
|
return new ResolverFrameError(FILTER_TOO_BROAD, `${namespace}/${type}: the filter matches more than ${maxMatch} rows; nothing changed. Narrow the where, or raise SUBSTRATE_FILTER_WRITE_MAX_MATCH`, { maxMatch });
|
|
156
156
|
}
|
|
157
|
+
const UUID_SHAPE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
158
|
+
/** A miss on an id that is not UUID-shaped is usually a shortId sent where the UUID belongs. */
|
|
159
|
+
function idHint(value) {
|
|
160
|
+
return typeof value === "string" && UUID_SHAPE.test(value) ? "" : " — if this is a shortId, resolve it with where: { shortId: { eq: N } }";
|
|
161
|
+
}
|
|
157
162
|
/**
|
|
158
163
|
* Thrown by a write-path resolver when a crossRef declaring `onMissing: 'reject'`
|
|
159
164
|
* references a target that does not exist (or has been tombstoned). Extends
|
|
@@ -163,7 +168,7 @@ function filterTooBroad(namespace, type, maxMatch) {
|
|
|
163
168
|
var MissingReferentError = class extends ResolverFrameError {
|
|
164
169
|
name = "MissingReferentError";
|
|
165
170
|
constructor(field, target) {
|
|
166
|
-
super("missing_referent", `crossRef '${field}' references a non-existent ${target.ns}/${target.type} (id=${target.id})`, {
|
|
171
|
+
super("missing_referent", `crossRef '${field}' references a non-existent ${target.ns}/${target.type} (id=${target.id})${idHint(target.id)}`, {
|
|
167
172
|
field,
|
|
168
173
|
target
|
|
169
174
|
});
|
|
@@ -9705,6 +9710,12 @@ var Engine = class {
|
|
|
9705
9710
|
}
|
|
9706
9711
|
return false;
|
|
9707
9712
|
}
|
|
9713
|
+
/** An unqualified key's refusal, naming the fix when one is evident. */
|
|
9714
|
+
#unqualifiedMessage(key) {
|
|
9715
|
+
if (key === "params" || key === "fields" || key === "where") return `'${key}' is part of a frame, not a frame key: send { "<ns>/<op>": { "params": {...}, "fields": {...} } }`;
|
|
9716
|
+
const owners = [...this.#namespaces].filter(([, cfg]) => cfg.registry.get(key) !== void 0);
|
|
9717
|
+
return `unqualified frame key '${key}' — expected '<ns>/<name>'${owners.length === 1 ? ` — did you mean '${owners[0]?.[0]}/${key}'?` : ""}`;
|
|
9718
|
+
}
|
|
9708
9719
|
/**
|
|
9709
9720
|
* Everything a frame entry does before its resolver runs: the grant, the
|
|
9710
9721
|
* lookups, policy, the walk refusals, the filter guard, the cursor and the
|
|
@@ -9712,7 +9723,7 @@ var Engine = class {
|
|
|
9712
9723
|
*/
|
|
9713
9724
|
#prepareEntry(envelope, key, entry, ctxBase, operation, tx, txEdges, parsed, onWrite, signal, afterTx, txEntries) {
|
|
9714
9725
|
if (!parsed) {
|
|
9715
|
-
addError(envelope, [key],
|
|
9726
|
+
addError(envelope, [key], this.#unqualifiedMessage(key), "unqualified_key");
|
|
9716
9727
|
this.#metric("engine_unqualified_key", key);
|
|
9717
9728
|
return null;
|
|
9718
9729
|
}
|
|
@@ -9946,7 +9957,7 @@ var Engine = class {
|
|
|
9946
9957
|
*/
|
|
9947
9958
|
async #runArrayEntry(envelope, key, parsed, frames, ctxBase, onWrite, signal) {
|
|
9948
9959
|
if (!parsed) {
|
|
9949
|
-
addError(envelope, [key],
|
|
9960
|
+
addError(envelope, [key], this.#unqualifiedMessage(key), "unqualified_key");
|
|
9950
9961
|
this.#metric("engine_unqualified_key", key);
|
|
9951
9962
|
return;
|
|
9952
9963
|
}
|
|
@@ -11766,7 +11777,7 @@ function preparePatch(rawParams, fields) {
|
|
|
11766
11777
|
* missing row has a true answer; asserting a write against one does not.
|
|
11767
11778
|
*/
|
|
11768
11779
|
function updateNotFound(typeName, id) {
|
|
11769
|
-
return new ResolverFrameError("not_found", `updateResolver('${typeName}'): no row with id '${String(id)}'`, { field: "id" });
|
|
11780
|
+
return new ResolverFrameError("not_found", `updateResolver('${typeName}'): no row with id '${String(id)}'${idHint(id)}`, { field: "id" });
|
|
11770
11781
|
}
|
|
11771
11782
|
|
|
11772
11783
|
//#endregion
|
|
@@ -19602,4 +19613,4 @@ function kernelMigrationTracking(sql) {
|
|
|
19602
19613
|
}
|
|
19603
19614
|
|
|
19604
19615
|
//#endregion
|
|
19605
|
-
export { publishSchema as $, isColumnField as $t, isReservedAutoCrudField as A, WALKS_IN_SUBSCRIPTION as An, decodeCursor as At, createResolver as B,
|
|
19616
|
+
export { publishSchema as $, isColumnField as $t, isReservedAutoCrudField as A, WALKS_IN_SUBSCRIPTION as An, decodeCursor as At, createResolver as B, isRestrictViolation as Bn, jsonResponse as Bt, makeCtx as C, ReservedField as Cn, metadataExprType as Ct, RESERVED_AUTOCRUD_FIELDS as D, UnsupportedFilterError as Dn, LIKE_TRAILING_ESCAPE as Dt, selectAll as E, STORE_BUSY as En, isJsonPathPredicate as Et, createResolverWithEdges as F, filterTooBroad as Fn, fieldRequested as Ft, listResolver as G, canonicalize as Gn, WS_REASON_SERVER_RESTART as Gt, updateResolver as H, CLIENT_SUPPLIED_SERVER_FIELD as Hn, parseAuthConfig as Ht, installAutoCrud as I, idHint as In, HttpBridgeClient as It, resolveIdentity as J, normaliseVocabValues as Jt, getResolver as K, BootstrapConfigError as Kn, WS_REASON_SUBSCRIPTION_OVERLOADED as Kt, deleteManyResolver as L, isAuthCause as Ln, JSON_HEADERS as Lt, field as M, WALKS_UNSUPPORTED_STORE as Mn, normalizeOrderBy as Mt, AutoCrudNameCollisionError as N, WALK_BUDGET_EXCEEDED as Nn, fullBuiltinOperators as Nt, RESERVED_AUTOCRUD_FIELD_NAMES as O, VALUE_OUT_OF_RANGE as On, endsWithEscape as Ot, autoCrudOptionsOf as P, WALK_UNSUPPORTED_REF as Pn, applyExtensionResultMeta as Pt, loadPlugins as Q, DEFAULT_ORDERED_BY as Qt, updateManyResolver as R, isBatchElementError as Rn, buildContext as Rt, EngineQueryError as S, ROW_POLICY_BLOCKS_WALK as Sn, exprTypeOfField as St, queryOne as T, RestrictViolation as Tn, assertJsonPathPredicate as Tt, applyUpdatePatch as U, ROW_METADATA_FIELDS as Un, signHs256 as Ut, deleteResolver as V, DEFAULT_FILTER_WRITE_LIMITS as Vn, parseJsonBody as Vt, deleteRow as W, assertNoRepeatedIds as Wn, WS_CODE_SUBSCRIPTION_UNSUPPORTED_FRAME as Wt, resolveEntityRow as X, storedVocabSpellings as Xt, resolveEntityId as Y, normaliseVocabWhere as Yt, MemoryEdgesStore as Z, vocabImplication as Zt, AUDIT_EVENT_TYPE as _, FILTER_TOO_BROAD as _n, refNames as _t, composeFromManifests as a, normaliseMetadataWhere as an, forEachWalkHop as at, assertOrderedBy as b, QUERY_TIMEOUT as bn, registerExtensionOperator as bt, MemoryDataset as c, ISO_INSTANT_FORM as cn, windowGroupBy as ct, uuidFromName as d, isIsoTimestamp as dn, aggType as dt, naturalOrderOf as en, effectiveFilterOperators as et, emitFieldEvents as f, normalizeIsoTimestamp as fn, canRaise as ft, buildAuditRow as g, BridgeUnreachableError as gn, isRefOperand as gt, SYSTEM_TYPE_DEFS as h, BatchElementError as hn, groupConjuncts as ht, PluginLoadError as i, normaliseMetadataOrderBy as in, saveSweepState as it, reservedMetadataFieldMessage as j, WALKS_NEED_PARTITIONED as jn, encodeCursor as jt, RESERVED_METADATA_FIELD_NAMES as k, WALKS_IN_MUTATION as kn, CursorDecodeError as kt, planServesShape as l, isImpossibleIsoTimestamp as ln, preResolveExtensionOperatorsDetailed as lt, runInviteSweep as m, validateHardDeleteEnv as mn, bindingWalks as mt, kernelMigrationTracking as n, METADATA_AUTHOR_FIELDS as nn, loadSweepState as nt, DEFAULT_NAMESPACE as o, normaliseWalkNode as on, whereUsesWalks as ot, migrateFieldValues as p, assertHardDeleteAllowed as pn, isDateField as pt, UnattributedWriteError as q, defineBootstrap as qn, canonicalVocabValue as qt, mountKernelRoute as r, METADATA_FILTER_FIELDS as rn, runSweep as rt, compose as s, createKeyedMutex as sn, sharedPicks as st, composeKernelPlugins as t, RegistryBase as tn, applyObligations as tt, isStoreProfileName as u, isIsoInstant as un, aggParts as ut, INVITE_TYPE as v, MissingReferentError as vn, getExtensionOperator as vt, queryAll as w, ResolverFrameError as wn, walkAggExprType as wt, defineNamespace as x, REGEX_BUDGET_EXCEEDED as xn, unregisterExtensionOperator as xt, assertIndexDecl as y, NamespaceMismatch as yn, listExtensionOperators as yt, purgeResolver as z, isResolverFrameError as zn, error400 as zt };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { i as txScopeIdFor, l as typeTableRef, s as guardedRefRead, u as whileNoTypeTable } from "./src-
|
|
2
|
-
import { B as ROW_FILTER_FIELD, V as matchesRowFilter, W as inFlightError, Y as unresolvedRow, Z as cosineSimilarity, et as memberKey } from "./plugin-
|
|
1
|
+
import { i as txScopeIdFor, l as typeTableRef, s as guardedRefRead, u as whileNoTypeTable } from "./src-DxD3iktO.js";
|
|
2
|
+
import { B as ROW_FILTER_FIELD, V as matchesRowFilter, W as inFlightError, Y as unresolvedRow, Z as cosineSimilarity, et as memberKey } from "./plugin-DWagHKxm.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../plugins/substrate-recall/package.json
|
|
5
|
-
var version = "1.0.0-beta.
|
|
5
|
+
var version = "1.0.0-beta.2";
|
|
6
6
|
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region ../../plugins/substrate-recall/src/in-memory-cluster-store.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as publishSchema, D as RESERVED_AUTOCRUD_FIELDS, I as installAutoCrud, J as resolveIdentity, Lt as JSON_HEADERS, M as field, O as RESERVED_AUTOCRUD_FIELD_NAMES, P as autoCrudOptionsOf,
|
|
1
|
+
import { $ as publishSchema, D as RESERVED_AUTOCRUD_FIELDS, Gn as canonicalize$1, I as installAutoCrud, J as resolveIdentity, Lt as JSON_HEADERS, M as field, O as RESERVED_AUTOCRUD_FIELD_NAMES, P as autoCrudOptionsOf, b as assertOrderedBy, d as uuidFromName, f as emitFieldEvents, j as reservedMetadataFieldMessage, l as planServesShape, p as migrateFieldValues, wn as ResolverFrameError, x as defineNamespace, y as assertIndexDecl } from "./src-C0ylwQFC.js";
|
|
2
2
|
import { s as requireCapability } from "./src-DmiUWOLp.js";
|
|
3
3
|
import "./src-B_kHkbsr.js";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as isColumnField, At as decodeCursor, Cn as ReservedField, Ct as metadataExprType, Dn as UnsupportedFilterError, Dt as LIKE_TRAILING_ESCAPE, En as STORE_BUSY, Et as isJsonPathPredicate, Fn as filterTooBroad, Ft as fieldRequested, Mt as normalizeOrderBy, Nt as fullBuiltinOperators, On as VALUE_OUT_OF_RANGE, Ot as endsWithEscape, Pn as WALK_UNSUPPORTED_REF, Pt as applyExtensionResultMeta, St as exprTypeOfField, Tt as assertJsonPathPredicate,
|
|
1
|
+
import { $t as isColumnField, At as decodeCursor, Cn as ReservedField, Ct as metadataExprType, Dn as UnsupportedFilterError, Dt as LIKE_TRAILING_ESCAPE, En as STORE_BUSY, Et as isJsonPathPredicate, Fn as filterTooBroad, Ft as fieldRequested, Mt as normalizeOrderBy, Nt as fullBuiltinOperators, On as VALUE_OUT_OF_RANGE, Ot as endsWithEscape, Pn as WALK_UNSUPPORTED_REF, Pt as applyExtensionResultMeta, St as exprTypeOfField, Tt as assertJsonPathPredicate, Wn as assertNoRepeatedIds, _t as refNames, at as forEachWalkHop, bn as QUERY_TIMEOUT, ct as windowGroupBy, dt as aggType, en as naturalOrderOf, fn as normalizeIsoTimestamp, ft as canRaise, gt as isRefOperand, ht as groupConjuncts, jt as encodeCursor, kt as CursorDecodeError, lt as preResolveExtensionOperatorsDetailed, mt as bindingWalks, ot as whereUsesWalks, pt as isDateField, rn as METADATA_FILTER_FIELDS, sn as createKeyedMutex, st as sharedPicks, ut as aggParts, wn as ResolverFrameError, wt as walkAggExprType, yn as NamespaceMismatch } from "./src-C0ylwQFC.js";
|
|
2
2
|
import { F as isInt32, I as parseInt64, L as stringifyJson, P as isInt16, R as stringifyJsonExact, z as DATE_UNITS } from "./src-B_kHkbsr.js";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
|
|
@@ -551,7 +551,8 @@ function buildRowProjection(sql, table, fields, alias = "r", walk = null) {
|
|
|
551
551
|
const wanted = [...keys, RAW_KEY];
|
|
552
552
|
const subset = sql`COALESCE(CASE WHEN pg_column_size(${ex}) < ${sql.unsafe(String(INLINE_EXTRA_BYTES))} THEN (SELECT jsonb_object_agg(k, ${ex} -> k) FROM unnest(${wanted}::text[]) k WHERE ${ex} ? k) ELSE (SELECT jsonb_object_agg(e.key, e.value) FROM jsonb_each(${ex}) e WHERE e.key = ANY(${wanted}::text[])) END, '{}'::jsonb)`;
|
|
553
553
|
const allColumns = [...keys].every((k) => k === "id" || table.column(k)?.state === "column");
|
|
554
|
-
const
|
|
554
|
+
const probe = (k) => sql`CASE WHEN ${ex} ? ${k}::text THEN jsonb_build_object(${k}::text, ${ex} -> ${k}::text) ELSE '{}'::jsonb END`;
|
|
555
|
+
const extra = fields === void 0 ? ex : allColumns ? sql`CASE WHEN ${ex} ?| ${["id", RAW_KEY]}::text[] THEN ${probe("id")} || ${probe(RAW_KEY)} ELSE '{}'::jsonb END` : subset;
|
|
555
556
|
const head = columns.length === 0 ? "" : `${columns.join(", ")}, `;
|
|
556
557
|
return sql`${sql.unsafe(head)}${extra} AS extra${walk === null ? sql`` : sql`, ${walk}`}`;
|
|
557
558
|
}
|
|
@@ -2333,24 +2334,39 @@ async function freeTableName(tx, namespace, type) {
|
|
|
2333
2334
|
WHERE relname = ${preferred} AND relnamespace = current_schema()::regnamespace`).length === 0 ? preferred : hashedName(preferred, [namespace, type]);
|
|
2334
2335
|
}
|
|
2335
2336
|
const kindCheck = (column) => `CHECK (${column} IS NULL OR ${column} IN ('agent','user','system'))`;
|
|
2337
|
+
/** Each column kind's alignment in bytes; 0 for variable-length (text), which goes last. */
|
|
2338
|
+
const ALIGN = {
|
|
2339
|
+
date: 8,
|
|
2340
|
+
number: 8,
|
|
2341
|
+
int64: 8,
|
|
2342
|
+
int32: 4,
|
|
2343
|
+
int16: 2,
|
|
2344
|
+
boolean: 1,
|
|
2345
|
+
text: 0,
|
|
2346
|
+
enum: 0,
|
|
2347
|
+
crossRef: 0
|
|
2348
|
+
};
|
|
2336
2349
|
function createTableSql(table, declared, enforceUuidCheck) {
|
|
2350
|
+
const fields = [...declared].sort(([, a], [, b]) => ALIGN[b.kind] - ALIGN[a.kind]);
|
|
2351
|
+
const column = ([field, { kind, vocab }]) => {
|
|
2352
|
+
const c = columnName(field);
|
|
2353
|
+
const def = `${ident(c)} ${PG_TYPE$1[kind]}`;
|
|
2354
|
+
return kind === "enum" ? [def, `CONSTRAINT ${ident(enumCheckName(c))} ${enumCheck(c, vocab)}`] : [def];
|
|
2355
|
+
};
|
|
2337
2356
|
const parts = [
|
|
2338
|
-
"id text PRIMARY KEY",
|
|
2339
2357
|
"deleted_at timestamptz NULL",
|
|
2340
2358
|
"created_at timestamptz NULL",
|
|
2341
2359
|
"updated_at timestamptz NULL",
|
|
2360
|
+
"seq bigint NULL",
|
|
2361
|
+
...fields.filter(([, f]) => ALIGN[f.kind] > 0).flatMap(column),
|
|
2362
|
+
"id text PRIMARY KEY",
|
|
2342
2363
|
`created_by_kind text NULL ${kindCheck("created_by_kind")}`,
|
|
2343
2364
|
"created_by_id text NULL",
|
|
2344
2365
|
`updated_by_kind text NULL ${kindCheck("updated_by_kind")}`,
|
|
2345
2366
|
"updated_by_id text NULL",
|
|
2346
|
-
"
|
|
2347
|
-
|
|
2367
|
+
"extra jsonb NOT NULL DEFAULT '{}'",
|
|
2368
|
+
...fields.filter(([, f]) => ALIGN[f.kind] === 0).flatMap(column)
|
|
2348
2369
|
];
|
|
2349
|
-
for (const [field, { kind, vocab }] of declared) {
|
|
2350
|
-
const column = columnName(field);
|
|
2351
|
-
parts.push(`${ident(column)} ${PG_TYPE$1[kind]}`);
|
|
2352
|
-
if (kind === "enum") parts.push(`CONSTRAINT ${ident(enumCheckName(column))} ${enumCheck(column, vocab)}`);
|
|
2353
|
-
}
|
|
2354
2370
|
if (enforceUuidCheck) parts.push(`CONSTRAINT id_uuid_format CHECK (id ~ '${UUID_REGEX}')`);
|
|
2355
2371
|
return `CREATE TABLE ${ident(table)} (\n ${parts.join(",\n ")}\n)`;
|
|
2356
2372
|
}
|
|
@@ -5804,7 +5820,9 @@ function buildGroupedRead(sql, spec, matched, joins, table, fieldDef) {
|
|
|
5804
5820
|
}
|
|
5805
5821
|
const raises = aggs.some((a) => a.raises) || Object.values(spec.groupBy ?? {}).some(canRaise) || canRaise(spec.having);
|
|
5806
5822
|
const grouped = sql`SELECT ${list([...keys.map((k) => sql`${k.frag} AS ${u(`k${k.i}`)}`), ...aggs.map((a) => sql`${a.raw} AS ${u(`a${a.j}`)}`)])} FROM ${u(table.from)} r${joins} WHERE ${matched}${keys.length === 0 ? sql`` : sql` GROUP BY ${u(keys.map((_, i) => i + 1).join(", "))}`} OFFSET 0`;
|
|
5807
|
-
const
|
|
5823
|
+
const firstOrder = spec.orderBy?.[0] === void 0 ? void 0 : Object.keys(spec.orderBy[0])[0];
|
|
5824
|
+
const fenced = raises && spec.limit !== void 0 && !aggs.some((a) => a.name === firstOrder);
|
|
5825
|
+
const inner = fenced ? sql`SELECT y.*, count(*) OVER () AS w FROM (${grouped}) y OFFSET 0` : grouped;
|
|
5808
5826
|
const outputs = new Map([...keys.map((k) => [k.name, u(`x.k${k.i}`)]), ...aggs.map((a) => [a.name, a.typed])]);
|
|
5809
5827
|
const types = new Map([...keys.map((k) => [k.name, k.type]), ...aggs.map((a) => [a.name, a.type])]);
|
|
5810
5828
|
const having = spec.having === void 0 ? sql`` : sql` WHERE ${compileExprTyped(sql, spec.having, {
|
|
@@ -5832,7 +5850,7 @@ function buildGroupedRead(sql, spec, matched, joins, table, fieldDef) {
|
|
|
5832
5850
|
const limit = spec.limit === void 0 ? sql`` : sql` LIMIT ${spec.limit + 1}`;
|
|
5833
5851
|
const offset = spec.offset === void 0 || spec.offset === 0 ? sql`` : sql` OFFSET ${spec.offset}`;
|
|
5834
5852
|
return {
|
|
5835
|
-
statement: sql`SELECT 1 AS g, ${list([...outs.map((o, n) => sql`${project(o.frag, o.type)} AS ${u(`o${n}`)}`), ...
|
|
5853
|
+
statement: sql`SELECT 1 AS g, ${list([...outs.map((o, n) => sql`${project(o.frag, o.type)} AS ${u(`o${n}`)}`), ...fenced ? [sql`x.w`] : []])} FROM (${inner}) x${having}${order.length === 0 ? sql`` : sql` ORDER BY ${list(order)}`}${limit}${offset}`,
|
|
5836
5854
|
decode: (row) => Object.fromEntries(outs.map((o, n) => {
|
|
5837
5855
|
const v = row[`o${n}`] ?? null;
|
|
5838
5856
|
return [o.name, o.type === "int64" && v !== null ? BigInt(v) : v];
|
package/dist/substrate-admin.js
CHANGED
|
@@ -36,7 +36,7 @@ function isEntrypointPath(moduleUrl, argv1) {
|
|
|
36
36
|
*/
|
|
37
37
|
if (isEntrypointPath(import.meta.url, process.argv[1])) {
|
|
38
38
|
assertNodeVersion();
|
|
39
|
-
import("./run-
|
|
39
|
+
import("./run-D-4sXpTu.js").then(({ runAdminCli }) => runAdminCli());
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
//#endregion
|
package/dist/substrate.js
CHANGED
|
@@ -3,7 +3,7 @@ import { t as assertNodeVersion } from "./node-version-BtK_Nq6z.js";
|
|
|
3
3
|
|
|
4
4
|
//#region src/bin/substrate.ts
|
|
5
5
|
assertNodeVersion();
|
|
6
|
-
import("./cli-
|
|
6
|
+
import("./cli-COS16L1Z.js").then(({ runCli }) => runCli(process.argv.slice(2))).then((code) => process.exit(code));
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
9
|
export { };
|
package/dist/testing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Gt as WS_REASON_SERVER_RESTART, Q as loadPlugins, Ut as signHs256, Z as MemoryEdgesStore, c as MemoryDataset, s as compose } from "./src-
|
|
1
|
+
import { Gt as WS_REASON_SERVER_RESTART, Q as loadPlugins, Ut as signHs256, Z as MemoryEdgesStore, c as MemoryDataset, s as compose } from "./src-C0ylwQFC.js";
|
|
2
2
|
import "./src-B_kHkbsr.js";
|
|
3
|
-
import { b as runMigrations, g as deriveListIndexMigration, n as PgEdgesStore, r as PgDataset, y as runDerivedMigrations } from "./src-
|
|
3
|
+
import { b as runMigrations, g as deriveListIndexMigration, n as PgEdgesStore, r as PgDataset, y as runDerivedMigrations } from "./src-DxD3iktO.js";
|
|
4
4
|
import { t as FakeEmbedder } from "./fake-DdXtb-m8.js";
|
|
5
5
|
import postgres from "postgres";
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mnmal-ai/substrate",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
4
|
"description": "Substrate — an agent-first typed-data server: the substrate and substrate-admin binaries, the built-in plugins and the SDK subpaths.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -35,24 +35,24 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@inquirer/prompts": "^8.7.2",
|
|
38
|
-
"@mnmal-ai/substrate-bootstrap": "1.0.0-beta.
|
|
39
|
-
"@mnmal-ai/substrate-client": "1.0.0-beta.
|
|
40
|
-
"@mnmal-ai/substrate-compose": "1.0.0-beta.
|
|
41
|
-
"@mnmal-ai/substrate-config": "1.0.0-beta.
|
|
42
|
-
"@mnmal-ai/substrate-core": "1.0.0-beta.
|
|
43
|
-
"@mnmal-ai/substrate-dataset-memory": "1.0.0-beta.
|
|
44
|
-
"@mnmal-ai/substrate-dataset-pg": "1.0.0-beta.
|
|
45
|
-
"@mnmal-ai/substrate-embedder": "1.0.0-beta.
|
|
46
|
-
"@mnmal-ai/substrate-filter": "1.0.0-beta.
|
|
47
|
-
"@mnmal-ai/substrate-pack": "1.0.0-beta.
|
|
48
|
-
"@mnmal-ai/substrate-policy": "1.0.0-beta.
|
|
49
|
-
"@mnmal-ai/substrate-proposals": "1.0.0-beta.
|
|
50
|
-
"@mnmal-ai/substrate-recall": "1.0.0-beta.
|
|
51
|
-
"@mnmal-ai/substrate-sdk": "1.0.0-beta.
|
|
52
|
-
"@mnmal-ai/substrate-sentinel-client": "1.0.0-beta.
|
|
53
|
-
"@mnmal-ai/substrate-server-fastify": "1.0.0-beta.
|
|
54
|
-
"@mnmal-ai/substrate-server-memory": "1.0.0-beta.
|
|
55
|
-
"@mnmal-ai/substrate-types": "1.0.0-beta.
|
|
38
|
+
"@mnmal-ai/substrate-bootstrap": "1.0.0-beta.2",
|
|
39
|
+
"@mnmal-ai/substrate-client": "1.0.0-beta.2",
|
|
40
|
+
"@mnmal-ai/substrate-compose": "1.0.0-beta.2",
|
|
41
|
+
"@mnmal-ai/substrate-config": "1.0.0-beta.2",
|
|
42
|
+
"@mnmal-ai/substrate-core": "1.0.0-beta.2",
|
|
43
|
+
"@mnmal-ai/substrate-dataset-memory": "1.0.0-beta.2",
|
|
44
|
+
"@mnmal-ai/substrate-dataset-pg": "1.0.0-beta.2",
|
|
45
|
+
"@mnmal-ai/substrate-embedder": "1.0.0-beta.2",
|
|
46
|
+
"@mnmal-ai/substrate-filter": "1.0.0-beta.2",
|
|
47
|
+
"@mnmal-ai/substrate-pack": "1.0.0-beta.2",
|
|
48
|
+
"@mnmal-ai/substrate-policy": "1.0.0-beta.2",
|
|
49
|
+
"@mnmal-ai/substrate-proposals": "1.0.0-beta.2",
|
|
50
|
+
"@mnmal-ai/substrate-recall": "1.0.0-beta.2",
|
|
51
|
+
"@mnmal-ai/substrate-sdk": "1.0.0-beta.2",
|
|
52
|
+
"@mnmal-ai/substrate-sentinel-client": "1.0.0-beta.2",
|
|
53
|
+
"@mnmal-ai/substrate-server-fastify": "1.0.0-beta.2",
|
|
54
|
+
"@mnmal-ai/substrate-server-memory": "1.0.0-beta.2",
|
|
55
|
+
"@mnmal-ai/substrate-types": "1.0.0-beta.2",
|
|
56
56
|
"@mnmal-ai/surface-core": "0.17.1",
|
|
57
57
|
"@types/node": "^26.6.4",
|
|
58
58
|
"@types/semver": "^7.5.0",
|