@mnmal-ai/substrate 1.0.0-alpha.9 → 1.0.0-beta.1

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 (52) hide show
  1. package/README.md +31 -13
  2. package/dist/boot-store-BMQUbHKv.js +4086 -0
  3. package/dist/{runtime-metrics-DwpDJ8vz.d.ts → bridge-DnToJedN.d.ts} +2 -87
  4. package/dist/cli-DModIbnN.js +3390 -0
  5. package/dist/client.browser.js +2507 -0
  6. package/dist/client.d.ts +222 -171
  7. package/dist/client.js +6 -7
  8. package/dist/cluster-worker.js +0 -1
  9. package/dist/{content-type-C7T28xNb.js → content-type-wLljot5M.js} +0 -1
  10. package/dist/{env-utils-CGNazUNt.js → env-utils-s25Z1YSA.js} +0 -1
  11. package/dist/{errors-D4vKuwz8.d.ts → errors-Cmkp1qxf.d.ts} +44 -4
  12. package/dist/{fake-DUVtKVSE.js → fake-DdXtb-m8.js} +0 -1
  13. package/dist/{index-D7mSOFlM.d.ts → index-BI4KqFiR.d.ts} +7 -11
  14. package/dist/msgpackr-Dq18g6Ds.js +16 -0
  15. package/dist/node-version-BtK_Nq6z.js +32 -0
  16. package/dist/pack.d.ts +75 -11
  17. package/dist/pack.js +4 -4
  18. package/dist/{plugin-DpncES1p.js → plugin-CEOhrEme.js} +78 -8
  19. package/dist/proposals-bootstrap.js +6 -5
  20. package/dist/proposals.config.schema.json +5 -0
  21. package/dist/proposals.d.ts +17 -5
  22. package/dist/proposals.default-config.json +2 -1
  23. package/dist/proposals.js +2 -3
  24. package/dist/recall-bootstrap.js +3 -4
  25. package/dist/recall.d.ts +11 -12
  26. package/dist/recall.js +2 -3
  27. package/dist/{repl-DeKzfvNV.js → repl-BvDZy-Ut.js} +52 -26
  28. package/dist/{row-SRhura12.d.ts → row-D0If4qif.d.ts} +91 -13
  29. package/dist/run-BT123RV1.js +2443 -0
  30. package/dist/{plugin-t2g2wX0b.d.ts → schema-aIkY8sR3.d.ts} +1293 -63
  31. package/dist/{script-C6DSa_Na.js → script-ByQ9pzhC.js} +54 -26
  32. package/dist/script-runner.js +78 -0
  33. package/dist/sdk.d.ts +236 -38
  34. package/dist/sdk.js +5 -110
  35. package/dist/semver-D_zdq0hi.js +17 -0
  36. package/dist/src-BMD2OE--.js +8289 -0
  37. package/dist/{src-BLgbLq2k.js → src-B_kHkbsr.js} +780 -330
  38. package/dist/{src-DjIuRjzF.js → src-CKSJ13p8.js} +10231 -4237
  39. package/dist/{src-C12EA0w9.js → src-CW7eRDss.js} +179 -96
  40. package/dist/{row-DZ0Fnpc6.js → src-DmiUWOLp.js} +2 -1
  41. package/dist/{src-DCy7Iy2l.js → src-DmjwFMu8.js} +900 -77
  42. package/dist/{src-DiNTSaFk.js → src-FXO5JPyk.js} +686 -856
  43. package/dist/substrate-admin.js +17 -782
  44. package/dist/substrate.js +4 -5302
  45. package/dist/testing.d.ts +473 -96
  46. package/dist/testing.js +19 -165
  47. package/dist/{ws-C72iVS5T.d.ts → ws-DW8ng02H.d.ts} +4 -5
  48. package/package.json +26 -26
  49. package/dist/dataset-CqrqTYPz.js +0 -1535
  50. package/dist/pg-edges-store-KH_FQCxx.js +0 -381
  51. package/dist/schema-g4FQLr0V.d.ts +0 -433
  52. package/dist/src-BD27zeGF.js +0 -2339
@@ -1,5 +1,4 @@
1
- import { createRequire as __binCreateRequire } from 'node:module'; const require = __binCreateRequire(import.meta.url);
2
- import { n as defaultPluginsForPersona, r as parsePort, t as KNOWN_PLUGINS } from "./substrate.js";
1
+ import { a as parsePositive, i as DEFAULT_SIZING, n as defaultPluginsForPersona, r as parsePort, t as KNOWN_PLUGINS } from "./cli-DModIbnN.js";
3
2
  import { createRequire } from "node:module";
4
3
  import path from "node:path";
5
4
  import { stripVTControlCharacters, styleText } from "node:util";
@@ -36,7 +35,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
35
  var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
37
36
 
38
37
  //#endregion
39
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/key.js
38
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/key.js
40
39
  const keybindingLookup = /* @__PURE__ */ new Set(["emacs", "vim"]);
41
40
  function isKeybinding(value) {
42
41
  return keybindingLookup.has(value);
@@ -55,7 +54,7 @@ const isNumberKey = (key) => "1234567890".includes(key.name);
55
54
  const isEnterKey = (key) => key.name === "enter" || key.name === "return";
56
55
 
57
56
  //#endregion
58
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/errors.js
57
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/errors.js
59
58
  var AbortPromptError = class extends Error {
60
59
  name = "AbortPromptError";
61
60
  message = "Prompt was aborted";
@@ -79,7 +78,7 @@ var ValidationError = class extends Error {
79
78
  };
80
79
 
81
80
  //#endregion
82
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/hook-engine.js
81
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/hook-engine.js
83
82
  const hookStorage = new AsyncLocalStorage();
84
83
  function createStore(rl) {
85
84
  return {
@@ -174,7 +173,7 @@ const effectScheduler = {
174
173
  };
175
174
 
176
175
  //#endregion
177
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-state.js
176
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/use-state.js
178
177
  function isFactory(value) {
179
178
  return typeof value === "function";
180
179
  }
@@ -199,7 +198,7 @@ function useState(defaultValue) {
199
198
  }
200
199
 
201
200
  //#endregion
202
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-effect.js
201
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/use-effect.js
203
202
  function useEffect(cb, depArray) {
204
203
  withPointer((pointer) => {
205
204
  const oldDeps = pointer.get();
@@ -209,7 +208,7 @@ function useEffect(cb, depArray) {
209
208
  }
210
209
 
211
210
  //#endregion
212
- //#region ../../node_modules/.pnpm/@inquirer+figures@2.0.9/node_modules/@inquirer/figures/dist/index.js
211
+ //#region ../../node_modules/.pnpm/@inquirer+figures@2.0.10/node_modules/@inquirer/figures/dist/index.js
213
212
  function isUnicodeSupported() {
214
213
  if (!process$1.platform.startsWith("win")) return process$1.env["TERM"] !== "linux";
215
214
  return Boolean(process$1.env["CI"]) || Boolean(process$1.env["WT_SESSION"]) || Boolean(process$1.env["TERMINUS_SUBLIME"]) || process$1.env["ConEmuTask"] === "{cmd::Cmder}" || process$1.env["TERM_PROGRAM"] === "Terminus-Sublime" || process$1.env["TERM_PROGRAM"] === "vscode" || process$1.env["TERM"] === "xterm-256color" || process$1.env["TERM"] === "alacritty" || process$1.env["TERMINAL_EMULATOR"] === "JetBrains-JediTerm";
@@ -495,7 +494,7 @@ const figures = shouldUseMain ? mainSymbols : fallbackSymbols;
495
494
  const replacements = Object.entries(specialMainSymbols);
496
495
 
497
496
  //#endregion
498
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/theme.js
497
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/theme.js
499
498
  const defaultTheme = {
500
499
  prefix: {
501
500
  idle: styleText("blue", "?"),
@@ -535,7 +534,7 @@ function getDefaultTheme() {
535
534
  }
536
535
 
537
536
  //#endregion
538
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/make-theme.js
537
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/make-theme.js
539
538
  function isPlainObject(value) {
540
539
  if (typeof value !== "object" || value === null) return false;
541
540
  let proto = value;
@@ -555,7 +554,7 @@ function makeTheme(...themes) {
555
554
  }
556
555
 
557
556
  //#endregion
558
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-prefix.js
557
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/use-prefix.js
559
558
  function usePrefix({ status = "idle", theme }) {
560
559
  const [showLoader, setShowLoader] = useState(false);
561
560
  const [tick, setTick] = useState(0);
@@ -582,7 +581,7 @@ function usePrefix({ status = "idle", theme }) {
582
581
  }
583
582
 
584
583
  //#endregion
585
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-memo.js
584
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/use-memo.js
586
585
  function useMemo(fn, dependencies) {
587
586
  return withPointer((pointer) => {
588
587
  const prev = pointer.get();
@@ -599,13 +598,13 @@ function useMemo(fn, dependencies) {
599
598
  }
600
599
 
601
600
  //#endregion
602
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-ref.js
601
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/use-ref.js
603
602
  function useRef(val) {
604
603
  return useState({ current: val })[0];
605
604
  }
606
605
 
607
606
  //#endregion
608
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/use-keypress.js
607
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/use-keypress.js
609
608
  function useKeypress(userHandler) {
610
609
  const signal = useRef(userHandler);
611
610
  signal.current = userHandler;
@@ -939,7 +938,7 @@ function wrapAnsi(string, columns, options) {
939
938
  }
940
939
 
941
940
  //#endregion
942
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/utils.js
941
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/utils.js
943
942
  var import_cli_width = /* @__PURE__ */ __toESM(require_cli_width(), 1);
944
943
  /**
945
944
  * Force line returns at specific width. This function is ANSI code friendly and it'll
@@ -966,7 +965,7 @@ function readlineWidth() {
966
965
  }
967
966
 
968
967
  //#endregion
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
968
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
970
969
  function usePointerPosition({ active, renderedItems, pageSize, loop }) {
971
970
  const state = useRef({
972
971
  lastPointer: active,
@@ -1052,7 +1051,7 @@ function usePagination({ items, active, renderItem, pageSize, loop = true }) {
1052
1051
  }
1053
1052
 
1054
1053
  //#endregion
1055
- //#region ../../node_modules/.pnpm/@inquirer+type@4.2.0_@types+node@26.6.5/node_modules/@inquirer/type/dist/utils.js
1054
+ //#region ../../node_modules/.pnpm/@inquirer+type@4.2.1_@types+node@26.6.6/node_modules/@inquirer/type/dist/utils.js
1056
1055
  /**
1057
1056
  * Create a promise and get access to its `resolve` and `reject` functions.
1058
1057
  *
@@ -1373,7 +1372,7 @@ const process$2 = globalThis.process;
1373
1372
  const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
1374
1373
 
1375
1374
  //#endregion
1376
- //#region ../../node_modules/.pnpm/@inquirer+ansi@2.0.9/node_modules/@inquirer/ansi/dist/index.js
1375
+ //#region ../../node_modules/.pnpm/@inquirer+ansi@2.0.10/node_modules/@inquirer/ansi/dist/index.js
1377
1376
  const ESC = "\x1B[";
1378
1377
  /** Hide the cursor */
1379
1378
  const cursorHide = "\x1B[?25l";
@@ -1393,7 +1392,7 @@ const eraseLine = "\x1B[2K";
1393
1392
  const eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + "\x1B[2K\x1B[G" : "";
1394
1393
 
1395
1394
  //#endregion
1396
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/screen-manager.js
1395
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/screen-manager.js
1397
1396
  const height = (content) => content.split("\n").length;
1398
1397
  const lastLine = (content) => content.split("\n").pop() ?? "";
1399
1398
  var ScreenManager = class {
@@ -1451,7 +1450,7 @@ var ScreenManager = class {
1451
1450
  };
1452
1451
 
1453
1452
  //#endregion
1454
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/create-prompt.js
1453
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/create-prompt.js
1455
1454
  var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
1456
1455
  const nativeSetImmediate = globalThis.setImmediate;
1457
1456
  const nativeClearImmediate = globalThis.clearImmediate;
@@ -1557,7 +1556,7 @@ function createPrompt(view) {
1557
1556
  }
1558
1557
  });
1559
1558
  };
1560
- if ("readableFlowing" in input) {
1559
+ if ("readableFlowing" in input && input.isTTY) {
1561
1560
  const immediate = nativeSetImmediate(startCycle);
1562
1561
  cleanups.add(() => nativeClearImmediate(immediate));
1563
1562
  } else startCycle();
@@ -1568,7 +1567,7 @@ function createPrompt(view) {
1568
1567
  }
1569
1568
 
1570
1569
  //#endregion
1571
- //#region ../../node_modules/.pnpm/@inquirer+core@12.0.5_@types+node@26.6.5/node_modules/@inquirer/core/dist/lib/Separator.js
1570
+ //#region ../../node_modules/.pnpm/@inquirer+core@12.0.6_@types+node@26.6.6/node_modules/@inquirer/core/dist/lib/Separator.js
1572
1571
  /**
1573
1572
  * Separator object
1574
1573
  * Used to space/separate choices group
@@ -1585,7 +1584,7 @@ var Separator = class {
1585
1584
  };
1586
1585
 
1587
1586
  //#endregion
1588
- //#region ../../node_modules/.pnpm/@inquirer+checkbox@5.2.7_@types+node@26.6.5/node_modules/@inquirer/checkbox/dist/index.js
1587
+ //#region ../../node_modules/.pnpm/@inquirer+checkbox@5.2.8_@types+node@26.6.6/node_modules/@inquirer/checkbox/dist/index.js
1589
1588
  const checkboxTheme = {
1590
1589
  icon: {
1591
1590
  checked: styleText("green", figures.circleFilled),
@@ -1773,7 +1772,7 @@ var dist_default$3 = createPrompt((config, done) => {
1773
1772
  });
1774
1773
 
1775
1774
  //#endregion
1776
- //#region ../../node_modules/.pnpm/@inquirer+confirm@6.3.4_@types+node@26.6.5/node_modules/@inquirer/confirm/dist/index.js
1775
+ //#region ../../node_modules/.pnpm/@inquirer+confirm@6.3.5_@types+node@26.6.6/node_modules/@inquirer/confirm/dist/index.js
1777
1776
  const confirmTheme = {
1778
1777
  keywords: {
1779
1778
  yes: "Yes",
@@ -1847,7 +1846,7 @@ var dist_default$2 = createPrompt((config, done) => {
1847
1846
  });
1848
1847
 
1849
1848
  //#endregion
1850
- //#region ../../node_modules/.pnpm/@inquirer+input@5.1.8_@types+node@26.6.5/node_modules/@inquirer/input/dist/index.js
1849
+ //#region ../../node_modules/.pnpm/@inquirer+input@5.1.9_@types+node@26.6.6/node_modules/@inquirer/input/dist/index.js
1851
1850
  const inputTheme = { validationFailureMode: "keep" };
1852
1851
  var dist_default$1 = createPrompt((config, done) => {
1853
1852
  const { prefill = "tab" } = config;
@@ -1917,7 +1916,7 @@ var dist_default$1 = createPrompt((config, done) => {
1917
1916
  });
1918
1917
 
1919
1918
  //#endregion
1920
- //#region ../../node_modules/.pnpm/@inquirer+select@5.2.7_@types+node@26.6.5/node_modules/@inquirer/select/dist/index.js
1919
+ //#region ../../node_modules/.pnpm/@inquirer+select@5.2.8_@types+node@26.6.6/node_modules/@inquirer/select/dist/index.js
1921
1920
  const selectTheme = {
1922
1921
  icon: { cursor: figures.pointer },
1923
1922
  style: {
@@ -2172,6 +2171,28 @@ async function runRepl(seed) {
2172
2171
  }
2173
2172
  ]
2174
2173
  });
2174
+ const ask = async (message, fallback, flag) => Number(await dist_default$1({
2175
+ message,
2176
+ default: String(fallback),
2177
+ validate: (v) => {
2178
+ try {
2179
+ parsePositive(flag, v);
2180
+ return true;
2181
+ } catch (err) {
2182
+ return err.message;
2183
+ }
2184
+ }
2185
+ }));
2186
+ let { rowsPerDay, retentionDays, readTargetMs, writeHeavy } = seed;
2187
+ if (seed.profile === void 0 && process.stdin.isTTY === true) {
2188
+ rowsPerDay ??= await ask("Expected rows written per day:", DEFAULT_SIZING.rowsPerDay, "rows-per-day");
2189
+ retentionDays ??= await ask("Days of data to keep:", DEFAULT_SIZING.retentionDays, "retention-days");
2190
+ readTargetMs ??= await ask("Read latency target (ms):", DEFAULT_SIZING.readTargetMs, "read-target-ms");
2191
+ writeHeavy = writeHeavy || await dist_default$2({
2192
+ message: "Is write throughput a priority?",
2193
+ default: false
2194
+ });
2195
+ }
2175
2196
  const tls = seed.tls || await dist_default$2({
2176
2197
  message: "Terminate TLS in the binary (HTTPS)?",
2177
2198
  default: false
@@ -2210,6 +2231,11 @@ async function runRepl(seed) {
2210
2231
  tls,
2211
2232
  tlsCertPath,
2212
2233
  tlsKeyPath,
2234
+ rowsPerDay,
2235
+ retentionDays,
2236
+ readTargetMs,
2237
+ writeHeavy,
2238
+ profile: seed.profile,
2213
2239
  yes: true,
2214
2240
  force
2215
2241
  };
@@ -1,6 +1,5 @@
1
- import { E as Row, s as FieldInput } from "./schema-g4FQLr0V.js";
2
- import { l as BridgeCredential } from "./runtime-metrics-DwpDJ8vz.js";
3
- import { J as AutoCrudVerb, Q as PolicyDecision, Z as Policy, et as RequestContext } from "./plugin-t2g2wX0b.js";
1
+ import { Ln as Row, _t as PolicyDecision, gt as Policy, in as WhereClause, l as FieldInput, n as Dropped, p as PlanClause, pt as AutoCrudVerb, yt as RequestContext } from "./schema-aIkY8sR3.js";
2
+ import { n as BridgeCredential } from "./bridge-DnToJedN.js";
4
3
  //#region ../../packages/substrate-types/src/nl.d.ts
5
4
  /**
6
5
  * The engine-dispatchable frame a successful NL translation produces. Keys
@@ -49,11 +48,16 @@ interface NlAskRequest {
49
48
  project?: string;
50
49
  /** Force the reading to this type; resubmit a clarify option's `type`. Must name a type of the namespace. */
51
50
  type?: string;
51
+ /**
52
+ * "Now" for relative dates and month-day year inference: ISO-8601 date-time with an
53
+ * offset (`2026-10-02T12:00:00-05:00`). Ranges are in its offset. Defaults to the server clock.
54
+ */
55
+ asOf?: string;
52
56
  }
53
57
  type NlParseStatus = 'resolved' | 'ambiguous' | 'partial' | 'clarify' | 'refuse' | 'unparsed';
54
58
  interface NlEvidence {
55
59
  span: string;
56
- role: 'id' | 'type' | 'value' | 'time' | 'order' | 'count' | 'scope' | 'field' | 'author' | 'history';
60
+ role: 'id' | 'type' | 'value' | 'time' | 'order' | 'count' | 'aggregate' | 'scope' | 'field' | 'author' | 'history';
57
61
  detail: string;
58
62
  }
59
63
  type NlJudgeAction = 'pick' | 'type' | 'bind' | 'recall' | 'clarify' | 'refuse' | 'escalate';
@@ -74,19 +78,45 @@ interface NlJudgeStep {
74
78
  choice?: NlJudgeChoice;
75
79
  /** Why the reply was not applied. */
76
80
  rejected?: string;
81
+ /** Keys of an applied reply outside the offered options (a walk, a comparison), ignored. */
82
+ ignored?: string[];
77
83
  }
78
- /** What an ask answered. The four kinds are exhaustive. */
84
+ /** What an ask answered. The five kinds are exhaustive. */
79
85
  type NlOutcome = {
80
86
  kind: 'rows';
81
87
  frame: Query;
82
88
  answer: string;
83
- /** Absent on the wire when the engine rejected the frame; `errors` then says why. */
89
+ /**
90
+ * Absent on the wire when the engine rejected the frame; `errors` then says why.
91
+ * On a `count` answer it is the engine's `{ count }`, or the first page of rows
92
+ * when the server could not count and the rows were paged instead.
93
+ */
84
94
  data: unknown;
85
- /** On a `count` answer: every row the frame matches, across pages; `data` holds only the first page. Absent when counting stopped short, with `errors` saying why. */
95
+ /** On a `count` answer: every row the frame matches. Absent when counting stopped short, with `errors` saying why. */
86
96
  count?: number;
97
+ /**
98
+ * On an `aggregate` answer: `fn` of `field` over the rows the frame matches,
99
+ * as one `value`, or per group keyed by `by` (a field, or the `day`/`hour`
100
+ * date group). Absent when the engine refused the frame, with `errors` saying why.
101
+ */
102
+ aggregate?: NlAggregate;
87
103
  errors?: unknown[];
88
104
  source: 'parser' | 'judge' | 'handoff';
89
105
  handoff?: string;
106
+ /** Parts of the question this answer does not reflect. Empty when nothing was lost. */
107
+ dropped: Dropped[];
108
+ /** The plan the frame ran, clause by clause, with the engine's served flags where it gave them. */
109
+ plan: PlanClause[];
110
+ } | {
111
+ /**
112
+ * The question cannot be answered without fabricating: something that
113
+ * changes which rows count was dropped from a count, aggregate, `$ref`
114
+ * or pick reading. Nothing ran; `dropped` says what, `plan` what was understood.
115
+ */
116
+ kind: 'unknown';
117
+ question: string;
118
+ dropped: Dropped[];
119
+ plan: PlanClause[];
90
120
  } | {
91
121
  kind: 'recall';
92
122
  query: string;
@@ -106,17 +136,33 @@ type NlOutcome = {
106
136
  kind: 'refuse';
107
137
  reason: string;
108
138
  };
139
+ interface NlAggregate {
140
+ fn: 'avg' | 'sum' | 'min' | 'max';
141
+ field: string;
142
+ by?: string;
143
+ /** Null when no row has a value (an empty set, or every value null). */
144
+ value?: number | string | null;
145
+ /** `key: null` is the rows with no value in the group field. */
146
+ groups?: {
147
+ key: string | boolean | null;
148
+ value: number | string | null;
149
+ }[];
150
+ /** More groups exist than were returned. */
151
+ truncated?: true;
152
+ }
109
153
  interface NlParsedData {
110
154
  status: NlParseStatus;
111
155
  frame?: Query;
112
156
  evidence: NlEvidence[];
113
157
  residual: string[];
114
158
  reason?: string;
159
+ /** The clock the question was read against: the request's `asOf`, else the server's. */
160
+ asOf?: string;
115
161
  }
116
162
  type NlJudgedStatus = 'resolved' | 'recall' | 'clarify' | 'refuse' | 'escalated';
117
163
  /**
118
- * One SSE event, discriminated by the SSE event name. The terminal answer is
119
- * named by its outcome kind (`rows` | `recall` | `clarify` | `refuse`) and
164
+ * One stream event, discriminated by `event`. The terminal answer is
165
+ * named by its outcome kind (`rows` | `recall` | `clarify` | `refuse` | `unknown`) and
120
166
  * carries the whole outcome; `done` always follows. An in-band `error` event
121
167
  * is not in this union: the client throws on it.
122
168
  */
@@ -154,12 +200,17 @@ type NlWireEvent = {
154
200
  data: Extract<NlOutcome, {
155
201
  kind: 'refuse';
156
202
  }>;
203
+ } | {
204
+ event: 'unknown';
205
+ data: Extract<NlOutcome, {
206
+ kind: 'unknown';
207
+ }>;
157
208
  } | {
158
209
  event: 'done';
159
210
  data: Record<string, never>;
160
211
  };
161
212
  /**
162
- * The JSON encoding's trail spells the terminal event `outcome`, where SSE
213
+ * The JSON encoding's trail spells the terminal event `outcome`, where the stream
163
214
  * names it by the outcome kind.
164
215
  */
165
216
  type NlTrailEvent = ({
@@ -187,8 +238,11 @@ interface NlPackField {
187
238
  /** `metadata` marks a server-managed virtual (createdAt, createdById, ...). */
188
239
  kind: 'scalar' | 'crossRef' | 'list' | 'struct' | 'metadata';
189
240
  valueType?: string;
190
- /** crossRef target type. */
191
- target?: string;
241
+ /** crossRef target. */
242
+ target?: {
243
+ namespace: string;
244
+ type: string;
245
+ };
192
246
  indexed: boolean;
193
247
  operators: string[];
194
248
  phrases: string[];
@@ -226,7 +280,25 @@ interface NlValueAlias {
226
280
  startsWith?: string;
227
281
  contains?: string;
228
282
  }
283
+ /** One `fieldPhrases` ruling: what a phrase binds to. Field refs are `'<Type>.<field>'` in the ruling's namespace. */
284
+ interface NlFieldPhrase {
285
+ field?: string;
286
+ /** Needs `field`: an equality binding ("valued PSA 9" -> Cert.grade = 9). */
287
+ value?: unknown;
288
+ /** Needs `field`: the implicit filter on that field's type. Never silent: it shows in `plan`. */
289
+ exclude?: WhereClause;
290
+ /** A difference (`sub`) or quotient (`div`) that orders; operands are `'<Type>.<field>'`, both on one type. */
291
+ select?: {
292
+ sub: [string, string];
293
+ } | {
294
+ div: [string, string];
295
+ };
296
+ /** A namespace default pick for this phrase. */
297
+ pick?: 'latest' | 'max' | 'min';
298
+ }
229
299
  interface NlNamespaceRulings {
300
+ /** Phrases bound to fields, values, implicit filters, computed orderings and pick defaults. Keys are normalised (trimmed, single-spaced, lower-cased). */
301
+ fieldPhrases?: Record<string, NlFieldPhrase>;
230
302
  /** Types never scoped to the asking project (their `project` means "belongs to", not "applies to"). */
231
303
  unscopedTypes?: string[];
232
304
  /** Extra phrases naming a type, e.g. `backlog` -> Task. Win over the generated phrases. */
@@ -250,6 +322,12 @@ interface NlNamespaceRulings {
250
322
  typeNotes?: Record<string, string>;
251
323
  /** A phrase that means a predicate, e.g. `accepted` -> Decision.status in [active, accepted]. */
252
324
  valueAliases?: Record<string, NlValueAlias[]>;
325
+ /**
326
+ * Rows of a type that never count unless asked for, e.g. `Run` -> `{ status: { in: ['skipped'] } }`.
327
+ * Applied as `NOT <clause>` whenever NL reads the type, as the seed or through a walk,
328
+ * and shown in `plan` as `ruling:<Type> default exclude`.
329
+ */
330
+ typeExcludes?: Record<string, WhereClause>;
253
331
  }
254
332
  /** The body of `GET /substrate/v1/nl/pack/:ns`. */
255
333
  interface NlServedPack extends NlNamespacePack {
@@ -718,4 +796,4 @@ declare function row<T>(predicate: (ctx: RequestContext, row: T) => boolean): Po
718
796
  */
719
797
  declare function applyRowFilters<T>(decision: PolicyDecision, rows: T[], ctx: RequestContext): T[];
720
798
  //#endregion
721
- export { NlJudgeStep as $, and as A, SYSTEM_NAMESPACE as B, flattenGrant as C, parseGrantEntries as D, intersectGrants as E, TokenProviderOpts as F, resolveAdminCredential as G, isActiveAdminKeyRow as H, adminClaimCapabilities as I, NlAskRequest as J, resolveDefaultKeyPath as K, isEncryptedKey as L, or as M, ADMIN_CAPABILITIES as N, decodeList as O, DEFAULT_CAPABILITIES as P, NlJudgeChoice as Q, makeAuthorizationProvider as R, expandFlat as S, grantIsUniform as T, AdminCredential as U, describeGrant as V, AdminEnv as W, NlEvidence as X, NlAskResult as Y, NlJudgeAction as Z, newlyGrantedPairs as _, denyAll as a, NlPackType as at, capabilitiesFor as b, requireIdentity as c, NlParsedData as ct, KeyUpdateRefusal as d, NlValueAlias as dt, NlJudgedStatus as et, checkRevocable as f, NlWireEvent as ft, newlyGranted as g, Query as gt, grantEntriesConfer as h, NLVocabularyHint as ht, allowVerbs as i, NlPackField as it, not as j, encodeList as k, requireNamespace as l, NlServedPack as lt, grantCovers as m, NLResult as mt, row as n, NlNamespaceRulings as nt, denyVerbs as o, NlPackValueRef as ot, checkUpdatable as p, NLBase as pt, resolveDefaultKidPath as q, allowAll as r, NlOutcome as rt, requireCapability as s, NlParseStatus as st, applyRowFilters as t, NlNamespacePack as tt, KeyMutationRefusal as u, NlTrailEvent as ut, revokedAtIso as v, grantEntryError as w, encodeGrant as x, Grant as y, makeTokenProvider as z };
799
+ export { NlJudgeAction as $, and as A, SYSTEM_NAMESPACE as B, flattenGrant as C, parseGrantEntries as D, intersectGrants as E, TokenProviderOpts as F, resolveAdminCredential as G, isActiveAdminKeyRow as H, adminClaimCapabilities as I, NlAggregate as J, resolveDefaultKeyPath as K, isEncryptedKey as L, or as M, ADMIN_CAPABILITIES as N, decodeList as O, DEFAULT_CAPABILITIES as P, NlFieldPhrase as Q, makeAuthorizationProvider as R, expandFlat as S, grantIsUniform as T, AdminCredential as U, describeGrant as V, AdminEnv as W, NlAskResult as X, NlAskRequest as Y, NlEvidence as Z, newlyGrantedPairs as _, NLVocabularyHint as _t, denyAll as a, NlOutcome as at, capabilitiesFor as b, requireIdentity as c, NlPackValueRef as ct, KeyUpdateRefusal as d, NlServedPack as dt, NlJudgeChoice as et, checkRevocable as f, NlTrailEvent as ft, newlyGranted as g, NLResult as gt, grantEntriesConfer as h, NLBase as ht, allowVerbs as i, NlNamespaceRulings as it, not as j, encodeList as k, requireNamespace as l, NlParseStatus as lt, grantCovers as m, NlWireEvent as mt, row as n, NlJudgedStatus as nt, denyVerbs as o, NlPackField as ot, checkUpdatable as p, NlValueAlias as pt, resolveDefaultKidPath as q, allowAll as r, NlNamespacePack as rt, requireCapability as s, NlPackType as st, applyRowFilters as t, NlJudgeStep as tt, KeyMutationRefusal as u, NlParsedData as ut, revokedAtIso as v, Query as vt, grantEntryError as w, encodeGrant as x, Grant as y, makeTokenProvider as z };