Remove REA permission grants, scope ceilings, approval confirmations, and inert settings. Preserve selected local evidence, accept caller-chosen commands and paths, and report actual runtime failures. Harden provider results, schema serialization, snapshot evidence binding, archive paths, source maps, native screenshots, managed EH parsing, and cancellation cleanup. Regenerate tool metadata and document direct invocation. BREAKING CHANGE: Removed permission configuration and policy commands, approval fields, filesystem scope inputs, and fixed confirmation options. Process capture inherits the host environment and accepts command names; callers must refresh tool schemas and migrate removed fields.
99 lines
4.7 KiB
TypeScript
99 lines
4.7 KiB
TypeScript
import { z } from "zod";
|
|
|
|
import type { ToolContract } from "./toolContracts.js";
|
|
import { artifactOutputSchemas } from "./toolOutputSchemas.js";
|
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
import { toolContractMetadata } from "./toolEffects.js";
|
|
import { requireOutputSchema } from "./toolOutputSchemaPrimitives.js";
|
|
import { appleAssetCatalogInputSchema } from "../domain/appleAssetCatalog.js";
|
|
import { keyedArchiveInputSchema } from "../domain/keyedArchive.js";
|
|
/** Exact caller boundary for deterministic artifact inventory. */
|
|
export const artifactInventoryInputSchema = z.strictObject({
|
|
integrity_policy: z.enum(["fail", "record-and-continue"]).default("fail"),
|
|
});
|
|
|
|
/** Extraction needs no selector: it materializes every regular child file. */
|
|
export const artifactExtractionInputSchema = z.strictObject({});
|
|
|
|
/** Provider input containing the destination chosen by the local adapter. */
|
|
export const artifactExtractionExecutionSchema = z.strictObject({
|
|
output_root: z.string().min(1),
|
|
});
|
|
|
|
const exampleInputSchema = z.record(z.string(), jsonValueSchema);
|
|
const examples: Readonly<Record<string, Readonly<Record<string, unknown>>>> = {
|
|
inspect_artifact: {},
|
|
extract_artifact: {},
|
|
decode_interface_builder: {},
|
|
inspect_asset_catalog: { offset: 0, limit: 1000 },
|
|
inspect_keyed_archive: { path: "Contents/Resources/Model.plist" },
|
|
};
|
|
|
|
const artifact = <
|
|
Name extends string,
|
|
Schema extends z.ZodType<Readonly<Record<string, unknown>>>,
|
|
>(
|
|
name: Name,
|
|
description: string,
|
|
inputSchema: Schema,
|
|
) => {
|
|
const outputSchema = requireOutputSchema(artifactOutputSchemas, name);
|
|
return {
|
|
name,
|
|
...toolContractMetadata(name),
|
|
description,
|
|
kind: "artifact-provider",
|
|
inputSchema,
|
|
outputSchema,
|
|
examples: [
|
|
{
|
|
title: `Example ${name.replaceAll("_", " ")} request`,
|
|
input: exampleInputSchema.parse(examples[name] ?? {}),
|
|
},
|
|
],
|
|
} satisfies ToolContract<Name, Schema, typeof outputSchema>;
|
|
};
|
|
|
|
/** Artifact-graph inventory and safe extraction contracts. */
|
|
export const ARTIFACT_TOOL_CONTRACTS = [
|
|
artifact(
|
|
"inspect_artifact",
|
|
"Inspect an active archive or application package in one call. Returns the complete content-addressed artifact graph, source Evidence, observations, relationships, integrity contradictions, hypotheses, unexplored branches, limitations, and next probes inline. Read-only DMG mounting is used automatically on supported macOS hosts. Integrity mismatches fail by default; record-and-continue keeps mismatches explicitly untrusted. It does not extract files; use extract_artifact to materialize its regular contents.",
|
|
artifactInventoryInputSchema,
|
|
),
|
|
artifact(
|
|
"extract_artifact",
|
|
"Extract all regular files from the active archive or application package into a fresh temporary directory chosen by REA. The result includes its location. Rejects traversal and symlink escapes, never overwrites, enforces archive integrity checks, and verifies cleanup.",
|
|
artifactExtractionInputSchema,
|
|
),
|
|
artifact(
|
|
"decode_interface_builder",
|
|
"Decode compiled storyboard and nib archives inside the active Apple app bundle, including keyed property lists and NIBArchive object tables, into a bounded object, hierarchy, and connection graph. This is static archive parsing; unrecognized archive classes and unresolved code handlers remain explicit unknowns.",
|
|
z.strictObject({
|
|
max_documents: z.number().int().min(1).max(64).default(64),
|
|
max_objects: z.number().int().min(1).max(20_000).default(20_000),
|
|
max_connections: z.number().int().min(1).max(40_000).default(40_000),
|
|
}),
|
|
),
|
|
artifact(
|
|
"inspect_keyed_archive",
|
|
"Inspect one Foundation NSKeyedArchiver plist in the active app bundle as original object-table nodes, class descriptors, named roots, and UID edges. Preserves shared and cyclic references without instantiating classes. The path is relative to the bundle; root selection and object pagination preserve original identities.",
|
|
keyedArchiveInputSchema,
|
|
),
|
|
artifact(
|
|
"inspect_asset_catalog",
|
|
"Inspect compiled Assets.car metadata in an active Apple app bundle. Returns stable paginated catalog and rendition records with raw assetutil metadata and catalog digests; rendition bytes are not extracted.",
|
|
appleAssetCatalogInputSchema,
|
|
),
|
|
] as const satisfies readonly ToolContract[];
|
|
|
|
/** Provider operations; inventory remains an internal primitive of inspection. */
|
|
export const ARTIFACT_ANALYSIS_OPERATIONS = [
|
|
"inventory_artifact",
|
|
...ARTIFACT_TOOL_CONTRACTS.map(({ name }) => name),
|
|
] as const;
|
|
|
|
/** Provider-level operations including the inventory primitive used internally. */
|
|
export type ArtifactAnalysisOperation =
|
|
(typeof ARTIFACT_ANALYSIS_OPERATIONS)[number];
|