import type { ExecutionClass } from "../config/types.js"; import type { PoolId } from "../pools/index.js"; import type { SubagentExecutionRequest } from "../workers/types.js"; import { type BuildTaskPacketInput, type ContextBrokerLimits, type ContextJson, type PacketCanonicalItem, type TaskPacketV1 } from "./types.js"; export type PacketErrorCode = "invalid-packet" | "invalid-json" | "digest-mismatch"; export declare class TaskPacketError extends Error { readonly code: PacketErrorCode; constructor(code: PacketErrorCode, message: string); } /** * Convert unknown repository values into bounded, secret-free JSON. The * Context Broker owns this boundary so callers never pass live object graphs * or arbitrary class instances into a child prompt. */ export declare function toContextJson(value: unknown, seen?: WeakSet): ContextJson; export declare function canonicalPacketJson(packet: unknown): string; /** SHA-256 over the canonical packet, excluding its self-referential digest. */ export declare function packetDigest(packet: TaskPacketV1 | Omit): string; export declare const computePacketDigest: typeof packetDigest; export declare function verifyPacketDigest(packet: TaskPacketV1): boolean; export declare function assertPacketDigest(packet: TaskPacketV1): void; /** Deep freeze a packet and every JSON value reachable from it. */ export declare function freezeTaskPacket(packet: T): Readonly; export declare function packetIdSeed(packet: Omit): string; export declare function defaultPacketId(seed: string): string; export declare function boundedLimits(input: ContextBrokerLimits, fallback?: ContextBrokerLimits): Required; export declare function buildPacketDigestInput(packet: Omit): string; export declare function makePacketId(input: BuildTaskPacketInput & { readonly sourceMissionRevision: number; }, digestSeed: string, factory?: (input: { readonly missionId: string; readonly taskId: string; readonly sourceMissionRevision: number; readonly digestSeed: string; }) => string): string; export declare function normalizeText(value: string, maxChars: number): string; export declare function normalizeStringList(values: readonly string[] | undefined, maxChars: number): readonly string[]; export declare function normalizeExecutionClass(value: ExecutionClass | undefined, poolId: PoolId | undefined): ExecutionClass; export declare function normalizePoolId(value: PoolId | undefined, executionClass: ExecutionClass): PoolId; export declare function normalizeJsonList(values: readonly unknown[] | undefined, maxItemChars: number): readonly ContextJson[]; export declare function itemJsonLength(item: PacketCanonicalItem): number; /** Render only the bounded packet projection; no parent transcript is copied. */ export declare function renderTaskPacketPrompt(packet: TaskPacketV1): string; /** Adapt a packet to the M5 worker request without giving the worker extra context. */ export declare function packetToSubagentRequest(packet: TaskPacketV1, options?: { readonly cwd?: string; readonly timeoutMs?: number; readonly excludedRouteIds?: readonly import("../config/types.js").StableId[]; }): SubagentExecutionRequest; export declare const createChildRequestFromPacket: typeof packetToSubagentRequest; export declare const taskPacketPrompt: typeof renderTaskPacketPrompt;