@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.
- package/LICENSE +202 -0
- package/README.md +868 -2
- package/_dist/afford.d.ts +69 -0
- package/_dist/afford.d.ts.map +1 -0
- package/_dist/attribute.d.ts +52 -0
- package/_dist/attribute.d.ts.map +1 -0
- package/_dist/batch.d.ts +28 -0
- package/_dist/batch.d.ts.map +1 -0
- package/_dist/cache.d.ts +15 -0
- package/_dist/cache.d.ts.map +1 -0
- package/_dist/deferred.d.ts +9 -0
- package/_dist/deferred.d.ts.map +1 -0
- package/_dist/graph.d.ts +3 -0
- package/_dist/graph.d.ts.map +1 -0
- package/_dist/image.d.ts +46 -0
- package/_dist/image.d.ts.map +1 -0
- package/_dist/inference.d.ts +58 -0
- package/_dist/inference.d.ts.map +1 -0
- package/_dist/limits.d.ts +142 -0
- package/_dist/limits.d.ts.map +1 -0
- package/_dist/media.d.ts +28 -0
- package/_dist/media.d.ts.map +1 -0
- package/_dist/message.d.ts +5 -0
- package/_dist/message.d.ts.map +1 -0
- package/_dist/mod.d.ts +298 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/offers.d.ts +19 -0
- package/_dist/offers.d.ts.map +1 -0
- package/_dist/onward.d.ts +77 -0
- package/_dist/onward.d.ts.map +1 -0
- package/_dist/prices.d.ts +27 -0
- package/_dist/prices.d.ts.map +1 -0
- package/_dist/provider.d.ts +49 -0
- package/_dist/provider.d.ts.map +1 -0
- package/_dist/results.d.ts +21 -0
- package/_dist/results.d.ts.map +1 -0
- package/_dist/route.d.ts +189 -0
- package/_dist/route.d.ts.map +1 -0
- package/_dist/sse.d.ts +4 -0
- package/_dist/sse.d.ts.map +1 -0
- package/_dist/stall.d.ts +47 -0
- package/_dist/stall.d.ts.map +1 -0
- package/_dist/step.d.ts +71 -0
- package/_dist/step.d.ts.map +1 -0
- package/_dist/submission.d.ts +7 -0
- package/_dist/submission.d.ts.map +1 -0
- package/_dist/vocab.d.ts +82 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/windows.d.ts +6 -0
- package/_dist/windows.d.ts.map +1 -0
- package/afford.js +135 -0
- package/afford.js.map +1 -0
- package/afford.ts +208 -0
- package/attribute.js +109 -0
- package/attribute.js.map +1 -0
- package/attribute.ts +120 -0
- package/batch.js +8 -0
- package/batch.js.map +1 -0
- package/batch.ts +37 -0
- package/cache.js +28 -0
- package/cache.js.map +1 -0
- package/cache.ts +53 -0
- package/deferred.js +29 -0
- package/deferred.js.map +1 -0
- package/deferred.ts +54 -0
- package/deno.json +1 -0
- package/graph.js +8 -0
- package/graph.js.map +1 -0
- package/graph.ts +9 -0
- package/image.js +118 -0
- package/image.js.map +1 -0
- package/image.ts +108 -0
- package/inference.js +119 -0
- package/inference.js.map +1 -0
- package/inference.ts +223 -0
- package/limits.js +204 -0
- package/limits.js.map +1 -0
- package/limits.ts +230 -0
- package/media.js +76 -0
- package/media.js.map +1 -0
- package/media.ts +139 -0
- package/message.js +21 -0
- package/message.js.map +1 -0
- package/message.ts +17 -0
- package/mod.js +396 -0
- package/mod.js.map +1 -0
- package/mod.ts +695 -0
- package/offers.js +53 -0
- package/offers.js.map +1 -0
- package/offers.ts +84 -0
- package/onward.js +110 -0
- package/onward.js.map +1 -0
- package/onward.ts +123 -0
- package/package.json +53 -4
- package/prices.js +61 -0
- package/prices.js.map +1 -0
- package/prices.json +643 -0
- package/prices.ts +60 -0
- package/provider.js +6 -0
- package/provider.js.map +1 -0
- package/provider.ts +89 -0
- package/results.js +51 -0
- package/results.js.map +1 -0
- package/results.ts +47 -0
- package/route.js +263 -0
- package/route.js.map +1 -0
- package/route.ts +359 -0
- package/sse.js +71 -0
- package/sse.js.map +1 -0
- package/sse.ts +82 -0
- package/stall.js +166 -0
- package/stall.js.map +1 -0
- package/stall.ts +201 -0
- package/step.js +226 -0
- package/step.js.map +1 -0
- package/step.ts +265 -0
- package/submission.js +38 -0
- package/submission.js.map +1 -0
- package/submission.ts +38 -0
- package/vocab.js +83 -0
- package/vocab.js.map +1 -0
- package/vocab.json +613 -0
- package/vocab.ts +139 -0
- package/windows.js +35 -0
- package/windows.js.map +1 -0
- package/windows.ts +28 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Request } from "./mod.js";
|
|
2
|
+
import { type Price, type Usage } from "./vocab.js";
|
|
3
|
+
export type Affordable = {
|
|
4
|
+
tokens: number;
|
|
5
|
+
dollars: number;
|
|
6
|
+
};
|
|
7
|
+
/** Tokens a provider may add around a prompt: role markers, a chat template's
|
|
8
|
+
* own system text, tool framing. */ export declare let FRAMING: number;
|
|
9
|
+
/** An upper bound on the input tokens a text prompt and the tools it declares
|
|
10
|
+
* can bill, never above the model's context window. A text token covers at
|
|
11
|
+
* least one UTF-8 byte, so the compact JSON bounds the text; doubling it
|
|
12
|
+
* covers a template that re-renders that JSON with spaces and indentation,
|
|
13
|
+
* and FRAMING the markers around it. Media is tokenized by its pixels or
|
|
14
|
+
* samples, not its bytes, so a prompt carrying any is bounded by the context
|
|
15
|
+
* window alone. Only the prompt is searched for media: a tool is declared as
|
|
16
|
+
* text, whatever its arguments are named. */ export declare let promptBound: (prompt: unknown, context: number, tools?: unknown) => number;
|
|
17
|
+
type Prompt = Pick<Request, 'instructions' | 'questions' | 'input'> & {
|
|
18
|
+
items: unknown[];
|
|
19
|
+
turnContext?: unknown[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* What a request that failed with nothing measured most likely cost, never
|
|
23
|
+
* above `most`, its hold: the text it sent at the input tariff, its anchored
|
|
24
|
+
* history uncounted since a cut request reads little of it, and the `output`
|
|
25
|
+
* tokens it was seen writing at the output tariff. An estimate, not a bound:
|
|
26
|
+
* it settles a hold the provider said nothing of, where the worst case would
|
|
27
|
+
* charge a space for money never spent.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { likely } from '@yaks/model'
|
|
31
|
+
* import { equal } from '@yaks/testing'
|
|
32
|
+
* let price = { input: 1, output: 10 }
|
|
33
|
+
* // 1,003 tokens of text sent, about four bytes each
|
|
34
|
+
* let req = { instructions: 'x'.repeat(3990), items: [], tools: [] }
|
|
35
|
+
* equal(likely(req, price, 5), 0.001003)
|
|
36
|
+
* equal(likely(req, price, 5, 100), 0.002003)
|
|
37
|
+
* equal(likely(req, price, 0.0005), 0.0005)
|
|
38
|
+
* ```
|
|
39
|
+
*/ export declare let likely: (req: Prompt & Pick<Request, 'tools'>, price: Price, most: number, output?: number) => number;
|
|
40
|
+
/** A request's input bound. An anchor continues a conversation the provider
|
|
41
|
+
* holds, whose earlier turns this side cannot measure. */ export declare let requestBound: (req: Prompt & Pick<Request, 'anchor' | 'tools'>, context: number) => number;
|
|
42
|
+
/** A request's price as it can be billed. A provider keeps the longest cache
|
|
43
|
+
* lifetime it offers that is not over what the request asks
|
|
44
|
+
* (`Request.cacheRetention`), or its default, so only a request asking an
|
|
45
|
+
* hour can write to the hour's cache at its dearer tariff. */ export declare let retained: (price: Price, seconds?: number, shared?: number) => Price;
|
|
46
|
+
/** The most output affordable after reserving every input token at its highest
|
|
47
|
+
* possible tariff, and `searches` web searches at theirs. The returned dollars
|
|
48
|
+
* cover that entire call; a provider must enforce the returned output token
|
|
49
|
+
* limit before it spends anything. */ export declare let affordable: (price: Price, input: number, remaining: number, tokens?: number, searches?: number) => Affordable | null;
|
|
50
|
+
/** Measured dollars require reported cost or complete usage. Input the
|
|
51
|
+
* provider classified (it said how many tokens it wrote to the cache, none
|
|
52
|
+
* included) is weighed as it said; unclassified input uses its highest cache
|
|
53
|
+
* tariff; missing usage stays unknown. */ export declare let measured: (reply: {
|
|
54
|
+
cost?: number;
|
|
55
|
+
costReported?: boolean;
|
|
56
|
+
usage?: Usage;
|
|
57
|
+
}, price: Price | undefined) => {
|
|
58
|
+
dollars: number;
|
|
59
|
+
reported: boolean;
|
|
60
|
+
} | undefined;
|
|
61
|
+
/** A conservative charge where the caller explicitly accounts unknown usage. */ export declare let charged: (reply: {
|
|
62
|
+
cost?: number;
|
|
63
|
+
costReported?: boolean;
|
|
64
|
+
usage?: Usage;
|
|
65
|
+
}, price: Price | undefined, maximum: number) => {
|
|
66
|
+
dollars: number;
|
|
67
|
+
reported: boolean;
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=afford.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"afford.d.ts","sources":["../afford.ts"],"names":[],"mappings":"AAEA,cAAc,OAAO,mBAAkB;AACvC,SAAS,KAAK,KAAK,EAAE,KAAK,KAAK,qBAA2B;AAE1D,YAAY;EAAe,QAAQ,MAAM;EAAE,SAAS,MAAM;;AAE1D;kCACkC,GAClC,OAAO,YAAI,gBAAc;AAsBzB;;;;;;;2CAO2C,GAC3C,OAAO,YAAI,cACT,QAAQ,OAAO,EACf,SAAS,MAAM,EACf,QAAQ,OAAO,KACd,MAAM,CAGI;KAMR,SAAS,KAAK,SAAS,iBAAiB,cAAc;EACzD,OAAO,OAAO;EACd,cAAc,OAAO;;AAWvB;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,YAAI,SACT,KAAK,SAAS,KAAK,SAAS,UAC5B,OAAO,OACP,MAAM,MAAM,EACZ,oBACC,MAAM,CAMR;AAED;wDACwD,GACxD,OAAO,YAAI,eACT,KAAK,SAAS,KAAK,SAAS,WAAW,UACvC,SAAS,MAAM,KACd,MAAM,CAKN;AAEH;;;4DAG4D,GAC5D,OAAO,YAAI,WAAY,OAAO,OAAO,kBAAa,oBAAa,MAI7D;AAMF;;;oCAGoC,GACpC,OAAO,YAAI,aACT,OAAO,OACP,OAAO,MAAM,EACb,WAAW,MAAM,EACjB,iBACA,sBACC,aAAa,IAAI,CAgCnB;AAED;;;wCAGwC,GACxC,OAAO,YAAI,WACT;EAAS,OAAO,MAAM;EAAE,eAAe,OAAO;EAAE,QAAQ;GACxD,OAAO,QAAQ,SAAS;EACrB,SAAS,MAAM;EAAE,UAAU,OAAO;IAAK,SAAS,CAyBpD;AAED,8EAA8E,GAC9E,OAAO,YAAI,UACT;EAAS,OAAO,MAAM;EAAE,eAAe,OAAO;EAAE,QAAQ;GACxD,OAAO,QAAQ,SAAS,EACxB,SAAS,MAAM;EACZ,SAAS,MAAM;EAAE,UAAU,OAAO;EAC0B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Usage } from "./vocab.js";
|
|
2
|
+
/** One part of a request: its key, and its size in any unit (characters). */ export type Part = [key: string, size: number];
|
|
3
|
+
/** A part's tokens by how they were paid: read from the cache, written to it,
|
|
4
|
+
* sent fresh, and generated. */ export type Paid = [read: number, write: number, fresh: number, output: number];
|
|
5
|
+
/**
|
|
6
|
+
* A request's input tokens, split across its parts in prompt order: each part
|
|
7
|
+
* scaled from its size to its share of `input_tokens`, then paid by where it
|
|
8
|
+
* sits. Parts with one key add up; an input with no sized part is all
|
|
9
|
+
* `unseen`.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { attribute } from '@yaks/model'
|
|
13
|
+
* import { equal } from '@yaks/testing'
|
|
14
|
+
*
|
|
15
|
+
* let usage = { input_tokens: 100, cached_tokens: 60, cache_write_tokens: 30 }
|
|
16
|
+
* equal(attribute(usage, [['tools', 50], ['chat', 30], ['tools', 0], ['new', 20]]), {
|
|
17
|
+
* tools: [50, 0, 0, 0],
|
|
18
|
+
* chat: [10, 20, 0, 0],
|
|
19
|
+
* new: [0, 10, 10, 0],
|
|
20
|
+
* })
|
|
21
|
+
* equal(attribute({ input_tokens: 5 }, []), { unseen: [0, 0, 5, 0] })
|
|
22
|
+
* ```
|
|
23
|
+
*/ export declare let attribute: (u: Usage, parts: Part[]) => Record<string, Paid>;
|
|
24
|
+
/**
|
|
25
|
+
* Generated tokens split across what a request generated, by size; with
|
|
26
|
+
* nothing sized, all of it is `fallback`'s.
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { generated } from '@yaks/model'
|
|
30
|
+
* import { equal } from '@yaks/testing'
|
|
31
|
+
*
|
|
32
|
+
* equal(generated(90, [['output', 20], ['call Bash', 10]]), {
|
|
33
|
+
* output: [0, 0, 0, 60],
|
|
34
|
+
* 'call Bash': [0, 0, 0, 30],
|
|
35
|
+
* })
|
|
36
|
+
* equal(generated(7, [], 'reasoning'), { reasoning: [0, 0, 0, 7] })
|
|
37
|
+
* ```
|
|
38
|
+
*/ export declare let generated: (tokens: number, parts: Part[], fallback?: string) => Record<string, Paid>;
|
|
39
|
+
/**
|
|
40
|
+
* Several splits as one, adding what they share.
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { merged } from '@yaks/model'
|
|
44
|
+
* import { equal } from '@yaks/testing'
|
|
45
|
+
*
|
|
46
|
+
* equal(merged({ a: [1, 0, 0, 0] }, { a: [0, 0, 0, 2], b: [0, 1, 0, 0] }), {
|
|
47
|
+
* a: [1, 0, 0, 2],
|
|
48
|
+
* b: [0, 1, 0, 0],
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*/ export declare let merged: (...splits: Record<string, Paid>[]) => Record<string, Paid>;
|
|
52
|
+
//# sourceMappingURL=attribute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute.d.ts","sources":["../attribute.ts"],"names":[],"mappings":"AAWA,cAAc,KAAK,qBAAoB;AAEvC,2EAA2E,GAC3E,YAAY,QAAQ,KAAK,MAAM,EAAE,MAAM,MAAM;AAE7C;8BAC8B,GAC9B,YAAY,QAAQ,MAAM,MAAM,EAAE,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE,QAAQ,MAAM;AAQ9E;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,YAAI,YAAa,GAAG,OAAO,OAAO,WAAS,OAAO,MAAM,EAAE,MAsBhE;AAED;;;;;;;;;;;;;;CAcC,GACD,OAAO,YAAI,YACT,QAAQ,MAAM,EACd,OAAO,QACP,sBACC,OAAO,MAAM,EAAE,MAMjB;AAED;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,SACT,GAAG,QAAQ,OAAO,MAAM,EAAE,YACzB,OAAO,MAAM,EAAE,MAQjB"}
|
package/_dist/batch.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Usage } from "./vocab.js";
|
|
2
|
+
/** What a batch costs against the same requests sent one by one. */ export declare let BATCH: number;
|
|
3
|
+
/** One request of a batch: the system text it shares with the others, then
|
|
4
|
+
* its own text, answered by `model` in at most `max` tokens. `id` names its
|
|
5
|
+
* answer, which comes back in any order. `cache` names the shared prefix,
|
|
6
|
+
* where a provider routes requests by it. */ export type Asked = {
|
|
7
|
+
id: string;
|
|
8
|
+
model: string;
|
|
9
|
+
system: string;
|
|
10
|
+
text: string;
|
|
11
|
+
max: number;
|
|
12
|
+
cache?: string;
|
|
13
|
+
};
|
|
14
|
+
/** One request's answer: its text and what it used, or why there is none. */ export type Answered = {
|
|
15
|
+
id: string;
|
|
16
|
+
text: string;
|
|
17
|
+
usage: Usage;
|
|
18
|
+
} | {
|
|
19
|
+
id: string;
|
|
20
|
+
error: string;
|
|
21
|
+
};
|
|
22
|
+
/** A provider's batches: send one, ask whether it has ended, read its
|
|
23
|
+
* answers. */ export type Batches = {
|
|
24
|
+
/** sends the requests as one batch, and answers its id */ submit: (asked: Asked[]) => Promise<string>;
|
|
25
|
+
ended: (id: string) => Promise<boolean>;
|
|
26
|
+
results: (id: string) => Promise<Answered[]>;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sources":["../batch.ts"],"names":[],"mappings":"AAMA,cAAc,KAAK,qBAAoB;AAEvC,kEAAkE,GAClE,OAAO,YAAI,cAAW;AAEtB;;;2CAG2C,GAC3C,YAAY;EACV,IAAI,MAAM;EACV,OAAO,MAAM;EACb,QAAQ,MAAM;EACd,MAAM,MAAM;EACZ,KAAK,MAAM;EACX,QAAQ,MAAM;;AAGhB,2EAA2E,GAC3E,YAAY;EACN,IAAI,MAAM;EAAE,MAAM,MAAM;EAAE,OAAO;;EACjC,IAAI,MAAM;EAAE,OAAO,MAAM;;AAE/B;YACY,GACZ,YAAY;EACV,wDAAwD,GACxD,SAAS,OAAO,YAAY,QAAQ,MAAM;EAC1C,QAAQ,IAAI,MAAM,KAAK,QAAQ,OAAO;EACtC,UAAU,IAAI,MAAM,KAAK,QAAQ"}
|
package/_dist/cache.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Reply } from "./mod.js";
|
|
2
|
+
/** The dispatch instant and the provider's documented retention in seconds. */ export type CacheContext = {
|
|
3
|
+
requestedAt: number;
|
|
4
|
+
retention?: unknown;
|
|
5
|
+
};
|
|
6
|
+
/** An ISO instant, or a provider's Unix seconds, normalized to an ISO instant.
|
|
7
|
+
* Dates without a timezone, durations, and nonfinite numbers are unknown. */ export declare let cacheExpiry: (value: unknown) => string | undefined;
|
|
8
|
+
/** Provider expiry wins, including an expired or invalid explicit value.
|
|
9
|
+
* Unknown retention clears a prior mark rather than implying a warm cache. */ export declare let prefixCacheMark: (reply: Reply, cache?: CacheContext) => {
|
|
10
|
+
cache_expires_at: string | null;
|
|
11
|
+
};
|
|
12
|
+
/** Read only the recorded request expiry from provider components. Missing,
|
|
13
|
+
* malformed, or ambiguous provider bookkeeping is cold. Callers also require
|
|
14
|
+
* a completed ask and known usage/model context before deciding to reuse it. */ export declare let cachedPrefixExpires: (comps: Record<string, unknown>) => string | undefined;
|
|
15
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sources":["../cache.ts"],"names":[],"mappings":"AAGA,cAAc,KAAK,mBAAkB;AAErC,6EAA6E,GAC7E,YAAY;EAAiB,aAAa,MAAM;EAAE,YAAY,OAAO;;AAErE;2EAC2E,GAC3E,OAAO,YAAI,cAAe,OAAO,OAAO,KAAG,MAAM,GAAG,SAAS,CAQ5D;AAED;4EAC4E,GAC5E,OAAO,YAAI,kBACT,OAAO,OACP,QAAQ;EACL,kBAAkB,MAAM,GAAG,IAAI;EAYnC;AAED;;8EAE8E,GAC9E,OAAO,YAAI,sBACT,OAAO,OAAO,MAAM,EAAE,OAAO,MAC5B,MAAM,GAAG,SAAS,CAQpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Model } from "./mod.js";
|
|
2
|
+
export declare let deferredModel: (load: () => Promise<Model>, meta: Pick<Model, 'mark' | 'vocab' | 'anchor' | 'lateResults' | 'hosted'> & {
|
|
3
|
+
recover?: true;
|
|
4
|
+
retrieve?: true;
|
|
5
|
+
info?: true;
|
|
6
|
+
count?: true;
|
|
7
|
+
reads?: Model['reads'] | true;
|
|
8
|
+
}) => Model;
|
|
9
|
+
//# sourceMappingURL=deferred.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deferred.d.ts","sources":["../deferred.ts"],"names":[],"mappings":"AAGA,SAAS,KAAK,KAAK,mBAA8B;AAEjD,OAAO,YAAI,gBACT,YAAY,QAAQ,QACpB,MACI,KACA,OACA,SAAS,UAAU,WAAW,gBAAgB;EAG9C,UAAU,IAAI;EACd,WAAW,IAAI;EACf,OAAO,IAAI;EACX,QAAQ,IAAI;EACZ,QAAQ,MAAM,WAAW,IAAI;MAEhC,MAkCF"}
|
package/_dist/graph.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sources":["../graph.ts"],"names":[],"mappings":"AAIA,cAAc,MAAM,2BAAgC;AAGpD,8EAA8E,GAC9E,OAAO,YAAI,eAAc,SAAsB"}
|
package/_dist/image.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An image made from a prompt, as a tool a model calls: `image_new`,
|
|
3
|
+
* declared for the image models a host offers, and asked of one of them with
|
|
4
|
+
* the prompt alone and no tools. The model's reply carries the image as an
|
|
5
|
+
* artifact, kept wherever the host's provider keeps generated media
|
|
6
|
+
* (`Reply.artifacts`). What a host adds is its own: how the call is paid
|
|
7
|
+
* for, where the bytes go, and what the caller is told of them.
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { equal } from '@yaks/testing'
|
|
11
|
+
* import { imageMade, imageTool } from '@yaks/model/image'
|
|
12
|
+
*
|
|
13
|
+
* let tool = imageTool(['sketch', 'paint'])
|
|
14
|
+
* equal(tool.name, 'image_new')
|
|
15
|
+
* let asked: unknown[] = []
|
|
16
|
+
* let made = await imageMade(
|
|
17
|
+
* (req) => {
|
|
18
|
+
* asked.push([req.model, req.items, req.input])
|
|
19
|
+
* return Promise.resolve({ id: 'r', model: req.model, items: [] })
|
|
20
|
+
* },
|
|
21
|
+
* ['sketch', 'paint'],
|
|
22
|
+
* { prompt: 'A yak', size: '1024x1024' },
|
|
23
|
+
* )
|
|
24
|
+
* equal(made.model, 'sketch')
|
|
25
|
+
* equal(asked, [[
|
|
26
|
+
* 'sketch',
|
|
27
|
+
* [{ kind: 'user', text: 'A yak' }],
|
|
28
|
+
* { size: '1024x1024' },
|
|
29
|
+
* ]])
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @module
|
|
33
|
+
*/ import { type Model, type Reply, type Tool } from "./mod.js";
|
|
34
|
+
/** What a host says of `image_new` beside the words it has of its own:
|
|
35
|
+
* where the image goes (`about`), and how to choose among its models
|
|
36
|
+
* (`choosing`). */ export type ImageWords = {
|
|
37
|
+
about?: string;
|
|
38
|
+
choosing?: string;
|
|
39
|
+
};
|
|
40
|
+
/** The tool a model makes an image with, for `models`, the first made with
|
|
41
|
+
* unless another is asked for. */ export declare let imageTool: (models: string[], _dts_1: never) => Tool;
|
|
42
|
+
/** The image `args` (`image_new`'s) asks for, made by `make`: the prompt
|
|
43
|
+
* alone, no tools, every other setting as the request's `input`. A missing
|
|
44
|
+
* prompt or a model not among `models` is a `ModelError` coded `input`, for
|
|
45
|
+
* the caller to correct, and nothing is asked. */ export declare let imageMade: (make: Model, models: string[], args: Record<string, unknown>) => Promise<Reply>;
|
|
46
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sources":["../image.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCC,GACD,SAAS,KAAK,KAAK,EAAc,KAAK,KAAK,EAAE,KAAK,IAAI,mBAAkB;AAExE;;iBAEiB,GACjB,YAAY;EAAe,QAAQ,MAAM;EAAE,WAAW,MAAM;;AAE5D;gCACgC,GAChC,OAAO,YAAI,YACT,QAAQ,MAAM,IACd,kBACC,KAmCD;AAEF;;;gDAGgD,GAChD,OAAO,YAAI,YACT,MAAM,OACN,QAAQ,MAAM,IACd,MAAM,OAAO,MAAM,EAAE,OAAO,MAC3B,QAAQ,OAiBV"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type Mark, type Model, type Reply, type Request } from "./mod.js";
|
|
2
|
+
/** A session yields while resume has no receipt; submit is idempotent by call. */ export type Executor = {
|
|
3
|
+
/** A durable admission mark distinguishes these asks from older inline work. */ name?: string;
|
|
4
|
+
/** New asks may dispatch only while the independently deployed service is live. */ available?: () => boolean | Promise<boolean>;
|
|
5
|
+
submit: (call: string, request: Request) => Promise<void>;
|
|
6
|
+
resume: (call: string) => Promise<Reply | undefined>;
|
|
7
|
+
};
|
|
8
|
+
type Media = 'image' | 'document';
|
|
9
|
+
type FrozenItem = Exclude<Request['items'][number], {
|
|
10
|
+
kind: Media;
|
|
11
|
+
}> | {
|
|
12
|
+
kind: Media;
|
|
13
|
+
bytes: number[];
|
|
14
|
+
mediaType: string;
|
|
15
|
+
label: string;
|
|
16
|
+
};
|
|
17
|
+
/** JSON input to an executor. Functions and process-local cancellation never
|
|
18
|
+
* enter the private frozen object. */ export type FrozenModelRequest = Pick<Request, 'call' | 'model' | 'input' | 'modalities' | 'effort' | 'instructions' | 'tools' | 'questions' | 'tokens' | 'anchor' | 'conversation' | 'sites' | 'cachePrefix' | 'cacheRetention'> & {
|
|
19
|
+
items: FrozenItem[];
|
|
20
|
+
turnContext?: FrozenItem[];
|
|
21
|
+
};
|
|
22
|
+
export declare let frozenRequest: (req: Request) => FrozenModelRequest;
|
|
23
|
+
export declare let thawedRequest: ({}: FrozenModelRequest) => Request;
|
|
24
|
+
/** The ask's pinned executor and private object references. */ export type Inference = {
|
|
25
|
+
call: string;
|
|
26
|
+
executor: string;
|
|
27
|
+
request: string;
|
|
28
|
+
receipt: string;
|
|
29
|
+
};
|
|
30
|
+
/** A complete private answer, or evidence that generation cannot be repeated. */ export type InferenceReceipt = {
|
|
31
|
+
call: string;
|
|
32
|
+
reply?: Reply;
|
|
33
|
+
mark?: Mark;
|
|
34
|
+
failure?: {
|
|
35
|
+
code: string;
|
|
36
|
+
interrupted: boolean;
|
|
37
|
+
reason: string;
|
|
38
|
+
exception?: {
|
|
39
|
+
type: string;
|
|
40
|
+
stack?: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/** Every effect belongs to the host. claim must atomically mark submission,
|
|
45
|
+
* return false if already marked, and never clear that mark on failure. */ export type InferenceHost = {
|
|
46
|
+
read: (job: Inference) => Promise<InferenceReceipt | undefined>;
|
|
47
|
+
save: (job: Inference, receipt: InferenceReceipt) => Promise<void>;
|
|
48
|
+
request: (job: Inference) => Promise<Request>;
|
|
49
|
+
model: (job: Inference) => Promise<Model>;
|
|
50
|
+
submitted: (job: Inference) => Promise<boolean>;
|
|
51
|
+
claim: (job: Inference) => Promise<boolean>;
|
|
52
|
+
checkpoint: (job: Inference, mark: Mark) => Promise<void>;
|
|
53
|
+
/** Complete provider evidence can retry delivery, never generation. */ recoverable?: (job: Inference) => Promise<boolean>;
|
|
54
|
+
};
|
|
55
|
+
/** Paid generation is never repeated after an uncertain submission. A saved
|
|
56
|
+
* provider receipt may still recover its output without another generation. */ export declare let infer: (job: Inference, host: InferenceHost) => Promise<string>;
|
|
57
|
+
/** Sessions receive a final result, never a reason to regenerate this ask. */ export declare let inferenceReply: (receipt: InferenceReceipt) => Reply;
|
|
58
|
+
//# sourceMappingURL=inference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inference.d.ts","sources":["../inference.ts"],"names":[],"mappings":"AAEA,SACE,KAAK,IAAI,EACT,KAAK,KAAK,EAEV,KAAK,KAAK,EACV,KAAK,OAAO,mBACG;AAEjB,gFAAgF,GAChF,YAAY;EACV,8EAA8E,GAC9E,OAAO,MAAM;EACb,iFAAiF,GACjF,kBAAkB,OAAO,GAAG,QAAQ,OAAO;EAC3C,SAAS,MAAM,MAAM,EAAE,SAAS,YAAY,QAAQ,IAAI;EACxD,SAAS,MAAM,MAAM,KAAK,QAAQ,QAAQ,SAAS;;KAIhD,QAAQ,UAAU;KAClB,aAAa,QAAQ,QAAQ,SAAS,MAAM;EAAK,MAAM;;EAC1D,MAAM;EACN,OAAO,MAAM;EACb,WAAW,MAAM;EACjB,OAAO,MAAM;;AAGf;oCACoC,GACpC,YAAY,qBACR,KACA,SACE,SACA,UACA,UACA,eACA,WACA,iBACA,UACA,cACA,WACA,WACA,iBACA,UACA,gBACA;EAEA,OAAO;EAAc,cAAc;;AAQzC,OAAO,YAAI,gBAAiB,KAAK,YAAU,mBAoC1C;AAED,OAAO,YAAI,gBACT,IAAyB,kBAAkB,KAC1C,QAID;AAEF,6DAA6D,GAC7D,YAAY;EACV,MAAM,MAAM;EACZ,UAAU,MAAM;EAChB,SAAS,MAAM;EACf,SAAS,MAAM;;AAGjB,+EAA+E,GAC/E,YAAY;EACV,MAAM,MAAM;EACZ,QAAQ;EACR,OAAO;EACP;IACE,MAAM,MAAM;IACZ,aAAa,OAAO;IACpB,QAAQ,MAAM;IACd;MAAc,MAAM,MAAM;MAAE,QAAQ,MAAM;;;;AAI9C;yEACyE,GACzE,YAAY;EACV,OAAO,KAAK,cAAc,QAAQ,mBAAmB,SAAS;EAC9D,OAAO,KAAK,WAAW,SAAS,qBAAqB,QAAQ,IAAI;EACjE,UAAU,KAAK,cAAc,QAAQ;EACrC,QAAQ,KAAK,cAAc,QAAQ;EACnC,YAAY,KAAK,cAAc,QAAQ,OAAO;EAC9C,QAAQ,KAAK,cAAc,QAAQ,OAAO;EAC1C,aAAa,KAAK,WAAW,MAAM,SAAS,QAAQ,IAAI;EACxD,qEAAqE,GACrE,eAAe,KAAK,cAAc,QAAQ,OAAO;;AAGnD;6EAC6E,GAC7E,OAAO,YAAI,QACT,KAAK,WACL,MAAM,kBACL,QAAQ,MAAM,EAmEhB;AAED,4EAA4E,GAC5E,OAAO,YAAI,iBAAkB,SAAS,qBAAmB,MASxD"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { Bundle, Eid } from "@yaks/graph";
|
|
2
|
+
/** A provider's plan limit, as the provider reported it (`rate_limit`). */ export type Limit = {
|
|
3
|
+
/** the provider whose plan it is, by name: `claude`, `codex` */ provider: string;
|
|
4
|
+
/** the account whose plan it is, where the one reporting knows it */ account?: Eid;
|
|
5
|
+
/** what it meters where that is not the whole plan: `model`, the requests
|
|
6
|
+
* of the one model the reading came back from (Claude's cap on Fable) */ per?: 'model';
|
|
7
|
+
/** the model a limit `per` model meters, as whoever knows which model the
|
|
8
|
+
* request asked says it ({@link metering}) */ model?: Eid;
|
|
9
|
+
/** the limit's window in minutes */ window: number;
|
|
10
|
+
/** percent of the window's limit used */ used: number;
|
|
11
|
+
resets?: string;
|
|
12
|
+
};
|
|
13
|
+
/** The row holding the latest reading of one plan-limit window
|
|
14
|
+
* (`rate_limit`), named by its provider entity, the window in minutes and,
|
|
15
|
+
* where the reading came from one, the account whose plan it is; a limit on
|
|
16
|
+
* one model's requests, by the model too. */ export declare let limitEid: (provider: Eid, window: number, account?: Eid, model?: Eid) => Eid;
|
|
17
|
+
/**
|
|
18
|
+
* Readings as those of a request that asked `model`: a limit `per` model
|
|
19
|
+
* meters that one.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { metering } from './limits.ts'
|
|
23
|
+
* import { equal } from '@yaks/testing'
|
|
24
|
+
*
|
|
25
|
+
* let week = { provider: 'claude', window: 10080, used: 43 }
|
|
26
|
+
* let cap = { ...week, used: 6, per: 'model' as const }
|
|
27
|
+
* equal(metering([week, cap], 'fable'), [week, { ...cap, model: 'fable' }])
|
|
28
|
+
* equal(metering([week, cap]), [week, cap])
|
|
29
|
+
* ```
|
|
30
|
+
*/ export declare let metering: (limits: Limit[], model?: Eid) => Limit[];
|
|
31
|
+
/**
|
|
32
|
+
* Whether a failed request says the provider's own account has nothing left
|
|
33
|
+
* to spend: a code a provider answers that with, or a plan window it read
|
|
34
|
+
* full that has not reset by `now`. A provider merely busy is not dry, nor is
|
|
35
|
+
* a caller's own ceiling (`limit`, {@link spent}).
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { dry } from './limits.ts'
|
|
39
|
+
* import { equal } from '@yaks/testing'
|
|
40
|
+
*
|
|
41
|
+
* let now = Date.parse('2026-11-23T12:00:00Z')
|
|
42
|
+
* let full = { provider: 'claude', window: 300, used: 100, resets: '2026-11-23T14:00:00Z' }
|
|
43
|
+
* equal(dry({ code: 'busy', limits: [full] }, now), true)
|
|
44
|
+
* equal(dry({ code: 'busy', limits: [{ ...full, resets: '2026-11-23T11:00:00Z' }] }, now), false)
|
|
45
|
+
* equal(dry({ code: 'project_spend_limit_exceeded' }, now), true)
|
|
46
|
+
* equal(dry({ code: 'credit' }, now), true)
|
|
47
|
+
* equal(dry({ code: 'limit' }, now), false)
|
|
48
|
+
* equal(dry({ code: 'busy' }, now), false)
|
|
49
|
+
* ```
|
|
50
|
+
*/ export declare let dry: (e: {
|
|
51
|
+
code?: string;
|
|
52
|
+
limits?: Limit[];
|
|
53
|
+
}, now?: number) => boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether a failed request says the plan it spends is used up: the
|
|
56
|
+
* provider's account {@link dry}, or the ceiling @yaks/openai's native door
|
|
57
|
+
* holds it to (`limit`).
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { spent } from './limits.ts'
|
|
61
|
+
* import { equal } from '@yaks/testing'
|
|
62
|
+
*
|
|
63
|
+
* equal(spent({ code: 'usage_limit_reached' }), true)
|
|
64
|
+
* equal(spent({ code: 'limit' }), true)
|
|
65
|
+
* equal(spent({ code: 'busy' }), false)
|
|
66
|
+
* ```
|
|
67
|
+
*/ export declare let spent: (e: {
|
|
68
|
+
code?: string;
|
|
69
|
+
limits?: Limit[];
|
|
70
|
+
}, now?: number) => boolean;
|
|
71
|
+
/** The row of an account a CLI keeps on this machine (`account`), named by
|
|
72
|
+
* its directory. */ export declare let accountEid: (home: string) => Eid;
|
|
73
|
+
/** Where each CLI on this machine keeps the account it signs in with, and
|
|
74
|
+
* its transcripts: the variable that names the directory, and the one it
|
|
75
|
+
* keeps under the home directory without it. Antigravity's CLI reads no such
|
|
76
|
+
* variable. */ export declare let ACCOUNTS: {
|
|
77
|
+
readonly claude: {
|
|
78
|
+
readonly env: 'CLAUDE_CONFIG_DIR';
|
|
79
|
+
readonly dir: '.claude';
|
|
80
|
+
};
|
|
81
|
+
readonly codex: {
|
|
82
|
+
readonly env: 'CODEX_HOME';
|
|
83
|
+
readonly dir: '.codex';
|
|
84
|
+
};
|
|
85
|
+
readonly grok: {
|
|
86
|
+
readonly env: 'GROK_HOME';
|
|
87
|
+
readonly dir: '.grok';
|
|
88
|
+
};
|
|
89
|
+
readonly antigravity: {
|
|
90
|
+
readonly env: undefined;
|
|
91
|
+
readonly dir: '.gemini/antigravity-cli';
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/** A CLI that keeps an account on this machine (`ACCOUNTS`). */ export type Runner = keyof typeof ACCOUNTS;
|
|
95
|
+
/** The directory of the account a CLI signs in with in an environment: the
|
|
96
|
+
* one its variable names (`CLAUDE_CONFIG_DIR`, `CODEX_HOME`, `GROK_HOME`),
|
|
97
|
+
* else its own under the home directory (`~/.claude`, `~/.codex`, ...). */ export declare let accountHome: (runner: Runner, env: (name: string) => string | undefined) => string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* An environment that signs a CLI in with the account in `home`, the
|
|
100
|
+
* inverse of {@link accountHome}: the variable names it, except for the
|
|
101
|
+
* account the CLI keeps by default, which it is run without. Claude Code
|
|
102
|
+
* keeps its default account's config beside `~/.claude`, in `~/.claude.json`,
|
|
103
|
+
* and reads `$CLAUDE_CONFIG_DIR/.claude.json` once the variable is set.
|
|
104
|
+
*
|
|
105
|
+
* ```ts
|
|
106
|
+
* import { signingIn } from './limits.ts'
|
|
107
|
+
* import { equal } from '@yaks/testing'
|
|
108
|
+
*
|
|
109
|
+
* let env = { HOME: '/u', CLAUDE_CONFIG_DIR: '/u/.claude-work' }
|
|
110
|
+
* equal(signingIn('claude', '/u/.claude-teams', env).CLAUDE_CONFIG_DIR, '/u/.claude-teams')
|
|
111
|
+
* equal(signingIn('claude', '/u/.claude', env), { HOME: '/u' })
|
|
112
|
+
* equal(signingIn('codex', '/u/.codex-2', { HOME: '/u' }).CODEX_HOME, '/u/.codex-2')
|
|
113
|
+
* ```
|
|
114
|
+
*/ export declare let signingIn: (runner: Runner, home: string, env: Record<string, string>) => Record<string, string>;
|
|
115
|
+
/**
|
|
116
|
+
* Readings as rows: each one's `rate_limit`, read at `at`, and its provider's
|
|
117
|
+
* row. A limit on one model's requests is kept where the model is known, and
|
|
118
|
+
* otherwise says nothing of any plan.
|
|
119
|
+
*
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { limitEid, limitRows } from './limits.ts'
|
|
122
|
+
* import { identityEid } from '@yaks/graph/identity'
|
|
123
|
+
* import { equal } from '@yaks/testing'
|
|
124
|
+
*
|
|
125
|
+
* let codex = identityEid('provider', ['codex'])
|
|
126
|
+
* let week = { provider: 'codex', window: 10080, used: 9 }
|
|
127
|
+
* equal(limitRows([week], '2026-11-11T00:00:00.000Z'), [
|
|
128
|
+
* { entity: { eid: codex }, provider: { name: 'codex' } },
|
|
129
|
+
* {
|
|
130
|
+
* entity: { eid: limitEid(codex, 10080) },
|
|
131
|
+
* rate_limit: { provider: codex, window: 10080, used: 9, at: '2026-11-11T00:00:00.000Z' },
|
|
132
|
+
* },
|
|
133
|
+
* ])
|
|
134
|
+
* let [, cap] = limitRows([{ ...week, per: 'model', model: 'm' }])
|
|
135
|
+
* equal(cap, {
|
|
136
|
+
* entity: { eid: limitEid(codex, 10080, undefined, 'm') },
|
|
137
|
+
* rate_limit: { provider: codex, window: 10080, model: 'm', used: 9 },
|
|
138
|
+
* })
|
|
139
|
+
* equal(limitRows([{ ...week, per: 'model' }]), [])
|
|
140
|
+
* ```
|
|
141
|
+
*/ export declare let limitRows: (read: Limit[], at?: string) => Bundle[];
|
|
142
|
+
//# sourceMappingURL=limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sources":["../limits.ts"],"names":[],"mappings":"AAKA,cAAc,MAAM,EAAE,GAAG,2BAAgC;AAGzD,yEAAyE,GACzE,YAAY;EACV,8DAA8D,GAC9D,UAAU,MAAM;EAChB,mEAAmE,GACnE,UAAU;EACV;yEACuE,GACvE,MAAM;EACN;8CAC4C,GAC5C,QAAQ;EACR,kCAAkC,GAClC,QAAQ,MAAM;EACd,uCAAuC,GACvC,MAAM,MAAM;EACZ,SAAS,MAAM;;AAGjB;;;2CAG2C,GAC3C,OAAO,YAAI,WACT,UAAU,KACV,QAAQ,MAAM,EACd,UAAU,KACV,QAAQ,QACP,IAMC;AAEJ;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,WAAY,QAAQ,SAAS,QAAQ,QAAM,QACc;AAcpE;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,YAAI,MACT;EAAK,OAAO,MAAM;EAAE,SAAS;GAC7B,MAAK,MAAM,KACV,OAAO,CAIP;AAEH;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,QACT;EAAK,OAAO,MAAM;EAAE,SAAS;GAC7B,MAAK,MAAM,KACV,OAAO,CAAoC;AAE9C;kBACkB,GAClB,OAAO,YAAI,aAAc,MAAM,MAAM,KAAG,IAAqC;AAE7E;;;aAGa,GACb,OAAO,YAAI;WACT;aAAU,KAAK;aAAqB,KAAK;;WACzC;aAAS,KAAK;aAAc,KAAK;;WACjC;aAAQ,KAAK;aAAa,KAAK;;WAC/B;aAAe;aAAgB,KAAK;;EAC5B;AAEV,8DAA8D,GAC9D,YAAY,sBAAsB;AAElC;;yEAEyE,GACzE,OAAO,YAAI,cACT,QAAQ,QACR,MAAM,MAAM,MAAM,KAAK,MAAM,GAAG,SAAS,KACxC,MAAM,GAAG,SAAS,CAIpB;AAED;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,YAAI,YACT,QAAQ,QACR,MAAM,MAAM,EACZ,KAAK,OAAO,MAAM,EAAE,MAAM,MACzB,OAAO,MAAM,EAAE,MAAM,EAKvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC,GACD,OAAO,YAAI,YAAa,MAAM,SAAS,KAAK,MAAM,KAAG,SAuBpD"}
|
package/_dist/media.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Reply, type Request } from "./mod.js";
|
|
2
|
+
import { type Blobs } from "@yaks/blob";
|
|
3
|
+
/** Private delivery metadata, attributed to the original model request. */ export type MediaReceipt = {
|
|
4
|
+
call: string;
|
|
5
|
+
id: string;
|
|
6
|
+
model: string;
|
|
7
|
+
/** The adapter that owns delivery; absent on legacy Workers AI receipts. */ provider?: string;
|
|
8
|
+
input: unknown;
|
|
9
|
+
response: unknown;
|
|
10
|
+
/** False retains partial output without authorizing delivery. */ complete?: boolean;
|
|
11
|
+
cost?: number;
|
|
12
|
+
costReported?: boolean;
|
|
13
|
+
reply?: Reply;
|
|
14
|
+
};
|
|
15
|
+
/** The host's durable private store; never a transcript or a public blob. */ export type MediaReceipts = {
|
|
16
|
+
read: (call: string) => Promise<MediaReceipt | undefined>;
|
|
17
|
+
save: (receipt: MediaReceipt) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
/** A private receipt pointer, or an inline receipt written by an older host. */ export type MediaRecord = Partial<MediaReceipt> & {
|
|
20
|
+
payload?: string;
|
|
21
|
+
};
|
|
22
|
+
/** Checkpoint before any download, storage, cancellation or delivery work. */ export declare let receivedMedia: (req: Request, receipt: MediaReceipt, store?: MediaReceipts) => Promise<void>;
|
|
23
|
+
/** Delivery only. There is deliberately no generation callback at this door. */ export declare let recoveredMedia: (call: string, store: MediaReceipts | undefined, deliver: (receipt: MediaReceipt) => Promise<Reply>) => Promise<Reply>;
|
|
24
|
+
/** Adapt the existing private-record interface without knowing its storage. */ export declare let mediaReceipts: (records: {
|
|
25
|
+
read: (call: string) => Promise<MediaRecord | undefined>;
|
|
26
|
+
update: <T>(call: string, fn: (record: MediaRecord) => Promise<T>) => Promise<T>;
|
|
27
|
+
}, blobs?: Blobs) => MediaReceipts;
|
|
28
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sources":["../media.ts"],"names":[],"mappings":"AAEA,SAAqB,KAAK,KAAK,EAAE,KAAK,OAAO,mBAAkB;AAC/D,SAAoB,KAAK,KAAK,0BAAqD;AAEnF,yEAAyE,GACzE,YAAY;EACV,MAAM,MAAM;EACZ,IAAI,MAAM;EACV,OAAO,MAAM;EACb,0EAA0E,GAC1E,WAAW,MAAM;EACjB,OAAO,OAAO;EACd,UAAU,OAAO;EACjB,+DAA+D,GAC/D,WAAW,OAAO;EAClB,OAAO,MAAM;EACb,eAAe,OAAO;EACtB,QAAQ;;AAGV,2EAA2E,GAC3E,YAAY;EACV,OAAO,MAAM,MAAM,KAAK,QAAQ,eAAe,SAAS;EACxD,OAAO,SAAS,iBAAiB,QAAQ,IAAI;;AAG/C,8EAA8E,GAC9E,YAAY,cAAc,QAAQ;EAAkB,UAAU,MAAM;;AAEpE,4EAA4E,GAC5E,OAAO,YAAI,gBACT,KAAK,SACL,SAAS,cACT,QAAQ,kBACP,QAAQ,IAAI,EAId;AAED,8EAA8E,GAC9E,OAAO,YAAI,iBACT,MAAM,MAAM,EACZ,OAAO,gBAAgB,SAAS,EAChC,UAAU,SAAS,iBAAiB,QAAQ,WAC3C,QAAQ,OAkBV;AAED,6EAA6E,GAC7E,OAAO,YAAI,gBACT;EACE,OAAO,MAAM,MAAM,KAAK,QAAQ,cAAc,SAAS;EACvD,SAAS,GACP,MAAM,MAAM,EACZ,KAAK,QAAQ,gBAAgB,QAAQ,OAClC,QAAQ;GAEf,QAAQ,UACP,cA8DF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Item } from "./mod.js";
|
|
2
|
+
/** Render a message's author in its words, including APIs that only offer
|
|
3
|
+
* user and assistant turns. An absent source leaves a person's own user turn
|
|
4
|
+
* or the receiving model's own output unchanged. */ export declare let message: <T extends Item>(item: T) => T;
|
|
5
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sources":["../message.ts"],"names":[],"mappings":"AACA,cAAc,IAAI,mBAAkB;AAEpC;;kDAEkD,GAClD,OAAO,YAAI,UAAW,UAAU,MAAM,MAAM,MAAsB,EAUjE"}
|