lody 0.72.0 → 0.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{directory-handle-D57OdGy1.js → directory-handle-zGmrHbmq.js} +11 -11
- package/dist/chunks/{index-Cbwwpq6s.js → index-Cuqd9gip.js} +184 -42
- package/dist/chunks/package-C4jJQVT8.js +4133 -0
- package/dist/chunks/{review-viewer-CkoswOhv.js → review-viewer-BTyuDovX.js} +2 -2
- package/dist/chunks/{schemas-CDSDDVK-.js → schemas-BDpQ67Nq.js} +89 -19
- package/dist/claude-acp.js +52 -3465
- package/dist/code-collab-watch-worker.js +102 -36
- package/dist/codex-acp.js +1 -1
- package/dist/file-index-scan-worker.js +2 -2
- package/dist/index.js +7320 -6467
- package/package.json +12 -10
- package/dist/chunks/package-CkkAIS-_.js +0 -11
package/dist/claude-acp.js
CHANGED
|
@@ -27,14 +27,14 @@ import path__default from "node:path";
|
|
|
27
27
|
import * as os$1 from "node:os";
|
|
28
28
|
import os__default from "node:os";
|
|
29
29
|
import process$1 from "node:process";
|
|
30
|
-
import {
|
|
30
|
+
import { a as CreateElicitationResponse, n as ndJsonStream, b as agent$1, m as methods, R as RequestError, p as packageJson } from "./chunks/package-C4jJQVT8.js";
|
|
31
31
|
import { execFile as execFile$1 } from "node:child_process";
|
|
32
32
|
import { randomUUID as randomUUID$1 } from "node:crypto";
|
|
33
33
|
import * as fs$2 from "node:fs/promises";
|
|
34
34
|
import { promisify as promisify$1 } from "node:util";
|
|
35
|
-
import { p as packageJson } from "./chunks/package-CkkAIS-_.js";
|
|
36
35
|
import * as fs$1 from "node:fs";
|
|
37
|
-
import { WritableStream
|
|
36
|
+
import { WritableStream, ReadableStream as ReadableStream$1 } from "node:stream/web";
|
|
37
|
+
import "./chunks/schemas-BDpQ67Nq.js";
|
|
38
38
|
(async () => {
|
|
39
39
|
var wW = Object.create;
|
|
40
40
|
var { getPrototypeOf: TW, defineProperty: $y, getOwnPropertyNames: AW } = Object;
|
|
@@ -52928,3446 +52928,6 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
|
52928
52928
|
}
|
|
52929
52929
|
return null;
|
|
52930
52930
|
}
|
|
52931
|
-
const AGENT_METHODS = {
|
|
52932
|
-
initialize: "initialize",
|
|
52933
|
-
authenticate: "authenticate",
|
|
52934
|
-
providers_list: "providers/list",
|
|
52935
|
-
providers_set: "providers/set",
|
|
52936
|
-
providers_disable: "providers/disable",
|
|
52937
|
-
session_new: "session/new",
|
|
52938
|
-
session_load: "session/load",
|
|
52939
|
-
session_set_mode: "session/set_mode",
|
|
52940
|
-
session_set_config_option: "session/set_config_option",
|
|
52941
|
-
session_prompt: "session/prompt",
|
|
52942
|
-
session_cancel: "session/cancel",
|
|
52943
|
-
session_list: "session/list",
|
|
52944
|
-
session_delete: "session/delete",
|
|
52945
|
-
session_fork: "session/fork",
|
|
52946
|
-
session_resume: "session/resume",
|
|
52947
|
-
session_close: "session/close",
|
|
52948
|
-
logout: "logout",
|
|
52949
|
-
nes_start: "nes/start",
|
|
52950
|
-
nes_suggest: "nes/suggest",
|
|
52951
|
-
nes_accept: "nes/accept",
|
|
52952
|
-
nes_reject: "nes/reject",
|
|
52953
|
-
nes_close: "nes/close",
|
|
52954
|
-
document_did_open: "document/didOpen",
|
|
52955
|
-
document_did_change: "document/didChange",
|
|
52956
|
-
document_did_close: "document/didClose",
|
|
52957
|
-
document_did_save: "document/didSave",
|
|
52958
|
-
document_did_focus: "document/didFocus"
|
|
52959
|
-
};
|
|
52960
|
-
const CLIENT_METHODS = {
|
|
52961
|
-
session_request_permission: "session/request_permission",
|
|
52962
|
-
session_update: "session/update",
|
|
52963
|
-
fs_write_text_file: "fs/write_text_file",
|
|
52964
|
-
fs_read_text_file: "fs/read_text_file",
|
|
52965
|
-
terminal_create: "terminal/create",
|
|
52966
|
-
terminal_output: "terminal/output",
|
|
52967
|
-
terminal_release: "terminal/release",
|
|
52968
|
-
terminal_wait_for_exit: "terminal/wait_for_exit",
|
|
52969
|
-
terminal_kill: "terminal/kill",
|
|
52970
|
-
elicitation_create: "elicitation/create",
|
|
52971
|
-
elicitation_complete: "elicitation/complete"
|
|
52972
|
-
};
|
|
52973
|
-
const skippedItem = Symbol("skippedItem");
|
|
52974
|
-
function defaultOnError(schema, fallback) {
|
|
52975
|
-
return schema.catch(fallback);
|
|
52976
|
-
}
|
|
52977
|
-
function requiredDefaultOnError(schema, fallback) {
|
|
52978
|
-
const schemaWithCatch = schema.catch(fallback);
|
|
52979
|
-
return unknown().transform((value, context) => {
|
|
52980
|
-
if (value !== void 0) return schemaWithCatch.parse(value);
|
|
52981
|
-
context.addIssue({
|
|
52982
|
-
code: "custom",
|
|
52983
|
-
message: "Required value is missing"
|
|
52984
|
-
});
|
|
52985
|
-
return NEVER;
|
|
52986
|
-
});
|
|
52987
|
-
}
|
|
52988
|
-
function stringTag(value, key) {
|
|
52989
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
52990
|
-
return void 0;
|
|
52991
|
-
}
|
|
52992
|
-
const tag = value[key];
|
|
52993
|
-
return typeof tag === "string" ? tag : void 0;
|
|
52994
|
-
}
|
|
52995
|
-
function excludeKnownTags(schema, key, knownTags) {
|
|
52996
|
-
return schema.superRefine((value, context) => {
|
|
52997
|
-
const tag = stringTag(value, key);
|
|
52998
|
-
if (tag !== void 0 && knownTags.includes(tag)) {
|
|
52999
|
-
context.addIssue({
|
|
53000
|
-
code: "custom",
|
|
53001
|
-
path: [
|
|
53002
|
-
key
|
|
53003
|
-
],
|
|
53004
|
-
message: `${key} ${JSON.stringify(tag)} is reserved by a known variant, but the value does not match that variant's schema`
|
|
53005
|
-
});
|
|
53006
|
-
}
|
|
53007
|
-
});
|
|
53008
|
-
}
|
|
53009
|
-
function preserveCustomPayload(schema, key, knownTags) {
|
|
53010
|
-
return unknown().transform((value, context) => {
|
|
53011
|
-
const result = schema.safeParse(value);
|
|
53012
|
-
if (!result.success) {
|
|
53013
|
-
for (const issue of result.error.issues) {
|
|
53014
|
-
context.addIssue({
|
|
53015
|
-
...issue,
|
|
53016
|
-
input: value
|
|
53017
|
-
});
|
|
53018
|
-
}
|
|
53019
|
-
return NEVER;
|
|
53020
|
-
}
|
|
53021
|
-
const output = result.data;
|
|
53022
|
-
const tag = stringTag(value, key);
|
|
53023
|
-
if (tag !== void 0 && !knownTags.includes(tag)) {
|
|
53024
|
-
const raw = value;
|
|
53025
|
-
for (const [property, rawValue] of Object.entries(raw)) {
|
|
53026
|
-
if (property === "__proto__") continue;
|
|
53027
|
-
if (!Object.hasOwn(output, property)) output[property] = rawValue;
|
|
53028
|
-
}
|
|
53029
|
-
}
|
|
53030
|
-
return output;
|
|
53031
|
-
});
|
|
53032
|
-
}
|
|
53033
|
-
function vecSkipError(itemSchema) {
|
|
53034
|
-
return array(itemSchema.catch(skippedItem)).transform((items) => items.filter((item) => item !== skippedItem));
|
|
53035
|
-
}
|
|
53036
|
-
const zRequestId = union([
|
|
53037
|
-
number(),
|
|
53038
|
-
string()
|
|
53039
|
-
]).nullable();
|
|
53040
|
-
const zSessionId = string();
|
|
53041
|
-
const zWriteTextFileRequest = object({
|
|
53042
|
-
sessionId: zSessionId,
|
|
53043
|
-
path: string(),
|
|
53044
|
-
content: string(),
|
|
53045
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53046
|
-
});
|
|
53047
|
-
const zReadTextFileRequest = object({
|
|
53048
|
-
sessionId: zSessionId,
|
|
53049
|
-
path: string(),
|
|
53050
|
-
line: defaultOnError(int().gte(0).max(4294967295, {
|
|
53051
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
53052
|
-
}).nullish(), () => void 0),
|
|
53053
|
-
limit: defaultOnError(int().gte(0).max(4294967295, {
|
|
53054
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
53055
|
-
}).nullish(), () => void 0),
|
|
53056
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53057
|
-
});
|
|
53058
|
-
const zToolCallId = string();
|
|
53059
|
-
const zToolKind = union([
|
|
53060
|
-
literal("read"),
|
|
53061
|
-
literal("edit"),
|
|
53062
|
-
literal("delete"),
|
|
53063
|
-
literal("move"),
|
|
53064
|
-
literal("search"),
|
|
53065
|
-
literal("execute"),
|
|
53066
|
-
literal("think"),
|
|
53067
|
-
literal("fetch"),
|
|
53068
|
-
literal("switch_mode"),
|
|
53069
|
-
literal("other")
|
|
53070
|
-
]);
|
|
53071
|
-
const zToolCallStatus = union([
|
|
53072
|
-
literal("pending"),
|
|
53073
|
-
literal("in_progress"),
|
|
53074
|
-
literal("completed"),
|
|
53075
|
-
literal("failed")
|
|
53076
|
-
]);
|
|
53077
|
-
const zRole = union([
|
|
53078
|
-
literal("assistant"),
|
|
53079
|
-
literal("user")
|
|
53080
|
-
]);
|
|
53081
|
-
const zAnnotations = object({
|
|
53082
|
-
audience: defaultOnError(vecSkipError(zRole).nullish(), () => void 0),
|
|
53083
|
-
lastModified: defaultOnError(string().nullish(), () => void 0),
|
|
53084
|
-
priority: defaultOnError(number().nullish(), () => void 0),
|
|
53085
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53086
|
-
});
|
|
53087
|
-
const zTextContent = object({
|
|
53088
|
-
annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
|
|
53089
|
-
text: string(),
|
|
53090
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53091
|
-
});
|
|
53092
|
-
const zImageContent = object({
|
|
53093
|
-
annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
|
|
53094
|
-
data: string(),
|
|
53095
|
-
mimeType: string(),
|
|
53096
|
-
uri: defaultOnError(string().nullish(), () => void 0),
|
|
53097
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53098
|
-
});
|
|
53099
|
-
const zAudioContent = object({
|
|
53100
|
-
annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
|
|
53101
|
-
data: string(),
|
|
53102
|
-
mimeType: string(),
|
|
53103
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53104
|
-
});
|
|
53105
|
-
const zResourceLink = object({
|
|
53106
|
-
annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
|
|
53107
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53108
|
-
mimeType: defaultOnError(string().nullish(), () => void 0),
|
|
53109
|
-
name: string(),
|
|
53110
|
-
size: defaultOnError(number().nullish(), () => void 0),
|
|
53111
|
-
title: defaultOnError(string().nullish(), () => void 0),
|
|
53112
|
-
uri: string(),
|
|
53113
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53114
|
-
});
|
|
53115
|
-
const zTextResourceContents = object({
|
|
53116
|
-
mimeType: defaultOnError(string().nullish(), () => void 0),
|
|
53117
|
-
text: string(),
|
|
53118
|
-
uri: string(),
|
|
53119
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53120
|
-
});
|
|
53121
|
-
const zBlobResourceContents = object({
|
|
53122
|
-
blob: string(),
|
|
53123
|
-
mimeType: defaultOnError(string().nullish(), () => void 0),
|
|
53124
|
-
uri: string(),
|
|
53125
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53126
|
-
});
|
|
53127
|
-
const zEmbeddedResourceResource = union([
|
|
53128
|
-
zTextResourceContents,
|
|
53129
|
-
zBlobResourceContents
|
|
53130
|
-
]);
|
|
53131
|
-
const zEmbeddedResource = object({
|
|
53132
|
-
annotations: defaultOnError(zAnnotations.nullish(), () => void 0),
|
|
53133
|
-
resource: zEmbeddedResourceResource,
|
|
53134
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53135
|
-
});
|
|
53136
|
-
const zContentBlock = union([
|
|
53137
|
-
zTextContent.and(object({
|
|
53138
|
-
type: literal("text")
|
|
53139
|
-
})),
|
|
53140
|
-
zImageContent.and(object({
|
|
53141
|
-
type: literal("image")
|
|
53142
|
-
})),
|
|
53143
|
-
zAudioContent.and(object({
|
|
53144
|
-
type: literal("audio")
|
|
53145
|
-
})),
|
|
53146
|
-
zResourceLink.and(object({
|
|
53147
|
-
type: literal("resource_link")
|
|
53148
|
-
})),
|
|
53149
|
-
zEmbeddedResource.and(object({
|
|
53150
|
-
type: literal("resource")
|
|
53151
|
-
}))
|
|
53152
|
-
]);
|
|
53153
|
-
const zContent = object({
|
|
53154
|
-
content: zContentBlock,
|
|
53155
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53156
|
-
});
|
|
53157
|
-
const zDiff = object({
|
|
53158
|
-
path: string(),
|
|
53159
|
-
oldText: defaultOnError(string().nullish(), () => void 0),
|
|
53160
|
-
newText: string(),
|
|
53161
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53162
|
-
});
|
|
53163
|
-
const zTerminalId = string();
|
|
53164
|
-
const zTerminal = object({
|
|
53165
|
-
terminalId: zTerminalId,
|
|
53166
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53167
|
-
});
|
|
53168
|
-
const zToolCallContent = union([
|
|
53169
|
-
zContent.and(object({
|
|
53170
|
-
type: literal("content")
|
|
53171
|
-
})),
|
|
53172
|
-
zDiff.and(object({
|
|
53173
|
-
type: literal("diff")
|
|
53174
|
-
})),
|
|
53175
|
-
zTerminal.and(object({
|
|
53176
|
-
type: literal("terminal")
|
|
53177
|
-
}))
|
|
53178
|
-
]);
|
|
53179
|
-
const zToolCallLocation = object({
|
|
53180
|
-
path: string(),
|
|
53181
|
-
line: defaultOnError(int().gte(0).max(4294967295, {
|
|
53182
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
53183
|
-
}).nullish(), () => void 0),
|
|
53184
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53185
|
-
});
|
|
53186
|
-
const zToolCallUpdate = object({
|
|
53187
|
-
toolCallId: zToolCallId,
|
|
53188
|
-
kind: defaultOnError(zToolKind.nullish(), () => void 0),
|
|
53189
|
-
status: defaultOnError(zToolCallStatus.nullish(), () => void 0),
|
|
53190
|
-
title: defaultOnError(string().nullish(), () => void 0),
|
|
53191
|
-
name: defaultOnError(string().nullish(), () => void 0),
|
|
53192
|
-
content: defaultOnError(vecSkipError(zToolCallContent).nullish(), () => void 0),
|
|
53193
|
-
locations: defaultOnError(vecSkipError(zToolCallLocation).nullish(), () => void 0),
|
|
53194
|
-
rawInput: defaultOnError(unknown().optional(), () => void 0),
|
|
53195
|
-
rawOutput: defaultOnError(unknown().optional(), () => void 0),
|
|
53196
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53197
|
-
});
|
|
53198
|
-
const zPermissionOptionId = string();
|
|
53199
|
-
const zPermissionOptionKind = union([
|
|
53200
|
-
literal("allow_once"),
|
|
53201
|
-
literal("allow_always"),
|
|
53202
|
-
literal("reject_once"),
|
|
53203
|
-
literal("reject_always")
|
|
53204
|
-
]);
|
|
53205
|
-
const zPermissionOption = object({
|
|
53206
|
-
optionId: zPermissionOptionId,
|
|
53207
|
-
name: string(),
|
|
53208
|
-
kind: zPermissionOptionKind,
|
|
53209
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53210
|
-
});
|
|
53211
|
-
const zRequestPermissionRequest = object({
|
|
53212
|
-
sessionId: zSessionId,
|
|
53213
|
-
toolCall: zToolCallUpdate,
|
|
53214
|
-
options: array(zPermissionOption),
|
|
53215
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53216
|
-
});
|
|
53217
|
-
const zEnvVariable = object({
|
|
53218
|
-
name: string(),
|
|
53219
|
-
value: string(),
|
|
53220
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53221
|
-
});
|
|
53222
|
-
const zCreateTerminalRequest = object({
|
|
53223
|
-
sessionId: zSessionId,
|
|
53224
|
-
command: string(),
|
|
53225
|
-
args: defaultOnError(vecSkipError(string()).optional(), () => []),
|
|
53226
|
-
env: defaultOnError(vecSkipError(zEnvVariable).optional(), () => []),
|
|
53227
|
-
cwd: defaultOnError(string().nullish(), () => void 0),
|
|
53228
|
-
outputByteLimit: defaultOnError(number().nullish(), () => void 0),
|
|
53229
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53230
|
-
});
|
|
53231
|
-
const zTerminalOutputRequest = object({
|
|
53232
|
-
sessionId: zSessionId,
|
|
53233
|
-
terminalId: zTerminalId,
|
|
53234
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53235
|
-
});
|
|
53236
|
-
const zReleaseTerminalRequest = object({
|
|
53237
|
-
sessionId: zSessionId,
|
|
53238
|
-
terminalId: zTerminalId,
|
|
53239
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53240
|
-
});
|
|
53241
|
-
const zWaitForTerminalExitRequest = object({
|
|
53242
|
-
sessionId: zSessionId,
|
|
53243
|
-
terminalId: zTerminalId,
|
|
53244
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53245
|
-
});
|
|
53246
|
-
const zKillTerminalRequest = object({
|
|
53247
|
-
sessionId: zSessionId,
|
|
53248
|
-
terminalId: zTerminalId,
|
|
53249
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53250
|
-
});
|
|
53251
|
-
const zElicitationSessionScope = object({
|
|
53252
|
-
sessionId: zSessionId,
|
|
53253
|
-
toolCallId: defaultOnError(zToolCallId.nullish(), () => void 0)
|
|
53254
|
-
});
|
|
53255
|
-
const zElicitationRequestScope = object({
|
|
53256
|
-
requestId: zRequestId
|
|
53257
|
-
});
|
|
53258
|
-
const zElicitationSchemaType = literal("object");
|
|
53259
|
-
const zStringFormat = union([
|
|
53260
|
-
literal("email"),
|
|
53261
|
-
literal("uri"),
|
|
53262
|
-
literal("date"),
|
|
53263
|
-
literal("date-time")
|
|
53264
|
-
]);
|
|
53265
|
-
const zEnumOption = object({
|
|
53266
|
-
const: string(),
|
|
53267
|
-
title: string(),
|
|
53268
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53269
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53270
|
-
});
|
|
53271
|
-
const zStringPropertySchema = object({
|
|
53272
|
-
title: defaultOnError(string().nullish(), () => void 0),
|
|
53273
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53274
|
-
minLength: int().gte(0).max(4294967295, {
|
|
53275
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
53276
|
-
}).nullish(),
|
|
53277
|
-
maxLength: int().gte(0).max(4294967295, {
|
|
53278
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
53279
|
-
}).nullish(),
|
|
53280
|
-
pattern: string().nullish(),
|
|
53281
|
-
format: zStringFormat.nullish(),
|
|
53282
|
-
default: defaultOnError(string().nullish(), () => void 0),
|
|
53283
|
-
enum: array(string()).nullish(),
|
|
53284
|
-
oneOf: array(zEnumOption).nullish(),
|
|
53285
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53286
|
-
});
|
|
53287
|
-
const zNumberPropertySchema = object({
|
|
53288
|
-
title: defaultOnError(string().nullish(), () => void 0),
|
|
53289
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53290
|
-
minimum: number().nullish(),
|
|
53291
|
-
maximum: number().nullish(),
|
|
53292
|
-
default: defaultOnError(number().nullish(), () => void 0),
|
|
53293
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53294
|
-
});
|
|
53295
|
-
const zIntegerPropertySchema = object({
|
|
53296
|
-
title: defaultOnError(string().nullish(), () => void 0),
|
|
53297
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53298
|
-
minimum: number().nullish(),
|
|
53299
|
-
maximum: number().nullish(),
|
|
53300
|
-
default: defaultOnError(number().nullish(), () => void 0),
|
|
53301
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53302
|
-
});
|
|
53303
|
-
const zBooleanPropertySchema = object({
|
|
53304
|
-
title: defaultOnError(string().nullish(), () => void 0),
|
|
53305
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53306
|
-
default: defaultOnError(boolean().nullish(), () => void 0),
|
|
53307
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53308
|
-
});
|
|
53309
|
-
const zStringMultiSelectItems = object({
|
|
53310
|
-
enum: array(string()),
|
|
53311
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53312
|
-
});
|
|
53313
|
-
const zTitledMultiSelectItems = object({
|
|
53314
|
-
anyOf: array(zEnumOption),
|
|
53315
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53316
|
-
});
|
|
53317
|
-
const zMultiSelectItems = preserveCustomPayload(union([
|
|
53318
|
-
zStringMultiSelectItems.and(object({
|
|
53319
|
-
type: literal("string")
|
|
53320
|
-
})),
|
|
53321
|
-
excludeKnownTags(object({
|
|
53322
|
-
type: string()
|
|
53323
|
-
}), "type", [
|
|
53324
|
-
"string"
|
|
53325
|
-
]),
|
|
53326
|
-
zTitledMultiSelectItems
|
|
53327
|
-
]), "type", [
|
|
53328
|
-
"string"
|
|
53329
|
-
]);
|
|
53330
|
-
const zMultiSelectPropertySchema = object({
|
|
53331
|
-
title: defaultOnError(string().nullish(), () => void 0),
|
|
53332
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53333
|
-
minItems: number().nullish(),
|
|
53334
|
-
maxItems: number().nullish(),
|
|
53335
|
-
items: zMultiSelectItems,
|
|
53336
|
-
default: defaultOnError(vecSkipError(string()).nullish(), () => void 0),
|
|
53337
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53338
|
-
});
|
|
53339
|
-
const zElicitationPropertySchema = preserveCustomPayload(union([
|
|
53340
|
-
zStringPropertySchema.and(object({
|
|
53341
|
-
type: literal("string")
|
|
53342
|
-
})),
|
|
53343
|
-
zNumberPropertySchema.and(object({
|
|
53344
|
-
type: literal("number")
|
|
53345
|
-
})),
|
|
53346
|
-
zIntegerPropertySchema.and(object({
|
|
53347
|
-
type: literal("integer")
|
|
53348
|
-
})),
|
|
53349
|
-
zBooleanPropertySchema.and(object({
|
|
53350
|
-
type: literal("boolean")
|
|
53351
|
-
})),
|
|
53352
|
-
zMultiSelectPropertySchema.and(object({
|
|
53353
|
-
type: literal("array")
|
|
53354
|
-
})),
|
|
53355
|
-
excludeKnownTags(object({
|
|
53356
|
-
type: string()
|
|
53357
|
-
}), "type", [
|
|
53358
|
-
"array",
|
|
53359
|
-
"boolean",
|
|
53360
|
-
"integer",
|
|
53361
|
-
"number",
|
|
53362
|
-
"string"
|
|
53363
|
-
])
|
|
53364
|
-
]), "type", [
|
|
53365
|
-
"array",
|
|
53366
|
-
"boolean",
|
|
53367
|
-
"integer",
|
|
53368
|
-
"number",
|
|
53369
|
-
"string"
|
|
53370
|
-
]);
|
|
53371
|
-
const zElicitationSchema = object({
|
|
53372
|
-
type: defaultOnError(zElicitationSchemaType.optional().default("object"), () => "object"),
|
|
53373
|
-
title: defaultOnError(string().nullish(), () => void 0),
|
|
53374
|
-
properties: record(string(), zElicitationPropertySchema).optional().default({}),
|
|
53375
|
-
required: array(string()).nullish(),
|
|
53376
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53377
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53378
|
-
});
|
|
53379
|
-
const zElicitationFormMode = intersection(union([
|
|
53380
|
-
zElicitationSessionScope,
|
|
53381
|
-
zElicitationRequestScope
|
|
53382
|
-
]), object({
|
|
53383
|
-
requestedSchema: zElicitationSchema
|
|
53384
|
-
}));
|
|
53385
|
-
const zElicitationId = string();
|
|
53386
|
-
const zElicitationUrlMode = intersection(union([
|
|
53387
|
-
zElicitationSessionScope,
|
|
53388
|
-
zElicitationRequestScope
|
|
53389
|
-
]), object({
|
|
53390
|
-
elicitationId: zElicitationId,
|
|
53391
|
-
url: url()
|
|
53392
|
-
}));
|
|
53393
|
-
const zCreateElicitationRequest = preserveCustomPayload(intersection(union([
|
|
53394
|
-
zElicitationFormMode.and(object({
|
|
53395
|
-
mode: literal("form")
|
|
53396
|
-
})),
|
|
53397
|
-
zElicitationUrlMode.and(object({
|
|
53398
|
-
mode: literal("url")
|
|
53399
|
-
})),
|
|
53400
|
-
excludeKnownTags(intersection(union([
|
|
53401
|
-
zElicitationSessionScope,
|
|
53402
|
-
zElicitationRequestScope
|
|
53403
|
-
]), object({
|
|
53404
|
-
mode: string()
|
|
53405
|
-
})), "mode", [
|
|
53406
|
-
"form",
|
|
53407
|
-
"url"
|
|
53408
|
-
])
|
|
53409
|
-
]), object({
|
|
53410
|
-
message: string(),
|
|
53411
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53412
|
-
})), "mode", [
|
|
53413
|
-
"form",
|
|
53414
|
-
"url"
|
|
53415
|
-
]);
|
|
53416
|
-
const zMcpServerAcpId = string();
|
|
53417
|
-
const zConnectMcpRequest = object({
|
|
53418
|
-
serverId: zMcpServerAcpId,
|
|
53419
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53420
|
-
});
|
|
53421
|
-
const zMcpConnectionId = string();
|
|
53422
|
-
const zMessageMcpRequest = object({
|
|
53423
|
-
connectionId: zMcpConnectionId,
|
|
53424
|
-
method: string(),
|
|
53425
|
-
params: record(string(), unknown()).nullish(),
|
|
53426
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53427
|
-
});
|
|
53428
|
-
const zDisconnectMcpRequest = object({
|
|
53429
|
-
connectionId: zMcpConnectionId,
|
|
53430
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53431
|
-
});
|
|
53432
|
-
const zExtRequest = unknown();
|
|
53433
|
-
object({
|
|
53434
|
-
id: zRequestId,
|
|
53435
|
-
method: string(),
|
|
53436
|
-
params: union([
|
|
53437
|
-
zWriteTextFileRequest,
|
|
53438
|
-
zReadTextFileRequest,
|
|
53439
|
-
zRequestPermissionRequest,
|
|
53440
|
-
zCreateTerminalRequest,
|
|
53441
|
-
zTerminalOutputRequest,
|
|
53442
|
-
zReleaseTerminalRequest,
|
|
53443
|
-
zWaitForTerminalExitRequest,
|
|
53444
|
-
zKillTerminalRequest,
|
|
53445
|
-
zCreateElicitationRequest,
|
|
53446
|
-
zConnectMcpRequest,
|
|
53447
|
-
zMessageMcpRequest,
|
|
53448
|
-
zDisconnectMcpRequest,
|
|
53449
|
-
zExtRequest
|
|
53450
|
-
]).nullish()
|
|
53451
|
-
});
|
|
53452
|
-
const zProtocolVersion = int().gte(0).lte(65535);
|
|
53453
|
-
const zPromptCapabilities = object({
|
|
53454
|
-
image: defaultOnError(boolean().optional().default(false), () => false),
|
|
53455
|
-
audio: defaultOnError(boolean().optional().default(false), () => false),
|
|
53456
|
-
embeddedContext: defaultOnError(boolean().optional().default(false), () => false),
|
|
53457
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53458
|
-
});
|
|
53459
|
-
const zMcpCapabilities = object({
|
|
53460
|
-
http: defaultOnError(boolean().optional().default(false), () => false),
|
|
53461
|
-
sse: defaultOnError(boolean().optional().default(false), () => false),
|
|
53462
|
-
acp: defaultOnError(boolean().optional().default(false), () => false),
|
|
53463
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53464
|
-
});
|
|
53465
|
-
const zSessionListCapabilities = object({
|
|
53466
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53467
|
-
});
|
|
53468
|
-
const zSessionDeleteCapabilities = object({
|
|
53469
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53470
|
-
});
|
|
53471
|
-
const zSessionAdditionalDirectoriesCapabilities = object({
|
|
53472
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53473
|
-
});
|
|
53474
|
-
const zSessionForkCapabilities = object({
|
|
53475
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53476
|
-
});
|
|
53477
|
-
const zSessionResumeCapabilities = object({
|
|
53478
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53479
|
-
});
|
|
53480
|
-
const zSessionCloseCapabilities = object({
|
|
53481
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53482
|
-
});
|
|
53483
|
-
const zSessionCapabilities = object({
|
|
53484
|
-
list: defaultOnError(zSessionListCapabilities.nullish(), () => void 0),
|
|
53485
|
-
delete: defaultOnError(zSessionDeleteCapabilities.nullish(), () => void 0),
|
|
53486
|
-
additionalDirectories: defaultOnError(zSessionAdditionalDirectoriesCapabilities.nullish(), () => void 0),
|
|
53487
|
-
fork: defaultOnError(zSessionForkCapabilities.nullish(), () => void 0),
|
|
53488
|
-
resume: defaultOnError(zSessionResumeCapabilities.nullish(), () => void 0),
|
|
53489
|
-
close: defaultOnError(zSessionCloseCapabilities.nullish(), () => void 0),
|
|
53490
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53491
|
-
});
|
|
53492
|
-
const zLogoutCapabilities = object({
|
|
53493
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53494
|
-
});
|
|
53495
|
-
const zAgentAuthCapabilities = object({
|
|
53496
|
-
logout: defaultOnError(zLogoutCapabilities.nullish(), () => void 0),
|
|
53497
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53498
|
-
});
|
|
53499
|
-
const zProvidersCapabilities = object({
|
|
53500
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53501
|
-
});
|
|
53502
|
-
const zNesDocumentDidOpenCapabilities = object({
|
|
53503
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53504
|
-
});
|
|
53505
|
-
const zTextDocumentSyncKind = union([
|
|
53506
|
-
literal("full"),
|
|
53507
|
-
literal("incremental")
|
|
53508
|
-
]);
|
|
53509
|
-
const zNesDocumentDidChangeCapabilities = object({
|
|
53510
|
-
syncKind: zTextDocumentSyncKind,
|
|
53511
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53512
|
-
});
|
|
53513
|
-
const zNesDocumentDidCloseCapabilities = object({
|
|
53514
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53515
|
-
});
|
|
53516
|
-
const zNesDocumentDidSaveCapabilities = object({
|
|
53517
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53518
|
-
});
|
|
53519
|
-
const zNesDocumentDidFocusCapabilities = object({
|
|
53520
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53521
|
-
});
|
|
53522
|
-
const zNesDocumentEventCapabilities = object({
|
|
53523
|
-
didOpen: defaultOnError(zNesDocumentDidOpenCapabilities.nullish(), () => void 0),
|
|
53524
|
-
didChange: defaultOnError(zNesDocumentDidChangeCapabilities.nullish(), () => void 0),
|
|
53525
|
-
didClose: defaultOnError(zNesDocumentDidCloseCapabilities.nullish(), () => void 0),
|
|
53526
|
-
didSave: defaultOnError(zNesDocumentDidSaveCapabilities.nullish(), () => void 0),
|
|
53527
|
-
didFocus: defaultOnError(zNesDocumentDidFocusCapabilities.nullish(), () => void 0),
|
|
53528
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53529
|
-
});
|
|
53530
|
-
const zNesEventCapabilities = object({
|
|
53531
|
-
document: defaultOnError(zNesDocumentEventCapabilities.nullish(), () => void 0),
|
|
53532
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53533
|
-
});
|
|
53534
|
-
const zNesRecentFilesCapabilities = object({
|
|
53535
|
-
maxCount: defaultOnError(int().gte(0).max(4294967295, {
|
|
53536
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
53537
|
-
}).nullish(), () => void 0),
|
|
53538
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53539
|
-
});
|
|
53540
|
-
const zNesRelatedSnippetsCapabilities = object({
|
|
53541
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53542
|
-
});
|
|
53543
|
-
const zNesEditHistoryCapabilities = object({
|
|
53544
|
-
maxCount: defaultOnError(int().gte(0).max(4294967295, {
|
|
53545
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
53546
|
-
}).nullish(), () => void 0),
|
|
53547
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53548
|
-
});
|
|
53549
|
-
const zNesUserActionsCapabilities = object({
|
|
53550
|
-
maxCount: defaultOnError(int().gte(0).max(4294967295, {
|
|
53551
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
53552
|
-
}).nullish(), () => void 0),
|
|
53553
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53554
|
-
});
|
|
53555
|
-
const zNesOpenFilesCapabilities = object({
|
|
53556
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53557
|
-
});
|
|
53558
|
-
const zNesDiagnosticsCapabilities = object({
|
|
53559
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53560
|
-
});
|
|
53561
|
-
const zNesContextCapabilities = object({
|
|
53562
|
-
recentFiles: defaultOnError(zNesRecentFilesCapabilities.nullish(), () => void 0),
|
|
53563
|
-
relatedSnippets: defaultOnError(zNesRelatedSnippetsCapabilities.nullish(), () => void 0),
|
|
53564
|
-
editHistory: defaultOnError(zNesEditHistoryCapabilities.nullish(), () => void 0),
|
|
53565
|
-
userActions: defaultOnError(zNesUserActionsCapabilities.nullish(), () => void 0),
|
|
53566
|
-
openFiles: defaultOnError(zNesOpenFilesCapabilities.nullish(), () => void 0),
|
|
53567
|
-
diagnostics: defaultOnError(zNesDiagnosticsCapabilities.nullish(), () => void 0),
|
|
53568
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53569
|
-
});
|
|
53570
|
-
const zNesCapabilities = object({
|
|
53571
|
-
events: defaultOnError(zNesEventCapabilities.nullish(), () => void 0),
|
|
53572
|
-
context: defaultOnError(zNesContextCapabilities.nullish(), () => void 0),
|
|
53573
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53574
|
-
});
|
|
53575
|
-
const zPositionEncodingKind = union([
|
|
53576
|
-
literal("utf-16"),
|
|
53577
|
-
literal("utf-32"),
|
|
53578
|
-
literal("utf-8")
|
|
53579
|
-
]);
|
|
53580
|
-
const zAgentCapabilities = object({
|
|
53581
|
-
loadSession: defaultOnError(boolean().optional().default(false), () => false),
|
|
53582
|
-
promptCapabilities: defaultOnError(zPromptCapabilities.optional().default({
|
|
53583
|
-
image: false,
|
|
53584
|
-
audio: false,
|
|
53585
|
-
embeddedContext: false
|
|
53586
|
-
}), () => ({
|
|
53587
|
-
image: false,
|
|
53588
|
-
audio: false,
|
|
53589
|
-
embeddedContext: false
|
|
53590
|
-
})),
|
|
53591
|
-
mcpCapabilities: defaultOnError(zMcpCapabilities.optional().default({
|
|
53592
|
-
http: false,
|
|
53593
|
-
sse: false,
|
|
53594
|
-
acp: false
|
|
53595
|
-
}), () => ({
|
|
53596
|
-
http: false,
|
|
53597
|
-
sse: false,
|
|
53598
|
-
acp: false
|
|
53599
|
-
})),
|
|
53600
|
-
sessionCapabilities: defaultOnError(zSessionCapabilities.optional().default({}), () => ({})),
|
|
53601
|
-
auth: defaultOnError(zAgentAuthCapabilities.optional().default({}), () => ({})),
|
|
53602
|
-
providers: defaultOnError(zProvidersCapabilities.nullish(), () => void 0),
|
|
53603
|
-
nes: defaultOnError(zNesCapabilities.nullish(), () => void 0),
|
|
53604
|
-
positionEncoding: defaultOnError(zPositionEncodingKind.nullish(), () => void 0),
|
|
53605
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53606
|
-
});
|
|
53607
|
-
const zAuthMethodId = string();
|
|
53608
|
-
const zAuthEnvVar = object({
|
|
53609
|
-
name: string(),
|
|
53610
|
-
label: defaultOnError(string().nullish(), () => void 0),
|
|
53611
|
-
secret: defaultOnError(boolean().optional().default(true), () => true),
|
|
53612
|
-
optional: defaultOnError(boolean().optional().default(false), () => false),
|
|
53613
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53614
|
-
});
|
|
53615
|
-
const zAuthMethodEnvVar = object({
|
|
53616
|
-
id: zAuthMethodId,
|
|
53617
|
-
name: string(),
|
|
53618
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53619
|
-
vars: requiredDefaultOnError(vecSkipError(zAuthEnvVar), () => []),
|
|
53620
|
-
link: defaultOnError(string().nullish(), () => void 0),
|
|
53621
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53622
|
-
});
|
|
53623
|
-
const zAuthMethodTerminal = object({
|
|
53624
|
-
id: zAuthMethodId,
|
|
53625
|
-
name: string(),
|
|
53626
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53627
|
-
args: defaultOnError(vecSkipError(string()).optional(), () => []),
|
|
53628
|
-
env: defaultOnError(record(string(), string()).optional(), () => void 0),
|
|
53629
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53630
|
-
});
|
|
53631
|
-
const zAuthMethodAgent = object({
|
|
53632
|
-
id: zAuthMethodId,
|
|
53633
|
-
name: string(),
|
|
53634
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53635
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53636
|
-
});
|
|
53637
|
-
const zAuthMethod = union([
|
|
53638
|
-
zAuthMethodEnvVar.and(object({
|
|
53639
|
-
type: literal("env_var")
|
|
53640
|
-
})),
|
|
53641
|
-
zAuthMethodTerminal.and(object({
|
|
53642
|
-
type: literal("terminal")
|
|
53643
|
-
})),
|
|
53644
|
-
zAuthMethodAgent
|
|
53645
|
-
]);
|
|
53646
|
-
const zImplementation = object({
|
|
53647
|
-
name: string(),
|
|
53648
|
-
title: defaultOnError(string().nullish(), () => void 0),
|
|
53649
|
-
version: string(),
|
|
53650
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53651
|
-
});
|
|
53652
|
-
const zInitializeResponse = object({
|
|
53653
|
-
protocolVersion: zProtocolVersion,
|
|
53654
|
-
agentCapabilities: defaultOnError(zAgentCapabilities.optional().default({
|
|
53655
|
-
loadSession: false,
|
|
53656
|
-
promptCapabilities: {
|
|
53657
|
-
image: false,
|
|
53658
|
-
audio: false,
|
|
53659
|
-
embeddedContext: false
|
|
53660
|
-
},
|
|
53661
|
-
mcpCapabilities: {
|
|
53662
|
-
http: false,
|
|
53663
|
-
sse: false,
|
|
53664
|
-
acp: false
|
|
53665
|
-
},
|
|
53666
|
-
sessionCapabilities: {},
|
|
53667
|
-
auth: {}
|
|
53668
|
-
}), () => ({
|
|
53669
|
-
loadSession: false,
|
|
53670
|
-
promptCapabilities: {
|
|
53671
|
-
image: false,
|
|
53672
|
-
audio: false,
|
|
53673
|
-
embeddedContext: false
|
|
53674
|
-
},
|
|
53675
|
-
mcpCapabilities: {
|
|
53676
|
-
http: false,
|
|
53677
|
-
sse: false,
|
|
53678
|
-
acp: false
|
|
53679
|
-
},
|
|
53680
|
-
sessionCapabilities: {},
|
|
53681
|
-
auth: {}
|
|
53682
|
-
})),
|
|
53683
|
-
authMethods: defaultOnError(vecSkipError(zAuthMethod).optional().default([]), () => []),
|
|
53684
|
-
agentInfo: defaultOnError(zImplementation.nullish(), () => void 0),
|
|
53685
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53686
|
-
});
|
|
53687
|
-
const zAuthenticateResponse = object({
|
|
53688
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53689
|
-
});
|
|
53690
|
-
const zProviderId = string();
|
|
53691
|
-
const zLlmProtocol = union([
|
|
53692
|
-
literal("anthropic"),
|
|
53693
|
-
literal("openai"),
|
|
53694
|
-
literal("azure"),
|
|
53695
|
-
literal("vertex"),
|
|
53696
|
-
literal("bedrock"),
|
|
53697
|
-
string()
|
|
53698
|
-
]);
|
|
53699
|
-
const zProviderCurrentConfig = object({
|
|
53700
|
-
apiType: zLlmProtocol,
|
|
53701
|
-
baseUrl: string(),
|
|
53702
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53703
|
-
});
|
|
53704
|
-
const zProviderInfo = object({
|
|
53705
|
-
providerId: zProviderId,
|
|
53706
|
-
supported: requiredDefaultOnError(vecSkipError(zLlmProtocol), () => []),
|
|
53707
|
-
required: boolean(),
|
|
53708
|
-
current: zProviderCurrentConfig.nullish(),
|
|
53709
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53710
|
-
});
|
|
53711
|
-
const zListProvidersResponse = object({
|
|
53712
|
-
providers: array(zProviderInfo),
|
|
53713
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53714
|
-
});
|
|
53715
|
-
const zSetProviderResponse = object({
|
|
53716
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53717
|
-
});
|
|
53718
|
-
const zDisableProviderResponse = object({
|
|
53719
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53720
|
-
});
|
|
53721
|
-
const zLogoutResponse = object({
|
|
53722
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53723
|
-
});
|
|
53724
|
-
const zSessionModeId = string();
|
|
53725
|
-
const zSessionMode = object({
|
|
53726
|
-
id: zSessionModeId,
|
|
53727
|
-
name: string(),
|
|
53728
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53729
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53730
|
-
});
|
|
53731
|
-
const zSessionModeState = object({
|
|
53732
|
-
currentModeId: zSessionModeId,
|
|
53733
|
-
availableModes: requiredDefaultOnError(vecSkipError(zSessionMode), () => []),
|
|
53734
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53735
|
-
});
|
|
53736
|
-
const zSessionConfigId = string();
|
|
53737
|
-
const zSessionConfigOptionCategory = union([
|
|
53738
|
-
literal("mode"),
|
|
53739
|
-
literal("model"),
|
|
53740
|
-
literal("model_config"),
|
|
53741
|
-
literal("thought_level"),
|
|
53742
|
-
string()
|
|
53743
|
-
]);
|
|
53744
|
-
const zSessionConfigValueId = string();
|
|
53745
|
-
const zSessionConfigSelectOption = object({
|
|
53746
|
-
value: zSessionConfigValueId,
|
|
53747
|
-
name: string(),
|
|
53748
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53749
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53750
|
-
});
|
|
53751
|
-
const zSessionConfigGroupId = string();
|
|
53752
|
-
const zSessionConfigSelectGroup = object({
|
|
53753
|
-
group: zSessionConfigGroupId,
|
|
53754
|
-
name: string(),
|
|
53755
|
-
options: requiredDefaultOnError(vecSkipError(zSessionConfigSelectOption), () => []),
|
|
53756
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53757
|
-
});
|
|
53758
|
-
const zSessionConfigSelectOptions = union([
|
|
53759
|
-
array(zSessionConfigSelectOption),
|
|
53760
|
-
array(zSessionConfigSelectGroup)
|
|
53761
|
-
]);
|
|
53762
|
-
const zSessionConfigSelect = object({
|
|
53763
|
-
currentValue: zSessionConfigValueId,
|
|
53764
|
-
options: zSessionConfigSelectOptions
|
|
53765
|
-
});
|
|
53766
|
-
const zSessionConfigBoolean = object({
|
|
53767
|
-
currentValue: boolean()
|
|
53768
|
-
});
|
|
53769
|
-
const zSessionConfigOption = intersection(union([
|
|
53770
|
-
zSessionConfigSelect.and(object({
|
|
53771
|
-
type: literal("select")
|
|
53772
|
-
})),
|
|
53773
|
-
zSessionConfigBoolean.and(object({
|
|
53774
|
-
type: literal("boolean")
|
|
53775
|
-
}))
|
|
53776
|
-
]), object({
|
|
53777
|
-
id: zSessionConfigId,
|
|
53778
|
-
name: string(),
|
|
53779
|
-
description: defaultOnError(string().nullish(), () => void 0),
|
|
53780
|
-
category: defaultOnError(zSessionConfigOptionCategory.nullish(), () => void 0),
|
|
53781
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53782
|
-
}));
|
|
53783
|
-
const zNewSessionResponse = object({
|
|
53784
|
-
sessionId: zSessionId,
|
|
53785
|
-
modes: defaultOnError(zSessionModeState.nullish(), () => void 0),
|
|
53786
|
-
configOptions: defaultOnError(vecSkipError(zSessionConfigOption).nullish(), () => void 0),
|
|
53787
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53788
|
-
});
|
|
53789
|
-
const zLoadSessionResponse = object({
|
|
53790
|
-
modes: defaultOnError(zSessionModeState.nullish(), () => void 0),
|
|
53791
|
-
configOptions: defaultOnError(vecSkipError(zSessionConfigOption).nullish(), () => void 0),
|
|
53792
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53793
|
-
});
|
|
53794
|
-
const zSessionInfo = object({
|
|
53795
|
-
sessionId: zSessionId,
|
|
53796
|
-
cwd: string(),
|
|
53797
|
-
additionalDirectories: defaultOnError(vecSkipError(string()).optional(), () => []),
|
|
53798
|
-
title: defaultOnError(string().nullish(), () => void 0),
|
|
53799
|
-
updatedAt: defaultOnError(string().nullish(), () => void 0),
|
|
53800
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53801
|
-
});
|
|
53802
|
-
const zListSessionsResponse = object({
|
|
53803
|
-
sessions: requiredDefaultOnError(vecSkipError(zSessionInfo), () => []),
|
|
53804
|
-
nextCursor: defaultOnError(string().nullish(), () => void 0),
|
|
53805
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53806
|
-
});
|
|
53807
|
-
const zDeleteSessionResponse = object({
|
|
53808
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53809
|
-
});
|
|
53810
|
-
const zForkSessionResponse = object({
|
|
53811
|
-
sessionId: zSessionId,
|
|
53812
|
-
modes: defaultOnError(zSessionModeState.nullish(), () => void 0),
|
|
53813
|
-
configOptions: defaultOnError(vecSkipError(zSessionConfigOption).nullish(), () => void 0),
|
|
53814
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53815
|
-
});
|
|
53816
|
-
const zResumeSessionResponse = object({
|
|
53817
|
-
modes: defaultOnError(zSessionModeState.nullish(), () => void 0),
|
|
53818
|
-
configOptions: defaultOnError(vecSkipError(zSessionConfigOption).nullish(), () => void 0),
|
|
53819
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53820
|
-
});
|
|
53821
|
-
const zCloseSessionResponse = object({
|
|
53822
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53823
|
-
});
|
|
53824
|
-
const zSetSessionModeResponse = object({
|
|
53825
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53826
|
-
});
|
|
53827
|
-
const zSetSessionConfigOptionResponse = object({
|
|
53828
|
-
configOptions: requiredDefaultOnError(vecSkipError(zSessionConfigOption), () => []),
|
|
53829
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53830
|
-
});
|
|
53831
|
-
const zStopReason = union([
|
|
53832
|
-
literal("end_turn"),
|
|
53833
|
-
literal("max_tokens"),
|
|
53834
|
-
literal("max_turn_requests"),
|
|
53835
|
-
literal("refusal"),
|
|
53836
|
-
literal("cancelled")
|
|
53837
|
-
]);
|
|
53838
|
-
const zUsage = object({
|
|
53839
|
-
totalTokens: number(),
|
|
53840
|
-
inputTokens: number(),
|
|
53841
|
-
outputTokens: number(),
|
|
53842
|
-
thoughtTokens: defaultOnError(number().nullish(), () => void 0),
|
|
53843
|
-
cachedReadTokens: defaultOnError(number().nullish(), () => void 0),
|
|
53844
|
-
cachedWriteTokens: defaultOnError(number().nullish(), () => void 0),
|
|
53845
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53846
|
-
});
|
|
53847
|
-
const zPromptResponse = object({
|
|
53848
|
-
stopReason: zStopReason,
|
|
53849
|
-
usage: defaultOnError(zUsage.nullish(), () => void 0),
|
|
53850
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53851
|
-
});
|
|
53852
|
-
const zStartNesResponse = object({
|
|
53853
|
-
sessionId: zSessionId,
|
|
53854
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53855
|
-
});
|
|
53856
|
-
const zNesSuggestionId = string();
|
|
53857
|
-
const zPosition = object({
|
|
53858
|
-
line: int().gte(0).max(4294967295, {
|
|
53859
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
53860
|
-
}),
|
|
53861
|
-
character: int().gte(0).max(4294967295, {
|
|
53862
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
53863
|
-
}),
|
|
53864
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53865
|
-
});
|
|
53866
|
-
const zRange = object({
|
|
53867
|
-
start: zPosition,
|
|
53868
|
-
end: zPosition,
|
|
53869
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53870
|
-
});
|
|
53871
|
-
const zNesTextEdit = object({
|
|
53872
|
-
range: zRange,
|
|
53873
|
-
newText: string(),
|
|
53874
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53875
|
-
});
|
|
53876
|
-
const zNesEditSuggestion = object({
|
|
53877
|
-
id: zNesSuggestionId,
|
|
53878
|
-
uri: string(),
|
|
53879
|
-
edits: array(zNesTextEdit),
|
|
53880
|
-
cursorPosition: defaultOnError(zPosition.nullish(), () => void 0),
|
|
53881
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53882
|
-
});
|
|
53883
|
-
const zNesJumpSuggestion = object({
|
|
53884
|
-
id: zNesSuggestionId,
|
|
53885
|
-
uri: string(),
|
|
53886
|
-
position: zPosition,
|
|
53887
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53888
|
-
});
|
|
53889
|
-
const zNesRenameSuggestion = object({
|
|
53890
|
-
id: zNesSuggestionId,
|
|
53891
|
-
uri: string(),
|
|
53892
|
-
position: zPosition,
|
|
53893
|
-
newName: string(),
|
|
53894
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53895
|
-
});
|
|
53896
|
-
const zNesSearchAndReplaceSuggestion = object({
|
|
53897
|
-
id: zNesSuggestionId,
|
|
53898
|
-
uri: string(),
|
|
53899
|
-
search: string(),
|
|
53900
|
-
replace: string(),
|
|
53901
|
-
isRegex: boolean().nullish(),
|
|
53902
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53903
|
-
});
|
|
53904
|
-
const zNesSuggestion = union([
|
|
53905
|
-
zNesEditSuggestion.and(object({
|
|
53906
|
-
kind: literal("edit")
|
|
53907
|
-
})),
|
|
53908
|
-
zNesJumpSuggestion.and(object({
|
|
53909
|
-
kind: literal("jump")
|
|
53910
|
-
})),
|
|
53911
|
-
zNesRenameSuggestion.and(object({
|
|
53912
|
-
kind: literal("rename")
|
|
53913
|
-
})),
|
|
53914
|
-
zNesSearchAndReplaceSuggestion.and(object({
|
|
53915
|
-
kind: literal("searchAndReplace")
|
|
53916
|
-
}))
|
|
53917
|
-
]);
|
|
53918
|
-
const zSuggestNesResponse = object({
|
|
53919
|
-
suggestions: array(zNesSuggestion),
|
|
53920
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53921
|
-
});
|
|
53922
|
-
const zCloseNesResponse = object({
|
|
53923
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53924
|
-
});
|
|
53925
|
-
const zExtResponse = unknown();
|
|
53926
|
-
const zMessageMcpResponse = unknown();
|
|
53927
|
-
const zErrorCode = union([
|
|
53928
|
-
literal(-32700),
|
|
53929
|
-
literal(-32600),
|
|
53930
|
-
literal(-32601),
|
|
53931
|
-
literal(-32602),
|
|
53932
|
-
literal(-32603),
|
|
53933
|
-
literal(-32800),
|
|
53934
|
-
literal(-32e3),
|
|
53935
|
-
literal(-32002),
|
|
53936
|
-
int().min(-2147483648, {
|
|
53937
|
-
error: "Invalid value: Expected int32 to be >= -2147483648"
|
|
53938
|
-
}).max(2147483647, {
|
|
53939
|
-
error: "Invalid value: Expected int32 to be <= 2147483647"
|
|
53940
|
-
})
|
|
53941
|
-
]);
|
|
53942
|
-
const zError = object({
|
|
53943
|
-
code: zErrorCode,
|
|
53944
|
-
message: string(),
|
|
53945
|
-
data: defaultOnError(unknown().optional(), () => void 0)
|
|
53946
|
-
});
|
|
53947
|
-
union([
|
|
53948
|
-
object({
|
|
53949
|
-
id: zRequestId,
|
|
53950
|
-
result: union([
|
|
53951
|
-
zInitializeResponse,
|
|
53952
|
-
zAuthenticateResponse,
|
|
53953
|
-
zListProvidersResponse,
|
|
53954
|
-
zSetProviderResponse,
|
|
53955
|
-
zDisableProviderResponse,
|
|
53956
|
-
zLogoutResponse,
|
|
53957
|
-
zNewSessionResponse,
|
|
53958
|
-
zLoadSessionResponse,
|
|
53959
|
-
zListSessionsResponse,
|
|
53960
|
-
zDeleteSessionResponse,
|
|
53961
|
-
zForkSessionResponse,
|
|
53962
|
-
zResumeSessionResponse,
|
|
53963
|
-
zCloseSessionResponse,
|
|
53964
|
-
zSetSessionModeResponse,
|
|
53965
|
-
zSetSessionConfigOptionResponse,
|
|
53966
|
-
zPromptResponse,
|
|
53967
|
-
zStartNesResponse,
|
|
53968
|
-
zSuggestNesResponse,
|
|
53969
|
-
zCloseNesResponse,
|
|
53970
|
-
zExtResponse,
|
|
53971
|
-
zMessageMcpResponse
|
|
53972
|
-
])
|
|
53973
|
-
}),
|
|
53974
|
-
object({
|
|
53975
|
-
id: zRequestId,
|
|
53976
|
-
error: zError
|
|
53977
|
-
})
|
|
53978
|
-
]);
|
|
53979
|
-
const zMessageId = string();
|
|
53980
|
-
const zContentChunk = object({
|
|
53981
|
-
content: zContentBlock,
|
|
53982
|
-
messageId: defaultOnError(zMessageId.nullish(), () => void 0),
|
|
53983
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53984
|
-
});
|
|
53985
|
-
const zToolCall = object({
|
|
53986
|
-
toolCallId: zToolCallId,
|
|
53987
|
-
title: string(),
|
|
53988
|
-
name: defaultOnError(string().nullish(), () => void 0),
|
|
53989
|
-
kind: defaultOnError(zToolKind.optional(), () => void 0),
|
|
53990
|
-
status: defaultOnError(zToolCallStatus.optional(), () => void 0),
|
|
53991
|
-
content: defaultOnError(vecSkipError(zToolCallContent).optional(), () => []),
|
|
53992
|
-
locations: defaultOnError(vecSkipError(zToolCallLocation).optional(), () => []),
|
|
53993
|
-
rawInput: defaultOnError(unknown().optional(), () => void 0),
|
|
53994
|
-
rawOutput: defaultOnError(unknown().optional(), () => void 0),
|
|
53995
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
53996
|
-
});
|
|
53997
|
-
const zPlanEntryPriority = union([
|
|
53998
|
-
literal("high"),
|
|
53999
|
-
literal("medium"),
|
|
54000
|
-
literal("low")
|
|
54001
|
-
]);
|
|
54002
|
-
const zPlanEntryStatus = union([
|
|
54003
|
-
literal("pending"),
|
|
54004
|
-
literal("in_progress"),
|
|
54005
|
-
literal("completed")
|
|
54006
|
-
]);
|
|
54007
|
-
const zPlanEntry = object({
|
|
54008
|
-
content: string(),
|
|
54009
|
-
priority: zPlanEntryPriority,
|
|
54010
|
-
status: zPlanEntryStatus,
|
|
54011
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54012
|
-
});
|
|
54013
|
-
const zPlan = object({
|
|
54014
|
-
entries: requiredDefaultOnError(vecSkipError(zPlanEntry), () => []),
|
|
54015
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54016
|
-
});
|
|
54017
|
-
const zPlanId = string();
|
|
54018
|
-
const zPlanItems = object({
|
|
54019
|
-
planId: zPlanId,
|
|
54020
|
-
entries: requiredDefaultOnError(vecSkipError(zPlanEntry), () => []),
|
|
54021
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54022
|
-
});
|
|
54023
|
-
const zPlanFile = object({
|
|
54024
|
-
planId: zPlanId,
|
|
54025
|
-
uri: string(),
|
|
54026
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54027
|
-
});
|
|
54028
|
-
const zPlanMarkdown = object({
|
|
54029
|
-
planId: zPlanId,
|
|
54030
|
-
content: string(),
|
|
54031
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54032
|
-
});
|
|
54033
|
-
const zPlanUpdateContent = union([
|
|
54034
|
-
zPlanItems.and(object({
|
|
54035
|
-
type: literal("items")
|
|
54036
|
-
})),
|
|
54037
|
-
zPlanFile.and(object({
|
|
54038
|
-
type: literal("file")
|
|
54039
|
-
})),
|
|
54040
|
-
zPlanMarkdown.and(object({
|
|
54041
|
-
type: literal("markdown")
|
|
54042
|
-
}))
|
|
54043
|
-
]);
|
|
54044
|
-
const zPlanUpdate = object({
|
|
54045
|
-
plan: zPlanUpdateContent,
|
|
54046
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54047
|
-
});
|
|
54048
|
-
const zPlanRemoved = object({
|
|
54049
|
-
planId: zPlanId,
|
|
54050
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54051
|
-
});
|
|
54052
|
-
const zUnstructuredCommandInput = object({
|
|
54053
|
-
hint: string(),
|
|
54054
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54055
|
-
});
|
|
54056
|
-
const zAvailableCommandInput = zUnstructuredCommandInput;
|
|
54057
|
-
const zAvailableCommand = object({
|
|
54058
|
-
name: string(),
|
|
54059
|
-
description: string(),
|
|
54060
|
-
input: defaultOnError(zAvailableCommandInput.nullish(), () => void 0),
|
|
54061
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54062
|
-
});
|
|
54063
|
-
const zAvailableCommandsUpdate = object({
|
|
54064
|
-
availableCommands: requiredDefaultOnError(vecSkipError(zAvailableCommand), () => []),
|
|
54065
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54066
|
-
});
|
|
54067
|
-
const zCurrentModeUpdate = object({
|
|
54068
|
-
currentModeId: zSessionModeId,
|
|
54069
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54070
|
-
});
|
|
54071
|
-
const zConfigOptionUpdate = object({
|
|
54072
|
-
configOptions: requiredDefaultOnError(vecSkipError(zSessionConfigOption), () => []),
|
|
54073
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54074
|
-
});
|
|
54075
|
-
const zSessionInfoUpdate = object({
|
|
54076
|
-
title: defaultOnError(string().nullish(), () => void 0),
|
|
54077
|
-
updatedAt: defaultOnError(string().nullish(), () => void 0),
|
|
54078
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54079
|
-
});
|
|
54080
|
-
const zCost = object({
|
|
54081
|
-
amount: number(),
|
|
54082
|
-
currency: string(),
|
|
54083
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54084
|
-
});
|
|
54085
|
-
const zUsageUpdate = object({
|
|
54086
|
-
used: number(),
|
|
54087
|
-
size: number(),
|
|
54088
|
-
cost: defaultOnError(zCost.nullish(), () => void 0),
|
|
54089
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54090
|
-
});
|
|
54091
|
-
const zSessionUpdate = union([
|
|
54092
|
-
zContentChunk.and(object({
|
|
54093
|
-
sessionUpdate: literal("user_message_chunk")
|
|
54094
|
-
})),
|
|
54095
|
-
zContentChunk.and(object({
|
|
54096
|
-
sessionUpdate: literal("agent_message_chunk")
|
|
54097
|
-
})),
|
|
54098
|
-
zContentChunk.and(object({
|
|
54099
|
-
sessionUpdate: literal("agent_thought_chunk")
|
|
54100
|
-
})),
|
|
54101
|
-
zToolCall.and(object({
|
|
54102
|
-
sessionUpdate: literal("tool_call")
|
|
54103
|
-
})),
|
|
54104
|
-
zToolCallUpdate.and(object({
|
|
54105
|
-
sessionUpdate: literal("tool_call_update")
|
|
54106
|
-
})),
|
|
54107
|
-
zPlan.and(object({
|
|
54108
|
-
sessionUpdate: literal("plan")
|
|
54109
|
-
})),
|
|
54110
|
-
zPlanUpdate.and(object({
|
|
54111
|
-
sessionUpdate: literal("plan_update")
|
|
54112
|
-
})),
|
|
54113
|
-
zPlanRemoved.and(object({
|
|
54114
|
-
sessionUpdate: literal("plan_removed")
|
|
54115
|
-
})),
|
|
54116
|
-
zAvailableCommandsUpdate.and(object({
|
|
54117
|
-
sessionUpdate: literal("available_commands_update")
|
|
54118
|
-
})),
|
|
54119
|
-
zCurrentModeUpdate.and(object({
|
|
54120
|
-
sessionUpdate: literal("current_mode_update")
|
|
54121
|
-
})),
|
|
54122
|
-
zConfigOptionUpdate.and(object({
|
|
54123
|
-
sessionUpdate: literal("config_option_update")
|
|
54124
|
-
})),
|
|
54125
|
-
zSessionInfoUpdate.and(object({
|
|
54126
|
-
sessionUpdate: literal("session_info_update")
|
|
54127
|
-
})),
|
|
54128
|
-
zUsageUpdate.and(object({
|
|
54129
|
-
sessionUpdate: literal("usage_update")
|
|
54130
|
-
}))
|
|
54131
|
-
]);
|
|
54132
|
-
const zSessionNotification = object({
|
|
54133
|
-
sessionId: zSessionId,
|
|
54134
|
-
update: zSessionUpdate,
|
|
54135
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54136
|
-
});
|
|
54137
|
-
const zCompleteElicitationNotification = object({
|
|
54138
|
-
elicitationId: zElicitationId,
|
|
54139
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54140
|
-
});
|
|
54141
|
-
const zMessageMcpNotification = object({
|
|
54142
|
-
connectionId: zMcpConnectionId,
|
|
54143
|
-
method: string(),
|
|
54144
|
-
params: defaultOnError(record(string(), unknown()).nullish(), () => void 0),
|
|
54145
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54146
|
-
});
|
|
54147
|
-
const zExtNotification = unknown();
|
|
54148
|
-
object({
|
|
54149
|
-
method: string(),
|
|
54150
|
-
params: union([
|
|
54151
|
-
zSessionNotification,
|
|
54152
|
-
zCompleteElicitationNotification,
|
|
54153
|
-
zMessageMcpNotification,
|
|
54154
|
-
zExtNotification
|
|
54155
|
-
]).nullish()
|
|
54156
|
-
});
|
|
54157
|
-
const zFileSystemCapabilities = object({
|
|
54158
|
-
readTextFile: defaultOnError(boolean().optional().default(false), () => false),
|
|
54159
|
-
writeTextFile: defaultOnError(boolean().optional().default(false), () => false),
|
|
54160
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54161
|
-
});
|
|
54162
|
-
const zBooleanConfigOptionCapabilities = object({
|
|
54163
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54164
|
-
});
|
|
54165
|
-
const zSessionConfigOptionsCapabilities = object({
|
|
54166
|
-
boolean: defaultOnError(zBooleanConfigOptionCapabilities.nullish(), () => void 0),
|
|
54167
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54168
|
-
});
|
|
54169
|
-
const zClientSessionCapabilities = object({
|
|
54170
|
-
configOptions: defaultOnError(zSessionConfigOptionsCapabilities.nullish(), () => void 0),
|
|
54171
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54172
|
-
});
|
|
54173
|
-
const zPlanCapabilities = object({
|
|
54174
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54175
|
-
});
|
|
54176
|
-
const zAuthCapabilities = object({
|
|
54177
|
-
terminal: defaultOnError(boolean().optional().default(false), () => false),
|
|
54178
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54179
|
-
});
|
|
54180
|
-
const zElicitationFormCapabilities = object({
|
|
54181
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54182
|
-
});
|
|
54183
|
-
const zElicitationUrlCapabilities = object({
|
|
54184
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54185
|
-
});
|
|
54186
|
-
const zElicitationCapabilities = object({
|
|
54187
|
-
form: defaultOnError(zElicitationFormCapabilities.nullish(), () => void 0),
|
|
54188
|
-
url: defaultOnError(zElicitationUrlCapabilities.nullish(), () => void 0),
|
|
54189
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54190
|
-
});
|
|
54191
|
-
const zNesJumpCapabilities = object({
|
|
54192
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54193
|
-
});
|
|
54194
|
-
const zNesRenameCapabilities = object({
|
|
54195
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54196
|
-
});
|
|
54197
|
-
const zNesSearchAndReplaceCapabilities = object({
|
|
54198
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54199
|
-
});
|
|
54200
|
-
const zClientNesCapabilities = object({
|
|
54201
|
-
jump: defaultOnError(zNesJumpCapabilities.nullish(), () => void 0),
|
|
54202
|
-
rename: defaultOnError(zNesRenameCapabilities.nullish(), () => void 0),
|
|
54203
|
-
searchAndReplace: defaultOnError(zNesSearchAndReplaceCapabilities.nullish(), () => void 0),
|
|
54204
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54205
|
-
});
|
|
54206
|
-
const zClientCapabilities = object({
|
|
54207
|
-
fs: defaultOnError(zFileSystemCapabilities.optional().default({
|
|
54208
|
-
readTextFile: false,
|
|
54209
|
-
writeTextFile: false
|
|
54210
|
-
}), () => ({
|
|
54211
|
-
readTextFile: false,
|
|
54212
|
-
writeTextFile: false
|
|
54213
|
-
})),
|
|
54214
|
-
terminal: defaultOnError(boolean().optional().default(false), () => false),
|
|
54215
|
-
session: defaultOnError(zClientSessionCapabilities.nullish(), () => void 0),
|
|
54216
|
-
plan: defaultOnError(zPlanCapabilities.nullish(), () => void 0),
|
|
54217
|
-
auth: defaultOnError(zAuthCapabilities.optional().default({
|
|
54218
|
-
terminal: false
|
|
54219
|
-
}), () => ({
|
|
54220
|
-
terminal: false
|
|
54221
|
-
})),
|
|
54222
|
-
elicitation: defaultOnError(zElicitationCapabilities.nullish(), () => void 0),
|
|
54223
|
-
nes: defaultOnError(zClientNesCapabilities.nullish(), () => void 0),
|
|
54224
|
-
positionEncodings: defaultOnError(vecSkipError(zPositionEncodingKind).optional(), () => []),
|
|
54225
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54226
|
-
});
|
|
54227
|
-
const zInitializeRequest = object({
|
|
54228
|
-
protocolVersion: zProtocolVersion,
|
|
54229
|
-
clientCapabilities: defaultOnError(zClientCapabilities.optional().default({
|
|
54230
|
-
fs: {
|
|
54231
|
-
readTextFile: false,
|
|
54232
|
-
writeTextFile: false
|
|
54233
|
-
},
|
|
54234
|
-
terminal: false,
|
|
54235
|
-
auth: {
|
|
54236
|
-
terminal: false
|
|
54237
|
-
}
|
|
54238
|
-
}), () => ({
|
|
54239
|
-
fs: {
|
|
54240
|
-
readTextFile: false,
|
|
54241
|
-
writeTextFile: false
|
|
54242
|
-
},
|
|
54243
|
-
terminal: false,
|
|
54244
|
-
auth: {
|
|
54245
|
-
terminal: false
|
|
54246
|
-
}
|
|
54247
|
-
})),
|
|
54248
|
-
clientInfo: defaultOnError(zImplementation.nullish(), () => void 0),
|
|
54249
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54250
|
-
});
|
|
54251
|
-
const zAuthenticateRequest = object({
|
|
54252
|
-
methodId: zAuthMethodId,
|
|
54253
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54254
|
-
});
|
|
54255
|
-
const zListProvidersRequest = object({
|
|
54256
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54257
|
-
});
|
|
54258
|
-
const zSetProviderRequest = object({
|
|
54259
|
-
providerId: zProviderId,
|
|
54260
|
-
apiType: zLlmProtocol,
|
|
54261
|
-
baseUrl: string(),
|
|
54262
|
-
headers: record(string(), string()).optional(),
|
|
54263
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54264
|
-
});
|
|
54265
|
-
const zDisableProviderRequest = object({
|
|
54266
|
-
providerId: zProviderId,
|
|
54267
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54268
|
-
});
|
|
54269
|
-
const zLogoutRequest = object({
|
|
54270
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54271
|
-
});
|
|
54272
|
-
const zHttpHeader = object({
|
|
54273
|
-
name: string(),
|
|
54274
|
-
value: string(),
|
|
54275
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54276
|
-
});
|
|
54277
|
-
const zMcpServerHttp = object({
|
|
54278
|
-
name: string(),
|
|
54279
|
-
url: string(),
|
|
54280
|
-
headers: array(zHttpHeader),
|
|
54281
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54282
|
-
});
|
|
54283
|
-
const zMcpServerSse = object({
|
|
54284
|
-
name: string(),
|
|
54285
|
-
url: string(),
|
|
54286
|
-
headers: array(zHttpHeader),
|
|
54287
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54288
|
-
});
|
|
54289
|
-
const zMcpServerAcp = object({
|
|
54290
|
-
name: string(),
|
|
54291
|
-
serverId: zMcpServerAcpId,
|
|
54292
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54293
|
-
});
|
|
54294
|
-
const zMcpServerStdio = object({
|
|
54295
|
-
name: string(),
|
|
54296
|
-
command: string(),
|
|
54297
|
-
args: array(string()),
|
|
54298
|
-
env: array(zEnvVariable),
|
|
54299
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54300
|
-
});
|
|
54301
|
-
const zMcpServer = union([
|
|
54302
|
-
zMcpServerHttp.and(object({
|
|
54303
|
-
type: literal("http")
|
|
54304
|
-
})),
|
|
54305
|
-
zMcpServerSse.and(object({
|
|
54306
|
-
type: literal("sse")
|
|
54307
|
-
})),
|
|
54308
|
-
zMcpServerAcp.and(object({
|
|
54309
|
-
type: literal("acp")
|
|
54310
|
-
})),
|
|
54311
|
-
zMcpServerStdio
|
|
54312
|
-
]);
|
|
54313
|
-
const zNewSessionRequest = object({
|
|
54314
|
-
cwd: string(),
|
|
54315
|
-
additionalDirectories: defaultOnError(vecSkipError(string()).optional(), () => []),
|
|
54316
|
-
mcpServers: requiredDefaultOnError(vecSkipError(zMcpServer), () => []),
|
|
54317
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54318
|
-
});
|
|
54319
|
-
const zLoadSessionRequest = object({
|
|
54320
|
-
mcpServers: requiredDefaultOnError(vecSkipError(zMcpServer), () => []),
|
|
54321
|
-
cwd: string(),
|
|
54322
|
-
additionalDirectories: defaultOnError(vecSkipError(string()).optional(), () => []),
|
|
54323
|
-
sessionId: zSessionId,
|
|
54324
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54325
|
-
});
|
|
54326
|
-
const zListSessionsRequest = object({
|
|
54327
|
-
cwd: string().nullish(),
|
|
54328
|
-
cursor: string().nullish(),
|
|
54329
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54330
|
-
});
|
|
54331
|
-
const zDeleteSessionRequest = object({
|
|
54332
|
-
sessionId: zSessionId,
|
|
54333
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54334
|
-
});
|
|
54335
|
-
const zForkSessionRequest = object({
|
|
54336
|
-
sessionId: zSessionId,
|
|
54337
|
-
cwd: string(),
|
|
54338
|
-
additionalDirectories: defaultOnError(vecSkipError(string()).optional(), () => []),
|
|
54339
|
-
mcpServers: defaultOnError(vecSkipError(zMcpServer).optional(), () => []),
|
|
54340
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54341
|
-
});
|
|
54342
|
-
const zResumeSessionRequest = object({
|
|
54343
|
-
sessionId: zSessionId,
|
|
54344
|
-
cwd: string(),
|
|
54345
|
-
additionalDirectories: defaultOnError(vecSkipError(string()).optional(), () => []),
|
|
54346
|
-
mcpServers: defaultOnError(vecSkipError(zMcpServer).optional(), () => []),
|
|
54347
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54348
|
-
});
|
|
54349
|
-
const zCloseSessionRequest = object({
|
|
54350
|
-
sessionId: zSessionId,
|
|
54351
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54352
|
-
});
|
|
54353
|
-
const zSetSessionModeRequest = object({
|
|
54354
|
-
sessionId: zSessionId,
|
|
54355
|
-
modeId: zSessionModeId,
|
|
54356
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54357
|
-
});
|
|
54358
|
-
const zSetSessionConfigOptionRequest = intersection(union([
|
|
54359
|
-
object({
|
|
54360
|
-
value: boolean(),
|
|
54361
|
-
type: literal("boolean")
|
|
54362
|
-
}),
|
|
54363
|
-
object({
|
|
54364
|
-
value: zSessionConfigValueId
|
|
54365
|
-
})
|
|
54366
|
-
]), object({
|
|
54367
|
-
sessionId: zSessionId,
|
|
54368
|
-
configId: zSessionConfigId,
|
|
54369
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54370
|
-
}));
|
|
54371
|
-
const zPromptRequest = object({
|
|
54372
|
-
sessionId: zSessionId,
|
|
54373
|
-
prompt: array(zContentBlock),
|
|
54374
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54375
|
-
});
|
|
54376
|
-
const zWorkspaceFolder = object({
|
|
54377
|
-
uri: string(),
|
|
54378
|
-
name: string(),
|
|
54379
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54380
|
-
});
|
|
54381
|
-
const zNesRepository = object({
|
|
54382
|
-
name: string(),
|
|
54383
|
-
owner: string(),
|
|
54384
|
-
remoteUrl: string(),
|
|
54385
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54386
|
-
});
|
|
54387
|
-
const zStartNesRequest = object({
|
|
54388
|
-
workspaceUri: defaultOnError(string().nullish(), () => void 0),
|
|
54389
|
-
workspaceFolders: array(zWorkspaceFolder).nullish(),
|
|
54390
|
-
repository: defaultOnError(zNesRepository.nullish(), () => void 0),
|
|
54391
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54392
|
-
});
|
|
54393
|
-
const zNesTriggerKind = union([
|
|
54394
|
-
literal("automatic"),
|
|
54395
|
-
literal("diagnostic"),
|
|
54396
|
-
literal("manual")
|
|
54397
|
-
]);
|
|
54398
|
-
const zNesRecentFile = object({
|
|
54399
|
-
uri: string(),
|
|
54400
|
-
languageId: string(),
|
|
54401
|
-
text: string(),
|
|
54402
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54403
|
-
});
|
|
54404
|
-
const zNesExcerpt = object({
|
|
54405
|
-
startLine: int().gte(0).max(4294967295, {
|
|
54406
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
54407
|
-
}),
|
|
54408
|
-
endLine: int().gte(0).max(4294967295, {
|
|
54409
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
54410
|
-
}),
|
|
54411
|
-
text: string(),
|
|
54412
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54413
|
-
});
|
|
54414
|
-
const zNesRelatedSnippet = object({
|
|
54415
|
-
uri: string(),
|
|
54416
|
-
excerpts: array(zNesExcerpt),
|
|
54417
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54418
|
-
});
|
|
54419
|
-
const zNesEditHistoryEntry = object({
|
|
54420
|
-
uri: string(),
|
|
54421
|
-
diff: string(),
|
|
54422
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54423
|
-
});
|
|
54424
|
-
const zNesUserAction = object({
|
|
54425
|
-
action: string(),
|
|
54426
|
-
uri: string(),
|
|
54427
|
-
position: zPosition,
|
|
54428
|
-
timestampMs: number(),
|
|
54429
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54430
|
-
});
|
|
54431
|
-
const zNesOpenFile = object({
|
|
54432
|
-
uri: string(),
|
|
54433
|
-
languageId: string(),
|
|
54434
|
-
visibleRange: defaultOnError(zRange.nullish(), () => void 0),
|
|
54435
|
-
lastFocusedMs: defaultOnError(number().nullish(), () => void 0),
|
|
54436
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54437
|
-
});
|
|
54438
|
-
const zNesDiagnosticSeverity = union([
|
|
54439
|
-
literal("error"),
|
|
54440
|
-
literal("warning"),
|
|
54441
|
-
literal("information"),
|
|
54442
|
-
literal("hint")
|
|
54443
|
-
]);
|
|
54444
|
-
const zNesDiagnostic = object({
|
|
54445
|
-
uri: string(),
|
|
54446
|
-
range: zRange,
|
|
54447
|
-
severity: zNesDiagnosticSeverity,
|
|
54448
|
-
message: string(),
|
|
54449
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54450
|
-
});
|
|
54451
|
-
const zNesSuggestContext = object({
|
|
54452
|
-
recentFiles: array(zNesRecentFile).nullish(),
|
|
54453
|
-
relatedSnippets: array(zNesRelatedSnippet).nullish(),
|
|
54454
|
-
editHistory: array(zNesEditHistoryEntry).nullish(),
|
|
54455
|
-
userActions: array(zNesUserAction).nullish(),
|
|
54456
|
-
openFiles: array(zNesOpenFile).nullish(),
|
|
54457
|
-
diagnostics: array(zNesDiagnostic).nullish(),
|
|
54458
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54459
|
-
});
|
|
54460
|
-
const zSuggestNesRequest = object({
|
|
54461
|
-
sessionId: zSessionId,
|
|
54462
|
-
uri: string(),
|
|
54463
|
-
version: number(),
|
|
54464
|
-
position: zPosition,
|
|
54465
|
-
selection: zRange.nullish(),
|
|
54466
|
-
triggerKind: zNesTriggerKind,
|
|
54467
|
-
context: zNesSuggestContext.nullish(),
|
|
54468
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54469
|
-
});
|
|
54470
|
-
const zCloseNesRequest = object({
|
|
54471
|
-
sessionId: zSessionId,
|
|
54472
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54473
|
-
});
|
|
54474
|
-
object({
|
|
54475
|
-
id: zRequestId,
|
|
54476
|
-
method: string(),
|
|
54477
|
-
params: union([
|
|
54478
|
-
zInitializeRequest,
|
|
54479
|
-
zAuthenticateRequest,
|
|
54480
|
-
zListProvidersRequest,
|
|
54481
|
-
zSetProviderRequest,
|
|
54482
|
-
zDisableProviderRequest,
|
|
54483
|
-
zLogoutRequest,
|
|
54484
|
-
zNewSessionRequest,
|
|
54485
|
-
zLoadSessionRequest,
|
|
54486
|
-
zListSessionsRequest,
|
|
54487
|
-
zDeleteSessionRequest,
|
|
54488
|
-
zForkSessionRequest,
|
|
54489
|
-
zResumeSessionRequest,
|
|
54490
|
-
zCloseSessionRequest,
|
|
54491
|
-
zSetSessionModeRequest,
|
|
54492
|
-
zSetSessionConfigOptionRequest,
|
|
54493
|
-
zPromptRequest,
|
|
54494
|
-
zStartNesRequest,
|
|
54495
|
-
zSuggestNesRequest,
|
|
54496
|
-
zCloseNesRequest,
|
|
54497
|
-
zMessageMcpRequest,
|
|
54498
|
-
zExtRequest
|
|
54499
|
-
]).nullish()
|
|
54500
|
-
});
|
|
54501
|
-
const zWriteTextFileResponse = object({
|
|
54502
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54503
|
-
});
|
|
54504
|
-
const zReadTextFileResponse = object({
|
|
54505
|
-
content: string(),
|
|
54506
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54507
|
-
});
|
|
54508
|
-
const zSelectedPermissionOutcome = object({
|
|
54509
|
-
optionId: zPermissionOptionId,
|
|
54510
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54511
|
-
});
|
|
54512
|
-
const zRequestPermissionOutcome = union([
|
|
54513
|
-
object({
|
|
54514
|
-
outcome: literal("cancelled")
|
|
54515
|
-
}),
|
|
54516
|
-
zSelectedPermissionOutcome.and(object({
|
|
54517
|
-
outcome: literal("selected")
|
|
54518
|
-
}))
|
|
54519
|
-
]);
|
|
54520
|
-
const zRequestPermissionResponse = object({
|
|
54521
|
-
outcome: zRequestPermissionOutcome,
|
|
54522
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54523
|
-
});
|
|
54524
|
-
const zCreateTerminalResponse = object({
|
|
54525
|
-
terminalId: zTerminalId,
|
|
54526
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54527
|
-
});
|
|
54528
|
-
const zTerminalExitStatus = object({
|
|
54529
|
-
exitCode: defaultOnError(int().gte(0).max(4294967295, {
|
|
54530
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
54531
|
-
}).nullish(), () => void 0),
|
|
54532
|
-
signal: defaultOnError(string().nullish(), () => void 0),
|
|
54533
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54534
|
-
});
|
|
54535
|
-
const zTerminalOutputResponse = object({
|
|
54536
|
-
output: string(),
|
|
54537
|
-
truncated: boolean(),
|
|
54538
|
-
exitStatus: defaultOnError(zTerminalExitStatus.nullish(), () => void 0),
|
|
54539
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54540
|
-
});
|
|
54541
|
-
const zReleaseTerminalResponse = object({
|
|
54542
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54543
|
-
});
|
|
54544
|
-
const zWaitForTerminalExitResponse = object({
|
|
54545
|
-
exitCode: defaultOnError(int().gte(0).max(4294967295, {
|
|
54546
|
-
error: "Invalid value: Expected uint32 to be <= 4294967295"
|
|
54547
|
-
}).nullish(), () => void 0),
|
|
54548
|
-
signal: defaultOnError(string().nullish(), () => void 0),
|
|
54549
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54550
|
-
});
|
|
54551
|
-
const zKillTerminalResponse = object({
|
|
54552
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54553
|
-
});
|
|
54554
|
-
const zElicitationContentValue = union([
|
|
54555
|
-
string(),
|
|
54556
|
-
number(),
|
|
54557
|
-
number(),
|
|
54558
|
-
boolean(),
|
|
54559
|
-
array(string())
|
|
54560
|
-
]);
|
|
54561
|
-
const zElicitationAcceptAction = object({
|
|
54562
|
-
content: record(string(), zElicitationContentValue).nullish()
|
|
54563
|
-
});
|
|
54564
|
-
const zCreateElicitationResponse = preserveCustomPayload(intersection(union([
|
|
54565
|
-
zElicitationAcceptAction.and(object({
|
|
54566
|
-
action: literal("accept")
|
|
54567
|
-
})),
|
|
54568
|
-
object({
|
|
54569
|
-
action: literal("decline")
|
|
54570
|
-
}),
|
|
54571
|
-
object({
|
|
54572
|
-
action: literal("cancel")
|
|
54573
|
-
}),
|
|
54574
|
-
excludeKnownTags(object({
|
|
54575
|
-
action: string()
|
|
54576
|
-
}), "action", [
|
|
54577
|
-
"accept",
|
|
54578
|
-
"cancel",
|
|
54579
|
-
"decline"
|
|
54580
|
-
])
|
|
54581
|
-
]), object({
|
|
54582
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54583
|
-
})), "action", [
|
|
54584
|
-
"accept",
|
|
54585
|
-
"cancel",
|
|
54586
|
-
"decline"
|
|
54587
|
-
]);
|
|
54588
|
-
const zConnectMcpResponse = object({
|
|
54589
|
-
connectionId: zMcpConnectionId,
|
|
54590
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54591
|
-
});
|
|
54592
|
-
const zDisconnectMcpResponse = object({
|
|
54593
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54594
|
-
});
|
|
54595
|
-
union([
|
|
54596
|
-
object({
|
|
54597
|
-
id: zRequestId,
|
|
54598
|
-
result: union([
|
|
54599
|
-
zWriteTextFileResponse,
|
|
54600
|
-
zReadTextFileResponse,
|
|
54601
|
-
zRequestPermissionResponse,
|
|
54602
|
-
zCreateTerminalResponse,
|
|
54603
|
-
zTerminalOutputResponse,
|
|
54604
|
-
zReleaseTerminalResponse,
|
|
54605
|
-
zWaitForTerminalExitResponse,
|
|
54606
|
-
zKillTerminalResponse,
|
|
54607
|
-
zCreateElicitationResponse,
|
|
54608
|
-
zConnectMcpResponse,
|
|
54609
|
-
zDisconnectMcpResponse,
|
|
54610
|
-
zMessageMcpResponse,
|
|
54611
|
-
zExtResponse
|
|
54612
|
-
])
|
|
54613
|
-
}),
|
|
54614
|
-
object({
|
|
54615
|
-
id: zRequestId,
|
|
54616
|
-
error: zError
|
|
54617
|
-
})
|
|
54618
|
-
]);
|
|
54619
|
-
const zCancelNotification = object({
|
|
54620
|
-
sessionId: zSessionId,
|
|
54621
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54622
|
-
});
|
|
54623
|
-
const zDidOpenDocumentNotification = object({
|
|
54624
|
-
sessionId: zSessionId,
|
|
54625
|
-
uri: string(),
|
|
54626
|
-
languageId: string(),
|
|
54627
|
-
version: number(),
|
|
54628
|
-
text: string(),
|
|
54629
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54630
|
-
});
|
|
54631
|
-
const zTextDocumentContentChangeEvent = object({
|
|
54632
|
-
range: zRange.nullish(),
|
|
54633
|
-
text: string(),
|
|
54634
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54635
|
-
});
|
|
54636
|
-
const zDidChangeDocumentNotification = object({
|
|
54637
|
-
sessionId: zSessionId,
|
|
54638
|
-
uri: string(),
|
|
54639
|
-
version: number(),
|
|
54640
|
-
contentChanges: requiredDefaultOnError(vecSkipError(zTextDocumentContentChangeEvent), () => []),
|
|
54641
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54642
|
-
});
|
|
54643
|
-
const zDidCloseDocumentNotification = object({
|
|
54644
|
-
sessionId: zSessionId,
|
|
54645
|
-
uri: string(),
|
|
54646
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54647
|
-
});
|
|
54648
|
-
const zDidSaveDocumentNotification = object({
|
|
54649
|
-
sessionId: zSessionId,
|
|
54650
|
-
uri: string(),
|
|
54651
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54652
|
-
});
|
|
54653
|
-
const zDidFocusDocumentNotification = object({
|
|
54654
|
-
sessionId: zSessionId,
|
|
54655
|
-
uri: string(),
|
|
54656
|
-
version: number(),
|
|
54657
|
-
position: zPosition,
|
|
54658
|
-
visibleRange: zRange,
|
|
54659
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54660
|
-
});
|
|
54661
|
-
const zAcceptNesNotification = object({
|
|
54662
|
-
sessionId: zSessionId,
|
|
54663
|
-
id: zNesSuggestionId,
|
|
54664
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54665
|
-
});
|
|
54666
|
-
const zNesRejectReason = union([
|
|
54667
|
-
literal("rejected"),
|
|
54668
|
-
literal("ignored"),
|
|
54669
|
-
literal("replaced"),
|
|
54670
|
-
literal("cancelled")
|
|
54671
|
-
]);
|
|
54672
|
-
const zRejectNesNotification = object({
|
|
54673
|
-
sessionId: zSessionId,
|
|
54674
|
-
id: zNesSuggestionId,
|
|
54675
|
-
reason: defaultOnError(zNesRejectReason.nullish(), () => void 0),
|
|
54676
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54677
|
-
});
|
|
54678
|
-
object({
|
|
54679
|
-
method: string(),
|
|
54680
|
-
params: union([
|
|
54681
|
-
zCancelNotification,
|
|
54682
|
-
zDidOpenDocumentNotification,
|
|
54683
|
-
zDidChangeDocumentNotification,
|
|
54684
|
-
zDidCloseDocumentNotification,
|
|
54685
|
-
zDidSaveDocumentNotification,
|
|
54686
|
-
zDidFocusDocumentNotification,
|
|
54687
|
-
zAcceptNesNotification,
|
|
54688
|
-
zRejectNesNotification,
|
|
54689
|
-
zMessageMcpNotification,
|
|
54690
|
-
zExtNotification
|
|
54691
|
-
]).nullish()
|
|
54692
|
-
});
|
|
54693
|
-
object({
|
|
54694
|
-
requestId: zRequestId,
|
|
54695
|
-
_meta: defaultOnError(record(string(), unknown()).nullish(), () => void 0)
|
|
54696
|
-
});
|
|
54697
|
-
const CANCEL_REQUEST_METHOD = "$/cancel_request";
|
|
54698
|
-
function isRequestMessage(value) {
|
|
54699
|
-
return isJsonRpcEnvelope(value) && "id" in value && typeof value["method"] === "string" && isJsonRpcId(value["id"]);
|
|
54700
|
-
}
|
|
54701
|
-
function isResponseMessage(value) {
|
|
54702
|
-
if (!isJsonRpcEnvelope(value) || "method" in value) {
|
|
54703
|
-
return false;
|
|
54704
|
-
}
|
|
54705
|
-
if (!("id" in value) || !isJsonRpcId(value["id"])) {
|
|
54706
|
-
return false;
|
|
54707
|
-
}
|
|
54708
|
-
const hasResult = Object.hasOwn(value, "result");
|
|
54709
|
-
const hasError = Object.hasOwn(value, "error");
|
|
54710
|
-
if (hasResult === hasError) {
|
|
54711
|
-
return false;
|
|
54712
|
-
}
|
|
54713
|
-
return !hasError || isErrorResponse(value["error"]);
|
|
54714
|
-
}
|
|
54715
|
-
function isNotificationMessage(value) {
|
|
54716
|
-
return isJsonRpcEnvelope(value) && !("id" in value) && typeof value["method"] === "string";
|
|
54717
|
-
}
|
|
54718
|
-
function isRecord(value) {
|
|
54719
|
-
return typeof value === "object" && value !== null;
|
|
54720
|
-
}
|
|
54721
|
-
function isJsonRpcEnvelope(value) {
|
|
54722
|
-
return isRecord(value) && value["jsonrpc"] === "2.0";
|
|
54723
|
-
}
|
|
54724
|
-
function isJsonRpcId(value) {
|
|
54725
|
-
return value === null || typeof value === "string" || typeof value === "number" && Number.isFinite(value);
|
|
54726
|
-
}
|
|
54727
|
-
function isResponseShapedMessage(value) {
|
|
54728
|
-
return isRecord(value) && !("method" in value) && ("id" in value || "result" in value || "error" in value);
|
|
54729
|
-
}
|
|
54730
|
-
function isResponseBatch(batch) {
|
|
54731
|
-
let hasValidCall = false;
|
|
54732
|
-
let hasValidResponse = false;
|
|
54733
|
-
let hasCallShape = false;
|
|
54734
|
-
let hasResponseShape = false;
|
|
54735
|
-
for (const entry of batch) {
|
|
54736
|
-
hasValidCall ||= isRequestMessage(entry) || isNotificationMessage(entry);
|
|
54737
|
-
hasValidResponse ||= isResponseMessage(entry);
|
|
54738
|
-
if (!isRecord(entry)) {
|
|
54739
|
-
continue;
|
|
54740
|
-
}
|
|
54741
|
-
hasCallShape ||= "method" in entry;
|
|
54742
|
-
hasResponseShape ||= "result" in entry || "error" in entry;
|
|
54743
|
-
}
|
|
54744
|
-
if (hasValidCall) {
|
|
54745
|
-
return false;
|
|
54746
|
-
}
|
|
54747
|
-
if (hasValidResponse) {
|
|
54748
|
-
return true;
|
|
54749
|
-
}
|
|
54750
|
-
return hasResponseShape && !hasCallShape;
|
|
54751
|
-
}
|
|
54752
|
-
function cancelRequestId(params) {
|
|
54753
|
-
if (!isRecord(params) || !isJsonRpcId(params["requestId"])) {
|
|
54754
|
-
return void 0;
|
|
54755
|
-
}
|
|
54756
|
-
return params["requestId"];
|
|
54757
|
-
}
|
|
54758
|
-
function isErrorResponse(value) {
|
|
54759
|
-
return isRecord(value) && typeof value["code"] === "number" && Number.isInteger(value["code"]) && typeof value["message"] === "string";
|
|
54760
|
-
}
|
|
54761
|
-
const Handled = {
|
|
54762
|
-
yes() {
|
|
54763
|
-
return {
|
|
54764
|
-
handled: true
|
|
54765
|
-
};
|
|
54766
|
-
},
|
|
54767
|
-
no(message, retry = false) {
|
|
54768
|
-
return {
|
|
54769
|
-
handled: false,
|
|
54770
|
-
message,
|
|
54771
|
-
retry
|
|
54772
|
-
};
|
|
54773
|
-
}
|
|
54774
|
-
};
|
|
54775
|
-
function rejectedPromise(error) {
|
|
54776
|
-
const promise = Promise.reject(error);
|
|
54777
|
-
promise.catch(() => {
|
|
54778
|
-
});
|
|
54779
|
-
return promise;
|
|
54780
|
-
}
|
|
54781
|
-
function errorDetails(error) {
|
|
54782
|
-
if (error instanceof Error) {
|
|
54783
|
-
return error.message;
|
|
54784
|
-
}
|
|
54785
|
-
if (typeof error === "object" && error != null && "message" in error && typeof error.message === "string") {
|
|
54786
|
-
return error.message;
|
|
54787
|
-
}
|
|
54788
|
-
return void 0;
|
|
54789
|
-
}
|
|
54790
|
-
function isZodError(error) {
|
|
54791
|
-
return typeof error === "object" && error !== null && "name" in error && error.name === "ZodError" && "issues" in error && Array.isArray(error.issues) && "format" in error && typeof error.format === "function";
|
|
54792
|
-
}
|
|
54793
|
-
function errorToResult(error) {
|
|
54794
|
-
if (error instanceof RequestError) {
|
|
54795
|
-
return error.toResult();
|
|
54796
|
-
}
|
|
54797
|
-
if (isZodError(error)) {
|
|
54798
|
-
return RequestError.invalidParams(error.format()).toResult();
|
|
54799
|
-
}
|
|
54800
|
-
const details = errorDetails(error);
|
|
54801
|
-
try {
|
|
54802
|
-
return RequestError.internalError(details ? JSON.parse(details) : {}).toResult();
|
|
54803
|
-
} catch {
|
|
54804
|
-
return RequestError.internalError({
|
|
54805
|
-
details
|
|
54806
|
-
}).toResult();
|
|
54807
|
-
}
|
|
54808
|
-
}
|
|
54809
|
-
function requestCancelledError(reason) {
|
|
54810
|
-
if (reason instanceof RequestError && reason.code === -32800) {
|
|
54811
|
-
return reason;
|
|
54812
|
-
}
|
|
54813
|
-
return RequestError.requestCancelled(reason);
|
|
54814
|
-
}
|
|
54815
|
-
function errorToRequestResult(error, signal) {
|
|
54816
|
-
const requestCancelled = abortErrorToRequestCancelled(error, signal);
|
|
54817
|
-
return requestCancelled ? requestCancelled.toResult() : errorToResult(error);
|
|
54818
|
-
}
|
|
54819
|
-
function abortErrorToRequestCancelled(error, signal) {
|
|
54820
|
-
if (!signal.aborted || !isAbortError(error)) {
|
|
54821
|
-
return void 0;
|
|
54822
|
-
}
|
|
54823
|
-
return requestCancelledError(signal.reason);
|
|
54824
|
-
}
|
|
54825
|
-
function isAbortError(error) {
|
|
54826
|
-
if (typeof error !== "object" || error === null) {
|
|
54827
|
-
return false;
|
|
54828
|
-
}
|
|
54829
|
-
const maybeAbortError = error;
|
|
54830
|
-
return maybeAbortError.name === "AbortError" || maybeAbortError.code === "ABORT_ERR";
|
|
54831
|
-
}
|
|
54832
|
-
class RequestResponder {
|
|
54833
|
-
id;
|
|
54834
|
-
sendResult;
|
|
54835
|
-
signal;
|
|
54836
|
-
finishRequest;
|
|
54837
|
-
didRespond = false;
|
|
54838
|
-
constructor(id, sendResult, signal = new AbortController().signal, finishRequest) {
|
|
54839
|
-
this.id = id;
|
|
54840
|
-
this.sendResult = sendResult;
|
|
54841
|
-
this.signal = signal;
|
|
54842
|
-
this.finishRequest = finishRequest;
|
|
54843
|
-
}
|
|
54844
|
-
get responded() {
|
|
54845
|
-
return this.didRespond;
|
|
54846
|
-
}
|
|
54847
|
-
respond(response) {
|
|
54848
|
-
return this.respondWithResult({
|
|
54849
|
-
result: response ?? null
|
|
54850
|
-
});
|
|
54851
|
-
}
|
|
54852
|
-
respondWithError(error) {
|
|
54853
|
-
const errorResponse = error instanceof RequestError ? error.toErrorResponse() : error;
|
|
54854
|
-
return this.respondWithResult({
|
|
54855
|
-
error: errorResponse
|
|
54856
|
-
});
|
|
54857
|
-
}
|
|
54858
|
-
respondWithResult(result) {
|
|
54859
|
-
if (this.didRespond) {
|
|
54860
|
-
return rejectedPromise(new Error("JSON-RPC request already responded"));
|
|
54861
|
-
}
|
|
54862
|
-
this.didRespond = true;
|
|
54863
|
-
return this.sendResult(result).finally(() => {
|
|
54864
|
-
this.finishRequest?.();
|
|
54865
|
-
});
|
|
54866
|
-
}
|
|
54867
|
-
}
|
|
54868
|
-
class HandlerRegistration {
|
|
54869
|
-
disposeHandler;
|
|
54870
|
-
active = true;
|
|
54871
|
-
constructor(disposeHandler) {
|
|
54872
|
-
this.disposeHandler = disposeHandler;
|
|
54873
|
-
}
|
|
54874
|
-
dispose() {
|
|
54875
|
-
if (!this.active) {
|
|
54876
|
-
return;
|
|
54877
|
-
}
|
|
54878
|
-
this.active = false;
|
|
54879
|
-
this.disposeHandler();
|
|
54880
|
-
}
|
|
54881
|
-
[Symbol.dispose]() {
|
|
54882
|
-
this.dispose();
|
|
54883
|
-
}
|
|
54884
|
-
runIndefinitely() {
|
|
54885
|
-
return this;
|
|
54886
|
-
}
|
|
54887
|
-
}
|
|
54888
|
-
class ConnectionContext {
|
|
54889
|
-
connection;
|
|
54890
|
-
constructor(connection2) {
|
|
54891
|
-
this.connection = connection2;
|
|
54892
|
-
}
|
|
54893
|
-
sendRequest(method, params, mapResponse, options) {
|
|
54894
|
-
return this.connection.sendRequest(method, params, mapResponse, options);
|
|
54895
|
-
}
|
|
54896
|
-
sendNotification(method, params) {
|
|
54897
|
-
return this.connection.sendNotification(method, params);
|
|
54898
|
-
}
|
|
54899
|
-
sendBatch(entries) {
|
|
54900
|
-
return this.connection.sendBatch(entries);
|
|
54901
|
-
}
|
|
54902
|
-
sendCancelRequest(requestId) {
|
|
54903
|
-
return this.connection.sendCancelRequest(requestId);
|
|
54904
|
-
}
|
|
54905
|
-
addDynamicHandler(handler) {
|
|
54906
|
-
return this.connection.addDynamicHandler(handler);
|
|
54907
|
-
}
|
|
54908
|
-
get signal() {
|
|
54909
|
-
return this.connection.signal;
|
|
54910
|
-
}
|
|
54911
|
-
get closed() {
|
|
54912
|
-
return this.connection.closed;
|
|
54913
|
-
}
|
|
54914
|
-
}
|
|
54915
|
-
class Connection {
|
|
54916
|
-
pendingResponses = /* @__PURE__ */ new Map();
|
|
54917
|
-
incomingRequests = /* @__PURE__ */ new Map();
|
|
54918
|
-
nextRequestId = 0;
|
|
54919
|
-
staticHandlers = [];
|
|
54920
|
-
dynamicHandlers = /* @__PURE__ */ new Set();
|
|
54921
|
-
stream;
|
|
54922
|
-
writeQueue = Promise.resolve();
|
|
54923
|
-
abortController = new AbortController();
|
|
54924
|
-
closedPromise;
|
|
54925
|
-
retryQueue = [];
|
|
54926
|
-
context = new ConnectionContext(this);
|
|
54927
|
-
receiveReader;
|
|
54928
|
-
allowBatches = true;
|
|
54929
|
-
constructor(requestHandlerOrStream, notificationHandlerOrHandlers, streamOrOptions, options) {
|
|
54930
|
-
if (typeof requestHandlerOrStream === "function") {
|
|
54931
|
-
const requestHandler = requestHandlerOrStream;
|
|
54932
|
-
const notificationHandler = notificationHandlerOrHandlers;
|
|
54933
|
-
const stream2 = streamOrOptions;
|
|
54934
|
-
this.initialize(stream2, [
|
|
54935
|
-
...options?.handlers ?? [],
|
|
54936
|
-
this.legacyHandler(requestHandler, notificationHandler)
|
|
54937
|
-
], options);
|
|
54938
|
-
return;
|
|
54939
|
-
}
|
|
54940
|
-
const stream = requestHandlerOrStream;
|
|
54941
|
-
const handlers = notificationHandlerOrHandlers;
|
|
54942
|
-
const connectionOptions = streamOrOptions;
|
|
54943
|
-
this.initialize(stream, [
|
|
54944
|
-
...connectionOptions?.handlers ?? [],
|
|
54945
|
-
...handlers
|
|
54946
|
-
], connectionOptions);
|
|
54947
|
-
}
|
|
54948
|
-
static builder() {
|
|
54949
|
-
return new ConnectionBuilder();
|
|
54950
|
-
}
|
|
54951
|
-
runUntil(op2) {
|
|
54952
|
-
let opSettled = false;
|
|
54953
|
-
const opPromise = Promise.resolve().then(() => op2(this.context)).finally(() => {
|
|
54954
|
-
opSettled = true;
|
|
54955
|
-
});
|
|
54956
|
-
const closedPromise = this.closed.then(() => {
|
|
54957
|
-
if (opSettled) {
|
|
54958
|
-
return new Promise(() => {
|
|
54959
|
-
});
|
|
54960
|
-
}
|
|
54961
|
-
throw this.closedReason();
|
|
54962
|
-
});
|
|
54963
|
-
return Promise.race([
|
|
54964
|
-
opPromise,
|
|
54965
|
-
closedPromise
|
|
54966
|
-
]).finally(() => {
|
|
54967
|
-
opSettled = true;
|
|
54968
|
-
this.close();
|
|
54969
|
-
});
|
|
54970
|
-
}
|
|
54971
|
-
addDynamicHandler(handler) {
|
|
54972
|
-
this.dynamicHandlers.add(handler);
|
|
54973
|
-
if (this.retryQueue.length > 0) {
|
|
54974
|
-
for (const message of this.retryQueue.splice(0)) {
|
|
54975
|
-
void this.processIncomingMessage(message).catch((error) => this.close(error));
|
|
54976
|
-
}
|
|
54977
|
-
}
|
|
54978
|
-
return new HandlerRegistration(() => {
|
|
54979
|
-
this.dynamicHandlers.delete(handler);
|
|
54980
|
-
});
|
|
54981
|
-
}
|
|
54982
|
-
get signal() {
|
|
54983
|
-
return this.abortController.signal;
|
|
54984
|
-
}
|
|
54985
|
-
get closed() {
|
|
54986
|
-
return this.closedPromise;
|
|
54987
|
-
}
|
|
54988
|
-
getContext() {
|
|
54989
|
-
return this.context;
|
|
54990
|
-
}
|
|
54991
|
-
sendRequest(method, params, mapResponse, options = {}) {
|
|
54992
|
-
if (this.abortController.signal.aborted) {
|
|
54993
|
-
return rejectedPromise(this.closedReason());
|
|
54994
|
-
}
|
|
54995
|
-
const request = this.prepareRequest(method, params, mapResponse, options);
|
|
54996
|
-
const requestSent = this.sendWireMessage(request.message);
|
|
54997
|
-
void requestSent.catch(() => {
|
|
54998
|
-
});
|
|
54999
|
-
if (options.cancellationSignal?.aborted) {
|
|
55000
|
-
request.cancel();
|
|
55001
|
-
}
|
|
55002
|
-
return request.response;
|
|
55003
|
-
}
|
|
55004
|
-
sendBatch(entries) {
|
|
55005
|
-
if (this.abortController.signal.aborted) {
|
|
55006
|
-
return rejectedPromise(this.closedReason());
|
|
55007
|
-
}
|
|
55008
|
-
if (!this.allowBatches) {
|
|
55009
|
-
return rejectedPromise(new TypeError("JSON-RPC batches are not supported on this connection"));
|
|
55010
|
-
}
|
|
55011
|
-
if (entries.length === 0) {
|
|
55012
|
-
return rejectedPromise(new TypeError("JSON-RPC batch must contain at least one entry"));
|
|
55013
|
-
}
|
|
55014
|
-
const messages = [];
|
|
55015
|
-
const cancellations = [];
|
|
55016
|
-
const outputs = [];
|
|
55017
|
-
for (const entry of entries) {
|
|
55018
|
-
if (entry.kind === "notification") {
|
|
55019
|
-
messages.push({
|
|
55020
|
-
jsonrpc: "2.0",
|
|
55021
|
-
method: entry.method,
|
|
55022
|
-
params: entry.params
|
|
55023
|
-
});
|
|
55024
|
-
outputs.push(Promise.resolve(void 0));
|
|
55025
|
-
continue;
|
|
55026
|
-
}
|
|
55027
|
-
const request = this.prepareRequest(entry.method, entry.params, entry.mapResponse, entry.options);
|
|
55028
|
-
messages.push(request.message);
|
|
55029
|
-
outputs.push(request.response);
|
|
55030
|
-
cancellations.push({
|
|
55031
|
-
signal: entry.options?.cancellationSignal,
|
|
55032
|
-
cancel: request.cancel
|
|
55033
|
-
});
|
|
55034
|
-
}
|
|
55035
|
-
const batch = messages;
|
|
55036
|
-
const batchSent = this.sendWireMessage(batch);
|
|
55037
|
-
for (const cancellation of cancellations) {
|
|
55038
|
-
if (cancellation.signal?.aborted) {
|
|
55039
|
-
cancellation.cancel();
|
|
55040
|
-
}
|
|
55041
|
-
}
|
|
55042
|
-
const response = Promise.all([
|
|
55043
|
-
batchSent,
|
|
55044
|
-
...outputs
|
|
55045
|
-
]).then(([, ...resolved]) => resolved);
|
|
55046
|
-
response.catch(() => {
|
|
55047
|
-
});
|
|
55048
|
-
return response;
|
|
55049
|
-
}
|
|
55050
|
-
sendCancelRequest(requestId) {
|
|
55051
|
-
return this.sendNotification(CANCEL_REQUEST_METHOD, {
|
|
55052
|
-
requestId
|
|
55053
|
-
});
|
|
55054
|
-
}
|
|
55055
|
-
sendNotification(method, params) {
|
|
55056
|
-
if (this.abortController.signal.aborted) {
|
|
55057
|
-
return rejectedPromise(this.closedReason());
|
|
55058
|
-
}
|
|
55059
|
-
return this.sendWireMessage({
|
|
55060
|
-
jsonrpc: "2.0",
|
|
55061
|
-
method,
|
|
55062
|
-
params
|
|
55063
|
-
});
|
|
55064
|
-
}
|
|
55065
|
-
prepareRequest(method, params, mapResponse, options = {}) {
|
|
55066
|
-
const id = this.nextRequestId++;
|
|
55067
|
-
let cancel = () => {
|
|
55068
|
-
};
|
|
55069
|
-
const response = new Promise((resolve2, reject) => {
|
|
55070
|
-
const pendingResponse = {
|
|
55071
|
-
resolve: (value) => {
|
|
55072
|
-
try {
|
|
55073
|
-
resolve2(mapResponse ? mapResponse(value) : value);
|
|
55074
|
-
} catch (error) {
|
|
55075
|
-
reject(error);
|
|
55076
|
-
}
|
|
55077
|
-
},
|
|
55078
|
-
reject
|
|
55079
|
-
};
|
|
55080
|
-
cancel = () => {
|
|
55081
|
-
if (pendingResponse.cancellationSent) {
|
|
55082
|
-
return;
|
|
55083
|
-
}
|
|
55084
|
-
pendingResponse.cancellationSent = true;
|
|
55085
|
-
pendingResponse.cleanup?.();
|
|
55086
|
-
void this.sendCancelRequest(id).catch(() => {
|
|
55087
|
-
});
|
|
55088
|
-
};
|
|
55089
|
-
options.cancellationSignal?.addEventListener("abort", cancel, {
|
|
55090
|
-
once: true
|
|
55091
|
-
});
|
|
55092
|
-
pendingResponse.cleanup = () => {
|
|
55093
|
-
options.cancellationSignal?.removeEventListener("abort", cancel);
|
|
55094
|
-
};
|
|
55095
|
-
this.pendingResponses.set(id, pendingResponse);
|
|
55096
|
-
});
|
|
55097
|
-
response.catch(() => {
|
|
55098
|
-
});
|
|
55099
|
-
return {
|
|
55100
|
-
message: {
|
|
55101
|
-
jsonrpc: "2.0",
|
|
55102
|
-
id,
|
|
55103
|
-
method,
|
|
55104
|
-
params
|
|
55105
|
-
},
|
|
55106
|
-
response,
|
|
55107
|
-
cancel: () => cancel()
|
|
55108
|
-
};
|
|
55109
|
-
}
|
|
55110
|
-
close(error) {
|
|
55111
|
-
if (this.abortController.signal.aborted) {
|
|
55112
|
-
return;
|
|
55113
|
-
}
|
|
55114
|
-
const closeError = error ?? new Error("ACP connection closed");
|
|
55115
|
-
this.abortController.abort(closeError);
|
|
55116
|
-
for (const pendingResponse of this.pendingResponses.values()) {
|
|
55117
|
-
pendingResponse.cleanup?.();
|
|
55118
|
-
pendingResponse.reject(closeError);
|
|
55119
|
-
}
|
|
55120
|
-
this.pendingResponses.clear();
|
|
55121
|
-
for (const controller of this.incomingRequests.values()) {
|
|
55122
|
-
controller.abort(closeError);
|
|
55123
|
-
}
|
|
55124
|
-
this.incomingRequests.clear();
|
|
55125
|
-
void this.receiveReader?.cancel(closeError).catch(() => {
|
|
55126
|
-
});
|
|
55127
|
-
}
|
|
55128
|
-
initialize(stream, handlers, options) {
|
|
55129
|
-
this.stream = stream;
|
|
55130
|
-
this.staticHandlers = handlers;
|
|
55131
|
-
this.allowBatches = options?.allowBatches ?? true;
|
|
55132
|
-
this.closedPromise = new Promise((resolve2) => {
|
|
55133
|
-
this.abortController.signal.addEventListener("abort", () => resolve2());
|
|
55134
|
-
});
|
|
55135
|
-
void this.receive();
|
|
55136
|
-
}
|
|
55137
|
-
legacyHandler(requestHandler, notificationHandler) {
|
|
55138
|
-
return {
|
|
55139
|
-
handleMessage: async (message, cx2) => {
|
|
55140
|
-
if (message.kind === "request") {
|
|
55141
|
-
const result = await requestHandler(message.method, message.params, cx2);
|
|
55142
|
-
await message.responder.respond(result);
|
|
55143
|
-
} else {
|
|
55144
|
-
await notificationHandler(message.method, message.params, cx2);
|
|
55145
|
-
}
|
|
55146
|
-
return Handled.yes();
|
|
55147
|
-
}
|
|
55148
|
-
};
|
|
55149
|
-
}
|
|
55150
|
-
async receive() {
|
|
55151
|
-
let closeError = void 0;
|
|
55152
|
-
try {
|
|
55153
|
-
const reader = this.stream.readable.getReader();
|
|
55154
|
-
this.receiveReader = reader;
|
|
55155
|
-
try {
|
|
55156
|
-
while (!this.abortController.signal.aborted) {
|
|
55157
|
-
const { value: message, done } = await reader.read();
|
|
55158
|
-
if (this.abortController.signal.aborted) {
|
|
55159
|
-
break;
|
|
55160
|
-
}
|
|
55161
|
-
if (done) {
|
|
55162
|
-
break;
|
|
55163
|
-
}
|
|
55164
|
-
if (!message) {
|
|
55165
|
-
continue;
|
|
55166
|
-
}
|
|
55167
|
-
this.receiveWireMessage(message);
|
|
55168
|
-
}
|
|
55169
|
-
} finally {
|
|
55170
|
-
if (this.receiveReader === reader) {
|
|
55171
|
-
this.receiveReader = void 0;
|
|
55172
|
-
}
|
|
55173
|
-
reader.releaseLock();
|
|
55174
|
-
}
|
|
55175
|
-
} catch (error) {
|
|
55176
|
-
closeError = error;
|
|
55177
|
-
} finally {
|
|
55178
|
-
this.close(closeError);
|
|
55179
|
-
}
|
|
55180
|
-
}
|
|
55181
|
-
receiveWireMessage(message) {
|
|
55182
|
-
if (Array.isArray(message)) {
|
|
55183
|
-
if (!this.allowBatches) {
|
|
55184
|
-
this.close(new TypeError("JSON-RPC batches are not supported on this connection"));
|
|
55185
|
-
return;
|
|
55186
|
-
}
|
|
55187
|
-
this.receiveBatch(message);
|
|
55188
|
-
return;
|
|
55189
|
-
}
|
|
55190
|
-
if (!isRecord(message)) {
|
|
55191
|
-
console.error("Invalid message", {
|
|
55192
|
-
message
|
|
55193
|
-
});
|
|
55194
|
-
return;
|
|
55195
|
-
}
|
|
55196
|
-
this.receiveMessage(message);
|
|
55197
|
-
}
|
|
55198
|
-
receiveBatch(batch) {
|
|
55199
|
-
if (batch.length === 0) {
|
|
55200
|
-
void this.sendWireMessage({
|
|
55201
|
-
jsonrpc: "2.0",
|
|
55202
|
-
id: null,
|
|
55203
|
-
error: RequestError.invalidRequest(batch).toErrorResponse()
|
|
55204
|
-
}).catch(() => {
|
|
55205
|
-
});
|
|
55206
|
-
return;
|
|
55207
|
-
}
|
|
55208
|
-
const responseBatch = isResponseBatch(batch);
|
|
55209
|
-
const responseCount = responseBatch ? 0 : batch.reduce((count, message) => count + (isNotificationMessage(message) ? 0 : 1), 0);
|
|
55210
|
-
let remaining = responseCount;
|
|
55211
|
-
let remainingNotifications = batch.reduce((count, message) => count + (isNotificationMessage(message) ? 1 : 0), 0);
|
|
55212
|
-
let responseSent = false;
|
|
55213
|
-
const responses = [];
|
|
55214
|
-
const sendResponsesIfReady = async () => {
|
|
55215
|
-
if (responseSent || remaining !== 0 || remainingNotifications !== 0 || responses.length === 0) {
|
|
55216
|
-
return;
|
|
55217
|
-
}
|
|
55218
|
-
responseSent = true;
|
|
55219
|
-
await this.sendWireMessage(responses);
|
|
55220
|
-
};
|
|
55221
|
-
const collectResponse = async (response) => {
|
|
55222
|
-
responses.push(response);
|
|
55223
|
-
remaining -= 1;
|
|
55224
|
-
await sendResponsesIfReady();
|
|
55225
|
-
};
|
|
55226
|
-
for (const message of batch) {
|
|
55227
|
-
if (responseBatch) {
|
|
55228
|
-
if (isResponseShapedMessage(message)) {
|
|
55229
|
-
this.receiveMessage(message);
|
|
55230
|
-
}
|
|
55231
|
-
continue;
|
|
55232
|
-
}
|
|
55233
|
-
if (!isRequestMessage(message) && !isNotificationMessage(message)) {
|
|
55234
|
-
void collectResponse({
|
|
55235
|
-
jsonrpc: "2.0",
|
|
55236
|
-
id: null,
|
|
55237
|
-
error: RequestError.invalidRequest(message).toErrorResponse()
|
|
55238
|
-
}).catch(() => {
|
|
55239
|
-
});
|
|
55240
|
-
continue;
|
|
55241
|
-
}
|
|
55242
|
-
const processing = this.receiveMessage(message, isRequestMessage(message) ? collectResponse : void 0);
|
|
55243
|
-
if (isNotificationMessage(message)) {
|
|
55244
|
-
void processing.finally(() => {
|
|
55245
|
-
remainingNotifications -= 1;
|
|
55246
|
-
void sendResponsesIfReady().catch((error) => this.close(error));
|
|
55247
|
-
});
|
|
55248
|
-
}
|
|
55249
|
-
}
|
|
55250
|
-
}
|
|
55251
|
-
receiveMessage(message, sendResponse) {
|
|
55252
|
-
if (this.abortController.signal.aborted) {
|
|
55253
|
-
return Promise.resolve();
|
|
55254
|
-
}
|
|
55255
|
-
if (!isRecord(message)) {
|
|
55256
|
-
console.error("Invalid message", {
|
|
55257
|
-
message
|
|
55258
|
-
});
|
|
55259
|
-
return Promise.resolve();
|
|
55260
|
-
}
|
|
55261
|
-
if ("method" in message) {
|
|
55262
|
-
if (!("id" in message)) {
|
|
55263
|
-
this.handleProtocolNotification(message);
|
|
55264
|
-
}
|
|
55265
|
-
return this.processIncomingMessage(this.toIncomingMessage(message, sendResponse)).catch((error) => this.close(error));
|
|
55266
|
-
} else if ("id" in message) {
|
|
55267
|
-
this.handleResponse(message);
|
|
55268
|
-
} else {
|
|
55269
|
-
console.error("Invalid message", {
|
|
55270
|
-
message
|
|
55271
|
-
});
|
|
55272
|
-
}
|
|
55273
|
-
return Promise.resolve();
|
|
55274
|
-
}
|
|
55275
|
-
async processIncomingMessage(message) {
|
|
55276
|
-
if (this.abortController.signal.aborted) {
|
|
55277
|
-
return;
|
|
55278
|
-
}
|
|
55279
|
-
let current = message;
|
|
55280
|
-
let retry = false;
|
|
55281
|
-
try {
|
|
55282
|
-
for (const handler of [
|
|
55283
|
-
...this.staticHandlers,
|
|
55284
|
-
...this.dynamicHandlers.values()
|
|
55285
|
-
]) {
|
|
55286
|
-
if (this.abortController.signal.aborted) {
|
|
55287
|
-
return;
|
|
55288
|
-
}
|
|
55289
|
-
const result = await handler.handleMessage(current, this.context) ?? {
|
|
55290
|
-
handled: true
|
|
55291
|
-
};
|
|
55292
|
-
if (result.handled) {
|
|
55293
|
-
return;
|
|
55294
|
-
}
|
|
55295
|
-
current = result.message ?? current;
|
|
55296
|
-
retry = retry || Boolean(result.retry);
|
|
55297
|
-
}
|
|
55298
|
-
if (retry) {
|
|
55299
|
-
this.retryQueue.push(current);
|
|
55300
|
-
} else if (current.kind === "request") {
|
|
55301
|
-
await current.responder.respondWithError(RequestError.methodNotFound(current.method));
|
|
55302
|
-
}
|
|
55303
|
-
} catch (error) {
|
|
55304
|
-
if (this.abortController.signal.aborted) {
|
|
55305
|
-
return;
|
|
55306
|
-
}
|
|
55307
|
-
if (current.kind === "request" && !current.responder.responded) {
|
|
55308
|
-
await current.responder.respondWithResult(errorToRequestResult(error, current.responder.signal));
|
|
55309
|
-
} else {
|
|
55310
|
-
const response = errorToResult(error);
|
|
55311
|
-
if ("error" in response) {
|
|
55312
|
-
console.error("Error handling notification", message.raw, response.error);
|
|
55313
|
-
}
|
|
55314
|
-
}
|
|
55315
|
-
}
|
|
55316
|
-
}
|
|
55317
|
-
toIncomingMessage(message, sendResponse) {
|
|
55318
|
-
if ("id" in message) {
|
|
55319
|
-
const abortController = new AbortController();
|
|
55320
|
-
this.incomingRequests.set(message.id, abortController);
|
|
55321
|
-
const finishRequest = () => {
|
|
55322
|
-
if (this.incomingRequests.get(message.id) === abortController) {
|
|
55323
|
-
this.incomingRequests.delete(message.id);
|
|
55324
|
-
}
|
|
55325
|
-
};
|
|
55326
|
-
return {
|
|
55327
|
-
kind: "request",
|
|
55328
|
-
method: message.method,
|
|
55329
|
-
params: message.params,
|
|
55330
|
-
raw: message,
|
|
55331
|
-
signal: abortController.signal,
|
|
55332
|
-
responder: new RequestResponder(message.id, (result) => {
|
|
55333
|
-
const response = {
|
|
55334
|
-
jsonrpc: "2.0",
|
|
55335
|
-
id: message.id,
|
|
55336
|
-
...result
|
|
55337
|
-
};
|
|
55338
|
-
return sendResponse ? sendResponse(response) : this.sendWireMessage(response);
|
|
55339
|
-
}, abortController.signal, finishRequest)
|
|
55340
|
-
};
|
|
55341
|
-
}
|
|
55342
|
-
return {
|
|
55343
|
-
kind: "notification",
|
|
55344
|
-
method: message.method,
|
|
55345
|
-
params: message.params,
|
|
55346
|
-
raw: message
|
|
55347
|
-
};
|
|
55348
|
-
}
|
|
55349
|
-
handleResponse(response) {
|
|
55350
|
-
const pendingResponse = this.pendingResponses.get(response.id);
|
|
55351
|
-
if (pendingResponse) {
|
|
55352
|
-
this.pendingResponses.delete(response.id);
|
|
55353
|
-
pendingResponse.cleanup?.();
|
|
55354
|
-
if (!isResponseMessage(response)) {
|
|
55355
|
-
pendingResponse.reject(RequestError.invalidRequest(response));
|
|
55356
|
-
} else if ("result" in response) {
|
|
55357
|
-
pendingResponse.resolve(response.result);
|
|
55358
|
-
} else {
|
|
55359
|
-
const { code, message, data } = response.error;
|
|
55360
|
-
pendingResponse.reject(new RequestError(code, message, data));
|
|
55361
|
-
}
|
|
55362
|
-
} else {
|
|
55363
|
-
console.error("Got response to unknown request", response.id);
|
|
55364
|
-
}
|
|
55365
|
-
}
|
|
55366
|
-
handleProtocolNotification(message) {
|
|
55367
|
-
if (message.method !== CANCEL_REQUEST_METHOD) {
|
|
55368
|
-
return;
|
|
55369
|
-
}
|
|
55370
|
-
const requestId = cancelRequestId(message.params);
|
|
55371
|
-
if (requestId === void 0) {
|
|
55372
|
-
return;
|
|
55373
|
-
}
|
|
55374
|
-
const controller = this.incomingRequests.get(requestId);
|
|
55375
|
-
if (!controller || controller.signal.aborted) {
|
|
55376
|
-
return;
|
|
55377
|
-
}
|
|
55378
|
-
controller.abort(RequestError.requestCancelled({
|
|
55379
|
-
requestId
|
|
55380
|
-
}));
|
|
55381
|
-
}
|
|
55382
|
-
closedReason() {
|
|
55383
|
-
return this.abortController.signal.reason ?? new Error("ACP connection closed");
|
|
55384
|
-
}
|
|
55385
|
-
async sendWireMessage(message) {
|
|
55386
|
-
if (this.abortController.signal.aborted) {
|
|
55387
|
-
return rejectedPromise(this.closedReason());
|
|
55388
|
-
}
|
|
55389
|
-
this.writeQueue = this.writeQueue.then(async () => {
|
|
55390
|
-
if (this.abortController.signal.aborted) {
|
|
55391
|
-
throw this.closedReason();
|
|
55392
|
-
}
|
|
55393
|
-
const writer = this.stream.writable.getWriter();
|
|
55394
|
-
try {
|
|
55395
|
-
await writer.write(message);
|
|
55396
|
-
} finally {
|
|
55397
|
-
writer.releaseLock();
|
|
55398
|
-
}
|
|
55399
|
-
}).catch((error) => {
|
|
55400
|
-
this.close(error);
|
|
55401
|
-
throw error;
|
|
55402
|
-
});
|
|
55403
|
-
return this.writeQueue;
|
|
55404
|
-
}
|
|
55405
|
-
}
|
|
55406
|
-
class ConnectionBuilder {
|
|
55407
|
-
handlers = [];
|
|
55408
|
-
connectionName;
|
|
55409
|
-
name(name) {
|
|
55410
|
-
this.connectionName = name;
|
|
55411
|
-
return this;
|
|
55412
|
-
}
|
|
55413
|
-
withHandler(handler) {
|
|
55414
|
-
this.handlers.push(handler);
|
|
55415
|
-
return this;
|
|
55416
|
-
}
|
|
55417
|
-
onReceiveMessage(handler) {
|
|
55418
|
-
return this.withHandler({
|
|
55419
|
-
handleMessage: async (message, cx2) => await handler(message, cx2) ?? Handled.no(message),
|
|
55420
|
-
describe: () => this.connectionName ?? "onReceiveMessage"
|
|
55421
|
-
});
|
|
55422
|
-
}
|
|
55423
|
-
onReceiveRequest(method, parse, handler) {
|
|
55424
|
-
return this.withHandler({
|
|
55425
|
-
handleMessage: async (message, cx2) => {
|
|
55426
|
-
if (message.kind !== "request" || message.method !== method) {
|
|
55427
|
-
return Handled.no(message);
|
|
55428
|
-
}
|
|
55429
|
-
const request = parse(message.params);
|
|
55430
|
-
return await handler(request, message.responder, cx2) ?? Handled.yes();
|
|
55431
|
-
},
|
|
55432
|
-
describe: () => `${this.connectionName ?? "request"}:${method}`
|
|
55433
|
-
});
|
|
55434
|
-
}
|
|
55435
|
-
onReceiveNotification(method, parse, handler) {
|
|
55436
|
-
return this.withHandler({
|
|
55437
|
-
handleMessage: async (message, cx2) => {
|
|
55438
|
-
if (message.kind !== "notification" || message.method !== method) {
|
|
55439
|
-
return Handled.no(message);
|
|
55440
|
-
}
|
|
55441
|
-
const notification = parse(message.params);
|
|
55442
|
-
return await handler(notification, cx2) ?? Handled.yes();
|
|
55443
|
-
},
|
|
55444
|
-
describe: () => `${this.connectionName ?? "notification"}:${method}`
|
|
55445
|
-
});
|
|
55446
|
-
}
|
|
55447
|
-
connect(stream, options) {
|
|
55448
|
-
return new Connection(stream, this.handlers, options);
|
|
55449
|
-
}
|
|
55450
|
-
connectWith(stream, op2, options) {
|
|
55451
|
-
return this.connect(stream, options).runUntil(op2);
|
|
55452
|
-
}
|
|
55453
|
-
}
|
|
55454
|
-
class RequestError extends Error {
|
|
55455
|
-
code;
|
|
55456
|
-
data;
|
|
55457
|
-
constructor(code, message, data) {
|
|
55458
|
-
super(message);
|
|
55459
|
-
this.code = code;
|
|
55460
|
-
this.name = "RequestError";
|
|
55461
|
-
this.data = data;
|
|
55462
|
-
}
|
|
55463
|
-
static parseError(data, additionalMessage) {
|
|
55464
|
-
return new RequestError(-32700, `Parse error${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
|
|
55465
|
-
}
|
|
55466
|
-
static invalidRequest(data, additionalMessage) {
|
|
55467
|
-
return new RequestError(-32600, `Invalid request${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
|
|
55468
|
-
}
|
|
55469
|
-
static methodNotFound(method) {
|
|
55470
|
-
return new RequestError(-32601, `"Method not found": ${method}`, {
|
|
55471
|
-
method
|
|
55472
|
-
});
|
|
55473
|
-
}
|
|
55474
|
-
static invalidParams(data, additionalMessage) {
|
|
55475
|
-
return new RequestError(-32602, `Invalid params${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
|
|
55476
|
-
}
|
|
55477
|
-
static internalError(data, additionalMessage) {
|
|
55478
|
-
return new RequestError(-32603, `Internal error${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
|
|
55479
|
-
}
|
|
55480
|
-
static requestCancelled(data, additionalMessage) {
|
|
55481
|
-
return new RequestError(-32800, `Request cancelled${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
|
|
55482
|
-
}
|
|
55483
|
-
static authRequired(data, additionalMessage) {
|
|
55484
|
-
return new RequestError(-32e3, `Authentication required${additionalMessage ? `: ${additionalMessage}` : ""}`, data);
|
|
55485
|
-
}
|
|
55486
|
-
static resourceNotFound(uri) {
|
|
55487
|
-
return new RequestError(-32002, `Resource not found${uri ? `: ${uri}` : ""}`, uri && {
|
|
55488
|
-
uri
|
|
55489
|
-
});
|
|
55490
|
-
}
|
|
55491
|
-
toResult() {
|
|
55492
|
-
return {
|
|
55493
|
-
error: {
|
|
55494
|
-
code: this.code,
|
|
55495
|
-
message: this.message,
|
|
55496
|
-
data: this.data
|
|
55497
|
-
}
|
|
55498
|
-
};
|
|
55499
|
-
}
|
|
55500
|
-
toErrorResponse() {
|
|
55501
|
-
return {
|
|
55502
|
-
code: this.code,
|
|
55503
|
-
message: this.message,
|
|
55504
|
-
data: this.data
|
|
55505
|
-
};
|
|
55506
|
-
}
|
|
55507
|
-
}
|
|
55508
|
-
const newline = 10;
|
|
55509
|
-
class LineBuffer {
|
|
55510
|
-
#pending = [];
|
|
55511
|
-
push(chunk) {
|
|
55512
|
-
const lines = [];
|
|
55513
|
-
let start = 0;
|
|
55514
|
-
let newlineIndex = chunk.indexOf(newline, start);
|
|
55515
|
-
while (newlineIndex !== -1) {
|
|
55516
|
-
lines.push(this.#takeLine(chunk.subarray(start, newlineIndex)));
|
|
55517
|
-
start = newlineIndex + 1;
|
|
55518
|
-
newlineIndex = chunk.indexOf(newline, start);
|
|
55519
|
-
}
|
|
55520
|
-
if (start < chunk.byteLength) {
|
|
55521
|
-
this.#pending.push(start === 0 ? chunk : new Uint8Array(chunk.subarray(start)));
|
|
55522
|
-
}
|
|
55523
|
-
return lines;
|
|
55524
|
-
}
|
|
55525
|
-
flush() {
|
|
55526
|
-
if (this.#pending.length === 0) {
|
|
55527
|
-
return void 0;
|
|
55528
|
-
}
|
|
55529
|
-
return this.#takeLine(new Uint8Array(0));
|
|
55530
|
-
}
|
|
55531
|
-
#takeLine(tail) {
|
|
55532
|
-
if (this.#pending.length === 0) {
|
|
55533
|
-
return tail;
|
|
55534
|
-
}
|
|
55535
|
-
let total = tail.byteLength;
|
|
55536
|
-
for (const part of this.#pending) {
|
|
55537
|
-
total += part.byteLength;
|
|
55538
|
-
}
|
|
55539
|
-
const line = new Uint8Array(total);
|
|
55540
|
-
let offset = 0;
|
|
55541
|
-
for (const part of this.#pending) {
|
|
55542
|
-
line.set(part, offset);
|
|
55543
|
-
offset += part.byteLength;
|
|
55544
|
-
}
|
|
55545
|
-
line.set(tail, offset);
|
|
55546
|
-
this.#pending = [];
|
|
55547
|
-
return line;
|
|
55548
|
-
}
|
|
55549
|
-
}
|
|
55550
|
-
function ndJsonStream$1(output, input) {
|
|
55551
|
-
const textEncoder = new TextEncoder();
|
|
55552
|
-
const textDecoder = new TextDecoder();
|
|
55553
|
-
let cancelled = false;
|
|
55554
|
-
let inputReader;
|
|
55555
|
-
const readable = new ReadableStream({
|
|
55556
|
-
async start(controller) {
|
|
55557
|
-
const lines = new LineBuffer();
|
|
55558
|
-
const enqueueLine = (lineBytes) => {
|
|
55559
|
-
const trimmedLine = textDecoder.decode(lineBytes).trim();
|
|
55560
|
-
if (trimmedLine) {
|
|
55561
|
-
try {
|
|
55562
|
-
const message = JSON.parse(trimmedLine);
|
|
55563
|
-
if (isRecord(message) || Array.isArray(message)) {
|
|
55564
|
-
controller.enqueue(message);
|
|
55565
|
-
} else {
|
|
55566
|
-
console.warn("Skipping JSON line that is not an object:", trimmedLine);
|
|
55567
|
-
}
|
|
55568
|
-
} catch (err) {
|
|
55569
|
-
console.error("Failed to parse JSON message:", trimmedLine, err);
|
|
55570
|
-
}
|
|
55571
|
-
}
|
|
55572
|
-
};
|
|
55573
|
-
const reader = input.getReader();
|
|
55574
|
-
inputReader = reader;
|
|
55575
|
-
try {
|
|
55576
|
-
while (true) {
|
|
55577
|
-
const { value, done } = await reader.read();
|
|
55578
|
-
if (cancelled) {
|
|
55579
|
-
return;
|
|
55580
|
-
}
|
|
55581
|
-
if (done) {
|
|
55582
|
-
break;
|
|
55583
|
-
}
|
|
55584
|
-
if (!value) {
|
|
55585
|
-
continue;
|
|
55586
|
-
}
|
|
55587
|
-
for (const line of lines.push(value)) {
|
|
55588
|
-
enqueueLine(line);
|
|
55589
|
-
if (cancelled) {
|
|
55590
|
-
return;
|
|
55591
|
-
}
|
|
55592
|
-
}
|
|
55593
|
-
}
|
|
55594
|
-
if (cancelled) {
|
|
55595
|
-
return;
|
|
55596
|
-
}
|
|
55597
|
-
const lastLine = lines.flush();
|
|
55598
|
-
if (lastLine) {
|
|
55599
|
-
enqueueLine(lastLine);
|
|
55600
|
-
}
|
|
55601
|
-
} catch (err) {
|
|
55602
|
-
if (cancelled) {
|
|
55603
|
-
return;
|
|
55604
|
-
}
|
|
55605
|
-
controller.error(err);
|
|
55606
|
-
return;
|
|
55607
|
-
} finally {
|
|
55608
|
-
if (inputReader === reader) {
|
|
55609
|
-
inputReader = void 0;
|
|
55610
|
-
}
|
|
55611
|
-
reader.releaseLock();
|
|
55612
|
-
}
|
|
55613
|
-
if (cancelled) {
|
|
55614
|
-
return;
|
|
55615
|
-
}
|
|
55616
|
-
controller.close();
|
|
55617
|
-
},
|
|
55618
|
-
cancel(reason) {
|
|
55619
|
-
cancelled = true;
|
|
55620
|
-
return inputReader?.cancel(reason);
|
|
55621
|
-
}
|
|
55622
|
-
});
|
|
55623
|
-
const writable = new WritableStream({
|
|
55624
|
-
async write(message) {
|
|
55625
|
-
const content = JSON.stringify(message) + "\n";
|
|
55626
|
-
const writer = output.getWriter();
|
|
55627
|
-
try {
|
|
55628
|
-
await writer.write(textEncoder.encode(content));
|
|
55629
|
-
} finally {
|
|
55630
|
-
writer.releaseLock();
|
|
55631
|
-
}
|
|
55632
|
-
}
|
|
55633
|
-
});
|
|
55634
|
-
return {
|
|
55635
|
-
readable,
|
|
55636
|
-
writable
|
|
55637
|
-
};
|
|
55638
|
-
}
|
|
55639
|
-
function tagOf(value, key) {
|
|
55640
|
-
return typeof value === "object" && value !== null ? value[key] : void 0;
|
|
55641
|
-
}
|
|
55642
|
-
zElicitationFormMode.and(object({
|
|
55643
|
-
mode: literal("form")
|
|
55644
|
-
})).and(object({
|
|
55645
|
-
message: string()
|
|
55646
|
-
}));
|
|
55647
|
-
zElicitationUrlMode.and(object({
|
|
55648
|
-
mode: literal("url")
|
|
55649
|
-
})).and(object({
|
|
55650
|
-
message: string()
|
|
55651
|
-
}));
|
|
55652
|
-
union([
|
|
55653
|
-
zElicitationSessionScope,
|
|
55654
|
-
zElicitationRequestScope
|
|
55655
|
-
]).and(object({
|
|
55656
|
-
message: string()
|
|
55657
|
-
}));
|
|
55658
|
-
zStringPropertySchema.and(object({
|
|
55659
|
-
type: literal("string")
|
|
55660
|
-
}));
|
|
55661
|
-
zNumberPropertySchema.and(object({
|
|
55662
|
-
type: literal("number")
|
|
55663
|
-
}));
|
|
55664
|
-
zIntegerPropertySchema.and(object({
|
|
55665
|
-
type: literal("integer")
|
|
55666
|
-
}));
|
|
55667
|
-
zBooleanPropertySchema.and(object({
|
|
55668
|
-
type: literal("boolean")
|
|
55669
|
-
}));
|
|
55670
|
-
zMultiSelectPropertySchema.and(object({
|
|
55671
|
-
type: literal("array")
|
|
55672
|
-
}));
|
|
55673
|
-
zStringMultiSelectItems.and(object({
|
|
55674
|
-
type: literal("string")
|
|
55675
|
-
}));
|
|
55676
|
-
const zGuardCreateElicitationResponseAccept = zElicitationAcceptAction.and(object({
|
|
55677
|
-
action: literal("accept")
|
|
55678
|
-
}));
|
|
55679
|
-
const zGuardCreateElicitationResponseDecline = object({
|
|
55680
|
-
action: literal("decline")
|
|
55681
|
-
});
|
|
55682
|
-
const zGuardCreateElicitationResponseCancel = object({
|
|
55683
|
-
action: literal("cancel")
|
|
55684
|
-
});
|
|
55685
|
-
const CreateElicitationResponse = {
|
|
55686
|
-
isAccept(value) {
|
|
55687
|
-
return tagOf(value, "action") === "accept" && zGuardCreateElicitationResponseAccept.safeParse(value).success;
|
|
55688
|
-
},
|
|
55689
|
-
isDecline(value) {
|
|
55690
|
-
return tagOf(value, "action") === "decline" && zGuardCreateElicitationResponseDecline.safeParse(value).success;
|
|
55691
|
-
},
|
|
55692
|
-
isCancel(value) {
|
|
55693
|
-
return tagOf(value, "action") === "cancel" && zGuardCreateElicitationResponseCancel.safeParse(value).success;
|
|
55694
|
-
},
|
|
55695
|
-
isCustom(value) {
|
|
55696
|
-
const tag = tagOf(value, "action");
|
|
55697
|
-
return typeof tag === "string" && ![
|
|
55698
|
-
"accept",
|
|
55699
|
-
"cancel",
|
|
55700
|
-
"decline"
|
|
55701
|
-
].includes(tag);
|
|
55702
|
-
}
|
|
55703
|
-
};
|
|
55704
|
-
function ndJsonStream(output, input) {
|
|
55705
|
-
return ndJsonStream$1(output, input);
|
|
55706
|
-
}
|
|
55707
|
-
function emptyObjectResponse(response) {
|
|
55708
|
-
return response ?? {};
|
|
55709
|
-
}
|
|
55710
|
-
function isStream(value) {
|
|
55711
|
-
return typeof value === "object" && value !== null && "readable" in value && "writable" in value;
|
|
55712
|
-
}
|
|
55713
|
-
function memoryStreamPair() {
|
|
55714
|
-
const leftToRight = new TransformStream();
|
|
55715
|
-
const rightToLeft = new TransformStream();
|
|
55716
|
-
return [
|
|
55717
|
-
{
|
|
55718
|
-
readable: rightToLeft.readable,
|
|
55719
|
-
writable: leftToRight.writable
|
|
55720
|
-
},
|
|
55721
|
-
{
|
|
55722
|
-
readable: leftToRight.readable,
|
|
55723
|
-
writable: rightToLeft.writable
|
|
55724
|
-
}
|
|
55725
|
-
];
|
|
55726
|
-
}
|
|
55727
|
-
const methods = {
|
|
55728
|
-
agent: {
|
|
55729
|
-
initialize: AGENT_METHODS.initialize,
|
|
55730
|
-
authenticate: AGENT_METHODS.authenticate,
|
|
55731
|
-
logout: AGENT_METHODS.logout,
|
|
55732
|
-
providers: {
|
|
55733
|
-
list: AGENT_METHODS.providers_list,
|
|
55734
|
-
set: AGENT_METHODS.providers_set,
|
|
55735
|
-
disable: AGENT_METHODS.providers_disable
|
|
55736
|
-
},
|
|
55737
|
-
session: {
|
|
55738
|
-
new: AGENT_METHODS.session_new,
|
|
55739
|
-
load: AGENT_METHODS.session_load,
|
|
55740
|
-
list: AGENT_METHODS.session_list,
|
|
55741
|
-
delete: AGENT_METHODS.session_delete,
|
|
55742
|
-
fork: AGENT_METHODS.session_fork,
|
|
55743
|
-
resume: AGENT_METHODS.session_resume,
|
|
55744
|
-
close: AGENT_METHODS.session_close,
|
|
55745
|
-
setMode: AGENT_METHODS.session_set_mode,
|
|
55746
|
-
setConfigOption: AGENT_METHODS.session_set_config_option,
|
|
55747
|
-
prompt: AGENT_METHODS.session_prompt,
|
|
55748
|
-
cancel: AGENT_METHODS.session_cancel
|
|
55749
|
-
}
|
|
55750
|
-
},
|
|
55751
|
-
client: {
|
|
55752
|
-
session: {
|
|
55753
|
-
requestPermission: CLIENT_METHODS.session_request_permission,
|
|
55754
|
-
update: CLIENT_METHODS.session_update
|
|
55755
|
-
},
|
|
55756
|
-
fs: {
|
|
55757
|
-
writeTextFile: CLIENT_METHODS.fs_write_text_file,
|
|
55758
|
-
readTextFile: CLIENT_METHODS.fs_read_text_file
|
|
55759
|
-
},
|
|
55760
|
-
elicitation: {
|
|
55761
|
-
create: CLIENT_METHODS.elicitation_create,
|
|
55762
|
-
complete: CLIENT_METHODS.elicitation_complete
|
|
55763
|
-
}
|
|
55764
|
-
}
|
|
55765
|
-
};
|
|
55766
|
-
const startActiveSession = Symbol("startActiveSession");
|
|
55767
|
-
class AcpContext {
|
|
55768
|
-
cx;
|
|
55769
|
-
currentRequestId;
|
|
55770
|
-
constructor(cx2, currentRequestId) {
|
|
55771
|
-
this.cx = cx2;
|
|
55772
|
-
this.currentRequestId = currentRequestId;
|
|
55773
|
-
}
|
|
55774
|
-
get requestId() {
|
|
55775
|
-
return this.currentRequestId;
|
|
55776
|
-
}
|
|
55777
|
-
get connectionContext() {
|
|
55778
|
-
return this.cx;
|
|
55779
|
-
}
|
|
55780
|
-
sendRequest(method, params, mapResponse, options) {
|
|
55781
|
-
return this.cx.sendRequest(method, params, mapResponse, options);
|
|
55782
|
-
}
|
|
55783
|
-
sendNotification(method, params) {
|
|
55784
|
-
return this.cx.sendNotification(method, params);
|
|
55785
|
-
}
|
|
55786
|
-
addDynamicHandler(handler) {
|
|
55787
|
-
return this.cx.addDynamicHandler(handler);
|
|
55788
|
-
}
|
|
55789
|
-
}
|
|
55790
|
-
class AgentContext extends AcpContext {
|
|
55791
|
-
constructor(cx2, requestId) {
|
|
55792
|
-
super(cx2, requestId);
|
|
55793
|
-
}
|
|
55794
|
-
static create(cx2, requestId) {
|
|
55795
|
-
return new AgentContext(cx2, requestId);
|
|
55796
|
-
}
|
|
55797
|
-
request(method, params, options) {
|
|
55798
|
-
const spec = clientRequestSpecsByMethod[method];
|
|
55799
|
-
return this.sendRequest(method, params, spec?.mapResponse, options);
|
|
55800
|
-
}
|
|
55801
|
-
notify(method, params) {
|
|
55802
|
-
return this.sendNotification(method, params);
|
|
55803
|
-
}
|
|
55804
|
-
}
|
|
55805
|
-
class ClientContext extends AcpContext {
|
|
55806
|
-
constructor(cx2, requestId) {
|
|
55807
|
-
super(cx2, requestId);
|
|
55808
|
-
}
|
|
55809
|
-
static create(cx2, requestId) {
|
|
55810
|
-
return new ClientContext(cx2, requestId);
|
|
55811
|
-
}
|
|
55812
|
-
[startActiveSession](params, options) {
|
|
55813
|
-
return this.sendRequest(AGENT_METHODS.session_new, params, (response) => this.attachSession(response), options);
|
|
55814
|
-
}
|
|
55815
|
-
buildSession(cwdOrRequest) {
|
|
55816
|
-
if (typeof cwdOrRequest === "string") {
|
|
55817
|
-
return SessionBuilder.create(this, {
|
|
55818
|
-
cwd: cwdOrRequest,
|
|
55819
|
-
mcpServers: []
|
|
55820
|
-
});
|
|
55821
|
-
}
|
|
55822
|
-
return SessionBuilder.create(this, cwdOrRequest);
|
|
55823
|
-
}
|
|
55824
|
-
attachSession(response) {
|
|
55825
|
-
const updates = new AsyncQueue();
|
|
55826
|
-
const closeSignal = this.connectionContext.signal;
|
|
55827
|
-
const failUpdatesOnClose = () => {
|
|
55828
|
-
updates.fail(closeSignal.reason ?? new Error("ACP connection closed"));
|
|
55829
|
-
};
|
|
55830
|
-
if (closeSignal.aborted) {
|
|
55831
|
-
failUpdatesOnClose();
|
|
55832
|
-
} else {
|
|
55833
|
-
closeSignal.addEventListener("abort", failUpdatesOnClose);
|
|
55834
|
-
}
|
|
55835
|
-
const sessionRegistration = sessionUpdateRouter(this.connectionContext).attach(response, updates);
|
|
55836
|
-
const closeRegistration = new HandlerRegistration(() => {
|
|
55837
|
-
closeSignal.removeEventListener("abort", failUpdatesOnClose);
|
|
55838
|
-
});
|
|
55839
|
-
return ActiveSession.create(this, response, updates, [
|
|
55840
|
-
sessionRegistration,
|
|
55841
|
-
closeRegistration
|
|
55842
|
-
]);
|
|
55843
|
-
}
|
|
55844
|
-
request(method, params, options) {
|
|
55845
|
-
const spec = agentRequestSpecsByMethod[method];
|
|
55846
|
-
return this.sendRequest(method, params, spec?.mapResponse, options);
|
|
55847
|
-
}
|
|
55848
|
-
notify(method, params) {
|
|
55849
|
-
return this.sendNotification(method, params);
|
|
55850
|
-
}
|
|
55851
|
-
}
|
|
55852
|
-
class AcpConnectionHandle {
|
|
55853
|
-
connection;
|
|
55854
|
-
constructor(connection2) {
|
|
55855
|
-
this.connection = connection2;
|
|
55856
|
-
}
|
|
55857
|
-
get signal() {
|
|
55858
|
-
return this.connection.signal;
|
|
55859
|
-
}
|
|
55860
|
-
get closed() {
|
|
55861
|
-
return this.connection.closed;
|
|
55862
|
-
}
|
|
55863
|
-
close(error) {
|
|
55864
|
-
this.connection.close(error);
|
|
55865
|
-
}
|
|
55866
|
-
}
|
|
55867
|
-
class AgentConnectionHandle extends AcpConnectionHandle {
|
|
55868
|
-
connectHandlers;
|
|
55869
|
-
client;
|
|
55870
|
-
didStartConnectHandlers = false;
|
|
55871
|
-
constructor(connection2, connectHandlers = []) {
|
|
55872
|
-
super(connection2);
|
|
55873
|
-
this.connectHandlers = connectHandlers;
|
|
55874
|
-
this.client = AgentContext.create(connection2.getContext());
|
|
55875
|
-
}
|
|
55876
|
-
startConnectHandlers() {
|
|
55877
|
-
if (this.didStartConnectHandlers) {
|
|
55878
|
-
return;
|
|
55879
|
-
}
|
|
55880
|
-
this.didStartConnectHandlers = true;
|
|
55881
|
-
runConnectHandlers(this, this.connectHandlers);
|
|
55882
|
-
}
|
|
55883
|
-
}
|
|
55884
|
-
class ClientConnectionHandle extends AcpConnectionHandle {
|
|
55885
|
-
connectHandlers;
|
|
55886
|
-
agent;
|
|
55887
|
-
didStartConnectHandlers = false;
|
|
55888
|
-
constructor(connection2, connectHandlers = []) {
|
|
55889
|
-
super(connection2);
|
|
55890
|
-
this.connectHandlers = connectHandlers;
|
|
55891
|
-
this.agent = ClientContext.create(connection2.getContext());
|
|
55892
|
-
}
|
|
55893
|
-
startConnectHandlers() {
|
|
55894
|
-
if (this.didStartConnectHandlers) {
|
|
55895
|
-
return;
|
|
55896
|
-
}
|
|
55897
|
-
this.didStartConnectHandlers = true;
|
|
55898
|
-
runConnectHandlers(this, this.connectHandlers);
|
|
55899
|
-
}
|
|
55900
|
-
}
|
|
55901
|
-
function agentConnection(connection2, connectHandlers = []) {
|
|
55902
|
-
return new AgentConnectionHandle(connection2, connectHandlers);
|
|
55903
|
-
}
|
|
55904
|
-
function clientConnection(connection2, connectHandlers = []) {
|
|
55905
|
-
return new ClientConnectionHandle(connection2, connectHandlers);
|
|
55906
|
-
}
|
|
55907
|
-
class AsyncQueue {
|
|
55908
|
-
values = [];
|
|
55909
|
-
waiters = [];
|
|
55910
|
-
failed = false;
|
|
55911
|
-
failure;
|
|
55912
|
-
enqueue(value) {
|
|
55913
|
-
if (this.failed) {
|
|
55914
|
-
return;
|
|
55915
|
-
}
|
|
55916
|
-
const waiter = this.waiters.shift();
|
|
55917
|
-
if (waiter) {
|
|
55918
|
-
waiter.resolve(value);
|
|
55919
|
-
} else {
|
|
55920
|
-
this.values.push({
|
|
55921
|
-
kind: "value",
|
|
55922
|
-
value
|
|
55923
|
-
});
|
|
55924
|
-
}
|
|
55925
|
-
}
|
|
55926
|
-
reject(error) {
|
|
55927
|
-
if (this.failed) {
|
|
55928
|
-
return;
|
|
55929
|
-
}
|
|
55930
|
-
if (this.waiters.length > 0) {
|
|
55931
|
-
for (const waiter of this.waiters.splice(0)) {
|
|
55932
|
-
waiter.reject(error);
|
|
55933
|
-
}
|
|
55934
|
-
return;
|
|
55935
|
-
}
|
|
55936
|
-
this.values.push({
|
|
55937
|
-
kind: "error",
|
|
55938
|
-
error
|
|
55939
|
-
});
|
|
55940
|
-
}
|
|
55941
|
-
clearErrors() {
|
|
55942
|
-
this.values = this.values.filter((entry) => entry.kind === "value");
|
|
55943
|
-
}
|
|
55944
|
-
fail(error) {
|
|
55945
|
-
if (this.failed) {
|
|
55946
|
-
return;
|
|
55947
|
-
}
|
|
55948
|
-
this.failed = true;
|
|
55949
|
-
this.failure = error;
|
|
55950
|
-
for (const waiter of this.waiters.splice(0)) {
|
|
55951
|
-
waiter.reject(error);
|
|
55952
|
-
}
|
|
55953
|
-
}
|
|
55954
|
-
next() {
|
|
55955
|
-
if (this.values.length > 0) {
|
|
55956
|
-
const entry = this.values.shift();
|
|
55957
|
-
if (entry.kind === "error") {
|
|
55958
|
-
return Promise.reject(entry.error);
|
|
55959
|
-
}
|
|
55960
|
-
return Promise.resolve(entry.value);
|
|
55961
|
-
}
|
|
55962
|
-
if (this.failed) {
|
|
55963
|
-
return Promise.reject(this.failure);
|
|
55964
|
-
}
|
|
55965
|
-
return new Promise((resolve2, reject) => {
|
|
55966
|
-
this.waiters.push({
|
|
55967
|
-
resolve: resolve2,
|
|
55968
|
-
reject
|
|
55969
|
-
});
|
|
55970
|
-
});
|
|
55971
|
-
}
|
|
55972
|
-
}
|
|
55973
|
-
function cloneNewSessionRequest(request) {
|
|
55974
|
-
return {
|
|
55975
|
-
...request,
|
|
55976
|
-
additionalDirectories: request.additionalDirectories ? [
|
|
55977
|
-
...request.additionalDirectories
|
|
55978
|
-
] : void 0,
|
|
55979
|
-
mcpServers: [
|
|
55980
|
-
...request.mcpServers
|
|
55981
|
-
]
|
|
55982
|
-
};
|
|
55983
|
-
}
|
|
55984
|
-
class SessionBuilder {
|
|
55985
|
-
cx;
|
|
55986
|
-
request;
|
|
55987
|
-
constructor(cx2, request) {
|
|
55988
|
-
this.cx = cx2;
|
|
55989
|
-
this.request = cloneNewSessionRequest(request);
|
|
55990
|
-
}
|
|
55991
|
-
static create(cx2, request) {
|
|
55992
|
-
return new SessionBuilder(cx2, request);
|
|
55993
|
-
}
|
|
55994
|
-
toRequest() {
|
|
55995
|
-
return cloneNewSessionRequest(this.request);
|
|
55996
|
-
}
|
|
55997
|
-
withAdditionalDirectories(additionalDirectories) {
|
|
55998
|
-
this.request = {
|
|
55999
|
-
...this.request,
|
|
56000
|
-
additionalDirectories: [
|
|
56001
|
-
...additionalDirectories
|
|
56002
|
-
]
|
|
56003
|
-
};
|
|
56004
|
-
return this;
|
|
56005
|
-
}
|
|
56006
|
-
withMcpServer(mcpServer) {
|
|
56007
|
-
this.request = {
|
|
56008
|
-
...this.request,
|
|
56009
|
-
mcpServers: [
|
|
56010
|
-
...this.request.mcpServers,
|
|
56011
|
-
mcpServer
|
|
56012
|
-
]
|
|
56013
|
-
};
|
|
56014
|
-
return this;
|
|
56015
|
-
}
|
|
56016
|
-
async start(options) {
|
|
56017
|
-
return this.cx[startActiveSession](this.toRequest(), options);
|
|
56018
|
-
}
|
|
56019
|
-
async withSession(op2) {
|
|
56020
|
-
const session = await this.start();
|
|
56021
|
-
try {
|
|
56022
|
-
return await op2(session);
|
|
56023
|
-
} finally {
|
|
56024
|
-
session.dispose();
|
|
56025
|
-
}
|
|
56026
|
-
}
|
|
56027
|
-
}
|
|
56028
|
-
class ActiveSession {
|
|
56029
|
-
cx;
|
|
56030
|
-
sessionResponse;
|
|
56031
|
-
updates;
|
|
56032
|
-
registrations;
|
|
56033
|
-
constructor(cx2, sessionResponse, updates, registrations) {
|
|
56034
|
-
this.cx = cx2;
|
|
56035
|
-
this.sessionResponse = sessionResponse;
|
|
56036
|
-
this.updates = updates;
|
|
56037
|
-
this.registrations = registrations;
|
|
56038
|
-
}
|
|
56039
|
-
static create(cx2, sessionResponse, updates, registrations) {
|
|
56040
|
-
return new ActiveSession(cx2, sessionResponse, updates, registrations);
|
|
56041
|
-
}
|
|
56042
|
-
get sessionId() {
|
|
56043
|
-
return this.sessionResponse.sessionId;
|
|
56044
|
-
}
|
|
56045
|
-
get modes() {
|
|
56046
|
-
return this.sessionResponse.modes;
|
|
56047
|
-
}
|
|
56048
|
-
get meta() {
|
|
56049
|
-
return this.sessionResponse._meta;
|
|
56050
|
-
}
|
|
56051
|
-
get newSessionResponse() {
|
|
56052
|
-
return this.sessionResponse;
|
|
56053
|
-
}
|
|
56054
|
-
prompt(prompt, options) {
|
|
56055
|
-
this.updates.clearErrors();
|
|
56056
|
-
const response = this.cx.request(AGENT_METHODS.session_prompt, {
|
|
56057
|
-
sessionId: this.sessionId,
|
|
56058
|
-
prompt: this.promptBlocks(prompt)
|
|
56059
|
-
}, options);
|
|
56060
|
-
void response.then((value) => {
|
|
56061
|
-
this.updates.enqueue({
|
|
56062
|
-
kind: "stop",
|
|
56063
|
-
response: value,
|
|
56064
|
-
stopReason: value.stopReason
|
|
56065
|
-
});
|
|
56066
|
-
}, (error) => {
|
|
56067
|
-
this.updates.reject(error);
|
|
56068
|
-
});
|
|
56069
|
-
return response;
|
|
56070
|
-
}
|
|
56071
|
-
nextUpdate() {
|
|
56072
|
-
return this.updates.next();
|
|
56073
|
-
}
|
|
56074
|
-
async readText() {
|
|
56075
|
-
let output = "";
|
|
56076
|
-
for (; ; ) {
|
|
56077
|
-
const message = await this.nextUpdate();
|
|
56078
|
-
if (message.kind === "stop") {
|
|
56079
|
-
return output;
|
|
56080
|
-
}
|
|
56081
|
-
const { update } = message;
|
|
56082
|
-
if (update.sessionUpdate === "agent_message_chunk" && update.content.type === "text") {
|
|
56083
|
-
output += update.content.text;
|
|
56084
|
-
}
|
|
56085
|
-
}
|
|
56086
|
-
}
|
|
56087
|
-
dispose() {
|
|
56088
|
-
for (const registration of this.registrations.splice(0)) {
|
|
56089
|
-
registration.dispose();
|
|
56090
|
-
}
|
|
56091
|
-
this.updates.fail(new Error("Active session disposed"));
|
|
56092
|
-
}
|
|
56093
|
-
[Symbol.dispose]() {
|
|
56094
|
-
this.dispose();
|
|
56095
|
-
}
|
|
56096
|
-
promptBlocks(prompt) {
|
|
56097
|
-
if (typeof prompt === "string") {
|
|
56098
|
-
return [
|
|
56099
|
-
{
|
|
56100
|
-
type: "text",
|
|
56101
|
-
text: prompt
|
|
56102
|
-
}
|
|
56103
|
-
];
|
|
56104
|
-
}
|
|
56105
|
-
if (Array.isArray(prompt)) {
|
|
56106
|
-
return prompt;
|
|
56107
|
-
}
|
|
56108
|
-
return [
|
|
56109
|
-
prompt
|
|
56110
|
-
];
|
|
56111
|
-
}
|
|
56112
|
-
}
|
|
56113
|
-
function parseParams(parser, params) {
|
|
56114
|
-
if (!parser) {
|
|
56115
|
-
return params;
|
|
56116
|
-
}
|
|
56117
|
-
if (typeof parser === "function") {
|
|
56118
|
-
return parser(params);
|
|
56119
|
-
}
|
|
56120
|
-
return parser.parse(params);
|
|
56121
|
-
}
|
|
56122
|
-
function requestSpec(method, params, mapResponse) {
|
|
56123
|
-
return {
|
|
56124
|
-
method,
|
|
56125
|
-
params,
|
|
56126
|
-
mapResponse
|
|
56127
|
-
};
|
|
56128
|
-
}
|
|
56129
|
-
function notificationSpec(method, params) {
|
|
56130
|
-
return {
|
|
56131
|
-
method,
|
|
56132
|
-
params
|
|
56133
|
-
};
|
|
56134
|
-
}
|
|
56135
|
-
function registerAppRequest(builder, spec, context, handler) {
|
|
56136
|
-
builder.onReceiveRequest(spec.method, (params) => parseParams(spec.params, params), async (params, responder, cx2) => {
|
|
56137
|
-
const response = await handler(context(params, cx2, responder.signal, responder.id));
|
|
56138
|
-
await responder.respond(spec.mapResponse ? spec.mapResponse(response) : response);
|
|
56139
|
-
});
|
|
56140
|
-
}
|
|
56141
|
-
function registerAppNotification(builder, spec, context, handler) {
|
|
56142
|
-
builder.onReceiveNotification(spec.method, (params) => parseParams(spec.params, params), (params, cx2) => handler(context(params, cx2, cx2.signal)));
|
|
56143
|
-
}
|
|
56144
|
-
function specsByMethod(specs) {
|
|
56145
|
-
const byMethod = {};
|
|
56146
|
-
for (const spec of Object.values(specs)) {
|
|
56147
|
-
byMethod[spec.method] = spec;
|
|
56148
|
-
}
|
|
56149
|
-
return byMethod;
|
|
56150
|
-
}
|
|
56151
|
-
const agentRequestSpecs = {
|
|
56152
|
-
initialize: requestSpec(AGENT_METHODS.initialize, zInitializeRequest),
|
|
56153
|
-
newSession: requestSpec(AGENT_METHODS.session_new, zNewSessionRequest),
|
|
56154
|
-
loadSession: requestSpec(AGENT_METHODS.session_load, zLoadSessionRequest, emptyObjectResponse),
|
|
56155
|
-
unstable_forkSession: requestSpec(AGENT_METHODS.session_fork, zForkSessionRequest),
|
|
56156
|
-
listSessions: requestSpec(AGENT_METHODS.session_list, zListSessionsRequest),
|
|
56157
|
-
deleteSession: requestSpec(AGENT_METHODS.session_delete, zDeleteSessionRequest, emptyObjectResponse),
|
|
56158
|
-
resumeSession: requestSpec(AGENT_METHODS.session_resume, zResumeSessionRequest),
|
|
56159
|
-
closeSession: requestSpec(AGENT_METHODS.session_close, zCloseSessionRequest, emptyObjectResponse),
|
|
56160
|
-
setSessionMode: requestSpec(AGENT_METHODS.session_set_mode, zSetSessionModeRequest, emptyObjectResponse),
|
|
56161
|
-
setSessionConfigOption: requestSpec(AGENT_METHODS.session_set_config_option, zSetSessionConfigOptionRequest),
|
|
56162
|
-
authenticate: requestSpec(AGENT_METHODS.authenticate, zAuthenticateRequest, emptyObjectResponse),
|
|
56163
|
-
unstable_listProviders: requestSpec(AGENT_METHODS.providers_list, zListProvidersRequest),
|
|
56164
|
-
unstable_setProvider: requestSpec(AGENT_METHODS.providers_set, zSetProviderRequest, emptyObjectResponse),
|
|
56165
|
-
unstable_disableProvider: requestSpec(AGENT_METHODS.providers_disable, zDisableProviderRequest, emptyObjectResponse),
|
|
56166
|
-
logout: requestSpec(AGENT_METHODS.logout, zLogoutRequest, emptyObjectResponse),
|
|
56167
|
-
prompt: requestSpec(AGENT_METHODS.session_prompt, zPromptRequest),
|
|
56168
|
-
unstable_startNes: requestSpec(AGENT_METHODS.nes_start, zStartNesRequest),
|
|
56169
|
-
unstable_suggestNes: requestSpec(AGENT_METHODS.nes_suggest, zSuggestNesRequest),
|
|
56170
|
-
unstable_closeNes: requestSpec(AGENT_METHODS.nes_close, zCloseNesRequest, emptyObjectResponse)
|
|
56171
|
-
};
|
|
56172
|
-
const agentNotificationSpecs = {
|
|
56173
|
-
cancel: notificationSpec(AGENT_METHODS.session_cancel, zCancelNotification),
|
|
56174
|
-
unstable_didOpenDocument: notificationSpec(AGENT_METHODS.document_did_open, zDidOpenDocumentNotification),
|
|
56175
|
-
unstable_didChangeDocument: notificationSpec(AGENT_METHODS.document_did_change, zDidChangeDocumentNotification),
|
|
56176
|
-
unstable_didCloseDocument: notificationSpec(AGENT_METHODS.document_did_close, zDidCloseDocumentNotification),
|
|
56177
|
-
unstable_didSaveDocument: notificationSpec(AGENT_METHODS.document_did_save, zDidSaveDocumentNotification),
|
|
56178
|
-
unstable_didFocusDocument: notificationSpec(AGENT_METHODS.document_did_focus, zDidFocusDocumentNotification),
|
|
56179
|
-
unstable_acceptNes: notificationSpec(AGENT_METHODS.nes_accept, zAcceptNesNotification),
|
|
56180
|
-
unstable_rejectNes: notificationSpec(AGENT_METHODS.nes_reject, zRejectNesNotification)
|
|
56181
|
-
};
|
|
56182
|
-
const clientRequestSpecs = {
|
|
56183
|
-
requestPermission: requestSpec(CLIENT_METHODS.session_request_permission, zRequestPermissionRequest),
|
|
56184
|
-
writeTextFile: requestSpec(CLIENT_METHODS.fs_write_text_file, zWriteTextFileRequest, emptyObjectResponse),
|
|
56185
|
-
readTextFile: requestSpec(CLIENT_METHODS.fs_read_text_file, zReadTextFileRequest),
|
|
56186
|
-
createTerminal: requestSpec(CLIENT_METHODS.terminal_create, zCreateTerminalRequest),
|
|
56187
|
-
terminalOutput: requestSpec(CLIENT_METHODS.terminal_output, zTerminalOutputRequest),
|
|
56188
|
-
releaseTerminal: requestSpec(CLIENT_METHODS.terminal_release, zReleaseTerminalRequest, emptyObjectResponse),
|
|
56189
|
-
waitForTerminalExit: requestSpec(CLIENT_METHODS.terminal_wait_for_exit, zWaitForTerminalExitRequest),
|
|
56190
|
-
killTerminal: requestSpec(CLIENT_METHODS.terminal_kill, zKillTerminalRequest, emptyObjectResponse),
|
|
56191
|
-
unstable_createElicitation: requestSpec(CLIENT_METHODS.elicitation_create, zCreateElicitationRequest)
|
|
56192
|
-
};
|
|
56193
|
-
const clientNotificationSpecs = {
|
|
56194
|
-
sessionUpdate: notificationSpec(CLIENT_METHODS.session_update, zSessionNotification),
|
|
56195
|
-
unstable_completeElicitation: notificationSpec(CLIENT_METHODS.elicitation_complete, zCompleteElicitationNotification)
|
|
56196
|
-
};
|
|
56197
|
-
const agentRequestSpecsByMethod = specsByMethod(agentRequestSpecs);
|
|
56198
|
-
const agentNotificationSpecsByMethod = specsByMethod(agentNotificationSpecs);
|
|
56199
|
-
const clientRequestSpecsByMethod = specsByMethod(clientRequestSpecs);
|
|
56200
|
-
specsByMethod(clientNotificationSpecs);
|
|
56201
|
-
function agentRequestContext(params, client, signal, requestId) {
|
|
56202
|
-
return {
|
|
56203
|
-
params,
|
|
56204
|
-
requestId,
|
|
56205
|
-
signal,
|
|
56206
|
-
client
|
|
56207
|
-
};
|
|
56208
|
-
}
|
|
56209
|
-
function agentNotificationContext(params, client, signal) {
|
|
56210
|
-
return {
|
|
56211
|
-
params,
|
|
56212
|
-
signal,
|
|
56213
|
-
client
|
|
56214
|
-
};
|
|
56215
|
-
}
|
|
56216
|
-
class SessionUpdateRouter {
|
|
56217
|
-
activeSessions = /* @__PURE__ */ new Map();
|
|
56218
|
-
handleMessage(message) {
|
|
56219
|
-
if (message.kind !== "notification" || message.method !== CLIENT_METHODS.session_update) {
|
|
56220
|
-
return Handled.no(message);
|
|
56221
|
-
}
|
|
56222
|
-
const notification = zSessionNotification.parse(message.params);
|
|
56223
|
-
const update = {
|
|
56224
|
-
kind: "session_update",
|
|
56225
|
-
notification,
|
|
56226
|
-
update: notification.update
|
|
56227
|
-
};
|
|
56228
|
-
const activeSessions = this.activeSessions.get(notification.sessionId);
|
|
56229
|
-
if (activeSessions && activeSessions.size > 0) {
|
|
56230
|
-
for (const session of activeSessions) {
|
|
56231
|
-
session.enqueue(update);
|
|
56232
|
-
}
|
|
56233
|
-
}
|
|
56234
|
-
return Handled.no(message);
|
|
56235
|
-
}
|
|
56236
|
-
attach(response, updates) {
|
|
56237
|
-
const sessions = this.activeSessions.get(response.sessionId) ?? /* @__PURE__ */ new Set();
|
|
56238
|
-
sessions.add(updates);
|
|
56239
|
-
this.activeSessions.set(response.sessionId, sessions);
|
|
56240
|
-
return new HandlerRegistration(() => {
|
|
56241
|
-
sessions.delete(updates);
|
|
56242
|
-
if (sessions.size === 0) {
|
|
56243
|
-
this.activeSessions.delete(response.sessionId);
|
|
56244
|
-
}
|
|
56245
|
-
});
|
|
56246
|
-
}
|
|
56247
|
-
}
|
|
56248
|
-
const sessionUpdateRouters = /* @__PURE__ */ new WeakMap();
|
|
56249
|
-
function sessionUpdateRouter(cx2) {
|
|
56250
|
-
let router = sessionUpdateRouters.get(cx2);
|
|
56251
|
-
if (!router) {
|
|
56252
|
-
router = new SessionUpdateRouter();
|
|
56253
|
-
sessionUpdateRouters.set(cx2, router);
|
|
56254
|
-
}
|
|
56255
|
-
return router;
|
|
56256
|
-
}
|
|
56257
|
-
function runConnectHandlers(connection2, handlers) {
|
|
56258
|
-
for (const handler of handlers) {
|
|
56259
|
-
let result;
|
|
56260
|
-
try {
|
|
56261
|
-
result = handler(connection2);
|
|
56262
|
-
} catch (error) {
|
|
56263
|
-
connection2.close(error);
|
|
56264
|
-
throw error;
|
|
56265
|
-
}
|
|
56266
|
-
void Promise.resolve(result).catch((error) => {
|
|
56267
|
-
connection2.close(error);
|
|
56268
|
-
});
|
|
56269
|
-
}
|
|
56270
|
-
}
|
|
56271
|
-
const appBuilder = Symbol("appBuilder");
|
|
56272
|
-
const runAgentConnectHandlers = Symbol("runAgentConnectHandlers");
|
|
56273
|
-
const runClientConnectHandlers = Symbol("runClientConnectHandlers");
|
|
56274
|
-
const stableConnectionOptions = {
|
|
56275
|
-
allowBatches: false
|
|
56276
|
-
};
|
|
56277
|
-
function agent$1(options) {
|
|
56278
|
-
return new AgentApp(options);
|
|
56279
|
-
}
|
|
56280
|
-
class AgentApp {
|
|
56281
|
-
builder = Connection.builder();
|
|
56282
|
-
connectHandlers = [];
|
|
56283
|
-
constructor(options = {}) {
|
|
56284
|
-
if (options.name) {
|
|
56285
|
-
this.builder.name(options.name);
|
|
56286
|
-
}
|
|
56287
|
-
}
|
|
56288
|
-
[appBuilder]() {
|
|
56289
|
-
return this.builder;
|
|
56290
|
-
}
|
|
56291
|
-
[runAgentConnectHandlers](connection2) {
|
|
56292
|
-
runConnectHandlers(connection2, this.connectHandlers);
|
|
56293
|
-
}
|
|
56294
|
-
connect(target, options = {}) {
|
|
56295
|
-
return this.connectConnection(target, options).connection;
|
|
56296
|
-
}
|
|
56297
|
-
connectWith(target, op2) {
|
|
56298
|
-
const { rawConnection, connection: connection2 } = this.connectConnection(target);
|
|
56299
|
-
return rawConnection.runUntil(() => op2(connection2.client));
|
|
56300
|
-
}
|
|
56301
|
-
onConnect(handler) {
|
|
56302
|
-
this.connectHandlers.push(handler);
|
|
56303
|
-
return this;
|
|
56304
|
-
}
|
|
56305
|
-
onRequest(method, handlerOrParams, handler) {
|
|
56306
|
-
if (handler) {
|
|
56307
|
-
return this.request({
|
|
56308
|
-
method,
|
|
56309
|
-
params: handlerOrParams
|
|
56310
|
-
}, handler);
|
|
56311
|
-
}
|
|
56312
|
-
const spec = agentRequestSpecsByMethod[method];
|
|
56313
|
-
if (!spec) {
|
|
56314
|
-
throw new Error(`Unknown ACP request method '${method}'. Pass a params parser for custom methods.`);
|
|
56315
|
-
}
|
|
56316
|
-
return this.request(spec, handlerOrParams);
|
|
56317
|
-
}
|
|
56318
|
-
onNotification(method, handlerOrParams, handler) {
|
|
56319
|
-
if (handler) {
|
|
56320
|
-
return this.notification({
|
|
56321
|
-
method,
|
|
56322
|
-
params: handlerOrParams
|
|
56323
|
-
}, handler);
|
|
56324
|
-
}
|
|
56325
|
-
const spec = agentNotificationSpecsByMethod[method];
|
|
56326
|
-
if (!spec) {
|
|
56327
|
-
throw new Error(`Unknown ACP notification method '${method}'. Pass a params parser for custom methods.`);
|
|
56328
|
-
}
|
|
56329
|
-
return this.notification(spec, handlerOrParams);
|
|
56330
|
-
}
|
|
56331
|
-
request(spec, handler) {
|
|
56332
|
-
registerAppRequest(this.builder, spec, (params, cx2, signal, requestId) => agentRequestContext(params, AgentContext.create(cx2, requestId), signal, requestId), handler);
|
|
56333
|
-
return this;
|
|
56334
|
-
}
|
|
56335
|
-
notification(spec, handler) {
|
|
56336
|
-
registerAppNotification(this.builder, spec, (params, cx2, signal) => agentNotificationContext(params, AgentContext.create(cx2), signal), handler);
|
|
56337
|
-
return this;
|
|
56338
|
-
}
|
|
56339
|
-
connectConnection(target, options = {}) {
|
|
56340
|
-
if (isStream(target)) {
|
|
56341
|
-
const state2 = this.openStreamConnection(target);
|
|
56342
|
-
if (!options.deferConnectHandlers) {
|
|
56343
|
-
this[runAgentConnectHandlers](state2.connection);
|
|
56344
|
-
}
|
|
56345
|
-
return state2;
|
|
56346
|
-
}
|
|
56347
|
-
const [thisStream, peerStream] = memoryStreamPair();
|
|
56348
|
-
const peerRawConnection = target[appBuilder]().connect(peerStream, stableConnectionOptions);
|
|
56349
|
-
const peerConnection = clientConnection(peerRawConnection);
|
|
56350
|
-
const state = this.openStreamConnection(thisStream);
|
|
56351
|
-
void state.rawConnection.closed.then(() => peerConnection.close());
|
|
56352
|
-
void peerRawConnection.closed.then(() => state.connection.close());
|
|
56353
|
-
try {
|
|
56354
|
-
target[runClientConnectHandlers](peerConnection);
|
|
56355
|
-
this[runAgentConnectHandlers](state.connection);
|
|
56356
|
-
} catch (error) {
|
|
56357
|
-
peerConnection.close(error);
|
|
56358
|
-
state.connection.close(error);
|
|
56359
|
-
throw error;
|
|
56360
|
-
}
|
|
56361
|
-
return state;
|
|
56362
|
-
}
|
|
56363
|
-
openStreamConnection(stream) {
|
|
56364
|
-
const rawConnection = this.builder.connect(stream, stableConnectionOptions);
|
|
56365
|
-
return {
|
|
56366
|
-
rawConnection,
|
|
56367
|
-
connection: agentConnection(rawConnection, this.connectHandlers)
|
|
56368
|
-
};
|
|
56369
|
-
}
|
|
56370
|
-
}
|
|
56371
52931
|
function mcpElicitationToCreateRequest(request, sessionId) {
|
|
56372
52932
|
if (request.mode === "url") {
|
|
56373
52933
|
if (!request.url) {
|
|
@@ -57601,7 +54161,7 @@ ${content.text}
|
|
|
57601
54161
|
}
|
|
57602
54162
|
}
|
|
57603
54163
|
function nodeToWebWritable(nodeStream) {
|
|
57604
|
-
return new WritableStream
|
|
54164
|
+
return new WritableStream({
|
|
57605
54165
|
write(chunk) {
|
|
57606
54166
|
return new Promise((resolve2, reject) => {
|
|
57607
54167
|
nodeStream.write(Buffer.from(chunk), (err) => {
|
|
@@ -57883,6 +54443,16 @@ ${content.text}
|
|
|
57883
54443
|
const DEFAULT_FORCE_CANCEL_GRACE_MS = 3e4;
|
|
57884
54444
|
const TURN_NO_RESULT_MESSAGE = "The turn ended without a result: the agent went idle while this prompt was still in flight (e.g. the model stream dropped mid-turn). Any partial output may be incomplete; please retry.";
|
|
57885
54445
|
const STEER_METHOD = "_session/steering";
|
|
54446
|
+
function getLodyForkTurnId(meta) {
|
|
54447
|
+
if (!meta || typeof meta !== "object") return void 0;
|
|
54448
|
+
const lody = meta.lody;
|
|
54449
|
+
if (!lody || typeof lody !== "object") return void 0;
|
|
54450
|
+
const forkAtTurn = lody.forkAtTurn;
|
|
54451
|
+
if (!forkAtTurn || typeof forkAtTurn !== "object") return void 0;
|
|
54452
|
+
const version = forkAtTurn.version;
|
|
54453
|
+
const turnId = forkAtTurn.turnId;
|
|
54454
|
+
return version === 1 && typeof turnId === "string" && turnId.length > 0 ? turnId : void 0;
|
|
54455
|
+
}
|
|
57886
54456
|
const STEER_PRIORITY = "now";
|
|
57887
54457
|
function parseSteerRequest(params) {
|
|
57888
54458
|
if (!params || typeof params !== "object") {
|
|
@@ -58320,6 +54890,11 @@ ${content.text}
|
|
|
58320
54890
|
version: 1,
|
|
58321
54891
|
appliedNotification: CLAUDE_STEER_APPLIED_METHOD
|
|
58322
54892
|
}
|
|
54893
|
+
},
|
|
54894
|
+
lody: {
|
|
54895
|
+
forkAtTurn: {
|
|
54896
|
+
version: 1
|
|
54897
|
+
}
|
|
58323
54898
|
}
|
|
58324
54899
|
},
|
|
58325
54900
|
promptCapabilities: {
|
|
@@ -58377,6 +54952,7 @@ ${content.text}
|
|
|
58377
54952
|
};
|
|
58378
54953
|
}
|
|
58379
54954
|
async unstable_forkSession(params) {
|
|
54955
|
+
const forkTurnId = getLodyForkTurnId(params._meta);
|
|
58380
54956
|
const response = await this.createSession({
|
|
58381
54957
|
cwd: params.cwd,
|
|
58382
54958
|
mcpServers: params.mcpServers ?? [],
|
|
@@ -58384,7 +54960,8 @@ ${content.text}
|
|
|
58384
54960
|
_meta: params._meta
|
|
58385
54961
|
}, {
|
|
58386
54962
|
resume: params.sessionId,
|
|
58387
|
-
forkSession: true
|
|
54963
|
+
forkSession: true,
|
|
54964
|
+
resumeSessionAt: forkTurnId
|
|
58388
54965
|
});
|
|
58389
54966
|
setTimeout(() => {
|
|
58390
54967
|
this.sendAvailableCommandsUpdate(response.sessionId);
|
|
@@ -58687,14 +55264,14 @@ ${content.text}
|
|
|
58687
55264
|
session.pendingOrphanResults = 0;
|
|
58688
55265
|
session.orphanCommands?.clear();
|
|
58689
55266
|
if (!turn.isLocalOnlyCommand) {
|
|
58690
|
-
for (const [taskId,
|
|
58691
|
-
if (!
|
|
55267
|
+
for (const [taskId, record] of session.liveBackgroundTasks) {
|
|
55268
|
+
if (!record.endedPerLevel) {
|
|
58692
55269
|
continue;
|
|
58693
55270
|
}
|
|
58694
|
-
if (
|
|
55271
|
+
if (record.endedPerLevel === "sweep-armed") {
|
|
58695
55272
|
session.liveBackgroundTasks.delete(taskId);
|
|
58696
55273
|
} else {
|
|
58697
|
-
|
|
55274
|
+
record.endedPerLevel = "sweep-armed";
|
|
58698
55275
|
}
|
|
58699
55276
|
}
|
|
58700
55277
|
}
|
|
@@ -58763,8 +55340,8 @@ ${content.text}
|
|
|
58763
55340
|
return false;
|
|
58764
55341
|
}
|
|
58765
55342
|
for (const taskId of turn.spawnedTaskIds) {
|
|
58766
|
-
const
|
|
58767
|
-
if (
|
|
55343
|
+
const record = session.liveBackgroundTasks.get(taskId);
|
|
55344
|
+
if (record?.isSubagent && !record.endedPerLevel) {
|
|
58768
55345
|
return true;
|
|
58769
55346
|
}
|
|
58770
55347
|
}
|
|
@@ -59250,13 +55827,13 @@ ${message.api_refusal_explanation}` : "";
|
|
|
59250
55827
|
case "background_tasks_changed":
|
|
59251
55828
|
if (session.liveBackgroundTasks.size > 0) {
|
|
59252
55829
|
const live = new Set(message.tasks.map((t) => t.task_id));
|
|
59253
|
-
for (const [taskId,
|
|
55830
|
+
for (const [taskId, record] of session.liveBackgroundTasks) {
|
|
59254
55831
|
if (live.has(taskId)) {
|
|
59255
|
-
|
|
55832
|
+
record.endedPerLevel = void 0;
|
|
59256
55833
|
continue;
|
|
59257
55834
|
}
|
|
59258
|
-
if (
|
|
59259
|
-
|
|
55835
|
+
if (record.isSubagent) {
|
|
55836
|
+
record.endedPerLevel ??= "ended";
|
|
59260
55837
|
} else {
|
|
59261
55838
|
session.liveBackgroundTasks.delete(taskId);
|
|
59262
55839
|
}
|
|
@@ -59516,10 +56093,6 @@ ${message.api_refusal_explanation}` : "";
|
|
|
59516
56093
|
}
|
|
59517
56094
|
case "user":
|
|
59518
56095
|
case "assistant": {
|
|
59519
|
-
const mappedMessageId = messageIdForGrouping(message);
|
|
59520
|
-
if (mappedMessageId && typeof message.uuid === "string" && message.uuid.length > 0) {
|
|
59521
|
-
session.messageIdToUuid.set(mappedMessageId, message.uuid);
|
|
59522
|
-
}
|
|
59523
56096
|
if (message.type === "user" && "uuid" in message && message.uuid) {
|
|
59524
56097
|
const queued = findUnsettledTurn(message.uuid);
|
|
59525
56098
|
if (queued) {
|
|
@@ -59645,6 +56218,9 @@ ${message.api_refusal_explanation}` : "";
|
|
|
59645
56218
|
})) {
|
|
59646
56219
|
await sendUpdate(notification);
|
|
59647
56220
|
}
|
|
56221
|
+
if (message.type === "assistant" && message.parent_tool_use_id === null && typeof message.uuid === "string" && message.uuid.length > 0) {
|
|
56222
|
+
await sendUpdate(createClaudeTurnBoundaryUpdate(params.sessionId, message.uuid));
|
|
56223
|
+
}
|
|
59648
56224
|
break;
|
|
59649
56225
|
}
|
|
59650
56226
|
case "tool_progress": {
|
|
@@ -59955,10 +56531,6 @@ ${message.api_refusal_explanation}` : "";
|
|
|
59955
56531
|
const messages = await Rkt(sessionId);
|
|
59956
56532
|
for (const message of messages) {
|
|
59957
56533
|
const replayMessageId = messageIdForGrouping(message);
|
|
59958
|
-
const replaySession = this.sessions[sessionId];
|
|
59959
|
-
if (replaySession && replayMessageId && message.uuid) {
|
|
59960
|
-
replaySession.messageIdToUuid.set(replayMessageId, message.uuid);
|
|
59961
|
-
}
|
|
59962
56534
|
if (message.type === "assistant" && isSyntheticLoginMessage(message.message)) {
|
|
59963
56535
|
continue;
|
|
59964
56536
|
}
|
|
@@ -59976,6 +56548,9 @@ ${message.api_refusal_explanation}` : "";
|
|
|
59976
56548
|
})) {
|
|
59977
56549
|
await this.client.sessionUpdate(notification);
|
|
59978
56550
|
}
|
|
56551
|
+
if (message.type === "assistant" && message.parent_tool_use_id === null && typeof message.uuid === "string" && message.uuid.length > 0) {
|
|
56552
|
+
await this.client.sessionUpdate(createClaudeTurnBoundaryUpdate(sessionId, message.uuid));
|
|
56553
|
+
}
|
|
59979
56554
|
}
|
|
59980
56555
|
}
|
|
59981
56556
|
async readTextFile(params) {
|
|
@@ -60838,8 +57413,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
60838
57413
|
emittedToolCalls: /* @__PURE__ */ new Set(),
|
|
60839
57414
|
liveBackgroundTasks: /* @__PURE__ */ new Map(),
|
|
60840
57415
|
emittedAssistantText: false,
|
|
60841
|
-
owedTrailingIdles: 0
|
|
60842
|
-
messageIdToUuid: /* @__PURE__ */ new Map()
|
|
57416
|
+
owedTrailingIdles: 0
|
|
60843
57417
|
};
|
|
60844
57418
|
return {
|
|
60845
57419
|
sessionId,
|
|
@@ -61476,6 +58050,19 @@ ${chunk.resource.text}
|
|
|
61476
58050
|
update.messageId = messageId;
|
|
61477
58051
|
}
|
|
61478
58052
|
}
|
|
58053
|
+
function createClaudeTurnBoundaryUpdate(sessionId, turnId) {
|
|
58054
|
+
return {
|
|
58055
|
+
sessionId,
|
|
58056
|
+
update: {
|
|
58057
|
+
sessionUpdate: "session_info_update",
|
|
58058
|
+
_meta: {
|
|
58059
|
+
lody: {
|
|
58060
|
+
turnId
|
|
58061
|
+
}
|
|
58062
|
+
}
|
|
58063
|
+
}
|
|
58064
|
+
};
|
|
58065
|
+
}
|
|
61479
58066
|
function isTaskTool(toolName) {
|
|
61480
58067
|
return toolName === "TaskCreate" || toolName === "TaskUpdate" || toolName === "TaskList" || toolName === "TaskGet";
|
|
61481
58068
|
}
|