@voltojs/providers 0.0.0-stage → 0.2.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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/dist/anthropic/index.d.ts +5 -0
  3. package/dist/anthropic/index.d.ts.map +1 -0
  4. package/dist/anthropic/index.js +3 -0
  5. package/dist/anthropic/index.js.map +1 -0
  6. package/dist/anthropic/model-port.d.ts +34 -0
  7. package/dist/anthropic/model-port.d.ts.map +1 -0
  8. package/dist/anthropic/model-port.js +337 -0
  9. package/dist/anthropic/model-port.js.map +1 -0
  10. package/dist/anthropic/stream-normalize.d.ts +27 -0
  11. package/dist/anthropic/stream-normalize.d.ts.map +1 -0
  12. package/dist/anthropic/stream-normalize.js +140 -0
  13. package/dist/anthropic/stream-normalize.js.map +1 -0
  14. package/dist/embedder-openai/embedder.d.ts +18 -0
  15. package/dist/embedder-openai/embedder.d.ts.map +1 -0
  16. package/dist/embedder-openai/embedder.js +44 -0
  17. package/dist/embedder-openai/embedder.js.map +1 -0
  18. package/dist/embedder-openai/index.d.ts +3 -0
  19. package/dist/embedder-openai/index.d.ts.map +1 -0
  20. package/dist/embedder-openai/index.js +2 -0
  21. package/dist/embedder-openai/index.js.map +1 -0
  22. package/dist/openai/index.d.ts +5 -0
  23. package/dist/openai/index.d.ts.map +1 -0
  24. package/dist/openai/index.js +3 -0
  25. package/dist/openai/index.js.map +1 -0
  26. package/dist/openai/model-port.d.ts +37 -0
  27. package/dist/openai/model-port.d.ts.map +1 -0
  28. package/dist/openai/model-port.js +330 -0
  29. package/dist/openai/model-port.js.map +1 -0
  30. package/dist/openai/stream-normalize.d.ts +70 -0
  31. package/dist/openai/stream-normalize.d.ts.map +1 -0
  32. package/dist/openai/stream-normalize.js +185 -0
  33. package/dist/openai/stream-normalize.js.map +1 -0
  34. package/dist/pi-ai/catalog.d.ts +40 -0
  35. package/dist/pi-ai/catalog.d.ts.map +1 -0
  36. package/dist/pi-ai/catalog.js +38 -0
  37. package/dist/pi-ai/catalog.js.map +1 -0
  38. package/dist/pi-ai/collection.d.ts +133 -0
  39. package/dist/pi-ai/collection.d.ts.map +1 -0
  40. package/dist/pi-ai/collection.js +532 -0
  41. package/dist/pi-ai/collection.js.map +1 -0
  42. package/dist/pi-ai/context.d.ts +15 -0
  43. package/dist/pi-ai/context.d.ts.map +1 -0
  44. package/dist/pi-ai/context.js +414 -0
  45. package/dist/pi-ai/context.js.map +1 -0
  46. package/dist/pi-ai/index.d.ts +8 -0
  47. package/dist/pi-ai/index.d.ts.map +1 -0
  48. package/dist/pi-ai/index.js +4 -0
  49. package/dist/pi-ai/index.js.map +1 -0
  50. package/dist/pi-ai/model-port.d.ts +45 -0
  51. package/dist/pi-ai/model-port.d.ts.map +1 -0
  52. package/dist/pi-ai/model-port.js +168 -0
  53. package/dist/pi-ai/model-port.js.map +1 -0
  54. package/dist/pi-ai/replay.d.ts +46 -0
  55. package/dist/pi-ai/replay.d.ts.map +1 -0
  56. package/dist/pi-ai/replay.js +99 -0
  57. package/dist/pi-ai/replay.js.map +1 -0
  58. package/dist/pi-ai/stream-normalize.d.ts +13 -0
  59. package/dist/pi-ai/stream-normalize.d.ts.map +1 -0
  60. package/dist/pi-ai/stream-normalize.js +118 -0
  61. package/dist/pi-ai/stream-normalize.js.map +1 -0
  62. package/package.json +48 -3
  63. package/README.md +0 -3
@@ -0,0 +1,414 @@
1
+ import { readReplayEnvelope } from "./replay.js";
2
+ /**
3
+ * Translate core's neutral Message[] (and tool definitions) into a pi-ai
4
+ * Context ready to hand to Models.stream/streamSimple.
5
+ *
6
+ * `model` is the current route's resolved pi-ai Model. Its `id` is passed
7
+ * through to `readReplayEnvelope` so a message produced by a different model
8
+ * degrades to unsigned content instead of replaying a foreign provider's
9
+ * signatures; its `api`/`provider`/`id` are also stamped onto outgoing
10
+ * assistant messages so pi-ai's own `transformMessages` isSameModel check
11
+ * (which gates whether signed thinking/tool-call blocks survive) passes.
12
+ */
13
+ export function toPiContext(req, model) {
14
+ const modelId = model.id;
15
+ const systemSections = req.messages
16
+ .filter((m) => m.role === "system")
17
+ // String-typed in core, but a block array can arrive at runtime (see
18
+ // projectSystemContent) — project instead of joining "[object Object]".
19
+ .map((m) => projectSystemContent(m.content));
20
+ // `ModelRequest.responseFormat` has no pi-ai equivalent to forward (see
21
+ // responseFormatInstruction), so it is carried as a system instruction —
22
+ // never silently dropped.
23
+ if (req.responseFormat !== undefined) {
24
+ systemSections.push(responseFormatInstruction(req.responseFormat));
25
+ }
26
+ const systemPrompt = systemSections.join("\n\n");
27
+ // Built once per call (not rescanned per tool-result block): maps a
28
+ // tool_use block's id to its name, for mapToolResultMessage's reverse
29
+ // lookup below.
30
+ const toolNameById = buildToolNameIndex(req.messages);
31
+ const messages = [];
32
+ for (const message of req.messages) {
33
+ if (message.role === "system") {
34
+ continue; // merged into systemPrompt above
35
+ }
36
+ if (message.role === "user") {
37
+ messages.push(mapUserMessage(message));
38
+ }
39
+ else if (message.role === "assistant") {
40
+ messages.push(mapAssistantMessage(message, modelId, model));
41
+ }
42
+ else {
43
+ messages.push(...mapToolResultMessage(message.content, toolNameById));
44
+ }
45
+ }
46
+ const context = { messages };
47
+ if (systemPrompt.length > 0) {
48
+ context.systemPrompt = systemPrompt;
49
+ }
50
+ if (req.tools.length > 0) {
51
+ context.tools = req.tools.map(mapToolDefinition);
52
+ }
53
+ return context;
54
+ }
55
+ /**
56
+ * pi-ai exposes no request-level response-format option: `SimpleStreamOptions`
57
+ * carries sampling, reasoning and cache knobs only, and `constrainedSampling`
58
+ * is a per-tool grammar setting rather than a reply format. Native JSON-schema
59
+ * support is also uneven across the provider catalog this adapter serves, so
60
+ * there is nothing portable to forward. Mirror the standalone Anthropic
61
+ * adapter: state the required JSON shape in the system prompt. This is
62
+ * prompt-level guidance, not provider-side constrained decoding; a host that
63
+ * needs native schema enforcement must use the OpenAI-compatible adapter.
64
+ */
65
+ function responseFormatInstruction(format) {
66
+ if (format.schema !== undefined) {
67
+ return ("You MUST respond with valid JSON matching this schema:\n" +
68
+ JSON.stringify(format.schema, null, 2));
69
+ }
70
+ return ("You MUST respond with valid JSON only. No markdown, no explanations " +
71
+ "outside the JSON.");
72
+ }
73
+ /**
74
+ * Project a system message's content to the plain string pi-ai's
75
+ * `Context.systemPrompt` accepts — there is no system-image surface. Core
76
+ * state can carry a BLOCK-ARRAY system message (the compaction
77
+ * image-preservation summary lands one behind a documented cast, spec
78
+ * 2026-10-16 D5); without this projection the block array joins into
79
+ * "[object Object]" garbage. With it the model sees the summary and the
80
+ * preserved-image marker, and image blocks degrade to the same
81
+ * `[image: WxH mediaType]` placeholder core's extractBlockText renders.
82
+ */
83
+ function projectSystemContent(content) {
84
+ if (typeof content === "string")
85
+ return content;
86
+ return content.map(systemBlockText).join("\n");
87
+ }
88
+ /** One system block's text projection — mirrors core's extractBlockText. */
89
+ function systemBlockText(block) {
90
+ switch (block.type) {
91
+ case "text":
92
+ case "structured":
93
+ return block.text;
94
+ case "image": {
95
+ const dims = block.width !== undefined && block.height !== undefined
96
+ ? `${block.width}x${block.height} `
97
+ : "";
98
+ return `[image: ${dims}${block.source.mediaType}]`;
99
+ }
100
+ case "tool_use":
101
+ return `[tool: ${block.name}]`;
102
+ case "tool_result":
103
+ return block.content.map(systemBlockText).join("\n");
104
+ case "reasoning":
105
+ return "";
106
+ }
107
+ }
108
+ // ──────────────────────────────────────────────
109
+ // user
110
+ // ──────────────────────────────────────────────
111
+ /**
112
+ * Map a request-surface image block to pi-ai's `ImageContent`.
113
+ *
114
+ * The Runner's `resolveImageRefs` replaces AttachmentStore refs with base64
115
+ * before the provider sees the request. A ref that still reaches here means
116
+ * that resolve step was skipped — throw rather than silently shipping a
117
+ * payload the model cannot use, so the failure surfaces as a broken pipeline
118
+ * instead of "the model cannot see the image".
119
+ *
120
+ * Vision gating is deliberately NOT done here: pi-ai's own transformMessages
121
+ * strips images when `model.input` lacks "image" (collection.ts only puts it
122
+ * there when the model is known-vision). This mapper is a pure wire-shape
123
+ * translation.
124
+ */
125
+ function toPiImageContent(block) {
126
+ // Core's ImageContent is ref-only; the wire shape arrives as an untyped
127
+ // cast at the request boundary. Narrow at runtime rather than widening core.
128
+ const src = block.source;
129
+ if (src.type === "base64" && typeof src.mediaType === "string" && typeof src.data === "string") {
130
+ return { type: "image", data: src.data, mimeType: src.mediaType };
131
+ }
132
+ if (src.type === "ref") {
133
+ throw new Error(`pi-ai: unresolved image ref "${src.id ?? "<unknown>"}" reached the provider; ` +
134
+ `the Runner must resolve AttachmentStore refs to base64 before modelPort.stream()`);
135
+ }
136
+ throw new Error(`pi-ai: unsupported image source type "${src.type ?? "<missing>"}"`);
137
+ }
138
+ function mapUserMessage(message) {
139
+ const timestamp = 0; // see note in mapAssistantMessage about historical timestamps
140
+ if (typeof message.content === "string") {
141
+ return { role: "user", content: message.content, timestamp };
142
+ }
143
+ const content = [];
144
+ for (const block of message.content) {
145
+ if (block.type === "text") {
146
+ content.push({ type: "text", text: block.text });
147
+ }
148
+ else if (block.type === "image") {
149
+ content.push(toPiImageContent(block));
150
+ }
151
+ // Other ContentBlock variants (tool_use / tool_result / reasoning) are not
152
+ // part of core's user-message contract; skip defensively rather than
153
+ // throwing so a malformed upstream state doesn't break the whole request.
154
+ }
155
+ return { role: "user", content, timestamp };
156
+ }
157
+ // ──────────────────────────────────────────────
158
+ // assistant
159
+ // ──────────────────────────────────────────────
160
+ function mapAssistantMessage(message, model, piModel) {
161
+ // Second, independent guard alongside readReplayEnvelope's own model check:
162
+ // `source` is stamped by the kernel from the step context at assembly time,
163
+ // while `modelMeta` is adapter-private and self-declared. A message whose
164
+ // envelope claims the current model but whose kernel-stamped source
165
+ // disagrees is foreign replay just as much as a mismatched envelope is; do
166
+ // not trust the envelope in that case. An absent `source` (older messages,
167
+ // or messages assembled before this field existed) is not a mismatch — it
168
+ // falls back to the envelope's own check alone.
169
+ //
170
+ // `source.providerId` is deliberately not compared. It is provenance for
171
+ // display (the host's provider-config id, e.g. "deepseek-official"), not a
172
+ // routing predicate: pi-ai's own `model.provider` is a different vocabulary
173
+ // ("deepseek"), so comparing them would mark every replay foreign and
174
+ // silently strip signed thinking/tool-call blocks. modelId remains the
175
+ // only field this decision reads.
176
+ const isForeignSource = message.source !== undefined && message.source.modelId !== model;
177
+ const envelope = isForeignSource ? undefined : readReplayEnvelope(message.modelMeta, model);
178
+ const content = [];
179
+ message.content.forEach((block, index) => {
180
+ const replayBlock = envelope?.blocks[index];
181
+ const mapped = mapAssistantContentBlock(block, replayBlock);
182
+ if (mapped !== undefined) {
183
+ content.push(mapped);
184
+ }
185
+ });
186
+ return {
187
+ role: "assistant",
188
+ content,
189
+ // pi-ai's AssistantMessage doubles as "the full response envelope from a
190
+ // provider" (api/provider/model/usage/stopReason are all required,
191
+ // non-optional fields), but core's neutral AssistantMessage only tracks
192
+ // content + stopReason + modelMeta. `usage` is a genuine placeholder
193
+ // (we don't track historical token counts), but api/provider/model MUST
194
+ // match the current route's real Model: pi-ai's own transformMessages
195
+ // (dist/api/transform-messages.js) computes `isSameModel` by comparing
196
+ // `assistantMsg.provider === model.provider && assistantMsg.api ===
197
+ // model.api && assistantMsg.model === model.id` before deciding whether
198
+ // to keep signed thinking/tool-call blocks or strip them to plain text.
199
+ // Hardcoding "unknown" here made isSameModel always false, silently
200
+ // dropping thinkingSignature/thoughtSignature on every replay.
201
+ api: piModel.api,
202
+ provider: piModel.provider,
203
+ model,
204
+ usage: zeroUsage(),
205
+ stopReason: mapStopReason(message.stopReason),
206
+ // See mapUserMessage: core does not track per-message wall-clock time,
207
+ // so historical messages get a static placeholder timestamp rather than
208
+ // reading the clock here (which would make this pure-translation
209
+ // function's output depend on when it happens to run).
210
+ timestamp: 0,
211
+ };
212
+ }
213
+ function mapAssistantContentBlock(block, replayBlock) {
214
+ switch (block.type) {
215
+ case "text": {
216
+ const textSignature = replayBlock?.type === "text" ? replayBlock.textSignature : undefined;
217
+ const text = { type: "text", text: block.text };
218
+ if (textSignature !== undefined) {
219
+ text.textSignature = textSignature;
220
+ }
221
+ return text;
222
+ }
223
+ case "reasoning": {
224
+ // The thinking block must always carry the reasoning text through,
225
+ // whether or not a signature is available (foreign replay / missing
226
+ // envelope / predates the envelope). Losing the text would silently
227
+ // break a provider that relies on seeing its own prior reasoning.
228
+ const thinking = { type: "thinking", thinking: block.text };
229
+ if (replayBlock?.type === "reasoning") {
230
+ if (replayBlock.thinkingSignature !== undefined) {
231
+ thinking.thinkingSignature = replayBlock.thinkingSignature;
232
+ }
233
+ if (replayBlock.redacted !== undefined) {
234
+ thinking.redacted = replayBlock.redacted;
235
+ }
236
+ }
237
+ return thinking;
238
+ }
239
+ case "tool_use": {
240
+ const thoughtSignature = replayBlock?.type === "tool_use" ? replayBlock.thoughtSignature : undefined;
241
+ const toolCall = {
242
+ type: "toolCall",
243
+ id: block.id,
244
+ name: block.name,
245
+ arguments: toPiToolArguments(block.input),
246
+ };
247
+ if (thoughtSignature !== undefined) {
248
+ toolCall.thoughtSignature = thoughtSignature;
249
+ }
250
+ return toolCall;
251
+ }
252
+ case "image":
253
+ case "tool_result":
254
+ // Assistant messages do not carry image or tool_result blocks in
255
+ // core's model; skip defensively rather than throwing, so a
256
+ // malformed upstream state doesn't break the whole request.
257
+ return undefined;
258
+ }
259
+ }
260
+ // ──────────────────────────────────────────────
261
+ // tool arguments
262
+ // ──────────────────────────────────────────────
263
+ /**
264
+ * Validate a tool_use input as JSON before handing it to pi-ai, whose
265
+ * `ToolCall.arguments` is `JsonObject` while core's `ToolUseContent.input`
266
+ * is the wider `Record<string, unknown>`.
267
+ *
268
+ * The data in practice is JSON (provider tool-call parsing, zod-validated
269
+ * tool output), so this rejects only states that could never survive wire
270
+ * serialization anyway — throwing names the offending path instead of
271
+ * letting `JSON.stringify` silently drop a `function`/`undefined` field and
272
+ * ship a tool call the model never authorized.
273
+ */
274
+ function toPiToolArguments(input) {
275
+ const out = {};
276
+ for (const [key, value] of Object.entries(input)) {
277
+ out[key] = toPiJsonValue(value, key);
278
+ }
279
+ return out;
280
+ }
281
+ function toPiJsonValue(value, path) {
282
+ if (value === null)
283
+ return null;
284
+ switch (typeof value) {
285
+ case "string":
286
+ case "boolean":
287
+ return value;
288
+ case "number":
289
+ if (!Number.isFinite(value)) {
290
+ throw new Error(`pi-ai: tool argument "${path}" is ${String(value)}, which JSON cannot represent`);
291
+ }
292
+ return value;
293
+ case "object": {
294
+ if (Array.isArray(value)) {
295
+ return value.map((item, index) => toPiJsonValue(item, `${path}[${index}]`));
296
+ }
297
+ return toPiToolArguments(value);
298
+ }
299
+ default:
300
+ throw new Error(`pi-ai: tool argument "${path}" has type ${typeof value}, which JSON cannot represent`);
301
+ }
302
+ }
303
+ function mapStopReason(stopReason) {
304
+ switch (stopReason) {
305
+ case "tool_use":
306
+ return "toolUse";
307
+ case "max_tokens":
308
+ return "length";
309
+ case "end_turn":
310
+ case undefined:
311
+ return "stop";
312
+ }
313
+ }
314
+ function zeroUsage() {
315
+ return {
316
+ input: 0,
317
+ output: 0,
318
+ cacheRead: 0,
319
+ cacheWrite: 0,
320
+ totalTokens: 0,
321
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
322
+ };
323
+ }
324
+ // ──────────────────────────────────────────────
325
+ // tool result
326
+ // ──────────────────────────────────────────────
327
+ /**
328
+ * Map tool results to pi-ai's `ToolResultMessage`, dropping any result whose
329
+ * originating `tool_use` block cannot be found.
330
+ *
331
+ * This is not hypothetical: compaction (`packages/core/src/compactor.ts`)
332
+ * walks the message list greedily against a token budget and can compress an
333
+ * old assistant `tool_use` message while its later `tool` result message
334
+ * stays inside the recent-keep window, with nothing pairing the two. That is
335
+ * an ordinary, expected outcome of normal operation, not a corrupted
336
+ * transcript — so we degrade (drop the orphaned result) instead of throwing.
337
+ * pi-ai's ToolResultMessage.toolName is a required, non-empty-in-practice
338
+ * string; there is no sensible placeholder to send for an orphaned result,
339
+ * so omitting the whole message is the only safe option.
340
+ */
341
+ function mapToolResultMessage(blocks, toolNameById) {
342
+ const messages = [];
343
+ for (const block of blocks) {
344
+ const toolName = toolNameById.get(block.toolUseId);
345
+ if (toolName === undefined) {
346
+ continue;
347
+ }
348
+ // Map text and structured blocks 1:1 (structured degrades to a text
349
+ // block with its text projection — pi-ai's tool result content takes
350
+ // text/image only), preserving order so interleaved content stays
351
+ // meaningful to the model. An empty content
352
+ // array degrades to a single empty text block (same as before image
353
+ // passthrough), because a toolResult with no content at all is not a
354
+ // shape any provider path expects.
355
+ const content = [];
356
+ for (const b of block.content) {
357
+ if (b.type === "text") {
358
+ content.push({ type: "text", text: b.text });
359
+ }
360
+ else if (b.type === "structured") {
361
+ content.push({ type: "text", text: b.text });
362
+ }
363
+ else {
364
+ content.push(toPiImageContent(b));
365
+ }
366
+ }
367
+ if (content.length === 0) {
368
+ content.push({ type: "text", text: "" });
369
+ }
370
+ messages.push({
371
+ role: "toolResult",
372
+ toolCallId: block.toolUseId,
373
+ toolName,
374
+ content,
375
+ isError: block.isError ?? false,
376
+ timestamp: 0,
377
+ });
378
+ }
379
+ return messages;
380
+ }
381
+ /** Index every assistant `tool_use` block's id -> name, once per toPiContext call. */
382
+ function buildToolNameIndex(allMessages) {
383
+ const index = new Map();
384
+ for (const message of allMessages) {
385
+ if (message.role !== "assistant") {
386
+ continue;
387
+ }
388
+ for (const block of message.content) {
389
+ if (block.type === "tool_use") {
390
+ index.set(block.id, block.name);
391
+ }
392
+ }
393
+ }
394
+ return index;
395
+ }
396
+ // ──────────────────────────────────────────────
397
+ // tools
398
+ // ──────────────────────────────────────────────
399
+ function mapToolDefinition(tool) {
400
+ return {
401
+ name: tool.name,
402
+ description: tool.description,
403
+ // `Tool<TParameters extends TSchema>` — `TSchema` (from the `typebox`
404
+ // package) is declared as `export interface TSchema {}`: a structurally
405
+ // empty interface with no required members and no hidden Symbol brand.
406
+ // Any plain JSON-Schema-shaped object is therefore structurally
407
+ // assignable to it without a cast; TypeBox schemas are just JSON Schema
408
+ // objects with extra optional properties (see typebox's
409
+ // types/schema.d.mts). Verified by reading the installed
410
+ // typebox@1.3.7 package directly.
411
+ parameters: tool.inputSchema,
412
+ };
413
+ }
414
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/pi-ai/context.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,kBAAkB,EAAsB,MAAM,aAAa,CAAC;AAErE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,GAAiB,EAAE,KAAqB;IAClE,MAAM,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC;IACzB,MAAM,cAAc,GAAG,GAAG,CAAC,QAAQ;SAChC,MAAM,CAAC,CAAC,CAAC,EAA6C,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;QAC9E,qEAAqE;QACrE,wEAAwE;SACvE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/C,wEAAwE;IACxE,yEAAyE;IACzE,0BAA0B;IAC1B,IAAI,GAAG,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACrC,cAAc,CAAC,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEjD,oEAAoE;IACpE,sEAAsE;IACtE,gBAAgB;IAChB,MAAM,YAAY,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEtD,MAAM,QAAQ,GAAgB,EAAE,CAAC;IACjC,KAAK,MAAM,OAAO,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;QACnC,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,SAAS,CAAC,iCAAiC;QAC7C,CAAC;QACD,IAAI,OAAO,CAAC,IAAI,KAA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AAI,GAAG,EAAkB,CAAC;IACxC,KAAK,MAAM,OAAO,IAAI,WAAW,EAAE,CAAC;QAClC,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YACjC,SAAS;QACX,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBAC9B,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,iDAAiD;AACjD,QAAQ;AACR,iDAAiD;AAEjD,SAAS,iBAAiB,CAAC,IAAoB;IAC7C,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,sEAAsE;QACtE,wEAAwE;QACxE,uEAAuE;QACvE,gEAAgE;QAChE,wEAAwE;QACxE,wDAAwD;QACxD,yDAAyD;QACzD,kCAAkC;QAClC,UAAU,EAAE,IAAI,CAAC,WAAW;KAC7B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { createPiAiModelPort } from "./model-port.js";
2
+ export type { CreatePiAiModelPortOptions } from "./model-port.js";
3
+ export type { PiAiProviderConfig } from "./collection.js";
4
+ export type { ProviderProtocol, ConfiguredProtocol, ProviderAuth } from "./collection.js";
5
+ export { isProviderProtocol, resolveProviderProtocol } from "./collection.js";
6
+ export { listCatalogProviders } from "./catalog.js";
7
+ export type { CatalogModel, CatalogProvider } from "./catalog.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pi-ai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,YAAY,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAClE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { createPiAiModelPort } from "./model-port.js";
2
+ export { isProviderProtocol, resolveProviderProtocol } from "./collection.js";
3
+ export { listCatalogProviders } from "./catalog.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pi-ai/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAItD,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { Models } from "@earendil-works/pi-ai";
2
+ import type { ModelPort } from "@voltojs/core";
3
+ import { type PiAiProviderConfig, type ProviderAuth } from "./collection.js";
4
+ export interface RouteRequestOptions {
5
+ /** How the API key is sent; absent derives from the model protocol. */
6
+ auth?: ProviderAuth;
7
+ /** Non-secret headers from the provider route. */
8
+ headers?: Record<string, string>;
9
+ /** The route's raw key, used to build auth headers without exposing it. */
10
+ apiKey?: string;
11
+ }
12
+ export interface CreatePiAiModelPortOptions {
13
+ providers: PiAiProviderConfig[];
14
+ /**
15
+ * Which configured provider `req.model` is resolved against. Required when
16
+ * more than one provider is configured — cross-provider routing (picking
17
+ * the provider per-request) is out of scope for this phase; a future phase
18
+ * will let the config carry both providerId and modelId per request.
19
+ */
20
+ defaultProviderId?: string;
21
+ /** Used when a request omits `req.model`. */
22
+ defaultModel?: string;
23
+ }
24
+ /**
25
+ * Build a volto ModelPort backed by pi-ai. `req.model` is treated as a model
26
+ * code within the single configured route (`defaultProviderId`, or the sole
27
+ * provider when only one is configured). Fails synchronously at construction
28
+ * time if the route is ambiguous — see resolveProviderId.
29
+ */
30
+ export declare function createPiAiModelPort(opts: CreatePiAiModelPortOptions): ModelPort;
31
+ /**
32
+ * Same as {@link createPiAiModelPort}, but takes an already-built `Models`
33
+ * collection directly. Exported (not re-exported from index.ts) so tests can
34
+ * inject a `Models` collection carrying a faux/mocked provider without going
35
+ * through real network-backed provider construction — see model-port.test.ts.
36
+ */
37
+ export declare function createPiAiModelPortFromModels(models: Models, providerId: string, defaultModel?: string,
38
+ /**
39
+ * API key injected into every `streamSimple` call for this route (rule 2 —
40
+ * catalog providers carry no baked-in auth; the key travels per request).
41
+ * Undefined for custom providers, whose key is already baked into their
42
+ * `fixedApiKeyAuth` by `buildModels()`.
43
+ */
44
+ requestApiKey?: string, route?: RouteRequestOptions): ModelPort;
45
+ //# sourceMappingURL=model-port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-port.d.ts","sourceRoot":"","sources":["../../src/pi-ai/model-port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAc,SAAS,EAAmC,MAAM,eAAe,CAAC;AAC5F,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,WAAW,mBAAmB;IAClC,uEAAuE;IACvE,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,6CAA6C;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,0BAA0B,GAAG,SAAS,CAoB/E;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM;AACrB;;;;;GAKG;AACH,aAAa,CAAC,EAAE,MAAM,EACtB,KAAK,CAAC,EAAE,mBAAmB,GAC1B,SAAS,CA0HX"}