@salesforce/sfdx-agent-sdk 0.32.0 → 0.34.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 (42) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +45 -50
  3. package/dist/agent-connectivity-resolver.d.ts +11 -5
  4. package/dist/agent-connectivity-resolver.js +34 -16
  5. package/dist/harness/harness-config.d.ts +5 -84
  6. package/dist/harness/harness-config.js +0 -30
  7. package/dist/harness/public.d.ts +3 -4
  8. package/dist/index.d.ts +3 -3
  9. package/dist/index.js +1 -1
  10. package/dist/models/claude-opus-4-5.d.ts +2 -1
  11. package/dist/models/claude-opus-4-5.js +4 -0
  12. package/dist/models/claude-opus-4-6.d.ts +2 -1
  13. package/dist/models/claude-opus-4-6.js +4 -0
  14. package/dist/models/claude-opus-4-7.d.ts +3 -1
  15. package/dist/models/claude-opus-4-7.js +7 -0
  16. package/dist/models/claude-opus-4-8.d.ts +3 -1
  17. package/dist/models/claude-opus-4-8.js +7 -0
  18. package/dist/models/claude-sonnet-4-5.d.ts +2 -1
  19. package/dist/models/claude-sonnet-4-5.js +4 -0
  20. package/dist/models/claude-sonnet-4-6.d.ts +2 -1
  21. package/dist/models/claude-sonnet-4-6.js +4 -0
  22. package/dist/models/create-claude-model.d.ts +12 -5
  23. package/dist/models/create-claude-model.js +6 -4
  24. package/dist/models/{gpt-5-1-geo.d.ts → gpt-5-1.d.ts} +1 -1
  25. package/dist/models/{gpt-5-1-geo.js → gpt-5-1.js} +4 -4
  26. package/dist/models/{gpt-5-2-geo.d.ts → gpt-5-2.d.ts} +1 -1
  27. package/dist/models/{gpt-5-2-geo.js → gpt-5-2.js} +4 -4
  28. package/dist/models/gpt-5-4.d.ts +5 -0
  29. package/dist/models/gpt-5-4.js +5 -0
  30. package/dist/models/gpt-5.d.ts +5 -0
  31. package/dist/models/gpt-5.js +5 -0
  32. package/dist/models/index.d.ts +13 -5
  33. package/dist/models/index.js +39 -25
  34. package/dist/models/model.d.ts +65 -14
  35. package/dist/models/model.js +49 -17
  36. package/dist/policy-resolver.d.ts +4 -2
  37. package/dist/types/tools.d.ts +2 -2
  38. package/package.json +8 -8
  39. package/dist/models/gpt-5-4-geo.d.ts +0 -16
  40. package/dist/models/gpt-5-4-geo.js +0 -26
  41. package/dist/models/gpt-5-geo.d.ts +0 -17
  42. package/dist/models/gpt-5-geo.js +0 -28
package/CHANGELOG.md CHANGED
@@ -3,6 +3,26 @@
3
3
  All notable changes to `@salesforce/sfdx-agent-sdk` are documented in this file.
4
4
  Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
+ ## [0.34.0] - 2026-07-15
7
+
8
+ ### Features
9
+ - **agent-sdk,harness-claude,harness-mastra**: per-model gateway config — geo-aware ids, thinking mode, param exclusion @W-23447370@ ([#672](https://github.com/forcedotcom/agentic-dx/pull/672))
10
+
11
+ ## [0.33.0] - 2026-07-14
12
+
13
+ ### Features
14
+ - **agent-sdk,harness-mastra,harness-claude**: cross-harness conformance test suite @W-23372341@ ([#663](https://github.com/forcedotcom/agentic-dx/pull/663))
15
+ - **sdk,harness-mastra,harness-claude**: delete deprecated tool-approval surfaces @W-23090034 ([#637](https://github.com/forcedotcom/agentic-dx/pull/637))
16
+
17
+ ### Fixes
18
+ - **harness-mastra**: thread model maxOutputTokens instead of flooring max_tokens at 4096 @W-23413250@ ([#656](https://github.com/forcedotcom/agentic-dx/pull/656))
19
+
20
+ ### Chores
21
+ - **deps-dev**: bump typescript-eslint from 8.62.1 to 8.63.0 in the dev-dependencies group across 1 directory ([#665](https://github.com/forcedotcom/agentic-dx/pull/665))
22
+ - **deps-dev**: bump the eslint group across 1 directory with 2 updates ([#659](https://github.com/forcedotcom/agentic-dx/pull/659))
23
+ - **deps-dev**: bump @vitest/eslint-plugin from 1.6.22 to 1.6.23 in the vitest group ([#660](https://github.com/forcedotcom/agentic-dx/pull/660))
24
+ - **deps-dev**: bump the vitest group across 1 directory with 3 updates ([#655](https://github.com/forcedotcom/agentic-dx/pull/655))
25
+
6
26
  ## [0.32.0] - 2026-07-08
7
27
 
8
28
  ### Fixes
package/README.md CHANGED
@@ -34,7 +34,7 @@ for (const failure of manager.getRestoreFailures()) {
34
34
  // storage folder will replay this agent automatically.
35
35
  const agent = await manager.createAgent('/path/to/project', {
36
36
  agentId: 'developer-assistant',
37
- modelId: 'llmgateway__OpenAIGPT5',
37
+ modelId: 'sfdc_ai__DefaultGPT5',
38
38
  instructions: 'You are a helpful Salesforce developer assistant.',
39
39
  });
40
40
 
@@ -232,33 +232,27 @@ function onApprovalRequest(event: ToolApprovalRequestEvent): Promise<boolean> {
232
232
 
233
233
  #### `AgentConfig`
234
234
 
235
- | Field | Type | Description |
236
- | ---------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
237
- | `orgAlias?` | `string` | Salesforce org alias or username. Falls back to project/default org. |
238
- | `modelId?` | `ModelName \| Model` | LLM model selector. Pass a `ModelName` enum value for an in-tree model (e.g. `'llmgateway__OpenAIGPT5'`), or a pre-built `Model` instance to opt into a Bedrock-Anthropic Claude variant the SDK has not yet released — see `createClaudeModel(gatewayId, overrides)` exported from this package. |
239
- | `name?` | `string` | Human-readable agent name. |
240
- | `description?` | `string` | Agent purpose description. |
241
- | `instructions?` | `string` | System instructions for the agent. |
242
- | `tools?` | `ToolDefinition[]` | Consumer-executed tool schemas. |
243
- | `mcpServers?` | `MCPConfiguration` | MCP server connections. |
244
- | `skills?` | `string[]` | Each entry is either an individual skill folder (containing `SKILL.md`) or a parent folder containing skill subfolders. Relative and absolute paths supported; forms can be mixed in the same array. |
245
- | `rules?` | `string[]` | Each entry is either an individual `.md` rule file or a directory of `.md` rule files (scanned one level deep, alphabetical, non-`.md` skipped). Bodies are composed verbatim into the agent's effective system prompt; YAML frontmatter is optional and stripped if present. Matches Claude Code's `.claude/rules/*.md` convention. |
246
- | `toolPolicies?` | `ToolPolicyRule[]` | Ordered per-tool approval rules resolved by `resolveToolApprovalPolicy` (cross-tier deny-wins / within-tier last-wins). Author directly or via `definePolicy(...)`. See "Tool Approval Policy" below. Has no effect until a harness wires the resolver (Phase 2); until then gating uses the deprecated `StreamOptions.requireToolApproval`. |
247
- | `defaultToolDecision?` | `Decision` | Fallback decision when no rule matches. Defaults to `'allow'` (no policy ⇒ no gating). Set to `'require-approval'` for a fail-closed posture (recommended for catalogs with un-annotated MCP servers). |
235
+ | Field | Type | Description |
236
+ | ---------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
237
+ | `orgAlias?` | `string` | Salesforce org alias or username. Falls back to project/default org. |
238
+ | `modelId?` | `ModelName \| Model` | LLM model selector. Pass a `ModelName` enum value for an in-tree model (e.g. `'sfdc_ai__DefaultGPT5'`), or a pre-built `Model` instance to opt into a Bedrock-Anthropic Claude variant the SDK has not yet released — see `createClaudeModel(gatewayId, overrides)` exported from this package. Legacy pinned `llmgateway__*` ids still resolve via a back-compat alias map. |
239
+ | `name?` | `string` | Human-readable agent name. |
240
+ | `description?` | `string` | Agent purpose description. |
241
+ | `instructions?` | `string` | System instructions for the agent. |
242
+ | `tools?` | `ToolDefinition[]` | Consumer-executed tool schemas. |
243
+ | `mcpServers?` | `MCPConfiguration` | MCP server connections. |
244
+ | `skills?` | `string[]` | Each entry is either an individual skill folder (containing `SKILL.md`) or a parent folder containing skill subfolders. Relative and absolute paths supported; forms can be mixed in the same array. |
245
+ | `rules?` | `string[]` | Each entry is either an individual `.md` rule file or a directory of `.md` rule files (scanned one level deep, alphabetical, non-`.md` skipped). Bodies are composed verbatim into the agent's effective system prompt; YAML frontmatter is optional and stripped if present. Matches Claude Code's `.claude/rules/*.md` convention. |
246
+ | `toolPolicies?` | `ToolPolicyRule[]` | Ordered per-tool approval rules resolved by `resolveToolApprovalPolicy` (cross-tier deny-wins / within-tier last-wins). Author directly or via `definePolicy(...)`. See "Tool Approval Policy" below. |
247
+ | `defaultToolDecision?` | `Decision` | Fallback decision when no rule matches. Defaults to `'allow'` (no policy ⇒ no gating). Set to `'require-approval'` for a fail-closed posture (recommended for catalogs with un-annotated MCP servers). |
248
248
 
249
249
  #### `StreamOptions`
250
250
 
251
- | Field | Type | Description |
252
- | ---------------------- | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
253
- | `abortSignal?` | `AbortSignal` | Abort the streaming operation. |
254
- | `requireToolApproval?` | `boolean \| ToolApprovalMode` | **Deprecated.** Per-call all-or-nothing gating. Superseded by per-tool policy on `AgentConfig.toolPolicies`; the serial-vs-batch UX axis moved to `batchApprovals`. Kept functional for one release so harness PRs migrate independently. `true` / `'serial'` emits one approval per stream; `'batch'` surfaces parallel approvals on one stream (requires Pattern A iterators). See "Tool Approval Flow" below. |
255
- | `batchApprovals?` | `boolean` | When `true`, parallel approval-requests within a turn surface on the same stream so the consumer can render a batch approval card (requires Pattern A iterators collect-all-then-settle). Defaults to `false` (serial). The self-documenting replacement for the UX half of the deprecated `requireToolApproval` enum; the gating half moves to `AgentConfig.toolPolicies`. No effect when no tool in the turn resolves to `'require-approval'`. |
256
- | `maxSteps?` | `number` | Maximum number of LLM call steps the agent may take per `stream()` invocation. Each step is one LLM call (which may produce text, tool calls, or both). Must be `>= 1`. Defaults to `DEFAULT_MAX_STEPS` (1024) — high enough to be effectively unlimited for real tasks; the practical ceiling is the context window and cost. The constant is exported so consumers and harness authors share one source of truth. |
257
-
258
- `ToolApprovalMode` is the exported (deprecated) type alias `'serial' | 'batch'`. Pair with the (deprecated)
259
- `resolveToolApprovalMode(boolean | ToolApprovalMode | undefined)` to normalize consumer input the same way the SDK does
260
- internally (`undefined` / `false` → `undefined`, `true` → `'serial'`, strings pass through, unknown strings throw). New
261
- code should configure `AgentConfig.toolPolicies` and set `batchApprovals` for the UX axis instead.
251
+ | Field | Type | Description |
252
+ | ----------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
253
+ | `abortSignal?` | `AbortSignal` | Abort the streaming operation. |
254
+ | `batchApprovals?` | `boolean` | When `true`, parallel approval-requests within a turn surface on the same stream so the consumer can render a batch approval card (requires Pattern A iterators — collect-all-then-settle). Defaults to `false` (serial). Controls only the serial-vs-batch emission UX; the gating on/off decision lives on `AgentConfig.toolPolicies` / `AgentConfig.defaultToolDecision`. No effect when no tool in the turn resolves to `'require-approval'`. |
255
+ | `maxSteps?` | `number` | Maximum number of LLM call steps the agent may take per `stream()` invocation. Each step is one LLM call (which may produce text, tool calls, or both). Must be `>= 1`. Defaults to `DEFAULT_MAX_STEPS` (1024) high enough to be effectively unlimited for real tasks; the practical ceiling is the context window and cost. The constant is exported so consumers and harness authors share one source of truth. |
262
256
 
263
257
  #### Tool Approval Policy
264
258
 
@@ -722,21 +716,16 @@ consumers can branch on tool hints (e.g. auto-approve `readOnlyHint`) or group b
722
716
  reparsing namespaced tool names. `annotations` is `undefined` when the source did not declare them (per the MCP spec);
723
717
  `serverName` is `undefined` when the tool is not from an MCP server.
724
718
 
725
- `requireToolApproval` accepts a `boolean` (`true` is shorthand for `'serial'`) or one of the mode strings exposed via
726
- the `ToolApprovalMode` type alias (`'serial' | 'batch'`):
727
-
728
- - **`'serial'`** (the safe default) — `tool-approval-request` events surface one at a time. The next request (if any)
729
- arrives later on the same `eventStream` after the consumer settles the current one.
730
- - **`'batch'`** — when the model emits parallel `tool_use` blocks, all approval-requests for that batch surface on the
731
- same `eventStream` together, so the consumer can render a batch-approval card. The consumer must gather all approvals
732
- before settling — a `break`-on-first-approval loop will hang the turn because Mastra/Claude won't continue emitting
733
- tool-results until the consumer has settled the entire batch.
719
+ Gating is configured on the agent via `AgentConfig.toolPolicies` / `AgentConfig.defaultToolDecision` (see "Tool Approval
720
+ Policy" above). The per-call `StreamOptions.batchApprovals` flag controls only how the resulting `tool-approval-request`
721
+ events are emitted:
734
722
 
735
- The SDK also exports `resolveToolApprovalMode(value)`the canonical
736
- `boolean | ToolApprovalMode | undefined ToolApprovalMode | undefined` normalizer harness implementations should use to
737
- dispatch (`undefined` / `false` `undefined`, `true` `'serial'`, strings pass through). Reject unknown strings via
738
- `throw` instead of reimplementing the boolean-vs-string branch the helper's defensive throw catches `as any` consumers
739
- passing invalid values that would otherwise silently degrade to "approval gating on but no coordinator allocated."
723
+ - **`batchApprovals: false`** (the safe default) — `tool-approval-request` events surface one at a time. The next
724
+ request (if any) arrives later on the same `eventStream` after the consumer settles the current one.
725
+ - **`batchApprovals: true`** when the model emits parallel `tool_use` blocks, all approval-requests for that batch
726
+ surface on the same `eventStream` together, so the consumer can render a batch-approval card. The consumer must gather
727
+ all approvals before settling a `break`-on-first-approval loop will hang the turn because Mastra/Claude won't
728
+ continue emitting tool-results until the consumer has settled the entire batch.
740
729
 
741
730
  #### Single stream per turn
742
731
 
@@ -749,12 +738,12 @@ in-line as approval-requests / consumer-tool-calls arrive.
749
738
 
750
739
  #### Pattern: settle in-line, continue iterating
751
740
 
752
- The same shape works for `'serial'` and `'batch'` mode:
741
+ The same shape works for serial and batch emission. Configure gating on the agent
742
+ (`defaultToolDecision: 'require-approval'`, or per-tool `toolPolicies`); the `chat()` call needs no approval flag:
753
743
 
754
744
  ```typescript
755
- const { eventStream } = await session.chat('Run the deployment', {
756
- requireToolApproval: true, // or 'serial' / 'batch'
757
- });
745
+ // Agent configured with e.g. { defaultToolDecision: 'require-approval' }
746
+ const { eventStream } = await session.chat('Run the deployment');
758
747
 
759
748
  for await (const event of eventStream) {
760
749
  if (event.type === 'tool-approval-request') {
@@ -789,12 +778,13 @@ for await (const event of eventStream) {
789
778
 
790
779
  #### Pattern variant: batch-collect approvals before settling
791
780
 
792
- Same single-stream loop, just gather the batch before deciding (useful for "approve these N tools?" UI cards under
793
- `requireToolApproval: 'batch'`):
781
+ Same single-stream loop, just gather the batch before deciding (useful for "approve these N tools?" UI cards). Set
782
+ `batchApprovals: true` on the `chat()` call; gating itself stays on the agent's `toolPolicies` / `defaultToolDecision`:
794
783
 
795
784
  ```typescript
785
+ // Agent configured with e.g. { defaultToolDecision: 'require-approval' }
796
786
  const { eventStream } = await session.chat('Run the deployment', {
797
- requireToolApproval: 'batch',
787
+ batchApprovals: true,
798
788
  });
799
789
 
800
790
  const pendingBatch: ToolApprovalRequestEvent[] = [];
@@ -873,8 +863,8 @@ for await (const event of eventStream) {
873
863
  }
874
864
  ```
875
865
 
876
- When `requireToolApproval: true` is also set, consumer-executed tools bypass the approval gate by construction (per
877
- `StreamOptions.requireToolApproval` JSDoc). They surface as a normal `tool-call` event without a preceding
866
+ When approval gating is active (via `AgentConfig.toolPolicies` / `defaultToolDecision`), consumer-executed tools bypass
867
+ the approval gate by construction. They surface as a normal `tool-call` event without a preceding
878
868
  `tool-approval-request`. Built-in / MCP tools still gate normally.
879
869
 
880
870
  ### Tool-Result Redaction
@@ -1047,7 +1037,7 @@ The connectivity facts a harness needs to make an LLM request. Five fields. Auth
1047
1037
  | --------------- | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1048
1038
  | `model` | `Model` | Capability descriptor used for pre-flight multimodal validation and SDK-side context-usage reporting. |
1049
1039
  | `baseUrl` | `string` | Provider-native or gateway base URL (no trailing slash, no path beyond the API root). Harnesses concat the wire-shape-specific path. |
1050
- | `nativeModelId` | `string` | Wire id the provider SDK sets on the request body's `model` field. May differ from `model.name` (e.g. Anthropic-direct expects `claude-sonnet-4-6`; the Salesforce gateway expects `llmgateway__BedrockAnthropicClaude46Sonnet`). |
1040
+ | `nativeModelId` | `string` | Wire id the provider SDK sets on the request body's `model` field. May differ from `model.name` (e.g. Anthropic-direct expects `claude-sonnet-4-6`; the Salesforce gateway expects `sfdc_ai__DefaultBedrockAnthropicClaude46Sonnet`). |
1051
1041
  | `providerHint` | `ProviderHint` | Wire shape the harness should speak. The manager validates this against the harness's `supportedProviderHints` before any harness work begins; a harness only sees hints it recognizes. |
1052
1042
  | `getHeaders` | `() => Promise<Record<string, string>>` | Returns the FULL header set (Authorization included) for the NEXT outbound request. **Per-call invocation contract.** Mastra harnesses MUST call this on every HTTP call (inside their fetch wrapper); Claude harnesses MUST call this once per subprocess spawn. Caching the returned map across requests is a bug. |
1053
1043
 
@@ -1094,7 +1084,7 @@ const manager = await createAgentManager('/path/to/storage', new MastraHarnessFa
1094
1084
  | `getApiKey` | `() => string \| Promise<string>` | Returns the API key. Re-evaluated on every `resolve()` call, and the resulting `getHeaders()` re-invokes it on every header read so a rotating key source (env var, secret store, BYOK toggle) lands without reconstructing the resolver. |
1095
1085
  | `baseUrl` | `string` | Fully-qualified provider URL with API version segment (e.g. `https://api.openai.com/v1`, not `https://api.openai.com`). |
1096
1086
  | `providerHint` | `ProviderHint` | Wire shape. Must be one a harness in the consumer's setup advertises via `HarnessFactory.supportedProviderHints`. |
1097
- | `nativeModelIdFor?` | `(model: Model) => string` | Optional translator from canonical `model.name` to the endpoint-native model id. Direct-provider endpoints expect their own naming (`claude-sonnet-4-6`); gateway-shaped endpoints accept the canonical `llmgateway__*` id verbatim. Defaults to `model.name`. |
1087
+ | `nativeModelIdFor?` | `(model: Model) => string` | Optional translator from canonical `model.name` to the endpoint-native model id. Direct-provider endpoints expect their own naming (`claude-sonnet-4-6`); gateway-shaped endpoints accept the canonical `sfdc_ai__Default*` id verbatim. Defaults to `model.name`. |
1098
1088
  | `connectionFactory?` | `OrgConnectionFactory` | Optional. When supplied, the resolver mints an org connection + JWT alongside the api-key bag — the BYOK shape (api-key authenticates the LLM; org JWT authenticates MCP servers / identity). Without it, `orgConnection` and `orgJwt` are omitted from `ResolvedConnectivity`. |
1099
1089
 
1100
1090
  The resolver throws `AgentSDKError(NOT_SUPPORTED)` when `getApiKey()` returns empty / nullish so consumers see "the
@@ -1106,6 +1096,11 @@ header bag. **Reserved auth headers are not overridable**: the resolver spreads
1106
1096
  `Authorization` / `Content-Type` last, so a `Model` instance whose `customHeaders` includes an `Authorization` key
1107
1097
  silently shadows nothing — the resolver wins.
1108
1098
 
1099
+ `Model.excludedParameters` is an optional denylist of generation parameters the LLM Gateway rejects for the model.
1100
+ Harnesses consult it before forwarding a generation parameter — currently only `temperature`, which the gateway
1101
+ deprecated for Claude Opus 4.7+ and now rejects. A model that lists `temperature` (the in-tree Opus 4.7 / 4.8 models do)
1102
+ has it stripped from the request; leaving `excludedParameters` unset (the default) forwards every parameter unchanged.
1103
+
1109
1104
  #### `HarnessAgentConfig`
1110
1105
 
1111
1106
  Harness-facing configuration derived from `AgentConfig`. Strips `orgAlias` (resolved above the harness) and adds:
@@ -90,11 +90,17 @@ export declare class DefaultAgentConnectivityResolver implements AgentConnectivi
90
90
  * its `name` — a programming error worth surfacing eagerly rather than silently
91
91
  * defaulting.
92
92
  *
93
- * **Scope:** This helper is for the Salesforce gateway path only both
94
- * `llmgateway__BedrockAnthropic*` and `llmgateway__Anthropic*` prefixes go to the
95
- * gateway's Bedrock pass-through, so both collapse to `'bedrock-anthropic'`. A
96
- * consumer wanting direct-Anthropic auth (`providerHint: 'anthropic'`) drives that
97
- * path through {@link ApiKeyConnectivityResolver} with an explicit `providerHint`
93
+ * **Scope:** This helper is for the Salesforce gateway path only. It keys on the
94
+ * model FAMILY segment, not the namespace prefix, because the geo-aware
95
+ * `sfdc_ai__Default*` prefix is shared across families: `sfdc_ai__DefaultBedrockAnthropic*`
96
+ * is a Claude model that must reach the Bedrock pass-through, while
97
+ * `sfdc_ai__DefaultGPT*` is an OpenAI model that must reach the Responses endpoint.
98
+ * Matching on the bare `sfdc_ai__Default` prefix alone would mis-route every geo
99
+ * Claude id onto the OpenAI wire path (wire-observed 500/502 — W-23256760). Both
100
+ * `BedrockAnthropic*` and `Anthropic*` families collapse to `'bedrock-anthropic'`
101
+ * (the gateway's Bedrock pass-through) under either namespace prefix. A consumer
102
+ * wanting direct-Anthropic auth (`providerHint: 'anthropic'`) drives that path
103
+ * through {@link ApiKeyConnectivityResolver} with an explicit `providerHint`
98
104
  * argument, not through this resolver.
99
105
  *
100
106
  * Exported (module-path only, not on the public `index.ts` surface) so e2e test
@@ -2,7 +2,7 @@
2
2
  * Copyright 2026, Salesforce, Inc. All rights reserved.
3
3
  * See LICENSE.txt for license terms.
4
4
  */
5
- import { Model, ModelName, Models, createClaudeModel } from './models/index.js';
5
+ import { Model, ModelName, Models, createClaudeModel, LEGACY_MODEL_ID_ALIASES, } from './models/index.js';
6
6
  import { createJWTFromConnection, RealOrgConnectionFactory, SfApiEnv, } from '@salesforce/agentic-common';
7
7
  // TODO(@W-22782317): Temporary workaround — only on prod orgs the LLM Gateway must
8
8
  // route requests through AgentforceVibes rather than the default VibesService. Remove once a
@@ -63,11 +63,17 @@ export class DefaultAgentConnectivityResolver {
63
63
  * its `name` — a programming error worth surfacing eagerly rather than silently
64
64
  * defaulting.
65
65
  *
66
- * **Scope:** This helper is for the Salesforce gateway path only both
67
- * `llmgateway__BedrockAnthropic*` and `llmgateway__Anthropic*` prefixes go to the
68
- * gateway's Bedrock pass-through, so both collapse to `'bedrock-anthropic'`. A
69
- * consumer wanting direct-Anthropic auth (`providerHint: 'anthropic'`) drives that
70
- * path through {@link ApiKeyConnectivityResolver} with an explicit `providerHint`
66
+ * **Scope:** This helper is for the Salesforce gateway path only. It keys on the
67
+ * model FAMILY segment, not the namespace prefix, because the geo-aware
68
+ * `sfdc_ai__Default*` prefix is shared across families: `sfdc_ai__DefaultBedrockAnthropic*`
69
+ * is a Claude model that must reach the Bedrock pass-through, while
70
+ * `sfdc_ai__DefaultGPT*` is an OpenAI model that must reach the Responses endpoint.
71
+ * Matching on the bare `sfdc_ai__Default` prefix alone would mis-route every geo
72
+ * Claude id onto the OpenAI wire path (wire-observed 500/502 — W-23256760). Both
73
+ * `BedrockAnthropic*` and `Anthropic*` families collapse to `'bedrock-anthropic'`
74
+ * (the gateway's Bedrock pass-through) under either namespace prefix. A consumer
75
+ * wanting direct-Anthropic auth (`providerHint: 'anthropic'`) drives that path
76
+ * through {@link ApiKeyConnectivityResolver} with an explicit `providerHint`
71
77
  * argument, not through this resolver.
72
78
  *
73
79
  * Exported (module-path only, not on the public `index.ts` surface) so e2e test
@@ -77,16 +83,20 @@ export class DefaultAgentConnectivityResolver {
77
83
  */
78
84
  export function pickProviderHintForGatewayModel(model) {
79
85
  const name = model.name;
80
- if (name.startsWith('llmgateway__BedrockAnthropic') || name.startsWith('llmgateway__Anthropic')) {
86
+ if (name.startsWith('llmgateway__BedrockAnthropic') ||
87
+ name.startsWith('llmgateway__Anthropic') ||
88
+ name.startsWith('sfdc_ai__DefaultBedrockAnthropic') ||
89
+ name.startsWith('sfdc_ai__DefaultAnthropic')) {
81
90
  return 'bedrock-anthropic';
82
91
  }
83
92
  if (name.startsWith('llmgateway__OpenAI') || name.startsWith('sfdc_ai__Default')) {
84
- // `sfdc_ai__Default*` is the geo-aware OpenAI route (W-23256760): the
85
- // gateway selects the regional deployment, but the wire shape is still
86
- // OpenAI Responses, so it resolves to the same providerHint.
93
+ // `sfdc_ai__Default*` (minus the Anthropic families handled above) is the
94
+ // geo-aware OpenAI route (W-23256760): the gateway selects the regional
95
+ // deployment, but the wire shape is still OpenAI Responses, so it resolves
96
+ // to the same providerHint.
87
97
  return 'openai-responses';
88
98
  }
89
- throw new Error(`Cannot infer providerHint for model "${name}". Salesforce gateway models must start with "llmgateway__BedrockAnthropic*", "llmgateway__OpenAI*", or "sfdc_ai__Default*".`);
99
+ throw new Error(`Cannot infer providerHint for model "${name}". Salesforce gateway models must start with "sfdc_ai__DefaultBedrockAnthropic*", "sfdc_ai__DefaultGPT*", or a legacy "llmgateway__BedrockAnthropic*" / "llmgateway__OpenAI*" id.`);
90
100
  }
91
101
  /**
92
102
  * Returns the Salesforce LLM Gateway base URL for the given environment.
@@ -168,12 +178,19 @@ function rehydratePersistedModel(persisted) {
168
178
  if (typeof obj.name !== 'string') {
169
179
  throw new Error(`Cannot resolve modelId: missing string "name" on persisted object.`);
170
180
  }
171
- // If the persisted name matches an in-tree model, prefer the strict registry the
172
- // returned instance has the correct prototype and the canonical caps.
173
- if (Object.values(ModelName).includes(obj.name)) {
181
+ // If the persisted name matches an in-tree model a current `ModelName` value OR a
182
+ // legacy pinned id the alias map remaps (e.g. an `AgentConfig` written before the
183
+ // geo-aware rename) — prefer the strict registry, which returns an instance with the
184
+ // correct prototype and canonical caps. `getByName` consults the alias map itself.
185
+ if (Object.values(ModelName).includes(obj.name) || obj.name in LEGACY_MODEL_ID_ALIASES) {
174
186
  return Models.getByName(obj.name);
175
187
  }
176
- if (!obj.name.startsWith('llmgateway__BedrockAnthropic')) {
188
+ // Escape-hatch rehydration (consumer-built Claude variants via createClaudeModel):
189
+ // accept both the geo-aware `sfdc_ai__DefaultBedrockAnthropic*` prefix and the legacy
190
+ // pinned `llmgateway__BedrockAnthropic*` prefix so instances persisted under either
191
+ // scheme rehydrate during the deprecation window.
192
+ if (!obj.name.startsWith('sfdc_ai__DefaultBedrockAnthropic') &&
193
+ !obj.name.startsWith('llmgateway__BedrockAnthropic')) {
177
194
  throw new Error(`Cannot rehydrate persisted model "${obj.name}". Only Bedrock-Anthropic Claude variants are supported via the consumer-built Model escape hatch.`);
178
195
  }
179
196
  return createClaudeModel(obj.name, {
@@ -183,7 +200,8 @@ function rehydratePersistedModel(persisted) {
183
200
  contextWindow: obj.contextWindow,
184
201
  supportsPromptCache: obj.supportsPromptCache,
185
202
  supportedFormats: obj.supportedFormats,
186
- permittedParameters: obj.permittedParameters,
203
+ excludedParameters: obj.excludedParameters,
204
+ thinkingMode: obj.thinkingMode,
187
205
  customHeaders: obj.customHeaders,
188
206
  });
189
207
  }
@@ -75,17 +75,12 @@ export type AgentConfig = {
75
75
  * the common cases. Per-MCP-server policy is expressed here via
76
76
  * `{ matcher: { type: 'mcp', serverName } }` rules — `MCPServerConfig`
77
77
  * carries no policy fields.
78
- *
79
- * Has no effect until a harness wires the resolver into its gate site
80
- * (Phase 2). Until then, harnesses gate via the deprecated
81
- * {@link StreamOptions.requireToolApproval}.
82
78
  */
83
79
  toolPolicies?: ToolPolicyRule[];
84
80
  /**
85
81
  * Fallback decision for tool invocations that match no rule in
86
82
  * {@link toolPolicies} (or any built-in / harness tier). Defaults to
87
- * `'allow'` for back-compat ("no policy ⇒ no gating," matching today's
88
- * behavior when `requireToolApproval` is unset).
83
+ * `'allow'` ("no policy ⇒ no gating").
89
84
  *
90
85
  * Set to `'require-approval'` for a fail-closed posture — recommended for
91
86
  * tenants whose MCP catalog includes un-annotated servers, since
@@ -126,84 +121,12 @@ export type HarnessAgentConfig = Omit<AgentConfig, 'orgAlias'> & {
126
121
  * `test/harness/harness-config.test.ts` that asserts unknown fields survive.
127
122
  */
128
123
  export declare function toHarnessConfig(config: AgentConfig, orgJwt?: JSONWebToken): HarnessAgentConfig;
129
- /**
130
- * Approval-mode selector for `StreamOptions.requireToolApproval`.
131
- *
132
- * Distinguishes the legacy "serial" UX (one approval per stream;
133
- * consumer settles before the next is surfaced) from the parallel
134
- * "batch" UX (all approval-requests for a parallel `tool_use` batch
135
- * surface on the same stream so the consumer can render them as a
136
- * batch approval card). See `requireToolApproval` for the safety
137
- * note on choosing `batch`.
138
- *
139
- * @deprecated Tool-approval gating is moving to per-tool policy on
140
- * {@link AgentConfig.toolPolicies}, resolved by `resolveToolApprovalPolicy`.
141
- * The serial-vs-batch UX axis survives as {@link StreamOptions.batchApprovals}.
142
- * Removed in a future major once harnesses and consumers have migrated.
143
- */
144
- export type ToolApprovalMode = 'serial' | 'batch';
145
- /**
146
- * Resolves `StreamOptions.requireToolApproval` to its canonical mode:
147
- * `undefined` (gating off), `'serial'`, or `'batch'`. Centralizes the
148
- * boolean-vs-string normalization so harnesses don't duplicate the
149
- * resolution logic.
150
- *
151
- * Semantics:
152
- * - `undefined` / `false` → `undefined` (no gating).
153
- * - `true` → `'serial'` (back-compat shorthand for the original `boolean` shape).
154
- * - `'serial'` → `'serial'` (explicit, equivalent to `true`).
155
- * - `'batch'` → `'batch'`.
156
- *
157
- * @deprecated Superseded by per-tool policy on {@link AgentConfig.toolPolicies}
158
- * (resolved by `resolveToolApprovalPolicy`) plus {@link StreamOptions.batchApprovals}
159
- * for the UX axis. Kept functional for one release so harness PRs can migrate
160
- * independently; removed in a future major.
161
- */
162
- export declare function resolveToolApprovalMode(requireToolApproval: boolean | ToolApprovalMode | undefined): ToolApprovalMode | undefined;
163
124
  /**
164
125
  * Per-call options controlling streaming behavior.
165
126
  */
166
127
  export type StreamOptions = {
167
128
  /** Signal to abort the streaming operation. */
168
129
  abortSignal?: AbortSignal;
169
- /**
170
- * When set, the harness requires human approval before executing any
171
- * native tool (e.g., MCP tools). The stream emits a `tool-approval-request`
172
- * event and suspends until the consumer calls `approveToolCall()` or
173
- * `declineToolCall()`.
174
- *
175
- * Accepts a `boolean` (back-compatible shorthand) or one of the
176
- * approval-mode strings:
177
- *
178
- * - **`true` or `'serial'`** (the safe default): each chat-stream
179
- * surfaces ONE `tool-approval-request` at a time. The consumer
180
- * settles the approval; the next `tool-approval-request` (if any)
181
- * appears on the continuation stream. Identical to the SDK's
182
- * behavior before parallel-approval UX (#447) — safe for consumers
183
- * whose iterator returns on the first approval-request and
184
- * re-iterates the continuation (Pattern B).
185
- *
186
- * - **`'batch'`**: when the model emits parallel `tool_use` blocks, the
187
- * broker surfaces ALL approval-requests on the same stream so the
188
- * consumer can render a batch approval UI ("Approve these N tools?").
189
- * Consumers MUST iterate to natural park collecting approvals
190
- * (Pattern A); a `break`-on-first-approval loop will miss the
191
- * subsequent approvals on the same stream and the chat will hang.
192
- * Only opt into `'batch'` after the consumer's iterator collects all
193
- * approvals before settling.
194
- *
195
- * Does not affect consumer-executed tools (those defined via
196
- * `AgentConfig.tools` without an execute handler) — the consumer
197
- * already controls execution for those via `submitToolResult()`.
198
- *
199
- * @deprecated Per-call all-or-nothing gating is superseded by per-tool
200
- * policy on {@link AgentConfig.toolPolicies}. The serial-vs-batch UX axis
201
- * moved to {@link batchApprovals}. Kept functional for one release so
202
- * harness PRs can migrate independently; removed in a future major. New
203
- * code should configure `AgentConfig.toolPolicies` and, if a batch UX is
204
- * wanted, set `batchApprovals: true`.
205
- */
206
- requireToolApproval?: boolean | ToolApprovalMode;
207
130
  /**
208
131
  * When `true`, parallel approval-requests within a turn (the model emits
209
132
  * multiple `tool_use` blocks in one batch, more than one of which resolves
@@ -212,14 +135,12 @@ export type StreamOptions = {
212
135
  * natural park before settling.
213
136
  *
214
137
  * Defaults to `false` (serial: one approval-request at a time; the consumer
215
- * settles before the next surfaces). Identical to pre-#447 behavior under
216
- * `requireToolApproval: true`.
138
+ * settles before the next surfaces).
217
139
  *
218
140
  * Has no effect when no tool in the turn resolves to `'require-approval'` —
219
- * there is nothing to batch. This is the self-documenting replacement for
220
- * the UX half of the deprecated {@link requireToolApproval} enum; the
221
- * "gating on/off" half moves to per-tool policy on
222
- * {@link AgentConfig.toolPolicies}.
141
+ * there is nothing to batch. The "gating on/off" decision lives on per-tool
142
+ * policy in {@link AgentConfig.toolPolicies} / {@link AgentConfig.defaultToolDecision};
143
+ * this flag controls only the serial-vs-batch emission UX.
223
144
  */
224
145
  batchApprovals?: boolean;
225
146
  /**
@@ -24,36 +24,6 @@ export function toHarnessConfig(config, orgJwt) {
24
24
  const { orgAlias: _, ...rest } = config;
25
25
  return { ...rest, orgJwt };
26
26
  }
27
- /**
28
- * Resolves `StreamOptions.requireToolApproval` to its canonical mode:
29
- * `undefined` (gating off), `'serial'`, or `'batch'`. Centralizes the
30
- * boolean-vs-string normalization so harnesses don't duplicate the
31
- * resolution logic.
32
- *
33
- * Semantics:
34
- * - `undefined` / `false` → `undefined` (no gating).
35
- * - `true` → `'serial'` (back-compat shorthand for the original `boolean` shape).
36
- * - `'serial'` → `'serial'` (explicit, equivalent to `true`).
37
- * - `'batch'` → `'batch'`.
38
- *
39
- * @deprecated Superseded by per-tool policy on {@link AgentConfig.toolPolicies}
40
- * (resolved by `resolveToolApprovalPolicy`) plus {@link StreamOptions.batchApprovals}
41
- * for the UX axis. Kept functional for one release so harness PRs can migrate
42
- * independently; removed in a future major.
43
- */
44
- export function resolveToolApprovalMode(requireToolApproval) {
45
- if (requireToolApproval === undefined || requireToolApproval === false)
46
- return undefined;
47
- if (requireToolApproval === true)
48
- return 'serial';
49
- if (requireToolApproval === 'serial' || requireToolApproval === 'batch')
50
- return requireToolApproval;
51
- // Defensive: an `as any` consumer could pass an unknown string. Without
52
- // this guard the value flows through to harness checks, which then
53
- // silently degrade to "approval gating on but no broker allocated" and
54
- // the chat hangs without an error a consumer can debug.
55
- throw new Error(`Invalid requireToolApproval value: ${JSON.stringify(requireToolApproval)}. Expected boolean, 'serial', or 'batch'.`);
56
- }
57
27
  /**
58
28
  * Default maximum steps for a single agent stream invocation.
59
29
  *
@@ -37,10 +37,9 @@
37
37
  * counterparts live only here.
38
38
  *
39
39
  * Symbols that consumers and harnesses both need (`AgentConfig`,
40
- * `StreamOptions`, `DEFAULT_MAX_STEPS`, `resolveToolApprovalMode`,
41
- * `ChatEvent` types, `Message` types, `MCPConfiguration`, etc.) stay on
42
- * the bare specifier. The split is "harness-only" vs. "consumer-AND-harness",
43
- * not "harness vs. consumer."
40
+ * `StreamOptions`, `DEFAULT_MAX_STEPS`, `ChatEvent` types, `Message`
41
+ * types, `MCPConfiguration`, etc.) stay on the bare specifier. The split
42
+ * is "harness-only" vs. "consumer-AND-harness", not "harness vs. consumer."
44
43
  */
45
44
  export type { AgentHarness, HarnessFactory, WithAgentConfig, ConfigOf } from './index.js';
46
45
  export type { AgentHooks } from '../types/redaction.js';
package/dist/index.d.ts CHANGED
@@ -5,12 +5,12 @@ export { BUILT_IN_TOOL_POLICIES, SKILL_BRIDGE_SERVER_ID, definePolicy, matcherMa
5
5
  export type { ResolverResult, ResolverTiers, ToolInvocation } from './policy-resolver.js';
6
6
  export type { ContextUsage, FinishReason, UsageMetadata } from './types/usage.js';
7
7
  export type { AgentHooks, HooksForAgent, ToolResultRedactor, ToolResultRedactionInput, ToolResultRedactionResult, } from './types/redaction.js';
8
- export type { AgentConfig, HarnessAgentConfig, StreamOptions, ToolApprovalMode } from './harness/harness-config.js';
9
- export { DEFAULT_MAX_STEPS, resolveToolApprovalMode } from './harness/harness-config.js';
8
+ export type { AgentConfig, HarnessAgentConfig, StreamOptions } from './harness/harness-config.js';
9
+ export { DEFAULT_MAX_STEPS } from './harness/harness-config.js';
10
10
  export type { MCPConfiguration, MCPServerConfig, MCPStdioServerConfig, MCPRemoteServerConfig, McpServerInfo, McpServerErrorCategory, McpServerErrorDetail, McpToolInfo, McpToolAnnotations, } from './mcp-config.js';
11
11
  export { McpServerStatus, mcpServerConfigEqual } from './mcp-config.js';
12
12
  export { Model, ModelName, createClaudeModel, Models, validateMultimodalFiles } from './models/index.js';
13
- export type { ClaudeModelOverrides, MultimodalFile, SupportedFileFormat } from './models/index.js';
13
+ export type { ClaudeModelOverrides, MultimodalFile, SupportedFileFormat, ThinkingMode } from './models/index.js';
14
14
  export { MimeType } from './models/index.js';
15
15
  export { inferSfApiEnv, SfApiEnv } from '@salesforce/agentic-common';
16
16
  export { type AgentManager, type RestoreFailure, createAgentManager } from './agent-manager.js';
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@
8
8
  // `resolveToolApprovalPolicy` into their gate sites (Phase 2); consumers author
9
9
  // `AgentConfig.toolPolicies` (directly or via `definePolicy`).
10
10
  export { BUILT_IN_TOOL_POLICIES, SKILL_BRIDGE_SERVER_ID, definePolicy, matcherMatches, resolveToolApprovalPolicy, } from './policy-resolver.js';
11
- export { DEFAULT_MAX_STEPS, resolveToolApprovalMode } from './harness/harness-config.js';
11
+ export { DEFAULT_MAX_STEPS } from './harness/harness-config.js';
12
12
  export { McpServerStatus, mcpServerConfigEqual } from './mcp-config.js';
13
13
  export { Model, ModelName, createClaudeModel, Models, validateMultimodalFiles } from './models/index.js';
14
14
  export { MimeType } from './models/index.js';
@@ -1,4 +1,4 @@
1
- import { Model, ModelName } from './model.js';
1
+ import { Model, ModelName, type ThinkingMode } from './model.js';
2
2
  import { type SupportedFileFormat } from './types.js';
3
3
  export declare class ClaudeOpus45 extends Model {
4
4
  readonly name: ModelName;
@@ -7,5 +7,6 @@ export declare class ClaudeOpus45 extends Model {
7
7
  readonly maxOutputTokens: number;
8
8
  readonly contextWindow: number;
9
9
  readonly supportsPromptCache: boolean;
10
+ readonly thinkingMode: ThinkingMode;
10
11
  readonly supportedFormats: readonly SupportedFileFormat[];
11
12
  }
@@ -12,6 +12,10 @@ export class ClaudeOpus45 extends Model {
12
12
  maxOutputTokens = 64000;
13
13
  contextWindow = 200000;
14
14
  supportsPromptCache = true;
15
+ // The Bedrock 4.5 backend accepts only the legacy `thinking.type: "enabled"`
16
+ // shape and rejects `"adaptive"` (which arrives with 4.6+). Verified on the
17
+ // wire; see the harness thinking-mode probe.
18
+ thinkingMode = 'enabled';
15
19
  supportedFormats = [
16
20
  { name: 'png', mimeType: MimeType.Png, maxBytesPerFile: 3.75 * 1024 * 1024 },
17
21
  { name: 'jpeg', mimeType: MimeType.Jpeg, maxBytesPerFile: 3.75 * 1024 * 1024 },
@@ -1,4 +1,4 @@
1
- import { Model, ModelName } from './model.js';
1
+ import { Model, ModelName, type ThinkingMode } from './model.js';
2
2
  import { type SupportedFileFormat } from './types.js';
3
3
  export declare class ClaudeOpus46 extends Model {
4
4
  readonly name: ModelName;
@@ -7,5 +7,6 @@ export declare class ClaudeOpus46 extends Model {
7
7
  readonly maxOutputTokens: number;
8
8
  readonly contextWindow: number;
9
9
  readonly supportsPromptCache: boolean;
10
+ readonly thinkingMode: ThinkingMode;
10
11
  readonly supportedFormats: readonly SupportedFileFormat[];
11
12
  }
@@ -13,6 +13,10 @@ export class ClaudeOpus46 extends Model {
13
13
  maxOutputTokens = 128_000;
14
14
  contextWindow = 1_000_000;
15
15
  supportsPromptCache = true;
16
+ // The Bedrock 4.6+ backend requires the `thinking.type: "adaptive"` shape and
17
+ // rejects the legacy `"enabled"`. Verified on the wire; see the harness
18
+ // thinking-mode probe.
19
+ thinkingMode = 'adaptive';
16
20
  supportedFormats = [
17
21
  { name: 'png', mimeType: MimeType.Png, maxBytesPerFile: 3.75 * 1024 * 1024 },
18
22
  { name: 'jpeg', mimeType: MimeType.Jpeg, maxBytesPerFile: 3.75 * 1024 * 1024 },