@mnmal-ai/substrate-nl 1.0.0-beta.8 → 1.0.0-beta.9
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
CHANGED
|
@@ -8,8 +8,8 @@ Natural-language ask surface. A deterministic parser reads a question against a
|
|
|
8
8
|
- `asOf` is "now" for relative dates ("yesterday", "last week"), for the year of a month-day ("on Oct 23") and for a month with no year ("in march"): an ISO-8601 date-time with an offset, such as `2026-10-02T12:00:00-05:00`, in years 1000 to 9998. Day boundaries are in its offset. Anything else is `400 invalid_params`. Without it the server clock is used. The `parsed` event's `asOf` says which clock the question was read against.
|
|
9
9
|
- Years and months: `in|during 2025` is that whole year. `this year` and `last year` are calendar years, while `last N years` is rolling. `in|during <month>` is the most recent such month that has begun, and `in <month> <year>` or `in <year> <month>` is that month. `since|after|before|until|between|from` take a year or a month as an operand ("since 2024", "before march 2025"). In `between <month> and <month> <year>` a first month with no year takes the second's year, or the year before when it comes later in the calendar, so "between november and february 2026" is 2025-11 to 2026-03. A second month with no year always takes the first's year, and a window that ends before it starts is not read ("between november 2025 and february"). `on` refuses a year or a month. A year is a four-digit number from 1900 to 2199. Any other number there is not a year, so the phrase is not a date, the number stays unread and the answer is `unknown` ("items between 1000 and 2000"). A rolling window too long for a date is not read, and is never an error. A whole month or year after a lead word that is also a stored value, alone or inside a multi-word value of up to 4 words ("todos in may" when `may` is a value, "todos in may release" when `may release` is), is held and dropped with a reason, so the answer is `unknown`.
|
|
10
10
|
- shortId: a number is a shortId after `#`, after an id word (`shortid`, `id`, `number`, `short id`), or right after a singular type word when that type's first mention is singular ("todo 1752", "todo 5 and todo 7", but not "todos and todo 5"). A number after a plural type word or any other word is not an id. A number nothing claimed leaves the reading partial, so the answer is `unknown`. A judge cannot pick away any leftover with a digit in it ("2025", "q3", "fy2025") as noise. Beside an id, a leftover entry that contains a number does the same, while leftover words stay commentary.
|
|
11
|
-
- Aggregates: `average|avg|mean <field>`, `total|sum [of] <field>`, `min|minimum|max|maximum <field>`, each over the seed type with every filter, value and time range the question also names. The field must be a seed number field (min and max also take a date field). An unknown field, a wrong kind or a field on a walked type is dropped with a reason, and the answer is `unknown`. `highest|lowest <field>` is an aggregate only when `of` or `for` follows the field, a type is named after the field, and no type is named before the superlative ("the highest price of items"). Otherwise it orders ("items with the highest price", "items with the highest price for last week"). A recency or limit word inside a count or an aggregate ("the last sale", "the first 3 items") is dropped as a filter, so the answer is `unknown`. So is an aggregate inside a "how many" question. The outcome is `rows` with `answer: 'aggregate'`, the engine's `data`, and `aggregate: { fn, field, value }`. A store that answers no walks, or a seed under a row policy, refuses the frame: `aggregate` is then absent and `errors` says why. Unlike a plain count, there is no paged fallback. A count per unit runs as an aggregate, so it has none either.
|
|
12
|
-
- Grouping an aggregate or a count: `by|per hour|day|week|month|year` groups by the type's time field (the `timeField` ruling, else `createdAt`), truncated through `groupBy` and `dateTrunc`. Labels are the hour `2026-10-20T09`, the day `2026-10-20`, the week's Monday `2026-10-19`, the month `2026-10` and the year `2026`. A count per unit answers `aggregate: { fn: 'count', field: '*', by, groups }`. A unit wins over a field group in the same question: "average price of items by condition per month" groups by month and leaves "condition" unread, so the parse is partial and `ask` answers `unknown`. `by|per <field>` groups by a seed enum or yes/no field, as one aggregate per value (at most 20) plus one for rows with no value. That last group is keyed `null` and is left out when its value is null. Either one gives `aggregate: { fn, field, by, groups: [{ key, value }], truncated? }`. Grouping by any other field is dropped with a reason, and the ungrouped value still answers. The adjectives `hourly|daily|weekly|monthly|yearly|annual|annually` also name a unit:
|
|
11
|
+
- Aggregates: `average|avg|mean <field>`, `total|sum [of] <field>`, `min|minimum|max|maximum <field>`, each over the seed type with every filter, value and time range the question also names. The field must be a seed number or integer (`int16`, `int32`, `int64`) field (min and max also take a date field). An unknown field, a wrong kind or a field on a walked type is dropped with a reason, and the answer is `unknown`. `highest|lowest <field>` is an aggregate only when `of` or `for` follows the field, a type is named after the field, and no type is named before the superlative ("the highest price of items"). Otherwise it orders ("items with the highest price", "items with the highest price for last week"). A recency or limit word inside a count or an aggregate ("the last sale", "the first 3 items") is dropped as a filter, so the answer is `unknown`. So is an aggregate inside a "how many" question. The outcome is `rows` with `answer: 'aggregate'`, the engine's `data`, and `aggregate: { fn, field, value }`. A `sum` over an integer field, and a `min` or `max` of an `int64` field, is an exact int64, so its `value` (and each group's) is a decimal string on the JSON wire. An `avg` is a number. A store that answers no walks, or a seed under a row policy, refuses the frame: `aggregate` is then absent and `errors` says why. Unlike a plain count, there is no paged fallback. A count per unit runs as an aggregate, so it has none either.
|
|
12
|
+
- Grouping an aggregate or a count: `by|per hour|day|week|month|year` groups by the type's time field (the `timeField` ruling, else `createdAt`; "per month by due date" names a date field of the type instead, by its words or a unique prefix of its name, followed by at most one of `date`, `time`, `day` or `timestamp`, so "by due date" names `dueAt` as well as `dueDate`), truncated through `groupBy` and `dateTrunc`. Labels are the hour `2026-10-20T09`, the day `2026-10-20`, the week's Monday `2026-10-19`, the month `2026-10` and the year `2026`. A count per unit answers `aggregate: { fn: 'count', field: '*', by, groups }`. A unit wins over a field group in the same question: "average price of items by condition per month" groups by month and leaves "condition" unread, so the parse is partial and `ask` answers `unknown`. `by|per <field>` groups by a seed enum or yes/no field, as one aggregate per value (at most 20) plus one for rows with no value. That last group is keyed `null` and is left out when its value is null. Either one gives `aggregate: { fn, field, by, groups: [{ key, value }], truncated? }`. Grouping by any other field is dropped with a reason, and the ungrouped value still answers. The adjectives `hourly|daily|weekly|monthly|yearly|annual|annually` also name a unit:
|
|
13
13
|
- Immediately before or after the aggregate word of a claimed aggregate, an adjective is the unit, even when it is also a pack value.
|
|
14
14
|
- Anywhere else, an adjective that no value claimed is the unit only in a question with a claimed aggregate or "how many" ("how many sales weekly").
|
|
15
15
|
- A field name, or a field phrase, of the asked types (and the types their crossRefs reach) wins over the unit reading ("annual fee"), including right after the aggregate word.
|
package/dist/ask/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/ask/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAGf,KAAK,gBAAgB,EAGtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,cAAc,CAAC;AAC/D,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;AAyCD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,GAAG,UAAU,EAAE,CA2B9F;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/ask/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EAGf,KAAK,gBAAgB,EAGtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,cAAc,CAAC;AAC/D,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;AAyCD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,GAAG,UAAU,EAAE,CA2B9F;AAiQD,wBAAuB,MAAM,CAC3B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,OAAO,GACZ,cAAc,CAAC,OAAO,CAAC,CAmJzB"}
|
|
@@ -1704,7 +1704,8 @@ function parseQuestion(question, pack, ctx) {
|
|
|
1704
1704
|
count,
|
|
1705
1705
|
countUnit: countUnit ?? (aggregate?.group?.unit !== void 0 ? {
|
|
1706
1706
|
span: aggregate.group.span,
|
|
1707
|
-
unit: aggregate.group.unit
|
|
1707
|
+
unit: aggregate.group.unit,
|
|
1708
|
+
end: aggregate.group.end ?? tokens.length
|
|
1708
1709
|
} : null),
|
|
1709
1710
|
aggregate,
|
|
1710
1711
|
allProjects,
|
|
@@ -1907,7 +1908,14 @@ function assemble(type, a) {
|
|
|
1907
1908
|
if (a.author !== null) where.push({ createdById: { startsWith: a.author } });
|
|
1908
1909
|
const orderExclude = a.fieldOrder?.phrase?.entry.exclude;
|
|
1909
1910
|
if (sortBy !== null && sortBy.hop === void 0 && orderExclude !== void 0) where.push({ NOT: orderExclude });
|
|
1910
|
-
const
|
|
1911
|
+
const unitClaim = a.count ? a.countUnit : aggClaim?.group?.unit !== void 0 ? {
|
|
1912
|
+
...aggClaim.group,
|
|
1913
|
+
end: aggClaim.group.end ?? tokens.length
|
|
1914
|
+
} : null;
|
|
1915
|
+
const bucket = unitClaim === null ? null : claimDateField(tokens, unitClaim.end, fields, rulings);
|
|
1916
|
+
const bucketField = bucket?.name ?? null;
|
|
1917
|
+
const agg = aggClaim === null ? null : aggregateOn(aggClaim, type, pack, rulings, bucketField ?? void 0);
|
|
1918
|
+
if (agg !== null && agg.fn === void 0) for (const t of bucket?.taken ?? []) t.used = false;
|
|
1911
1919
|
if (agg !== null) {
|
|
1912
1920
|
dropped.push(...agg.dropped);
|
|
1913
1921
|
ev.push(...agg.evidence);
|
|
@@ -2047,7 +2055,7 @@ function assemble(type, a) {
|
|
|
2047
2055
|
delete params.orderBy;
|
|
2048
2056
|
}
|
|
2049
2057
|
const countBy = a.count && a.countUnit !== null ? a.countUnit : null;
|
|
2050
|
-
const timeField = own(rulings.timeField, type) ?? "createdAt";
|
|
2058
|
+
const timeField = bucketField ?? own(rulings.timeField, type) ?? "createdAt";
|
|
2051
2059
|
if (countBy !== null) {
|
|
2052
2060
|
params.aggregate = { value: { count: true } };
|
|
2053
2061
|
params.groupBy = { bucket: { dateTrunc: [{ lit: countBy.unit }, timeField] } };
|
|
@@ -2127,11 +2135,15 @@ function fieldAt(tokens, walkClaims, pack, rulings, i, numeric) {
|
|
|
2127
2135
|
end: i
|
|
2128
2136
|
} : null;
|
|
2129
2137
|
}
|
|
2138
|
+
/** Integer kinds sum, average and order like `number`. */
|
|
2139
|
+
const isNumeric = (valueType) => valueType === "number" || valueType === "int16" || valueType === "int32" || valueType === "int64";
|
|
2140
|
+
/** A field kind with its article: "an int32", "a date". */
|
|
2141
|
+
const aKind = (kind) => `${/^[aeiou]/.test(kind ?? "") ? "an" : "a"} ${kind}`;
|
|
2130
2142
|
/** True when `words` name a field on one of `types` (a number field, with `numeric`). */
|
|
2131
2143
|
function namesField(words, types, rulings, numeric = false) {
|
|
2132
2144
|
return types.some((t) => {
|
|
2133
2145
|
const name = fieldByWords(words, t.fields, rulings);
|
|
2134
|
-
return name !== null && (!numeric || t.fields[name]?.valueType
|
|
2146
|
+
return name !== null && (!numeric || isNumeric(t.fields[name]?.valueType));
|
|
2135
2147
|
});
|
|
2136
2148
|
}
|
|
2137
2149
|
/** Marks tokens `from`..`f.end` used; a field phrase named here is not walked to. */
|
|
@@ -2340,6 +2352,43 @@ function adjectiveAt(tokens, k, names) {
|
|
|
2340
2352
|
3
|
|
2341
2353
|
].some((n) => namesField(words.slice(0, n).join(" "), names.types, names.rulings)) ? void 0 : unit;
|
|
2342
2354
|
}
|
|
2355
|
+
/** Words that may follow a named date field without naming anything else ("by due date"). */
|
|
2356
|
+
const GENERIC_DATE_WORDS = /* @__PURE__ */ new Set([
|
|
2357
|
+
"date",
|
|
2358
|
+
"time",
|
|
2359
|
+
"day",
|
|
2360
|
+
"timestamp"
|
|
2361
|
+
]);
|
|
2362
|
+
/**
|
|
2363
|
+
* Claims "by <date field>" right after a unit phrase ending at token `end` ("per month by due
|
|
2364
|
+
* date"): the longest run of up to three free words naming a date field, or a lone word that
|
|
2365
|
+
* starts exactly one date field's phrase ("due"), then one free generic date word the field's
|
|
2366
|
+
* own words do not hold ("due date" on `dueAt`). Anything else stays unread.
|
|
2367
|
+
*/
|
|
2368
|
+
function claimDateField(tokens, end, fields, rulings) {
|
|
2369
|
+
const by = tokens[end + 1];
|
|
2370
|
+
if (by === void 0 || by.used || by.text !== "by") return null;
|
|
2371
|
+
const dates = Object.values(fields).filter((f) => f.valueType === "date");
|
|
2372
|
+
for (let n = 3; n >= 1; n--) {
|
|
2373
|
+
const slice = tokens.slice(end + 2, end + 2 + n);
|
|
2374
|
+
if (slice.length < n || slice.some((t) => t.used)) continue;
|
|
2375
|
+
const words = slice.map((t) => t.text).join(" ");
|
|
2376
|
+
const named = fieldByWords(words, fields, rulings);
|
|
2377
|
+
const starts = dates.filter((f) => f.phrases.some((p) => p.startsWith(`${words} `)));
|
|
2378
|
+
const name = named ?? (starts.length === 1 ? starts[0]?.name ?? null : null);
|
|
2379
|
+
const f = name === null ? void 0 : fields[name];
|
|
2380
|
+
if (name === null || f?.valueType !== "date") continue;
|
|
2381
|
+
const taken = [by, ...slice];
|
|
2382
|
+
const next = tokens[end + 2 + n];
|
|
2383
|
+
if (next !== void 0 && !next.used && GENERIC_DATE_WORDS.has(next.text) && !f.phrases.some((p) => p.split(" ").includes(next.text))) taken.push(next);
|
|
2384
|
+
for (const t of taken) t.used = true;
|
|
2385
|
+
return {
|
|
2386
|
+
name,
|
|
2387
|
+
taken
|
|
2388
|
+
};
|
|
2389
|
+
}
|
|
2390
|
+
return null;
|
|
2391
|
+
}
|
|
2343
2392
|
/**
|
|
2344
2393
|
* Claims "by|per <unit>" from token `from` on, skipping used tokens and "<author verb> by";
|
|
2345
2394
|
* with `adjectives`, a unit adjective too, whichever comes first. With `awayFromAggregate`,
|
|
@@ -2353,7 +2402,8 @@ function claimUnit(tokens, from, adjectives, awayFromAggregate = false) {
|
|
|
2353
2402
|
by.used = true;
|
|
2354
2403
|
return {
|
|
2355
2404
|
span: by.text,
|
|
2356
|
-
unit: adjective
|
|
2405
|
+
unit: adjective,
|
|
2406
|
+
end: k
|
|
2357
2407
|
};
|
|
2358
2408
|
}
|
|
2359
2409
|
if (by.used || by.text !== "by" && by.text !== "per") continue;
|
|
@@ -2364,7 +2414,8 @@ function claimUnit(tokens, from, adjectives, awayFromAggregate = false) {
|
|
|
2364
2414
|
by.used = next.used = true;
|
|
2365
2415
|
return {
|
|
2366
2416
|
span: `${by.text} ${next.text}`,
|
|
2367
|
-
unit
|
|
2417
|
+
unit,
|
|
2418
|
+
end: k + 1
|
|
2368
2419
|
};
|
|
2369
2420
|
}
|
|
2370
2421
|
return null;
|
|
@@ -2460,13 +2511,14 @@ function seedField(o, type, pack, rulings, doing) {
|
|
|
2460
2511
|
};
|
|
2461
2512
|
}
|
|
2462
2513
|
/** An aggregate claim read on `type`: its function and field, or drops saying why not. */
|
|
2463
|
-
function aggregateOn(c, type, pack, rulings) {
|
|
2514
|
+
function aggregateOn(c, type, pack, rulings, bucketField) {
|
|
2464
2515
|
const r = seedField({
|
|
2465
2516
|
span: c.span,
|
|
2466
2517
|
...c.field
|
|
2467
2518
|
}, type, pack, rulings, "aggregating");
|
|
2468
2519
|
const wants = c.fn === "min" || c.fn === "max" ? ["number", "date"] : ["number"];
|
|
2469
|
-
const
|
|
2520
|
+
const accepts = (vt) => isNumeric(vt) || wants.length > 1 && vt === "date";
|
|
2521
|
+
const reason = "reason" in r ? r.reason : (r.f.kind === "scalar" || r.f.kind === "metadata") && accepts(r.f.valueType) ? null : `${c.word} needs a ${wants.join(" or ")} field; ${r.name} is ${aKind(r.f.valueType ?? r.f.kind)} field`;
|
|
2470
2522
|
if (reason !== null || "reason" in r) return {
|
|
2471
2523
|
dropped: [{
|
|
2472
2524
|
span: c.span,
|
|
@@ -2498,7 +2550,7 @@ function aggregateOn(c, type, pack, rulings) {
|
|
|
2498
2550
|
return out;
|
|
2499
2551
|
};
|
|
2500
2552
|
if (g.unit !== void 0) {
|
|
2501
|
-
const field = own(rulings.timeField, type) ?? "createdAt";
|
|
2553
|
+
const field = bucketField ?? own(rulings.timeField, type) ?? "createdAt";
|
|
2502
2554
|
out.dateGroup = {
|
|
2503
2555
|
field,
|
|
2504
2556
|
by: g.unit
|
|
@@ -2537,7 +2589,7 @@ function orderField(o, type, pack, rulings) {
|
|
|
2537
2589
|
if ("reason" in r) return r;
|
|
2538
2590
|
const { name, f } = r;
|
|
2539
2591
|
if (o.pick !== void 0) return { reason: pickReason(o.pick, `${type}.${name}`, type) };
|
|
2540
|
-
if (!((f.kind === "scalar" || f.kind === "metadata") && (f.valueType
|
|
2592
|
+
if (!((f.kind === "scalar" || f.kind === "metadata") && (isNumeric(f.valueType) || f.valueType === "date" && o.numeric !== true))) return { reason: o.numeric === true ? `"most" needs a number field; ${name} is ${aKind(f.valueType ?? f.kind)} field` : `${name} is ${aKind(f.valueType ?? f.kind)} field; only number and date fields order` };
|
|
2541
2593
|
return { field: name };
|
|
2542
2594
|
}
|
|
2543
2595
|
/** Why a pick word cannot order: it is not a direction, or there is one value per seed row. */
|
|
@@ -2586,12 +2638,12 @@ function hopOrder(o, seed, to, pack, rulings) {
|
|
|
2586
2638
|
if (path.length > 1) return { reason: `ordering across ${path.length} hops is not supported; one hop only` };
|
|
2587
2639
|
const f = own(pack.types, to.type)?.fields[to.field];
|
|
2588
2640
|
const qualified = `${to.type}.${to.field}`;
|
|
2589
|
-
if (f === void 0 || f.kind !== "scalar" && f.kind !== "metadata" || f.valueType !== "number") return { reason: `ordering across a hop needs a number field; ${qualified} is
|
|
2641
|
+
if (f === void 0 || f.kind !== "scalar" && f.kind !== "metadata" || f.valueType !== "number") return { reason: `ordering across a hop needs a number field; ${qualified} is ${aKind(f?.valueType ?? f?.kind)} field` };
|
|
2590
2642
|
const h = path[0];
|
|
2591
2643
|
if (o.pick !== void 0 && (h.dir === "out" || o.pick.kind !== "latest")) return { reason: pickReason(o.pick, qualified, seed) };
|
|
2592
2644
|
const cap = to.field.charAt(0).toUpperCase() + to.field.slice(1);
|
|
2593
|
-
const
|
|
2594
|
-
const where =
|
|
2645
|
+
const excludes = [o.phrase?.entry.exclude, own(rulings.typeExcludes, to.type)].flatMap((x) => x === void 0 ? [] : [{ NOT: x }]);
|
|
2646
|
+
const where = excludes.length === 0 ? {} : { where: excludes.length === 1 ? excludes[0] : { AND: excludes } };
|
|
2595
2647
|
if (h.dir === "out") return { hop: {
|
|
2596
2648
|
name: `${to.type.charAt(0).toLowerCase()}${to.type.slice(1)}${cap}`,
|
|
2597
2649
|
agg: {
|
|
@@ -2630,6 +2682,11 @@ function coerce(raw, f) {
|
|
|
2630
2682
|
const n = Number(raw);
|
|
2631
2683
|
return Number.isFinite(n) ? n : void 0;
|
|
2632
2684
|
}
|
|
2685
|
+
if (isNumeric(f.valueType)) {
|
|
2686
|
+
if (!/^-?\d+$/.test(raw)) return void 0;
|
|
2687
|
+
const n = Number(raw);
|
|
2688
|
+
return Number.isSafeInteger(n) ? n : BigInt(raw).toString();
|
|
2689
|
+
}
|
|
2633
2690
|
if (f.valueType === "boolean") return raw === "true" ? true : raw === "false" ? false : void 0;
|
|
2634
2691
|
return raw;
|
|
2635
2692
|
}
|
|
@@ -3205,6 +3262,7 @@ async function aggregate(c, frame, key, source, http, deps, dropped, handoff) {
|
|
|
3205
3262
|
const by = group?.field ?? trunc?.[0].lit;
|
|
3206
3263
|
const short = (k) => typeof k === "string" && trunc !== void 0 ? k.slice(0, LABEL_LENGTH[trunc[0].lit]) : k;
|
|
3207
3264
|
const rows = data?.groups;
|
|
3265
|
+
const wire = (v) => typeof v === "bigint" ? v.toString() : v;
|
|
3208
3266
|
const result = rows === void 0 ? void 0 : {
|
|
3209
3267
|
fn,
|
|
3210
3268
|
field,
|
|
@@ -3212,9 +3270,9 @@ async function aggregate(c, frame, key, source, http, deps, dropped, handoff) {
|
|
|
3212
3270
|
by,
|
|
3213
3271
|
groups: rows.filter((g) => trunc === void 0 || g.bucket !== null).map((g) => ({
|
|
3214
3272
|
key: short(g.bucket ?? g.key),
|
|
3215
|
-
value: g.value
|
|
3273
|
+
value: wire(g.value)
|
|
3216
3274
|
}))
|
|
3217
|
-
} : { value: rows[0]?.value ?? null },
|
|
3275
|
+
} : { value: wire(rows[0]?.value ?? null) },
|
|
3218
3276
|
...data?.truncated === true ? { truncated: true } : {}
|
|
3219
3277
|
};
|
|
3220
3278
|
return {
|
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-CNk9iqtw.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 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/parse/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE9F,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAuB,MAAM,kBAAkB,CAAC;AAsB3E,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC;AAElC,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,8FAA8F;IAC9F,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAC7F,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,qGAAqG;IACrG,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,yFAAyF;IACzF,OAAO,EAAE,OAAO,EAAE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YAAY,GAChB,WAAW,CAgcb;AAivBD,KAAK,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AA4BjD,QAAA,MAAM,UAAU,YAAI,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAU,CAAC;AACrE,8CAA8C;AAC9C,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
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.9",
|
|
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.9",
|
|
41
|
+
"@mnmal-ai/substrate-config": "1.0.0-beta.9",
|
|
42
42
|
"@types/node": "^26.6.4",
|
|
43
43
|
"postgres": "4.1.0",
|
|
44
44
|
"tsdown": "^0.23.0",
|