@tangle-network/agent-provider-tangle 3.6.9 → 3.6.11
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/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { JsonBoundError, MAX_INLINE_PAYLOAD_BYTES, MAX_PAYLOAD_STRING_BYTES, MAX
|
|
|
3
3
|
export type { JsonBoundRule, JsonBoundViolation } from "./tangle-contract-safety.js";
|
|
4
4
|
export * from "./tangle-types.js";
|
|
5
5
|
export { createTangleProvider } from "./tangle-provider.js";
|
|
6
|
+
export { TangleDispatchNotAdmittedError } from "./tangle-session-control.js";
|
|
6
7
|
export { captureTangleEnvironmentEvidence, captureTangleSandboxEvidence } from "./tangle-evidence.js";
|
|
7
8
|
export type { TangleEnvironmentEvidence, TangleEnvironmentEvidenceOptions, TangleSandboxEvidenceOptions } from "./tangle-evidence.js";
|
|
8
9
|
export { DEFAULT_TANGLE_READY_TIMEOUT_MS } from "./tangle-readiness.js";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { JsonBoundError, MAX_INLINE_PAYLOAD_BYTES, MAX_PAYLOAD_STRING_BYTES, MAX_TOTAL_PAYLOAD_BYTES, } from "./tangle-contract-safety.js";
|
|
2
2
|
export * from "./tangle-types.js";
|
|
3
3
|
export { createTangleProvider } from "./tangle-provider.js";
|
|
4
|
+
export { TangleDispatchNotAdmittedError } from "./tangle-session-control.js";
|
|
4
5
|
export { captureTangleEnvironmentEvidence, captureTangleSandboxEvidence } from "./tangle-evidence.js";
|
|
5
6
|
export { DEFAULT_TANGLE_READY_TIMEOUT_MS } from "./tangle-readiness.js";
|
|
6
7
|
export { defaultTangleSandboxCapabilities } from "./tangle-capabilities.js";
|
package/dist/tangle-provider.js
CHANGED
|
@@ -306,10 +306,12 @@ export function createTangleProvider(options) {
|
|
|
306
306
|
if (!box || boundedIdentifier(box.id, "Tangle environment id") !== id)
|
|
307
307
|
return null;
|
|
308
308
|
if (options.requireNativeSessionCapture) {
|
|
309
|
-
requireNativeCaptureProof(box);
|
|
310
309
|
// Native capture admits only the backend the live container reports, so a
|
|
311
|
-
// suspended sandbox must run again before anything can reconnect to it.
|
|
310
|
+
// suspended sandbox must run again before anything can reconnect to it. A stopped
|
|
311
|
+
// sandbox has no container and so no capture proof; the proof is required of the
|
|
312
|
+
// container the resume produced.
|
|
312
313
|
await resumeForReconnect(box, options.client, readyTimeoutMs, operation?.signal);
|
|
314
|
+
requireNativeCaptureProof(box);
|
|
313
315
|
}
|
|
314
316
|
let backendType;
|
|
315
317
|
let backendReadError;
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import type { AgentExactRunControlRef, AgentRunControlRef } from "@tangle-network/agent-interface";
|
|
2
2
|
import type { AgentSessionRef } from "@tangle-network/agent-interface/environment-provider";
|
|
3
|
+
/**
|
|
4
|
+
* Sandbox started nothing for this dispatch: it reported `dispatched: false`
|
|
5
|
+
* and named another execution that owns the session or turn. That execution
|
|
6
|
+
* can be in flight, or a completed turn cached under the same turn id.
|
|
7
|
+
*
|
|
8
|
+
* The request was refused before it ran, so there is nothing to reconcile.
|
|
9
|
+
* A retry of the same request gets the same answer while that owner holds.
|
|
10
|
+
*/
|
|
11
|
+
export declare class TangleDispatchNotAdmittedError extends Error {
|
|
12
|
+
readonly code: "DISPATCH_NOT_ADMITTED";
|
|
13
|
+
readonly sessionId: string;
|
|
14
|
+
readonly requestedExecutionId: string;
|
|
15
|
+
/** The execution that Sandbox named as the owner of the session or turn. */
|
|
16
|
+
readonly activeExecutionId: string;
|
|
17
|
+
constructor(sessionId: string, requestedExecutionId: string, activeExecutionId: string);
|
|
18
|
+
}
|
|
3
19
|
export declare function sessionRefFromSandboxDispatch(dispatched: unknown, providerName: string, environmentId: string, expectedExecutionId: string | undefined, requestDigest?: `sha256:${string}` | undefined, expectedSessionId?: string | undefined, callerControlRef?: AgentExactRunControlRef | undefined): AgentSessionRef;
|
|
4
20
|
export declare function retainedSessionControlRef(sessionId: string, executionId: string, provider: string, environmentId: string, requestDigest?: `sha256:${string}`, runId?: string): AgentExactRunControlRef;
|
|
5
21
|
export declare function sessionPromptExecutionId(requestDigest: `sha256:${string}`): string;
|
|
@@ -2,6 +2,29 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { AgentExactRunControlRefSchema, canonicalCandidateDigest, } from "@tangle-network/agent-interface";
|
|
3
3
|
import { nonEmptyString } from "./tangle-environment-values.js";
|
|
4
4
|
import { assertBoundedJson, boundedIdentifier, } from "./tangle-contract-safety.js";
|
|
5
|
+
/**
|
|
6
|
+
* Sandbox started nothing for this dispatch: it reported `dispatched: false`
|
|
7
|
+
* and named another execution that owns the session or turn. That execution
|
|
8
|
+
* can be in flight, or a completed turn cached under the same turn id.
|
|
9
|
+
*
|
|
10
|
+
* The request was refused before it ran, so there is nothing to reconcile.
|
|
11
|
+
* A retry of the same request gets the same answer while that owner holds.
|
|
12
|
+
*/
|
|
13
|
+
export class TangleDispatchNotAdmittedError extends Error {
|
|
14
|
+
code = "DISPATCH_NOT_ADMITTED";
|
|
15
|
+
sessionId;
|
|
16
|
+
requestedExecutionId;
|
|
17
|
+
/** The execution that Sandbox named as the owner of the session or turn. */
|
|
18
|
+
activeExecutionId;
|
|
19
|
+
constructor(sessionId, requestedExecutionId, activeExecutionId) {
|
|
20
|
+
super("sandbox dispatch returned an execution id different from the requested run: " +
|
|
21
|
+
"another execution owns the session or turn and nothing was dispatched");
|
|
22
|
+
this.name = "TangleDispatchNotAdmittedError";
|
|
23
|
+
this.sessionId = sessionId;
|
|
24
|
+
this.requestedExecutionId = requestedExecutionId;
|
|
25
|
+
this.activeExecutionId = activeExecutionId;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
5
28
|
export function sessionRefFromSandboxDispatch(dispatched, providerName, environmentId, expectedExecutionId, requestDigest = undefined, expectedSessionId = undefined, callerControlRef = undefined) {
|
|
6
29
|
const record = dispatched && typeof dispatched === "object" && !Array.isArray(dispatched)
|
|
7
30
|
? dispatched
|
|
@@ -22,6 +45,10 @@ export function sessionRefFromSandboxDispatch(dispatched, providerName, environm
|
|
|
22
45
|
}
|
|
23
46
|
if (expectedExecutionId !== undefined &&
|
|
24
47
|
executionId !== expectedExecutionId) {
|
|
48
|
+
if (record.dispatched === false) {
|
|
49
|
+
boundedIdentifier(executionId, "Tangle active execution id");
|
|
50
|
+
throw new TangleDispatchNotAdmittedError(id, expectedExecutionId, executionId);
|
|
51
|
+
}
|
|
25
52
|
throw new Error("sandbox dispatch returned an execution id different from the requested run");
|
|
26
53
|
}
|
|
27
54
|
boundedIdentifier(executionId, "Tangle dispatched execution id");
|