@tangle-network/agent-provider-tangle 0.7.2 → 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.
- package/dist/tangle-events.js +9 -1
- package/dist/tangle-prompt.js +20 -3
- package/package.json +1 -1
package/dist/tangle-events.js
CHANGED
|
@@ -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
|
-
|
|
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))) {
|
package/dist/tangle-prompt.js
CHANGED
|
@@ -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
|
|
66
|
-
if (Object.hasOwn(
|
|
67
|
-
|
|
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");
|