Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

refactor(web): share retained text artifact metadata

morlutoc0eb61278036
diff --git a/src/domain/webBundleAnalysis.ts b/src/domain/webBundleAnalysis.ts
index 0fee60d97..da6acfbd1 100644
--- a/src/domain/webBundleAnalysis.ts
+++ b/src/domain/webBundleAnalysis.ts
@@ -9,7 +9,10 @@ import {
} from "./browserDeadline.js";
import { emptyArraySchema } from "./emptyArraySchema.js";
import { inspectWebPageWithSourceInputSchema } from "./browserObservation.js";
-import { webTextArtifactSchema } from "./webContentArtifact.js";
+import {
+ webTextArtifactMetadataSchema,
+ webTextArtifactSchema,
+} from "./webContentArtifact.js";
/** Isolated analyzer heap used when max_heap_mb is omitted. */
export const DEFAULT_WEB_BUNDLE_HEAP_MB = 1024;
@@ -298,11 +301,7 @@ const sourceMapSchema = z.union([
}),
]);
-const webTextArtifactSummarySchema = z.object({
- sha256: z.string().regex(/^[a-f0-9]{64}$/u),
- bytes: z.number().int().min(0),
- media_type: z.string().min(1),
- charset: z.literal("utf-8"),
+const webTextArtifactSummarySchema = webTextArtifactMetadataSchema.extend({
text_available: z.literal(true),
});
diff --git a/src/domain/webContentArtifact.ts b/src/domain/webContentArtifact.ts
index a5224341e..0d9a49208 100644
--- a/src/domain/webContentArtifact.ts
+++ b/src/domain/webContentArtifact.ts
@@ -2,15 +2,17 @@ import { createHash } from "node:crypto";
import { z } from "zod";
+/** Metadata shared by complete and summarized retained web text artifacts. */
+export const webTextArtifactMetadataSchema = z.object({
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u),
+ bytes: z.number().int().min(0),
+ media_type: z.string().min(1),
+ charset: z.literal("utf-8"),
+});
+
/** Self-verifying text artifact used by web-source analysis boundaries. */
-export const webTextArtifactSchema = z
- .object({
- sha256: z.string().regex(/^[a-f0-9]{64}$/u),
- bytes: z.number().int().min(0),
- media_type: z.string().min(1),
- charset: z.literal("utf-8"),
- text: z.string(),
- })
+export const webTextArtifactSchema = webTextArtifactMetadataSchema
+ .extend({ text: z.string() })
.superRefine((artifact, context) => {
const bytes = Buffer.byteLength(artifact.text);
const digest = createHash("sha256").update(artifact.text).digest("hex");