@salesforce/sfdx-agent-harness-mastra 0.46.0 → 0.48.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.48.0] - 2026-08-14
7
+
8
+ _No changes — released alongside dependent packages._
9
+
10
+ ## [0.47.0] - 2026-08-10
11
+
12
+ ### Fixes
13
+ - **harness-mastra**: classify stream truncations @W-23801521 ([#746](https://github.com/forcedotcom/agentic-dx/pull/746))
14
+
6
15
  ## [0.46.0] - 2026-08-10
7
16
 
8
17
  ### Fixes
@@ -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 { isNetworkStreamError } from './stream-errors.js';
5
6
  /**
6
7
  * Adapts Mastra `ChunkType` stream events to our {@link ChatEvent} discriminated union.
7
8
  *
@@ -146,6 +147,7 @@ export class MastraEventAdapter {
146
147
  return {
147
148
  type: 'error',
148
149
  error: rawError instanceof Error ? rawError : new Error(String(rawError)),
150
+ ...(isNetworkStreamError(rawError) ? { code: rawError.code } : {}),
149
151
  };
150
152
  }
151
153
  case 'tripwire':
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { AnthropicBedrock } from '@anthropic-ai/bedrock-sdk';
6
6
  import Anthropic from '@anthropic-ai/sdk';
7
+ import { NetworkStreamError, isStreamTransportError } from './stream-errors.js';
7
8
  import { TextSpanLifecycle, createGatewayFetch, isEmptyUsage, isParameterExcluded, mapAnthropicFinishReason, mapAnthropicUsage, normalizeToolArgsString, toolResultOutputToString, } from './v3-stream-mapping.js';
8
9
  /**
9
10
  * Builds the in-process `LanguageModelV3` impl for the Salesforce LLM Gateway's
@@ -310,7 +311,10 @@ async function doStream(ctx, options) {
310
311
  controller.close();
311
312
  return;
312
313
  }
313
- controller.enqueue({ type: 'error', error });
314
+ controller.enqueue({
315
+ type: 'error',
316
+ error: isStreamTransportError(error) ? new NetworkStreamError(error) : error,
317
+ });
314
318
  controller.close();
315
319
  }
316
320
  },
@@ -0,0 +1,8 @@
1
+ export declare const NETWORK_ERROR_CODE: 'network-error';
2
+ export declare class NetworkStreamError extends Error {
3
+ readonly name = "NetworkStreamError";
4
+ readonly code: "network-error";
5
+ constructor(cause: Error);
6
+ }
7
+ export declare function isStreamTransportError(error: unknown): error is Error;
8
+ export declare function isNetworkStreamError(error: unknown): error is NetworkStreamError;
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc. All rights reserved.
3
+ * See LICENSE.txt for license terms.
4
+ */
5
+ export const NETWORK_ERROR_CODE = 'network-error';
6
+ export class NetworkStreamError extends Error {
7
+ name = 'NetworkStreamError';
8
+ code = NETWORK_ERROR_CODE;
9
+ constructor(cause) {
10
+ super(cause.message, { cause });
11
+ }
12
+ }
13
+ export function isStreamTransportError(error) {
14
+ const seen = new Set();
15
+ let current = error;
16
+ while (current instanceof Error && !seen.has(current)) {
17
+ seen.add(current);
18
+ if ('code' in current && current.code === 'UND_ERR_SOCKET')
19
+ return true;
20
+ const message = current.message.toLowerCase().replace(/[.!]$/, '');
21
+ if (message === 'terminated' ||
22
+ message === 'other side closed' ||
23
+ message === 'truncated event message received') {
24
+ return true;
25
+ }
26
+ current = current.cause;
27
+ }
28
+ return false;
29
+ }
30
+ export function isNetworkStreamError(error) {
31
+ return error instanceof NetworkStreamError;
32
+ }
33
+ //# sourceMappingURL=stream-errors.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sfdx-agent-harness-mastra",
3
- "version": "0.46.0",
3
+ "version": "0.48.0",
4
4
  "description": "Mastra-backed AgentHarness implementation for @salesforce/sfdx-agent-sdk",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -42,12 +42,12 @@
42
42
  "openai": "^7.0.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@salesforce/sfdx-agent-sdk": "0.47.0"
45
+ "@salesforce/sfdx-agent-sdk": "0.49.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.47.0",
50
+ "@salesforce/sfdx-agent-sdk": "0.49.0",
51
51
  "@types/node": "^22.20.1",
52
52
  "@vitest/coverage-istanbul": "^4.1.10",
53
53
  "@vitest/eslint-plugin": "^1.6.26",