@tangle-network/agent-provider-tangle 4.5.1 → 4.5.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/README.md +4 -0
- package/dist/tangle-environment-dispatch.js +16 -11
- package/dist/tangle-prompt.js +7 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,6 +41,10 @@ Use the typed field for large profiles; generic provider metadata keeps its exis
|
|
|
41
41
|
|
|
42
42
|
Exact execution replay preserves the admitted request and its digest.
|
|
43
43
|
An explicit replay override cannot replace the selected account, credential channel, or harness.
|
|
44
|
+
Before dispatch admission, replay the original `create` and turn with their original idempotency keys.
|
|
45
|
+
Native-capture `get()` requires an already selected backend; it is not the entrypoint for an intent whose first dispatch was refused.
|
|
46
|
+
A backend 404 alone does not prove that a prior execution ran nothing or authorize replacing it under new keys.
|
|
47
|
+
When an older SDK's reuse receipt omits the exact control reference, the adapter reads the session's authoritative status and validates its echoed reference against the original session, execution, environment and request digest. Missing or conflicting authority still refuses recovery.
|
|
44
48
|
|
|
45
49
|
## Workspace file reads
|
|
46
50
|
|
|
@@ -15,13 +15,10 @@ export function dispatchEnvironmentRun(box, provider, environmentId) {
|
|
|
15
15
|
callerControlRef.environmentId !== environmentId) {
|
|
16
16
|
throw new Error("Tangle control reference does not match this environment");
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
input
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (input.executionId !== undefined &&
|
|
23
|
-
input.executionId !== callerControlRef.executionId) {
|
|
24
|
-
throw new Error("Tangle executionId conflicts with the control reference");
|
|
18
|
+
for (const field of ["sessionId", "executionId"]) {
|
|
19
|
+
if (input[field] !== undefined && input[field] !== callerControlRef[field]) {
|
|
20
|
+
throw new Error(`Tangle ${field} conflicts with the control reference`);
|
|
21
|
+
}
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
24
|
const expectedSessionId = input.sessionId ??
|
|
@@ -62,6 +59,16 @@ export function dispatchEnvironmentRun(box, provider, environmentId) {
|
|
|
62
59
|
}
|
|
63
60
|
throw error;
|
|
64
61
|
}
|
|
62
|
+
const receipt = dispatched;
|
|
63
|
+
if (receipt?.dispatched === false && receipt.alreadyExisted === true &&
|
|
64
|
+
receipt.sessionId === expectedSessionId && receipt.executionId === expectedExecutionId &&
|
|
65
|
+
receipt.runControlRef === undefined && callerControlRef === undefined && box.session) {
|
|
66
|
+
// Recover an older SDK's omitted reuse reference from server status; validate every binding below.
|
|
67
|
+
const status = await awaitWithSignal(box.session(expectedSessionId).status({ signal: input.signal }), input.signal);
|
|
68
|
+
const echoedRef = status && typeof status === "object" && !Array.isArray(status) && "runControlRef" in status ? status.runControlRef : undefined;
|
|
69
|
+
if (echoedRef !== undefined)
|
|
70
|
+
dispatched = { ...receipt, runControlRef: echoedRef };
|
|
71
|
+
}
|
|
65
72
|
let reference;
|
|
66
73
|
try {
|
|
67
74
|
reference = sessionRefFromSandboxDispatch(dispatched, provider, environmentId, expectedExecutionId, requestDigest, expectedSessionId, callerControlRef);
|
|
@@ -79,12 +86,10 @@ export function dispatchEnvironmentRun(box, provider, environmentId) {
|
|
|
79
86
|
}
|
|
80
87
|
throw error;
|
|
81
88
|
}
|
|
82
|
-
const boundReference = reference;
|
|
83
89
|
if (input.signal?.aborted && input.detach !== true) {
|
|
84
|
-
await interruptAfterAbort(box,
|
|
85
|
-
input.signal.throwIfAborted();
|
|
90
|
+
await interruptAfterAbort(box, reference);
|
|
86
91
|
}
|
|
87
92
|
input.signal?.throwIfAborted();
|
|
88
|
-
return
|
|
93
|
+
return reference;
|
|
89
94
|
};
|
|
90
95
|
}
|
package/dist/tangle-prompt.js
CHANGED
|
@@ -3,6 +3,7 @@ import { projectAgentTerminalRecord } from "@tangle-network/sandbox/runtime";
|
|
|
3
3
|
import { assertCliAuthReferenceSupported, cliAuthReferenceSchema, } from "@tangle-network/sandbox/auth";
|
|
4
4
|
import { agentProfileSchema, canonicalAgentProfileDigest, boundedEventContentRecordSchema, AgentExactRunControlRefSchema, AgentTurnInputSchema, ContextTransferReceiptSchema, contextTransferResultMatchesRequest, } from "@tangle-network/agent-interface";
|
|
5
5
|
import { tokenUsageFromData } from "./tangle-result-values.js";
|
|
6
|
+
import { TangleCredentialCapacityError } from "./model-credential-capacity.js";
|
|
6
7
|
import { assertBoundedJson, boundedString, PROFILE_AT_PROFILE, } from "./tangle-contract-safety.js";
|
|
7
8
|
import { profileCredentialSource } from "./model-credential-source.js";
|
|
8
9
|
import { tangleRuntimeAttachments } from "./tangle-runtime-attachments.js";
|
|
@@ -555,6 +556,12 @@ export function agentTurnResultFromPromptRecord(record, options = {}) {
|
|
|
555
556
|
!contextTransferResultMatchesRequest(options.contextTransferRequest, contextTransferReceipt.data)) {
|
|
556
557
|
throw new Error("Tangle prompt result context receipt does not match its request");
|
|
557
558
|
}
|
|
559
|
+
// The harness's own subscription quota is spent: the same typed refusal the
|
|
560
|
+
// credential owner gives before dispatch, with when it resets.
|
|
561
|
+
if (!record.success && record.errorCode === "provider_quota_exhausted") {
|
|
562
|
+
const resetAt = record.resetAt;
|
|
563
|
+
throw new TangleCredentialCapacityError("provider_quota_exhausted", "exhausted", typeof resetAt === "string" && new Date(resetAt).toISOString() === resetAt ? resetAt : undefined, 429);
|
|
564
|
+
}
|
|
558
565
|
const usage = tokenUsageFromData(record);
|
|
559
566
|
const awaiting = AWAITING_STATUSES.has(record.status);
|
|
560
567
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-provider-tangle",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.3",
|
|
4
4
|
"description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"LICENSE"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tangle-network/agent-interface": "^5.10.
|
|
36
|
+
"@tangle-network/agent-interface": "^5.10.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@tangle-network/sandbox": ">=0.60.88 <2.0.0"
|