fascicle 0.9.11 → 0.10.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/dist/agents.d.ts +1 -1
- package/dist/{index-BwkQPMfX.d.ts → index-D20uBog5.d.ts} +25 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +48 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.10.0 — 2026-08-05
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **`provider_reported` now carries what an `ai_sdk` provider reports, for every provider on that transport.** The AI SDK returns provider-volunteered detail on `providerMetadata` (Bedrock's guardrail trace, Anthropic's cache breakdown, OpenAI's service tier), already keyed by provider name. The transport read `text`, `toolCalls`, `finishReason`, and `usage` off the result and dropped the rest, so `GenerateResult.provider_reported` was structurally unreachable for every ai_sdk provider: only `claude_cli` ever populated it. The neutral `TurnResult` gains an optional `provider_reported`, the transport fills it from `providerMetadata` on both the `generateText` result and the streamed step-finish (so a streamed run and a plain run of the same call still report identically), the loop copies it onto `steps[i].provider_reported`, and `generate` folds the last reporting step into the call-level field. Keys and payloads ride through untranslated, so `provider_reported.bedrock.trace` needs no translation layer and a custom `ai_sdk` provider is served without per-provider code; a `native` adapter fills the same field from its own `invoke_turn`. Finish-reason mapping is untouched: a guardrail intervention still surfaces as `content_filter`, now with the trace beside it. This closes a real blind spot for Bedrock guardrails configured with a PII action of `NONE`, which detect and report without rewriting: the model output is byte-identical whether such a guardrail is attached and detecting or absent entirely, so the trace was the only in-process evidence it ran. `bedrock_guardrail_wire.test.ts` pins the round trip against the real peer over a stubbed fetch, and `provider_reported.test.ts` pins pass-through, stream parity, and the multi-step semantics.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **`docs/cli.md` named a `provider_reported` path that does not exist.** The multi-turn recipe said to capture `result.provider_reported.session_id`, but the adapter reports under a provider-name key, so the value has always been at `result.provider_reported.claude_cli.session_id`. Following the documented path yielded `undefined` and a fresh session on every call.
|
|
12
|
+
|
|
13
|
+
### Internal
|
|
14
|
+
|
|
15
|
+
- **The Bedrock guardrail docs show how to read the trace the change above made readable.** `docs/providers.md` gains a worked read of `provider_reported.bedrock.trace` beside the existing guardrail recipe, `docs/troubleshooting.md` gains an entry for the symptom that actually gets reported ("the guardrail seems ignored, the output came back unchanged"), and the adapter docstring carries the same claim at the source. The entry separates policy from wiring: a PII action of `NONE` detects without rewriting, so unchanged output is the configured behaviour rather than a dropped `guardrailConfig`, and the way to test the wiring instead is a deliberately invalid `guardrailIdentifier`: AWS rejects the call only if the config reached the Converse command, so a call that succeeds is the failure signal.
|
|
16
|
+
|
|
3
17
|
## v0.9.11 — 2026-08-05
|
|
4
18
|
|
|
5
19
|
### Added
|
package/dist/agents.d.ts
CHANGED
|
@@ -189,6 +189,12 @@ type StepRecord = {
|
|
|
189
189
|
usage: UsageTotals;
|
|
190
190
|
cost?: CostBreakdown;
|
|
191
191
|
finish_reason: FinishReason;
|
|
192
|
+
/**
|
|
193
|
+
* This turn's provider-reported detail, keyed by provider name. See
|
|
194
|
+
* TurnResult.provider_reported; a multi-step call keeps every turn's payload
|
|
195
|
+
* here, since the call-level field can only carry one.
|
|
196
|
+
*/
|
|
197
|
+
provider_reported?: Record<string, unknown>;
|
|
192
198
|
};
|
|
193
199
|
type UserContentPart = {
|
|
194
200
|
type: 'text';
|
|
@@ -307,6 +313,18 @@ type TurnResult = {
|
|
|
307
313
|
}>;
|
|
308
314
|
readonly finish_reason: FinishReason;
|
|
309
315
|
readonly usage: UsageTotals;
|
|
316
|
+
/**
|
|
317
|
+
* Opaque detail the provider reported about this turn, keyed by provider
|
|
318
|
+
* name: Bedrock's guardrail trace, Anthropic's cache breakdown, whatever a
|
|
319
|
+
* given provider volunteers beyond text/usage/finish_reason. The keys are the
|
|
320
|
+
* provider's own, so a caller narrows `provider_reported['bedrock']` at its
|
|
321
|
+
* use site rather than the engine modelling every payload.
|
|
322
|
+
*
|
|
323
|
+
* Absent when the provider reported nothing, never an empty object. The loop
|
|
324
|
+
* copies it onto the step record and generate folds it into
|
|
325
|
+
* GenerateResult.provider_reported.
|
|
326
|
+
*/
|
|
327
|
+
readonly provider_reported?: Record<string, unknown>;
|
|
310
328
|
};
|
|
311
329
|
/**
|
|
312
330
|
* One turn's resolved request handed to a native adapter's invoke_turn.
|
|
@@ -420,6 +438,12 @@ type GenerateResult<t = string> = {
|
|
|
420
438
|
provider: string;
|
|
421
439
|
model_id: string;
|
|
422
440
|
};
|
|
441
|
+
/**
|
|
442
|
+
* Provider-keyed detail for the call, taken from the last step that reported
|
|
443
|
+
* any: provider payloads are opaque, so they cannot be summed the way usage
|
|
444
|
+
* and cost are. Mirrors `content` and `finish_reason` in reflecting the final
|
|
445
|
+
* turn; `steps[i].provider_reported` holds every turn's own payload.
|
|
446
|
+
*/
|
|
423
447
|
provider_reported?: Record<string, unknown>;
|
|
424
448
|
};
|
|
425
449
|
type ProviderInit = {
|
|
@@ -684,4 +708,4 @@ declare class provider_auth_error extends Error {
|
|
|
684
708
|
}
|
|
685
709
|
//#endregion
|
|
686
710
|
export { ProviderFactory as $, PricingTable as A, ToolApprovalRequest as B, GenerateOptions as C, PrepareStepHook as D, PrepareStepContext as E, RetryPolicy as F, UsageTotals as G, ToolExecContext as H, StepRecord as I, EffortTranslation as J, UserContentPart as K, StreamChunk as L, ProviderInit as M, ResolvedModel as N, PrepareStepResult as O, RetryFailureKind as P, ProviderCapability as Q, Tool as R, FinishReason as S, Message as T, TurnRequest as U, ToolCallRecord as V, TurnResult as W, NativeProviderAdapter as X, ExternalAgentAdapter as Y, ProviderAdapter as Z, CostBreakdown as _, on_chunk_error as a, EngineConfig as b, provider_error as c, schema_validation_error as d, ProviderTransport as et, tool_approval_denied_error as f, AssistantContentPart as g, AiSdkTelemetrySettings as h, model_required_error as i, ProviderConfigMap as j, Pricing as k, provider_not_configured_error as l, create_engine as m, engine_config_error as n, default_normalize_usage as nt, provider_auth_error as o, tool_error as p, AiSdkProviderAdapter as q, engine_disposed_error as r, provider_capability_error as s, claude_cli_error as t, RawProviderUsage as tt, rate_limit_error as u, EffortLevel as v, GenerateResult as w, EngineDefaults as x, Engine as y, ToolApprovalHandler as z };
|
|
687
|
-
//# sourceMappingURL=index-
|
|
711
|
+
//# sourceMappingURL=index-D20uBog5.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as fallback, B as describe, C as checkpoint, D as LoopResult, E as LoopGuardResult, F as parallel, G as Step, H as run, I as sequence, J as TrajectoryLogger, K as StepMetadata, L as DescribeOptions, M as pipe, N as map, O as loop, P as branch, R as FlowNode, S as suspend, T as LoopConfig, U as CheckpointStore, V as step, W as RunContext, Y as __json_default_export, _ as suspended_error, a as SpanStartEvent, b as stash, c as span_end_event_schema, d as STEP_KINDS, f as StepKind, g as resume_validation_error, h as describe_cycle_error, i as SpanEndEvent, j as retry, k as timeout, l as span_start_event_schema, m as aborted_error, n as EmitEvent, o as custom_event_schema, p as is_step_kind, q as TrajectoryEvent, r as ParsedTrajectoryEvent, s as emit_event_schema, t as CustomTrajectoryEvent, u as trajectory_event_schema, v as timeout_error, w as compose, x as use, y as scope, z as FlowValue } from "./index-SkPG_Rew.js";
|
|
2
|
-
import { $ as ProviderFactory, A as PricingTable, B as ToolApprovalRequest, C as GenerateOptions, D as PrepareStepHook, E as PrepareStepContext, F as RetryPolicy, G as UsageTotals, H as ToolExecContext, I as StepRecord, J as EffortTranslation, K as UserContentPart, L as StreamChunk, M as ProviderInit, N as ResolvedModel, O as PrepareStepResult, P as RetryFailureKind, Q as ProviderCapability, R as Tool, S as FinishReason, T as Message, U as TurnRequest, V as ToolCallRecord, W as TurnResult, X as NativeProviderAdapter, Y as ExternalAgentAdapter, Z as ProviderAdapter, _ as CostBreakdown, a as on_chunk_error, b as EngineConfig, c as provider_error, d as schema_validation_error, et as ProviderTransport, f as tool_approval_denied_error, g as AssistantContentPart, h as AiSdkTelemetrySettings, i as model_required_error, j as ProviderConfigMap, k as Pricing, l as provider_not_configured_error, m as create_engine, n as engine_config_error, nt as default_normalize_usage, o as provider_auth_error, p as tool_error, q as AiSdkProviderAdapter, r as engine_disposed_error, s as provider_capability_error, t as claude_cli_error, tt as RawProviderUsage, u as rate_limit_error, v as EffortLevel, w as GenerateResult, x as EngineDefaults, y as Engine, z as ToolApprovalHandler } from "./index-
|
|
2
|
+
import { $ as ProviderFactory, A as PricingTable, B as ToolApprovalRequest, C as GenerateOptions, D as PrepareStepHook, E as PrepareStepContext, F as RetryPolicy, G as UsageTotals, H as ToolExecContext, I as StepRecord, J as EffortTranslation, K as UserContentPart, L as StreamChunk, M as ProviderInit, N as ResolvedModel, O as PrepareStepResult, P as RetryFailureKind, Q as ProviderCapability, R as Tool, S as FinishReason, T as Message, U as TurnRequest, V as ToolCallRecord, W as TurnResult, X as NativeProviderAdapter, Y as ExternalAgentAdapter, Z as ProviderAdapter, _ as CostBreakdown, a as on_chunk_error, b as EngineConfig, c as provider_error, d as schema_validation_error, et as ProviderTransport, f as tool_approval_denied_error, g as AssistantContentPart, h as AiSdkTelemetrySettings, i as model_required_error, j as ProviderConfigMap, k as Pricing, l as provider_not_configured_error, m as create_engine, n as engine_config_error, nt as default_normalize_usage, o as provider_auth_error, p as tool_error, q as AiSdkProviderAdapter, r as engine_disposed_error, s as provider_capability_error, t as claude_cli_error, tt as RawProviderUsage, u as rate_limit_error, v as EffortLevel, w as GenerateResult, x as EngineDefaults, y as Engine, z as ToolApprovalHandler } from "./index-D20uBog5.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/composites/adversarial.d.ts
|
package/dist/index.js
CHANGED
|
@@ -6787,6 +6787,7 @@ async function run_tool_loop(config) {
|
|
|
6787
6787
|
};
|
|
6788
6788
|
const breakdown = compute_and_record_cost(config, step_index, turn.usage);
|
|
6789
6789
|
if (breakdown !== void 0) record_step.cost = breakdown;
|
|
6790
|
+
if (turn.provider_reported !== void 0) record_step.provider_reported = turn.provider_reported;
|
|
6790
6791
|
steps.push(record_step);
|
|
6791
6792
|
if (config.on_finish_step !== void 0) config.on_finish_step(record_step);
|
|
6792
6793
|
end_step_span(config.trajectory, step_span, {
|
|
@@ -7042,6 +7043,7 @@ async function run_tool_loop(config) {
|
|
|
7042
7043
|
};
|
|
7043
7044
|
const breakdown = compute_and_record_cost(config, step_index, turn.usage);
|
|
7044
7045
|
if (breakdown !== void 0) step_record.cost = breakdown;
|
|
7046
|
+
if (turn.provider_reported !== void 0) step_record.provider_reported = turn.provider_reported;
|
|
7045
7047
|
steps.push(step_record);
|
|
7046
7048
|
if (config.on_finish_step !== void 0) config.on_finish_step(step_record);
|
|
7047
7049
|
end_step_span(config.trajectory, step_span, {
|
|
@@ -7154,6 +7156,26 @@ function to_raw_provider_usage(usage) {
|
|
|
7154
7156
|
return raw;
|
|
7155
7157
|
}
|
|
7156
7158
|
/**
|
|
7159
|
+
* Normalize an AI SDK `providerMetadata` value into the neutral
|
|
7160
|
+
* TurnResult.provider_reported shape.
|
|
7161
|
+
*
|
|
7162
|
+
* The SDK's metadata is already keyed by provider name, which is the shape
|
|
7163
|
+
* provider_reported documents, so the keys ride through untranslated and every
|
|
7164
|
+
* ai_sdk provider is served by this one seam: bedrock's guardrail `trace`,
|
|
7165
|
+
* anthropic's cache detail, openai's own fields. The payloads stay opaque
|
|
7166
|
+
* (callers narrow them at the use site), so this copies the top level and
|
|
7167
|
+
* inspects nothing below it. An absent or empty map returns undefined, keeping
|
|
7168
|
+
* "the provider reported nothing" spelled one way.
|
|
7169
|
+
*/
|
|
7170
|
+
function to_provider_reported(metadata) {
|
|
7171
|
+
if (metadata === null || typeof metadata !== "object") return void 0;
|
|
7172
|
+
const keys = Object.keys(metadata);
|
|
7173
|
+
if (keys.length === 0) return void 0;
|
|
7174
|
+
const reported = {};
|
|
7175
|
+
for (const key of keys) reported[key] = Reflect.get(metadata, key);
|
|
7176
|
+
return reported;
|
|
7177
|
+
}
|
|
7178
|
+
/**
|
|
7157
7179
|
* Map fascicle's Message[] to the AI SDK's ModelMessage[] shape.
|
|
7158
7180
|
*/
|
|
7159
7181
|
function to_sdk_messages(messages) {
|
|
@@ -7341,6 +7363,7 @@ async function collect_stream(params, step_index, dispatcher, on_first_chunk, in
|
|
|
7341
7363
|
const tool_calls = [];
|
|
7342
7364
|
let finish_reason = "stop";
|
|
7343
7365
|
let raw_usage = {};
|
|
7366
|
+
let provider_reported;
|
|
7344
7367
|
let first = true;
|
|
7345
7368
|
for await (const part of stream_result.stream) {
|
|
7346
7369
|
if (first) {
|
|
@@ -7356,6 +7379,7 @@ async function collect_stream(params, step_index, dispatcher, on_first_chunk, in
|
|
|
7356
7379
|
if (part.type === "finish-step") {
|
|
7357
7380
|
finish_reason = map_finish_reason(part.finishReason);
|
|
7358
7381
|
raw_usage = to_raw_provider_usage(part.usage);
|
|
7382
|
+
provider_reported = to_provider_reported(part.providerMetadata);
|
|
7359
7383
|
}
|
|
7360
7384
|
if (part.type === "error") throw part.error;
|
|
7361
7385
|
if (part.type === "abort") throw new aborted_error("aborted", { step_index });
|
|
@@ -7372,7 +7396,8 @@ async function collect_stream(params, step_index, dispatcher, on_first_chunk, in
|
|
|
7372
7396
|
text,
|
|
7373
7397
|
tool_calls,
|
|
7374
7398
|
finish_reason,
|
|
7375
|
-
usage: adapter.normalize_usage(raw_usage)
|
|
7399
|
+
usage: adapter.normalize_usage(raw_usage),
|
|
7400
|
+
...provider_reported !== void 0 ? { provider_reported } : {}
|
|
7376
7401
|
};
|
|
7377
7402
|
}
|
|
7378
7403
|
/**
|
|
@@ -7396,11 +7421,13 @@ async function collect_non_stream(params, adapter) {
|
|
|
7396
7421
|
input: tc.input
|
|
7397
7422
|
});
|
|
7398
7423
|
const raw_usage = to_raw_provider_usage(result.usage);
|
|
7424
|
+
const provider_reported = to_provider_reported(result.providerMetadata);
|
|
7399
7425
|
return {
|
|
7400
7426
|
text: result.text,
|
|
7401
7427
|
tool_calls,
|
|
7402
7428
|
finish_reason: map_finish_reason(result.finishReason),
|
|
7403
|
-
usage: adapter.normalize_usage(raw_usage)
|
|
7429
|
+
usage: adapter.normalize_usage(raw_usage),
|
|
7430
|
+
...provider_reported !== void 0 ? { provider_reported } : {}
|
|
7404
7431
|
};
|
|
7405
7432
|
}
|
|
7406
7433
|
/**
|
|
@@ -7413,6 +7440,10 @@ async function collect_non_stream(params, adapter) {
|
|
|
7413
7440
|
* turn result, so `parse_with_schema` re-validates it and the repair loop
|
|
7414
7441
|
* engages exactly as it does for the prompt-based path. Returns undefined for
|
|
7415
7442
|
* any other error so the caller rethrows.
|
|
7443
|
+
*
|
|
7444
|
+
* The recovered turn carries no provider_reported: the SDK's error exposes
|
|
7445
|
+
* text, usage, finishReason and response metadata, but not providerMetadata,
|
|
7446
|
+
* so there is nothing to read. The repair turn that follows reports normally.
|
|
7416
7447
|
*/
|
|
7417
7448
|
function recover_no_object_generated(err, adapter) {
|
|
7418
7449
|
if (!NoObjectGeneratedError.isInstance(err)) return void 0;
|
|
@@ -7923,6 +7954,8 @@ async function generate(opts_in, engine) {
|
|
|
7923
7954
|
}
|
|
7924
7955
|
};
|
|
7925
7956
|
if (aggregated_cost !== void 0) result.cost = aggregated_cost;
|
|
7957
|
+
const aggregated_reported = last_provider_reported(steps_accum);
|
|
7958
|
+
if (aggregated_reported !== void 0) result.provider_reported = aggregated_reported;
|
|
7926
7959
|
if (on_chunk_provided) await dispatcher.dispatch({
|
|
7927
7960
|
kind: "finish",
|
|
7928
7961
|
finish_reason,
|
|
@@ -7946,6 +7979,19 @@ function round6(v) {
|
|
|
7946
7979
|
return Math.round(v * 1e6) / 1e6;
|
|
7947
7980
|
}
|
|
7948
7981
|
/**
|
|
7982
|
+
* Pick the call-level `provider_reported` from the step records: the payload of
|
|
7983
|
+
* the last step that reported one.
|
|
7984
|
+
*
|
|
7985
|
+
* Provider payloads are opaque, so unlike usage and cost there is nothing to
|
|
7986
|
+
* sum and no safe way to merge two turns' keys (a provider reports the same keys
|
|
7987
|
+
* every turn, so merging would silently overwrite rather than combine). Taking
|
|
7988
|
+
* the final reporting turn matches how `content` and `finish_reason` are drawn
|
|
7989
|
+
* from the last turn; every turn's own payload stays on `steps[i]`.
|
|
7990
|
+
*/
|
|
7991
|
+
function last_provider_reported(steps) {
|
|
7992
|
+
return steps.findLast((s) => s.provider_reported !== void 0)?.provider_reported;
|
|
7993
|
+
}
|
|
7994
|
+
/**
|
|
7949
7995
|
* Sum per-step cost breakdowns into a single `CostBreakdown` for the whole
|
|
7950
7996
|
* generate call.
|
|
7951
7997
|
*
|