@tangle-network/agent-provider-tangle 3.4.2 → 3.5.1
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 +19 -2
- package/dist/node.d.ts +2 -0
- package/dist/node.js +1 -0
- package/dist/tangle-evidence-json.d.ts +10 -0
- package/dist/tangle-evidence-json.js +82 -0
- package/dist/tangle-evidence-native-files.d.ts +27 -0
- package/dist/tangle-evidence-native-files.js +177 -0
- package/dist/tangle-evidence-writer.d.ts +29 -0
- package/dist/tangle-evidence-writer.js +144 -0
- package/dist/tangle-evidence.d.ts +14 -0
- package/dist/tangle-evidence.js +501 -441
- package/dist/tangle-retained-attribution.d.ts +6 -0
- package/dist/tangle-retained-attribution.js +62 -0
- package/dist/tangle-types.d.ts +7 -0
- package/package.json +9 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AgentExactRunControlRef } from "@tangle-network/agent-interface";
|
|
2
|
+
/** Recover callers from server admission frames, never from bare native attempt IDs. */
|
|
3
|
+
export declare function retainedCaptureAttribution(events: readonly unknown[], anchor: AgentExactRunControlRef, signal?: AbortSignal): Promise<{
|
|
4
|
+
controlRefs: AgentExactRunControlRef[];
|
|
5
|
+
missing: string[];
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { AgentExactRunControlRefSchema } from "@tangle-network/agent-interface";
|
|
2
|
+
import { EvidenceJsonArray } from "./tangle-evidence-json.js";
|
|
3
|
+
import { sameRunControlRef } from "./tangle-session-control.js";
|
|
4
|
+
function record(value) {
|
|
5
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
6
|
+
? value : undefined;
|
|
7
|
+
}
|
|
8
|
+
/** Recover callers from server admission frames, never from bare native attempt IDs. */
|
|
9
|
+
export async function retainedCaptureAttribution(events, anchor, signal) {
|
|
10
|
+
const refs = new Map();
|
|
11
|
+
const invalid = new Set();
|
|
12
|
+
const missing = [];
|
|
13
|
+
let count = 0;
|
|
14
|
+
const reject = (id, reason) => {
|
|
15
|
+
invalid.add(id);
|
|
16
|
+
refs.delete(id);
|
|
17
|
+
missing.push(`Retained caller attribution for execution ${id}: ${reason}`);
|
|
18
|
+
};
|
|
19
|
+
for (const value of events) {
|
|
20
|
+
const entry = record(value);
|
|
21
|
+
const metadata = record(entry?.metadata);
|
|
22
|
+
if (!entry || !metadata || typeof metadata.executionId !== "string" ||
|
|
23
|
+
metadata.sessionId !== anchor.sessionId)
|
|
24
|
+
throw new Error("Retained admission buffer names another session");
|
|
25
|
+
const executionId = metadata.executionId;
|
|
26
|
+
const frames = entry.frames instanceof EvidenceJsonArray ? entry.frames.entries() : entry.frames;
|
|
27
|
+
if (!frames || (!Array.isArray(frames) && !(entry.frames instanceof EvidenceJsonArray))) {
|
|
28
|
+
throw new Error("Retained admission frames are unavailable");
|
|
29
|
+
}
|
|
30
|
+
for await (const value of frames) {
|
|
31
|
+
signal?.throwIfAborted();
|
|
32
|
+
if (++count > 100_000)
|
|
33
|
+
throw new Error("Retained admission frame limit exceeded");
|
|
34
|
+
const frame = record(value);
|
|
35
|
+
if (frame?.type !== "execution.started")
|
|
36
|
+
continue;
|
|
37
|
+
const data = record(frame.data);
|
|
38
|
+
const parsed = AgentExactRunControlRefSchema.safeParse(data?.runControlRef);
|
|
39
|
+
if (frame.sessionId !== anchor.sessionId || frame.executionId !== executionId ||
|
|
40
|
+
data?.sessionId !== anchor.sessionId || data.executionId !== executionId || !parsed.success ||
|
|
41
|
+
parsed.data.provider !== anchor.provider || parsed.data.environmentId !== anchor.environmentId ||
|
|
42
|
+
parsed.data.sessionId !== anchor.sessionId || parsed.data.executionId !== executionId) {
|
|
43
|
+
reject(executionId, "missing or mismatched server admission reference");
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (invalid.has(executionId))
|
|
47
|
+
continue;
|
|
48
|
+
const previous = refs.get(executionId);
|
|
49
|
+
if (previous && !sameRunControlRef(previous, parsed.data)) {
|
|
50
|
+
reject(executionId, "conflicting server admission references");
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
refs.set(executionId, parsed.data);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const admittedAnchor = refs.get(anchor.executionId);
|
|
57
|
+
if (!admittedAnchor || !sameRunControlRef(admittedAnchor, anchor)) {
|
|
58
|
+
missing.push("Retained server admissions do not match the current exact control reference");
|
|
59
|
+
return { controlRefs: [], missing };
|
|
60
|
+
}
|
|
61
|
+
return { controlRefs: [...refs.values()], missing };
|
|
62
|
+
}
|
package/dist/tangle-types.d.ts
CHANGED
|
@@ -701,6 +701,13 @@ export interface SandboxSessionLike {
|
|
|
701
701
|
}): Promise<unknown[]>;
|
|
702
702
|
/** The SDK returns generic records. Validate their shape before retaining any bytes. */
|
|
703
703
|
rawEvidence?(): Promise<unknown>;
|
|
704
|
+
/** Bounded, hash-verified native archive; unavailable servers must not fall back to aggregate JSON. */
|
|
705
|
+
exportRawEvidence?(destination: string, options: {
|
|
706
|
+
maxBytes: number;
|
|
707
|
+
maxFiles: number;
|
|
708
|
+
maxArchiveBytes?: number;
|
|
709
|
+
signal?: AbortSignal;
|
|
710
|
+
}): Promise<unknown>;
|
|
704
711
|
/** Exact native coding-agent TUI bound to this session id. */
|
|
705
712
|
interactive?(options?: {
|
|
706
713
|
ref?: AgentInteractiveSessionRef;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-provider-tangle",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -56,6 +56,14 @@
|
|
|
56
56
|
"dist/tangle-environment.js",
|
|
57
57
|
"dist/tangle-evidence.d.ts",
|
|
58
58
|
"dist/tangle-evidence.js",
|
|
59
|
+
"dist/tangle-evidence-writer.js",
|
|
60
|
+
"dist/tangle-evidence-writer.d.ts",
|
|
61
|
+
"dist/tangle-evidence-json.js",
|
|
62
|
+
"dist/tangle-evidence-json.d.ts",
|
|
63
|
+
"dist/tangle-evidence-native-files.js",
|
|
64
|
+
"dist/tangle-evidence-native-files.d.ts",
|
|
65
|
+
"dist/tangle-retained-attribution.js",
|
|
66
|
+
"dist/tangle-retained-attribution.d.ts",
|
|
59
67
|
"dist/tangle-native-capture-proof.d.ts",
|
|
60
68
|
"dist/tangle-native-capture-proof.js",
|
|
61
69
|
"dist/tangle-environment-dispatch.d.ts",
|