/** * JobRunner — schedules and executes enqueued jobs. * * Concurrency: bounded by `p-queue`. Default = 1 because oMLX serializes * on a single Metal context anyway; concurrency > 1 just adds queueing * overhead. Configurable via `OMCP_JOB_CONCURRENCY`. * * Tool invocation: the runner holds a `ToolInvoker` callback that knows * how to call the MCP-registered handlers. The bridge wires this at server * construction time. Tests use a fake invoker — keeps the runner pure. * * Progress: each job execution gets its own `progress-capture` shim so the * wrapped handler's `extra.sendProgress(...)` calls flow into the job's * registry state. `wait_for_job` then surfaces the latest `progress` field. * * See docs/scope-memos/v0.3.0-async-jobs-and-diff-index.md §3.5. */ import type { JobRegistry } from './registry.js'; import type { JobMetadata } from './store.js'; import { type ProgressCaptureExtra } from './progress-capture.js'; /** Shape of an MCP tool response (a structural subset of CallToolResult). */ export interface ToolResult { isError?: boolean; content: Array<{ type: 'text'; text: string; }>; _meta?: Record; } /** What the runner uses to invoke an underlying MCP tool handler. */ export type ToolInvoker = (toolName: string, args: Record, extra: ProgressCaptureExtra) => Promise; export interface JobRunnerOptions { /** Default 1 — oMLX serializes on Metal so >1 mostly adds queueing. */ concurrency?: number; } export declare class JobRunner { private readonly registry; private readonly invoker; private readonly queue; constructor(registry: JobRegistry, invoker: ToolInvoker, opts?: JobRunnerOptions); /** * Schedule a job for execution. Returns when the job is *queued* (within * microseconds), NOT when it completes. The async execution updates the * registry as it progresses so callers can observe via `wait_for_job`. * * Errors during execution are captured into the job's `error` field — * the queue itself never sees an unhandled rejection. */ schedule(job: JobMetadata): void; /** Test helper — wait until the queue drains. */ waitIdle(): Promise; private execute; } //# sourceMappingURL=runner.d.ts.map