@tangle-network/agent-provider-cli-bridge 1.1.2 → 1.1.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.
@@ -33,6 +33,7 @@ export async function* streamTrackedCliBridgeTurn(options, environmentInput, pro
33
33
  let admitted = false;
34
34
  let admissionValidated = false;
35
35
  try {
36
+ await confirmCliBridgeContextTransfer(options, originalTurn, run, signal);
36
37
  if (useNativeInteractions) {
37
38
  await beginCliBridgeNativeTurn(options, providerName, environmentInput, turn, run, transport, nativeSessions, signal, () => {
38
39
  admitted = true;
@@ -51,7 +52,6 @@ export async function* streamTrackedCliBridgeTurn(options, environmentInput, pro
51
52
  yield event;
52
53
  }
53
54
  }
54
- await confirmCliBridgeContextTransfer(options, originalTurn, run, signal);
55
55
  drained = true;
56
56
  if (runs.get(run.id) === run)
57
57
  runs.delete(run.id);
@@ -112,6 +112,7 @@ export async function dispatchCliBridgeTurn(options, environmentInput, prepared,
112
112
  let accepted = false;
113
113
  let responseBody;
114
114
  try {
115
+ await confirmCliBridgeContextTransfer(options, prepared.turn, run, signal);
115
116
  if (useNativeInteractions) {
116
117
  await beginCliBridgeNativeTurn(options, providerName, environmentInput, prepared.turn, run, transport, nativeSessions, signal, () => {
117
118
  accepted = true;
@@ -146,7 +147,6 @@ export async function dispatchCliBridgeTurn(options, environmentInput, prepared,
146
147
  }
147
148
  const controlRef = exactControlRefForRun(run, providerName);
148
149
  run.controlRef = controlRef;
149
- await confirmCliBridgeContextTransfer(options, prepared.turn, run, signal);
150
150
  if (responseBody) {
151
151
  await detachCliBridgeReader(responseBody);
152
152
  responseBody = undefined;
@@ -202,7 +202,11 @@ async function confirmCliBridgeContextTransfer(options, turn, run, signal) {
202
202
  const transfer = await lookupCliBridgeContext(options, turn.contextTransfer, signal);
203
203
  if (transfer === undefined ||
204
204
  (transfer.status !== "accepted" && transfer.status !== "replayed")) {
205
- throw new Error("cli-bridge did not confirm admitted portable context");
205
+ throw new CliBridgeRequestRejectedError(409, "cli-bridge did not confirm admitted portable context");
206
+ }
207
+ if (transfer.environmentId !== run.environmentId || transfer.sessionId !== run.sessionId ||
208
+ transfer.runId !== run.id || transfer.executionId !== run.executionId) {
209
+ throw new CliBridgeRequestRejectedError(409, "cli-bridge portable context belongs to another environment or run");
206
210
  }
207
211
  run.contextTransferReceipt = transfer;
208
212
  }
@@ -83,7 +83,7 @@ export function prepareCliBridgeRun(options, environmentInput, originalTurn, pro
83
83
  const executionId = validatedTurn.executionId ?? destination?.executionId ?? runId;
84
84
  if (destination !== undefined &&
85
85
  (destination.provider !== providerName ||
86
- destination.environmentId !== environmentId ||
86
+ (destination.environmentId !== undefined && destination.environmentId !== environmentId) ||
87
87
  destination.sessionId !== sessionId ||
88
88
  destination.executionId !== executionId)) {
89
89
  throw new Error("cli-bridge context transfer targets another destination");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-provider-cli-bridge",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "AgentEnvironmentProvider adapter for cli-bridge retained sessions and one-shot turns",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -64,7 +64,7 @@
64
64
  "LICENSE"
65
65
  ],
66
66
  "dependencies": {
67
- "@tangle-network/agent-interface": "^3.0.0",
67
+ "@tangle-network/agent-interface": "^4.0.0",
68
68
  "undici": "8.11.2"
69
69
  },
70
70
  "devDependencies": {