@mnmal-ai/substrate 1.0.0-alpha.0 → 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/README.md +3 -3
- package/dist/client.js +4 -4
- package/dist/{dataset-BXkus75W.js → dataset-BQ8egGl5.js} +19 -11
- package/dist/{agent-token-BIboWOU0.js → env-utils-CGNazUNt.js} +31 -2
- package/dist/pack.js +1 -1
- package/dist/{plugin-j1jt1l3n.js → plugin-QuJN9pG_.js} +40 -12
- package/dist/proposals-bootstrap.js +2 -2
- package/dist/proposals.js +1 -1
- package/dist/recall-bootstrap.js +11 -4
- package/dist/recall.config.schema.json +6 -0
- package/dist/recall.d.ts +21 -6
- package/dist/recall.js +2 -2
- package/dist/{row-DK7lPZVe.js → row-DZ0Fnpc6.js} +9 -11
- package/dist/sdk.d.ts +6 -0
- package/dist/sdk.js +5 -6
- package/dist/{src-C4DzaIQZ.js → src-BLgbLq2k.js} +2 -0
- package/dist/{src-D88LvCX8.js → src-CG7giuHr.js} +2 -2
- package/dist/{src-D91yij6C.js → src-CHp3QyqB.js} +234 -162
- package/dist/{src-CzxvmhFn.js → src-CXKnqeTW.js} +100 -88
- package/dist/{src-DuopV8u7.js → src-DMzc3HfW.js} +53 -11
- package/dist/{src-CrEgiMJQ.js → src-DWm0iA88.js} +17 -11
- package/dist/substrate-admin.js +5 -5
- package/dist/substrate.js +35 -20
- package/dist/testing.d.ts +6 -1
- package/dist/testing.js +2 -2
- package/package.json +19 -19
- package/dist/env-utils-B7SGmoeJ.js +0 -21
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-
|
|
4
|
-
import {
|
|
5
|
-
import { L as encodeList, T as SYSTEM_NAMESPACE, f as coversNamespace, m as grantedIn, p as grantOf } from "./row-
|
|
6
|
-
import { t as
|
|
7
|
-
import {
|
|
8
|
-
import { a as
|
|
9
|
-
import {
|
|
10
|
-
import { B as version, R as openSql, t as openPgDataset, z as AdminCliError } from "./dataset-BXkus75W.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
|
|
79
|
-
|
|
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 ?? "")
|
|
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 ?? "")
|
|
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 ?? "")
|
|
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({
|
|
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({
|
|
2236
|
+
}) : new MemoryDataset({
|
|
2237
|
+
namespace: ns,
|
|
2238
|
+
fieldDefLookup: fieldDefLookupFor(ns)
|
|
2239
|
+
});
|
|
2230
2240
|
}
|
|
2231
2241
|
return datasets;
|
|
2232
2242
|
}
|
|
@@ -3351,6 +3361,10 @@ function installShutdown(args) {
|
|
|
3351
3361
|
}
|
|
3352
3362
|
shuttingDown = true;
|
|
3353
3363
|
process.stdout.write(`\nreceived ${signal} — shutting down (grace ${config.shutdownGraceMs}ms)\n`);
|
|
3364
|
+
setTimeout(() => {
|
|
3365
|
+
process.stderr.write("shutdown exceeded its grace; exiting with work still pending\n");
|
|
3366
|
+
process.exit(1);
|
|
3367
|
+
}, config.shutdownGraceMs + 1e3).unref();
|
|
3354
3368
|
clearInterval(sweepTimer);
|
|
3355
3369
|
if (inviteSweepTimer !== null) clearInterval(inviteSweepTimer);
|
|
3356
3370
|
(sentinelClient !== null ? sentinelClient.stop().catch((err) => {
|
|
@@ -4484,9 +4498,10 @@ function isEmbedderMode(value) {
|
|
|
4484
4498
|
/**
|
|
4485
4499
|
* The cortext line publishes on its own versions and declares substrate as a
|
|
4486
4500
|
* peer range. Raise the floor when a cortext release drops support for the
|
|
4487
|
-
* substrate major this binary is on.
|
|
4501
|
+
* substrate major this binary is on. The floor names a prerelease because a
|
|
4502
|
+
* caret range admits no prerelease of a version it does not itself name.
|
|
4488
4503
|
*/
|
|
4489
|
-
const CORTEXT_RANGE = "^1.0.0";
|
|
4504
|
+
const CORTEXT_RANGE = "^1.0.0-alpha.0";
|
|
4490
4505
|
const KNOWN_PLUGINS = [
|
|
4491
4506
|
{
|
|
4492
4507
|
name: "cortext",
|
|
@@ -4854,7 +4869,7 @@ async function runNormaliseVocab(argv, options = {}) {
|
|
|
4854
4869
|
write("usage: substrate normalise-vocab <namespace> <Type> <field> [--apply] [--reject a,b] [--json]\n");
|
|
4855
4870
|
return 2;
|
|
4856
4871
|
}
|
|
4857
|
-
const baseUrl = (options.baseUrl ?? process.env.SUBSTRATE_URL ?? "")
|
|
4872
|
+
const baseUrl = trimTrailingSlashes(options.baseUrl ?? process.env.SUBSTRATE_URL ?? "");
|
|
4858
4873
|
if (baseUrl === "") {
|
|
4859
4874
|
write("SUBSTRATE_URL is required (e.g. https://substrate.example.com:3100)\n");
|
|
4860
4875
|
return 2;
|
|
@@ -5008,7 +5023,7 @@ function toMessage(err) {
|
|
|
5008
5023
|
* Used by /substrate/v1/nl + /substrate/v1/_system/drop-{namespace,type}.
|
|
5009
5024
|
*/
|
|
5010
5025
|
async function postSubstrate(endpoint, path, body, errorMode = "textPreview") {
|
|
5011
|
-
const url = `${endpoint
|
|
5026
|
+
const url = `${trimTrailingSlashes(endpoint)}${path}`;
|
|
5012
5027
|
let res;
|
|
5013
5028
|
try {
|
|
5014
5029
|
res = await fetch(url, {
|
|
@@ -5046,7 +5061,7 @@ async function postSubstrate(endpoint, path, body, errorMode = "textPreview") {
|
|
|
5046
5061
|
* a transport failure wraps the cause with the failing URL.
|
|
5047
5062
|
*/
|
|
5048
5063
|
async function getSubstrate(endpoint, path) {
|
|
5049
|
-
const url = `${endpoint
|
|
5064
|
+
const url = `${trimTrailingSlashes(endpoint)}${path}`;
|
|
5050
5065
|
let res;
|
|
5051
5066
|
try {
|
|
5052
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-
|
|
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(/^_
|
|
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.
|
|
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.
|
|
40
|
-
"@mnmal-ai/substrate-client": "1.0.0-alpha.
|
|
41
|
-
"@mnmal-ai/substrate-compose": "1.0.0-alpha.
|
|
42
|
-
"@mnmal-ai/substrate-config": "1.0.0-alpha.
|
|
43
|
-
"@mnmal-ai/substrate-core": "1.0.0-alpha.
|
|
44
|
-
"@mnmal-ai/substrate-dataset-memory": "1.0.0-alpha.
|
|
45
|
-
"@mnmal-ai/substrate-dataset-pg": "1.0.0-alpha.
|
|
46
|
-
"@mnmal-ai/substrate-embedder": "1.0.0-alpha.
|
|
47
|
-
"@mnmal-ai/substrate-filter": "1.0.0-alpha.
|
|
48
|
-
"@mnmal-ai/substrate-pack": "1.0.0-alpha.
|
|
49
|
-
"@mnmal-ai/substrate-policy": "1.0.0-alpha.
|
|
50
|
-
"@mnmal-ai/substrate-proposals": "1.0.0-alpha.
|
|
51
|
-
"@mnmal-ai/substrate-recall": "1.0.0-alpha.
|
|
52
|
-
"@mnmal-ai/substrate-sdk": "1.0.0-alpha.
|
|
53
|
-
"@mnmal-ai/substrate-sentinel-client": "1.0.0-alpha.
|
|
54
|
-
"@mnmal-ai/substrate-server-fastify": "1.0.0-alpha.
|
|
55
|
-
"@mnmal-ai/substrate-server-memory": "1.0.0-alpha.
|
|
56
|
-
"@mnmal-ai/substrate-types": "1.0.0-alpha.
|
|
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 };
|