@tangle-network/agent-provider-tangle 4.4.4 → 4.4.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/tangle-evidence-native-files.d.ts +2 -0
- package/dist/tangle-evidence-native-files.js +6 -3
- package/dist/tangle-evidence-omission.d.ts +11 -0
- package/dist/tangle-evidence-omission.js +30 -0
- package/dist/tangle-evidence.d.ts +6 -1
- package/dist/tangle-evidence.js +2 -15
- package/dist/tangle-types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -18,6 +18,8 @@ export interface PreparedNativeEvidence {
|
|
|
18
18
|
native: RetainedNativeEvidence | undefined;
|
|
19
19
|
payloads: WeakMap<object, NativePayloadFile>;
|
|
20
20
|
directory?: string;
|
|
21
|
+
/** Wall time of the bounded export that copied the session's native store out of the sandbox. */
|
|
22
|
+
copyMs?: number;
|
|
21
23
|
remove(): Promise<void>;
|
|
22
24
|
}
|
|
23
25
|
export declare const MAX_METADATA_BYTES: number;
|
|
@@ -4,6 +4,7 @@ import { mkdtemp, open, rm } from "node:fs/promises";
|
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { EvidenceJsonArray } from "./tangle-evidence-json.js";
|
|
7
|
+
import { NATIVE_OMIT_CONTENT_DIRECTORIES } from "./tangle-evidence-omission.js";
|
|
7
8
|
const MAX_ENTRIES = 100_000;
|
|
8
9
|
// Match the shipped Sandbox archive reader: a valid producer manifest or NDJSON
|
|
9
10
|
// record must not be rejected after capture solely by this consumer's bound.
|
|
@@ -101,9 +102,11 @@ export async function prepareNativeDirectoryEvidence(session, maxBytes, signal)
|
|
|
101
102
|
const destination = join(temporary, "export");
|
|
102
103
|
const remove = () => rm(temporary, { recursive: true, force: true });
|
|
103
104
|
try {
|
|
104
|
-
const
|
|
105
|
+
const copyStarted = performance.now();
|
|
106
|
+
const response = record(await session.exportRawEvidence(destination, { maxBytes, maxFiles: MAX_ENTRIES, omitContent: NATIVE_OMIT_CONTENT_DIRECTORIES, signal }));
|
|
107
|
+
const copyMs = Math.round(performance.now() - copyStarted);
|
|
105
108
|
if (response.status === "unavailable") {
|
|
106
|
-
return { native: response, payloads: new WeakMap(), remove };
|
|
109
|
+
return { native: response, payloads: new WeakMap(), copyMs, remove };
|
|
107
110
|
}
|
|
108
111
|
if ((response.status !== "captured" && response.status !== "partial") || response.directory !== destination ||
|
|
109
112
|
typeof response.manifestPath !== "string" || !response.manifestPath.startsWith(destination + "/") ||
|
|
@@ -170,7 +173,7 @@ export async function prepareNativeDirectoryEvidence(session, maxBytes, signal)
|
|
|
170
173
|
const { schema: _schema, ...legacyMetadata } = manifest;
|
|
171
174
|
// The existing evidence validator checks all identity, attribution and completeness fields.
|
|
172
175
|
const native = { ...legacyMetadata, files, processIo, processTerminals, processSources, events };
|
|
173
|
-
return { native, payloads, directory: destination, remove };
|
|
176
|
+
return { native, payloads, directory: destination, copyMs, remove };
|
|
174
177
|
}
|
|
175
178
|
catch (error) {
|
|
176
179
|
await remove();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type HarnessContentOmission = "harness-install" | "harness-cache";
|
|
2
|
+
/** Why a native file keeps only its metadata, or undefined when its bytes are session state. */
|
|
3
|
+
export declare function harnessContentOmission(rootScope: string, path: string): HarnessContentOmission | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Session-home directories whose bytes the Sidecar leaves on the box (`exportRawEvidence`
|
|
6
|
+
* `omitContent`). Derived from the rules above, never written separately: every file the Sidecar
|
|
7
|
+
* omits must be one this capture would keep as metadata anyway, and a prefix that covered the
|
|
8
|
+
* native session store would be refused by the Sidecar (400). Each copy of a codex HOME was about
|
|
9
|
+
* 99 MB and 4-6 s with these bytes, 4.4 MB and under 0.6 s without them (2026-10-19, Beelink).
|
|
10
|
+
*/
|
|
11
|
+
export declare const NATIVE_OMIT_CONTENT_DIRECTORIES: readonly string[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex caches under its home that it downloads again on start: plugin template assets and
|
|
3
|
+
* the remote plugin and apps catalogs. Session state (`.codex/sessions`, the thread sqlite,
|
|
4
|
+
* config) stays. One canary's capture was 84% these directories (186.8 MB of evidence).
|
|
5
|
+
*/
|
|
6
|
+
const HARNESS_CACHE_DIRECTORIES = [".codex/plugins/cache/", ".codex/cache/remote_plugin_catalog/", ".codex/cache/codex_apps_tools/"];
|
|
7
|
+
/** Installed harness packages under a session home, as concrete directories. */
|
|
8
|
+
const HARNESS_INSTALL_DIRECTORIES = [".config/opencode/node_modules/"];
|
|
9
|
+
/** Why a native file keeps only its metadata, or undefined when its bytes are session state. */
|
|
10
|
+
export function harnessContentOmission(rootScope, path) {
|
|
11
|
+
// A harness's installed packages, e.g. `.config/opencode/node_modules`.
|
|
12
|
+
if (path.split("/").includes("node_modules"))
|
|
13
|
+
return "harness-install";
|
|
14
|
+
if (rootScope === "session-home" && HARNESS_CACHE_DIRECTORIES.some((directory) => path.startsWith(directory)))
|
|
15
|
+
return "harness-cache";
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Session-home directories whose bytes the Sidecar leaves on the box (`exportRawEvidence`
|
|
20
|
+
* `omitContent`). Derived from the rules above, never written separately: every file the Sidecar
|
|
21
|
+
* omits must be one this capture would keep as metadata anyway, and a prefix that covered the
|
|
22
|
+
* native session store would be refused by the Sidecar (400). Each copy of a codex HOME was about
|
|
23
|
+
* 99 MB and 4-6 s with these bytes, 4.4 MB and under 0.6 s without them (2026-10-19, Beelink).
|
|
24
|
+
*/
|
|
25
|
+
export const NATIVE_OMIT_CONTENT_DIRECTORIES = [...HARNESS_CACHE_DIRECTORIES, ...HARNESS_INSTALL_DIRECTORIES];
|
|
26
|
+
for (const directory of NATIVE_OMIT_CONTENT_DIRECTORIES) {
|
|
27
|
+
if (!directory.endsWith("/") || harnessContentOmission("session-home", directory + "file") === undefined) {
|
|
28
|
+
throw new Error(`Tangle evidence would omit ${directory} without keeping its files as metadata`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AgentExactRunControlRef, type AgentProfile } from "@tangle-network/agent-interface";
|
|
2
2
|
import type { AgentEnvironment } from "@tangle-network/agent-interface/environment-provider";
|
|
3
3
|
import type { NativeCaptureProofLike, SandboxInstanceLike, TangleEvidenceAttemptLike, TangleEvidenceSourceLike } from "./tangle-types.js";
|
|
4
|
+
import { type HarnessContentOmission } from "./tangle-evidence-omission.js";
|
|
4
5
|
interface WorkspaceEntryMetadata {
|
|
5
6
|
path: string;
|
|
6
7
|
type: "file" | "directory" | "symlink";
|
|
@@ -120,6 +121,11 @@ export interface TangleEnvironmentEvidence {
|
|
|
120
121
|
skippedEntries: number;
|
|
121
122
|
} | null;
|
|
122
123
|
complete: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Wall time, in ms, of the bounded export that copied this session's
|
|
126
|
+
* native store out of the sandbox. Directory capture only.
|
|
127
|
+
*/
|
|
128
|
+
copyMs?: number;
|
|
123
129
|
entries: Array<{
|
|
124
130
|
sourceId?: string;
|
|
125
131
|
rootScope: "session-home" | "workspace-session";
|
|
@@ -205,5 +211,4 @@ export declare function captureTangleEnvironmentEvidenceToDirectory(environment:
|
|
|
205
211
|
export declare function captureTangleSandboxEvidenceToDirectory(box: SandboxInstanceLike, options: TangleSandboxEvidenceOptions & TangleDirectoryEvidenceOptions): Promise<TangleDirectoryEvidence>;
|
|
206
212
|
/** Export exact Sandbox session and workspace evidence before its owning box is deleted. */
|
|
207
213
|
export declare function captureTangleSandboxEvidence(box: SandboxInstanceLike, options: TangleSandboxEvidenceOptions): Promise<TangleEnvironmentEvidence>;
|
|
208
|
-
type HarnessContentOmission = "harness-install" | "harness-cache";
|
|
209
214
|
export {};
|
package/dist/tangle-evidence.js
CHANGED
|
@@ -6,6 +6,7 @@ import { AgentExactRunControlRefSchema } from "@tangle-network/agent-interface";
|
|
|
6
6
|
import { requireNativeCaptureProof } from "./tangle-native-capture-proof.js";
|
|
7
7
|
import { retainedCaptureAttribution } from "./tangle-retained-attribution.js";
|
|
8
8
|
import { readWorkspaceArchive } from "./tangle-evidence-tar.js";
|
|
9
|
+
import { harnessContentOmission } from "./tangle-evidence-omission.js";
|
|
9
10
|
const handles = new WeakMap();
|
|
10
11
|
const blockedNames = new Set([".ssh", ".config", ".claude", ".codex", ".opencode", ".env", ".env.local", ".npmrc", ".sidecar"]);
|
|
11
12
|
const MAX_ENTRIES = 100_000;
|
|
@@ -501,6 +502,7 @@ async function captureSandboxEvidence(box, options, writer) {
|
|
|
501
502
|
};
|
|
502
503
|
const nativeStore = {
|
|
503
504
|
scope: "session", roots: [], inventory: null, complete: false, entries: [], excludedPaths: [],
|
|
505
|
+
...(prepared?.copyMs === undefined ? {} : { copyMs: prepared.copyMs }),
|
|
504
506
|
};
|
|
505
507
|
const processStreams = {
|
|
506
508
|
complete: false, streamCount: 0, processCount: 0, terminalCount: 0,
|
|
@@ -1127,21 +1129,6 @@ function withoutRepeatedFrameText(record, previous) {
|
|
|
1127
1129
|
return record;
|
|
1128
1130
|
return { ...record, frames: frames.map(compact) };
|
|
1129
1131
|
}
|
|
1130
|
-
/**
|
|
1131
|
-
* Codex caches under its home that it downloads again on start: plugin template assets and
|
|
1132
|
-
* the remote plugin and apps catalogs. Session state (`.codex/sessions`, the thread sqlite,
|
|
1133
|
-
* config) stays. One canary's capture was 84% these directories (186.8 MB of evidence).
|
|
1134
|
-
*/
|
|
1135
|
-
const HARNESS_CACHE_DIRECTORIES = [".codex/plugins/cache/", ".codex/cache/remote_plugin_catalog/", ".codex/cache/codex_apps_tools/"];
|
|
1136
|
-
/** Why a native file keeps only its metadata, or undefined when its bytes are session state. */
|
|
1137
|
-
function harnessContentOmission(rootScope, path) {
|
|
1138
|
-
// A harness's installed packages, e.g. `.config/opencode/node_modules`.
|
|
1139
|
-
if (path.split("/").includes("node_modules"))
|
|
1140
|
-
return "harness-install";
|
|
1141
|
-
if (rootScope === "session-home" && HARNESS_CACHE_DIRECTORIES.some((directory) => path.startsWith(directory)))
|
|
1142
|
-
return "harness-cache";
|
|
1143
|
-
return undefined;
|
|
1144
|
-
}
|
|
1145
1132
|
function withoutNativeContent(source) {
|
|
1146
1133
|
const metadata = { ...source };
|
|
1147
1134
|
delete metadata.contentBase64;
|
package/dist/tangle-types.d.ts
CHANGED
|
@@ -743,6 +743,8 @@ export interface SandboxSessionLike {
|
|
|
743
743
|
maxBytes: number;
|
|
744
744
|
maxFiles: number;
|
|
745
745
|
maxArchiveBytes?: number;
|
|
746
|
+
/** Session-home directories whose files are listed with metadata only; ignored by an older SDK. */
|
|
747
|
+
omitContent?: readonly string[];
|
|
746
748
|
signal?: AbortSignal;
|
|
747
749
|
}): Promise<unknown>;
|
|
748
750
|
/** Exact native coding-agent TUI bound to this session id. */
|