@serene-pub/sdk 0.6.0-pr-1
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/LICENSE +202 -0
- package/NOTICE +17 -0
- package/README.md +368 -0
- package/dist/actions.d.ts +572 -0
- package/dist/actions.js +829 -0
- package/dist/annexFields.d.ts +234 -0
- package/dist/annexFields.js +413 -0
- package/dist/announce.d.ts +464 -0
- package/dist/announce.js +426 -0
- package/dist/attributes.d.ts +670 -0
- package/dist/attributes.js +904 -0
- package/dist/bands.d.ts +125 -0
- package/dist/bands.js +256 -0
- package/dist/builder.d.ts +683 -0
- package/dist/builder.js +677 -0
- package/dist/candidates.d.ts +109 -0
- package/dist/candidates.js +118 -0
- package/dist/capabilities.d.ts +744 -0
- package/dist/capabilities.js +679 -0
- package/dist/channels.d.ts +106 -0
- package/dist/channels.js +129 -0
- package/dist/clauses.d.ts +40 -0
- package/dist/clauses.js +43 -0
- package/dist/component.d.ts +33 -0
- package/dist/component.js +27 -0
- package/dist/componentBuild.d.ts +48 -0
- package/dist/componentBuild.js +84 -0
- package/dist/componentClient.d.ts +100 -0
- package/dist/componentClient.js +13 -0
- package/dist/componentImports.d.ts +51 -0
- package/dist/componentImports.js +106 -0
- package/dist/componentModule.d.ts +8 -0
- package/dist/componentModule.js +270 -0
- package/dist/componentWire.d.ts +130 -0
- package/dist/componentWire.js +280 -0
- package/dist/config.d.ts +295 -0
- package/dist/config.js +231 -0
- package/dist/connections.d.ts +89 -0
- package/dist/connections.js +131 -0
- package/dist/declarations.d.ts +290 -0
- package/dist/declarations.js +794 -0
- package/dist/descriptors.d.ts +1774 -0
- package/dist/descriptors.js +1329 -0
- package/dist/dev.d.ts +136 -0
- package/dist/dev.js +161 -0
- package/dist/document.d.ts +202 -0
- package/dist/document.js +312 -0
- package/dist/engines.d.ts +117 -0
- package/dist/engines.js +203 -0
- package/dist/eventMapLaws.d.ts +63 -0
- package/dist/eventMapLaws.js +128 -0
- package/dist/events.d.ts +554 -0
- package/dist/events.js +633 -0
- package/dist/executor.d.ts +771 -0
- package/dist/executor.js +1829 -0
- package/dist/extension.d.ts +448 -0
- package/dist/extension.js +315 -0
- package/dist/facets.d.ts +53 -0
- package/dist/facets.js +60 -0
- package/dist/foldedSections.d.ts +74 -0
- package/dist/foldedSections.js +161 -0
- package/dist/genres.d.ts +507 -0
- package/dist/genres.js +633 -0
- package/dist/guardedConnection.d.ts +138 -0
- package/dist/guardedConnection.js +341 -0
- package/dist/handlebarsReach.d.ts +122 -0
- package/dist/handlebarsReach.js +222 -0
- package/dist/hash.d.ts +146 -0
- package/dist/hash.js +166 -0
- package/dist/hookGrants.d.ts +47 -0
- package/dist/hookGrants.js +68 -0
- package/dist/hooks.d.ts +290 -0
- package/dist/hooks.js +113 -0
- package/dist/hostElements.d.ts +447 -0
- package/dist/hostElements.js +702 -0
- package/dist/i18n.d.ts +94 -0
- package/dist/i18n.js +123 -0
- package/dist/identity.d.ts +93 -0
- package/dist/identity.js +135 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +176 -0
- package/dist/layout.d.ts +194 -0
- package/dist/layout.js +40 -0
- package/dist/media.d.ts +202 -0
- package/dist/media.js +70 -0
- package/dist/messageBlocks.d.ts +487 -0
- package/dist/messageBlocks.js +683 -0
- package/dist/migration.d.ts +128 -0
- package/dist/migration.js +261 -0
- package/dist/names.d.ts +78 -0
- package/dist/names.js +136 -0
- package/dist/nodeInput.d.ts +399 -0
- package/dist/nodeInput.js +178 -0
- package/dist/participants.d.ts +291 -0
- package/dist/participants.js +252 -0
- package/dist/personGate.d.ts +62 -0
- package/dist/personGate.js +77 -0
- package/dist/pick.d.ts +84 -0
- package/dist/pick.js +103 -0
- package/dist/pluginHarness.d.ts +235 -0
- package/dist/pluginHarness.js +558 -0
- package/dist/pluginPermissions.d.ts +25 -0
- package/dist/pluginPermissions.js +97 -0
- package/dist/pluginRuleRef.d.ts +13 -0
- package/dist/pluginRuleRef.js +10 -0
- package/dist/predicates.d.ts +182 -0
- package/dist/predicates.js +249 -0
- package/dist/preview.d.ts +120 -0
- package/dist/preview.js +82 -0
- package/dist/promptBlocks.d.ts +130 -0
- package/dist/promptBlocks.js +197 -0
- package/dist/rankingDecisions.d.ts +60 -0
- package/dist/rankingDecisions.js +48 -0
- package/dist/receipt.d.ts +313 -0
- package/dist/receipt.js +60 -0
- package/dist/receiverRules.d.ts +24 -0
- package/dist/receiverRules.js +94 -0
- package/dist/refs.d.ts +117 -0
- package/dist/refs.js +137 -0
- package/dist/registry.d.ts +230 -0
- package/dist/registry.js +273 -0
- package/dist/review.d.ts +108 -0
- package/dist/review.js +97 -0
- package/dist/sampling.d.ts +152 -0
- package/dist/sampling.js +712 -0
- package/dist/scope.d.ts +65 -0
- package/dist/scope.js +128 -0
- package/dist/scripts.d.ts +243 -0
- package/dist/scripts.js +326 -0
- package/dist/sessionLayout.d.ts +339 -0
- package/dist/sessionLayout.js +503 -0
- package/dist/sessionSettings.d.ts +70 -0
- package/dist/sessionSettings.js +2 -0
- package/dist/settings.d.ts +501 -0
- package/dist/settings.js +604 -0
- package/dist/settingsSlot.d.ts +108 -0
- package/dist/settingsSlot.js +166 -0
- package/dist/shapes.d.ts +373 -0
- package/dist/shapes.js +408 -0
- package/dist/sheets.d.ts +165 -0
- package/dist/sheets.js +251 -0
- package/dist/statShapes.d.ts +96 -0
- package/dist/statShapes.js +112 -0
- package/dist/status.d.ts +103 -0
- package/dist/status.js +125 -0
- package/dist/storage.d.ts +145 -0
- package/dist/storage.js +33 -0
- package/dist/storyTime.d.ts +308 -0
- package/dist/storyTime.js +560 -0
- package/dist/surfaces.d.ts +501 -0
- package/dist/surfaces.js +292 -0
- package/dist/template.d.ts +312 -0
- package/dist/template.js +554 -0
- package/dist/templateCheck.d.ts +60 -0
- package/dist/templateCheck.js +516 -0
- package/dist/templateFit.d.ts +157 -0
- package/dist/templateFit.js +349 -0
- package/dist/templateIds.d.ts +138 -0
- package/dist/templateIds.js +144 -0
- package/dist/templateScopeAt.d.ts +131 -0
- package/dist/templateScopeAt.js +354 -0
- package/dist/testing.d.ts +177 -0
- package/dist/testing.js +383 -0
- package/dist/tokenizers.d.ts +113 -0
- package/dist/tokenizers.js +184 -0
- package/dist/turnLock.d.ts +96 -0
- package/dist/turnLock.js +79 -0
- package/dist/turnOrder.d.ts +143 -0
- package/dist/turnOrder.js +128 -0
- package/dist/validate.d.ts +74 -0
- package/dist/validate.js +1399 -0
- package/dist/values.d.ts +212 -0
- package/dist/values.js +390 -0
- package/dist/variables.d.ts +493 -0
- package/dist/variables.js +662 -0
- package/dist/verdicts.d.ts +275 -0
- package/dist/verdicts.js +348 -0
- package/dist/widgetDecls.d.ts +88 -0
- package/dist/widgetDecls.js +119 -0
- package/dist/widgets.d.ts +1527 -0
- package/dist/widgets.js +208 -0
- package/dist/wire.d.ts +126 -0
- package/dist/wire.js +140 -0
- package/dist/worldinfo.d.ts +150 -0
- package/dist/worldinfo.js +212 -0
- package/host-elements.d.ts +914 -0
- package/package.json +67 -0
|
@@ -0,0 +1,744 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a connection can do, and what a node needs from one.
|
|
3
|
+
*
|
|
4
|
+
* A connection used to carry a single `modality` — one scalar saying "this is a
|
|
5
|
+
* text connection" or "this is an image connection" — and adapters were split
|
|
6
|
+
* into two families by it. That model cannot describe a real backend. KoboldCPP
|
|
7
|
+
* does text, images, vision, speech and transcription from one process and
|
|
8
|
+
* already reports so. An OpenAI-compatible endpoint may or may not do images
|
|
9
|
+
* depending entirely on who is behind it. And the model was already violated in
|
|
10
|
+
* practice: rows carrying `modality: 'embeddings'` existed and matched no family.
|
|
11
|
+
*
|
|
12
|
+
* The replacement has two axes, deliberately kept apart:
|
|
13
|
+
*
|
|
14
|
+
* - **Transforms** say what can *flow*: text in, an image out. They are the
|
|
15
|
+
* modality question, asked properly — as a relation rather than a label.
|
|
16
|
+
* - **Features** say how a request can be *constrained*: JSON schema, a
|
|
17
|
+
* grammar, tool calls. Orthogonal to transforms; a backend that generates
|
|
18
|
+
* text may or may not be able to promise the shape of it.
|
|
19
|
+
*
|
|
20
|
+
* Mixing the two into one list is what makes a capability screen unreadable:
|
|
21
|
+
* "Chat" and "Strict JSON schema" are not the same kind of fact and should not
|
|
22
|
+
* sit in the same column.
|
|
23
|
+
*
|
|
24
|
+
* ## Who decides
|
|
25
|
+
*
|
|
26
|
+
* Four layers, each narrowing the last, resolved once by `resolveCapabilities`:
|
|
27
|
+
*
|
|
28
|
+
* adapter (what the WIRE FORMAT can express — gates the key space entirely)
|
|
29
|
+
* → preset (what this named service defaults to)
|
|
30
|
+
* → probe (what the live backend actually answered)
|
|
31
|
+
* → user (the final toggle)
|
|
32
|
+
*
|
|
33
|
+
* Those four collapse into two INDEPENDENT gradings, and the composite is their
|
|
34
|
+
* floor: the adapter grades the API (what the format can express), while the
|
|
35
|
+
* preset, probe and person grade the MODEL (what the thing answering actually
|
|
36
|
+
* does — vision is a property of a model, never of a format). See `composite`.
|
|
37
|
+
*
|
|
38
|
+
* The adapter layer is a gate, not a default: a capability absent from
|
|
39
|
+
* `supports` can never be turned on by any later layer, because the protocol has
|
|
40
|
+
* no way to say it. That is the whole reason an adapter is scoped by API format
|
|
41
|
+
* rather than by vendor — "Claude over an OpenAI-compatible endpoint" and
|
|
42
|
+
* "Claude over the native Anthropic API" differ in exactly this.
|
|
43
|
+
*/
|
|
44
|
+
import type { I18nText } from './settings.js';
|
|
45
|
+
/**
|
|
46
|
+
* The endpoints of a transform.
|
|
47
|
+
*
|
|
48
|
+
* A superset of `MediaKind`, and the difference is the point. In
|
|
49
|
+
* `MediaCapability`, text is the *implicit* kind — `accepts: ['image']` means
|
|
50
|
+
* "images as well as text", and there is no way to write "an image and text
|
|
51
|
+
* together, both required". That is precisely the thing vision needs to say, so
|
|
52
|
+
* text is a first-class member here.
|
|
53
|
+
*
|
|
54
|
+
* `embedding` is out-only: a vector is never stored as media and never travels
|
|
55
|
+
* as a `MediaRef`. It is here because embedding connections exist and had
|
|
56
|
+
* nowhere to live under the old one-modality model.
|
|
57
|
+
*
|
|
58
|
+
* `entities` is out-only for the same reason: a named-entity span is a reading
|
|
59
|
+
* OF text, not a medium anything is stored or sent in. It is a kind rather than
|
|
60
|
+
* a feature because the thing producing it is a different model on a different
|
|
61
|
+
* connection, which is exactly what a transform's output side names.
|
|
62
|
+
*
|
|
63
|
+
* ⚠ **Append, never insert.** `side()` orders a transform's kinds by position
|
|
64
|
+
* here, so moving an existing member rewrites ids that are stored as primary
|
|
65
|
+
* keys (`connection_defaults`) and compared as strings everywhere else.
|
|
66
|
+
* @experimental
|
|
67
|
+
*/
|
|
68
|
+
export declare const IO_KINDS: readonly ["text", "image", "audio", "video", "document", "embedding", "entities"];
|
|
69
|
+
/** @experimental */
|
|
70
|
+
export type IoKind = (typeof IO_KINDS)[number];
|
|
71
|
+
/** @experimental */
|
|
72
|
+
export interface Transform {
|
|
73
|
+
in: readonly IoKind[];
|
|
74
|
+
out: readonly IoKind[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A transform's canonical address, e.g. `text+image->text`.
|
|
78
|
+
*
|
|
79
|
+
* A transform is a map key, a JSON object key, a UI list key, a database value
|
|
80
|
+
* and a `satisfies()` lookup — and `{in, out}` is none of those. The derived
|
|
81
|
+
* string is, and it is stable because the sides are ordered by `IO_KINDS`
|
|
82
|
+
* declaration order rather than alphabetically: text leads, so vision reads
|
|
83
|
+
* `text+image->text` rather than `image+text->text`.
|
|
84
|
+
* @experimental
|
|
85
|
+
*/
|
|
86
|
+
export type TransformId = `${string}->${string}`;
|
|
87
|
+
/** Read an id back apart, for a UI that wants the kinds rather than the string. @internal */
|
|
88
|
+
export declare function parseTransform(id: TransformId): Transform;
|
|
89
|
+
/**
|
|
90
|
+
* The kinds, as values.
|
|
91
|
+
*
|
|
92
|
+
* `IoKinds.image` autocompletes; `IoKinds.imgae` is a compile error. That is the
|
|
93
|
+
* whole job — a JS/TS-defined node names its combinations with objects and enum
|
|
94
|
+
* members rather than by spelling a string, because `'text+imgae->text'` is a
|
|
95
|
+
* perfectly good `TransformId` today and fails at *run* time, on the machine of
|
|
96
|
+
* whoever installed the plugin, as a capability nothing can ever satisfy.
|
|
97
|
+
*
|
|
98
|
+
* ⚠ Named `IoKinds`, NOT `Kind`. `descriptors.ts` has exported `Kind` — the node
|
|
99
|
+
* kind, `'inlet' | 'query' | 'task' | 'oracle' | 'outlet'` — since long
|
|
100
|
+
* before this existed, and both names would meet inside a single descriptor
|
|
101
|
+
* literal that already says `kind: 'oracle'`. `IoKinds` also matches the two
|
|
102
|
+
* spellings already here, `IoKind` and `IO_KINDS`.
|
|
103
|
+
*
|
|
104
|
+
* `satisfies Record<IoKind, IoKind>` is load-bearing in both directions: adding
|
|
105
|
+
* a kind to `IO_KINDS` without adding it here stops compiling, and so does a
|
|
106
|
+
* member here whose value is not its own name.
|
|
107
|
+
* @experimental
|
|
108
|
+
*/
|
|
109
|
+
export declare const IoKinds: {
|
|
110
|
+
readonly text: 'text';
|
|
111
|
+
readonly image: 'image';
|
|
112
|
+
readonly audio: 'audio';
|
|
113
|
+
readonly video: 'video';
|
|
114
|
+
readonly document: 'document';
|
|
115
|
+
readonly embedding: 'embedding';
|
|
116
|
+
readonly entities: 'entities';
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Non-empty, structurally.
|
|
120
|
+
*
|
|
121
|
+
* `TransformId` is the open template `${string}->${string}`, so `'->'` is a
|
|
122
|
+
* legal one today. Requiring at least one kind per side is what makes an empty
|
|
123
|
+
* side unwritable through `tf()` rather than merely wrong.
|
|
124
|
+
*/
|
|
125
|
+
type Kinds = readonly [IoKind, ...IoKind[]];
|
|
126
|
+
/** What an author writes: `{ in: [IoKinds.text, IoKinds.image], out: [IoKinds.text] }`. @experimental */
|
|
127
|
+
export interface TransformShape {
|
|
128
|
+
in: Kinds;
|
|
129
|
+
out: Kinds;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Walk the CANONICAL order keeping members of `Ks` — sorting and deduping fall
|
|
133
|
+
* out free.
|
|
134
|
+
*
|
|
135
|
+
* We filter the fixed six-element `IO_KINDS` tuple rather than sorting the
|
|
136
|
+
* author's, so this mirrors the runtime `side()` by CONSTRUCTION: recursion
|
|
137
|
+
* depth six, no combinatorics, no type-level comparator to keep in step, and no
|
|
138
|
+
* way for the computed type and the emitted string to drift. An author writing
|
|
139
|
+
* `[IoKinds.image, IoKinds.text]` gets `text+image->…`, the same id `side()` builds.
|
|
140
|
+
*
|
|
141
|
+
* ⚠ Walks `typeof IO_KINDS` positionally, so it degrades SILENTLY to `never` if
|
|
142
|
+
* `IO_KINDS` ever stops being a literal tuple — drop the `as const` and every
|
|
143
|
+
* `tf()` call becomes an unassignable `never` rather than a wrong string.
|
|
144
|
+
*/
|
|
145
|
+
type InOrder<O extends readonly IoKind[], Ks extends readonly IoKind[]> = O extends readonly [
|
|
146
|
+
infer H extends IoKind,
|
|
147
|
+
...infer T extends readonly IoKind[]
|
|
148
|
+
] ? H extends Ks[number] ? [H, ...InOrder<T, Ks>] : InOrder<T, Ks> : [];
|
|
149
|
+
type Join<T extends readonly string[]> = T extends readonly [
|
|
150
|
+
infer H extends string
|
|
151
|
+
] ? H : T extends readonly [
|
|
152
|
+
infer H extends string,
|
|
153
|
+
...infer R extends readonly string[]
|
|
154
|
+
] ? `${H}+${Join<R>}` : never;
|
|
155
|
+
type Side<Ks extends readonly IoKind[]> = Join<InOrder<typeof IO_KINDS, Ks>>;
|
|
156
|
+
/** The exact id a shape denotes, as a literal type. @experimental */
|
|
157
|
+
export type IdOf<T extends TransformShape> = `${Side<T['in']>}->${Side<T['out']>}`;
|
|
158
|
+
/**
|
|
159
|
+
* A transform id, from the kinds rather than from a string.
|
|
160
|
+
*
|
|
161
|
+
* Returns the EXACT literal — `tf({ in: [IoKinds.text, IoKinds.image], out: [IoKinds.text] })`
|
|
162
|
+
* has type `'text+image->text'`, not `TransformId` and not `string`. So a
|
|
163
|
+
* `requires:` entry written this way is checkable against `TRANSFORMS` at the
|
|
164
|
+
* call site by anything that cares to, and a mistyped kind is a compile error
|
|
165
|
+
* where it was written.
|
|
166
|
+
*
|
|
167
|
+
* The canonical STRING is still what gets stored, keyed on and compared — this
|
|
168
|
+
* is an authoring surface over `transformId`'s machinery, not a second
|
|
169
|
+
* representation. There is one body, `build`; the widened face over it is
|
|
170
|
+
* `transformId`, and see there for why the two are separate functions rather
|
|
171
|
+
* than an overload pair.
|
|
172
|
+
*
|
|
173
|
+
* A novel combination is deliberately still expressible: `tf({ in: [IoKinds.audio],
|
|
174
|
+
* out: [IoKinds.image] })` compiles and yields `'audio->image'`, which `TRANSFORMS`
|
|
175
|
+
* does not name. Core's table names what core ships; a plugin may introduce a
|
|
176
|
+
* transform, and closing that door is a separate ruling nobody has taken.
|
|
177
|
+
* @experimental
|
|
178
|
+
*/
|
|
179
|
+
export declare function tf<const T extends TransformShape>(t: T): IdOf<T>;
|
|
180
|
+
/**
|
|
181
|
+
* The widened form, over the same body.
|
|
182
|
+
*
|
|
183
|
+
* Kept because the runtime path has kinds in hand as `readonly IoKind[]` — a
|
|
184
|
+
* parsed id, a probe result — where there is no literal type to preserve and
|
|
185
|
+
* `TransformId` is the honest answer.
|
|
186
|
+
*
|
|
187
|
+
* ⚠ Deliberately a SEPARATE function rather than a second overload on `tf`. As
|
|
188
|
+
* an overload it silently rescues everything the narrow signature is there to
|
|
189
|
+
* reject: `tf({ in: [], out: [IoKinds.text] })` fails the non-empty `Kinds`
|
|
190
|
+
* check, falls through to `readonly IoKind[]`, and compiles as `TransformId`.
|
|
191
|
+
* Two faces over one body keeps `tf` strict and this one honest.
|
|
192
|
+
* @internal
|
|
193
|
+
*/
|
|
194
|
+
export declare const transformId: (t: Transform) => TransformId;
|
|
195
|
+
/** @experimental */
|
|
196
|
+
export interface TransformMeta {
|
|
197
|
+
i18n: I18nText;
|
|
198
|
+
/** One line under the name, in plain language. */
|
|
199
|
+
tagline?: I18nText;
|
|
200
|
+
/**
|
|
201
|
+
* `basic` is shown to everyone; everything else waits behind a disclosure.
|
|
202
|
+
*
|
|
203
|
+
* A first-timer opening a connection form should meet Chat and nothing else.
|
|
204
|
+
* Seven capability toggles on a first run is how somebody concludes the app
|
|
205
|
+
* is not for them — and the person who needs Image editing is by definition
|
|
206
|
+
* not a first-timer.
|
|
207
|
+
*/
|
|
208
|
+
disclosure?: 'basic' | 'advanced';
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Human names for the transforms core knows about.
|
|
212
|
+
*
|
|
213
|
+
* A closed table over an open id space: a plugin may introduce a transform this
|
|
214
|
+
* does not name, and everything keeps working — it simply shows as its id until
|
|
215
|
+
* somebody names it. Never render a raw `text->image` to a person; that is what
|
|
216
|
+
* `transformLabel` is for.
|
|
217
|
+
* @internal
|
|
218
|
+
*/
|
|
219
|
+
export declare const TRANSFORMS: {
|
|
220
|
+
readonly 'text->text': {
|
|
221
|
+
readonly i18n: {
|
|
222
|
+
readonly en: 'Chat';
|
|
223
|
+
};
|
|
224
|
+
readonly tagline: {
|
|
225
|
+
readonly en: 'Writes replies.';
|
|
226
|
+
};
|
|
227
|
+
readonly disclosure: 'basic';
|
|
228
|
+
};
|
|
229
|
+
readonly 'text+image->text': {
|
|
230
|
+
readonly i18n: {
|
|
231
|
+
readonly en: 'Vision';
|
|
232
|
+
};
|
|
233
|
+
readonly tagline: {
|
|
234
|
+
readonly en: 'Can look at pictures you send it.';
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
readonly 'text+document->text': {
|
|
238
|
+
readonly i18n: {
|
|
239
|
+
readonly en: 'Document reading';
|
|
240
|
+
};
|
|
241
|
+
readonly tagline: {
|
|
242
|
+
readonly en: 'Can read files you attach.';
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
readonly 'text->image': {
|
|
246
|
+
readonly i18n: {
|
|
247
|
+
readonly en: 'Image generation';
|
|
248
|
+
};
|
|
249
|
+
readonly tagline: {
|
|
250
|
+
readonly en: 'Draws pictures from a description.';
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
readonly 'text+image->image': {
|
|
254
|
+
readonly i18n: {
|
|
255
|
+
readonly en: 'Image editing';
|
|
256
|
+
};
|
|
257
|
+
readonly tagline: {
|
|
258
|
+
readonly en: 'Changes a picture you give it.';
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
readonly 'image->image': {
|
|
262
|
+
readonly i18n: {
|
|
263
|
+
readonly en: 'Image transform';
|
|
264
|
+
};
|
|
265
|
+
readonly tagline: {
|
|
266
|
+
readonly en: 'Upscales or restyles, with no prompt.';
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
readonly 'audio->text': {
|
|
270
|
+
readonly i18n: {
|
|
271
|
+
readonly en: 'Transcription';
|
|
272
|
+
};
|
|
273
|
+
readonly tagline: {
|
|
274
|
+
readonly en: 'Turns speech into text.';
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
readonly 'text->audio': {
|
|
278
|
+
readonly i18n: {
|
|
279
|
+
readonly en: 'Speech';
|
|
280
|
+
};
|
|
281
|
+
readonly tagline: {
|
|
282
|
+
readonly en: 'Reads text aloud.';
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
readonly 'text->embedding': {
|
|
286
|
+
readonly i18n: {
|
|
287
|
+
readonly en: 'Embeddings';
|
|
288
|
+
};
|
|
289
|
+
readonly tagline: {
|
|
290
|
+
readonly en: 'Turns text into vectors, for search.';
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
readonly 'text->entities': {
|
|
294
|
+
readonly i18n: {
|
|
295
|
+
readonly en: 'Named entities';
|
|
296
|
+
};
|
|
297
|
+
readonly tagline: {
|
|
298
|
+
readonly en: 'Finds the people, places and things a passage names.';
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
/** @internal */
|
|
303
|
+
export type KnownTransformId = keyof typeof TRANSFORMS;
|
|
304
|
+
/**
|
|
305
|
+
* How a request can be constrained or SHAPED, as opposed to what flows through
|
|
306
|
+
* it.
|
|
307
|
+
*
|
|
308
|
+
* Every one of these is already implemented somewhere in the app and merely
|
|
309
|
+
* unnamed: `json_object` and `json_schema` are OpenAI's two `response_format`
|
|
310
|
+
* modes, `grammar` is the GBNF path the llama.cpp family takes, and `tools` is
|
|
311
|
+
* the four-valued `toolUse` field that sat on every adapter with no consumers.
|
|
312
|
+
*
|
|
313
|
+
* Two kinds live here, and the split is worth naming because it is not obvious
|
|
314
|
+
* from the list:
|
|
315
|
+
*
|
|
316
|
+
* - **Constraints** on one request — the five above, plus `streaming`, which
|
|
317
|
+
* constrains how the answer arrives rather than what it says.
|
|
318
|
+
* - **Behaviours** the connection can be asked for — `continue_reply`, and the
|
|
319
|
+
* two `wire_*` ids. These are not fields on a request; they say what kind of
|
|
320
|
+
* request can be made at all.
|
|
321
|
+
*
|
|
322
|
+
* The axis they share, and the reason none of them is a transform, is that every
|
|
323
|
+
* one qualifies a call whose in and out kinds are already settled. `text->text`
|
|
324
|
+
* either way; these say HOW.
|
|
325
|
+
* @experimental
|
|
326
|
+
*/
|
|
327
|
+
export declare const FEATURES: readonly ['json_object', 'json_schema', 'strict_schema', 'grammar', 'tools', 'streaming',
|
|
328
|
+
/**
|
|
329
|
+
* The connection can resume an assistant message from a partial, as a TRUE
|
|
330
|
+
* PREFILL: the model is handed the text so far inside an OPEN assistant turn
|
|
331
|
+
* and writes the next characters of it, rather than being asked in a fresh
|
|
332
|
+
* turn to carry on.
|
|
333
|
+
*
|
|
334
|
+
* A behaviour rather than a wire, which is why it is not spelled `wire_*`. It
|
|
335
|
+
* is nonetheless answerable only alongside one — a completion wire prefills by
|
|
336
|
+
* leaving the seed block unclosed, and a chat wire can only prefill where the
|
|
337
|
+
* protocol itself accepts a trailing assistant turn — so the app's manifest
|
|
338
|
+
* records which of a type's wire modes actually carries it, and the effective
|
|
339
|
+
* answer is the pair. The SDK names the capability; it does not own that pair,
|
|
340
|
+
* because which endpoint an adapter speaks is not a fact this package can see.
|
|
341
|
+
*
|
|
342
|
+
* ⚠ The distinction it draws is the whole reason it exists. Appending a
|
|
343
|
+
* "please continue" user turn, or sending the partial as a closed assistant
|
|
344
|
+
* turn and hoping, both LOOK like a continuation and neither is one: the model
|
|
345
|
+
* starts a new reply, the join then glues two beginnings together, and nothing
|
|
346
|
+
* reports it. A connection that can only do that does not hold this.
|
|
347
|
+
*/
|
|
348
|
+
'continue_reply', 'wire_chat', 'wire_completion'];
|
|
349
|
+
/** @experimental */
|
|
350
|
+
export type FeatureId = (typeof FEATURES)[number];
|
|
351
|
+
/** @experimental */
|
|
352
|
+
export type CapabilityId = TransformId | FeatureId;
|
|
353
|
+
/** Transforms contain `->`; features never do. The two spaces cannot collide. @internal */
|
|
354
|
+
export declare const isTransformId: (id: string) => id is TransformId;
|
|
355
|
+
/**
|
|
356
|
+
* Strengthenings: holding the key implies holding the values, at the same BAND.
|
|
357
|
+
*
|
|
358
|
+
* A backend that can enforce a strict schema can obviously enforce a loose one.
|
|
359
|
+
* Declaring the implication once means an adapter states the strongest thing it
|
|
360
|
+
* does and the rest follows, rather than seven adapters each remembering to list
|
|
361
|
+
* the weaker forms.
|
|
362
|
+
* @internal
|
|
363
|
+
*/
|
|
364
|
+
export declare const IMPLIES: Partial<Record<FeatureId, readonly FeatureId[]>>;
|
|
365
|
+
/**
|
|
366
|
+
* X is available at its `emulated` band when any of the values is at ITS top.
|
|
367
|
+
*
|
|
368
|
+
* This is where "Serene Pub provides it to a backend that never heard of it"
|
|
369
|
+
* becomes data instead of a comment. `jsonSchemaToGbnf` is literally
|
|
370
|
+
* "provide `json_schema` by compiling it to a `grammar`" — declared here once,
|
|
371
|
+
* rather than re-derived inside each adapter that happens to have a grammar.
|
|
372
|
+
* @internal
|
|
373
|
+
*/
|
|
374
|
+
export declare const EMULATABLE_VIA: Partial<Record<FeatureId, readonly FeatureId[]>>;
|
|
375
|
+
/**
|
|
376
|
+
* How well something is supported, as a number: 0 is unsupported, open upward.
|
|
377
|
+
*
|
|
378
|
+
* This replaced a flat three-value enum (`native | emulated | none`), which
|
|
379
|
+
* could not express the fact the rest of this section is built around: how many
|
|
380
|
+
* WAYS there are to support a capability differs per capability. Serene Pub can
|
|
381
|
+
* format and parse tool calls for a backend that never heard of them, so `tools`
|
|
382
|
+
* has a middle. Nothing fakes a picture, so `text->image` has none — and under
|
|
383
|
+
* the flat enum its very best possible answer was `native`, one of three, which
|
|
384
|
+
* a badge then had to render as though something better existed.
|
|
385
|
+
*
|
|
386
|
+
* A grade means nothing on its own; it is read against `bandsFor(id)`. So the
|
|
387
|
+
* top of a two-band capability is simply the top, and `gradeLetter` calls it an
|
|
388
|
+
* `A` rather than inventing a deficiency the protocol does not have.
|
|
389
|
+
*
|
|
390
|
+
* Not an enum with more members, and not a float. An open integer scale is what
|
|
391
|
+
* lets a capability core never named have a shape core never named, and it makes
|
|
392
|
+
* `Math.min` the entire comparator — see `composite`, which replaced three
|
|
393
|
+
* separately hardcoded `{native: 2, emulated: 1, none: 0}` rank tables.
|
|
394
|
+
* @experimental
|
|
395
|
+
*/
|
|
396
|
+
export type Grade = number;
|
|
397
|
+
/**
|
|
398
|
+
* The band names core knows: what a grade MEANS, once you know the capability.
|
|
399
|
+
*
|
|
400
|
+
* A CLOSED vocabulary, while the grade scale is open, and the asymmetry is
|
|
401
|
+
* deliberate. These are the names an author writes, so closing them makes
|
|
402
|
+
* `"nativ"` a compile error at the place it was typed. The openness that matters
|
|
403
|
+
* is `bandsFor`'s fallback — a plugin's own transform grades correctly without
|
|
404
|
+
* anybody editing this file — and that needs no new band NAMES to work.
|
|
405
|
+
* @experimental
|
|
406
|
+
*/
|
|
407
|
+
export declare const BAND: {
|
|
408
|
+
readonly none: 'none';
|
|
409
|
+
readonly emulated: 'emulated';
|
|
410
|
+
readonly native: 'native';
|
|
411
|
+
};
|
|
412
|
+
/** @experimental */
|
|
413
|
+
export type Band = (typeof BAND)[keyof typeof BAND];
|
|
414
|
+
/**
|
|
415
|
+
* Weakest to strongest, independently of any one capability's own table.
|
|
416
|
+
*
|
|
417
|
+
* Consulted when a band a capability does not HAVE is asked for: `emulated`
|
|
418
|
+
* asked of `text->image` walks down to `none`, because a claim is never stronger
|
|
419
|
+
* than what permits it and nothing supplies an emulated picture.
|
|
420
|
+
* @internal
|
|
421
|
+
*/
|
|
422
|
+
export declare const BAND_ORDER: readonly ["none", "emulated", "native"];
|
|
423
|
+
/**
|
|
424
|
+
* Per capability, what its grades mean — the index IS the grade.
|
|
425
|
+
*
|
|
426
|
+
* Only capabilities whose shape differs from binary are listed. Everything else
|
|
427
|
+
* falls back to `DEFAULT_BANDS` through `bandsFor`, which is the half that keeps
|
|
428
|
+
* this table from having to name a capability in order for that capability to
|
|
429
|
+
* grade correctly: a plugin introduces a transform, and it is binary until
|
|
430
|
+
* somebody says otherwise.
|
|
431
|
+
*
|
|
432
|
+
* The three listed here are exactly the keys of `EMULATABLE_VIA`, and that is
|
|
433
|
+
* not a coincidence. An `emulated` band exists precisely where Serene Pub can
|
|
434
|
+
* supply the capability itself over a backend that cannot, which is what that
|
|
435
|
+
* table records. `closure` raises through `gradeOf(id, BAND.emulated)`, so a
|
|
436
|
+
* capability with no such band cannot be emulated upward at all — the honest
|
|
437
|
+
* answer, arrived at without a second list stating it.
|
|
438
|
+
* @experimental
|
|
439
|
+
*/
|
|
440
|
+
export declare const BANDS: Partial<Record<CapabilityId, readonly Band[]>>;
|
|
441
|
+
/** A capability nobody gave bands: it either works or it does not. @experimental */
|
|
442
|
+
export declare const DEFAULT_BANDS: readonly Band[];
|
|
443
|
+
/** @internal */
|
|
444
|
+
export declare const bandsFor: (id: CapabilityId) => readonly Band[];
|
|
445
|
+
/** The best this capability can be — what `native` means FOR IT. @experimental */
|
|
446
|
+
export declare const topGrade: (id: CapabilityId) => Grade;
|
|
447
|
+
/** Which band a grade lands in, or `undefined` for a grade off the scale. @internal */
|
|
448
|
+
export declare const bandOf: (id: CapabilityId, grade: Grade) => Band | undefined;
|
|
449
|
+
/**
|
|
450
|
+
* What an author may write for one grade: the band by name, or the number.
|
|
451
|
+
*
|
|
452
|
+
* Both, because neither alone is safe. A bare number in a declaration is
|
|
453
|
+
* unreadable and silently wrong at the one place it matters most — `tools: 1` is
|
|
454
|
+
* emulated tool calling and `tools: 2` is native, one keystroke apart with no
|
|
455
|
+
* type to catch it, while `1` on a two-band capability is its maximum. A name
|
|
456
|
+
* alone cannot address a band core has not named.
|
|
457
|
+
*
|
|
458
|
+
* ⚠ An AUTHORING type, never a stored one. `CapabilitySet` and
|
|
459
|
+
* `CapabilityOverrides` hold grades and nothing else — the same split by
|
|
460
|
+
* position the old vocabulary had, where an adapter could declare `probed` and a
|
|
461
|
+
* connection could only store a resolved answer.
|
|
462
|
+
* @experimental
|
|
463
|
+
*/
|
|
464
|
+
export type GradeSpec = Band | Grade;
|
|
465
|
+
/**
|
|
466
|
+
* A spec as a grade, on this capability's own scale.
|
|
467
|
+
*
|
|
468
|
+
* Total, and never stronger than the scale allows: a number is clamped into
|
|
469
|
+
* range, and a band the capability does not have walks DOWN `BAND_ORDER`. Both
|
|
470
|
+
* failures are authoring bugs rather than data, so this stays pure and the
|
|
471
|
+
* manifest conformance test is what fails the build over one.
|
|
472
|
+
* @internal
|
|
473
|
+
*/
|
|
474
|
+
export declare function gradeOf(id: CapabilityId, spec: GradeSpec): Grade;
|
|
475
|
+
/**
|
|
476
|
+
* The composite of the two independent gradings: their floor.
|
|
477
|
+
*
|
|
478
|
+
* The ONE comparator in this file, and it is `Math.min` because a grade is a
|
|
479
|
+
* number. Three hardcoded rank tables used to do this — in `closure`, in
|
|
480
|
+
* `resolveCapabilities`, and in a `weakest` helper — and the fourth would have
|
|
481
|
+
* been written by whoever next needed to compare two.
|
|
482
|
+
*
|
|
483
|
+
* The two arguments are what the four layers actually produce, named:
|
|
484
|
+
*
|
|
485
|
+
* - the API grade, from the adapter/manifest layer — what this WIRE FORMAT can
|
|
486
|
+
* express. Also an absolute gate on the key space, which is why it is the
|
|
487
|
+
* ceiling every layer below is taken against rather than merely a default.
|
|
488
|
+
* - the MODEL grade, from the preset, the probe and the person — what the
|
|
489
|
+
* thing actually answering does. Inherently per-model: vision is a property
|
|
490
|
+
* of a model, not of a format, which is why no preset can settle it.
|
|
491
|
+
*
|
|
492
|
+
* Neither can promise past the other, so the composite is the floor — and the
|
|
493
|
+
* two need no second column, table or stored field to be graded independently.
|
|
494
|
+
* @experimental
|
|
495
|
+
*/
|
|
496
|
+
export declare const composite: (api: Grade, model: Grade) => Grade;
|
|
497
|
+
/**
|
|
498
|
+
* What an adapter declares for one capability: a grade, or one nobody proved.
|
|
499
|
+
*
|
|
500
|
+
* `unproven` is deliberately a SEPARATE flag rather than a point on the scale.
|
|
501
|
+
* `native`/`emulated`/`none` answered *how well*; `probed` answered *have we
|
|
502
|
+
* asked* — two different questions, and one number would have to conflate them.
|
|
503
|
+
* Whether they should eventually collapse is an open ruling, held on purpose;
|
|
504
|
+
* they do not collapse here.
|
|
505
|
+
*
|
|
506
|
+
* `until` must carry what to assume until an answer arrives, because there is no
|
|
507
|
+
* universally right pessimism. Tool calling degrades to `emulated` — the app can
|
|
508
|
+
* format and parse it for a model that has never heard of tools. Image
|
|
509
|
+
* generation degrades to `none`, because nothing can fake a picture. A single
|
|
510
|
+
* hardcoded default would have to be wrong for one of them.
|
|
511
|
+
* @experimental
|
|
512
|
+
*/
|
|
513
|
+
export type Declared = GradeSpec | {
|
|
514
|
+
unproven: true;
|
|
515
|
+
until: GradeSpec;
|
|
516
|
+
};
|
|
517
|
+
/** What a connection STORES: grades, each on its own capability's scale. @experimental */
|
|
518
|
+
export type CapabilitySet = Partial<Record<CapabilityId, Grade>>;
|
|
519
|
+
/**
|
|
520
|
+
* The grade as a letter, relative to THIS capability's own top band.
|
|
521
|
+
*
|
|
522
|
+
* Derived at render and nowhere else: no letter is ever stored, sent on the wire
|
|
523
|
+
* or compared. `A` is the best this capability can be, so a two-band
|
|
524
|
+
* capability's grade 1 is an `A` — which is the entire reason grades are read
|
|
525
|
+
* per capability rather than against one global scale.
|
|
526
|
+
*
|
|
527
|
+
* Grade 0 has no letter, because 0 is not a quality but an absence; the caller
|
|
528
|
+
* says "Off". Anything past `Z` clamps rather than walking out of the alphabet.
|
|
529
|
+
* @internal
|
|
530
|
+
*/
|
|
531
|
+
export declare function gradeLetter(id: CapabilityId, grade: Grade): string | undefined;
|
|
532
|
+
/** @experimental */
|
|
533
|
+
export interface AdapterCapabilities {
|
|
534
|
+
/**
|
|
535
|
+
* What this WIRE PROTOCOL can express.
|
|
536
|
+
*
|
|
537
|
+
* A gate, not a default. A capability absent here can never be switched on by
|
|
538
|
+
* a preset, a probe or a person, because the protocol has no way to say it —
|
|
539
|
+
* which is exactly why the native Anthropic API hides image generation
|
|
540
|
+
* outright while an OpenAI-compatible endpoint pointed at Anthropic merely
|
|
541
|
+
* defaults it off.
|
|
542
|
+
*/
|
|
543
|
+
supports: Partial<Record<CapabilityId, Declared>>;
|
|
544
|
+
/** Which of those are ON when no preset says otherwise. */
|
|
545
|
+
defaults?: readonly CapabilityId[];
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* A preset's opinion. `true` means "on at whatever grade the adapter declares".
|
|
549
|
+
*
|
|
550
|
+
* Authored, so a band name is accepted alongside a grade. A band this capability
|
|
551
|
+
* does not have resolves to 0 — an `emulated` picture is a claim nothing can
|
|
552
|
+
* fulfil, and reading it as "off" is more honest than showing it as supplied.
|
|
553
|
+
* @experimental
|
|
554
|
+
*/
|
|
555
|
+
export type PresetCapabilities = Partial<Record<CapabilityId, GradeSpec | boolean>>;
|
|
556
|
+
/**
|
|
557
|
+
* What a person switched by hand. `false` is an explicit off, not an absence.
|
|
558
|
+
*
|
|
559
|
+
* STORED, so grades only — the wire carries the band name (see the socket
|
|
560
|
+
* contract) and the handler that writes this column is where it becomes a
|
|
561
|
+
* number.
|
|
562
|
+
* @experimental
|
|
563
|
+
*/
|
|
564
|
+
export type CapabilityOverrides = Partial<Record<CapabilityId, Grade | false>>;
|
|
565
|
+
/**
|
|
566
|
+
* Apply `IMPLIES` and `EMULATABLE_VIA` until nothing changes.
|
|
567
|
+
*
|
|
568
|
+
* Run once at the end of resolution rather than at every read, so `satisfies()`
|
|
569
|
+
* stays a lookup. The fixpoint loop is bounded by the feature count; it exists
|
|
570
|
+
* because the two relations chain — a native `grammar` gives `json_schema` at
|
|
571
|
+
* `emulated`, which in turn implies `json_object`.
|
|
572
|
+
* @experimental
|
|
573
|
+
*/
|
|
574
|
+
export declare function closure(set: CapabilitySet): CapabilitySet;
|
|
575
|
+
/** @experimental */
|
|
576
|
+
export interface ResolveCapabilitiesArgs {
|
|
577
|
+
adapter: AdapterCapabilities;
|
|
578
|
+
preset?: PresetCapabilities;
|
|
579
|
+
/** What a live probe answered. Only keys it actually determined. */
|
|
580
|
+
probe?: CapabilitySet;
|
|
581
|
+
overrides?: CapabilityOverrides;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* The four layers, collapsed to what a connection stores.
|
|
585
|
+
*
|
|
586
|
+
* Pure and total: no I/O, and every input optional, so a connection that has
|
|
587
|
+
* never been tested still resolves to something coherent rather than to nothing.
|
|
588
|
+
* @internal
|
|
589
|
+
*/
|
|
590
|
+
export declare function resolveCapabilities(args: ResolveCapabilitiesArgs): CapabilitySet;
|
|
591
|
+
/** @experimental */
|
|
592
|
+
export interface Need {
|
|
593
|
+
/** Unmet ⇒ the run fails at bind, with a sentence naming the capability. */
|
|
594
|
+
requires?: readonly CapabilityId[];
|
|
595
|
+
/** May be absent; the binding must handle both. See `ctx.can()`. */
|
|
596
|
+
optional?: readonly CapabilityId[];
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* The answer to "can this connection run this node", in the four forms its four
|
|
600
|
+
* callers need.
|
|
601
|
+
*
|
|
602
|
+
* A boolean would force each of them to walk the sets again to say anything
|
|
603
|
+
* useful — and the picker in particular must be able to say *why* a connection
|
|
604
|
+
* is not offered, or "why isn't mine in the list" has no answer anywhere.
|
|
605
|
+
* @experimental
|
|
606
|
+
*/
|
|
607
|
+
export interface Verdict {
|
|
608
|
+
ok: boolean;
|
|
609
|
+
/** Required and unavailable. The run cannot proceed. */
|
|
610
|
+
missing: CapabilityId[];
|
|
611
|
+
/**
|
|
612
|
+
* Required, available, and BELOW this capability's own top band. Proceed, but
|
|
613
|
+
* it is worth saying.
|
|
614
|
+
*
|
|
615
|
+
* Per capability, which is the point: `tools` supplied by Serene Pub over a
|
|
616
|
+
* backend that never heard of them is genuinely a lesser thing and says so,
|
|
617
|
+
* while `text->image` at grade 1 is the best `text->image` gets and is not
|
|
618
|
+
* reported as a degradation. A flat enum could not tell those apart.
|
|
619
|
+
*/
|
|
620
|
+
degraded: CapabilityId[];
|
|
621
|
+
/** Optional and unavailable — the branches the binding has to take. */
|
|
622
|
+
absent: CapabilityId[];
|
|
623
|
+
/** What `ctx.can()` reads. Only ids this need actually mentioned. */
|
|
624
|
+
grades: Partial<Record<CapabilityId, Grade>>;
|
|
625
|
+
}
|
|
626
|
+
/** @experimental */
|
|
627
|
+
export declare function satisfies(need: Need, have: CapabilitySet): Verdict;
|
|
628
|
+
/**
|
|
629
|
+
* Which METHOD a service is called by for the same capability.
|
|
630
|
+
*
|
|
631
|
+
* `chat` sends role-tagged messages; `completion` sends one text prompt. It is
|
|
632
|
+
* the same content generation — `text->text` either way — so a node asking for
|
|
633
|
+
* `text->text` must stay agnostic, and `wireModeOf` below is the "either" the
|
|
634
|
+
* agnostic caller reads.
|
|
635
|
+
*
|
|
636
|
+
* ⚠ Never "chat format". That collides with PROMPT FORMAT, which is the
|
|
637
|
+
* delimiters *inside* a completion's single prompt string (Vicuna, ChatML) and
|
|
638
|
+
* is meaningful only in `completion` mode — in `chat` mode the roles carry the
|
|
639
|
+
* structure and there is no prompt format at all, not even a default one.
|
|
640
|
+
* Conflating the two is what let a live defect hide: adapters derived the wire
|
|
641
|
+
* mode from their own local flags while the pipeline rendered a prompt format
|
|
642
|
+
* nothing carried, so a chat-shaped backend was handed a payload built for text
|
|
643
|
+
* completion and sent a placeholder greeting instead of the assembled prompt.
|
|
644
|
+
* @internal
|
|
645
|
+
*/
|
|
646
|
+
export type WireMode = (typeof WIRE_MODE_ORDER)[number];
|
|
647
|
+
/**
|
|
648
|
+
* The capability each mode is requested as.
|
|
649
|
+
*
|
|
650
|
+
* Features rather than transforms, and deliberately: what flows is `text->text`
|
|
651
|
+
* in both modes. These qualify HOW the request is made, which is exactly what
|
|
652
|
+
* the feature axis is for (`json_schema` is a field on a request, `grammar` is a
|
|
653
|
+
* decoder constraint, and these two are the shape of the prompt field itself).
|
|
654
|
+
*
|
|
655
|
+
* Two ids rather than one enum-valued key because a backend routinely offers
|
|
656
|
+
* BOTH, and a single key could not say so — nor be graded, presetted, probed and
|
|
657
|
+
* hand-overridden independently, which is the entire four-layer model.
|
|
658
|
+
* @internal
|
|
659
|
+
*/
|
|
660
|
+
export declare const WIRE_CAPABILITY: {
|
|
661
|
+
readonly chat: 'wire_chat';
|
|
662
|
+
readonly completion: 'wire_completion';
|
|
663
|
+
};
|
|
664
|
+
/**
|
|
665
|
+
* The tie-break, as data: which mode wins when a connection offers both.
|
|
666
|
+
*
|
|
667
|
+
* **Chat first.** Three reasons, in the order they matter:
|
|
668
|
+
*
|
|
669
|
+
* 1. It is the mode that LOSES NOTHING. Roles reach the model as roles; a flat
|
|
670
|
+
* completion has to encode them as delimiters the model must have been
|
|
671
|
+
* trained to read. Going the other way is always possible (a flat prompt can
|
|
672
|
+
* be rebuilt from messages) and going this way is not, so the recoverable
|
|
673
|
+
* direction is the safe default.
|
|
674
|
+
* 2. Completion mode carries a SECOND choice — which completion template — and
|
|
675
|
+
* getting it wrong produces run-on generation with no error attached. An
|
|
676
|
+
* "either" that silently required a second correct decision would not be an
|
|
677
|
+
* either.
|
|
678
|
+
* 3. It is what every adapter offering both already defaulted to before wire
|
|
679
|
+
* mode existed (`extraJson.useSession ?? true`, `prerenderPrompt ?? false`),
|
|
680
|
+
* so an existing connection keeps sending what it sent yesterday.
|
|
681
|
+
*
|
|
682
|
+
* A caller that genuinely requires one mode does not consult this at all — it
|
|
683
|
+
* asks for that mode's capability by id, like any other.
|
|
684
|
+
* @internal
|
|
685
|
+
*/
|
|
686
|
+
export declare const WIRE_MODE_ORDER: readonly ['chat', 'completion'];
|
|
687
|
+
/**
|
|
688
|
+
* The mode a resolved capability set prefers, or `undefined` if it holds neither.
|
|
689
|
+
*
|
|
690
|
+
* The "either" default: a caller that does not care hands over what the four
|
|
691
|
+
* layers resolved and is told which method to use. `undefined` is a real answer
|
|
692
|
+
* — a set that names neither wire capability has not been resolved against an
|
|
693
|
+
* adapter that declares one — and is deliberately not defaulted here, because
|
|
694
|
+
* the honest fallback depends on what the caller knows about the connection.
|
|
695
|
+
* @internal
|
|
696
|
+
*/
|
|
697
|
+
export declare function wireModeOf(have: CapabilitySet): WireMode | undefined;
|
|
698
|
+
/**
|
|
699
|
+
* What to show a person for a capability id.
|
|
700
|
+
*
|
|
701
|
+
* Never render the id itself: `text+image->text` is an address, not a name, and
|
|
702
|
+
* a capability screen full of arrows is the thing rulings about newcomers are
|
|
703
|
+
* trying to prevent. An unknown id falls back to the id so a plugin's capability
|
|
704
|
+
* is legible rather than blank.
|
|
705
|
+
* @internal
|
|
706
|
+
*/
|
|
707
|
+
export declare function capabilityLabel(id: CapabilityId): string;
|
|
708
|
+
/** The one-liner under the name, when there is one. @internal */
|
|
709
|
+
export declare function capabilityTagline(id: CapabilityId): string | undefined;
|
|
710
|
+
/** Whether a first-timer should see this without opening anything. @internal */
|
|
711
|
+
export declare const isBasicCapability: (id: CapabilityId) => boolean;
|
|
712
|
+
/**
|
|
713
|
+
* The capabilities a descriptor's slots declared as optional, as a literal union.
|
|
714
|
+
*
|
|
715
|
+
* Matched in two steps rather than one. The obvious single-step form —
|
|
716
|
+
* `S[K] extends { optional: readonly (infer C)[] }` — never matches anything,
|
|
717
|
+
* because `SlotDecl.optional` is declared OPTIONAL and that `?` survives into
|
|
718
|
+
* every inferred slot type, so a required property in the pattern can never line
|
|
719
|
+
* up with an optional one in the source. The result is a silent `never`: every
|
|
720
|
+
* `ctx.can()` call becomes an error, which at least fails loudly. The genuinely
|
|
721
|
+
* dangerous direction is the opposite one, so the inner check is written against
|
|
722
|
+
* `readonly (infer C)[]` explicitly: a slot with no `optional` infers `undefined`
|
|
723
|
+
* there, which does not match an array and contributes `never` — rather than
|
|
724
|
+
* inferring `unknown` and widening the union to accept anything at all.
|
|
725
|
+
*
|
|
726
|
+
* `DeclaredKeysOnly` is load-bearing for the same reason. The slots type arrives
|
|
727
|
+
* as `Record<string, SlotDecl> & { connection: {...literal...} }` — the literal
|
|
728
|
+
* survives, but so does the index signature, and `S[string]` is a bare `SlotDecl`
|
|
729
|
+
* whose `optional` is the full `CapabilityId[]`. Mapping over the raw `keyof`
|
|
730
|
+
* therefore unions in EVERY capability and `can()` accepts anything, silently.
|
|
731
|
+
* Stripping the index signature first is what keeps the answer to exactly what
|
|
732
|
+
* the author wrote.
|
|
733
|
+
*/
|
|
734
|
+
type DeclaredKeysOnly<T> = {
|
|
735
|
+
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
|
|
736
|
+
};
|
|
737
|
+
/** @experimental */
|
|
738
|
+
export type OptionalCapsOf<S> = S extends object ? {
|
|
739
|
+
[K in keyof DeclaredKeysOnly<S>]: DeclaredKeysOnly<S>[K] extends {
|
|
740
|
+
optional?: infer O;
|
|
741
|
+
} ? O extends readonly (infer C)[] ? C extends CapabilityId ? C : never : never : never;
|
|
742
|
+
}[keyof DeclaredKeysOnly<S>] : never;
|
|
743
|
+
export {};
|
|
744
|
+
//# sourceMappingURL=capabilities.d.ts.map
|