@mnmal-ai/substrate 1.0.0-alpha.1 → 1.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/substrate.js CHANGED
@@ -1,13 +1,12 @@
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-YXlv_RyL.js";
4
- import { a as makeAuthorizationProvider, n as DEFAULT_CAPABILITIES } from "./agent-token-BIboWOU0.js";
5
- import { L as encodeList, T as SYSTEM_NAMESPACE, f as coversNamespace, m as grantedIn, p as grantOf } from "./row-DK7lPZVe.js";
6
- import { t as parsePositiveInt } from "./env-utils-B7SGmoeJ.js";
7
- import { c as AuthError, d as AdminBackfillError, l as NetworkError, n as tokenAudience, r as SubstrateClient, t as noRedirectFetch } from "./src-DuopV8u7.js";
8
- import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore } from "./src-zcyUofMJ.js";
9
- import { a as runDerivedMigrations, n as txScopeIdFor, o as runMigrations, r as deriveListIndexMigration, s as tryWithPgAdvisoryLock, t as PgDataset } from "./src-CjEwiKXw.js";
10
- import { B as version, R as openSql, t as openPgDataset, z as AdminCliError } from "./dataset-DOXGRz50.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-CHp3QyqB.js";
4
+ import { i as DEFAULT_CAPABILITIES, n as trimTrailingSlashes, s as makeAuthorizationProvider, t as parsePositiveInt } from "./env-utils-CGNazUNt.js";
5
+ import { L as encodeList, T as SYSTEM_NAMESPACE, f as coversNamespace, m as grantedIn, p as grantOf } from "./row-DZ0Fnpc6.js";
6
+ import { c as AuthError, d as AdminBackfillError, l as NetworkError, n as tokenAudience, r as SubstrateClient, t as noRedirectFetch } from "./src-DMzc3HfW.js";
7
+ import { a as InMemoryLexicalStore, i as PgClusterStore, n as PgLexicalStore, o as InMemoryEmbeddingsStore, r as PgEmbeddingsStore, s as InMemoryClusterStore } from "./src-DWm0iA88.js";
8
+ import { a as runDerivedMigrations, n as txScopeIdFor, o as runMigrations, r as deriveListIndexMigration, s as tryWithPgAdvisoryLock, t as PgDataset } from "./src-CXKnqeTW.js";
9
+ import { B as version, R as openSql, t as openPgDataset, z as AdminCliError } from "./dataset-BQ8egGl5.js";
11
10
  import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
12
11
  import { homedir, hostname } from "node:os";
13
12
  import { basename, dirname, join, resolve } from "node:path";
@@ -75,8 +74,13 @@ var HttpBridgeClient = class {
75
74
  _deletedAt: true
76
75
  }
77
76
  } };
78
- const data = (await this.query(frame)).data?.[key];
79
- if (data === void 0 || data === null) return null;
77
+ const envelope = await this.query(frame);
78
+ const data = envelope.data?.[key];
79
+ if (data === void 0) {
80
+ const code = envelope.errors?.[0]?.code ?? "no_data";
81
+ throw new BridgeUnreachableError(this.name, this.baseUrl, `refused (${code})`);
82
+ }
83
+ if (data === null) return null;
80
84
  if (Array.isArray(data)) {
81
85
  const first = data[0];
82
86
  return first === void 0 || first === null ? null : first;
@@ -796,7 +800,7 @@ async function runAsk(argv, options = {}) {
796
800
  else project = v;
797
801
  } else words.push(a);
798
802
  }
799
- const endpoint = (env.SUBSTRATE_URL ?? "").replace(/\/+$/, "");
803
+ const endpoint = trimTrailingSlashes(env.SUBSTRATE_URL ?? "");
800
804
  if (endpoint === "") {
801
805
  write("SUBSTRATE_URL is required (e.g. https://substrate.example.com:3100)\n");
802
806
  return 2;
@@ -896,7 +900,7 @@ async function runBackfillField(argv, options = {}) {
896
900
  write("usage: substrate backfill-field <namespace> <Type> <field> --values <file.json> [--apply] [--overwrite] [--json]\n");
897
901
  return 2;
898
902
  }
899
- const baseUrl = (options.baseUrl ?? process.env.SUBSTRATE_URL ?? "").replace(/\/+$/, "");
903
+ const baseUrl = trimTrailingSlashes(options.baseUrl ?? process.env.SUBSTRATE_URL ?? "");
900
904
  if (baseUrl === "") {
901
905
  write("SUBSTRATE_URL is required (e.g. https://substrate.example.com:3100)\n");
902
906
  return 2;
@@ -1073,7 +1077,7 @@ async function scanField(field, opts) {
1073
1077
  async function runCheckEnums(argv = [], options = {}) {
1074
1078
  const write = options.write ?? ((text) => process.stdout.write(text));
1075
1079
  const asJson = argv.includes("--json");
1076
- const baseUrl = (options.baseUrl ?? process.env.SUBSTRATE_URL ?? "").replace(/\/+$/, "");
1080
+ const baseUrl = trimTrailingSlashes(options.baseUrl ?? process.env.SUBSTRATE_URL ?? "");
1077
1081
  if (baseUrl === "") {
1078
1082
  write("SUBSTRATE_URL is required (e.g. https://substrate.example.com:3100)\n");
1079
1083
  return 2;
@@ -2091,7 +2095,10 @@ const filterRegistry = { register(name, op) {
2091
2095
  const pendingMcpTools = [];
2092
2096
  async function wireStore(storeSpec, fieldDefLookupFor) {
2093
2097
  if (storeSpec === "memory") return {
2094
- dataset: new MemoryDataset({ namespace: DEFAULT_NAMESPACE }),
2098
+ dataset: new MemoryDataset({
2099
+ namespace: DEFAULT_NAMESPACE,
2100
+ fieldDefLookup: fieldDefLookupFor(DEFAULT_NAMESPACE)
2101
+ }),
2095
2102
  edges: new MemoryEdgesStore({ now: () => /* @__PURE__ */ new Date() }),
2096
2103
  substrateNamespaceDataset: null,
2097
2104
  sql: null,
@@ -2226,7 +2233,10 @@ function buildPluginDatasetMap(plugins, defaultDataset, sharedSql, sharedEdges,
2226
2233
  fieldDefLookup: fieldDefLookupFor(ns),
2227
2234
  ...nsDef.promotedColumns !== void 0 ? { promotedColumns: nsDef.promotedColumns } : {},
2228
2235
  ...sharedEdges !== null ? { edgesStore: sharedEdges } : {}
2229
- }) : new MemoryDataset({ namespace: ns });
2236
+ }) : new MemoryDataset({
2237
+ namespace: ns,
2238
+ fieldDefLookup: fieldDefLookupFor(ns)
2239
+ });
2230
2240
  }
2231
2241
  return datasets;
2232
2242
  }
@@ -4859,7 +4869,7 @@ async function runNormaliseVocab(argv, options = {}) {
4859
4869
  write("usage: substrate normalise-vocab <namespace> <Type> <field> [--apply] [--reject a,b] [--json]\n");
4860
4870
  return 2;
4861
4871
  }
4862
- const baseUrl = (options.baseUrl ?? process.env.SUBSTRATE_URL ?? "").replace(/\/+$/, "");
4872
+ const baseUrl = trimTrailingSlashes(options.baseUrl ?? process.env.SUBSTRATE_URL ?? "");
4863
4873
  if (baseUrl === "") {
4864
4874
  write("SUBSTRATE_URL is required (e.g. https://substrate.example.com:3100)\n");
4865
4875
  return 2;
@@ -5013,7 +5023,7 @@ function toMessage(err) {
5013
5023
  * Used by /substrate/v1/nl + /substrate/v1/_system/drop-{namespace,type}.
5014
5024
  */
5015
5025
  async function postSubstrate(endpoint, path, body, errorMode = "textPreview") {
5016
- const url = `${endpoint.replace(/\/+$/, "")}${path}`;
5026
+ const url = `${trimTrailingSlashes(endpoint)}${path}`;
5017
5027
  let res;
5018
5028
  try {
5019
5029
  res = await fetch(url, {
@@ -5051,7 +5061,7 @@ async function postSubstrate(endpoint, path, body, errorMode = "textPreview") {
5051
5061
  * a transport failure wraps the cause with the failing URL.
5052
5062
  */
5053
5063
  async function getSubstrate(endpoint, path) {
5054
- const url = `${endpoint.replace(/\/+$/, "")}${path}`;
5064
+ const url = `${trimTrailingSlashes(endpoint)}${path}`;
5055
5065
  let res;
5056
5066
  try {
5057
5067
  res = await fetch(url, {
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as Id, E as Row, _ as EdgesStore, b as ActorIdentity, f as CanDeleteResult, g as EdgeWriteInput, h as EdgeRef, l as PackEnvelope, m as EdgePatch, p as Edge, u as Schema } from "./schema-g4FQLr0V.js";
1
+ import { C as Id, E as Row, _ as EdgesStore, b as ActorIdentity, f as CanDeleteResult, g as EdgeWriteInput, h as EdgeRef, l as PackEnvelope, m as EdgePatch, n as FieldDef, p as Edge, u as Schema } from "./schema-g4FQLr0V.js";
2
2
  import { a as RuntimeErrors, n as ResolveObservation, r as ResolverStat, s as SlowRequest, t as ProcessStat } from "./runtime-metrics-DwpDJ8vz.js";
3
3
  import { $ as PolicyProbeContext, A as ScheduledTask, B as StartOpts, C as QualifiedFrame, D as RegistryEntryInput, E as RegistryEntry, F as HttpMethod, G as WsConnection, H as SubstrateResponse, I as PluginRouter, K as WsHandler, P as HttpHandler, Q as PolicyDecision, R as RequestObserver, St as WriteResult, T as RegistryBase, U as SubstrateServer, V as SubstrateRequest, Y as Identity, _t as ReadResult, a as EngineHandle, ct as Dataset, dt as DropResult, et as RequestContext, g as NamespaceConfig, gt as ReadParams, lt as DatasetRegistry, mt as FilterCapabilities, n as DropParticipant, o as EngineInput, p as KernelPlugin, st as ConditionalUpdateResult, t as CoordinatorPlugin, ut as DeleteResult, w as Registry$1, xt as WriteOptions, yt as UpdateFieldRef, z as RuntimeOp } from "./plugin-t2g2wX0b.js";
4
4
  import { a as WsResponseFrame, f as IdempotencyStore, l as SweepDeps, s as BridgeRegistry, u as SweepState } from "./ws-C72iVS5T.js";
@@ -728,6 +728,11 @@ interface MemoryDatasetOptions {
728
728
  * tests without spinning up pg.
729
729
  */
730
730
  txScopeId?: string;
731
+ /**
732
+ * The namespace's field declarations. Lets `date` fields filter and sort as
733
+ * instants, as the pg dataset's lookup does; without it they compare as text.
734
+ */
735
+ fieldDefLookup?: (type: string, field: string) => FieldDef | undefined;
731
736
  }
732
737
  export declare class MemoryDataset implements Dataset {
733
738
  #private;
package/dist/testing.js CHANGED
@@ -1,5 +1,5 @@
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-YXlv_RyL.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-CHp3QyqB.js";
3
3
  import { t as FakeEmbedder } from "./fake-DUVtKVSE.js";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import postgres from "postgres";
@@ -183,7 +183,7 @@ const TEST_SCHEMA_PREFIX = "substrate_test_";
183
183
  * migrations stay incremental.
184
184
  */
185
185
  function pgTestSchemaName(packageName) {
186
- const slug = packageName.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
186
+ const slug = packageName.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "");
187
187
  return `${TEST_SCHEMA_PREFIX}${slug}`.slice(0, 63);
188
188
  }
189
189
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mnmal-ai/substrate",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.2",
4
4
  "description": "Substrate — an agent-first typed-data server: the substrate and substrate-admin binaries, the built-in plugins and the SDK subpaths.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -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.1",
40
- "@mnmal-ai/substrate-client": "1.0.0-alpha.1",
41
- "@mnmal-ai/substrate-compose": "1.0.0-alpha.1",
42
- "@mnmal-ai/substrate-config": "1.0.0-alpha.1",
43
- "@mnmal-ai/substrate-core": "1.0.0-alpha.1",
44
- "@mnmal-ai/substrate-dataset-memory": "1.0.0-alpha.1",
45
- "@mnmal-ai/substrate-dataset-pg": "1.0.0-alpha.1",
46
- "@mnmal-ai/substrate-embedder": "1.0.0-alpha.1",
47
- "@mnmal-ai/substrate-filter": "1.0.0-alpha.1",
48
- "@mnmal-ai/substrate-pack": "1.0.0-alpha.1",
49
- "@mnmal-ai/substrate-policy": "1.0.0-alpha.1",
50
- "@mnmal-ai/substrate-proposals": "1.0.0-alpha.1",
51
- "@mnmal-ai/substrate-recall": "1.0.0-alpha.1",
52
- "@mnmal-ai/substrate-sdk": "1.0.0-alpha.1",
53
- "@mnmal-ai/substrate-sentinel-client": "1.0.0-alpha.1",
54
- "@mnmal-ai/substrate-server-fastify": "1.0.0-alpha.1",
55
- "@mnmal-ai/substrate-server-memory": "1.0.0-alpha.1",
56
- "@mnmal-ai/substrate-types": "1.0.0-alpha.1",
39
+ "@mnmal-ai/substrate-bootstrap": "1.0.0-alpha.2",
40
+ "@mnmal-ai/substrate-client": "1.0.0-alpha.2",
41
+ "@mnmal-ai/substrate-compose": "1.0.0-alpha.2",
42
+ "@mnmal-ai/substrate-config": "1.0.0-alpha.2",
43
+ "@mnmal-ai/substrate-core": "1.0.0-alpha.2",
44
+ "@mnmal-ai/substrate-dataset-memory": "1.0.0-alpha.2",
45
+ "@mnmal-ai/substrate-dataset-pg": "1.0.0-alpha.2",
46
+ "@mnmal-ai/substrate-embedder": "1.0.0-alpha.2",
47
+ "@mnmal-ai/substrate-filter": "1.0.0-alpha.2",
48
+ "@mnmal-ai/substrate-pack": "1.0.0-alpha.2",
49
+ "@mnmal-ai/substrate-policy": "1.0.0-alpha.2",
50
+ "@mnmal-ai/substrate-proposals": "1.0.0-alpha.2",
51
+ "@mnmal-ai/substrate-recall": "1.0.0-alpha.2",
52
+ "@mnmal-ai/substrate-sdk": "1.0.0-alpha.2",
53
+ "@mnmal-ai/substrate-sentinel-client": "1.0.0-alpha.2",
54
+ "@mnmal-ai/substrate-server-fastify": "1.0.0-alpha.2",
55
+ "@mnmal-ai/substrate-server-memory": "1.0.0-alpha.2",
56
+ "@mnmal-ai/substrate-types": "1.0.0-alpha.2",
57
57
  "@types/node": "^26.6.4",
58
58
  "@types/semver": "^7.5.0",
59
59
  "@types/ws": "^8.18.1",
@@ -1,21 +0,0 @@
1
- import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- //#region ../../packages/substrate-types/src/env-utils.ts
3
- /**
4
- * Pure env-string parsing helpers shared by plugins and deployment helpers
5
- * (e.g. `substrate-sentinel-client`) without a substrate-sdk runtime dep.
6
- */
7
- /**
8
- * Strict positive-integer env parsing. Returns `fallback` when `raw` is
9
- * undefined (env var unset). Throws with `envVar` in the message when `raw`
10
- * is set but not a positive integer — never falls back on invalid input, so
11
- * a config typo fails at boot.
12
- */
13
- function parsePositiveInt(raw, envVar, fallback) {
14
- if (raw === void 0) return fallback;
15
- const n = Number(raw);
16
- if (!Number.isFinite(n) || !Number.isInteger(n) || n <= 0) throw new Error(`${envVar} must be a positive integer (got '${raw}')`);
17
- return n;
18
- }
19
-
20
- //#endregion
21
- export { parsePositiveInt as t };