@tangle-network/agent-provider-cli-bridge 0.9.5 → 0.9.6
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/retained-control.js +2 -10
- package/dist/retained-native.js +3 -11
- package/package.json +2 -2
package/dist/retained-control.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentExactRunControlRefSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, agentRunCancellationRequestDigest, agentRunCancellationAcknowledgementMatchesRequest, } from "@tangle-network/agent-interface";
|
|
1
|
+
import { AgentExactRunControlRefSchema, AgentRunCancellationAcknowledgementSchema, AgentRunCancellationRequestSchema, agentRunCancellationRequestDigest, agentRunCancellationAcknowledgementMatchesRequest, sameAgentRunControlRef, } from "@tangle-network/agent-interface";
|
|
2
2
|
import { assertCliBridgeProviderOptions, } from "./provider-options.js";
|
|
3
3
|
import { createCliBridgeTransport, MAX_CLI_BRIDGE_CONTROL_RESPONSE_BYTES, readBoundedCliBridgeResponse, requestHeaders, trimSlash, } from "./transport.js";
|
|
4
4
|
import { assertCliBridgeRunId, runSnapshot } from "./wire.js";
|
|
@@ -180,7 +180,7 @@ function waitForOperation(operation, signal) {
|
|
|
180
180
|
}
|
|
181
181
|
export async function cancelExactCliBridgeRun(options, transport, run, request, signal) {
|
|
182
182
|
const exactRequest = AgentRunCancellationRequestSchema.parse(request);
|
|
183
|
-
if (!run.controlRef || !
|
|
183
|
+
if (!run.controlRef || !sameAgentRunControlRef(run.controlRef, exactRequest.run)) {
|
|
184
184
|
throw new Error("cli-bridge cancellation targets another retained run");
|
|
185
185
|
}
|
|
186
186
|
const timeoutSignal = cliBridgeCancellationSignal(options);
|
|
@@ -214,14 +214,6 @@ function parseExactCancellationAcknowledgement(request, status, responseText) {
|
|
|
214
214
|
}
|
|
215
215
|
return acknowledgement;
|
|
216
216
|
}
|
|
217
|
-
function sameControlRef(left, right) {
|
|
218
|
-
return left.runId === right.runId &&
|
|
219
|
-
left.provider === right.provider &&
|
|
220
|
-
left.environmentId === right.environmentId &&
|
|
221
|
-
left.sessionId === right.sessionId &&
|
|
222
|
-
left.executionId === right.executionId &&
|
|
223
|
-
left.requestDigest === right.requestDigest;
|
|
224
|
-
}
|
|
225
217
|
export async function getCliBridgeRun(options, transport, run, waitMs, signal) {
|
|
226
218
|
const query = waitMs === undefined ? "" : `?wait_ms=${waitMs}`;
|
|
227
219
|
const response = await waitForOperation(transport.fetch(`${trimSlash(options.baseUrl)}/v1/runs/${encodeURIComponent(run.id)}${query}`, {
|
package/dist/retained-native.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentNativeContextContinuationResultSchema, AgentExactRunControlRefSchema, NativeContextBoundaryProofSchema, NativeContextContinuationRequestSchema, RequestedInteractionsSchema, agentNativeContextContinuationResultMatchesRequest, canonicalCandidateDigest, nativeContextContinuationTurnDigest, } from "@tangle-network/agent-interface";
|
|
1
|
+
import { AgentNativeContextContinuationResultSchema, AgentExactRunControlRefSchema, NativeContextBoundaryProofSchema, NativeContextContinuationRequestSchema, RequestedInteractionsSchema, agentNativeContextContinuationResultMatchesRequest, canonicalCandidateDigest, nativeContextContinuationTurnDigest, sameAgentRunControlRef, } from "@tangle-network/agent-interface";
|
|
2
2
|
import { CliBridgeRequestRejectedError } from "./retained-stream.js";
|
|
3
3
|
import { advanceCliBridgeRun, exactControlRefForRun, } from "./retained-run-state.js";
|
|
4
4
|
import { MAX_CLI_BRIDGE_CONTROL_RESPONSE_BYTES, readBoundedCliBridgeResponse, requestHeaders, trimSlash, } from "./transport.js";
|
|
@@ -91,7 +91,7 @@ export async function readCliBridgeNativeContextBoundary(options, providerName,
|
|
|
91
91
|
export async function continueCliBridgeNative(options, providerName, transport, run, request, continuationOptions, runs) {
|
|
92
92
|
const exactRequest = NativeContextContinuationRequestSchema.parse(request);
|
|
93
93
|
const current = currentCliBridgeControlRef(run, providerName);
|
|
94
|
-
if (!
|
|
94
|
+
if (!sameAgentRunControlRef(current, exactRequest.run)) {
|
|
95
95
|
throw new Error("cli-bridge native continuation targets another retained run");
|
|
96
96
|
}
|
|
97
97
|
if (nativeContextContinuationTurnDigest(continuationOptions.turn) !==
|
|
@@ -132,7 +132,7 @@ export async function continueCliBridgeNative(options, providerName, transport,
|
|
|
132
132
|
function currentCliBridgeControlRef(run, providerName) {
|
|
133
133
|
if (run.controlRef !== undefined) {
|
|
134
134
|
const controlRef = AgentExactRunControlRefSchema.parse(run.controlRef);
|
|
135
|
-
if (!
|
|
135
|
+
if (!sameAgentRunControlRef(controlRef, exactControlRefForRun(run, providerName))) {
|
|
136
136
|
throw new Error("cli-bridge retained run has a conflicting control reference");
|
|
137
137
|
}
|
|
138
138
|
return controlRef;
|
|
@@ -141,14 +141,6 @@ function currentCliBridgeControlRef(run, providerName) {
|
|
|
141
141
|
run.controlRef = controlRef;
|
|
142
142
|
return controlRef;
|
|
143
143
|
}
|
|
144
|
-
function sameControlRef(left, right) {
|
|
145
|
-
return left.runId === right.runId &&
|
|
146
|
-
left.provider === right.provider &&
|
|
147
|
-
left.environmentId === right.environmentId &&
|
|
148
|
-
left.sessionId === right.sessionId &&
|
|
149
|
-
left.executionId === right.executionId &&
|
|
150
|
-
left.requestDigest === right.requestDigest;
|
|
151
|
-
}
|
|
152
144
|
function assertBoundaryControlRef(proof, controlRef) {
|
|
153
145
|
if (proof.runId !== controlRef.runId ||
|
|
154
146
|
proof.provider !== controlRef.provider ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-provider-cli-bridge",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "AgentEnvironmentProvider adapter for cli-bridge retained sessions and one-shot turns",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"LICENSE"
|
|
60
60
|
],
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@tangle-network/agent-interface": "^1.
|
|
62
|
+
"@tangle-network/agent-interface": "^1.5.0",
|
|
63
63
|
"undici": "7.29.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|