/** * Graph Execution Engine v2 — Imperative `graph_*` Tool Registration * * Version: 2.0 * Date: 2026-07-25 * * Phase 4, Subtask 6. Wraps the {@link GraphToolSet} tool-logic layer (subtask * 5, `graph-tools.ts`) with zod `args` schemas and `defineTool` registrations * so the eight imperative `graph_*` tools become platform-agnostic * {@link CanonicalToolDef}s consumable by `buildCanonicalTools`. * * The arg schemas mirror `.rolebox/design/tool-merge-map.md` §2.2, adapted to * the real TypeScript arg shapes exported by `graph-tools.ts` (which are * documented as divergences in that module's header — e.g. `join` is the * structured `JoinConfig`, edge `retry` accepts `number | RetryConfig`). This * module contains **no graph logic** — it only adapts types and error text. * * ## Precedence contract * * This factory is additive. Its keys are the `graph_*` namespace, which does * not collide with any existing `dispatch_*` / `loop_*` tool key. Registration * therefore never overrides a legacy tool. In `tool-assembly.ts` the graph * tools are merged with the same additive pattern as `extraTools` / * `loopToolsOverride` (Object.assign onto the assembled map). * * Design reference: `.rolebox/design/tool-merge-map.md` §2.2, §3, §4 (Phase A). */ import type { CanonicalToolDef } from "../../platform/types.ts"; import type { DispatchManager } from "../../dispatch/core/manager.ts"; import type { NodeLivenessFeed, NodeDispatchPort } from "../engine/index.ts"; import { type GraphToolSet, type GraphNotifySource } from "./graph-tools.ts"; /** * Build the eight imperative `graph_*` tools bound to a dispatch manager and * a single in-memory graph registry (one shared `GraphToolSet` instance). * * @param manager - Active {@link DispatchManager}; required for non dry-run * execution. Optional for construction/status/cancel/dry-run. * @param opts.directory - Working directory for graph node dispatches. * @param opts.stateDir - Optional engine-state persistence dir. * @param opts.dispatch - Optional dispatch seam (a {@link NodeDispatchPort}). * When present it is threaded into the constructed toolset in place of * the manager-backed bridge — the dsh platform path constructs graph * tools with {@link DshDispatchAdapter} this way, while the opencode * path keeps using `manager` unchanged (additive routing by platform). * @param opts.graphNotify - Optional graph node-completion + graph-terminal * notifier (subtask 3): a prebuilt `GraphCompletionHandler` or an owner * config carrying the emperor session + session client. Threaded into * every engine the toolset constructs so graph node completions AND * graph-terminal transitions route to graph-notify targeting the emperor * session. More here in src/graph/tools/graph-tools.ts. * @param opts.toolset - Optional prebuilt {@link GraphToolSet} (subtask 2). * When provided, the tools bind to THIS instance instead of * constructing a fresh one — letting a platform assembly layer (e.g. * tool-service / PiLightweightServiceStack) construct the toolset once * and reuse it for both the `graph_*` tools AND the HookDeps * `graphTools` query, so the two surfaces always observe the same * in-memory graph registry. * @returns A record of `graph_*` key → {@link CanonicalToolDef}. */ export declare function createGraphTools(manager: DispatchManager | undefined, opts?: { directory?: string; stateDir?: string; graphNotify?: GraphNotifySource; toolset?: GraphToolSet; /** * Optional dispatch seam (a {@link NodeDispatchPort}) threaded into the * constructed toolset in place of the manager-backed bridge. This is the * additive dsh platform path: `createGraphTools(undefined, { dispatch })` * builds a toolset whose engines dispatch through the dsh subagent seam * while the opencode path (`manager` only) is byte-identical. When both * are present, `dispatch` wins over the manager bridge (mirrors * `createEngine`'s explicit > manager precedence). */ dispatch?: NodeDispatchPort; nodeStallWarnMs?: number; nodeStallGraceMs?: number; livenessFeed?: NodeLivenessFeed; /** * Optional platform-provided acting-agent resolver. Mirrors the dispatch * path's `getEffectiveAgent` deps injection (`src/dispatch/tools.ts:70-73`): * on platforms where `context.agent` is never populated (Pi / DSH), the * graph tools fall back to this resolver so the injected `` * still forwards the orchestrator's real role instead of falling back to * `default_agent`. Receives the invoking session id so a per-session * resolver (e.g. DSH's role switcher) can resolve the active role for that * session. Absent → `context.agent`-only (opencode, unchanged). */ getEffectiveAgent?: (sessionID?: string) => string; }): Record; export type { GraphNotifySource, GraphNotifyConfig, } from "./graph-tools.ts"; export { createGraphToolSet, type GraphToolSet } from "./graph-tools.ts"; //# sourceMappingURL=index.d.ts.map