thinkwell 0.5.5 → 0.5.7
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/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +232 -278
- package/dist/agent.js.map +1 -1
- package/dist/build.js +44 -98
- package/dist/cli/build.js +92 -227
- package/dist/cli/bundle.js +570 -1136
- package/dist/cli/check.js +125 -214
- package/dist/cli/commands.js +63 -177
- package/dist/cli/compiler-host.js +81 -190
- package/dist/cli/dependency-check.js +125 -269
- package/dist/cli/dependency-errors.js +12 -84
- package/dist/cli/fmt.js +1 -13
- package/dist/cli/init-command.js +21 -68
- package/dist/cli/init.js +90 -220
- package/dist/cli/loader.js +95 -361
- package/dist/cli/new-command.js +25 -73
- package/dist/cli/package-manager.js +50 -117
- package/dist/cli/schema.d.ts.map +1 -1
- package/dist/cli/schema.js +91 -245
- package/dist/cli/schema.js.map +1 -1
- package/dist/cli/workspace.js +92 -226
- package/dist/connectors/index.js +1 -7
- package/dist/generated/features.d.ts +6 -0
- package/dist/generated/features.d.ts.map +1 -0
- package/dist/generated/features.js +5 -0
- package/dist/generated/features.js.map +1 -0
- package/dist/index.js +0 -5
- package/dist/schema.js +3 -36
- package/dist/session.js +50 -82
- package/dist/think-builder.d.ts.map +1 -1
- package/dist/think-builder.js +287 -368
- package/dist/think-builder.js.map +1 -1
- package/dist/thought-event.d.ts +1 -0
- package/dist/thought-event.d.ts.map +1 -1
- package/dist/thought-event.js +0 -1
- package/dist/thought-stream.js +60 -96
- package/dist-pkg/acp.cjs +13386 -1876
- package/dist-pkg/cli-build.cjs +264 -446
- package/dist-pkg/cli-bundle.cjs +433 -818
- package/dist-pkg/cli-check.cjs +302 -499
- package/dist-pkg/cli-dependency-check.cjs +39 -82
- package/dist-pkg/cli-dependency-errors.cjs +9 -41
- package/dist-pkg/cli-loader.cjs +91 -173
- package/dist-pkg/protocol.cjs +2 -8
- package/dist-pkg/thinkwell.cjs +927 -1846
- package/package.json +9 -7
package/dist-pkg/thinkwell.cjs
CHANGED
|
@@ -29,31 +29,12 @@ __export(stdio_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
function parseCommand(command) {
|
|
31
31
|
const parts = [];
|
|
32
|
-
let current = "";
|
|
33
|
-
let inQuote = null;
|
|
32
|
+
let current = "", inQuote = null;
|
|
34
33
|
for (let i = 0; i < command.length; i++) {
|
|
35
34
|
const char = command[i];
|
|
36
|
-
|
|
37
|
-
if (char === inQuote) {
|
|
38
|
-
inQuote = null;
|
|
39
|
-
} else {
|
|
40
|
-
current += char;
|
|
41
|
-
}
|
|
42
|
-
} else if (char === '"' || char === "'") {
|
|
43
|
-
inQuote = char;
|
|
44
|
-
} else if (char === " " || char === " ") {
|
|
45
|
-
if (current) {
|
|
46
|
-
parts.push(current);
|
|
47
|
-
current = "";
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
current += char;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (current) {
|
|
54
|
-
parts.push(current);
|
|
35
|
+
inQuote ? char === inQuote ? inQuote = null : current += char : char === '"' || char === "'" ? inQuote = char : char === " " || char === " " ? current && (parts.push(current), current = "") : current += char;
|
|
55
36
|
}
|
|
56
|
-
return parts;
|
|
37
|
+
return current && parts.push(current), parts;
|
|
57
38
|
}
|
|
58
39
|
function stdio(options) {
|
|
59
40
|
return new StdioConnector(options);
|
|
@@ -73,60 +54,43 @@ var init_stdio = __esm({
|
|
|
73
54
|
closed = false;
|
|
74
55
|
closingGracefully = false;
|
|
75
56
|
constructor(process2) {
|
|
76
|
-
this.process = process2
|
|
77
|
-
if (!process2.stdout || !process2.stdin) {
|
|
57
|
+
if (this.process = process2, !process2.stdout || !process2.stdin)
|
|
78
58
|
throw new Error("Process must have stdio pipes");
|
|
79
|
-
}
|
|
80
59
|
this.readline = (0, import_node_readline.createInterface)({
|
|
81
60
|
input: process2.stdout,
|
|
82
|
-
crlfDelay:
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
console.error(`Process exited with code ${code}`);
|
|
88
|
-
}
|
|
89
|
-
if (signal && !this.closingGracefully) {
|
|
90
|
-
console.error(`Process killed by signal ${signal}`);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
process2.on("error", (error40) => {
|
|
94
|
-
console.error("Process error:", error40);
|
|
95
|
-
this.closed = true;
|
|
61
|
+
crlfDelay: 1 / 0
|
|
62
|
+
}), process2.on("exit", (code, signal) => {
|
|
63
|
+
this.closed = true, code !== 0 && code !== null && !this.closingGracefully && console.error(`Process exited with code ${code}`), signal && !this.closingGracefully && console.error(`Process killed by signal ${signal}`);
|
|
64
|
+
}), process2.on("error", (error40) => {
|
|
65
|
+
console.error("Process error:", error40), this.closed = true;
|
|
96
66
|
});
|
|
97
67
|
}
|
|
98
68
|
/**
|
|
99
69
|
* Send a JSON-RPC message to the subprocess
|
|
100
70
|
*/
|
|
101
71
|
send(message) {
|
|
102
|
-
if (this.closed || !this.process.stdin)
|
|
72
|
+
if (this.closed || !this.process.stdin)
|
|
103
73
|
throw new Error("Connection is closed");
|
|
104
|
-
}
|
|
105
74
|
const json2 = JSON.stringify(message);
|
|
106
|
-
this.process.stdin.write(json2 +
|
|
75
|
+
this.process.stdin.write(json2 + `
|
|
76
|
+
`);
|
|
107
77
|
}
|
|
108
78
|
/**
|
|
109
79
|
* Async iterable of messages received from the subprocess
|
|
110
80
|
*/
|
|
111
81
|
get messages() {
|
|
112
|
-
const readline = this.readline;
|
|
113
|
-
const isClosed = /* @__PURE__ */ __name(() => this.closed, "isClosed");
|
|
82
|
+
const readline = this.readline, isClosed = /* @__PURE__ */ __name(() => this.closed, "isClosed");
|
|
114
83
|
return {
|
|
115
84
|
async *[Symbol.asyncIterator]() {
|
|
116
85
|
for await (const line of readline) {
|
|
117
|
-
if (isClosed())
|
|
86
|
+
if (isClosed())
|
|
118
87
|
return;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
yield message;
|
|
126
|
-
} catch (error40) {
|
|
127
|
-
console.error("Failed to parse JSON-RPC message:", error40);
|
|
128
|
-
console.error("Line:", line);
|
|
129
|
-
}
|
|
88
|
+
if (line.trim())
|
|
89
|
+
try {
|
|
90
|
+
yield JSON.parse(line);
|
|
91
|
+
} catch (error40) {
|
|
92
|
+
console.error("Failed to parse JSON-RPC message:", error40), console.error("Line:", line);
|
|
93
|
+
}
|
|
130
94
|
}
|
|
131
95
|
}
|
|
132
96
|
};
|
|
@@ -135,33 +99,17 @@ var init_stdio = __esm({
|
|
|
135
99
|
* Close the connection and terminate the subprocess
|
|
136
100
|
*/
|
|
137
101
|
async close() {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
this.closed = true;
|
|
142
|
-
this.closingGracefully = true;
|
|
143
|
-
this.readline.close();
|
|
144
|
-
this.process.stdout?.destroy();
|
|
145
|
-
this.process.stdin?.end();
|
|
146
|
-
await new Promise((resolve2) => {
|
|
147
|
-
let sigtermTimeout = null;
|
|
148
|
-
let sigkillTimeout = null;
|
|
102
|
+
this.closed || (this.closed = true, this.closingGracefully = true, this.readline.close(), this.process.stdout?.destroy(), this.process.stdin?.end(), await new Promise((resolve2) => {
|
|
103
|
+
let sigtermTimeout = null, sigkillTimeout = null;
|
|
149
104
|
const onExit = /* @__PURE__ */ __name(() => {
|
|
150
|
-
|
|
151
|
-
clearTimeout(sigtermTimeout);
|
|
152
|
-
if (sigkillTimeout)
|
|
153
|
-
clearTimeout(sigkillTimeout);
|
|
154
|
-
resolve2();
|
|
105
|
+
sigtermTimeout && clearTimeout(sigtermTimeout), sigkillTimeout && clearTimeout(sigkillTimeout), resolve2();
|
|
155
106
|
}, "onExit");
|
|
156
|
-
this.process.once("exit", onExit)
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
sigkillTimeout = setTimeout(() => {
|
|
160
|
-
this.process.kill("SIGKILL");
|
|
161
|
-
resolve2();
|
|
107
|
+
this.process.once("exit", onExit), sigtermTimeout = setTimeout(() => {
|
|
108
|
+
this.process.kill("SIGTERM"), sigkillTimeout = setTimeout(() => {
|
|
109
|
+
this.process.kill("SIGKILL"), resolve2();
|
|
162
110
|
}, 500);
|
|
163
111
|
}, 250);
|
|
164
|
-
});
|
|
112
|
+
}));
|
|
165
113
|
}
|
|
166
114
|
};
|
|
167
115
|
StdioConnector = class {
|
|
@@ -170,44 +118,35 @@ var init_stdio = __esm({
|
|
|
170
118
|
}
|
|
171
119
|
options;
|
|
172
120
|
constructor(options) {
|
|
173
|
-
if (typeof options
|
|
121
|
+
if (typeof options == "string") {
|
|
174
122
|
const parts = parseCommand(options);
|
|
175
123
|
this.options = {
|
|
176
124
|
command: parts[0],
|
|
177
125
|
args: parts.slice(1)
|
|
178
126
|
};
|
|
179
|
-
} else
|
|
127
|
+
} else
|
|
180
128
|
this.options = options;
|
|
181
|
-
}
|
|
182
129
|
}
|
|
183
130
|
/**
|
|
184
131
|
* Spawn the subprocess and return a connection to it
|
|
185
132
|
*/
|
|
186
133
|
async connect() {
|
|
187
|
-
const { command, args = [], env, cwd } = this.options
|
|
188
|
-
const process2 = (0, import_node_child_process.spawn)(command, args, {
|
|
134
|
+
const { command, args = [], env, cwd } = this.options, process2 = (0, import_node_child_process.spawn)(command, args, {
|
|
189
135
|
stdio: ["pipe", "pipe", "inherit"],
|
|
190
136
|
// stdin, stdout piped; stderr inherited
|
|
191
137
|
env: env ? { ...globalThis.process.env, ...env } : void 0,
|
|
192
138
|
cwd
|
|
193
139
|
});
|
|
194
|
-
await new Promise((resolve2, reject) => {
|
|
140
|
+
return await new Promise((resolve2, reject) => {
|
|
195
141
|
const onSpawn = /* @__PURE__ */ __name(() => {
|
|
196
|
-
cleanup();
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
reject(error40);
|
|
202
|
-
}, "onError");
|
|
203
|
-
const cleanup = /* @__PURE__ */ __name(() => {
|
|
204
|
-
process2.removeListener("spawn", onSpawn);
|
|
205
|
-
process2.removeListener("error", onError);
|
|
142
|
+
cleanup(), resolve2();
|
|
143
|
+
}, "onSpawn"), onError = /* @__PURE__ */ __name((error40) => {
|
|
144
|
+
cleanup(), reject(error40);
|
|
145
|
+
}, "onError"), cleanup = /* @__PURE__ */ __name(() => {
|
|
146
|
+
process2.removeListener("spawn", onSpawn), process2.removeListener("error", onError);
|
|
206
147
|
}, "cleanup");
|
|
207
|
-
process2.once("spawn", onSpawn);
|
|
208
|
-
|
|
209
|
-
});
|
|
210
|
-
return new StdioConnection(process2);
|
|
148
|
+
process2.once("spawn", onSpawn), process2.once("error", onError);
|
|
149
|
+
}), new StdioConnection(process2);
|
|
211
150
|
}
|
|
212
151
|
};
|
|
213
152
|
__name(parseCommand, "parseCommand");
|
|
@@ -4410,11 +4349,12 @@ var coerce = {
|
|
|
4410
4349
|
};
|
|
4411
4350
|
var NEVER = INVALID;
|
|
4412
4351
|
|
|
4413
|
-
// ../../node_modules/.pnpm/@agentclientprotocol+sdk@0.
|
|
4352
|
+
// ../../node_modules/.pnpm/@agentclientprotocol+sdk@0.16.1_zod@3.25.76/node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
4414
4353
|
var AGENT_METHODS = {
|
|
4415
4354
|
authenticate: "authenticate",
|
|
4416
4355
|
initialize: "initialize",
|
|
4417
4356
|
session_cancel: "session/cancel",
|
|
4357
|
+
session_close: "session/close",
|
|
4418
4358
|
session_fork: "session/fork",
|
|
4419
4359
|
session_list: "session/list",
|
|
4420
4360
|
session_load: "session/load",
|
|
@@ -15952,38 +15892,81 @@ __name(date4, "date");
|
|
|
15952
15892
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v4/classic/external.js
|
|
15953
15893
|
config(en_default2());
|
|
15954
15894
|
|
|
15955
|
-
// ../../node_modules/.pnpm/@agentclientprotocol+sdk@0.
|
|
15956
|
-
var
|
|
15957
|
-
_meta: external_exports2.
|
|
15958
|
-
|
|
15895
|
+
// ../../node_modules/.pnpm/@agentclientprotocol+sdk@0.16.1_zod@3.25.76/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js
|
|
15896
|
+
var zAuthCapabilities = external_exports2.object({
|
|
15897
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
15898
|
+
terminal: external_exports2.boolean().optional().default(false)
|
|
15899
|
+
});
|
|
15900
|
+
var zAuthEnvVar = external_exports2.object({
|
|
15901
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
15902
|
+
label: external_exports2.string().nullish(),
|
|
15903
|
+
name: external_exports2.string(),
|
|
15904
|
+
optional: external_exports2.boolean().optional().default(false),
|
|
15905
|
+
secret: external_exports2.boolean().optional().default(true)
|
|
15906
|
+
});
|
|
15907
|
+
var zAuthMethodAgent = external_exports2.object({
|
|
15908
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
15909
|
+
description: external_exports2.string().nullish(),
|
|
15910
|
+
id: external_exports2.string(),
|
|
15911
|
+
name: external_exports2.string()
|
|
15912
|
+
});
|
|
15913
|
+
var zAuthMethodEnvVar = external_exports2.object({
|
|
15914
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
15915
|
+
description: external_exports2.string().nullish(),
|
|
15916
|
+
id: external_exports2.string(),
|
|
15917
|
+
link: external_exports2.string().nullish(),
|
|
15918
|
+
name: external_exports2.string(),
|
|
15919
|
+
vars: external_exports2.array(zAuthEnvVar)
|
|
15920
|
+
});
|
|
15921
|
+
var zAuthMethodTerminal = external_exports2.object({
|
|
15922
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
15923
|
+
args: external_exports2.array(external_exports2.string()).optional(),
|
|
15924
|
+
description: external_exports2.string().nullish(),
|
|
15925
|
+
env: external_exports2.record(external_exports2.string(), external_exports2.string()).optional(),
|
|
15959
15926
|
id: external_exports2.string(),
|
|
15960
15927
|
name: external_exports2.string()
|
|
15961
15928
|
});
|
|
15929
|
+
var zAuthMethod = external_exports2.union([
|
|
15930
|
+
zAuthMethodEnvVar.and(external_exports2.object({
|
|
15931
|
+
type: external_exports2.literal("env_var")
|
|
15932
|
+
})),
|
|
15933
|
+
zAuthMethodTerminal.and(external_exports2.object({
|
|
15934
|
+
type: external_exports2.literal("terminal")
|
|
15935
|
+
})),
|
|
15936
|
+
zAuthMethodAgent
|
|
15937
|
+
]);
|
|
15962
15938
|
var zAuthenticateRequest = external_exports2.object({
|
|
15963
|
-
_meta: external_exports2.
|
|
15939
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
15964
15940
|
methodId: external_exports2.string()
|
|
15965
15941
|
});
|
|
15966
15942
|
var zAuthenticateResponse = external_exports2.object({
|
|
15967
|
-
_meta: external_exports2.
|
|
15943
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish()
|
|
15968
15944
|
});
|
|
15969
15945
|
var zBlobResourceContents = external_exports2.object({
|
|
15970
|
-
_meta: external_exports2.
|
|
15946
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
15971
15947
|
blob: external_exports2.string(),
|
|
15972
|
-
mimeType: external_exports2.
|
|
15948
|
+
mimeType: external_exports2.string().nullish(),
|
|
15973
15949
|
uri: external_exports2.string()
|
|
15974
15950
|
});
|
|
15951
|
+
var zCloseSessionResponse = external_exports2.object({
|
|
15952
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish()
|
|
15953
|
+
});
|
|
15954
|
+
var zCost = external_exports2.object({
|
|
15955
|
+
amount: external_exports2.number(),
|
|
15956
|
+
currency: external_exports2.string()
|
|
15957
|
+
});
|
|
15975
15958
|
var zCreateTerminalResponse = external_exports2.object({
|
|
15976
|
-
_meta: external_exports2.
|
|
15959
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
15977
15960
|
terminalId: external_exports2.string()
|
|
15978
15961
|
});
|
|
15979
15962
|
var zDiff = external_exports2.object({
|
|
15980
|
-
_meta: external_exports2.
|
|
15963
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
15981
15964
|
newText: external_exports2.string(),
|
|
15982
|
-
oldText: external_exports2.
|
|
15965
|
+
oldText: external_exports2.string().nullish(),
|
|
15983
15966
|
path: external_exports2.string()
|
|
15984
15967
|
});
|
|
15985
15968
|
var zEnvVariable = external_exports2.object({
|
|
15986
|
-
_meta: external_exports2.
|
|
15969
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
15987
15970
|
name: external_exports2.string(),
|
|
15988
15971
|
value: external_exports2.string()
|
|
15989
15972
|
});
|
|
@@ -15996,7 +15979,11 @@ var zErrorCode = external_exports2.union([
|
|
|
15996
15979
|
external_exports2.literal(-32800),
|
|
15997
15980
|
external_exports2.literal(-32e3),
|
|
15998
15981
|
external_exports2.literal(-32002),
|
|
15999
|
-
external_exports2.number().int()
|
|
15982
|
+
external_exports2.number().int().min(-2147483648, {
|
|
15983
|
+
message: "Invalid value: Expected int32 to be >= -2147483648"
|
|
15984
|
+
}).max(2147483647, {
|
|
15985
|
+
message: "Invalid value: Expected int32 to be <= 2147483647"
|
|
15986
|
+
})
|
|
16000
15987
|
]);
|
|
16001
15988
|
var zError = external_exports2.object({
|
|
16002
15989
|
code: zErrorCode,
|
|
@@ -16006,54 +15993,55 @@ var zError = external_exports2.object({
|
|
|
16006
15993
|
var zExtNotification = external_exports2.unknown();
|
|
16007
15994
|
var zExtRequest = external_exports2.unknown();
|
|
16008
15995
|
var zExtResponse = external_exports2.unknown();
|
|
16009
|
-
var
|
|
16010
|
-
_meta: external_exports2.
|
|
15996
|
+
var zFileSystemCapabilities = external_exports2.object({
|
|
15997
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16011
15998
|
readTextFile: external_exports2.boolean().optional().default(false),
|
|
16012
15999
|
writeTextFile: external_exports2.boolean().optional().default(false)
|
|
16013
16000
|
});
|
|
16014
16001
|
var zClientCapabilities = external_exports2.object({
|
|
16015
|
-
_meta: external_exports2.
|
|
16016
|
-
|
|
16002
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16003
|
+
auth: zAuthCapabilities.optional().default({ terminal: false }),
|
|
16004
|
+
fs: zFileSystemCapabilities.optional().default({ readTextFile: false, writeTextFile: false }),
|
|
16017
16005
|
terminal: external_exports2.boolean().optional().default(false)
|
|
16018
16006
|
});
|
|
16019
16007
|
var zHttpHeader = external_exports2.object({
|
|
16020
|
-
_meta: external_exports2.
|
|
16008
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16021
16009
|
name: external_exports2.string(),
|
|
16022
16010
|
value: external_exports2.string()
|
|
16023
16011
|
});
|
|
16024
16012
|
var zImplementation = external_exports2.object({
|
|
16025
|
-
_meta: external_exports2.
|
|
16013
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16026
16014
|
name: external_exports2.string(),
|
|
16027
|
-
title: external_exports2.
|
|
16015
|
+
title: external_exports2.string().nullish(),
|
|
16028
16016
|
version: external_exports2.string()
|
|
16029
16017
|
});
|
|
16030
|
-
var
|
|
16031
|
-
_meta: external_exports2.
|
|
16018
|
+
var zKillTerminalResponse = external_exports2.object({
|
|
16019
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish()
|
|
16032
16020
|
});
|
|
16033
16021
|
var zListSessionsRequest = external_exports2.object({
|
|
16034
|
-
_meta: external_exports2.
|
|
16035
|
-
cursor: external_exports2.
|
|
16036
|
-
cwd: external_exports2.
|
|
16022
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16023
|
+
cursor: external_exports2.string().nullish(),
|
|
16024
|
+
cwd: external_exports2.string().nullish()
|
|
16037
16025
|
});
|
|
16038
16026
|
var zMcpCapabilities = external_exports2.object({
|
|
16039
|
-
_meta: external_exports2.
|
|
16027
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16040
16028
|
http: external_exports2.boolean().optional().default(false),
|
|
16041
16029
|
sse: external_exports2.boolean().optional().default(false)
|
|
16042
16030
|
});
|
|
16043
16031
|
var zMcpServerHttp = external_exports2.object({
|
|
16044
|
-
_meta: external_exports2.
|
|
16032
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16045
16033
|
headers: external_exports2.array(zHttpHeader),
|
|
16046
16034
|
name: external_exports2.string(),
|
|
16047
16035
|
url: external_exports2.string()
|
|
16048
16036
|
});
|
|
16049
16037
|
var zMcpServerSse = external_exports2.object({
|
|
16050
|
-
_meta: external_exports2.
|
|
16038
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16051
16039
|
headers: external_exports2.array(zHttpHeader),
|
|
16052
16040
|
name: external_exports2.string(),
|
|
16053
16041
|
url: external_exports2.string()
|
|
16054
16042
|
});
|
|
16055
16043
|
var zMcpServerStdio = external_exports2.object({
|
|
16056
|
-
_meta: external_exports2.
|
|
16044
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16057
16045
|
args: external_exports2.array(external_exports2.string()),
|
|
16058
16046
|
command: external_exports2.string(),
|
|
16059
16047
|
env: external_exports2.array(zEnvVariable),
|
|
@@ -16070,13 +16058,13 @@ var zMcpServer = external_exports2.union([
|
|
|
16070
16058
|
]);
|
|
16071
16059
|
var zModelId = external_exports2.string();
|
|
16072
16060
|
var zModelInfo = external_exports2.object({
|
|
16073
|
-
_meta: external_exports2.
|
|
16074
|
-
description: external_exports2.
|
|
16061
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16062
|
+
description: external_exports2.string().nullish(),
|
|
16075
16063
|
modelId: zModelId,
|
|
16076
16064
|
name: external_exports2.string()
|
|
16077
16065
|
});
|
|
16078
16066
|
var zNewSessionRequest = external_exports2.object({
|
|
16079
|
-
_meta: external_exports2.
|
|
16067
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16080
16068
|
cwd: external_exports2.string(),
|
|
16081
16069
|
mcpServers: external_exports2.array(zMcpServer)
|
|
16082
16070
|
});
|
|
@@ -16088,7 +16076,7 @@ var zPermissionOptionKind = external_exports2.union([
|
|
|
16088
16076
|
external_exports2.literal("reject_always")
|
|
16089
16077
|
]);
|
|
16090
16078
|
var zPermissionOption = external_exports2.object({
|
|
16091
|
-
_meta: external_exports2.
|
|
16079
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16092
16080
|
kind: zPermissionOptionKind,
|
|
16093
16081
|
name: external_exports2.string(),
|
|
16094
16082
|
optionId: zPermissionOptionId
|
|
@@ -16104,75 +16092,76 @@ var zPlanEntryStatus = external_exports2.union([
|
|
|
16104
16092
|
external_exports2.literal("completed")
|
|
16105
16093
|
]);
|
|
16106
16094
|
var zPlanEntry = external_exports2.object({
|
|
16107
|
-
_meta: external_exports2.
|
|
16095
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16108
16096
|
content: external_exports2.string(),
|
|
16109
16097
|
priority: zPlanEntryPriority,
|
|
16110
16098
|
status: zPlanEntryStatus
|
|
16111
16099
|
});
|
|
16112
16100
|
var zPlan = external_exports2.object({
|
|
16113
|
-
_meta: external_exports2.
|
|
16101
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16114
16102
|
entries: external_exports2.array(zPlanEntry)
|
|
16115
16103
|
});
|
|
16116
16104
|
var zPromptCapabilities = external_exports2.object({
|
|
16117
|
-
_meta: external_exports2.
|
|
16105
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16118
16106
|
audio: external_exports2.boolean().optional().default(false),
|
|
16119
16107
|
embeddedContext: external_exports2.boolean().optional().default(false),
|
|
16120
16108
|
image: external_exports2.boolean().optional().default(false)
|
|
16121
16109
|
});
|
|
16122
16110
|
var zProtocolVersion = external_exports2.number().int().gte(0).lte(65535);
|
|
16123
16111
|
var zInitializeRequest = external_exports2.object({
|
|
16124
|
-
_meta: external_exports2.
|
|
16112
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16125
16113
|
clientCapabilities: zClientCapabilities.optional().default({
|
|
16114
|
+
auth: { terminal: false },
|
|
16126
16115
|
fs: { readTextFile: false, writeTextFile: false },
|
|
16127
16116
|
terminal: false
|
|
16128
16117
|
}),
|
|
16129
|
-
clientInfo:
|
|
16118
|
+
clientInfo: zImplementation.nullish(),
|
|
16130
16119
|
protocolVersion: zProtocolVersion
|
|
16131
16120
|
});
|
|
16132
16121
|
var zReadTextFileResponse = external_exports2.object({
|
|
16133
|
-
_meta: external_exports2.
|
|
16122
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16134
16123
|
content: external_exports2.string()
|
|
16135
16124
|
});
|
|
16136
16125
|
var zReleaseTerminalResponse = external_exports2.object({
|
|
16137
|
-
_meta: external_exports2.
|
|
16126
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish()
|
|
16138
16127
|
});
|
|
16139
|
-
var zRequestId = external_exports2.union([external_exports2.
|
|
16128
|
+
var zRequestId = external_exports2.union([external_exports2.number(), external_exports2.string()]).nullable();
|
|
16140
16129
|
var zCancelRequestNotification = external_exports2.object({
|
|
16141
|
-
_meta: external_exports2.
|
|
16130
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16142
16131
|
requestId: zRequestId
|
|
16143
16132
|
});
|
|
16144
16133
|
var zRole = external_exports2.enum(["assistant", "user"]);
|
|
16145
16134
|
var zAnnotations = external_exports2.object({
|
|
16146
|
-
_meta: external_exports2.
|
|
16147
|
-
audience: external_exports2.
|
|
16148
|
-
lastModified: external_exports2.
|
|
16149
|
-
priority: external_exports2.
|
|
16135
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16136
|
+
audience: external_exports2.array(zRole).nullish(),
|
|
16137
|
+
lastModified: external_exports2.string().nullish(),
|
|
16138
|
+
priority: external_exports2.number().nullish()
|
|
16150
16139
|
});
|
|
16151
16140
|
var zAudioContent = external_exports2.object({
|
|
16152
|
-
_meta: external_exports2.
|
|
16153
|
-
annotations:
|
|
16141
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16142
|
+
annotations: zAnnotations.nullish(),
|
|
16154
16143
|
data: external_exports2.string(),
|
|
16155
16144
|
mimeType: external_exports2.string()
|
|
16156
16145
|
});
|
|
16157
16146
|
var zImageContent = external_exports2.object({
|
|
16158
|
-
_meta: external_exports2.
|
|
16159
|
-
annotations:
|
|
16147
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16148
|
+
annotations: zAnnotations.nullish(),
|
|
16160
16149
|
data: external_exports2.string(),
|
|
16161
16150
|
mimeType: external_exports2.string(),
|
|
16162
|
-
uri: external_exports2.
|
|
16151
|
+
uri: external_exports2.string().nullish()
|
|
16163
16152
|
});
|
|
16164
16153
|
var zResourceLink = external_exports2.object({
|
|
16165
|
-
_meta: external_exports2.
|
|
16166
|
-
annotations:
|
|
16167
|
-
description: external_exports2.
|
|
16168
|
-
mimeType: external_exports2.
|
|
16154
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16155
|
+
annotations: zAnnotations.nullish(),
|
|
16156
|
+
description: external_exports2.string().nullish(),
|
|
16157
|
+
mimeType: external_exports2.string().nullish(),
|
|
16169
16158
|
name: external_exports2.string(),
|
|
16170
|
-
size: external_exports2.
|
|
16171
|
-
title: external_exports2.
|
|
16159
|
+
size: external_exports2.number().nullish(),
|
|
16160
|
+
title: external_exports2.string().nullish(),
|
|
16172
16161
|
uri: external_exports2.string()
|
|
16173
16162
|
});
|
|
16174
16163
|
var zSelectedPermissionOutcome = external_exports2.object({
|
|
16175
|
-
_meta: external_exports2.
|
|
16164
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16176
16165
|
optionId: zPermissionOptionId
|
|
16177
16166
|
});
|
|
16178
16167
|
var zRequestPermissionOutcome = external_exports2.union([
|
|
@@ -16184,20 +16173,32 @@ var zRequestPermissionOutcome = external_exports2.union([
|
|
|
16184
16173
|
}))
|
|
16185
16174
|
]);
|
|
16186
16175
|
var zRequestPermissionResponse = external_exports2.object({
|
|
16187
|
-
_meta: external_exports2.
|
|
16176
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16188
16177
|
outcome: zRequestPermissionOutcome
|
|
16189
16178
|
});
|
|
16179
|
+
var zSessionCloseCapabilities = external_exports2.object({
|
|
16180
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish()
|
|
16181
|
+
});
|
|
16182
|
+
var zSessionConfigBoolean = external_exports2.object({
|
|
16183
|
+
currentValue: external_exports2.boolean()
|
|
16184
|
+
});
|
|
16190
16185
|
var zSessionConfigGroupId = external_exports2.string();
|
|
16191
16186
|
var zSessionConfigId = external_exports2.string();
|
|
16187
|
+
var zSessionConfigOptionCategory = external_exports2.union([
|
|
16188
|
+
external_exports2.literal("mode"),
|
|
16189
|
+
external_exports2.literal("model"),
|
|
16190
|
+
external_exports2.literal("thought_level"),
|
|
16191
|
+
external_exports2.string()
|
|
16192
|
+
]);
|
|
16192
16193
|
var zSessionConfigValueId = external_exports2.string();
|
|
16193
16194
|
var zSessionConfigSelectOption = external_exports2.object({
|
|
16194
|
-
_meta: external_exports2.
|
|
16195
|
-
description: external_exports2.
|
|
16195
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16196
|
+
description: external_exports2.string().nullish(),
|
|
16196
16197
|
name: external_exports2.string(),
|
|
16197
16198
|
value: zSessionConfigValueId
|
|
16198
16199
|
});
|
|
16199
16200
|
var zSessionConfigSelectGroup = external_exports2.object({
|
|
16200
|
-
_meta: external_exports2.
|
|
16201
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16201
16202
|
group: zSessionConfigGroupId,
|
|
16202
16203
|
name: external_exports2.string(),
|
|
16203
16204
|
options: external_exports2.array(zSessionConfigSelectOption)
|
|
@@ -16210,152 +16211,167 @@ var zSessionConfigSelect = external_exports2.object({
|
|
|
16210
16211
|
currentValue: zSessionConfigValueId,
|
|
16211
16212
|
options: zSessionConfigSelectOptions
|
|
16212
16213
|
});
|
|
16213
|
-
var zSessionConfigOption =
|
|
16214
|
-
|
|
16215
|
-
|
|
16216
|
-
|
|
16217
|
-
|
|
16214
|
+
var zSessionConfigOption = external_exports2.intersection(external_exports2.union([
|
|
16215
|
+
zSessionConfigSelect.and(external_exports2.object({
|
|
16216
|
+
type: external_exports2.literal("select")
|
|
16217
|
+
})),
|
|
16218
|
+
zSessionConfigBoolean.and(external_exports2.object({
|
|
16219
|
+
type: external_exports2.literal("boolean")
|
|
16220
|
+
}))
|
|
16221
|
+
]), external_exports2.object({
|
|
16222
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16223
|
+
category: zSessionConfigOptionCategory.nullish(),
|
|
16224
|
+
description: external_exports2.string().nullish(),
|
|
16218
16225
|
id: zSessionConfigId,
|
|
16219
16226
|
name: external_exports2.string()
|
|
16220
16227
|
}));
|
|
16221
16228
|
var zConfigOptionUpdate = external_exports2.object({
|
|
16222
|
-
_meta: external_exports2.
|
|
16229
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16223
16230
|
configOptions: external_exports2.array(zSessionConfigOption)
|
|
16224
16231
|
});
|
|
16225
16232
|
var zSessionForkCapabilities = external_exports2.object({
|
|
16226
|
-
_meta: external_exports2.
|
|
16233
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish()
|
|
16227
16234
|
});
|
|
16228
16235
|
var zSessionId = external_exports2.string();
|
|
16229
16236
|
var zCancelNotification = external_exports2.object({
|
|
16230
|
-
_meta: external_exports2.
|
|
16237
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16231
16238
|
sessionId: zSessionId
|
|
16232
16239
|
});
|
|
16233
16240
|
var zClientNotification = external_exports2.object({
|
|
16234
16241
|
method: external_exports2.string(),
|
|
16235
|
-
params: external_exports2.union([
|
|
16242
|
+
params: external_exports2.union([zCancelNotification, zExtNotification]).nullish()
|
|
16243
|
+
});
|
|
16244
|
+
var zCloseSessionRequest = external_exports2.object({
|
|
16245
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16246
|
+
sessionId: zSessionId
|
|
16236
16247
|
});
|
|
16237
16248
|
var zCreateTerminalRequest = external_exports2.object({
|
|
16238
|
-
_meta: external_exports2.
|
|
16249
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16239
16250
|
args: external_exports2.array(external_exports2.string()).optional(),
|
|
16240
16251
|
command: external_exports2.string(),
|
|
16241
|
-
cwd: external_exports2.
|
|
16252
|
+
cwd: external_exports2.string().nullish(),
|
|
16242
16253
|
env: external_exports2.array(zEnvVariable).optional(),
|
|
16243
|
-
outputByteLimit: external_exports2.
|
|
16254
|
+
outputByteLimit: external_exports2.number().nullish(),
|
|
16244
16255
|
sessionId: zSessionId
|
|
16245
16256
|
});
|
|
16246
16257
|
var zForkSessionRequest = external_exports2.object({
|
|
16247
|
-
_meta: external_exports2.
|
|
16258
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16248
16259
|
cwd: external_exports2.string(),
|
|
16249
16260
|
mcpServers: external_exports2.array(zMcpServer).optional(),
|
|
16250
16261
|
sessionId: zSessionId
|
|
16251
16262
|
});
|
|
16252
|
-
var
|
|
16253
|
-
_meta: external_exports2.
|
|
16263
|
+
var zKillTerminalRequest = external_exports2.object({
|
|
16264
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16254
16265
|
sessionId: zSessionId,
|
|
16255
16266
|
terminalId: external_exports2.string()
|
|
16256
16267
|
});
|
|
16257
16268
|
var zLoadSessionRequest = external_exports2.object({
|
|
16258
|
-
_meta: external_exports2.
|
|
16269
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16259
16270
|
cwd: external_exports2.string(),
|
|
16260
16271
|
mcpServers: external_exports2.array(zMcpServer),
|
|
16261
16272
|
sessionId: zSessionId
|
|
16262
16273
|
});
|
|
16263
16274
|
var zReadTextFileRequest = external_exports2.object({
|
|
16264
|
-
_meta: external_exports2.
|
|
16265
|
-
limit: external_exports2.
|
|
16266
|
-
|
|
16275
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16276
|
+
limit: external_exports2.number().int().gte(0).max(4294967295, {
|
|
16277
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
16278
|
+
}).nullish(),
|
|
16279
|
+
line: external_exports2.number().int().gte(0).max(4294967295, {
|
|
16280
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
16281
|
+
}).nullish(),
|
|
16267
16282
|
path: external_exports2.string(),
|
|
16268
16283
|
sessionId: zSessionId
|
|
16269
16284
|
});
|
|
16270
16285
|
var zReleaseTerminalRequest = external_exports2.object({
|
|
16271
|
-
_meta: external_exports2.
|
|
16286
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16272
16287
|
sessionId: zSessionId,
|
|
16273
16288
|
terminalId: external_exports2.string()
|
|
16274
16289
|
});
|
|
16275
16290
|
var zResumeSessionRequest = external_exports2.object({
|
|
16276
|
-
_meta: external_exports2.
|
|
16291
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16277
16292
|
cwd: external_exports2.string(),
|
|
16278
16293
|
mcpServers: external_exports2.array(zMcpServer).optional(),
|
|
16279
16294
|
sessionId: zSessionId
|
|
16280
16295
|
});
|
|
16281
16296
|
var zSessionInfo = external_exports2.object({
|
|
16282
|
-
_meta: external_exports2.
|
|
16297
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16283
16298
|
cwd: external_exports2.string(),
|
|
16284
16299
|
sessionId: zSessionId,
|
|
16285
|
-
title: external_exports2.
|
|
16286
|
-
updatedAt: external_exports2.
|
|
16300
|
+
title: external_exports2.string().nullish(),
|
|
16301
|
+
updatedAt: external_exports2.string().nullish()
|
|
16287
16302
|
});
|
|
16288
16303
|
var zListSessionsResponse = external_exports2.object({
|
|
16289
|
-
_meta: external_exports2.
|
|
16290
|
-
nextCursor: external_exports2.
|
|
16304
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16305
|
+
nextCursor: external_exports2.string().nullish(),
|
|
16291
16306
|
sessions: external_exports2.array(zSessionInfo)
|
|
16292
16307
|
});
|
|
16293
16308
|
var zSessionInfoUpdate = external_exports2.object({
|
|
16294
|
-
_meta: external_exports2.
|
|
16295
|
-
title: external_exports2.
|
|
16296
|
-
updatedAt: external_exports2.
|
|
16309
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16310
|
+
title: external_exports2.string().nullish(),
|
|
16311
|
+
updatedAt: external_exports2.string().nullish()
|
|
16297
16312
|
});
|
|
16298
16313
|
var zSessionListCapabilities = external_exports2.object({
|
|
16299
|
-
_meta: external_exports2.
|
|
16314
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish()
|
|
16300
16315
|
});
|
|
16301
16316
|
var zSessionModeId = external_exports2.string();
|
|
16302
16317
|
var zCurrentModeUpdate = external_exports2.object({
|
|
16303
|
-
_meta: external_exports2.
|
|
16318
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16304
16319
|
currentModeId: zSessionModeId
|
|
16305
16320
|
});
|
|
16306
16321
|
var zSessionMode = external_exports2.object({
|
|
16307
|
-
_meta: external_exports2.
|
|
16308
|
-
description: external_exports2.
|
|
16322
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16323
|
+
description: external_exports2.string().nullish(),
|
|
16309
16324
|
id: zSessionModeId,
|
|
16310
16325
|
name: external_exports2.string()
|
|
16311
16326
|
});
|
|
16312
16327
|
var zSessionModeState = external_exports2.object({
|
|
16313
|
-
_meta: external_exports2.
|
|
16328
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16314
16329
|
availableModes: external_exports2.array(zSessionMode),
|
|
16315
16330
|
currentModeId: zSessionModeId
|
|
16316
16331
|
});
|
|
16317
16332
|
var zSessionModelState = external_exports2.object({
|
|
16318
|
-
_meta: external_exports2.
|
|
16333
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16319
16334
|
availableModels: external_exports2.array(zModelInfo),
|
|
16320
16335
|
currentModelId: zModelId
|
|
16321
16336
|
});
|
|
16322
16337
|
var zForkSessionResponse = external_exports2.object({
|
|
16323
|
-
_meta: external_exports2.
|
|
16324
|
-
configOptions: external_exports2.
|
|
16325
|
-
models:
|
|
16326
|
-
modes:
|
|
16338
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16339
|
+
configOptions: external_exports2.array(zSessionConfigOption).nullish(),
|
|
16340
|
+
models: zSessionModelState.nullish(),
|
|
16341
|
+
modes: zSessionModeState.nullish(),
|
|
16327
16342
|
sessionId: zSessionId
|
|
16328
16343
|
});
|
|
16329
16344
|
var zLoadSessionResponse = external_exports2.object({
|
|
16330
|
-
_meta: external_exports2.
|
|
16331
|
-
configOptions: external_exports2.
|
|
16332
|
-
models:
|
|
16333
|
-
modes:
|
|
16345
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16346
|
+
configOptions: external_exports2.array(zSessionConfigOption).nullish(),
|
|
16347
|
+
models: zSessionModelState.nullish(),
|
|
16348
|
+
modes: zSessionModeState.nullish()
|
|
16334
16349
|
});
|
|
16335
16350
|
var zNewSessionResponse = external_exports2.object({
|
|
16336
|
-
_meta: external_exports2.
|
|
16337
|
-
configOptions: external_exports2.
|
|
16338
|
-
models:
|
|
16339
|
-
modes:
|
|
16351
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16352
|
+
configOptions: external_exports2.array(zSessionConfigOption).nullish(),
|
|
16353
|
+
models: zSessionModelState.nullish(),
|
|
16354
|
+
modes: zSessionModeState.nullish(),
|
|
16340
16355
|
sessionId: zSessionId
|
|
16341
16356
|
});
|
|
16342
16357
|
var zResumeSessionResponse = external_exports2.object({
|
|
16343
|
-
_meta: external_exports2.
|
|
16344
|
-
configOptions: external_exports2.
|
|
16345
|
-
models:
|
|
16346
|
-
modes:
|
|
16358
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16359
|
+
configOptions: external_exports2.array(zSessionConfigOption).nullish(),
|
|
16360
|
+
models: zSessionModelState.nullish(),
|
|
16361
|
+
modes: zSessionModeState.nullish()
|
|
16347
16362
|
});
|
|
16348
16363
|
var zSessionResumeCapabilities = external_exports2.object({
|
|
16349
|
-
_meta: external_exports2.
|
|
16364
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish()
|
|
16350
16365
|
});
|
|
16351
16366
|
var zSessionCapabilities = external_exports2.object({
|
|
16352
|
-
_meta: external_exports2.
|
|
16353
|
-
|
|
16354
|
-
|
|
16355
|
-
|
|
16367
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16368
|
+
close: zSessionCloseCapabilities.nullish(),
|
|
16369
|
+
fork: zSessionForkCapabilities.nullish(),
|
|
16370
|
+
list: zSessionListCapabilities.nullish(),
|
|
16371
|
+
resume: zSessionResumeCapabilities.nullish()
|
|
16356
16372
|
});
|
|
16357
16373
|
var zAgentCapabilities = external_exports2.object({
|
|
16358
|
-
_meta: external_exports2.
|
|
16374
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16359
16375
|
loadSession: external_exports2.boolean().optional().default(false),
|
|
16360
16376
|
mcpCapabilities: zMcpCapabilities.optional().default({ http: false, sse: false }),
|
|
16361
16377
|
promptCapabilities: zPromptCapabilities.optional().default({
|
|
@@ -16366,7 +16382,7 @@ var zAgentCapabilities = external_exports2.object({
|
|
|
16366
16382
|
sessionCapabilities: zSessionCapabilities.optional().default({})
|
|
16367
16383
|
});
|
|
16368
16384
|
var zInitializeResponse = external_exports2.object({
|
|
16369
|
-
_meta: external_exports2.
|
|
16385
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16370
16386
|
agentCapabilities: zAgentCapabilities.optional().default({
|
|
16371
16387
|
loadSession: false,
|
|
16372
16388
|
mcpCapabilities: { http: false, sse: false },
|
|
@@ -16377,35 +16393,42 @@ var zInitializeResponse = external_exports2.object({
|
|
|
16377
16393
|
},
|
|
16378
16394
|
sessionCapabilities: {}
|
|
16379
16395
|
}),
|
|
16380
|
-
agentInfo:
|
|
16396
|
+
agentInfo: zImplementation.nullish(),
|
|
16381
16397
|
authMethods: external_exports2.array(zAuthMethod).optional().default([]),
|
|
16382
16398
|
protocolVersion: zProtocolVersion
|
|
16383
16399
|
});
|
|
16384
|
-
var zSetSessionConfigOptionRequest = external_exports2.
|
|
16385
|
-
|
|
16400
|
+
var zSetSessionConfigOptionRequest = external_exports2.intersection(external_exports2.union([
|
|
16401
|
+
external_exports2.object({
|
|
16402
|
+
type: external_exports2.literal("boolean"),
|
|
16403
|
+
value: external_exports2.boolean()
|
|
16404
|
+
}),
|
|
16405
|
+
external_exports2.object({
|
|
16406
|
+
value: zSessionConfigValueId
|
|
16407
|
+
})
|
|
16408
|
+
]), external_exports2.object({
|
|
16409
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16386
16410
|
configId: zSessionConfigId,
|
|
16387
|
-
sessionId: zSessionId
|
|
16388
|
-
|
|
16389
|
-
});
|
|
16411
|
+
sessionId: zSessionId
|
|
16412
|
+
}));
|
|
16390
16413
|
var zSetSessionConfigOptionResponse = external_exports2.object({
|
|
16391
|
-
_meta: external_exports2.
|
|
16414
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16392
16415
|
configOptions: external_exports2.array(zSessionConfigOption)
|
|
16393
16416
|
});
|
|
16394
16417
|
var zSetSessionModeRequest = external_exports2.object({
|
|
16395
|
-
_meta: external_exports2.
|
|
16418
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16396
16419
|
modeId: zSessionModeId,
|
|
16397
16420
|
sessionId: zSessionId
|
|
16398
16421
|
});
|
|
16399
16422
|
var zSetSessionModeResponse = external_exports2.object({
|
|
16400
|
-
_meta: external_exports2.
|
|
16423
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish()
|
|
16401
16424
|
});
|
|
16402
16425
|
var zSetSessionModelRequest = external_exports2.object({
|
|
16403
|
-
_meta: external_exports2.
|
|
16426
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16404
16427
|
modelId: zModelId,
|
|
16405
16428
|
sessionId: zSessionId
|
|
16406
16429
|
});
|
|
16407
16430
|
var zSetSessionModelResponse = external_exports2.object({
|
|
16408
|
-
_meta: external_exports2.
|
|
16431
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish()
|
|
16409
16432
|
});
|
|
16410
16433
|
var zStopReason = external_exports2.union([
|
|
16411
16434
|
external_exports2.literal("end_turn"),
|
|
@@ -16414,61 +16437,36 @@ var zStopReason = external_exports2.union([
|
|
|
16414
16437
|
external_exports2.literal("refusal"),
|
|
16415
16438
|
external_exports2.literal("cancelled")
|
|
16416
16439
|
]);
|
|
16417
|
-
var zPromptResponse = external_exports2.object({
|
|
16418
|
-
_meta: external_exports2.union([external_exports2.record(external_exports2.string(), external_exports2.unknown()), external_exports2.null()]).optional(),
|
|
16419
|
-
stopReason: zStopReason
|
|
16420
|
-
});
|
|
16421
|
-
var zAgentResponse = external_exports2.union([
|
|
16422
|
-
external_exports2.object({
|
|
16423
|
-
id: zRequestId,
|
|
16424
|
-
result: external_exports2.union([
|
|
16425
|
-
zInitializeResponse,
|
|
16426
|
-
zAuthenticateResponse,
|
|
16427
|
-
zNewSessionResponse,
|
|
16428
|
-
zLoadSessionResponse,
|
|
16429
|
-
zListSessionsResponse,
|
|
16430
|
-
zForkSessionResponse,
|
|
16431
|
-
zResumeSessionResponse,
|
|
16432
|
-
zSetSessionModeResponse,
|
|
16433
|
-
zSetSessionConfigOptionResponse,
|
|
16434
|
-
zPromptResponse,
|
|
16435
|
-
zSetSessionModelResponse,
|
|
16436
|
-
zExtResponse
|
|
16437
|
-
])
|
|
16438
|
-
}),
|
|
16439
|
-
external_exports2.object({
|
|
16440
|
-
error: zError,
|
|
16441
|
-
id: zRequestId
|
|
16442
|
-
})
|
|
16443
|
-
]);
|
|
16444
16440
|
var zTerminal = external_exports2.object({
|
|
16445
|
-
_meta: external_exports2.
|
|
16441
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16446
16442
|
terminalId: external_exports2.string()
|
|
16447
16443
|
});
|
|
16448
16444
|
var zTerminalExitStatus = external_exports2.object({
|
|
16449
|
-
_meta: external_exports2.
|
|
16450
|
-
exitCode: external_exports2.
|
|
16451
|
-
|
|
16445
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16446
|
+
exitCode: external_exports2.number().int().gte(0).max(4294967295, {
|
|
16447
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
16448
|
+
}).nullish(),
|
|
16449
|
+
signal: external_exports2.string().nullish()
|
|
16452
16450
|
});
|
|
16453
16451
|
var zTerminalOutputRequest = external_exports2.object({
|
|
16454
|
-
_meta: external_exports2.
|
|
16452
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16455
16453
|
sessionId: zSessionId,
|
|
16456
16454
|
terminalId: external_exports2.string()
|
|
16457
16455
|
});
|
|
16458
16456
|
var zTerminalOutputResponse = external_exports2.object({
|
|
16459
|
-
_meta: external_exports2.
|
|
16460
|
-
exitStatus:
|
|
16457
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16458
|
+
exitStatus: zTerminalExitStatus.nullish(),
|
|
16461
16459
|
output: external_exports2.string(),
|
|
16462
16460
|
truncated: external_exports2.boolean()
|
|
16463
16461
|
});
|
|
16464
16462
|
var zTextContent = external_exports2.object({
|
|
16465
|
-
_meta: external_exports2.
|
|
16466
|
-
annotations:
|
|
16463
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16464
|
+
annotations: zAnnotations.nullish(),
|
|
16467
16465
|
text: external_exports2.string()
|
|
16468
16466
|
});
|
|
16469
16467
|
var zTextResourceContents = external_exports2.object({
|
|
16470
|
-
_meta: external_exports2.
|
|
16471
|
-
mimeType: external_exports2.
|
|
16468
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16469
|
+
mimeType: external_exports2.string().nullish(),
|
|
16472
16470
|
text: external_exports2.string(),
|
|
16473
16471
|
uri: external_exports2.string()
|
|
16474
16472
|
});
|
|
@@ -16477,8 +16475,8 @@ var zEmbeddedResourceResource = external_exports2.union([
|
|
|
16477
16475
|
zBlobResourceContents
|
|
16478
16476
|
]);
|
|
16479
16477
|
var zEmbeddedResource = external_exports2.object({
|
|
16480
|
-
_meta: external_exports2.
|
|
16481
|
-
annotations:
|
|
16478
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16479
|
+
annotations: zAnnotations.nullish(),
|
|
16482
16480
|
resource: zEmbeddedResourceResource
|
|
16483
16481
|
});
|
|
16484
16482
|
var zContentBlock = external_exports2.union([
|
|
@@ -16499,15 +16497,17 @@ var zContentBlock = external_exports2.union([
|
|
|
16499
16497
|
}))
|
|
16500
16498
|
]);
|
|
16501
16499
|
var zContent = external_exports2.object({
|
|
16502
|
-
_meta: external_exports2.
|
|
16500
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16503
16501
|
content: zContentBlock
|
|
16504
16502
|
});
|
|
16505
16503
|
var zContentChunk = external_exports2.object({
|
|
16506
|
-
_meta: external_exports2.
|
|
16507
|
-
content: zContentBlock
|
|
16504
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16505
|
+
content: zContentBlock,
|
|
16506
|
+
messageId: external_exports2.string().nullish()
|
|
16508
16507
|
});
|
|
16509
16508
|
var zPromptRequest = external_exports2.object({
|
|
16510
|
-
_meta: external_exports2.
|
|
16509
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16510
|
+
messageId: external_exports2.string().nullish(),
|
|
16511
16511
|
prompt: external_exports2.array(zContentBlock),
|
|
16512
16512
|
sessionId: zSessionId
|
|
16513
16513
|
});
|
|
@@ -16515,22 +16515,20 @@ var zClientRequest = external_exports2.object({
|
|
|
16515
16515
|
id: zRequestId,
|
|
16516
16516
|
method: external_exports2.string(),
|
|
16517
16517
|
params: external_exports2.union([
|
|
16518
|
-
|
|
16519
|
-
|
|
16520
|
-
|
|
16521
|
-
|
|
16522
|
-
|
|
16523
|
-
|
|
16524
|
-
|
|
16525
|
-
|
|
16526
|
-
|
|
16527
|
-
|
|
16528
|
-
|
|
16529
|
-
|
|
16530
|
-
|
|
16531
|
-
|
|
16532
|
-
external_exports2.null()
|
|
16533
|
-
]).optional()
|
|
16518
|
+
zInitializeRequest,
|
|
16519
|
+
zAuthenticateRequest,
|
|
16520
|
+
zNewSessionRequest,
|
|
16521
|
+
zLoadSessionRequest,
|
|
16522
|
+
zListSessionsRequest,
|
|
16523
|
+
zForkSessionRequest,
|
|
16524
|
+
zResumeSessionRequest,
|
|
16525
|
+
zCloseSessionRequest,
|
|
16526
|
+
zSetSessionModeRequest,
|
|
16527
|
+
zSetSessionConfigOptionRequest,
|
|
16528
|
+
zPromptRequest,
|
|
16529
|
+
zSetSessionModelRequest,
|
|
16530
|
+
zExtRequest
|
|
16531
|
+
]).nullish()
|
|
16534
16532
|
});
|
|
16535
16533
|
var zToolCallContent = external_exports2.union([
|
|
16536
16534
|
zContent.and(external_exports2.object({
|
|
@@ -16545,8 +16543,10 @@ var zToolCallContent = external_exports2.union([
|
|
|
16545
16543
|
]);
|
|
16546
16544
|
var zToolCallId = external_exports2.string();
|
|
16547
16545
|
var zToolCallLocation = external_exports2.object({
|
|
16548
|
-
_meta: external_exports2.
|
|
16549
|
-
line: external_exports2.
|
|
16546
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16547
|
+
line: external_exports2.number().int().gte(0).max(4294967295, {
|
|
16548
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
16549
|
+
}).nullish(),
|
|
16550
16550
|
path: external_exports2.string()
|
|
16551
16551
|
});
|
|
16552
16552
|
var zToolCallStatus = external_exports2.union([
|
|
@@ -16568,7 +16568,7 @@ var zToolKind = external_exports2.union([
|
|
|
16568
16568
|
external_exports2.literal("other")
|
|
16569
16569
|
]);
|
|
16570
16570
|
var zToolCall = external_exports2.object({
|
|
16571
|
-
_meta: external_exports2.
|
|
16571
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16572
16572
|
content: external_exports2.array(zToolCallContent).optional(),
|
|
16573
16573
|
kind: zToolKind.optional(),
|
|
16574
16574
|
locations: external_exports2.array(zToolCallLocation).optional(),
|
|
@@ -16579,37 +16579,81 @@ var zToolCall = external_exports2.object({
|
|
|
16579
16579
|
toolCallId: zToolCallId
|
|
16580
16580
|
});
|
|
16581
16581
|
var zToolCallUpdate = external_exports2.object({
|
|
16582
|
-
_meta: external_exports2.
|
|
16583
|
-
content: external_exports2.
|
|
16584
|
-
kind:
|
|
16585
|
-
locations: external_exports2.
|
|
16582
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16583
|
+
content: external_exports2.array(zToolCallContent).nullish(),
|
|
16584
|
+
kind: zToolKind.nullish(),
|
|
16585
|
+
locations: external_exports2.array(zToolCallLocation).nullish(),
|
|
16586
16586
|
rawInput: external_exports2.unknown().optional(),
|
|
16587
16587
|
rawOutput: external_exports2.unknown().optional(),
|
|
16588
|
-
status:
|
|
16589
|
-
title: external_exports2.
|
|
16588
|
+
status: zToolCallStatus.nullish(),
|
|
16589
|
+
title: external_exports2.string().nullish(),
|
|
16590
16590
|
toolCallId: zToolCallId
|
|
16591
16591
|
});
|
|
16592
16592
|
var zRequestPermissionRequest = external_exports2.object({
|
|
16593
|
-
_meta: external_exports2.
|
|
16593
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16594
16594
|
options: external_exports2.array(zPermissionOption),
|
|
16595
16595
|
sessionId: zSessionId,
|
|
16596
16596
|
toolCall: zToolCallUpdate
|
|
16597
16597
|
});
|
|
16598
16598
|
var zUnstructuredCommandInput = external_exports2.object({
|
|
16599
|
-
_meta: external_exports2.
|
|
16599
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16600
16600
|
hint: external_exports2.string()
|
|
16601
16601
|
});
|
|
16602
16602
|
var zAvailableCommandInput = zUnstructuredCommandInput;
|
|
16603
16603
|
var zAvailableCommand = external_exports2.object({
|
|
16604
|
-
_meta: external_exports2.
|
|
16604
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16605
16605
|
description: external_exports2.string(),
|
|
16606
|
-
input:
|
|
16606
|
+
input: zAvailableCommandInput.nullish(),
|
|
16607
16607
|
name: external_exports2.string()
|
|
16608
16608
|
});
|
|
16609
16609
|
var zAvailableCommandsUpdate = external_exports2.object({
|
|
16610
|
-
_meta: external_exports2.
|
|
16610
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16611
16611
|
availableCommands: external_exports2.array(zAvailableCommand)
|
|
16612
16612
|
});
|
|
16613
|
+
var zUsage = external_exports2.object({
|
|
16614
|
+
cachedReadTokens: external_exports2.number().nullish(),
|
|
16615
|
+
cachedWriteTokens: external_exports2.number().nullish(),
|
|
16616
|
+
inputTokens: external_exports2.number(),
|
|
16617
|
+
outputTokens: external_exports2.number(),
|
|
16618
|
+
thoughtTokens: external_exports2.number().nullish(),
|
|
16619
|
+
totalTokens: external_exports2.number()
|
|
16620
|
+
});
|
|
16621
|
+
var zPromptResponse = external_exports2.object({
|
|
16622
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16623
|
+
stopReason: zStopReason,
|
|
16624
|
+
usage: zUsage.nullish(),
|
|
16625
|
+
userMessageId: external_exports2.string().nullish()
|
|
16626
|
+
});
|
|
16627
|
+
var zAgentResponse = external_exports2.union([
|
|
16628
|
+
external_exports2.object({
|
|
16629
|
+
id: zRequestId,
|
|
16630
|
+
result: external_exports2.union([
|
|
16631
|
+
zInitializeResponse,
|
|
16632
|
+
zAuthenticateResponse,
|
|
16633
|
+
zNewSessionResponse,
|
|
16634
|
+
zLoadSessionResponse,
|
|
16635
|
+
zListSessionsResponse,
|
|
16636
|
+
zForkSessionResponse,
|
|
16637
|
+
zResumeSessionResponse,
|
|
16638
|
+
zCloseSessionResponse,
|
|
16639
|
+
zSetSessionModeResponse,
|
|
16640
|
+
zSetSessionConfigOptionResponse,
|
|
16641
|
+
zPromptResponse,
|
|
16642
|
+
zSetSessionModelResponse,
|
|
16643
|
+
zExtResponse
|
|
16644
|
+
])
|
|
16645
|
+
}),
|
|
16646
|
+
external_exports2.object({
|
|
16647
|
+
error: zError,
|
|
16648
|
+
id: zRequestId
|
|
16649
|
+
})
|
|
16650
|
+
]);
|
|
16651
|
+
var zUsageUpdate = external_exports2.object({
|
|
16652
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16653
|
+
cost: zCost.nullish(),
|
|
16654
|
+
size: external_exports2.number(),
|
|
16655
|
+
used: external_exports2.number()
|
|
16656
|
+
});
|
|
16613
16657
|
var zSessionUpdate = external_exports2.union([
|
|
16614
16658
|
zContentChunk.and(external_exports2.object({
|
|
16615
16659
|
sessionUpdate: external_exports2.literal("user_message_chunk")
|
|
@@ -16640,29 +16684,34 @@ var zSessionUpdate = external_exports2.union([
|
|
|
16640
16684
|
})),
|
|
16641
16685
|
zSessionInfoUpdate.and(external_exports2.object({
|
|
16642
16686
|
sessionUpdate: external_exports2.literal("session_info_update")
|
|
16687
|
+
})),
|
|
16688
|
+
zUsageUpdate.and(external_exports2.object({
|
|
16689
|
+
sessionUpdate: external_exports2.literal("usage_update")
|
|
16643
16690
|
}))
|
|
16644
16691
|
]);
|
|
16645
16692
|
var zSessionNotification = external_exports2.object({
|
|
16646
|
-
_meta: external_exports2.
|
|
16693
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16647
16694
|
sessionId: zSessionId,
|
|
16648
16695
|
update: zSessionUpdate
|
|
16649
16696
|
});
|
|
16650
16697
|
var zAgentNotification = external_exports2.object({
|
|
16651
16698
|
method: external_exports2.string(),
|
|
16652
|
-
params: external_exports2.union([
|
|
16699
|
+
params: external_exports2.union([zSessionNotification, zExtNotification]).nullish()
|
|
16653
16700
|
});
|
|
16654
16701
|
var zWaitForTerminalExitRequest = external_exports2.object({
|
|
16655
|
-
_meta: external_exports2.
|
|
16702
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16656
16703
|
sessionId: zSessionId,
|
|
16657
16704
|
terminalId: external_exports2.string()
|
|
16658
16705
|
});
|
|
16659
16706
|
var zWaitForTerminalExitResponse = external_exports2.object({
|
|
16660
|
-
_meta: external_exports2.
|
|
16661
|
-
exitCode: external_exports2.
|
|
16662
|
-
|
|
16707
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16708
|
+
exitCode: external_exports2.number().int().gte(0).max(4294967295, {
|
|
16709
|
+
message: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
16710
|
+
}).nullish(),
|
|
16711
|
+
signal: external_exports2.string().nullish()
|
|
16663
16712
|
});
|
|
16664
16713
|
var zWriteTextFileRequest = external_exports2.object({
|
|
16665
|
-
_meta: external_exports2.
|
|
16714
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish(),
|
|
16666
16715
|
content: external_exports2.string(),
|
|
16667
16716
|
path: external_exports2.string(),
|
|
16668
16717
|
sessionId: zSessionId
|
|
@@ -16671,22 +16720,19 @@ var zAgentRequest = external_exports2.object({
|
|
|
16671
16720
|
id: zRequestId,
|
|
16672
16721
|
method: external_exports2.string(),
|
|
16673
16722
|
params: external_exports2.union([
|
|
16674
|
-
|
|
16675
|
-
|
|
16676
|
-
|
|
16677
|
-
|
|
16678
|
-
|
|
16679
|
-
|
|
16680
|
-
|
|
16681
|
-
|
|
16682
|
-
|
|
16683
|
-
|
|
16684
|
-
]),
|
|
16685
|
-
external_exports2.null()
|
|
16686
|
-
]).optional()
|
|
16723
|
+
zWriteTextFileRequest,
|
|
16724
|
+
zReadTextFileRequest,
|
|
16725
|
+
zRequestPermissionRequest,
|
|
16726
|
+
zCreateTerminalRequest,
|
|
16727
|
+
zTerminalOutputRequest,
|
|
16728
|
+
zReleaseTerminalRequest,
|
|
16729
|
+
zWaitForTerminalExitRequest,
|
|
16730
|
+
zKillTerminalRequest,
|
|
16731
|
+
zExtRequest
|
|
16732
|
+
]).nullish()
|
|
16687
16733
|
});
|
|
16688
16734
|
var zWriteTextFileResponse = external_exports2.object({
|
|
16689
|
-
_meta: external_exports2.
|
|
16735
|
+
_meta: external_exports2.record(external_exports2.string(), external_exports2.unknown()).nullish()
|
|
16690
16736
|
});
|
|
16691
16737
|
var zClientResponse = external_exports2.union([
|
|
16692
16738
|
external_exports2.object({
|
|
@@ -16699,7 +16745,7 @@ var zClientResponse = external_exports2.union([
|
|
|
16699
16745
|
zTerminalOutputResponse,
|
|
16700
16746
|
zReleaseTerminalResponse,
|
|
16701
16747
|
zWaitForTerminalExitResponse,
|
|
16702
|
-
|
|
16748
|
+
zKillTerminalResponse,
|
|
16703
16749
|
zExtResponse
|
|
16704
16750
|
])
|
|
16705
16751
|
}),
|
|
@@ -16709,7 +16755,7 @@ var zClientResponse = external_exports2.union([
|
|
|
16709
16755
|
})
|
|
16710
16756
|
]);
|
|
16711
16757
|
|
|
16712
|
-
// ../../node_modules/.pnpm/@agentclientprotocol+sdk@0.
|
|
16758
|
+
// ../../node_modules/.pnpm/@agentclientprotocol+sdk@0.16.1_zod@3.25.76/node_modules/@agentclientprotocol/sdk/dist/acp.js
|
|
16713
16759
|
var ClientSideConnection = class {
|
|
16714
16760
|
static {
|
|
16715
16761
|
__name(this, "ClientSideConnection");
|
|
@@ -16761,17 +16807,13 @@ var ClientSideConnection = class {
|
|
|
16761
16807
|
return client.waitForTerminalExit?.(validatedParams);
|
|
16762
16808
|
}
|
|
16763
16809
|
case CLIENT_METHODS.terminal_kill: {
|
|
16764
|
-
const validatedParams =
|
|
16810
|
+
const validatedParams = zKillTerminalRequest.parse(params);
|
|
16765
16811
|
const result = await client.killTerminal?.(validatedParams);
|
|
16766
16812
|
return result ?? {};
|
|
16767
16813
|
}
|
|
16768
16814
|
default:
|
|
16769
|
-
if (
|
|
16770
|
-
|
|
16771
|
-
if (!client.extMethod) {
|
|
16772
|
-
throw RequestError.methodNotFound(method);
|
|
16773
|
-
}
|
|
16774
|
-
return client.extMethod(customMethod, params);
|
|
16815
|
+
if (client.extMethod) {
|
|
16816
|
+
return client.extMethod(method, params);
|
|
16775
16817
|
}
|
|
16776
16818
|
throw RequestError.methodNotFound(method);
|
|
16777
16819
|
}
|
|
@@ -16783,12 +16825,8 @@ var ClientSideConnection = class {
|
|
|
16783
16825
|
return client.sessionUpdate(validatedParams);
|
|
16784
16826
|
}
|
|
16785
16827
|
default:
|
|
16786
|
-
if (
|
|
16787
|
-
|
|
16788
|
-
if (!client.extNotification) {
|
|
16789
|
-
return;
|
|
16790
|
-
}
|
|
16791
|
-
return client.extNotification(customMethod, params);
|
|
16828
|
+
if (client.extNotification) {
|
|
16829
|
+
return client.extNotification(method, params);
|
|
16792
16830
|
}
|
|
16793
16831
|
throw RequestError.methodNotFound(method);
|
|
16794
16832
|
}
|
|
@@ -16860,10 +16898,6 @@ var ClientSideConnection = class {
|
|
|
16860
16898
|
return await this.#connection.sendRequest(AGENT_METHODS.session_fork, params);
|
|
16861
16899
|
}
|
|
16862
16900
|
/**
|
|
16863
|
-
* **UNSTABLE**
|
|
16864
|
-
*
|
|
16865
|
-
* This capability is not part of the spec yet, and may be removed or changed at any point.
|
|
16866
|
-
*
|
|
16867
16901
|
* Lists existing sessions from the agent.
|
|
16868
16902
|
*
|
|
16869
16903
|
* This method is only available if the agent advertises the `listSessions` capability.
|
|
@@ -16871,10 +16905,8 @@ var ClientSideConnection = class {
|
|
|
16871
16905
|
* Returns a list of sessions with metadata like session ID, working directory,
|
|
16872
16906
|
* title, and last update time. Supports filtering by working directory and
|
|
16873
16907
|
* cursor-based pagination.
|
|
16874
|
-
*
|
|
16875
|
-
* @experimental
|
|
16876
16908
|
*/
|
|
16877
|
-
async
|
|
16909
|
+
async listSessions(params) {
|
|
16878
16910
|
return await this.#connection.sendRequest(AGENT_METHODS.session_list, params);
|
|
16879
16911
|
}
|
|
16880
16912
|
/**
|
|
@@ -16894,6 +16926,23 @@ var ClientSideConnection = class {
|
|
|
16894
16926
|
async unstable_resumeSession(params) {
|
|
16895
16927
|
return await this.#connection.sendRequest(AGENT_METHODS.session_resume, params);
|
|
16896
16928
|
}
|
|
16929
|
+
/**
|
|
16930
|
+
* **UNSTABLE**
|
|
16931
|
+
*
|
|
16932
|
+
* This capability is not part of the spec yet, and may be removed or changed at any point.
|
|
16933
|
+
*
|
|
16934
|
+
* Closes an active session and frees up any resources associated with it.
|
|
16935
|
+
*
|
|
16936
|
+
* This method is only available if the agent advertises the `session.close` capability.
|
|
16937
|
+
*
|
|
16938
|
+
* The agent must cancel any ongoing work (as if `session/cancel` was called)
|
|
16939
|
+
* and then free up any resources associated with the session.
|
|
16940
|
+
*
|
|
16941
|
+
* @experimental
|
|
16942
|
+
*/
|
|
16943
|
+
async unstable_closeSession(params) {
|
|
16944
|
+
return await this.#connection.sendRequest(AGENT_METHODS.session_close, params);
|
|
16945
|
+
}
|
|
16897
16946
|
/**
|
|
16898
16947
|
* Sets the operational mode for a session.
|
|
16899
16948
|
*
|
|
@@ -16924,6 +16973,15 @@ var ClientSideConnection = class {
|
|
|
16924
16973
|
async unstable_setSessionModel(params) {
|
|
16925
16974
|
return await this.#connection.sendRequest(AGENT_METHODS.session_set_model, params) ?? {};
|
|
16926
16975
|
}
|
|
16976
|
+
/**
|
|
16977
|
+
* Set a configuration option for a given session.
|
|
16978
|
+
*
|
|
16979
|
+
* The response contains the full set of configuration options and their current values,
|
|
16980
|
+
* as changing one option may affect the available values or state of other options.
|
|
16981
|
+
*/
|
|
16982
|
+
async setSessionConfigOption(params) {
|
|
16983
|
+
return await this.#connection.sendRequest(AGENT_METHODS.session_set_config_option, params);
|
|
16984
|
+
}
|
|
16927
16985
|
/**
|
|
16928
16986
|
* Authenticates the client using the specified authentication method.
|
|
16929
16987
|
*
|
|
@@ -16976,7 +17034,7 @@ var ClientSideConnection = class {
|
|
|
16976
17034
|
* Allows the Client to send an arbitrary request that is not part of the ACP spec.
|
|
16977
17035
|
*/
|
|
16978
17036
|
async extMethod(method, params) {
|
|
16979
|
-
return await this.#connection.sendRequest(
|
|
17037
|
+
return await this.#connection.sendRequest(method, params);
|
|
16980
17038
|
}
|
|
16981
17039
|
/**
|
|
16982
17040
|
* Extension notification
|
|
@@ -16984,7 +17042,7 @@ var ClientSideConnection = class {
|
|
|
16984
17042
|
* Allows the Client to send an arbitrary notification that is not part of the ACP spec.
|
|
16985
17043
|
*/
|
|
16986
17044
|
async extNotification(method, params) {
|
|
16987
|
-
return await this.#connection.sendNotification(
|
|
17045
|
+
return await this.#connection.sendNotification(method, params);
|
|
16988
17046
|
}
|
|
16989
17047
|
/**
|
|
16990
17048
|
* AbortSignal that aborts when the connection closes.
|
|
@@ -17314,18 +17372,12 @@ function isJsonRpcResponse(message) {
|
|
|
17314
17372
|
__name(isJsonRpcResponse, "isJsonRpcResponse");
|
|
17315
17373
|
function createRequest(id, method, params) {
|
|
17316
17374
|
const request = { jsonrpc: "2.0", id, method };
|
|
17317
|
-
|
|
17318
|
-
request.params = params;
|
|
17319
|
-
}
|
|
17320
|
-
return request;
|
|
17375
|
+
return params !== void 0 && (request.params = params), request;
|
|
17321
17376
|
}
|
|
17322
17377
|
__name(createRequest, "createRequest");
|
|
17323
17378
|
function createNotification(method, params) {
|
|
17324
17379
|
const notification = { jsonrpc: "2.0", method };
|
|
17325
|
-
|
|
17326
|
-
notification.params = params;
|
|
17327
|
-
}
|
|
17328
|
-
return notification;
|
|
17380
|
+
return params !== void 0 && (notification.params = params), notification;
|
|
17329
17381
|
}
|
|
17330
17382
|
__name(createNotification, "createNotification");
|
|
17331
17383
|
function createSuccessResponse(id, result) {
|
|
@@ -17387,24 +17439,15 @@ var MessageQueue = class {
|
|
|
17387
17439
|
* Otherwise, it's buffered until the next consumer is ready.
|
|
17388
17440
|
*/
|
|
17389
17441
|
push(message) {
|
|
17390
|
-
|
|
17391
|
-
return;
|
|
17392
|
-
}
|
|
17393
|
-
if (this.resolvers.length > 0) {
|
|
17394
|
-
const resolve2 = this.resolvers.shift();
|
|
17395
|
-
resolve2(message);
|
|
17396
|
-
} else {
|
|
17397
|
-
this.queue.push(message);
|
|
17398
|
-
}
|
|
17442
|
+
this.closed || (this.resolvers.length > 0 ? this.resolvers.shift()(message) : this.queue.push(message));
|
|
17399
17443
|
}
|
|
17400
17444
|
/**
|
|
17401
17445
|
* Close the queue, causing the async iterator to complete.
|
|
17402
17446
|
*/
|
|
17403
17447
|
close() {
|
|
17404
17448
|
this.closed = true;
|
|
17405
|
-
for (const resolve2 of this.resolvers)
|
|
17449
|
+
for (const resolve2 of this.resolvers)
|
|
17406
17450
|
resolve2({ type: "shutdown" });
|
|
17407
|
-
}
|
|
17408
17451
|
this.resolvers = [];
|
|
17409
17452
|
}
|
|
17410
17453
|
/**
|
|
@@ -17424,25 +17467,17 @@ var MessageQueue = class {
|
|
|
17424
17467
|
* ```
|
|
17425
17468
|
*/
|
|
17426
17469
|
async *[Symbol.asyncIterator]() {
|
|
17427
|
-
|
|
17470
|
+
for (; !this.closed; ) {
|
|
17428
17471
|
let message;
|
|
17429
|
-
if (this.queue.length > 0) {
|
|
17430
|
-
|
|
17431
|
-
}
|
|
17432
|
-
message = await new Promise((resolve2) => {
|
|
17433
|
-
this.resolvers.push(resolve2);
|
|
17434
|
-
});
|
|
17435
|
-
}
|
|
17436
|
-
if (message.type === "shutdown") {
|
|
17472
|
+
if (this.queue.length > 0 ? message = this.queue.shift() : message = await new Promise((resolve2) => {
|
|
17473
|
+
this.resolvers.push(resolve2);
|
|
17474
|
+
}), message.type === "shutdown")
|
|
17437
17475
|
return;
|
|
17438
|
-
}
|
|
17439
17476
|
yield message;
|
|
17440
17477
|
}
|
|
17441
|
-
|
|
17478
|
+
for (; this.queue.length > 0; ) {
|
|
17442
17479
|
const message = this.queue.shift();
|
|
17443
|
-
|
|
17444
|
-
yield message;
|
|
17445
|
-
}
|
|
17480
|
+
message.type !== "shutdown" && (yield message);
|
|
17446
17481
|
}
|
|
17447
17482
|
}
|
|
17448
17483
|
};
|
|
@@ -17453,31 +17488,23 @@ var import_node_crypto = require("node:crypto");
|
|
|
17453
17488
|
async function createHttpListener(options) {
|
|
17454
17489
|
const { acpUrl, onMessage } = options;
|
|
17455
17490
|
let sessionId = null;
|
|
17456
|
-
const connections = /* @__PURE__ */ new Map();
|
|
17457
|
-
const sockets = /* @__PURE__ */ new Set();
|
|
17491
|
+
const connections = /* @__PURE__ */ new Map(), sockets = /* @__PURE__ */ new Set();
|
|
17458
17492
|
let server = null;
|
|
17459
17493
|
server = (0, import_node_http.createServer)(async (req, res) => {
|
|
17460
|
-
res.setHeader("Access-Control-Allow-Origin", "*")
|
|
17461
|
-
|
|
17462
|
-
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Mcp-Session-Id");
|
|
17463
|
-
if (req.method === "OPTIONS") {
|
|
17464
|
-
res.writeHead(204);
|
|
17465
|
-
res.end();
|
|
17494
|
+
if (res.setHeader("Access-Control-Allow-Origin", "*"), res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS, GET"), res.setHeader("Access-Control-Allow-Headers", "Content-Type, Mcp-Session-Id"), req.method === "OPTIONS") {
|
|
17495
|
+
res.writeHead(204), res.end();
|
|
17466
17496
|
return;
|
|
17467
17497
|
}
|
|
17468
17498
|
if (req.method === "GET") {
|
|
17469
|
-
res.writeHead(204);
|
|
17470
|
-
res.end();
|
|
17499
|
+
res.writeHead(204), res.end();
|
|
17471
17500
|
return;
|
|
17472
17501
|
}
|
|
17473
17502
|
if (req.method !== "POST") {
|
|
17474
|
-
res.writeHead(405, { "Content-Type": "application/json" });
|
|
17475
|
-
res.end(JSON.stringify({ error: "Method not allowed" }));
|
|
17503
|
+
res.writeHead(405, { "Content-Type": "application/json" }), res.end(JSON.stringify({ error: "Method not allowed" }));
|
|
17476
17504
|
return;
|
|
17477
17505
|
}
|
|
17478
17506
|
try {
|
|
17479
|
-
const body = await readBody(req);
|
|
17480
|
-
const message = JSON.parse(body);
|
|
17507
|
+
const body = await readBody(req), message = JSON.parse(body);
|
|
17481
17508
|
let connection = connections.get("default");
|
|
17482
17509
|
if (!connection) {
|
|
17483
17510
|
const connectionId = (0, import_node_crypto.randomUUID)();
|
|
@@ -17485,9 +17512,7 @@ async function createHttpListener(options) {
|
|
|
17485
17512
|
connectionId,
|
|
17486
17513
|
sessionId: sessionId ?? "pending",
|
|
17487
17514
|
pendingResponses: /* @__PURE__ */ new Map()
|
|
17488
|
-
}
|
|
17489
|
-
connections.set("default", connection);
|
|
17490
|
-
onMessage({
|
|
17515
|
+
}, connections.set("default", connection), onMessage({
|
|
17491
17516
|
type: "connection-received",
|
|
17492
17517
|
acpUrl,
|
|
17493
17518
|
sessionId: connection.sessionId,
|
|
@@ -17501,81 +17526,59 @@ async function createHttpListener(options) {
|
|
|
17501
17526
|
}
|
|
17502
17527
|
await handleMessage(connection, message, res, onMessage);
|
|
17503
17528
|
} catch (error40) {
|
|
17504
|
-
console.error("MCP bridge HTTP error:", error40);
|
|
17505
|
-
res.writeHead(500, { "Content-Type": "application/json" });
|
|
17506
|
-
res.end(JSON.stringify({ error: "Internal server error" }));
|
|
17529
|
+
console.error("MCP bridge HTTP error:", error40), res.writeHead(500, { "Content-Type": "application/json" }), res.end(JSON.stringify({ error: "Internal server error" }));
|
|
17507
17530
|
}
|
|
17508
|
-
})
|
|
17509
|
-
|
|
17510
|
-
|
|
17511
|
-
|
|
17512
|
-
});
|
|
17513
|
-
server.on("connection", (socket) => {
|
|
17514
|
-
sockets.add(socket);
|
|
17515
|
-
socket.on("close", () => {
|
|
17531
|
+
}), await new Promise((resolve2, reject) => {
|
|
17532
|
+
server.listen(0, "127.0.0.1", () => resolve2()), server.on("error", reject);
|
|
17533
|
+
}), server.on("connection", (socket) => {
|
|
17534
|
+
sockets.add(socket), socket.on("close", () => {
|
|
17516
17535
|
sockets.delete(socket);
|
|
17517
17536
|
});
|
|
17518
17537
|
});
|
|
17519
17538
|
const address = server.address();
|
|
17520
|
-
if (!address || typeof address
|
|
17539
|
+
if (!address || typeof address == "string")
|
|
17521
17540
|
throw new Error("Failed to get server address");
|
|
17522
|
-
}
|
|
17523
17541
|
const port = address.port;
|
|
17524
17542
|
return {
|
|
17525
17543
|
acpUrl,
|
|
17526
17544
|
port,
|
|
17527
17545
|
setSessionId(id) {
|
|
17528
17546
|
sessionId = id;
|
|
17529
|
-
for (const conn of connections.values())
|
|
17547
|
+
for (const conn of connections.values())
|
|
17530
17548
|
conn.sessionId = id;
|
|
17531
|
-
}
|
|
17532
17549
|
},
|
|
17533
17550
|
async close() {
|
|
17534
|
-
for (const [key, conn] of connections)
|
|
17551
|
+
for (const [key, conn] of connections)
|
|
17535
17552
|
onMessage({
|
|
17536
17553
|
type: "connection-closed",
|
|
17537
17554
|
connectionId: conn.connectionId
|
|
17538
|
-
});
|
|
17539
|
-
|
|
17540
|
-
}
|
|
17541
|
-
for (const socket of sockets) {
|
|
17555
|
+
}), connections.delete(key);
|
|
17556
|
+
for (const socket of sockets)
|
|
17542
17557
|
socket.destroy();
|
|
17543
|
-
|
|
17544
|
-
|
|
17545
|
-
|
|
17546
|
-
await new Promise((resolve2, reject) => {
|
|
17547
|
-
server.close((err) => {
|
|
17548
|
-
if (err) {
|
|
17549
|
-
reject(err);
|
|
17550
|
-
} else {
|
|
17551
|
-
resolve2();
|
|
17552
|
-
}
|
|
17553
|
-
});
|
|
17558
|
+
sockets.clear(), server && await new Promise((resolve2, reject) => {
|
|
17559
|
+
server.close((err) => {
|
|
17560
|
+
err ? reject(err) : resolve2();
|
|
17554
17561
|
});
|
|
17555
|
-
}
|
|
17562
|
+
});
|
|
17556
17563
|
}
|
|
17557
17564
|
};
|
|
17558
17565
|
}
|
|
17559
17566
|
__name(createHttpListener, "createHttpListener");
|
|
17560
17567
|
async function handleMessage(connection, message, res, onMessage) {
|
|
17561
17568
|
if (isJsonRpcRequest(message)) {
|
|
17562
|
-
const idKey = String(message.id)
|
|
17563
|
-
const responsePromise = new Promise((resolve2) => {
|
|
17569
|
+
const idKey = String(message.id), responsePromise = new Promise((resolve2) => {
|
|
17564
17570
|
connection.pendingResponses.set(idKey, resolve2);
|
|
17565
|
-
})
|
|
17566
|
-
const dispatch = {
|
|
17571
|
+
}), dispatch = {
|
|
17567
17572
|
type: "request",
|
|
17568
17573
|
id: message.id,
|
|
17569
17574
|
method: message.method,
|
|
17570
17575
|
params: message.params,
|
|
17571
17576
|
responder: createResponder((result) => {
|
|
17572
17577
|
const resolver = connection.pendingResponses.get(idKey);
|
|
17573
|
-
connection.pendingResponses.delete(idKey);
|
|
17574
|
-
resolver?.({ jsonrpc: "2.0", id: message.id, result });
|
|
17578
|
+
connection.pendingResponses.delete(idKey), resolver?.({ jsonrpc: "2.0", id: message.id, result });
|
|
17575
17579
|
}, (error40) => {
|
|
17576
17580
|
const resolver = connection.pendingResponses.get(idKey);
|
|
17577
|
-
connection.pendingResponses.delete(idKey);
|
|
17578
|
-
resolver?.({ jsonrpc: "2.0", id: message.id, error: error40 });
|
|
17581
|
+
connection.pendingResponses.delete(idKey), resolver?.({ jsonrpc: "2.0", id: message.id, error: error40 });
|
|
17579
17582
|
})
|
|
17580
17583
|
};
|
|
17581
17584
|
onMessage({
|
|
@@ -17587,8 +17590,7 @@ async function handleMessage(connection, message, res, onMessage) {
|
|
|
17587
17590
|
res.writeHead(200, {
|
|
17588
17591
|
"Content-Type": "application/json",
|
|
17589
17592
|
"Mcp-Session-Id": connection.connectionId
|
|
17590
|
-
});
|
|
17591
|
-
res.end(JSON.stringify(response));
|
|
17593
|
+
}), res.end(JSON.stringify(response));
|
|
17592
17594
|
} else if (isJsonRpcNotification(message)) {
|
|
17593
17595
|
const dispatch = {
|
|
17594
17596
|
type: "notification",
|
|
@@ -17599,21 +17601,15 @@ async function handleMessage(connection, message, res, onMessage) {
|
|
|
17599
17601
|
type: "client-message",
|
|
17600
17602
|
connectionId: connection.connectionId,
|
|
17601
17603
|
dispatch
|
|
17602
|
-
});
|
|
17603
|
-
|
|
17604
|
-
res.end();
|
|
17605
|
-
} else {
|
|
17606
|
-
res.writeHead(400, { "Content-Type": "application/json" });
|
|
17607
|
-
res.end(JSON.stringify({ error: "Invalid message type" }));
|
|
17608
|
-
}
|
|
17604
|
+
}), res.writeHead(202), res.end();
|
|
17605
|
+
} else
|
|
17606
|
+
res.writeHead(400, { "Content-Type": "application/json" }), res.end(JSON.stringify({ error: "Invalid message type" }));
|
|
17609
17607
|
}
|
|
17610
17608
|
__name(handleMessage, "handleMessage");
|
|
17611
17609
|
function readBody(req) {
|
|
17612
17610
|
return new Promise((resolve2, reject) => {
|
|
17613
17611
|
const chunks = [];
|
|
17614
|
-
req.on("data", (chunk) => chunks.push(chunk));
|
|
17615
|
-
req.on("end", () => resolve2(Buffer.concat(chunks).toString("utf-8")));
|
|
17616
|
-
req.on("error", reject);
|
|
17612
|
+
req.on("data", (chunk) => chunks.push(chunk)), req.on("end", () => resolve2(Buffer.concat(chunks).toString("utf-8"))), req.on("error", reject);
|
|
17617
17613
|
});
|
|
17618
17614
|
}
|
|
17619
17615
|
__name(readBody, "readBody");
|
|
@@ -17643,38 +17639,28 @@ var McpBridge = class {
|
|
|
17643
17639
|
* Returns the transformed server list and a session key for later correlation.
|
|
17644
17640
|
*/
|
|
17645
17641
|
async transformMcpServers(servers, sessionKey) {
|
|
17646
|
-
if (!servers || servers.length === 0)
|
|
17642
|
+
if (!servers || servers.length === 0)
|
|
17647
17643
|
return { transformedServers: servers, hasAcpServers: false };
|
|
17648
|
-
}
|
|
17649
17644
|
const pendingSession = {
|
|
17650
17645
|
listeners: [],
|
|
17651
17646
|
urlMap: /* @__PURE__ */ new Map()
|
|
17652
|
-
};
|
|
17653
|
-
const transformedServers = [];
|
|
17647
|
+
}, transformedServers = [];
|
|
17654
17648
|
let hasAcpServers = false;
|
|
17655
|
-
for (const server of servers)
|
|
17649
|
+
for (const server of servers)
|
|
17656
17650
|
if (server.url.startsWith("acp:")) {
|
|
17657
17651
|
hasAcpServers = true;
|
|
17658
17652
|
const listener = await createHttpListener({
|
|
17659
17653
|
acpUrl: server.url,
|
|
17660
17654
|
onMessage: /* @__PURE__ */ __name((msg) => this.handleBridgeMessage(msg), "onMessage")
|
|
17661
17655
|
});
|
|
17662
|
-
this.listeners.set(server.url, listener)
|
|
17663
|
-
pendingSession.listeners.push(listener);
|
|
17664
|
-
pendingSession.urlMap.set(server.url, `http://127.0.0.1:${listener.port}`);
|
|
17665
|
-
transformedServers.push({
|
|
17656
|
+
this.listeners.set(server.url, listener), pendingSession.listeners.push(listener), pendingSession.urlMap.set(server.url, `http://127.0.0.1:${listener.port}`), transformedServers.push({
|
|
17666
17657
|
...server,
|
|
17667
17658
|
url: `http://127.0.0.1:${listener.port}`,
|
|
17668
17659
|
type: "http"
|
|
17669
17660
|
});
|
|
17670
|
-
} else
|
|
17661
|
+
} else
|
|
17671
17662
|
transformedServers.push(server);
|
|
17672
|
-
|
|
17673
|
-
}
|
|
17674
|
-
if (hasAcpServers) {
|
|
17675
|
-
this.pendingSessions.set(sessionKey, pendingSession);
|
|
17676
|
-
}
|
|
17677
|
-
return { transformedServers, hasAcpServers };
|
|
17663
|
+
return hasAcpServers && this.pendingSessions.set(sessionKey, pendingSession), { transformedServers, hasAcpServers };
|
|
17678
17664
|
}
|
|
17679
17665
|
/**
|
|
17680
17666
|
* Complete session creation after receiving the session ID from the agent
|
|
@@ -17684,25 +17670,22 @@ var McpBridge = class {
|
|
|
17684
17670
|
*/
|
|
17685
17671
|
completeSession(sessionKey, sessionId) {
|
|
17686
17672
|
const pending = this.pendingSessions.get(sessionKey);
|
|
17687
|
-
if (
|
|
17688
|
-
|
|
17689
|
-
|
|
17690
|
-
|
|
17673
|
+
if (pending) {
|
|
17674
|
+
for (const listener of pending.listeners)
|
|
17675
|
+
listener.setSessionId(sessionId);
|
|
17676
|
+
this.pendingSessions.delete(sessionKey);
|
|
17691
17677
|
}
|
|
17692
|
-
this.pendingSessions.delete(sessionKey);
|
|
17693
17678
|
}
|
|
17694
17679
|
/**
|
|
17695
17680
|
* Cancel a pending session (e.g., on error)
|
|
17696
17681
|
*/
|
|
17697
17682
|
async cancelSession(sessionKey) {
|
|
17698
17683
|
const pending = this.pendingSessions.get(sessionKey);
|
|
17699
|
-
if (
|
|
17700
|
-
|
|
17701
|
-
|
|
17702
|
-
|
|
17703
|
-
this.listeners.delete(listener.acpUrl);
|
|
17684
|
+
if (pending) {
|
|
17685
|
+
for (const listener of pending.listeners)
|
|
17686
|
+
await listener.close(), this.listeners.delete(listener.acpUrl);
|
|
17687
|
+
this.pendingSessions.delete(sessionKey);
|
|
17704
17688
|
}
|
|
17705
|
-
this.pendingSessions.delete(sessionKey);
|
|
17706
17689
|
}
|
|
17707
17690
|
/**
|
|
17708
17691
|
* Handle a message from an HTTP listener
|
|
@@ -17715,8 +17698,7 @@ var McpBridge = class {
|
|
|
17715
17698
|
acpUrl: msg.acpUrl,
|
|
17716
17699
|
sessionId: msg.sessionId,
|
|
17717
17700
|
responder: null
|
|
17718
|
-
})
|
|
17719
|
-
this.messageQueue.push({
|
|
17701
|
+
}), this.messageQueue.push({
|
|
17720
17702
|
type: "mcp-connection-received",
|
|
17721
17703
|
acpUrl: msg.acpUrl,
|
|
17722
17704
|
connectionId: msg.connectionId
|
|
@@ -17732,8 +17714,7 @@ var McpBridge = class {
|
|
|
17732
17714
|
break;
|
|
17733
17715
|
}
|
|
17734
17716
|
case "connection-closed": {
|
|
17735
|
-
this.connections.delete(msg.connectionId)
|
|
17736
|
-
this.messageQueue.push({
|
|
17717
|
+
this.connections.delete(msg.connectionId), this.messageQueue.push({
|
|
17737
17718
|
type: "mcp-connection-disconnected",
|
|
17738
17719
|
connectionId: msg.connectionId
|
|
17739
17720
|
});
|
|
@@ -17752,13 +17733,11 @@ var McpBridge = class {
|
|
|
17752
17733
|
*/
|
|
17753
17734
|
async close() {
|
|
17754
17735
|
this.connections.clear();
|
|
17755
|
-
for (const listener of this.listeners.values())
|
|
17736
|
+
for (const listener of this.listeners.values())
|
|
17756
17737
|
await listener.close();
|
|
17757
|
-
}
|
|
17758
17738
|
this.listeners.clear();
|
|
17759
|
-
for (const key of this.pendingSessions.keys())
|
|
17739
|
+
for (const key of this.pendingSessions.keys())
|
|
17760
17740
|
await this.cancelSession(key);
|
|
17761
|
-
}
|
|
17762
17741
|
}
|
|
17763
17742
|
};
|
|
17764
17743
|
|
|
@@ -17789,22 +17768,16 @@ function createNoopLogger() {
|
|
|
17789
17768
|
}
|
|
17790
17769
|
__name(createNoopLogger, "createNoopLogger");
|
|
17791
17770
|
function createLogger(options = {}) {
|
|
17792
|
-
const level = options.level ?? "info";
|
|
17793
|
-
const levelNum = LOG_LEVELS[level];
|
|
17794
|
-
const name = options.name;
|
|
17795
|
-
const useJson = options.json ?? false;
|
|
17771
|
+
const level = options.level ?? "info", levelNum = LOG_LEVELS[level], name = options.name, useJson = options.json ?? false;
|
|
17796
17772
|
let traceStream = null;
|
|
17797
|
-
|
|
17798
|
-
traceStream = (0, import_node_fs.createWriteStream)(options.trace.path, { flags: "a" });
|
|
17799
|
-
}
|
|
17773
|
+
options.trace && (traceStream = (0, import_node_fs.createWriteStream)(options.trace.path, { flags: "a" }));
|
|
17800
17774
|
function isEnabled(checkLevel) {
|
|
17801
17775
|
return LOG_LEVELS[checkLevel] <= levelNum;
|
|
17802
17776
|
}
|
|
17803
17777
|
__name(isEnabled, "isEnabled");
|
|
17804
17778
|
function log(logLevel, message, data) {
|
|
17805
|
-
if (!isEnabled(logLevel))
|
|
17779
|
+
if (!isEnabled(logLevel))
|
|
17806
17780
|
return;
|
|
17807
|
-
}
|
|
17808
17781
|
const entry = {
|
|
17809
17782
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17810
17783
|
level: logLevel,
|
|
@@ -17812,27 +17785,23 @@ function createLogger(options = {}) {
|
|
|
17812
17785
|
message,
|
|
17813
17786
|
data
|
|
17814
17787
|
};
|
|
17815
|
-
if (useJson)
|
|
17816
|
-
|
|
17817
|
-
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
const levelStr = logLevel.toUpperCase().padEnd(5);
|
|
17821
|
-
const dataStr = data ? ` ${JSON.stringify(data)}` : "";
|
|
17822
|
-
const output = logLevel === "error" || logLevel === "warn" ? console.error : console.log;
|
|
17823
|
-
output(`${entry.timestamp} ${levelStr} ${prefix}${prefix ? " " : ""}${message}${dataStr}`);
|
|
17788
|
+
if (useJson)
|
|
17789
|
+
(logLevel === "error" || logLevel === "warn" ? console.error : console.log)(JSON.stringify(entry));
|
|
17790
|
+
else {
|
|
17791
|
+
const prefix = name ? `[${name}]` : "", levelStr = logLevel.toUpperCase().padEnd(5), dataStr = data ? ` ${JSON.stringify(data)}` : "";
|
|
17792
|
+
(logLevel === "error" || logLevel === "warn" ? console.error : console.log)(`${entry.timestamp} ${levelStr} ${prefix}${prefix ? " " : ""}${message}${dataStr}`);
|
|
17824
17793
|
}
|
|
17825
17794
|
}
|
|
17826
17795
|
__name(log, "log");
|
|
17827
17796
|
function traceMessage(entry) {
|
|
17828
|
-
if (!traceStream)
|
|
17797
|
+
if (!traceStream)
|
|
17829
17798
|
return;
|
|
17830
|
-
}
|
|
17831
17799
|
const fullEntry = {
|
|
17832
17800
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17833
17801
|
...entry
|
|
17834
17802
|
};
|
|
17835
|
-
traceStream.write(JSON.stringify(fullEntry) +
|
|
17803
|
+
traceStream.write(JSON.stringify(fullEntry) + `
|
|
17804
|
+
`);
|
|
17836
17805
|
}
|
|
17837
17806
|
__name(traceMessage, "traceMessage");
|
|
17838
17807
|
function child(childName) {
|
|
@@ -17847,17 +17816,11 @@ function createLogger(options = {}) {
|
|
|
17847
17816
|
}
|
|
17848
17817
|
__name(child, "child");
|
|
17849
17818
|
async function close() {
|
|
17850
|
-
|
|
17851
|
-
|
|
17852
|
-
|
|
17853
|
-
if (err)
|
|
17854
|
-
reject(err);
|
|
17855
|
-
else
|
|
17856
|
-
resolve2();
|
|
17857
|
-
});
|
|
17819
|
+
traceStream && (await new Promise((resolve2, reject) => {
|
|
17820
|
+
traceStream.end((err) => {
|
|
17821
|
+
err ? reject(err) : resolve2();
|
|
17858
17822
|
});
|
|
17859
|
-
|
|
17860
|
-
}
|
|
17823
|
+
}), traceStream = null);
|
|
17861
17824
|
}
|
|
17862
17825
|
__name(close, "close");
|
|
17863
17826
|
return {
|
|
@@ -17879,9 +17842,7 @@ var defaultLogger = createNoopLogger();
|
|
|
17879
17842
|
function staticInstantiator(config2) {
|
|
17880
17843
|
return {
|
|
17881
17844
|
async instantiate() {
|
|
17882
|
-
const { StdioConnector: StdioConnector2 } = await Promise.resolve().then(() => (init_stdio(), stdio_exports));
|
|
17883
|
-
const proxyConnectors = (config2.proxies ?? []).map((spec) => new StdioConnector2(normalizeCommandSpec(spec)));
|
|
17884
|
-
const agentConnector = new StdioConnector2(normalizeCommandSpec(config2.agent));
|
|
17845
|
+
const { StdioConnector: StdioConnector2 } = await Promise.resolve().then(() => (init_stdio(), stdio_exports)), proxyConnectors = (config2.proxies ?? []).map((spec) => new StdioConnector2(normalizeCommandSpec(spec))), agentConnector = new StdioConnector2(normalizeCommandSpec(config2.agent));
|
|
17885
17846
|
return {
|
|
17886
17847
|
proxies: proxyConnectors,
|
|
17887
17848
|
agent: agentConnector
|
|
@@ -17891,9 +17852,8 @@ function staticInstantiator(config2) {
|
|
|
17891
17852
|
}
|
|
17892
17853
|
__name(staticInstantiator, "staticInstantiator");
|
|
17893
17854
|
function fromCommands(commands) {
|
|
17894
|
-
if (commands.length === 0)
|
|
17855
|
+
if (commands.length === 0)
|
|
17895
17856
|
throw new Error("At least one command (the agent) is required");
|
|
17896
|
-
}
|
|
17897
17857
|
return staticInstantiator({
|
|
17898
17858
|
proxies: commands.slice(0, -1),
|
|
17899
17859
|
agent: commands[commands.length - 1]
|
|
@@ -17901,7 +17861,7 @@ function fromCommands(commands) {
|
|
|
17901
17861
|
}
|
|
17902
17862
|
__name(fromCommands, "fromCommands");
|
|
17903
17863
|
function normalizeCommandSpec(spec) {
|
|
17904
|
-
if (typeof spec
|
|
17864
|
+
if (typeof spec == "string") {
|
|
17905
17865
|
const parts = parseCommand2(spec);
|
|
17906
17866
|
return {
|
|
17907
17867
|
command: parts[0],
|
|
@@ -17913,31 +17873,12 @@ function normalizeCommandSpec(spec) {
|
|
|
17913
17873
|
__name(normalizeCommandSpec, "normalizeCommandSpec");
|
|
17914
17874
|
function parseCommand2(command) {
|
|
17915
17875
|
const parts = [];
|
|
17916
|
-
let current = "";
|
|
17917
|
-
let inQuote = null;
|
|
17876
|
+
let current = "", inQuote = null;
|
|
17918
17877
|
for (let i = 0; i < command.length; i++) {
|
|
17919
17878
|
const char = command[i];
|
|
17920
|
-
|
|
17921
|
-
if (char === inQuote) {
|
|
17922
|
-
inQuote = null;
|
|
17923
|
-
} else {
|
|
17924
|
-
current += char;
|
|
17925
|
-
}
|
|
17926
|
-
} else if (char === '"' || char === "'") {
|
|
17927
|
-
inQuote = char;
|
|
17928
|
-
} else if (char === " " || char === " ") {
|
|
17929
|
-
if (current) {
|
|
17930
|
-
parts.push(current);
|
|
17931
|
-
current = "";
|
|
17932
|
-
}
|
|
17933
|
-
} else {
|
|
17934
|
-
current += char;
|
|
17935
|
-
}
|
|
17936
|
-
}
|
|
17937
|
-
if (current) {
|
|
17938
|
-
parts.push(current);
|
|
17879
|
+
inQuote ? char === inQuote ? inQuote = null : current += char : char === '"' || char === "'" ? inQuote = char : char === " " || char === " " ? current && (parts.push(current), current = "") : current += char;
|
|
17939
17880
|
}
|
|
17940
|
-
return parts;
|
|
17881
|
+
return current && parts.push(current), parts;
|
|
17941
17882
|
}
|
|
17942
17883
|
__name(parseCommand2, "parseCommand");
|
|
17943
17884
|
|
|
@@ -17967,25 +17908,15 @@ var Conductor = class {
|
|
|
17967
17908
|
// Maps MCP connection IDs to their responders for _mcp/connect
|
|
17968
17909
|
mcpConnectResponders = /* @__PURE__ */ new Map();
|
|
17969
17910
|
constructor(config2) {
|
|
17970
|
-
this.config = config2
|
|
17971
|
-
|
|
17972
|
-
|
|
17973
|
-
|
|
17974
|
-
|
|
17975
|
-
|
|
17976
|
-
|
|
17977
|
-
|
|
17978
|
-
|
|
17979
|
-
level: "info",
|
|
17980
|
-
name: config2.name ?? "conductor",
|
|
17981
|
-
trace: config2.trace
|
|
17982
|
-
});
|
|
17983
|
-
} else {
|
|
17984
|
-
this.logger = createNoopLogger();
|
|
17985
|
-
}
|
|
17986
|
-
if (config2.mcpBridgeMode !== "disabled") {
|
|
17987
|
-
this.mcpBridge = new McpBridge({ messageQueue: this.messageQueue });
|
|
17988
|
-
}
|
|
17911
|
+
this.config = config2, config2.logging ? this.logger = createLogger({
|
|
17912
|
+
...config2.logging,
|
|
17913
|
+
name: config2.logging.name ?? config2.name ?? "conductor",
|
|
17914
|
+
trace: config2.trace ?? config2.logging.trace
|
|
17915
|
+
}) : config2.trace ? this.logger = createLogger({
|
|
17916
|
+
level: "info",
|
|
17917
|
+
name: config2.name ?? "conductor",
|
|
17918
|
+
trace: config2.trace
|
|
17919
|
+
}) : this.logger = createNoopLogger(), config2.mcpBridgeMode !== "disabled" && (this.mcpBridge = new McpBridge({ messageQueue: this.messageQueue }));
|
|
17989
17920
|
}
|
|
17990
17921
|
/**
|
|
17991
17922
|
* Connect to a client and run the conductor's message loop.
|
|
@@ -17993,42 +17924,22 @@ var Conductor = class {
|
|
|
17993
17924
|
* This method blocks until the conductor shuts down.
|
|
17994
17925
|
*/
|
|
17995
17926
|
async connect(clientConnector) {
|
|
17996
|
-
if (this.state.type !== "uninitialized")
|
|
17927
|
+
if (this.state.type !== "uninitialized")
|
|
17997
17928
|
throw new Error(`Conductor is already ${this.state.type}`);
|
|
17998
|
-
|
|
17999
|
-
this.logger.info("Connecting to client");
|
|
18000
|
-
this.clientConnection = await clientConnector.connect();
|
|
18001
|
-
this.logger.debug("Client connected, starting message pump");
|
|
18002
|
-
this.pumpClientMessages(this.clientConnection);
|
|
18003
|
-
this.logger.debug("Starting event loop");
|
|
18004
|
-
await this.runEventLoop();
|
|
18005
|
-
this.logger.info("Event loop exited");
|
|
17929
|
+
this.logger.info("Connecting to client"), this.clientConnection = await clientConnector.connect(), this.logger.debug("Client connected, starting message pump"), this.pumpClientMessages(this.clientConnection), this.logger.debug("Starting event loop"), await this.runEventLoop(), this.logger.info("Event loop exited");
|
|
18006
17930
|
}
|
|
18007
17931
|
/**
|
|
18008
17932
|
* Shut down the conductor
|
|
18009
17933
|
*/
|
|
18010
17934
|
async shutdown() {
|
|
18011
|
-
if (this.state.type === "shutdown")
|
|
17935
|
+
if (this.state.type === "shutdown")
|
|
18012
17936
|
return;
|
|
18013
|
-
}
|
|
18014
|
-
this.logger.info("Shutting down conductor");
|
|
18015
|
-
this.state = { type: "shutdown" };
|
|
18016
|
-
this.messageQueue.close();
|
|
17937
|
+
this.logger.info("Shutting down conductor"), this.state = { type: "shutdown" }, this.messageQueue.close();
|
|
18017
17938
|
const closePromises = [];
|
|
18018
|
-
|
|
18019
|
-
|
|
18020
|
-
}
|
|
18021
|
-
for (const proxy of this.proxies) {
|
|
17939
|
+
this.clientConnection && closePromises.push(this.clientConnection.close());
|
|
17940
|
+
for (const proxy of this.proxies)
|
|
18022
17941
|
closePromises.push(proxy.close());
|
|
18023
|
-
|
|
18024
|
-
if (this.agentConnection) {
|
|
18025
|
-
closePromises.push(this.agentConnection.close());
|
|
18026
|
-
}
|
|
18027
|
-
if (this.mcpBridge) {
|
|
18028
|
-
closePromises.push(this.mcpBridge.close());
|
|
18029
|
-
}
|
|
18030
|
-
await Promise.all(closePromises);
|
|
18031
|
-
await this.logger.close();
|
|
17942
|
+
this.agentConnection && closePromises.push(this.agentConnection.close()), this.mcpBridge && closePromises.push(this.mcpBridge.close()), await Promise.all(closePromises), await this.logger.close();
|
|
18032
17943
|
}
|
|
18033
17944
|
/**
|
|
18034
17945
|
* Pump messages from the client into the message queue
|
|
@@ -18039,26 +17950,21 @@ var Conductor = class {
|
|
|
18039
17950
|
for await (const message of client.messages) {
|
|
18040
17951
|
if (isJsonRpcResponse(message)) {
|
|
18041
17952
|
const dispatch2 = this.messageToDispatch(message, { type: "client" });
|
|
18042
|
-
|
|
18043
|
-
this.handleResponse(dispatch2);
|
|
18044
|
-
}
|
|
17953
|
+
dispatch2 && dispatch2.type === "response" && this.handleResponse(dispatch2);
|
|
18045
17954
|
continue;
|
|
18046
17955
|
}
|
|
18047
17956
|
const dispatch = this.messageToDispatch(message, { type: "client" });
|
|
18048
|
-
|
|
18049
|
-
|
|
18050
|
-
|
|
18051
|
-
|
|
18052
|
-
|
|
18053
|
-
|
|
18054
|
-
});
|
|
18055
|
-
}
|
|
17957
|
+
dispatch && this.messageQueue.push({
|
|
17958
|
+
type: "left-to-right",
|
|
17959
|
+
targetIndex: 0,
|
|
17960
|
+
// First component (proxy[0] or agent if no proxies)
|
|
17961
|
+
dispatch
|
|
17962
|
+
});
|
|
18056
17963
|
}
|
|
18057
17964
|
} catch (error40) {
|
|
18058
17965
|
this.logger.error("Error reading from client", { error: String(error40) });
|
|
18059
17966
|
} finally {
|
|
18060
|
-
this.logger.debug("Client disconnected, shutting down");
|
|
18061
|
-
this.shutdown();
|
|
17967
|
+
this.logger.debug("Client disconnected, shutting down"), this.shutdown();
|
|
18062
17968
|
}
|
|
18063
17969
|
})();
|
|
18064
17970
|
}
|
|
@@ -18069,35 +17975,28 @@ var Conductor = class {
|
|
|
18069
17975
|
(async () => {
|
|
18070
17976
|
try {
|
|
18071
17977
|
for await (const message of connection.messages) {
|
|
18072
|
-
if (isJsonRpcRequest(message)) {
|
|
18073
|
-
|
|
18074
|
-
|
|
18075
|
-
continue;
|
|
18076
|
-
}
|
|
17978
|
+
if (isJsonRpcRequest(message) && message.method === PROXY_SUCCESSOR_REQUEST) {
|
|
17979
|
+
this.handleProxySuccessorRequest(proxyIndex, message);
|
|
17980
|
+
continue;
|
|
18077
17981
|
}
|
|
18078
|
-
if (isJsonRpcNotification(message)) {
|
|
18079
|
-
|
|
18080
|
-
|
|
18081
|
-
continue;
|
|
18082
|
-
}
|
|
17982
|
+
if (isJsonRpcNotification(message) && message.method === PROXY_SUCCESSOR_NOTIFICATION) {
|
|
17983
|
+
this.handleProxySuccessorNotification(proxyIndex, message);
|
|
17984
|
+
continue;
|
|
18083
17985
|
}
|
|
18084
17986
|
const dispatch = this.messageToDispatch(message, {
|
|
18085
17987
|
type: "proxy",
|
|
18086
17988
|
index: proxyIndex
|
|
18087
17989
|
});
|
|
18088
|
-
|
|
18089
|
-
|
|
18090
|
-
|
|
18091
|
-
|
|
18092
|
-
|
|
18093
|
-
});
|
|
18094
|
-
}
|
|
17990
|
+
dispatch && this.messageQueue.push({
|
|
17991
|
+
type: "right-to-left",
|
|
17992
|
+
sourceIndex: { type: "proxy", index: proxyIndex },
|
|
17993
|
+
dispatch
|
|
17994
|
+
});
|
|
18095
17995
|
}
|
|
18096
17996
|
} catch (error40) {
|
|
18097
17997
|
this.logger.error("Error reading from proxy", { proxyIndex, error: String(error40) });
|
|
18098
17998
|
} finally {
|
|
18099
|
-
this.logger.debug("Proxy disconnected, shutting down", { proxyIndex });
|
|
18100
|
-
this.shutdown();
|
|
17999
|
+
this.logger.debug("Proxy disconnected, shutting down", { proxyIndex }), this.shutdown();
|
|
18101
18000
|
}
|
|
18102
18001
|
})();
|
|
18103
18002
|
}
|
|
@@ -18111,19 +18010,16 @@ var Conductor = class {
|
|
|
18111
18010
|
const dispatch = this.messageToDispatch(message, {
|
|
18112
18011
|
type: "successor"
|
|
18113
18012
|
});
|
|
18114
|
-
|
|
18115
|
-
|
|
18116
|
-
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
});
|
|
18120
|
-
}
|
|
18013
|
+
dispatch && this.messageQueue.push({
|
|
18014
|
+
type: "right-to-left",
|
|
18015
|
+
sourceIndex: { type: "successor" },
|
|
18016
|
+
dispatch
|
|
18017
|
+
});
|
|
18121
18018
|
}
|
|
18122
18019
|
} catch (error40) {
|
|
18123
18020
|
this.logger.error("Error reading from agent", { error: String(error40) });
|
|
18124
18021
|
} finally {
|
|
18125
|
-
this.logger.debug("Agent disconnected, shutting down");
|
|
18126
|
-
this.shutdown();
|
|
18022
|
+
this.logger.debug("Agent disconnected, shutting down"), this.shutdown();
|
|
18127
18023
|
}
|
|
18128
18024
|
})();
|
|
18129
18025
|
}
|
|
@@ -18134,21 +18030,17 @@ var Conductor = class {
|
|
|
18134
18030
|
* We unwrap the inner request and forward it.
|
|
18135
18031
|
*/
|
|
18136
18032
|
handleProxySuccessorRequest(proxyIndex, message) {
|
|
18137
|
-
const params = message.params
|
|
18138
|
-
const inner = unwrapProxySuccessorRequest(params);
|
|
18139
|
-
const responder = createResponder((result) => {
|
|
18033
|
+
const params = message.params, inner = unwrapProxySuccessorRequest(params), responder = createResponder((result) => {
|
|
18140
18034
|
this.proxies[proxyIndex]?.send(createSuccessResponse(message.id, result));
|
|
18141
18035
|
}, (error40) => {
|
|
18142
18036
|
this.proxies[proxyIndex]?.send(createErrorResponse(message.id, error40));
|
|
18143
|
-
})
|
|
18144
|
-
const dispatch = {
|
|
18037
|
+
}), dispatch = {
|
|
18145
18038
|
type: "request",
|
|
18146
18039
|
id: message.id,
|
|
18147
18040
|
method: inner.method,
|
|
18148
18041
|
params: inner.params,
|
|
18149
18042
|
responder
|
|
18150
|
-
};
|
|
18151
|
-
const targetIndex = proxyIndex + 1;
|
|
18043
|
+
}, targetIndex = proxyIndex + 1;
|
|
18152
18044
|
this.messageQueue.push({
|
|
18153
18045
|
type: "left-to-right",
|
|
18154
18046
|
targetIndex,
|
|
@@ -18161,14 +18053,11 @@ var Conductor = class {
|
|
|
18161
18053
|
* The proxy is forwarding a notification to its successor.
|
|
18162
18054
|
*/
|
|
18163
18055
|
handleProxySuccessorNotification(proxyIndex, message) {
|
|
18164
|
-
const params = message.params
|
|
18165
|
-
const inner = unwrapProxySuccessorNotification(params);
|
|
18166
|
-
const dispatch = {
|
|
18056
|
+
const params = message.params, inner = unwrapProxySuccessorNotification(params), dispatch = {
|
|
18167
18057
|
type: "notification",
|
|
18168
18058
|
method: inner.method,
|
|
18169
18059
|
params: inner.params
|
|
18170
|
-
};
|
|
18171
|
-
const targetIndex = proxyIndex + 1;
|
|
18060
|
+
}, targetIndex = proxyIndex + 1;
|
|
18172
18061
|
this.messageQueue.push({
|
|
18173
18062
|
type: "left-to-right",
|
|
18174
18063
|
targetIndex,
|
|
@@ -18189,101 +18078,87 @@ var Conductor = class {
|
|
|
18189
18078
|
responder
|
|
18190
18079
|
};
|
|
18191
18080
|
}
|
|
18192
|
-
|
|
18193
|
-
|
|
18194
|
-
|
|
18195
|
-
|
|
18196
|
-
|
|
18197
|
-
|
|
18198
|
-
|
|
18199
|
-
|
|
18200
|
-
|
|
18201
|
-
|
|
18202
|
-
id: message.id,
|
|
18203
|
-
result: "result" in message ? message.result : void 0,
|
|
18204
|
-
error: "error" in message ? message.error : void 0
|
|
18205
|
-
};
|
|
18206
|
-
}
|
|
18207
|
-
return null;
|
|
18081
|
+
return isJsonRpcNotification(message) ? {
|
|
18082
|
+
type: "notification",
|
|
18083
|
+
method: message.method,
|
|
18084
|
+
params: message.params
|
|
18085
|
+
} : isJsonRpcResponse(message) ? {
|
|
18086
|
+
type: "response",
|
|
18087
|
+
id: message.id,
|
|
18088
|
+
result: "result" in message ? message.result : void 0,
|
|
18089
|
+
error: "error" in message ? message.error : void 0
|
|
18090
|
+
} : null;
|
|
18208
18091
|
}
|
|
18209
18092
|
/**
|
|
18210
18093
|
* Create a responder that routes the response back to the appropriate destination
|
|
18211
18094
|
*/
|
|
18212
18095
|
createResponderForSource(source, requestId) {
|
|
18213
|
-
if (source.type === "client")
|
|
18096
|
+
if (source.type === "client")
|
|
18214
18097
|
return createResponder((result) => {
|
|
18215
18098
|
this.clientConnection?.send(createSuccessResponse(requestId, result));
|
|
18216
18099
|
}, (error40) => {
|
|
18217
18100
|
this.clientConnection?.send(createErrorResponse(requestId, error40));
|
|
18218
18101
|
});
|
|
18219
|
-
|
|
18102
|
+
if (source.type === "proxy") {
|
|
18220
18103
|
const proxyIndex = source.index;
|
|
18221
18104
|
return createResponder((result) => {
|
|
18222
18105
|
this.proxies[proxyIndex]?.send(createSuccessResponse(requestId, result));
|
|
18223
18106
|
}, (error40) => {
|
|
18224
18107
|
this.proxies[proxyIndex]?.send(createErrorResponse(requestId, error40));
|
|
18225
18108
|
});
|
|
18226
|
-
} else
|
|
18109
|
+
} else
|
|
18227
18110
|
return createResponder((result) => {
|
|
18228
18111
|
this.agentConnection?.send(createSuccessResponse(requestId, result));
|
|
18229
18112
|
}, (error40) => {
|
|
18230
18113
|
this.agentConnection?.send(createErrorResponse(requestId, error40));
|
|
18231
18114
|
});
|
|
18232
|
-
}
|
|
18233
18115
|
}
|
|
18234
18116
|
/**
|
|
18235
18117
|
* Run the main event loop, processing messages from the queue
|
|
18236
18118
|
*/
|
|
18237
18119
|
async runEventLoop() {
|
|
18238
|
-
for await (const message of this.messageQueue)
|
|
18120
|
+
for await (const message of this.messageQueue)
|
|
18239
18121
|
await this.handleMessage(message);
|
|
18240
|
-
}
|
|
18241
18122
|
}
|
|
18242
18123
|
/**
|
|
18243
18124
|
* Handle a message from the queue
|
|
18244
18125
|
*/
|
|
18245
18126
|
async handleMessage(message) {
|
|
18246
|
-
this.logger.traceMessage({
|
|
18127
|
+
switch (this.logger.traceMessage({
|
|
18247
18128
|
direction: message.type === "left-to-right" ? "left-to-right" : message.type === "right-to-left" ? "right-to-left" : "internal",
|
|
18248
18129
|
source: this.getMessageSource(message),
|
|
18249
18130
|
target: this.getMessageTarget(message),
|
|
18250
18131
|
message
|
|
18251
|
-
})
|
|
18252
|
-
switch (message.type) {
|
|
18132
|
+
}), message.type) {
|
|
18253
18133
|
case "left-to-right":
|
|
18254
18134
|
this.logger.trace("Routing left-to-right", {
|
|
18255
18135
|
targetIndex: message.targetIndex,
|
|
18256
18136
|
dispatchType: message.dispatch.type,
|
|
18257
18137
|
method: "method" in message.dispatch ? message.dispatch.method : void 0
|
|
18258
|
-
});
|
|
18259
|
-
await this.handleLeftToRight(message.targetIndex, message.dispatch);
|
|
18138
|
+
}), await this.handleLeftToRight(message.targetIndex, message.dispatch);
|
|
18260
18139
|
break;
|
|
18261
18140
|
case "right-to-left":
|
|
18262
18141
|
this.logger.trace("Routing right-to-left", {
|
|
18263
18142
|
sourceIndex: message.sourceIndex,
|
|
18264
18143
|
dispatchType: message.dispatch.type,
|
|
18265
18144
|
method: "method" in message.dispatch ? message.dispatch.method : void 0
|
|
18266
|
-
});
|
|
18267
|
-
await this.handleRightToLeft(message.sourceIndex, message.dispatch);
|
|
18145
|
+
}), await this.handleRightToLeft(message.sourceIndex, message.dispatch);
|
|
18268
18146
|
break;
|
|
18269
18147
|
case "shutdown":
|
|
18270
18148
|
this.logger.debug("Received shutdown message");
|
|
18271
18149
|
break;
|
|
18272
18150
|
// MCP bridge messages
|
|
18273
18151
|
case "mcp-connection-received":
|
|
18274
|
-
this.logger.debug("MCP connection received", { acpUrl: message.acpUrl, connectionId: message.connectionId });
|
|
18275
|
-
await this.handleMcpConnectionReceived(message.acpUrl, message.connectionId);
|
|
18152
|
+
this.logger.debug("MCP connection received", { acpUrl: message.acpUrl, connectionId: message.connectionId }), await this.handleMcpConnectionReceived(message.acpUrl, message.connectionId);
|
|
18276
18153
|
break;
|
|
18277
18154
|
case "mcp-connection-established":
|
|
18278
18155
|
this.logger.debug("MCP connection established", { connectionId: message.connectionId });
|
|
18279
18156
|
break;
|
|
18280
18157
|
case "mcp-client-to-server":
|
|
18281
|
-
this.logger.trace("MCP client-to-server message", { connectionId: message.connectionId });
|
|
18282
|
-
await this.handleMcpClientToServer(message.connectionId, message.dispatch);
|
|
18158
|
+
this.logger.trace("MCP client-to-server message", { connectionId: message.connectionId }), await this.handleMcpClientToServer(message.connectionId, message.dispatch);
|
|
18283
18159
|
break;
|
|
18284
18160
|
case "mcp-connection-disconnected":
|
|
18285
|
-
this.logger.debug("MCP connection disconnected", { connectionId: message.connectionId });
|
|
18286
|
-
await this.handleMcpConnectionDisconnected(message.connectionId);
|
|
18161
|
+
this.logger.debug("MCP connection disconnected", { connectionId: message.connectionId }), await this.handleMcpConnectionDisconnected(message.connectionId);
|
|
18287
18162
|
break;
|
|
18288
18163
|
}
|
|
18289
18164
|
}
|
|
@@ -18312,10 +18187,7 @@ var Conductor = class {
|
|
|
18312
18187
|
case "left-to-right":
|
|
18313
18188
|
return message.targetIndex < this.proxies.length ? `proxy[${message.targetIndex}]` : "agent";
|
|
18314
18189
|
case "right-to-left":
|
|
18315
|
-
|
|
18316
|
-
return "client";
|
|
18317
|
-
}
|
|
18318
|
-
return message.sourceIndex.type === "successor" ? `proxy[${this.proxies.length - 1}]` : `proxy[${message.sourceIndex.index - 1}]`;
|
|
18190
|
+
return message.sourceIndex.type === "proxy" && message.sourceIndex.index === 0 ? "client" : message.sourceIndex.type === "successor" ? `proxy[${this.proxies.length - 1}]` : `proxy[${message.sourceIndex.index - 1}]`;
|
|
18319
18191
|
case "mcp-connection-received":
|
|
18320
18192
|
case "mcp-client-to-server":
|
|
18321
18193
|
case "mcp-connection-disconnected":
|
|
@@ -18338,12 +18210,10 @@ var Conductor = class {
|
|
|
18338
18210
|
}
|
|
18339
18211
|
const target = this.getTargetConnection(targetIndex);
|
|
18340
18212
|
if (!target) {
|
|
18341
|
-
|
|
18342
|
-
|
|
18343
|
-
|
|
18344
|
-
|
|
18345
|
-
});
|
|
18346
|
-
}
|
|
18213
|
+
dispatch.type === "request" && dispatch.responder.respondWithError({
|
|
18214
|
+
code: -32603,
|
|
18215
|
+
message: `No target connection for index ${targetIndex}`
|
|
18216
|
+
});
|
|
18347
18217
|
return;
|
|
18348
18218
|
}
|
|
18349
18219
|
this.forwardToConnection(target, dispatch);
|
|
@@ -18357,9 +18227,7 @@ var Conductor = class {
|
|
|
18357
18227
|
return;
|
|
18358
18228
|
}
|
|
18359
18229
|
if (this.proxies.length === 0) {
|
|
18360
|
-
|
|
18361
|
-
this.forwardToConnection(this.clientConnection, dispatch);
|
|
18362
|
-
}
|
|
18230
|
+
this.clientConnection && this.forwardToConnection(this.clientConnection, dispatch);
|
|
18363
18231
|
return;
|
|
18364
18232
|
}
|
|
18365
18233
|
if (sourceIndex.type === "successor") {
|
|
@@ -18367,13 +18235,7 @@ var Conductor = class {
|
|
|
18367
18235
|
this.forwardWrappedToProxy(lastProxyIndex, dispatch);
|
|
18368
18236
|
} else if (sourceIndex.type === "proxy") {
|
|
18369
18237
|
const proxyIndex = sourceIndex.index;
|
|
18370
|
-
|
|
18371
|
-
if (this.clientConnection) {
|
|
18372
|
-
this.forwardToConnection(this.clientConnection, dispatch);
|
|
18373
|
-
}
|
|
18374
|
-
} else {
|
|
18375
|
-
this.forwardWrappedToProxy(proxyIndex - 1, dispatch);
|
|
18376
|
-
}
|
|
18238
|
+
proxyIndex === 0 ? this.clientConnection && this.forwardToConnection(this.clientConnection, dispatch) : this.forwardWrappedToProxy(proxyIndex - 1, dispatch);
|
|
18377
18239
|
}
|
|
18378
18240
|
}
|
|
18379
18241
|
/**
|
|
@@ -18384,28 +18246,25 @@ var Conductor = class {
|
|
|
18384
18246
|
*/
|
|
18385
18247
|
forwardWrappedToProxy(proxyIndex, dispatch) {
|
|
18386
18248
|
const proxy = this.proxies[proxyIndex];
|
|
18387
|
-
if (
|
|
18388
|
-
|
|
18389
|
-
|
|
18390
|
-
|
|
18391
|
-
|
|
18392
|
-
|
|
18393
|
-
|
|
18394
|
-
|
|
18395
|
-
|
|
18396
|
-
|
|
18397
|
-
}
|
|
18398
|
-
|
|
18399
|
-
|
|
18400
|
-
|
|
18401
|
-
|
|
18402
|
-
|
|
18403
|
-
|
|
18404
|
-
|
|
18249
|
+
if (proxy)
|
|
18250
|
+
switch (dispatch.type) {
|
|
18251
|
+
case "request": {
|
|
18252
|
+
const wrappedParams = wrapAsProxySuccessorRequest(dispatch.method, dispatch.params), outgoingId = this.generateRequestId();
|
|
18253
|
+
this.pendingRequests.set(String(outgoingId), {
|
|
18254
|
+
originalId: dispatch.id,
|
|
18255
|
+
responder: dispatch.responder,
|
|
18256
|
+
source: proxyIndex
|
|
18257
|
+
}), proxy.send(createRequest(outgoingId, PROXY_SUCCESSOR_REQUEST, wrappedParams));
|
|
18258
|
+
break;
|
|
18259
|
+
}
|
|
18260
|
+
case "notification": {
|
|
18261
|
+
const wrappedParams = wrapAsProxySuccessorNotification(dispatch.method, dispatch.params);
|
|
18262
|
+
proxy.send(createNotification(PROXY_SUCCESSOR_NOTIFICATION, wrappedParams));
|
|
18263
|
+
break;
|
|
18264
|
+
}
|
|
18265
|
+
case "response":
|
|
18266
|
+
break;
|
|
18405
18267
|
}
|
|
18406
|
-
case "response":
|
|
18407
|
-
break;
|
|
18408
|
-
}
|
|
18409
18268
|
}
|
|
18410
18269
|
/**
|
|
18411
18270
|
* Handle the initialize request - instantiate components and perform initialization sequence
|
|
@@ -18426,8 +18285,7 @@ var Conductor = class {
|
|
|
18426
18285
|
});
|
|
18427
18286
|
return;
|
|
18428
18287
|
}
|
|
18429
|
-
this.state = { type: "initializing" };
|
|
18430
|
-
this.logger.info("Starting initialization");
|
|
18288
|
+
this.state = { type: "initializing" }, this.logger.info("Starting initialization");
|
|
18431
18289
|
try {
|
|
18432
18290
|
const initRequest = {
|
|
18433
18291
|
method: dispatch.method,
|
|
@@ -18438,38 +18296,25 @@ var Conductor = class {
|
|
|
18438
18296
|
this.logger.info("Components instantiated", { proxyCount: proxies.length });
|
|
18439
18297
|
for (const proxyConnector of proxies) {
|
|
18440
18298
|
const proxyConnection = await proxyConnector.connect();
|
|
18441
|
-
this.proxies.push(proxyConnection);
|
|
18442
|
-
|
|
18443
|
-
|
|
18444
|
-
}
|
|
18445
|
-
this.logger.debug("Connecting to agent");
|
|
18446
|
-
this.agentConnection = await agent.connect();
|
|
18447
|
-
this.pumpAgentMessages(this.agentConnection);
|
|
18448
|
-
this.logger.info("Agent connected");
|
|
18449
|
-
this.state = { type: "running" };
|
|
18450
|
-
this.logger.info("Conductor running");
|
|
18451
|
-
if (this.proxies.length === 0) {
|
|
18299
|
+
this.proxies.push(proxyConnection), this.logger.debug("Proxy connected", { proxyIndex: this.proxies.length - 1 }), this.pumpProxyMessages(proxyConnection, this.proxies.length - 1);
|
|
18300
|
+
}
|
|
18301
|
+
if (this.logger.debug("Connecting to agent"), this.agentConnection = await agent.connect(), this.pumpAgentMessages(this.agentConnection), this.logger.info("Agent connected"), this.state = { type: "running" }, this.logger.info("Conductor running"), this.proxies.length === 0) {
|
|
18452
18302
|
const outgoingId = this.generateRequestId();
|
|
18453
18303
|
this.pendingRequests.set(String(outgoingId), {
|
|
18454
18304
|
originalId: dispatch.id,
|
|
18455
18305
|
responder: this.createAgentInitializeResponder(dispatch.responder),
|
|
18456
18306
|
source: "client"
|
|
18457
|
-
});
|
|
18458
|
-
this.agentConnection.send(createRequest(outgoingId, dispatch.method, dispatch.params));
|
|
18307
|
+
}), this.agentConnection.send(createRequest(outgoingId, dispatch.method, dispatch.params));
|
|
18459
18308
|
} else {
|
|
18460
|
-
const paramsWithProxy = this.addProxyCapability(dispatch.params);
|
|
18461
|
-
const outgoingId = this.generateRequestId();
|
|
18309
|
+
const paramsWithProxy = this.addProxyCapability(dispatch.params), outgoingId = this.generateRequestId();
|
|
18462
18310
|
this.pendingRequests.set(String(outgoingId), {
|
|
18463
18311
|
originalId: dispatch.id,
|
|
18464
18312
|
responder: this.createProxyInitializeResponder(this.createAgentInitializeResponder(dispatch.responder)),
|
|
18465
18313
|
source: "client"
|
|
18466
|
-
});
|
|
18467
|
-
this.proxies[0].send(createRequest(outgoingId, dispatch.method, paramsWithProxy));
|
|
18314
|
+
}), this.proxies[0].send(createRequest(outgoingId, dispatch.method, paramsWithProxy));
|
|
18468
18315
|
}
|
|
18469
18316
|
} catch (error40) {
|
|
18470
|
-
this.state = { type: "uninitialized" }
|
|
18471
|
-
this.logger.error("Initialization failed", { error: String(error40) });
|
|
18472
|
-
dispatch.responder.respondWithError({
|
|
18317
|
+
this.state = { type: "uninitialized" }, this.logger.error("Initialization failed", { error: String(error40) }), dispatch.responder.respondWithError({
|
|
18473
18318
|
code: -32603,
|
|
18474
18319
|
message: `Failed to initialize: ${error40}`
|
|
18475
18320
|
});
|
|
@@ -18479,8 +18324,7 @@ var Conductor = class {
|
|
|
18479
18324
|
* Add proxy capability to initialize params
|
|
18480
18325
|
*/
|
|
18481
18326
|
addProxyCapability(params) {
|
|
18482
|
-
const p = params ?? {};
|
|
18483
|
-
const meta = p._meta ?? {};
|
|
18327
|
+
const p = params ?? {}, meta = p._meta ?? {};
|
|
18484
18328
|
return {
|
|
18485
18329
|
...p,
|
|
18486
18330
|
_meta: {
|
|
@@ -18493,9 +18337,7 @@ var Conductor = class {
|
|
|
18493
18337
|
* Remove proxy capability from initialize params (for forwarding to agent)
|
|
18494
18338
|
*/
|
|
18495
18339
|
removeProxyCapability(params) {
|
|
18496
|
-
const p = params ?? {};
|
|
18497
|
-
const meta = p._meta ?? {};
|
|
18498
|
-
const { proxy: _, ...restMeta } = meta;
|
|
18340
|
+
const p = params ?? {}, meta = p._meta ?? {}, { proxy: _, ...restMeta } = meta;
|
|
18499
18341
|
return {
|
|
18500
18342
|
...p,
|
|
18501
18343
|
_meta: restMeta
|
|
@@ -18506,8 +18348,7 @@ var Conductor = class {
|
|
|
18506
18348
|
*/
|
|
18507
18349
|
createProxyInitializeResponder(originalResponder) {
|
|
18508
18350
|
return createResponder((result) => {
|
|
18509
|
-
|
|
18510
|
-
if (!response?._meta?.proxy) {
|
|
18351
|
+
if (!result?._meta?.proxy) {
|
|
18511
18352
|
originalResponder.respondWithError({
|
|
18512
18353
|
code: -32600,
|
|
18513
18354
|
message: "Proxy component did not accept proxy capability"
|
|
@@ -18524,11 +18365,7 @@ var Conductor = class {
|
|
|
18524
18365
|
*/
|
|
18525
18366
|
createAgentInitializeResponder(originalResponder) {
|
|
18526
18367
|
return createResponder((result) => {
|
|
18527
|
-
|
|
18528
|
-
if (response?.capabilities?.mcp_acp_transport) {
|
|
18529
|
-
this.agentSupportsMcpAcpTransport = true;
|
|
18530
|
-
}
|
|
18531
|
-
originalResponder.respond(result);
|
|
18368
|
+
result?.capabilities?.mcp_acp_transport && (this.agentSupportsMcpAcpTransport = true), originalResponder.respond(result);
|
|
18532
18369
|
}, (error40) => {
|
|
18533
18370
|
originalResponder.respondWithError(error40);
|
|
18534
18371
|
});
|
|
@@ -18542,12 +18379,7 @@ var Conductor = class {
|
|
|
18542
18379
|
this.logger.warn("No pending request for response ID", { id: dispatch.id });
|
|
18543
18380
|
return;
|
|
18544
18381
|
}
|
|
18545
|
-
this.pendingRequests.delete(String(dispatch.id));
|
|
18546
|
-
if (dispatch.error) {
|
|
18547
|
-
pending.responder.respondWithError(dispatch.error);
|
|
18548
|
-
} else {
|
|
18549
|
-
pending.responder.respond(dispatch.result);
|
|
18550
|
-
}
|
|
18382
|
+
this.pendingRequests.delete(String(dispatch.id)), dispatch.error ? pending.responder.respondWithError(dispatch.error) : pending.responder.respond(dispatch.result);
|
|
18551
18383
|
}
|
|
18552
18384
|
/**
|
|
18553
18385
|
* Forward a dispatch to a connection, handling request ID rewriting
|
|
@@ -18561,19 +18393,14 @@ var Conductor = class {
|
|
|
18561
18393
|
responder: dispatch.responder,
|
|
18562
18394
|
source: "client"
|
|
18563
18395
|
// Default - actual source tracking is in PendingRequest
|
|
18564
|
-
});
|
|
18565
|
-
connection.send(createRequest(outgoingId, dispatch.method, dispatch.params));
|
|
18396
|
+
}), connection.send(createRequest(outgoingId, dispatch.method, dispatch.params));
|
|
18566
18397
|
break;
|
|
18567
18398
|
}
|
|
18568
18399
|
case "notification":
|
|
18569
18400
|
connection.send(createNotification(dispatch.method, dispatch.params));
|
|
18570
18401
|
break;
|
|
18571
18402
|
case "response":
|
|
18572
|
-
|
|
18573
|
-
connection.send(createErrorResponse(dispatch.id, dispatch.error));
|
|
18574
|
-
} else {
|
|
18575
|
-
connection.send(createSuccessResponse(dispatch.id, dispatch.result));
|
|
18576
|
-
}
|
|
18403
|
+
dispatch.error ? connection.send(createErrorResponse(dispatch.id, dispatch.error)) : connection.send(createSuccessResponse(dispatch.id, dispatch.result));
|
|
18577
18404
|
break;
|
|
18578
18405
|
}
|
|
18579
18406
|
}
|
|
@@ -18582,13 +18409,7 @@ var Conductor = class {
|
|
|
18582
18409
|
* Index 0..n-1 are proxies, index n is the agent
|
|
18583
18410
|
*/
|
|
18584
18411
|
getTargetConnection(targetIndex) {
|
|
18585
|
-
|
|
18586
|
-
return this.proxies[targetIndex];
|
|
18587
|
-
}
|
|
18588
|
-
if (targetIndex === this.proxies.length) {
|
|
18589
|
-
return this.agentConnection;
|
|
18590
|
-
}
|
|
18591
|
-
return null;
|
|
18412
|
+
return targetIndex < this.proxies.length ? this.proxies[targetIndex] : targetIndex === this.proxies.length ? this.agentConnection : null;
|
|
18592
18413
|
}
|
|
18593
18414
|
/**
|
|
18594
18415
|
* Handle a session/new request - transform acp: URLs to http: URLs
|
|
@@ -18601,33 +18422,21 @@ var Conductor = class {
|
|
|
18601
18422
|
* 4. When the response comes back with session_id, deliver it to the listeners
|
|
18602
18423
|
*/
|
|
18603
18424
|
async handleSessionNew(targetIndex, dispatch) {
|
|
18604
|
-
const params = dispatch.params;
|
|
18605
|
-
const servers = params?.mcpServers;
|
|
18606
|
-
const sessionKey = `session-${this.generateRequestId()}`;
|
|
18607
|
-
const { transformedServers, hasAcpServers } = await this.mcpBridge.transformMcpServers(servers, sessionKey);
|
|
18425
|
+
const params = dispatch.params, servers = params?.mcpServers, sessionKey = `session-${this.generateRequestId()}`, { transformedServers, hasAcpServers } = await this.mcpBridge.transformMcpServers(servers, sessionKey);
|
|
18608
18426
|
if (!hasAcpServers) {
|
|
18609
18427
|
const target2 = this.getTargetConnection(targetIndex);
|
|
18610
|
-
|
|
18611
|
-
this.forwardToConnection(target2, dispatch);
|
|
18612
|
-
}
|
|
18428
|
+
target2 && this.forwardToConnection(target2, dispatch);
|
|
18613
18429
|
return;
|
|
18614
18430
|
}
|
|
18615
18431
|
const modifiedParams = {
|
|
18616
18432
|
...params,
|
|
18617
18433
|
mcpServers: transformedServers
|
|
18618
|
-
}
|
|
18619
|
-
const originalResponder = dispatch.responder;
|
|
18620
|
-
const wrappedResponder = createResponder((result) => {
|
|
18434
|
+
}, originalResponder = dispatch.responder, wrappedResponder = createResponder((result) => {
|
|
18621
18435
|
const response = result;
|
|
18622
|
-
|
|
18623
|
-
this.mcpBridge.completeSession(sessionKey, response.sessionId);
|
|
18624
|
-
}
|
|
18625
|
-
originalResponder.respond(result);
|
|
18436
|
+
response?.sessionId && this.mcpBridge.completeSession(sessionKey, response.sessionId), originalResponder.respond(result);
|
|
18626
18437
|
}, async (error40) => {
|
|
18627
|
-
await this.mcpBridge.cancelSession(sessionKey);
|
|
18628
|
-
|
|
18629
|
-
});
|
|
18630
|
-
const target = this.getTargetConnection(targetIndex);
|
|
18438
|
+
await this.mcpBridge.cancelSession(sessionKey), originalResponder.respondWithError(error40);
|
|
18439
|
+
}), target = this.getTargetConnection(targetIndex);
|
|
18631
18440
|
if (!target) {
|
|
18632
18441
|
dispatch.responder.respondWithError({
|
|
18633
18442
|
code: -32603,
|
|
@@ -18655,8 +18464,7 @@ var Conductor = class {
|
|
|
18655
18464
|
const mcpConnectParams = {
|
|
18656
18465
|
connectionId,
|
|
18657
18466
|
url: acpUrl
|
|
18658
|
-
}
|
|
18659
|
-
const responder = createResponder((result) => {
|
|
18467
|
+
}, responder = createResponder((result) => {
|
|
18660
18468
|
const response = result;
|
|
18661
18469
|
this.messageQueue.push({
|
|
18662
18470
|
type: "mcp-connection-established",
|
|
@@ -18674,13 +18482,7 @@ var Conductor = class {
|
|
|
18674
18482
|
params: mcpConnectParams,
|
|
18675
18483
|
responder
|
|
18676
18484
|
};
|
|
18677
|
-
|
|
18678
|
-
if (this.clientConnection) {
|
|
18679
|
-
this.forwardToConnection(this.clientConnection, dispatch);
|
|
18680
|
-
}
|
|
18681
|
-
} else {
|
|
18682
|
-
this.forwardWrappedToProxy(this.proxies.length - 1, dispatch);
|
|
18683
|
-
}
|
|
18485
|
+
this.proxies.length === 0 ? this.clientConnection && this.forwardToConnection(this.clientConnection, dispatch) : this.forwardWrappedToProxy(this.proxies.length - 1, dispatch);
|
|
18684
18486
|
}
|
|
18685
18487
|
/**
|
|
18686
18488
|
* Handle an MCP message from a client (through the HTTP bridge)
|
|
@@ -18702,26 +18504,14 @@ var Conductor = class {
|
|
|
18702
18504
|
params: mcpMessageParams,
|
|
18703
18505
|
responder: dispatch.responder
|
|
18704
18506
|
};
|
|
18705
|
-
|
|
18706
|
-
if (this.clientConnection) {
|
|
18707
|
-
this.forwardToConnection(this.clientConnection, mcpDispatch);
|
|
18708
|
-
}
|
|
18709
|
-
} else {
|
|
18710
|
-
this.forwardWrappedToProxy(this.proxies.length - 1, mcpDispatch);
|
|
18711
|
-
}
|
|
18507
|
+
this.proxies.length === 0 ? this.clientConnection && this.forwardToConnection(this.clientConnection, mcpDispatch) : this.forwardWrappedToProxy(this.proxies.length - 1, mcpDispatch);
|
|
18712
18508
|
} else if (dispatch.type === "notification") {
|
|
18713
18509
|
const mcpDispatch = {
|
|
18714
18510
|
type: "notification",
|
|
18715
18511
|
method: "_mcp/message",
|
|
18716
18512
|
params: mcpMessageParams
|
|
18717
18513
|
};
|
|
18718
|
-
|
|
18719
|
-
if (this.clientConnection) {
|
|
18720
|
-
this.forwardToConnection(this.clientConnection, mcpDispatch);
|
|
18721
|
-
}
|
|
18722
|
-
} else {
|
|
18723
|
-
this.forwardWrappedToProxy(this.proxies.length - 1, mcpDispatch);
|
|
18724
|
-
}
|
|
18514
|
+
this.proxies.length === 0 ? this.clientConnection && this.forwardToConnection(this.clientConnection, mcpDispatch) : this.forwardWrappedToProxy(this.proxies.length - 1, mcpDispatch);
|
|
18725
18515
|
}
|
|
18726
18516
|
}
|
|
18727
18517
|
/**
|
|
@@ -18734,13 +18524,7 @@ var Conductor = class {
|
|
|
18734
18524
|
method: "_mcp/disconnect",
|
|
18735
18525
|
params: { connectionId }
|
|
18736
18526
|
};
|
|
18737
|
-
|
|
18738
|
-
if (this.clientConnection) {
|
|
18739
|
-
this.forwardToConnection(this.clientConnection, dispatch);
|
|
18740
|
-
}
|
|
18741
|
-
} else {
|
|
18742
|
-
this.forwardWrappedToProxy(this.proxies.length - 1, dispatch);
|
|
18743
|
-
}
|
|
18527
|
+
this.proxies.length === 0 ? this.clientConnection && this.forwardToConnection(this.clientConnection, dispatch) : this.forwardWrappedToProxy(this.proxies.length - 1, dispatch);
|
|
18744
18528
|
}
|
|
18745
18529
|
/**
|
|
18746
18530
|
* Generate a unique request ID for outgoing requests
|
|
@@ -18762,44 +18546,28 @@ var MessageChannel = class {
|
|
|
18762
18546
|
resolvers = [];
|
|
18763
18547
|
closed = false;
|
|
18764
18548
|
push(message) {
|
|
18765
|
-
|
|
18766
|
-
return;
|
|
18767
|
-
}
|
|
18768
|
-
if (this.resolvers.length > 0) {
|
|
18769
|
-
const resolve2 = this.resolvers.shift();
|
|
18770
|
-
resolve2(message);
|
|
18771
|
-
} else {
|
|
18772
|
-
this.queue.push(message);
|
|
18773
|
-
}
|
|
18549
|
+
this.closed || (this.resolvers.length > 0 ? this.resolvers.shift()(message) : this.queue.push(message));
|
|
18774
18550
|
}
|
|
18775
18551
|
close() {
|
|
18776
18552
|
this.closed = true;
|
|
18777
|
-
for (const resolve2 of this.resolvers)
|
|
18553
|
+
for (const resolve2 of this.resolvers)
|
|
18778
18554
|
resolve2(null);
|
|
18779
|
-
}
|
|
18780
18555
|
this.resolvers = [];
|
|
18781
18556
|
}
|
|
18782
18557
|
isClosed() {
|
|
18783
18558
|
return this.closed;
|
|
18784
18559
|
}
|
|
18785
18560
|
async *[Symbol.asyncIterator]() {
|
|
18786
|
-
|
|
18561
|
+
for (; !this.closed; ) {
|
|
18787
18562
|
let message;
|
|
18788
|
-
if (this.queue.length > 0) {
|
|
18789
|
-
|
|
18790
|
-
}
|
|
18791
|
-
message = await new Promise((resolve2) => {
|
|
18792
|
-
this.resolvers.push(resolve2);
|
|
18793
|
-
});
|
|
18794
|
-
}
|
|
18795
|
-
if (message === null) {
|
|
18563
|
+
if (this.queue.length > 0 ? message = this.queue.shift() : message = await new Promise((resolve2) => {
|
|
18564
|
+
this.resolvers.push(resolve2);
|
|
18565
|
+
}), message === null)
|
|
18796
18566
|
return;
|
|
18797
|
-
}
|
|
18798
18567
|
yield message;
|
|
18799
18568
|
}
|
|
18800
|
-
|
|
18569
|
+
for (; this.queue.length > 0; )
|
|
18801
18570
|
yield this.queue.shift();
|
|
18802
|
-
}
|
|
18803
18571
|
}
|
|
18804
18572
|
};
|
|
18805
18573
|
var ChannelConnectionEnd = class {
|
|
@@ -18809,8 +18577,7 @@ var ChannelConnectionEnd = class {
|
|
|
18809
18577
|
sendChannel;
|
|
18810
18578
|
receiveChannel;
|
|
18811
18579
|
constructor(sendChannel, receiveChannel) {
|
|
18812
|
-
this.sendChannel = sendChannel;
|
|
18813
|
-
this.receiveChannel = receiveChannel;
|
|
18580
|
+
this.sendChannel = sendChannel, this.receiveChannel = receiveChannel;
|
|
18814
18581
|
}
|
|
18815
18582
|
send(message) {
|
|
18816
18583
|
this.sendChannel.push(message);
|
|
@@ -18819,13 +18586,11 @@ var ChannelConnectionEnd = class {
|
|
|
18819
18586
|
return this.receiveChannel;
|
|
18820
18587
|
}
|
|
18821
18588
|
async close() {
|
|
18822
|
-
this.sendChannel.close();
|
|
18823
|
-
this.receiveChannel.close();
|
|
18589
|
+
this.sendChannel.close(), this.receiveChannel.close();
|
|
18824
18590
|
}
|
|
18825
18591
|
};
|
|
18826
18592
|
function createChannelPair() {
|
|
18827
|
-
const leftToRight = new MessageChannel();
|
|
18828
|
-
const rightToLeft = new MessageChannel();
|
|
18593
|
+
const leftToRight = new MessageChannel(), rightToLeft = new MessageChannel();
|
|
18829
18594
|
return {
|
|
18830
18595
|
left: new ChannelConnectionEnd(leftToRight, rightToLeft),
|
|
18831
18596
|
right: new ChannelConnectionEnd(rightToLeft, leftToRight)
|
|
@@ -18902,21 +18667,19 @@ var McpServerBuilder = class {
|
|
|
18902
18667
|
* Set instructions for the MCP server
|
|
18903
18668
|
*/
|
|
18904
18669
|
instructions(text) {
|
|
18905
|
-
this._instructions = text;
|
|
18906
|
-
return this;
|
|
18670
|
+
return this._instructions = text, this;
|
|
18907
18671
|
}
|
|
18908
18672
|
/**
|
|
18909
18673
|
* Register a tool with input/output JSON schemas
|
|
18910
18674
|
*/
|
|
18911
18675
|
tool(name, description, inputSchema, outputSchema, handler) {
|
|
18912
|
-
this._tools.set(name, {
|
|
18676
|
+
return this._tools.set(name, {
|
|
18913
18677
|
name,
|
|
18914
18678
|
description,
|
|
18915
18679
|
inputSchema,
|
|
18916
18680
|
outputSchema,
|
|
18917
18681
|
handler
|
|
18918
|
-
});
|
|
18919
|
-
return this;
|
|
18682
|
+
}), this;
|
|
18920
18683
|
}
|
|
18921
18684
|
/**
|
|
18922
18685
|
* Build the MCP server
|
|
@@ -18934,10 +18697,7 @@ var McpServer = class {
|
|
|
18934
18697
|
_instructions;
|
|
18935
18698
|
_tools;
|
|
18936
18699
|
constructor(name, instructions, tools) {
|
|
18937
|
-
this.id = v4_default();
|
|
18938
|
-
this.name = name;
|
|
18939
|
-
this._instructions = instructions;
|
|
18940
|
-
this._tools = tools;
|
|
18700
|
+
this.id = v4_default(), this.name = name, this._instructions = instructions, this._tools = tools;
|
|
18941
18701
|
}
|
|
18942
18702
|
/**
|
|
18943
18703
|
* Get the acp: URL for this server
|
|
@@ -18977,17 +18737,15 @@ var McpServer = class {
|
|
|
18977
18737
|
case "initialize":
|
|
18978
18738
|
return this.handleInitialize(params);
|
|
18979
18739
|
case "notifications/initialized":
|
|
18980
|
-
return
|
|
18740
|
+
return;
|
|
18981
18741
|
default:
|
|
18982
18742
|
throw new Error(`Unknown MCP method: ${method}`);
|
|
18983
18743
|
}
|
|
18984
18744
|
}
|
|
18985
18745
|
handleInitialize(params) {
|
|
18986
|
-
const instructions = this._instructions ?? "You have access to tools. Call return_result when done.";
|
|
18987
|
-
const tools = this.getToolDefinitions();
|
|
18988
|
-
const clientVersion = params?.protocolVersion ?? "2024-11-05";
|
|
18746
|
+
const instructions = this._instructions ?? "You have access to tools. Call return_result when done.", tools = this.getToolDefinitions();
|
|
18989
18747
|
return {
|
|
18990
|
-
protocolVersion:
|
|
18748
|
+
protocolVersion: params?.protocolVersion ?? "2024-11-05",
|
|
18991
18749
|
serverInfo: {
|
|
18992
18750
|
name: this.name,
|
|
18993
18751
|
version: "0.1.0"
|
|
@@ -19007,22 +18765,19 @@ var McpServer = class {
|
|
|
19007
18765
|
}
|
|
19008
18766
|
async handleToolsCall(params, context) {
|
|
19009
18767
|
const tool = this._tools.get(params.name);
|
|
19010
|
-
if (!tool)
|
|
18768
|
+
if (!tool)
|
|
19011
18769
|
return {
|
|
19012
18770
|
content: [{ type: "text", text: `Unknown tool: ${params.name}` }],
|
|
19013
18771
|
isError: true
|
|
19014
18772
|
};
|
|
19015
|
-
}
|
|
19016
18773
|
try {
|
|
19017
18774
|
const result = await tool.handler(params.arguments, context);
|
|
19018
|
-
const resultText = typeof result === "string" ? result : JSON.stringify(result);
|
|
19019
18775
|
return {
|
|
19020
|
-
content: [{ type: "text", text:
|
|
18776
|
+
content: [{ type: "text", text: typeof result == "string" ? result : JSON.stringify(result) }]
|
|
19021
18777
|
};
|
|
19022
18778
|
} catch (error40) {
|
|
19023
|
-
const message = error40 instanceof Error ? error40.message : String(error40);
|
|
19024
18779
|
return {
|
|
19025
|
-
content: [{ type: "text", text: `Tool error: ${message}` }],
|
|
18780
|
+
content: [{ type: "text", text: `Tool error: ${error40 instanceof Error ? error40.message : String(error40)}` }],
|
|
19026
18781
|
isError: true
|
|
19027
18782
|
};
|
|
19028
18783
|
}
|
|
@@ -19068,12 +18823,9 @@ var McpOverAcpHandler = class {
|
|
|
19068
18823
|
* Handle an incoming mcp/connect request
|
|
19069
18824
|
*/
|
|
19070
18825
|
handleConnect(params) {
|
|
19071
|
-
const connectionId = params.connectionId ?? `conn-${Date.now()}-${Math.random().toString(36).slice(2)}
|
|
19072
|
-
|
|
19073
|
-
const server = this._serversByUrl.get(url2);
|
|
19074
|
-
if (!server) {
|
|
18826
|
+
const connectionId = params.connectionId ?? `conn-${Date.now()}-${Math.random().toString(36).slice(2)}`, url2 = params.acp_url ?? params.url, server = this._serversByUrl.get(url2);
|
|
18827
|
+
if (!server)
|
|
19075
18828
|
throw new Error(`No MCP server registered for URL: ${url2}`);
|
|
19076
|
-
}
|
|
19077
18829
|
this._connections.set(connectionId, {
|
|
19078
18830
|
connectionId,
|
|
19079
18831
|
server,
|
|
@@ -19103,16 +18855,10 @@ var McpOverAcpHandler = class {
|
|
|
19103
18855
|
* MCP response (e.g., InitializeResult, ToolsListResult) directly.
|
|
19104
18856
|
*/
|
|
19105
18857
|
async handleMessage(params) {
|
|
19106
|
-
const connectionId = params.connectionId;
|
|
19107
|
-
|
|
19108
|
-
const mcpParams = params.params;
|
|
19109
|
-
const connection = this._connections.get(connectionId);
|
|
19110
|
-
if (!connection) {
|
|
18858
|
+
const connectionId = params.connectionId, method = params.method, mcpParams = params.params, connection = this._connections.get(connectionId);
|
|
18859
|
+
if (!connection)
|
|
19111
18860
|
throw new Error(`Unknown connection: ${connectionId}`);
|
|
19112
|
-
|
|
19113
|
-
if (method === "tools/list") {
|
|
19114
|
-
this._resolveToolsDiscovery(connection.sessionId);
|
|
19115
|
-
}
|
|
18861
|
+
method === "tools/list" && this._resolveToolsDiscovery(connection.sessionId);
|
|
19116
18862
|
const context = {
|
|
19117
18863
|
connectionId,
|
|
19118
18864
|
sessionId: connection.sessionId
|
|
@@ -19131,27 +18877,18 @@ var McpOverAcpHandler = class {
|
|
|
19131
18877
|
*/
|
|
19132
18878
|
waitForToolsDiscovery(sessionId, timeout = 2e3) {
|
|
19133
18879
|
const existing = this._toolsDiscoveryBySession.get(sessionId);
|
|
19134
|
-
|
|
19135
|
-
|
|
19136
|
-
|
|
19137
|
-
|
|
19138
|
-
|
|
19139
|
-
|
|
19140
|
-
};
|
|
19141
|
-
});
|
|
19142
|
-
}
|
|
19143
|
-
return new Promise((resolve2) => {
|
|
18880
|
+
return existing ? new Promise((resolve2) => {
|
|
18881
|
+
const originalResolve = existing.resolve;
|
|
18882
|
+
existing.resolve = () => {
|
|
18883
|
+
originalResolve(), resolve2();
|
|
18884
|
+
};
|
|
18885
|
+
}) : new Promise((resolve2) => {
|
|
19144
18886
|
const state = {
|
|
19145
18887
|
resolve: /* @__PURE__ */ __name(() => {
|
|
19146
|
-
|
|
19147
|
-
clearTimeout(state.timeoutId);
|
|
19148
|
-
}
|
|
19149
|
-
this._toolsDiscoveryBySession.delete(sessionId);
|
|
19150
|
-
resolve2();
|
|
18888
|
+
state.timeoutId && clearTimeout(state.timeoutId), this._toolsDiscoveryBySession.delete(sessionId), resolve2();
|
|
19151
18889
|
}, "resolve"),
|
|
19152
18890
|
timeoutId: setTimeout(() => {
|
|
19153
|
-
state.timeoutId = null;
|
|
19154
|
-
state.resolve();
|
|
18891
|
+
state.timeoutId = null, state.resolve();
|
|
19155
18892
|
}, timeout)
|
|
19156
18893
|
};
|
|
19157
18894
|
this._toolsDiscoveryBySession.set(sessionId, state);
|
|
@@ -19162,9 +18899,7 @@ var McpOverAcpHandler = class {
|
|
|
19162
18899
|
*/
|
|
19163
18900
|
_resolveToolsDiscovery(sessionId) {
|
|
19164
18901
|
const state = this._toolsDiscoveryBySession.get(sessionId);
|
|
19165
|
-
|
|
19166
|
-
state.resolve();
|
|
19167
|
-
}
|
|
18902
|
+
state && state.resolve();
|
|
19168
18903
|
}
|
|
19169
18904
|
/**
|
|
19170
18905
|
* Handle an incoming mcp/disconnect notification
|
|
@@ -19175,637 +18910,53 @@ var McpOverAcpHandler = class {
|
|
|
19175
18910
|
}
|
|
19176
18911
|
/**
|
|
19177
18912
|
* Check if this is an MCP-over-ACP request.
|
|
19178
|
-
* Note: The ACP SDK strips the underscore prefix, so we check for "mcp/".
|
|
19179
18913
|
*/
|
|
19180
18914
|
isMcpRequest(method) {
|
|
19181
|
-
return method.startsWith("
|
|
18915
|
+
return method.startsWith("_mcp/");
|
|
19182
18916
|
}
|
|
19183
18917
|
/**
|
|
19184
18918
|
* Route an MCP-over-ACP request to the appropriate handler.
|
|
19185
|
-
* Note: Methods arrive without the underscore prefix (e.g., "mcp/connect" not "_mcp/connect").
|
|
19186
18919
|
*/
|
|
19187
18920
|
async routeRequest(method, params) {
|
|
19188
18921
|
switch (method) {
|
|
19189
|
-
case "
|
|
18922
|
+
case "_mcp/connect":
|
|
19190
18923
|
return this.handleConnect(params);
|
|
19191
|
-
case "
|
|
18924
|
+
case "_mcp/message":
|
|
19192
18925
|
return this.handleMessage(params);
|
|
19193
|
-
case "
|
|
18926
|
+
case "_mcp/disconnect":
|
|
19194
18927
|
this.handleDisconnect(params);
|
|
19195
|
-
return
|
|
18928
|
+
return;
|
|
19196
18929
|
default:
|
|
19197
18930
|
throw new Error(`Unknown MCP-over-ACP method: ${method}`);
|
|
19198
18931
|
}
|
|
19199
18932
|
}
|
|
19200
18933
|
};
|
|
19201
18934
|
|
|
19202
|
-
//
|
|
19203
|
-
var
|
|
19204
|
-
|
|
19205
|
-
content: external_exports.string(),
|
|
19206
|
-
path: external_exports.string(),
|
|
19207
|
-
sessionId: external_exports.string()
|
|
19208
|
-
});
|
|
19209
|
-
var readTextFileRequestSchema = external_exports.object({
|
|
19210
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19211
|
-
limit: external_exports.number().optional().nullable(),
|
|
19212
|
-
line: external_exports.number().optional().nullable(),
|
|
19213
|
-
path: external_exports.string(),
|
|
19214
|
-
sessionId: external_exports.string()
|
|
19215
|
-
});
|
|
19216
|
-
var terminalOutputRequestSchema = external_exports.object({
|
|
19217
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19218
|
-
sessionId: external_exports.string(),
|
|
19219
|
-
terminalId: external_exports.string()
|
|
19220
|
-
});
|
|
19221
|
-
var releaseTerminalRequestSchema = external_exports.object({
|
|
19222
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19223
|
-
sessionId: external_exports.string(),
|
|
19224
|
-
terminalId: external_exports.string()
|
|
19225
|
-
});
|
|
19226
|
-
var waitForTerminalExitRequestSchema = external_exports.object({
|
|
19227
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19228
|
-
sessionId: external_exports.string(),
|
|
19229
|
-
terminalId: external_exports.string()
|
|
19230
|
-
});
|
|
19231
|
-
var killTerminalCommandRequestSchema = external_exports.object({
|
|
19232
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19233
|
-
sessionId: external_exports.string(),
|
|
19234
|
-
terminalId: external_exports.string()
|
|
19235
|
-
});
|
|
19236
|
-
var extMethodRequestSchema = external_exports.record(external_exports.unknown());
|
|
19237
|
-
var roleSchema = external_exports.union([external_exports.literal("assistant"), external_exports.literal("user")]);
|
|
19238
|
-
var textResourceContentsSchema = external_exports.object({
|
|
19239
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19240
|
-
mimeType: external_exports.string().optional().nullable(),
|
|
19241
|
-
text: external_exports.string(),
|
|
19242
|
-
uri: external_exports.string()
|
|
19243
|
-
});
|
|
19244
|
-
var blobResourceContentsSchema = external_exports.object({
|
|
19245
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19246
|
-
blob: external_exports.string(),
|
|
19247
|
-
mimeType: external_exports.string().optional().nullable(),
|
|
19248
|
-
uri: external_exports.string()
|
|
19249
|
-
});
|
|
19250
|
-
var toolKindSchema = external_exports.union([
|
|
19251
|
-
external_exports.literal("read"),
|
|
19252
|
-
external_exports.literal("edit"),
|
|
19253
|
-
external_exports.literal("delete"),
|
|
19254
|
-
external_exports.literal("move"),
|
|
19255
|
-
external_exports.literal("search"),
|
|
19256
|
-
external_exports.literal("execute"),
|
|
19257
|
-
external_exports.literal("think"),
|
|
19258
|
-
external_exports.literal("fetch"),
|
|
19259
|
-
external_exports.literal("switch_mode"),
|
|
19260
|
-
external_exports.literal("other")
|
|
19261
|
-
]);
|
|
19262
|
-
var toolCallStatusSchema = external_exports.union([
|
|
19263
|
-
external_exports.literal("pending"),
|
|
19264
|
-
external_exports.literal("in_progress"),
|
|
19265
|
-
external_exports.literal("completed"),
|
|
19266
|
-
external_exports.literal("failed")
|
|
19267
|
-
]);
|
|
19268
|
-
var writeTextFileResponseSchema = external_exports.object({
|
|
19269
|
-
_meta: external_exports.record(external_exports.unknown()).optional()
|
|
19270
|
-
});
|
|
19271
|
-
var readTextFileResponseSchema = external_exports.object({
|
|
19272
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19273
|
-
content: external_exports.string()
|
|
19274
|
-
});
|
|
19275
|
-
var requestPermissionResponseSchema = external_exports.object({
|
|
19276
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19277
|
-
outcome: external_exports.union([
|
|
19278
|
-
external_exports.object({
|
|
19279
|
-
outcome: external_exports.literal("cancelled")
|
|
19280
|
-
}),
|
|
19281
|
-
external_exports.object({
|
|
19282
|
-
optionId: external_exports.string(),
|
|
19283
|
-
outcome: external_exports.literal("selected")
|
|
19284
|
-
})
|
|
19285
|
-
])
|
|
19286
|
-
});
|
|
19287
|
-
var createTerminalResponseSchema = external_exports.object({
|
|
19288
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19289
|
-
terminalId: external_exports.string()
|
|
19290
|
-
});
|
|
19291
|
-
var releaseTerminalResponseSchema = external_exports.object({
|
|
19292
|
-
_meta: external_exports.record(external_exports.unknown()).optional()
|
|
19293
|
-
});
|
|
19294
|
-
var waitForTerminalExitResponseSchema = external_exports.object({
|
|
19295
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19296
|
-
exitCode: external_exports.number().optional().nullable(),
|
|
19297
|
-
signal: external_exports.string().optional().nullable()
|
|
19298
|
-
});
|
|
19299
|
-
var killTerminalResponseSchema = external_exports.object({
|
|
19300
|
-
_meta: external_exports.record(external_exports.unknown()).optional()
|
|
19301
|
-
});
|
|
19302
|
-
var extMethodResponseSchema = external_exports.record(external_exports.unknown());
|
|
19303
|
-
var cancelNotificationSchema = external_exports.object({
|
|
19304
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19305
|
-
sessionId: external_exports.string()
|
|
19306
|
-
});
|
|
19307
|
-
var extNotificationSchema = external_exports.record(external_exports.unknown());
|
|
19308
|
-
var authenticateRequestSchema = external_exports.object({
|
|
19309
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19310
|
-
methodId: external_exports.string()
|
|
19311
|
-
});
|
|
19312
|
-
var setSessionModeRequestSchema = external_exports.object({
|
|
19313
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19314
|
-
modeId: external_exports.string(),
|
|
19315
|
-
sessionId: external_exports.string()
|
|
19316
|
-
});
|
|
19317
|
-
var setSessionModelRequestSchema = external_exports.object({
|
|
19318
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19319
|
-
modelId: external_exports.string(),
|
|
19320
|
-
sessionId: external_exports.string()
|
|
19321
|
-
});
|
|
19322
|
-
var extMethodRequest1Schema = external_exports.record(external_exports.unknown());
|
|
19323
|
-
var httpHeaderSchema = external_exports.object({
|
|
19324
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19325
|
-
name: external_exports.string(),
|
|
19326
|
-
value: external_exports.string()
|
|
19327
|
-
});
|
|
19328
|
-
var annotationsSchema = external_exports.object({
|
|
19329
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19330
|
-
audience: external_exports.array(roleSchema).optional().nullable(),
|
|
19331
|
-
lastModified: external_exports.string().optional().nullable(),
|
|
19332
|
-
priority: external_exports.number().optional().nullable()
|
|
19333
|
-
});
|
|
19334
|
-
var embeddedResourceResourceSchema = external_exports.union([
|
|
19335
|
-
textResourceContentsSchema,
|
|
19336
|
-
blobResourceContentsSchema
|
|
19337
|
-
]);
|
|
19338
|
-
var authenticateResponseSchema = external_exports.object({
|
|
19339
|
-
_meta: external_exports.record(external_exports.unknown()).optional()
|
|
19340
|
-
});
|
|
19341
|
-
var setSessionModeResponseSchema = external_exports.object({
|
|
19342
|
-
meta: external_exports.unknown().optional()
|
|
19343
|
-
});
|
|
19344
|
-
var promptResponseSchema = external_exports.object({
|
|
19345
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19346
|
-
stopReason: external_exports.union([
|
|
19347
|
-
external_exports.literal("end_turn"),
|
|
19348
|
-
external_exports.literal("max_tokens"),
|
|
19349
|
-
external_exports.literal("max_turn_requests"),
|
|
19350
|
-
external_exports.literal("refusal"),
|
|
19351
|
-
external_exports.literal("cancelled")
|
|
19352
|
-
])
|
|
19353
|
-
});
|
|
19354
|
-
var setSessionModelResponseSchema = external_exports.object({
|
|
19355
|
-
_meta: external_exports.record(external_exports.unknown()).optional()
|
|
19356
|
-
});
|
|
19357
|
-
var extMethodResponse1Schema = external_exports.record(external_exports.unknown());
|
|
19358
|
-
var sessionModeIdSchema = external_exports.string();
|
|
19359
|
-
var extNotification1Schema = external_exports.record(external_exports.unknown());
|
|
19360
|
-
var unstructuredCommandInputSchema = external_exports.object({
|
|
19361
|
-
hint: external_exports.string()
|
|
19362
|
-
});
|
|
19363
|
-
var permissionOptionSchema = external_exports.object({
|
|
19364
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19365
|
-
kind: external_exports.union([
|
|
19366
|
-
external_exports.literal("allow_once"),
|
|
19367
|
-
external_exports.literal("allow_always"),
|
|
19368
|
-
external_exports.literal("reject_once"),
|
|
19369
|
-
external_exports.literal("reject_always")
|
|
19370
|
-
]),
|
|
19371
|
-
name: external_exports.string(),
|
|
19372
|
-
optionId: external_exports.string()
|
|
19373
|
-
});
|
|
19374
|
-
var toolCallContentSchema = external_exports.union([
|
|
19375
|
-
external_exports.object({
|
|
19376
|
-
content: external_exports.union([
|
|
19377
|
-
external_exports.object({
|
|
19378
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19379
|
-
annotations: annotationsSchema.optional().nullable(),
|
|
19380
|
-
text: external_exports.string(),
|
|
19381
|
-
type: external_exports.literal("text")
|
|
19382
|
-
}),
|
|
19383
|
-
external_exports.object({
|
|
19384
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19385
|
-
annotations: annotationsSchema.optional().nullable(),
|
|
19386
|
-
data: external_exports.string(),
|
|
19387
|
-
mimeType: external_exports.string(),
|
|
19388
|
-
type: external_exports.literal("image"),
|
|
19389
|
-
uri: external_exports.string().optional().nullable()
|
|
19390
|
-
}),
|
|
19391
|
-
external_exports.object({
|
|
19392
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19393
|
-
annotations: annotationsSchema.optional().nullable(),
|
|
19394
|
-
data: external_exports.string(),
|
|
19395
|
-
mimeType: external_exports.string(),
|
|
19396
|
-
type: external_exports.literal("audio")
|
|
19397
|
-
}),
|
|
19398
|
-
external_exports.object({
|
|
19399
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19400
|
-
annotations: annotationsSchema.optional().nullable(),
|
|
19401
|
-
description: external_exports.string().optional().nullable(),
|
|
19402
|
-
mimeType: external_exports.string().optional().nullable(),
|
|
19403
|
-
name: external_exports.string(),
|
|
19404
|
-
size: external_exports.number().optional().nullable(),
|
|
19405
|
-
title: external_exports.string().optional().nullable(),
|
|
19406
|
-
type: external_exports.literal("resource_link"),
|
|
19407
|
-
uri: external_exports.string()
|
|
19408
|
-
}),
|
|
19409
|
-
external_exports.object({
|
|
19410
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19411
|
-
annotations: annotationsSchema.optional().nullable(),
|
|
19412
|
-
resource: embeddedResourceResourceSchema,
|
|
19413
|
-
type: external_exports.literal("resource")
|
|
19414
|
-
})
|
|
19415
|
-
]),
|
|
19416
|
-
type: external_exports.literal("content")
|
|
19417
|
-
}),
|
|
19418
|
-
external_exports.object({
|
|
19419
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19420
|
-
newText: external_exports.string(),
|
|
19421
|
-
oldText: external_exports.string().optional().nullable(),
|
|
19422
|
-
path: external_exports.string(),
|
|
19423
|
-
type: external_exports.literal("diff")
|
|
19424
|
-
}),
|
|
19425
|
-
external_exports.object({
|
|
19426
|
-
terminalId: external_exports.string(),
|
|
19427
|
-
type: external_exports.literal("terminal")
|
|
19428
|
-
})
|
|
19429
|
-
]);
|
|
19430
|
-
var toolCallLocationSchema = external_exports.object({
|
|
19431
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19432
|
-
line: external_exports.number().optional().nullable(),
|
|
19433
|
-
path: external_exports.string()
|
|
19434
|
-
});
|
|
19435
|
-
var envVariableSchema = external_exports.object({
|
|
19436
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19437
|
-
name: external_exports.string(),
|
|
19438
|
-
value: external_exports.string()
|
|
19439
|
-
});
|
|
19440
|
-
var terminalExitStatusSchema = external_exports.object({
|
|
19441
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19442
|
-
exitCode: external_exports.number().optional().nullable(),
|
|
19443
|
-
signal: external_exports.string().optional().nullable()
|
|
19444
|
-
});
|
|
19445
|
-
var fileSystemCapabilitySchema = external_exports.object({
|
|
19446
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19447
|
-
readTextFile: external_exports.boolean().optional(),
|
|
19448
|
-
writeTextFile: external_exports.boolean().optional()
|
|
19449
|
-
});
|
|
19450
|
-
var stdioSchema = external_exports.object({
|
|
19451
|
-
args: external_exports.array(external_exports.string()),
|
|
19452
|
-
command: external_exports.string(),
|
|
19453
|
-
env: external_exports.array(envVariableSchema),
|
|
19454
|
-
name: external_exports.string()
|
|
19455
|
-
});
|
|
19456
|
-
var mcpServerSchema = external_exports.union([
|
|
19457
|
-
external_exports.object({
|
|
19458
|
-
headers: external_exports.array(httpHeaderSchema),
|
|
19459
|
-
name: external_exports.string(),
|
|
19460
|
-
type: external_exports.literal("http"),
|
|
19461
|
-
url: external_exports.string()
|
|
19462
|
-
}),
|
|
19463
|
-
external_exports.object({
|
|
19464
|
-
headers: external_exports.array(httpHeaderSchema),
|
|
19465
|
-
name: external_exports.string(),
|
|
19466
|
-
type: external_exports.literal("sse"),
|
|
19467
|
-
url: external_exports.string()
|
|
19468
|
-
}),
|
|
19469
|
-
stdioSchema
|
|
19470
|
-
]);
|
|
19471
|
-
var contentBlockSchema = external_exports.union([
|
|
19472
|
-
external_exports.object({
|
|
19473
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19474
|
-
annotations: annotationsSchema.optional().nullable(),
|
|
19475
|
-
text: external_exports.string(),
|
|
19476
|
-
type: external_exports.literal("text")
|
|
19477
|
-
}),
|
|
19478
|
-
external_exports.object({
|
|
19479
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19480
|
-
annotations: annotationsSchema.optional().nullable(),
|
|
19481
|
-
data: external_exports.string(),
|
|
19482
|
-
mimeType: external_exports.string(),
|
|
19483
|
-
type: external_exports.literal("image"),
|
|
19484
|
-
uri: external_exports.string().optional().nullable()
|
|
19485
|
-
}),
|
|
19486
|
-
external_exports.object({
|
|
19487
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19488
|
-
annotations: annotationsSchema.optional().nullable(),
|
|
19489
|
-
data: external_exports.string(),
|
|
19490
|
-
mimeType: external_exports.string(),
|
|
19491
|
-
type: external_exports.literal("audio")
|
|
19492
|
-
}),
|
|
19493
|
-
external_exports.object({
|
|
19494
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19495
|
-
annotations: annotationsSchema.optional().nullable(),
|
|
19496
|
-
description: external_exports.string().optional().nullable(),
|
|
19497
|
-
mimeType: external_exports.string().optional().nullable(),
|
|
19498
|
-
name: external_exports.string(),
|
|
19499
|
-
size: external_exports.number().optional().nullable(),
|
|
19500
|
-
title: external_exports.string().optional().nullable(),
|
|
19501
|
-
type: external_exports.literal("resource_link"),
|
|
19502
|
-
uri: external_exports.string()
|
|
19503
|
-
}),
|
|
19504
|
-
external_exports.object({
|
|
19505
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19506
|
-
annotations: annotationsSchema.optional().nullable(),
|
|
19507
|
-
resource: embeddedResourceResourceSchema,
|
|
19508
|
-
type: external_exports.literal("resource")
|
|
19509
|
-
})
|
|
19510
|
-
]);
|
|
19511
|
-
var authMethodSchema = external_exports.object({
|
|
19512
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19513
|
-
description: external_exports.string().optional().nullable(),
|
|
19514
|
-
id: external_exports.string(),
|
|
19515
|
-
name: external_exports.string()
|
|
19516
|
-
});
|
|
19517
|
-
var mcpCapabilitiesSchema = external_exports.object({
|
|
19518
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19519
|
-
http: external_exports.boolean().optional(),
|
|
19520
|
-
sse: external_exports.boolean().optional()
|
|
19521
|
-
});
|
|
19522
|
-
var promptCapabilitiesSchema = external_exports.object({
|
|
19523
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19524
|
-
audio: external_exports.boolean().optional(),
|
|
19525
|
-
embeddedContext: external_exports.boolean().optional(),
|
|
19526
|
-
image: external_exports.boolean().optional()
|
|
19527
|
-
});
|
|
19528
|
-
var modelInfoSchema = external_exports.object({
|
|
19529
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19530
|
-
description: external_exports.string().optional().nullable(),
|
|
19531
|
-
modelId: external_exports.string(),
|
|
19532
|
-
name: external_exports.string()
|
|
19533
|
-
});
|
|
19534
|
-
var sessionModeSchema = external_exports.object({
|
|
19535
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19536
|
-
description: external_exports.string().optional().nullable(),
|
|
19537
|
-
id: sessionModeIdSchema,
|
|
19538
|
-
name: external_exports.string()
|
|
19539
|
-
});
|
|
19540
|
-
var sessionModelStateSchema = external_exports.object({
|
|
19541
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19542
|
-
availableModels: external_exports.array(modelInfoSchema),
|
|
19543
|
-
currentModelId: external_exports.string()
|
|
19544
|
-
});
|
|
19545
|
-
var sessionModeStateSchema = external_exports.object({
|
|
19546
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19547
|
-
availableModes: external_exports.array(sessionModeSchema),
|
|
19548
|
-
currentModeId: external_exports.string()
|
|
19549
|
-
});
|
|
19550
|
-
var planEntrySchema = external_exports.object({
|
|
19551
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19552
|
-
content: external_exports.string(),
|
|
19553
|
-
priority: external_exports.union([external_exports.literal("high"), external_exports.literal("medium"), external_exports.literal("low")]),
|
|
19554
|
-
status: external_exports.union([
|
|
19555
|
-
external_exports.literal("pending"),
|
|
19556
|
-
external_exports.literal("in_progress"),
|
|
19557
|
-
external_exports.literal("completed")
|
|
19558
|
-
])
|
|
19559
|
-
});
|
|
19560
|
-
var availableCommandInputSchema = unstructuredCommandInputSchema;
|
|
19561
|
-
var clientNotificationSchema = external_exports.union([
|
|
19562
|
-
cancelNotificationSchema,
|
|
19563
|
-
extNotificationSchema
|
|
19564
|
-
]);
|
|
19565
|
-
var createTerminalRequestSchema = external_exports.object({
|
|
19566
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19567
|
-
args: external_exports.array(external_exports.string()).optional(),
|
|
19568
|
-
command: external_exports.string(),
|
|
19569
|
-
cwd: external_exports.string().optional().nullable(),
|
|
19570
|
-
env: external_exports.array(envVariableSchema).optional(),
|
|
19571
|
-
outputByteLimit: external_exports.number().optional().nullable(),
|
|
19572
|
-
sessionId: external_exports.string()
|
|
19573
|
-
});
|
|
19574
|
-
var terminalOutputResponseSchema = external_exports.object({
|
|
19575
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19576
|
-
exitStatus: terminalExitStatusSchema.optional().nullable(),
|
|
19577
|
-
output: external_exports.string(),
|
|
19578
|
-
truncated: external_exports.boolean()
|
|
19579
|
-
});
|
|
19580
|
-
var newSessionRequestSchema = external_exports.object({
|
|
19581
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19582
|
-
cwd: external_exports.string(),
|
|
19583
|
-
mcpServers: external_exports.array(mcpServerSchema)
|
|
19584
|
-
});
|
|
19585
|
-
var loadSessionRequestSchema = external_exports.object({
|
|
19586
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19587
|
-
cwd: external_exports.string(),
|
|
19588
|
-
mcpServers: external_exports.array(mcpServerSchema),
|
|
19589
|
-
sessionId: external_exports.string()
|
|
19590
|
-
});
|
|
19591
|
-
var promptRequestSchema = external_exports.object({
|
|
19592
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19593
|
-
prompt: external_exports.array(contentBlockSchema),
|
|
19594
|
-
sessionId: external_exports.string()
|
|
19595
|
-
});
|
|
19596
|
-
var newSessionResponseSchema = external_exports.object({
|
|
19597
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19598
|
-
models: sessionModelStateSchema.optional().nullable(),
|
|
19599
|
-
modes: sessionModeStateSchema.optional().nullable(),
|
|
19600
|
-
sessionId: external_exports.string()
|
|
19601
|
-
});
|
|
19602
|
-
var loadSessionResponseSchema = external_exports.object({
|
|
19603
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19604
|
-
models: sessionModelStateSchema.optional().nullable(),
|
|
19605
|
-
modes: sessionModeStateSchema.optional().nullable()
|
|
19606
|
-
});
|
|
19607
|
-
var toolCallUpdateSchema = external_exports.object({
|
|
19608
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19609
|
-
content: external_exports.array(toolCallContentSchema).optional().nullable(),
|
|
19610
|
-
kind: toolKindSchema.optional().nullable(),
|
|
19611
|
-
locations: external_exports.array(toolCallLocationSchema).optional().nullable(),
|
|
19612
|
-
rawInput: external_exports.record(external_exports.unknown()).optional(),
|
|
19613
|
-
rawOutput: external_exports.record(external_exports.unknown()).optional(),
|
|
19614
|
-
status: toolCallStatusSchema.optional().nullable(),
|
|
19615
|
-
title: external_exports.string().optional().nullable(),
|
|
19616
|
-
toolCallId: external_exports.string()
|
|
19617
|
-
});
|
|
19618
|
-
var clientCapabilitiesSchema = external_exports.object({
|
|
19619
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19620
|
-
fs: fileSystemCapabilitySchema.optional(),
|
|
19621
|
-
terminal: external_exports.boolean().optional()
|
|
19622
|
-
});
|
|
19623
|
-
var agentCapabilitiesSchema = external_exports.object({
|
|
19624
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19625
|
-
loadSession: external_exports.boolean().optional(),
|
|
19626
|
-
mcpCapabilities: mcpCapabilitiesSchema.optional(),
|
|
19627
|
-
promptCapabilities: promptCapabilitiesSchema.optional()
|
|
19628
|
-
});
|
|
19629
|
-
var availableCommandSchema = external_exports.object({
|
|
19630
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19631
|
-
description: external_exports.string(),
|
|
19632
|
-
input: availableCommandInputSchema.optional().nullable(),
|
|
19633
|
-
name: external_exports.string()
|
|
19634
|
-
});
|
|
19635
|
-
var clientResponseSchema = external_exports.union([
|
|
19636
|
-
writeTextFileResponseSchema,
|
|
19637
|
-
readTextFileResponseSchema,
|
|
19638
|
-
requestPermissionResponseSchema,
|
|
19639
|
-
createTerminalResponseSchema,
|
|
19640
|
-
terminalOutputResponseSchema,
|
|
19641
|
-
releaseTerminalResponseSchema,
|
|
19642
|
-
waitForTerminalExitResponseSchema,
|
|
19643
|
-
killTerminalResponseSchema,
|
|
19644
|
-
extMethodResponseSchema
|
|
19645
|
-
]);
|
|
19646
|
-
var requestPermissionRequestSchema = external_exports.object({
|
|
19647
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19648
|
-
options: external_exports.array(permissionOptionSchema),
|
|
19649
|
-
sessionId: external_exports.string(),
|
|
19650
|
-
toolCall: toolCallUpdateSchema
|
|
19651
|
-
});
|
|
19652
|
-
var initializeRequestSchema = external_exports.object({
|
|
19653
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19654
|
-
clientCapabilities: clientCapabilitiesSchema.optional(),
|
|
19655
|
-
protocolVersion: external_exports.number()
|
|
19656
|
-
});
|
|
19657
|
-
var initializeResponseSchema = external_exports.object({
|
|
19658
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19659
|
-
agentCapabilities: agentCapabilitiesSchema.optional(),
|
|
19660
|
-
authMethods: external_exports.array(authMethodSchema).optional(),
|
|
19661
|
-
protocolVersion: external_exports.number()
|
|
19662
|
-
});
|
|
19663
|
-
var sessionNotificationSchema = external_exports.object({
|
|
19664
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19665
|
-
sessionId: external_exports.string(),
|
|
19666
|
-
update: external_exports.union([
|
|
19667
|
-
external_exports.object({
|
|
19668
|
-
content: contentBlockSchema,
|
|
19669
|
-
sessionUpdate: external_exports.literal("user_message_chunk")
|
|
19670
|
-
}),
|
|
19671
|
-
external_exports.object({
|
|
19672
|
-
content: contentBlockSchema,
|
|
19673
|
-
sessionUpdate: external_exports.literal("agent_message_chunk")
|
|
19674
|
-
}),
|
|
19675
|
-
external_exports.object({
|
|
19676
|
-
content: contentBlockSchema,
|
|
19677
|
-
sessionUpdate: external_exports.literal("agent_thought_chunk")
|
|
19678
|
-
}),
|
|
19679
|
-
external_exports.object({
|
|
19680
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19681
|
-
content: external_exports.array(toolCallContentSchema).optional(),
|
|
19682
|
-
kind: external_exports.union([
|
|
19683
|
-
external_exports.literal("read"),
|
|
19684
|
-
external_exports.literal("edit"),
|
|
19685
|
-
external_exports.literal("delete"),
|
|
19686
|
-
external_exports.literal("move"),
|
|
19687
|
-
external_exports.literal("search"),
|
|
19688
|
-
external_exports.literal("execute"),
|
|
19689
|
-
external_exports.literal("think"),
|
|
19690
|
-
external_exports.literal("fetch"),
|
|
19691
|
-
external_exports.literal("switch_mode"),
|
|
19692
|
-
external_exports.literal("other")
|
|
19693
|
-
]).optional(),
|
|
19694
|
-
locations: external_exports.array(toolCallLocationSchema).optional(),
|
|
19695
|
-
rawInput: external_exports.record(external_exports.unknown()).optional(),
|
|
19696
|
-
rawOutput: external_exports.record(external_exports.unknown()).optional(),
|
|
19697
|
-
sessionUpdate: external_exports.literal("tool_call"),
|
|
19698
|
-
status: external_exports.union([
|
|
19699
|
-
external_exports.literal("pending"),
|
|
19700
|
-
external_exports.literal("in_progress"),
|
|
19701
|
-
external_exports.literal("completed"),
|
|
19702
|
-
external_exports.literal("failed")
|
|
19703
|
-
]).optional(),
|
|
19704
|
-
title: external_exports.string(),
|
|
19705
|
-
toolCallId: external_exports.string()
|
|
19706
|
-
}),
|
|
19707
|
-
external_exports.object({
|
|
19708
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19709
|
-
content: external_exports.array(toolCallContentSchema).optional().nullable(),
|
|
19710
|
-
kind: toolKindSchema.optional().nullable(),
|
|
19711
|
-
locations: external_exports.array(toolCallLocationSchema).optional().nullable(),
|
|
19712
|
-
rawInput: external_exports.record(external_exports.unknown()).optional(),
|
|
19713
|
-
rawOutput: external_exports.record(external_exports.unknown()).optional(),
|
|
19714
|
-
sessionUpdate: external_exports.literal("tool_call_update"),
|
|
19715
|
-
status: toolCallStatusSchema.optional().nullable(),
|
|
19716
|
-
title: external_exports.string().optional().nullable(),
|
|
19717
|
-
toolCallId: external_exports.string()
|
|
19718
|
-
}),
|
|
19719
|
-
external_exports.object({
|
|
19720
|
-
_meta: external_exports.record(external_exports.unknown()).optional(),
|
|
19721
|
-
entries: external_exports.array(planEntrySchema),
|
|
19722
|
-
sessionUpdate: external_exports.literal("plan")
|
|
19723
|
-
}),
|
|
19724
|
-
external_exports.object({
|
|
19725
|
-
availableCommands: external_exports.array(availableCommandSchema),
|
|
19726
|
-
sessionUpdate: external_exports.literal("available_commands_update")
|
|
19727
|
-
}),
|
|
19728
|
-
external_exports.object({
|
|
19729
|
-
currentModeId: sessionModeIdSchema,
|
|
19730
|
-
sessionUpdate: external_exports.literal("current_mode_update")
|
|
19731
|
-
})
|
|
19732
|
-
])
|
|
19733
|
-
});
|
|
19734
|
-
var clientRequestSchema = external_exports.union([
|
|
19735
|
-
writeTextFileRequestSchema,
|
|
19736
|
-
readTextFileRequestSchema,
|
|
19737
|
-
requestPermissionRequestSchema,
|
|
19738
|
-
createTerminalRequestSchema,
|
|
19739
|
-
terminalOutputRequestSchema,
|
|
19740
|
-
releaseTerminalRequestSchema,
|
|
19741
|
-
waitForTerminalExitRequestSchema,
|
|
19742
|
-
killTerminalCommandRequestSchema,
|
|
19743
|
-
extMethodRequestSchema
|
|
19744
|
-
]);
|
|
19745
|
-
var agentRequestSchema = external_exports.union([
|
|
19746
|
-
initializeRequestSchema,
|
|
19747
|
-
authenticateRequestSchema,
|
|
19748
|
-
newSessionRequestSchema,
|
|
19749
|
-
loadSessionRequestSchema,
|
|
19750
|
-
setSessionModeRequestSchema,
|
|
19751
|
-
promptRequestSchema,
|
|
19752
|
-
setSessionModelRequestSchema,
|
|
19753
|
-
extMethodRequest1Schema
|
|
19754
|
-
]);
|
|
19755
|
-
var agentResponseSchema = external_exports.union([
|
|
19756
|
-
initializeResponseSchema,
|
|
19757
|
-
authenticateResponseSchema,
|
|
19758
|
-
newSessionResponseSchema,
|
|
19759
|
-
loadSessionResponseSchema,
|
|
19760
|
-
setSessionModeResponseSchema,
|
|
19761
|
-
promptResponseSchema,
|
|
19762
|
-
setSessionModelResponseSchema,
|
|
19763
|
-
extMethodResponse1Schema
|
|
19764
|
-
]);
|
|
19765
|
-
var agentNotificationSchema = external_exports.union([
|
|
19766
|
-
sessionNotificationSchema,
|
|
19767
|
-
extNotification1Schema
|
|
19768
|
-
]);
|
|
19769
|
-
var agentClientProtocolSchema = external_exports.union([
|
|
19770
|
-
clientRequestSchema,
|
|
19771
|
-
clientResponseSchema,
|
|
19772
|
-
clientNotificationSchema,
|
|
19773
|
-
agentRequestSchema,
|
|
19774
|
-
agentResponseSchema,
|
|
19775
|
-
agentNotificationSchema
|
|
19776
|
-
]);
|
|
18935
|
+
// ../acp/dist/connection.js
|
|
18936
|
+
var import_node_fs2 = require("node:fs");
|
|
18937
|
+
var import_node_path = require("node:path");
|
|
19777
18938
|
|
|
19778
18939
|
// ../acp/dist/skill.js
|
|
19779
18940
|
var SKILL_NAME_PATTERN = /^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9]))*$/;
|
|
19780
|
-
var MAX_NAME_LENGTH = 64;
|
|
19781
|
-
var MAX_DESCRIPTION_LENGTH = 1024;
|
|
19782
18941
|
function validateSkillName(name) {
|
|
19783
|
-
if (typeof name
|
|
18942
|
+
if (typeof name != "string" || name.length === 0)
|
|
19784
18943
|
throw new Error("Skill name is required");
|
|
19785
|
-
|
|
19786
|
-
|
|
19787
|
-
|
|
19788
|
-
}
|
|
19789
|
-
if (!SKILL_NAME_PATTERN.test(name)) {
|
|
18944
|
+
if (name.length > 64)
|
|
18945
|
+
throw new Error(`Skill name must be at most 64 characters, got ${name.length}`);
|
|
18946
|
+
if (!SKILL_NAME_PATTERN.test(name))
|
|
19790
18947
|
throw new Error(`Invalid skill name "${name}": must be lowercase alphanumeric with hyphens, no leading/trailing/consecutive hyphens`);
|
|
19791
|
-
}
|
|
19792
18948
|
}
|
|
19793
18949
|
__name(validateSkillName, "validateSkillName");
|
|
19794
18950
|
function validateSkillDescription(description) {
|
|
19795
|
-
if (typeof description
|
|
18951
|
+
if (typeof description != "string" || description.trim().length === 0)
|
|
19796
18952
|
throw new Error("Skill description is required");
|
|
19797
|
-
|
|
19798
|
-
|
|
19799
|
-
throw new Error(`Skill description must be at most ${MAX_DESCRIPTION_LENGTH} characters, got ${description.length}`);
|
|
19800
|
-
}
|
|
18953
|
+
if (description.length > 1024)
|
|
18954
|
+
throw new Error(`Skill description must be at most 1024 characters, got ${description.length}`);
|
|
19801
18955
|
}
|
|
19802
18956
|
__name(validateSkillDescription, "validateSkillDescription");
|
|
19803
18957
|
function parseSkillMd(content) {
|
|
19804
|
-
const { frontmatter, body } = extractFrontmatter(content);
|
|
19805
|
-
|
|
19806
|
-
validateSkillName(fields.name);
|
|
19807
|
-
validateSkillDescription(fields.description);
|
|
19808
|
-
return {
|
|
18958
|
+
const { frontmatter, body } = extractFrontmatter(content), fields = parseYamlFrontmatter(frontmatter);
|
|
18959
|
+
return validateSkillName(fields.name), validateSkillDescription(fields.description), {
|
|
19809
18960
|
...fields,
|
|
19810
18961
|
name: fields.name,
|
|
19811
18962
|
description: fields.description,
|
|
@@ -19815,37 +18966,29 @@ function parseSkillMd(content) {
|
|
|
19815
18966
|
__name(parseSkillMd, "parseSkillMd");
|
|
19816
18967
|
function extractFrontmatter(content) {
|
|
19817
18968
|
const trimmed = content.trimStart();
|
|
19818
|
-
if (!trimmed.startsWith("---"))
|
|
18969
|
+
if (!trimmed.startsWith("---"))
|
|
19819
18970
|
throw new Error("SKILL.md must begin with YAML frontmatter (---)");
|
|
19820
|
-
|
|
19821
|
-
|
|
19822
|
-
if (endIndex === -1)
|
|
18971
|
+
const endIndex = trimmed.indexOf(`
|
|
18972
|
+
---`, 3);
|
|
18973
|
+
if (endIndex === -1)
|
|
19823
18974
|
throw new Error("SKILL.md frontmatter is missing closing ---");
|
|
19824
|
-
}
|
|
19825
|
-
const frontmatter = trimmed.slice(3, endIndex).trim();
|
|
19826
|
-
const afterClosing = endIndex + 4;
|
|
19827
|
-
const body = trimmed.slice(afterClosing).replace(/^(\r?\n){1,2}/, "");
|
|
18975
|
+
const frontmatter = trimmed.slice(3, endIndex).trim(), afterClosing = endIndex + 4, body = trimmed.slice(afterClosing).replace(/^(\r?\n){1,2}/, "");
|
|
19828
18976
|
return { frontmatter, body };
|
|
19829
18977
|
}
|
|
19830
18978
|
__name(extractFrontmatter, "extractFrontmatter");
|
|
19831
18979
|
function parseYamlFrontmatter(yaml) {
|
|
19832
18980
|
const result = {};
|
|
19833
|
-
for (const line of yaml.split(
|
|
18981
|
+
for (const line of yaml.split(`
|
|
18982
|
+
`)) {
|
|
19834
18983
|
const trimmed = line.trim();
|
|
19835
18984
|
if (trimmed === "" || trimmed.startsWith("#"))
|
|
19836
18985
|
continue;
|
|
19837
18986
|
const colonIndex = trimmed.indexOf(":");
|
|
19838
|
-
if (colonIndex === -1)
|
|
18987
|
+
if (colonIndex === -1)
|
|
19839
18988
|
throw new Error(`Invalid frontmatter line: ${trimmed}`);
|
|
19840
|
-
}
|
|
19841
18989
|
const key = trimmed.slice(0, colonIndex).trim();
|
|
19842
18990
|
let value = trimmed.slice(colonIndex + 1).trim();
|
|
19843
|
-
|
|
19844
|
-
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
19845
|
-
value = value.slice(1, -1);
|
|
19846
|
-
}
|
|
19847
|
-
}
|
|
19848
|
-
result[key] = value;
|
|
18991
|
+
typeof value == "string" && (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) && (value = value.slice(1, -1)), result[key] = value;
|
|
19849
18992
|
}
|
|
19850
18993
|
return result;
|
|
19851
18994
|
}
|
|
@@ -19853,16 +18996,15 @@ __name(parseYamlFrontmatter, "parseYamlFrontmatter");
|
|
|
19853
18996
|
|
|
19854
18997
|
// ../acp/dist/skill-server.js
|
|
19855
18998
|
var import_promises = require("node:fs/promises");
|
|
19856
|
-
var
|
|
18999
|
+
var import_node_path2 = require("node:path");
|
|
19857
19000
|
function isStoredSkill(skill) {
|
|
19858
|
-
return "basePath" in skill && typeof skill.basePath
|
|
19001
|
+
return "basePath" in skill && typeof skill.basePath == "string";
|
|
19859
19002
|
}
|
|
19860
19003
|
__name(isStoredSkill, "isStoredSkill");
|
|
19861
19004
|
function createSkillServer(skills) {
|
|
19862
19005
|
const skillsByName = /* @__PURE__ */ new Map();
|
|
19863
|
-
for (const skill of skills)
|
|
19006
|
+
for (const skill of skills)
|
|
19864
19007
|
skillsByName.set(skill.name, skill);
|
|
19865
|
-
}
|
|
19866
19008
|
return mcpServer("skills").tool("activate_skill", "Activate a skill by name, returning its full instructions.", {
|
|
19867
19009
|
type: "object",
|
|
19868
19010
|
properties: {
|
|
@@ -19871,9 +19013,8 @@ function createSkillServer(skills) {
|
|
|
19871
19013
|
required: ["skill_name"]
|
|
19872
19014
|
}, { type: "string" }, async (input) => {
|
|
19873
19015
|
const skill = skillsByName.get(input.skill_name);
|
|
19874
|
-
if (!skill)
|
|
19016
|
+
if (!skill)
|
|
19875
19017
|
throw new Error(`Unknown skill: "${input.skill_name}"`);
|
|
19876
|
-
}
|
|
19877
19018
|
return skill.body;
|
|
19878
19019
|
}).tool("call_skill_tool", "Call a tool provided by a skill.", {
|
|
19879
19020
|
type: "object",
|
|
@@ -19885,17 +19026,14 @@ function createSkillServer(skills) {
|
|
|
19885
19026
|
required: ["skill_name", "tool_name"]
|
|
19886
19027
|
}, {}, async (input) => {
|
|
19887
19028
|
const skill = skillsByName.get(input.skill_name);
|
|
19888
|
-
if (!skill)
|
|
19029
|
+
if (!skill)
|
|
19889
19030
|
throw new Error(`Unknown skill: "${input.skill_name}"`);
|
|
19890
|
-
}
|
|
19891
19031
|
const tools = skill.tools;
|
|
19892
|
-
if (!tools || tools.length === 0)
|
|
19032
|
+
if (!tools || tools.length === 0)
|
|
19893
19033
|
throw new Error(`Skill "${input.skill_name}" has no tools`);
|
|
19894
|
-
}
|
|
19895
19034
|
const tool = tools.find((t) => t.name === input.tool_name);
|
|
19896
|
-
if (!tool)
|
|
19035
|
+
if (!tool)
|
|
19897
19036
|
throw new Error(`Unknown tool "${input.tool_name}" for skill "${input.skill_name}"`);
|
|
19898
|
-
}
|
|
19899
19037
|
return tool.handler(input.input);
|
|
19900
19038
|
}).tool("read_skill_file", "Read a file from a stored skill's directory.", {
|
|
19901
19039
|
type: "object",
|
|
@@ -19906,28 +19044,30 @@ function createSkillServer(skills) {
|
|
|
19906
19044
|
required: ["skill_name", "path"]
|
|
19907
19045
|
}, { type: "string" }, async (input) => {
|
|
19908
19046
|
const skill = skillsByName.get(input.skill_name);
|
|
19909
|
-
if (!skill)
|
|
19047
|
+
if (!skill)
|
|
19910
19048
|
throw new Error(`Unknown skill: "${input.skill_name}"`);
|
|
19911
|
-
|
|
19912
|
-
if (!isStoredSkill(skill)) {
|
|
19049
|
+
if (!isStoredSkill(skill))
|
|
19913
19050
|
throw new Error(`Skill "${input.skill_name}" is not a stored skill (no basePath)`);
|
|
19914
|
-
|
|
19915
|
-
if ((0, import_node_path.isAbsolute)(input.path)) {
|
|
19051
|
+
if ((0, import_node_path2.isAbsolute)(input.path))
|
|
19916
19052
|
throw new Error("Path must be relative");
|
|
19917
|
-
|
|
19918
|
-
|
|
19919
|
-
const rel = (0, import_node_path.relative)(skill.basePath, resolved);
|
|
19920
|
-
if (rel.startsWith("..") || (0, import_node_path.isAbsolute)(rel)) {
|
|
19053
|
+
const resolved = (0, import_node_path2.resolve)(skill.basePath, input.path), rel = (0, import_node_path2.relative)(skill.basePath, resolved);
|
|
19054
|
+
if (rel.startsWith("..") || (0, import_node_path2.isAbsolute)(rel))
|
|
19921
19055
|
throw new Error("Path traversal is not allowed");
|
|
19922
|
-
}
|
|
19923
19056
|
return (0, import_promises.readFile)(resolved, "utf-8");
|
|
19924
19057
|
}).build();
|
|
19925
19058
|
}
|
|
19926
19059
|
__name(createSkillServer, "createSkillServer");
|
|
19927
19060
|
|
|
19061
|
+
// dist/generated/features.js
|
|
19062
|
+
var features2 = {
|
|
19063
|
+
FAULT_INJECTION: false,
|
|
19064
|
+
LOG_PERMISSIONS: false,
|
|
19065
|
+
STRIP_CLAUDECODE_ENV: true
|
|
19066
|
+
};
|
|
19067
|
+
|
|
19928
19068
|
// dist/think-builder.js
|
|
19929
19069
|
var import_promises2 = require("node:fs/promises");
|
|
19930
|
-
var
|
|
19070
|
+
var import_node_path3 = require("node:path");
|
|
19931
19071
|
|
|
19932
19072
|
// dist/thought-stream.js
|
|
19933
19073
|
var ThoughtStream = class {
|
|
@@ -19943,8 +19083,7 @@ var ThoughtStream = class {
|
|
|
19943
19083
|
_done = false;
|
|
19944
19084
|
constructor() {
|
|
19945
19085
|
this.result = new Promise((resolve2, reject) => {
|
|
19946
|
-
this._resolveResult = resolve2;
|
|
19947
|
-
this._rejectResult = reject;
|
|
19086
|
+
this._resolveResult = resolve2, this._rejectResult = reject;
|
|
19948
19087
|
});
|
|
19949
19088
|
}
|
|
19950
19089
|
/**
|
|
@@ -19952,27 +19091,19 @@ var ThoughtStream = class {
|
|
|
19952
19091
|
* @internal
|
|
19953
19092
|
*/
|
|
19954
19093
|
pushEvent(event) {
|
|
19955
|
-
|
|
19956
|
-
return;
|
|
19957
|
-
if (this._eventResolvers.length > 0) {
|
|
19958
|
-
const resolver = this._eventResolvers.shift();
|
|
19959
|
-
resolver({ value: event, done: false });
|
|
19960
|
-
} else {
|
|
19961
|
-
this._pendingEvents.push(event);
|
|
19962
|
-
}
|
|
19094
|
+
this._done || (this._eventResolvers.length > 0 ? this._eventResolvers.shift()({ value: event, done: false }) : this._pendingEvents.push(event));
|
|
19963
19095
|
}
|
|
19964
19096
|
/**
|
|
19965
19097
|
* Signal that no more events will arrive. Flushes waiting consumers.
|
|
19966
19098
|
* @internal
|
|
19967
19099
|
*/
|
|
19968
19100
|
close() {
|
|
19969
|
-
if (this._done)
|
|
19970
|
-
|
|
19971
|
-
|
|
19972
|
-
|
|
19973
|
-
|
|
19101
|
+
if (!this._done) {
|
|
19102
|
+
this._done = true;
|
|
19103
|
+
for (const resolver of this._eventResolvers)
|
|
19104
|
+
resolver({ value: void 0, done: true });
|
|
19105
|
+
this._eventResolvers = [];
|
|
19974
19106
|
}
|
|
19975
|
-
this._eventResolvers = [];
|
|
19976
19107
|
}
|
|
19977
19108
|
/**
|
|
19978
19109
|
* Resolve the result promise.
|
|
@@ -19990,28 +19121,17 @@ var ThoughtStream = class {
|
|
|
19990
19121
|
}
|
|
19991
19122
|
[Symbol.asyncIterator]() {
|
|
19992
19123
|
return {
|
|
19993
|
-
next: /* @__PURE__ */ __name(() => {
|
|
19994
|
-
|
|
19995
|
-
|
|
19996
|
-
|
|
19997
|
-
|
|
19998
|
-
|
|
19999
|
-
}
|
|
20000
|
-
if (this._done) {
|
|
20001
|
-
return Promise.resolve({ value: void 0, done: true });
|
|
20002
|
-
}
|
|
20003
|
-
return new Promise((resolve2) => {
|
|
20004
|
-
this._eventResolvers.push(resolve2);
|
|
20005
|
-
});
|
|
20006
|
-
}, "next"),
|
|
19124
|
+
next: /* @__PURE__ */ __name(() => this._pendingEvents.length > 0 ? Promise.resolve({
|
|
19125
|
+
value: this._pendingEvents.shift(),
|
|
19126
|
+
done: false
|
|
19127
|
+
}) : this._done ? Promise.resolve({ value: void 0, done: true }) : new Promise((resolve2) => {
|
|
19128
|
+
this._eventResolvers.push(resolve2);
|
|
19129
|
+
}), "next"),
|
|
20007
19130
|
return: /* @__PURE__ */ __name(() => {
|
|
20008
|
-
this._done = true;
|
|
20009
|
-
this.
|
|
20010
|
-
for (const resolver of this._eventResolvers) {
|
|
19131
|
+
this._done = true, this._pendingEvents = [];
|
|
19132
|
+
for (const resolver of this._eventResolvers)
|
|
20011
19133
|
resolver({ value: void 0, done: true });
|
|
20012
|
-
}
|
|
20013
|
-
this._eventResolvers = [];
|
|
20014
|
-
return Promise.resolve({ value: void 0, done: true });
|
|
19134
|
+
return this._eventResolvers = [], Promise.resolve({ value: void 0, done: true });
|
|
20015
19135
|
}, "return")
|
|
20016
19136
|
};
|
|
20017
19137
|
}
|
|
@@ -20028,45 +19148,30 @@ var ThinkSession = class {
|
|
|
20028
19148
|
_updateResolvers = [];
|
|
20029
19149
|
_closed = false;
|
|
20030
19150
|
constructor(sessionId, conn) {
|
|
20031
|
-
this.sessionId = sessionId;
|
|
20032
|
-
this._conn = conn;
|
|
19151
|
+
this.sessionId = sessionId, this._conn = conn;
|
|
20033
19152
|
}
|
|
20034
19153
|
async sendPrompt(content) {
|
|
20035
19154
|
const response = await this._conn.connection.prompt({
|
|
20036
19155
|
sessionId: this.sessionId,
|
|
20037
19156
|
prompt: [{ type: "text", text: content }]
|
|
20038
19157
|
});
|
|
20039
|
-
|
|
20040
|
-
this._pushInternal({ type: "stop", reason: response.stopReason });
|
|
20041
|
-
}
|
|
19158
|
+
response.stopReason && this._pushInternal({ type: "stop", reason: response.stopReason });
|
|
20042
19159
|
}
|
|
20043
19160
|
pushUpdate(update) {
|
|
20044
19161
|
this._pushInternal(update);
|
|
20045
19162
|
}
|
|
20046
19163
|
_pushInternal(update) {
|
|
20047
|
-
|
|
20048
|
-
const resolver = this._updateResolvers.shift();
|
|
20049
|
-
resolver(update);
|
|
20050
|
-
} else {
|
|
20051
|
-
this._pendingUpdates.push(update);
|
|
20052
|
-
}
|
|
19164
|
+
this._updateResolvers.length > 0 ? this._updateResolvers.shift()(update) : this._pendingUpdates.push(update);
|
|
20053
19165
|
}
|
|
20054
19166
|
async readUpdate() {
|
|
20055
|
-
|
|
20056
|
-
return this._pendingUpdates.shift();
|
|
20057
|
-
}
|
|
20058
|
-
if (this._closed) {
|
|
20059
|
-
return { type: "stop", reason: "session_closed" };
|
|
20060
|
-
}
|
|
20061
|
-
return new Promise((resolve2) => {
|
|
19167
|
+
return this._pendingUpdates.length > 0 ? this._pendingUpdates.shift() : this._closed ? { type: "stop", reason: "session_closed" } : new Promise((resolve2) => {
|
|
20062
19168
|
this._updateResolvers.push(resolve2);
|
|
20063
19169
|
});
|
|
20064
19170
|
}
|
|
20065
19171
|
close() {
|
|
20066
19172
|
this._closed = true;
|
|
20067
|
-
for (const resolver of this._updateResolvers)
|
|
19173
|
+
for (const resolver of this._updateResolvers)
|
|
20068
19174
|
resolver({ type: "stop", reason: "session_closed" });
|
|
20069
|
-
}
|
|
20070
19175
|
this._updateResolvers = [];
|
|
20071
19176
|
}
|
|
20072
19177
|
};
|
|
@@ -20082,13 +19187,7 @@ var PlanImpl = class _PlanImpl {
|
|
|
20082
19187
|
_cwd;
|
|
20083
19188
|
_existingSessionId;
|
|
20084
19189
|
constructor(state) {
|
|
20085
|
-
this._conn = state.conn;
|
|
20086
|
-
this._promptParts = state.promptParts;
|
|
20087
|
-
this._tools = state.tools;
|
|
20088
|
-
this._skills = state.skills;
|
|
20089
|
-
this._schemaProvider = state.schemaProvider;
|
|
20090
|
-
this._cwd = state.cwd;
|
|
20091
|
-
this._existingSessionId = state.existingSessionId;
|
|
19190
|
+
this._conn = state.conn, this._promptParts = state.promptParts, this._tools = state.tools, this._skills = state.skills, this._schemaProvider = state.schemaProvider, this._cwd = state.cwd, this._existingSessionId = state.existingSessionId;
|
|
20092
19191
|
}
|
|
20093
19192
|
_clone(overrides) {
|
|
20094
19193
|
return new _PlanImpl({
|
|
@@ -20106,13 +19205,15 @@ var PlanImpl = class _PlanImpl {
|
|
|
20106
19205
|
return this._clone({ promptParts: [...this._promptParts, content] });
|
|
20107
19206
|
}
|
|
20108
19207
|
textln(content) {
|
|
20109
|
-
return this._clone({ promptParts: [...this._promptParts, content +
|
|
19208
|
+
return this._clone({ promptParts: [...this._promptParts, content + `
|
|
19209
|
+
`] });
|
|
20110
19210
|
}
|
|
20111
19211
|
quote(content, tag = "quote") {
|
|
20112
|
-
const part =
|
|
20113
|
-
`
|
|
19212
|
+
const part = content.includes(`
|
|
19213
|
+
`) ? `<${tag}>
|
|
20114
19214
|
${content}
|
|
20115
19215
|
</${tag}>
|
|
19216
|
+
` : `<${tag}>${content}</${tag}>
|
|
20116
19217
|
`;
|
|
20117
19218
|
return this._clone({ promptParts: [...this._promptParts, part] });
|
|
20118
19219
|
}
|
|
@@ -20125,233 +19226,210 @@ ${content}
|
|
|
20125
19226
|
});
|
|
20126
19227
|
}
|
|
20127
19228
|
tool(name, description, inputSchemaOrHandler, outputSchemaOrHandler, handler) {
|
|
20128
|
-
let inputSchema;
|
|
20129
|
-
|
|
20130
|
-
let actualHandler;
|
|
20131
|
-
if (typeof inputSchemaOrHandler === "function") {
|
|
20132
|
-
inputSchema = { toJsonSchema: /* @__PURE__ */ __name(() => ({ type: "object" }), "toJsonSchema") };
|
|
20133
|
-
outputSchema = { toJsonSchema: /* @__PURE__ */ __name(() => ({ type: "object" }), "toJsonSchema") };
|
|
20134
|
-
actualHandler = inputSchemaOrHandler;
|
|
20135
|
-
} else if (typeof outputSchemaOrHandler === "function") {
|
|
20136
|
-
inputSchema = inputSchemaOrHandler;
|
|
20137
|
-
outputSchema = { toJsonSchema: /* @__PURE__ */ __name(() => ({ type: "object" }), "toJsonSchema") };
|
|
20138
|
-
actualHandler = outputSchemaOrHandler;
|
|
20139
|
-
} else {
|
|
20140
|
-
inputSchema = inputSchemaOrHandler;
|
|
20141
|
-
outputSchema = outputSchemaOrHandler;
|
|
20142
|
-
actualHandler = handler;
|
|
20143
|
-
}
|
|
19229
|
+
let inputSchema, outputSchema, actualHandler;
|
|
19230
|
+
typeof inputSchemaOrHandler == "function" ? (inputSchema = { toJsonSchema: /* @__PURE__ */ __name(() => ({ type: "object" }), "toJsonSchema") }, outputSchema = { toJsonSchema: /* @__PURE__ */ __name(() => ({ type: "object" }), "toJsonSchema") }, actualHandler = inputSchemaOrHandler) : typeof outputSchemaOrHandler == "function" ? (inputSchema = inputSchemaOrHandler, outputSchema = { toJsonSchema: /* @__PURE__ */ __name(() => ({ type: "object" }), "toJsonSchema") }, actualHandler = outputSchemaOrHandler) : (inputSchema = inputSchemaOrHandler, outputSchema = outputSchemaOrHandler, actualHandler = handler);
|
|
20144
19231
|
const newTools = new Map(this._tools);
|
|
20145
|
-
newTools.set(name, {
|
|
19232
|
+
return newTools.set(name, {
|
|
20146
19233
|
name,
|
|
20147
19234
|
description,
|
|
20148
19235
|
handler: actualHandler,
|
|
20149
19236
|
inputSchema,
|
|
20150
19237
|
outputSchema,
|
|
20151
19238
|
includeInPrompt: true
|
|
20152
|
-
});
|
|
20153
|
-
return this._clone({ tools: newTools });
|
|
19239
|
+
}), this._clone({ tools: newTools });
|
|
20154
19240
|
}
|
|
20155
19241
|
defineTool(name, description, inputSchemaOrHandler, outputSchemaOrHandler, handler) {
|
|
20156
|
-
let inputSchema;
|
|
20157
|
-
|
|
20158
|
-
let actualHandler;
|
|
20159
|
-
if (typeof inputSchemaOrHandler === "function") {
|
|
20160
|
-
inputSchema = { toJsonSchema: /* @__PURE__ */ __name(() => ({ type: "object" }), "toJsonSchema") };
|
|
20161
|
-
outputSchema = { toJsonSchema: /* @__PURE__ */ __name(() => ({ type: "object" }), "toJsonSchema") };
|
|
20162
|
-
actualHandler = inputSchemaOrHandler;
|
|
20163
|
-
} else if (typeof outputSchemaOrHandler === "function") {
|
|
20164
|
-
inputSchema = inputSchemaOrHandler;
|
|
20165
|
-
outputSchema = { toJsonSchema: /* @__PURE__ */ __name(() => ({ type: "object" }), "toJsonSchema") };
|
|
20166
|
-
actualHandler = outputSchemaOrHandler;
|
|
20167
|
-
} else {
|
|
20168
|
-
inputSchema = inputSchemaOrHandler;
|
|
20169
|
-
outputSchema = outputSchemaOrHandler;
|
|
20170
|
-
actualHandler = handler;
|
|
20171
|
-
}
|
|
19242
|
+
let inputSchema, outputSchema, actualHandler;
|
|
19243
|
+
typeof inputSchemaOrHandler == "function" ? (inputSchema = { toJsonSchema: /* @__PURE__ */ __name(() => ({ type: "object" }), "toJsonSchema") }, outputSchema = { toJsonSchema: /* @__PURE__ */ __name(() => ({ type: "object" }), "toJsonSchema") }, actualHandler = inputSchemaOrHandler) : typeof outputSchemaOrHandler == "function" ? (inputSchema = inputSchemaOrHandler, outputSchema = { toJsonSchema: /* @__PURE__ */ __name(() => ({ type: "object" }), "toJsonSchema") }, actualHandler = outputSchemaOrHandler) : (inputSchema = inputSchemaOrHandler, outputSchema = outputSchemaOrHandler, actualHandler = handler);
|
|
20172
19244
|
const newTools = new Map(this._tools);
|
|
20173
|
-
newTools.set(name, {
|
|
19245
|
+
return newTools.set(name, {
|
|
20174
19246
|
name,
|
|
20175
19247
|
description,
|
|
20176
19248
|
handler: actualHandler,
|
|
20177
19249
|
inputSchema,
|
|
20178
19250
|
outputSchema,
|
|
20179
19251
|
includeInPrompt: false
|
|
20180
|
-
});
|
|
20181
|
-
return this._clone({ tools: newTools });
|
|
19252
|
+
}), this._clone({ tools: newTools });
|
|
20182
19253
|
}
|
|
20183
19254
|
skill(pathOrDef) {
|
|
20184
|
-
|
|
20185
|
-
|
|
20186
|
-
|
|
20187
|
-
|
|
20188
|
-
|
|
20189
|
-
|
|
20190
|
-
|
|
20191
|
-
|
|
20192
|
-
|
|
20193
|
-
|
|
20194
|
-
|
|
20195
|
-
body: pathOrDef.body,
|
|
20196
|
-
tools: pathOrDef.tools
|
|
20197
|
-
}
|
|
20198
|
-
}]
|
|
20199
|
-
});
|
|
20200
|
-
}
|
|
19255
|
+
return typeof pathOrDef == "string" ? this._clone({ skills: [...this._skills, { type: "stored", path: pathOrDef }] }) : (validateSkillName(pathOrDef.name), validateSkillDescription(pathOrDef.description), this._clone({
|
|
19256
|
+
skills: [...this._skills, {
|
|
19257
|
+
type: "virtual",
|
|
19258
|
+
skill: {
|
|
19259
|
+
name: pathOrDef.name,
|
|
19260
|
+
description: pathOrDef.description,
|
|
19261
|
+
body: pathOrDef.body,
|
|
19262
|
+
tools: pathOrDef.tools
|
|
19263
|
+
}
|
|
19264
|
+
}]
|
|
19265
|
+
}));
|
|
20201
19266
|
}
|
|
20202
19267
|
cwd(path) {
|
|
20203
19268
|
return this._clone({ cwd: path });
|
|
20204
19269
|
}
|
|
20205
19270
|
async _resolveSkills() {
|
|
20206
19271
|
const resolved = [];
|
|
20207
|
-
for (const deferred of this._skills)
|
|
20208
|
-
if (deferred.type === "virtual")
|
|
19272
|
+
for (const deferred of this._skills)
|
|
19273
|
+
if (deferred.type === "virtual")
|
|
20209
19274
|
resolved.push(deferred.skill);
|
|
20210
|
-
|
|
20211
|
-
const content = await (0, import_promises2.readFile)(deferred.path, "utf-8")
|
|
20212
|
-
const parsed = parseSkillMd(content);
|
|
20213
|
-
const stored = {
|
|
19275
|
+
else {
|
|
19276
|
+
const content = await (0, import_promises2.readFile)(deferred.path, "utf-8"), parsed = parseSkillMd(content), stored = {
|
|
20214
19277
|
name: parsed.name,
|
|
20215
19278
|
description: parsed.description,
|
|
20216
19279
|
body: parsed.body,
|
|
20217
|
-
basePath: (0,
|
|
19280
|
+
basePath: (0, import_node_path3.dirname)(deferred.path)
|
|
20218
19281
|
};
|
|
20219
19282
|
resolved.push(stored);
|
|
20220
19283
|
}
|
|
20221
|
-
}
|
|
20222
19284
|
return resolved;
|
|
20223
19285
|
}
|
|
20224
19286
|
_buildSkillsPrompt(skills) {
|
|
20225
19287
|
if (skills.length === 0)
|
|
20226
19288
|
return "";
|
|
20227
|
-
let xml =
|
|
20228
|
-
for (const skill of skills) {
|
|
20229
|
-
xml += ` <skill>
|
|
20230
|
-
`;
|
|
20231
|
-
xml += ` <name>${skill.name}</name>
|
|
19289
|
+
let xml = `<available_skills>
|
|
20232
19290
|
`;
|
|
20233
|
-
|
|
19291
|
+
for (const skill of skills)
|
|
19292
|
+
xml += ` <skill>
|
|
19293
|
+
`, xml += ` <name>${skill.name}</name>
|
|
19294
|
+
`, xml += ` <description>${skill.description}</description>
|
|
19295
|
+
`, xml += ` </skill>
|
|
20234
19296
|
`;
|
|
20235
|
-
|
|
19297
|
+
return xml += `</available_skills>
|
|
19298
|
+
`, xml += `
|
|
19299
|
+
`, xml += `The above skills are available to you. When a task matches a skill's description,
|
|
19300
|
+
`, xml += "call the `activate_skill` tool with the skill name to load its full instructions.\n", xml += "If the skill provides tools, use `call_skill_tool` to invoke them.\n", xml += "If the skill references files, use `read_skill_file` to access them.\n", xml + `
|
|
20236
19301
|
`;
|
|
20237
|
-
}
|
|
20238
|
-
xml += "</available_skills>\n";
|
|
20239
|
-
xml += "\n";
|
|
20240
|
-
xml += "The above skills are available to you. When a task matches a skill's description,\n";
|
|
20241
|
-
xml += "call the `activate_skill` tool with the skill name to load its full instructions.\n";
|
|
20242
|
-
xml += "If the skill provides tools, use `call_skill_tool` to invoke them.\n";
|
|
20243
|
-
xml += "If the skill references files, use `read_skill_file` to access them.\n";
|
|
20244
|
-
return xml + "\n";
|
|
20245
19302
|
}
|
|
20246
19303
|
async run() {
|
|
20247
19304
|
return this.stream().result;
|
|
20248
19305
|
}
|
|
20249
19306
|
stream() {
|
|
20250
19307
|
const stream = new ThoughtStream();
|
|
20251
|
-
this._executeStream(stream).catch((err) => {
|
|
20252
|
-
stream.rejectResult(err instanceof Error ? err : new Error(String(err?.message ?? err)));
|
|
20253
|
-
|
|
20254
|
-
});
|
|
20255
|
-
return stream;
|
|
19308
|
+
return this._executeStream(stream).catch((err) => {
|
|
19309
|
+
stream.rejectResult(err instanceof Error ? err : new Error(String(err?.message ?? err))), stream.close();
|
|
19310
|
+
}), stream;
|
|
20256
19311
|
}
|
|
20257
19312
|
async _executeStream(stream) {
|
|
20258
|
-
|
|
20259
|
-
|
|
20260
|
-
|
|
20261
|
-
|
|
20262
|
-
});
|
|
20263
|
-
this._conn.initialized = true;
|
|
20264
|
-
}
|
|
19313
|
+
this._conn.initialized || (await this._conn.connection.initialize({
|
|
19314
|
+
protocolVersion: 1,
|
|
19315
|
+
clientCapabilities: {}
|
|
19316
|
+
}), this._conn.initialized = true);
|
|
20265
19317
|
const resolvedSkills = await this._resolveSkills();
|
|
20266
19318
|
let prompt = this._buildSkillsPrompt(resolvedSkills) + this._promptParts.join("");
|
|
20267
19319
|
const toolsWithPrompt = Array.from(this._tools.values()).filter((t) => t.includeInPrompt);
|
|
20268
19320
|
if (toolsWithPrompt.length > 0) {
|
|
20269
|
-
prompt +=
|
|
20270
|
-
|
|
19321
|
+
prompt += `
|
|
19322
|
+
|
|
19323
|
+
Available tools:
|
|
19324
|
+
`;
|
|
19325
|
+
for (const tool of toolsWithPrompt)
|
|
20271
19326
|
prompt += `- ${tool.name}: ${tool.description}
|
|
20272
19327
|
`;
|
|
20273
|
-
}
|
|
20274
19328
|
}
|
|
20275
19329
|
const serverBuilder = mcpServer("thinkwell");
|
|
20276
|
-
let resultReceived = false;
|
|
20277
|
-
|
|
20278
|
-
|
|
20279
|
-
|
|
20280
|
-
|
|
20281
|
-
|
|
20282
|
-
|
|
20283
|
-
|
|
20284
|
-
|
|
20285
|
-
|
|
20286
|
-
|
|
20287
|
-
|
|
20288
|
-
|
|
20289
|
-
|
|
20290
|
-
|
|
20291
|
-
|
|
20292
|
-
|
|
20293
|
-
|
|
20294
|
-
|
|
20295
|
-
|
|
20296
|
-
|
|
20297
|
-
|
|
20298
|
-
|
|
19330
|
+
let resultReceived = false, result, resultError, resolveResultReady;
|
|
19331
|
+
const resultReady = new Promise((r) => {
|
|
19332
|
+
resolveResultReady = r;
|
|
19333
|
+
}), rawSchema = this._schemaProvider?.toJsonSchema() ?? { type: "object" }, needsWrap = rawSchema.type !== "object", outputSchema = needsWrap ? { type: "object", properties: { result: rawSchema }, required: ["result"] } : rawSchema, acceptResult = /* @__PURE__ */ __name((input) => {
|
|
19334
|
+
if (resultReceived)
|
|
19335
|
+
return;
|
|
19336
|
+
const value = needsWrap ? input.result : input, schemaRequired = rawSchema.required;
|
|
19337
|
+
let required2 = Array.isArray(schemaRequired) ? schemaRequired : void 0;
|
|
19338
|
+
if (features2.FAULT_INJECTION) {
|
|
19339
|
+
const injectedField = process.env.THINKWELL_INJECT_REQUIRED_FIELD;
|
|
19340
|
+
injectedField && (required2 = required2 ? [...required2, injectedField] : [injectedField]);
|
|
19341
|
+
}
|
|
19342
|
+
if (Array.isArray(required2)) {
|
|
19343
|
+
if (value == null || typeof value != "object") {
|
|
19344
|
+
resultError = new TypeError(`Agent result must be an object when schema has required fields, got ${value === null ? "null" : typeof value}`), resultReceived = true, resolveResultReady();
|
|
19345
|
+
return;
|
|
19346
|
+
}
|
|
19347
|
+
const obj = value, missing = required2.filter((key) => !Object.hasOwn(obj, key));
|
|
19348
|
+
if (missing.length > 0) {
|
|
19349
|
+
resultError = new TypeError(`Agent result is missing required field(s): ${missing.join(", ")}`), resultReceived = true, resolveResultReady();
|
|
19350
|
+
return;
|
|
19351
|
+
}
|
|
19352
|
+
}
|
|
19353
|
+
result = value, resultReceived = true, resolveResultReady();
|
|
19354
|
+
}, "acceptResult");
|
|
19355
|
+
prompt += "\n\nWhen you have your answer, call the `return_result` MCP tool with the result.", serverBuilder.tool("return_result", "Return the final result", outputSchema, { type: "object", properties: { success: { type: "boolean" } } }, async (input) => (acceptResult(input), { success: true }));
|
|
19356
|
+
for (const tool of this._tools.values())
|
|
19357
|
+
serverBuilder.tool(tool.name, tool.description, tool.inputSchema.toJsonSchema(), tool.outputSchema.toJsonSchema(), async (input, _context) => tool.handler(input));
|
|
19358
|
+
const server = serverBuilder.build(), skillServer = resolvedSkills.length > 0 ? createSkillServer(resolvedSkills) : void 0;
|
|
19359
|
+
this._conn.mcpHandler.register(server), skillServer && this._conn.mcpHandler.register(skillServer), this._conn.mcpHandler.setSessionId(this._existingSessionId ?? "pending");
|
|
20299
19360
|
try {
|
|
20300
19361
|
let sessionId;
|
|
20301
|
-
if (this._existingSessionId)
|
|
19362
|
+
if (this._existingSessionId)
|
|
20302
19363
|
sessionId = this._existingSessionId;
|
|
20303
|
-
|
|
19364
|
+
else {
|
|
20304
19365
|
const mcpServers = [{
|
|
20305
19366
|
type: "http",
|
|
20306
19367
|
name: server.name,
|
|
20307
19368
|
url: server.acpUrl,
|
|
20308
19369
|
headers: []
|
|
20309
19370
|
}];
|
|
20310
|
-
|
|
20311
|
-
|
|
20312
|
-
|
|
20313
|
-
|
|
20314
|
-
|
|
20315
|
-
|
|
20316
|
-
});
|
|
20317
|
-
}
|
|
19371
|
+
skillServer && mcpServers.push({
|
|
19372
|
+
type: "http",
|
|
19373
|
+
name: skillServer.name,
|
|
19374
|
+
url: skillServer.acpUrl,
|
|
19375
|
+
headers: []
|
|
19376
|
+
});
|
|
20318
19377
|
const request = {
|
|
20319
19378
|
cwd: this._cwd ?? process.cwd(),
|
|
20320
19379
|
mcpServers
|
|
20321
19380
|
};
|
|
20322
|
-
|
|
20323
|
-
sessionId = response.sessionId;
|
|
19381
|
+
sessionId = (await this._conn.connection.newSession(request)).sessionId;
|
|
20324
19382
|
}
|
|
20325
19383
|
this._conn.mcpHandler.setSessionId(sessionId);
|
|
20326
19384
|
const session = new ThinkSession(sessionId, this._conn);
|
|
20327
|
-
this._conn.sessionHandlers.set(sessionId, session);
|
|
20328
|
-
await this._conn.mcpHandler.waitForToolsDiscovery(sessionId, 2e3);
|
|
19385
|
+
this._conn.sessionHandlers.set(sessionId, session), await this._conn.mcpHandler.waitForToolsDiscovery(sessionId, 2e3);
|
|
20329
19386
|
try {
|
|
20330
|
-
const
|
|
20331
|
-
|
|
20332
|
-
|
|
20333
|
-
|
|
20334
|
-
if (
|
|
20335
|
-
|
|
19387
|
+
const pendingToolCalls = [], sendTurn = /* @__PURE__ */ __name(async (text) => {
|
|
19388
|
+
const promptPromise = session.sendPrompt(text);
|
|
19389
|
+
for (; !resultReceived; ) {
|
|
19390
|
+
const update = await session.readUpdate();
|
|
19391
|
+
if (update.type === "stop")
|
|
19392
|
+
break;
|
|
19393
|
+
if (update.type === "tool_start") {
|
|
19394
|
+
const toolName = update.title;
|
|
19395
|
+
(this._tools.has(toolName) || toolName === "return_result") && pendingToolCalls.push({ id: update.id, name: toolName, input: update.input });
|
|
20336
19396
|
}
|
|
20337
|
-
|
|
19397
|
+
stream.pushEvent(update);
|
|
20338
19398
|
}
|
|
20339
|
-
|
|
20340
|
-
}
|
|
20341
|
-
await
|
|
20342
|
-
|
|
20343
|
-
|
|
19399
|
+
await promptPromise, !resultReceived && pendingToolCalls.some((c) => c.name === "return_result") && await resultReady;
|
|
19400
|
+
}, "sendTurn");
|
|
19401
|
+
for (await sendTurn(prompt); !resultReceived && pendingToolCalls.length > 0; ) {
|
|
19402
|
+
const calls = pendingToolCalls.splice(0), results = [];
|
|
19403
|
+
for (const call of calls) {
|
|
19404
|
+
if (call.name === "return_result") {
|
|
19405
|
+
acceptResult(call.input);
|
|
19406
|
+
break;
|
|
19407
|
+
}
|
|
19408
|
+
const tool = this._tools.get(call.name);
|
|
19409
|
+
if (tool)
|
|
19410
|
+
try {
|
|
19411
|
+
const output = await tool.handler(call.input), text = typeof output == "string" ? output : JSON.stringify(output);
|
|
19412
|
+
results.push(`Tool "${call.name}" (id: ${call.id}) result:
|
|
19413
|
+
${text}`);
|
|
19414
|
+
} catch (err) {
|
|
19415
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
19416
|
+
results.push(`Tool "${call.name}" (id: ${call.id}) error:
|
|
19417
|
+
${msg}`);
|
|
19418
|
+
}
|
|
19419
|
+
}
|
|
19420
|
+
if (resultReceived || results.length === 0)
|
|
19421
|
+
break;
|
|
19422
|
+
const followUp = results.join(`
|
|
19423
|
+
|
|
19424
|
+
`) + "\n\nWhen you have your answer, call the `return_result` MCP tool with the result.";
|
|
19425
|
+
await sendTurn(followUp);
|
|
20344
19426
|
}
|
|
19427
|
+
resultError ? stream.rejectResult(resultError) : resultReceived && result !== void 0 ? stream.resolveResult(result) : resultReceived ? stream.rejectResult(new TypeError("Agent returned an undefined value")) : stream.rejectResult(new Error("Agent session ended without returning a result"));
|
|
20345
19428
|
} finally {
|
|
20346
|
-
stream.close();
|
|
20347
|
-
session.close();
|
|
20348
|
-
this._conn.sessionHandlers.delete(sessionId);
|
|
19429
|
+
stream.close(), session.close(), this._conn.sessionHandlers.delete(sessionId);
|
|
20349
19430
|
}
|
|
20350
19431
|
} finally {
|
|
20351
|
-
this._conn.mcpHandler.unregister(server);
|
|
20352
|
-
if (skillServer) {
|
|
20353
|
-
this._conn.mcpHandler.unregister(skillServer);
|
|
20354
|
-
}
|
|
19432
|
+
this._conn.mcpHandler.unregister(server), skillServer && this._conn.mcpHandler.unregister(skillServer);
|
|
20355
19433
|
}
|
|
20356
19434
|
}
|
|
20357
19435
|
};
|
|
@@ -20381,9 +19459,7 @@ var Session = class {
|
|
|
20381
19459
|
* @internal
|
|
20382
19460
|
*/
|
|
20383
19461
|
constructor(conn, sessionId, options) {
|
|
20384
|
-
this._conn = conn;
|
|
20385
|
-
this._sessionId = sessionId;
|
|
20386
|
-
this._options = options;
|
|
19462
|
+
this._conn = conn, this._sessionId = sessionId, this._options = options;
|
|
20387
19463
|
}
|
|
20388
19464
|
/**
|
|
20389
19465
|
* The unique session identifier
|
|
@@ -20412,9 +19488,8 @@ var Session = class {
|
|
|
20412
19488
|
* ```
|
|
20413
19489
|
*/
|
|
20414
19490
|
think(schema) {
|
|
20415
|
-
if (this._closed)
|
|
19491
|
+
if (this._closed)
|
|
20416
19492
|
throw new Error("Session is closed");
|
|
20417
|
-
}
|
|
20418
19493
|
return createPlan(this._conn, schema, this._sessionId);
|
|
20419
19494
|
}
|
|
20420
19495
|
/**
|
|
@@ -20429,8 +19504,10 @@ var Session = class {
|
|
|
20429
19504
|
};
|
|
20430
19505
|
|
|
20431
19506
|
// dist/agent.js
|
|
19507
|
+
var import_node_fs3 = require("node:fs");
|
|
19508
|
+
var import_node_path4 = require("node:path");
|
|
20432
19509
|
var AGENT_COMMANDS = {
|
|
20433
|
-
claude: "npx -y @
|
|
19510
|
+
claude: "npx -y @agentclientprotocol/claude-agent-acp",
|
|
20434
19511
|
codex: "npx -y @zed-industries/codex-acp",
|
|
20435
19512
|
gemini: "npx -y @google/gemini-cli --experimental-acp",
|
|
20436
19513
|
kiro: "kiro-cli acp",
|
|
@@ -20444,9 +19521,8 @@ var AgentImpl = class {
|
|
|
20444
19521
|
}
|
|
20445
19522
|
_conn;
|
|
20446
19523
|
constructor(key, conn) {
|
|
20447
|
-
if (key !== AGENT_KEY)
|
|
19524
|
+
if (key !== AGENT_KEY)
|
|
20448
19525
|
throw new Error("Agent cannot be constructed directly. Use open() instead.");
|
|
20449
|
-
}
|
|
20450
19526
|
this._conn = conn;
|
|
20451
19527
|
}
|
|
20452
19528
|
think(schema) {
|
|
@@ -20457,8 +19533,7 @@ var AgentImpl = class {
|
|
|
20457
19533
|
const request = {
|
|
20458
19534
|
cwd: options?.cwd ?? process.cwd(),
|
|
20459
19535
|
mcpServers: []
|
|
20460
|
-
};
|
|
20461
|
-
const response = await this._conn.connection.newSession(request);
|
|
19536
|
+
}, response = await this._conn.connection.newSession(request);
|
|
20462
19537
|
return new Session(this._conn, response.sessionId, options);
|
|
20463
19538
|
}
|
|
20464
19539
|
async close() {
|
|
@@ -20470,31 +19545,53 @@ var AgentImpl = class {
|
|
|
20470
19545
|
}
|
|
20471
19546
|
}
|
|
20472
19547
|
async _initialize() {
|
|
20473
|
-
|
|
20474
|
-
return;
|
|
20475
|
-
await this._conn.connection.initialize({
|
|
19548
|
+
this._conn.initialized || (await this._conn.connection.initialize({
|
|
20476
19549
|
protocolVersion: 1,
|
|
20477
19550
|
clientCapabilities: {}
|
|
20478
|
-
});
|
|
20479
|
-
this._conn.initialized = true;
|
|
19551
|
+
}), this._conn.initialized = true);
|
|
20480
19552
|
}
|
|
20481
19553
|
};
|
|
20482
|
-
function
|
|
19554
|
+
function createTracer() {
|
|
19555
|
+
const traceDir = process.env.THINKWELL_TRACE;
|
|
19556
|
+
if (!traceDir)
|
|
19557
|
+
return null;
|
|
19558
|
+
try {
|
|
19559
|
+
(0, import_node_fs3.mkdirSync)(traceDir, { recursive: true });
|
|
19560
|
+
} catch {
|
|
19561
|
+
return null;
|
|
19562
|
+
}
|
|
19563
|
+
const tracePath = (0, import_node_path4.join)(traceDir, `trace-${process.pid}-${Date.now()}.ndjson`);
|
|
19564
|
+
let seq = 0;
|
|
19565
|
+
const t0 = performance.now();
|
|
19566
|
+
return (dir, msg) => {
|
|
19567
|
+
const record2 = {
|
|
19568
|
+
seq: seq++,
|
|
19569
|
+
ms: Math.round((performance.now() - t0) * 1e3) / 1e3,
|
|
19570
|
+
dir,
|
|
19571
|
+
msg
|
|
19572
|
+
};
|
|
19573
|
+
try {
|
|
19574
|
+
(0, import_node_fs3.appendFileSync)(tracePath, JSON.stringify(record2) + `
|
|
19575
|
+
`);
|
|
19576
|
+
} catch {
|
|
19577
|
+
}
|
|
19578
|
+
};
|
|
19579
|
+
}
|
|
19580
|
+
__name(createTracer, "createTracer");
|
|
19581
|
+
function componentConnectionToStream(connection, trace) {
|
|
20483
19582
|
const readable = new ReadableStream({
|
|
20484
19583
|
async start(controller) {
|
|
20485
19584
|
try {
|
|
20486
|
-
for await (const message of connection.messages)
|
|
20487
|
-
controller.enqueue(message);
|
|
20488
|
-
}
|
|
19585
|
+
for await (const message of connection.messages)
|
|
19586
|
+
trace?.("recv", message), controller.enqueue(message);
|
|
20489
19587
|
controller.close();
|
|
20490
19588
|
} catch (error40) {
|
|
20491
19589
|
controller.error(error40);
|
|
20492
19590
|
}
|
|
20493
19591
|
}
|
|
20494
|
-
})
|
|
20495
|
-
const writable = new WritableStream({
|
|
19592
|
+
}), writable = new WritableStream({
|
|
20496
19593
|
write(message) {
|
|
20497
|
-
connection.send(message);
|
|
19594
|
+
trace?.("send", message), connection.send(message);
|
|
20498
19595
|
},
|
|
20499
19596
|
close() {
|
|
20500
19597
|
connection.close();
|
|
@@ -20506,38 +19603,37 @@ __name(componentConnectionToStream, "componentConnectionToStream");
|
|
|
20506
19603
|
function createClient(conn, mcpHandler) {
|
|
20507
19604
|
return {
|
|
20508
19605
|
sessionUpdate(notification) {
|
|
20509
|
-
const { sessionId } = notification;
|
|
20510
|
-
|
|
20511
|
-
|
|
20512
|
-
console.error(`No handler for session: ${sessionId}`);
|
|
20513
|
-
return Promise.resolve();
|
|
20514
|
-
}
|
|
19606
|
+
const { sessionId } = notification, handler = conn.sessionHandlers.get(sessionId);
|
|
19607
|
+
if (!handler)
|
|
19608
|
+
return console.error(`No handler for session: ${sessionId}`), Promise.resolve();
|
|
20515
19609
|
const update = convertNotification(notification);
|
|
20516
|
-
|
|
20517
|
-
handler.pushUpdate(update);
|
|
20518
|
-
}
|
|
20519
|
-
return Promise.resolve();
|
|
19610
|
+
return update && handler.pushUpdate(update), Promise.resolve();
|
|
20520
19611
|
},
|
|
20521
19612
|
requestPermission(request) {
|
|
20522
|
-
const
|
|
20523
|
-
return Promise.resolve({
|
|
19613
|
+
const response = {
|
|
20524
19614
|
outcome: {
|
|
20525
19615
|
outcome: "selected",
|
|
20526
|
-
optionId:
|
|
19616
|
+
optionId: request.options[0]?.optionId ?? "approve"
|
|
20527
19617
|
}
|
|
20528
|
-
}
|
|
19618
|
+
};
|
|
19619
|
+
if (features2.LOG_PERMISSIONS) {
|
|
19620
|
+
const logDir = process.env.THINKWELL_LOG_DIR ?? process.cwd(), logPath = (0, import_node_path4.join)(logDir, "permissions.ndjson"), record2 = {
|
|
19621
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
19622
|
+
request,
|
|
19623
|
+
response
|
|
19624
|
+
};
|
|
19625
|
+
(0, import_node_fs3.appendFileSync)(logPath, JSON.stringify(record2) + `
|
|
19626
|
+
`);
|
|
19627
|
+
}
|
|
19628
|
+
return Promise.resolve(response);
|
|
20529
19629
|
},
|
|
20530
19630
|
async extMethod(method, params) {
|
|
20531
|
-
if (mcpHandler.isMcpRequest(method))
|
|
20532
|
-
|
|
20533
|
-
return result ?? {};
|
|
20534
|
-
}
|
|
19631
|
+
if (mcpHandler.isMcpRequest(method))
|
|
19632
|
+
return await mcpHandler.routeRequest(method, params) ?? {};
|
|
20535
19633
|
throw new Error(`Unknown extension method: ${method}`);
|
|
20536
19634
|
},
|
|
20537
19635
|
async extNotification(method, params) {
|
|
20538
|
-
|
|
20539
|
-
await mcpHandler.routeRequest(method, params);
|
|
20540
|
-
}
|
|
19636
|
+
mcpHandler.isMcpRequest(method) && await mcpHandler.routeRequest(method, params);
|
|
20541
19637
|
}
|
|
20542
19638
|
};
|
|
20543
19639
|
}
|
|
@@ -20563,9 +19659,7 @@ function convertToolCallContent(content) {
|
|
|
20563
19659
|
return { type: "terminal", terminalId: content.terminalId };
|
|
20564
19660
|
case "content": {
|
|
20565
19661
|
const block = convertContentBlock(content.content);
|
|
20566
|
-
|
|
20567
|
-
return null;
|
|
20568
|
-
return { type: "content", content: block };
|
|
19662
|
+
return block ? { type: "content", content: block } : null;
|
|
20569
19663
|
}
|
|
20570
19664
|
}
|
|
20571
19665
|
}
|
|
@@ -20575,39 +19669,35 @@ function convertNotification(notification) {
|
|
|
20575
19669
|
switch (update.sessionUpdate) {
|
|
20576
19670
|
case "agent_thought_chunk": {
|
|
20577
19671
|
const content = update.content;
|
|
20578
|
-
if (content.type === "text")
|
|
19672
|
+
if (content.type === "text")
|
|
20579
19673
|
return { type: "thought", text: content.text };
|
|
20580
|
-
}
|
|
20581
19674
|
break;
|
|
20582
19675
|
}
|
|
20583
19676
|
case "agent_message_chunk": {
|
|
20584
19677
|
const content = update.content;
|
|
20585
|
-
if (content.type === "text")
|
|
19678
|
+
if (content.type === "text")
|
|
20586
19679
|
return { type: "message", text: content.text };
|
|
20587
|
-
}
|
|
20588
19680
|
break;
|
|
20589
19681
|
}
|
|
20590
19682
|
case "tool_call": {
|
|
20591
|
-
|
|
19683
|
+
const event = {
|
|
20592
19684
|
type: "tool_start",
|
|
20593
19685
|
id: update.toolCallId,
|
|
20594
19686
|
title: update.title,
|
|
20595
19687
|
kind: update.kind
|
|
20596
19688
|
};
|
|
19689
|
+
return update.rawInput !== void 0 && (event.input = update.rawInput), event;
|
|
20597
19690
|
}
|
|
20598
19691
|
case "tool_call_update": {
|
|
20599
19692
|
const status = update.status ?? "in_progress";
|
|
20600
|
-
|
|
20601
|
-
return { type: "tool_done", id: update.toolCallId, status };
|
|
20602
|
-
}
|
|
20603
|
-
return {
|
|
19693
|
+
return status === "completed" || status === "failed" ? { type: "tool_done", id: update.toolCallId, status } : {
|
|
20604
19694
|
type: "tool_update",
|
|
20605
19695
|
id: update.toolCallId,
|
|
20606
19696
|
status,
|
|
20607
19697
|
content: update.content?.map(convertToolCallContent).filter((c) => c !== null)
|
|
20608
19698
|
};
|
|
20609
19699
|
}
|
|
20610
|
-
case "plan":
|
|
19700
|
+
case "plan":
|
|
20611
19701
|
return {
|
|
20612
19702
|
type: "plan",
|
|
20613
19703
|
entries: update.entries.map((e) => ({
|
|
@@ -20616,10 +19706,12 @@ function convertNotification(notification) {
|
|
|
20616
19706
|
priority: e.priority
|
|
20617
19707
|
}))
|
|
20618
19708
|
};
|
|
20619
|
-
}
|
|
20620
19709
|
case "user_message_chunk":
|
|
20621
19710
|
case "available_commands_update":
|
|
20622
19711
|
case "current_mode_update":
|
|
19712
|
+
case "config_option_update":
|
|
19713
|
+
case "session_info_update":
|
|
19714
|
+
case "usage_update":
|
|
20623
19715
|
break;
|
|
20624
19716
|
}
|
|
20625
19717
|
return null;
|
|
@@ -20635,35 +19727,27 @@ function parseCommandWithEnv(command, env) {
|
|
|
20635
19727
|
}
|
|
20636
19728
|
__name(parseCommandWithEnv, "parseCommandWithEnv");
|
|
20637
19729
|
function resolveCommand(nameOrOptions, options) {
|
|
20638
|
-
const envCmd = process.env.THINKWELL_AGENT_CMD;
|
|
20639
|
-
|
|
20640
|
-
|
|
20641
|
-
const opts = typeof nameOrOptions === "string" ? options : nameOrOptions;
|
|
20642
|
-
return { command: envCmd, options: opts };
|
|
20643
|
-
}
|
|
19730
|
+
const envCmd = process.env.THINKWELL_AGENT_CMD, envAgent = process.env.THINKWELL_AGENT;
|
|
19731
|
+
if (envCmd)
|
|
19732
|
+
return { command: envCmd, options: typeof nameOrOptions == "string" ? options : nameOrOptions };
|
|
20644
19733
|
if (envAgent) {
|
|
20645
|
-
if (!(envAgent in AGENT_COMMANDS))
|
|
19734
|
+
if (!(envAgent in AGENT_COMMANDS))
|
|
20646
19735
|
throw new Error(`Unknown agent name in $THINKWELL_AGENT: '${envAgent}'. Valid names: ${Object.keys(AGENT_COMMANDS).join(", ")}`);
|
|
20647
|
-
|
|
20648
|
-
const opts = typeof nameOrOptions === "string" ? options : nameOrOptions;
|
|
19736
|
+
const opts = typeof nameOrOptions == "string" ? options : nameOrOptions;
|
|
20649
19737
|
return { command: AGENT_COMMANDS[envAgent], options: opts };
|
|
20650
19738
|
}
|
|
20651
|
-
|
|
20652
|
-
return { command: AGENT_COMMANDS[nameOrOptions], options };
|
|
20653
|
-
}
|
|
20654
|
-
return { command: nameOrOptions.cmd, options: nameOrOptions };
|
|
19739
|
+
return typeof nameOrOptions == "string" ? { command: AGENT_COMMANDS[nameOrOptions], options } : { command: nameOrOptions.cmd, options: nameOrOptions };
|
|
20655
19740
|
}
|
|
20656
19741
|
__name(resolveCommand, "resolveCommand");
|
|
20657
19742
|
async function open(nameOrOptions, maybeOptions) {
|
|
20658
|
-
const { command, options } = resolveCommand(nameOrOptions, maybeOptions)
|
|
20659
|
-
|
|
20660
|
-
|
|
19743
|
+
const { command, options } = resolveCommand(nameOrOptions, maybeOptions), agentEnv = {
|
|
19744
|
+
// Strip CLAUDECODE to prevent the nested-session guard from blocking
|
|
19745
|
+
// the agent's Claude Code subprocess when thinkwell runs inside Claude Code.
|
|
19746
|
+
...features2.STRIP_CLAUDECODE_ENV ? { CLAUDECODE: "" } : {},
|
|
19747
|
+
...options?.env
|
|
19748
|
+
}, commandSpec = parseCommandWithEnv(command, agentEnv), conductor = new Conductor({
|
|
20661
19749
|
instantiator: fromCommands([commandSpec])
|
|
20662
|
-
})
|
|
20663
|
-
const pair = createChannelPair();
|
|
20664
|
-
const stream = componentConnectionToStream(pair.left);
|
|
20665
|
-
const mcpHandler = new McpOverAcpHandler();
|
|
20666
|
-
const conn = {
|
|
19750
|
+
}), pair = createChannelPair(), trace = createTracer(), stream = componentConnectionToStream(pair.left, trace), mcpHandler = new McpOverAcpHandler(), conn = {
|
|
20667
19751
|
conductor,
|
|
20668
19752
|
connection: null,
|
|
20669
19753
|
// Set below after creating the client
|
|
@@ -20672,19 +19756,16 @@ async function open(nameOrOptions, maybeOptions) {
|
|
|
20672
19756
|
initialized: false,
|
|
20673
19757
|
conductorPromise: null
|
|
20674
19758
|
// Set below after starting the conductor
|
|
20675
|
-
};
|
|
20676
|
-
const clientConnection = new ClientSideConnection((_agent) => createClient(conn, mcpHandler), stream);
|
|
19759
|
+
}, clientConnection = new ClientSideConnection((_agent) => createClient(conn, mcpHandler), stream);
|
|
20677
19760
|
conn.connection = clientConnection;
|
|
20678
19761
|
const clientConnector = {
|
|
20679
19762
|
async connect() {
|
|
20680
19763
|
return pair.right;
|
|
20681
19764
|
}
|
|
20682
19765
|
};
|
|
20683
|
-
conn.conductorPromise = conductor.connect(clientConnector)
|
|
20684
|
-
conn.conductorPromise.catch((error40) => {
|
|
19766
|
+
return conn.conductorPromise = conductor.connect(clientConnector), conn.conductorPromise.catch((error40) => {
|
|
20685
19767
|
console.error("Conductor error:", error40);
|
|
20686
|
-
});
|
|
20687
|
-
return new AgentImpl(AGENT_KEY, conn);
|
|
19768
|
+
}), new AgentImpl(AGENT_KEY, conn);
|
|
20688
19769
|
}
|
|
20689
19770
|
__name(open, "open");
|
|
20690
19771
|
|