claude-opencode-mcp 1.0.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/CHANGELOG.md +56 -0
- package/LICENSE +21 -0
- package/README.md +514 -0
- package/SECURITY.md +80 -0
- package/agents/deepseek-coder.md +32 -0
- package/agents/deepseek-researcher.md +36 -0
- package/agents/deepseek-reviewer.md +31 -0
- package/agents/deepseek-tester.md +31 -0
- package/dist/cli/init.d.ts +6 -0
- package/dist/cli/init.js +208 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/config/config.d.ts +109 -0
- package/dist/config/config.js +163 -0
- package/dist/config/config.js.map +1 -0
- package/dist/errors.d.ts +29 -0
- package/dist/errors.js +68 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +116 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/execute.d.ts +30 -0
- package/dist/mcp/execute.js +128 -0
- package/dist/mcp/execute.js.map +1 -0
- package/dist/mcp/server.d.ts +19 -0
- package/dist/mcp/server.js +38 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/session-utils.d.ts +5 -0
- package/dist/mcp/session-utils.js +55 -0
- package/dist/mcp/session-utils.js.map +1 -0
- package/dist/mcp/tool-utils.d.ts +11 -0
- package/dist/mcp/tool-utils.js +44 -0
- package/dist/mcp/tool-utils.js.map +1 -0
- package/dist/mcp/tools/abort-session.d.ts +3 -0
- package/dist/mcp/tools/abort-session.js +48 -0
- package/dist/mcp/tools/abort-session.js.map +1 -0
- package/dist/mcp/tools/create-session.d.ts +3 -0
- package/dist/mcp/tools/create-session.js +53 -0
- package/dist/mcp/tools/create-session.js.map +1 -0
- package/dist/mcp/tools/delegate-task.d.ts +4 -0
- package/dist/mcp/tools/delegate-task.js +98 -0
- package/dist/mcp/tools/delegate-task.js.map +1 -0
- package/dist/mcp/tools/get-diff.d.ts +3 -0
- package/dist/mcp/tools/get-diff.js +97 -0
- package/dist/mcp/tools/get-diff.js.map +1 -0
- package/dist/mcp/tools/get-session.d.ts +3 -0
- package/dist/mcp/tools/get-session.js +79 -0
- package/dist/mcp/tools/get-session.js.map +1 -0
- package/dist/mcp/tools/list-agents.d.ts +3 -0
- package/dist/mcp/tools/list-agents.js +72 -0
- package/dist/mcp/tools/list-agents.js.map +1 -0
- package/dist/mcp/tools/send-message.d.ts +3 -0
- package/dist/mcp/tools/send-message.js +59 -0
- package/dist/mcp/tools/send-message.js.map +1 -0
- package/dist/opencode/agents.d.ts +46 -0
- package/dist/opencode/agents.js +239 -0
- package/dist/opencode/agents.js.map +1 -0
- package/dist/opencode/binary.d.ts +19 -0
- package/dist/opencode/binary.js +129 -0
- package/dist/opencode/binary.js.map +1 -0
- package/dist/opencode/client.d.ts +32 -0
- package/dist/opencode/client.js +55 -0
- package/dist/opencode/client.js.map +1 -0
- package/dist/opencode/manager.d.ts +66 -0
- package/dist/opencode/manager.js +492 -0
- package/dist/opencode/manager.js.map +1 -0
- package/dist/opencode/permission-watcher.d.ts +26 -0
- package/dist/opencode/permission-watcher.js +144 -0
- package/dist/opencode/permission-watcher.js.map +1 -0
- package/dist/opencode/run.d.ts +39 -0
- package/dist/opencode/run.js +318 -0
- package/dist/opencode/run.js.map +1 -0
- package/dist/opencode/sessions.d.ts +26 -0
- package/dist/opencode/sessions.js +105 -0
- package/dist/opencode/sessions.js.map +1 -0
- package/dist/opencode/setup.d.ts +38 -0
- package/dist/opencode/setup.js +109 -0
- package/dist/opencode/setup.js.map +1 -0
- package/dist/security/paths.d.ts +20 -0
- package/dist/security/paths.js +93 -0
- package/dist/security/paths.js.map +1 -0
- package/dist/security/policy.d.ts +17 -0
- package/dist/security/policy.js +86 -0
- package/dist/security/policy.js.map +1 -0
- package/dist/types/index.d.ts +131 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/util/fs.d.ts +12 -0
- package/dist/util/fs.js +73 -0
- package/dist/util/fs.js.map +1 -0
- package/dist/util/git.d.ts +54 -0
- package/dist/util/git.js +202 -0
- package/dist/util/git.js.map +1 -0
- package/dist/util/logger.d.ts +21 -0
- package/dist/util/logger.js +129 -0
- package/dist/util/logger.js.map +1 -0
- package/dist/util/text.d.ts +11 -0
- package/dist/util/text.js +126 -0
- package/dist/util/text.js.map +1 -0
- package/dist/workspace/context.d.ts +12 -0
- package/dist/workspace/context.js +67 -0
- package/dist/workspace/context.js.map +1 -0
- package/dist/workspace/resolver.d.ts +35 -0
- package/dist/workspace/resolver.js +112 -0
- package/dist/workspace/resolver.js.map +1 -0
- package/dist/workspace/validator.d.ts +13 -0
- package/dist/workspace/validator.js +102 -0
- package/dist/workspace/validator.js.map +1 -0
- package/docs/agent-configuration.md +100 -0
- package/docs/architecture.md +115 -0
- package/docs/claude-code-setup.md +116 -0
- package/docs/configuration.md +184 -0
- package/docs/contributing.md +71 -0
- package/docs/deepseek-setup.md +84 -0
- package/docs/development.md +146 -0
- package/docs/installation.md +88 -0
- package/docs/opencode-setup.md +97 -0
- package/docs/security-audit.md +80 -0
- package/docs/security.md +128 -0
- package/docs/troubleshooting.md +126 -0
- package/docs/workspace-model.md +126 -0
- package/package.json +79 -0
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured error model for the bridge.
|
|
3
|
+
*
|
|
4
|
+
* Every failure surfaced to Claude Code uses one of these codes so that the
|
|
5
|
+
* orchestrator can react deterministically instead of parsing prose.
|
|
6
|
+
*/
|
|
7
|
+
export declare const BRIDGE_ERROR_CODES: readonly ["WORKSPACE_NOT_FOUND", "WORKSPACE_NOT_ALLOWED", "WORKSPACE_NOT_READABLE", "WORKSPACE_MISMATCH", "OPENCODE_NOT_AVAILABLE", "OPENCODE_START_TIMEOUT", "OPENCODE_UNAVAILABLE", "OPENCODE_SESSION_NOT_FOUND", "OPENCODE_ERROR", "AGENT_NOT_FOUND", "AGENT_TIMEOUT", "AGENT_ABORTED", "AGENT_EXECUTION_FAILED", "INVALID_PATH", "INVALID_ARGUMENT", "PERMISSION_DENIED", "MODEL_NOT_AVAILABLE", "DIFF_UNAVAILABLE", "NOT_GIT_REPOSITORY", "CONFIG_INVALID", "INTERNAL_ERROR"];
|
|
8
|
+
export type BridgeErrorCode = (typeof BRIDGE_ERROR_CODES)[number];
|
|
9
|
+
export interface SerializedBridgeError {
|
|
10
|
+
code: BridgeErrorCode;
|
|
11
|
+
message: string;
|
|
12
|
+
details?: Record<string, unknown>;
|
|
13
|
+
retryable: boolean;
|
|
14
|
+
request_id?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface BridgeErrorOptions {
|
|
17
|
+
details?: Record<string, unknown>;
|
|
18
|
+
retryable?: boolean;
|
|
19
|
+
cause?: unknown;
|
|
20
|
+
}
|
|
21
|
+
export declare class BridgeError extends Error {
|
|
22
|
+
readonly code: BridgeErrorCode;
|
|
23
|
+
readonly details?: Record<string, unknown>;
|
|
24
|
+
readonly retryable: boolean;
|
|
25
|
+
constructor(code: BridgeErrorCode, message: string, options?: BridgeErrorOptions);
|
|
26
|
+
toJSON(): SerializedBridgeError;
|
|
27
|
+
}
|
|
28
|
+
export declare function isBridgeError(error: unknown): error is BridgeError;
|
|
29
|
+
export declare function serializeError(error: unknown, requestId?: string): SerializedBridgeError;
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured error model for the bridge.
|
|
3
|
+
*
|
|
4
|
+
* Every failure surfaced to Claude Code uses one of these codes so that the
|
|
5
|
+
* orchestrator can react deterministically instead of parsing prose.
|
|
6
|
+
*/
|
|
7
|
+
export const BRIDGE_ERROR_CODES = [
|
|
8
|
+
"WORKSPACE_NOT_FOUND",
|
|
9
|
+
"WORKSPACE_NOT_ALLOWED",
|
|
10
|
+
"WORKSPACE_NOT_READABLE",
|
|
11
|
+
"WORKSPACE_MISMATCH",
|
|
12
|
+
"OPENCODE_NOT_AVAILABLE",
|
|
13
|
+
"OPENCODE_START_TIMEOUT",
|
|
14
|
+
"OPENCODE_UNAVAILABLE",
|
|
15
|
+
"OPENCODE_SESSION_NOT_FOUND",
|
|
16
|
+
"OPENCODE_ERROR",
|
|
17
|
+
"AGENT_NOT_FOUND",
|
|
18
|
+
"AGENT_TIMEOUT",
|
|
19
|
+
"AGENT_ABORTED",
|
|
20
|
+
"AGENT_EXECUTION_FAILED",
|
|
21
|
+
"INVALID_PATH",
|
|
22
|
+
"INVALID_ARGUMENT",
|
|
23
|
+
"PERMISSION_DENIED",
|
|
24
|
+
"MODEL_NOT_AVAILABLE",
|
|
25
|
+
"DIFF_UNAVAILABLE",
|
|
26
|
+
"NOT_GIT_REPOSITORY",
|
|
27
|
+
"CONFIG_INVALID",
|
|
28
|
+
"INTERNAL_ERROR",
|
|
29
|
+
];
|
|
30
|
+
export class BridgeError extends Error {
|
|
31
|
+
code;
|
|
32
|
+
details;
|
|
33
|
+
retryable;
|
|
34
|
+
constructor(code, message, options = {}) {
|
|
35
|
+
super(message, options.cause !== undefined ? { cause: options.cause } : undefined);
|
|
36
|
+
this.name = "BridgeError";
|
|
37
|
+
this.code = code;
|
|
38
|
+
this.details = options.details;
|
|
39
|
+
this.retryable = options.retryable ?? false;
|
|
40
|
+
}
|
|
41
|
+
toJSON() {
|
|
42
|
+
return {
|
|
43
|
+
code: this.code,
|
|
44
|
+
message: this.message,
|
|
45
|
+
...(this.details ? { details: this.details } : {}),
|
|
46
|
+
retryable: this.retryable,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function isBridgeError(error) {
|
|
51
|
+
return error instanceof BridgeError;
|
|
52
|
+
}
|
|
53
|
+
export function serializeError(error, requestId) {
|
|
54
|
+
if (isBridgeError(error)) {
|
|
55
|
+
const serialized = error.toJSON();
|
|
56
|
+
return requestId ? { ...serialized, request_id: requestId } : serialized;
|
|
57
|
+
}
|
|
58
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
59
|
+
const serialized = {
|
|
60
|
+
code: "INTERNAL_ERROR",
|
|
61
|
+
message,
|
|
62
|
+
retryable: false,
|
|
63
|
+
};
|
|
64
|
+
if (requestId)
|
|
65
|
+
serialized.request_id = requestId;
|
|
66
|
+
return serialized;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,qBAAqB;IACrB,uBAAuB;IACvB,wBAAwB;IACxB,oBAAoB;IACpB,wBAAwB;IACxB,wBAAwB;IACxB,sBAAsB;IACtB,4BAA4B;IAC5B,gBAAgB;IAChB,iBAAiB;IACjB,eAAe;IACf,eAAe;IACf,wBAAwB;IACxB,cAAc;IACd,kBAAkB;IAClB,mBAAmB;IACnB,qBAAqB;IACrB,kBAAkB;IAClB,oBAAoB;IACpB,gBAAgB;IAChB,gBAAgB;CACR,CAAC;AAkBX,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAkB;IACtB,OAAO,CAA2B;IAClC,SAAS,CAAU;IAE5B,YAAY,IAAqB,EAAE,OAAe,EAAE,UAA8B,EAAE;QAClF,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACnF,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;IAC9C,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAClD,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;CACF;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,KAAK,YAAY,WAAW,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,SAAkB;IAC/D,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAClC,OAAO,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;IAC3E,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,MAAM,UAAU,GAA0B;QACxC,IAAI,EAAE,gBAAgB;QACtB,OAAO;QACP,SAAS,EAAE,KAAK;KACjB,CAAC;IACF,IAAI,SAAS;QAAE,UAAU,CAAC,UAAU,GAAG,SAAS,CAAC;IACjD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { runInit } from "./cli/init.js";
|
|
6
|
+
import { loadConfig } from "./config/config.js";
|
|
7
|
+
import { createMcpServer, SERVER_VERSION } from "./mcp/server.js";
|
|
8
|
+
import { OpenCodeManager } from "./opencode/manager.js";
|
|
9
|
+
import { SessionRegistry } from "./opencode/sessions.js";
|
|
10
|
+
import { prepareRun } from "./opencode/setup.js";
|
|
11
|
+
import { createLogger, defaultLogFile, stateDirectory } from "./util/logger.js";
|
|
12
|
+
async function runServer() {
|
|
13
|
+
const logger = createLogger({ file: defaultLogFile() });
|
|
14
|
+
const env = process.env;
|
|
15
|
+
const stateDir = stateDirectory();
|
|
16
|
+
let globalConfig;
|
|
17
|
+
try {
|
|
18
|
+
globalConfig = (await loadConfig({ env })).config;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
logger.error("failed to load configuration", {
|
|
22
|
+
error: error instanceof Error ? error.message : String(error),
|
|
23
|
+
});
|
|
24
|
+
process.exitCode = 1;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const registry = new SessionRegistry(path.join(stateDir, "sessions.json"), logger);
|
|
28
|
+
const manager = new OpenCodeManager({ logger, env });
|
|
29
|
+
const server = createMcpServer({ logger, manager, registry, globalConfig, env, stateDir });
|
|
30
|
+
let shuttingDown = false;
|
|
31
|
+
const shutdown = async (reason) => {
|
|
32
|
+
if (shuttingDown)
|
|
33
|
+
return;
|
|
34
|
+
shuttingDown = true;
|
|
35
|
+
logger.info("shutting down", { reason });
|
|
36
|
+
try {
|
|
37
|
+
await server.close();
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// ignore
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
await manager.stopAll();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// ignore
|
|
47
|
+
}
|
|
48
|
+
logger.info("shutdown complete");
|
|
49
|
+
setImmediate(() => process.exit(0));
|
|
50
|
+
};
|
|
51
|
+
const transport = new StdioServerTransport();
|
|
52
|
+
await server.connect(transport);
|
|
53
|
+
logger.info("claude-opencode-mcp started", {
|
|
54
|
+
pid: process.pid,
|
|
55
|
+
cwd: process.cwd(),
|
|
56
|
+
state_dir: stateDir,
|
|
57
|
+
});
|
|
58
|
+
server.server.onclose = () => {
|
|
59
|
+
void shutdown("transport closed");
|
|
60
|
+
};
|
|
61
|
+
process.on("SIGINT", () => void shutdown("SIGINT"));
|
|
62
|
+
process.on("SIGTERM", () => void shutdown("SIGTERM"));
|
|
63
|
+
// Never orphan an OpenCode child, even if we exit through an unexpected path.
|
|
64
|
+
process.on("exit", () => manager.killAllSync());
|
|
65
|
+
if (globalConfig.opencode.autoStart && !globalConfig.opencode.url) {
|
|
66
|
+
setImmediate(() => {
|
|
67
|
+
void (async () => {
|
|
68
|
+
try {
|
|
69
|
+
await prepareRun({ manager, logger, env, globalConfig }, {});
|
|
70
|
+
logger.info("warmed up OpenCode for the default workspace");
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
logger.debug("OpenCode warmup skipped", {
|
|
74
|
+
error: error instanceof Error ? error.message : String(error),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
})();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function main() {
|
|
82
|
+
const program = new Command();
|
|
83
|
+
program
|
|
84
|
+
.name("claude-opencode-mcp")
|
|
85
|
+
.description("MCP bridge that lets Claude Code delegate tasks to OpenCode agents (DeepSeek by default) in the same workspace.")
|
|
86
|
+
.version(SERVER_VERSION, "-v, --version", "print the bridge version")
|
|
87
|
+
.action(async () => {
|
|
88
|
+
await runServer();
|
|
89
|
+
});
|
|
90
|
+
program
|
|
91
|
+
.command("init")
|
|
92
|
+
.description("initialize optional project-local configuration and validate the environment")
|
|
93
|
+
.option("--dir <path>", "project directory (defaults to the current directory)")
|
|
94
|
+
.option("--force", "overwrite existing generated files")
|
|
95
|
+
.option("--write-mcp", "create or update .mcp.json in the project")
|
|
96
|
+
.action(async (options) => {
|
|
97
|
+
const code = await runInit({
|
|
98
|
+
...(options.dir ? { dir: options.dir } : {}),
|
|
99
|
+
...(options.force ? { force: true } : {}),
|
|
100
|
+
...(options.writeMcp ? { writeMcp: true } : {}),
|
|
101
|
+
});
|
|
102
|
+
process.exitCode = code;
|
|
103
|
+
});
|
|
104
|
+
program
|
|
105
|
+
.command("serve")
|
|
106
|
+
.description("run the MCP stdio server (default command)")
|
|
107
|
+
.action(async () => {
|
|
108
|
+
await runServer();
|
|
109
|
+
});
|
|
110
|
+
await program.parseAsync(process.argv);
|
|
111
|
+
}
|
|
112
|
+
main().catch((error) => {
|
|
113
|
+
process.stderr.write(`claude-opencode-mcp fatal error: ${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEhF,KAAK,UAAU,SAAS;IACtB,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,CAAC,CAAC;IACxD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IACxB,MAAM,QAAQ,GAAG,cAAc,EAAE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,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEL,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,4CAA4C,CAAC;SACzD,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,SAAS,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEL,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,oCAAoC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAChH,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { LoadedConfig, ResolvedConfig } from "../config/config.js";
|
|
2
|
+
import type { OpenCodeManager } from "../opencode/manager.js";
|
|
3
|
+
import type { SessionRegistry } from "../opencode/sessions.js";
|
|
4
|
+
import type { PreparedRun } from "../opencode/setup.js";
|
|
5
|
+
import type { AgentSession, DelegateResult } from "../types/index.js";
|
|
6
|
+
import type { Logger } from "../util/logger.js";
|
|
7
|
+
import { type ToolExtra } from "./tool-utils.js";
|
|
8
|
+
export interface AppContext {
|
|
9
|
+
logger: Logger;
|
|
10
|
+
manager: OpenCodeManager;
|
|
11
|
+
registry: SessionRegistry;
|
|
12
|
+
globalConfig: ResolvedConfig;
|
|
13
|
+
env: NodeJS.ProcessEnv;
|
|
14
|
+
stateDir: string;
|
|
15
|
+
/** Override per-workspace config loading (tests/embedding). */
|
|
16
|
+
loadProjectConfig?: (cwd: string) => Promise<LoadedConfig>;
|
|
17
|
+
}
|
|
18
|
+
export declare function loadWorkspaceConfig(ctx: AppContext, cwd: string): Promise<ResolvedConfig>;
|
|
19
|
+
export interface ExecuteRunInput {
|
|
20
|
+
prepared: PreparedRun;
|
|
21
|
+
session: AgentSession;
|
|
22
|
+
text: string;
|
|
23
|
+
timeoutMs: number;
|
|
24
|
+
disableEdits: boolean;
|
|
25
|
+
extra: ToolExtra;
|
|
26
|
+
requestId: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function executeRun(ctx: AppContext, input: ExecuteRunInput): Promise<DelegateResult>;
|
|
29
|
+
export declare function countChangedFiles(session: AgentSession): Promise<number>;
|
|
30
|
+
export declare function assertSession(session: AgentSession | null, sessionId: string): AgentSession;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { loadConfig } from "../config/config.js";
|
|
2
|
+
import { BridgeError, isBridgeError } from "../errors.js";
|
|
3
|
+
import { runPrompt } from "../opencode/run.js";
|
|
4
|
+
import { diffSinceBaseline } from "../util/git.js";
|
|
5
|
+
import { truncate } from "../util/text.js";
|
|
6
|
+
import { createProgressReporter } from "./tool-utils.js";
|
|
7
|
+
export async function loadWorkspaceConfig(ctx, cwd) {
|
|
8
|
+
if (ctx.loadProjectConfig) {
|
|
9
|
+
return (await ctx.loadProjectConfig(cwd)).config;
|
|
10
|
+
}
|
|
11
|
+
return (await loadConfig({ cwd, env: ctx.env })).config;
|
|
12
|
+
}
|
|
13
|
+
export async function executeRun(ctx, input) {
|
|
14
|
+
const { prepared, session } = input;
|
|
15
|
+
const progress = createProgressReporter(input.extra, ctx.logger, input.requestId);
|
|
16
|
+
const runLogger = ctx.logger.child({
|
|
17
|
+
request_id: input.requestId,
|
|
18
|
+
session_id: session.id,
|
|
19
|
+
agent: session.agent,
|
|
20
|
+
cwd: session.cwd,
|
|
21
|
+
});
|
|
22
|
+
ctx.registry.update(session.id, { status: "running", lastError: undefined });
|
|
23
|
+
ctx.manager.beginRun(prepared.serverKey, session.id);
|
|
24
|
+
try {
|
|
25
|
+
const result = await runPrompt({
|
|
26
|
+
client: prepared.client,
|
|
27
|
+
sessionId: session.id,
|
|
28
|
+
agent: session.agent,
|
|
29
|
+
model: prepared.model,
|
|
30
|
+
text: input.text,
|
|
31
|
+
timeoutMs: input.timeoutMs,
|
|
32
|
+
disableEdits: input.disableEdits,
|
|
33
|
+
...(progress ? { onProgress: progress } : {}),
|
|
34
|
+
...(input.extra.signal ? { signal: input.extra.signal } : {}),
|
|
35
|
+
logger: runLogger,
|
|
36
|
+
});
|
|
37
|
+
const truncatedSummary = truncate(result.summary, prepared.config.limits.summaryChars);
|
|
38
|
+
const filesChanged = await countChangedFiles(session);
|
|
39
|
+
const status = result.status === "completed"
|
|
40
|
+
? "completed"
|
|
41
|
+
: result.status === "timeout"
|
|
42
|
+
? "timeout"
|
|
43
|
+
: "failed";
|
|
44
|
+
ctx.registry.update(session.id, {
|
|
45
|
+
status,
|
|
46
|
+
...(truncatedSummary.text ? { lastSummary: truncatedSummary.text } : {}),
|
|
47
|
+
...(result.error
|
|
48
|
+
? { lastError: { code: result.error.code, message: result.error.message } }
|
|
49
|
+
: { lastError: undefined }),
|
|
50
|
+
durationMs: result.durationMs,
|
|
51
|
+
...(result.messageID ? { lastMessageID: result.messageID } : {}),
|
|
52
|
+
});
|
|
53
|
+
runLogger.info("delegated run finished", {
|
|
54
|
+
status: result.status,
|
|
55
|
+
duration_ms: result.durationMs,
|
|
56
|
+
files_changed: filesChanged,
|
|
57
|
+
findings: result.findings.length,
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
status: result.status,
|
|
61
|
+
session_id: session.id,
|
|
62
|
+
agent: session.agent,
|
|
63
|
+
cwd: session.cwd,
|
|
64
|
+
model: prepared.modelString,
|
|
65
|
+
summary: truncatedSummary.text,
|
|
66
|
+
findings: result.findings,
|
|
67
|
+
files_changed: filesChanged,
|
|
68
|
+
duration_ms: result.durationMs,
|
|
69
|
+
truncated: truncatedSummary.truncated,
|
|
70
|
+
...(result.error
|
|
71
|
+
? {
|
|
72
|
+
error: {
|
|
73
|
+
code: result.error.code,
|
|
74
|
+
message: result.error.message,
|
|
75
|
+
...(result.error.details ? { details: result.error.details } : {}),
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
: {}),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
const code = isBridgeError(error) ? error.code : "INTERNAL_ERROR";
|
|
83
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
84
|
+
ctx.registry.update(session.id, {
|
|
85
|
+
status: code === "AGENT_ABORTED" ? "aborted" : "failed",
|
|
86
|
+
lastError: { code, message },
|
|
87
|
+
});
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
ctx.manager.endRun(prepared.serverKey, session.id);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export async function countChangedFiles(session) {
|
|
95
|
+
const baseline = session.baseline
|
|
96
|
+
? {
|
|
97
|
+
head: session.baseline.head,
|
|
98
|
+
stashRef: session.baseline.stashRef,
|
|
99
|
+
untracked: session.baseline.untracked,
|
|
100
|
+
unborn: session.baseline.unborn,
|
|
101
|
+
dirty: session.baseline.stashRef !== null,
|
|
102
|
+
}
|
|
103
|
+
: null;
|
|
104
|
+
if (!baseline)
|
|
105
|
+
return 0;
|
|
106
|
+
try {
|
|
107
|
+
const diff = await diffSinceBaseline(session.cwd, baseline, {
|
|
108
|
+
maxPatchChars: 20_000,
|
|
109
|
+
maxNewFiles: 50,
|
|
110
|
+
});
|
|
111
|
+
return diff.files.length;
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export function assertSession(session, sessionId) {
|
|
118
|
+
if (!session) {
|
|
119
|
+
throw new BridgeError("OPENCODE_SESSION_NOT_FOUND", `Unknown session: ${sessionId}`, {
|
|
120
|
+
details: {
|
|
121
|
+
session_id: sessionId,
|
|
122
|
+
hint: "Create a session with create_session or delegate_task first.",
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return session;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/mcp/execute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,OAAO,EAAE,iBAAiB,EAAoB,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAkB,MAAM,iBAAiB,CAAC;AAazE,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,GAAe,EAAE,GAAW;IACpE,IAAI,GAAG,CAAC,iBAAiB,EAAE,CAAC;QAC1B,OAAO,CAAC,MAAM,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;IACnD,CAAC;IACD,OAAO,CAAC,MAAM,UAAU,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAC1D,CAAC;AAYD,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAe,EAAE,KAAsB;IACtE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACpC,MAAM,QAAQ,GAAG,sBAAsB,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAClF,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QACjC,UAAU,EAAE,KAAK,CAAC,SAA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C,QAAQ;QACnD,CAAC,CAAC;YACE,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI;YAC3B,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,QAAQ;YACnC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS;YACrC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM;YAC/B,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,QAAQ,KAAK,IAAI;SAC1C;QACH,CAAC,CAAC,IAAI,CAAC;IACT,IAAI,CAAC,QAAQ;QAAE,OAAO,CAAC,CAAC;IACxB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE;YAC1D,aAAa,EAAE,MAAM;YACrB,WAAW,EAAE,EAAE;SAChB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAA4B,EAAE,SAAiB;IAC3E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,WAAW,CAAC,4BAA4B,EAAE,oBAAoB,SAAS,EAAE,EAAE;YACnF,OAAO,EAAE;gBACP,UAAU,EAAE,SAAS;gBACrB,IAAI,EAAE,8DAA8D;aACrE;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { LoadedConfig, ResolvedConfig } from "../config/config.js";
|
|
3
|
+
import type { OpenCodeManager } from "../opencode/manager.js";
|
|
4
|
+
import type { SessionRegistry } from "../opencode/sessions.js";
|
|
5
|
+
import type { Logger } from "../util/logger.js";
|
|
6
|
+
export declare const SERVER_NAME = "claude-opencode-mcp";
|
|
7
|
+
export declare const SERVER_VERSION = "1.0.0";
|
|
8
|
+
export declare const SERVER_INSTRUCTIONS: string;
|
|
9
|
+
export interface CreateMcpServerOptions {
|
|
10
|
+
logger: Logger;
|
|
11
|
+
manager: OpenCodeManager;
|
|
12
|
+
registry: SessionRegistry;
|
|
13
|
+
globalConfig: ResolvedConfig;
|
|
14
|
+
env?: NodeJS.ProcessEnv;
|
|
15
|
+
stateDir: string;
|
|
16
|
+
/** Override per-workspace config loading (tests/embedding). */
|
|
17
|
+
loadProjectConfig?: (cwd: string) => Promise<LoadedConfig>;
|
|
18
|
+
}
|
|
19
|
+
export declare function createMcpServer(options: CreateMcpServerOptions): McpServer;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { registerAbortSession } from "./tools/abort-session.js";
|
|
3
|
+
import { registerCreateSession } from "./tools/create-session.js";
|
|
4
|
+
import { registerDelegateTask } from "./tools/delegate-task.js";
|
|
5
|
+
import { registerGetDiff } from "./tools/get-diff.js";
|
|
6
|
+
import { registerGetSession } from "./tools/get-session.js";
|
|
7
|
+
import { registerListAgents } from "./tools/list-agents.js";
|
|
8
|
+
import { registerSendMessage } from "./tools/send-message.js";
|
|
9
|
+
export const SERVER_NAME = "claude-opencode-mcp";
|
|
10
|
+
export const SERVER_VERSION = "1.0.0";
|
|
11
|
+
export const SERVER_INSTRUCTIONS = [
|
|
12
|
+
"Claude Code is the orchestrator; this server delegates focused tasks to OpenCode agents that run in the same workspace.",
|
|
13
|
+
"Use delegate_task for one-shot work, or create_session + send_message for multi-step work that must keep context.",
|
|
14
|
+
"Read-only agents: deepseek-researcher, deepseek-reviewer. Editing agent: deepseek-coder. Test-running agent: deepseek-tester.",
|
|
15
|
+
"After a coder session, call get_diff to inspect exactly what changed before reporting back to the user.",
|
|
16
|
+
"Paths supplied to delegate_task are exploration hints, not boundaries.",
|
|
17
|
+
].join(" ");
|
|
18
|
+
export function createMcpServer(options) {
|
|
19
|
+
const ctx = {
|
|
20
|
+
logger: options.logger,
|
|
21
|
+
manager: options.manager,
|
|
22
|
+
registry: options.registry,
|
|
23
|
+
globalConfig: options.globalConfig,
|
|
24
|
+
env: options.env ?? process.env,
|
|
25
|
+
stateDir: options.stateDir,
|
|
26
|
+
...(options.loadProjectConfig ? { loadProjectConfig: options.loadProjectConfig } : {}),
|
|
27
|
+
};
|
|
28
|
+
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION }, { instructions: SERVER_INSTRUCTIONS });
|
|
29
|
+
registerDelegateTask(server, ctx);
|
|
30
|
+
registerCreateSession(server, ctx);
|
|
31
|
+
registerSendMessage(server, ctx);
|
|
32
|
+
registerGetSession(server, ctx);
|
|
33
|
+
registerGetDiff(server, ctx);
|
|
34
|
+
registerAbortSession(server, ctx);
|
|
35
|
+
registerListAgents(server, ctx);
|
|
36
|
+
return server;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,CAAC,MAAM,WAAW,GAAG,qBAAqB,CAAC;AACjD,MAAM,CAAC,MAAM,cA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encode/setup.js";
|
|
2
|
+
import type { AgentSession } from "../types/index.js";
|
|
3
|
+
import type { AppContext } from "./execute.js";
|
|
4
|
+
export declare function defaultSessionTitle(agent: string, task: string): string;
|
|
5
|
+
export declare function createDelegatedSession(ctx: AppContext, prepared: PreparedRun, title?: string | null): Promise<AgentSession>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BridgeError } from "../errors.js";
|
|
2
|
+
import { createSessionRecord } from "../opencode/sessions.js";
|
|
3
|
+
import { captureGitBaseline } from "../util/git.js";
|
|
4
|
+
export function defaultSessionTitle(agent, task) {
|
|
5
|
+
const cleaned = task.replace(/\s+/g, " ").trim();
|
|
6
|
+
const short = cleaned.length > 60 ? `${cleaned.slice(0, 57)}…` : cleaned;
|
|
7
|
+
return `${agent}: ${short || "delegated task"}`;
|
|
8
|
+
}
|
|
9
|
+
export async function createDelegatedSession(ctx, prepared, title) {
|
|
10
|
+
const baseline = await captureGitBaseline(prepared.workspace.cwd);
|
|
11
|
+
let opencodeId;
|
|
12
|
+
try {
|
|
13
|
+
const result = await prepared.client.session.create({
|
|
14
|
+
body: { title: title?.trim() ? title.trim() : undefined },
|
|
15
|
+
});
|
|
16
|
+
if (result.error || !result.data) {
|
|
17
|
+
throw new BridgeError("OPENCODE_ERROR", "OpenCode did not return a session id.", {
|
|
18
|
+
details: { error: result.error },
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
opencodeId = result.data.id;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (error instanceof BridgeError)
|
|
25
|
+
throw error;
|
|
26
|
+
throw new BridgeError("OPENCODE_UNAVAILABLE", `Could not create an OpenCode session: ${error instanceof Error ? error.message : String(error)}`, { cause: error, retryable: true });
|
|
27
|
+
}
|
|
28
|
+
const session = createSessionRecord({
|
|
29
|
+
id: opencodeId,
|
|
30
|
+
cwd: prepared.workspace.cwd,
|
|
31
|
+
agent: prepared.definition.name,
|
|
32
|
+
provider: prepared.model?.providerID ?? null,
|
|
33
|
+
model: prepared.modelString,
|
|
34
|
+
title: title?.trim() ? title.trim() : null,
|
|
35
|
+
...(baseline
|
|
36
|
+
? {
|
|
37
|
+
baseline: {
|
|
38
|
+
head: baseline.head,
|
|
39
|
+
stashRef: baseline.stashRef,
|
|
40
|
+
untracked: baseline.untracked,
|
|
41
|
+
unborn: baseline.unborn,
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
: {}),
|
|
45
|
+
});
|
|
46
|
+
ctx.registry.upsert(session);
|
|
47
|
+
ctx.logger.info("created delegated session", {
|
|
48
|
+
session_id: session.id,
|
|
49
|
+
cwd: session.cwd,
|
|
50
|
+
agent: session.agent,
|
|
51
|
+
model: session.model,
|
|
52
|
+
});
|
|
53
|
+
return session;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=session-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-utils.js","sourceRoot":"","sources":["../../src/mcp/session-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,UAAU,mBAAmB,CAAC,KAAa,EAAE,IAAY;IAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACjD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;IACzE,OAAO,GAAG,KAAK,KAAK,KAAK,IAAI,gBAAgB,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,GAAe,EACf,QAA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,QAAQ,CAAC,WAAW;QAC3B,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI;QAC1C,GAAG,CAAC,QAAQ;YACV,CAAC,CAAC;gBACE,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ,CAAC,IAAI;oBACnB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;oBAC3B,SAAS,EAAE,QAAQ,CAAC,SAAS;oBAC7B,MAAM,EAAE,QAAQ,CAAC,MAAM;iBACxB;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;IACH,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC7B,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,EAAE;QAC3C,UAAU,EAAE,OAAO,CAAC,EAAE;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
2
|
+
import type { CallToolResult, ServerNotification, ServerRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import type { RunProgress } from "../types/index.js";
|
|
4
|
+
import type { Logger } from "../util/logger.js";
|
|
5
|
+
export type ToolExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
|
|
6
|
+
export declare function jsonResult(value: unknown, options?: {
|
|
7
|
+
isError?: boolean;
|
|
8
|
+
}): CallToolResult;
|
|
9
|
+
export declare function errorResult(error: unknown, requestId?: string): CallToolResult;
|
|
10
|
+
export type ProgressReporter = (progress: RunProgress) => Promise<void>;
|
|
11
|
+
export declare function createProgressReporter(extra: ToolExtra, logger: Logger, requestId: string): ProgressReporter | undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { serializeError } from "../errors.js";
|
|
2
|
+
export function jsonResult(value, options = {}) {
|
|
3
|
+
const text = JSON.stringify(value, null, 2) ?? String(value);
|
|
4
|
+
const result = { content: [{ type: "text", text }] };
|
|
5
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
6
|
+
result.structuredContent = value;
|
|
7
|
+
}
|
|
8
|
+
if (options.isError)
|
|
9
|
+
result.isError = true;
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
export function errorResult(error, requestId) {
|
|
13
|
+
return jsonResult({ error: serializeError(error, requestId) }, { isError: true });
|
|
14
|
+
}
|
|
15
|
+
export function createProgressReporter(extra, logger, requestId) {
|
|
16
|
+
const token = extra._meta?.progressToken;
|
|
17
|
+
if (token === undefined || token === null)
|
|
18
|
+
return undefined;
|
|
19
|
+
let lastSentAt = 0;
|
|
20
|
+
return async (progress) => {
|
|
21
|
+
const now = Date.now();
|
|
22
|
+
if (progress.progress < 100 && now - lastSentAt < 400)
|
|
23
|
+
return;
|
|
24
|
+
lastSentAt = now;
|
|
25
|
+
try {
|
|
26
|
+
await extra.sendNotification({
|
|
27
|
+
method: "notifications/progress",
|
|
28
|
+
params: {
|
|
29
|
+
progressToken: token,
|
|
30
|
+
progress: progress.progress,
|
|
31
|
+
...(progress.total !== undefined ? { total: progress.total } : {}),
|
|
32
|
+
...(progress.message ? { message: progress.message } : {}),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
logger.debug("failed to send progress notification", {
|
|
38
|
+
request_id: requestId,
|
|
39
|
+
error: error instanceof Error ? error.message : String(error),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=tool-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-utils.js","sour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