@mnmal-ai/substrate 1.0.0-beta.2 → 1.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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 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`) |
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 `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, 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";
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-MJrgIOq8.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
- 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-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";
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-Bvl6kSZl.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-Sc1C0RIX.js";
7
+ import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore } from "./src-D8NiaRYa.js";
8
+ import { et as memberKey } from "./plugin-UnGCrT3p.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.2";
1756
+ var version = "1.0.0-beta.4";
1757
1757
 
1758
1758
  //#endregion
1759
1759
  //#region src/plugin-manifest.ts
@@ -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-C0ylwQFC.js";
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-MJrgIOq8.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-DpnnxRpR.js";
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";
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-C9oqfHOP.js";
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-Bvl6kSZl.js";
7
7
  import { n as runScript, t as DEFAULT_MAX_WRITES } from "./script-ByQ9pzhC.js";
8
- import { D as tryWithPgAdvisoryLock } from "./src-DxD3iktO.js";
9
- import { n as PgLexicalStore, r as PgEmbeddingsStore } from "./src-D1PgjgUg.js";
8
+ import { D as tryWithPgAdvisoryLock } from "./src-Sc1C0RIX.js";
9
+ import { n as PgLexicalStore, r as PgEmbeddingsStore } from "./src-D8NiaRYa.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-C8ZgDrQ7.js");
2168
+ const { runRepl } = await import("./repl-CsuBQ2zu.js");
2169
2169
  config = await runRepl(config);
2170
2170
  } catch (err) {
2171
2171
  if (err.message?.includes("User force closed")) return 130;
@@ -3281,12 +3281,12 @@ const CORE_TOOLS = [
3281
3281
  ];
3282
3282
  /**
3283
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
3284
+ * (`core` while unset or blank). An unknown name throws: a typo that silently registered nothing
3285
3285
  * would read as "this server has no such tool", which is a worse failure than
3286
3286
  * refusing to start.
3287
3287
  */
3288
3288
  function resolveToolAllowlist(raw, known) {
3289
- if (raw === void 0 || raw.trim() === "") return new Set(known);
3289
+ if (raw === void 0 || raw.trim() === "") return new Set(CORE_TOOLS);
3290
3290
  const names = /* @__PURE__ */ new Set();
3291
3291
  for (const n of raw.split(",").map((t) => t.trim())) {
3292
3292
  if (n === "") continue;
@@ -3310,7 +3310,6 @@ async function fetchOverview(endpoint) {
3310
3310
  async function runMcp() {
3311
3311
  const endpoint = process.env.SUBSTRATE_URL ?? "http://localhost:3100";
3312
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.");
3314
3313
  const server = createMcpServer(endpoint, {
3315
3314
  ...process.env.SUBSTRATE_MCP_TOOLS === void 0 ? {} : { tools: process.env.SUBSTRATE_MCP_TOOLS },
3316
3315
  instructions: buildInstructions(await fetchOverview(endpoint))
@@ -3349,7 +3348,7 @@ Subcommands:
3349
3348
  mcp Boot the stdio MCP server. Reads SUBSTRATE_URL, and
3350
3349
  SUBSTRATE_MCP_TOOLS (csv of tool names, core or all;
3351
3350
  core: query, mutate, schema, recall, run, whoami; default
3352
- all, deprecated: core from 1.0.0-beta.3).
3351
+ core).
3353
3352
  init [dir] [flags] Scaffold a new Substrate runtime directory. Interactive by
3354
3353
  default; pass --yes for non-interactive scripted use.
3355
3354
  federate <verb> Federation onboarding: enroll / join / check.
@@ -1998,7 +1998,9 @@ var HttpTransport = class {
1998
1998
  };
1999
1999
  throw new AuthError(`${res.status === 401 ? "Unauthorised" : "Forbidden"}: ${url}`, res.status, info);
2000
2000
  }
2001
- throw new NetworkError(`${res.status} from ${url}`, null, await errorInfo(res));
2001
+ const info = await errorInfo(res);
2002
+ const reason = [info.code, info.serverMessage].filter((s) => s !== void 0).join(": ");
2003
+ throw new NetworkError(`${res.status} from ${url}${reason ? `: ${reason}` : ""}`, null, info);
2002
2004
  }
2003
2005
  };
2004
2006
  /** The status plus whatever a JSON body says: the whole object as `body`, the first string of `error.message` (the recall plugin's nested shape), `error`, `message` as the message, and the first string of `error.code`, `code` as the code. Non-JSON bodies leave the status alone. */
package/dist/client.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { a as adminClaimCapabilities, c as makeTokenProvider, d as resolveDefaultKidPath, i as DEFAULT_CAPABILITIES, l as resolveAdminCredential, o as isEncryptedKey, r as ADMIN_CAPABILITIES, s as makeAuthorizationProvider, u as resolveDefaultKeyPath } from "./env-utils-s25Z1YSA.js";
2
2
  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, g as checkUpdatable, h as checkRevocable, i as allowVerbs, j as flattenGrant, k as encodeGrant, l as requireNamespace, n as row, o as denyVerbs, r as allowAll, s as requireCapability, t as applyRowFilters, v as grantEntriesConfer, w as or, x as revokedAtIso, y as newlyGranted } from "./src-DmiUWOLp.js";
3
3
  import { x as SchemaDriftError } from "./src-B_kHkbsr.js";
4
- import { C as diagnose, E as createH2Fetch, S as DIAGNOSE_CHECKS, T as substrateFetch, _ as SKIPPABLE_STEPS, a as SubstrateClient, b as planOnboarding, c as reduceSubscribeRows, d as NetworkError, f as SubscribeError, g as ONBOARD_STEPS, h as CURRENT_MARK, i as tokenAudience, l as watchRows, m as BACKFILL_CHUNK, n as resolveAgentCapabilities, o as collectDiagnostics, p as AdminBackfillError, r as noRedirectFetch, s as createDefaultDiagnosticsSink, t as createClientFromEnv, u as AuthError, v as STEP_MARKS, w as reconcileIdentities, x as requiredOutstanding, y as currentStep } from "./src-FXO5JPyk.js";
4
+ import { C as diagnose, E as createH2Fetch, S as DIAGNOSE_CHECKS, T as substrateFetch, _ as SKIPPABLE_STEPS, a as SubstrateClient, b as planOnboarding, c as reduceSubscribeRows, d as NetworkError, f as SubscribeError, g as ONBOARD_STEPS, h as CURRENT_MARK, i as tokenAudience, l as watchRows, m as BACKFILL_CHUNK, n as resolveAgentCapabilities, o as collectDiagnostics, p as AdminBackfillError, r as noRedirectFetch, s as createDefaultDiagnosticsSink, t as createClientFromEnv, u as AuthError, v as STEP_MARKS, w as reconcileIdentities, x as requiredOutstanding, y as currentStep } from "./src-Bvl6kSZl.js";
5
5
  import { n as runScript, t as DEFAULT_MAX_WRITES } from "./script-ByQ9pzhC.js";
6
6
 
7
7
  export { ADMIN_CAPABILITIES, AdminBackfillError, AuthError, BACKFILL_CHUNK, CURRENT_MARK, DEFAULT_CAPABILITIES, DEFAULT_MAX_WRITES, DIAGNOSE_CHECKS, NetworkError, ONBOARD_STEPS, SKIPPABLE_STEPS, STEP_MARKS, SYSTEM_NAMESPACE, SchemaDriftError, SubscribeError, SubstrateClient, adminClaimCapabilities, allowAll, allowVerbs, and, applyRowFilters, capabilitiesFor, checkRevocable, checkUpdatable, collectDiagnostics, createClientFromEnv, createDefaultDiagnosticsSink, createH2Fetch, currentStep, decodeList, denyAll, denyVerbs, describeGrant, diagnose, encodeGrant, encodeList, expandFlat, flattenGrant, grantCovers, grantEntriesConfer, grantEntryError, grantIsUniform, intersectGrants, isActiveAdminKeyRow, isEncryptedKey, makeAuthorizationProvider, makeTokenProvider, newlyGranted, newlyGrantedPairs, noRedirectFetch, not, or, parseGrantEntries, planOnboarding, reconcileIdentities, reduceSubscribeRows, requireCapability, requireIdentity, requireNamespace, requiredOutstanding, resolveAdminCredential, resolveAgentCapabilities, resolveDefaultKeyPath, resolveDefaultKidPath, revokedAtIso, row, runScript, substrateFetch, tokenAudience, watchRows };
@@ -1,6 +1,6 @@
1
- import { Bt as jsonResponse, Rt as buildContext, tt as applyObligations, wn as ResolverFrameError } from "./src-C0ylwQFC.js";
1
+ import { Bt as jsonResponse, Rt as buildContext, tt as applyObligations, wn as ResolverFrameError } from "./src-MJrgIOq8.js";
2
2
  import "./src-B_kHkbsr.js";
3
- import { w as queryTimeoutError } from "./src-DxD3iktO.js";
3
+ import { w as queryTimeoutError } from "./src-Sc1C0RIX.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 { qn as defineBootstrap } from "./src-C0ylwQFC.js";
2
- import { n as createNoopPubSub, t as createProposalsPlugin } from "./src-Db3XI_pn.js";
1
+ import { qn as defineBootstrap } from "./src-MJrgIOq8.js";
2
+ import { n as createNoopPubSub, t as createProposalsPlugin } from "./src-D6gf1Gu9.js";
3
3
  import { z } from "zod";
4
4
 
5
5
  //#region ../../plugins/substrate-proposals/src/bootstrap.ts
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-Db3XI_pn.js";
1
+ import { i as ProposalError, n as createNoopPubSub, r as storageSettled, t as createProposalsPlugin } from "./src-D6gf1Gu9.js";
2
2
 
3
3
  export { ProposalError, createNoopPubSub, createProposalsPlugin, storageSettled };
@@ -1,6 +1,6 @@
1
- import { qn as defineBootstrap } from "./src-C0ylwQFC.js";
1
+ import { qn as defineBootstrap } from "./src-MJrgIOq8.js";
2
2
  import { t as FakeEmbedder } from "./fake-DdXtb-m8.js";
3
- import { t as createRecallPlugin } from "./plugin-DWagHKxm.js";
3
+ import { t as createRecallPlugin } from "./plugin-UnGCrT3p.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-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";
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-D8NiaRYa.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-UnGCrT3p.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-COS16L1Z.js";
1
+ import { a as parsePositive, i as DEFAULT_SIZING, n as defaultPluginsForPersona, r as parsePort, t as KNOWN_PLUGINS } from "./cli-DzVfzGoy.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-C0ylwQFC.js";
1
+ import { _ as AUDIT_EVENT_TYPE, g as buildAuditRow } from "./src-MJrgIOq8.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-DpnnxRpR.js";
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-DxD3iktO.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-C9oqfHOP.js";
6
+ import { T as substrateFetch } from "./src-Bvl6kSZl.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-Sc1C0RIX.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.js CHANGED
@@ -1,4 +1,4 @@
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";
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-MJrgIOq8.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";
@@ -1936,7 +1936,9 @@ var HttpTransport = class {
1936
1936
  };
1937
1937
  throw new AuthError(`${res.status === 401 ? "Unauthorised" : "Forbidden"}: ${url}`, res.status, info);
1938
1938
  }
1939
- throw new NetworkError(`${res.status} from ${url}`, null, await errorInfo(res));
1939
+ const info = await errorInfo(res);
1940
+ const reason = [info.code, info.serverMessage].filter((s) => s !== void 0).join(": ");
1941
+ throw new NetworkError(`${res.status} from ${url}${reason ? `: ${reason}` : ""}`, null, info);
1940
1942
  }
1941
1943
  };
1942
1944
  /** The status plus whatever a JSON body says: the whole object as `body`, the first string of `error.message` (the recall plugin's nested shape), `error`, `message` as the message, and the first string of `error.code`, `code` as the code. Non-JSON bodies leave the status alone. */
@@ -1,4 +1,4 @@
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";
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-MJrgIOq8.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,8 +1,8 @@
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";
1
+ import { i as txScopeIdFor, l as typeTableRef, s as guardedRefRead, u as whileNoTypeTable } from "./src-Sc1C0RIX.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-UnGCrT3p.js";
3
3
 
4
4
  //#region ../../plugins/substrate-recall/package.json
5
- var version = "1.0.0-beta.2";
5
+ var version = "1.0.0-beta.4";
6
6
 
7
7
  //#endregion
8
8
  //#region ../../plugins/substrate-recall/src/in-memory-cluster-store.ts
@@ -1530,15 +1530,19 @@ function withRequestContext(handler, trustedProxies, authEnabled) {
1530
1530
  * validation. Anything that doesn't look like an object of objects (or arrays
1531
1531
  * of objects, for batched mutate §5.13) is rejected.
1532
1532
  */
1533
- function validateFrame(value) {
1534
- if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
1535
- for (const entry of Object.values(value)) {
1536
- if (entry === null || typeof entry !== "object") return false;
1533
+ const FRAME_SHAPE = "a frame is { \"<ns>/<Type>\": { \"params\": {...}, \"fields\": {...} } }";
1534
+ const kindOf = (v) => v === null ? "null" : Array.isArray(v) ? "array" : typeof v;
1535
+ /** Why a request body is not a frame, naming the offending key; null when it is one. Entry keys are checked by the engine. */
1536
+ function frameShapeError(value) {
1537
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return `the body is ${kindOf(value)}, not a frame: ${FRAME_SHAPE}`;
1538
+ for (const [key, entry] of Object.entries(value)) {
1539
+ if (entry === null || typeof entry !== "object") return `'${key}' is ${kindOf(entry)}; each key maps to { params?, fields?, idempotencyKey? }: ${FRAME_SHAPE}`;
1537
1540
  if (Array.isArray(entry)) {
1538
- for (const sub of entry) if (sub === null || typeof sub !== "object" || Array.isArray(sub)) return false;
1541
+ const i = entry.findIndex((sub) => sub === null || typeof sub !== "object" || Array.isArray(sub));
1542
+ if (i >= 0) return `'${key}'[${i}] is ${kindOf(entry[i])}; each element of a batch is { params?, fields?, idempotencyKey? }`;
1539
1543
  }
1540
1544
  }
1541
- return true;
1545
+ return null;
1542
1546
  }
1543
1547
  function readAcceptHeader(req) {
1544
1548
  return req.headers.accept ?? req.headers.Accept;
@@ -2396,7 +2400,7 @@ function checkExpr(expr, scope, path) {
2396
2400
  }
2397
2401
  if (typeof e !== "object" || Array.isArray(e)) return refuse("not an expression", at);
2398
2402
  const keys = Object.keys(e);
2399
- if (keys.length !== 1) return refuse(`an expression object has exactly one key, got ${keys.length}`, at);
2403
+ if (keys.length !== 1) return refuse(`an expression is a field name ("title"), a number, or an object with exactly one function key such as { "lower": ["title"] } or { "lit": "text" }; got an object with ${keys.length === 0 ? "no keys" : `keys ${keys.join(", ")}`}`, at);
2400
2404
  const key = keys[0];
2401
2405
  const val = e[key];
2402
2406
  if (key === "lit") return typeof val === "string" ? {
@@ -6322,7 +6326,7 @@ function validateFrameParams(p, scope, h) {
6322
6326
  "groupBy",
6323
6327
  "having",
6324
6328
  "offset"
6325
- ]) if (p[k] !== void 0 && !grouped) fail("agg_invalid", `${k} shapes an aggregate's groups; it needs aggregate`, [k]);
6329
+ ]) if (p[k] !== void 0 && !grouped) fail("agg_invalid", `${k} shapes an aggregate's groups; it needs aggregate.${k === "offset" ? " To page rows, pass the previous page's _pagination nextCursor as params.cursor; for a total, use count: true." : ""}`, [k]);
6326
6330
  if (p.aggregate !== void 0) {
6327
6331
  const refused = p.groupBy !== void 0 ? ["select", "cursor"] : [
6328
6332
  "select",
@@ -6526,6 +6530,32 @@ function clientErrorMessage(err, metric, key) {
6526
6530
  });
6527
6531
  return "internal error";
6528
6532
  }
6533
+ const FRAME_KEYS = /* @__PURE__ */ new Set([
6534
+ "params",
6535
+ "fields",
6536
+ "idempotencyKey"
6537
+ ]);
6538
+ const PARAM_SPELLINGS = /* @__PURE__ */ new Set([
6539
+ "where",
6540
+ "limit",
6541
+ "orderBy",
6542
+ "cursor",
6543
+ "count",
6544
+ "offset"
6545
+ ]);
6546
+ /**
6547
+ * The refusal for a frame entry carrying a key other than `params`, `fields`
6548
+ * or `idempotencyKey`, or null when it carries none. An ignored `where` would
6549
+ * read every row, so an unknown key is refused rather than dropped.
6550
+ */
6551
+ function unknownFrameKeyMessage(entry) {
6552
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return null;
6553
+ const bad = Object.keys(entry).filter((k) => !FRAME_KEYS.has(k));
6554
+ if (bad.length === 0) return null;
6555
+ const inParams = bad.filter((k) => PARAM_SPELLINGS.has(k));
6556
+ const hint = inParams.length > 0 ? `; ${inParams.map((k) => `'${k}'`).join(", ")} belongs in params (params.${inParams[0]})` : "";
6557
+ return `unknown frame key${bad.length > 1 ? "s" : ""} ${bad.map((k) => `'${k}'`).join(", ")}: a frame takes params, fields and idempotencyKey${hint}`;
6558
+ }
6529
6559
  /**
6530
6560
  * No-op `BridgeRegistry` — used when no bridges are wired. Every namespace
6531
6561
  * routes locally and is reachable.
@@ -7842,6 +7872,19 @@ var SubscribeSubsystem = class {
7842
7872
  }, this.#metric);
7843
7873
  return null;
7844
7874
  }
7875
+ const badKeys = unknownFrameKeyMessage(frameEntry);
7876
+ if (badKeys !== null) {
7877
+ deliverFrame(input.onFrame, {
7878
+ id: input.id,
7879
+ kind: "error",
7880
+ errors: [{
7881
+ message: badKeys,
7882
+ code: "unknown_frame_key",
7883
+ path: [key]
7884
+ }]
7885
+ }, this.#metric);
7886
+ return null;
7887
+ }
7845
7888
  const { ns, name } = parsed;
7846
7889
  if (!checkIdentityGrant(ctxBase.identity, ns, "subscribe").ok) {
7847
7890
  deliverFrame(input.onFrame, {
@@ -8536,6 +8579,11 @@ var StreamSubsystem = class {
8536
8579
  await emitError(`unqualified frame key '${key}' — expected '<ns>/<name>'`, "unqualified_key");
8537
8580
  return;
8538
8581
  }
8582
+ const badKeys = unknownFrameKeyMessage(frameEntry);
8583
+ if (badKeys !== null) {
8584
+ await emitError(badKeys, "unknown_frame_key");
8585
+ return;
8586
+ }
8539
8587
  const { ns, name } = parsed;
8540
8588
  if (!checkIdentityGrant(input.ctx.identity, ns, "stream").ok) {
8541
8589
  await emitError(`namespace '${ns}' not in identity's allowed namespaces`, "unauthorized_namespace");
@@ -9727,6 +9775,12 @@ var Engine = class {
9727
9775
  this.#metric("engine_unqualified_key", key);
9728
9776
  return null;
9729
9777
  }
9778
+ const badKeys = unknownFrameKeyMessage(entry);
9779
+ if (badKeys !== null) {
9780
+ addError(envelope, [key], badKeys, "unknown_frame_key");
9781
+ this.#metric("engine_unknown_frame_key", key);
9782
+ return null;
9783
+ }
9730
9784
  const { ns, name } = parsed;
9731
9785
  if (this.#refuseUngranted(envelope, key, ns, ctxBase.identity, operation)) return null;
9732
9786
  if (this.#tombstoned.has(ns)) {
@@ -11241,13 +11295,19 @@ function coerceId(raw) {
11241
11295
  * their `params` IS the row body, so "unknown" keys are extra body fields,
11242
11296
  * which is a separate concern from top-level param-shape validation.
11243
11297
  */
11244
- function rejectUnknownParams(resolverName, typeName, params, allowed) {
11298
+ function rejectUnknownParams(resolverName, typeName, params, allowed, fields) {
11245
11299
  if (!params) return;
11246
- for (const key of Object.keys(params)) if (!allowed.has(key)) throw new ResolverFrameError("unknown_param", `${resolverName}('${typeName}'): unknown param '${key}'. Allowed: ${[...allowed].sort().join(", ")}.`, {
11300
+ for (const key of Object.keys(params)) if (!allowed.has(key)) throw new ResolverFrameError("unknown_param", `${resolverName}('${typeName}'): unknown param '${key}'. Allowed: ${[...allowed].sort().join(", ")}.${unknownParamHint(key, allowed, fields)}`, {
11247
11301
  field: key,
11248
11302
  allowed: [...allowed].sort()
11249
11303
  });
11250
11304
  }
11305
+ /** The likely fix for an unknown param, when one is obvious: a field name sent as a param, or a paging token under the wrong name. */
11306
+ function unknownParamHint(key, allowed, fields) {
11307
+ if (allowed.has("where") && fields !== void 0 && Object.hasOwn(fields, key)) return ` '${key}' is a field: filters go in where, e.g. params: { where: { ${key}: { eq: ... } } }.`;
11308
+ if (allowed.has("cursor") && /cursor|page|after|token/i.test(key)) return " To page, pass the previous page's _pagination nextCursor as params.cursor.";
11309
+ return "";
11310
+ }
11251
11311
  /**
11252
11312
  * Refuse a caller-supplied value for a `readonly` field, on create and update
11253
11313
  * alike. shortId is the main case: the engine allocates it.
@@ -11573,7 +11633,7 @@ function extractLimit(params) {
11573
11633
  }
11574
11634
  function listResolver(typeName, dataset, options = {}) {
11575
11635
  return async (_ctx, args) => {
11576
- rejectUnknownParams("list", typeName, args.params, KNOWN_LIST_PARAMS);
11636
+ rejectUnknownParams("list", typeName, args.params, KNOWN_LIST_PARAMS, options.fields);
11577
11637
  const ds = args.dataset ?? dataset;
11578
11638
  const limit = extractLimit(args.params);
11579
11639
  const readParams = {};
@@ -17781,7 +17841,8 @@ function mutateRoute(engine, trustedProxies, authEnabled) {
17781
17841
  return async (req) => {
17782
17842
  const parsed = parseJsonBody(req);
17783
17843
  if (!parsed.ok) return parsed.response;
17784
- if (!validateFrame(parsed.value)) return error400("frame must be an object of { params?, fields? } entries");
17844
+ const shapeError = frameShapeError(parsed.value);
17845
+ if (shapeError !== null) return error400(shapeError);
17785
17846
  const frame = parsed.value;
17786
17847
  const envelope = await engine.mutate({
17787
17848
  frame,
@@ -18051,7 +18112,8 @@ function queryRoute(engine, trustedProxies, authEnabled, pageLimits) {
18051
18112
  return async (req) => {
18052
18113
  const parsed = parseJsonBody(req);
18053
18114
  if (!parsed.ok) return parsed.response;
18054
- if (!validateFrame(parsed.value)) return error400("frame must be an object of { params?, fields? } entries");
18115
+ const shapeError = frameShapeError(parsed.value);
18116
+ if (shapeError !== null) return error400(shapeError);
18055
18117
  const frame = parsed.value;
18056
18118
  const envelope = await engine.query({
18057
18119
  frame,
@@ -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, 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";
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-MJrgIOq8.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
 
@@ -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-D-4sXpTu.js").then(({ runAdminCli }) => runAdminCli());
39
+ import("./run-Bjurey5l.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-COS16L1Z.js").then(({ runCli }) => runCli(process.argv.slice(2))).then((code) => process.exit(code));
6
+ import("./cli-DzVfzGoy.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-C0ylwQFC.js";
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-MJrgIOq8.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-DxD3iktO.js";
3
+ import { b as runMigrations, g as deriveListIndexMigration, n as PgEdgesStore, r as PgDataset, y as runDerivedMigrations } from "./src-Sc1C0RIX.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.2",
3
+ "version": "1.0.0-beta.4",
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.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",
38
+ "@mnmal-ai/substrate-bootstrap": "1.0.0-beta.4",
39
+ "@mnmal-ai/substrate-client": "1.0.0-beta.4",
40
+ "@mnmal-ai/substrate-compose": "1.0.0-beta.4",
41
+ "@mnmal-ai/substrate-config": "1.0.0-beta.4",
42
+ "@mnmal-ai/substrate-core": "1.0.0-beta.4",
43
+ "@mnmal-ai/substrate-dataset-memory": "1.0.0-beta.4",
44
+ "@mnmal-ai/substrate-dataset-pg": "1.0.0-beta.4",
45
+ "@mnmal-ai/substrate-embedder": "1.0.0-beta.4",
46
+ "@mnmal-ai/substrate-filter": "1.0.0-beta.4",
47
+ "@mnmal-ai/substrate-pack": "1.0.0-beta.4",
48
+ "@mnmal-ai/substrate-policy": "1.0.0-beta.4",
49
+ "@mnmal-ai/substrate-proposals": "1.0.0-beta.4",
50
+ "@mnmal-ai/substrate-recall": "1.0.0-beta.4",
51
+ "@mnmal-ai/substrate-sdk": "1.0.0-beta.4",
52
+ "@mnmal-ai/substrate-sentinel-client": "1.0.0-beta.4",
53
+ "@mnmal-ai/substrate-server-fastify": "1.0.0-beta.4",
54
+ "@mnmal-ai/substrate-server-memory": "1.0.0-beta.4",
55
+ "@mnmal-ai/substrate-types": "1.0.0-beta.4",
56
56
  "@mnmal-ai/surface-core": "0.17.1",
57
57
  "@types/node": "^26.6.4",
58
58
  "@types/semver": "^7.5.0",