@gaunt-sloth/core 2.0.0-alpha.9 → 2.0.0-beta.0
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/.gsloth.review.md +2 -0
- package/README.md +71 -20
- package/dist/config/colour.d.ts +38 -0
- package/dist/config/colour.js +36 -0
- package/dist/config/colour.js.map +1 -0
- package/dist/config/configDiscovery.d.ts +79 -0
- package/dist/config/configDiscovery.js +80 -0
- package/dist/config/configDiscovery.js.map +1 -0
- package/dist/config/defaults.d.ts +20 -20
- package/dist/config/defaults.js +10 -8
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/filesystem-tools.d.ts +41 -0
- package/dist/config/filesystem-tools.js +56 -0
- package/dist/config/filesystem-tools.js.map +1 -0
- package/dist/config/loader.d.ts +171 -19
- package/dist/config/loader.js +1054 -144
- package/dist/config/loader.js.map +1 -1
- package/dist/config/mouse.d.ts +50 -0
- package/dist/config/mouse.js +44 -0
- package/dist/config/mouse.js.map +1 -0
- package/dist/config/profiles.d.ts +68 -0
- package/dist/config/profiles.js +93 -0
- package/dist/config/profiles.js.map +1 -0
- package/dist/config/providerKeys.d.ts +69 -0
- package/dist/config/providerKeys.js +69 -0
- package/dist/config/providerKeys.js.map +1 -0
- package/dist/config/schema.d.ts +2671 -138
- package/dist/config/schema.js +1361 -85
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shell-policy.d.ts +899 -111
- package/dist/config/shell-policy.js +800 -70
- package/dist/config/shell-policy.js.map +1 -1
- package/dist/config/tool-descriptions.d.ts +211 -0
- package/dist/config/tool-descriptions.js +272 -0
- package/dist/config/tool-descriptions.js.map +1 -0
- package/dist/config/types.d.ts +352 -41
- package/dist/config/types.js +1 -0
- package/dist/config/types.js.map +1 -1
- package/dist/config.d.ts +35 -1
- package/dist/config.js +16 -1
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +28 -1
- package/dist/constants.js +28 -1
- package/dist/constants.js.map +1 -1
- package/dist/core/GthAbstractAgent.d.ts +166 -11
- package/dist/core/GthAbstractAgent.js +484 -45
- package/dist/core/GthAbstractAgent.js.map +1 -1
- package/dist/core/GthAgentRunner.d.ts +543 -57
- package/dist/core/GthAgentRunner.js +1494 -140
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.d.ts +117 -2
- package/dist/core/GthLangChainAgent.js +602 -29
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/core/approvals/annotations.d.ts +122 -0
- package/dist/core/approvals/annotations.js +137 -0
- package/dist/core/approvals/annotations.js.map +1 -0
- package/dist/core/approvals/grants.d.ts +216 -0
- package/dist/core/approvals/grants.js +469 -0
- package/dist/core/approvals/grants.js.map +1 -0
- package/dist/core/approvals/matcher.d.ts +202 -0
- package/dist/core/approvals/matcher.js +267 -0
- package/dist/core/approvals/matcher.js.map +1 -0
- package/dist/core/approvals/mcpSubjects.d.ts +40 -0
- package/dist/core/approvals/mcpSubjects.js +99 -0
- package/dist/core/approvals/mcpSubjects.js.map +1 -0
- package/dist/core/approvals/promptHeader.d.ts +28 -0
- package/dist/core/approvals/promptHeader.js +62 -0
- package/dist/core/approvals/promptHeader.js.map +1 -0
- package/dist/core/approvals/toolAnnotationSources.d.ts +105 -0
- package/dist/core/approvals/toolAnnotationSources.js +277 -0
- package/dist/core/approvals/toolAnnotationSources.js.map +1 -0
- package/dist/core/approvals/toolHost.d.ts +46 -0
- package/dist/core/approvals/toolHost.js +108 -0
- package/dist/core/approvals/toolHost.js.map +1 -0
- package/dist/core/debugCapture.d.ts +74 -0
- package/dist/core/debugCapture.js +100 -0
- package/dist/core/debugCapture.js.map +1 -0
- package/dist/core/gthLeanAgentFactory.d.ts +4 -4
- package/dist/core/gthLeanAgentFactory.js +4 -4
- package/dist/core/launchBanner.d.ts +127 -0
- package/dist/core/launchBanner.js +414 -0
- package/dist/core/launchBanner.js.map +1 -0
- package/dist/core/modelLabel.d.ts +19 -0
- package/dist/core/modelLabel.js +26 -0
- package/dist/core/modelLabel.js.map +1 -0
- package/dist/core/plainToolIndication.d.ts +15 -0
- package/dist/core/plainToolIndication.js +174 -0
- package/dist/core/plainToolIndication.js.map +1 -0
- package/dist/core/reasoningBlocks.d.ts +65 -0
- package/dist/core/reasoningBlocks.js +103 -0
- package/dist/core/reasoningBlocks.js.map +1 -0
- package/dist/core/refusal.d.ts +53 -0
- package/dist/core/refusal.js +133 -0
- package/dist/core/refusal.js.map +1 -0
- package/dist/core/runHeader.d.ts +38 -0
- package/dist/core/runHeader.js +42 -0
- package/dist/core/runHeader.js.map +1 -0
- package/dist/core/runStats.d.ts +14 -3
- package/dist/core/runStats.js +48 -3
- package/dist/core/runStats.js.map +1 -1
- package/dist/core/shell/ShellCommandFailedError.d.ts +3 -4
- package/dist/core/shell/ShellCommandFailedError.js +3 -4
- package/dist/core/shell/ShellCommandFailedError.js.map +1 -1
- package/dist/core/shell/abstention.d.ts +88 -0
- package/dist/core/shell/abstention.js +184 -0
- package/dist/core/shell/abstention.js.map +1 -0
- package/dist/core/shell/approvalCapture.d.ts +271 -0
- package/dist/core/shell/approvalCapture.js +108 -0
- package/dist/core/shell/approvalCapture.js.map +1 -0
- package/dist/core/shell/approvalStop.d.ts +123 -0
- package/dist/core/shell/approvalStop.js +269 -0
- package/dist/core/shell/approvalStop.js.map +1 -0
- package/dist/core/shell/arity.d.ts +6 -0
- package/dist/core/shell/arity.js +20 -6
- package/dist/core/shell/arity.js.map +1 -1
- package/dist/core/shell/denylist.d.ts +11 -0
- package/dist/core/shell/denylist.js +37 -0
- package/dist/core/shell/denylist.js.map +1 -0
- package/dist/core/shell/escalationSeverity.d.ts +141 -0
- package/dist/core/shell/escalationSeverity.js +89 -0
- package/dist/core/shell/escalationSeverity.js.map +1 -0
- package/dist/core/shell/framing.d.ts +190 -0
- package/dist/core/shell/framing.js +633 -0
- package/dist/core/shell/framing.js.map +1 -0
- package/dist/core/shell/hardline.d.ts +103 -0
- package/dist/core/shell/hardline.js +780 -0
- package/dist/core/shell/hardline.js.map +1 -0
- package/dist/core/shell/negotiation.d.ts +328 -0
- package/dist/core/shell/negotiation.js +488 -0
- package/dist/core/shell/negotiation.js.map +1 -0
- package/dist/core/shell/normalize.d.ts +44 -4
- package/dist/core/shell/normalize.js +61 -7
- package/dist/core/shell/normalize.js.map +1 -1
- package/dist/core/shell/openWorld.d.ts +263 -0
- package/dist/core/shell/openWorld.js +1188 -0
- package/dist/core/shell/openWorld.js.map +1 -0
- package/dist/core/shell/rater.d.ts +873 -0
- package/dist/core/shell/rater.js +1454 -0
- package/dist/core/shell/rater.js.map +1 -0
- package/dist/core/shell/raterModel.d.ts +41 -0
- package/dist/core/shell/raterModel.js +51 -0
- package/dist/core/shell/raterModel.js.map +1 -0
- package/dist/core/shell/raterVocabulary.d.ts +121 -0
- package/dist/core/shell/raterVocabulary.js +116 -0
- package/dist/core/shell/raterVocabulary.js.map +1 -0
- package/dist/core/shell/rejection.d.ts +69 -0
- package/dist/core/shell/rejection.js +38 -0
- package/dist/core/shell/rejection.js.map +1 -0
- package/dist/core/toolCallRepair/grammar.d.ts +41 -0
- package/dist/core/toolCallRepair/grammar.js +116 -0
- package/dist/core/toolCallRepair/grammar.js.map +1 -0
- package/dist/core/toolCallRepair/index.d.ts +2 -0
- package/dist/core/toolCallRepair/index.js +7 -0
- package/dist/core/toolCallRepair/index.js.map +1 -0
- package/dist/core/toolCallRepair/payload.d.ts +36 -0
- package/dist/core/toolCallRepair/payload.js +341 -0
- package/dist/core/toolCallRepair/payload.js.map +1 -0
- package/dist/core/toolCallRepair/promote.d.ts +45 -0
- package/dist/core/toolCallRepair/promote.js +90 -0
- package/dist/core/toolCallRepair/promote.js.map +1 -0
- package/dist/core/toolDisplay.d.ts +123 -0
- package/dist/core/toolDisplay.js +451 -0
- package/dist/core/toolDisplay.js.map +1 -0
- package/dist/core/toolOutputChannel.d.ts +95 -0
- package/dist/core/toolOutputChannel.js +165 -0
- package/dist/core/toolOutputChannel.js.map +1 -0
- package/dist/core/types.d.ts +349 -16
- package/dist/core/types.js.map +1 -1
- package/dist/history/historyFormat.d.ts +12 -3
- package/dist/history/historyFormat.js +50 -8
- package/dist/history/historyFormat.js.map +1 -1
- package/dist/history/historyStore.d.ts +77 -0
- package/dist/history/historyStore.js +173 -6
- package/dist/history/historyStore.js.map +1 -1
- package/dist/history/recordSession.d.ts +10 -1
- package/dist/history/recordSession.js +27 -0
- package/dist/history/recordSession.js.map +1 -1
- package/dist/providers/anthropic.js +12 -0
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/configurationPassthrough.d.ts +107 -0
- package/dist/providers/configurationPassthrough.js +148 -0
- package/dist/providers/configurationPassthrough.js.map +1 -0
- package/dist/providers/geminiSchemaSanitizer.d.ts +55 -0
- package/dist/providers/geminiSchemaSanitizer.js +347 -0
- package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
- package/dist/providers/geminiThinking.d.ts +60 -0
- package/dist/providers/geminiThinking.js +92 -0
- package/dist/providers/geminiThinking.js.map +1 -0
- package/dist/providers/google-genai.js +18 -1
- package/dist/providers/google-genai.js.map +1 -1
- package/dist/providers/groq.js +12 -0
- package/dist/providers/groq.js.map +1 -1
- package/dist/providers/huggingface.d.ts +25 -0
- package/dist/providers/huggingface.js +69 -0
- package/dist/providers/huggingface.js.map +1 -0
- package/dist/providers/modelCatalog.d.ts +109 -0
- package/dist/providers/modelCatalog.js +245 -0
- package/dist/providers/modelCatalog.js.map +1 -0
- package/dist/providers/modelDiscovery.d.ts +99 -5
- package/dist/providers/modelDiscovery.js +191 -35
- package/dist/providers/modelDiscovery.js.map +1 -1
- package/dist/providers/ollama.d.ts +18 -4
- package/dist/providers/ollama.js +67 -37
- package/dist/providers/ollama.js.map +1 -1
- package/dist/providers/openai.js +34 -0
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/openrouter.d.ts +26 -4
- package/dist/providers/openrouter.js +83 -26
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/providers/vertexai.js +19 -1
- package/dist/providers/vertexai.js.map +1 -1
- package/dist/providers/xai.js +20 -0
- package/dist/providers/xai.js.map +1 -1
- package/dist/runtime/askStructured.d.ts +105 -0
- package/dist/runtime/askStructured.js +120 -0
- package/dist/runtime/askStructured.js.map +1 -0
- package/dist/runtime/conversation.d.ts +64 -0
- package/dist/runtime/conversation.js +171 -0
- package/dist/runtime/conversation.js.map +1 -0
- package/dist/runtime/singleShot.d.ts +37 -6
- package/dist/runtime/singleShot.js +113 -67
- package/dist/runtime/singleShot.js.map +1 -1
- package/dist/runtime/structuredOutput.d.ts +104 -0
- package/dist/runtime/structuredOutput.js +393 -0
- package/dist/runtime/structuredOutput.js.map +1 -0
- package/dist/utils/ProgressIndicator.d.ts +21 -0
- package/dist/utils/ProgressIndicator.js +30 -3
- package/dist/utils/ProgressIndicator.js.map +1 -1
- package/dist/utils/aiignoreUtils.js.map +1 -1
- package/dist/utils/binaryOutputUtils.js.map +1 -1
- package/dist/utils/consoleUtils.d.ts +95 -0
- package/dist/utils/consoleUtils.js +112 -2
- package/dist/utils/consoleUtils.js.map +1 -1
- package/dist/utils/crashHandler.d.ts +87 -0
- package/dist/utils/crashHandler.js +128 -0
- package/dist/utils/crashHandler.js.map +1 -0
- package/dist/utils/debugDump.d.ts +134 -0
- package/dist/utils/debugDump.js +381 -0
- package/dist/utils/debugDump.js.map +1 -0
- package/dist/utils/debugUtils.d.ts +13 -4
- package/dist/utils/debugUtils.js +36 -13
- package/dist/utils/debugUtils.js.map +1 -1
- package/dist/utils/displayWidth.d.ts +53 -0
- package/dist/utils/displayWidth.js +195 -0
- package/dist/utils/displayWidth.js.map +1 -0
- package/dist/utils/fileUtils.js.map +1 -1
- package/dist/utils/globalConfigUtils.d.ts +14 -2
- package/dist/utils/globalConfigUtils.js +22 -4
- package/dist/utils/globalConfigUtils.js.map +1 -1
- package/dist/utils/llmUtils.d.ts +39 -8
- package/dist/utils/llmUtils.js +76 -8
- package/dist/utils/llmUtils.js.map +1 -1
- package/dist/utils/redactSecrets.d.ts +63 -0
- package/dist/utils/redactSecrets.js +286 -0
- package/dist/utils/redactSecrets.js.map +1 -0
- package/dist/utils/systemPromptNotes.d.ts +222 -0
- package/dist/utils/systemPromptNotes.js +338 -0
- package/dist/utils/systemPromptNotes.js.map +1 -0
- package/dist/utils/systemUtils.d.ts +18 -1
- package/dist/utils/systemUtils.js +38 -3
- package/dist/utils/systemUtils.js.map +1 -1
- package/dist/utils/toolMatching.d.ts +30 -0
- package/dist/utils/toolMatching.js +44 -0
- package/dist/utils/toolMatching.js.map +1 -0
- package/dist/utils/untrustedText.d.ts +86 -0
- package/dist/utils/untrustedText.js +101 -0
- package/dist/utils/untrustedText.js.map +1 -0
- package/package.json +21 -7
- package/schema/gsloth-config.schema.json +1921 -326
- package/dist/core/shell/allowlist.d.ts +0 -75
- package/dist/core/shell/allowlist.js +0 -187
- package/dist/core/shell/allowlist.js.map +0 -1
- package/dist/core/shell/judge.d.ts +0 -161
- package/dist/core/shell/judge.js +0 -261
- package/dist/core/shell/judge.js.map +0 -1
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module runtime/structuredOutput
|
|
3
|
+
*
|
|
4
|
+
* EXT-88 — the **`withStructuredOutput` boundary**. Every `withStructuredOutput` call in this
|
|
5
|
+
* project goes through {@link structuredOutputBoundary}: `rateShellCommand` (the approvals rater),
|
|
6
|
+
* {@link askStructured} (arbitrary caller schemas, including `gth workflow` scripts) and
|
|
7
|
+
* `@gaunt-sloth/batch`'s eval judge. Review's rating step is deliberately not one of them — it
|
|
8
|
+
* reaches its schema through a bound TOOL, which is a different path with different rules.
|
|
9
|
+
*
|
|
10
|
+
* ## The problem it exists to solve
|
|
11
|
+
*
|
|
12
|
+
* A single Zod object normally does two jobs at once — it is converted into the JSON Schema the
|
|
13
|
+
* provider is sent, and it validates the answer that comes back. Those two jobs want **opposite**
|
|
14
|
+
* things from an optional field, and Zod has only one knob for both:
|
|
15
|
+
*
|
|
16
|
+
* - **On the wire**, OpenAI's strict `json_schema` rule is *"`required` must be supplied and must
|
|
17
|
+
* include every key in `properties`"*. A `.optional()` field is left out of `required`, and the
|
|
18
|
+
* OpenAI API rejects the whole request with `400 Invalid schema for response_format`. Optionality
|
|
19
|
+
* there is spelled as a **nullable type on a required key**, not as an absent key.
|
|
20
|
+
* - **On the way back**, providers do not agree. Some (ChatGroq) rewrite the schema themselves so
|
|
21
|
+
* every property is required-and-nullable, and their models answer `null`. Others (Anthropic,
|
|
22
|
+
* Google GenAI, Ollama) leave the field genuinely optional and their models may simply omit it.
|
|
23
|
+
* Zod's `.optional()` admits `undefined` and **not** `null`, so the first group's answer is
|
|
24
|
+
* rejected by the very schema that asked for it — and the caller sees a parse failure that looks
|
|
25
|
+
* like a bad model rather than a self-contradicting request.
|
|
26
|
+
*
|
|
27
|
+
* ## The shape that satisfies both
|
|
28
|
+
*
|
|
29
|
+
* For every field the caller declared `.optional()`, the boundary sends
|
|
30
|
+
* `inner.nullable().prefault(null)` instead. That one node is the wire/validation twin:
|
|
31
|
+
*
|
|
32
|
+
* - **Wire** — `prefault` does not change the parsed *output* type, so the key lands in `required`
|
|
33
|
+
* and its type is `["string","null"]` / `anyOf: [T, null]`. Strict mode is satisfied, and the
|
|
34
|
+
* model is given a legal way to say "nothing here". Unlike `.default()`, `prefault` emits **no
|
|
35
|
+
* `default` keyword** into the JSON Schema, so nothing extra is added to what the provider sees.
|
|
36
|
+
* - **Validation** — the same node accepts the value, accepts `null`, and accepts the key being
|
|
37
|
+
* **missing** (which is what `prefault` supplies the `null` for). All three arms are needed: the
|
|
38
|
+
* third is what keeps the providers that do *not* hoist working.
|
|
39
|
+
*
|
|
40
|
+
* The `null` never escapes: {@link StructuredOutputBoundary.safeParse} strips it back to the key
|
|
41
|
+
* being **absent** and then validates with the caller's **original** schema, so the parsed type is
|
|
42
|
+
* exactly what the caller declared — an optional string stays `string | undefined` and never
|
|
43
|
+
* becomes `string | null | undefined`.
|
|
44
|
+
*
|
|
45
|
+
* ## Two properties that must not be lost in a "simplification"
|
|
46
|
+
*
|
|
47
|
+
* - **Every `.describe()` survives into the emitted JSON Schema.** The descriptions are the only
|
|
48
|
+
* place the model is told what the fields mean. Expressing the null-to-absent step with
|
|
49
|
+
* `.transform()` on the field is the obvious-looking alternative and it costs the field its
|
|
50
|
+
* description — worse, the conversion OpenAI's path uses refuses to represent a transform at all.
|
|
51
|
+
* Normalization therefore happens in **code**, after the parse, never in the schema.
|
|
52
|
+
* - **A genuinely malformed answer still fails.** This boundary removes a *false* parse failure; it
|
|
53
|
+
* is not a blanket "accept anything". A wrong type in an optional field is still rejected, because
|
|
54
|
+
* the final validation is the caller's own untouched schema. In particular `.catch()` must not be
|
|
55
|
+
* used to express any of this — it would swallow real failures.
|
|
56
|
+
*
|
|
57
|
+
* ## Coverage, and the deliberate limits
|
|
58
|
+
*
|
|
59
|
+
* The rewrite descends through objects, arrays, tuples, records and the single-child wrappers
|
|
60
|
+
* (`nullable`, `readonly`, `default`, `prefault`, `nonoptional`), so an optional nested inside an
|
|
61
|
+
* object inside an array is handled.
|
|
62
|
+
*
|
|
63
|
+
* It deliberately stops at **unions** (including discriminated unions), **intersections**, `lazy`,
|
|
64
|
+
* `map`, `set`, `pipe`/`transform` and `custom`, leaving those subtrees exactly as the caller wrote
|
|
65
|
+
* them, and it leaves a **recursive** schema alone in its entirety. The reason is one rule: the
|
|
66
|
+
* rewrite and the normalization must cover **precisely the same set**. At a union the incoming value
|
|
67
|
+
* gives no reliable answer to *which branch was taken*, so a `null` could not be stripped back out;
|
|
68
|
+
* rewriting there while being unable to normalize would manufacture the very parse failure this
|
|
69
|
+
* module removes. Recursion is refused for the neighbouring reason — a rewrite that stopped at the
|
|
70
|
+
* cycle would make a key required at one depth and optional at the next, which satisfies no
|
|
71
|
+
* provider's strict rule and is harder to reason about than the caller's own schema.
|
|
72
|
+
*
|
|
73
|
+
* An optional inside one of those constructs keeps today's behaviour — correct everywhere it is
|
|
74
|
+
* correct today, and still rejected by OpenAI's strict rule, which is a visible error rather than a
|
|
75
|
+
* silent one.
|
|
76
|
+
*/
|
|
77
|
+
import * as z from 'zod';
|
|
78
|
+
/**
|
|
79
|
+
* A normalizer's answer for "this key must not be present at all" — distinct from `undefined`,
|
|
80
|
+
* because an object key explicitly set to `undefined` is still an own property and `Object.hasOwn`
|
|
81
|
+
* would report it. Callers must not have to learn a second spelling of "absent".
|
|
82
|
+
*/
|
|
83
|
+
const ABSENT = Symbol('structured-output-absent');
|
|
84
|
+
function defOf(schema) {
|
|
85
|
+
return schema._zod.def;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Rebuild `schema` with part of its definition replaced, keeping everything else — the checks
|
|
89
|
+
* (`minItems`, `minimum`, …) and the registered `.describe()` metadata. Built from Zod's own clone
|
|
90
|
+
* rather than by calling `z.object(...)` / `z.array(...)` afresh, because re-constructing would
|
|
91
|
+
* silently drop those constraints from the schema the provider is sent.
|
|
92
|
+
*
|
|
93
|
+
* The metadata is copied through the registry rather than by cloning with Zod's `parent` option.
|
|
94
|
+
* A parent link is how Zod represents "the same schema, re-described", and its JSON-Schema emitter
|
|
95
|
+
* honours that by emitting a **`$ref` to the parent** with the differences as sibling keys. For a
|
|
96
|
+
* rewritten object that is actively wrong: the `$ref` would point at a definition still carrying the
|
|
97
|
+
* ORIGINAL `required` list — the one missing exactly the optional key this module exists to hoist —
|
|
98
|
+
* and `$ref`-with-siblings is not accepted by every provider's strict mode. Copying the metadata
|
|
99
|
+
* leaves the clone an independent schema, which is what it actually is.
|
|
100
|
+
*/
|
|
101
|
+
function cloneWith(schema, patch) {
|
|
102
|
+
const next = { ...defOf(schema), ...patch };
|
|
103
|
+
const cloned = z.core.clone(schema, next);
|
|
104
|
+
const meta = z.globalRegistry.get(schema);
|
|
105
|
+
if (meta)
|
|
106
|
+
z.globalRegistry.add(cloned, meta);
|
|
107
|
+
return cloned;
|
|
108
|
+
}
|
|
109
|
+
function isRecord(value) {
|
|
110
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* `.optional()` → `inner.nullable().prefault(null)`, plus the normalizer that puts it back.
|
|
114
|
+
*
|
|
115
|
+
* The description is re-stated on the nullable wrapper so it lands at **field level** in the emitted
|
|
116
|
+
* JSON Schema whichever way the caller spelled it (`z.string().describe(D).optional()` carries it on
|
|
117
|
+
* the inner type, `z.string().optional().describe(D)` on the wrapper).
|
|
118
|
+
*
|
|
119
|
+
* `null` is only stripped where the caller's own declaration gives it no meaning. A field written
|
|
120
|
+
* `z.string().nullable().optional()` asked for `null` to be a value in its own right, so it keeps
|
|
121
|
+
* it; only a plain `.optional()`, for which `null` was never a legal answer and can only have come
|
|
122
|
+
* from the required-and-nullable rewrite, collapses to the key being absent.
|
|
123
|
+
*/
|
|
124
|
+
function walkOptional(schema, def) {
|
|
125
|
+
const inner = def.innerType;
|
|
126
|
+
const innerWalk = walk(inner);
|
|
127
|
+
const description = schema.description ?? inner.description;
|
|
128
|
+
const nullIsMeaningful = inner.safeParse(null).success;
|
|
129
|
+
// A field that already admits `null` needs no second nullable wrapper — one would emit a nested
|
|
130
|
+
// `anyOf` inside an `anyOf` that says nothing the inner one does not.
|
|
131
|
+
let nullable = nullIsMeaningful ? innerWalk.schema : innerWalk.schema.nullable();
|
|
132
|
+
if (description !== undefined)
|
|
133
|
+
nullable = nullable.describe(description);
|
|
134
|
+
const wireSchema = nullable.prefault(null);
|
|
135
|
+
const innerNormalize = innerWalk.normalize;
|
|
136
|
+
const normalize = (value) => {
|
|
137
|
+
if (value === undefined)
|
|
138
|
+
return ABSENT;
|
|
139
|
+
if (value === null)
|
|
140
|
+
return nullIsMeaningful ? null : ABSENT;
|
|
141
|
+
return innerNormalize ? innerNormalize(value) : value;
|
|
142
|
+
};
|
|
143
|
+
return { schema: wireSchema, normalize };
|
|
144
|
+
}
|
|
145
|
+
function walkObject(schema, def) {
|
|
146
|
+
const shape = def.shape ?? {};
|
|
147
|
+
const nextShape = {};
|
|
148
|
+
const normalizers = [];
|
|
149
|
+
let changed = false;
|
|
150
|
+
for (const [key, field] of Object.entries(shape)) {
|
|
151
|
+
const result = walk(field);
|
|
152
|
+
nextShape[key] = result.schema;
|
|
153
|
+
if (result.schema !== field)
|
|
154
|
+
changed = true;
|
|
155
|
+
if (result.normalize)
|
|
156
|
+
normalizers.push([key, result.normalize]);
|
|
157
|
+
}
|
|
158
|
+
if (!changed && normalizers.length === 0)
|
|
159
|
+
return { schema };
|
|
160
|
+
const normalize = (value) => {
|
|
161
|
+
if (!isRecord(value))
|
|
162
|
+
return value;
|
|
163
|
+
const out = { ...value };
|
|
164
|
+
for (const [key, normalizeField] of normalizers) {
|
|
165
|
+
if (!Object.hasOwn(out, key))
|
|
166
|
+
continue;
|
|
167
|
+
const normalized = normalizeField(out[key]);
|
|
168
|
+
if (normalized === ABSENT)
|
|
169
|
+
delete out[key];
|
|
170
|
+
else
|
|
171
|
+
out[key] = normalized;
|
|
172
|
+
}
|
|
173
|
+
return out;
|
|
174
|
+
};
|
|
175
|
+
return { schema: changed ? cloneWith(schema, { shape: nextShape }) : schema, normalize };
|
|
176
|
+
}
|
|
177
|
+
function walkArray(schema, def) {
|
|
178
|
+
const element = def.element;
|
|
179
|
+
const result = walk(element);
|
|
180
|
+
if (result.schema === element && !result.normalize)
|
|
181
|
+
return { schema };
|
|
182
|
+
const normalizeElement = result.normalize;
|
|
183
|
+
const normalize = normalizeElement
|
|
184
|
+
? (value) => {
|
|
185
|
+
if (!Array.isArray(value))
|
|
186
|
+
return value;
|
|
187
|
+
return value.map((item) => {
|
|
188
|
+
const normalized = normalizeElement(item);
|
|
189
|
+
// An element position has no key to remove, so "absent" degrades to `undefined` — which
|
|
190
|
+
// is what an optional element schema accepts anyway.
|
|
191
|
+
return normalized === ABSENT ? undefined : normalized;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
: undefined;
|
|
195
|
+
return {
|
|
196
|
+
schema: result.schema === element ? schema : cloneWith(schema, { element: result.schema }),
|
|
197
|
+
normalize,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function walkTuple(schema, def) {
|
|
201
|
+
const items = def.items ?? [];
|
|
202
|
+
const rest = def.rest ?? null;
|
|
203
|
+
const itemResults = items.map((item) => walk(item));
|
|
204
|
+
const restResult = rest ? walk(rest) : undefined;
|
|
205
|
+
const changed = itemResults.some((result, index) => result.schema !== items[index]) ||
|
|
206
|
+
(restResult !== undefined && rest !== null && restResult.schema !== rest);
|
|
207
|
+
const needsNormalize = itemResults.some((result) => result.normalize) || restResult?.normalize !== undefined;
|
|
208
|
+
if (!changed && !needsNormalize)
|
|
209
|
+
return { schema };
|
|
210
|
+
const normalize = needsNormalize
|
|
211
|
+
? (value) => {
|
|
212
|
+
if (!Array.isArray(value))
|
|
213
|
+
return value;
|
|
214
|
+
return value.map((item, index) => {
|
|
215
|
+
// Gate on POSITION: a prefix item is normalized by its own item schema and never by the
|
|
216
|
+
// rest schema, which describes a different position entirely.
|
|
217
|
+
const normalizeItem = index < items.length ? itemResults[index]?.normalize : restResult?.normalize;
|
|
218
|
+
if (!normalizeItem)
|
|
219
|
+
return item;
|
|
220
|
+
const normalized = normalizeItem(item);
|
|
221
|
+
return normalized === ABSENT ? undefined : normalized;
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
: undefined;
|
|
225
|
+
return {
|
|
226
|
+
schema: changed
|
|
227
|
+
? cloneWith(schema, {
|
|
228
|
+
items: itemResults.map((result) => result.schema),
|
|
229
|
+
rest: restResult ? restResult.schema : rest,
|
|
230
|
+
})
|
|
231
|
+
: schema,
|
|
232
|
+
normalize,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function walkRecord(schema, def) {
|
|
236
|
+
const valueType = def.valueType;
|
|
237
|
+
const result = walk(valueType);
|
|
238
|
+
if (result.schema === valueType && !result.normalize)
|
|
239
|
+
return { schema };
|
|
240
|
+
const normalizeValue = result.normalize;
|
|
241
|
+
const normalize = normalizeValue
|
|
242
|
+
? (value) => {
|
|
243
|
+
if (!isRecord(value))
|
|
244
|
+
return value;
|
|
245
|
+
const out = {};
|
|
246
|
+
for (const [key, item] of Object.entries(value)) {
|
|
247
|
+
const normalized = normalizeValue(item);
|
|
248
|
+
if (normalized !== ABSENT)
|
|
249
|
+
out[key] = normalized;
|
|
250
|
+
}
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
253
|
+
: undefined;
|
|
254
|
+
return {
|
|
255
|
+
schema: result.schema === valueType ? schema : cloneWith(schema, { valueType: result.schema }),
|
|
256
|
+
normalize,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The single-child wrappers: `nullable`, `readonly`, `default`, `prefault`, `nonoptional`.
|
|
261
|
+
*
|
|
262
|
+
* A wrapper is **transparent to optionality**. `z.string().optional().default('foo')` is still sent
|
|
263
|
+
* as a required key typed `anyOf: [T, null]`, so a `null` arriving here is the wire's "nothing here"
|
|
264
|
+
* and must reach the inner normalizer that knows how to remove it. Passing every `null` straight
|
|
265
|
+
* through instead would advertise `null` to the provider and then reject the one it sends — the same
|
|
266
|
+
* self-contradiction this module exists to remove, one wrapper deep. What "absent" then means is the
|
|
267
|
+
* caller's own business, because the final validation is the caller's untouched schema: under
|
|
268
|
+
* `.default('foo')` it resolves to `'foo'`, under `.readonly()` the key simply stays absent.
|
|
269
|
+
*
|
|
270
|
+
* The exception is a wrapper that makes `null` a value in its own right — the caller wrote
|
|
271
|
+
* `.nullable()` **outside** the optional. That is the question {@link walkOptional} asks of its own
|
|
272
|
+
* inner type, asked one level up, and it is what keeps the two spellings of nullable-and-optional
|
|
273
|
+
* from disagreeing about the same field.
|
|
274
|
+
*
|
|
275
|
+
* `undefined` is passed through rather than being given a second meaning here: the wire never
|
|
276
|
+
* produces one (`prefault` supplies `null` for a missing key), and a genuinely missing object key
|
|
277
|
+
* never reaches a field normalizer at all — {@link walkObject} skips it.
|
|
278
|
+
*/
|
|
279
|
+
function walkWrapper(schema, def) {
|
|
280
|
+
const inner = def.innerType;
|
|
281
|
+
const result = walk(inner);
|
|
282
|
+
if (result.schema === inner && !result.normalize)
|
|
283
|
+
return { schema };
|
|
284
|
+
const innerNormalize = result.normalize;
|
|
285
|
+
const nullIsMeaningful = innerNormalize !== undefined && schema.safeParse(null).success;
|
|
286
|
+
const normalize = innerNormalize
|
|
287
|
+
? (value) => {
|
|
288
|
+
if (value === undefined)
|
|
289
|
+
return value;
|
|
290
|
+
if (value === null && nullIsMeaningful)
|
|
291
|
+
return null;
|
|
292
|
+
return innerNormalize(value);
|
|
293
|
+
}
|
|
294
|
+
: undefined;
|
|
295
|
+
return {
|
|
296
|
+
schema: result.schema === inner ? schema : cloneWith(schema, { innerType: result.schema }),
|
|
297
|
+
normalize,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Thrown when the walk re-enters a schema it is already inside, i.e. the caller's schema is
|
|
302
|
+
* recursive. Caught in {@link structuredOutputBoundary}, which then leaves the whole schema alone —
|
|
303
|
+
* see the module doc's limits.
|
|
304
|
+
*/
|
|
305
|
+
const CYCLIC = Symbol('structured-output-cyclic');
|
|
306
|
+
/** The schemas the current walk is inside. A node reached twice on one path is a cycle. */
|
|
307
|
+
const inProgress = new WeakSet();
|
|
308
|
+
/**
|
|
309
|
+
* Rewrite one node. Every branch here has a matching arm in the normalizer it returns — the two
|
|
310
|
+
* halves are produced by the **same** walk precisely so their coverage cannot drift apart. Anything
|
|
311
|
+
* not listed is returned untouched, with no normalizer.
|
|
312
|
+
*
|
|
313
|
+
* A **recursive** schema aborts the whole walk rather than being partly rewritten. Zod spells
|
|
314
|
+
* recursion as a getter in an object's shape, which reads as an ordinary `object` here and would
|
|
315
|
+
* otherwise descend for ever. Rewriting only the levels reached before the cycle would put an
|
|
316
|
+
* optional key in `required` at one depth and leave it out at the next — an inconsistency that
|
|
317
|
+
* satisfies no provider's strict rule while making the emitted schema harder to reason about than
|
|
318
|
+
* the caller's own.
|
|
319
|
+
*/
|
|
320
|
+
function walk(schema) {
|
|
321
|
+
if (inProgress.has(schema))
|
|
322
|
+
throw CYCLIC;
|
|
323
|
+
inProgress.add(schema);
|
|
324
|
+
try {
|
|
325
|
+
return walkNode(schema);
|
|
326
|
+
}
|
|
327
|
+
finally {
|
|
328
|
+
inProgress.delete(schema);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
function walkNode(schema) {
|
|
332
|
+
const def = defOf(schema);
|
|
333
|
+
switch (def.type) {
|
|
334
|
+
case 'optional':
|
|
335
|
+
return walkOptional(schema, def);
|
|
336
|
+
case 'object':
|
|
337
|
+
return walkObject(schema, def);
|
|
338
|
+
case 'array':
|
|
339
|
+
return walkArray(schema, def);
|
|
340
|
+
case 'tuple':
|
|
341
|
+
return walkTuple(schema, def);
|
|
342
|
+
case 'record':
|
|
343
|
+
return walkRecord(schema, def);
|
|
344
|
+
case 'nullable':
|
|
345
|
+
case 'readonly':
|
|
346
|
+
case 'default':
|
|
347
|
+
case 'prefault':
|
|
348
|
+
case 'nonoptional':
|
|
349
|
+
return walkWrapper(schema, def);
|
|
350
|
+
default:
|
|
351
|
+
return { schema };
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Memoized per schema instance. Repeated calls with the same schema — the common case, since call
|
|
356
|
+
* sites hold a module-level schema constant — return the same `wireSchema` reference, which is what
|
|
357
|
+
* LangChain's own JSON-Schema conversion cache is keyed on.
|
|
358
|
+
*/
|
|
359
|
+
const boundaries = new WeakMap();
|
|
360
|
+
/**
|
|
361
|
+
* Build the {@link StructuredOutputBoundary} for a schema — the one entry point every
|
|
362
|
+
* `withStructuredOutput` call in this project goes through. See the module doc for what it does and
|
|
363
|
+
* why.
|
|
364
|
+
*
|
|
365
|
+
* @param schema The caller's schema, used unchanged for the final validation.
|
|
366
|
+
*/
|
|
367
|
+
export function structuredOutputBoundary(schema) {
|
|
368
|
+
const cached = boundaries.get(schema);
|
|
369
|
+
if (cached)
|
|
370
|
+
return cached;
|
|
371
|
+
let walked;
|
|
372
|
+
try {
|
|
373
|
+
walked = walk(schema);
|
|
374
|
+
}
|
|
375
|
+
catch (error) {
|
|
376
|
+
// A recursive schema is left exactly as the caller wrote it — the same answer this module gives
|
|
377
|
+
// for a union, and for the same reason: it will not rewrite what it cannot also normalize.
|
|
378
|
+
if (error !== CYCLIC)
|
|
379
|
+
throw error;
|
|
380
|
+
walked = { schema: schema };
|
|
381
|
+
}
|
|
382
|
+
const normalize = walked.normalize;
|
|
383
|
+
const boundary = {
|
|
384
|
+
wireSchema: walked.schema,
|
|
385
|
+
safeParse(raw) {
|
|
386
|
+
const normalized = normalize ? normalize(raw) : raw;
|
|
387
|
+
return schema.safeParse(normalized === ABSENT ? undefined : normalized);
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
boundaries.set(schema, boundary);
|
|
391
|
+
return boundary;
|
|
392
|
+
}
|
|
393
|
+
//# sourceMappingURL=structuredOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structuredOutput.js","sourceRoot":"","sources":["../../src/runtime/structuredOutput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AAEH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAKzB;;;;GAIG;AACH,MAAM,MAAM,GAAG,MAAM,CAAC,0BAA0B,CAAC,CAAC;AA0BlD,SAAS,KAAK,CAAC,MAAiB;IAC9B,OAAQ,MAAkD,CAAC,IAAI,CAAC,GAAG,CAAC;AACtE,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAS,SAAS,CAAC,MAAiB,EAAE,KAAyB;IAC7D,MAAM,IAAI,GAAG,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAC5C,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,CA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E,QAA6C,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,7 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A dot-per-second terminal progress indicator.
|
|
3
|
+
*
|
|
4
|
+
* **EXT-53 — always stop it, on every exit path.** In its automatic (non-`manual`) mode the
|
|
5
|
+
* indicator owns a 1s `setInterval`, which is an *active libuv handle*: while it is alive Node's
|
|
6
|
+
* event loop can never drain and the process cannot exit, no matter that every await has resolved.
|
|
7
|
+
* A `stop()` that is only reachable on the success path therefore turns any error into a hang
|
|
8
|
+
* rather than an exit. Construct the indicator OUTSIDE the `try` and clear it in a `finally`.
|
|
9
|
+
*
|
|
10
|
+
* `stop()` is idempotent (see below), so a `finally { indicator.stop() }` is always safe to add
|
|
11
|
+
* even where a success-path `stop()` already ran.
|
|
12
|
+
*/
|
|
1
13
|
export declare class ProgressIndicator {
|
|
2
14
|
private interval;
|
|
15
|
+
private readonly manual;
|
|
16
|
+
private stopped;
|
|
3
17
|
constructor(initialMessage: string, manual?: boolean);
|
|
4
18
|
private indicateInner;
|
|
5
19
|
indicate(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Clear the interval (releasing the libuv handle) and terminate the dot line with a newline.
|
|
22
|
+
*
|
|
23
|
+
* Idempotent: the handle is nulled and a second call is a complete no-op, so it emits no stray
|
|
24
|
+
* blank line. That is what makes it safe to call from a `finally` on top of an existing
|
|
25
|
+
* success-path `stop()`.
|
|
26
|
+
*/
|
|
6
27
|
stop(): void;
|
|
7
28
|
}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { stdout } from '#src/utils/systemUtils.js';
|
|
2
|
+
/**
|
|
3
|
+
* A dot-per-second terminal progress indicator.
|
|
4
|
+
*
|
|
5
|
+
* **EXT-53 — always stop it, on every exit path.** In its automatic (non-`manual`) mode the
|
|
6
|
+
* indicator owns a 1s `setInterval`, which is an *active libuv handle*: while it is alive Node's
|
|
7
|
+
* event loop can never drain and the process cannot exit, no matter that every await has resolved.
|
|
8
|
+
* A `stop()` that is only reachable on the success path therefore turns any error into a hang
|
|
9
|
+
* rather than an exit. Construct the indicator OUTSIDE the `try` and clear it in a `finally`.
|
|
10
|
+
*
|
|
11
|
+
* `stop()` is idempotent (see below), so a `finally { indicator.stop() }` is always safe to add
|
|
12
|
+
* even where a success-path `stop()` already ran.
|
|
13
|
+
*/
|
|
2
14
|
export class ProgressIndicator {
|
|
3
15
|
interval = undefined;
|
|
16
|
+
manual;
|
|
17
|
+
stopped = false;
|
|
4
18
|
constructor(initialMessage, manual) {
|
|
19
|
+
this.manual = !!manual;
|
|
5
20
|
stdout.write(initialMessage);
|
|
6
|
-
if (!manual) {
|
|
21
|
+
if (!this.manual) {
|
|
7
22
|
this.interval = setInterval(this.indicateInner, 1000);
|
|
8
23
|
}
|
|
9
24
|
}
|
|
@@ -11,14 +26,26 @@ export class ProgressIndicator {
|
|
|
11
26
|
stdout.write('.');
|
|
12
27
|
}
|
|
13
28
|
indicate() {
|
|
14
|
-
if (this.
|
|
29
|
+
if (!this.manual) {
|
|
15
30
|
throw new Error('ProgressIndicator.indicate only to be called in manual mode');
|
|
16
31
|
}
|
|
17
32
|
this.indicateInner();
|
|
18
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Clear the interval (releasing the libuv handle) and terminate the dot line with a newline.
|
|
36
|
+
*
|
|
37
|
+
* Idempotent: the handle is nulled and a second call is a complete no-op, so it emits no stray
|
|
38
|
+
* blank line. That is what makes it safe to call from a `finally` on top of an existing
|
|
39
|
+
* success-path `stop()`.
|
|
40
|
+
*/
|
|
19
41
|
stop() {
|
|
20
|
-
if (this.
|
|
42
|
+
if (this.stopped) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.stopped = true;
|
|
46
|
+
if (this.interval !== undefined) {
|
|
21
47
|
clearInterval(this.interval);
|
|
48
|
+
this.interval = undefined;
|
|
22
49
|
}
|
|
23
50
|
stdout.write('\n');
|
|
24
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressIndicator.js","sourceRoot":"","sources":["../../src/utils/ProgressIndicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD,MAAM,OAAO,iBAAiB;IACpB,QAAQ,GAAuB,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ProgressIndicator.js","sourceRoot":"","sources":["../../src/utils/ProgressIndicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,iBAAiB;IACpB,QAAQ,GAAuB,SAAS,CAAC;IAChC,MAAM,CAAU;IACzB,OAAO,GAAG,KAAK,CAAC;IAExB,YAAY,cAAsB,EAAE,MAAgB;QAClD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QACvB,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAsB,CAAC;QAC7E,CAAC;IACH,CAAC;IAEO,aAAa;QACnB,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;QACjF,CAAC;QACD,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;IACH,IAAI;QACF,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,aAAa,C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,EAAE,SAAS,CAAC,CAAC;QAC7D,IAAI,CAAC;YACH,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;YACjE,MAAM,WAAW,GAAG,+BAA+B,WAAW,CAAC,QAAQ,OAAO,QAAQ,GAAG,CAAC;YAC1F,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YACnD,eAAe,CAAC,IAAI,CAAC,uBAAuB,WAAW,CAAC,QAAQ,QAAQ,QAAQ,EAAE,CAAC,CAAC;QACtF,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,gBAAgB,GAAG,kCAAkC,WAAW,CAAC,QAAQ,GAAG,CAAC;YACnF,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,OAAO;QACL,eAAe,EAAE,sBAAsB,CAAC,OAAO,EAAE,cAAc,CAAC;QAChE,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
import { StatusLevel, StatusUpdateCallback } from '#src/core/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* ANSI color codes — the 16-colour slots only, deliberately. A 16-colour slot is rendered with the
|
|
4
|
+
* user's OWN terminal theme colour, so output looks native in light and dark schemes alike; a
|
|
5
|
+
* 256-colour or 24-bit escape would pin us to one palette and clash with half of them.
|
|
6
|
+
*
|
|
7
|
+
* Exported so the surfaces that build their own pre-styled blocks (rather than passing a whole
|
|
8
|
+
* message through {@link colorText}) still draw from this one table — see
|
|
9
|
+
* `core/launchBanner.ts`, which paints only the face half of each banner row.
|
|
10
|
+
*
|
|
11
|
+
* `as const` because `packages/core` publishes `"./*.js": "./dist/*.js"`, so this is PUBLIC API of a
|
|
12
|
+
* published package: without it any consumer could assign `ANSI_COLORS.magenta` and repaint the
|
|
13
|
+
* whole CLI from the outside. Read-only, one table, no remote control.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ANSI_COLORS: {
|
|
16
|
+
readonly red: '\u001B[31m';
|
|
17
|
+
readonly yellow: '\u001B[33m';
|
|
18
|
+
readonly green: '\u001B[32m';
|
|
19
|
+
readonly magenta: '\u001B[35m';
|
|
20
|
+
readonly dim: '\u001B[2m';
|
|
21
|
+
readonly reset: '\u001B[0m';
|
|
22
|
+
};
|
|
2
23
|
export declare const initSessionLogging: (logFileName: string, enableLogging: boolean) => void;
|
|
3
24
|
/**
|
|
4
25
|
* Set the console logging level.
|
|
@@ -18,11 +39,85 @@ export declare const resetConsoleLevel: () => void;
|
|
|
18
39
|
export declare const flushSessionLog: () => void;
|
|
19
40
|
export declare const stopSessionLogging: () => void;
|
|
20
41
|
export declare function displayError(message: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Open a warning-capture window: from now until {@link endWarningCapture}, each
|
|
44
|
+
* `displayWarning` message is buffered (IN ADDITION to being printed/logged as usual). Used by
|
|
45
|
+
* the TUI session module to grab the transient load-time config advisories and thread them into
|
|
46
|
+
* the persistent notice surface. Idempotent-ish: a second call starts a fresh buffer.
|
|
47
|
+
*/
|
|
48
|
+
export declare const beginWarningCapture: () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Close the warning-capture window opened by {@link beginWarningCapture} and return everything
|
|
51
|
+
* collected (empty array if none / never opened). Always call this — a `try/finally` around the
|
|
52
|
+
* captured work — so a throw can't leak the capture state into later warnings.
|
|
53
|
+
*/
|
|
54
|
+
export declare const endWarningCapture: () => string[];
|
|
21
55
|
export declare function displayWarning(message: string): void;
|
|
22
56
|
export declare function displaySuccess(message: string): void;
|
|
23
57
|
export declare function displayInfo(message: string): void;
|
|
24
58
|
export declare function display(message: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* TUI-C30 — print one pre-styled tool-call indication block (the plain surface's compact
|
|
61
|
+
* `✓ name(args…)` + greyed preview, built by `core/plainToolIndication.ts`). Same INFO-level
|
|
62
|
+
* gate, stdout channel and session-log treatment as {@link displayInfo} — matching the stream
|
|
63
|
+
* discipline of the existing tool notices — but WITHOUT the blanket dim wrap: the block styles
|
|
64
|
+
* each line itself (diff colours, per-line dim), and an outer wrapper would be broken by the
|
|
65
|
+
* inner resets. The session log gets the ANSI-stripped text via {@link writeToSessionLog}.
|
|
66
|
+
*/
|
|
67
|
+
export declare function displayToolIndication(message: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* TUI-C33 — print the interactive-launch banner (the pre-styled block built by
|
|
70
|
+
* `core/launchBanner.ts`) on the plain surface. Same DISPLAY-level gate and stdout channel as
|
|
71
|
+
* {@link display}, so a quieted console silences it too, but deliberately NOT routed through
|
|
72
|
+
* {@link writeToSessionLog}: the session log is a transcript of the conversation, not a screenshot
|
|
73
|
+
* of the screen, and a five-row sloth at the top of it is noise. The block also styles itself (the
|
|
74
|
+
* face half of each row carries the colour), so no outer wrap is applied.
|
|
75
|
+
*/
|
|
76
|
+
export declare function displayLaunchBanner(message: string): void;
|
|
25
77
|
export declare function formatInputPrompt(message: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* How loud one line of an interactive dialog is — its COLOUR, and nothing else.
|
|
80
|
+
*
|
|
81
|
+
* The other `display*` helpers bind a colour to a stream: picking red means picking stdout, picking
|
|
82
|
+
* yellow means picking stderr. A dialog needs both halves independently, so this names the half that
|
|
83
|
+
* is about appearance and leaves the stream to {@link displayDialogLine}, which always chooses the
|
|
84
|
+
* same one.
|
|
85
|
+
*
|
|
86
|
+
* `notice`/`warn`/`danger` are the three tones `core/shell/escalationSeverity` grades an escalation
|
|
87
|
+
* with, so a surface can pass a rater outcome's tone straight through; `plain` is text with no
|
|
88
|
+
* severity (the framed command, a blank spacer) and `prompt` is the line the human types their
|
|
89
|
+
* answer after.
|
|
90
|
+
*/
|
|
91
|
+
export type DialogTone = 'plain' | 'notice' | 'warn' | 'danger' | 'prompt';
|
|
92
|
+
/**
|
|
93
|
+
* Print one line of an interactive dialog — an approval prompt, an attack banner — **on stderr**.
|
|
94
|
+
*
|
|
95
|
+
* ## One dialog, one stream
|
|
96
|
+
*
|
|
97
|
+
* A dialog's meaning is carried by the ORDER of its lines: a heading, then whose words the next
|
|
98
|
+
* lines are, then the words. Two streams cannot promise an order. Only writes to the *same* stream
|
|
99
|
+
* are delivered in the order they were made — across stdout and stderr nothing is promised, and the
|
|
100
|
+
* difference is observable the moment the two go to different places: with stdout a pipe or a file
|
|
101
|
+
* it is block-buffered while stderr is not, so a captured run can carry a rater's answer above the
|
|
102
|
+
* command it answers. A security dialog whose line order holds only on a terminal is not a gate, so
|
|
103
|
+
* every line of one goes through here and through nothing else.
|
|
104
|
+
*
|
|
105
|
+
* **stderr, because a prompt is not program output.** It is the conventional home for interaction,
|
|
106
|
+
* it is not block-buffered, and it leaves stdout carrying only what the run produced. The cost is
|
|
107
|
+
* real and is documented for users: piping stdout (`gth code --no-tui | tee log`) no longer captures
|
|
108
|
+
* the dialog — the terminal still shows it, `2>` still collects it, and an enabled session log still
|
|
109
|
+
* records it. The log write here is UNCONDITIONAL, which the gated helpers' is not: theirs sits
|
|
110
|
+
* behind the level guard, so a quieted console drops those lines from the transcript as well as
|
|
111
|
+
* from the screen. A dialog stays whole in both places.
|
|
112
|
+
*
|
|
113
|
+
* ## Not level-gated, on purpose
|
|
114
|
+
*
|
|
115
|
+
* The dialog is a QUESTION, not a status message, and the level filter is per line: gated, a quieted
|
|
116
|
+
* console prints the parts above its threshold and drops the rest, which is how an approval prompt
|
|
117
|
+
* comes to show a severity heading with no command under it. Half a dialog is worse than none,
|
|
118
|
+
* because it still looks like a whole one.
|
|
119
|
+
*/
|
|
120
|
+
export declare function displayDialogLine(message: string, tone?: DialogTone): void;
|
|
26
121
|
/**
|
|
27
122
|
* Display a debug message to the console and log it.
|
|
28
123
|
* This function also integrates with debugUtils to output logs when at debug level.
|