@nola-lang/core 0.1.3 → 0.1.5

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 (49) hide show
  1. package/dist/debug-task.d.ts +14 -0
  2. package/dist/debug-task.d.ts.map +1 -0
  3. package/dist/debug-task.js +10 -0
  4. package/dist/debug-task.js.map +1 -0
  5. package/dist/errors.d.ts +6 -0
  6. package/dist/errors.d.ts.map +1 -1
  7. package/dist/errors.js +4 -0
  8. package/dist/errors.js.map +1 -1
  9. package/dist/fingerprint.d.ts +16 -24
  10. package/dist/fingerprint.d.ts.map +1 -1
  11. package/dist/fingerprint.js +25 -26
  12. package/dist/fingerprint.js.map +1 -1
  13. package/dist/index.d.ts +137 -31
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +13 -3
  16. package/dist/index.js.map +1 -1
  17. package/dist/inference-model.d.ts +58 -0
  18. package/dist/inference-model.d.ts.map +1 -0
  19. package/dist/inference-model.js +2 -0
  20. package/dist/inference-model.js.map +1 -0
  21. package/dist/ingest-line.d.ts +27 -0
  22. package/dist/ingest-line.d.ts.map +1 -0
  23. package/dist/ingest-line.js +85 -0
  24. package/dist/ingest-line.js.map +1 -0
  25. package/dist/nola-protocol.d.ts +195 -0
  26. package/dist/nola-protocol.d.ts.map +1 -0
  27. package/dist/nola-protocol.js +32 -0
  28. package/dist/nola-protocol.js.map +1 -0
  29. package/dist/platform-model.d.ts +28 -0
  30. package/dist/platform-model.d.ts.map +1 -0
  31. package/dist/platform-model.js +15 -0
  32. package/dist/platform-model.js.map +1 -0
  33. package/dist/provider-dialect.d.ts +13 -0
  34. package/dist/provider-dialect.d.ts.map +1 -0
  35. package/dist/provider-dialect.js +5 -0
  36. package/dist/provider-dialect.js.map +1 -0
  37. package/dist/redact.d.ts +2 -0
  38. package/dist/redact.d.ts.map +1 -1
  39. package/dist/redact.js +15 -0
  40. package/dist/redact.js.map +1 -1
  41. package/dist/render-classic.d.ts +40 -0
  42. package/dist/render-classic.d.ts.map +1 -0
  43. package/dist/render-classic.js +117 -0
  44. package/dist/render-classic.js.map +1 -0
  45. package/dist/retry-after.d.ts +7 -0
  46. package/dist/retry-after.d.ts.map +1 -0
  47. package/dist/retry-after.js +15 -0
  48. package/dist/retry-after.js.map +1 -0
  49. package/package.json +1 -1
@@ -0,0 +1,58 @@
1
+ import type { ProviderOutput } from "./index.js";
2
+ /** One infer-function argument as the model sees it — native type TEXT, live value. */
3
+ export interface InferenceScopeArg {
4
+ name: string;
5
+ /** InferType.toNativeType(); absent when unannotated/underivable */
6
+ type?: string;
7
+ /** true ⇔ the param was `.`-prefixed (value available) */
8
+ contextual: boolean;
9
+ /** only when contextual */
10
+ value?: unknown;
11
+ }
12
+ /** The asking infer function's frame; `parent` is the caller frame's scope. */
13
+ export interface InferenceScope {
14
+ fn: string;
15
+ /** display path of the defining .tsi; absent without a file root */
16
+ file?: string;
17
+ /** the marker text ("" when none) */
18
+ instruction: string;
19
+ args: InferenceScopeArg[];
20
+ /** rendered marker template — present only when the author wrote one */
21
+ text?: string;
22
+ /** true when the template read `.next`: `text` already contains the remainder */
23
+ coversRemainder?: boolean;
24
+ parent?: InferenceScope;
25
+ }
26
+ export interface InferenceCorrection {
27
+ /** the provider's rejected reply */
28
+ response: string;
29
+ /** the validation error it failed with */
30
+ error: string;
31
+ }
32
+ /**
33
+ * The canonical, pure-JSON description of one ask. Fingerprints, ledgers,
34
+ * receipts and hook payloads are defined over it; chat messages are a
35
+ * derived view (`renderClassic`). No closures, no InferType instances.
36
+ */
37
+ export interface InferenceModel {
38
+ /** "extract" for an extractor, "call" for the slot-filling ask of a call intent */
39
+ intent: "extract" | "call";
40
+ input: {
41
+ /** the authored backtick text (or the call intent's synthesized request) */
42
+ instruction: string;
43
+ /** rendered `${.member}` template for this site — present only when the author wrote one */
44
+ text?: string;
45
+ /** call intents only: the callee's name */
46
+ callee?: string;
47
+ /** call intents only: the authored hint; absent when the author wrote none */
48
+ hint?: string;
49
+ };
50
+ /** innermost first; absent for a frame-less ask */
51
+ scope?: InferenceScope;
52
+ /** the user's config `system.message` — never the built-in preamble */
53
+ system?: string;
54
+ output: ProviderOutput;
55
+ /** present on the correction attempt only; never fingerprint input */
56
+ correction?: InferenceCorrection;
57
+ }
58
+ //# sourceMappingURL=inference-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inference-model.d.ts","sourceRoot":"","sources":["../src/inference-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,uFAAuF;AACvF,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,UAAU,EAAE,OAAO,CAAC;IACpB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,iBAAiB,EAAE,CAAC;IAC1B,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,mFAAmF;IACnF,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC;IAC3B,KAAK,EAAE;QACL,4EAA4E;QAC5E,WAAW,EAAE,MAAM,CAAC;QACpB,4FAA4F;QAC5F,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,2CAA2C;QAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,8EAA8E;QAC9E,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,mDAAmD;IACnD,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,cAAc,CAAC;IACvB,sEAAsE;IACtE,UAAU,CAAC,EAAE,mBAAmB,CAAC;CAClC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inference-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inference-model.js","sourceRoot":"","sources":["../src/inference-model.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import type { NolaIngestEnvelope } from "./nola-protocol.js";
2
+ /** The role → style functions a line is rendered with. Colour never changes the text: strip the escapes and the plain line remains. */
3
+ export interface LinePalette {
4
+ dim: (s: string) => string;
5
+ command: (s: string) => string;
6
+ path: (s: string) => string;
7
+ ok: (s: string) => string;
8
+ warn: (s: string) => string;
9
+ error: (s: string) => string;
10
+ }
11
+ export declare const plainPalette: LinePalette;
12
+ /** The same roles in ANSI colour — what a TTY sees; strip the escapes and `plainPalette`'s line remains. */
13
+ export declare const ansiPalette: LinePalette;
14
+ /** What the console process prints one line for: an ingested envelope, or the UI's "cleared" notice. */
15
+ export type IngestLineNotice = NolaIngestEnvelope | {
16
+ kind: "cleared";
17
+ at: number;
18
+ };
19
+ /**
20
+ * One ingested envelope → one log line, the way tracing tools show spans:
21
+ * time, kind, then what happened. Ask-level events (start, end, invocation
22
+ * end) sit at column 0; attempt-level events (request, reply, validation,
23
+ * retry) indent under their ask. Colour is by role and never changes the
24
+ * text: strip the escapes and the plain line is what remains.
25
+ */
26
+ export declare function formatIngestLine(notice: IngestLineNotice, p?: LinePalette): string;
27
+ //# sourceMappingURL=ingest-line.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingest-line.d.ts","sourceRoot":"","sources":["../src/ingest-line.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,uIAAuI;AACvI,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3B,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5B,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1B,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5B,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAC9B;AAGD,eAAO,MAAM,YAAY,EAAE,WAA4F,CAAC;AAGxH,4GAA4G;AAC5G,eAAO,MAAM,WAAW,EAAE,WAOxB,CAAC;AAEH,wGAAwG;AACxG,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAiCpF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,GAAE,WAA0B,GAAG,MAAM,CAiDhG"}
@@ -0,0 +1,85 @@
1
+ const id = (s) => s;
2
+ export const plainPalette = Object.freeze({ dim: id, command: id, path: id, ok: id, warn: id, error: id });
3
+ const sgr = (open, close) => (s) => `\u001b[${open}m${s}\u001b[${close}m`;
4
+ /** The same roles in ANSI colour — what a TTY sees; strip the escapes and `plainPalette`'s line remains. */
5
+ export const ansiPalette = Object.freeze({
6
+ dim: sgr(2, 22),
7
+ command: sgr(36, 39),
8
+ path: sgr(1, 22),
9
+ ok: sgr(32, 39),
10
+ warn: sgr(33, 39),
11
+ error: sgr(31, 39),
12
+ });
13
+ const INSTRUCTION_MAX = 72;
14
+ const KIND_WIDTH = 6;
15
+ const siteText = (site) => (site?.file && site.loc ? `${site.file}:${site.loc}` : "<unknown>");
16
+ const pad2 = (n) => String(n).padStart(2, "0");
17
+ /** Local wall-clock time of the event, `HH:MM:SS.mmm` — the way every tracing tool opens a line. */
18
+ function timeText(at) {
19
+ const d = new Date(at);
20
+ return `${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}.${String(d.getMilliseconds()).padStart(3, "0")}`;
21
+ }
22
+ /** One line, whitespace collapsed, cut to INSTRUCTION_MAX characters. */
23
+ function excerpt(text) {
24
+ const flat = text.replace(/\s+/g, " ").trim();
25
+ return flat.length > INSTRUCTION_MAX ? `${flat.slice(0, INSTRUCTION_MAX - 1)}…` : flat;
26
+ }
27
+ const attempts = (n) => (n !== undefined && n > 1 ? `, ${n} attempts` : "");
28
+ /**
29
+ * One ingested envelope → one log line, the way tracing tools show spans:
30
+ * time, kind, then what happened. Ask-level events (start, end, invocation
31
+ * end) sit at column 0; attempt-level events (request, reply, validation,
32
+ * retry) indent under their ask. Colour is by role and never changes the
33
+ * text: strip the escapes and the plain line is what remains.
34
+ */
35
+ export function formatIngestLine(notice, p = plainPalette) {
36
+ const kind = (label, color, nested = false) => nested ? ` ${color(label.padEnd(KIND_WIDTH - 2))}` : color(label.padEnd(KIND_WIDTH));
37
+ if (notice.kind === "cleared")
38
+ return `${p.dim(timeText(notice.at))} ${kind("clear", p.warn)} all traces removed`;
39
+ const envelope = notice;
40
+ const head = `${p.dim(timeText(envelope.at))}${envelope.project ? ` ${p.dim(envelope.project)}` : ""}`;
41
+ const event = envelope.event;
42
+ switch (envelope.kind) {
43
+ case "askStart": {
44
+ const e = event;
45
+ const instruction = e.instruction ? ` — ${excerpt(e.instruction)}` : "";
46
+ return `${head} ${kind("ask", p.command)} ${p.path(siteText(e.site))} via ${e.provider ?? "?"}${instruction}`;
47
+ }
48
+ case "providerRequest": {
49
+ const e = event;
50
+ const profile = e.profile ? ` (${e.profile})` : "";
51
+ return `${head} ${kind("req", p.dim, true)} #${e.attempt ?? "?"} → ${e.provider ?? "?"}${profile}`;
52
+ }
53
+ case "providerResponse": {
54
+ const e = event;
55
+ return `${head} ${kind("res", p.dim, true)} #${e.attempt ?? "?"} ← ${e.provider ?? "?"} ${e.durationMs ?? "?"}ms`;
56
+ }
57
+ case "validationFailed": {
58
+ const e = event;
59
+ return `${head} ${kind("warn", p.warn, true)} #${e.attempt ?? "?"} validation failed: ${e.error ?? ""}`;
60
+ }
61
+ case "retry": {
62
+ const e = event;
63
+ return `${head} ${kind("retry", p.warn, true)} after #${e.attempt ?? "?"}: ${e.reason ?? ""}`;
64
+ }
65
+ case "askEnd": {
66
+ const r = event.receipt;
67
+ const ok = r?.outcome?.ok !== false;
68
+ const summary = `${p.path(siteText(r?.site))} via ${r?.servedBy ?? "?"} ${r?.durationMs ?? "?"}ms${attempts(r?.attempts)}`;
69
+ return ok
70
+ ? `${head} ${kind("ok", p.ok)} ${summary}`
71
+ : `${head} ${kind("fail", p.error)} ${summary} — ${r?.outcome?.error ?? "unknown error"}`;
72
+ }
73
+ case "invocationStart": {
74
+ const e = event;
75
+ return `${head} ${kind("infer", p.command)} ${e.fn ?? "?"}() ${p.dim(e.file ?? "<unknown>")}`;
76
+ }
77
+ case "invocationEnd": {
78
+ const t = event.trace;
79
+ return `${head} ${kind("done", p.dim)} ${t?.fn ?? "?"}() ${p.dim(t?.file ?? "<unknown>")}`;
80
+ }
81
+ default:
82
+ return `${head} ${kind(envelope.kind, p.dim)}`;
83
+ }
84
+ }
85
+ //# sourceMappingURL=ingest-line.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingest-line.js","sourceRoot":"","sources":["../src/ingest-line.ts"],"names":[],"mappings":"AAYA,MAAM,EAAE,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,YAAY,GAAgB,MAAM,C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KAAK,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC;YAC3H,OAAO,EAAE;gBACP,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,OAAO,EAAE;gBAC1C,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,OAAO,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,IAAI,eAAe,EAAE,CAAC;QAC9F,CAAC;QACD,KAAK,iBAAiB,CAAC,CAAC,CAAC;YACvB,MAAM,CAAC,GAAG,KAA6B,CAAC;YACxC,OAAO,GAAG,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,WAAW,CAAC,EAAE,CAAC;QAChG,CAAC;QACD,KAAK,eAAe,CAAC,CAAC,CAAC;YACrB,MAAM,CAAC,GAAI,KAA4B,CAAC,KAAK,CAAC;YAC9C,OAAO,GAAG,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,IAAI,WAAW,CAAC,EAAE,CAAC;QAC7F,CAAC;QACD;YACE,OAAO,GAAG,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IACnD,CAAC;AACH,CAAC"}
@@ -0,0 +1,195 @@
1
+ import type { ProviderParams } from "./index.js";
2
+ import type { InferenceModel } from "./inference-model.js";
3
+ /**
4
+ * The hosted API wire contract. Lives in core so the platform (server) side
5
+ * imports the very same shapes the `nola()` provider and the scaffolder
6
+ * send; nothing here depends on the runtime or the providers.
7
+ */
8
+ /** Wire envelope version of POST /v1/infer. */
9
+ export declare const NOLA_PROTOCOL = 1;
10
+ /** Default base URL of the hosted API; `NOLA_API_URL` overrides it in every client. */
11
+ export declare const NOLA_API_URL = "https://api.nola.sh";
12
+ /**
13
+ * Reply headers on POST /v1/infer. The run counter is sent in every mode (credit is spent first, the
14
+ * free runs take over when it is gone); `balance` is present only while the account is in paid mode.
15
+ */
16
+ export declare const NOLA_USAGE_HEADERS: {
17
+ readonly used: "x-nola-runs-used";
18
+ readonly limit: "x-nola-runs-limit";
19
+ readonly balance: "x-nola-balance-micro";
20
+ };
21
+ /** GET /v1/capabilities — every Nola-protocol server self-describes (console design §6). */
22
+ export interface NolaCapabilitiesResponse {
23
+ protocol: typeof NOLA_PROTOCOL;
24
+ /** Whether this server serves POST /v1/infer. Absent (legacy servers) is read as true. */
25
+ infer?: boolean;
26
+ /** Whether this server accepts POST /v1/ingest trace ingestion. */
27
+ ingest: boolean;
28
+ /** Inference profiles this server resolves (defined in the console UI); absent when it resolves none. */
29
+ profiles?: readonly string[];
30
+ /** How a CLI signs in against this server; absent when sign-in is not offered (console API off, no CLI client). */
31
+ auth?: NolaAuthConfig;
32
+ /** The console origin (`https://platform.nola.sh`) — billing page, account; absent on servers without a console. */
33
+ consoleUrl?: string;
34
+ }
35
+ /** Envelope version of POST /v1/ingest. */
36
+ export declare const NOLA_INGEST_VERSION = 1;
37
+ /** The eight runtime hook events; kind names are the NolaTelemetry method names minus the `on` prefix. */
38
+ export declare const NOLA_INGEST_KINDS: readonly ["askStart", "providerRequest", "providerResponse", "validationFailed", "retry", "askEnd", "invocationStart", "invocationEnd"];
39
+ export type NolaIngestKind = (typeof NOLA_INGEST_KINDS)[number];
40
+ /**
41
+ * One POST /v1/ingest body — one hook event, fire-and-forget (console design
42
+ * §11). `event` is the core hook event exactly as emitted, JSON-serialized
43
+ * (a `Site` serializes structurally to `{ file, loc }`); consumers narrow by
44
+ * `kind`. `seq` is a monotonic per-process counter — POSTs arrive out of
45
+ * order and consumers order by it. `runId` is one UUID minted per process.
46
+ */
47
+ export interface NolaIngestEnvelope {
48
+ v: typeof NOLA_INGEST_VERSION;
49
+ runId: string;
50
+ pid: number;
51
+ /** The app's project name (config `project`, defaulting to the nearest package.json `name`). Additive since 2026-09-01. */
52
+ project?: string;
53
+ seq: number;
54
+ /** Date.now() at emit time. */
55
+ at: number;
56
+ kind: NolaIngestKind;
57
+ event: unknown;
58
+ }
59
+ export interface NolaInferRequest {
60
+ protocol: typeof NOLA_PROTOCOL;
61
+ /** the client's lockstep package version — the server renders with the matching classic template */
62
+ version: string;
63
+ /** ask identity for tracing — present together, exactly when the runtime supplied `ProviderRequest.trace` */
64
+ askId?: string;
65
+ invocationId?: string;
66
+ spanPath?: readonly string[];
67
+ /** the ask itself — the canonical InferenceModel */
68
+ intent: InferenceModel;
69
+ /** upstream model selector, "<provider>/<model>" — absent ⇒ the server chooses (trial keys are restricted server-side) */
70
+ model?: string;
71
+ /**
72
+ * Free-form inference profile — the `ask with <name>` name under managed
73
+ * mode (`model: nola.infer()`). The platform's smart routing resolves it to a
74
+ * model and params; unknown to the client by design. Additive since
75
+ * 2026-08-30.
76
+ */
77
+ profile?: string;
78
+ /** The app's project name — deployment metadata for per-project display/metering. Additive since 2026-09-01. */
79
+ project?: string;
80
+ params?: ProviderParams;
81
+ }
82
+ export interface NolaInferResponse {
83
+ /** the model's raw reply; the runtime parses, validates and corrects it like any provider's */
84
+ text: string;
85
+ durationMs?: number;
86
+ }
87
+ /** Every non-2xx body. `details` is a JSON object; `quota_exceeded` carries `{ runsUsed, runsLimit }`. */
88
+ export interface NolaErrorResponse {
89
+ error: {
90
+ code: string;
91
+ message: string;
92
+ details?: Record<string, unknown>;
93
+ };
94
+ }
95
+ export type NolaAccountKind = "anonymous" | "user";
96
+ /**
97
+ * POST /v1/trial — no auth, no body fields (the client sends `{}`; nothing
98
+ * on the machine identifies it to the server). 201 with a fresh anonymous
99
+ * account and its one key; the raw key appears here exactly once. One per
100
+ * machine as far as the CLI is concerned — every later key needs a signed-in
101
+ * user (spec 2026-09-04-cli-sign-in-design.md).
102
+ */
103
+ export interface NolaTrialResponse {
104
+ apiKey: string;
105
+ account: {
106
+ id: string;
107
+ kind: NolaAccountKind;
108
+ };
109
+ trial: {
110
+ runs: number;
111
+ };
112
+ }
113
+ /** The `/authorize` query parameter the CLI uses to hand its recorded trial account id to the tenant's post-login Action. */
114
+ export declare const NOLA_ACCOUNT_PARAM = "ext-nola_account";
115
+ /** The access-token claim the Action writes from that parameter; the API claims the account from it (platform spec 2026-09-07). */
116
+ export declare const NOLA_ACCOUNT_CLAIM = "nola:account_id";
117
+ /** Where a CLI signs in (from GET /v1/capabilities): the Auth0 tenant as `https://<domain>`, the CLI's public client id, the API audience. */
118
+ export interface NolaAuthConfig {
119
+ issuer: string;
120
+ clientId: string;
121
+ audience: string;
122
+ /**
123
+ * Loopback ports registered on the tenant as `http://127.0.0.1:<port>/callback` for the
124
+ * Authorization Code + PKCE flow; the CLI binds the first free one. Absent or empty means
125
+ * this server cannot sign a CLI in.
126
+ */
127
+ redirectPorts?: readonly number[];
128
+ }
129
+ /** POST /v1/console/keys — 201 (Auth0 bearer). The raw key appears here exactly once. */
130
+ export interface NolaConsoleCreatedKeyResponse {
131
+ id: string;
132
+ name: string | null;
133
+ prefix: string;
134
+ suffix: string | null;
135
+ apiKey: string;
136
+ }
137
+ /** GET /v1/console/me — the signed-in user and their personal account (Auth0 bearer). */
138
+ export interface NolaConsoleMeResponse {
139
+ user: {
140
+ id: string;
141
+ email: string | null;
142
+ name: string | null;
143
+ avatarUrl: string | null;
144
+ };
145
+ account: {
146
+ id: string;
147
+ kind: NolaAccountKind;
148
+ status: "active" | "suspended";
149
+ mode: "trial" | "paid";
150
+ trial: {
151
+ runsUsed: number;
152
+ runsLimit: number;
153
+ };
154
+ balanceMicro: number;
155
+ spendThisMonthMicro: number;
156
+ liveKeyCount: number;
157
+ };
158
+ }
159
+ /** POST /v1/console/sessions/:id/claim — links a project key's account (a `POST /v1/billing/session` session) to the signed-in user (Auth0 bearer). */
160
+ export interface NolaClaimResponse {
161
+ outcome: "claimed" | "merged" | "already_owned";
162
+ accountId: string;
163
+ }
164
+ /** GET /v1/account — Bearer auth. */
165
+ export interface NolaAccountResponse {
166
+ id: string;
167
+ kind: NolaAccountKind;
168
+ status: "active" | "suspended";
169
+ trial: {
170
+ runsUsed: number;
171
+ runsLimit: number;
172
+ };
173
+ /** prepaid credits, in millionths of a US dollar */
174
+ balance: {
175
+ microUsd: number;
176
+ };
177
+ /** The model hosted runs use and its retail price (micro-USD per million tokens) — what `nola account` prints. */
178
+ model: NolaHostedModel;
179
+ }
180
+ /** The single hosted model (phase 1): a short display name and its price, both decided by the server. */
181
+ export interface NolaHostedModel {
182
+ /** e.g. "gpt-oss-120b" */
183
+ name: string;
184
+ pricing: {
185
+ inputMicroPerMTok: number;
186
+ outputMicroPerMTok: number;
187
+ };
188
+ }
189
+ /** POST /v1/billing/session — Bearer auth, empty JSON body. The URL carries only a session id, never the key. */
190
+ export interface NolaBillingSessionResponse {
191
+ url: string;
192
+ /** ISO-8601 */
193
+ expiresAt: string;
194
+ }
195
+ //# sourceMappingURL=nola-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nola-protocol.d.ts","sourceRoot":"","sources":["../src/nola-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;GAIG;AAEH,+CAA+C;AAC/C,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,uFAAuF;AACvF,eAAO,MAAM,YAAY,wBAAwB,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;CAAqG,CAAC;AAErI,4FAA4F;AAC5F,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,OAAO,aAAa,CAAC;IAC/B,0FA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AAM,WAAW,0BAA0B;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe;IACf,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The hosted API wire contract. Lives in core so the platform (server) side
3
+ * imports the very same shapes the `nola()` provider and the scaffolder
4
+ * send; nothing here depends on the runtime or the providers.
5
+ */
6
+ /** Wire envelope version of POST /v1/infer. */
7
+ export const NOLA_PROTOCOL = 1;
8
+ /** Default base URL of the hosted API; `NOLA_API_URL` overrides it in every client. */
9
+ export const NOLA_API_URL = "https://api.nola.sh";
10
+ /**
11
+ * Reply headers on POST /v1/infer. The run counter is sent in every mode (credit is spent first, the
12
+ * free runs take over when it is gone); `balance` is present only while the account is in paid mode.
13
+ */
14
+ export const NOLA_USAGE_HEADERS = { used: "x-nola-runs-used", limit: "x-nola-runs-limit", balance: "x-nola-balance-micro" };
15
+ /** Envelope version of POST /v1/ingest. */
16
+ export const NOLA_INGEST_VERSION = 1;
17
+ /** The eight runtime hook events; kind names are the NolaTelemetry method names minus the `on` prefix. */
18
+ export const NOLA_INGEST_KINDS = [
19
+ "askStart",
20
+ "providerRequest",
21
+ "providerResponse",
22
+ "validationFailed",
23
+ "retry",
24
+ "askEnd",
25
+ "invocationStart",
26
+ "invocationEnd",
27
+ ];
28
+ /** The `/authorize` query parameter the CLI uses to hand its recorded trial account id to the tenant's post-login Action. */
29
+ export const NOLA_ACCOUNT_PARAM = "ext-nola_account";
30
+ /** The access-token claim the Action writes from that parameter; the API claims the account from it (platform spec 2026-09-07). */
31
+ export const NOLA_ACCOUNT_CLAIM = "nola:account_id";
32
+ //# sourceMappingURL=nola-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nola-protocol.js","sourceRoot":"","sources":["../src/nola-protocol.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,+CAA+C;AAC/C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B,uFAAuF;AACvF,MAAM,CAAC,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,sBAAsB,EAAW,CAAC;AAiBrI,2CAA2C;AAC3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC,0GAA0G;AAC1G,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,UAAU;IACV,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,OAAO;IACP,QAAQ;IACR,iBAAiB;IACjB,eAAe;CACP,CAAC;AA0EX,6HAA6H;AAC7H,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AACrD,mIAAmI;AACnI,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { AskTrace, ProviderParams, ProviderResponse } from "./index.js";
2
+ import type { InferenceModel } from "./inference-model.js";
3
+ /**
4
+ * The platform-served model (platform-config design 2026-09-03). It is the
5
+ * ONLY `infer`-dialect model: the runtime hands it the canonical
6
+ * InferenceModel, every other model receives the classic rendering through
7
+ * `complete`. The brand (not the method) is the detection gate, so a user
8
+ * object that happens to have an `infer` method is still a config error.
9
+ */
10
+ export declare const PLATFORM_MODEL: unique symbol;
11
+ /** The request a platform model consumes: the canonical model, never a rendering. */
12
+ export interface InferRequest {
13
+ model: InferenceModel;
14
+ params?: ProviderParams;
15
+ signal?: AbortSignal;
16
+ trace?: AskTrace;
17
+ /** Free-form inference profile (`ask with <name>` under a platform default). Part of the ask fingerprint. */
18
+ profile?: string;
19
+ /** The app's project name — deployment metadata for the server, NEVER part of the ask fingerprint. */
20
+ project?: string;
21
+ }
22
+ export interface PlatformModel {
23
+ readonly name: string;
24
+ infer(req: InferRequest): Promise<ProviderResponse>;
25
+ readonly [PLATFORM_MODEL]: true;
26
+ }
27
+ export declare function isPlatformModel(value: unknown): value is PlatformModel;
28
+ //# sourceMappingURL=platform-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-model.d.ts","sourceRoot":"","sources":["../src/platform-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,MAAyC,CAAC;AAE9E,qFAAqF;AACrF,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,6GAA6G;IAC7G,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACpD,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC;CACjC;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAOtE"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The platform-served model (platform-config design 2026-09-03). It is the
3
+ * ONLY `infer`-dialect model: the runtime hands it the canonical
4
+ * InferenceModel, every other model receives the classic rendering through
5
+ * `complete`. The brand (not the method) is the detection gate, so a user
6
+ * object that happens to have an `infer` method is still a config error.
7
+ */
8
+ export const PLATFORM_MODEL = Symbol.for("nola.platformModel");
9
+ export function isPlatformModel(value) {
10
+ return (!!value &&
11
+ typeof value === "object" &&
12
+ value[PLATFORM_MODEL] === true &&
13
+ typeof value.infer === "function");
14
+ }
15
+ //# sourceMappingURL=platform-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-model.js","sourceRoot":"","sources":["../src/platform-model.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAoB9E,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,CACL,CAAC,CAAC,KAAK;QACP,OAAO,KAAK,KAAK,QAAQ;QACxB,KAAwC,CAAC,cAAc,CAAC,KAAK,IAAI;QAClE,OAAQ,KAA6B,CAAC,KAAK,KAAK,UAAU,CAC3D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { InferenceModel } from "./inference-model.js";
2
+ import type { ClassicPrompt } from "./render-classic.js";
3
+ /**
4
+ * Payload union for hook events and the fingerprint: the canonical model
5
+ * for a managed ask, its classic rendering for everyone else. Requests no
6
+ * longer carry the union (reshape design 2026-09-01) — the method name is
7
+ * the dialect: `infer` takes `InferRequest { model }`, `complete` takes
8
+ * `ProviderRequest { payload: ClassicPrompt }`.
9
+ */
10
+ export type ProviderPayload = ClassicPrompt | InferenceModel;
11
+ /** Structural discriminator between the two payload shapes (a ClassicPrompt has no `intent`). */
12
+ export declare function isInferenceModel(payload: ProviderPayload): payload is InferenceModel;
13
+ //# sourceMappingURL=provider-dialect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-dialect.d.ts","sourceRoot":"","sources":["../src/provider-dialect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,cAAc,CAAC;AAE7D,iGAAiG;AACjG,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,IAAI,cAAc,CAEpF"}
@@ -0,0 +1,5 @@
1
+ /** Structural discriminator between the two payload shapes (a ClassicPrompt has no `intent`). */
2
+ export function isInferenceModel(payload) {
3
+ return "intent" in payload;
4
+ }
5
+ //# sourceMappingURL=provider-dialect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-dialect.js","sourceRoot":"","sources":["../src/provider-dialect.ts"],"names":[],"mappings":"AAYA,iGAAiG;AACjG,MAAM,UAAU,gBAAgB,CAAC,OAAwB;IACvD,OAAO,QAAQ,IAAI,OAAO,CAAC;AAC7B,CAAC"}
package/dist/redact.d.ts CHANGED
@@ -2,4 +2,6 @@
2
2
  export declare function redactSecrets(text: string): string;
3
3
  /** Render any thrown value as a redacted single-line string. */
4
4
  export declare function redactError(error: unknown): string;
5
+ /** redactSecrets over every string inside a JSON-shaped value; structure and non-strings untouched. */
6
+ export declare function redactDeep<T>(value: T): T;
5
7
  //# sourceMappingURL=redact.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAUA,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUlD;AAED,gEAAgE;AAChE,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAElD"}
1
+ {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAWA,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUlD;AAED,gEAAgE;AAChE,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAElD;AAED,uGAAuG;AACvG,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CASzC"}
package/dist/redact.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // runtime re-throws them into user stacks and persists them into receipts.
3
3
  const PATTERNS = [
4
4
  /\b(?:sk|rk|pk)-[A-Za-z0-9_-]{8,}/g, // OpenAI-family keys
5
+ /\bnola_sk_[A-Za-z0-9]{8,}/g, // Nola API keys
5
6
  /\bAIza[0-9A-Za-z_-]{10,}/g, // Google API keys
6
7
  /\b(?:Bearer|Basic)\s+[A-Za-z0-9._~+/=-]{8,}/gi, // Authorization values
7
8
  /\b[0-9a-f]{32,}\b/gi, // long hex blobs (key fingerprints)
@@ -22,4 +23,18 @@ export function redactSecrets(text) {
22
23
  export function redactError(error) {
23
24
  return redactSecrets(error instanceof Error ? error.message : String(error));
24
25
  }
26
+ /** redactSecrets over every string inside a JSON-shaped value; structure and non-strings untouched. */
27
+ export function redactDeep(value) {
28
+ if (typeof value === "string")
29
+ return redactSecrets(value);
30
+ if (Array.isArray(value))
31
+ return value.map(redactDeep);
32
+ if (value !== null && typeof value === "object") {
33
+ const out = {};
34
+ for (const [k, v] of Object.entries(value))
35
+ out[k] = redactDeep(v);
36
+ return out;
37
+ }
38
+ return value;
39
+ }
25
40
  //# sourceMappingURL=redact.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,2EAA2E;AAE3E,MAAM,QAAQ,GAAsB;IAClC,mCAAmC,EAAE,qBAAqB;IAC1D,2BAA2B,EAAE,kBAAkB;IAC/C,+CAA+C,EAAE,uBAAuB;IACxE,qBAAqB,EAAE,oCAAoC;CAC5D,CAAC;AAEF,uEAAuE;AACvE,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACnC,MAAM,KAAK,GAAG,KAAK,CAAC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AAC;AACb,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,aAAa,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,UAAU,CAAI,KAAQ;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,aAAa,CAAC,KAAK,CAAM,CAAC;IAChE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,UAAU,CAAM,CAAC;IAC5D,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC9F,OAAO,GAAQ,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { JsonSchema, Message, ProviderOutput } from "./index.js";
2
+ import type { InferenceModel, InferenceScope } from "./inference-model.js";
3
+ export declare const SYSTEM_PREAMBLE: string;
4
+ /** What a classic (chat-dialect) provider sends: system text, conversation, output contract. */
5
+ export interface ClassicPrompt {
6
+ system: string;
7
+ messages: Message[];
8
+ output: ProviderOutput;
9
+ }
10
+ /** The correction turn's user message after a failed attempt. */
11
+ export declare function CORRECTION_PROMPT(error: string): string;
12
+ /** Whether a wire schema is a bare string with no hints worth showing the model. */
13
+ export declare function isTrivialStringSchema(schema: JsonSchema): boolean;
14
+ /** Joins prompt blocks with the blank-line separator, skipping empty ones. */
15
+ export declare function joinBlocks(...parts: string[]): string;
16
+ /** The schema the reply must satisfy — free text and non-JSON syntaxes read as a bare string. */
17
+ export declare function outputSchema(output: ProviderOutput): JsonSchema;
18
+ /** Outer→inner list of the model's scopes (root caller first, asking frame last). */
19
+ export declare function scopeChain(model: Pick<InferenceModel, "scope">): InferenceScope[];
20
+ /**
21
+ * One CONTEXT block: signature + source file, the authored instruction as
22
+ * Purpose, and the argument list — plain (non-contextual) params appear by
23
+ * name with an explicit unknown marker so the model never invents a value;
24
+ * contextual values stay JSON-quoted except long/multiline strings, which
25
+ * read as real text in a tagged block.
26
+ */
27
+ export declare function renderScopeBlock(scope: Pick<InferenceScope, "fn" | "file" | "instruction" | "args">, nested: boolean): string;
28
+ /** The response-discipline tail of the TASK block — the lines the JSON parser contract relies on. */
29
+ export declare function renderTaskFormat(schema: JsonSchema): string;
30
+ /** The built-in TASK block: the instruction verbatim inside <request>, then the format lines. */
31
+ export declare function renderTaskBlock(model: Pick<InferenceModel, "input" | "output">, hasContext: boolean): string;
32
+ /**
33
+ * The user-message text from scope depth `from` (outer→inner) to the TASK:
34
+ * a node's `text` override replaces its block, a scope whose override covers
35
+ * the remainder ends the walk.
36
+ */
37
+ export declare function renderClassicText(model: InferenceModel, from?: number): string;
38
+ /** The classic chat rendering of a model — deterministic; what every chat-dialect provider sends. */
39
+ export declare function renderClassic(model: InferenceModel): ClassicPrompt;
40
+ //# sourceMappingURL=render-classic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-classic.d.ts","sourceRoot":"","sources":["../src/render-classic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3E,eAAO,MAAM,eAAe,QAGkE,CAAC;AAE/F,gGAAgG;AAChG,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,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