/** * tm layer — the shared governance pipeline + tm_fetch retrieval. Split out of * the former tools.ts hub. Assembly lives in tools.ts. * * tm_fetch — paged/structured retrieval of offloaded payloads (handles) * * (tm_read / tm_grep / tm_bash were the v1-only governed passthroughs and are * gone with the v1 personality: on v2 the host's native read / grep / shell are * governed by src/host/v2-offload.ts through the SAME `govern` seam below.) * * Shared governance (every tool): threshold offload (per content class: * TM_OFFLOAD_THRESHOLD_TEXT for markdown/text/log prose, * TM_OFFLOAD_THRESHOLD_DATA for json/csv/code/binary; an unknown/absent * class falls back to the global TM_OFFLOAD_THRESHOLD — backward * compatible), R6 reuse (same envprotect matchers as the global hook — * anti-backdoor), structured errors (never a bare throw), and store * failure degradation (governance faults never fail the task). */ import type * as crypto from "node:crypto"; import type { EnvProtectMode } from "../envprotect.js"; import { type TmConfig } from "./config.js"; import type { RunStore } from "./store.js"; import { detectContentType } from "./preview.js"; export interface TmDeps { client: unknown; $: unknown; cfg: TmConfig; store: RunStore; runId: string; /** Store-persisted HMAC key — used to VERIFY handle tokens in tm_fetch. * Persisted at the store root so a handle survives a plugin restart. */ hmacKey: crypto.BinaryLike; accessToken: string; expireAt: number; mode: EnvProtectMode; extra: RegExp[]; /** * Step-id namespace prefix for SECONDARY pipeline instances. A second * buildPipelines instance (PTC's) starts its counter at s0001 again — * without a distinct prefix its offloaded payloads would collide with * the main pipeline's same-numbered steps inside the shared run store * (refs ignore seq, so tm_fetch's last-append-wins would return the * WRONG payload). PTC passes "ptc-"; the main instance stays "". */ stepPrefix?: string; /** * Workspace root (the server() directory). Fix batch T3: the ctxDir * fallback when the execute ctx carries no directory — the desktop * sidecar's process cwd is the user HOME, NOT the workspace, so a * HOME-cwd would misresolve every relative path. */ workspaceDir?: string; } interface GovernOptions { contentType: ReturnType; clue?: string; /** * Skip ONLY the threshold test and offload regardless of size. The preview / * handle / store path is reused verbatim, so this is not a second offload * implementation — it is the same one with the "is it big enough?" question * answered by the caller (context pruning: a body that is about to be REPLACED * must be recoverable whatever its size, since after the prune its threshold * will never be re-evaluated). */ alwaysOffload?: boolean; } /** * Dot-path projection over an offloaded JSON payload. Grammar (the * deliberately small jq subset): segments split on ".", each `name`, * `name[]` (map into the array) or `[]` (expand the current arrays) — * e.g. `items[].name`, `[].stargazers_count`, `query.pages`. Returns null * when the body is not valid JSON (the caller then IGNORES `fields` and * serves the normal paged mode — non-JSON handles keep the old behavior). */ export declare function projectJsonFields(body: string, path: string, cap: number): { values: string[]; matched: number; truncated: boolean; } | null; export declare function buildPipelines(deps: TmDeps): { nextStepId: () => string; govern: (stepId: string, tool: string, content: string, opts: GovernOptions) => unknown; tmFetch: (rawArgs: Record, _ctx: unknown) => Promise; store: RunStore; }; /** The shared governance seam + tm_fetch retrieval (v2 native-offload + every * governed tool's offload path call `govern`; PTC's separate instance is gone * with the v1 personality). */ export type TmPipelines = ReturnType; export {}; //# sourceMappingURL=pipelines.d.ts.map