@opencode/browse 0.0.18-dev.193 → 0.0.18-dev.199

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.
Files changed (45) hide show
  1. package/dist/cli.mjs +62 -117
  2. package/package.json +13 -33
  3. package/dist/Runtime-r9sev1rq.mjs +0 -16
  4. package/dist/THIRD_PARTY_NOTICES.txt +0 -310
  5. package/dist/Undici-xgvbtsb1.mjs +0 -25295
  6. package/dist/cli-ekwkvvmm.mjs +0 -5943
  7. package/dist/coreBundle-mbshhes2.mjs +0 -8
  8. package/dist/helpers-3ycvp75a.mjs +0 -71
  9. package/dist/index-xsb9s479.mjs +0 -13
  10. package/dist/legacy-runtime-v1sdjj5h.mjs +0 -135
  11. package/dist/log-yek648ak.mjs +0 -9
  12. package/dist/main-1qwrze1y.mjs +0 -140
  13. package/dist/main-2p0v71q0.mjs +0 -1752
  14. package/dist/main-3g7fdzbh.mjs +0 -5360
  15. package/dist/main-55a4gpef.mjs +0 -1261
  16. package/dist/main-693wwz19.mjs +0 -4
  17. package/dist/main-91vhk5de.mjs +0 -38
  18. package/dist/main-9t32k44b.mjs +0 -798
  19. package/dist/main-bv9nawja.mjs +0 -5191
  20. package/dist/main-cgnkhs2x.mjs +0 -35
  21. package/dist/main-esdgpebk.mjs +0 -161
  22. package/dist/main-fg5awggs.mjs +0 -5514
  23. package/dist/main-gexpjhk5.mjs +0 -32
  24. package/dist/main-gt2gskrq.mjs +0 -160
  25. package/dist/main-gw77et6v.mjs +0 -342
  26. package/dist/main-j98fzrvv.mjs +0 -68
  27. package/dist/main-kcw411ep.mjs +0 -891
  28. package/dist/main-nnfxg7re.mjs +0 -11403
  29. package/dist/main-pcqtqhgv.mjs +0 -64
  30. package/dist/main-pmfd055v.mjs +0 -63
  31. package/dist/main-pxs5m0kb.mjs +0 -329
  32. package/dist/main-qazf3bhk.mjs +0 -223
  33. package/dist/main-sf7vaxb6.mjs +0 -17
  34. package/dist/main-stf180y1.mjs +0 -229
  35. package/dist/main-tk4axre7.mjs +0 -39
  36. package/dist/main-zedq93ez.mjs +0 -215
  37. package/dist/main-zzggnpf4.mjs +0 -73
  38. package/dist/mcp-xfx04fxe.mjs +0 -9470
  39. package/dist/migrate-4rewxqd7.mjs +0 -354
  40. package/dist/relay-me036e19.mjs +0 -18765
  41. package/dist/remove-stored-secrets-ymhge5va.mjs +0 -6
  42. package/dist/runtime-update-hd2cvy1c.mjs +0 -246
  43. package/dist/setup-0hmbzam5.mjs +0 -1052
  44. package/dist/update-vnkjbc0e.mjs +0 -17
  45. package/dist/version-jn0h3rmc.mjs +0 -8
@@ -1,1752 +0,0 @@
1
- import {
2
- SessionDeleted,
3
- ExecuteLogEntry,
4
- ExecuteLogSummary,
5
- ExecuteAftermath,
6
- ExtensionStatus,
7
- RelayVersion,
8
- RecordingQuality,
9
- SettingsGetResponse,
10
- SettingsSetResponse,
11
- parseTargetSelection2,
12
- getObject2,
13
- getString2
14
- } from "./main-kcw411ep.mjs";
15
- import {
16
- cliCommand
17
- } from "./main-1qwrze1y.mjs";
18
- import {
19
- isStream,
20
- provideContext
21
- } from "./main-3g7fdzbh.mjs";
22
- import {
23
- TaggedError,
24
- passthrough,
25
- transformOptional,
26
- withDefault2,
27
- declare,
28
- encodeUnknownOption,
29
- make8,
30
- isSchema,
31
- optionalKey,
32
- optional,
33
- toType,
34
- Literal,
35
- TemplateLiteral,
36
- Never,
37
- Any,
38
- Unknown,
39
- String3,
40
- Number2,
41
- Boolean3,
42
- Void,
43
- Struct,
44
- fieldsAssign,
45
- Record,
46
- StructWithRest,
47
- ArraySchema,
48
- Union,
49
- Literals,
50
- UndefinedOr,
51
- decodeTo2,
52
- decode2,
53
- withConstructorDefault,
54
- tag2,
55
- Opaque,
56
- Finite,
57
- isBetween,
58
- Int2,
59
- Defect,
60
- Uint8ArrayFromBase64,
61
- Exit,
62
- Class2,
63
- Error3,
64
- toJsonSchemaDocument,
65
- Json,
66
- JsonObject
67
- } from "./main-fg5awggs.mjs";
68
- import {
69
- getStackTraceLimit,
70
- setStackTraceLimit,
71
- none,
72
- some,
73
- isSome,
74
- fromUndefinedOr,
75
- flatMap,
76
- Service2,
77
- makeUnsafe3,
78
- empty4,
79
- make10,
80
- add,
81
- getOrUndefinedUnsafe,
82
- merge2,
83
- StackTrace,
84
- effectContext,
85
- isEffect,
86
- succeed6,
87
- sync2,
88
- gen,
89
- fail6,
90
- context2,
91
- contextWith,
92
- provide3,
93
- fnUntraced
94
- } from "./main-bv9nawja.mjs";
95
- import {
96
- pipeArguments,
97
- identity,
98
- constTrue,
99
- constFalse,
100
- constUndefined,
101
- isString,
102
- isNumber,
103
- isBoolean,
104
- hasProperty
105
- } from "./main-qazf3bhk.mjs";
106
-
107
- // node_modules/effect/dist/PrimaryKey.js
108
- var symbol = "~effect/PrimaryKey";
109
- // node_modules/effect/dist/rpc/RpcSchema.js
110
- var StreamSchemaTypeId = "~effect/rpc/RpcSchema/StreamSchema";
111
- function isStreamSchema(schema) {
112
- return hasProperty(schema, StreamSchemaTypeId);
113
- }
114
- function getStreamSchemas(schema) {
115
- return isStreamSchema(schema) ? some({
116
- success: schema.success,
117
- error: schema.error
118
- }) : none();
119
- }
120
- var schema = /* @__PURE__ */ declare(isStream);
121
- function Stream(success, error) {
122
- return make8(schema.ast, {
123
- [StreamSchemaTypeId]: StreamSchemaTypeId,
124
- success,
125
- error
126
- });
127
- }
128
-
129
- class ClientAbort extends (/* @__PURE__ */ Service2()("effect/rpc/RpcSchema/ClientAbort")) {
130
- static annotation = /* @__PURE__ */ this.context(true).pipe(/* @__PURE__ */ add(StackTrace, {
131
- name: "ClientAbort",
132
- stack: constUndefined,
133
- parent: undefined
134
- }));
135
- }
136
-
137
- // node_modules/effect/dist/rpc/Rpc.js
138
- var TypeId = "~effect/rpc/Rpc";
139
- class ServerClient {
140
- id;
141
- annotations;
142
- constructor(id) {
143
- this.id = id;
144
- this.annotations = empty4();
145
- }
146
- annotate(tag, value) {
147
- this.annotations = add(this.annotations, tag, value);
148
- return this;
149
- }
150
- }
151
- var Proto = {
152
- [TypeId]: TypeId,
153
- pipe() {
154
- return pipeArguments(this, arguments);
155
- },
156
- setSuccess(successSchema) {
157
- return makeProto({
158
- _tag: this._tag,
159
- payloadSchema: this.payloadSchema,
160
- successSchema,
161
- errorSchema: this.errorSchema,
162
- defectSchema: this.defectSchema,
163
- annotations: this.annotations,
164
- middlewares: this.middlewares
165
- });
166
- },
167
- setError(errorSchema) {
168
- return makeProto({
169
- _tag: this._tag,
170
- payloadSchema: this.payloadSchema,
171
- successSchema: this.successSchema,
172
- errorSchema,
173
- defectSchema: this.defectSchema,
174
- annotations: this.annotations,
175
- middlewares: this.middlewares
176
- });
177
- },
178
- setPayload(payloadSchema) {
179
- return makeProto({
180
- _tag: this._tag,
181
- payloadSchema: isSchema(payloadSchema) ? payloadSchema : Struct(payloadSchema),
182
- successSchema: this.successSchema,
183
- errorSchema: this.errorSchema,
184
- defectSchema: this.defectSchema,
185
- annotations: this.annotations,
186
- middlewares: this.middlewares
187
- });
188
- },
189
- middleware(middleware) {
190
- return makeProto({
191
- _tag: this._tag,
192
- payloadSchema: this.payloadSchema,
193
- successSchema: this.successSchema,
194
- errorSchema: this.errorSchema,
195
- defectSchema: this.defectSchema,
196
- annotations: this.annotations,
197
- middlewares: new Set([...this.middlewares, middleware])
198
- });
199
- },
200
- prefix(prefix) {
201
- return makeProto({
202
- _tag: `${prefix}${this._tag}`,
203
- payloadSchema: this.payloadSchema,
204
- successSchema: this.successSchema,
205
- errorSchema: this.errorSchema,
206
- defectSchema: this.defectSchema,
207
- annotations: this.annotations,
208
- middlewares: this.middlewares
209
- });
210
- },
211
- annotate(tag, value) {
212
- return makeProto({
213
- _tag: this._tag,
214
- payloadSchema: this.payloadSchema,
215
- successSchema: this.successSchema,
216
- errorSchema: this.errorSchema,
217
- defectSchema: this.defectSchema,
218
- middlewares: this.middlewares,
219
- annotations: add(this.annotations, tag, value)
220
- });
221
- },
222
- annotateMerge(context) {
223
- return makeProto({
224
- _tag: this._tag,
225
- payloadSchema: this.payloadSchema,
226
- successSchema: this.successSchema,
227
- errorSchema: this.errorSchema,
228
- defectSchema: this.defectSchema,
229
- middlewares: this.middlewares,
230
- annotations: merge2(this.annotations, context)
231
- });
232
- }
233
- };
234
- var makeProto = (options) => {
235
- function Rpc() {}
236
- Object.setPrototypeOf(Rpc, Proto);
237
- Object.assign(Rpc, options);
238
- Rpc.key = `effect/rpc/Rpc/${options._tag}`;
239
- return Rpc;
240
- };
241
- var make = (tag, options) => {
242
- const successSchema = options?.success ?? Void;
243
- const errorSchema = options?.error ?? Never;
244
- const defectSchema = options?.defect ?? Defect();
245
- let payloadSchema;
246
- if (options?.primaryKey) {
247
- payloadSchema = class Payload extends Class2(`effect/rpc/Rpc/${tag}`)(options.payload) {
248
- [symbol]() {
249
- return options.primaryKey(this);
250
- }
251
- };
252
- } else {
253
- payloadSchema = isSchema(options?.payload) ? options?.payload : options?.payload ? Struct(options?.payload) : Void;
254
- }
255
- return makeProto({
256
- _tag: tag,
257
- payloadSchema,
258
- successSchema: options?.stream ? Stream(successSchema, errorSchema) : successSchema,
259
- errorSchema: options?.stream ? Never : errorSchema,
260
- defectSchema,
261
- annotations: empty4(),
262
- middlewares: new Set
263
- });
264
- };
265
- var exitSchemaCache = /* @__PURE__ */ new WeakMap;
266
- var exitSchema = (self) => {
267
- if (exitSchemaCache.has(self)) {
268
- return exitSchemaCache.get(self);
269
- }
270
- const rpc = self;
271
- const failures = new Set([rpc.errorSchema]);
272
- const streamSchemas = getStreamSchemas(rpc.successSchema);
273
- if (isSome(streamSchemas)) {
274
- failures.add(streamSchemas.value.error);
275
- }
276
- for (const middleware of rpc.middlewares) {
277
- failures.add(middleware.error);
278
- }
279
- const schema = Exit(isSome(streamSchemas) ? Void : rpc.successSchema, Union([...failures]), rpc.defectSchema);
280
- exitSchemaCache.set(self, schema);
281
- return schema;
282
- };
283
- var WrapperTypeId = "~effect/rpc/Rpc/Wrapper";
284
- var isWrapper = (u) => (WrapperTypeId in u);
285
-
286
- // node_modules/effect/dist/rpc/RpcGroup.js
287
- var RpcGroupProto = {
288
- add(...rpcs) {
289
- const requests = new Map(this.requests);
290
- for (const rpc of rpcs) {
291
- requests.set(rpc._tag, rpc);
292
- }
293
- return makeProto2({
294
- requests,
295
- annotations: this.annotations
296
- });
297
- },
298
- merge(...groups) {
299
- const requests = new Map(this.requests);
300
- const annotations = new Map(this.annotations.mapUnsafe);
301
- for (const group of groups) {
302
- for (const [tag, rpc] of group.requests) {
303
- requests.set(tag, rpc);
304
- }
305
- for (const [key, value] of group.annotations.mapUnsafe) {
306
- annotations.set(key, value);
307
- }
308
- }
309
- return makeProto2({
310
- requests,
311
- annotations: makeUnsafe3(annotations)
312
- });
313
- },
314
- omit(...tags) {
315
- const requests = new Map(this.requests);
316
- for (const tag of tags) {
317
- requests.delete(tag);
318
- }
319
- return makeProto2({
320
- requests,
321
- annotations: this.annotations
322
- });
323
- },
324
- middleware(middleware) {
325
- const requests = new Map;
326
- for (const [tag, rpc] of this.requests) {
327
- requests.set(tag, rpc.middleware(middleware));
328
- }
329
- return makeProto2({
330
- requests,
331
- annotations: this.annotations
332
- });
333
- },
334
- toHandlers(build) {
335
- const self = this;
336
- return gen(function* () {
337
- const services = yield* context2();
338
- const handlers = isEffect(build) ? yield* build : build;
339
- const contextMap = new Map;
340
- self.requests.forEach((rpc, tag) => {
341
- contextMap.set(rpc.key, {
342
- tag: rpc._tag,
343
- handler: handlers[tag],
344
- context: services
345
- });
346
- });
347
- return makeUnsafe3(contextMap);
348
- });
349
- },
350
- prefix(prefix) {
351
- const requests = new Map;
352
- for (const rpc of this.requests.values()) {
353
- const newRpc = rpc.prefix(prefix);
354
- requests.set(newRpc._tag, newRpc);
355
- }
356
- return makeProto2({
357
- requests,
358
- annotations: this.annotations
359
- });
360
- },
361
- toLayer(build) {
362
- return effectContext(this.toHandlers(build));
363
- },
364
- of: identity,
365
- toLayerHandler(service, build) {
366
- const self = this;
367
- return effectContext(gen(function* () {
368
- const services = yield* context2();
369
- const handler = isEffect(build) ? yield* build : build;
370
- const contextMap = new Map;
371
- const rpc = self.requests.get(service);
372
- contextMap.set(rpc.key, {
373
- handler,
374
- context: services
375
- });
376
- return makeUnsafe3(contextMap);
377
- }));
378
- },
379
- accessHandler(service) {
380
- return contextWith((parentContext) => {
381
- const rpc = this.requests.get(service);
382
- const {
383
- handler,
384
- context
385
- } = getOrUndefinedUnsafe(parentContext, rpc.key);
386
- return succeed6((payload, options) => {
387
- options.rpc = rpc;
388
- const result = handler(payload, options);
389
- const effectOrStream = isWrapper(result) ? result.value : result;
390
- return isEffect(effectOrStream) ? provide3(effectOrStream, context) : provideContext(effectOrStream, context);
391
- });
392
- });
393
- },
394
- annotate(service, value) {
395
- return makeProto2({
396
- requests: this.requests,
397
- annotations: add(this.annotations, service, value)
398
- });
399
- },
400
- annotateRpcs(service, value) {
401
- return this.annotateRpcsMerge(make10(service, value));
402
- },
403
- annotateMerge(context) {
404
- return makeProto2({
405
- requests: this.requests,
406
- annotations: merge2(this.annotations, context)
407
- });
408
- },
409
- annotateRpcsMerge(context) {
410
- const requests = new Map;
411
- for (const [tag, rpc] of this.requests) {
412
- requests.set(tag, rpc.annotateMerge(merge2(context, rpc.annotations)));
413
- }
414
- return makeProto2({
415
- requests,
416
- annotations: this.annotations
417
- });
418
- }
419
- };
420
- var makeProto2 = (options) => Object.assign(function() {}, RpcGroupProto, {
421
- requests: options.requests,
422
- annotations: options.annotations
423
- });
424
- var make2 = (...rpcs) => makeProto2({
425
- requests: new Map(rpcs.map((rpc) => [rpc._tag, rpc])),
426
- annotations: empty4()
427
- });
428
-
429
- // node_modules/effect/dist/rpc/RpcMiddleware.js
430
- var TypeId2 = "~effect/rpc/RpcMiddleware";
431
- var Service = () => (id, options) => {
432
- const limit = getStackTraceLimit();
433
- let creationError;
434
- if (limit !== 0) {
435
- setStackTraceLimit(2);
436
- creationError = new globalThis.Error;
437
- setStackTraceLimit(limit);
438
- }
439
- function ServiceClass() {}
440
- const ServiceClass_ = ServiceClass;
441
- Object.setPrototypeOf(ServiceClass, Object.getPrototypeOf(Service2(id)));
442
- ServiceClass.key = id;
443
- Object.defineProperty(ServiceClass, "stack", {
444
- get() {
445
- return creationError?.stack;
446
- }
447
- });
448
- ServiceClass_[TypeId2] = TypeId2;
449
- ServiceClass_.error = options?.error ?? Never;
450
- ServiceClass_.requiredForClient = options?.requiredForClient ?? false;
451
- return ServiceClass;
452
- };
453
-
454
- // node_modules/effect/dist/ai/McpSchema.js
455
- var optionalWithDefault = (schema, defaultValue) => {
456
- const effect = sync2(defaultValue);
457
- return optionalKey(schema).pipe(decode2({
458
- decode: withDefault2(effect),
459
- encode: passthrough()
460
- }), withConstructorDefault(effect));
461
- };
462
- var optional2 = (schema) => optionalKey(schema).pipe(decodeTo2(toType(optional(schema)), {
463
- decode: passthrough(),
464
- encode: transformOptional(flatMap(fromUndefinedOr))
465
- }));
466
- var RequestId = /* @__PURE__ */ Union([String3, Finite]);
467
- var ProgressToken = /* @__PURE__ */ Union([String3, Finite]);
468
-
469
- class RequestMeta extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
470
- _meta: /* @__PURE__ */ optional2(/* @__PURE__ */ StructWithRest(/* @__PURE__ */ Struct({
471
- progressToken: /* @__PURE__ */ optional2(ProgressToken)
472
- }), [JsonObject]))
473
- }))) {
474
- }
475
-
476
- class ResultMeta extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
477
- _meta: /* @__PURE__ */ optional2(JsonObject)
478
- }))) {
479
- }
480
-
481
- class NotificationMeta extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
482
- _meta: /* @__PURE__ */ optional2(JsonObject)
483
- }))) {
484
- }
485
- var Cursor = String3;
486
-
487
- class PaginatedRequestMeta extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
488
- ...RequestMeta.fields,
489
- cursor: /* @__PURE__ */ optional2(Cursor)
490
- }))) {
491
- }
492
-
493
- class PaginatedResultMeta extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
494
- ...ResultMeta.fields,
495
- nextCursor: /* @__PURE__ */ optional2(Cursor)
496
- }))) {
497
- }
498
- var Role = /* @__PURE__ */ Literals(["user", "assistant"]);
499
-
500
- class Annotations extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
501
- audience: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(Role)),
502
- priority: /* @__PURE__ */ optional2(/* @__PURE__ */ Finite.check(/* @__PURE__ */ isBetween({
503
- minimum: 0,
504
- maximum: 1
505
- }))),
506
- lastModified: /* @__PURE__ */ optional2(String3)
507
- }))) {
508
- }
509
-
510
- class Icon extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/Icon")({
511
- src: String3,
512
- mimeType: /* @__PURE__ */ optional2(String3),
513
- sizes: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3)),
514
- theme: /* @__PURE__ */ optional2(/* @__PURE__ */ Literals(["light", "dark"]))
515
- })) {
516
- }
517
-
518
- class Implementation extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
519
- name: String3,
520
- title: /* @__PURE__ */ optional2(String3),
521
- version: String3,
522
- icons: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(Icon)),
523
- description: /* @__PURE__ */ optional2(String3),
524
- websiteUrl: /* @__PURE__ */ optional2(String3)
525
- }))) {
526
- }
527
-
528
- class ClientCapabilities extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ClientCapabilities")({
529
- experimental: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(String3, /* @__PURE__ */ Struct({}))),
530
- extensions: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(/* @__PURE__ */ TemplateLiteral([String3, "/", String3]), Json)),
531
- roots: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({
532
- listChanged: /* @__PURE__ */ optional2(Boolean3)
533
- })),
534
- sampling: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({
535
- context: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({})),
536
- tools: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({}))
537
- })),
538
- elicitation: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({
539
- form: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({})),
540
- url: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({}))
541
- }))
542
- })) {
543
- }
544
-
545
- class ServerCapabilities extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
546
- experimental: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(String3, /* @__PURE__ */ Struct({}))),
547
- extensions: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(/* @__PURE__ */ TemplateLiteral([String3, "/", String3]), Json)),
548
- logging: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({})),
549
- completions: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({})),
550
- prompts: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({
551
- listChanged: /* @__PURE__ */ optional2(Boolean3)
552
- })),
553
- resources: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({
554
- subscribe: /* @__PURE__ */ optional2(Boolean3),
555
- listChanged: /* @__PURE__ */ optional2(Boolean3)
556
- })),
557
- tools: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({
558
- listChanged: /* @__PURE__ */ optional2(Boolean3)
559
- }))
560
- }))) {
561
- }
562
-
563
- class McpErrorBase extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/McpErrorBase")({
564
- code: Int2,
565
- message: String3,
566
- data: /* @__PURE__ */ optional2(Any)
567
- })) {
568
- }
569
- var INVALID_REQUEST_ERROR_CODE = -32600;
570
- var METHOD_NOT_FOUND_ERROR_CODE = -32601;
571
- var INVALID_PARAMS_ERROR_CODE = -32602;
572
- var INTERNAL_ERROR_CODE = -32603;
573
- var PARSE_ERROR_CODE = -32700;
574
- var HEADER_MISMATCH_ERROR_CODE = -32020;
575
-
576
- class ParseError extends (/* @__PURE__ */ Error3("effect/ai/McpSchema/ParseError")({
577
- ...McpErrorBase.fields,
578
- _tag: /* @__PURE__ */ tag2("ParseError"),
579
- code: /* @__PURE__ */ tag2(PARSE_ERROR_CODE)
580
- })) {
581
- }
582
-
583
- class InvalidRequest extends (/* @__PURE__ */ Error3("effect/ai/McpSchema/InvalidRequest")({
584
- ...McpErrorBase.fields,
585
- _tag: /* @__PURE__ */ tag2("InvalidRequest"),
586
- code: /* @__PURE__ */ tag2(INVALID_REQUEST_ERROR_CODE)
587
- })) {
588
- }
589
-
590
- class MethodNotFound extends (/* @__PURE__ */ Error3("effect/ai/McpSchema/MethodNotFound")({
591
- ...McpErrorBase.fields,
592
- _tag: /* @__PURE__ */ tag2("MethodNotFound"),
593
- code: /* @__PURE__ */ tag2(METHOD_NOT_FOUND_ERROR_CODE)
594
- })) {
595
- }
596
-
597
- class InvalidParams extends (/* @__PURE__ */ Error3("effect/ai/McpSchema/InvalidParams")({
598
- ...McpErrorBase.fields,
599
- _tag: /* @__PURE__ */ tag2("InvalidParams"),
600
- code: /* @__PURE__ */ tag2(INVALID_PARAMS_ERROR_CODE)
601
- })) {
602
- }
603
-
604
- class InternalError extends (/* @__PURE__ */ Error3("effect/ai/McpSchema/InternalError")({
605
- ...McpErrorBase.fields,
606
- _tag: /* @__PURE__ */ tag2("InternalError"),
607
- code: /* @__PURE__ */ tag2(INTERNAL_ERROR_CODE)
608
- })) {
609
- static notImplemented = /* @__PURE__ */ new InternalError({
610
- message: "Not implemented"
611
- });
612
- }
613
- var McpError = /* @__PURE__ */ Union([ParseError, InvalidRequest, MethodNotFound, InvalidParams, InternalError, McpErrorBase]);
614
-
615
- class Ping extends (/* @__PURE__ */ make("ping", {
616
- success: /* @__PURE__ */ Struct({}),
617
- error: McpError,
618
- payload: /* @__PURE__ */ UndefinedOr(RequestMeta)
619
- })) {
620
- }
621
-
622
- class InitializeResult extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
623
- ...ResultMeta.fields,
624
- protocolVersion: String3,
625
- capabilities: ServerCapabilities,
626
- serverInfo: Implementation,
627
- instructions: /* @__PURE__ */ optional2(String3)
628
- }))) {
629
- }
630
-
631
- class Initialize extends (/* @__PURE__ */ make("initialize", {
632
- success: InitializeResult,
633
- error: McpError,
634
- payload: {
635
- ...RequestMeta.fields,
636
- protocolVersion: String3,
637
- capabilities: ClientCapabilities,
638
- clientInfo: Implementation
639
- }
640
- })) {
641
- }
642
- class CancelledNotification extends (/* @__PURE__ */ make("notifications/cancelled", {
643
- payload: {
644
- ...NotificationMeta.fields,
645
- requestId: RequestId,
646
- reason: /* @__PURE__ */ optional2(String3)
647
- }
648
- })) {
649
- }
650
-
651
- class ProgressNotification extends (/* @__PURE__ */ make("notifications/progress", {
652
- payload: {
653
- ...NotificationMeta.fields,
654
- progressToken: ProgressToken,
655
- progress: Finite,
656
- total: /* @__PURE__ */ optional2(Finite),
657
- message: /* @__PURE__ */ optional2(String3)
658
- }
659
- })) {
660
- }
661
-
662
- class Resource extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/Resource")({
663
- uri: String3,
664
- name: String3,
665
- title: /* @__PURE__ */ optional2(String3),
666
- description: /* @__PURE__ */ optional2(String3),
667
- mimeType: /* @__PURE__ */ optional2(String3),
668
- annotations: /* @__PURE__ */ optional2(Annotations),
669
- icons: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(Icon)),
670
- size: /* @__PURE__ */ optional2(Int2),
671
- _meta: /* @__PURE__ */ optional2(JsonObject)
672
- })) {
673
- }
674
-
675
- class ResourceTemplate extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ResourceTemplate")({
676
- uriTemplate: String3,
677
- name: String3,
678
- title: /* @__PURE__ */ optional2(String3),
679
- description: /* @__PURE__ */ optional2(String3),
680
- mimeType: /* @__PURE__ */ optional2(String3),
681
- annotations: /* @__PURE__ */ optional2(Annotations),
682
- icons: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(Icon)),
683
- _meta: /* @__PURE__ */ optional2(JsonObject)
684
- })) {
685
- }
686
-
687
- class ResourceContents extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
688
- uri: String3,
689
- mimeType: /* @__PURE__ */ optional2(String3),
690
- _meta: /* @__PURE__ */ optional2(JsonObject)
691
- }))) {
692
- }
693
-
694
- class TextResourceContents extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
695
- ...ResourceContents.fields,
696
- text: String3
697
- }))) {
698
- }
699
-
700
- class BlobResourceContents extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
701
- ...ResourceContents.fields,
702
- blob: Uint8ArrayFromBase64
703
- }))) {
704
- }
705
-
706
- class ListResourcesResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ListResourcesResult")({
707
- ...PaginatedResultMeta.fields,
708
- resources: /* @__PURE__ */ ArraySchema(Resource)
709
- })) {
710
- }
711
- class ListResourceTemplatesResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ListResourceTemplatesResult")({
712
- ...PaginatedResultMeta.fields,
713
- resourceTemplates: /* @__PURE__ */ ArraySchema(ResourceTemplate)
714
- })) {
715
- }
716
- class ReadResourceResult extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
717
- ...ResultMeta.fields,
718
- contents: /* @__PURE__ */ ArraySchema(/* @__PURE__ */ Union([TextResourceContents, BlobResourceContents]))
719
- }))) {
720
- }
721
-
722
- class ReadResource extends (/* @__PURE__ */ make("resources/read", {
723
- success: ReadResourceResult,
724
- error: McpError,
725
- payload: {
726
- ...RequestMeta.fields,
727
- uri: String3
728
- }
729
- })) {
730
- }
731
-
732
- class ResourceListChangedNotification extends (/* @__PURE__ */ make("notifications/resources/list_changed", {
733
- payload: /* @__PURE__ */ UndefinedOr(NotificationMeta)
734
- })) {
735
- }
736
-
737
- class Subscribe extends (/* @__PURE__ */ make("resources/subscribe", {
738
- success: /* @__PURE__ */ Struct({}),
739
- error: McpError,
740
- payload: {
741
- ...RequestMeta.fields,
742
- uri: String3
743
- }
744
- })) {
745
- }
746
-
747
- class Unsubscribe extends (/* @__PURE__ */ make("resources/unsubscribe", {
748
- success: /* @__PURE__ */ Struct({}),
749
- error: McpError,
750
- payload: {
751
- ...RequestMeta.fields,
752
- uri: String3
753
- }
754
- })) {
755
- }
756
-
757
- class ResourceUpdatedNotification extends (/* @__PURE__ */ make("notifications/resources/updated", {
758
- payload: {
759
- ...NotificationMeta.fields,
760
- uri: String3
761
- }
762
- })) {
763
- }
764
-
765
- class PromptArgument extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
766
- name: String3,
767
- title: /* @__PURE__ */ optional2(String3),
768
- description: /* @__PURE__ */ optional2(String3),
769
- required: /* @__PURE__ */ optional2(Boolean3)
770
- }))) {
771
- }
772
-
773
- class Prompt extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/Prompt")({
774
- name: String3,
775
- title: /* @__PURE__ */ optional2(String3),
776
- description: /* @__PURE__ */ optional2(String3),
777
- arguments: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(PromptArgument)),
778
- icons: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(Icon)),
779
- _meta: /* @__PURE__ */ optional2(JsonObject)
780
- })) {
781
- }
782
-
783
- class TextContent extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
784
- type: /* @__PURE__ */ tag2("text"),
785
- text: String3,
786
- annotations: /* @__PURE__ */ optional2(Annotations),
787
- _meta: /* @__PURE__ */ optional2(JsonObject)
788
- }))) {
789
- }
790
-
791
- class ImageContent extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
792
- type: /* @__PURE__ */ tag2("image"),
793
- data: Uint8ArrayFromBase64,
794
- mimeType: String3,
795
- annotations: /* @__PURE__ */ optional2(Annotations),
796
- _meta: /* @__PURE__ */ optional2(JsonObject)
797
- }))) {
798
- }
799
-
800
- class AudioContent extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
801
- type: /* @__PURE__ */ tag2("audio"),
802
- data: Uint8ArrayFromBase64,
803
- mimeType: String3,
804
- annotations: /* @__PURE__ */ optional2(Annotations),
805
- _meta: /* @__PURE__ */ optional2(JsonObject)
806
- }))) {
807
- }
808
-
809
- class EmbeddedResource extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
810
- type: /* @__PURE__ */ tag2("resource"),
811
- resource: /* @__PURE__ */ Union([TextResourceContents, BlobResourceContents]),
812
- annotations: /* @__PURE__ */ optional2(Annotations),
813
- _meta: /* @__PURE__ */ optional2(JsonObject)
814
- }))) {
815
- }
816
-
817
- class ResourceLink extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
818
- ...Resource.fields,
819
- type: /* @__PURE__ */ tag2("resource_link")
820
- }))) {
821
- }
822
- var ContentBlock = /* @__PURE__ */ Union([TextContent, ImageContent, AudioContent, EmbeddedResource, ResourceLink]);
823
-
824
- class PromptMessage extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
825
- role: Role,
826
- content: ContentBlock
827
- }))) {
828
- }
829
-
830
- class ListPromptsResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ListPromptsResult")({
831
- ...PaginatedResultMeta.fields,
832
- prompts: /* @__PURE__ */ ArraySchema(Prompt)
833
- })) {
834
- }
835
- class GetPromptResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/GetPromptResult")({
836
- ...ResultMeta.fields,
837
- messages: /* @__PURE__ */ ArraySchema(PromptMessage),
838
- description: /* @__PURE__ */ optional2(String3)
839
- })) {
840
- }
841
-
842
- class GetPrompt extends (/* @__PURE__ */ make("prompts/get", {
843
- success: GetPromptResult,
844
- error: McpError,
845
- payload: {
846
- ...RequestMeta.fields,
847
- name: String3,
848
- title: /* @__PURE__ */ optional2(String3),
849
- arguments: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(String3, String3))
850
- }
851
- })) {
852
- }
853
-
854
- class PromptListChangedNotification extends (/* @__PURE__ */ make("notifications/prompts/list_changed", {
855
- payload: /* @__PURE__ */ UndefinedOr(NotificationMeta)
856
- })) {
857
- }
858
-
859
- class ToolAnnotations extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
860
- title: /* @__PURE__ */ optional2(String3),
861
- readOnlyHint: /* @__PURE__ */ optionalWithDefault(Boolean3, constFalse),
862
- destructiveHint: /* @__PURE__ */ optionalWithDefault(Boolean3, constTrue),
863
- idempotentHint: /* @__PURE__ */ optionalWithDefault(Boolean3, constFalse),
864
- openWorldHint: /* @__PURE__ */ optionalWithDefault(Boolean3, constTrue)
865
- }))) {
866
- }
867
- var ToolJson = /* @__PURE__ */ StructWithRest(/* @__PURE__ */ Struct({
868
- type: /* @__PURE__ */ Literal("object"),
869
- properties: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(String3, JsonObject)),
870
- required: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3))
871
- }), [JsonObject]);
872
- var ToolOutputJson = JsonObject;
873
-
874
- class Tool extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/Tool")({
875
- name: String3,
876
- title: /* @__PURE__ */ optional2(String3),
877
- description: /* @__PURE__ */ optional2(String3),
878
- inputSchema: ToolJson,
879
- outputSchema: /* @__PURE__ */ optional2(ToolOutputJson),
880
- annotations: /* @__PURE__ */ optional2(ToolAnnotations),
881
- icons: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(Icon)),
882
- _meta: /* @__PURE__ */ optional2(JsonObject)
883
- })) {
884
- }
885
-
886
- class ListToolsResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ListToolsResult")({
887
- ...PaginatedResultMeta.fields,
888
- tools: /* @__PURE__ */ ArraySchema(Tool)
889
- })) {
890
- }
891
- class CallToolResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/CallToolResult")({
892
- ...ResultMeta.fields,
893
- content: /* @__PURE__ */ ArraySchema(ContentBlock),
894
- structuredContent: /* @__PURE__ */ optional2(Json),
895
- isError: /* @__PURE__ */ optional2(Boolean3)
896
- })) {
897
- }
898
-
899
- class CallTool extends (/* @__PURE__ */ make("tools/call", {
900
- success: CallToolResult,
901
- error: McpError,
902
- payload: {
903
- ...RequestMeta.fields,
904
- name: String3,
905
- arguments: /* @__PURE__ */ optionalWithDefault(/* @__PURE__ */ Record(String3, Any), () => ({}))
906
- }
907
- })) {
908
- }
909
-
910
- class ToolListChangedNotification extends (/* @__PURE__ */ make("notifications/tools/list_changed", {
911
- payload: /* @__PURE__ */ UndefinedOr(NotificationMeta)
912
- })) {
913
- }
914
- var LoggingLevel = /* @__PURE__ */ Literals(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
915
-
916
- class SetLevel extends (/* @__PURE__ */ make("logging/setLevel", {
917
- payload: {
918
- ...RequestMeta.fields,
919
- level: LoggingLevel
920
- },
921
- success: /* @__PURE__ */ Struct({}),
922
- error: McpError
923
- })) {
924
- }
925
-
926
- class LoggingMessageNotification extends (/* @__PURE__ */ make("notifications/message", {
927
- payload: /* @__PURE__ */ Struct({
928
- ...NotificationMeta.fields,
929
- level: LoggingLevel,
930
- logger: /* @__PURE__ */ optional2(String3),
931
- data: Any
932
- })
933
- })) {
934
- }
935
-
936
- class ToolUseContent extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ToolUseContent")({
937
- type: /* @__PURE__ */ tag2("tool_use"),
938
- id: String3,
939
- name: String3,
940
- input: /* @__PURE__ */ Record(String3, Unknown),
941
- _meta: /* @__PURE__ */ optional2(JsonObject)
942
- })) {
943
- }
944
-
945
- class ToolResultContent extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ToolResultContent")({
946
- type: /* @__PURE__ */ tag2("tool_result"),
947
- toolUseId: String3,
948
- content: /* @__PURE__ */ ArraySchema(ContentBlock),
949
- structuredContent: /* @__PURE__ */ optional2(Json),
950
- isError: /* @__PURE__ */ optional2(Boolean3),
951
- _meta: /* @__PURE__ */ optional2(JsonObject)
952
- })) {
953
- }
954
- var SamplingMessageContentBlock = /* @__PURE__ */ Union([TextContent, ImageContent, AudioContent, ToolUseContent, ToolResultContent]);
955
-
956
- class SamplingMessage extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
957
- role: Role,
958
- content: /* @__PURE__ */ Union([SamplingMessageContentBlock, /* @__PURE__ */ ArraySchema(SamplingMessageContentBlock)]),
959
- _meta: /* @__PURE__ */ optional2(JsonObject)
960
- }))) {
961
- }
962
-
963
- class ToolChoice extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ToolChoice")({
964
- mode: /* @__PURE__ */ optional2(/* @__PURE__ */ Literals(["auto", "required", "none"]))
965
- })) {
966
- }
967
-
968
- class ModelHint extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
969
- name: /* @__PURE__ */ optional2(String3)
970
- }))) {
971
- }
972
-
973
- class ModelPreferences extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ModelPreferences")({
974
- hints: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(ModelHint)),
975
- costPriority: /* @__PURE__ */ optional2(/* @__PURE__ */ Finite.check(/* @__PURE__ */ isBetween({
976
- minimum: 0,
977
- maximum: 1
978
- }))),
979
- speedPriority: /* @__PURE__ */ optional2(/* @__PURE__ */ Finite.check(/* @__PURE__ */ isBetween({
980
- minimum: 0,
981
- maximum: 1
982
- }))),
983
- intelligencePriority: /* @__PURE__ */ optional2(/* @__PURE__ */ Finite.check(/* @__PURE__ */ isBetween({
984
- minimum: 0,
985
- maximum: 1
986
- })))
987
- })) {
988
- }
989
-
990
- class CreateMessageResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/CreateMessageResult")({
991
- role: Role,
992
- content: /* @__PURE__ */ Union([SamplingMessageContentBlock, /* @__PURE__ */ ArraySchema(SamplingMessageContentBlock)]),
993
- _meta: /* @__PURE__ */ optional2(JsonObject),
994
- model: String3,
995
- stopReason: /* @__PURE__ */ optional2(String3)
996
- })) {
997
- }
998
-
999
- class CreateMessage extends (/* @__PURE__ */ make("sampling/createMessage", {
1000
- success: CreateMessageResult,
1001
- error: McpError,
1002
- payload: {
1003
- messages: /* @__PURE__ */ ArraySchema(SamplingMessage),
1004
- modelPreferences: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct(ModelPreferences.fields)),
1005
- systemPrompt: /* @__PURE__ */ optional2(String3),
1006
- includeContext: /* @__PURE__ */ optional2(/* @__PURE__ */ Literals(["none", "thisServer", "allServers"])),
1007
- temperature: /* @__PURE__ */ optional2(Finite),
1008
- maxTokens: Int2,
1009
- stopSequences: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3)),
1010
- metadata: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(String3, Unknown)),
1011
- tools: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(/* @__PURE__ */ Struct(Tool.fields))),
1012
- toolChoice: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct(ToolChoice.fields))
1013
- }
1014
- })) {
1015
- }
1016
- class CompleteResult extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
1017
- ...ResultMeta.fields,
1018
- completion: /* @__PURE__ */ Struct({
1019
- values: /* @__PURE__ */ ArraySchema(String3),
1020
- total: /* @__PURE__ */ optional2(Int2),
1021
- hasMore: /* @__PURE__ */ optional2(Boolean3)
1022
- })
1023
- }))) {
1024
- static empty = /* @__PURE__ */ CompleteResult.make({
1025
- completion: {
1026
- values: [],
1027
- total: 0,
1028
- hasMore: false
1029
- }
1030
- });
1031
- }
1032
- class Root extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/Root")({
1033
- uri: String3,
1034
- name: /* @__PURE__ */ optional2(String3),
1035
- _meta: /* @__PURE__ */ optional2(JsonObject)
1036
- })) {
1037
- }
1038
-
1039
- class ListRootsResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ListRootsResult")({
1040
- roots: /* @__PURE__ */ ArraySchema(Root)
1041
- })) {
1042
- }
1043
-
1044
- class ListRoots extends (/* @__PURE__ */ make("roots/list", {
1045
- success: ListRootsResult,
1046
- error: McpError,
1047
- payload: /* @__PURE__ */ UndefinedOr(RequestMeta)
1048
- })) {
1049
- }
1050
- class ElicitationString extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitationString")({
1051
- type: /* @__PURE__ */ tag2("string"),
1052
- title: /* @__PURE__ */ optional2(String3),
1053
- description: /* @__PURE__ */ optional2(String3),
1054
- minLength: /* @__PURE__ */ optional2(Int2),
1055
- maxLength: /* @__PURE__ */ optional2(Int2),
1056
- format: /* @__PURE__ */ optional2(/* @__PURE__ */ Literals(["email", "uri", "date", "date-time"])),
1057
- default: /* @__PURE__ */ optional2(String3)
1058
- })) {
1059
- }
1060
-
1061
- class ElicitationNumber extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitationNumber")({
1062
- type: /* @__PURE__ */ Literals(["number", "integer"]),
1063
- title: /* @__PURE__ */ optional2(String3),
1064
- description: /* @__PURE__ */ optional2(String3),
1065
- minimum: /* @__PURE__ */ optional2(Finite),
1066
- maximum: /* @__PURE__ */ optional2(Finite),
1067
- default: /* @__PURE__ */ optional2(Finite)
1068
- })) {
1069
- }
1070
-
1071
- class ElicitationBoolean extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitationBoolean")({
1072
- type: /* @__PURE__ */ tag2("boolean"),
1073
- title: /* @__PURE__ */ optional2(String3),
1074
- description: /* @__PURE__ */ optional2(String3),
1075
- default: /* @__PURE__ */ optional2(Boolean3)
1076
- })) {
1077
- }
1078
-
1079
- class UntitledSingleSelectEnum extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/UntitledSingleSelectEnum")({
1080
- type: /* @__PURE__ */ tag2("string"),
1081
- title: /* @__PURE__ */ optional2(String3),
1082
- description: /* @__PURE__ */ optional2(String3),
1083
- enum: /* @__PURE__ */ ArraySchema(String3),
1084
- default: /* @__PURE__ */ optional2(String3)
1085
- })) {
1086
- }
1087
-
1088
- class TitledSingleSelectEnum extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/TitledSingleSelectEnum")({
1089
- type: /* @__PURE__ */ tag2("string"),
1090
- title: /* @__PURE__ */ optional2(String3),
1091
- description: /* @__PURE__ */ optional2(String3),
1092
- oneOf: /* @__PURE__ */ ArraySchema(/* @__PURE__ */ Struct({
1093
- const: String3,
1094
- title: String3
1095
- })),
1096
- default: /* @__PURE__ */ optional2(String3)
1097
- })) {
1098
- }
1099
- var SingleSelectEnum = /* @__PURE__ */ Union([UntitledSingleSelectEnum, TitledSingleSelectEnum]);
1100
-
1101
- class UntitledMultiSelectEnum extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/UntitledMultiSelectEnum")({
1102
- type: /* @__PURE__ */ tag2("array"),
1103
- title: /* @__PURE__ */ optional2(String3),
1104
- description: /* @__PURE__ */ optional2(String3),
1105
- minItems: /* @__PURE__ */ optional2(Int2),
1106
- maxItems: /* @__PURE__ */ optional2(Int2),
1107
- items: /* @__PURE__ */ Struct({
1108
- type: /* @__PURE__ */ tag2("string"),
1109
- enum: /* @__PURE__ */ ArraySchema(String3)
1110
- }),
1111
- default: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3))
1112
- })) {
1113
- }
1114
-
1115
- class TitledMultiSelectEnum extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/TitledMultiSelectEnum")({
1116
- type: /* @__PURE__ */ tag2("array"),
1117
- title: /* @__PURE__ */ optional2(String3),
1118
- description: /* @__PURE__ */ optional2(String3),
1119
- minItems: /* @__PURE__ */ optional2(Int2),
1120
- maxItems: /* @__PURE__ */ optional2(Int2),
1121
- items: /* @__PURE__ */ Struct({
1122
- anyOf: /* @__PURE__ */ ArraySchema(/* @__PURE__ */ Struct({
1123
- const: String3,
1124
- title: String3
1125
- }))
1126
- }),
1127
- default: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3))
1128
- })) {
1129
- }
1130
- var MultiSelectEnum = /* @__PURE__ */ Union([UntitledMultiSelectEnum, TitledMultiSelectEnum]);
1131
-
1132
- class LegacyTitledEnum extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/LegacyTitledEnum")({
1133
- type: /* @__PURE__ */ tag2("string"),
1134
- title: /* @__PURE__ */ optional2(String3),
1135
- description: /* @__PURE__ */ optional2(String3),
1136
- enum: /* @__PURE__ */ ArraySchema(String3),
1137
- enumNames: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3)),
1138
- default: /* @__PURE__ */ optional2(String3)
1139
- })) {
1140
- }
1141
- var ElicitationEnum = /* @__PURE__ */ Union([LegacyTitledEnum, SingleSelectEnum, MultiSelectEnum]);
1142
- var PrimitiveSchemaDefinition = /* @__PURE__ */ Union([ElicitationEnum, ElicitationString, ElicitationNumber, ElicitationBoolean]);
1143
- var ElicitationForm = /* @__PURE__ */ Struct({
1144
- $schema: /* @__PURE__ */ optional2(String3),
1145
- type: /* @__PURE__ */ tag2("object"),
1146
- properties: /* @__PURE__ */ Record(String3, PrimitiveSchemaDefinition),
1147
- required: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3))
1148
- });
1149
-
1150
- class ElicitRequestFormParams extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitRequestFormParams")({
1151
- ...RequestMeta.fields,
1152
- mode: /* @__PURE__ */ optional2(/* @__PURE__ */ Literal("form")),
1153
- message: String3,
1154
- requestedSchema: ElicitationForm
1155
- })) {
1156
- }
1157
-
1158
- class ElicitRequestURLParams extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitRequestURLParams")({
1159
- ...RequestMeta.fields,
1160
- mode: /* @__PURE__ */ Literal("url"),
1161
- message: String3,
1162
- elicitationId: String3,
1163
- url: String3
1164
- })) {
1165
- }
1166
- var ElicitRequestParams = /* @__PURE__ */ Union([ElicitRequestFormParams, ElicitRequestURLParams]);
1167
-
1168
- class ElicitAcceptResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitAcceptResult")({
1169
- ...ResultMeta.fields,
1170
- action: /* @__PURE__ */ Literal("accept"),
1171
- content: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(String3, /* @__PURE__ */ Union([String3, Finite, Boolean3, /* @__PURE__ */ ArraySchema(String3)])))
1172
- })) {
1173
- }
1174
-
1175
- class ElicitDeclineResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitDeclineResult")({
1176
- ...ResultMeta.fields,
1177
- action: /* @__PURE__ */ Literals(["cancel", "decline"])
1178
- })) {
1179
- }
1180
- var ElicitResult = /* @__PURE__ */ Union([ElicitAcceptResult, ElicitDeclineResult]);
1181
- class Elicit extends (/* @__PURE__ */ make("elicitation/create", {
1182
- success: ElicitResult,
1183
- error: McpError,
1184
- payload: ElicitRequestParams
1185
- })) {
1186
- }
1187
-
1188
- class ElicitationCompleteNotification extends (/* @__PURE__ */ make("notifications/elicitation/complete", {
1189
- payload: {
1190
- elicitationId: String3
1191
- }
1192
- })) {
1193
- }
1194
-
1195
- class ElicitationDeclined extends (/* @__PURE__ */ Error3("@effect/ai/McpSchema/ElicitationDeclined")({
1196
- _tag: /* @__PURE__ */ tag2("ElicitationDeclined"),
1197
- request: Elicit.payloadSchema,
1198
- cause: /* @__PURE__ */ optional2(/* @__PURE__ */ Defect())
1199
- })) {
1200
- }
1201
-
1202
- class McpReverseOperationUnsupported extends (/* @__PURE__ */ TaggedError("McpReverseOperationUnsupported")) {
1203
- }
1204
-
1205
- class McpReverseOperationError extends (/* @__PURE__ */ TaggedError("McpReverseOperationError")) {
1206
- }
1207
-
1208
- class McpRequestContext extends (/* @__PURE__ */ Service2()("effect/ai/McpSchema/McpRequestContext")) {
1209
- }
1210
-
1211
- class McpServerClient extends (/* @__PURE__ */ Service2()("effect/ai/McpSchema/McpServerClient")) {
1212
- }
1213
-
1214
- class McpServerClientMiddleware extends (/* @__PURE__ */ Service()("effect/ai/McpSchema/McpServerClientMiddleware")) {
1215
- }
1216
- class ServerNotificationRpcs extends (/* @__PURE__ */ make2(CancelledNotification, ProgressNotification, LoggingMessageNotification, ResourceUpdatedNotification, ResourceListChangedNotification, ToolListChangedNotification, PromptListChangedNotification, ElicitationCompleteNotification)) {
1217
- }
1218
- class EnabledWhen extends (/* @__PURE__ */ Service2()("effect/ai/McpSchema/EnabledWhen")) {
1219
- }
1220
- // src/relay/user-settings.ts
1221
- var settingKeys = ["window", "grouping", "idleMinutes", "humanInput", "handoffNotifications", "autoUpdate"];
1222
- var relaySettingKeys = ["autoUpdate"];
1223
- var settingSpecs = {
1224
- window: { label: "Where agents open their tabs (current: the user's window; separate: an unfocused window of their own)", values: ["current", "separate"], variable: "OPENCODE_BROWSER_AGENT_WINDOW" },
1225
- grouping: { label: "How agent tabs are grouped (one shared group, one group per session, or none)", values: ["shared", "session", "none"] },
1226
- idleMinutes: { label: "Close agent tabs untouched for this many minutes", values: [10, 30, 60, "never"] },
1227
- humanInput: { label: "Human-like input (off is faster, but easier for sites to flag)", values: ["on", "off"], variable: "OPENCODE_BROWSER_HUMAN_INPUT" },
1228
- handoffNotifications: { label: "System notification on a handoff (only while recorded, or every handoff)", values: ["recording", "always"] },
1229
- autoUpdate: { label: "installs: install updates automatically when idle, only notify, or never check", values: ["on", "notify", "off"], variable: "OPENCODE_BROWSER_AUTO_UPDATE" }
1230
- };
1231
- var securityVariables = [
1232
- "OPENCODE_BROWSER_ALLOW_NODE",
1233
- "OPENCODE_BROWSER_ALLOW_ALL_COOKIES",
1234
- "OPENCODE_BROWSER_ALLOW_FOREGROUND",
1235
- "OPENCODE_BROWSER_ALLOW_ALL_STORAGE",
1236
- "OPENCODE_BROWSER_ALLOW_FILE_URLS",
1237
- "OPENCODE_BROWSER_UPDATE_CHECK"
1238
- ];
1239
-
1240
- class SettingsInputError extends Error {
1241
- }
1242
- var allowed = (key) => settingSpecs[key].values.map(String).join(", ");
1243
- function parseSettingChanges(input) {
1244
- if (input === null || typeof input !== "object" || Array.isArray(input))
1245
- throw new SettingsInputError('Pass the settings to change as an object, for example { grouping: "shared" }.');
1246
- const problems = [];
1247
- const changes = {};
1248
- for (const [key, raw] of Object.entries(input)) {
1249
- if (!settingKeys.includes(key)) {
1250
- problems.push(/allow|update|security|node|cookie|foreground|storage|file/i.test(key) ? `"${key}" is not a setting: security switches (${securityVariables.join(", ")}) are set only in the relay's environment, never here.` : `Unknown setting "${key}". Settings: ${settingKeys.join(", ")}.`);
1251
- continue;
1252
- }
1253
- const setting = key;
1254
- const value = setting === "idleMinutes" ? idleValue(raw) : raw;
1255
- if (value === undefined || !settingSpecs[setting].values.includes(value)) {
1256
- problems.push(`${setting} must be one of ${allowed(setting)} (got ${JSON.stringify(raw)}).`);
1257
- continue;
1258
- }
1259
- changes[setting] = value;
1260
- }
1261
- if (problems.length)
1262
- throw new SettingsInputError(problems.join(" "));
1263
- if (!Object.keys(changes).length)
1264
- throw new SettingsInputError(`Nothing to change. Settings: ${settingKeys.join(", ")}.`);
1265
- return changes;
1266
- }
1267
- function idleValue(raw) {
1268
- if (raw === "never" || raw === 0 || raw === "0")
1269
- return "never";
1270
- if (typeof raw === "number")
1271
- return raw;
1272
- if (typeof raw === "string" && /^\d+$/.test(raw))
1273
- return Number(raw);
1274
- return;
1275
- }
1276
- function settingsFromExtension(wire) {
1277
- const values = wire && typeof wire.settings === "object" && wire.settings !== null && !Array.isArray(wire.settings) ? wire.settings : undefined;
1278
- if (!values)
1279
- throw new Error("The extension answered settings without them");
1280
- const settings = {};
1281
- for (const key of settingKeys) {
1282
- const value = values[key];
1283
- if (relaySettingKeys.includes(key))
1284
- settings[key] = String(settingSpecs[key].values[0]);
1285
- else if (key === "idleMinutes")
1286
- settings[key] = value === 0 ? "never" : typeof value === "number" ? value : 10;
1287
- else
1288
- settings[key] = typeof value === "string" ? value : String(settingSpecs[key].values[0]);
1289
- }
1290
- return settings;
1291
- }
1292
- function settingsToExtension(changes) {
1293
- return Object.fromEntries(Object.entries(changes).filter(([key]) => !relaySettingKeys.includes(key)).map(([key, value]) => [key, key === "idleMinutes" && value === "never" ? 0 : value]));
1294
- }
1295
- function report(stored, overrides) {
1296
- return Object.fromEntries(settingKeys.map((key) => {
1297
- const override = overrides[key];
1298
- return [key, {
1299
- value: stored[key],
1300
- effective: override?.value ?? stored[key],
1301
- allowed: settingSpecs[key].values,
1302
- description: settingSpecs[key].label,
1303
- ...override ? { overriddenBy: override.variable } : {}
1304
- }];
1305
- }));
1306
- }
1307
- var securityNote = `Security switches (${securityVariables.join(", ")}) are environment-only and can't be read or changed here.`;
1308
- function describeSettings(stored, overrides) {
1309
- return { settings: report(stored, overrides), note: securityNote };
1310
- }
1311
- function describeChanges(options) {
1312
- const changed = [];
1313
- const unchanged = [];
1314
- const overridden = [];
1315
- for (const [key, value] of Object.entries(options.requested)) {
1316
- const override = options.overrides[key];
1317
- if (override)
1318
- overridden.push({ key, requested: value, variable: override.variable, effective: override.value });
1319
- else if (options.before[key] === options.after[key])
1320
- unchanged.push(key);
1321
- else
1322
- changed.push({ key, from: options.before[key], to: options.after[key] });
1323
- }
1324
- const lines = [];
1325
- if (changed.length)
1326
- lines.push(`Changed ${changed.map((item) => `${item.key} from ${item.from} to ${item.to}`).join(", ")}. Tell the user what you changed; they can change it back on the extension's options page.`);
1327
- if (unchanged.length)
1328
- lines.push(`Already set: ${unchanged.map((key) => `${key} is ${options.after[key]}`).join(", ")}.`);
1329
- for (const item of overridden)
1330
- lines.push(`Not changed: ${item.key} is fixed to ${item.effective} by ${item.variable} in the relay's environment, so this setting has no effect. Tell the user; to change it they remove or edit ${item.variable} where opencode starts, then run \`${cliCommand("relay restart")}\`.`);
1331
- return { changed, unchanged, overridden, settings: report(options.after, options.overrides), message: lines.join(" ") };
1332
- }
1333
- function formatSettings(settings) {
1334
- const width = Math.max(...settingKeys.map((key) => key.length));
1335
- return settingKeys.map((key) => {
1336
- const item = settings[key];
1337
- const override = item.overriddenBy ? ` (in effect: ${item.effective}, set by ${item.overriddenBy} on the relay)` : "";
1338
- return `${key.padEnd(width)} ${String(item.value).padEnd(9)} one of ${item.allowed.join(", ")}${override}`;
1339
- });
1340
- }
1341
-
1342
- // src/mcp/schema.ts
1343
- function mcpUpdateNote2(notice) {
1344
- return `Note: browse has an update: ${notice.summary}. Tell the user they can run \`${notice.command}\` and then restart opencode, or ask you to run it for them.`;
1345
- }
1346
- function objectSchema(properties, required = []) {
1347
- return {
1348
- type: "object",
1349
- properties,
1350
- required: [...required],
1351
- additionalProperties: false
1352
- };
1353
- }
1354
- function valuesSchema(values, description) {
1355
- const groups = new Map;
1356
- for (const value of values) {
1357
- const type = typeof value === "number" ? Number.isInteger(value) ? "integer" : "number" : "string";
1358
- groups.set(type, [...groups.get(type) ?? [], value]);
1359
- }
1360
- const variants = [...groups].map(([type, items]) => ({ type, enum: items }));
1361
- return variants.length === 1 ? { ...variants[0], description } : { anyOf: variants, description };
1362
- }
1363
- var emptyInputSchema = objectSchema({});
1364
- var sessionSchemaProperty = {
1365
- type: "string",
1366
- description: "Optional session id. Defaults to your current session."
1367
- };
1368
- var sessionAliasSchemaProperty = { type: "string", description: "Same as id." };
1369
- var ExecuteToolOutput = Struct({
1370
- session: String3,
1371
- value: optionalKey(Unknown),
1372
- logs: optionalKey(ArraySchema(ExecuteLogEntry)),
1373
- logSummary: optionalKey(ExecuteLogSummary),
1374
- warnings: optionalKey(ArraySchema(String3)),
1375
- diagnostic: optionalKey(String3),
1376
- aftermath: optionalKey(ExecuteAftermath),
1377
- notice: optionalKey(String3)
1378
- });
1379
- var StatusToolOutput = Struct({
1380
- endpoint: String3,
1381
- currentSession: String3,
1382
- sharedSession: Boolean3,
1383
- version: RelayVersion,
1384
- status: ExtensionStatus,
1385
- buildProblem: optionalKey(String3),
1386
- update: optionalKey(Json),
1387
- autoUpdate: Json
1388
- });
1389
- var CurrentSessionToolOutput = Struct({
1390
- currentSession: String3
1391
- });
1392
- var SessionDeleteToolOutput = SessionDeleted.pipe(fieldsAssign({
1393
- currentSession: String3
1394
- }));
1395
- var NetworkToolOutput = Struct({
1396
- action: Literals(["start", "status", "stop", "cancel"]),
1397
- session: String3,
1398
- active: optionalKey(Boolean3),
1399
- startedAt: optionalKey(String3),
1400
- entryCount: optionalKey(Number2),
1401
- responseCount: optionalKey(Number2),
1402
- failureCount: optionalKey(Number2),
1403
- capturedBodyBytes: optionalKey(Number2),
1404
- truncatedBodyCount: optionalKey(Number2),
1405
- droppedEntryCount: optionalKey(Number2),
1406
- urlFilter: optionalKey(String3),
1407
- endsAt: optionalKey(String3),
1408
- ended: optionalKey(String3),
1409
- stoppedAt: optionalKey(String3),
1410
- exchanges: optionalKey(ArraySchema(Struct({
1411
- id: String3,
1412
- startedDateTime: String3,
1413
- durationMs: Number2,
1414
- request: Struct({
1415
- method: String3,
1416
- url: String3,
1417
- headers: ArraySchema(Struct({ name: String3, value: String3 })),
1418
- resourceType: String3,
1419
- body: optionalKey(Struct({
1420
- size: Number2,
1421
- mimeType: String3,
1422
- text: optionalKey(String3),
1423
- truncated: Boolean3
1424
- })),
1425
- redirectedFrom: optionalKey(String3)
1426
- }),
1427
- response: optionalKey(Struct({
1428
- status: Number2,
1429
- statusText: String3,
1430
- headers: ArraySchema(Struct({ name: String3, value: String3 })),
1431
- body: optionalKey(Struct({
1432
- size: Number2,
1433
- mimeType: String3,
1434
- text: optionalKey(String3),
1435
- truncated: Boolean3
1436
- }))
1437
- })),
1438
- failure: optionalKey(String3)
1439
- }))),
1440
- cancelled: optionalKey(Boolean3)
1441
- });
1442
- var RecordingToolOutput = Struct({
1443
- action: Literals(["start", "stop", "status", "cancel"]),
1444
- session: String3,
1445
- success: optionalKey(Boolean3),
1446
- tabId: optionalKey(Number2),
1447
- startedAt: optionalKey(Number2),
1448
- path: optionalKey(String3),
1449
- mimeType: optionalKey(String3),
1450
- artifactType: optionalKey(Literals(["webm", "mp4"])),
1451
- frameRate: optionalKey(Number2),
1452
- duration: optionalKey(Number2),
1453
- size: optionalKey(Number2),
1454
- frameCount: optionalKey(Number2),
1455
- quality: optionalKey(RecordingQuality),
1456
- isRecording: optionalKey(Boolean3),
1457
- error: optionalKey(String3)
1458
- });
1459
- var agentSettingKeys = settingKeys.filter((key) => key !== "autoUpdate");
1460
- var AgentSettingValue = Union([String3, Number2]);
1461
- var AgentSettingReport = Struct({
1462
- value: AgentSettingValue,
1463
- effective: AgentSettingValue,
1464
- allowed: ArraySchema(AgentSettingValue),
1465
- description: String3,
1466
- overriddenBy: optionalKey(String3)
1467
- });
1468
- var AgentSettings = Record(Literals(agentSettingKeys), AgentSettingReport);
1469
- var SettingsToolOutput = Struct({
1470
- settings: AgentSettings,
1471
- note: optionalKey(SettingsGetResponse.fields.note),
1472
- changed: optionalKey(SettingsSetResponse.fields.changed),
1473
- unchanged: optionalKey(SettingsSetResponse.fields.unchanged),
1474
- overridden: optionalKey(SettingsSetResponse.fields.overridden),
1475
- message: optionalKey(SettingsSetResponse.fields.message)
1476
- });
1477
- function toolOutputJson(schema) {
1478
- const document = toJsonSchemaDocument(schema);
1479
- const json = Object.keys(document.definitions).length === 0 ? document.schema : { ...document.schema, $defs: document.definitions };
1480
- return json;
1481
- }
1482
- function logSummaryHasContent(summary) {
1483
- return summary !== undefined && (summary.totalCount > 0 || summary.returnedCount > 0 || summary.repeatedCount > 0 || summary.omittedCount > 0);
1484
- }
1485
- function aftermathHasContent(aftermath) {
1486
- return aftermath !== undefined && (aftermath.startUrl !== aftermath.endUrl || aftermath.navigations.length > 0 || aftermath.consoleErrorCount > 0 || aftermath.pageErrorCount > 0 || aftermath.handoffs > 0 || aftermath.challenge !== undefined);
1487
- }
1488
- function executeToolOutput(result) {
1489
- return {
1490
- session: result.session.id,
1491
- ...result.value === undefined ? {} : { value: result.value },
1492
- ...result.logs.length > 0 ? { logs: result.logs } : {},
1493
- ...logSummaryHasContent(result.logSummary) ? { logSummary: result.logSummary } : {},
1494
- ...result.warnings && result.warnings.length > 0 ? { warnings: result.warnings } : {},
1495
- ...result.diagnostic ? { diagnostic: result.diagnostic } : {},
1496
- ...aftermathHasContent(result.aftermath) ? { aftermath: result.aftermath } : {},
1497
- ...result.notice ? { notice: result.notice } : {}
1498
- };
1499
- }
1500
- var errorMessageLimit = 3000;
1501
- var errorLogLimit = 20;
1502
- var errorLogLineLimit = 300;
1503
- var errorLogsLimit = 2500;
1504
- function clip(text, limit) {
1505
- if (text.length <= limit)
1506
- return text;
1507
- const head = Math.ceil(limit * 2 / 3);
1508
- const tail = limit - head;
1509
- return `${text.slice(0, head)}
1510
- … ${text.length - limit} characters cut …
1511
- ${text.slice(-tail)}`;
1512
- }
1513
- function aftermathLine(aftermath) {
1514
- if (!aftermath)
1515
- return;
1516
- const parts = [];
1517
- if (aftermath.endUrl === null)
1518
- parts.push("the page closed");
1519
- else if (aftermath.startUrl !== aftermath.endUrl)
1520
- parts.push(`moved from ${clip(aftermath.startUrl ?? "nowhere", 200)} to ${clip(aftermath.endUrl, 200)}`);
1521
- if (aftermath.navigations.length > 0)
1522
- parts.push(`${aftermath.navigations.length} navigation${aftermath.navigations.length === 1 ? "" : "s"}`);
1523
- if (aftermath.consoleErrorCount > 0)
1524
- parts.push(`${aftermath.consoleErrorCount} console error${aftermath.consoleErrorCount === 1 ? "" : "s"}`);
1525
- if (aftermath.pageErrorCount > 0)
1526
- parts.push(`${aftermath.pageErrorCount} page error${aftermath.pageErrorCount === 1 ? "" : "s"}`);
1527
- if (aftermath.handoffs > 0)
1528
- parts.push(`${aftermath.handoffs} handoff${aftermath.handoffs === 1 ? "" : "s"}`);
1529
- return parts.length > 0 ? `Page: ${parts.join("; ")}` : undefined;
1530
- }
1531
- function errorLogsBlock(logs) {
1532
- if (logs.length === 0)
1533
- return;
1534
- const lines = [];
1535
- let size = 0;
1536
- for (const entry of logs.slice(-errorLogLimit).reverse()) {
1537
- const prefix = entry.source === "page" ? `[page ${entry.type}]` : `[${entry.type}]`;
1538
- const repeat = entry.repeatCount && entry.repeatCount > 1 ? ` (×${entry.repeatCount})` : "";
1539
- const line = clip(`${prefix} ${entry.text}${repeat}`, errorLogLineLimit).replaceAll(`
1540
- `, " ");
1541
- if (size + line.length > errorLogsLimit)
1542
- break;
1543
- lines.unshift(line);
1544
- size += line.length + 1;
1545
- }
1546
- const shown = lines.length < logs.length ? `last ${lines.length} of ${logs.length}` : `${logs.length}`;
1547
- return `Logs (${shown}):
1548
- ${lines.join(`
1549
- `)}`;
1550
- }
1551
- function executeErrorText(result) {
1552
- const warnings = result.warnings ?? [];
1553
- return [
1554
- clip(result.text, errorMessageLimit),
1555
- warnings.length > 0 ? `Warnings:
1556
- ${warnings.map((warning) => `- ${warning}`).join(`
1557
- `)}` : undefined,
1558
- result.diagnostic ? `Diagnostic: ${result.diagnostic}` : undefined,
1559
- aftermathLine(result.aftermath),
1560
- errorLogsBlock(result.logs)
1561
- ].filter((part) => part !== undefined).join(`
1562
-
1563
- `);
1564
- }
1565
- function executeToolText(result) {
1566
- const text = result.isError ? executeErrorText(result) : isString(result.value) ? result.value : result.value === undefined ? result.text : JSON.stringify(result.value);
1567
- return result.notice ? `${text}
1568
-
1569
- ${result.notice}` : text;
1570
- }
1571
- function executeToolResult(value) {
1572
- const result = value;
1573
- if (result.media && result.media.length > 0) {
1574
- return new CallToolResult({
1575
- content: [
1576
- TextContent.make({ text: result.isError ? executeErrorText(result) : result.text }),
1577
- ...result.media.map((image) => ImageContent.make({
1578
- data: new Uint8Array(Buffer.from(image.data, "base64")),
1579
- mimeType: image.mimeType
1580
- }))
1581
- ],
1582
- isError: result.isError
1583
- });
1584
- }
1585
- if (result.isError)
1586
- return toolResult({ text: executeToolText(result), isError: true });
1587
- return toolResultForValue2(executeToolOutput(result), {
1588
- outputSchema: ExecuteToolOutput,
1589
- text: executeToolText(result),
1590
- isError: result.isError
1591
- });
1592
- }
1593
- var ensureSessionExists = fnUntraced(function* (relay, id) {
1594
- const sessions = yield* relay.sessions;
1595
- const exists = sessions.some((session) => {
1596
- return session.id === id;
1597
- });
1598
- if (!exists) {
1599
- return yield* fail6(new Error(`Session not found: ${id}`));
1600
- }
1601
- });
1602
- function parseExecuteArguments(input) {
1603
- const object = requireObject(input);
1604
- const code = requiredStringField(object, "code");
1605
- const session = optionalStringField(object, "session");
1606
- const timeoutMs = optionalNonNegativeIntegerField(object, "timeoutMs");
1607
- const targetSelection = parseMcpTargetSelection(object);
1608
- const browser = optionalStringField(object, "browser");
1609
- return {
1610
- code,
1611
- ...session ? { session } : {},
1612
- ...timeoutMs === undefined ? {} : { timeoutMs },
1613
- ...targetSelection ? { targetSelection } : {},
1614
- ...browser ? { browser } : {}
1615
- };
1616
- }
1617
- function parseAdoptArguments(input) {
1618
- const object = requireObject(input);
1619
- const session = optionalStringField(object, "session");
1620
- const targetSelection = parseMcpTargetSelection(object);
1621
- const tabId = typeof object.tabId === "number" && Number.isInteger(object.tabId) ? object.tabId : undefined;
1622
- if (tabId !== undefined && targetSelection)
1623
- throw new Error("Use only one of tabId, targetUrl, or targetIndex");
1624
- return {
1625
- ...session ? { session } : {},
1626
- ...targetSelection ? { targetSelection } : {},
1627
- ...tabId === undefined ? {} : { tabId }
1628
- };
1629
- }
1630
- function parseMcpTargetSelection(input) {
1631
- const urlIncludes = optionalStringField(input, "targetUrl");
1632
- const selection = parseTargetSelection2({
1633
- ...urlIncludes ? { urlIncludes } : {},
1634
- ...input.targetIndex === undefined ? {} : { index: input.targetIndex }
1635
- });
1636
- return selection?.urlIncludes || selection?.index !== undefined ? selection : undefined;
1637
- }
1638
- function requiredStringField(input, field) {
1639
- const value = optionalStringField(input, field);
1640
- if (!value) {
1641
- throw new Error(`${field} is required`);
1642
- }
1643
- return value;
1644
- }
1645
- function requiredAction(input, actions) {
1646
- const action = optionalStringField(input, "action");
1647
- if (!action || !actions.includes(action)) {
1648
- throw new Error(`action must be one of ${actions.join(", ")}`);
1649
- }
1650
- return action;
1651
- }
1652
- function optionalStringField(input, field) {
1653
- const value = getString2(requireObject(input), field);
1654
- return value ? value : undefined;
1655
- }
1656
- function optionalBooleanField(input, field) {
1657
- const value = requireObject(input)[field];
1658
- return isBoolean(value) ? value : undefined;
1659
- }
1660
- function optionalPositiveIntegerField(input, field) {
1661
- const value = requireObject(input)[field];
1662
- if (value === undefined)
1663
- return;
1664
- if (!isNumber(value) || !Number.isInteger(value) || value <= 0) {
1665
- throw new Error(`${field} must be a positive integer`);
1666
- }
1667
- return value;
1668
- }
1669
- function optionalNonNegativeIntegerField(input, field) {
1670
- const value = requireObject(input)[field];
1671
- if (value === undefined)
1672
- return;
1673
- if (!isNumber(value) || !Number.isInteger(value) || value < 0) {
1674
- throw new Error(`${field} must be a non-negative integer`);
1675
- }
1676
- return value;
1677
- }
1678
- function optionalStringArrayField(input, field) {
1679
- const value = requireObject(input)[field];
1680
- if (value === undefined)
1681
- return;
1682
- if (!Array.isArray(value) || !value.every((item) => isString(item) && item.length > 0)) {
1683
- throw new Error(`${field} must be an array of non-empty strings`);
1684
- }
1685
- return value;
1686
- }
1687
- function requireObject(input) {
1688
- const object = getObject2(input);
1689
- if (!object) {
1690
- throw new Error("Expected arguments object");
1691
- }
1692
- return object;
1693
- }
1694
- function stringifyResult(value) {
1695
- if (isString(value)) {
1696
- return value;
1697
- }
1698
- return JSON.stringify(value);
1699
- }
1700
- function encodedStructuredContent(value, schema) {
1701
- if (!schema)
1702
- return value;
1703
- const encoded = encodeUnknownOption(schema)(value);
1704
- return isSome(encoded) ? encoded.value : undefined;
1705
- }
1706
- function toolResultForValue2(value, options = {}) {
1707
- const object = getObject2(value);
1708
- const isError = options.isError ?? object?.isError === true;
1709
- const media = Array.isArray(object?.media) ? object.media.flatMap((item) => {
1710
- const image = getObject2(item);
1711
- const mimeType = getString2(image, "mimeType");
1712
- const data = getString2(image, "data");
1713
- return image?.type === "image" && mimeType !== undefined && data !== undefined ? [{ data, mimeType }] : [];
1714
- }) : [];
1715
- const errorText = isError ? getString2(object, "text") : undefined;
1716
- if (media.length > 0) {
1717
- const { media: _media, ...rest } = object ?? {};
1718
- const text = options.text ?? errorText ?? stringifyResult(rest);
1719
- return new CallToolResult({
1720
- content: [
1721
- TextContent.make({ text }),
1722
- ...media.map((image) => ImageContent.make({
1723
- data: new Uint8Array(Buffer.from(image.data, "base64")),
1724
- mimeType: image.mimeType
1725
- }))
1726
- ],
1727
- isError
1728
- });
1729
- }
1730
- const text = options.text ?? errorText ?? stringifyResult(value);
1731
- const structuredContent = object ? encodedStructuredContent(object, options.outputSchema) : undefined;
1732
- return toolResult({
1733
- text,
1734
- ...structuredContent === undefined ? {} : { structuredContent },
1735
- isError
1736
- });
1737
- }
1738
- function mcpErrorMessage2(tool, message) {
1739
- if (!message.startsWith("Session not found:")) {
1740
- return message;
1741
- }
1742
- return tool === "execute" || tool === "session_adopt" ? `${message} Create it with session_new first, or omit the explicit session id to use the MCP current session.` : `${message} Create it with session_new first.`;
1743
- }
1744
- function toolResult(options) {
1745
- return new CallToolResult({
1746
- content: [TextContent.make({ text: options.text })],
1747
- structuredContent: options.structuredContent,
1748
- isError: options.isError
1749
- });
1750
- }
1751
-
1752
- export { isStreamSchema, getStreamSchemas, ClientAbort, ServerClient, make, exitSchema, isWrapper, make2, Implementation, ClientCapabilities, INVALID_REQUEST_ERROR_CODE, METHOD_NOT_FOUND_ERROR_CODE, INVALID_PARAMS_ERROR_CODE, INTERNAL_ERROR_CODE, HEADER_MISMATCH_ERROR_CODE, ParseError, InvalidRequest, MethodNotFound, InvalidParams, InternalError, McpError, Ping, Initialize, CancelledNotification, ProgressNotification, ResourceListChangedNotification, ResourceUpdatedNotification, Prompt, TextContent, PromptListChangedNotification, Tool, CallToolResult, ToolListChangedNotification, LoggingLevel, LoggingMessageNotification, CreateMessage, ListRootsResult, ListRoots, Elicit, McpReverseOperationUnsupported, McpReverseOperationError, McpRequestContext, McpServerClient, McpServerClientMiddleware, ServerNotificationRpcs, EnabledWhen, settingKeys, settingSpecs, securityVariables, SettingsInputError, parseSettingChanges, settingsFromExtension, settingsToExtension, describeSettings, describeChanges, formatSettings, mcpUpdateNote2, objectSchema, valuesSchema, emptyInputSchema, sessionSchemaProperty, sessionAliasSchemaProperty, StatusToolOutput, CurrentSessionToolOutput, SessionDeleteToolOutput, NetworkToolOutput, RecordingToolOutput, agentSettingKeys, SettingsToolOutput, toolOutputJson, executeToolResult, ensureSessionExists, parseExecuteArguments, parseAdoptArguments, requiredStringField, requiredAction, optionalStringField, optionalBooleanField, optionalPositiveIntegerField, optionalStringArrayField, requireObject, toolResultForValue2, mcpErrorMessage2, toolResult };