@warlock.js/ai 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/cjs/index.cjs +20 -1
- package/cjs/{src-DFibP2FQ.cjs → src-Bmajk4Qg.cjs} +1 -1
- package/cjs/{src-C02yzsLs.cjs → src-OZyDYHxm.cjs} +2789 -691
- package/cjs/src-OZyDYHxm.cjs.map +1 -0
- package/esm/agent/agent-config.type.d.mts +29 -0
- package/esm/agent/agent-config.type.d.mts.map +1 -1
- package/esm/agent/agent.d.mts.map +1 -1
- package/esm/agent/agent.mjs +126 -7
- package/esm/agent/agent.mjs.map +1 -1
- package/esm/agent/signature.mjs +57 -0
- package/esm/agent/signature.mjs.map +1 -0
- package/esm/agent/snapshot.mjs +101 -0
- package/esm/agent/snapshot.mjs.map +1 -0
- package/esm/ai-openai/src/image.mjs +5 -0
- package/esm/ai-openai/src/index.mjs +3 -0
- package/esm/ai-openai/src/sdk.mjs +3 -0
- package/esm/ai-openai/src/speech.mjs +5 -0
- package/esm/ai-openai/src/transcription.mjs +6 -0
- package/esm/ai-openai/src/utils/index.mjs +1 -0
- package/esm/ai-openai/src/utils/to-openai-messages.mjs +3 -0
- package/esm/ai.d.mts +45 -0
- package/esm/ai.d.mts.map +1 -1
- package/esm/ai.mjs +37 -1
- package/esm/ai.mjs.map +1 -1
- package/esm/contracts/agent/agent-options.type.d.mts +22 -2
- package/esm/contracts/agent/agent-options.type.d.mts.map +1 -1
- package/esm/contracts/agent/agent-snapshot.type.d.mts +90 -0
- package/esm/contracts/agent/agent-snapshot.type.d.mts.map +1 -0
- package/esm/contracts/agent/agent.contract.d.mts +29 -1
- package/esm/contracts/agent/agent.contract.d.mts.map +1 -1
- package/esm/contracts/agent/index.d.mts +2 -1
- package/esm/contracts/image-model.contract.d.mts +156 -0
- package/esm/contracts/image-model.contract.d.mts.map +1 -0
- package/esm/contracts/index.d.mts +8 -3
- package/esm/contracts/planner/index.d.mts +3 -2
- package/esm/contracts/planner/planner-config.type.d.mts +30 -0
- package/esm/contracts/planner/planner-config.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-execute-options.type.d.mts +13 -1
- package/esm/contracts/planner/planner-execute-options.type.d.mts.map +1 -1
- package/esm/contracts/planner/planner-snapshot.type.d.mts +77 -0
- package/esm/contracts/planner/planner-snapshot.type.d.mts.map +1 -0
- package/esm/contracts/planner/planner.contract.d.mts +21 -1
- package/esm/contracts/planner/planner.contract.d.mts.map +1 -1
- package/esm/contracts/result/base-report.type.d.mts +1 -1
- package/esm/contracts/result/base-report.type.d.mts.map +1 -1
- package/esm/contracts/result/base-report.type.mjs.map +1 -1
- package/esm/contracts/sdk-adapter.contract.d.mts +37 -0
- package/esm/contracts/sdk-adapter.contract.d.mts.map +1 -1
- package/esm/contracts/speech-model.contract.d.mts +97 -0
- package/esm/contracts/speech-model.contract.d.mts.map +1 -0
- package/esm/contracts/transcription-model.contract.d.mts +101 -0
- package/esm/contracts/transcription-model.contract.d.mts.map +1 -0
- package/esm/errors/agent-drift-error.d.mts +32 -0
- package/esm/errors/agent-drift-error.d.mts.map +1 -0
- package/esm/errors/agent-drift-error.mjs +31 -0
- package/esm/errors/agent-drift-error.mjs.map +1 -0
- package/esm/errors/error-code.type.d.mts +1 -1
- package/esm/errors/index.d.mts +2 -0
- package/esm/errors/index.mjs +2 -0
- package/esm/errors/planner-drift-error.d.mts +34 -0
- package/esm/errors/planner-drift-error.d.mts.map +1 -0
- package/esm/errors/planner-drift-error.mjs +33 -0
- package/esm/errors/planner-drift-error.mjs.map +1 -0
- package/esm/image/image-cost.d.mts +32 -0
- package/esm/image/image-cost.d.mts.map +1 -0
- package/esm/image/image-cost.mjs +55 -0
- package/esm/image/image-cost.mjs.map +1 -0
- package/esm/image/image.d.mts +92 -0
- package/esm/image/image.d.mts.map +1 -0
- package/esm/image/image.mjs +113 -0
- package/esm/image/image.mjs.map +1 -0
- package/esm/image/index.mjs +4 -0
- package/esm/index.d.mts +26 -4
- package/esm/index.mjs +20 -1
- package/esm/mock/index.d.mts +3 -0
- package/esm/mock/index.mjs +3 -0
- package/esm/mock/mock-config.type.d.mts +22 -0
- package/esm/mock/mock-config.type.d.mts.map +1 -1
- package/esm/mock/mock-image-model.d.mts +41 -0
- package/esm/mock/mock-image-model.d.mts.map +1 -0
- package/esm/mock/mock-image-model.mjs +52 -0
- package/esm/mock/mock-image-model.mjs.map +1 -0
- package/esm/mock/mock-sdk.d.mts +7 -1
- package/esm/mock/mock-sdk.d.mts.map +1 -1
- package/esm/mock/mock-sdk.mjs +27 -0
- package/esm/mock/mock-sdk.mjs.map +1 -1
- package/esm/mock/mock-speech-model.d.mts +31 -0
- package/esm/mock/mock-speech-model.d.mts.map +1 -0
- package/esm/mock/mock-speech-model.mjs +39 -0
- package/esm/mock/mock-speech-model.mjs.map +1 -0
- package/esm/mock/mock-transcription-model.d.mts +32 -0
- package/esm/mock/mock-transcription-model.d.mts.map +1 -0
- package/esm/mock/mock-transcription-model.mjs +36 -0
- package/esm/mock/mock-transcription-model.mjs.map +1 -0
- package/esm/planner/planner-run.d.mts +8 -0
- package/esm/planner/planner-run.d.mts.map +1 -1
- package/esm/planner/planner-run.mjs +161 -6
- package/esm/planner/planner-run.mjs.map +1 -1
- package/esm/planner/planner.d.mts.map +1 -1
- package/esm/planner/planner.mjs +25 -1
- package/esm/planner/planner.mjs.map +1 -1
- package/esm/planner/snapshot.mjs +95 -0
- package/esm/planner/snapshot.mjs.map +1 -0
- package/esm/rag/index.d.mts +7 -0
- package/esm/rag/index.mjs +7 -0
- package/esm/rag/loaders/errors.d.mts +19 -0
- package/esm/rag/loaders/errors.d.mts.map +1 -0
- package/esm/rag/loaders/errors.mjs +25 -0
- package/esm/rag/loaders/errors.mjs.map +1 -0
- package/esm/rag/loaders/index.mjs +7 -0
- package/esm/rag/loaders/load-html.d.mts +26 -0
- package/esm/rag/loaders/load-html.d.mts.map +1 -0
- package/esm/rag/loaders/load-html.mjs +138 -0
- package/esm/rag/loaders/load-html.mjs.map +1 -0
- package/esm/rag/loaders/load-pdf.d.mts +38 -0
- package/esm/rag/loaders/load-pdf.d.mts.map +1 -0
- package/esm/rag/loaders/load-pdf.mjs +150 -0
- package/esm/rag/loaders/load-pdf.mjs.map +1 -0
- package/esm/rag/loaders/load-text.d.mts +47 -0
- package/esm/rag/loaders/load-text.d.mts.map +1 -0
- package/esm/rag/loaders/load-text.mjs +60 -0
- package/esm/rag/loaders/load-text.mjs.map +1 -0
- package/esm/rag/loaders/load-web.d.mts +42 -0
- package/esm/rag/loaders/load-web.d.mts.map +1 -0
- package/esm/rag/loaders/load-web.mjs +89 -0
- package/esm/rag/loaders/load-web.mjs.map +1 -0
- package/esm/rag/loaders/loader.type.d.mts +89 -0
- package/esm/rag/loaders/loader.type.d.mts.map +1 -0
- package/esm/rag/store/pg-vector-store.d.mts +139 -0
- package/esm/rag/store/pg-vector-store.d.mts.map +1 -0
- package/esm/rag/store/pg-vector-store.mjs +328 -0
- package/esm/rag/store/pg-vector-store.mjs.map +1 -0
- package/esm/speech/index.mjs +3 -0
- package/esm/speech/speech.d.mts +65 -0
- package/esm/speech/speech.d.mts.map +1 -0
- package/esm/speech/speech.mjs +123 -0
- package/esm/speech/speech.mjs.map +1 -0
- package/esm/supervisor/entries.mjs +2 -2
- package/esm/supervisor/entries.mjs.map +1 -1
- package/esm/transcribe/audio-input.d.mts +47 -0
- package/esm/transcribe/audio-input.d.mts.map +1 -0
- package/esm/transcribe/audio-input.mjs +84 -0
- package/esm/transcribe/audio-input.mjs.map +1 -0
- package/esm/transcribe/index.mjs +4 -0
- package/esm/transcribe/transcribe.d.mts +64 -0
- package/esm/transcribe/transcribe.d.mts.map +1 -0
- package/esm/transcribe/transcribe.mjs +128 -0
- package/esm/transcribe/transcribe.mjs.map +1 -0
- package/llms-full.txt +753 -0
- package/llms.txt +5 -0
- package/package.json +3 -3
- package/skills/README.md +4 -0
- package/skills/durable-agent-runs/SKILL.md +135 -0
- package/skills/generate-images/SKILL.md +138 -0
- package/skills/generate-speech/SKILL.md +139 -0
- package/skills/rag-loaders-and-stores/SKILL.md +164 -0
- package/skills/transcribe-audio/SKILL.md +157 -0
- package/cjs/src-C02yzsLs.cjs.map +0 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Usage } from "./result/usage.type.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../@warlock.js/ai/src/contracts/image-model.contract.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* USD pricing for an image-generation model. Image providers meter one
|
|
6
|
+
* of two ways, and this single shape covers both so the cost rolls up
|
|
7
|
+
* through the same `Usage.cost` path the text models already use — no
|
|
8
|
+
* second accounting path (only a different INPUT unit).
|
|
9
|
+
*
|
|
10
|
+
* - **Token-metered** (OpenAI `gpt-image-1` family): the request bills
|
|
11
|
+
* per input/output token exactly like a chat model. Set `input` /
|
|
12
|
+
* `output` (USD per 1M tokens) and the framework prices the returned
|
|
13
|
+
* token `Usage` with the standard {@link computeCost} math.
|
|
14
|
+
* - **Per-image-metered** (DALL·E, Google Imagen): the request bills a
|
|
15
|
+
* flat amount per generated image, with no token usage. Set `perImage`
|
|
16
|
+
* (USD per image), optionally overridden per requested size via
|
|
17
|
+
* `perImageBySize`.
|
|
18
|
+
*
|
|
19
|
+
* When BOTH families' fields are set, per-image wins (a provider is one
|
|
20
|
+
* or the other, never both). When nothing is set, `Usage.cost` stays
|
|
21
|
+
* `undefined` — honest "cost unknown", not a false zero.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // gpt-image-1 — token-metered:
|
|
25
|
+
* const pricing: ImageModelPricing = { input: 5, output: 40 };
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // DALL·E 3 — per-image, size-tiered:
|
|
29
|
+
* const pricing: ImageModelPricing = {
|
|
30
|
+
* perImage: 0.04,
|
|
31
|
+
* perImageBySize: { "1024x1024": 0.04, "1792x1024": 0.08, "1024x1792": 0.08 },
|
|
32
|
+
* };
|
|
33
|
+
*/
|
|
34
|
+
type ImageModelPricing = {
|
|
35
|
+
/** USD per 1M input (prompt) tokens — token-metered models only. */input?: number; /** USD per 1M output (image) tokens — token-metered models only. */
|
|
36
|
+
output?: number; /** Flat USD per generated image — per-image-metered models. */
|
|
37
|
+
perImage?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Per-size USD-per-image overrides, keyed by the requested `size`
|
|
40
|
+
* label (e.g. `"1024x1024"`). When the resolved request size is a key
|
|
41
|
+
* here, it wins over the flat `perImage`. Lets one model price its
|
|
42
|
+
* size tiers (DALL·E 3 HD/large sizes cost more) without a second
|
|
43
|
+
* model instance.
|
|
44
|
+
*/
|
|
45
|
+
perImageBySize?: Record<string, number>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* One generated image, normalized to a discriminated shape so callers
|
|
49
|
+
* never have to probe which field a provider populated.
|
|
50
|
+
*
|
|
51
|
+
* - `{ type: "url" }` — a remote URL the provider hosts (DALL·E with
|
|
52
|
+
* `response_format: "url"`); URLs are typically short-lived, so
|
|
53
|
+
* download promptly if you need to persist the bytes.
|
|
54
|
+
* - `{ type: "base64" }` — inlined base64 bytes with an explicit IANA
|
|
55
|
+
* `mediaType` (the GPT-image family and Imagen always return bytes).
|
|
56
|
+
*
|
|
57
|
+
* `revisedPrompt` carries the provider's rewritten prompt when prompt
|
|
58
|
+
* enhancement ran (OpenAI `revised_prompt`, Imagen `enhancedPrompt`).
|
|
59
|
+
*/
|
|
60
|
+
type GeneratedImage = {
|
|
61
|
+
type: "url";
|
|
62
|
+
url: string;
|
|
63
|
+
mediaType?: string;
|
|
64
|
+
revisedPrompt?: string;
|
|
65
|
+
} | {
|
|
66
|
+
type: "base64";
|
|
67
|
+
base64: string;
|
|
68
|
+
mediaType: string;
|
|
69
|
+
revisedPrompt?: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Options for a single {@link ImageModelContract.generate} request.
|
|
73
|
+
* Every field is optional and provider-neutral; each adapter maps the
|
|
74
|
+
* ones its API supports and ignores the rest. Provider-specific knobs
|
|
75
|
+
* ride the index signature.
|
|
76
|
+
*/
|
|
77
|
+
type ImageGenerationOptions = {
|
|
78
|
+
/** How many images to generate. Adapters clamp to the provider's max. */count?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Requested pixel size as `"WxH"` (e.g. `"1024x1024"`). Forwarded to
|
|
81
|
+
* the provider's size param AND used to resolve `perImageBySize`
|
|
82
|
+
* pricing. Mutually-informative with `aspectRatio` — pass whichever
|
|
83
|
+
* the target provider speaks (OpenAI = size, Imagen = aspectRatio).
|
|
84
|
+
*/
|
|
85
|
+
size?: string; /** Quality tier (e.g. `"standard"` / `"hd"` / `"low"` / `"high"`). */
|
|
86
|
+
quality?: string; /** Aspect ratio (e.g. `"1:1"`, `"16:9"`) — ratio-based providers (Imagen). */
|
|
87
|
+
aspectRatio?: string; /** Concepts to steer the image away from (Imagen `negativePrompt`). */
|
|
88
|
+
negativePrompt?: string; /** Output container hint (`"png"` / `"jpeg"` / `"webp"`). */
|
|
89
|
+
format?: string; /** Cancellation handle wired into the provider request where supported. */
|
|
90
|
+
signal?: AbortSignal; /** Provider-specific escape hatch — forwarded verbatim. */
|
|
91
|
+
[key: string]: unknown;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Raw result of an {@link ImageModelContract.generate} call. Low-level,
|
|
95
|
+
* like `EmbedderContract.embed` — it returns the images plus token
|
|
96
|
+
* `Usage` (zeroed for per-image-metered providers) and THROWS a typed
|
|
97
|
+
* `AIError` on failure. The never-throws `{ data, error, usage, report }`
|
|
98
|
+
* envelope is added one layer up by the `ai.image()` facade verb.
|
|
99
|
+
*/
|
|
100
|
+
type ImageGenerationResponse = {
|
|
101
|
+
images: GeneratedImage[];
|
|
102
|
+
/**
|
|
103
|
+
* Token usage when the provider meters per token (gpt-image-1);
|
|
104
|
+
* `{ input: 0, output: 0, total: 0 }` for per-image-metered providers
|
|
105
|
+
* (DALL·E, Imagen), whose spend is priced from the image count via
|
|
106
|
+
* {@link ImageModelPricing.perImage}.
|
|
107
|
+
*/
|
|
108
|
+
usage: Usage;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Provider-neutral contract for an image-generation model — the output
|
|
112
|
+
* counterpart to {@link EmbedderContract}. Produced by an adapter's
|
|
113
|
+
* optional `image?(config)` factory and handed to the `ai.image()`
|
|
114
|
+
* facade verb, which wraps `generate()` into the uniform result
|
|
115
|
+
* envelope, prices it, builds the report, and routes it to observers.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* const model = openai.image({ name: "gpt-image-1" });
|
|
119
|
+
* const { images, usage } = await model.generate("a red bicycle on a white background");
|
|
120
|
+
*/
|
|
121
|
+
interface ImageModelContract {
|
|
122
|
+
/** Image model identifier (e.g. `"gpt-image-1"`, `"imagen-4.0-generate-001"`). */
|
|
123
|
+
readonly name: string;
|
|
124
|
+
/** Provider this model belongs to (e.g. `"openai"`, `"google"`). */
|
|
125
|
+
readonly provider: string;
|
|
126
|
+
/**
|
|
127
|
+
* Per-million-token OR per-image USD pricing. When set, `ai.image()`
|
|
128
|
+
* computes `Usage.cost` at emit time so image spend rolls up through
|
|
129
|
+
* the same report tree as text spend. Resolution mirrors the chat
|
|
130
|
+
* models: per-model `pricing` > SDK registry > undefined.
|
|
131
|
+
*/
|
|
132
|
+
readonly pricing?: ImageModelPricing;
|
|
133
|
+
/**
|
|
134
|
+
* Generate one or more images from a text prompt. Returns the
|
|
135
|
+
* normalized images plus usage, or throws a typed `AIError` (auth,
|
|
136
|
+
* rate-limit, content-filter, invalid-request) — caught and surfaced
|
|
137
|
+
* on `result.error` by the `ai.image()` facade.
|
|
138
|
+
*/
|
|
139
|
+
generate(prompt: string, options?: ImageGenerationOptions): Promise<ImageGenerationResponse>;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Configuration passed to an adapter's `image()` factory. Mirrors
|
|
143
|
+
* {@link EmbedderConfig}: `name` plus an optional per-model `pricing`
|
|
144
|
+
* override and provider-specific keys on the index signature.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* openai.image({ name: "dall-e-3", pricing: { perImage: 0.04 } });
|
|
148
|
+
*/
|
|
149
|
+
type ImageModelConfig = {
|
|
150
|
+
name: string; /** Per-model USD pricing override; wins over the SDK-level registry. */
|
|
151
|
+
pricing?: ImageModelPricing;
|
|
152
|
+
[key: string]: unknown;
|
|
153
|
+
};
|
|
154
|
+
//#endregion
|
|
155
|
+
export { GeneratedImage, ImageGenerationOptions, ImageGenerationResponse, ImageModelConfig, ImageModelContract, ImageModelPricing };
|
|
156
|
+
//# sourceMappingURL=image-model.contract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-model.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/image-model.contract.ts"],"mappings":";;;;;AAgCA;;;;;;;;;;AAcyB;AAgBzB;;;;;;;;;;;;;AAEsE;AAQtE;;;KAxCY,iBAAA;EA0CV,oEAxCA,KAAA,WAiDA;EA/CA,MAAA,WAmDA;EAjDA,QAAA;EAqDA;;;;AAEY;AAUd;;EAzDE,cAAA,GAAiB,MAAM;AAAA;;;;;;AAiEX;AAcd;;;;;;;KA/DY,cAAA;EACN,IAAA;EAAa,GAAA;EAAa,SAAA;EAAoB,aAAA;AAAA;EAC9C,IAAA;EAAgB,MAAA;EAAgB,SAAA;EAAmB,aAAA;AAAA;;;AAgFoC;AAW7F;;;KAnFY,sBAAA;EAoFV,yEAlFA,KAAA;EAoFU;;;AACE;;;EA9EZ,IAAA;EAEA,OAAA;EAEA,WAAA;EAEA,cAAA;EAEA,MAAA;EAEA,MAAA,GAAS,WAAW;GAEnB,GAAA;AAAA;;;;;;;;KAUS,uBAAA;EACV,MAAA,EAAQ,cAAA;;;;;;;EAOR,KAAA,EAAO,KAAK;AAAA;;;;;;;;;;;;UAcG,kBAAA;;WAEN,IAAA;;WAEA,QAAA;;;;;;;WAOA,OAAA,GAAU,iBAAA;;;;;;;EAQnB,QAAA,CAAS,MAAA,UAAgB,OAAA,GAAU,sBAAA,GAAyB,OAAA,CAAQ,uBAAA;AAAA;;;;;;;;;KAW1D,gBAAA;EACV,IAAA;EAEA,OAAA,GAAU,iBAAiB;EAAA,CAC1B,GAAA;AAAA"}
|
|
@@ -60,8 +60,10 @@ import { SupervisorAgentCompletedPayload, SupervisorAgentFailedPayload, Supervis
|
|
|
60
60
|
import { WorkflowCancelledPayload, WorkflowCompletedPayload, WorkflowErrorPayload, WorkflowLoopWarningPayload, WorkflowStartingPayload, WorkflowStepCompletedPayload, WorkflowStepFailedPayload, WorkflowStepRetryingPayload, WorkflowStepSkippedPayload, WorkflowStepStartingPayload, WorkflowStepStreamingPayload } from "./events/workflow-events.type.mjs";
|
|
61
61
|
import { AgentEventMap, SupervisorEventMap, WorkflowEventMap } from "./events/event-map.type.mjs";
|
|
62
62
|
import { StreamingToolGuardConfig } from "./streaming-tool-guard-config.type.mjs";
|
|
63
|
-
import { AgentExecuteOptions } from "./agent/agent-options.type.mjs";
|
|
63
|
+
import { AgentExecuteOptions, AgentResumeOptions } from "./agent/agent-options.type.mjs";
|
|
64
|
+
import { AgentSnapshot, AgentSnapshotStatus } from "./agent/agent-snapshot.type.mjs";
|
|
64
65
|
import { EmbedderConfig, EmbedderContract, EmbeddingBatchResult, EmbeddingResult, EmbeddingUsage } from "./embedder.contract.mjs";
|
|
66
|
+
import { GeneratedImage, ImageGenerationOptions, ImageGenerationResponse, ImageModelConfig, ImageModelContract, ImageModelPricing } from "./image-model.contract.mjs";
|
|
65
67
|
import { MemoryItem, MemoryTier, RecalledMemory } from "./memory/memory-item.type.mjs";
|
|
66
68
|
import { RecallOptions } from "./memory/recall-options.type.mjs";
|
|
67
69
|
import { MemoryContract } from "./memory/memory.contract.mjs";
|
|
@@ -75,11 +77,14 @@ import { OrchestratorAsToolOptions, OrchestratorContract, OrchestratorSessionSco
|
|
|
75
77
|
import { OrchestratorConfig, OrchestratorMemoryConfig, SummarizeCallback, SummarizeConfig } from "./orchestrator/orchestrator-config.type.mjs";
|
|
76
78
|
import { SessionContract } from "./orchestrator/session.contract.mjs";
|
|
77
79
|
import { PlannerCapability } from "./planner/planner-capability.type.mjs";
|
|
78
|
-
import { PlannerConfig } from "./planner/planner-config.type.mjs";
|
|
79
80
|
import { PlannerPlan, PlannerStep } from "./planner/planner-plan.type.mjs";
|
|
80
81
|
import { PlannerReport, PlannerReportType, PlannerResult, PlannerStepSnapshot } from "./planner/planner-result.type.mjs";
|
|
81
|
-
import {
|
|
82
|
+
import { PlannerSnapshot, PlannerSnapshotStatus } from "./planner/planner-snapshot.type.mjs";
|
|
83
|
+
import { PlannerConfig } from "./planner/planner-config.type.mjs";
|
|
84
|
+
import { PlannerExecuteOptions, PlannerResumeOptions, PlannerStepDirective } from "./planner/planner-execute-options.type.mjs";
|
|
82
85
|
import { PlannerContract } from "./planner/planner.contract.mjs";
|
|
86
|
+
import { GeneratedAudio, SpeechGenerationResponse, SpeechModelConfig, SpeechModelContract, SpeechModelPricing, SpeechOptions } from "./speech-model.contract.mjs";
|
|
87
|
+
import { AudioInput, TranscribeOptions, TranscriptionModelConfig, TranscriptionModelContract, TranscriptionModelPricing, TranscriptionResponse, TranscriptionSegment } from "./transcription-model.contract.mjs";
|
|
83
88
|
import { ModelConfig, SDKAdapterContract } from "./sdk-adapter.contract.mjs";
|
|
84
89
|
import { CompleteEvent } from "./events/complete-event.type.mjs";
|
|
85
90
|
import { UsageEvent } from "./events/usage-event.type.mjs";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PlannerCapability } from "./planner-capability.type.mjs";
|
|
2
|
-
import { PlannerConfig } from "./planner-config.type.mjs";
|
|
3
2
|
import { PlannerPlan, PlannerStep } from "./planner-plan.type.mjs";
|
|
4
3
|
import { PlannerReport, PlannerReportType, PlannerResult, PlannerStepSnapshot } from "./planner-result.type.mjs";
|
|
5
|
-
import {
|
|
4
|
+
import { PlannerSnapshot, PlannerSnapshotStatus } from "./planner-snapshot.type.mjs";
|
|
5
|
+
import { PlannerConfig } from "./planner-config.type.mjs";
|
|
6
|
+
import { PlannerExecuteOptions, PlannerResumeOptions, PlannerStepDirective } from "./planner-execute-options.type.mjs";
|
|
6
7
|
import { PlannerContract } from "./planner.contract.mjs";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AgentContract } from "../agent/agent.contract.mjs";
|
|
2
2
|
import { FlowObserveOption } from "../../observe/resolve-observers.mjs";
|
|
3
|
+
import { SnapshotStore } from "../orchestrator/snapshot-store.contract.mjs";
|
|
3
4
|
import { ModelContract } from "../model.contract.mjs";
|
|
4
5
|
import { SystemPromptContract } from "../system-prompt.contract.mjs";
|
|
5
6
|
import { PlannerCapability } from "./planner-capability.type.mjs";
|
|
7
|
+
import { PlannerSnapshot } from "./planner-snapshot.type.mjs";
|
|
6
8
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
7
9
|
|
|
8
10
|
//#region ../@warlock.js/ai/src/contracts/planner/planner-config.type.d.ts
|
|
@@ -103,6 +105,34 @@ type PlannerConfig<TOutput = unknown> = {
|
|
|
103
105
|
replan?: {
|
|
104
106
|
maxReplans: number;
|
|
105
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* Opt-in durable mid-run crash-resume. When set, the planner
|
|
110
|
+
* checkpoints its state to a {@link SnapshotStore} after every settled
|
|
111
|
+
* plan node, so a `planner.resume(runId)` after a crash re-hydrates the
|
|
112
|
+
* frozen plan + executed-node ledger + usage + child reports and
|
|
113
|
+
* continues scheduling only the unfinished frontier — never re-calling
|
|
114
|
+
* the planning LLM and never re-dispatching a completed node's
|
|
115
|
+
* capability.
|
|
116
|
+
*
|
|
117
|
+
* Absent ⇒ no persistence, zero behavior change: the planner runs
|
|
118
|
+
* byte-for-byte as today.
|
|
119
|
+
*
|
|
120
|
+
* - `store` — the snapshot store to persist to. Optional; falls back to
|
|
121
|
+
* `ai.config({ defaultSnapshotStore })`. When neither is set, snapshot
|
|
122
|
+
* writes silently skip and `resume()` throws.
|
|
123
|
+
* - `deleteOnComplete` — drop the snapshot once the run terminates
|
|
124
|
+
* successfully. Default `false` (keep it for the completed-run
|
|
125
|
+
* short-circuit + audit).
|
|
126
|
+
*
|
|
127
|
+
* **Idempotency caveat.** A crash mid-node re-runs that node's
|
|
128
|
+
* capability on resume; side-effectful capabilities must be idempotent —
|
|
129
|
+
* the same caller-responsibility boundary the supervisor and workflow
|
|
130
|
+
* primitives already document.
|
|
131
|
+
*/
|
|
132
|
+
durable?: {
|
|
133
|
+
/** Snapshot store to persist to. Falls back to the global default. */store?: SnapshotStore<PlannerSnapshot>; /** Drop the snapshot on successful completion. Default `false`. */
|
|
134
|
+
deleteOnComplete?: boolean;
|
|
135
|
+
};
|
|
106
136
|
};
|
|
107
137
|
//#endregion
|
|
108
138
|
export { PlannerConfig };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-config.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/planner/planner-config.type.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"planner-config.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/planner/planner-config.type.ts"],"mappings":";;;;;;;;;;;;AAoCA;;;;;;;;;;;;;;;;;;;;;;;;;KAAY,aAAA;EAmCI,0EAjCd,IAAA,UA+CA;EA7CA,OAAA;EA6C0B;;;;;;;EArC1B,OAAA,GAAU,iBAAA;EAqFc;;;AAEN;EAlFlB,KAAA,GAAQ,aAAA;;;;;;EAMR,OAAA,GAAU,aAAA;;;;;;EAMV,YAAA,GAAe,oBAAA;;;;;;EAMf,YAAA,EAAc,iBAAA;;;;;;;EAOd,QAAA;;;;;;;EAOA,MAAA,GAAS,gBAAA,CAAiB,OAAA;;;;;;;;;;EAU1B,GAAA;EAEA,cAAA;;;;;;;;;EASA,MAAA;IAAW,UAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;EAyBX,OAAA;0EAEE,KAAA,GAAQ,aAAA,CAAc,eAAA;IAEtB,gBAAA;EAAA;AAAA"}
|
|
@@ -85,6 +85,18 @@ type PlannerExecuteOptions<TOutput = unknown> = {
|
|
|
85
85
|
*/
|
|
86
86
|
onStep?: (snapshot: PlannerStepSnapshot, plan: PlannerPlan) => void | PlannerStepDirective | Promise<void | PlannerStepDirective>;
|
|
87
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Options accepted by `planner.resume(runId, options?)`.
|
|
90
|
+
*
|
|
91
|
+
* `force: true` bypasses the signature drift check — use only when you
|
|
92
|
+
* have verified the definition change is safe for the in-flight
|
|
93
|
+
* snapshot. `PlannerDriftError` is otherwise thrown without executing
|
|
94
|
+
* anything. Everything else mirrors {@link PlannerExecuteOptions} (e.g.
|
|
95
|
+
* re-supply a `signal` to keep the resumed run cancellable).
|
|
96
|
+
*/
|
|
97
|
+
type PlannerResumeOptions<TOutput = unknown> = PlannerExecuteOptions<TOutput> & {
|
|
98
|
+
/** Bypass the drift check and resume against the changed definition. */force?: boolean;
|
|
99
|
+
};
|
|
88
100
|
//#endregion
|
|
89
|
-
export { PlannerExecuteOptions, PlannerStepDirective };
|
|
101
|
+
export { PlannerExecuteOptions, PlannerResumeOptions, PlannerStepDirective };
|
|
90
102
|
//# sourceMappingURL=planner-execute-options.type.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-execute-options.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/planner/planner-execute-options.type.ts"],"mappings":";;;;;;;;AAiBA;;;;;;;;;AAG8B;KAHlB,oBAAA;EACN,IAAA;AAAA;EACA,IAAA;AAAA;EACA,IAAA;EAAgB,QAAA;AAAA;;;;;;;KAQV,qBAAA;EAAsB,+DAEhC,KAAA;EAKA;;;;EAAA,YAAA,GAAe,YAAA;EAef;;;;;EATA,MAAA,GAAS,gBAAA,CAAiB,OAAA;EAyC1B;;;;;;;;EAhCA,MAAA,GAAS,WAAA;EAmC6D
|
|
1
|
+
{"version":3,"file":"planner-execute-options.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/planner/planner-execute-options.type.ts"],"mappings":";;;;;;;;AAiBA;;;;;;;;;AAG8B;KAHlB,oBAAA;EACN,IAAA;AAAA;EACA,IAAA;AAAA;EACA,IAAA;EAAgB,QAAA;AAAA;;;;;;;KAQV,qBAAA;EAAsB,+DAEhC,KAAA;EAKA;;;;EAAA,YAAA,GAAe,YAAA;EAef;;;;;EATA,MAAA,GAAS,gBAAA,CAAiB,OAAA;EAyC1B;;;;;;;;EAhCA,MAAA,GAAS,WAAA;EAmC6D;AAYxE;;;;;EAxCE,SAAA;EAwC0E;;;AAErE;;;;;;EAhCL,IAAA;;;;;;;;EAQA,YAAA,GAAe,WAAA;;;;;;;EAOf,MAAA,IACE,QAAA,EAAU,mBAAA,EACV,IAAA,EAAM,WAAA,YACI,oBAAA,GAAuB,OAAA,QAAe,oBAAA;AAAA;;;;;;;;;;KAYxC,oBAAA,sBAA0C,qBAAqB,CAAC,OAAA;0EAE1E,KAAA;AAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Usage } from "../result/usage.type.mjs";
|
|
2
|
+
import { BaseReport } from "../result/base-report.type.mjs";
|
|
3
|
+
import { PlannerPlan } from "./planner-plan.type.mjs";
|
|
4
|
+
import { PlannerStepSnapshot } from "./planner-result.type.mjs";
|
|
5
|
+
|
|
6
|
+
//#region ../@warlock.js/ai/src/contracts/planner/planner-snapshot.type.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Lifecycle status of a durable planner run, recorded on the persisted
|
|
9
|
+
* snapshot so `resume()` can decide whether a run is still in flight.
|
|
10
|
+
*
|
|
11
|
+
* - `"running"` — the execution loop is active; a resume is legitimate
|
|
12
|
+
* if the process crashed between node boundaries.
|
|
13
|
+
* - `"completed"` — the planner terminated successfully; resume is a
|
|
14
|
+
* no-op and re-returns the final result rebuilt from the snapshot.
|
|
15
|
+
* - `"cancelled"` — aborted via `AbortSignal`; resume is allowed.
|
|
16
|
+
* - `"failed"` — terminated with an error; resume after the fix.
|
|
17
|
+
*/
|
|
18
|
+
type PlannerSnapshotStatus = "running" | "completed" | "cancelled" | "failed";
|
|
19
|
+
/**
|
|
20
|
+
* Persisted shape written to the configured {@link
|
|
21
|
+
* import("../orchestrator/snapshot-store.contract").SnapshotStore} after
|
|
22
|
+
* every plan node settles. Exists so `planner.resume(runId)` can
|
|
23
|
+
* re-hydrate the frozen plan + per-node ledger + rolled-up usage +
|
|
24
|
+
* child reports and continue scheduling the unfinished DAG / sequential
|
|
25
|
+
* tail.
|
|
26
|
+
*
|
|
27
|
+
* **Checkpoint granularity is per-node.** The snapshot is written at the
|
|
28
|
+
* end of `executeStep`, after the step's `PlannerStepSnapshot` is pushed
|
|
29
|
+
* and its usage + child report folded in. A completed node's capability
|
|
30
|
+
* dispatch is never re-invoked on resume — the sequential skip-guard /
|
|
31
|
+
* DAG re-seed derive the completed-node set from `executedSteps`.
|
|
32
|
+
*
|
|
33
|
+
* `signature` is the same structural fingerprint exposed on the planner
|
|
34
|
+
* instance (`computeSignature(name, capabilities)`). `resume()` compares
|
|
35
|
+
* it against the current definition; a mismatch throws `PlannerDriftError`
|
|
36
|
+
* (bypassable with `{ force: true }`). A mid-run re-plan is NOT drift —
|
|
37
|
+
* the plan changed, not the definition; `replanCount` is persisted so the
|
|
38
|
+
* replan budget is honored across a resume.
|
|
39
|
+
*
|
|
40
|
+
* Every field is JSON-serializable — `PlannerPlan`, `PlannerStepSnapshot`,
|
|
41
|
+
* `Usage`, and `BaseReport` are the same plain-data shapes already
|
|
42
|
+
* persisted on reports.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const snapshot: PlannerSnapshot | undefined = await store.load(runId);
|
|
46
|
+
* if (snapshot?.status === "running") {
|
|
47
|
+
* await planner.resume(runId);
|
|
48
|
+
* }
|
|
49
|
+
*/
|
|
50
|
+
type PlannerSnapshot = {
|
|
51
|
+
/** The store key — stable across the whole run. */runId: string; /** Planner name, for the resume error message + attribution. */
|
|
52
|
+
plannerName: string; /** Structural drift fingerprint — `computeSignature(name, capabilities)`. */
|
|
53
|
+
signature: string; /** `PlannerConfig.version` — metadata only, never compared. */
|
|
54
|
+
version?: string; /** The original `execute(goal)` value — needed to rebuild prompts on replan. */
|
|
55
|
+
goal: string;
|
|
56
|
+
/**
|
|
57
|
+
* The frozen plan generated on the first run. Resume must NOT re-call
|
|
58
|
+
* the planning LLM — re-asking would burn tokens and risk a different
|
|
59
|
+
* plan that no longer matches the executed-node ledger.
|
|
60
|
+
*/
|
|
61
|
+
plan: PlannerPlan;
|
|
62
|
+
/**
|
|
63
|
+
* Per-node ledger (completed / failed / skipped). This IS the
|
|
64
|
+
* completed-node set — the sequential skip-guard and DAG re-seed both
|
|
65
|
+
* reconstruct "what ran" from it.
|
|
66
|
+
*/
|
|
67
|
+
executedSteps: PlannerStepSnapshot[]; /** Rolled-up usage across executed nodes — never double-counted on resume. */
|
|
68
|
+
usage: Usage; /** Child reports accumulated across executed nodes. */
|
|
69
|
+
children: BaseReport[]; /** Replan budget consumed so far, so a resume can't exceed `maxReplans`. */
|
|
70
|
+
replanCount: number;
|
|
71
|
+
status: PlannerSnapshotStatus;
|
|
72
|
+
startedAt: string;
|
|
73
|
+
savedAt: string;
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
export { PlannerSnapshot, PlannerSnapshotStatus };
|
|
77
|
+
//# sourceMappingURL=planner-snapshot.type.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-snapshot.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/planner/planner-snapshot.type.ts"],"mappings":";;;;;;;;AAgBA;;;;AAAiC;AAqCjC;;;;KArCY,qBAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAoEH;;;;;;;KA/BG,eAAA;qDAEV,KAAA;EAEA,WAAA;EAEA,SAAA;EAEA,OAAA;EAEA,IAAA;;;;;;EAMA,IAAA,EAAM,WAAA;;;;;;EAMN,aAAA,EAAe,mBAAA;EAEf,KAAA,EAAO,KAAA;EAEP,QAAA,EAAU,UAAA;EAEV,WAAA;EACA,MAAA,EAAQ,qBAAA;EACR,SAAA;EACA,OAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExecutableContract } from "../executable.contract.mjs";
|
|
2
2
|
import { PlannerResult } from "./planner-result.type.mjs";
|
|
3
|
-
import { PlannerExecuteOptions } from "./planner-execute-options.type.mjs";
|
|
3
|
+
import { PlannerExecuteOptions, PlannerResumeOptions } from "./planner-execute-options.type.mjs";
|
|
4
4
|
|
|
5
5
|
//#region ../@warlock.js/ai/src/contracts/planner/planner.contract.d.ts
|
|
6
6
|
/**
|
|
@@ -54,6 +54,26 @@ interface PlannerContract<TOutput = unknown> extends ExecutableContract<string,
|
|
|
54
54
|
* shape; runtime failures surface on `result.error`.
|
|
55
55
|
*/
|
|
56
56
|
execute(goal: string, options?: PlannerExecuteOptions<TOutput>): Promise<PlannerResult<TOutput>>;
|
|
57
|
+
/**
|
|
58
|
+
* Resume a durable run after a crash. Loads the snapshot persisted
|
|
59
|
+
* under `runId` (requires `durable` on the config, or a global
|
|
60
|
+
* `defaultSnapshotStore`), re-hydrates the frozen plan + executed-node
|
|
61
|
+
* ledger + usage, and continues scheduling only the unfinished frontier
|
|
62
|
+
* — never re-calling the planning LLM and never re-dispatching a
|
|
63
|
+
* completed node's capability. A resume of an already-settled run
|
|
64
|
+
* re-returns the stored result without running anything.
|
|
65
|
+
*
|
|
66
|
+
* Refuses to continue when the current definition has structurally
|
|
67
|
+
* drifted from the snapshot (`PlannerDriftError`), unless
|
|
68
|
+
* `{ force: true }` is passed. Throws `PlannerFailedError` when no store
|
|
69
|
+
* is configured or no snapshot exists for `runId`.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* const result = await research.execute("compare A vs B", { runId: "plan-7" });
|
|
73
|
+
* // ...process crashes mid-run...
|
|
74
|
+
* const recovered = await research.resume("plan-7");
|
|
75
|
+
*/
|
|
76
|
+
resume(runId: string, options?: PlannerResumeOptions<TOutput>): Promise<PlannerResult<TOutput>>;
|
|
57
77
|
}
|
|
58
78
|
//#endregion
|
|
59
79
|
export { PlannerContract };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/planner/planner.contract.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"planner.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/planner/planner.contract.ts"],"mappings":";;;;;;;AA2CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAAiB,eAAA,4BAA2C,kBAAA,SAE1D,qBAAA,CAAsB,OAAA,GACtB,aAAA,CAAc,OAAA;EAmBW;EAAA,SAhBhB,IAAA;EAsCP;;;;;EAAA,SAhCO,SAAA;EAkCgB;;AAAO;;;EA3BhC,OAAA,CACE,IAAA,UACA,OAAA,GAAU,qBAAA,CAAsB,OAAA,IAC/B,OAAA,CAAQ,aAAA,CAAc,OAAA;;;;;;;;;;;;;;;;;;;;EAqBzB,MAAA,CACE,KAAA,UACA,OAAA,GAAU,oBAAA,CAAqB,OAAA,IAC9B,OAAA,CAAQ,aAAA,CAAc,OAAA;AAAA"}
|
|
@@ -20,7 +20,7 @@ declare const REPORT_SCHEMA_VERSION = 1;
|
|
|
20
20
|
* {@link BaseReport}. Forms a closed union so consumers can narrow on
|
|
21
21
|
* the tree without string-matching on `name`.
|
|
22
22
|
*/
|
|
23
|
-
type ReportType = "tool" | "callback" | "agent" | "workflow" | "supervisor" | "team" | "orchestrator" | "batch" | "planner";
|
|
23
|
+
type ReportType = "tool" | "callback" | "agent" | "workflow" | "supervisor" | "team" | "orchestrator" | "batch" | "planner" | "image" | "speech" | "transcription" | "video" | "realtime";
|
|
24
24
|
/**
|
|
25
25
|
* Terminal status every executable primitive reports. Unified across
|
|
26
26
|
* tools, agents, workflows, and supervisors so dashboards and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-report.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/base-report.type.ts"],"mappings":";;;;;;;AAeA;;;;AAAkC;AAOlC;;;;cAPa,qBAAA;
|
|
1
|
+
{"version":3,"file":"base-report.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/base-report.type.ts"],"mappings":";;;;;;;AAeA;;;;AAAkC;AAOlC;;;;cAPa,qBAAA;AAgDb;;;;AAAwB;AAAxB,KAzCY,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KAyCA,YAAA;;;;;;;;AA0HS;;;;;;;;;;;;;;;;;KA1FT,UAAA;sFAEV,KAAA;;;;;;;;;;EAUA,WAAA;;;;;;;EAOA,SAAA;EAEA,IAAA;;;;;;;;;;;;EAYA,OAAA;;;;;;;;;;EAUA,SAAA;EAEA,IAAA,EAAM,UAAA;EAEN,MAAA,EAAQ,YAAA;;;;;;;;;;;;EAYR,KAAA,GAAQ,OAAA;EAER,SAAA;EAEA,OAAA;EAEA,QAAA;EAEA,KAAA,EAAO,KAAA;;;;;;EAMP,QAAA,EAAU,UAAA;;;;;;;;EAQV,QAAA,GAAW,YAAA;;;;;;;;;EASX,mBAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-report.type.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/base-report.type.ts"],"sourcesContent":["import type { AIError } from \"../../errors/ai-error\";\nimport type { AttemptEntry } from \"./attempt-entry.type\";\nimport type { Usage } from \"./usage.type\";\n\n/**\n * Wire-format version stamped on every root `BaseReport`. Bumped only\n * when we make a BREAKING change to the report shape (field removed,\n * required-ness flipped, semantics changed). Additive changes (new\n * optional fields) do not bump.\n *\n * Panoptic and other downstream consumers branch on this to parse\n * old stored reports with their original-shape rules.\n *\n * Current: **1** — initial Panoptic-readiness shape.\n */\nexport const REPORT_SCHEMA_VERSION = 1;\n\n/**\n * Discriminator for the kind of executable that produced a given\n * {@link BaseReport}. Forms a closed union so consumers can narrow on\n * the tree without string-matching on `name`.\n */\nexport type ReportType =\n | \"tool\"\n | \"callback\"\n | \"agent\"\n | \"workflow\"\n | \"supervisor\"\n | \"team\"\n | \"orchestrator\"\n | \"batch\"\n | \"planner\";\n\n/**\n * Terminal status every executable primitive reports. Unified across\n * tools, agents, workflows, and supervisors so dashboards and\n * generic traversal helpers don't special-case per primitive.\n *\n * - `\"completed\"` — ran to natural end with a usable result.\n * - `\"failed\"` — aborted mid-run or finished without a usable result\n * (crash, schema failure, max-trips, etc.). The\n * accompanying `error` on the envelope carries the typed cause.\n * - `\"cancelled\"` — caller aborted before completion via `AbortSignal`.\n * - `\"max-iterations\"` — supervisor-specific termination when the\n * iteration cap was hit without an explicit `END` / `satisfied`.\n * Harmless on non-supervisor reports; keeping it on the shared\n * union lets consumers write one `switch` for every status.\n * - `\"awaiting-input\"` — orchestrator-specific NON-terminal status: the\n * session is paused waiting for the next user turn (§15.6). The only\n * non-terminal member of this union; consumers branching on\n * `status === \"completed\"` must treat it as a session-continues path,\n * not a failure. Harmless on non-orchestrator reports.\n * - `\"awaiting-approval\"` — planner-specific NON-terminal status: a\n * `mode: \"plan-only\"` run generated and validated a plan but executed\n * nothing, pending sign-off (the plan rides on `result.plan`). Mirrors\n * `\"awaiting-input\"` at the plan boundary. Harmless on non-planner\n * reports.\n */\nexport type ReportStatus =\n | \"completed\"\n | \"failed\"\n | \"cancelled\"\n | \"max-iterations\"\n | \"awaiting-input\"\n | \"awaiting-approval\";\n\n/**\n * Universal execution report shared by every primitive. Per-primitive\n * report types extend this with their own domain-specific fields\n * (agent trips, workflow steps, supervisor iteration snapshots) while\n * keeping the root fields identical. Recursion happens through\n * {@link BaseReport.children} — any executable this node invoked\n * contributes its own full report here, producing a walkable tree of\n * the entire run.\n *\n * **Usage rollup.** `usage` at every node equals this node's own cost\n * plus the sum of each child's `usage`. Leaves (tools) contribute\n * zero own-cost; composites contribute their direct LLM spend only,\n * with children covering everything delegated.\n *\n * @example\n * function totalCost(report: BaseReport): number {\n * return report.usage.total;\n * }\n *\n * function walk(report: BaseReport, depth = 0): void {\n * console.log(`${\" \".repeat(depth)}${report.type} \"${report.name}\" — ${report.status}`);\n * for (const child of report.children) walk(child, depth + 1);\n * }\n */\nexport type BaseReport = {\n /** Stable id for this execution node. Generated per `execute()`/`invoke()` call. */\n runId: string;\n /**\n * Run-id of the immediate parent execution node, when this node was\n * invoked as part of a larger run (e.g. a tool dispatched by an\n * agent; an agent dispatched by a supervisor; an inner primitive\n * wrapped via `asTool()`). Absent on root nodes.\n *\n * Lets Panoptic and other flat-row consumers reconstruct the tree\n * without traversing `children[]` in memory.\n */\n parentRunId?: string;\n /**\n * Run-id of the top-level execution this node belongs to. Equals\n * `runId` on the root node, and is propagated downward to every\n * descendant. Used to slice flat report tables back into per-run\n * groupings.\n */\n rootRunId: string;\n /** Executable identity — the tool/agent/workflow/supervisor name. */\n name: string;\n /**\n * Dev-curated version string mirrored from the primitive's config\n * (`AgentConfig.version`, `ToolConfig.version`, etc.). Free-form —\n * the framework neither parses nor compares it. Stored verbatim on\n * every report so trip-archive queries can distinguish runs of\n * \"agent X v2.1\" from \"agent X v2.2\" even when name + signature\n * are identical.\n *\n * Stays `undefined` when the dev didn't declare one — never\n * auto-defaulted.\n */\n version?: string;\n /**\n * Caller-supplied identifier that groups multiple `.execute()` calls\n * into one conceptual user session / request. Propagated to every\n * descendant report node so flat queries (\"total spend for session\n * X today\") work without joining the tree.\n *\n * Threaded from `execute()` options on every primitive. Optional —\n * absent when the caller didn't supply one.\n */\n sessionId?: string;\n /** Discriminator for the kind of executable that produced this report. */\n type: ReportType;\n /** Terminal status of this execution. */\n status: ReportStatus;\n /**\n * Terminal error stamped on a `failed` / `cancelled` node so the typed\n * cause travels WITH the report tree — not only on the result envelope.\n * Essential for the observe path: an {@link import(\"../../observe/observer.contract\").Observer}\n * receives `collect(report)` with no envelope, so a failed root would\n * otherwise expose `status` with no error type/message. Child tool nodes\n * already carry their error this way (`ToolCall.error`); root primitives\n * (agent / workflow / supervisor / orchestrator / planner) stamp it here\n * too. Absent on a `completed` node. Panoptic normalizes it to a JSON-safe\n * span error during projection — the raw `AIError` never has to serialize.\n */\n error?: AIError;\n /** ISO-8601 wall-clock timestamp when execution began. */\n startedAt: string;\n /** ISO-8601 wall-clock timestamp when execution finished. */\n endedAt: string;\n /** Monotonic duration in milliseconds — `performance.now()` delta. */\n duration: number;\n /** Rolled-up usage: own cost + sum of `children[].usage`. */\n usage: Usage;\n /**\n * Reports of every executable invoked by this node, in invocation\n * order. Empty for leaves (pure tools) and for executables that\n * didn't delegate work.\n */\n children: BaseReport[];\n /**\n * Retry history when middleware (or, for workflow steps, the engine\n * itself) retried this node before it either succeeded or gave up.\n * Absent when zero retries happened — keeps the common-case payload\n * lean. The surviving (final) attempt is NOT duplicated here; its\n * outcome is the report's own `status` / timing.\n */\n attempts?: AttemptEntry[];\n /**\n * Wire-format version of this report shape. Only present on root\n * report nodes — implies the same version for the whole tree.\n * Panoptic / archive consumers branch on this to parse old reports\n * with their original-shape rules.\n *\n * Always equals {@link REPORT_SCHEMA_VERSION} at write time.\n */\n reportSchemaVersion?: number;\n};\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,wBAAwB"}
|
|
1
|
+
{"version":3,"file":"base-report.type.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/base-report.type.ts"],"sourcesContent":["import type { AIError } from \"../../errors/ai-error\";\nimport type { AttemptEntry } from \"./attempt-entry.type\";\nimport type { Usage } from \"./usage.type\";\n\n/**\n * Wire-format version stamped on every root `BaseReport`. Bumped only\n * when we make a BREAKING change to the report shape (field removed,\n * required-ness flipped, semantics changed). Additive changes (new\n * optional fields) do not bump.\n *\n * Panoptic and other downstream consumers branch on this to parse\n * old stored reports with their original-shape rules.\n *\n * Current: **1** — initial Panoptic-readiness shape.\n */\nexport const REPORT_SCHEMA_VERSION = 1;\n\n/**\n * Discriminator for the kind of executable that produced a given\n * {@link BaseReport}. Forms a closed union so consumers can narrow on\n * the tree without string-matching on `name`.\n */\nexport type ReportType =\n | \"tool\"\n | \"callback\"\n | \"agent\"\n | \"workflow\"\n | \"supervisor\"\n | \"team\"\n | \"orchestrator\"\n | \"batch\"\n | \"planner\"\n | \"image\"\n | \"speech\"\n | \"transcription\"\n | \"video\"\n | \"realtime\";\n\n/**\n * Terminal status every executable primitive reports. Unified across\n * tools, agents, workflows, and supervisors so dashboards and\n * generic traversal helpers don't special-case per primitive.\n *\n * - `\"completed\"` — ran to natural end with a usable result.\n * - `\"failed\"` — aborted mid-run or finished without a usable result\n * (crash, schema failure, max-trips, etc.). The\n * accompanying `error` on the envelope carries the typed cause.\n * - `\"cancelled\"` — caller aborted before completion via `AbortSignal`.\n * - `\"max-iterations\"` — supervisor-specific termination when the\n * iteration cap was hit without an explicit `END` / `satisfied`.\n * Harmless on non-supervisor reports; keeping it on the shared\n * union lets consumers write one `switch` for every status.\n * - `\"awaiting-input\"` — orchestrator-specific NON-terminal status: the\n * session is paused waiting for the next user turn (§15.6). The only\n * non-terminal member of this union; consumers branching on\n * `status === \"completed\"` must treat it as a session-continues path,\n * not a failure. Harmless on non-orchestrator reports.\n * - `\"awaiting-approval\"` — planner-specific NON-terminal status: a\n * `mode: \"plan-only\"` run generated and validated a plan but executed\n * nothing, pending sign-off (the plan rides on `result.plan`). Mirrors\n * `\"awaiting-input\"` at the plan boundary. Harmless on non-planner\n * reports.\n */\nexport type ReportStatus =\n | \"completed\"\n | \"failed\"\n | \"cancelled\"\n | \"max-iterations\"\n | \"awaiting-input\"\n | \"awaiting-approval\";\n\n/**\n * Universal execution report shared by every primitive. Per-primitive\n * report types extend this with their own domain-specific fields\n * (agent trips, workflow steps, supervisor iteration snapshots) while\n * keeping the root fields identical. Recursion happens through\n * {@link BaseReport.children} — any executable this node invoked\n * contributes its own full report here, producing a walkable tree of\n * the entire run.\n *\n * **Usage rollup.** `usage` at every node equals this node's own cost\n * plus the sum of each child's `usage`. Leaves (tools) contribute\n * zero own-cost; composites contribute their direct LLM spend only,\n * with children covering everything delegated.\n *\n * @example\n * function totalCost(report: BaseReport): number {\n * return report.usage.total;\n * }\n *\n * function walk(report: BaseReport, depth = 0): void {\n * console.log(`${\" \".repeat(depth)}${report.type} \"${report.name}\" — ${report.status}`);\n * for (const child of report.children) walk(child, depth + 1);\n * }\n */\nexport type BaseReport = {\n /** Stable id for this execution node. Generated per `execute()`/`invoke()` call. */\n runId: string;\n /**\n * Run-id of the immediate parent execution node, when this node was\n * invoked as part of a larger run (e.g. a tool dispatched by an\n * agent; an agent dispatched by a supervisor; an inner primitive\n * wrapped via `asTool()`). Absent on root nodes.\n *\n * Lets Panoptic and other flat-row consumers reconstruct the tree\n * without traversing `children[]` in memory.\n */\n parentRunId?: string;\n /**\n * Run-id of the top-level execution this node belongs to. Equals\n * `runId` on the root node, and is propagated downward to every\n * descendant. Used to slice flat report tables back into per-run\n * groupings.\n */\n rootRunId: string;\n /** Executable identity — the tool/agent/workflow/supervisor name. */\n name: string;\n /**\n * Dev-curated version string mirrored from the primitive's config\n * (`AgentConfig.version`, `ToolConfig.version`, etc.). Free-form —\n * the framework neither parses nor compares it. Stored verbatim on\n * every report so trip-archive queries can distinguish runs of\n * \"agent X v2.1\" from \"agent X v2.2\" even when name + signature\n * are identical.\n *\n * Stays `undefined` when the dev didn't declare one — never\n * auto-defaulted.\n */\n version?: string;\n /**\n * Caller-supplied identifier that groups multiple `.execute()` calls\n * into one conceptual user session / request. Propagated to every\n * descendant report node so flat queries (\"total spend for session\n * X today\") work without joining the tree.\n *\n * Threaded from `execute()` options on every primitive. Optional —\n * absent when the caller didn't supply one.\n */\n sessionId?: string;\n /** Discriminator for the kind of executable that produced this report. */\n type: ReportType;\n /** Terminal status of this execution. */\n status: ReportStatus;\n /**\n * Terminal error stamped on a `failed` / `cancelled` node so the typed\n * cause travels WITH the report tree — not only on the result envelope.\n * Essential for the observe path: an {@link import(\"../../observe/observer.contract\").Observer}\n * receives `collect(report)` with no envelope, so a failed root would\n * otherwise expose `status` with no error type/message. Child tool nodes\n * already carry their error this way (`ToolCall.error`); root primitives\n * (agent / workflow / supervisor / orchestrator / planner) stamp it here\n * too. Absent on a `completed` node. Panoptic normalizes it to a JSON-safe\n * span error during projection — the raw `AIError` never has to serialize.\n */\n error?: AIError;\n /** ISO-8601 wall-clock timestamp when execution began. */\n startedAt: string;\n /** ISO-8601 wall-clock timestamp when execution finished. */\n endedAt: string;\n /** Monotonic duration in milliseconds — `performance.now()` delta. */\n duration: number;\n /** Rolled-up usage: own cost + sum of `children[].usage`. */\n usage: Usage;\n /**\n * Reports of every executable invoked by this node, in invocation\n * order. Empty for leaves (pure tools) and for executables that\n * didn't delegate work.\n */\n children: BaseReport[];\n /**\n * Retry history when middleware (or, for workflow steps, the engine\n * itself) retried this node before it either succeeded or gave up.\n * Absent when zero retries happened — keeps the common-case payload\n * lean. The surviving (final) attempt is NOT duplicated here; its\n * outcome is the report's own `status` / timing.\n */\n attempts?: AttemptEntry[];\n /**\n * Wire-format version of this report shape. Only present on root\n * report nodes — implies the same version for the whole tree.\n * Panoptic / archive consumers branch on this to parse old reports\n * with their original-shape rules.\n *\n * Always equals {@link REPORT_SCHEMA_VERSION} at write time.\n */\n reportSchemaVersion?: number;\n};\n"],"mappings":";;;;;;;;;;;;AAeA,MAAa,wBAAwB"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ModelPricing } from "./result/model-pricing.type.mjs";
|
|
2
2
|
import { ModelContract } from "./model.contract.mjs";
|
|
3
3
|
import { EmbedderConfig, EmbedderContract } from "./embedder.contract.mjs";
|
|
4
|
+
import { ImageModelConfig, ImageModelContract } from "./image-model.contract.mjs";
|
|
5
|
+
import { SpeechModelConfig, SpeechModelContract } from "./speech-model.contract.mjs";
|
|
6
|
+
import { TranscriptionModelConfig, TranscriptionModelContract } from "./transcription-model.contract.mjs";
|
|
4
7
|
|
|
5
8
|
//#region ../@warlock.js/ai/src/contracts/sdk-adapter.contract.d.ts
|
|
6
9
|
/**
|
|
@@ -71,6 +74,40 @@ interface SDKAdapterContract {
|
|
|
71
74
|
* const { vector } = await embedder.embed("Hello world");
|
|
72
75
|
*/
|
|
73
76
|
embedder?(config: EmbedderConfig): EmbedderContract;
|
|
77
|
+
/**
|
|
78
|
+
* Create an image-generation model bound to this SDK's client.
|
|
79
|
+
* Optional — only providers with an image API expose it (OpenAI,
|
|
80
|
+
* Google today; Anthropic/Bedrock/Ollama do not). The structural
|
|
81
|
+
* absence of this method IS the capability guard: an adapter that
|
|
82
|
+
* can't generate images simply doesn't define it, so `ai.someSdk.image(...)`
|
|
83
|
+
* is a compile-time error rather than a silent runtime failure.
|
|
84
|
+
* Hand the returned model to `ai.image({ model, prompt })`.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* const model = openai.image({ name: "gpt-image-1" });
|
|
88
|
+
* const { data } = await ai.image({ model, prompt: "a red bicycle" });
|
|
89
|
+
*/
|
|
90
|
+
image?(config: ImageModelConfig): ImageModelContract;
|
|
91
|
+
/**
|
|
92
|
+
* Create a text-to-speech model bound to this SDK's client, for use
|
|
93
|
+
* with `ai.speech({ model, text })`. Optional — only providers with a
|
|
94
|
+
* TTS API expose it. Structural absence is the capability guard.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* const tts = openai.speech({ name: "tts-1", voice: "alloy" });
|
|
98
|
+
* const { data } = await ai.speech({ model: tts, text: "Hello" });
|
|
99
|
+
*/
|
|
100
|
+
speech?(config: SpeechModelConfig): SpeechModelContract;
|
|
101
|
+
/**
|
|
102
|
+
* Create a speech-to-text (transcription) model bound to this SDK's
|
|
103
|
+
* client, for use with `ai.transcribe({ model, audio })`. Optional —
|
|
104
|
+
* only providers with an STT API expose it.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const stt = openai.transcribe({ name: "whisper-1" });
|
|
108
|
+
* const { data } = await ai.transcribe({ model: stt, audio });
|
|
109
|
+
*/
|
|
110
|
+
transcribe?(config: TranscriptionModelConfig): TranscriptionModelContract;
|
|
74
111
|
}
|
|
75
112
|
//#endregion
|
|
76
113
|
export { ModelConfig, SDKAdapterContract };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-adapter.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/sdk-adapter.contract.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk-adapter.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/sdk-adapter.contract.ts"],"mappings":";;;;;;;;;;AAwBA;;;;;;;;;;;AAiBc;KAjBF,WAAA;EAkCuB,qEAhCjC,IAAA,UAqCc;EAnCd,WAAA,WA6CqC;EA3CrC,SAAA;EAsDmC;;;;;;;;EA7CnC,OAAA,GAAU,YAAY,EAwBtB;EAAA,CAtBC,GAAA;AAAA;;;;;;;;;;;;;;;UAiBc,kBAAA;EAoDP;;;;EA/CR,KAAA,CAAM,MAAA,EAAQ,WAAA,GAAc,aAAA;EA0DmB;;AAA0B;;;;;;EAhDzE,KAAA,CAAM,IAAA,UAAc,KAAA,YAAiB,OAAA;;;;;;;;;;EAWrC,QAAA,EAAU,MAAA,EAAQ,cAAA,GAAiB,gBAAA;;;;;;;;;;;;;;EAenC,KAAA,EAAO,MAAA,EAAQ,gBAAA,GAAmB,kBAAA;;;;;;;;;;EAWlC,MAAA,EAAQ,MAAA,EAAQ,iBAAA,GAAoB,mBAAA;;;;;;;;;;EAWpC,UAAA,EAAY,MAAA,EAAQ,wBAAA,GAA2B,0BAAA;AAAA"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Usage } from "./result/usage.type.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../@warlock.js/ai/src/contracts/speech-model.contract.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* USD pricing for a text-to-speech model. TTS providers meter one of
|
|
6
|
+
* two ways, and this single shape covers both so the cost folds into
|
|
7
|
+
* the same `Usage.cost` rollup the text + image paths use:
|
|
8
|
+
*
|
|
9
|
+
* - **Per-character** (OpenAI `tts-1` / `tts-1-hd`): billed per input
|
|
10
|
+
* character. Set `perMillionCharacters` (USD per 1,000,000 chars).
|
|
11
|
+
* - **Token-metered** (OpenAI `gpt-4o-mini-tts`): billed per input/output
|
|
12
|
+
* token like a chat model. Set `input` / `output` (USD per 1M tokens).
|
|
13
|
+
*
|
|
14
|
+
* Per-character wins when both are set. Nothing set → `Usage.cost`
|
|
15
|
+
* stays `undefined` (honest "cost unknown", not a false zero).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* const pricing: SpeechModelPricing = { perMillionCharacters: 15 }; // tts-1
|
|
19
|
+
*/
|
|
20
|
+
type SpeechModelPricing = {
|
|
21
|
+
/** USD per 1M input characters — per-character-metered TTS. */perMillionCharacters?: number; /** USD per 1M input tokens — token-metered TTS. */
|
|
22
|
+
input?: number; /** USD per 1M output (audio) tokens — token-metered TTS. */
|
|
23
|
+
output?: number;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Generated audio, normalized to a discriminated shape (mirrors
|
|
27
|
+
* {@link GeneratedImage}). TTS providers return raw audio bytes, so the
|
|
28
|
+
* `base64` variant is the only one today; the union leaves room for a
|
|
29
|
+
* future hosted-`url` variant without a breaking change.
|
|
30
|
+
*/
|
|
31
|
+
type GeneratedAudio = {
|
|
32
|
+
type: "base64"; /** Base64-encoded audio bytes. */
|
|
33
|
+
base64: string; /** IANA media type (e.g. `"audio/mpeg"`, `"audio/wav"`). */
|
|
34
|
+
mediaType: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Options for a single {@link SpeechModelContract.generate} request.
|
|
38
|
+
* Provider-neutral; each adapter maps the ones its API supports.
|
|
39
|
+
*/
|
|
40
|
+
type SpeechOptions = {
|
|
41
|
+
/** Voice id/name (e.g. OpenAI `"alloy"`, `"verse"`). Defaults per model config. */voice?: string; /** Output container (`"mp3"` / `"opus"` / `"aac"` / `"flac"` / `"wav"` / `"pcm"`). */
|
|
42
|
+
format?: string; /** Playback speed multiplier (provider range, e.g. OpenAI `0.25`–`4.0`). */
|
|
43
|
+
speed?: number; /** Extra steering of tone/delivery (OpenAI `gpt-4o-mini-tts` `instructions`). */
|
|
44
|
+
instructions?: string; /** Cancellation handle wired into the provider request where supported. */
|
|
45
|
+
signal?: AbortSignal; /** Provider-specific escape hatch — forwarded verbatim. */
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Raw result of a {@link SpeechModelContract.generate} call — low-level
|
|
50
|
+
* (like `EmbedderContract.embed`): returns the audio + usage and THROWS
|
|
51
|
+
* a typed `AIError` on failure. The never-throws `{ data, error, usage,
|
|
52
|
+
* report }` envelope is added by the `ai.speech()` facade verb.
|
|
53
|
+
*/
|
|
54
|
+
type SpeechGenerationResponse = {
|
|
55
|
+
audio: GeneratedAudio;
|
|
56
|
+
/**
|
|
57
|
+
* Token usage when the provider meters per token (gpt-4o-mini-tts);
|
|
58
|
+
* `{ input: 0, output: 0, total: 0 }` for per-character-metered models,
|
|
59
|
+
* whose spend is priced from {@link characters}.
|
|
60
|
+
*/
|
|
61
|
+
usage: Usage; /** Number of input characters synthesized — drives per-character cost. */
|
|
62
|
+
characters: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Provider-neutral contract for a text-to-speech model — the audio
|
|
66
|
+
* sibling of {@link ImageModelContract}. Produced by an adapter's
|
|
67
|
+
* optional `speech?(config)` factory and consumed by `ai.speech()`.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* const tts = openai.speech({ name: "tts-1", voice: "alloy" });
|
|
71
|
+
* const { audio } = await tts.generate("Welcome aboard.");
|
|
72
|
+
*/
|
|
73
|
+
interface SpeechModelContract {
|
|
74
|
+
/** Model identifier (e.g. `"tts-1"`, `"gpt-4o-mini-tts"`). */
|
|
75
|
+
readonly name: string;
|
|
76
|
+
/** Provider this model belongs to (e.g. `"openai"`). */
|
|
77
|
+
readonly provider: string;
|
|
78
|
+
/** Per-character or per-token USD pricing; folded into `Usage.cost` by `ai.speech()`. */
|
|
79
|
+
readonly pricing?: SpeechModelPricing;
|
|
80
|
+
/** Synthesize speech from text. Throws a typed `AIError` on failure. */
|
|
81
|
+
generate(text: string, options?: SpeechOptions): Promise<SpeechGenerationResponse>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Configuration passed to an adapter's `speech()` factory. Mirrors
|
|
85
|
+
* {@link ImageModelConfig}: `name` + an optional per-model `pricing`
|
|
86
|
+
* override + a default `voice`, with provider-specific keys on the
|
|
87
|
+
* index signature.
|
|
88
|
+
*/
|
|
89
|
+
type SpeechModelConfig = {
|
|
90
|
+
name: string; /** Per-model USD pricing override; wins over the SDK-level registry. */
|
|
91
|
+
pricing?: SpeechModelPricing; /** Default voice when a call omits `options.voice`. */
|
|
92
|
+
voice?: string;
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
export { GeneratedAudio, SpeechGenerationResponse, SpeechModelConfig, SpeechModelContract, SpeechModelPricing, SpeechOptions };
|
|
97
|
+
//# sourceMappingURL=speech-model.contract.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speech-model.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/speech-model.contract.ts"],"mappings":";;;;;AAkBA;;;;;;;;AAMQ;AASR;;;;;KAfY,kBAAA;EAoBV,+DAlBA,oBAAA,WAkBS;EAhBT,KAAA,WAuBuB;EArBvB,MAAA;AAAA;;;;;;;KASU,cAAA;EACV,IAAA,YAuBY;EArBZ,MAAA,UA8BkC;EA5BlC,SAAA;AAAA;;;;;KAOU,aAAA;EA8BA,mFA5BV,KAAA,WAwCe;EAtCf,MAAA;EAEA,KAAA,WA6CiC;EA3CjC,YAAA,WA2CiD;EAzCjD,MAAA,GAAS,WAAW,EAyCoC;EAAA,CAvCvD,GAAA;AAAA;;;;;;;KASS,wBAAA;EACV,KAAA,EAAO,cAAA;EA6B0E;AAAA;AASnF;;;EAhCE,KAAA,EAAO,KAAK,EAiCZ;EA/BA,UAAA;AAAA;;;;AAoCY;;;;;;UAxBG,mBAAA;;WAEN,IAAA;;WAEA,QAAA;;WAEA,OAAA,GAAU,kBAAA;;EAGnB,QAAA,CAAS,IAAA,UAAc,OAAA,GAAU,aAAA,GAAgB,OAAA,CAAQ,wBAAA;AAAA;;;;;;;KAS/C,iBAAA;EACV,IAAA;EAEA,OAAA,GAAU,kBAAkB;EAE5B,KAAA;EAAA,CACC,GAAA;AAAA"}
|