@salesforce/sfdx-agent-harness-mastra 0.93.0 → 0.95.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 CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to `@salesforce/sfdx-agent-harness-mastra` are documented in this file.
4
4
  Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
+ ## [0.95.0] - 2026-10-02
7
+
8
+ _No changes — released alongside dependent packages._
9
+
10
+ ## [0.94.0] - 2026-10-01
11
+
12
+ ### Fixes
13
+ - **harness-mastra**: persist declined tool-call reason from approval.reason @W-24066893@ ([#850](https://github.com/forcedotcom/agentic-dx/pull/850))
14
+
6
15
  ## [0.93.0] - 2026-09-29
7
16
 
8
17
  ### Features
@@ -2,6 +2,7 @@
2
2
  * Copyright 2026, Salesforce, Inc. All rights reserved.
3
3
  * See LICENSE.txt for license terms.
4
4
  */
5
+ import { DEFAULT_TOOL_DECLINE_REASON } from '@mastra/core/agent';
5
6
  import { CONTEXT_LENGTH_EXCEEDED_CODE, createContextLengthExceededError } from '@salesforce/sfdx-agent-sdk';
6
7
  import { hasToolArgsValidationErrorMarker } from './tool-args-marker.js';
7
8
  import { isClassifiedStreamError } from './stream-errors.js';
@@ -140,7 +141,7 @@ export class MastraEventAdapter {
140
141
  type: 'tool-result',
141
142
  toolCallId: chunk.payload.toolCallId,
142
143
  toolName: chunk.payload.toolName,
143
- result: chunk.payload.approval.reason ?? 'Tool call was not approved by the user',
144
+ result: chunk.payload.approval.reason ?? DEFAULT_TOOL_DECLINE_REASON,
144
145
  isError: true,
145
146
  };
146
147
  case 'step-start':
@@ -1,4 +1,4 @@
1
- import type { MastraDBMessage, MastraMessagePart } from '@mastra/core/agent';
1
+ import { type MastraDBMessage, type MastraMessagePart } from '@mastra/core/agent';
2
2
  import type { Message, MessagePart } from '@salesforce/sfdx-agent-sdk';
3
3
  import type { LogBus } from '@salesforce/agentic-common';
4
4
  /**
@@ -2,6 +2,7 @@
2
2
  * Copyright 2026, Salesforce, Inc. All rights reserved.
3
3
  * See LICENSE.txt for license terms.
4
4
  */
5
+ import { DEFAULT_TOOL_DECLINE_REASON } from '@mastra/core/agent';
5
6
  import { hasToolArgsValidationErrorMarker } from './tool-args-marker.js';
6
7
  /**
7
8
  * Reads the SDK `fileName` stashed under `providerMetadata.salesforce.fileName` when a file part
@@ -188,14 +189,24 @@ export function mapMastraPartToMessagePart(part, logBus) {
188
189
  // Prefer the structured `result` (the write path preserves it
189
190
  // alongside `errorText`) so a non-string error payload round-trips
190
191
  // as an object, not a JSON string; fall back to `errorText` for
191
- // natively-persisted error invocations that carry only that.
192
+ // natively-persisted error invocations that carry only that. A
193
+ // decline persists as `output-denied` carrying its reason on
194
+ // `approval.reason` (no `result`/`errorText`), so read that last —
195
+ // otherwise the declined call's message is lost on reload. A
196
+ // compatible persisted record can omit the optional reason;
197
+ // use Mastra's default denial text as the final fallback for that
198
+ // state so history never reloads an empty decline.
192
199
  return [
193
200
  toolCall,
194
201
  {
195
202
  type: 'tool-result',
196
203
  toolCallId: inv.toolCallId,
197
204
  toolName: inv.toolName,
198
- result: inv.result ?? inv.errorText,
205
+ result: inv.result ??
206
+ inv.errorText ??
207
+ (inv.state === 'output-denied'
208
+ ? (inv.approval?.reason ?? DEFAULT_TOOL_DECLINE_REASON)
209
+ : undefined),
199
210
  isError: true,
200
211
  },
201
212
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sfdx-agent-harness-mastra",
3
- "version": "0.93.0",
3
+ "version": "0.95.0",
4
4
  "description": "Mastra-backed AgentHarness implementation for @salesforce/sfdx-agent-sdk",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -37,17 +37,17 @@
37
37
  "@mastra/mcp": "^1.18.0",
38
38
  "@mastra/memory": "^1.30.0",
39
39
  "@mastra/schema-compat": "^1.3.10",
40
- "@salesforce/agentic-common": "0.22.0",
40
+ "@salesforce/agentic-common": "0.23.0",
41
41
  "@smithy/eventstream-codec": "^4.5.2",
42
42
  "openai": "^7.23.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@salesforce/sfdx-agent-sdk": "0.94.0"
45
+ "@salesforce/sfdx-agent-sdk": "0.96.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@eslint/js": "^10.0.1",
49
49
  "@salesforce/harness-conformance": "0.0.1",
50
- "@salesforce/sfdx-agent-sdk": "0.94.0",
50
+ "@salesforce/sfdx-agent-sdk": "0.96.0",
51
51
  "@types/node": "^22.20.1",
52
52
  "@vitest/coverage-istanbul": "^5.0.1",
53
53
  "@vitest/eslint-plugin": "^1.6.27",