@cloc/provider-ai-sdk 0.1.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 (82) hide show
  1. package/LICENSE +21 -0
  2. package/dist/agent.d.ts +93 -0
  3. package/dist/agent.d.ts.map +1 -0
  4. package/dist/agent.js +359 -0
  5. package/dist/agent.js.map +1 -0
  6. package/dist/config.d.ts +85 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +101 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/gateway.d.ts +74 -0
  11. package/dist/gateway.d.ts.map +1 -0
  12. package/dist/gateway.js +96 -0
  13. package/dist/gateway.js.map +1 -0
  14. package/dist/index.d.ts +47 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +46 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/memory-tool.d.ts +63 -0
  19. package/dist/memory-tool.d.ts.map +1 -0
  20. package/dist/memory-tool.js +183 -0
  21. package/dist/memory-tool.js.map +1 -0
  22. package/dist/output.d.ts +49 -0
  23. package/dist/output.d.ts.map +1 -0
  24. package/dist/output.js +41 -0
  25. package/dist/output.js.map +1 -0
  26. package/dist/plugin.d.ts +74 -0
  27. package/dist/plugin.d.ts.map +1 -0
  28. package/dist/plugin.js +86 -0
  29. package/dist/plugin.js.map +1 -0
  30. package/dist/request.d.ts +82 -0
  31. package/dist/request.d.ts.map +1 -0
  32. package/dist/request.js +80 -0
  33. package/dist/request.js.map +1 -0
  34. package/dist/safety.d.ts +54 -0
  35. package/dist/safety.d.ts.map +1 -0
  36. package/dist/safety.js +0 -0
  37. package/dist/safety.js.map +1 -0
  38. package/dist/secrets.d.ts +51 -0
  39. package/dist/secrets.d.ts.map +1 -0
  40. package/dist/secrets.js +47 -0
  41. package/dist/secrets.js.map +1 -0
  42. package/dist/skills-loader.d.ts +76 -0
  43. package/dist/skills-loader.d.ts.map +1 -0
  44. package/dist/skills-loader.js +99 -0
  45. package/dist/skills-loader.js.map +1 -0
  46. package/dist/stream.d.ts +58 -0
  47. package/dist/stream.d.ts.map +1 -0
  48. package/dist/stream.js +59 -0
  49. package/dist/stream.js.map +1 -0
  50. package/dist/tokens.d.ts +17 -0
  51. package/dist/tokens.d.ts.map +1 -0
  52. package/dist/tokens.js +17 -0
  53. package/dist/tokens.js.map +1 -0
  54. package/dist/tool-loop.d.ts +98 -0
  55. package/dist/tool-loop.d.ts.map +1 -0
  56. package/dist/tool-loop.js +210 -0
  57. package/dist/tool-loop.js.map +1 -0
  58. package/dist/trace.d.ts +78 -0
  59. package/dist/trace.d.ts.map +1 -0
  60. package/dist/trace.js +39 -0
  61. package/dist/trace.js.map +1 -0
  62. package/dist/validate.d.ts +54 -0
  63. package/dist/validate.d.ts.map +1 -0
  64. package/dist/validate.js +81 -0
  65. package/dist/validate.js.map +1 -0
  66. package/package.json +55 -0
  67. package/src/agent.ts +487 -0
  68. package/src/config.ts +147 -0
  69. package/src/gateway.ts +126 -0
  70. package/src/index.ts +101 -0
  71. package/src/memory-tool.ts +219 -0
  72. package/src/output.ts +67 -0
  73. package/src/plugin.ts +123 -0
  74. package/src/request.ts +178 -0
  75. package/src/safety.ts +0 -0
  76. package/src/secrets.ts +71 -0
  77. package/src/skills-loader.ts +153 -0
  78. package/src/stream.ts +80 -0
  79. package/src/tokens.ts +82 -0
  80. package/src/tool-loop.ts +268 -0
  81. package/src/trace.ts +87 -0
  82. package/src/validate.ts +118 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cloc contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @cloc/provider-ai-sdk · agent.ts — `AiSdkAgent`, the default AgentProvider over AI SDK v6
3
+ * (FR-002, FR-003, FR-004, data-model §1, contracts/agent-provider.ts).
4
+ *
5
+ * Implements the vendor-free core contract `generate(p, o?) → Promise<Output>` and
6
+ * `stream(p, o?) → AsyncIterable<Delta>` by composing: gateway routing + failover (gateway.ts),
7
+ * the budgeted render-time tool loop (tool-loop.ts), the `Output.object` structured path
8
+ * (output.ts), the validate-or-repair boundary (validate.ts), partial-object streaming (stream.ts),
9
+ * the `agent.generate` trace subtree (trace.ts), and data-not-instructions safety (safety.ts).
10
+ *
11
+ * v2 (027-agentic-primitives §16b): `generate()`/`stream()` may run a BUDGETED AI SDK 6
12
+ * `ToolLoopAgent` loop (`call → execute-tools → feed-results → repeat`) that surfaces the three
13
+ * OPTIONAL, GATED primitives from `GenOpts` — Skills (progressive disclosure; only level-1 metadata
14
+ * enters the prompt), Memory (the Anthropic memory-tool interface, `unstorage`-backed), and Tools
15
+ * (the three sources, joined to the loop). The loop is bounded by `stopWhen` (the SAME trajectory
16
+ * budget as the `0` console agent, §9.1) and shaped per-step by `prepareStep`; EVERY tool/skill/
17
+ * memory access clears the §58 policy gate BEFORE execution, and a denial DEGRADES (FR-014/FR-021).
18
+ * When none of the primitives are set the render is the plain pre-027 path (FR-002, zero added cost).
19
+ *
20
+ * No AI SDK / AI Gateway type crosses the public signature — they live ONLY inside this package
21
+ * (FR-002, Principle 8). The model is a swappable FIELD (GenOpts.model), never the contract.
22
+ *
23
+ * AI SDK v6 surface (verified against the installed ai@6.0.195 .d.ts, not stale memory):
24
+ * - `generateText({ model, output: Output.object({ schema }), prompt|messages, tools, stopWhen,
25
+ * prepareStep, maxOutputTokens, seed, abortSignal })` → `result.output` (typed; the older
26
+ * `result.experimental_output` is now `@deprecated` — we read the stable name first and fall
27
+ * back to the experimental/`output`-less alias so a rename in EITHER direction can't crash us).
28
+ * - `streamText({ ...same... })` → `result.partialOutputStream` (the `experimental_*` alias is
29
+ * `@deprecated`), `result.output` (a Promise of the final typed object), `result.fullStream`.
30
+ * - `maxTokens` is `maxOutputTokens`; `maxSteps` is `stopWhen: stepCountIs(n)`; the other stop
31
+ * conditions are `hasToolCall(name)` / `isLoopFinished()`; `prepareStep({ stepNumber, steps,
32
+ * model, messages }) => { model?, activeTools?, toolChoice? }` does per-step engineering;
33
+ * `generateObject` is deprecated in favor of `output: Output.object(...)` (FR-013).
34
+ * - `result.usage` is a `LanguageModelUsage` (`{ inputTokens, outputTokens, totalTokens,
35
+ * inputTokenDetails.cacheReadTokens, ... }`); on the streaming result it is a `Promise`.
36
+ */
37
+ import type { AgentProvider, GenOpts, Prompt, Output, Delta } from "./tokens.js";
38
+ import type { PolicyGateHook } from "./tokens.js";
39
+ import type { AgentConfig } from "./config.js";
40
+ import { type SecretHandle } from "./secrets.js";
41
+ import { type SpanSink, type AgentGenerateContext } from "./trace.js";
42
+ /** Host hooks the kernel supplies at boot (least-privilege; never read from cloc.yml). */
43
+ export interface AgentDeps {
44
+ /** The parsed `agent:` config (config.ts). */
45
+ config: AgentConfig;
46
+ /** By-name handle to the gateway credential (secrets.ts) — resolved lazily, granted at boot. */
47
+ secret: SecretHandle;
48
+ /** Optional OTel span opener the host backs with its real tracer (trace.ts). */
49
+ startSpan?: (name: "agent.generate", context: AgentGenerateContext) => SpanSink;
50
+ /**
51
+ * The §58 policy-before-execution gate every render-time PRIMITIVE access (tool / skill / memory)
52
+ * clears BEFORE execution (027-agentic-primitives FR-014, FR-021; §58). Injected by the kernel
53
+ * from 016-policy-gate; when absent the adapter falls back to {@link ALLOW_ALL_GATE} so the seam
54
+ * is exercisable without 016 present (tests/conformance ONLY — a real deployment injects 016's
55
+ * gate). A denial DEGRADES the render (proceeds without that capability), never bypasses.
56
+ */
57
+ gate?: PolicyGateHook;
58
+ /**
59
+ * OPTIONAL override for how a repair re-prompt is framed from the base prompt + the validation
60
+ * issues. Defaults to {@link defaultRepairPrompt} (the prior, current behavior: the issues are
61
+ * appended as an inert `<validation-issues>` data block, FR-005). A host can swap a richer
62
+ * strategy (e.g. per-kit guidance) WITHOUT touching the adapter; the default preserves behavior.
63
+ */
64
+ frameRepairPrompt?: (args: {
65
+ basePrompt: string;
66
+ issues: unknown;
67
+ attempt: number;
68
+ }) => string;
69
+ }
70
+ /**
71
+ * The default repair re-prompt framer: append the validation issues as an inert, clearly-delimited
72
+ * DATA block (never as instructions the model could be steered by — FR-015) plus a terse directive
73
+ * to return a corrected object. Extracted so {@link AiSdkAgent.generate} and `stream` share ONE
74
+ * framing and a host can override it via {@link AgentDeps.frameRepairPrompt} (additive seam).
75
+ */
76
+ export declare function defaultRepairPrompt(args: {
77
+ basePrompt: string;
78
+ issues: unknown;
79
+ attempt: number;
80
+ }): string;
81
+ /**
82
+ * The reference Agent. EXACTLY ONE AgentProvider wins per environment, resolved by token (FR-010).
83
+ * Constructed once at boot from the kernel-supplied {@link AgentDeps}; the request path never
84
+ * re-decides the Agent (§75.3).
85
+ */
86
+ export declare class AiSdkAgent implements AgentProvider {
87
+ #private;
88
+ private readonly deps;
89
+ constructor(deps: AgentDeps);
90
+ generate(p: Prompt, o?: GenOpts): Promise<Output>;
91
+ stream(p: Prompt, o?: GenOpts): AsyncIterable<Delta>;
92
+ }
93
+ //#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,IAAI;gBAAJ,IAAI,EAAE,SAAS;IAkFtC,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IA+CvD,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC;CA0HrD"}
package/dist/agent.js ADDED
@@ -0,0 +1,359 @@
1
+ /**
2
+ * @cloc/provider-ai-sdk · agent.ts — `AiSdkAgent`, the default AgentProvider over AI SDK v6
3
+ * (FR-002, FR-003, FR-004, data-model §1, contracts/agent-provider.ts).
4
+ *
5
+ * Implements the vendor-free core contract `generate(p, o?) → Promise<Output>` and
6
+ * `stream(p, o?) → AsyncIterable<Delta>` by composing: gateway routing + failover (gateway.ts),
7
+ * the budgeted render-time tool loop (tool-loop.ts), the `Output.object` structured path
8
+ * (output.ts), the validate-or-repair boundary (validate.ts), partial-object streaming (stream.ts),
9
+ * the `agent.generate` trace subtree (trace.ts), and data-not-instructions safety (safety.ts).
10
+ *
11
+ * v2 (027-agentic-primitives §16b): `generate()`/`stream()` may run a BUDGETED AI SDK 6
12
+ * `ToolLoopAgent` loop (`call → execute-tools → feed-results → repeat`) that surfaces the three
13
+ * OPTIONAL, GATED primitives from `GenOpts` — Skills (progressive disclosure; only level-1 metadata
14
+ * enters the prompt), Memory (the Anthropic memory-tool interface, `unstorage`-backed), and Tools
15
+ * (the three sources, joined to the loop). The loop is bounded by `stopWhen` (the SAME trajectory
16
+ * budget as the `0` console agent, §9.1) and shaped per-step by `prepareStep`; EVERY tool/skill/
17
+ * memory access clears the §58 policy gate BEFORE execution, and a denial DEGRADES (FR-014/FR-021).
18
+ * When none of the primitives are set the render is the plain pre-027 path (FR-002, zero added cost).
19
+ *
20
+ * No AI SDK / AI Gateway type crosses the public signature — they live ONLY inside this package
21
+ * (FR-002, Principle 8). The model is a swappable FIELD (GenOpts.model), never the contract.
22
+ *
23
+ * AI SDK v6 surface (verified against the installed ai@6.0.195 .d.ts, not stale memory):
24
+ * - `generateText({ model, output: Output.object({ schema }), prompt|messages, tools, stopWhen,
25
+ * prepareStep, maxOutputTokens, seed, abortSignal })` → `result.output` (typed; the older
26
+ * `result.experimental_output` is now `@deprecated` — we read the stable name first and fall
27
+ * back to the experimental/`output`-less alias so a rename in EITHER direction can't crash us).
28
+ * - `streamText({ ...same... })` → `result.partialOutputStream` (the `experimental_*` alias is
29
+ * `@deprecated`), `result.output` (a Promise of the final typed object), `result.fullStream`.
30
+ * - `maxTokens` is `maxOutputTokens`; `maxSteps` is `stopWhen: stepCountIs(n)`; the other stop
31
+ * conditions are `hasToolCall(name)` / `isLoopFinished()`; `prepareStep({ stepNumber, steps,
32
+ * model, messages }) => { model?, activeTools?, toolChoice? }` does per-step engineering;
33
+ * `generateObject` is deprecated in favor of `output: Output.object(...)` (FR-013).
34
+ * - `result.usage` is a `LanguageModelUsage` (`{ inputTokens, outputTokens, totalTokens,
35
+ * inputTokenDetails.cacheReadTokens, ... }`); on the streaming result it is a `Promise`.
36
+ */
37
+ import { generateText, streamText } from "ai";
38
+ import { ALLOW_ALL_GATE } from "./tokens.js";
39
+ import { modelRefToString } from "@cloc/core";
40
+ import { resolveGateway, withFailover, AgentError } from "./gateway.js";
41
+ import { resolveGatewayKey } from "./secrets.js";
42
+ import { outputSpecFor, makeStructuredOutput } from "./output.js";
43
+ import { validateOrRepair } from "./validate.js";
44
+ import { buildToolSet, buildAgenticToolSet, toAiStopWhen, toAiPrepareStep, } from "./tool-loop.js";
45
+ import { buildMemoryTools } from "./memory-tool.js";
46
+ import { frameSkillsForPrompt } from "./skills-loader.js";
47
+ import { frameGroundingAsData, collectProvenance } from "./safety.js";
48
+ import { startAgentSpan, } from "./trace.js";
49
+ import { chunkToDelta, loopEventToChunk, partialChunk, toCoreOutput, } from "./stream.js";
50
+ import { toAgentTurn } from "./request.js";
51
+ /**
52
+ * The default repair re-prompt framer: append the validation issues as an inert, clearly-delimited
53
+ * DATA block (never as instructions the model could be steered by — FR-015) plus a terse directive
54
+ * to return a corrected object. Extracted so {@link AiSdkAgent.generate} and `stream` share ONE
55
+ * framing and a host can override it via {@link AgentDeps.frameRepairPrompt} (additive seam).
56
+ */
57
+ export function defaultRepairPrompt(args) {
58
+ const { basePrompt, issues, attempt } = args;
59
+ return (`${basePrompt}\n\n` +
60
+ `<validation-issues attempt="${attempt}">${JSON.stringify(issues)}</validation-issues>\n` +
61
+ `Return a corrected object that satisfies the schema.`);
62
+ }
63
+ /** The default kit version stamped on the Output meta when the runtime does not pin one. */
64
+ const UNKNOWN_KIT_VERSION = "unknown";
65
+ /**
66
+ * The reference Agent. EXACTLY ONE AgentProvider wins per environment, resolved by token (FR-010).
67
+ * Constructed once at boot from the kernel-supplied {@link AgentDeps}; the request path never
68
+ * re-decides the Agent (§75.3).
69
+ */
70
+ export class AiSdkAgent {
71
+ deps;
72
+ #gatewayKey;
73
+ #keyResolved = false;
74
+ constructor(deps) {
75
+ this.deps = deps;
76
+ }
77
+ /** The §58 gate every primitive access clears; defaults to ALLOW_ALL only when none is wired. */
78
+ get #gate() {
79
+ return this.deps.gate ?? ALLOW_ALL_GATE;
80
+ }
81
+ /** Resolve the gateway credential BY NAME, once, lazily (FR-009). */
82
+ async #gateway() {
83
+ if (!this.#keyResolved) {
84
+ this.#gatewayKey = await resolveGatewayKey(this.deps.secret);
85
+ this.#keyResolved = true;
86
+ }
87
+ return resolveGateway(this.deps.config, this.#gatewayKey);
88
+ }
89
+ #span(turn) {
90
+ const ctx = {
91
+ "cloc.data_version": String(turn.providerOptions?.["dataVersion"] ?? ""),
92
+ "cloc.kit_version": String(turn.providerOptions?.["kitVersion"] ?? UNKNOWN_KIT_VERSION),
93
+ "cloc.tier": turn.tier,
94
+ ...(turn.seed !== undefined ? { "cloc.seed": String(turn.seed) } : {}),
95
+ };
96
+ return startAgentSpan(ctx, this.deps.startSpan);
97
+ }
98
+ /**
99
+ * The shared `generateText`/`streamText` option base for a turn (vendor types stay internal).
100
+ *
101
+ * Assembles the budgeted render-time tool loop (027-agentic-primitives §16b.3): the loop's tool
102
+ * set is the union of (1) the legacy per-turn `tools`, (2) the 027 agentic `GenOpts.tools` from
103
+ * all three sources (`plugin`/`capability`/`wired`, FR-012), and (3) the memory-tool interface
104
+ * when memory is enabled (§16b.2) — each GATED by the §58 gate before execution (FR-014). The
105
+ * budget is `stopWhen` mapped from the core trajectory budget (default `stepCountIs(N)`, §9.1,
106
+ * FR-013); `prepareStep` does per-step context engineering (model swap / activeTools / toolChoice,
107
+ * FR-011). Skill metadata (level-1 only) is prepended to the prompt; the body/bundled load lazily.
108
+ * When NONE of the primitives are set the loop is the plain pre-027 path (FR-002, zero added cost).
109
+ */
110
+ #callOptions(turn, onEvent, gw) {
111
+ const gate = this.#gate;
112
+ // (1) legacy per-turn tools (gate-checked) + (2) agentic GenOpts.tools (3 sources) + (3) memory.
113
+ const tools = {
114
+ ...buildToolSet(turn.tools, onEvent, gate),
115
+ ...buildAgenticToolSet(turn.agenticTools, onEvent, gate),
116
+ ...buildMemoryTools(turn.memory, gate, onEvent),
117
+ };
118
+ const prepareStep = toAiPrepareStep(turn.prepareStep, (d) => this.#resolveStepModel(d, gw));
119
+ return {
120
+ output: outputSpecFor(turn.outputSchema),
121
+ tools,
122
+ // The trajectory budget bounds the loop so it can never thrash unbounded (§9.1, FR-013).
123
+ stopWhen: toAiStopWhen(turn.stopWhen),
124
+ ...(prepareStep !== undefined ? { prepareStep } : {}),
125
+ prompt: this.#composePrompt(turn),
126
+ ...(turn.maxTokens !== undefined ? { maxOutputTokens: turn.maxTokens } : {}),
127
+ ...(turn.seed !== undefined ? { seed: turn.seed } : {}),
128
+ ...(turn.signal !== undefined ? { abortSignal: turn.signal } : {}),
129
+ ...(turn.providerOptions !== undefined ? { providerOptions: turn.providerOptions } : {}),
130
+ };
131
+ }
132
+ /** Resolve a `prepareStep` per-step model swap (a core `ModelRef`) to the routed v6 model. */
133
+ #resolveStepModel(directive, gw) {
134
+ if (directive.model === undefined)
135
+ return undefined;
136
+ const id = modelRefToString(directive.model);
137
+ return id ? gw.model(id) : undefined;
138
+ }
139
+ /**
140
+ * Frame the intent + grounded facts + level-1 skill metadata as a prompt where grounding is inert
141
+ * DATA (FR-015) and skills disclose only `name`+`description` (§16b.1 — the body is NOT in the
142
+ * prompt until activation; FR-005). When no skills/grounding are present this is just the intent.
143
+ */
144
+ #composePrompt(turn) {
145
+ const intent = typeof turn.intent === "string" ? turn.intent : JSON.stringify(turn.intent);
146
+ const data = frameGroundingAsData(turn.grounding);
147
+ const skills = turn.skills ? frameSkillsForPrompt(turn.skills) : "";
148
+ return [intent, skills, data].filter((s) => s.length > 0).join("\n\n");
149
+ }
150
+ // --- AgentProvider.generate ----------------------------------------------
151
+ async generate(p, o) {
152
+ const turn = toAgentTurn(p, o, false);
153
+ const span = this.#span(turn);
154
+ const events = [];
155
+ const onEvent = (e) => {
156
+ events.push(e);
157
+ span.addEvent(e.kind === "tool-call" ? { name: "tool.call", tool: e.tool } : { name: "tool.result", tool: e.tool });
158
+ };
159
+ try {
160
+ const gw = await this.#gateway();
161
+ const base = this.#callOptions(turn, onEvent, gw);
162
+ // Route hosted-first with per-request failover (FR-006/8). Each attempt runs the tool loop
163
+ // and the Output.object path; the first provider that yields a parseable object wins. An
164
+ // abort short-circuits the chain (it is a cancel, not a provider failure; conformance C1).
165
+ const { value: raw, modelId, hop } = await withFailover(gw, async (model) => generateText({ model, ...base }), undefined, turn.signal !== undefined ? { signal: turn.signal } : undefined);
166
+ // Validate-or-repair against the kit schema; re-prompt the SAME provider on repair (FR-005).
167
+ const plan = await validateOrRepair({
168
+ schema: turn.outputSchema,
169
+ initial: readOutput(raw),
170
+ policy: this.deps.config.repair,
171
+ events: {
172
+ onValidate: (ok) => span.addEvent({ name: "validate", ok }),
173
+ onRepair: (attempt, ok) => span.addEvent({ name: "repair", attempt, ok }),
174
+ },
175
+ repair: (issues, attempt) => this.#repair(base, gw, modelId, issues, attempt),
176
+ });
177
+ const structured = this.#finish(turn, plan, span, { modelId, hop, usage: readUsage(raw) });
178
+ return toCoreOutput(structured, turn.outputSchema);
179
+ }
180
+ catch (err) {
181
+ this.#fail(span, err);
182
+ throw err;
183
+ }
184
+ finally {
185
+ span.end();
186
+ }
187
+ }
188
+ // --- AgentProvider.stream ------------------------------------------------
189
+ stream(p, o) {
190
+ const turn = toAgentTurn(p, o, true);
191
+ const self = this;
192
+ return {
193
+ async *[Symbol.asyncIterator]() {
194
+ const span = self.#span(turn);
195
+ const queue = [];
196
+ const onEvent = (e) => {
197
+ queue.push(loopEventToChunk(e));
198
+ span.addEvent(e.kind === "tool-call" ? { name: "tool.call", tool: e.tool } : { name: "tool.result", tool: e.tool });
199
+ };
200
+ try {
201
+ const gw = await self.#gateway();
202
+ const base = self.#callOptions(turn, onEvent, gw);
203
+ // Failover for the streaming path: bind the first provider that starts a stream. An
204
+ // abort short-circuits the chain (cancel, not a provider failure; conformance C1).
205
+ const { value: result, modelId, hop } = await withFailover(gw, async (model) => streamText({ model, ...base }), undefined, turn.signal !== undefined ? { signal: turn.signal } : undefined);
206
+ // Drain any tool events captured before the first partial, then stream partial objects.
207
+ for (const c of queue.splice(0))
208
+ yield* emit(c);
209
+ for await (const snap of partialOutputStream(result)) {
210
+ for (const c of queue.splice(0))
211
+ yield* emit(c);
212
+ yield* emit(partialChunk(snap));
213
+ }
214
+ for (const c of queue.splice(0))
215
+ yield* emit(c);
216
+ // Terminal: validate-or-repair the completed object, then emit the single `final`.
217
+ const finalObject = await readFinalOutput(result);
218
+ const plan = await validateOrRepair({
219
+ schema: turn.outputSchema,
220
+ initial: finalObject,
221
+ policy: self.deps.config.repair,
222
+ events: {
223
+ onValidate: (ok) => span.addEvent({ name: "validate", ok }),
224
+ onRepair: (attempt, ok) => span.addEvent({ name: "repair", attempt, ok }),
225
+ },
226
+ // Streaming repair re-runs non-streamed against the same provider (bounded).
227
+ repair: (issues, attempt) => self.#repair(base, gw, modelId, issues, attempt),
228
+ });
229
+ const structured = self.#finish(turn, plan, span, { modelId, hop, usage: await readStreamUsage(result) });
230
+ const delta = chunkToDelta({ kind: "final", output: structured }, turn.outputSchema);
231
+ if (delta)
232
+ yield delta;
233
+ }
234
+ catch (err) {
235
+ // Invalidate any streamed partial: surface the error by REJECTING — never a fake `final`
236
+ // the runtime could mistake for completion (edge case, core Delta contract).
237
+ self.#fail(span, err);
238
+ throw err;
239
+ }
240
+ finally {
241
+ span.end();
242
+ }
243
+ function* emit(chunk) {
244
+ const d = chunkToDelta(chunk, turn.outputSchema);
245
+ if (d)
246
+ yield d;
247
+ }
248
+ },
249
+ };
250
+ }
251
+ // --- shared repair / finish / fail ---------------------------------------
252
+ /**
253
+ * The shared validate-or-repair repair channel: re-prompt the SAME provider (`modelId`) with the
254
+ * validation issues framed as an inert data block, NON-streamed, honoring the turn's abort signal.
255
+ * Used by BOTH `generate()` and `stream()` so the two paths repair identically (DRY; FR-005). The
256
+ * framing is overridable via {@link AgentDeps.frameRepairPrompt}; the default reproduces the prior
257
+ * inline behavior exactly.
258
+ */
259
+ async #repair(base, gw, modelId, issues, attempt) {
260
+ const frame = this.deps.frameRepairPrompt ?? defaultRepairPrompt;
261
+ const repaired = await generateText({
262
+ model: gw.model(modelId),
263
+ ...base,
264
+ prompt: frame({ basePrompt: base.prompt, issues, attempt }),
265
+ });
266
+ return readOutput(repaired);
267
+ }
268
+ #finish(turn, plan, span, routed) {
269
+ const [provider, ...rest] = routed.modelId.split("/");
270
+ const usage = routed.usage;
271
+ span.setAttributes({
272
+ "gateway.provider": provider ?? routed.modelId,
273
+ "gateway.model": rest.join("/") || routed.modelId,
274
+ "gateway.fallback": routed.hop,
275
+ "cost.usd": usage?.costUsd ?? 0,
276
+ ...(usage?.inputTokens !== undefined ? { "prompt.tokens": usage.inputTokens } : {}),
277
+ ...(usage?.outputTokens !== undefined ? { "output.tokens": usage.outputTokens } : {}),
278
+ ...(usage?.totalTokens !== undefined ? { "total.tokens": usage.totalTokens } : {}),
279
+ ...(usage?.cachedInputTokens !== undefined ? { "cache.read.tokens": usage.cachedInputTokens } : {}),
280
+ });
281
+ return makeStructuredOutput({
282
+ plan,
283
+ provenance: collectProvenance(turn.grounding),
284
+ kitVersion: String(turn.providerOptions?.["kitVersion"] ?? UNKNOWN_KIT_VERSION),
285
+ ...(turn.seed !== undefined ? { seed: String(turn.seed) } : {}),
286
+ });
287
+ }
288
+ #fail(span, err) {
289
+ const code = err instanceof AgentError ? err.code : "tool-failed";
290
+ const message = err instanceof Error ? err.message : String(err);
291
+ span.recordError(code, message);
292
+ }
293
+ }
294
+ /**
295
+ * Read the typed object from a non-streaming v6 result. v6 exposes the stable `result.output`; the
296
+ * older `result.experimental_output` is `@deprecated`. We read the STABLE name first and fall back
297
+ * to the deprecated alias (and `undefined`-safe) so a rename in either direction can't crash us.
298
+ */
299
+ function readOutput(result) {
300
+ const r = result;
301
+ return r.output ?? r.experimental_output;
302
+ }
303
+ /** Map a vendor `LanguageModelUsage` + provider metadata to the adapter's {@link ReadUsage}. */
304
+ function mapUsage(usage, cost) {
305
+ if (!usage && cost === undefined)
306
+ return undefined;
307
+ return {
308
+ ...(usage?.inputTokens !== undefined ? { inputTokens: usage.inputTokens } : {}),
309
+ ...(usage?.outputTokens !== undefined ? { outputTokens: usage.outputTokens } : {}),
310
+ ...(usage?.totalTokens !== undefined ? { totalTokens: usage.totalTokens } : {}),
311
+ ...(usage?.inputTokenDetails?.cacheReadTokens !== undefined
312
+ ? { cachedInputTokens: usage.inputTokenDetails.cacheReadTokens }
313
+ : {}),
314
+ ...(cost !== undefined ? { costUsd: cost } : {}),
315
+ };
316
+ }
317
+ /** Read token/cost usage from a non-streaming v6 result, when present (TODO(C3): mandated-metric set). */
318
+ function readUsage(result) {
319
+ const r = result;
320
+ return mapUsage(r.usage, r.providerMetadata?.gateway?.cost);
321
+ }
322
+ /**
323
+ * The v6 partial-object stream: the stable `result.partialOutputStream` (the `experimental_*` alias
324
+ * is `@deprecated`). Each snapshot is a partial of the kit plan — i.e. an object — so we read it as a
325
+ * partial record (assignable to `Partial<unknown>` for {@link partialChunk}; a bare `unknown` is not).
326
+ * We prefer the stable name and fall back to the deprecated alias, then an empty stream.
327
+ */
328
+ function partialOutputStream(result) {
329
+ const r = result;
330
+ return r.partialOutputStream ?? r.experimental_partialOutputStream ?? EMPTY_PARTIAL_STREAM();
331
+ }
332
+ /** A reusable empty async-iterable for the "no partial stream present" fallback (allocation-light). */
333
+ async function* EMPTY_PARTIAL_STREAM() {
334
+ /* yields nothing */
335
+ }
336
+ /**
337
+ * Await the final typed object of a v6 stream result. v6 exposes the stable `result.output` (a
338
+ * `Promise`); the older `result.experimental_output` is `@deprecated`. We prefer the stable name,
339
+ * fall back to the deprecated alias, and await whichever is a thenable.
340
+ */
341
+ async function readFinalOutput(result) {
342
+ const r = result;
343
+ const value = r.output ?? r.experimental_output;
344
+ return isThenable(value) ? await value : value;
345
+ }
346
+ /** Await stream usage (v6 `result.usage` is a Promise on the streaming result). */
347
+ async function readStreamUsage(result) {
348
+ const r = result;
349
+ const usage = isThenable(r.usage) ? await r.usage : r.usage;
350
+ const meta = isThenable(r.providerMetadata) ? await r.providerMetadata : r.providerMetadata;
351
+ return mapUsage(usage, meta?.gateway?.cost);
352
+ }
353
+ /** True for a thenable (a Promise or Promise-like), narrowing for `await`. */
354
+ function isThenable(value) {
355
+ return (typeof value === "object" &&
356
+ value !== null &&
357
+ typeof value.then === "function");
358
+ }
359
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAI9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE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/provider-ai-sdk · config.ts — the declarative `cloc.yml` `agent:` slice (data-model §5).
3
+ *
4
+ * Selection + tuning is data, never code (Constitution Principle 1; Appendix L.1 — `cloc.yml`
5
+ * is declarative/non-executable, never `cloc.config.ts`). The model is a FIELD (a gateway
6
+ * `provider/model` string), changeable with NO adapter-code edit (FR-007, FR-014). The gateway
7
+ * credential is referenced BY NAME (`secretRef`) — a secret VALUE in `cloc.yml` is rejected
8
+ * (FR-009, NFR-005, Principle 9).
9
+ *
10
+ * TODO(C2 — spec Clarification 2): the bounded-repair `maxAttempts` default below is provisional;
11
+ * the design doc names "validate / repair" without a limit. Routed to Governance (research.md C2).
12
+ * TODO(C1 — spec Clarification 1): whether a built-in default provider/model ships (so the block
13
+ * is optional) vs. BYO before the first synthesis request. Routed to Governance (research.md C1).
14
+ */
15
+ import { z } from "zod";
16
+ /** A gateway `provider/model` selection. Mirrors `cloc.yml` `model: { vendor, name }`. */
17
+ export interface ModelField {
18
+ /** Gateway provider string, e.g. "anthropic" (a FIELD of the Agent, FR-014). */
19
+ vendor: string;
20
+ /** Gateway model string, e.g. "claude-sonnet-4-5". */
21
+ name: string;
22
+ }
23
+ /** Per-request routing + ordered failover policy (FR-008, data-model §5). */
24
+ export interface GatewayRouting {
25
+ /** Ordered failover alternates; tried in order after the primary errors. */
26
+ fallbacks: ModelField[];
27
+ }
28
+ /** Bounded validate/repair policy (NFR-001, data-model §5). */
29
+ export interface RepairPolicy {
30
+ /** Max repair attempts before the request is rejected. TODO(C2): default is provisional. */
31
+ maxAttempts: number;
32
+ /** MUST reject on exhaustion — invalid output is NEVER passed through (FR-005). */
33
+ onExhaustion: "reject";
34
+ }
35
+ /** The parsed, validated `agent:` block (data-model §5). */
36
+ export interface AgentConfig {
37
+ /** The AgentProvider token's plugin id; the default is this package. */
38
+ provider: string;
39
+ /** The model FIELD — provider/model selection (FR-014). */
40
+ model: ModelField;
41
+ /** Optional routing + failover (FR-008). */
42
+ routing?: GatewayRouting;
43
+ /** NAME of the gateway credential — resolved by the secrets provider (FR-009). */
44
+ secretRef: string;
45
+ /** Bounded validate/repair (NFR-001). Defaulted when absent. */
46
+ repair: RepairPolicy;
47
+ }
48
+ /** Provisional default repair bound. TODO(C2): routed to Governance (research.md C2). */
49
+ export declare const DEFAULT_REPAIR_POLICY: RepairPolicy;
50
+ /** This plugin's id; also the default `provider` value when the block omits it. */
51
+ export declare const PROVIDER_ID = "provider-ai-sdk";
52
+ /** The raw `agent:` block schema as it appears in `cloc.yml`. */
53
+ export declare const AgentConfigSchema: z.ZodObject<{
54
+ provider: z.ZodDefault<z.ZodString>;
55
+ model: z.ZodObject<{
56
+ vendor: z.ZodString;
57
+ name: z.ZodString;
58
+ }, z.core.$strip>;
59
+ routing: z.ZodOptional<z.ZodObject<{
60
+ fallbacks: z.ZodDefault<z.ZodArray<z.ZodObject<{
61
+ vendor: z.ZodString;
62
+ name: z.ZodString;
63
+ }, z.core.$strip>>>;
64
+ }, z.core.$strip>>;
65
+ secretRef: z.ZodString;
66
+ repair: z.ZodOptional<z.ZodObject<{
67
+ maxAttempts: z.ZodNumber;
68
+ onExhaustion: z.ZodLiteral<"reject">;
69
+ }, z.core.$strip>>;
70
+ }, z.core.$strip>;
71
+ export type RawAgentConfig = z.input<typeof AgentConfigSchema>;
72
+ /**
73
+ * Parse + validate a raw `cloc.yml` `agent:` block into a normalized {@link AgentConfig}.
74
+ * Throws (Zod) on an invalid block — including a `secretRef` that holds a value, not a name.
75
+ */
76
+ export declare function parseAgentConfig(raw: unknown): AgentConfig;
77
+ /** Render one {@link ModelField} as the gateway `provider/model` string the SDK routes on. */
78
+ export declare function modelFieldToString(field: ModelField): string;
79
+ /**
80
+ * The ordered list of `provider/model` strings to try: primary first, then failovers, with
81
+ * consecutive/duplicate entries collapsed so the same provider is never retried twice in a row
82
+ * (a fallback identical to the primary would only waste a hop). Order is otherwise preserved.
83
+ */
84
+ export declare function modelChain(config: AgentConfig): string[];
85
+ //# sourceMappingURL=config.d.ts.map
@@ -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