@tangle-network/agent-provider-tangle 0.7.1 → 0.7.3

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.
@@ -72,7 +72,15 @@ export function environmentEventFromSandboxEvent(event, expected = {}) {
72
72
  if (Object.prototype.hasOwnProperty.call(data, "contextTransferReceipt")) {
73
73
  throw new Error("Tangle Sandbox emitted an unsolicited context transfer receipt");
74
74
  }
75
- const { executionId: eventExecutionId, sessionId: eventSessionId } = sandboxEventIdentity(event);
75
+ // An exact run stream is already selected by the runtime execution id.
76
+ // On that stream, session.updated carries the harness-native session id
77
+ // (for example an OpenCode session), not the runtime session id. Keep that
78
+ // value as event content while lifecycle frames remain identity-checked.
79
+ const identity = sandboxEventIdentity(event);
80
+ const eventExecutionId = identity.executionId;
81
+ const eventSessionId = expected.streamBound === true && record.type === "session.updated"
82
+ ? undefined
83
+ : identity.sessionId;
76
84
  if (expected.executionId !== undefined &&
77
85
  ((eventExecutionId === undefined && expected.streamBound !== true) ||
78
86
  (eventExecutionId !== undefined && eventExecutionId !== expected.executionId))) {
@@ -58,15 +58,32 @@ export function promptOptionsFromTurnInput(input, target) {
58
58
  ...(input.detach !== undefined ? { detach: input.detach } : {}),
59
59
  };
60
60
  }
61
+ const SANDBOX_OPTIONAL_RESULT_FIELDS = new Set([
62
+ "executionId",
63
+ "response",
64
+ "error",
65
+ "errorCode",
66
+ "toolInvocations",
67
+ "approval",
68
+ "question",
69
+ "plan",
70
+ "traceId",
71
+ "usage",
72
+ "costUsd",
73
+ ]);
61
74
  export function validatedSandboxPromptResult(result) {
62
75
  if (!result || typeof result !== "object" || Array.isArray(result)) {
63
76
  throw new Error("Tangle prompt returned no result object");
64
77
  }
65
- const record = result;
66
- if (Object.hasOwn(record, "contextTransferReceipt") &&
67
- record.contextTransferReceipt === undefined) {
78
+ const source = result;
79
+ if (Object.hasOwn(source, "contextTransferReceipt") &&
80
+ source.contextTransferReceipt === undefined) {
68
81
  throw new Error("Tangle prompt result returned a context receipt for a turn that requested no transfer");
69
82
  }
83
+ // The Sandbox SDK materializes absent optional response fields as
84
+ // `undefined`. They were absent on the JSON wire and must stay absent in the
85
+ // provider-neutral result before the strict JSON check runs.
86
+ const record = Object.fromEntries(Object.entries(source).filter(([field, value]) => value !== undefined || !SANDBOX_OPTIONAL_RESULT_FIELDS.has(field)));
70
87
  assertBoundedJson(record);
71
88
  if (typeof record.success !== "boolean") {
72
89
  throw new Error("Tangle prompt result omitted its success status");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-provider-tangle",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -67,7 +67,7 @@
67
67
  "LICENSE"
68
68
  ],
69
69
  "dependencies": {
70
- "@tangle-network/agent-interface": "0.48.0"
70
+ "@tangle-network/agent-interface": "0.49.0"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "@tangle-network/sandbox": ">=0.19.6 <1.0.0"
@@ -84,7 +84,7 @@
84
84
  "@types/node": "25.6.0",
85
85
  "typescript": "^6.0.3",
86
86
  "vitest": "^4.1.5",
87
- "@tangle-network/agent-provider-testkit": "0.6.3"
87
+ "@tangle-network/agent-provider-testkit": "0.6.4"
88
88
  },
89
89
  "scripts": {
90
90
  "build": "tsc -p tsconfig.json",