@tangle-network/agent-provider-tangle 3.6.10 → 3.6.12

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";
@@ -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");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-provider-tangle",
3
- "version": "3.6.10",
3
+ "version": "3.6.12",
4
4
  "description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -128,7 +128,7 @@
128
128
  "dist/model-credential-capacity.d.ts"
129
129
  ],
130
130
  "dependencies": {
131
- "@tangle-network/agent-interface": "^3.1.2"
131
+ "@tangle-network/agent-interface": "^4.0.0"
132
132
  },
133
133
  "peerDependencies": {
134
134
  "@tangle-network/sandbox": ">=0.60.27 <1.0.0"
@@ -139,7 +139,7 @@
139
139
  }
140
140
  },
141
141
  "devDependencies": {
142
- "@tangle-network/agent-provider-testkit": "0.10.2",
142
+ "@tangle-network/agent-provider-testkit": "0.11.0",
143
143
  "@tangle-network/agent-runtime": "0.292.3",
144
144
  "@tangle-network/sandbox": "0.60.27",
145
145
  "@types/node": "26.6.3",