@salesforce/sfdx-agent-sdk 0.59.0 → 0.61.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/README.md +17 -1
- package/dist/chat-session.d.ts +18 -14
- package/dist/chat-session.js +32 -17
- package/dist/harness/agent-harness.d.ts +3 -2
- package/dist/harness/public.d.ts +1 -0
- package/dist/harness/public.js +1 -0
- package/dist/harness/tool-decline.d.ts +3 -0
- package/dist/harness/tool-decline.js +13 -0
- package/dist/index.d.ts +1 -1
- package/dist/types/tools.d.ts +13 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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.61.0] - 2026-09-01
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
- **agent-sdk**: add policy-aware tool declines @W-24048333@ ([#776](https://github.com/forcedotcom/agentic-dx/pull/776))
|
|
10
|
+
|
|
11
|
+
### Chores
|
|
12
|
+
- **deps-dev**: bump typescript-eslint from 8.67.0 to 8.68.0 in the dev-dependencies group across 1 directory ([#777](https://github.com/forcedotcom/agentic-dx/pull/777))
|
|
13
|
+
- **deps-dev**: bump eslint from 10.8.1 to 10.9.1 in the eslint group ([#778](https://github.com/forcedotcom/agentic-dx/pull/778))
|
|
14
|
+
|
|
15
|
+
## [0.60.0] - 2026-08-28
|
|
16
|
+
|
|
17
|
+
### Tests
|
|
18
|
+
- **agent-sdk**: make connectivity-headers multi-step e2e deterministic via #529 held-iterator pattern @W-23930393@ ([#771](https://github.com/forcedotcom/agentic-dx/pull/771))
|
|
19
|
+
|
|
6
20
|
## [0.59.0] - 2026-08-28
|
|
7
21
|
|
|
8
22
|
_No changes — released alongside dependent packages._
|
package/README.md
CHANGED
|
@@ -168,7 +168,7 @@ A single conversation thread.
|
|
|
168
168
|
| `chat` | `(message: string, options?: ChatOptions) => Promise<ChatStreamResult>` | Send a message and stream the response. The returned `eventStream` is the single iterator for the entire chat turn. |
|
|
169
169
|
| `submitToolResult` | `(toolResult: ToolResultInfo) => Promise<void>` | Return a consumer-executed tool result. Control message on the existing turn — post-resume events flow on the same stream. |
|
|
170
170
|
| `approveToolCall` | `(toolCallId: string, options?: { remember?: boolean }) => Promise<void>` | Approve a pending tool call. `{ remember: true }` ("Allow always") appends an `allow` rule to `AgentConfig.toolPolicies` and persists it before settling. Control message on the existing turn. |
|
|
171
|
-
| `declineToolCall` | `(toolCallId: string, options?:
|
|
171
|
+
| `declineToolCall` | `(toolCallId: string, options?: DeclineToolCallOptions) => Promise<void>` | Decline a pending tool call. `{ remember: true }` ("Deny always") appends a `deny` rule and persists it before settling. `{ reason: { kind: 'organization-policy', modelMessage? } }` delivers a terminal policy explanation to the model and error result without persisting a remembered user rule. Control message on the existing turn. |
|
|
172
172
|
| `getMessageHistory` | `() => Promise<Message[]>` | Retrieve all messages in chronological order. |
|
|
173
173
|
| `clearHistory` | `() => Promise<void>` | Delete all messages. |
|
|
174
174
|
| `getContextUsage` | `() => ContextUsage` | Snapshot of how much of the model's context window the most recent turn used. |
|
|
@@ -377,6 +377,14 @@ With `{ remember: true }` the SDK derives the matcher from the pending `tool-app
|
|
|
377
377
|
restart and a persistence failure surfaces as the settle's rejection. A `remember` settle for a `toolCallId` with no
|
|
378
378
|
pending approval throws `TOOL_CALL_NOT_FOUND`.
|
|
379
379
|
|
|
380
|
+
**Organization-policy decline.** A host enforcing policy can call
|
|
381
|
+
`declineToolCall(id, { reason: { kind: 'organization-policy', modelMessage? } })`. A nonblank custom message is trimmed
|
|
382
|
+
and followed by a blank line plus the invariant “This block is enforced by organization policy, not by the user. Do not
|
|
383
|
+
retry this tool call or attempt the same action using another tool or command.” Blank or omitted custom text uses the
|
|
384
|
+
invariant alone. The exact resolved message reaches both the model and the single terminal `tool-result(isError=true)`.
|
|
385
|
+
It is never written to telemetry/log fields and never creates a remembered deny rule; untyped JavaScript that also
|
|
386
|
+
supplies `remember: true` still follows those safety rules.
|
|
387
|
+
|
|
380
388
|
#### `MCPConfiguration`
|
|
381
389
|
|
|
382
390
|
```typescript
|
|
@@ -565,6 +573,14 @@ type ToolResultInfo = {
|
|
|
565
573
|
/** Present when isError is true. Best-effort: error.stack is not guaranteed to point at the tool's throw site. */
|
|
566
574
|
error?: Error;
|
|
567
575
|
};
|
|
576
|
+
|
|
577
|
+
type ToolDeclineReason = {
|
|
578
|
+
kind: 'organization-policy';
|
|
579
|
+
modelMessage?: string;
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
type DeclineToolCallOptions =
|
|
583
|
+
{ remember?: boolean; reason?: undefined } | { remember?: false; reason: ToolDeclineReason };
|
|
568
584
|
```
|
|
569
585
|
|
|
570
586
|
### Message Types
|
package/dist/chat-session.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { ChatEvent, ChatStreamResult } from './types/events.js';
|
|
|
6
6
|
import type { Message, MessagePart } from './types/messages.js';
|
|
7
7
|
import type { SessionContext } from './types/session-context.js';
|
|
8
8
|
import { type TelemetryBus, type TelemetryEventCallback } from './types/telemetry-events.js';
|
|
9
|
-
import type { ToolPolicyRule, ToolResultInfo } from './types/tools.js';
|
|
9
|
+
import type { DeclineToolCallOptions, ToolPolicyRule, ToolResultInfo } from './types/tools.js';
|
|
10
10
|
import type { ContextUsage } from './types/usage.js';
|
|
11
11
|
/**
|
|
12
12
|
* Options for a single chat interaction.
|
|
@@ -160,10 +160,10 @@ export interface ChatSession {
|
|
|
160
160
|
* `updateAgentConfig` **before** settling the decline. Symmetric with
|
|
161
161
|
* {@link approveToolCall}'s `remember`. Throws `TOOL_CALL_NOT_FOUND` if
|
|
162
162
|
* `toolCallId` does not match a pending `tool-approval-request`.
|
|
163
|
+
* @param options.reason - Optional organization-policy reason delivered to the model and
|
|
164
|
+
* terminal error result. Policy reasons require `remember: false` and are never persisted.
|
|
163
165
|
*/
|
|
164
|
-
declineToolCall(toolCallId: string, options?:
|
|
165
|
-
remember?: boolean;
|
|
166
|
-
}): Promise<void>;
|
|
166
|
+
declineToolCall(toolCallId: string, options?: DeclineToolCallOptions): Promise<void>;
|
|
167
167
|
/**
|
|
168
168
|
* Retrieve message history for this session.
|
|
169
169
|
*
|
|
@@ -274,16 +274,18 @@ export declare class DefaultChatSession implements ChatSession {
|
|
|
274
274
|
private readonly clock;
|
|
275
275
|
private readonly idGenerator;
|
|
276
276
|
/**
|
|
277
|
-
* Tracks
|
|
278
|
-
*
|
|
277
|
+
* Tracks observability state for every in-flight `tool-call` keyed by `toolCallId`.
|
|
278
|
+
* The start timestamp drives `tool-execution-completed.durationMs`; an optional
|
|
279
|
+
* exact policy-message set lets the same derivation omit only that text from telemetry.
|
|
279
280
|
*
|
|
280
281
|
* Lifetime is per-session (not per-stream) so a `tool-call` on the initial chat stream
|
|
281
282
|
* pairs with a `tool-result` on the approval-continuation / submit-tool-result
|
|
282
283
|
* continuation stream — those are continuations of the same logical chat turn. Cleared
|
|
283
284
|
* on every terminal `finish` ChatEvent (the turn closed cleanly; any unmatched entries
|
|
284
|
-
* are stale and should not bleed into the next turn).
|
|
285
|
+
* are stale and should not bleed into the next turn). Attempted policy messages remain
|
|
286
|
+
* until result/turn cleanup because another concurrent settle for the same id may succeed.
|
|
285
287
|
*/
|
|
286
|
-
private readonly
|
|
288
|
+
private readonly toolExecutionsByToolCallId;
|
|
287
289
|
/**
|
|
288
290
|
* Tracks the `(toolName, serverName?)` of every tool call currently awaiting
|
|
289
291
|
* approval, keyed by `toolCallId`. Populated when a `tool-approval-request`
|
|
@@ -412,10 +414,12 @@ export declare class DefaultChatSession implements ChatSession {
|
|
|
412
414
|
* before returning a stream result.
|
|
413
415
|
* - WHEN `options.remember` is `true`, MUST append a `'deny'` `'remember'` rule and persist it
|
|
414
416
|
* BEFORE delegating the settle to the harness — symmetric with {@link approveToolCall}.
|
|
417
|
+
* - WHEN `options.reason` is present, MUST forward it without persisting a remembered rule,
|
|
418
|
+
* including when untyped JavaScript also supplies `remember: true`.
|
|
419
|
+
* - A resolved organization-policy message MUST stay on the public tool result but be omitted
|
|
420
|
+
* from derived telemetry and logs without suppressing unrelated tool diagnostics.
|
|
415
421
|
*/
|
|
416
|
-
declineToolCall(toolCallId: string, options?:
|
|
417
|
-
remember?: boolean;
|
|
418
|
-
}): Promise<void>;
|
|
422
|
+
declineToolCall(toolCallId: string, options?: DeclineToolCallOptions): Promise<void>;
|
|
419
423
|
/**
|
|
420
424
|
* @requirements
|
|
421
425
|
* - MUST delegate to `this.harness.getMessages()`, passing `this.agentId` and `this.threadId`.
|
|
@@ -489,8 +493,8 @@ export declare class DefaultChatSession implements ChatSession {
|
|
|
489
493
|
private emitToolApprovalResolved;
|
|
490
494
|
/**
|
|
491
495
|
* Clears the per-turn tracking maps at a terminal `finish`. Both maps are
|
|
492
|
-
* scoped to one logical chat turn: `
|
|
493
|
-
* `tool-
|
|
496
|
+
* scoped to one logical chat turn: `toolExecutionsByToolCallId` pairs a
|
|
497
|
+
* `tool-call` with its result for duration and policy-message redaction, and
|
|
494
498
|
* `pendingApprovalsByToolCallId` lets a `remember` settle build the right
|
|
495
499
|
* matcher. A stale entry surviving into the next turn would mispair a
|
|
496
500
|
* duration or remember the wrong tool, so the two clears must always fire
|
|
@@ -503,7 +507,7 @@ export declare class DefaultChatSession implements ChatSession {
|
|
|
503
507
|
* implementation free of telemetry plumbing — they just yield the right `ChatEvent` shapes.
|
|
504
508
|
*
|
|
505
509
|
* `tool-execution-completed.durationMs` is measured between the matching `tool-call` and
|
|
506
|
-
* `tool-result` using `this.clock`. The tracking map (`this.
|
|
510
|
+
* `tool-result` using `this.clock`. The tracking map (`this.toolExecutionsByToolCallId`) lives on the
|
|
507
511
|
* session, so a `tool-call` on the initial stream pairs with a `tool-result` on the
|
|
508
512
|
* approval-continuation / submit-tool-result continuation stream — those are continuations
|
|
509
513
|
* of the same logical chat turn. The map is cleared on every terminal `finish` ChatEvent
|
package/dist/chat-session.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* See LICENSE.txt for license terms.
|
|
4
4
|
*/
|
|
5
5
|
import { backfillCreatedAt, EventBus, LogBus, RealClock, UUIDGenerator, } from '@salesforce/agentic-common';
|
|
6
|
+
import { resolveToolDeclineModelMessage } from './harness/tool-decline.js';
|
|
6
7
|
import { AgentSDKError, AgentSDKErrorType } from './errors.js';
|
|
7
8
|
import { createTelemetryBus, } from './types/telemetry-events.js';
|
|
8
9
|
/**
|
|
@@ -24,16 +25,18 @@ export class DefaultChatSession {
|
|
|
24
25
|
clock;
|
|
25
26
|
idGenerator;
|
|
26
27
|
/**
|
|
27
|
-
* Tracks
|
|
28
|
-
*
|
|
28
|
+
* Tracks observability state for every in-flight `tool-call` keyed by `toolCallId`.
|
|
29
|
+
* The start timestamp drives `tool-execution-completed.durationMs`; an optional
|
|
30
|
+
* exact policy-message set lets the same derivation omit only that text from telemetry.
|
|
29
31
|
*
|
|
30
32
|
* Lifetime is per-session (not per-stream) so a `tool-call` on the initial chat stream
|
|
31
33
|
* pairs with a `tool-result` on the approval-continuation / submit-tool-result
|
|
32
34
|
* continuation stream — those are continuations of the same logical chat turn. Cleared
|
|
33
35
|
* on every terminal `finish` ChatEvent (the turn closed cleanly; any unmatched entries
|
|
34
|
-
* are stale and should not bleed into the next turn).
|
|
36
|
+
* are stale and should not bleed into the next turn). Attempted policy messages remain
|
|
37
|
+
* until result/turn cleanup because another concurrent settle for the same id may succeed.
|
|
35
38
|
*/
|
|
36
|
-
|
|
39
|
+
toolExecutionsByToolCallId = new Map();
|
|
37
40
|
/**
|
|
38
41
|
* Tracks the `(toolName, serverName?)` of every tool call currently awaiting
|
|
39
42
|
* approval, keyed by `toolCallId`. Populated when a `tool-approval-request`
|
|
@@ -319,13 +322,22 @@ export class DefaultChatSession {
|
|
|
319
322
|
* before returning a stream result.
|
|
320
323
|
* - WHEN `options.remember` is `true`, MUST append a `'deny'` `'remember'` rule and persist it
|
|
321
324
|
* BEFORE delegating the settle to the harness — symmetric with {@link approveToolCall}.
|
|
325
|
+
* - WHEN `options.reason` is present, MUST forward it without persisting a remembered rule,
|
|
326
|
+
* including when untyped JavaScript also supplies `remember: true`.
|
|
327
|
+
* - A resolved organization-policy message MUST stay on the public tool result but be omitted
|
|
328
|
+
* from derived telemetry and logs without suppressing unrelated tool diagnostics.
|
|
322
329
|
*/
|
|
323
330
|
async declineToolCall(toolCallId, options) {
|
|
324
331
|
this.assertNotDisposed();
|
|
325
332
|
// issue #529 contract change: see `submitToolResult` for the rationale.
|
|
326
|
-
const
|
|
333
|
+
const reason = options?.reason;
|
|
334
|
+
const policyWritten = await this.maybePersistRememberedRule(toolCallId, 'deny', reason === undefined && options?.remember === true);
|
|
335
|
+
const trackedExecution = this.toolExecutionsByToolCallId.get(toolCallId);
|
|
336
|
+
if (reason !== undefined && trackedExecution !== undefined) {
|
|
337
|
+
(trackedExecution.policyMessages ??= new Set()).add(resolveToolDeclineModelMessage(reason));
|
|
338
|
+
}
|
|
327
339
|
try {
|
|
328
|
-
await this.harness.declineToolCall(this.agentId, this.threadId, toolCallId);
|
|
340
|
+
await this.harness.declineToolCall(this.agentId, this.threadId, toolCallId, reason);
|
|
329
341
|
}
|
|
330
342
|
catch (err) {
|
|
331
343
|
this.notifySettleRejection(err);
|
|
@@ -503,15 +515,15 @@ export class DefaultChatSession {
|
|
|
503
515
|
}
|
|
504
516
|
/**
|
|
505
517
|
* Clears the per-turn tracking maps at a terminal `finish`. Both maps are
|
|
506
|
-
* scoped to one logical chat turn: `
|
|
507
|
-
* `tool-
|
|
518
|
+
* scoped to one logical chat turn: `toolExecutionsByToolCallId` pairs a
|
|
519
|
+
* `tool-call` with its result for duration and policy-message redaction, and
|
|
508
520
|
* `pendingApprovalsByToolCallId` lets a `remember` settle build the right
|
|
509
521
|
* matcher. A stale entry surviving into the next turn would mispair a
|
|
510
522
|
* duration or remember the wrong tool, so the two clears must always fire
|
|
511
523
|
* together — hence one helper rather than two call sites.
|
|
512
524
|
*/
|
|
513
525
|
clearPerTurnTracking() {
|
|
514
|
-
this.
|
|
526
|
+
this.toolExecutionsByToolCallId.clear();
|
|
515
527
|
this.pendingApprovalsByToolCallId.clear();
|
|
516
528
|
}
|
|
517
529
|
/**
|
|
@@ -520,7 +532,7 @@ export class DefaultChatSession {
|
|
|
520
532
|
* implementation free of telemetry plumbing — they just yield the right `ChatEvent` shapes.
|
|
521
533
|
*
|
|
522
534
|
* `tool-execution-completed.durationMs` is measured between the matching `tool-call` and
|
|
523
|
-
* `tool-result` using `this.clock`. The tracking map (`this.
|
|
535
|
+
* `tool-result` using `this.clock`. The tracking map (`this.toolExecutionsByToolCallId`) lives on the
|
|
524
536
|
* session, so a `tool-call` on the initial stream pairs with a `tool-result` on the
|
|
525
537
|
* approval-continuation / submit-tool-result continuation stream — those are continuations
|
|
526
538
|
* of the same logical chat turn. The map is cleared on every terminal `finish` ChatEvent
|
|
@@ -530,7 +542,7 @@ export class DefaultChatSession {
|
|
|
530
542
|
*/
|
|
531
543
|
deriveToolTelemetry(event) {
|
|
532
544
|
if (event.type === 'tool-call') {
|
|
533
|
-
this.
|
|
545
|
+
this.toolExecutionsByToolCallId.set(event.toolCallId, { startedAtMs: this.clock.now().getTime() });
|
|
534
546
|
// No Tier-1 logBus sibling: tool-execution-started pairs 1:1 with
|
|
535
547
|
// tool-execution-completed; the completion (isError=true) is the triage signal
|
|
536
548
|
this.telemetryBus.emitTelemetry({
|
|
@@ -544,13 +556,16 @@ export class DefaultChatSession {
|
|
|
544
556
|
});
|
|
545
557
|
}
|
|
546
558
|
else if (event.type === 'tool-result') {
|
|
547
|
-
const
|
|
548
|
-
if (
|
|
559
|
+
const trackedExecution = this.toolExecutionsByToolCallId.get(event.toolCallId);
|
|
560
|
+
if (trackedExecution === undefined)
|
|
549
561
|
return;
|
|
550
|
-
this.
|
|
562
|
+
this.toolExecutionsByToolCallId.delete(event.toolCallId);
|
|
551
563
|
const completedAt = this.clock.now();
|
|
552
|
-
const durationMs = completedAt.getTime() -
|
|
564
|
+
const durationMs = completedAt.getTime() - trackedExecution.startedAtMs;
|
|
553
565
|
const isError = event.isError === true;
|
|
566
|
+
const observableError = typeof event.result === 'string' && trackedExecution.policyMessages?.has(event.result) === true
|
|
567
|
+
? undefined
|
|
568
|
+
: event.error;
|
|
554
569
|
this.telemetryBus.emitTelemetry({
|
|
555
570
|
type: 'tool-execution-completed',
|
|
556
571
|
agentId: this.agentId,
|
|
@@ -559,7 +574,7 @@ export class DefaultChatSession {
|
|
|
559
574
|
toolName: event.toolName,
|
|
560
575
|
durationMs,
|
|
561
576
|
isError,
|
|
562
|
-
...(
|
|
577
|
+
...(observableError ? { error: observableError } : {}),
|
|
563
578
|
...(event.annotations ? { annotations: event.annotations } : {}),
|
|
564
579
|
...(event.serverName ? { serverName: event.serverName } : {}),
|
|
565
580
|
}, completedAt);
|
|
@@ -579,7 +594,7 @@ export class DefaultChatSession {
|
|
|
579
594
|
...(event.annotations ? { annotations: event.annotations } : {}),
|
|
580
595
|
...(event.serverName ? { serverName: event.serverName } : {}),
|
|
581
596
|
},
|
|
582
|
-
...(
|
|
597
|
+
...(observableError ? { error: observableError } : {}),
|
|
583
598
|
}, completedAt);
|
|
584
599
|
}
|
|
585
600
|
}
|
|
@@ -3,7 +3,7 @@ import type { McpServerInfo, McpAuthProviders } from '../mcp-config.js';
|
|
|
3
3
|
import type { ChatStreamResult } from '../types/events.js';
|
|
4
4
|
import type { Message, MessagePart } from '../types/messages.js';
|
|
5
5
|
import type { TelemetryEventCallback } from '../types/telemetry-events.js';
|
|
6
|
-
import type { ToolResultInfo } from '../types/tools.js';
|
|
6
|
+
import type { ToolDeclineReason, ToolResultInfo } from '../types/tools.js';
|
|
7
7
|
import type { AgentHooks } from '../types/redaction.js';
|
|
8
8
|
import type { WireCommunicationEventCallback } from '../types/wire-communication-event.js';
|
|
9
9
|
import type { AgentConfig, HarnessAgentConfig, StreamOptions } from './harness-config.js';
|
|
@@ -419,8 +419,9 @@ export interface AgentHarness {
|
|
|
419
419
|
* @param agentId - ID of the agent.
|
|
420
420
|
* @param threadId - ID of the conversation thread.
|
|
421
421
|
* @param toolCallId - ID of the tool call to decline.
|
|
422
|
+
* @param reason - Optional organization-policy reason to deliver to the model and terminal error result.
|
|
422
423
|
*/
|
|
423
|
-
declineToolCall(agentId: string, threadId: string, toolCallId: string): Promise<void>;
|
|
424
|
+
declineToolCall(agentId: string, threadId: string, toolCallId: string, reason?: ToolDeclineReason): Promise<void>;
|
|
424
425
|
/**
|
|
425
426
|
* Retrieve message history for a thread.
|
|
426
427
|
*
|
package/dist/harness/public.d.ts
CHANGED
|
@@ -51,3 +51,4 @@ export { lowerStreamInput, type InputMessagePart } from './stream-input.js';
|
|
|
51
51
|
export { GenSink } from './gen-sink.js';
|
|
52
52
|
export { matchesAlwaysActive, validateAlwaysActiveEntry, type AlwaysActiveEntry } from './always-active.js';
|
|
53
53
|
export { splitToolResultsIntoToolMessages, mergeToolResultsIntoAssistant } from './tool-message-normalizer.js';
|
|
54
|
+
export { resolveToolDeclineModelMessage } from './tool-decline.js';
|
package/dist/harness/public.js
CHANGED
|
@@ -10,4 +10,5 @@ export { lowerStreamInput } from './stream-input.js';
|
|
|
10
10
|
export { GenSink } from './gen-sink.js';
|
|
11
11
|
export { matchesAlwaysActive, validateAlwaysActiveEntry } from './always-active.js';
|
|
12
12
|
export { splitToolResultsIntoToolMessages, mergeToolResultsIntoAssistant } from './tool-message-normalizer.js';
|
|
13
|
+
export { resolveToolDeclineModelMessage } from './tool-decline.js';
|
|
13
14
|
//# sourceMappingURL=public.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc. All rights reserved.
|
|
3
|
+
* See LICENSE.txt for license terms.
|
|
4
|
+
*/
|
|
5
|
+
const ORGANIZATION_POLICY_DECLINE_INVARIANT = 'This block is enforced by organization policy, not by the user. Do not retry this tool call or attempt the same action using another tool or command.';
|
|
6
|
+
/** Resolves the terminal model-visible message for an organization-policy decline. */
|
|
7
|
+
export function resolveToolDeclineModelMessage(reason) {
|
|
8
|
+
const customMessage = reason.modelMessage?.trim();
|
|
9
|
+
return customMessage
|
|
10
|
+
? `${customMessage}\n\n${ORGANIZATION_POLICY_DECLINE_INVARIANT}`
|
|
11
|
+
: ORGANIZATION_POLICY_DECLINE_INVARIANT;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=tool-decline.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { Message, MessagePart, MessageRole, ImagePart, FilePart } from './types/messages.js';
|
|
2
2
|
export type { JsonValue, SessionContext } from './types/session-context.js';
|
|
3
3
|
export type { ChatEvent, StartEvent, TextDeltaEvent, ReasoningDeltaEvent, ToolCallEvent, ToolCallDeltaEvent, ToolApprovalRequestEvent, ToolResultEvent, ToolProgressEvent, StepStartEvent, StepFinishEvent, ErrorEvent, FinishEvent, ChatStreamResult, } from './types/events.js';
|
|
4
|
-
export type { Decision, ToolDefinition, ToolCallInfo, ToolMatcher, ToolPolicyRule, ToolResultInfo, } from './types/tools.js';
|
|
4
|
+
export type { DeclineToolCallOptions, Decision, ToolDeclineReason, ToolDefinition, ToolCallInfo, ToolMatcher, ToolPolicyRule, ToolResultInfo, } from './types/tools.js';
|
|
5
5
|
export { BUILT_IN_TOOL_POLICIES, SKILL_BRIDGE_SERVER_ID, definePolicy, matcherMatches, resolveToolApprovalPolicy, } from './policy-resolver.js';
|
|
6
6
|
export type { ResolverResult, ResolverTiers, ToolInvocation } from './policy-resolver.js';
|
|
7
7
|
export type { ContextUsage, FinishReason, UsageMetadata } from './types/usage.js';
|
package/dist/types/tools.d.ts
CHANGED
|
@@ -58,6 +58,19 @@ export type ToolDefinition = {
|
|
|
58
58
|
* `declineToolCall`.
|
|
59
59
|
*/
|
|
60
60
|
export type Decision = 'allow' | 'deny' | 'require-approval';
|
|
61
|
+
/** A model-visible explanation for a tool decline enforced outside the user approval flow. */
|
|
62
|
+
export type ToolDeclineReason = {
|
|
63
|
+
kind: 'organization-policy';
|
|
64
|
+
modelMessage?: string;
|
|
65
|
+
};
|
|
66
|
+
/** Options for declining a pending tool call. Policy declines cannot create remembered user rules. */
|
|
67
|
+
export type DeclineToolCallOptions = {
|
|
68
|
+
remember?: boolean;
|
|
69
|
+
reason?: undefined;
|
|
70
|
+
} | {
|
|
71
|
+
remember?: false;
|
|
72
|
+
reason: ToolDeclineReason;
|
|
73
|
+
};
|
|
61
74
|
/**
|
|
62
75
|
* Structured matcher selecting which tool invocations a {@link ToolPolicyRule}
|
|
63
76
|
* applies to.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/sfdx-agent-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.0",
|
|
4
4
|
"description": "Harness-agnostic agentic infrastructure for Salesforce developer experience tooling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@eslint/js": "^10.0.1",
|
|
50
|
-
"@salesforce/sfdx-agent-harness-claude": "0.
|
|
51
|
-
"@salesforce/sfdx-agent-harness-mastra": "0.
|
|
52
|
-
"@salesforce/sfdx-agent-harness-openai": "0.
|
|
50
|
+
"@salesforce/sfdx-agent-harness-claude": "0.57.0",
|
|
51
|
+
"@salesforce/sfdx-agent-harness-mastra": "0.60.0",
|
|
52
|
+
"@salesforce/sfdx-agent-harness-openai": "0.26.0",
|
|
53
53
|
"@types/node": "^22.20.1",
|
|
54
54
|
"@vitest/coverage-istanbul": "^4.1.10",
|
|
55
55
|
"@vitest/eslint-plugin": "^1.6.27",
|
|
56
|
-
"eslint": "^10.
|
|
56
|
+
"eslint": "^10.9.1",
|
|
57
57
|
"eslint-config-prettier": "^10.1.8",
|
|
58
58
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
59
59
|
"eslint-plugin-import": "^2.32.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"rimraf": "^6.1.3",
|
|
65
65
|
"tsx": "^4.23.12",
|
|
66
66
|
"typescript": "^7.0.2",
|
|
67
|
-
"typescript-eslint": "^8.
|
|
67
|
+
"typescript-eslint": "^8.68.0",
|
|
68
68
|
"vitest": "^4.1.8"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|