fascicle 0.9.9 → 0.9.11

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.9.11 — 2026-08-05
4
+
5
+ ### Added
6
+
7
+ - **The bedrock provider has a real ambient-credential mode.** `use_credential_chain: true` loads `@aws-sdk/credential-providers` (a new optional peer) and hands `fromNodeProviderChain()` to the SDK, so `~/.aws/credentials` profiles, SSO, and ECS/EC2 instance roles authenticate without exporting keys into the environment first. `credential_provider` is the escape hatch for callers that already hold a provider, such as an assume-role flow; supplying both is an `engine_config_error`. The chain is built once per adapter so its memoized credential cache survives across requests.
8
+
9
+ ### Fixed
10
+
11
+ - **`bedrock` documented an ambient AWS credential chain it never had.** The adapter's doc comments, `docs/providers.md`, and `docs/troubleshooting.md` all said that omitting credentials falls back to the AWS credential chain. It does not: `@ai-sdk/amazon-bedrock` resolves SigV4 keys from `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` and never opens `~/.aws/credentials`, so "omit the keys" silently produced an unauthenticated client that failed with a SigV4 error reading like a missing IAM grant. The claim is corrected everywhere and the real capability is now the `use_credential_chain` flag above. Lambda was never affected, since the execution role injects those env vars. `bedrock_credential_chain_wire.test.ts` pins the fix where it actually bit: with every AWS variable deleted from the environment and only a shared-credentials profile on disk, driving the real peer over a stubbed fetch and asserting the profile's key appears in the SigV4 `Authorization` scope. Its negative control asserts the same environment fails without the flag, so the suite cannot be masked by ambient credentials the way the bug was.
12
+
13
+ ### Internal
14
+
15
+ - **The site's three pages carry real head metadata.** `index.html`, `docs.html`, and `blueprint.html` shipped with a head holding only charset and viewport, so tabs showed the bare URL and every link preview and search result had nothing to render. Each page now sets `lang="en"`, a distinct title and description drawn from its own copy, a canonical link, and the Open Graph and Twitter text tags. These sit in the static head rather than the `<helmet>` block, so crawlers that never run JavaScript still see them. No library changes.
16
+
17
+ ## v0.9.10 — 2026-07-30
18
+
19
+ ### Added
20
+
21
+ - **Bedrock guardrails are documented and pinned by a wire contract test.** `provider_options.bedrock.guardrailConfig` reaches the top level of the Converse command through a seam `@ai-sdk/amazon-bedrock` does not document: its provider-options schema omits the key, and the request builder rest-spreads unknown keys into the command body, so a peer upgrade that tightens that spread would drop guardrails silently. `bedrock_guardrail_wire.test.ts` drives the real peer over a stubbed fetch and asserts the key lands top-level, survives the effort-translation merge, and that a `guardrail_intervened` stop surfaces as `finish_reason: 'content_filter'`. The bedrock section of `docs/providers.md` gains the matching recipe. No runtime changes.
22
+
3
23
  ## v0.9.9 — 2026-07-24
4
24
 
5
25
  No library behavior changes in this release. Every `src/` edit in this range is
package/dist/agents.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { G as Step } from "./index-SkPG_Rew.js";
2
- import { y as Engine } from "./index-Bfjpd_3o.js";
2
+ import { y as Engine } from "./index-BwkQPMfX.js";
3
3
  import { z } from "zod";
4
4
 
5
5
  //#region src/agents/define_agent.d.ts
@@ -427,6 +427,18 @@ type ProviderInit = {
427
427
  base_url?: string;
428
428
  [k: string]: unknown;
429
429
  };
430
+ /**
431
+ * AWS credentials as `@ai-sdk/amazon-bedrock`'s `credentialProvider` seam
432
+ * expects them. The SDK supplies `region` itself, calls the provider once per
433
+ * request, and never passes arguments, so a provider that caches and refreshes
434
+ * (as `fromNodeProviderChain()` does) is the norm rather than the exception.
435
+ */
436
+ type BedrockCredentials = {
437
+ accessKeyId: string;
438
+ secretAccessKey: string;
439
+ sessionToken?: string;
440
+ };
441
+ type BedrockCredentialProvider = () => PromiseLike<BedrockCredentials>;
430
442
  type ProviderConfigMap = {
431
443
  anthropic?: {
432
444
  api_key: string;
@@ -465,6 +477,8 @@ type ProviderConfigMap = {
465
477
  secret_access_key?: string;
466
478
  session_token?: string;
467
479
  base_url?: string;
480
+ use_credential_chain?: boolean;
481
+ credential_provider?: BedrockCredentialProvider;
468
482
  };
469
483
  claude_cli?: ClaudeCliProviderConfig;
470
484
  [custom: string]: ProviderInit | undefined;
@@ -670,4 +684,4 @@ declare class provider_auth_error extends Error {
670
684
  }
671
685
  //#endregion
672
686
  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 };
673
- //# sourceMappingURL=index-Bfjpd_3o.d.ts.map
687
+ //# sourceMappingURL=index-BwkQPMfX.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-Bfjpd_3o.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-BwkQPMfX.js";
3
3
  import { z } from "zod";
4
4
 
5
5
  //#region src/composites/adversarial.d.ts
package/dist/index.js CHANGED
@@ -1683,7 +1683,7 @@ async function retry_with_policy(fn, policy = DEFAULT_RETRY, abort) {
1683
1683
  /**
1684
1684
  * Read `key` off `err` and return it only if the value is a string.
1685
1685
  */
1686
- function read_string(err, key) {
1686
+ function read_string$1(err, key) {
1687
1687
  const value = Reflect.get(err, key);
1688
1688
  return typeof value === "string" ? value : void 0;
1689
1689
  }
@@ -1704,14 +1704,14 @@ function read_number$1(err, key) {
1704
1704
  */
1705
1705
  function classify_retryable(err) {
1706
1706
  if (err === null || typeof err !== "object") return void 0;
1707
- const kind = read_string(err, "kind");
1707
+ const kind = read_string$1(err, "kind");
1708
1708
  if (kind === "rate_limit") {
1709
1709
  const base = { kind: "rate_limit" };
1710
1710
  const retry_after = read_number$1(err, "retry_after_ms");
1711
1711
  if (retry_after !== void 0) base.retry_after_ms = retry_after;
1712
1712
  const status = read_number$1(err, "status");
1713
1713
  if (status !== void 0) base.status = status;
1714
- const message = read_string(err, "message");
1714
+ const message = read_string$1(err, "message");
1715
1715
  if (message !== void 0) base.message = message;
1716
1716
  return base;
1717
1717
  }
@@ -1719,15 +1719,15 @@ function classify_retryable(err) {
1719
1719
  const base = { kind: "provider_5xx" };
1720
1720
  const status = read_number$1(err, "status");
1721
1721
  if (status !== void 0) base.status = status;
1722
- const body = read_string(err, "body");
1722
+ const body = read_string$1(err, "body");
1723
1723
  if (body !== void 0) base.body = body;
1724
- const message = read_string(err, "message");
1724
+ const message = read_string$1(err, "message");
1725
1725
  if (message !== void 0) base.message = message;
1726
1726
  return base;
1727
1727
  }
1728
1728
  if (kind === "network" || kind === "timeout") {
1729
1729
  const base = { kind };
1730
- const message = read_string(err, "message");
1730
+ const message = read_string$1(err, "message");
1731
1731
  if (message !== void 0) base.message = message;
1732
1732
  return base;
1733
1733
  }
@@ -3922,31 +3922,85 @@ const SUPPORTED$1 = /* @__PURE__ */ new Set([
3922
3922
  "image_input",
3923
3923
  "reasoning"
3924
3924
  ]);
3925
+ /** Read a config field only when it is a string, so junk values stay unset. */
3926
+ function read_string(init, key) {
3927
+ const value = init[key];
3928
+ return typeof value === "string" ? value : void 0;
3929
+ }
3930
+ /** Pull the static fields off init, rejecting a missing or non-string region. */
3931
+ function read_static_credentials(init) {
3932
+ const region = read_string(init, "region") ?? "";
3933
+ if (region.length === 0) throw new engine_config_error("bedrock provider requires a non-empty region", "bedrock");
3934
+ return {
3935
+ region,
3936
+ api_key: read_string(init, "api_key"),
3937
+ access_key_id: read_string(init, "access_key_id"),
3938
+ secret_access_key: read_string(init, "secret_access_key"),
3939
+ session_token: read_string(init, "session_token"),
3940
+ base_url: read_string(init, "base_url")
3941
+ };
3942
+ }
3943
+ /** True when the caller is already supplying credentials in any static form. */
3944
+ function has_static_credentials(statics) {
3945
+ return statics.api_key !== void 0 || statics.access_key_id !== void 0 || statics.secret_access_key !== void 0 || statics.session_token !== void 0;
3946
+ }
3947
+ /**
3948
+ * Pick the dynamic credential source, or none. A bearer token or any explicit
3949
+ * SigV4 field short-circuits it: attaching a provider anyway would either
3950
+ * override the caller's keys (the SDK prefers `credentialProvider` over
3951
+ * `accessKeyId`) or force the optional @aws-sdk/credential-providers peer on
3952
+ * bearer-token users who never need it. The conflict check runs first, since
3953
+ * naming two dynamic sources is a mistake whatever else is set.
3954
+ */
3955
+ function resolve_dynamic_source(init, statics) {
3956
+ const use_chain = init["use_credential_chain"] === true;
3957
+ const raw = init["credential_provider"];
3958
+ const provider = typeof raw === "function" ? raw : void 0;
3959
+ if (use_chain && provider !== void 0) throw new engine_config_error("bedrock provider accepts use_credential_chain or credential_provider, not both", "bedrock");
3960
+ if (has_static_credentials(statics)) return void 0;
3961
+ if (provider !== void 0) return {
3962
+ kind: "explicit",
3963
+ provider
3964
+ };
3965
+ return use_chain ? { kind: "chain" } : void 0;
3966
+ }
3967
+ /**
3968
+ * Build the camelCase config the SDK expects, assigning only fields that are
3969
+ * set so the object carries no `undefined` entries. The SDK reads either shape
3970
+ * identically; the tests assert on key presence, which is the cheaper signal
3971
+ * that a credential really was omitted rather than silently resolved.
3972
+ */
3973
+ function to_sdk_config(statics, credential_provider) {
3974
+ const config = { region: statics.region };
3975
+ if (statics.api_key !== void 0) config.apiKey = statics.api_key;
3976
+ if (statics.access_key_id !== void 0) config.accessKeyId = statics.access_key_id;
3977
+ if (statics.secret_access_key !== void 0) config.secretAccessKey = statics.secret_access_key;
3978
+ if (statics.session_token !== void 0) config.sessionToken = statics.session_token;
3979
+ if (statics.base_url !== void 0) config.baseURL = statics.base_url;
3980
+ if (credential_provider !== void 0) config.credentialProvider = credential_provider;
3981
+ return config;
3982
+ }
3925
3983
  /**
3926
3984
  * Build the Bedrock ai_sdk adapter: validates the required region, resolves
3927
- * the chosen auth mode (bearer token, SigV4 keys, or the ambient AWS
3928
- * credential chain), and lazily loads @ai-sdk/amazon-bedrock to build models.
3985
+ * the chosen auth mode (bearer token, explicit SigV4 keys, or a dynamic
3986
+ * credential source), and lazily loads @ai-sdk/amazon-bedrock to build models.
3987
+ * See the module docstring for the full precedence ladder.
3929
3988
  */
3930
3989
  const create_bedrock_adapter = (init) => {
3931
- const region = typeof init["region"] === "string" ? init["region"] : "";
3932
- if (region.length === 0) throw new engine_config_error("bedrock provider requires a non-empty region", "bedrock");
3933
- const api_key = typeof init.api_key === "string" ? init.api_key : void 0;
3934
- const access_key_id = typeof init["access_key_id"] === "string" ? init["access_key_id"] : void 0;
3935
- const secret_access_key = typeof init["secret_access_key"] === "string" ? init["secret_access_key"] : void 0;
3936
- const session_token = typeof init["session_token"] === "string" ? init["session_token"] : void 0;
3937
- const base_url = typeof init.base_url === "string" ? init.base_url : void 0;
3990
+ const statics = read_static_credentials(init);
3991
+ const dynamic_source = resolve_dynamic_source(init, statics);
3992
+ let chain;
3993
+ async function resolve_credential_provider() {
3994
+ if (dynamic_source === void 0) return void 0;
3995
+ if (dynamic_source.kind === "explicit") return dynamic_source.provider;
3996
+ chain ??= (await load_optional_peer("@aws-sdk/credential-providers")).fromNodeProviderChain();
3997
+ return chain;
3998
+ }
3938
3999
  return {
3939
4000
  kind: "ai_sdk",
3940
4001
  name: "bedrock",
3941
4002
  async build_model(model_id) {
3942
- const sdk = await load_optional_peer("@ai-sdk/amazon-bedrock");
3943
- const config = { region };
3944
- if (api_key !== void 0) config.apiKey = api_key;
3945
- if (access_key_id !== void 0) config.accessKeyId = access_key_id;
3946
- if (secret_access_key !== void 0) config.secretAccessKey = secret_access_key;
3947
- if (session_token !== void 0) config.sessionToken = session_token;
3948
- if (base_url !== void 0) config.baseURL = base_url;
3949
- return sdk.createAmazonBedrock(config)(model_id);
4003
+ return (await load_optional_peer("@ai-sdk/amazon-bedrock")).createAmazonBedrock(to_sdk_config(statics, await resolve_credential_provider()))(model_id);
3950
4004
  },
3951
4005
  translate_effort: translate_bedrock_effort,
3952
4006
  normalize_usage: normalize_bedrock_usage,