@mnmal-ai/substrate 1.0.0-alpha.6 → 1.0.0-alpha.8

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
@@ -56,13 +56,13 @@ Imports the script and calls its default export with a `ScriptContext` (`args`,
56
56
  ```ts
57
57
  import type { ScriptContext } from '@mnmal-ai/substrate/client';
58
58
 
59
- // substrate run open-todos.mts --args '{"project":"substrate"}'
59
+ // substrate run titled.mts --args '{"title":"hello"}'
60
60
  export default async function (s: ScriptContext) {
61
- const open = await s.queryAll('cortext/Todo', {
62
- params: { where: { status: { eq: 'open' }, project: { eq: s.args.project } }, limit: 100 },
63
- fields: { id: true, project: true }
61
+ const notes = await s.queryAll('notes/Note', {
62
+ params: { where: { title: { eq: s.args.title } }, limit: 100 },
63
+ fields: { id: true }
64
64
  });
65
- return { open: open.length };
65
+ return { count: notes.length };
66
66
  }
67
67
  ```
68
68
 
@@ -72,7 +72,7 @@ Guardrails:
72
72
  - **A rejected frame throws.** A query whose key is missing from `data`, or a mutate the server refused, fails the run with the server's error rather than reading as empty.
73
73
  - **Truncation is reported.** `query` adds a warning when a result has `hasMore`; `queryAll` pages to the end.
74
74
 
75
- `s.recall({ query, namespace, type?, k?, threshold?, where?, row? })` returns hits best first, through the `recall/Hit` frame. Each hit's `row` is `id` plus the handle fields; pass `row: { body: true }` (or `true`) for more, on the hits you will read.
75
+ `s.recall({ query, namespace, type, k?, threshold?, where?, row? })` returns hits best first, through the `recall/Hit` frame. Each hit's `row` is `id` plus the handle fields; pass `row: { body: true }` (or `true`) for more, on the hits you will read.
76
76
 
77
77
  `--args` takes a JSON object, which the script reads as `s.args` (`{}` when omitted), so one script serves many calls.
78
78
 
@@ -99,7 +99,7 @@ set -a && source .env && set +a
99
99
  ./node_modules/.bin/substrate serve
100
100
  ```
101
101
 
102
- `substrate init` writes a `package.json` pinning `@mnmal-ai/substrate` and the chosen optional plugins, a `.npmrc` for the `@mnmal-ai` registry, a `.env` with `SUBSTRATE_PLUGIN_DIR=.`, a `substrate-recall.config.json` for the embedder, and, unless `--store=memory`, a `docker-compose.yml` running `pgvector/pgvector:pg17`. Flags: `--store=memory|postgres`, `--port`, `--pg-port`, `--plugins=<csv>` (from `cortext`, `substrate-nl`, `substrate-sentinel`; none by default), `--embedder=minilm|bge-base|ollama|none`, `--tls --tls-cert-path --tls-key-path`, `--substrate-url`, `--yes`, `--force`.
102
+ `substrate init` writes a `package.json` pinning `@mnmal-ai/substrate` and the chosen optional plugins, a `pnpm-workspace.yaml`, a `.env` with `SUBSTRATE_PLUGIN_DIR=.`, a `substrate-recall.config.json` for the embedder, and, unless `--store=memory`, a `docker-compose.yml` running `pgvector/pgvector:pg17`. Flags: `--store=memory|postgres`, `--port`, `--pg-port`, `--plugins=<csv>` (from `cortext`, `substrate-nl`, `substrate-sentinel`; none by default), `--embedder=bge-base|minilm|ollama|none` (default `bge-base`), `--tls --tls-cert-path --tls-key-path`, `--substrate-url`, `--yes`, `--force`.
103
103
 
104
104
  `SUBSTRATE_PLUGIN_DIR` is the directory whose `node_modules/` holds the plugins; in a scaffolded runtime that is the runtime directory itself. Recall and proposals load from `@mnmal-ai/substrate` itself, so they are present whenever the binary is installed there. Kernel plugins (`substrate-recall`, `substrate-nl`) compose first, then coordinators (`substrate-proposals`, `substrate-sentinel`, …), alphabetical within each tier. Per-plugin overrides live at `<SUBSTRATE_PLUGIN_DIR>/<pkg-basename>.config.json`. With `SUBSTRATE_PLUGIN_DIR` unset the binary boots with only the `_system` admin namespace and `/health`.
105
105
 
@@ -118,7 +118,7 @@ cat > substrate-recall.config.json <<'EOF'
118
118
  EOF
119
119
  ```
120
120
 
121
- `kind: "onnx"` runs the model in-process and needs `fastembed` installed in the runtime (the embedder code itself ships in `@mnmal-ai/substrate`); `substrate init` adds it for `--embedder=minilm` (the default) and `--embedder=bge-base`. `kind: "ollama"` takes a `baseUrl` instead.
121
+ `kind: "onnx"` runs the model in-process and needs `fastembed` installed in the runtime (the embedder code itself ships in `@mnmal-ai/substrate`); `substrate init` adds it for `--embedder=bge-base` (the default) and `--embedder=minilm`. `kind: "ollama"` takes a `baseUrl` instead.
122
122
 
123
123
  ## Docker
124
124
 
package/dist/client.d.ts CHANGED
@@ -791,7 +791,8 @@ interface ScriptRecallInput {
791
791
  query: string;
792
792
  /** Required, as on every recall surface. */
793
793
  namespace: string;
794
- type?: string;
794
+ /** Required, as on every recall surface: there is no default type. */
795
+ type: string;
795
796
  k?: number;
796
797
  threshold?: number;
797
798
  where?: Record<string, unknown>;
package/dist/client.js CHANGED
@@ -2,7 +2,7 @@ import { createRequire as __binCreateRequire } from 'node:module'; const require
2
2
  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-CGNazUNt.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, 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 "./row-DZ0Fnpc6.js";
4
4
  import { g as SchemaDriftError } from "./src-BLgbLq2k.js";
5
- import { C as diagnose, S as DIAGNOSE_CHECKS, _ 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-Dk3Zlsgd.js";
5
+ import { C as diagnose, S as DIAGNOSE_CHECKS, _ 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-DiNTSaFk.js";
6
6
  import { n as runScript, t as DEFAULT_MAX_WRITES } from "./script-C6DSa_Na.js";
7
7
 
8
8
  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, 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, tokenAudience, watchRows };
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { d as buildAuditRow, f as AUDIT_EVENT_TYPE } from "./src-CHp3QyqB.js";
2
+ import { d as buildAuditRow, f as AUDIT_EVENT_TYPE } from "./src-DjIuRjzF.js";
3
3
  import { a as adminClaimCapabilities, d as resolveDefaultKidPath, l as resolveAdminCredential, n as trimTrailingSlashes, r as ADMIN_CAPABILITIES, s as makeAuthorizationProvider, u as resolveDefaultKeyPath } from "./env-utils-CGNazUNt.js";
4
4
  import { D as isActiveAdminKeyRow, E as describeGrant, L as encodeList, M as grantEntryError, T as SYSTEM_NAMESPACE, v as grantEntriesConfer } from "./row-DZ0Fnpc6.js";
5
- import { C as diagnose, S as DIAGNOSE_CHECKS, _ 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-Dk3Zlsgd.js";
6
- import { i as pendingMigrations, o as runMigrations, t as PgDataset } from "./src-CXKnqeTW.js";
5
+ import { C as diagnose, S as DIAGNOSE_CHECKS, _ 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-DiNTSaFk.js";
6
+ import { i as pendingMigrations, o as runMigrations, t as PgDataset } from "./src-BD27zeGF.js";
7
7
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
8
8
  import { homedir } from "node:os";
9
9
  import { dirname, join } from "node:path";
@@ -11,7 +11,7 @@ import { createHash, createPublicKey, generateKeyPairSync, randomUUID } from "no
11
11
  import postgres from "postgres";
12
12
 
13
13
  //#region package.json
14
- var version = "1.0.0-alpha.6";
14
+ var version = "1.0.0-alpha.8";
15
15
 
16
16
  //#endregion
17
17
  //#region src/admin/errors.ts
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { n as txScopeIdFor } from "./src-CXKnqeTW.js";
2
+ import { n as txScopeIdFor } from "./src-BD27zeGF.js";
3
3
  import { randomUUID } from "node:crypto";
4
4
 
5
5
  //#region ../../packages/substrate-dataset-pg/src/pg-edges-store.ts
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { L as applyObligations, Q as buildContext, et as jsonResponse, wt as ResolverFrameError } from "./src-CHp3QyqB.js";
2
+ import { L as applyObligations, Q as buildContext, et as jsonResponse, wt as ResolverFrameError } from "./src-DjIuRjzF.js";
3
3
  import { Worker } from "node:worker_threads";
4
4
 
5
5
  //#region ../../plugins/substrate-recall/src/candidate-selection.ts
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { Pt as defineBootstrap } from "./src-CHp3QyqB.js";
3
- import { n as createNoopPubSub, t as createProposalsPlugin } from "./src-CG7giuHr.js";
2
+ import { Pt as defineBootstrap } from "./src-DjIuRjzF.js";
3
+ import { n as createNoopPubSub, t as createProposalsPlugin } from "./src-DCy7Iy2l.js";
4
4
  import { z } from "zod";
5
5
 
6
6
  //#region ../../plugins/substrate-proposals/src/bootstrap.ts
package/dist/proposals.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { n as createNoopPubSub, r as ProposalError, t as createProposalsPlugin } from "./src-CG7giuHr.js";
2
+ import { n as createNoopPubSub, r as ProposalError, t as createProposalsPlugin } from "./src-DCy7Iy2l.js";
3
3
 
4
4
  export { ProposalError, createNoopPubSub, createProposalsPlugin };
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { Pt as defineBootstrap } from "./src-CHp3QyqB.js";
2
+ import { Pt as defineBootstrap } from "./src-DjIuRjzF.js";
3
3
  import { t as FakeEmbedder } from "./fake-DUVtKVSE.js";
4
- import { t as createRecallPlugin } from "./plugin-BG8E04wi.js";
4
+ import { t as createRecallPlugin } from "./plugin-B3NxUCVn.js";
5
5
  import { z } from "zod";
6
6
 
7
7
  //#region ../../packages/substrate-embedder/src/types.ts
package/dist/recall.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- 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-BNJW0F9B.js";
3
- 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-BG8E04wi.js";
2
+ 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-CkZw6xVD.js";
3
+ 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-B3NxUCVn.js";
4
4
 
5
5
  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 };
@@ -36,7 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
37
37
 
38
38
  //#endregion
39
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/key.js
39
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/key.js
40
40
  const keybindingLookup = /* @__PURE__ */ new Set(["emacs", "vim"]);
41
41
  function isKeybinding(value) {
42
42
  return keybindingLookup.has(value);
@@ -55,7 +55,7 @@ const isNumberKey = (key) => "1234567890".includes(key.name);
55
55
  const isEnterKey = (key) => key.name === "enter" || key.name === "return";
56
56
 
57
57
  //#endregion
58
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/errors.js
58
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/errors.js
59
59
  var AbortPromptError = class extends Error {
60
60
  name = "AbortPromptError";
61
61
  message = "Prompt was aborted";
@@ -79,7 +79,7 @@ var ValidationError = class extends Error {
79
79
  };
80
80
 
81
81
  //#endregion
82
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/hook-engine.js
82
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/hook-engine.js
83
83
  const hookStorage = new AsyncLocalStorage();
84
84
  function createStore(rl) {
85
85
  return {
@@ -174,7 +174,7 @@ const effectScheduler = {
174
174
  };
175
175
 
176
176
  //#endregion
177
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-state.js
177
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-state.js
178
178
  function isFactory(value) {
179
179
  return typeof value === "function";
180
180
  }
@@ -199,7 +199,7 @@ function useState(defaultValue) {
199
199
  }
200
200
 
201
201
  //#endregion
202
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-effect.js
202
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-effect.js
203
203
  function useEffect(cb, depArray) {
204
204
  withPointer((pointer) => {
205
205
  const oldDeps = pointer.get();
@@ -495,7 +495,7 @@ const figures = shouldUseMain ? mainSymbols : fallbackSymbols;
495
495
  const replacements = Object.entries(specialMainSymbols);
496
496
 
497
497
  //#endregion
498
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/theme.js
498
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/theme.js
499
499
  const defaultTheme = {
500
500
  prefix: {
501
501
  idle: styleText("blue", "?"),
@@ -535,7 +535,7 @@ function getDefaultTheme() {
535
535
  }
536
536
 
537
537
  //#endregion
538
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/make-theme.js
538
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/make-theme.js
539
539
  function isPlainObject(value) {
540
540
  if (typeof value !== "object" || value === null) return false;
541
541
  let proto = value;
@@ -555,7 +555,7 @@ function makeTheme(...themes) {
555
555
  }
556
556
 
557
557
  //#endregion
558
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-prefix.js
558
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-prefix.js
559
559
  function usePrefix({ status = "idle", theme }) {
560
560
  const [showLoader, setShowLoader] = useState(false);
561
561
  const [tick, setTick] = useState(0);
@@ -582,7 +582,7 @@ function usePrefix({ status = "idle", theme }) {
582
582
  }
583
583
 
584
584
  //#endregion
585
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-memo.js
585
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-memo.js
586
586
  function useMemo(fn, dependencies) {
587
587
  return withPointer((pointer) => {
588
588
  const prev = pointer.get();
@@ -599,13 +599,13 @@ function useMemo(fn, dependencies) {
599
599
  }
600
600
 
601
601
  //#endregion
602
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-ref.js
602
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-ref.js
603
603
  function useRef(val) {
604
604
  return useState({ current: val })[0];
605
605
  }
606
606
 
607
607
  //#endregion
608
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-keypress.js
608
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-keypress.js
609
609
  function useKeypress(userHandler) {
610
610
  const signal = useRef(userHandler);
611
611
  signal.current = userHandler;
@@ -939,7 +939,7 @@ function wrapAnsi(string, columns, options) {
939
939
  }
940
940
 
941
941
  //#endregion
942
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/utils.js
942
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/utils.js
943
943
  var import_cli_width = /* @__PURE__ */ __toESM(require_cli_width(), 1);
944
944
  /**
945
945
  * Force line returns at specific width. This function is ANSI code friendly and it'll
@@ -966,7 +966,7 @@ function readlineWidth() {
966
966
  }
967
967
 
968
968
  //#endregion
969
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
969
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
970
970
  function usePointerPosition({ active, renderedItems, pageSize, loop }) {
971
971
  const state = useRef({
972
972
  lastPointer: active,
@@ -1393,7 +1393,7 @@ const eraseLine = "\x1B[2K";
1393
1393
  const eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + "\x1B[2K\x1B[G" : "";
1394
1394
 
1395
1395
  //#endregion
1396
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/screen-manager.js
1396
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/screen-manager.js
1397
1397
  const height = (content) => content.split("\n").length;
1398
1398
  const lastLine = (content) => content.split("\n").pop() ?? "";
1399
1399
  var ScreenManager = class {
@@ -1451,9 +1451,10 @@ var ScreenManager = class {
1451
1451
  };
1452
1452
 
1453
1453
  //#endregion
1454
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/create-prompt.js
1454
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/create-prompt.js
1455
1455
  var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
1456
1456
  const nativeSetImmediate = globalThis.setImmediate;
1457
+ const nativeClearImmediate = globalThis.clearImmediate;
1457
1458
  /**
1458
1459
  * Register an event listener and return its disposer, so registrations collapse
1459
1460
  * into a single statement: `cleanups.add(listenTo(rl, 'close', handler))`.
@@ -1556,8 +1557,10 @@ function createPrompt(view) {
1556
1557
  }
1557
1558
  });
1558
1559
  };
1559
- if ("readableFlowing" in input) nativeSetImmediate(startCycle);
1560
- else startCycle();
1560
+ if ("readableFlowing" in input) {
1561
+ const immediate = nativeSetImmediate(startCycle);
1562
+ cleanups.add(() => nativeClearImmediate(immediate));
1563
+ } else startCycle();
1561
1564
  return promptPromise;
1562
1565
  });
1563
1566
  };
@@ -1565,7 +1568,7 @@ function createPrompt(view) {
1565
1568
  }
1566
1569
 
1567
1570
  //#endregion
1568
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.4_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/Separator.js
1571
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/Separator.js
1569
1572
  /**
1570
1573
  * Separator object
1571
1574
  * Used to space/separate choices group
@@ -1582,7 +1585,7 @@ var Separator = class {
1582
1585
  };
1583
1586
 
1584
1587
  //#endregion
1585
- //#region ../../node_modules/.pnpm/@inquirer+checkbox@5.2.6_@types+node@26.6.5/node_modules/@inquirer/checkbox/dist/index.js
1588
+ //#region ../../node_modules/.pnpm/@inquirer+checkbox@5.2.7_@types+node@26.6.5/node_modules/@inquirer/checkbox/dist/index.js
1586
1589
  const checkboxTheme = {
1587
1590
  icon: {
1588
1591
  checked: styleText("green", figures.circleFilled),
@@ -1676,9 +1679,12 @@ var dist_default$3 = createPrompt((config, done) => {
1676
1679
  const [active, setActive] = useState(bounds.first);
1677
1680
  const [errorMsg, setError] = useState();
1678
1681
  useKeypress(async (key) => {
1682
+ if (status !== "idle") return;
1679
1683
  if (isEnterKey(key)) {
1684
+ setStatus("loading");
1680
1685
  const selection = items.filter(isChecked);
1681
1686
  const isValid = await validate([...selection]);
1687
+ setStatus("idle");
1682
1688
  if (required && !selection.length) setError("At least one choice must be selected");
1683
1689
  else if (isValid === true) {
1684
1690
  setStatus("done");
@@ -1767,7 +1773,7 @@ var dist_default$3 = createPrompt((config, done) => {
1767
1773
  });
1768
1774
 
1769
1775
  //#endregion
1770
- //#region ../../node_modules/.pnpm/@inquirer+confirm@6.3.3_@types+node@26.6.5/node_modules/@inquirer/confirm/dist/index.js
1776
+ //#region ../../node_modules/.pnpm/@inquirer+confirm@6.3.4_@types+node@26.6.5/node_modules/@inquirer/confirm/dist/index.js
1771
1777
  const confirmTheme = {
1772
1778
  keywords: {
1773
1779
  yes: "Yes",
@@ -1841,7 +1847,7 @@ var dist_default$2 = createPrompt((config, done) => {
1841
1847
  });
1842
1848
 
1843
1849
  //#endregion
1844
- //#region ../../node_modules/.pnpm/@inquirer+input@5.1.7_@types+node@26.6.5/node_modules/@inquirer/input/dist/index.js
1850
+ //#region ../../node_modules/.pnpm/@inquirer+input@5.1.8_@types+node@26.6.5/node_modules/@inquirer/input/dist/index.js
1845
1851
  const inputTheme = { validationFailureMode: "keep" };
1846
1852
  var dist_default$1 = createPrompt((config, done) => {
1847
1853
  const { prefill = "tab" } = config;
@@ -1911,7 +1917,7 @@ var dist_default$1 = createPrompt((config, done) => {
1911
1917
  });
1912
1918
 
1913
1919
  //#endregion
1914
- //#region ../../node_modules/.pnpm/@inquirer+select@5.2.6_@types+node@26.6.5/node_modules/@inquirer/select/dist/index.js
1920
+ //#region ../../node_modules/.pnpm/@inquirer+select@5.2.7_@types+node@26.6.5/node_modules/@inquirer/select/dist/index.js
1915
1921
  const selectTheme = {
1916
1922
  icon: { cursor: figures.pointer },
1917
1923
  style: {
@@ -2146,18 +2152,18 @@ async function runRepl(seed) {
2146
2152
  }));
2147
2153
  const embedder = seed.embedder ?? await dist_default({
2148
2154
  message: "Semantic recall embedder:",
2149
- default: "minilm",
2155
+ default: "bge-base",
2150
2156
  choices: [
2151
2157
  {
2152
- name: "minilm — all-MiniLM-L6-v2, in-process (recommended)",
2153
- value: "minilm"
2158
+ name: "bge-base — bge-base-en-v1.5, in-process (recommended)",
2159
+ value: "bge-base"
2154
2160
  },
2155
2161
  {
2156
- name: "bge-base — bge-base-en-v1.5, in-process, slower and stronger",
2157
- value: "bge-base"
2162
+ name: "minilm — all-MiniLM-L6-v2, in-process, smaller and faster",
2163
+ value: "minilm"
2158
2164
  },
2159
2165
  {
2160
- name: "ollama — bge-m3 via local Ollama",
2166
+ name: "ollama — bge-base-en-v1.5 via local Ollama",
2161
2167
  value: "ollama"
2162
2168
  },
2163
2169
  {
package/dist/sdk.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { $ as error400, A as resolveIdentity, At as CLIENT_SUPPLIED_SERVER_FIELD, C as purgeResolver, Ct as ReservedField, D as deleteRow, Dt as isAuthCause, E as deleteResolver, Et as UnsupportedFilterError, M as resolveEntityRow, Mt as canonicalize, Nt as BootstrapConfigError, O as createResolver, Ot as isResolverFrameError, Pt as defineBootstrap, S as updateResolver, St as NamespaceMismatch, T as getResolver, Tt as RestrictViolation, Z as JSON_HEADERS, _ as field, _t as createKeyedMutex, at as WS_REASON_SERVER_RESTART, b as installAutoCrud, bt as BridgeUnreachableError, ct as normaliseVocabValues, dt as vocabImplication, et as jsonResponse, ft as RegistryBase, g as RESERVED_AUTOCRUD_FIELD_NAMES, gt as normaliseMetadataWhere, h as RESERVED_AUTOCRUD_FIELDS, ht as normaliseMetadataOrderBy, it as WS_CODE_SUBSCRIPTION_UNSUPPORTED_FRAME, j as resolveEntityId, jt as ROW_METADATA_FIELDS, k as UnattributedWriteError, kt as isRestrictViolation, lt as normaliseVocabWhere, m as defineNamespace, mt as METADATA_FILTER_FIELDS, ot as WS_REASON_SUBSCRIPTION_OVERLOADED, pt as METADATA_AUTHOR_FIELDS, st as canonicalVocabValue, tt as parseJsonBody, ut as storedVocabSpellings, v as autoCrudOptionsOf, vt as assertHardDeleteAllowed, w as listResolver, wt as ResolverFrameError, x as applyUpdatePatch, xt as MissingReferentError, y as createResolverWithEdges, yt as validateHardDeleteEnv } from "./src-CHp3QyqB.js";
2
+ import { $ as error400, A as resolveIdentity, At as CLIENT_SUPPLIED_SERVER_FIELD, C as purgeResolver, Ct as ReservedField, D as deleteRow, Dt as isAuthCause, E as deleteResolver, Et as UnsupportedFilterError, M as resolveEntityRow, Mt as canonicalize, Nt as BootstrapConfigError, O as createResolver, Ot as isResolverFrameError, Pt as defineBootstrap, S as updateResolver, St as NamespaceMismatch, T as getResolver, Tt as RestrictViolation, Z as JSON_HEADERS, _ as field, _t as createKeyedMutex, at as WS_REASON_SERVER_RESTART, b as installAutoCrud, bt as BridgeUnreachableError, ct as normaliseVocabValues, dt as vocabImplication, et as jsonResponse, ft as RegistryBase, g as RESERVED_AUTOCRUD_FIELD_NAMES, gt as normaliseMetadataWhere, h as RESERVED_AUTOCRUD_FIELDS, ht as normaliseMetadataOrderBy, it as WS_CODE_SUBSCRIPTION_UNSUPPORTED_FRAME, j as resolveEntityId, jt as ROW_METADATA_FIELDS, k as UnattributedWriteError, kt as isRestrictViolation, lt as normaliseVocabWhere, m as defineNamespace, mt as METADATA_FILTER_FIELDS, ot as WS_REASON_SUBSCRIPTION_OVERLOADED, pt as METADATA_AUTHOR_FIELDS, st as canonicalVocabValue, tt as parseJsonBody, ut as storedVocabSpellings, v as autoCrudOptionsOf, vt as assertHardDeleteAllowed, w as listResolver, wt as ResolverFrameError, x as applyUpdatePatch, xt as MissingReferentError, y as createResolverWithEdges, yt as validateHardDeleteEnv } from "./src-DjIuRjzF.js";
3
3
  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-CGNazUNt.js";
4
4
  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 "./row-DZ0Fnpc6.js";
5
5
  import { S as assertNever, b as formatQualifiedKey, x as parseQualifiedKey } from "./src-BLgbLq2k.js";
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { Ct as ReservedField, Et as UnsupportedFilterError, H as assertJsonPathPredicate, J as fullBuiltinOperators, K as decodeCursor, St as NamespaceMismatch, U as isJsonPathPredicate, V as preResolveExtensionOperatorsDetailed, X as fieldRequested, Y as applyExtensionResultMeta, _t as createKeyedMutex, q as encodeCursor } from "./src-CHp3QyqB.js";
2
+ import { Ct as ReservedField, Et as UnsupportedFilterError, H as assertJsonPathPredicate, J as fullBuiltinOperators, K as decodeCursor, St as NamespaceMismatch, U as isJsonPathPredicate, V as preResolveExtensionOperatorsDetailed, X as fieldRequested, Y as applyExtensionResultMeta, _t as createKeyedMutex, q as encodeCursor } from "./src-DjIuRjzF.js";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
 
5
5
  //#region ../../packages/substrate-dataset-pg/src/advisory-lock.ts
@@ -652,7 +652,7 @@ var PgShortIdStore = class {
652
652
  })), "namespace", "type", "short_id", "row_id")}
653
653
  ON CONFLICT (namespace, type, short_id) DO NOTHING
654
654
  `;
655
- const max = entries.reduce((m, e) => e.shortId > m ? e.shortId : m, 0);
655
+ const max = entries.reduce((m, e) => Math.max(m, e.shortId), 0);
656
656
  const name = await this.ensureSequence(ns, type);
657
657
  await this.sql.unsafe(`SELECT setval('"${name}"', GREATEST((SELECT last_value FROM "${name}"), ${max}))`);
658
658
  }
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { n as txScopeIdFor } from "./src-CXKnqeTW.js";
3
- import { B as ROW_FILTER_FIELD, V as matchesRowFilter, W as inFlightError, Y as unresolvedRow, Z as cosineSimilarity, et as memberKey } from "./plugin-BG8E04wi.js";
2
+ import { n as txScopeIdFor } from "./src-BD27zeGF.js";
3
+ import { B as ROW_FILTER_FIELD, V as matchesRowFilter, W as inFlightError, Y as unresolvedRow, Z as cosineSimilarity, et as memberKey } from "./plugin-B3NxUCVn.js";
4
4
 
5
5
  //#region ../../plugins/substrate-recall/package.json
6
- var version = "1.0.0-alpha.6";
6
+ var version = "1.0.0-alpha.8";
7
7
 
8
8
  //#endregion
9
9
  //#region ../../plugins/substrate-recall/src/in-memory-cluster-store.ts
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { A as resolveIdentity, F as publishSchema, Z as JSON_HEADERS, _ as field, b as installAutoCrud, h as RESERVED_AUTOCRUD_FIELDS, l as migrateFieldValues, m as defineNamespace, v as autoCrudOptionsOf, wt as ResolverFrameError } from "./src-CHp3QyqB.js";
2
+ import { A as resolveIdentity, F as publishSchema, Z as JSON_HEADERS, _ as field, b as installAutoCrud, h as RESERVED_AUTOCRUD_FIELDS, l as migrateFieldValues, m as defineNamespace, v as autoCrudOptionsOf, wt as ResolverFrameError } from "./src-DjIuRjzF.js";
3
3
  import { s as requireCapability } from "./row-DZ0Fnpc6.js";
4
4
  import { randomUUID } from "node:crypto";
5
5
 
@@ -1742,6 +1742,10 @@ var WsTransport = class {
1742
1742
  if (this.#destroyed) throw new NetworkError("WsTransport destroyed", null);
1743
1743
  try {
1744
1744
  const mux = await this.#openOnce();
1745
+ if (this.#destroyed) {
1746
+ mux.close();
1747
+ throw new NetworkError("WsTransport destroyed", null);
1748
+ }
1745
1749
  scheduler.reset();
1746
1750
  this.#hasOpened = true;
1747
1751
  this.#mux = mux;
@@ -924,7 +924,8 @@ function authenticateBearer(token, cfg) {
924
924
  if (maxLifetime > 0 && payload.exp > nowSeconds + maxLifetime + leeway) return reject("lifetime_exceeds_max");
925
925
  }
926
926
  if (typeof payload.nbf === "number" && payload.nbf > nowSeconds + leeway) return reject("not_yet_valid");
927
- if (cfg.audiences !== void 0 && payload.aud !== void 0) {
927
+ if (cfg.audiences !== void 0) {
928
+ if (payload.aud === void 0) return reject("missing_audience");
928
929
  if (!(Array.isArray(payload.aud) ? payload.aud : [payload.aud]).some((a) => cfg.audiences?.includes(a))) return reject("wrong_audience");
929
930
  }
930
931
  const claimedCapabilities = Array.isArray(payload.capabilities) ? payload.capabilities.filter((c) => typeof c === "string") : [];
@@ -963,6 +964,7 @@ function authenticateBearer(token, cfg) {
963
964
  /** What a 401 should add for a reason whose fix is a server knob, not the token. */
964
965
  function rejectionDetail(reason) {
965
966
  if (reason === "lifetime_exceeds_max") return "the token expires further ahead than this server accepts; mint a shorter-lived token or raise SUBSTRATE_JWT_MAX_TTL_SECONDS";
967
+ if (reason === "missing_audience") return "the token has no aud; mint it with aud set to this server's origin (e.g. https://host:3100)";
966
968
  if (reason === "wrong_audience") return "the token's aud is not one of this server's origins; connect through an origin listed in SUBSTRATE_PUBLIC_ORIGIN, or add this one there";
967
969
  }
968
970
  /**
@@ -5460,7 +5462,8 @@ var Engine = class {
5460
5462
  const entry = frame[key];
5461
5463
  if (entry === void 0) continue;
5462
5464
  const parsed = parsedByKey.get(key) ?? null;
5463
- if (await this.#runEntry(envelope, key, entry, ctx, "mutate", parsed === null ? null : txFor(parsed.ns), txEdges, parsed, (event) => pending.push(event), signal, (fn) => settled.push(fn))) {
5465
+ const errorsBefore = envelope.errors?.length ?? 0;
5466
+ if (await this.#runEntry(envelope, key, entry, ctx, "mutate", parsed === null ? null : txFor(parsed.ns), txEdges, parsed, (event) => pending.push(event), signal, (fn) => settled.push(fn)) || (envelope.errors ?? []).slice(errorsBefore).some((e) => e.path?.[0] === key)) {
5464
5467
  refusedKey = key;
5465
5468
  throw new SharedTxRefusal();
5466
5469
  }
@@ -11634,6 +11637,18 @@ const WS_INSTRUCTIONS = {
11634
11637
  ]
11635
11638
  }
11636
11639
  };
11640
+ const CODE_MODE_INSTRUCTIONS = {
11641
+ command: "substrate run <script.mts> [--args <json>] [--dry-run | --write] [--max-writes <n>] [--out <file>]",
11642
+ summary: "For an agent with a shell: run a TypeScript script whose default export receives a signed client, so many reads and writes cost one call and return one small JSON report. It composes the operations above; it adds none, and every call meets the same grants and policy.",
11643
+ when: "a count or census over many rows, a join across types, recall followed by fetching the bodies of the hits worth reading, or a batch of writes chosen by what a read found. One lookup or one write is simpler as a direct query or mutate",
11644
+ context: "the default export gets `s` with `args`, `query(frame)`, `queryAll(key, { params, fields })`, `recall({ query, namespace, type, ... })`, `mutate(payload)` and `log(...)`; return a reduced result (counts, ids, a verdict), not whole rows",
11645
+ notes: [
11646
+ "signs from SUBSTRATE_URL, SUBSTRATE_AGENT_KEY_ID and SUBSTRATE_AGENT_KEY_PATH, and refuses to run unsigned",
11647
+ "read-only by default: `mutate` throws unless `--dry-run` (records each payload and sends nothing) or `--write` (sends up to `--max-writes` frames, default 50). Dry-run first, read the recorded mutations, then write",
11648
+ "a frame the server rejected fails the run with its error rather than reading as empty; a truncated `query` is reported in `warnings`, and `queryAll` pages to the end",
11649
+ "stdout is one report `{ ok, kid, mode, args, result, error?, mutations, warnings, stats }`; `mutations` lists every payload with `applied`, including those sent before a failure. Exit codes: 0 ok, 1 the script failed, 2 usage or configuration"
11650
+ ]
11651
+ };
11637
11652
  const AUTH_INSTRUCTIONS = {
11638
11653
  summary: "Bearer-JWT auth (§5.12). Present `Authorization: Bearer <jwt>` on every request, onboard included. Only /health, /substrate/v1/whoami and /substrate/v1/_system/register answer without one. Two paths to a token: (a) the invite→register exchange for a namespace-scoped JWT, or (b) a pre-registered per-principal key you sign with directly (the agent-identity path — see `identity`). How a MISSING token is treated depends on `mode`.",
11639
11654
  modes: {
@@ -11677,8 +11692,8 @@ function buildFrameGrammar(coordinators) {
11677
11692
  return {
11678
11693
  queryKey: "<ns>/<TypeName>",
11679
11694
  mutationKey: "<ns>/<mutationName>",
11680
- batched: "A mutate op-key MAY carry an Array<FrameEntry>. All frames under one op-key run serially inside the same transaction (all-or-nothing per op-key). Cross-op-key atomicity is not a goal — each op-key commits independently. Query/subscribe/stream op-keys reject array values.",
11681
- example: `{ "${exampleNs}/Todo": { "params": {"status": "open"}, "fields": {"id": true, "title": true} }, "${exampleNs}/createTodo": [{ "params": {"title": "first"}, "fields": {"id": true} }, { "params": {"title": "second"}, "fields": {"id": true} }] }`
11695
+ batched: "A mutate op-key MAY carry an Array<FrameEntry>. All frames under one array op-key run serially inside the same transaction (all-or-nothing per op-key), and each array op-key commits independently of every other op-key. The single-frame op-keys of one call share their own transaction: if any of them is refused, all of them roll back with `frame_rolled_back`. Query/subscribe/stream op-keys reject array values.",
11696
+ example: `{ "${exampleNs}/Todo": { "params": {"where": {"status": {"eq": "open"}}}, "fields": {"id": true, "title": true} }, "${exampleNs}/createTodo": [{ "params": {"title": "first"}, "fields": {"id": true} }, { "params": {"title": "second"}, "fields": {"id": true} }] }`
11682
11697
  };
11683
11698
  }
11684
11699
  function buildPluginContributions(plugins) {
@@ -11721,6 +11736,7 @@ function buildOnboardBody(deps) {
11721
11736
  stream: WS_INSTRUCTIONS.stream,
11722
11737
  substratePack: WS_INSTRUCTIONS.substratePack,
11723
11738
  sse: WS_INSTRUCTIONS.sse,
11739
+ codeMode: CODE_MODE_INSTRUCTIONS,
11724
11740
  plugins: buildPluginContributions(deps.coordinators),
11725
11741
  pluginRoutes: buildPluginRoutes(deps.coordinators)
11726
11742
  };
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
3
- import { d as buildAuditRow, f as AUDIT_EVENT_TYPE } from "./src-CHp3QyqB.js";
3
+ import { d as buildAuditRow, f as AUDIT_EVENT_TYPE } from "./src-DjIuRjzF.js";
4
4
  import { d as resolveDefaultKidPath, u as resolveDefaultKeyPath } from "./env-utils-CGNazUNt.js";
5
5
  import { E as describeGrant, I as decodeList, L as encodeList, M as grantEntryError, g as checkUpdatable, h as checkRevocable, y as newlyGranted } from "./row-DZ0Fnpc6.js";
6
- import { w as reconcileIdentities } from "./src-Dk3Zlsgd.js";
7
- import { A as describeAdminTarget, B as version, C as CLI_ACTOR_KID, D as listActiveAdminKeys, E as generateAdminKeypair, F as RESTART_NOTE, I as USAGE, L as argvError, M as resolveAdminTarget, N as ARGV_SPEC, O as readEd25519PublicKey, P as validateArgv, S as BootstrapError, T as forUpdate, _ as REVOKE_EXIT_CODES, a as formatRegisterOutput, b as runKeyPatchViaRoute, c as runRegisterViaRoute, d as formatDoctorReport, f as runDoctor, g as bootstrapKidPath, h as runBootstrap, i as runOnboard, j as resolveAdminAuth, k as readKeyById, l as grantLines, m as parseBootstrapArgs, n as formatChecklist, o as parseRegisterArgs, p as formatBootstrapOutput, r as onboardCommand, s as runRegister, t as openPgDataset, u as doctorCommand, v as UPDATE_EXIT_CODES, w as base64Url, x as ACTOR_HINT, y as runKeyListViaRoute, z as AdminCliError } from "./dataset-IfVlQQ4q.js";
6
+ import { w as reconcileIdentities } from "./src-DiNTSaFk.js";
7
+ import { A as describeAdminTarget, B as version, C as CLI_ACTOR_KID, D as listActiveAdminKeys, E as generateAdminKeypair, F as RESTART_NOTE, I as USAGE, L as argvError, M as resolveAdminTarget, N as ARGV_SPEC, O as readEd25519PublicKey, P as validateArgv, S as BootstrapError, T as forUpdate, _ as REVOKE_EXIT_CODES, a as formatRegisterOutput, b as runKeyPatchViaRoute, c as runRegisterViaRoute, d as formatDoctorReport, f as runDoctor, g as bootstrapKidPath, h as runBootstrap, i as runOnboard, j as resolveAdminAuth, k as readKeyById, l as grantLines, m as parseBootstrapArgs, n as formatChecklist, o as parseRegisterArgs, p as formatBootstrapOutput, r as onboardCommand, s as runRegister, t as openPgDataset, u as doctorCommand, v as UPDATE_EXIT_CODES, w as base64Url, x as ACTOR_HINT, y as runKeyListViaRoute, z as AdminCliError } from "./dataset-jZS_4ci4.js";
8
8
  import { existsSync, mkdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
9
9
  import { dirname } from "node:path";
10
10
  import { createHash, randomUUID } from "node:crypto";
package/dist/substrate.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
3
- import { B as saveSweepState, G as registerExtensionOperator, I as effectiveFilterOperators, N as MemoryEdgesStore, Q as buildContext, R as loadSweepState, W as getExtensionOperator, a as composeFromManifests, at as WS_REASON_SERVER_RESTART, bt as BridgeUnreachableError, c as MemoryDataset, d as buildAuditRow, f as AUDIT_EVENT_TYPE, i as PluginLoadError, n as kernelMigrationTracking, nt as parseAuthConfig, o as DEFAULT_NAMESPACE, p as INVITE_TYPE, r as mountKernelRoute, s as compose, t as composeKernelPlugins, u as runInviteSweep, yt as validateHardDeleteEnv, z as runSweep } from "./src-CHp3QyqB.js";
3
+ import { B as saveSweepState, G as registerExtensionOperator, I as effectiveFilterOperators, N as MemoryEdgesStore, Q as buildContext, R as loadSweepState, W as getExtensionOperator, a as composeFromManifests, at as WS_REASON_SERVER_RESTART, bt as BridgeUnreachableError, c as MemoryDataset, d as buildAuditRow, f as AUDIT_EVENT_TYPE, i as PluginLoadError, n as kernelMigrationTracking, nt as parseAuthConfig, o as DEFAULT_NAMESPACE, p as INVITE_TYPE, r as mountKernelRoute, s as compose, t as composeKernelPlugins, u as runInviteSweep, yt as validateHardDeleteEnv, z as runSweep } from "./src-DjIuRjzF.js";
4
4
  import { n as trimTrailingSlashes, s as makeAuthorizationProvider, t as parsePositiveInt } from "./env-utils-CGNazUNt.js";
5
5
  import { L as encodeList, T as SYSTEM_NAMESPACE, f as coversNamespace, m as grantedIn, p as grantOf } from "./row-DZ0Fnpc6.js";
6
- import { 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-Dk3Zlsgd.js";
6
+ import { 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-DiNTSaFk.js";
7
7
  import { n as runScript, t as DEFAULT_MAX_WRITES } from "./script-C6DSa_Na.js";
8
- import { a as runDerivedMigrations, o as runMigrations, r as deriveListIndexMigration, s as tryWithPgAdvisoryLock, t as PgDataset } from "./src-CXKnqeTW.js";
9
- import { t as PgEdgesStore } from "./pg-edges-store-DKPYyd8l.js";
10
- import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore } from "./src-BNJW0F9B.js";
11
- import { B as version, R as openSql, t as openPgDataset, z as AdminCliError } from "./dataset-IfVlQQ4q.js";
8
+ import { a as runDerivedMigrations, o as runMigrations, r as deriveListIndexMigration, s as tryWithPgAdvisoryLock, t as PgDataset } from "./src-BD27zeGF.js";
9
+ import { t as PgEdgesStore } from "./pg-edges-store-KH_FQCxx.js";
10
+ import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore } from "./src-CkZw6xVD.js";
11
+ import { B as version, R as openSql, t as openPgDataset, z as AdminCliError } from "./dataset-jZS_4ci4.js";
12
12
  import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
13
13
  import { homedir, hostname } from "node:os";
14
14
  import { basename, dirname, join, resolve } from "node:path";
@@ -1462,7 +1462,10 @@ function startSentinelClient(opts) {
1462
1462
  });
1463
1463
  return;
1464
1464
  }
1465
- const auth = makeAuthorizationProvider(cred, { lazyKey: true });
1465
+ const auth = makeAuthorizationProvider(cred, {
1466
+ lazyKey: true,
1467
+ audience: cred.origin
1468
+ });
1466
1469
  for (const nsValue of namespaces) {
1467
1470
  if (stopped) return;
1468
1471
  if (typeof nsValue !== "string" || nsValue.length === 0) continue;
@@ -1717,7 +1720,7 @@ function buildBridgeRegistry(specs, creds) {
1717
1720
  throw new Error(`bridge '${spec.name}' has a malformed url '${spec.url}'`);
1718
1721
  }
1719
1722
  if (specOrigin !== cred.origin) throw new Error(`bridge '${spec.name}' url origin '${specOrigin}' does not match its credential origin '${cred.origin}'`);
1720
- const auth = makeAuthorizationProvider(cred);
1723
+ const auth = makeAuthorizationProvider(cred, { audience: cred.origin });
1721
1724
  const client = new HttpBridgeClient({
1722
1725
  name: spec.name,
1723
1726
  baseUrl: spec.url,
@@ -2352,7 +2355,7 @@ function startBackground(args) {
2352
2355
  bridges: bridgeRegistry,
2353
2356
  engine,
2354
2357
  creds: config.bridgeCreds,
2355
- auth: makeAuthorizationProvider(sentinelClientConfig.cred),
2358
+ auth: makeAuthorizationProvider(sentinelClientConfig.cred, { audience: new URL(sentinelClientConfig.url.replace(/^ws/, "http")).origin }),
2356
2359
  metric: (name, payload) => {
2357
2360
  process.stdout.write(`sentinel-client.${name} ${JSON.stringify(payload ?? null)}\n`);
2358
2361
  },
@@ -3974,8 +3977,8 @@ async function runFederate(argv, env, out, errOut) {
3974
3977
  //#endregion
3975
3978
  //#region src/cli/init/config.ts
3976
3979
  const EMBEDDER_MODES = [
3977
- "minilm",
3978
3980
  "bge-base",
3981
+ "minilm",
3979
3982
  "ollama",
3980
3983
  "none"
3981
3984
  ];
@@ -4166,8 +4169,8 @@ function recallConfigTemplate(embedder, runtimeDir) {
4166
4169
  const config = embedder === "ollama" ? { embedder: {
4167
4170
  kind: "ollama",
4168
4171
  baseUrl: "http://localhost:11434",
4169
- model: "bge-m3",
4170
- dimension: 1024
4172
+ model: "hf.co/CompendiumLabs/bge-base-en-v1.5-gguf:F16",
4173
+ dimension: 768
4171
4174
  } } : { embedder: {
4172
4175
  kind: "onnx",
4173
4176
  ...ONNX_MODELS[embedder],
@@ -4329,7 +4332,7 @@ function readmeTemplate(ctx) {
4329
4332
  return `${lines.join("\n")}\n`;
4330
4333
  }
4331
4334
  function recallReadmeLines(embedder) {
4332
- const lines = embedder === "ollama" ? ["`substrate-recall.config.json` points at Ollama on `localhost:11434` with `bge-m3`. Pull the model first: `ollama pull bge-m3`."] : [`\`substrate-recall.config.json\` runs \`${ONNX_MODELS[embedder].model}\` in-process through \`fastembed\`, which \`pnpm install\` adds (about 540MB, most of it ONNX Runtime). The first write downloads the model into \`models/\`.`];
4335
+ const lines = embedder === "ollama" ? ["`substrate-recall.config.json` points at Ollama on `localhost:11434` with bge-base-en-v1.5. Pull the model first: `ollama pull hf.co/CompendiumLabs/bge-base-en-v1.5-gguf:F16`."] : [`\`substrate-recall.config.json\` runs \`${ONNX_MODELS[embedder].model}\` in-process through \`fastembed\`, which \`pnpm install\` adds (about 540MB, most of it ONNX Runtime). The first write downloads the model into \`models/\`.`];
4333
4336
  lines.push("", "Recall also ranks by keyword, so a small model loses little. Changing model later means emptying the stored vectors and embedding every row again, through the admin route `POST /substrate/v1/embed/reindex`.");
4334
4337
  return lines;
4335
4338
  }
@@ -4353,7 +4356,7 @@ async function runInit(argv) {
4353
4356
  return 1;
4354
4357
  }
4355
4358
  if (!config.yes) try {
4356
- const { runRepl } = await import("./repl-C52wyfMs.js");
4359
+ const { runRepl } = await import("./repl-DeKzfvNV.js");
4357
4360
  config = await runRepl(config);
4358
4361
  } catch (err) {
4359
4362
  if (err.message?.includes("User force closed")) return 130;
@@ -4380,7 +4383,7 @@ async function runInit(argv) {
4380
4383
  port: config.port ?? 3100,
4381
4384
  pgPort: config.pgPort ?? 5433,
4382
4385
  plugins: [...config.plugins ?? []],
4383
- embedder: config.embedder ?? "minilm",
4386
+ embedder: config.embedder ?? "bge-base",
4384
4387
  substrateUrl: config.substrateUrl ?? `${config.tls ? "https" : "http"}://localhost:${config.port ?? 3100}`,
4385
4388
  tls: config.tls,
4386
4389
  tlsCertPath: config.tlsCertPath,
@@ -5111,8 +5114,9 @@ Subcommands:
5111
5114
  run <script.mts> [--args <json>] [--dry-run | --write] [--max-writes <n>] [--out <file>]
5112
5115
  Run a script's default export (s) => result against a client
5113
5116
  signed from SUBSTRATE_URL + SUBSTRATE_AGENT_KEY_ID/_PATH, and
5114
- print one JSON report. --args is a JSON object, read as s.args. Read-only unless --dry-run (records
5115
- mutations) or --write (sends up to --max-writes frames, 50).
5117
+ print one JSON report. --args is a JSON object, read as
5118
+ s.args. Read-only unless --dry-run (records mutations) or
5119
+ --write (sends up to --max-writes frames, 50).
5116
5120
  check-enums [--json] [--record]
5117
5121
  Report stored values outside a field's declared enum.
5118
5122
  Read-only over HTTP (--record writes verdict rows); reads
@@ -5146,9 +5150,9 @@ Environment for \`serve\` (the load-bearing ones; the full reference is in the d
5146
5150
  outstanding ticket, which is the only revocation
5147
5151
  mechanism.
5148
5152
  SUBSTRATE_PUBLIC_ORIGIN This server's origins, comma-separated (e.g.
5149
- https://host:3100,https://alias). A token carrying
5150
- 'aud' must name one; a token with no 'aud' is still
5151
- accepted for now. Required with auth on a non-loopback
5153
+ https://host:3100,https://alias). A token must carry
5154
+ 'aud' naming one; a token with no 'aud' is refused.
5155
+ Required with auth on a non-loopback
5152
5156
  HOST; on loopback it defaults to the loopback origins.
5153
5157
  SUBSTRATE_TLS_KEY_PATH Serve HTTPS. Both are required together — setting one
5154
5158
  SUBSTRATE_TLS_CERT_PATH without the other refuses to boot.
package/dist/testing.d.ts CHANGED
@@ -56,8 +56,8 @@ interface AuthConfig {
56
56
  maxTokenLifetimeSeconds?: number;
57
57
  /**
58
58
  * The origins this server answers as (`SUBSTRATE_PUBLIC_ORIGIN`). When set, a
59
- * token carrying `aud` must name one of them; a token with no `aud` is still
60
- * accepted. Absent → `aud` is not checked.
59
+ * token must carry `aud` naming one of them, or it is refused. Absent → `aud`
60
+ * is not checked.
61
61
  */
62
62
  audiences?: ReadonlyArray<string>;
63
63
  /**
package/dist/testing.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { N as MemoryEdgesStore, P as loadPlugins, at as WS_REASON_SERVER_RESTART, c as MemoryDataset, rt as signHs256, s as compose } from "./src-CHp3QyqB.js";
3
- import { a as runDerivedMigrations, o as runMigrations, r as deriveListIndexMigration, t as PgDataset } from "./src-CXKnqeTW.js";
4
- import { t as PgEdgesStore } from "./pg-edges-store-DKPYyd8l.js";
2
+ import { N as MemoryEdgesStore, P as loadPlugins, at as WS_REASON_SERVER_RESTART, c as MemoryDataset, rt as signHs256, s as compose } from "./src-DjIuRjzF.js";
3
+ import { a as runDerivedMigrations, o as runMigrations, r as deriveListIndexMigration, t as PgDataset } from "./src-BD27zeGF.js";
4
+ import { t as PgEdgesStore } from "./pg-edges-store-KH_FQCxx.js";
5
5
  import { t as FakeEmbedder } from "./fake-DUVtKVSE.js";
6
6
  import { randomUUID } from "node:crypto";
7
7
  import postgres from "postgres";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mnmal-ai/substrate",
3
- "version": "1.0.0-alpha.6",
3
+ "version": "1.0.0-alpha.8",
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": {
@@ -36,24 +36,24 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@inquirer/prompts": "^8.7.2",
39
- "@mnmal-ai/substrate-bootstrap": "1.0.0-alpha.6",
40
- "@mnmal-ai/substrate-client": "1.0.0-alpha.6",
41
- "@mnmal-ai/substrate-compose": "1.0.0-alpha.6",
42
- "@mnmal-ai/substrate-config": "1.0.0-alpha.6",
43
- "@mnmal-ai/substrate-core": "1.0.0-alpha.6",
44
- "@mnmal-ai/substrate-dataset-memory": "1.0.0-alpha.6",
45
- "@mnmal-ai/substrate-dataset-pg": "1.0.0-alpha.6",
46
- "@mnmal-ai/substrate-embedder": "1.0.0-alpha.6",
47
- "@mnmal-ai/substrate-filter": "1.0.0-alpha.6",
48
- "@mnmal-ai/substrate-pack": "1.0.0-alpha.6",
49
- "@mnmal-ai/substrate-policy": "1.0.0-alpha.6",
50
- "@mnmal-ai/substrate-proposals": "1.0.0-alpha.6",
51
- "@mnmal-ai/substrate-recall": "1.0.0-alpha.6",
52
- "@mnmal-ai/substrate-sdk": "1.0.0-alpha.6",
53
- "@mnmal-ai/substrate-sentinel-client": "1.0.0-alpha.6",
54
- "@mnmal-ai/substrate-server-fastify": "1.0.0-alpha.6",
55
- "@mnmal-ai/substrate-server-memory": "1.0.0-alpha.6",
56
- "@mnmal-ai/substrate-types": "1.0.0-alpha.6",
39
+ "@mnmal-ai/substrate-bootstrap": "1.0.0-alpha.8",
40
+ "@mnmal-ai/substrate-client": "1.0.0-alpha.8",
41
+ "@mnmal-ai/substrate-compose": "1.0.0-alpha.8",
42
+ "@mnmal-ai/substrate-config": "1.0.0-alpha.8",
43
+ "@mnmal-ai/substrate-core": "1.0.0-alpha.8",
44
+ "@mnmal-ai/substrate-dataset-memory": "1.0.0-alpha.8",
45
+ "@mnmal-ai/substrate-dataset-pg": "1.0.0-alpha.8",
46
+ "@mnmal-ai/substrate-embedder": "1.0.0-alpha.8",
47
+ "@mnmal-ai/substrate-filter": "1.0.0-alpha.8",
48
+ "@mnmal-ai/substrate-pack": "1.0.0-alpha.8",
49
+ "@mnmal-ai/substrate-policy": "1.0.0-alpha.8",
50
+ "@mnmal-ai/substrate-proposals": "1.0.0-alpha.8",
51
+ "@mnmal-ai/substrate-recall": "1.0.0-alpha.8",
52
+ "@mnmal-ai/substrate-sdk": "1.0.0-alpha.8",
53
+ "@mnmal-ai/substrate-sentinel-client": "1.0.0-alpha.8",
54
+ "@mnmal-ai/substrate-server-fastify": "1.0.0-alpha.8",
55
+ "@mnmal-ai/substrate-server-memory": "1.0.0-alpha.8",
56
+ "@mnmal-ai/substrate-types": "1.0.0-alpha.8",
57
57
  "@types/node": "^26.6.4",
58
58
  "@types/semver": "^7.5.0",
59
59
  "@types/ws": "^8.18.1",