@mnmal-ai/substrate-nl 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.
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/ask/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,KAAK,KAAK,EAAqC,MAAM,mBAAmB,CAAC;AAElF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAa,MAAM,aAAa,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AA+ED,wBAAuB,MAAM,CAC3B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,OAAO,GACZ,cAAc,CAAC,OAAO,CAAC,CA8GzB"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/ask/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,KAAK,KAAK,EAAqC,MAAM,mBAAmB,CAAC;AAElF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAa,MAAM,aAAa,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAgFD,wBAAuB,MAAM,CAC3B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,OAAO,GACZ,cAAc,CAAC,OAAO,CAAC,CAqHzB"}
@@ -1,4 +1,4 @@
1
- import { defineBootstrap, error400, jsonResponse, parseJsonBody } from "@mnmal-ai/substrate/sdk";
1
+ import { defineBootstrap, error400, jsonResponse, parseJsonBody, trimTrailingSlashes } from "@mnmal-ai/substrate/sdk";
2
2
  import { z } from "zod";
3
3
  import { createHash } from "node:crypto";
4
4
 
@@ -800,7 +800,10 @@ function buildJudgePrompt(question, result, pack, rulings = {}, rejected = []) {
800
800
  ]
801
801
  }
802
802
  })] : [],
803
- branch("recall"),
803
+ branch("recall", { type: {
804
+ type: "string",
805
+ enum: allTypes
806
+ } }),
804
807
  branch("clarify"),
805
808
  branch("refuse"),
806
809
  branch("escalate")
@@ -824,7 +827,7 @@ function buildJudgePrompt(question, result, pack, rulings = {}, rejected = []) {
824
827
  " of a name or id, contains = a word inside a title or subject. Never bind a word that only",
825
828
  " describes the question (e.g. \"status\", \"called\").",
826
829
  "- recall: the question asks what is known ABOUT a topic (free-text subject words, not field values);",
827
- " semantic search over the text answers it.",
830
+ " semantic search over the text answers it. Name the type whose rows hold that knowledge.",
828
831
  "- clarify: RARE. Only when the question has two specific readings and nothing in it chooses one.",
829
832
  " Missing detail is not ambiguity: if a type or a topic fits, choose type or recall.",
830
833
  "- refuse: the question is not about this store at all, or asks to change data.",
@@ -942,6 +945,7 @@ async function parseWithJudge(question, pack, ctx, judge, opts = {}) {
942
945
  case "recall": return {
943
946
  status: "recall",
944
947
  query: question,
948
+ type: checked.type,
945
949
  trail
946
950
  };
947
951
  case "clarify":
@@ -1018,11 +1022,12 @@ async function rows(c, source, http, deps, handoff) {
1018
1022
  ...handoff !== void 0 ? { handoff } : {}
1019
1023
  };
1020
1024
  }
1021
- async function recall(query, ns, http, deps) {
1025
+ async function recall(query, ns, type, http, deps) {
1022
1026
  const frame = { "recall/Hit": {
1023
1027
  params: {
1024
1028
  to: query,
1025
1029
  namespace: ns,
1030
+ type,
1026
1031
  k: RECALL_K
1027
1032
  },
1028
1033
  fields: {
@@ -1142,7 +1147,7 @@ async function* runAsk(req, http, deps) {
1142
1147
  outcome = await rows(judged.candidate, "judge", http, deps);
1143
1148
  break;
1144
1149
  case "recall":
1145
- outcome = await recall(judged.query, deps.pack.namespace, http, deps);
1150
+ outcome = await recall(judged.query, deps.pack.namespace, ctx.forceType ?? judged.type, http, deps);
1146
1151
  break;
1147
1152
  case "refuse":
1148
1153
  outcome = {
@@ -1178,7 +1183,7 @@ var OllamaJudge = class {
1178
1183
  constructor(config) {
1179
1184
  this.#config = {
1180
1185
  ...config,
1181
- baseUrl: config.baseUrl.replace(/\/+$/, "")
1186
+ baseUrl: trimTrailingSlashes(config.baseUrl)
1182
1187
  };
1183
1188
  }
1184
1189
  async decide(prompt, signal) {
package/dist/bootstrap.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as bootstrap, t as NlBootstrapConfigSchema } from "./bootstrap-BpKUloR3.js";
1
+ import { n as bootstrap, t as NlBootstrapConfigSchema } from "./bootstrap-BAz6il5S.js";
2
2
 
3
3
  export { NlBootstrapConfigSchema, bootstrap, bootstrap as default };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as askHandler, c as profileNamespace, d as mergeRulings, f as readRulings, g as parseQuestion, h as parseWithJudge, i as createNlPlugin, l as buildNamespacePack, m as runAsk, n as bootstrap, o as packHandler, p as OllamaJudge, r as CONTRACT_VERSION, s as PackService, t as NlBootstrapConfigSchema, u as NamespaceRulingsSchema } from "./bootstrap-BpKUloR3.js";
1
+ import { a as askHandler, c as profileNamespace, d as mergeRulings, f as readRulings, g as parseQuestion, h as parseWithJudge, i as createNlPlugin, l as buildNamespacePack, m as runAsk, n as bootstrap, o as packHandler, p as OllamaJudge, r as CONTRACT_VERSION, s as PackService, t as NlBootstrapConfigSchema, u as NamespaceRulingsSchema } from "./bootstrap-BAz6il5S.js";
2
2
  import { complete } from "./complete.js";
3
3
 
4
4
  export { CONTRACT_VERSION, NamespaceRulingsSchema, NlBootstrapConfigSchema, OllamaJudge, PackService, askHandler, bootstrap, buildNamespacePack, complete, createNlPlugin, mergeRulings, packHandler, parseQuestion, parseWithJudge, profileNamespace, readRulings, runAsk };
@@ -30,6 +30,7 @@ export type JudgedResult = {
30
30
  } | {
31
31
  status: 'recall';
32
32
  query: string;
33
+ type: string;
33
34
  trail: JudgeStep[];
34
35
  } | {
35
36
  status: 'clarify' | 'refuse';
@@ -1 +1 @@
1
- {"version":3,"file":"judge.d.ts","sourceRoot":"","sources":["../../src/judge/judge.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEzF,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAEjB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC;AAExC,MAAM,MAAM,WAAW,GAAG,aAAa,CAAC;AAExC,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,6EAA6E;AAC7E,MAAM,WAAW,KAAK;IACpB,MAAM,CA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,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,qBAAa,WAAY,YAAW,KAAK;;IAGvC,YAAY,MAAM,EAAE,iBAAiB,EAEpC;IAEK,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAqBxE;CACF"}
1
+ {"version":3,"file":"ollama.d.ts","sourceRoot":"","sources":["../../src/judge/ollama.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,qBAAa,WAAY,YAAW,KAAK;;IAGvC,YAAY,MAAM,EAAE,iBAAiB,EAEpC;IAEK,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAqBxE;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mnmal-ai/substrate-nl",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.2",
4
4
  "description": "Natural-language questions for Substrate — a deterministic parser with an optional constrained judge, served at POST /substrate/v1/nl and GET /substrate/v1/nl/pack/:ns, plus browser-safe completion.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -37,8 +37,8 @@
37
37
  },
38
38
  "devDependencies": {
39
39
  "@biomejs/biome": "^2.5.15",
40
- "@mnmal-ai/substrate": "1.0.0-alpha.1",
41
- "@mnmal-ai/substrate-config": "1.0.0-alpha.1",
40
+ "@mnmal-ai/substrate": "1.0.0-alpha.2",
41
+ "@mnmal-ai/substrate-config": "1.0.0-alpha.2",
42
42
  "@types/node": "^26.6.4",
43
43
  "tsdown": "^0.23.0",
44
44
  "typescript": "^7.0.2",