harness-dispatch 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +582 -0
- package/config.default.yaml +397 -0
- package/data/coding_benchmarks.json +431 -0
- package/dist/auth.d.ts +9 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +73 -0
- package/dist/auth.js.map +1 -0
- package/dist/billing.d.ts +7 -0
- package/dist/billing.d.ts.map +1 -0
- package/dist/billing.js +201 -0
- package/dist/billing.js.map +1 -0
- package/dist/bin.d.ts +6 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +488 -0
- package/dist/bin.js.map +1 -0
- package/dist/breaker-store.d.ts +31 -0
- package/dist/breaker-store.d.ts.map +1 -0
- package/dist/breaker-store.js +103 -0
- package/dist/breaker-store.js.map +1 -0
- package/dist/circuit-breaker.d.ts +47 -0
- package/dist/circuit-breaker.d.ts.map +1 -0
- package/dist/circuit-breaker.js +102 -0
- package/dist/circuit-breaker.js.map +1 -0
- package/dist/config.d.ts +48 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +1248 -0
- package/dist/config.js.map +1 -0
- package/dist/dashboard/live.d.ts +49 -0
- package/dist/dashboard/live.d.ts.map +1 -0
- package/dist/dashboard/live.js +149 -0
- package/dist/dashboard/live.js.map +1 -0
- package/dist/dispatch-log.d.ts +46 -0
- package/dist/dispatch-log.d.ts.map +1 -0
- package/dist/dispatch-log.js +89 -0
- package/dist/dispatch-log.js.map +1 -0
- package/dist/dispatchers/base.d.ts +55 -0
- package/dist/dispatchers/base.d.ts.map +1 -0
- package/dist/dispatchers/base.js +80 -0
- package/dist/dispatchers/base.js.map +1 -0
- package/dist/dispatchers/generic-cli.d.ts +30 -0
- package/dist/dispatchers/generic-cli.d.ts.map +1 -0
- package/dist/dispatchers/generic-cli.js +471 -0
- package/dist/dispatchers/generic-cli.js.map +1 -0
- package/dist/dispatchers/openai-compatible.d.ts +57 -0
- package/dist/dispatchers/openai-compatible.d.ts.map +1 -0
- package/dist/dispatchers/openai-compatible.js +662 -0
- package/dist/dispatchers/openai-compatible.js.map +1 -0
- package/dist/dispatchers/shared/kill-tree.d.ts +21 -0
- package/dist/dispatchers/shared/kill-tree.d.ts.map +1 -0
- package/dist/dispatchers/shared/kill-tree.js +35 -0
- package/dist/dispatchers/shared/kill-tree.js.map +1 -0
- package/dist/dispatchers/shared/rate-limit-headers.d.ts +22 -0
- package/dist/dispatchers/shared/rate-limit-headers.d.ts.map +1 -0
- package/dist/dispatchers/shared/rate-limit-headers.js +124 -0
- package/dist/dispatchers/shared/rate-limit-headers.js.map +1 -0
- package/dist/dispatchers/shared/stream-subprocess.d.ts +53 -0
- package/dist/dispatchers/shared/stream-subprocess.d.ts.map +1 -0
- package/dist/dispatchers/shared/stream-subprocess.js +274 -0
- package/dist/dispatchers/shared/stream-subprocess.js.map +1 -0
- package/dist/dispatchers/shared/subprocess.d.ts +25 -0
- package/dist/dispatchers/shared/subprocess.d.ts.map +1 -0
- package/dist/dispatchers/shared/subprocess.js +110 -0
- package/dist/dispatchers/shared/subprocess.js.map +1 -0
- package/dist/dispatchers/shared/which-available.d.ts +2 -0
- package/dist/dispatchers/shared/which-available.d.ts.map +1 -0
- package/dist/dispatchers/shared/which-available.js +8 -0
- package/dist/dispatchers/shared/which-available.js.map +1 -0
- package/dist/dispatchers/shared/windows-cmd.d.ts +38 -0
- package/dist/dispatchers/shared/windows-cmd.d.ts.map +1 -0
- package/dist/dispatchers/shared/windows-cmd.js +91 -0
- package/dist/dispatchers/shared/windows-cmd.js.map +1 -0
- package/dist/http/server.d.ts +15 -0
- package/dist/http/server.d.ts.map +1 -0
- package/dist/http/server.js +495 -0
- package/dist/http/server.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/job-runner.d.ts +19 -0
- package/dist/job-runner.d.ts.map +1 -0
- package/dist/job-runner.js +42 -0
- package/dist/job-runner.js.map +1 -0
- package/dist/jobs.d.ts +116 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +542 -0
- package/dist/jobs.js.map +1 -0
- package/dist/leaderboard.d.ts +62 -0
- package/dist/leaderboard.d.ts.map +1 -0
- package/dist/leaderboard.js +287 -0
- package/dist/leaderboard.js.map +1 -0
- package/dist/mcp/config-hot-reload.d.ts +64 -0
- package/dist/mcp/config-hot-reload.d.ts.map +1 -0
- package/dist/mcp/config-hot-reload.js +144 -0
- package/dist/mcp/config-hot-reload.js.map +1 -0
- package/dist/mcp/dispatcher-factory.d.ts +20 -0
- package/dist/mcp/dispatcher-factory.d.ts.map +1 -0
- package/dist/mcp/dispatcher-factory.js +30 -0
- package/dist/mcp/dispatcher-factory.js.map +1 -0
- package/dist/mcp/resources.d.ts +8 -0
- package/dist/mcp/resources.d.ts.map +1 -0
- package/dist/mcp/resources.js +45 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/server.d.ts +36 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +80 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +171 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +658 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/observability/index.d.ts +52 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +111 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/spans.d.ts +47 -0
- package/dist/observability/spans.d.ts.map +1 -0
- package/dist/observability/spans.js +72 -0
- package/dist/observability/spans.js.map +1 -0
- package/dist/quota.d.ts +91 -0
- package/dist/quota.d.ts.map +1 -0
- package/dist/quota.js +331 -0
- package/dist/quota.js.map +1 -0
- package/dist/route-policy.d.ts +24 -0
- package/dist/route-policy.d.ts.map +1 -0
- package/dist/route-policy.js +92 -0
- package/dist/route-policy.js.map +1 -0
- package/dist/router.d.ts +162 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +878 -0
- package/dist/router.js.map +1 -0
- package/dist/safety.d.ts +7 -0
- package/dist/safety.d.ts.map +1 -0
- package/dist/safety.js +33 -0
- package/dist/safety.js.map +1 -0
- package/dist/status.d.ts +100 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +228 -0
- package/dist/status.js.map +1 -0
- package/dist/types.d.ts +402 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +13 -0
- package/dist/version.js.map +1 -0
- package/dist/working-dir.d.ts +15 -0
- package/dist/working-dir.d.ts.map +1 -0
- package/dist/working-dir.js +22 -0
- package/dist/working-dir.js.map +1 -0
- package/dist/workspaces.d.ts +19 -0
- package/dist/workspaces.d.ts.map +1 -0
- package/dist/workspaces.js +352 -0
- package/dist/workspaces.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP server entry points for harness-dispatch.
|
|
3
|
+
*
|
|
4
|
+
* Exposes:
|
|
5
|
+
* startMcpServer({ configPath }) — stdio transport (default).
|
|
6
|
+
* The HTTP transport lives in ../http/server.ts so MCP-over-HTTP and the
|
|
7
|
+
* OpenAI-compatible REST API share one authenticated server.
|
|
8
|
+
*/
|
|
9
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
+
import { ConfigHotReloader, RuntimeHolder } from "./config-hot-reload.js";
|
|
11
|
+
export interface BuildMcpOptions {
|
|
12
|
+
/** Path to config.yaml. Omit to auto-detect installed CLIs. */
|
|
13
|
+
configPath?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface BuiltMcp {
|
|
16
|
+
server: McpServer;
|
|
17
|
+
holder: RuntimeHolder;
|
|
18
|
+
reloader: ConfigHotReloader;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build a fresh `McpServer` with all tools/resources registered against
|
|
22
|
+
* existing runtime state. The SDK's Protocol.connect() throws if called
|
|
23
|
+
* twice on the same Server instance ("use a separate Protocol instance per
|
|
24
|
+
* connection") — so any transport that needs its own connect() call (e.g.
|
|
25
|
+
* one StreamableHTTPServerTransport per HTTP MCP session) needs its own
|
|
26
|
+
* McpServer instance too. holder/reloader are cheap to share; the McpServer
|
|
27
|
+
* wrapper is not.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildMcpServerInstance(holder: RuntimeHolder, reloader: ConfigHotReloader): McpServer;
|
|
30
|
+
/** Bootstrap runtime state + build an `McpServer` with all tools registered. */
|
|
31
|
+
export declare function buildMcpServer(opts?: BuildMcpOptions): Promise<BuiltMcp>;
|
|
32
|
+
export interface McpHandle {
|
|
33
|
+
close(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export declare function startMcpServer(opts?: BuildMcpOptions): Promise<McpHandle>;
|
|
36
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAoB,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAmC5F,MAAM,WAAW,eAAe;IAC9B,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,iBAAiB,GAC1B,SAAS,CAQX;AAED,gFAAgF;AAChF,wBAAsB,cAAc,CAAC,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgBlF;AAMD,MAAM,WAAW,SAAS;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,wBAAsB,cAAc,CAAC,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,SAAS,CAAC,CASnF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP server entry points for harness-dispatch.
|
|
3
|
+
*
|
|
4
|
+
* Exposes:
|
|
5
|
+
* startMcpServer({ configPath }) — stdio transport (default).
|
|
6
|
+
* The HTTP transport lives in ../http/server.ts so MCP-over-HTTP and the
|
|
7
|
+
* OpenAI-compatible REST API share one authenticated server.
|
|
8
|
+
*/
|
|
9
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
11
|
+
import { bootstrapRuntime, ConfigHotReloader, RuntimeHolder } from "./config-hot-reload.js";
|
|
12
|
+
import { registerTools } from "./tools.js";
|
|
13
|
+
import { registerResources } from "./resources.js";
|
|
14
|
+
import { initObservability } from "../observability/index.js";
|
|
15
|
+
import { VERSION } from "../version.js";
|
|
16
|
+
const SERVER_NAME = "harness-dispatch";
|
|
17
|
+
const SERVER_VERSION = VERSION;
|
|
18
|
+
const SERVER_INSTRUCTIONS = "This server turns the machine's installed coding harnesses (Claude Code, Codex, " +
|
|
19
|
+
"Cursor, Antigravity) and configured local/remote API endpoints into tools you can " +
|
|
20
|
+
"call — delegate bounded coding work you'd otherwise do yourself (implement, fix, " +
|
|
21
|
+
"review, or plan a task in a project) to whichever backend best fits it, freeing " +
|
|
22
|
+
"your own context/quota for orchestration. `dispatch` always starts new work: it " +
|
|
23
|
+
"runs the task as a background job and waits a short grace window — a fast task " +
|
|
24
|
+
"returns its full result inline (completed: true); a slow one returns completed: " +
|
|
25
|
+
"false plus a jobId. Check on it with `job_status` (partial output while running, " +
|
|
26
|
+
"full result once done, or omit jobId to list every known job) — nothing is ever " +
|
|
27
|
+
"lost to a timeout, including this MCP call's own. Always pass workingDir " +
|
|
28
|
+
"(the caller's project root — it is NOT inferred) and hints.taskType " +
|
|
29
|
+
"(execute | plan | review | local) on every " +
|
|
30
|
+
"call; omitting either degrades routing or runs the task in the wrong directory. " +
|
|
31
|
+
"Check the `usage` tool before passing an unfamiliar model or route name — " +
|
|
32
|
+
"semantics differ per field: hints.model is forwarded to the picked harness as-is " +
|
|
33
|
+
"(routing.modelHintMatched tells you whether it also matched a route), fanout " +
|
|
34
|
+
"`models` only selects which routes run (it does not set their model), and forcing " +
|
|
35
|
+
"a specific backend is done with the top-level `service` param. Read " +
|
|
36
|
+
"harness-dispatch://status or harness-dispatch://status.json for route readiness, " +
|
|
37
|
+
"billing policy, and safety detail.";
|
|
38
|
+
/**
|
|
39
|
+
* Build a fresh `McpServer` with all tools/resources registered against
|
|
40
|
+
* existing runtime state. The SDK's Protocol.connect() throws if called
|
|
41
|
+
* twice on the same Server instance ("use a separate Protocol instance per
|
|
42
|
+
* connection") — so any transport that needs its own connect() call (e.g.
|
|
43
|
+
* one StreamableHTTPServerTransport per HTTP MCP session) needs its own
|
|
44
|
+
* McpServer instance too. holder/reloader are cheap to share; the McpServer
|
|
45
|
+
* wrapper is not.
|
|
46
|
+
*/
|
|
47
|
+
export function buildMcpServerInstance(holder, reloader) {
|
|
48
|
+
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION }, { instructions: SERVER_INSTRUCTIONS });
|
|
49
|
+
registerTools(server, { holder, reloader });
|
|
50
|
+
registerResources(server, { holder, reloader });
|
|
51
|
+
return server;
|
|
52
|
+
}
|
|
53
|
+
/** Bootstrap runtime state + build an `McpServer` with all tools registered. */
|
|
54
|
+
export async function buildMcpServer(opts = {}) {
|
|
55
|
+
const stateOpts = {};
|
|
56
|
+
if (opts.configPath !== undefined)
|
|
57
|
+
stateOpts.configPath = opts.configPath;
|
|
58
|
+
const state = await bootstrapRuntime(stateOpts);
|
|
59
|
+
// Telemetry is opt-in: initialize only after config load, gated on
|
|
60
|
+
// `telemetry: { enabled: true }` (or the HARNESS_DISPATCH_TELEMETRY env
|
|
61
|
+
// var, which initObservability checks itself). Idempotent.
|
|
62
|
+
if (state.config.telemetry?.enabled) {
|
|
63
|
+
await initObservability({ enabled: true });
|
|
64
|
+
}
|
|
65
|
+
const holder = new RuntimeHolder(state);
|
|
66
|
+
const reloader = new ConfigHotReloader(holder, opts.configPath);
|
|
67
|
+
const server = buildMcpServerInstance(holder, reloader);
|
|
68
|
+
return { server, holder, reloader };
|
|
69
|
+
}
|
|
70
|
+
export async function startMcpServer(opts = {}) {
|
|
71
|
+
const { server } = await buildMcpServer(opts);
|
|
72
|
+
const transport = new StdioServerTransport();
|
|
73
|
+
await server.connect(transport);
|
|
74
|
+
return {
|
|
75
|
+
async close() {
|
|
76
|
+
await server.close();
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,WAAW,GAAG,kBAAkB,CAAC;AACvC,MAAM,cAAc,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G,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,IAAI,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAEhE,MAAM,MAAM,GAAG,sBAAsB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACxD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACtC,CAAC;AAUD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAwB,EAAE;IAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO;QACL,KAAK,CAAC,KAAK;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool registry for harness-dispatch.
|
|
3
|
+
*
|
|
4
|
+
* The public MCP surface is three tools, each doing exactly one thing:
|
|
5
|
+
* `dispatch` starts routed work (single or fanout) and only ever starts —
|
|
6
|
+
* `job_status` checks or lists it, `usage` reads route/quota state. Every
|
|
7
|
+
* dispatch is job-backed from the first moment — dispatch races an inline
|
|
8
|
+
* grace window against the background run, so a fast task returns its full
|
|
9
|
+
* result in-call and a slow one degrades to a pollable jobId with NOTHING
|
|
10
|
+
* lost to a timeout; job_status is how that jobId gets checked on later.
|
|
11
|
+
* Status is also exposed as resources so clients can inspect state without
|
|
12
|
+
* a tool call.
|
|
13
|
+
*/
|
|
14
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
15
|
+
import type { ServerNotification } from "@modelcontextprotocol/sdk/types.js";
|
|
16
|
+
import { z } from "zod";
|
|
17
|
+
import type { RouteSkip, TaskType, WorkspaceRun } from "../types.js";
|
|
18
|
+
import type { RuntimeHolder, ConfigHotReloader } from "./config-hot-reload.js";
|
|
19
|
+
import { type JobStatus } from "../jobs.js";
|
|
20
|
+
declare const dispatchInputShape: {
|
|
21
|
+
readonly prompt: z.ZodString;
|
|
22
|
+
readonly mode: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
23
|
+
single: "single";
|
|
24
|
+
fanout: "fanout";
|
|
25
|
+
}>>>;
|
|
26
|
+
readonly files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
readonly workingDir: z.ZodOptional<z.ZodString>;
|
|
28
|
+
readonly workspacePolicy: z.ZodOptional<z.ZodEnum<{
|
|
29
|
+
shared: "shared";
|
|
30
|
+
shared_locked: "shared_locked";
|
|
31
|
+
git_worktree: "git_worktree";
|
|
32
|
+
copy: "copy";
|
|
33
|
+
}>>;
|
|
34
|
+
readonly hints: z.ZodOptional<z.ZodObject<{
|
|
35
|
+
model: z.ZodOptional<z.ZodString>;
|
|
36
|
+
taskType: z.ZodOptional<z.ZodEnum<{
|
|
37
|
+
execute: "execute";
|
|
38
|
+
plan: "plan";
|
|
39
|
+
review: "review";
|
|
40
|
+
local: "local";
|
|
41
|
+
}>>;
|
|
42
|
+
preferLargeContext: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
safetyProfile: z.ZodOptional<z.ZodEnum<{
|
|
44
|
+
read_only: "read_only";
|
|
45
|
+
workspace_edit: "workspace_edit";
|
|
46
|
+
full_auto: "full_auto";
|
|
47
|
+
}>>;
|
|
48
|
+
workspacePolicy: z.ZodOptional<z.ZodEnum<{
|
|
49
|
+
shared: "shared";
|
|
50
|
+
shared_locked: "shared_locked";
|
|
51
|
+
git_worktree: "git_worktree";
|
|
52
|
+
copy: "copy";
|
|
53
|
+
}>>;
|
|
54
|
+
routePolicy: z.ZodOptional<z.ZodEnum<{
|
|
55
|
+
standard: "standard";
|
|
56
|
+
local_only: "local_only";
|
|
57
|
+
approval_required: "approval_required";
|
|
58
|
+
blocked: "blocked";
|
|
59
|
+
}>>;
|
|
60
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
readonly models: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
readonly service: z.ZodOptional<z.ZodString>;
|
|
64
|
+
readonly graceSeconds: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
};
|
|
66
|
+
declare const jobStatusInputShape: {
|
|
67
|
+
readonly jobId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
};
|
|
69
|
+
export declare const TOOL_NAMES: readonly ["dispatch", "job_status", "usage"];
|
|
70
|
+
export interface RouteResponse {
|
|
71
|
+
success: boolean;
|
|
72
|
+
output: string;
|
|
73
|
+
error?: string;
|
|
74
|
+
/** Set when workingDir was omitted and defaulted to the router's own cwd. */
|
|
75
|
+
warning?: string;
|
|
76
|
+
route: string;
|
|
77
|
+
model?: string;
|
|
78
|
+
durationMs?: number;
|
|
79
|
+
tokensUsed?: {
|
|
80
|
+
input: number;
|
|
81
|
+
output: number;
|
|
82
|
+
};
|
|
83
|
+
skippedRoutes?: RouteSkip[];
|
|
84
|
+
workspace?: WorkspaceRun;
|
|
85
|
+
routing?: {
|
|
86
|
+
tier: number;
|
|
87
|
+
quotaScore: number;
|
|
88
|
+
qualityScore: number;
|
|
89
|
+
cliCapability: number;
|
|
90
|
+
capabilityScore: number;
|
|
91
|
+
taskType: TaskType;
|
|
92
|
+
elo?: number;
|
|
93
|
+
finalScore: number;
|
|
94
|
+
reason: string;
|
|
95
|
+
/**
|
|
96
|
+
* Set only when hints.model was provided on this call. true if it
|
|
97
|
+
* matched something the picked route statically declares; false if it
|
|
98
|
+
* was passed through "blind" because nothing recognized it (still
|
|
99
|
+
* forwarded to the dispatcher either way — hints.model is unvalidated
|
|
100
|
+
* by design). Use this to tell "got exactly what I asked for" apart
|
|
101
|
+
* from "might have a typo" without comparing strings yourself.
|
|
102
|
+
*/
|
|
103
|
+
modelHintMatched?: boolean;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export interface FanoutItem {
|
|
107
|
+
route: string;
|
|
108
|
+
jobId: string;
|
|
109
|
+
/** false = still running past the grace window; poll its jobId. */
|
|
110
|
+
completed: boolean;
|
|
111
|
+
success?: boolean;
|
|
112
|
+
output?: string;
|
|
113
|
+
error?: string;
|
|
114
|
+
durationMs?: number;
|
|
115
|
+
capabilityScore: number;
|
|
116
|
+
qualityScore: number;
|
|
117
|
+
elo?: number;
|
|
118
|
+
workspace?: WorkspaceRun;
|
|
119
|
+
/** Tail of live output for a not-yet-completed item. */
|
|
120
|
+
partialOutput?: string;
|
|
121
|
+
}
|
|
122
|
+
/** A started dispatch: full inline result if it beat the grace window, else a pollable handle. */
|
|
123
|
+
export type DispatchResponse = ({
|
|
124
|
+
mode: "single";
|
|
125
|
+
jobId: string;
|
|
126
|
+
completed: true;
|
|
127
|
+
} & RouteResponse) | {
|
|
128
|
+
mode: "single";
|
|
129
|
+
jobId: string;
|
|
130
|
+
completed: false;
|
|
131
|
+
partialOutput?: string;
|
|
132
|
+
nextPollSeconds?: number;
|
|
133
|
+
instructions?: string;
|
|
134
|
+
warning?: string;
|
|
135
|
+
} | {
|
|
136
|
+
mode: "fanout";
|
|
137
|
+
/** true when every item finished within the grace window. */
|
|
138
|
+
completed: boolean;
|
|
139
|
+
results: FanoutItem[];
|
|
140
|
+
skippedRoutes?: RouteSkip[];
|
|
141
|
+
warning?: string;
|
|
142
|
+
};
|
|
143
|
+
export interface DispatchPollResponse {
|
|
144
|
+
jobId: string;
|
|
145
|
+
completed: boolean;
|
|
146
|
+
status: JobStatus;
|
|
147
|
+
/** Present once the run completed or failed with a recorded result. */
|
|
148
|
+
result?: RouteResponse;
|
|
149
|
+
/** Tail of live output while still running. */
|
|
150
|
+
partialOutput?: string;
|
|
151
|
+
}
|
|
152
|
+
export interface ToolDeps {
|
|
153
|
+
holder: RuntimeHolder;
|
|
154
|
+
reloader?: ConfigHotReloader;
|
|
155
|
+
}
|
|
156
|
+
export interface ToolExtra {
|
|
157
|
+
_meta?: {
|
|
158
|
+
progressToken?: string | number;
|
|
159
|
+
} & Record<string, unknown>;
|
|
160
|
+
sendNotification?: (notification: ServerNotification) => Promise<void>;
|
|
161
|
+
}
|
|
162
|
+
export declare function handleDispatch(deps: ToolDeps, input: z.infer<z.ZodObject<typeof dispatchInputShape>>, extra?: ToolExtra): Promise<unknown>;
|
|
163
|
+
export declare function handleJobStatus(input: z.infer<z.ZodObject<typeof jobStatusInputShape>>): Promise<unknown>;
|
|
164
|
+
export declare function registerTools(server: McpServer, deps: ToolDeps): void;
|
|
165
|
+
export type InvokeResult = {
|
|
166
|
+
kind: "json";
|
|
167
|
+
data: unknown;
|
|
168
|
+
};
|
|
169
|
+
export declare function invokeTool(name: string, args: unknown, deps: ToolDeps): Promise<InvokeResult>;
|
|
170
|
+
export {};
|
|
171
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAkB,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAKV,SAAS,EACT,QAAQ,EAER,YAAY,EACb,MAAM,aAAa,CAAC;AAIrB,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAoD,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAmF9F,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Dd,CAAC;AAEX,QAAA,MAAM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