@salesforce/sfdx-agent-harness-mastra 0.86.0 → 0.88.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,16 @@
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.88.0] - 2026-09-18
7
+
8
+ ### Fixes
9
+ - defer previous-workspace destroy while a coordinator is parked so a remembered-approval resume doesn't crash @W-24233008@ ([#834](https://github.com/forcedotcom/agentic-dx/pull/834))
10
+
11
+ ## [0.87.0] - 2026-09-17
12
+
13
+ ### Chores
14
+ - **deps**: upgrade all dependencies to latest @W-24127072@ ([#831](https://github.com/forcedotcom/agentic-dx/pull/831))
15
+
6
16
  ## [0.86.0] - 2026-09-17
7
17
 
8
18
  ### Fixes
@@ -242,7 +242,10 @@ export class MastraApprovalCoordinator {
242
242
  });
243
243
  }
244
244
  onTeardown(callback) {
245
- if (this.aborted || this.disposed) {
245
+ // If already terminal, fire now: a callback added after teardown ran
246
+ // would land in an already-cleared set and never fire. `isSettled()`
247
+ // covers natural-finish/timeout/pump-error settles (no abort/dispose flag).
248
+ if (this.aborted || this.disposed || this.isSettled()) {
246
249
  queueMicrotask(callback);
247
250
  return;
248
251
  }
@@ -1257,8 +1257,45 @@ export class MastraHarness {
1257
1257
  state.toolSearchProcessor = toolSearchProcessor;
1258
1258
  state.skillSearchProcessor = skillSearchProcessor;
1259
1259
  state.hooks = options?.hooks ?? {};
1260
- previousSkillSearchProcessor?.dispose();
1261
- await previousWorkspace?.destroy().catch(() => undefined);
1260
+ // Defer tearing down the previous Agent's workspace (+ its skill-search
1261
+ // processor) until every coordinator still bound to that Agent settles;
1262
+ // do NOT destroy synchronously. A coordinator parked on a tool-approval
1263
+ // resumes against the old Agent and reads `workspace.skills` (in
1264
+ // resumeStream, and via the skill-search processor's getter) — if the
1265
+ // workspace is already destroyed, @mastra/core throws
1266
+ // WorkspaceNotReadyError. Common trigger: an "Allow always" approval,
1267
+ // whose rule-persist calls updateAgentConfig (→ this method) before the
1268
+ // approval settles.
1269
+ //
1270
+ // Two things must BOTH stay for this to be correct: the filter +
1271
+ // `onTeardown` registration run in one synchronous tick (so no
1272
+ // coordinator settles between them and is missed), and `onTeardown`'s
1273
+ // own `isSettled()` arm handles an already-settled coordinator. Bounded
1274
+ // because `destroyAgent()`/`shutdown()` force-dispose coordinators, so
1275
+ // the deferred teardown always eventually runs.
1276
+ const disposePreviousAgentResources = async () => {
1277
+ previousSkillSearchProcessor?.dispose();
1278
+ await previousWorkspace?.destroy();
1279
+ };
1280
+ const onTeardownFailed = (error) => {
1281
+ // Guarded: a deferred teardown can reject after shutdown() disposed
1282
+ // the buses; logging there must not become an unhandled rejection.
1283
+ try {
1284
+ this.buses.getLogBus()?.debug('Deferred previous-Agent resource teardown failed', { error });
1285
+ }
1286
+ catch {
1287
+ /* buses already disposed */
1288
+ }
1289
+ };
1290
+ const unsettledCoordinators = [...state.coordinators.values()].filter((c) => !c.isSettled());
1291
+ if (unsettledCoordinators.length === 0) {
1292
+ await disposePreviousAgentResources().catch(onTeardownFailed);
1293
+ }
1294
+ else {
1295
+ void Promise.all(unsettledCoordinators.map((c) => new Promise((resolve) => c.onTeardown(resolve))))
1296
+ .then(() => disposePreviousAgentResources())
1297
+ .catch(onTeardownFailed);
1298
+ }
1262
1299
  }
1263
1300
  catch (error) {
1264
1301
  // Phase 2 failed after Phase 1 mutated state.mcpServers. We don't
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sfdx-agent-harness-mastra",
3
- "version": "0.86.0",
3
+ "version": "0.88.0",
4
4
  "description": "Mastra-backed AgentHarness implementation for @salesforce/sfdx-agent-sdk",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -29,27 +29,27 @@
29
29
  "LICENSE.txt"
30
30
  ],
31
31
  "dependencies": {
32
- "@ai-sdk/provider": "^4.0.10",
33
- "@anthropic-ai/bedrock-sdk": "^0.32.0",
34
- "@anthropic-ai/sdk": "^0.122.0",
35
- "@mastra/core": "^1.64.0",
36
- "@mastra/libsql": "^1.22.3",
37
- "@mastra/mcp": "^1.17.3",
38
- "@mastra/memory": "^1.28.2",
39
- "@mastra/schema-compat": "^1.3.7",
40
- "@salesforce/agentic-common": "0.20.0",
32
+ "@ai-sdk/provider": "4.0.4",
33
+ "@anthropic-ai/bedrock-sdk": "^0.33.6",
34
+ "@anthropic-ai/sdk": "^0.126.0",
35
+ "@mastra/core": "^1.67.0",
36
+ "@mastra/libsql": "^1.23.0",
37
+ "@mastra/mcp": "^1.18.0",
38
+ "@mastra/memory": "^1.30.0",
39
+ "@mastra/schema-compat": "^1.3.10",
40
+ "@salesforce/agentic-common": "0.21.0",
41
41
  "@smithy/eventstream-codec": "^4.5.2",
42
- "openai": "^7.0.0"
42
+ "openai": "^7.17.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@salesforce/sfdx-agent-sdk": "0.87.0"
45
+ "@salesforce/sfdx-agent-sdk": "0.89.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.87.0",
50
+ "@salesforce/sfdx-agent-sdk": "0.89.0",
51
51
  "@types/node": "^22.20.1",
52
- "@vitest/coverage-istanbul": "^4.1.11",
52
+ "@vitest/coverage-istanbul": "^5.0.1",
53
53
  "@vitest/eslint-plugin": "^1.6.27",
54
54
  "eslint": "^10.10.0",
55
55
  "eslint-config-prettier": "^10.1.8",
@@ -57,13 +57,13 @@
57
57
  "eslint-plugin-import": "^2.32.0",
58
58
  "eslint-plugin-n": "^18.3.0",
59
59
  "globals": "^17.12.0",
60
- "lint-staged": "^17.5.0",
61
- "prettier": "^3.9.6",
60
+ "lint-staged": "^17.5.1",
61
+ "prettier": "^3.9.7",
62
62
  "rimraf": "^6.1.3",
63
63
  "tsx": "^4.23.13",
64
64
  "typescript": "^7.0.2",
65
65
  "typescript-eslint": "^8.70.0",
66
- "vitest": "^4.1.11"
66
+ "vitest": "^5.0.1"
67
67
  },
68
68
  "engines": {
69
69
  "node": ">=22.22.1"