@fgv/ts-extras 5.1.0-45 → 5.1.0-46
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/dist/packlets/ai-assist/index.js +1 -1
- package/dist/packlets/ai-assist/index.js.map +1 -1
- package/dist/packlets/ai-assist/jsonResponse.js +270 -7
- package/dist/packlets/ai-assist/jsonResponse.js.map +1 -1
- package/dist/packlets/ai-assist/model.js +14 -0
- package/dist/packlets/ai-assist/model.js.map +1 -1
- package/dist/packlets/ai-assist/registry.js +57 -14
- package/dist/packlets/ai-assist/registry.js.map +1 -1
- package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js +65 -7
- package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js.map +1 -1
- package/dist/packlets/zip-file-tree/zipFileTreeWriter.js +16 -1
- package/dist/packlets/zip-file-tree/zipFileTreeWriter.js.map +1 -1
- package/dist/ts-extras.d.ts +253 -13
- package/lib/packlets/ai-assist/index.d.ts +1 -1
- package/lib/packlets/ai-assist/index.d.ts.map +1 -1
- package/lib/packlets/ai-assist/index.js +3 -2
- package/lib/packlets/ai-assist/index.js.map +1 -1
- package/lib/packlets/ai-assist/jsonResponse.d.ts +96 -0
- package/lib/packlets/ai-assist/jsonResponse.d.ts.map +1 -1
- package/lib/packlets/ai-assist/jsonResponse.js +271 -7
- package/lib/packlets/ai-assist/jsonResponse.js.map +1 -1
- package/lib/packlets/ai-assist/model.d.ts +43 -0
- package/lib/packlets/ai-assist/model.d.ts.map +1 -1
- package/lib/packlets/ai-assist/model.js +14 -0
- package/lib/packlets/ai-assist/model.js.map +1 -1
- package/lib/packlets/ai-assist/registry.d.ts +26 -6
- package/lib/packlets/ai-assist/registry.d.ts.map +1 -1
- package/lib/packlets/ai-assist/registry.js +57 -14
- package/lib/packlets/ai-assist/registry.js.map +1 -1
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts +54 -6
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts.map +1 -1
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js +65 -7
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js.map +1 -1
- package/lib/packlets/zip-file-tree/zipFileTreeWriter.d.ts +26 -1
- package/lib/packlets/zip-file-tree/zipFileTreeWriter.d.ts.map +1 -1
- package/lib/packlets/zip-file-tree/zipFileTreeWriter.js +17 -1
- package/lib/packlets/zip-file-tree/zipFileTreeWriter.js.map +1 -1
- package/package.json +7 -7
package/dist/ts-extras.d.ts
CHANGED
|
@@ -164,10 +164,12 @@ declare namespace AiAssist {
|
|
|
164
164
|
modelSpecKey,
|
|
165
165
|
modelSpec,
|
|
166
166
|
resolveEffectiveTools,
|
|
167
|
+
classifyJsonParseFailure,
|
|
167
168
|
extractJsonText,
|
|
168
169
|
fencedStringifiedJson,
|
|
169
170
|
IFencedStringifiedJsonExtractorOptions,
|
|
170
171
|
IFencedStringifiedJsonOptions,
|
|
172
|
+
JsonParseFailureReason,
|
|
171
173
|
JsonTextExtractor,
|
|
172
174
|
generateJsonCompletion,
|
|
173
175
|
SMART_JSON_PROMPT_HINT,
|
|
@@ -636,6 +638,53 @@ declare function callProxiedImageGeneration(proxyUrl: string, params: IProviderI
|
|
|
636
638
|
*/
|
|
637
639
|
declare function callProxiedListModels(proxyUrl: string, params: IProviderListModelsParams): Promise<Result<ReadonlyArray<IAiModelInfo>>>;
|
|
638
640
|
|
|
641
|
+
/**
|
|
642
|
+
* Classifies why a JSON-shaped LLM response would not parse, returning a
|
|
643
|
+
* {@link AiAssist.JsonParseFailureReason} a caller can branch on — repair the
|
|
644
|
+
* cheap cases, re-prompt the expensive ones, fail outright on the rest —
|
|
645
|
+
* instead of regex-matching an engine-specific `JSON.parse` message.
|
|
646
|
+
*
|
|
647
|
+
* Pass the same raw model text you handed
|
|
648
|
+
* {@link AiAssist.fencedStringifiedJson} or {@link AiAssist.extractJsonText};
|
|
649
|
+
* this applies the same BOM / whitespace / fence / preamble handling before
|
|
650
|
+
* scanning, and reports `offset` against that original text.
|
|
651
|
+
*
|
|
652
|
+
* Classification is **structural and deliberately conservative**. The scan
|
|
653
|
+
* walks the JSON grammar itself rather than reading the engine's error string,
|
|
654
|
+
* so its verdicts are stable across Node versions — and any fault it cannot
|
|
655
|
+
* name with confidence comes back as `'unknown'` rather than a guess. In
|
|
656
|
+
* particular an input that opened a structure and never closed it (the
|
|
657
|
+
* truncated-response shape {@link AiAssist.extractJsonText} already diagnoses)
|
|
658
|
+
* classifies as `'unknown'` here; the two diagnostics are complementary, not
|
|
659
|
+
* competing.
|
|
660
|
+
*
|
|
661
|
+
* This never fails and never repairs — it only names the fault. It is a
|
|
662
|
+
* diagnostic on the failure path, so calling it on text that parses fine is
|
|
663
|
+
* harmless but pointless: it returns `'unknown'`.
|
|
664
|
+
*
|
|
665
|
+
* @example
|
|
666
|
+
* ```ts
|
|
667
|
+
* const parsed = fencedStringifiedJson({ inner }).convert(raw);
|
|
668
|
+
* if (parsed.isFailure()) {
|
|
669
|
+
* const reason = classifyJsonParseFailure(raw);
|
|
670
|
+
* switch (reason.kind) {
|
|
671
|
+
* case 'unquoted-property-name': // cheap to repair
|
|
672
|
+
* case 'single-quoted-property-name':
|
|
673
|
+
* break;
|
|
674
|
+
* case 'elided-member':
|
|
675
|
+
* case 'unterminated-property-name': // worth a re-prompt
|
|
676
|
+
* break;
|
|
677
|
+
* default: // 'unknown' — fail outright
|
|
678
|
+
* }
|
|
679
|
+
* }
|
|
680
|
+
* ```
|
|
681
|
+
*
|
|
682
|
+
* @param text - Raw model output (the same string handed to the extractor).
|
|
683
|
+
* @returns A {@link AiAssist.JsonParseFailureReason}.
|
|
684
|
+
* @public
|
|
685
|
+
*/
|
|
686
|
+
declare function classifyJsonParseFailure(text: string): JsonParseFailureReason;
|
|
687
|
+
|
|
639
688
|
declare namespace Constants {
|
|
640
689
|
export {
|
|
641
690
|
ENCRYPTED_FILE_FORMAT,
|
|
@@ -710,8 +759,22 @@ declare function createEncryptedFile<TMetadata = JsonValue>(params: ICreateEncry
|
|
|
710
759
|
*/
|
|
711
760
|
declare function createEncryptedFileConverter<TMetadata = JsonValue>(metadataConverter?: Converter<TMetadata>): Converter<IEncryptedFile<TMetadata>>;
|
|
712
761
|
|
|
762
|
+
/**
|
|
763
|
+
* Creates a zip file from an array of files whose contents are either text or raw bytes.
|
|
764
|
+
*
|
|
765
|
+
* @remarks
|
|
766
|
+
* String contents are encoded as UTF-8; `Uint8Array` contents are stored verbatim, so
|
|
767
|
+
* arbitrary binary payloads round-trip through the archive unchanged.
|
|
768
|
+
* @public
|
|
769
|
+
*/
|
|
770
|
+
declare function createZipFromFiles(files: ReadonlyArray<IZipFile>, options?: ICreateZipOptions): Result<Uint8Array>;
|
|
771
|
+
|
|
713
772
|
/**
|
|
714
773
|
* Creates a zip file from an array of text files.
|
|
774
|
+
*
|
|
775
|
+
* @remarks
|
|
776
|
+
* Contents are encoded as UTF-8. Use `createZipFromFiles` to write entries whose
|
|
777
|
+
* contents are raw bytes.
|
|
715
778
|
* @public
|
|
716
779
|
*/
|
|
717
780
|
declare function createZipFromTextFiles(files: ReadonlyArray<IZipTextFile>, options?: ICreateZipOptions): Result<Uint8Array>;
|
|
@@ -4923,7 +4986,20 @@ declare interface IYamlSerializeOptions {
|
|
|
4923
4986
|
}
|
|
4924
4987
|
|
|
4925
4988
|
/**
|
|
4926
|
-
*
|
|
4989
|
+
* Interface for a file to be added to a zip file, whose contents are either text or
|
|
4990
|
+
* raw bytes.
|
|
4991
|
+
*
|
|
4992
|
+
* @remarks
|
|
4993
|
+
* String contents are encoded as UTF-8; `Uint8Array` contents are stored verbatim.
|
|
4994
|
+
* @public
|
|
4995
|
+
*/
|
|
4996
|
+
declare interface IZipFile {
|
|
4997
|
+
readonly path: string;
|
|
4998
|
+
readonly contents: string | Uint8Array;
|
|
4999
|
+
}
|
|
5000
|
+
|
|
5001
|
+
/**
|
|
5002
|
+
* Simple interface for a text file to be added to a zip file.
|
|
4927
5003
|
* @public
|
|
4928
5004
|
*/
|
|
4929
5005
|
declare interface IZipTextFile {
|
|
@@ -4951,6 +5027,57 @@ declare interface JarRecordParserOptions {
|
|
|
4951
5027
|
readonly fixedContinuationSize?: number;
|
|
4952
5028
|
}
|
|
4953
5029
|
|
|
5030
|
+
/**
|
|
5031
|
+
* Typed reason a JSON-shaped LLM response failed to parse, so a caller can
|
|
5032
|
+
* branch on the failure class instead of regex-matching the engine's
|
|
5033
|
+
* `JSON.parse` message (whose wording varies across V8 / Node versions).
|
|
5034
|
+
*
|
|
5035
|
+
* Every classified arm describes a fault at an **object property-name
|
|
5036
|
+
* position** — the position an LLM most often gets wrong, and the one whose
|
|
5037
|
+
* repair strategy differs most by case:
|
|
5038
|
+
*
|
|
5039
|
+
* - `'unquoted-property-name'`: a bare identifier where a quoted name belongs
|
|
5040
|
+
* (`{ key: 1 }`). `token` is the identifier run, `offset` its first
|
|
5041
|
+
* character. Identifier recognition is ASCII-only, so a non-ASCII bare name
|
|
5042
|
+
* (`{ ключ: 1 }`) reports `'unknown'` rather than being named.
|
|
5043
|
+
* - `'single-quoted-property-name'`: a single-quoted name (`{ 'key': 1 }`).
|
|
5044
|
+
* `token` is the quoted literal (or just `'` if it never closes), `offset`
|
|
5045
|
+
* the opening quote.
|
|
5046
|
+
* - `'unterminated-property-name'`: a name whose closing `"` is missing, and
|
|
5047
|
+
* whose body swallowed structural text (`{ "key: 1 }`). `token` is the
|
|
5048
|
+
* unterminated fragment, `offset` the opening quote.
|
|
5049
|
+
* - `'elided-member'`: a `,` where a member is expected — a leading or doubled
|
|
5050
|
+
* comma in an object (`{ , "a": 1 }`, `{ "a":1, , "b":2 }`) or an array
|
|
5051
|
+
* (`[1, , 2]`). `token` is `','`, `offset` its position.
|
|
5052
|
+
* - `'unknown'`: the catch-all. The scan reached the end of the text, or hit a
|
|
5053
|
+
* fault it cannot name with confidence, and reports nothing rather than
|
|
5054
|
+
* guessing. Truncated responses, missing colons, trailing commas, bad number
|
|
5055
|
+
* literals, and anything else not listed above land here.
|
|
5056
|
+
*
|
|
5057
|
+
* `offset` is a 0-based index into the `text` passed to
|
|
5058
|
+
* {@link AiAssist.classifyJsonParseFailure}, not into the extracted substring.
|
|
5059
|
+
* @public
|
|
5060
|
+
*/
|
|
5061
|
+
declare type JsonParseFailureReason = {
|
|
5062
|
+
readonly kind: 'unquoted-property-name';
|
|
5063
|
+
readonly token: string;
|
|
5064
|
+
readonly offset: number;
|
|
5065
|
+
} | {
|
|
5066
|
+
readonly kind: 'single-quoted-property-name';
|
|
5067
|
+
readonly token: string;
|
|
5068
|
+
readonly offset: number;
|
|
5069
|
+
} | {
|
|
5070
|
+
readonly kind: 'unterminated-property-name';
|
|
5071
|
+
readonly token: string;
|
|
5072
|
+
readonly offset: number;
|
|
5073
|
+
} | {
|
|
5074
|
+
readonly kind: 'elided-member';
|
|
5075
|
+
readonly token: string;
|
|
5076
|
+
readonly offset: number;
|
|
5077
|
+
} | {
|
|
5078
|
+
readonly kind: 'unknown';
|
|
5079
|
+
};
|
|
5080
|
+
|
|
4954
5081
|
/**
|
|
4955
5082
|
* Controls the optional system-prompt augmentation applied by
|
|
4956
5083
|
* {@link AiAssist.generateJsonCompletion}.
|
|
@@ -5817,6 +5944,35 @@ declare const modelSpec: Converter<ModelSpec>;
|
|
|
5817
5944
|
|
|
5818
5945
|
/**
|
|
5819
5946
|
* Known context keys for model specification maps.
|
|
5947
|
+
*
|
|
5948
|
+
* @remarks
|
|
5949
|
+
* Two axes live here and nothing else: the **quality tier** (`base` / `advanced`
|
|
5950
|
+
* / `frontier`) selects the *completion* model, and `image` / `embedding` select
|
|
5951
|
+
* the non-completion modalities.
|
|
5952
|
+
*
|
|
5953
|
+
* There is deliberately **no `tools` or `thinking` key**. Both existed before the
|
|
5954
|
+
* quality-tier axis landed and were removed with it: server-side tools and
|
|
5955
|
+
* reasoning effort are orthogonal *request* params that ride on top of whatever
|
|
5956
|
+
* model the tier already selected — they never select a model. A tool-using or
|
|
5957
|
+
* thinking-enabled call passes a tier like any other call (omit → `base`, or
|
|
5958
|
+
* `'advanced'` / `'frontier'`) and sets the tools / thinking request params
|
|
5959
|
+
* independently. Thinking composes with any tier without a tier-level capability
|
|
5960
|
+
* check — but that is a statement about the tier axis, not a claim that every
|
|
5961
|
+
* provider supports thinking: several descriptors declare
|
|
5962
|
+
* `thinkingMode: 'unsupported'` (e.g. `copy-paste`, `groq`, `mistral`, `ollama`,
|
|
5963
|
+
* `openai-compat`).
|
|
5964
|
+
*
|
|
5965
|
+
* Thinking availability is declared **per provider**, on the descriptor's
|
|
5966
|
+
* `thinkingMode`; the descriptor does not encode per-model thinking availability at
|
|
5967
|
+
* all, so a provider that declares support may still have individual models its own
|
|
5968
|
+
* API rejects thinking on. (`adaptiveThinkingModelPrefixes` is per-model but selects
|
|
5969
|
+
* a wire *shape*, not availability.) What the tier axis guarantees is therefore
|
|
5970
|
+
* narrow and exact: a tier selects a model within one provider and never changes the
|
|
5971
|
+
* provider, so it never changes `thinkingMode`.
|
|
5972
|
+
*
|
|
5973
|
+
* Do not add a `'tools'` or `'thinking'` key here, and do not hand-roll a
|
|
5974
|
+
* `resolveModel` + `resolveModelAlias` walk to emulate one — call
|
|
5975
|
+
* `resolveProviderModel` with the tier you want.
|
|
5820
5976
|
* @public
|
|
5821
5977
|
*/
|
|
5822
5978
|
declare type ModelSpecKey = 'base' | 'advanced' | 'frontier' | 'image' | 'embedding';
|
|
@@ -6460,10 +6616,20 @@ declare function resolveEffectiveTools(descriptor: IAiProviderDescriptor, settin
|
|
|
6460
6616
|
* `modelPrefix` is the longest prefix of `modelId`. Ties are broken by
|
|
6461
6617
|
* first-encountered.
|
|
6462
6618
|
*
|
|
6619
|
+
* @remarks
|
|
6620
|
+
* `modelId` may be either a concrete provider model id or an fgv model alias
|
|
6621
|
+
* (`@<provider>:<role>`, see `MODEL_ALIAS_SIGIL`) — it is resolved via
|
|
6622
|
+
* `resolveModelAlias` against `descriptor.aliases` before prefix matching,
|
|
6623
|
+
* so both forms select the same capability. A raw provider id passes through
|
|
6624
|
+
* unchanged. An alias that is not registered on `descriptor` (or is cyclic)
|
|
6625
|
+
* names no model and yields `undefined` rather than falling through to the
|
|
6626
|
+
* `modelPrefix: ''` catch-all.
|
|
6627
|
+
*
|
|
6463
6628
|
* @param descriptor - The provider descriptor
|
|
6464
|
-
* @param modelId - The
|
|
6465
|
-
* @returns The matching capability, or `undefined` when no rule matches
|
|
6466
|
-
* provider declares no embedding capabilities
|
|
6629
|
+
* @param modelId - The embedding model id — concrete or an fgv alias
|
|
6630
|
+
* @returns The matching capability, or `undefined` when no rule matches, the
|
|
6631
|
+
* provider declares no embedding capabilities, or `modelId` is an
|
|
6632
|
+
* unresolvable alias.
|
|
6467
6633
|
* @public
|
|
6468
6634
|
*/
|
|
6469
6635
|
declare function resolveEmbeddingCapability(descriptor: IAiProviderDescriptor, modelId: string): IAiEmbeddingModelCapability | undefined;
|
|
@@ -6476,10 +6642,20 @@ declare function resolveEmbeddingCapability(descriptor: IAiProviderDescriptor, m
|
|
|
6476
6642
|
* order does not matter for correctness — only for tie-breaking among rules
|
|
6477
6643
|
* with identical-length prefixes (an unusual case).
|
|
6478
6644
|
*
|
|
6645
|
+
* @remarks
|
|
6646
|
+
* `modelId` may be either a concrete provider model id or an fgv model alias
|
|
6647
|
+
* (`@<provider>:<role>`, see `MODEL_ALIAS_SIGIL`) — it is resolved via
|
|
6648
|
+
* `resolveModelAlias` against `descriptor.aliases` before prefix matching,
|
|
6649
|
+
* so both forms select the same capability. A raw provider id passes through
|
|
6650
|
+
* unchanged. An alias that is not registered on `descriptor` (or is cyclic)
|
|
6651
|
+
* names no model and yields `undefined` rather than falling through to the
|
|
6652
|
+
* `modelPrefix: ''` catch-all.
|
|
6653
|
+
*
|
|
6479
6654
|
* @param descriptor - The provider descriptor
|
|
6480
|
-
* @param modelId - The
|
|
6481
|
-
* @returns The matching capability, or `undefined` when no rule matches
|
|
6482
|
-
*
|
|
6655
|
+
* @param modelId - The image model id — concrete or an fgv alias
|
|
6656
|
+
* @returns The matching capability, or `undefined` when no rule matches, the
|
|
6657
|
+
* provider declares no image-generation capabilities, or `modelId` is an
|
|
6658
|
+
* unresolvable alias.
|
|
6483
6659
|
* @public
|
|
6484
6660
|
*/
|
|
6485
6661
|
declare function resolveImageCapability(descriptor: IAiProviderDescriptor, modelId: string): IAiImageModelCapability | undefined;
|
|
@@ -6560,6 +6736,20 @@ declare function resolveModelAlias(descriptor: IAiProviderDescriptor, model: str
|
|
|
6560
6736
|
* `ModelSpec` branch is selected first; the resulting string — which may itself
|
|
6561
6737
|
* be an fgv alias — is then resolved to a concrete id.
|
|
6562
6738
|
*
|
|
6739
|
+
* **This is the whole model-selection surface — do not hand-roll the walk.**
|
|
6740
|
+
* Callers should pass the `ModelSpecKey` they want and use the concrete id
|
|
6741
|
+
* this returns; a manual `resolveModel` + `resolveModelAlias` sequence is
|
|
6742
|
+
* both redundant and easy to get wrong (it is how alias-form ids leak into
|
|
6743
|
+
* capability lookups such as `resolveImageCapability`).
|
|
6744
|
+
*
|
|
6745
|
+
* **`context` carries the quality tier and the modality — never tools or
|
|
6746
|
+
* thinking.** `ModelSpecKey` has no `tools` / `thinking` key: server-side
|
|
6747
|
+
* tools and reasoning effort are orthogonal request params that ride on top of
|
|
6748
|
+
* whatever model the tier selected, and never select a model. A tool-path caller
|
|
6749
|
+
* passes a tier like any other caller — omit `context` for `base`, or pass
|
|
6750
|
+
* `'advanced'` / `'frontier'` — and sets the tools / thinking request params
|
|
6751
|
+
* separately.
|
|
6752
|
+
*
|
|
6563
6753
|
* @param descriptor - The provider descriptor (supplies `defaultModel` and `aliases`).
|
|
6564
6754
|
* @param modelOverride - An optional caller-supplied `ModelSpec` that takes precedence
|
|
6565
6755
|
* over `descriptor.defaultModel`. May itself contain or be an alias.
|
|
@@ -6802,9 +6992,15 @@ declare class ZipDirectoryItem<TCT extends string = string> implements FileTree.
|
|
|
6802
6992
|
* Implementation of `FileTree.IFileTreeFileItem` for files in a ZIP archive.
|
|
6803
6993
|
* ZIP files are read-only, so this item does not support mutation.
|
|
6804
6994
|
* Use {@link FileTree.isMutableFileItem | isMutableFileItem} to check before attempting mutations.
|
|
6995
|
+
*
|
|
6996
|
+
* @remarks
|
|
6997
|
+
* ZIP entries are byte-native, so this item also implements the read half of the
|
|
6998
|
+
* optional binary capability (`FileTree.IBinaryFileTreeFileItem`) — use
|
|
6999
|
+
* `FileTree.isBinaryFileItem` to narrow and `getRawBytes()` to read the entry's
|
|
7000
|
+
* undecoded bytes.
|
|
6805
7001
|
* @public
|
|
6806
7002
|
*/
|
|
6807
|
-
declare class ZipFileItem<TCT extends string = string> implements FileTree.
|
|
7003
|
+
declare class ZipFileItem<TCT extends string = string> implements FileTree.IBinaryFileTreeFileItem<TCT> {
|
|
6808
7004
|
/**
|
|
6809
7005
|
* Indicates that this `FileTree.FileTreeItem` is a file.
|
|
6810
7006
|
*/
|
|
@@ -6830,9 +7026,13 @@ declare class ZipFileItem<TCT extends string = string> implements FileTree.IFile
|
|
|
6830
7026
|
*/
|
|
6831
7027
|
get contentType(): TCT | undefined;
|
|
6832
7028
|
/**
|
|
6833
|
-
* The pre-loaded
|
|
7029
|
+
* The pre-loaded raw bytes of the ZIP entry.
|
|
7030
|
+
*/
|
|
7031
|
+
private readonly _bytes;
|
|
7032
|
+
/**
|
|
7033
|
+
* Text form of the entry, decoded lazily from the raw bytes on first text read.
|
|
6834
7034
|
*/
|
|
6835
|
-
private
|
|
7035
|
+
private _contents;
|
|
6836
7036
|
/**
|
|
6837
7037
|
* The ZIP file tree accessors that created this item.
|
|
6838
7038
|
*/
|
|
@@ -6848,10 +7048,12 @@ declare class ZipFileItem<TCT extends string = string> implements FileTree.IFile
|
|
|
6848
7048
|
/**
|
|
6849
7049
|
* Constructor for ZipFileItem.
|
|
6850
7050
|
* @param zipFilePath - The path of the file within the ZIP.
|
|
6851
|
-
* @param contents - The pre-loaded contents of the
|
|
7051
|
+
* @param contents - The pre-loaded contents of the entry, either as raw bytes or as
|
|
7052
|
+
* already-decoded text. Text is encoded as UTF-8 for the byte accessor and is also
|
|
7053
|
+
* retained verbatim, so supplying text never round-trips through a decode.
|
|
6852
7054
|
* @param accessors - The ZIP file tree accessors.
|
|
6853
7055
|
*/
|
|
6854
|
-
constructor(zipFilePath: string, contents: string, accessors: ZipFileTreeAccessors<TCT>);
|
|
7056
|
+
constructor(zipFilePath: string, contents: string | Uint8Array, accessors: ZipFileTreeAccessors<TCT>);
|
|
6855
7057
|
/**
|
|
6856
7058
|
* Sets the content type of the file.
|
|
6857
7059
|
* @param contentType - The content type of the file.
|
|
@@ -6864,8 +7066,21 @@ declare class ZipFileItem<TCT extends string = string> implements FileTree.IFile
|
|
|
6864
7066
|
getContents<T>(converter: Validator<T> | Converter<T>): Result<T>;
|
|
6865
7067
|
/**
|
|
6866
7068
|
* Gets the raw contents of the file as a string.
|
|
7069
|
+
*
|
|
7070
|
+
* @remarks
|
|
7071
|
+
* The entry's bytes are decoded as UTF-8 with the lenient WHATWG default, so
|
|
7072
|
+
* malformed input is silently replaced with U+FFFD. Use `getRawBytes()` for the
|
|
7073
|
+
* undecoded bytes — and `new TextDecoder('utf-8', { fatal: true }).decode(bytes)`
|
|
7074
|
+
* for a decode that fails loudly instead.
|
|
6867
7075
|
*/
|
|
6868
7076
|
getRawContents(): Result<string>;
|
|
7077
|
+
/**
|
|
7078
|
+
* Gets the raw bytes of the ZIP entry, with no text decoding applied.
|
|
7079
|
+
*
|
|
7080
|
+
* @remarks
|
|
7081
|
+
* The returned array is the item's internal buffer and must not be modified.
|
|
7082
|
+
*/
|
|
7083
|
+
getRawBytes(): Result<Uint8Array>;
|
|
6869
7084
|
}
|
|
6870
7085
|
|
|
6871
7086
|
declare namespace ZipFileTree {
|
|
@@ -6874,7 +7089,9 @@ declare namespace ZipFileTree {
|
|
|
6874
7089
|
ZipFileItem,
|
|
6875
7090
|
ZipDirectoryItem,
|
|
6876
7091
|
createZipFromTextFiles,
|
|
7092
|
+
createZipFromFiles,
|
|
6877
7093
|
IZipTextFile,
|
|
7094
|
+
IZipFile,
|
|
6878
7095
|
ZipCompressionLevel,
|
|
6879
7096
|
ICreateZipOptions
|
|
6880
7097
|
}
|
|
@@ -6885,9 +7102,15 @@ export { ZipFileTree }
|
|
|
6885
7102
|
* Read-only file tree accessors for ZIP archives.
|
|
6886
7103
|
* ZIP archives are read-only by design — use {@link FileTree.isMutableAccessors | isMutableAccessors}
|
|
6887
7104
|
* to check before attempting mutations.
|
|
7105
|
+
*
|
|
7106
|
+
* @remarks
|
|
7107
|
+
* ZIP entries are byte-native, so these accessors also implement the read half of the
|
|
7108
|
+
* optional binary capability (`FileTree.IBinaryFileTreeAccessors`) — use
|
|
7109
|
+
* `FileTree.isBinaryAccessors` to narrow and `getFileBytes()` to read an entry's
|
|
7110
|
+
* undecoded bytes.
|
|
6888
7111
|
* @public
|
|
6889
7112
|
*/
|
|
6890
|
-
declare class ZipFileTreeAccessors<TCT extends string = string> implements FileTree.
|
|
7113
|
+
declare class ZipFileTreeAccessors<TCT extends string = string> implements FileTree.IBinaryFileTreeAccessors<TCT> {
|
|
6891
7114
|
/**
|
|
6892
7115
|
* The unzipped file data.
|
|
6893
7116
|
*/
|
|
@@ -6981,8 +7204,25 @@ declare class ZipFileTreeAccessors<TCT extends string = string> implements FileT
|
|
|
6981
7204
|
getItem(path: string): Result<FileTree.FileTreeItem<TCT>>;
|
|
6982
7205
|
/**
|
|
6983
7206
|
* Gets the contents of a file in the file tree.
|
|
7207
|
+
*
|
|
7208
|
+
* @remarks
|
|
7209
|
+
* The entry's bytes are decoded as UTF-8 with the lenient WHATWG default. Use
|
|
7210
|
+
* `getFileBytes()` for the undecoded bytes.
|
|
6984
7211
|
*/
|
|
6985
7212
|
getFileContents(path: string): Result<string>;
|
|
7213
|
+
/**
|
|
7214
|
+
* Gets the raw bytes of a ZIP entry, with no text decoding applied.
|
|
7215
|
+
*
|
|
7216
|
+
* @remarks
|
|
7217
|
+
* The returned array is the archive's internal buffer and must not be modified.
|
|
7218
|
+
*/
|
|
7219
|
+
getFileBytes(path: string): Result<Uint8Array>;
|
|
7220
|
+
/**
|
|
7221
|
+
* Resolves a path to the ZIP file item it names.
|
|
7222
|
+
* @param path - Path of the entry to look up.
|
|
7223
|
+
* @returns `Success` with the item, or `Failure` if it is missing or is a directory.
|
|
7224
|
+
*/
|
|
7225
|
+
private _getFileItem;
|
|
6986
7226
|
/**
|
|
6987
7227
|
* Gets the content type of a file in the file tree.
|
|
6988
7228
|
*/
|
|
@@ -10,7 +10,7 @@ export { callProviderEmbedding, callProxiedEmbedding, type IProviderEmbeddingPar
|
|
|
10
10
|
export { callProviderCompletionStream, callProxiedCompletionStream, type IProviderCompletionStreamParams, executeClientToolTurn, type IExecuteClientToolTurnParams, type IExecuteClientToolTurnResult, type IToolExecutionDecision } from './streamingClient';
|
|
11
11
|
export { aiProviderId, aiServerToolType, aiWebSearchToolConfig, aiServerToolConfig, aiToolAnnotations, aiClientToolConfig, aiToolEnablement, aiAssistProviderConfig, aiAssistSettings, modelSpecKey, modelSpec } from './converters';
|
|
12
12
|
export { resolveEffectiveTools } from './toolFormats';
|
|
13
|
-
export { extractJsonText, fencedStringifiedJson, type IFencedStringifiedJsonExtractorOptions, type IFencedStringifiedJsonOptions, type JsonTextExtractor } from './jsonResponse';
|
|
13
|
+
export { classifyJsonParseFailure, extractJsonText, fencedStringifiedJson, type IFencedStringifiedJsonExtractorOptions, type IFencedStringifiedJsonOptions, type JsonParseFailureReason, type JsonTextExtractor } from './jsonResponse';
|
|
14
14
|
export { generateJsonCompletion, SMART_JSON_PROMPT_HINT, type IGenerateJsonCompletionParams, type IGenerateJsonCompletionResult, type JsonPromptHint } from './jsonCompletion';
|
|
15
15
|
export { anthropicEffortToBudgetTokens, type IResolvedThinkingConfig } from './thinkingOptionsResolver';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src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,EACL,4BAA4B,EAC5B,2BAA2B,EAC3B,KAAK,+BAA+B,EACpC,qBAAqB,EACrB,KAAK,4BAA4B,EACjC,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACV,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,KAAK,sCAAsC,EAC3C,KAAK,6BAA6B,EAClC,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/ai-assist/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,QAAQ,EACR,KAAK,iBAAiB,EACtB,oBAAoB,EACpB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,4BAA4B,EAC5B,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,gBAA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sCAAsC,EAC3C,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
8
|
-
exports.anthropicEffortToBudgetTokens = exports.SMART_JSON_PROMPT_HINT = exports.generateJsonCompletion = void 0;
|
|
7
|
+
exports.extractJsonText = exports.classifyJsonParseFailure = exports.resolveEffectiveTools = exports.modelSpec = exports.modelSpecKey = exports.aiAssistSettings = exports.aiAssistProviderConfig = exports.aiToolEnablement = exports.aiClientToolConfig = exports.aiToolAnnotations = exports.aiServerToolConfig = exports.aiWebSearchToolConfig = exports.aiServerToolType = exports.aiProviderId = exports.executeClientToolTurn = exports.callProxiedCompletionStream = exports.callProviderCompletionStream = exports.callProxiedEmbedding = exports.callProviderEmbedding = exports.callProxiedListModels = exports.callProviderListModels = exports.callProxiedImageGeneration = exports.callProviderImageGeneration = exports.callProxiedCompletion = exports.callProviderCompletion = exports.DEFAULT_MODEL_CAPABILITY_CONFIG = exports.supportsEmbedding = exports.resolveEmbeddingCapability = exports.supportsImageGeneration = exports.resolveImageCapability = exports.getProviderDescriptor = exports.getProviderDescriptors = exports.allProviderIds = exports.validateResolvedOptions = exports.resolveImageOptions = exports.toDataUrl = exports.usesMaxCompletionTokensField = exports.isAdaptiveThinkingModel = exports.isResponsesOnlyModel = exports.resolveProviderModel = exports.resolveModelAlias = exports.MODEL_ALIAS_SIGIL = exports.resolveModel = exports.MODEL_SPEC_BASE_KEY = exports.allModelSpecKeys = exports.providerApiKeySecretName = exports.DEFAULT_AI_ASSIST = exports.DEFAULT_ANTHROPIC_MAX_TOKENS = exports.allModelCapabilities = exports.AiPrompt = void 0;
|
|
8
|
+
exports.anthropicEffortToBudgetTokens = exports.SMART_JSON_PROMPT_HINT = exports.generateJsonCompletion = exports.fencedStringifiedJson = void 0;
|
|
9
9
|
var model_1 = require("./model");
|
|
10
10
|
Object.defineProperty(exports, "AiPrompt", { enumerable: true, get: function () { return model_1.AiPrompt; } });
|
|
11
11
|
Object.defineProperty(exports, "allModelCapabilities", { enumerable: true, get: function () { return model_1.allModelCapabilities; } });
|
|
@@ -63,6 +63,7 @@ Object.defineProperty(exports, "modelSpec", { enumerable: true, get: function ()
|
|
|
63
63
|
var toolFormats_1 = require("./toolFormats");
|
|
64
64
|
Object.defineProperty(exports, "resolveEffectiveTools", { enumerable: true, get: function () { return toolFormats_1.resolveEffectiveTools; } });
|
|
65
65
|
var jsonResponse_1 = require("./jsonResponse");
|
|
66
|
+
Object.defineProperty(exports, "classifyJsonParseFailure", { enumerable: true, get: function () { return jsonResponse_1.classifyJsonParseFailure; } });
|
|
66
67
|
Object.defineProperty(exports, "extractJsonText", { enumerable: true, get: function () { return jsonResponse_1.extractJsonText; } });
|
|
67
68
|
Object.defineProperty(exports, "fencedStringifiedJson", { enumerable: true, get: function () { return jsonResponse_1.fencedStringifiedJson; } });
|
|
68
69
|
var jsonCompletion_1 = require("./jsonCompletion");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/ai-assist/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,iCAiGiB;AAhGf,iGAAA,QAAQ,OAAA;AAER,6GAAA,oBAAoB,OAAA;AAcpB,qHAAA,4BAA4B,OAAA;AAe5B,0GAAA,iBAAiB,OAAA;AAEjB,iHAAA,wBAAwB,OAAA;AAoCxB,yGAAA,gBAAgB,OAAA;AAChB,4GAAA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AAMvB,2CAYsB;AAXpB,0GAAA,YAAY,OAAA;AACZ,8GAAA,gBAAgB,OAAA;AAChB,mHAAA,qBAAqB,OAAA;AACrB,gHAAA,kBAAkB,OAAA;AAClB,+GAAA,iBAAiB,OAAA;AACjB,gHAAA,kBAAkB,OAAA;AAClB,8GAAA,gBAAgB,OAAA;AAChB,oHAAA,sBAAsB,OAAA;AACtB,8GAAA,gBAAgB,OAAA;AAChB,0GAAA,YAAY,OAAA;AACZ,uGAAA,SAAS,OAAA;AAGX,6CAAsD;AAA7C,oHAAA,qBAAqB,OAAA;AAE9B,+CAQwB;AAPtB,wHAAA,wBAAwB,OAAA;AACxB,+GAAA,eAAe,OAAA;AACf,qHAAA,qBAAqB,OAAA;AAOvB,mDAM0B;AALxB,wHAAA,sBAAsB,OAAA;AACtB,wHAAA,sBAAsB,OAAA;AAMxB,qEAAwG;AAA/F,wIAAA,6BAA6B,OAAA","sourcesContent":["/**\n * AI assist packlet - provider registry, prompt class, settings, and API client.\n * @packageDocumentation\n */\n\nexport {\n AiPrompt,\n type AiModelCapability,\n allModelCapabilities,\n type AiProviderId,\n type AiServerToolType,\n type AiServerToolConfig,\n type AiToolConfig,\n type IAiWebSearchToolConfig,\n type IAiClientToolConfig,\n type IAiToolAnnotations,\n type IAiClientTool,\n type IAiClientToolCallSummary,\n type IAiClientToolContinuation,\n type IAiClientToolTurnResult,\n type IAiToolEnablement,\n type IAiCompletionResponse,\n DEFAULT_ANTHROPIC_MAX_TOKENS,\n type IChatMessage,\n type IChatRequest,\n type AiApiFormat,\n type AiImageApiFormat,\n type AiEmbeddingApiFormat,\n type AiEmbeddingTaskType,\n type IAiEmbeddingModelCapability,\n type IAiEmbeddingParams,\n type IAiEmbeddingUsage,\n type IAiEmbeddingResult,\n type IAiImageModelCapability,\n type IAiProviderDescriptor,\n type IAiAssistProviderConfig,\n type IAiAssistSettings,\n DEFAULT_AI_ASSIST,\n type IAiAssistKeyStore,\n providerApiKeySecretName,\n type IAiImageAttachment,\n type IAiImageData,\n type AiImageSize,\n type AiImageQuality,\n type GptImageSize,\n type GptImageQuality,\n type GptImageModelNames,\n type GrokImagineModelNames,\n type GeminiFlashImageModelNames,\n type IGptImageGenerationConfig,\n type IGrokImagineImageGenerationConfig,\n type IGeminiFlashImageGenerationConfig,\n type IGptImageModelOptions,\n type IGrokImagineModelOptions,\n type IGeminiFlashImageModelOptions,\n type IOtherModelOptions,\n type IModelFamilyConfig,\n type IAiImageGenerationOptions,\n type IAiImageGenerationParams,\n type IAiGeneratedImage,\n type IAiImageGenerationResponse,\n type IAiModelCapabilityRule,\n type IAiModelCapabilityConfig,\n type IAiModelInfo,\n type IAiStreamEvent,\n type IAiStreamTextDelta,\n type IAiStreamToolEvent,\n type IAiStreamToolUseStart,\n type IAiStreamToolUseDelta,\n type IAiStreamToolUseComplete,\n type IAiStreamDone,\n type IAiStreamError,\n type ModelSpec,\n type ModelSpecKey,\n type IModelSpecMap,\n allModelSpecKeys,\n MODEL_SPEC_BASE_KEY,\n resolveModel,\n type IModelAliasMap,\n MODEL_ALIAS_SIGIL,\n resolveModelAlias,\n resolveProviderModel,\n isResponsesOnlyModel,\n isAdaptiveThinkingModel,\n usesMaxCompletionTokensField,\n toDataUrl,\n type AiThinkingMode,\n type IThinkingConfig,\n type IThinkingProviderConfig,\n type IAnthropicThinkingOptions,\n type IOpenAiThinkingOptions,\n type IGeminiThinkingOptions,\n type IXAiThinkingOptions,\n type IOtherThinkingOptions,\n type IAnthropicThinkingConfig,\n type IOpenAiThinkingConfig,\n type IGeminiThinkingConfig,\n type IXAiThinkingConfig,\n type AnthropicThinkingModelNames,\n type OpenAiThinkingModelNames,\n type GeminiThinkingModelNames,\n type XAiThinkingModelNames\n} from './model';\n\nexport {\n type IResolvedImageOptions,\n resolveImageOptions,\n validateResolvedOptions\n} from './imageOptionsResolver';\n\nexport {\n allProviderIds,\n getProviderDescriptors,\n getProviderDescriptor,\n resolveImageCapability,\n supportsImageGeneration,\n resolveEmbeddingCapability,\n supportsEmbedding,\n DEFAULT_MODEL_CAPABILITY_CONFIG\n} from './registry';\n\nexport {\n callProviderCompletion,\n callProxiedCompletion,\n callProviderImageGeneration,\n callProxiedImageGeneration,\n callProviderListModels,\n callProxiedListModels,\n type IProviderCompletionParams,\n type IProviderImageGenerationParams,\n type IProviderListModelsParams\n} from './apiClient';\n\nexport {\n callProviderEmbedding,\n callProxiedEmbedding,\n type IProviderEmbeddingParams\n} from './embeddingClient';\n\nexport {\n callProviderCompletionStream,\n callProxiedCompletionStream,\n type IProviderCompletionStreamParams,\n executeClientToolTurn,\n type IExecuteClientToolTurnParams,\n type IExecuteClientToolTurnResult,\n type IToolExecutionDecision\n} from './streamingClient';\n\nexport {\n aiProviderId,\n aiServerToolType,\n aiWebSearchToolConfig,\n aiServerToolConfig,\n aiToolAnnotations,\n aiClientToolConfig,\n aiToolEnablement,\n aiAssistProviderConfig,\n aiAssistSettings,\n modelSpecKey,\n modelSpec\n} from './converters';\n\nexport { resolveEffectiveTools } from './toolFormats';\n\nexport {\n classifyJsonParseFailure,\n extractJsonText,\n fencedStringifiedJson,\n type IFencedStringifiedJsonExtractorOptions,\n type IFencedStringifiedJsonOptions,\n type JsonParseFailureReason,\n type JsonTextExtractor\n} from './jsonResponse';\n\nexport {\n generateJsonCompletion,\n SMART_JSON_PROMPT_HINT,\n type IGenerateJsonCompletionParams,\n type IGenerateJsonCompletionResult,\n type JsonPromptHint\n} from './jsonCompletion';\n\nexport { anthropicEffortToBudgetTokens, type IResolvedThinkingConfig } from './thinkingOptionsResolver';\n"]}
|
|
@@ -44,6 +44,102 @@ export type JsonTextExtractor = (text: string) => Result<string>;
|
|
|
44
44
|
* @public
|
|
45
45
|
*/
|
|
46
46
|
export declare const extractJsonText: JsonTextExtractor;
|
|
47
|
+
/**
|
|
48
|
+
* Typed reason a JSON-shaped LLM response failed to parse, so a caller can
|
|
49
|
+
* branch on the failure class instead of regex-matching the engine's
|
|
50
|
+
* `JSON.parse` message (whose wording varies across V8 / Node versions).
|
|
51
|
+
*
|
|
52
|
+
* Every classified arm describes a fault at an **object property-name
|
|
53
|
+
* position** — the position an LLM most often gets wrong, and the one whose
|
|
54
|
+
* repair strategy differs most by case:
|
|
55
|
+
*
|
|
56
|
+
* - `'unquoted-property-name'`: a bare identifier where a quoted name belongs
|
|
57
|
+
* (`{ key: 1 }`). `token` is the identifier run, `offset` its first
|
|
58
|
+
* character. Identifier recognition is ASCII-only, so a non-ASCII bare name
|
|
59
|
+
* (`{ ключ: 1 }`) reports `'unknown'` rather than being named.
|
|
60
|
+
* - `'single-quoted-property-name'`: a single-quoted name (`{ 'key': 1 }`).
|
|
61
|
+
* `token` is the quoted literal (or just `'` if it never closes), `offset`
|
|
62
|
+
* the opening quote.
|
|
63
|
+
* - `'unterminated-property-name'`: a name whose closing `"` is missing, and
|
|
64
|
+
* whose body swallowed structural text (`{ "key: 1 }`). `token` is the
|
|
65
|
+
* unterminated fragment, `offset` the opening quote.
|
|
66
|
+
* - `'elided-member'`: a `,` where a member is expected — a leading or doubled
|
|
67
|
+
* comma in an object (`{ , "a": 1 }`, `{ "a":1, , "b":2 }`) or an array
|
|
68
|
+
* (`[1, , 2]`). `token` is `','`, `offset` its position.
|
|
69
|
+
* - `'unknown'`: the catch-all. The scan reached the end of the text, or hit a
|
|
70
|
+
* fault it cannot name with confidence, and reports nothing rather than
|
|
71
|
+
* guessing. Truncated responses, missing colons, trailing commas, bad number
|
|
72
|
+
* literals, and anything else not listed above land here.
|
|
73
|
+
*
|
|
74
|
+
* `offset` is a 0-based index into the `text` passed to
|
|
75
|
+
* {@link AiAssist.classifyJsonParseFailure}, not into the extracted substring.
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
export type JsonParseFailureReason = {
|
|
79
|
+
readonly kind: 'unquoted-property-name';
|
|
80
|
+
readonly token: string;
|
|
81
|
+
readonly offset: number;
|
|
82
|
+
} | {
|
|
83
|
+
readonly kind: 'single-quoted-property-name';
|
|
84
|
+
readonly token: string;
|
|
85
|
+
readonly offset: number;
|
|
86
|
+
} | {
|
|
87
|
+
readonly kind: 'unterminated-property-name';
|
|
88
|
+
readonly token: string;
|
|
89
|
+
readonly offset: number;
|
|
90
|
+
} | {
|
|
91
|
+
readonly kind: 'elided-member';
|
|
92
|
+
readonly token: string;
|
|
93
|
+
readonly offset: number;
|
|
94
|
+
} | {
|
|
95
|
+
readonly kind: 'unknown';
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Classifies why a JSON-shaped LLM response would not parse, returning a
|
|
99
|
+
* {@link AiAssist.JsonParseFailureReason} a caller can branch on — repair the
|
|
100
|
+
* cheap cases, re-prompt the expensive ones, fail outright on the rest —
|
|
101
|
+
* instead of regex-matching an engine-specific `JSON.parse` message.
|
|
102
|
+
*
|
|
103
|
+
* Pass the same raw model text you handed
|
|
104
|
+
* {@link AiAssist.fencedStringifiedJson} or {@link AiAssist.extractJsonText};
|
|
105
|
+
* this applies the same BOM / whitespace / fence / preamble handling before
|
|
106
|
+
* scanning, and reports `offset` against that original text.
|
|
107
|
+
*
|
|
108
|
+
* Classification is **structural and deliberately conservative**. The scan
|
|
109
|
+
* walks the JSON grammar itself rather than reading the engine's error string,
|
|
110
|
+
* so its verdicts are stable across Node versions — and any fault it cannot
|
|
111
|
+
* name with confidence comes back as `'unknown'` rather than a guess. In
|
|
112
|
+
* particular an input that opened a structure and never closed it (the
|
|
113
|
+
* truncated-response shape {@link AiAssist.extractJsonText} already diagnoses)
|
|
114
|
+
* classifies as `'unknown'` here; the two diagnostics are complementary, not
|
|
115
|
+
* competing.
|
|
116
|
+
*
|
|
117
|
+
* This never fails and never repairs — it only names the fault. It is a
|
|
118
|
+
* diagnostic on the failure path, so calling it on text that parses fine is
|
|
119
|
+
* harmless but pointless: it returns `'unknown'`.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* const parsed = fencedStringifiedJson({ inner }).convert(raw);
|
|
124
|
+
* if (parsed.isFailure()) {
|
|
125
|
+
* const reason = classifyJsonParseFailure(raw);
|
|
126
|
+
* switch (reason.kind) {
|
|
127
|
+
* case 'unquoted-property-name': // cheap to repair
|
|
128
|
+
* case 'single-quoted-property-name':
|
|
129
|
+
* break;
|
|
130
|
+
* case 'elided-member':
|
|
131
|
+
* case 'unterminated-property-name': // worth a re-prompt
|
|
132
|
+
* break;
|
|
133
|
+
* default: // 'unknown' — fail outright
|
|
134
|
+
* }
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @param text - Raw model output (the same string handed to the extractor).
|
|
139
|
+
* @returns A {@link AiAssist.JsonParseFailureReason}.
|
|
140
|
+
* @public
|
|
141
|
+
*/
|
|
142
|
+
export declare function classifyJsonParseFailure(text: string): JsonParseFailureReason;
|
|
47
143
|
/**
|
|
48
144
|
* Options shared by every {@link AiAssist.fencedStringifiedJson} call.
|
|
49
145
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonResponse.d.ts","sourceRoot":"","sources":["../../../src/packlets/ai-assist/jsonResponse.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAc,KAAK,SAAS,EAAQ,MAAM,EAAW,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAClG,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAErF;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"jsonResponse.d.ts","sourceRoot":"","sources":["../../../src/packlets/ai-assist/jsonResponse.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAc,KAAK,SAAS,EAAQ,MAAM,EAAW,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAClG,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,mB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