@tangle-network/agent-provider-tangle 4.4.1 → 4.4.2

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.
@@ -127,8 +127,8 @@ export interface TangleEnvironmentEvidence {
127
127
  sizeBytes: number;
128
128
  sha256: string | null;
129
129
  linkTarget: string | null;
130
- /** Metadata only: the bytes are a harness's own install, not session state. */
131
- contentOmitted?: "harness-install";
130
+ /** Metadata only: the bytes are a harness's own install or cache, which it rebuilds on start. */
131
+ contentOmitted?: HarnessContentOmission;
132
132
  }>;
133
133
  excludedPaths: Array<{
134
134
  sourceId?: string;
@@ -199,4 +199,5 @@ export declare function captureTangleEnvironmentEvidenceToDirectory(environment:
199
199
  export declare function captureTangleSandboxEvidenceToDirectory(box: SandboxInstanceLike, options: TangleSandboxEvidenceOptions & TangleDirectoryEvidenceOptions): Promise<TangleDirectoryEvidence>;
200
200
  /** Export exact Sandbox session and workspace evidence before its owning box is deleted. */
201
201
  export declare function captureTangleSandboxEvidence(box: SandboxInstanceLike, options: TangleSandboxEvidenceOptions): Promise<TangleEnvironmentEvidence>;
202
+ type HarnessContentOmission = "harness-install" | "harness-cache";
202
203
  export {};
@@ -531,8 +531,8 @@ async function captureSandboxEvidence(box, options, writer) {
531
531
  nativePaths.add(identity);
532
532
  if (!nativeStatMetadata(entry))
533
533
  throw new Error("Tangle raw session entry metadata is invalid");
534
- const harnessInstall = entry.kind === "file" && harnessInstallPath(path);
535
- if (entry.kind === "file" && !harnessInstall) {
534
+ const omitted = entry.kind === "file" ? harnessContentOmission(entry.rootScope, path) : undefined;
535
+ if (entry.kind === "file" && !omitted) {
536
536
  const contentPath = "__retention__/sessions/" + id + "/native/" +
537
537
  (entry.sourceId === undefined ? "" : entry.sourceId + "/") + entry.rootScope + "/" + path;
538
538
  await retainNativeContent(entry, contentPath, entry.mode & 0o777);
@@ -557,7 +557,7 @@ async function captureSandboxEvidence(box, options, writer) {
557
557
  rootScope: entry.rootScope, path, kind: entry.kind, mode: entry.mode,
558
558
  uid: entry.uid, gid: entry.gid, mtimeMs: entry.mtimeMs, ctimeMs: entry.ctimeMs,
559
559
  sizeBytes: entry.sizeBytes, sha256: entry.sha256 ?? null, linkTarget: entry.linkTarget ?? null,
560
- ...(harnessInstall ? { contentOmitted: "harness-install" } : {}),
560
+ ...(omitted ? { contentOmitted: omitted } : {}),
561
561
  });
562
562
  }
563
563
  for (const exclusion of native.excluded) {
@@ -735,10 +735,12 @@ async function captureSandboxEvidence(box, options, writer) {
735
735
  manifestSource = {
736
736
  ...native,
737
737
  events: native.events.map((record) => withoutRepeatedFrameText(record, nativePartText)),
738
- files: native.files.map((entry) => entry.kind !== "file" ? entry
739
- : harnessInstallPath(entry.path)
740
- ? { ...withoutNativeContent(entry), contentOmitted: "harness-install" }
741
- : withoutNativeContent(entry)),
738
+ files: native.files.map((entry) => {
739
+ if (entry.kind !== "file")
740
+ return entry;
741
+ const omitted = harnessContentOmission(entry.rootScope, entry.path);
742
+ return omitted ? { ...withoutNativeContent(entry), contentOmitted: omitted } : withoutNativeContent(entry);
743
+ }),
742
744
  processIo: frameMetadata,
743
745
  processSources: native.processSources.map(withoutNativeContent),
744
746
  };
@@ -946,9 +948,20 @@ function withoutRepeatedFrameText(record, previous) {
946
948
  return record;
947
949
  return { ...record, frames: frames.map(compact) };
948
950
  }
949
- /** A harness's installed packages under its home, e.g. `.config/opencode/node_modules`. */
950
- function harnessInstallPath(path) {
951
- return path.split("/").includes("node_modules");
951
+ /**
952
+ * Codex caches under its home that it downloads again on start: plugin template assets and
953
+ * the remote plugin and apps catalogs. Session state (`.codex/sessions`, the thread sqlite,
954
+ * config) stays. One canary's capture was 84% these directories (186.8 MB of evidence).
955
+ */
956
+ const HARNESS_CACHE_DIRECTORIES = [".codex/plugins/cache/", ".codex/cache/remote_plugin_catalog/", ".codex/cache/codex_apps_tools/"];
957
+ /** Why a native file keeps only its metadata, or undefined when its bytes are session state. */
958
+ function harnessContentOmission(rootScope, path) {
959
+ // A harness's installed packages, e.g. `.config/opencode/node_modules`.
960
+ if (path.split("/").includes("node_modules"))
961
+ return "harness-install";
962
+ if (rootScope === "session-home" && HARNESS_CACHE_DIRECTORIES.some((directory) => path.startsWith(directory)))
963
+ return "harness-cache";
964
+ return undefined;
952
965
  }
953
966
  function withoutNativeContent(source) {
954
967
  const metadata = { ...source };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-provider-tangle",
3
- "version": "4.4.1",
3
+ "version": "4.4.2",
4
4
  "description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
5
5
  "type": "module",
6
6
  "license": "MIT",