@mnmal-ai/substrate 0.0.0-stage → 1.0.0-alpha.0

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.
Files changed (46) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +119 -2
  3. package/dist/agent-token-BIboWOU0.js +200 -0
  4. package/dist/client.d.ts +782 -0
  5. package/dist/client.js +7 -0
  6. package/dist/cluster-worker.js +35 -0
  7. package/dist/content-type-C7T28xNb.js +25 -0
  8. package/dist/dataset-BXkus75W.js +1527 -0
  9. package/dist/env-utils-B7SGmoeJ.js +21 -0
  10. package/dist/errors-D4vKuwz8.d.ts +130 -0
  11. package/dist/fake-DUVtKVSE.js +36 -0
  12. package/dist/index-D7mSOFlM.d.ts +69 -0
  13. package/dist/pack.d.ts +192 -0
  14. package/dist/pack.js +5 -0
  15. package/dist/plugin-j1jt1l3n.js +3844 -0
  16. package/dist/plugin-t2g2wX0b.d.ts +1568 -0
  17. package/dist/proposals-bootstrap.js +37 -0
  18. package/dist/proposals.config.schema.json +20 -0
  19. package/dist/proposals.d.ts +118 -0
  20. package/dist/proposals.default-config.json +4 -0
  21. package/dist/proposals.js +4 -0
  22. package/dist/recall-bootstrap.js +451 -0
  23. package/dist/recall.config.schema.json +232 -0
  24. package/dist/recall.d.ts +1981 -0
  25. package/dist/recall.default-config.json +4 -0
  26. package/dist/recall.js +5 -0
  27. package/dist/repl-C52wyfMs.js +2213 -0
  28. package/dist/row-ByLFE2Wx.d.ts +719 -0
  29. package/dist/row-DK7lPZVe.js +732 -0
  30. package/dist/runtime-metrics-DwpDJ8vz.d.ts +159 -0
  31. package/dist/schema-g4FQLr0V.d.ts +433 -0
  32. package/dist/sdk.d.ts +694 -0
  33. package/dist/sdk.js +112 -0
  34. package/dist/src-C4DzaIQZ.js +837 -0
  35. package/dist/src-CrEgiMJQ.js +1015 -0
  36. package/dist/src-CzxvmhFn.js +2327 -0
  37. package/dist/src-D88LvCX8.js +1797 -0
  38. package/dist/src-D91yij6C.js +13523 -0
  39. package/dist/src-DuopV8u7.js +2408 -0
  40. package/dist/substrate-admin.js +808 -0
  41. package/dist/substrate.js +5477 -0
  42. package/dist/testing.d.ts +1240 -0
  43. package/dist/testing.js +702 -0
  44. package/dist/types-8c0gtnd2.d.ts +35 -0
  45. package/dist/ws-C72iVS5T.d.ts +143 -0
  46. package/package.json +117 -3
package/dist/sdk.js ADDED
@@ -0,0 +1,112 @@
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-D91yij6C.js";
3
+ import { a as makeAuthorizationProvider, c as resolveDefaultKeyPath, i as isEncryptedKey, l as resolveDefaultKidPath, n as DEFAULT_CAPABILITIES, o as makeTokenProvider, r as adminClaimCapabilities, s as resolveAdminCredential, t as ADMIN_CAPABILITIES } from "./agent-token-BIboWOU0.js";
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-DK7lPZVe.js";
5
+ import { S as assertNever, b as formatQualifiedKey, x as parseQualifiedKey } from "./src-C4DzaIQZ.js";
6
+ import { t as parsePositiveInt } from "./env-utils-B7SGmoeJ.js";
7
+
8
+ //#region ../../packages/substrate-sdk/src/engine-helpers.ts
9
+ /**
10
+ * Engine-call helpers for coordinator/plugin authors.
11
+ *
12
+ * Run an internal engine query or build a request context from inside a
13
+ * plugin route or scheduled task, so coordinators share one implementation.
14
+ *
15
+ * Depends only on `@mnmal-ai/substrate-types`; this package must not take a
16
+ * runtime dependency on `substrate-core`.
17
+ */
18
+ /**
19
+ * Build a minimal `Partial<RequestContext>` for a plugin's engine call.
20
+ *
21
+ * PASS THE CALLER'S IDENTITY WHENEVER THERE IS ONE. Omitting it yields the
22
+ * SYSTEM ACTOR (`identity: null`), which the engine's per-frame namespace gate
23
+ * waves through unconditionally — correct for genuinely system-initiated work
24
+ * (a scheduled sweep, a liveness probe), and a privilege escalation for
25
+ * anything a caller asked for. A plugin route that omits it lets a caller reach
26
+ * namespaces their grant does not cover, because the route gate checks a
27
+ * capability without a namespace and the engine gate then checks a namespace
28
+ * without an identity.
29
+ *
30
+ * The distinction is WHO ASKED, not which plugin.
31
+ */
32
+ function makeCtx(namespace, operation, identity = null) {
33
+ return {
34
+ identity,
35
+ namespace,
36
+ operation,
37
+ now: /* @__PURE__ */ new Date(),
38
+ headers: {},
39
+ meta: {}
40
+ };
41
+ }
42
+ /**
43
+ * A frame the engine REFUSED, surfaced as a throw rather than as an empty result.
44
+ *
45
+ * Substrate returns a partial-success envelope: a rejected frame comes back with its
46
+ * key ABSENT from `data` and the reason in `errors`. Without this, `queryOne` /
47
+ * `queryAll` would render a refusal as `null` / `[]`, indistinguishable from a
48
+ * query that matched nothing.
49
+ */
50
+ var EngineQueryError = class extends Error {
51
+ name = "EngineQueryError";
52
+ code;
53
+ constructor(code, message) {
54
+ super(message);
55
+ this.code = code;
56
+ }
57
+ };
58
+ /** Throw when the envelope carries an error, so a refusal cannot read as absence. */
59
+ function assertNoFrameError(env, key) {
60
+ const err = env.errors?.[0];
61
+ if (err !== void 0) throw new EngineQueryError(err.code ?? "query_failed", err.message ?? `${key} was refused`);
62
+ }
63
+ /** Expand a list of field names into the `{ field: true }` selection map. */
64
+ function selectAll(fields) {
65
+ const out = {};
66
+ for (const f of fields) out[f] = true;
67
+ return out;
68
+ }
69
+ /** Accept either a field-name list or an already-built selection map. */
70
+ function toSelection(fields) {
71
+ return Array.isArray(fields) ? selectAll(fields) : fields;
72
+ }
73
+ /**
74
+ * Run an internal engine query and return the row list (empty when the frame
75
+ * resolves to nothing). `fields` may be a name list or a prebuilt selection map.
76
+ */
77
+ async function queryAll(engine, namespace, typeName, params, fields, identity = null) {
78
+ const key = formatQualifiedKey(namespace, typeName);
79
+ const env = await engine.query({
80
+ frame: { [key]: {
81
+ params,
82
+ fields: toSelection(fields)
83
+ } },
84
+ ctx: makeCtx(namespace, "query", identity)
85
+ });
86
+ assertNoFrameError(env, key);
87
+ const rows = env.data[key];
88
+ if (rows === void 0 || rows === null) return [];
89
+ return rows;
90
+ }
91
+ /**
92
+ * Run an internal engine query expecting at most one row; returns the first
93
+ * row or null. `fields` may be a name list or a prebuilt selection map.
94
+ */
95
+ async function queryOne(engine, namespace, typeName, params, fields, identity = null) {
96
+ const key = formatQualifiedKey(namespace, typeName);
97
+ const env = await engine.query({
98
+ frame: { [key]: {
99
+ params,
100
+ fields: toSelection(fields)
101
+ } },
102
+ ctx: makeCtx(namespace, "query", identity)
103
+ });
104
+ assertNoFrameError(env, key);
105
+ const rows = env.data[key];
106
+ if (rows === void 0 || rows === null) return null;
107
+ if (Array.isArray(rows)) return rows[0] ?? null;
108
+ return rows;
109
+ }
110
+
111
+ //#endregion
112
+ export { ADMIN_CAPABILITIES, BootstrapConfigError, BridgeUnreachableError, CLIENT_SUPPLIED_SERVER_FIELD, DEFAULT_CAPABILITIES, EngineQueryError, JSON_HEADERS, METADATA_AUTHOR_FIELDS, METADATA_FILTER_FIELDS, MissingReferentError, NamespaceMismatch, RESERVED_AUTOCRUD_FIELDS, RESERVED_AUTOCRUD_FIELD_NAMES, ROW_METADATA_FIELDS, RegistryBase, ReservedField, ResolverFrameError, RestrictViolation, SYSTEM_NAMESPACE, UnattributedWriteError, UnsupportedFilterError, WS_CODE_SUBSCRIPTION_UNSUPPORTED_FRAME, WS_REASON_SERVER_RESTART, WS_REASON_SUBSCRIPTION_OVERLOADED, adminClaimCapabilities, allCapabilities, allowAll, allowVerbs, and, applyRowFilters, applyUpdatePatch, assertHardDeleteAllowed, assertNever, autoCrudOptionsOf, canonicalVocabValue, canonicalize, capabilitiesFor, checkRevocable, checkUpdatable, confersAnywhere, coversNamespace, createKeyedMutex, createResolver, createResolverWithEdges, decodeList, defineBootstrap, defineNamespace, deleteResolver, deleteRow, denyAll, denyVerbs, describeGrant, encodeGrant, encodeList, error400, expandFlat, field, flattenGrant, formatQualifiedKey, getResolver, grantCovers, grantEntriesConfer, grantEntryError, grantIsUniform, grantOf, grantedIn, installAutoCrud, intersectGrants, isActiveAdminKeyRow, isAuthCause, isEncryptedKey, isResolverFrameError, isRestrictViolation, jsonResponse, listResolver, makeAuthorizationProvider, makeCtx, makeTokenProvider, newlyGranted, newlyGrantedPairs, normaliseMetadataOrderBy, normaliseMetadataWhere, normaliseVocabValues, normaliseVocabWhere, not, or, parseGrantEntries, parseJsonBody, parsePositiveInt, parseQualifiedKey, purgeResolver, queryAll, queryOne, requireCapability, requireIdentity, requireNamespace, resolveAdminCredential, resolveDefaultKeyPath, resolveDefaultKidPath, resolveEntityId, resolveEntityRow, resolveIdentity, revokedAtIso, row, selectAll, storedVocabSpellings, updateResolver, validateHardDeleteEnv, vocabImplication };