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

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
@@ -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 `.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=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
 
@@ -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-B0BJcyKb.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
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";
6
+ import { i as pendingMigrations, o as runMigrations, t as PgDataset } from "./src-CBV88iyK.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.7";
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-CBV88iyK.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-B0BJcyKb.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-B0BJcyKb.js";
3
+ import { n as createNoopPubSub, t as createProposalsPlugin } from "./src-DgLqCklp.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-DgLqCklp.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-B0BJcyKb.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-0dPAYAEm.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-C9pC-AKI.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-0dPAYAEm.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 };
@@ -2146,18 +2146,18 @@ async function runRepl(seed) {
2146
2146
  }));
2147
2147
  const embedder = seed.embedder ?? await dist_default({
2148
2148
  message: "Semantic recall embedder:",
2149
- default: "minilm",
2149
+ default: "bge-base",
2150
2150
  choices: [
2151
2151
  {
2152
- name: "minilm — all-MiniLM-L6-v2, in-process (recommended)",
2153
- value: "minilm"
2152
+ name: "bge-base — bge-base-en-v1.5, in-process (recommended)",
2153
+ value: "bge-base"
2154
2154
  },
2155
2155
  {
2156
- name: "bge-base — bge-base-en-v1.5, in-process, slower and stronger",
2157
- value: "bge-base"
2156
+ name: "minilm — all-MiniLM-L6-v2, in-process, smaller and faster",
2157
+ value: "minilm"
2158
2158
  },
2159
2159
  {
2160
- name: "ollama — bge-m3 via local Ollama",
2160
+ name: "ollama — bge-base-en-v1.5 via local Ollama",
2161
2161
  value: "ollama"
2162
2162
  },
2163
2163
  {
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-B0BJcyKb.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";
@@ -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
  /**
@@ -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-CBV88iyK.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-0dPAYAEm.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.7";
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 { 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-B0BJcyKb.js";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
 
5
5
  //#region ../../packages/substrate-dataset-pg/src/advisory-lock.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-B0BJcyKb.js";
3
3
  import { s as requireCapability } from "./row-DZ0Fnpc6.js";
4
4
  import { randomUUID } from "node:crypto";
5
5
 
@@ -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-B0BJcyKb.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
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";
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-DuPv47JG.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-B0BJcyKb.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
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";
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-CBV88iyK.js";
9
+ import { t as PgEdgesStore } from "./pg-edges-store-CKu6M8PU.js";
10
+ import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore } from "./src-C9pC-AKI.js";
11
+ import { B as version, R as openSql, t as openPgDataset, z as AdminCliError } from "./dataset-DuPv47JG.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-DiBeGwIW.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,
@@ -5146,9 +5149,9 @@ Environment for \`serve\` (the load-bearing ones; the full reference is in the d
5146
5149
  outstanding ticket, which is the only revocation
5147
5150
  mechanism.
5148
5151
  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
5152
+ https://host:3100,https://alias). A token must carry
5153
+ 'aud' naming one; a token with no 'aud' is refused.
5154
+ Required with auth on a non-loopback
5152
5155
  HOST; on loopback it defaults to the loopback origins.
5153
5156
  SUBSTRATE_TLS_KEY_PATH Serve HTTPS. Both are required together — setting one
5154
5157
  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-B0BJcyKb.js";
3
+ import { a as runDerivedMigrations, o as runMigrations, r as deriveListIndexMigration, t as PgDataset } from "./src-CBV88iyK.js";
4
+ import { t as PgEdgesStore } from "./pg-edges-store-CKu6M8PU.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.7",
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.7",
40
+ "@mnmal-ai/substrate-client": "1.0.0-alpha.7",
41
+ "@mnmal-ai/substrate-compose": "1.0.0-alpha.7",
42
+ "@mnmal-ai/substrate-config": "1.0.0-alpha.7",
43
+ "@mnmal-ai/substrate-core": "1.0.0-alpha.7",
44
+ "@mnmal-ai/substrate-dataset-memory": "1.0.0-alpha.7",
45
+ "@mnmal-ai/substrate-dataset-pg": "1.0.0-alpha.7",
46
+ "@mnmal-ai/substrate-embedder": "1.0.0-alpha.7",
47
+ "@mnmal-ai/substrate-filter": "1.0.0-alpha.7",
48
+ "@mnmal-ai/substrate-pack": "1.0.0-alpha.7",
49
+ "@mnmal-ai/substrate-policy": "1.0.0-alpha.7",
50
+ "@mnmal-ai/substrate-proposals": "1.0.0-alpha.7",
51
+ "@mnmal-ai/substrate-recall": "1.0.0-alpha.7",
52
+ "@mnmal-ai/substrate-sdk": "1.0.0-alpha.7",
53
+ "@mnmal-ai/substrate-sentinel-client": "1.0.0-alpha.7",
54
+ "@mnmal-ai/substrate-server-fastify": "1.0.0-alpha.7",
55
+ "@mnmal-ai/substrate-server-memory": "1.0.0-alpha.7",
56
+ "@mnmal-ai/substrate-types": "1.0.0-alpha.7",
57
57
  "@types/node": "^26.6.4",
58
58
  "@types/semver": "^7.5.0",
59
59
  "@types/ws": "^8.18.1",