@mnmal-ai/substrate-nl 1.0.0-beta.15 → 1.0.0-beta.17
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 -1
- package/config.schema.json +2 -1
- package/dist/{bootstrap-CNk9iqtw.js → bootstrap-LrRqIyiw.js} +9 -5
- package/dist/bootstrap.d.ts +1 -0
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +1 -1
- package/dist/index.js +1 -1
- package/dist/pack/service.d.ts +1 -1
- package/dist/pack/service.d.ts.map +1 -1
- package/dist/plugin.d.ts +6 -2
- package/dist/plugin.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -33,13 +33,15 @@ A **kernel-tier plugin**, installed separately: `pnpm add @mnmal-ai/substrate-nl
|
|
|
33
33
|
{
|
|
34
34
|
"judge": { "baseUrl": "http://localhost:11434", "model": "qwen3:14b", "timeoutMs": 20000 },
|
|
35
35
|
"rulings": { "tasks": { "liveStatus": { "Task": "open" } } },
|
|
36
|
-
"packTtlMs": 300000
|
|
36
|
+
"packTtlMs": 300000,
|
|
37
|
+
"inFlightPerCaller": 4
|
|
37
38
|
}
|
|
38
39
|
```
|
|
39
40
|
|
|
40
41
|
- `judge` optional: an [Ollama](https://ollama.com) server and model for the constrained judge (`timeoutMs` defaults to 20000). Absent means parser-only: every escalation is an honest hand-off. A slow or down judge hands off within `timeoutMs`. A hand-off with words the parser could not read answers `unknown` and runs nothing.
|
|
41
42
|
- `rulings` optional; per-namespace overrides merged over rulings the namespace declares.
|
|
42
43
|
- `packTtlMs` how long a served pack is reused (default 300000).
|
|
44
|
+
- `inFlightPerCaller` asks one caller may have running at once (default 4). One more is answered 429 `too_many_in_flight` with `retry-after`. Sessions that share a key count as one caller.
|
|
43
45
|
|
|
44
46
|
An unknown config key fails at boot. There are no env fallbacks, and no LLM vendor SDK is bundled.
|
|
45
47
|
|
package/config.schema.json
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"type": "object",
|
|
17
17
|
"additionalProperties": { "type": "object" }
|
|
18
18
|
},
|
|
19
|
-
"packTtlMs": { "type": "integer", "exclusiveMinimum": 0, "default": 300000 }
|
|
19
|
+
"packTtlMs": { "type": "integer", "exclusiveMinimum": 0, "default": 300000 },
|
|
20
|
+
"inFlightPerCaller": { "type": "integer", "exclusiveMinimum": 0, "default": 4 }
|
|
20
21
|
},
|
|
21
22
|
"additionalProperties": false
|
|
22
23
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { METADATA_AUTHOR_FIELDS, METADATA_FILTER_FIELDS, ROW_POLICY_BLOCKS_WALK, WALKS_NEED_PARTITIONED, WALKS_UNSUPPORTED_STORE, defineBootstrap, error400, isImpossibleIsoTimestamp, isIsoTimestamp, jsonResponse, parseJsonBody, trimTrailingSlashes } from "@mnmal-ai/substrate/sdk";
|
|
1
|
+
import { METADATA_AUTHOR_FIELDS, METADATA_FILTER_FIELDS, ROW_POLICY_BLOCKS_WALK, WALKS_NEED_PARTITIONED, WALKS_UNSUPPORTED_STORE, defineBootstrap, error400, isImpossibleIsoTimestamp, isIsoTimestamp, jsonResponse, parseJsonBody, seesNamespace, trimTrailingSlashes } from "@mnmal-ai/substrate/sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { FRAMES_JSON_MIME, encodeStreamFrame, framesEncodingFromAccept } from "@mnmal-ai/substrate/pack";
|
|
@@ -3802,7 +3802,7 @@ var PackService = class {
|
|
|
3802
3802
|
}
|
|
3803
3803
|
async get(ns, req) {
|
|
3804
3804
|
const schemas = this.#opts.engine.federatedSchema();
|
|
3805
|
-
const schema = Object.hasOwn(schemas, ns) ? schemas[ns] : void 0;
|
|
3805
|
+
const schema = Object.hasOwn(schemas, ns) && seesNamespace(req.identity, ns) ? schemas[ns] : void 0;
|
|
3806
3806
|
if (schema === void 0) return void 0;
|
|
3807
3807
|
const now = (this.#opts.now ?? Date.now)();
|
|
3808
3808
|
const ttl = this.#opts.ttlMs ?? 3e5;
|
|
@@ -3900,7 +3900,7 @@ function transientRefusal(errors) {
|
|
|
3900
3900
|
*/
|
|
3901
3901
|
function principalKey(req) {
|
|
3902
3902
|
const id = req.identity;
|
|
3903
|
-
if (id === void 0) return "\0anon";
|
|
3903
|
+
if (id === void 0 || id === null) return "\0anon";
|
|
3904
3904
|
const { expiresAt: _expiresAt, ...stable } = id;
|
|
3905
3905
|
return JSON.stringify(canonical(stable));
|
|
3906
3906
|
}
|
|
@@ -4086,7 +4086,8 @@ function createNlPlugin(cfg) {
|
|
|
4086
4086
|
path: "nl",
|
|
4087
4087
|
method: "POST",
|
|
4088
4088
|
handler: askHandler(deps),
|
|
4089
|
-
capability: "read"
|
|
4089
|
+
capability: "read",
|
|
4090
|
+
maxInFlightPerCaller: cfg.inFlightPerCaller ?? 4
|
|
4090
4091
|
}, {
|
|
4091
4092
|
path: "nl/pack/:ns",
|
|
4092
4093
|
method: "GET",
|
|
@@ -4106,6 +4107,7 @@ function createNlPlugin(cfg) {
|
|
|
4106
4107
|
* every escalation is an honest hand-off.
|
|
4107
4108
|
* - `rulings` optional; per-namespace override merged over declared rulings.
|
|
4108
4109
|
* - `packTtlMs` how long a served pack is reused. Default 300000.
|
|
4110
|
+
* - `inFlightPerCaller` asks one caller may have running at once. Default 4.
|
|
4109
4111
|
* Host-supplied (`hostDeps.nlEngine`): schema, operators and query access.
|
|
4110
4112
|
*/
|
|
4111
4113
|
const JudgeSchema = z.object({
|
|
@@ -4116,13 +4118,15 @@ const JudgeSchema = z.object({
|
|
|
4116
4118
|
const NlBootstrapConfigSchema = z.object({
|
|
4117
4119
|
judge: JudgeSchema.optional(),
|
|
4118
4120
|
rulings: z.record(z.string(), NamespaceRulingsSchema).optional(),
|
|
4119
|
-
packTtlMs: z.number().int().positive().default(3e5)
|
|
4121
|
+
packTtlMs: z.number().int().positive().default(3e5),
|
|
4122
|
+
inFlightPerCaller: z.number().int().positive().default(4)
|
|
4120
4123
|
}).strict();
|
|
4121
4124
|
const bootstrap = defineBootstrap.kernel({
|
|
4122
4125
|
schema: NlBootstrapConfigSchema,
|
|
4123
4126
|
build: (config, deps) => createNlPlugin({
|
|
4124
4127
|
engine: deps.nlEngine,
|
|
4125
4128
|
packTtlMs: config.packTtlMs,
|
|
4129
|
+
inFlightPerCaller: config.inFlightPerCaller,
|
|
4126
4130
|
...config.judge !== void 0 ? {
|
|
4127
4131
|
judge: new OllamaJudge(config.judge),
|
|
4128
4132
|
judgeTimeoutMs: config.judge.timeoutMs
|
package/dist/bootstrap.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const NlBootstrapConfigSchema: z.ZodObject<{
|
|
|
8
8
|
}, z.core.$strict>>;
|
|
9
9
|
rulings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("@mnmal-ai/substrate/sdk").NlNamespaceRulings, unknown, z.core.$ZodTypeInternals<import("@mnmal-ai/substrate/sdk").NlNamespaceRulings, unknown>>>>;
|
|
10
10
|
packTtlMs: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
inFlightPerCaller: z.ZodDefault<z.ZodNumber>;
|
|
11
12
|
}, z.core.$strict>;
|
|
12
13
|
export type NlBootstrapConfig = z.infer<typeof NlBootstrapConfigSchema>;
|
|
13
14
|
export interface NlHostDeps {
|
package/dist/bootstrap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAalD,eAAO,MAAM,uBAAuB;;;;;;;;;kBAOzB,CAAC;AAEZ,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,eAAO,MAAM,SAAS,+DAYpB,CAAC;eAGY,SAAS"}
|
package/dist/bootstrap.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as askHandler, c as profileNamespace, d as runAsk, f as parseWithJudge, g as readRulings, h as mergeRulings, i as createNlPlugin, l as buildNamespacePack, m as NamespaceRulingsSchema, n as bootstrap, o as packHandler, p as parseQuestion, r as CONTRACT_VERSION, s as PackService, t as NlBootstrapConfigSchema, u as OllamaJudge } from "./bootstrap-
|
|
1
|
+
import { a as askHandler, c as profileNamespace, d as runAsk, f as parseWithJudge, g as readRulings, h as mergeRulings, i as createNlPlugin, l as buildNamespacePack, m as NamespaceRulingsSchema, n as bootstrap, o as packHandler, p as parseQuestion, r as CONTRACT_VERSION, s as PackService, t as NlBootstrapConfigSchema, u as OllamaJudge } from "./bootstrap-LrRqIyiw.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 };
|
package/dist/pack/service.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type NlServedPack, type SubstrateRequest } from '@mnmal-ai/substrate/sdk';
|
|
2
2
|
import type { NlEngineAccess } from '../access.js';
|
|
3
3
|
import type { NamespaceRulings } from './rulings.js';
|
|
4
4
|
export type ServedPack = NlServedPack;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/pack/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/pack/service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAKnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,MAAM,UAAU,GAAG,YAAY,CAAC;AAEtC,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAQD;;;;;GAKG;AACH,qBAAa,WAAW;;IAMtB,YAAY,IAAI,EAAE,kBAAkB,EAEnC;IAEK,GAAG,CACP,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,gBAAgB,GACpB,OAAO,CAAC;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,CA8BzD;CA+CF"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@mnmal-ai/substrate-nl` as a substrate plugin: NL owns no namespace, only two
|
|
3
|
-
* kernel routes. Both are read-gated: row policy keeps the data safe, and
|
|
4
|
-
* gate keeps
|
|
3
|
+
* kernel routes. Both are read-gated: row policy keeps the data safe, and under
|
|
4
|
+
* auth mode `required` the gate keeps a caller with no key from spending the
|
|
5
|
+
* operator's judge GPU. Mode `attribute` admits tokenless reads, so there only
|
|
6
|
+
* the per-caller in-flight cap bounds them.
|
|
5
7
|
*/
|
|
6
8
|
import type { KernelPlugin } from '@mnmal-ai/substrate/sdk';
|
|
7
9
|
import type { NlEngineAccess } from './access.js';
|
|
@@ -13,6 +15,8 @@ export interface NlPluginConfig {
|
|
|
13
15
|
judgeTimeoutMs?: number;
|
|
14
16
|
rulings?: Record<string, NamespaceRulings>;
|
|
15
17
|
packTtlMs?: number;
|
|
18
|
+
/** `POST /nl` requests one caller may have running at once. Default 4. */
|
|
19
|
+
inFlightPerCaller?: number;
|
|
16
20
|
}
|
|
17
21
|
/** The routes rely on `KernelRouteClaim.capability`, which every 1.x host honours. */
|
|
18
22
|
export declare const CONTRACT_VERSION = ">=1.0.0-alpha.0 <2.0.0";
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI1D,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,2BAA2B,CAAC;AAEzD,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,GAAG,YAAY,CA2BhE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mnmal-ai/substrate-nl",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.17",
|
|
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.6.4",
|
|
40
|
-
"@mnmal-ai/substrate": "1.0.0-beta.
|
|
41
|
-
"@mnmal-ai/substrate-config": "1.0.0-beta.
|
|
40
|
+
"@mnmal-ai/substrate": "1.0.0-beta.17",
|
|
41
|
+
"@mnmal-ai/substrate-config": "1.0.0-beta.17",
|
|
42
42
|
"@types/node": "^26.6.4",
|
|
43
43
|
"postgres": "4.1.1",
|
|
44
44
|
"tsdown": "^0.23.0",
|