@yaks/model 0.0.0-stage → 0.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +868 -2
  3. package/_dist/afford.d.ts +69 -0
  4. package/_dist/afford.d.ts.map +1 -0
  5. package/_dist/attribute.d.ts +52 -0
  6. package/_dist/attribute.d.ts.map +1 -0
  7. package/_dist/batch.d.ts +28 -0
  8. package/_dist/batch.d.ts.map +1 -0
  9. package/_dist/cache.d.ts +15 -0
  10. package/_dist/cache.d.ts.map +1 -0
  11. package/_dist/deferred.d.ts +9 -0
  12. package/_dist/deferred.d.ts.map +1 -0
  13. package/_dist/graph.d.ts +3 -0
  14. package/_dist/graph.d.ts.map +1 -0
  15. package/_dist/image.d.ts +46 -0
  16. package/_dist/image.d.ts.map +1 -0
  17. package/_dist/inference.d.ts +58 -0
  18. package/_dist/inference.d.ts.map +1 -0
  19. package/_dist/limits.d.ts +142 -0
  20. package/_dist/limits.d.ts.map +1 -0
  21. package/_dist/media.d.ts +28 -0
  22. package/_dist/media.d.ts.map +1 -0
  23. package/_dist/message.d.ts +5 -0
  24. package/_dist/message.d.ts.map +1 -0
  25. package/_dist/mod.d.ts +298 -0
  26. package/_dist/mod.d.ts.map +1 -0
  27. package/_dist/offers.d.ts +19 -0
  28. package/_dist/offers.d.ts.map +1 -0
  29. package/_dist/onward.d.ts +77 -0
  30. package/_dist/onward.d.ts.map +1 -0
  31. package/_dist/prices.d.ts +27 -0
  32. package/_dist/prices.d.ts.map +1 -0
  33. package/_dist/provider.d.ts +49 -0
  34. package/_dist/provider.d.ts.map +1 -0
  35. package/_dist/results.d.ts +21 -0
  36. package/_dist/results.d.ts.map +1 -0
  37. package/_dist/route.d.ts +189 -0
  38. package/_dist/route.d.ts.map +1 -0
  39. package/_dist/sse.d.ts +4 -0
  40. package/_dist/sse.d.ts.map +1 -0
  41. package/_dist/stall.d.ts +47 -0
  42. package/_dist/stall.d.ts.map +1 -0
  43. package/_dist/step.d.ts +71 -0
  44. package/_dist/step.d.ts.map +1 -0
  45. package/_dist/submission.d.ts +7 -0
  46. package/_dist/submission.d.ts.map +1 -0
  47. package/_dist/vocab.d.ts +82 -0
  48. package/_dist/vocab.d.ts.map +1 -0
  49. package/_dist/windows.d.ts +6 -0
  50. package/_dist/windows.d.ts.map +1 -0
  51. package/afford.js +135 -0
  52. package/afford.js.map +1 -0
  53. package/afford.ts +208 -0
  54. package/attribute.js +109 -0
  55. package/attribute.js.map +1 -0
  56. package/attribute.ts +120 -0
  57. package/batch.js +8 -0
  58. package/batch.js.map +1 -0
  59. package/batch.ts +37 -0
  60. package/cache.js +28 -0
  61. package/cache.js.map +1 -0
  62. package/cache.ts +53 -0
  63. package/deferred.js +29 -0
  64. package/deferred.js.map +1 -0
  65. package/deferred.ts +54 -0
  66. package/deno.json +1 -0
  67. package/graph.js +8 -0
  68. package/graph.js.map +1 -0
  69. package/graph.ts +9 -0
  70. package/image.js +118 -0
  71. package/image.js.map +1 -0
  72. package/image.ts +108 -0
  73. package/inference.js +119 -0
  74. package/inference.js.map +1 -0
  75. package/inference.ts +223 -0
  76. package/limits.js +204 -0
  77. package/limits.js.map +1 -0
  78. package/limits.ts +230 -0
  79. package/media.js +76 -0
  80. package/media.js.map +1 -0
  81. package/media.ts +139 -0
  82. package/message.js +21 -0
  83. package/message.js.map +1 -0
  84. package/message.ts +17 -0
  85. package/mod.js +396 -0
  86. package/mod.js.map +1 -0
  87. package/mod.ts +695 -0
  88. package/offers.js +53 -0
  89. package/offers.js.map +1 -0
  90. package/offers.ts +84 -0
  91. package/onward.js +110 -0
  92. package/onward.js.map +1 -0
  93. package/onward.ts +123 -0
  94. package/package.json +53 -4
  95. package/prices.js +61 -0
  96. package/prices.js.map +1 -0
  97. package/prices.json +643 -0
  98. package/prices.ts +60 -0
  99. package/provider.js +6 -0
  100. package/provider.js.map +1 -0
  101. package/provider.ts +89 -0
  102. package/results.js +51 -0
  103. package/results.js.map +1 -0
  104. package/results.ts +47 -0
  105. package/route.js +263 -0
  106. package/route.js.map +1 -0
  107. package/route.ts +359 -0
  108. package/sse.js +71 -0
  109. package/sse.js.map +1 -0
  110. package/sse.ts +82 -0
  111. package/stall.js +166 -0
  112. package/stall.js.map +1 -0
  113. package/stall.ts +201 -0
  114. package/step.js +226 -0
  115. package/step.js.map +1 -0
  116. package/step.ts +265 -0
  117. package/submission.js +38 -0
  118. package/submission.js.map +1 -0
  119. package/submission.ts +38 -0
  120. package/vocab.js +83 -0
  121. package/vocab.js.map +1 -0
  122. package/vocab.json +613 -0
  123. package/vocab.ts +139 -0
  124. package/windows.js +35 -0
  125. package/windows.js.map +1 -0
  126. package/windows.ts +28 -0
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,298 @@
1
+ import type { Bundle, Eid, Hook, Plugin, ReadTx } from "@yaks/graph";
2
+ import type { VocabDoc } from "@yaks/vocab";
3
+ import type { Artifact } from "@yaks/blob";
4
+ import { type Price, type Usage } from "./vocab.js";
5
+ import type { MediaReceipt } from "./media.js";
6
+ export { listLabel, listPrice } from "./prices.js";
7
+ export { deferredModel } from "./deferred.js";
8
+ export { windows } from "./windows.js";
9
+ export { gone, type Link, onward, refused } from "./onward.js";
10
+ export { type ModelResult, type ModelResults, modelResults } from "./results.js";
11
+ export { message } from "./message.js";
12
+ export { type Offer, offerFor, offers, serving } from "./offers.js";
13
+ export type { Lent, Native, ProviderFacet, Spending } from "./provider.js";
14
+ export { type Executor, type FrozenModelRequest, frozenRequest, infer, type Inference, type InferenceHost, type InferenceReceipt, inferenceReply, thawedRequest } from "./inference.js";
15
+ export { type MediaReceipt, type MediaReceipts, mediaReceipts, type MediaRecord, receivedMedia, recoveredMedia } from "./media.js";
16
+ export { COST, dollars, hourly, MODEL, modelDoc, PRICE, type Price, PROVIDER, RATE_LIMIT, USAGE, type Usage, weigh } from "./vocab.js";
17
+ export { attribute, generated, merged, type Paid, type Part } from "./attribute.js";
18
+ export { type Affordable, affordable, charged, FRAMING, likely, measured, promptBound, requestBound, retained } from "./afford.js";
19
+ export { cachedPrefixExpires, cacheExpiry, prefixCacheMark } from "./cache.js";
20
+ export { acknowledged, began, submitCall, submitted } from "./submission.js";
21
+ export type { CacheContext } from "./cache.js";
22
+ import type { CacheContext } from "./cache.js";
23
+ import type { Affordable } from "./afford.js";
24
+ export { accountEid, accountHome, ACCOUNTS, dry, limitEid, limitRows, metering, signingIn, spent } from "./limits.js";
25
+ export type { Limit, Runner } from "./limits.js";
26
+ import type { Limit } from "./limits.js";
27
+ export declare let TOOL: string;
28
+ export declare let QUESTIONS: string;
29
+ export declare let ANSWER: string;
30
+ export declare let RESPONSE: string;
31
+ /** The {@link ModelError} code of a request whose {@link Request.anchor} the
32
+ * provider no longer holds: asked again with the whole conversation, it
33
+ * passes. */ export declare let UNANCHORED: string;
34
+ /**
35
+ * A provider or a model named where an eid is expected: `gpt-6-astra` in
36
+ * `using.model`. Each one's eid is derived from its name (the `identity`
37
+ * keyword), so the lookup is one read of the ids the name would have, no scan.
38
+ * A name both a provider and a model hold is refused rather than guessed.
39
+ */ export declare let addressed: (tx: ReadTx, ids: string[]) => Map<string, Eid> | Promise<Map<string, Eid>>;
40
+ /** Model vocabulary and catalogue name resolution. */ export declare let models: () => Plugin;
41
+ /** One line of a conversation as a model sees it. */ export type Item = ({
42
+ kind: 'image';
43
+ bytes: Uint8Array;
44
+ mediaType: string;
45
+ label: string;
46
+ } | {
47
+ kind: 'document';
48
+ bytes: Uint8Array;
49
+ mediaType: string;
50
+ label: string;
51
+ /** Original filename, including its extension, separate from display text. */ filename?: string;
52
+ } | {
53
+ kind: 'instruction';
54
+ text: string;
55
+ } | {
56
+ kind: 'user';
57
+ text: string;
58
+ } | {
59
+ kind: 'assistant';
60
+ text: string;
61
+ id?: string;
62
+ } | {
63
+ kind: 'call';
64
+ id: string;
65
+ name: string;
66
+ args: string;
67
+ } | {
68
+ kind: 'result';
69
+ id: string;
70
+ output: string;
71
+ }) & {
72
+ /** Who supplied these words, independent of the provider's turn role.
73
+ * Prompt assembly renders this before handing items to any provider. */ from?: string;
74
+ };
75
+ /** A tool as it is declared to the model. */ export type Tool = {
76
+ name: string;
77
+ description: string;
78
+ /** its arguments, as JSON Schema: an object, with no `oneOf`, `anyOf` or
79
+ * `allOf` at its root, which Claude's API and MCP refuse; a choice between
80
+ * arguments is said in the description and checked when the tool runs */ parameters: Record<string, unknown>;
81
+ };
82
+ /** One request to a model. */ /** Output text only; never private reasoning or partial tool arguments.
83
+ * Index identifies the final assistant item order in Reply.items. */ export type TextDelta = {
84
+ index: number;
85
+ id?: string;
86
+ text: string;
87
+ };
88
+ export type Request = {
89
+ /** The original request entity, stable across delivery recovery. */ call?: string;
90
+ /** Durably guard submission before the paid POST. Presence disables replay. */ onSubmit?: () => Promise<void>;
91
+ /** Persist the provider's first acknowledgement before consuming more output. */ onAck?: (mark: Mark) => Promise<void>;
92
+ /** Durably checkpoint private output, including incomplete streamed media. */ onReceipt?: (receipt: MediaReceipt) => Promise<void>;
93
+ /** A private receipt is already durable when this checkpoint runs. */ onMedia?: (receipt: MediaReceipt) => Promise<void>;
94
+ /** The reply's first output reached us: a token of text, reasoning or a
95
+ * tool call, or the whole reply from a request that does not stream. Called
96
+ * once, so the time to it is the request's time to first token. */ onFirst?: () => void;
97
+ /** Optional cancellation of this request, not of independent tool processes. */ signal?: AbortSignal;
98
+ onText?: (delta: TextDelta) => void;
99
+ model: string;
100
+ /** Explicit model-native inputs, such as lyrics or duration. A provider
101
+ * supporting native inputs validates them; never inferred from prose. */ input?: Record<string, unknown>;
102
+ /** Output modalities requested of a model that can generate media. */ modalities?: ('text' | 'image' | 'audio')[];
103
+ effort?: string;
104
+ instructions?: string;
105
+ items: Item[];
106
+ tools: Tool[];
107
+ /** typed questions about the conversation, answered in
108
+ * {@link Reply.answers} rather than in prose; a model that answers none
109
+ * refuses the request with a {@link ModelError} coded `questions` */ questions?: Questions;
110
+ /** the most tokens the reply may write; the provider's own limit where
111
+ * absent */ tokens?: number;
112
+ /** an anchor to continue from, in which case `items` holds only what
113
+ * followed it: whatever the same model's {@link Model.anchor} returned for an
114
+ * earlier reply. Opaque to the caller. A provider that no longer holds that
115
+ * reply (it expired, or was never kept) refuses with a {@link ModelError}
116
+ * coded {@link UNANCHORED}, and the caller asks again with the whole
117
+ * conversation. */ anchor?: string;
118
+ /** with an `anchor`, the tools by name the conversation it continues
119
+ * already declares: what the anchor's own request was sent. A provider
120
+ * that keeps declarations in the conversation declares only the others, so
121
+ * a tool loaded mid-conversation leaves the cached prefix whole. Unknown
122
+ * where absent. */ held?: string[];
123
+ /** the conversation this request continues, the same for each of its
124
+ * requests, so a provider that keys its prompt cache by conversation finds
125
+ * the prefix the last one cached */ conversation?: string;
126
+ /** the only sites the provider's own web tools may read, by hostname (a
127
+ * name under one included), with no search; where absent, the web they
128
+ * offer is the provider's whole web */ sites?: string[];
129
+ /** how long, in seconds, the request asks its provider to keep the prefix
130
+ * it caches; a provider offers a few lifetimes and keeps the longest one
131
+ * not over this, or its default where none fits or this is absent */ cacheRetention?: number;
132
+ /** The leading characters of instructions shared by this application's
133
+ * requests, its cache key, and their independent retention preference. */ cachePrefix?: {
134
+ length: number;
135
+ key: string;
136
+ retention: number;
137
+ /** Tool declarations shared by all requests using this prefix. */ tools?: string[];
138
+ };
139
+ /** Context supplied for this request only, after the transcript. */ turnContext?: Item[];
140
+ /** how long, in seconds, the reply's stream may go without progress (the
141
+ * connection, its first byte, any gap after) before the request fails as
142
+ * `stalled`; `@yaks/model/stall` `STALL_TIMEOUT` where absent, 0 for no
143
+ * limit. Its provider's row may name its own (`provider{stall_timeout}`). */ stallTimeout?: number;
144
+ };
145
+ /** One typed question, in Jev's terms: a `noul` is answered with the
146
+ * probability that it holds, a `choice` with one of its criteria's names, and
147
+ * a `score` with a number along its criteria, which are ordered. */ export type Question = {
148
+ type: 'noul' | 'choice' | 'score';
149
+ instructions: unknown;
150
+ /** a noul's `{true, false}`, a choice's options by name, a score's ordered
151
+ * list */ criteria?: unknown;
152
+ };
153
+ /** The questions a request asks, by name. */ export type Questions = Record<string, Question>;
154
+ /** A model's answer to one question: whichever of `noul`, `choice` and
155
+ * `score` its type calls for, how sure it is, and each option's probability. */ export type Answer = {
156
+ type?: Question['type'];
157
+ noul?: number;
158
+ choice?: string;
159
+ score?: number;
160
+ confidence?: number;
161
+ probabilities?: Record<string, number>;
162
+ };
163
+ /** One reply: the provider's id, the model that served it, and the items it
164
+ * produced. */ export type Reply = {
165
+ id: string;
166
+ model: string;
167
+ items: Item[];
168
+ /** what the model said of its reasoning before these items, as its
169
+ * provider returns it (a summary, or its thinking): for a person to read,
170
+ * never sent back to a model */ thought?: string;
171
+ /** the answer to each of the request's questions, by the question's name */ answers?: Record<string, Answer>;
172
+ usage?: Usage;
173
+ /** Effective cached-prefix expiry, not response/credential retention. Adapters
174
+ * supply explicit expiry; the resolver applies documented retention. Null
175
+ * means the provider sent an invalid value; it must not gain a fallback. */ cacheExpiresAt?: string | null;
176
+ /** the dollars the provider reported this request cost, where it reports
177
+ * them; a caller weighs `usage` at the model's {@link Price} otherwise */ cost?: number;
178
+ /** False for an adapter-measured tariff; provider-reported by default. */ costReported?: boolean;
179
+ artifacts?: (Artifact & {
180
+ call: string;
181
+ revised_prompt?: string;
182
+ })[];
183
+ /** The reply stopped at its output token limit (`Request.tokens`): what it
184
+ * was writing last is unfinished, a tool call's arguments included. */ cut?: boolean;
185
+ /** the plan limits the provider answered with, where it meters a plan */ limits?: Limit[];
186
+ };
187
+ /** The components a provider writes on the entry that records a reply. */ export type Mark = Record<string, Record<string, unknown>>;
188
+ /**
189
+ * A model: one request in, one reply out. A provider that stores something
190
+ * about a reply does so through three optional members, so that the
191
+ * conversation never has to know that provider's components: `mark` returns
192
+ * what to write on the entry recording the reply, `anchor` reads an anchor back
193
+ * off such an entry's components (or returns nothing, in which case the caller
194
+ * replays the conversation), and `vocab` declares the components `mark` writes.
195
+ * A plain function is a model that stores nothing.
196
+ */ export type Model = ((req: Request) => Promise<Reply>) & {
197
+ /** Download/store a saved recording only; never calls generation. */ recover?: (call: string) => Promise<Reply>;
198
+ /** A saved complete answer, with any original accounting finished; never generation. */ result?: (call: string, signal?: AbortSignal) => Promise<import("./results.js").ModelResult | undefined>;
199
+ /** Retrieve the original generation using its durable acknowledgement. */ retrieve?: (mark: Mark, signal?: AbortSignal) => Promise<Reply | undefined>;
200
+ list?: () => Promise<Listed[]>;
201
+ /** The input tokens its provider counts a request at, anchored history and
202
+ * framing included: what it will bill as that request's input. A meter
203
+ * holds this in place of a bound it works out (./afford.ts). */ count?: (req: Request) => Promise<number>;
204
+ info?: (name: string) => Promise<Listed | undefined>;
205
+ mark?: (reply: Reply, cache?: CacheContext) => Mark;
206
+ anchor?: (comps: Record<string, unknown>) => string | undefined;
207
+ vocab?: VocabDoc;
208
+ /** Takes a later output of a tool call it already has one for. Without it,
209
+ * a call that finishes after its first output is told as user text. */ lateResults?: true;
210
+ /** The media types it reads as they are, beside text, each with the most
211
+ * raw bytes of one file it takes, or Infinity for no published byte cap.
212
+ * A function selects the requested model's capabilities. Request-wide limits
213
+ * still apply. Without it, a file is read as its text. */ reads?: Record<string, number> | ((name: string) => Record<string, number> | Promise<Record<string, number>>);
214
+ /** What a request priced by the call rather than by its tokens (a track of
215
+ * music) would cost within `remaining` dollars, null where it would not
216
+ * fit; undefined for a request its tokens price. */ quote?: (req: Request, remaining: number) => Affordable | null | undefined;
217
+ /** The most its provider-run tools (a hosted web search or page fetch) add
218
+ * to one request, which a meter reserves beside the request's own bound. */ hosted?: Hosted;
219
+ };
220
+ /** Native file inputs for the selected model, including a provider's lazy lookup. */ export declare let modelReads: (model: Model, name: string) => Promise<Record<string, number>>;
221
+ /** What a model's provider-run tools may add to one request: at most
222
+ * `searches` web searches, billed at {@link Price} `web_search`, and `input`
223
+ * tokens of what they read fed back as input. The provider enforces both. */ export type Hosted = {
224
+ searches: number;
225
+ input: number;
226
+ };
227
+ /** What a provider answered a failed request with, as it arrived: the body of
228
+ * an error status, or the event that ended its stream, and the headers that
229
+ * speak of its limits. Stored as `response{body, headers}` beside the line
230
+ * recording the failure. */ export type Answered = {
231
+ body?: string;
232
+ headers?: Record<string, string>;
233
+ };
234
+ /** A failure the caller expects: `code` is the provider's own error code when
235
+ * it gave one, otherwise a name for the kind of failure. */ export declare class ModelError extends Error {
236
+ code: string;
237
+ /** The failure may pass: the caller can ask again, no sooner than `after`
238
+ * milliseconds where the provider said how long to wait. With `defer`, it
239
+ * is no failure but a wait for something outside: asked again as the same
240
+ * attempt, however long that takes (@yaks/effects spends no try on it). */ retry?: {
241
+ after?: number;
242
+ defer?: boolean;
243
+ resume_on?: string;
244
+ };
245
+ /** what the provider sent, where it sent anything */ response?: Answered;
246
+ /** the plan limits the provider answered with, where it meters a plan */ limits?: Limit[];
247
+ /** what the provider said the request used before it failed, where it
248
+ * said: a meter settles the request's hold at it */ usage?: Usage;
249
+ constructor(code: string, message?: any, retry?: {
250
+ after?: number;
251
+ defer?: boolean;
252
+ resume_on?: string;
253
+ }, response?: Answered);
254
+ }
255
+ /**
256
+ * What a person sees a model called: its row's `label` ("Sonnet 5.5"), else
257
+ * the label the list gives its name ({@link listLabel}), as a row that has
258
+ * none takes it when next asked; never its id. A model neither labels, or one
259
+ * with no row, is called by its name or its id, and `missing` hears an error
260
+ * to report, so the row gets one.
261
+ *
262
+ * ```ts
263
+ * import { labelOf } from '@yaks/model'
264
+ * import { equal } from '@yaks/testing'
265
+ *
266
+ * let heard: string[] = []
267
+ * let missing = (e: Error) => heard.push(e.message)
268
+ * equal(labelOf({ name: 'gpt-6.2-sol', label: 'Sol' }, missing), 'Sol')
269
+ * equal(labelOf({ name: 'claude-sonnet-5-5' }, missing), 'Sonnet 5.5')
270
+ * equal(labelOf({ name: 'glm-5.3' }, missing), 'glm-5.3')
271
+ * equal(labelOf(undefined, missing, 'O-9'), 'O-9')
272
+ * equal(heard, ['model glm-5.3 has no label', 'model O-9 has no row'])
273
+ * ```
274
+ */ export declare let labelOf: (model: {
275
+ name?: unknown;
276
+ label?: unknown;
277
+ } | null | undefined, missing?: (error: Error) => void, id?: string) => string;
278
+ /** What a provider says about one of its models, in graph vocabulary. */ export type Listed = {
279
+ name: string;
280
+ label?: string;
281
+ context?: number;
282
+ output?: number;
283
+ modalities?: string[];
284
+ price?: Price;
285
+ };
286
+ /** A requested name exists before dispatch, but is not offered until answered.
287
+ * A model with no price, met for the first time or held since before the
288
+ * table knew it, is weighed at its list price ({@link listPrice}) unless the
289
+ * batch prices it; a price on a stored row stands. A model with no label
290
+ * takes its list label ({@link listLabel}) the same way. A provider a `using`
291
+ * names that no row holds is a row of that name from then on: the host lent it
292
+ * is the one that answers it. */ export declare let requesting: Hook;
293
+ /** A provider's answer confirms a requested model; old asks keep their row. */ export declare let confirmed: (provider: string, name: string, listing?: Listed) => Bundle[];
294
+ /** Reported dollars win; otherwise usage is weighed at the model row's price. */ export declare let billed: (reply: Reply, price?: Price) => {
295
+ dollars: number;
296
+ reported: boolean;
297
+ } | undefined;
298
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AA+CA,cACE,MAAM,EAGN,GAAG,EACH,IAAI,EACJ,MAAM,EACN,MAAM,2BACuB;AAI/B,cAAc,QAAQ,2BAAgC;AAEtD,cAAc,QAAQ,0BAA+B;AACrD,SAGE,KAAK,KAAK,EAEV,KAAK,KAAK,qBAEO;AACnB,cAAc,YAAY,qBAAoB;AAE9C,SAAS,SAAS,EAAE,SAAS,sBAAqB;AAClD,SAAS,aAAa,wBAAuB;AAC7C,SAAS,OAAO,uBAAsB;AACtC,SAAS,IAAI,EAAE,KAAK,IAAI,EAAE,MAAM,EAAE,OAAO,sBAAqB;AAC9D,SAAS,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,YAAY,uBAAsB;AAChF,SAAS,OAAO,uBAAsB;AACtC,SAAS,KAAK,KAAK,EAAE,Q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E;EAC/D,mDAAmD,GACnD,WAAW,SAAQ;EACnB,uEAAuE,GACvE,SAAS,QAAO;EAChB;oDACkD,GAClD,QAAQ,MAAK;EACb,YACE,MAAM,MAAM,EACZ,aAAc,EACd;IAAU,QAAQ,MAAM;IAAE,QAAQ,OAAO;IAAE,YAAY,MAAM;GAAE,EAC/D,WAAW,QAAQ;AAQvB;AAEA;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,YAAI,UACT;EAAS,OAAO,OAAO;EAAE,QAAQ,OAAO;IAAK,IAAI,GAAG,SAAS,EAC7D,WAAW,OAAO,UAAU,IAAI,EAChC,KAAK,MAAM,KACV,MAAM,CASR;AAED,uEAAuE,GACvE,YAAY;EACV,MAAM,MAAM;EACZ,QAAQ,MAAM;EACd,UAAU,MAAM;EAChB,SAAS,MAAM;EACf,aAAa,MAAM;EACnB,QAAQ;;AAGV;;;;;;+BAM+B,GAC/B,OAAO,YAAI,YAAY,KA+GtB;AAED,6EAA6E,GAC7E,OAAO,YAAI,YACT,UAAU,MAAM,EAChB,MAAM,MAAM,EACZ,UAAU,WACT,SAaF;AAED,+EAA+E,GAC/E,OAAO,YAAI,SACT,OAAO,OACP,QAAQ;EACL,SAAS,MAAM;EAAE,UAAU,OAAO;IAAK,SAAS,CAKtC"}
@@ -0,0 +1,19 @@
1
+ import type { Eid, Graph } from "@yaks/graph";
2
+ import { type Model } from "./mod.js";
3
+ /** One provider's offering of a model: who serves it, under what name, and
4
+ * the implementation this host has for that provider (if any). */ export type Offer = {
5
+ provider: Eid;
6
+ model: Eid;
7
+ name: string;
8
+ serve?: Model;
9
+ };
10
+ /** Every `serves` edge that points at a model, each with the implementation
11
+ * this host has for its provider. */ export declare let offers: (g: Pick<Graph, 'read' | 'get'>, model: Eid, implementations: Readonly<Record<string, Model>>) => Promise<Offer[]>;
12
+ /** The offer a `using` resolves to: the named provider's, which must serve the
13
+ * model, or else the one provider this host can reach that serves it. */ export declare let offerFor: (all: Offer[], provider?: unknown) => Offer | string;
14
+ /** A host's providers as one model, asked for a model by its own name
15
+ * (`model.name`, the same row in every graph): the one of `implementations`
16
+ * whose provider `g` says serves it answers, under the name that provider
17
+ * calls it. A name none of them serves, or several do, is refused with a
18
+ * `ModelError` coded `provider`. */ export declare let serving: (g: Pick<Graph, 'read' | 'get'>, implementations: Readonly<Record<string, Model>>) => Model;
19
+ //# sourceMappingURL=offers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"offers.d.ts","sources":["../offers.ts"],"names":[],"mappings":"AAIA,cAAoB,GAAG,EAAE,KAAK,2BAAgC;AAG9D,SAAS,KAAK,KAAK,mBAA8B;AAGjD;gEACgE,GAChE,YAAY;EACV,UAAU;EACV,OAAO;EACP,MAAM,MAAM;EACZ,QAAQ;;AAGV;mCACmC,GACnC,OAAO,YAAI,SACT,GAAG,KAAK,OAAO,SAAS,QACxB,OAAO,KACP,iBAAiB,SAAS,OAAO,MAAM,EAAE,YACxC,QAAQ,SAsBV;AAED;uEACuE,GACvE,OAAO,YAAI,WACT,KAAK,SACL,WAAW,OAAO,KACjB,QAAQ,MAAM,CAahB;AAED;;;;kCAIkC,GAClC,OAAO,YAAI,UACT,GAAG,KAAK,OAAO,SAAS,QACxB,iBAAiB,SAAS,OAAO,MAAM,EAAE,YACxC,MAMF"}
@@ -0,0 +1,77 @@
1
+ import { type Model, ModelError, type Request } from "./mod.js";
2
+ /**
3
+ * Whether `error` is a provider saying it has no model by the name asked: one
4
+ * it retired, or one it never had.
5
+ *
6
+ * ```ts
7
+ * import { gone, ModelError } from '@yaks/model'
8
+ * import { equal } from '@yaks/testing'
9
+ * equal(gone(new ModelError('model', '5028: m was deprecated')), true)
10
+ * equal(gone(new ModelError('model_not_found')), true)
11
+ * equal(gone(new ModelError('busy')), false)
12
+ * equal(gone(new Error('model')), false)
13
+ * ```
14
+ */ export declare let gone: (error: unknown) => error is ModelError;
15
+ /**
16
+ * Whether `error` is a provider declining to run the request at all: the
17
+ * model asked is {@link gone}, or the provider's own account is dry (@yaks/model
18
+ * `dry`: its spend limit, billing quota, credit or plan window used up), or
19
+ * the request has no credential. A
20
+ * refused request ran nothing, so it costs nothing and another provider may
21
+ * take it. A caller's own ceiling (`limit`) is no refusal: every provider
22
+ * would meet it.
23
+ *
24
+ * ```ts
25
+ * import { ModelError, refused } from '@yaks/model'
26
+ * import { equal } from '@yaks/testing'
27
+ * equal(refused(new ModelError('model')), true)
28
+ * equal(refused(new ModelError('project_spend_limit_exceeded')), true)
29
+ * equal(refused(new ModelError('credit')), true)
30
+ * equal(refused(new ModelError('no_credential')), true)
31
+ * equal(refused(new ModelError('limit')), false)
32
+ * equal(refused(new ModelError('busy')), false)
33
+ * ```
34
+ */ export declare let refused: (error: unknown) => error is ModelError;
35
+ /** One model of a chain: what asks it, and the name it is asked by. */ export type Link = {
36
+ model: Model;
37
+ name: string;
38
+ };
39
+ /**
40
+ * A model that asks `chain(req)` in order: the first link answers the step,
41
+ * and a link {@link refused} before producing output passes the step to the
42
+ * next, even where the provider acknowledged the request first. `passed`
43
+ * hears each such failure with the name it was asked by. Other failures are
44
+ * thrown as they came.
45
+ *
46
+ * ```ts
47
+ * import { type Model, ModelError, onward } from '@yaks/model'
48
+ * import { equal } from '@yaks/testing'
49
+ * let failing = (code: string): Model => () => Promise.reject(new ModelError(code))
50
+ * let acked = (code: string): Model => async (req) => {
51
+ * await req.onAck?.({ p: { id: 'r' } })
52
+ * throw new ModelError(code)
53
+ * }
54
+ * let started = (code: string): Model => (req) => {
55
+ * req.onFirst?.()
56
+ * return Promise.reject(new ModelError(code))
57
+ * }
58
+ * let ok: Model = (req) =>
59
+ * Promise.resolve({ id: 'r', model: req.model, items: [] })
60
+ * let heard: string[] = []
61
+ * let chain = (links: Model[]) => () =>
62
+ * links.map((model, i) => ({ model, name: 'm' + i }))
63
+ * let ask = (...links: Model[]) =>
64
+ * onward(chain(links), (name) => heard.push(name))(
65
+ * { model: 'm0', items: [], tools: [] },
66
+ * ).then((r) => r.model, (e) => e.code)
67
+ * equal(await ask(failing('model'), ok), 'm1')
68
+ * equal(await ask(acked('project_spend_limit_exceeded'), ok), 'm1')
69
+ * equal(await ask(failing('credit'), failing('model'), ok), 'm2')
70
+ * equal(await ask(failing('busy'), ok), 'busy')
71
+ * equal(await ask(failing('limit'), ok), 'limit')
72
+ * equal(await ask(started('credit'), ok), 'credit')
73
+ * equal(await ask(failing('model')), 'model')
74
+ * equal(heard, ['m0', 'm0', 'm0', 'm1'])
75
+ * ```
76
+ */ export declare let onward: (chain: (req: Request) => Link[] | Promise<Link[]>, passed?: (name: string, error: ModelError) => void) => Model;
77
+ //# sourceMappingURL=onward.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onward.d.ts","sources":["../onward.ts"],"names":[],"mappings":"AAKA,SAAS,KAAK,KAAK,EAAE,UAAU,EAAE,KAAK,OAAO,mBAAkB;AAQ/D;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,OAAQ,OAAO,OAAO,KAAG,SAAS,WACQ;AAErD;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,YAAI,UAAW,OAAO,OAAO,KAAG,SAAS,WAEC;AAEjD,qEAAqE,GACrE,YAAY;EAAS,OAAO;EAAO,MAAM,MAAM;;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCC,GACD,OAAO,YAAI,SACT,QAAQ,KAAK,YAAY,SAAS,QAAQ,SAC1C,UAAU,MAAM,MAAM,EAAE,OAAO,eAAe,IAAI,KACjD,MAyBF"}
@@ -0,0 +1,27 @@
1
+ import type { Price } from "./vocab.js";
2
+ /**
3
+ * The list price of the model a request names, if the table holds it.
4
+ *
5
+ * ```ts
6
+ * import { listPrice } from '@yaks/model'
7
+ * import { assertEquals } from '@std/assert'
8
+ *
9
+ * assertEquals(listPrice('claude-haiku-4-5-20251001'), listPrice('claude-haiku-4-5'))
10
+ * assertEquals(listPrice('no-such-model'), undefined)
11
+ * ```
12
+ */ export declare let listPrice: (name: string) => Price | undefined;
13
+ /**
14
+ * What the table calls the model a request names, its window said after it,
15
+ * if the table holds it.
16
+ *
17
+ * ```ts
18
+ * import { listLabel } from '@yaks/model'
19
+ * import { assertEquals } from '@std/assert'
20
+ *
21
+ * assertEquals(listLabel('claude-sonnet-5-5'), 'Sonnet 5.5')
22
+ * assertEquals(listLabel('claude-opus-4-8[1m]'), 'Opus 4.8 1M')
23
+ * assertEquals(listLabel('gpt-6.2-sol'), 'GPT-6.2 Sol')
24
+ * assertEquals(listLabel('no-such-model'), undefined)
25
+ * ```
26
+ */ export declare let listLabel: (name: string) => string | undefined;
27
+ //# sourceMappingURL=prices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prices.d.ts","sources":["../prices.ts"],"names":[],"mappings":"AAOA,cAAc,KAAK,qBAAoB;AAqBvC;;;;;;;;;;CAUC,GACD,OAAO,YAAI,YAAa,MAAM,MAAM,KAAG,QAAQ,SAAS,CAAwB;AAEhF;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,YAAa,MAAM,MAAM,KAAG,MAAM,GAAG,SAAS,CAIxD"}
@@ -0,0 +1,49 @@
1
+ import type { ArtifactStore } from "@yaks/blob";
2
+ import type { Hold, Scope } from "@yaks/fp";
3
+ import type { Affordable } from "./afford.js";
4
+ import type { Listed, MediaReceipts, Model } from "./mod.js";
5
+ /** What a host lends the providers it composes. */ export type Lent = {
6
+ /** the connections every provider shares (a pool the host closes) */ fetch: typeof fetch;
7
+ /** the key the person signed in to `integration` with, if they did */ key: (integration: string) => Promise<string | undefined>;
8
+ /** a fresh key for `integration`, when `stale` stopped working */ refresh: (integration: string, stale: string) => Promise<string | undefined>;
9
+ /** where media a model generates is kept */ store: ArtifactStore;
10
+ /** the host's settings, `OPENAI_API_KEY` among them */ env: (name: string) => string | undefined;
11
+ /** where a call's private provider results are kept, so an interrupted
12
+ * call is delivered again without being bought again (a host that keeps
13
+ * none lends none) */ receipts?: MediaReceipts;
14
+ /** who may share a read under way, as @yaks/fp `sharing` takes it: the
15
+ * host's current request or object; a host that lends none shares only
16
+ * finished reads */ scope?: Scope;
17
+ /** keeps work a call leaves behind (a cancel sent once its reply is
18
+ * dropped) alive past its request, as a Worker's `waitUntil` does */ hold?: Hold;
19
+ };
20
+ /** What a host holds a provider's own calls to ({@link Native}): each is
21
+ * quoted before it is made, held to what the quote affords of what remains,
22
+ * and settled at what it cost. */ export type Spending = {
23
+ /** the most `quote` affords of what remains, held until settled; refused
24
+ * (a `ModelError` coded `limit`) where nothing fits */ hold: (quote: (remaining: number) => Affordable | null) => Promise<{
25
+ value: Affordable;
26
+ settle: (dollars: number, reported: boolean) => Promise<unknown>;
27
+ }>;
28
+ /** a model answered, as its provider lists it */ answered?: (name: string, info: Listed) => Promise<void>;
29
+ /** a failure that is the host's to hear rather than the caller's, such as
30
+ * the account's own credit spent */ report?: (error: unknown, model: string) => void;
31
+ };
32
+ /** A provider's own door: one call to a model, as the provider's API takes
33
+ * it, answered with what the model said. */ export type Native = {
34
+ /** whether it answers `model`; a door that doesn't say answers every name */ serves?: (model: string) => boolean;
35
+ run: (model: string, input: unknown, options?: {
36
+ extraHeaders?: Record<string, string>;
37
+ }) => Promise<unknown>;
38
+ };
39
+ /** A `./provider` facet: the models a plugin serves, keyed by the
40
+ * `provider.name` each serves under, given what the host lends and the
41
+ * plugin's own options from the config. */ export type ProviderFacet = {
42
+ providers?: (lent: Lent, options: Record<string, unknown>) => Record<string, Model>;
43
+ /** the hosts those models call with these options: where a host may send a
44
+ * credential it puts in their calls, and nowhere else */ hosts?: (options: Record<string, unknown>) => string[];
45
+ /** The options to carry when another host runs a single model request. */ modelOptions?: (options: Record<string, unknown>, model: string) => Record<string, unknown>;
46
+ /** its own door, each call held to what `spending` affords, for a host
47
+ * that passes a caller's input to the provider as it is */ native?: (lent: Lent, options: Record<string, unknown>, spending: Spending) => Native;
48
+ };
49
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sources":["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BACE,SAAS,OAAO,MAAM,EAAE,OAAO,GAC/B,OAAO,MAAM,KACV,OAAO,MAAM,EAAE,OAAO;EAC3B;2DACyD,GACzD,UACE,MAAM,MACN,SAAS,OAAO,MAAM,EAAE,OAAO,GAC/B,UAAU,aACP"}
@@ -0,0 +1,21 @@
1
+ import type { Graph } from "@yaks/graph";
2
+ import type { Mark, Reply } from "./mod.js";
3
+ import type { Price } from "./vocab.js";
4
+ export type ModelResult = {
5
+ reply: Reply;
6
+ mark?: Mark;
7
+ };
8
+ export type Acknowledgement = {
9
+ provider: string;
10
+ mark: Mark;
11
+ tariff?: Price;
12
+ requestedAt: number;
13
+ };
14
+ export type ModelResults = {
15
+ read(call: string): Promise<ModelResult | undefined>;
16
+ save(call: string, result: ModelResult): Promise<void>;
17
+ pending?(call: string): Promise<Acknowledgement | undefined>;
18
+ acknowledge?(call: string, evidence: Acknowledgement): Promise<void>;
19
+ };
20
+ /** Keep completed answers with their original ask in its own graph. */ export declare let modelResults: (g: Pick<Graph, 'get' | 'apply'>) => Required<ModelResults>;
21
+ //# sourceMappingURL=results.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"results.d.ts","sources":["../results.ts"],"names":[],"mappings":"AACA,cAAc,KAAK,2BAAgC;AACnD,cAAc,IAAI,EAAE,KAAK,mBAAkB;AAC3C,cAAc,KAAK,qBAAoB;AAEvC,YAAY;EAAgB,OAAO;EAAO,OAAO;;AACjD,YAAY;EACV,UAAU,MAAM;EAChB,MAAM;EACN,SAAS;EACT,aAAa,MAAM;;AAGrB,YAAY;EACV,KAAK,MAAM,MAAM,GAAG,QAAQ,cAAc,SAAS;EACnD,KAAK,MAAM,MAAM,EAAE,QAAQ,cAAc,QAAQ,IAAI;EACrD,SAAS,MAAM,MAAM,GAAG,QAAQ,kBAAkB,SAAS;EAC3D,aAAa,MAAM,MAAM,EAAE,UAAU,kBAAkB,QAAQ,IAAI;;AAGrE,qEAAqE,GACrE,OAAO,YAAI,eACT,GAAG,KAAK,OAAO,QAAQ,aACtB,SAAS,cAuBV"}