@opencode/browse 0.0.6-dev.27 → 0.0.6-dev.32
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/THIRD_PARTY_NOTICES.txt +310 -0
- package/dist/Undici-88kyhfpm.mjs +25295 -0
- package/dist/cli-pazs0vgt.mjs +6694 -0
- package/dist/cli.mjs +10 -10
- package/dist/{helpers-zeewknn2.mjs → helpers-1afz3xb6.mjs} +2 -1
- package/dist/index-yghakpfn.mjs +12 -0
- package/dist/{main-bq8az9yr.mjs → main-30dkfffj.mjs} +5 -4
- package/dist/{main-3g2t8jtq.mjs → main-3w449766.mjs} +9 -9
- package/dist/main-9z6jbwdp.mjs +14661 -0
- package/dist/main-aqzas8ts.mjs +1775 -0
- package/dist/main-brs53cap.mjs +205 -0
- package/dist/{main-a6mpfd6z.mjs → main-ea9djgtm.mjs} +2 -2
- package/dist/main-k9drabmz.mjs +4 -0
- package/dist/{main-cxrsjs2z.mjs → main-q641ckf5.mjs} +1443 -559
- package/dist/{main-a4yj9bpn.mjs → main-va90zea2.mjs} +30 -20
- package/dist/main-yf9xhpn4.mjs +290 -0
- package/dist/{main-x96gxahz.mjs → main-yxvg4ms6.mjs} +2 -2
- package/dist/mcp-4v2gsdr7.mjs +8515 -0
- package/dist/{relay-xqg264d4.mjs → relay-sxbxskww.mjs} +766 -1789
- package/dist/{runtime-update-gteb0gp8.mjs → runtime-update-tksdpg29.mjs} +22 -11
- package/dist/{setup-zka6z53q.mjs → setup-92ht2epc.mjs} +10 -40
- package/dist/{skill-text-kyjcembk.mjs → skill-text-rc6te209.mjs} +0 -75
- package/dist/{supervisor-w6hs0gbw.mjs → supervisor-0afrkpjb.mjs} +3 -3
- package/dist/{update-pj25xbh4.mjs → update-vv7x6c6j.mjs} +3 -3
- package/dist/{version-1hb8s8jj.mjs → version-pvx4s3qg.mjs} +1 -1
- package/package.json +4 -3
- package/skills/browse/SKILL.md +0 -75
- package/dist/cli-n0qhph13.mjs +0 -1853
- package/dist/main-vp3devjb.mjs +0 -4
- package/dist/main-xzc7qp1c.mjs +0 -1440
- package/dist/mcp-za7ymfdd.mjs +0 -972
|
@@ -2,16 +2,1340 @@ import {
|
|
|
2
2
|
parseTargetSelection2,
|
|
3
3
|
getObject2,
|
|
4
4
|
getString2
|
|
5
|
-
} from "./main-
|
|
5
|
+
} from "./main-aqzas8ts.mjs";
|
|
6
6
|
import {
|
|
7
7
|
isNodeError,
|
|
8
8
|
writeJsonFileAtomically
|
|
9
|
-
} from "./main-
|
|
9
|
+
} from "./main-30dkfffj.mjs";
|
|
10
|
+
import {
|
|
11
|
+
getStackTraceLimit,
|
|
12
|
+
setStackTraceLimit,
|
|
13
|
+
withFiber,
|
|
14
|
+
none,
|
|
15
|
+
some,
|
|
16
|
+
isSome,
|
|
17
|
+
fromUndefinedOr,
|
|
18
|
+
flatMap,
|
|
19
|
+
Service2,
|
|
20
|
+
makeUnsafe2,
|
|
21
|
+
empty,
|
|
22
|
+
make4,
|
|
23
|
+
add,
|
|
24
|
+
getOrUndefinedUnsafe,
|
|
25
|
+
merge,
|
|
26
|
+
TaggedError,
|
|
27
|
+
getCurrentFiber,
|
|
28
|
+
succeed2,
|
|
29
|
+
sync,
|
|
30
|
+
suspend,
|
|
31
|
+
succeedNone,
|
|
32
|
+
void_,
|
|
33
|
+
callback,
|
|
34
|
+
asSome,
|
|
35
|
+
flatMap2,
|
|
36
|
+
onExitPrimitive,
|
|
37
|
+
uninterruptibleMask,
|
|
38
|
+
effectContext,
|
|
39
|
+
StackTrace,
|
|
40
|
+
isEffect,
|
|
41
|
+
promise,
|
|
42
|
+
tryPromise,
|
|
43
|
+
succeed6,
|
|
44
|
+
sync2,
|
|
45
|
+
callback2,
|
|
46
|
+
gen,
|
|
47
|
+
fail4,
|
|
48
|
+
try_,
|
|
49
|
+
option2,
|
|
50
|
+
catchIf,
|
|
51
|
+
mapError,
|
|
52
|
+
context,
|
|
53
|
+
contextWith,
|
|
54
|
+
provide3,
|
|
55
|
+
acquireUseRelease,
|
|
56
|
+
fnUntraced,
|
|
57
|
+
fn,
|
|
58
|
+
isStream,
|
|
59
|
+
provideContext2,
|
|
60
|
+
passthrough,
|
|
61
|
+
transformOptional,
|
|
62
|
+
withDefault2,
|
|
63
|
+
declare,
|
|
64
|
+
decodeUnknownEffect2,
|
|
65
|
+
decodeUnknownSync,
|
|
66
|
+
make11,
|
|
67
|
+
isSchema,
|
|
68
|
+
optionalKey,
|
|
69
|
+
optional,
|
|
70
|
+
toType,
|
|
71
|
+
Literal,
|
|
72
|
+
TemplateLiteral,
|
|
73
|
+
Never,
|
|
74
|
+
Any,
|
|
75
|
+
Unknown,
|
|
76
|
+
String3,
|
|
77
|
+
Boolean3,
|
|
78
|
+
Void,
|
|
79
|
+
Struct,
|
|
80
|
+
Record,
|
|
81
|
+
StructWithRest,
|
|
82
|
+
ArraySchema,
|
|
83
|
+
Union,
|
|
84
|
+
Literals,
|
|
85
|
+
UndefinedOr,
|
|
86
|
+
decodeTo2,
|
|
87
|
+
decode2,
|
|
88
|
+
withConstructorDefault,
|
|
89
|
+
tag,
|
|
90
|
+
Opaque,
|
|
91
|
+
makeFilter,
|
|
92
|
+
isPattern,
|
|
93
|
+
Finite,
|
|
94
|
+
isBetween,
|
|
95
|
+
Int2,
|
|
96
|
+
Defect,
|
|
97
|
+
Uint8ArrayFromBase64,
|
|
98
|
+
Exit,
|
|
99
|
+
Class2,
|
|
100
|
+
Error2,
|
|
101
|
+
TaggedError2,
|
|
102
|
+
Json,
|
|
103
|
+
JsonObject
|
|
104
|
+
} from "./main-9z6jbwdp.mjs";
|
|
10
105
|
import {
|
|
11
106
|
dataRoot,
|
|
12
107
|
cliCommand
|
|
13
|
-
} from "./main-
|
|
108
|
+
} from "./main-ea9djgtm.mjs";
|
|
109
|
+
import {
|
|
110
|
+
pipeArguments,
|
|
111
|
+
identity,
|
|
112
|
+
constTrue,
|
|
113
|
+
constFalse,
|
|
114
|
+
constUndefined,
|
|
115
|
+
isString,
|
|
116
|
+
isNumber,
|
|
117
|
+
isBoolean,
|
|
118
|
+
isObject,
|
|
119
|
+
hasProperty
|
|
120
|
+
} from "./main-yf9xhpn4.mjs";
|
|
121
|
+
|
|
122
|
+
// node_modules/effect/dist/Semaphore.js
|
|
123
|
+
var makeUnsafe = (permits) => new SemaphoreImpl(permits);
|
|
124
|
+
var waitForPermits = (self, n, effect) => callback((resume) => {
|
|
125
|
+
if (self.free >= n)
|
|
126
|
+
return resume(effect);
|
|
127
|
+
const observer = () => {
|
|
128
|
+
if (self.free < n)
|
|
129
|
+
return;
|
|
130
|
+
self.waiters.delete(observer);
|
|
131
|
+
resume(effect);
|
|
132
|
+
};
|
|
133
|
+
self.waiters.add(observer);
|
|
134
|
+
return sync(() => {
|
|
135
|
+
self.waiters.delete(observer);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
class SemaphoreImpl {
|
|
140
|
+
waiters = /* @__PURE__ */ new Set;
|
|
141
|
+
taken = 0;
|
|
142
|
+
permits;
|
|
143
|
+
constructor(permits) {
|
|
144
|
+
this.permits = permits;
|
|
145
|
+
}
|
|
146
|
+
get free() {
|
|
147
|
+
return this.permits - this.taken;
|
|
148
|
+
}
|
|
149
|
+
take(n) {
|
|
150
|
+
const take = suspend(() => {
|
|
151
|
+
if (this.free < n) {
|
|
152
|
+
return waitForPermits(this, n, take);
|
|
153
|
+
}
|
|
154
|
+
this.taken += n;
|
|
155
|
+
return succeed2(n);
|
|
156
|
+
});
|
|
157
|
+
return take;
|
|
158
|
+
}
|
|
159
|
+
takeIfAvailable(n) {
|
|
160
|
+
return suspend(() => {
|
|
161
|
+
if (this.free < n)
|
|
162
|
+
return succeed2(false);
|
|
163
|
+
this.taken += n;
|
|
164
|
+
return succeed2(true);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
releaseUnsafe(fiber, n) {
|
|
168
|
+
this.taken -= n;
|
|
169
|
+
if (this.waiters.size > 0) {
|
|
170
|
+
fiber.currentDispatcher.scheduleTask(() => {
|
|
171
|
+
for (const observer of this.waiters) {
|
|
172
|
+
if (this.free <= 0)
|
|
173
|
+
break;
|
|
174
|
+
observer();
|
|
175
|
+
}
|
|
176
|
+
}, 0);
|
|
177
|
+
}
|
|
178
|
+
return this.free;
|
|
179
|
+
}
|
|
180
|
+
resize(permits) {
|
|
181
|
+
return withFiber((fiber) => {
|
|
182
|
+
this.permits = permits;
|
|
183
|
+
if (this.free < 0)
|
|
184
|
+
return void_;
|
|
185
|
+
this.releaseUnsafe(fiber, 0);
|
|
186
|
+
return void_;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
release(n) {
|
|
190
|
+
return withFiber((fiber) => succeed2(this.releaseUnsafe(fiber, n)));
|
|
191
|
+
}
|
|
192
|
+
get releaseAll() {
|
|
193
|
+
return withFiber((fiber) => succeed2(this.releaseUnsafe(fiber, this.taken)));
|
|
194
|
+
}
|
|
195
|
+
withPermits(n) {
|
|
196
|
+
return (self) => uninterruptibleMask((restore) => {
|
|
197
|
+
const acquire = suspend(() => {
|
|
198
|
+
if (this.free < n) {
|
|
199
|
+
const wait = waitForPermits(this, n, void_);
|
|
200
|
+
return flatMap2(restore(wait), () => acquire);
|
|
201
|
+
}
|
|
202
|
+
this.taken += n;
|
|
203
|
+
return onExitPrimitive(restore(self), () => {
|
|
204
|
+
this.releaseUnsafe(getCurrentFiber(), n);
|
|
205
|
+
return;
|
|
206
|
+
}, true);
|
|
207
|
+
});
|
|
208
|
+
return acquire;
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
withPermit = /* @__PURE__ */ this.withPermits(1);
|
|
212
|
+
withPermitsIfAvailable(n) {
|
|
213
|
+
return (self) => uninterruptibleMask((restore) => {
|
|
214
|
+
if (this.free < n)
|
|
215
|
+
return succeedNone;
|
|
216
|
+
this.taken += n;
|
|
217
|
+
return onExitPrimitive(restore(asSome(self)), () => {
|
|
218
|
+
this.releaseUnsafe(getCurrentFiber(), n);
|
|
219
|
+
return;
|
|
220
|
+
}, true);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
var make = (permits) => sync(() => new SemaphoreImpl(permits));
|
|
225
|
+
|
|
226
|
+
// node_modules/effect/dist/PrimaryKey.js
|
|
227
|
+
var symbol = "~effect/PrimaryKey";
|
|
228
|
+
// node_modules/effect/dist/rpc/RpcSchema.js
|
|
229
|
+
var StreamSchemaTypeId = "~effect/rpc/RpcSchema/StreamSchema";
|
|
230
|
+
function isStreamSchema(schema) {
|
|
231
|
+
return hasProperty(schema, StreamSchemaTypeId);
|
|
232
|
+
}
|
|
233
|
+
function getStreamSchemas(schema) {
|
|
234
|
+
return isStreamSchema(schema) ? some({
|
|
235
|
+
success: schema.success,
|
|
236
|
+
error: schema.error
|
|
237
|
+
}) : none();
|
|
238
|
+
}
|
|
239
|
+
var schema = /* @__PURE__ */ declare(isStream);
|
|
240
|
+
function Stream(success, error) {
|
|
241
|
+
return make11(schema.ast, {
|
|
242
|
+
[StreamSchemaTypeId]: StreamSchemaTypeId,
|
|
243
|
+
success,
|
|
244
|
+
error
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
class ClientAbort extends (/* @__PURE__ */ Service2()("effect/rpc/RpcSchema/ClientAbort")) {
|
|
249
|
+
static annotation = /* @__PURE__ */ this.context(true).pipe(/* @__PURE__ */ add(StackTrace, {
|
|
250
|
+
name: "ClientAbort",
|
|
251
|
+
stack: constUndefined,
|
|
252
|
+
parent: undefined
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// node_modules/effect/dist/rpc/Rpc.js
|
|
257
|
+
var TypeId = "~effect/rpc/Rpc";
|
|
258
|
+
class ServerClient {
|
|
259
|
+
id;
|
|
260
|
+
annotations;
|
|
261
|
+
constructor(id) {
|
|
262
|
+
this.id = id;
|
|
263
|
+
this.annotations = empty();
|
|
264
|
+
}
|
|
265
|
+
annotate(tag, value) {
|
|
266
|
+
this.annotations = add(this.annotations, tag, value);
|
|
267
|
+
return this;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
var Proto = {
|
|
271
|
+
[TypeId]: TypeId,
|
|
272
|
+
pipe() {
|
|
273
|
+
return pipeArguments(this, arguments);
|
|
274
|
+
},
|
|
275
|
+
setSuccess(successSchema) {
|
|
276
|
+
return makeProto({
|
|
277
|
+
_tag: this._tag,
|
|
278
|
+
payloadSchema: this.payloadSchema,
|
|
279
|
+
successSchema,
|
|
280
|
+
errorSchema: this.errorSchema,
|
|
281
|
+
defectSchema: this.defectSchema,
|
|
282
|
+
annotations: this.annotations,
|
|
283
|
+
middlewares: this.middlewares
|
|
284
|
+
});
|
|
285
|
+
},
|
|
286
|
+
setError(errorSchema) {
|
|
287
|
+
return makeProto({
|
|
288
|
+
_tag: this._tag,
|
|
289
|
+
payloadSchema: this.payloadSchema,
|
|
290
|
+
successSchema: this.successSchema,
|
|
291
|
+
errorSchema,
|
|
292
|
+
defectSchema: this.defectSchema,
|
|
293
|
+
annotations: this.annotations,
|
|
294
|
+
middlewares: this.middlewares
|
|
295
|
+
});
|
|
296
|
+
},
|
|
297
|
+
setPayload(payloadSchema) {
|
|
298
|
+
return makeProto({
|
|
299
|
+
_tag: this._tag,
|
|
300
|
+
payloadSchema: isSchema(payloadSchema) ? payloadSchema : Struct(payloadSchema),
|
|
301
|
+
successSchema: this.successSchema,
|
|
302
|
+
errorSchema: this.errorSchema,
|
|
303
|
+
defectSchema: this.defectSchema,
|
|
304
|
+
annotations: this.annotations,
|
|
305
|
+
middlewares: this.middlewares
|
|
306
|
+
});
|
|
307
|
+
},
|
|
308
|
+
middleware(middleware) {
|
|
309
|
+
return makeProto({
|
|
310
|
+
_tag: this._tag,
|
|
311
|
+
payloadSchema: this.payloadSchema,
|
|
312
|
+
successSchema: this.successSchema,
|
|
313
|
+
errorSchema: this.errorSchema,
|
|
314
|
+
defectSchema: this.defectSchema,
|
|
315
|
+
annotations: this.annotations,
|
|
316
|
+
middlewares: new Set([...this.middlewares, middleware])
|
|
317
|
+
});
|
|
318
|
+
},
|
|
319
|
+
prefix(prefix) {
|
|
320
|
+
return makeProto({
|
|
321
|
+
_tag: `${prefix}${this._tag}`,
|
|
322
|
+
payloadSchema: this.payloadSchema,
|
|
323
|
+
successSchema: this.successSchema,
|
|
324
|
+
errorSchema: this.errorSchema,
|
|
325
|
+
defectSchema: this.defectSchema,
|
|
326
|
+
annotations: this.annotations,
|
|
327
|
+
middlewares: this.middlewares
|
|
328
|
+
});
|
|
329
|
+
},
|
|
330
|
+
annotate(tag, value) {
|
|
331
|
+
return makeProto({
|
|
332
|
+
_tag: this._tag,
|
|
333
|
+
payloadSchema: this.payloadSchema,
|
|
334
|
+
successSchema: this.successSchema,
|
|
335
|
+
errorSchema: this.errorSchema,
|
|
336
|
+
defectSchema: this.defectSchema,
|
|
337
|
+
middlewares: this.middlewares,
|
|
338
|
+
annotations: add(this.annotations, tag, value)
|
|
339
|
+
});
|
|
340
|
+
},
|
|
341
|
+
annotateMerge(context) {
|
|
342
|
+
return makeProto({
|
|
343
|
+
_tag: this._tag,
|
|
344
|
+
payloadSchema: this.payloadSchema,
|
|
345
|
+
successSchema: this.successSchema,
|
|
346
|
+
errorSchema: this.errorSchema,
|
|
347
|
+
defectSchema: this.defectSchema,
|
|
348
|
+
middlewares: this.middlewares,
|
|
349
|
+
annotations: merge(this.annotations, context)
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
var makeProto = (options) => {
|
|
354
|
+
function Rpc() {}
|
|
355
|
+
Object.setPrototypeOf(Rpc, Proto);
|
|
356
|
+
Object.assign(Rpc, options);
|
|
357
|
+
Rpc.key = `effect/rpc/Rpc/${options._tag}`;
|
|
358
|
+
return Rpc;
|
|
359
|
+
};
|
|
360
|
+
var make2 = (tag, options) => {
|
|
361
|
+
const successSchema = options?.success ?? Void;
|
|
362
|
+
const errorSchema = options?.error ?? Never;
|
|
363
|
+
const defectSchema = options?.defect ?? Defect();
|
|
364
|
+
let payloadSchema;
|
|
365
|
+
if (options?.primaryKey) {
|
|
366
|
+
payloadSchema = class Payload extends Class2(`effect/rpc/Rpc/${tag}`)(options.payload) {
|
|
367
|
+
[symbol]() {
|
|
368
|
+
return options.primaryKey(this);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
} else {
|
|
372
|
+
payloadSchema = isSchema(options?.payload) ? options?.payload : options?.payload ? Struct(options?.payload) : Void;
|
|
373
|
+
}
|
|
374
|
+
return makeProto({
|
|
375
|
+
_tag: tag,
|
|
376
|
+
payloadSchema,
|
|
377
|
+
successSchema: options?.stream ? Stream(successSchema, errorSchema) : successSchema,
|
|
378
|
+
errorSchema: options?.stream ? Never : errorSchema,
|
|
379
|
+
defectSchema,
|
|
380
|
+
annotations: empty(),
|
|
381
|
+
middlewares: new Set
|
|
382
|
+
});
|
|
383
|
+
};
|
|
384
|
+
var exitSchemaCache = /* @__PURE__ */ new WeakMap;
|
|
385
|
+
var exitSchema = (self) => {
|
|
386
|
+
if (exitSchemaCache.has(self)) {
|
|
387
|
+
return exitSchemaCache.get(self);
|
|
388
|
+
}
|
|
389
|
+
const rpc = self;
|
|
390
|
+
const failures = new Set([rpc.errorSchema]);
|
|
391
|
+
const streamSchemas = getStreamSchemas(rpc.successSchema);
|
|
392
|
+
if (isSome(streamSchemas)) {
|
|
393
|
+
failures.add(streamSchemas.value.error);
|
|
394
|
+
}
|
|
395
|
+
for (const middleware of rpc.middlewares) {
|
|
396
|
+
failures.add(middleware.error);
|
|
397
|
+
}
|
|
398
|
+
const schema = Exit(isSome(streamSchemas) ? Void : rpc.successSchema, Union([...failures]), rpc.defectSchema);
|
|
399
|
+
exitSchemaCache.set(self, schema);
|
|
400
|
+
return schema;
|
|
401
|
+
};
|
|
402
|
+
var WrapperTypeId = "~effect/rpc/Rpc/Wrapper";
|
|
403
|
+
var isWrapper = (u) => (WrapperTypeId in u);
|
|
404
|
+
|
|
405
|
+
// node_modules/effect/dist/rpc/RpcGroup.js
|
|
406
|
+
var RpcGroupProto = {
|
|
407
|
+
add(...rpcs) {
|
|
408
|
+
const requests = new Map(this.requests);
|
|
409
|
+
for (const rpc of rpcs) {
|
|
410
|
+
requests.set(rpc._tag, rpc);
|
|
411
|
+
}
|
|
412
|
+
return makeProto2({
|
|
413
|
+
requests,
|
|
414
|
+
annotations: this.annotations
|
|
415
|
+
});
|
|
416
|
+
},
|
|
417
|
+
merge(...groups) {
|
|
418
|
+
const requests = new Map(this.requests);
|
|
419
|
+
const annotations = new Map(this.annotations.mapUnsafe);
|
|
420
|
+
for (const group of groups) {
|
|
421
|
+
for (const [tag, rpc] of group.requests) {
|
|
422
|
+
requests.set(tag, rpc);
|
|
423
|
+
}
|
|
424
|
+
for (const [key, value] of group.annotations.mapUnsafe) {
|
|
425
|
+
annotations.set(key, value);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return makeProto2({
|
|
429
|
+
requests,
|
|
430
|
+
annotations: makeUnsafe2(annotations)
|
|
431
|
+
});
|
|
432
|
+
},
|
|
433
|
+
omit(...tags) {
|
|
434
|
+
const requests = new Map(this.requests);
|
|
435
|
+
for (const tag of tags) {
|
|
436
|
+
requests.delete(tag);
|
|
437
|
+
}
|
|
438
|
+
return makeProto2({
|
|
439
|
+
requests,
|
|
440
|
+
annotations: this.annotations
|
|
441
|
+
});
|
|
442
|
+
},
|
|
443
|
+
middleware(middleware) {
|
|
444
|
+
const requests = new Map;
|
|
445
|
+
for (const [tag, rpc] of this.requests) {
|
|
446
|
+
requests.set(tag, rpc.middleware(middleware));
|
|
447
|
+
}
|
|
448
|
+
return makeProto2({
|
|
449
|
+
requests,
|
|
450
|
+
annotations: this.annotations
|
|
451
|
+
});
|
|
452
|
+
},
|
|
453
|
+
toHandlers(build) {
|
|
454
|
+
const self = this;
|
|
455
|
+
return gen(function* () {
|
|
456
|
+
const services = yield* context();
|
|
457
|
+
const handlers = isEffect(build) ? yield* build : build;
|
|
458
|
+
const contextMap = new Map;
|
|
459
|
+
self.requests.forEach((rpc, tag) => {
|
|
460
|
+
contextMap.set(rpc.key, {
|
|
461
|
+
tag: rpc._tag,
|
|
462
|
+
handler: handlers[tag],
|
|
463
|
+
context: services
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
return makeUnsafe2(contextMap);
|
|
467
|
+
});
|
|
468
|
+
},
|
|
469
|
+
prefix(prefix) {
|
|
470
|
+
const requests = new Map;
|
|
471
|
+
for (const rpc of this.requests.values()) {
|
|
472
|
+
const newRpc = rpc.prefix(prefix);
|
|
473
|
+
requests.set(newRpc._tag, newRpc);
|
|
474
|
+
}
|
|
475
|
+
return makeProto2({
|
|
476
|
+
requests,
|
|
477
|
+
annotations: this.annotations
|
|
478
|
+
});
|
|
479
|
+
},
|
|
480
|
+
toLayer(build) {
|
|
481
|
+
return effectContext(this.toHandlers(build));
|
|
482
|
+
},
|
|
483
|
+
of: identity,
|
|
484
|
+
toLayerHandler(service, build) {
|
|
485
|
+
const self = this;
|
|
486
|
+
return effectContext(gen(function* () {
|
|
487
|
+
const services = yield* context();
|
|
488
|
+
const handler = isEffect(build) ? yield* build : build;
|
|
489
|
+
const contextMap = new Map;
|
|
490
|
+
const rpc = self.requests.get(service);
|
|
491
|
+
contextMap.set(rpc.key, {
|
|
492
|
+
handler,
|
|
493
|
+
context: services
|
|
494
|
+
});
|
|
495
|
+
return makeUnsafe2(contextMap);
|
|
496
|
+
}));
|
|
497
|
+
},
|
|
498
|
+
accessHandler(service) {
|
|
499
|
+
return contextWith((parentContext) => {
|
|
500
|
+
const rpc = this.requests.get(service);
|
|
501
|
+
const {
|
|
502
|
+
handler,
|
|
503
|
+
context
|
|
504
|
+
} = getOrUndefinedUnsafe(parentContext, rpc.key);
|
|
505
|
+
return succeed6((payload, options) => {
|
|
506
|
+
options.rpc = rpc;
|
|
507
|
+
const result = handler(payload, options);
|
|
508
|
+
const effectOrStream = isWrapper(result) ? result.value : result;
|
|
509
|
+
return isEffect(effectOrStream) ? provide3(effectOrStream, context) : provideContext2(effectOrStream, context);
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
},
|
|
513
|
+
annotate(service, value) {
|
|
514
|
+
return makeProto2({
|
|
515
|
+
requests: this.requests,
|
|
516
|
+
annotations: add(this.annotations, service, value)
|
|
517
|
+
});
|
|
518
|
+
},
|
|
519
|
+
annotateRpcs(service, value) {
|
|
520
|
+
return this.annotateRpcsMerge(make4(service, value));
|
|
521
|
+
},
|
|
522
|
+
annotateMerge(context) {
|
|
523
|
+
return makeProto2({
|
|
524
|
+
requests: this.requests,
|
|
525
|
+
annotations: merge(this.annotations, context)
|
|
526
|
+
});
|
|
527
|
+
},
|
|
528
|
+
annotateRpcsMerge(context) {
|
|
529
|
+
const requests = new Map;
|
|
530
|
+
for (const [tag, rpc] of this.requests) {
|
|
531
|
+
requests.set(tag, rpc.annotateMerge(merge(context, rpc.annotations)));
|
|
532
|
+
}
|
|
533
|
+
return makeProto2({
|
|
534
|
+
requests,
|
|
535
|
+
annotations: this.annotations
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
var makeProto2 = (options) => Object.assign(function() {}, RpcGroupProto, {
|
|
540
|
+
requests: options.requests,
|
|
541
|
+
annotations: options.annotations
|
|
542
|
+
});
|
|
543
|
+
var make3 = (...rpcs) => makeProto2({
|
|
544
|
+
requests: new Map(rpcs.map((rpc) => [rpc._tag, rpc])),
|
|
545
|
+
annotations: empty()
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
// node_modules/effect/dist/rpc/RpcMiddleware.js
|
|
549
|
+
var TypeId2 = "~effect/rpc/RpcMiddleware";
|
|
550
|
+
var Service = () => (id, options) => {
|
|
551
|
+
const limit = getStackTraceLimit();
|
|
552
|
+
let creationError;
|
|
553
|
+
if (limit !== 0) {
|
|
554
|
+
setStackTraceLimit(2);
|
|
555
|
+
creationError = new globalThis.Error;
|
|
556
|
+
setStackTraceLimit(limit);
|
|
557
|
+
}
|
|
558
|
+
function ServiceClass() {}
|
|
559
|
+
const ServiceClass_ = ServiceClass;
|
|
560
|
+
Object.setPrototypeOf(ServiceClass, Object.getPrototypeOf(Service2(id)));
|
|
561
|
+
ServiceClass.key = id;
|
|
562
|
+
Object.defineProperty(ServiceClass, "stack", {
|
|
563
|
+
get() {
|
|
564
|
+
return creationError?.stack;
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
ServiceClass_[TypeId2] = TypeId2;
|
|
568
|
+
ServiceClass_.error = options?.error ?? Never;
|
|
569
|
+
ServiceClass_.requiredForClient = options?.requiredForClient ?? false;
|
|
570
|
+
return ServiceClass;
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
// node_modules/effect/dist/ai/McpSchema.js
|
|
574
|
+
var optionalWithDefault = (schema, defaultValue) => {
|
|
575
|
+
const effect = sync2(defaultValue);
|
|
576
|
+
return optionalKey(schema).pipe(decode2({
|
|
577
|
+
decode: withDefault2(effect),
|
|
578
|
+
encode: passthrough()
|
|
579
|
+
}), withConstructorDefault(effect));
|
|
580
|
+
};
|
|
581
|
+
var optional2 = (schema) => optionalKey(schema).pipe(decodeTo2(toType(optional(schema)), {
|
|
582
|
+
decode: passthrough(),
|
|
583
|
+
encode: transformOptional(flatMap(fromUndefinedOr))
|
|
584
|
+
}));
|
|
585
|
+
var RequestId = /* @__PURE__ */ Union([String3, Finite]);
|
|
586
|
+
var ProgressToken = /* @__PURE__ */ Union([String3, Finite]);
|
|
587
|
+
|
|
588
|
+
class RequestMeta extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
589
|
+
_meta: /* @__PURE__ */ optional2(/* @__PURE__ */ StructWithRest(/* @__PURE__ */ Struct({
|
|
590
|
+
progressToken: /* @__PURE__ */ optional2(ProgressToken)
|
|
591
|
+
}), [JsonObject]))
|
|
592
|
+
}))) {
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
class ResultMeta extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
596
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
597
|
+
}))) {
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
class NotificationMeta extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
601
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
602
|
+
}))) {
|
|
603
|
+
}
|
|
604
|
+
var Cursor = String3;
|
|
605
|
+
|
|
606
|
+
class PaginatedRequestMeta extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
607
|
+
...RequestMeta.fields,
|
|
608
|
+
cursor: /* @__PURE__ */ optional2(Cursor)
|
|
609
|
+
}))) {
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
class PaginatedResultMeta extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
613
|
+
...ResultMeta.fields,
|
|
614
|
+
nextCursor: /* @__PURE__ */ optional2(Cursor)
|
|
615
|
+
}))) {
|
|
616
|
+
}
|
|
617
|
+
var Role = /* @__PURE__ */ Literals(["user", "assistant"]);
|
|
618
|
+
|
|
619
|
+
class Annotations extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
620
|
+
audience: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(Role)),
|
|
621
|
+
priority: /* @__PURE__ */ optional2(/* @__PURE__ */ Finite.check(/* @__PURE__ */ isBetween({
|
|
622
|
+
minimum: 0,
|
|
623
|
+
maximum: 1
|
|
624
|
+
}))),
|
|
625
|
+
lastModified: /* @__PURE__ */ optional2(String3)
|
|
626
|
+
}))) {
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
class Icon extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/Icon")({
|
|
630
|
+
src: String3,
|
|
631
|
+
mimeType: /* @__PURE__ */ optional2(String3),
|
|
632
|
+
sizes: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3)),
|
|
633
|
+
theme: /* @__PURE__ */ optional2(/* @__PURE__ */ Literals(["light", "dark"]))
|
|
634
|
+
})) {
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
class Implementation extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
638
|
+
name: String3,
|
|
639
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
640
|
+
version: String3,
|
|
641
|
+
icons: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(Icon)),
|
|
642
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
643
|
+
websiteUrl: /* @__PURE__ */ optional2(String3)
|
|
644
|
+
}))) {
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
class ClientCapabilities extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ClientCapabilities")({
|
|
648
|
+
experimental: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(String3, /* @__PURE__ */ Struct({}))),
|
|
649
|
+
extensions: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(/* @__PURE__ */ TemplateLiteral([String3, "/", String3]), Json)),
|
|
650
|
+
roots: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({
|
|
651
|
+
listChanged: /* @__PURE__ */ optional2(Boolean3)
|
|
652
|
+
})),
|
|
653
|
+
sampling: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({
|
|
654
|
+
context: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({})),
|
|
655
|
+
tools: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({}))
|
|
656
|
+
})),
|
|
657
|
+
elicitation: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({
|
|
658
|
+
form: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({})),
|
|
659
|
+
url: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({}))
|
|
660
|
+
}))
|
|
661
|
+
})) {
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
class ServerCapabilities extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
665
|
+
experimental: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(String3, /* @__PURE__ */ Struct({}))),
|
|
666
|
+
extensions: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(/* @__PURE__ */ TemplateLiteral([String3, "/", String3]), Json)),
|
|
667
|
+
logging: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({})),
|
|
668
|
+
completions: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({})),
|
|
669
|
+
prompts: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({
|
|
670
|
+
listChanged: /* @__PURE__ */ optional2(Boolean3)
|
|
671
|
+
})),
|
|
672
|
+
resources: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({
|
|
673
|
+
subscribe: /* @__PURE__ */ optional2(Boolean3),
|
|
674
|
+
listChanged: /* @__PURE__ */ optional2(Boolean3)
|
|
675
|
+
})),
|
|
676
|
+
tools: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct({
|
|
677
|
+
listChanged: /* @__PURE__ */ optional2(Boolean3)
|
|
678
|
+
}))
|
|
679
|
+
}))) {
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
class McpErrorBase extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/McpErrorBase")({
|
|
683
|
+
code: Int2,
|
|
684
|
+
message: String3,
|
|
685
|
+
data: /* @__PURE__ */ optional2(Any)
|
|
686
|
+
})) {
|
|
687
|
+
}
|
|
688
|
+
var INVALID_REQUEST_ERROR_CODE = -32600;
|
|
689
|
+
var METHOD_NOT_FOUND_ERROR_CODE = -32601;
|
|
690
|
+
var INVALID_PARAMS_ERROR_CODE = -32602;
|
|
691
|
+
var INTERNAL_ERROR_CODE = -32603;
|
|
692
|
+
var PARSE_ERROR_CODE = -32700;
|
|
693
|
+
var HEADER_MISMATCH_ERROR_CODE = -32020;
|
|
694
|
+
|
|
695
|
+
class ParseError extends (/* @__PURE__ */ Error2("effect/ai/McpSchema/ParseError")({
|
|
696
|
+
...McpErrorBase.fields,
|
|
697
|
+
_tag: /* @__PURE__ */ tag("ParseError"),
|
|
698
|
+
code: /* @__PURE__ */ tag(PARSE_ERROR_CODE)
|
|
699
|
+
})) {
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
class InvalidRequest extends (/* @__PURE__ */ Error2("effect/ai/McpSchema/InvalidRequest")({
|
|
703
|
+
...McpErrorBase.fields,
|
|
704
|
+
_tag: /* @__PURE__ */ tag("InvalidRequest"),
|
|
705
|
+
code: /* @__PURE__ */ tag(INVALID_REQUEST_ERROR_CODE)
|
|
706
|
+
})) {
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
class MethodNotFound extends (/* @__PURE__ */ Error2("effect/ai/McpSchema/MethodNotFound")({
|
|
710
|
+
...McpErrorBase.fields,
|
|
711
|
+
_tag: /* @__PURE__ */ tag("MethodNotFound"),
|
|
712
|
+
code: /* @__PURE__ */ tag(METHOD_NOT_FOUND_ERROR_CODE)
|
|
713
|
+
})) {
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
class InvalidParams extends (/* @__PURE__ */ Error2("effect/ai/McpSchema/InvalidParams")({
|
|
717
|
+
...McpErrorBase.fields,
|
|
718
|
+
_tag: /* @__PURE__ */ tag("InvalidParams"),
|
|
719
|
+
code: /* @__PURE__ */ tag(INVALID_PARAMS_ERROR_CODE)
|
|
720
|
+
})) {
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
class InternalError extends (/* @__PURE__ */ Error2("effect/ai/McpSchema/InternalError")({
|
|
724
|
+
...McpErrorBase.fields,
|
|
725
|
+
_tag: /* @__PURE__ */ tag("InternalError"),
|
|
726
|
+
code: /* @__PURE__ */ tag(INTERNAL_ERROR_CODE)
|
|
727
|
+
})) {
|
|
728
|
+
static notImplemented = /* @__PURE__ */ new InternalError({
|
|
729
|
+
message: "Not implemented"
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
var McpError = /* @__PURE__ */ Union([ParseError, InvalidRequest, MethodNotFound, InvalidParams, InternalError, McpErrorBase]);
|
|
733
|
+
|
|
734
|
+
class Ping extends (/* @__PURE__ */ make2("ping", {
|
|
735
|
+
success: /* @__PURE__ */ Struct({}),
|
|
736
|
+
error: McpError,
|
|
737
|
+
payload: /* @__PURE__ */ UndefinedOr(RequestMeta)
|
|
738
|
+
})) {
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
class InitializeResult extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
742
|
+
...ResultMeta.fields,
|
|
743
|
+
protocolVersion: String3,
|
|
744
|
+
capabilities: ServerCapabilities,
|
|
745
|
+
serverInfo: Implementation,
|
|
746
|
+
instructions: /* @__PURE__ */ optional2(String3)
|
|
747
|
+
}))) {
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
class Initialize extends (/* @__PURE__ */ make2("initialize", {
|
|
751
|
+
success: InitializeResult,
|
|
752
|
+
error: McpError,
|
|
753
|
+
payload: {
|
|
754
|
+
...RequestMeta.fields,
|
|
755
|
+
protocolVersion: String3,
|
|
756
|
+
capabilities: ClientCapabilities,
|
|
757
|
+
clientInfo: Implementation
|
|
758
|
+
}
|
|
759
|
+
})) {
|
|
760
|
+
}
|
|
761
|
+
class CancelledNotification extends (/* @__PURE__ */ make2("notifications/cancelled", {
|
|
762
|
+
payload: {
|
|
763
|
+
...NotificationMeta.fields,
|
|
764
|
+
requestId: RequestId,
|
|
765
|
+
reason: /* @__PURE__ */ optional2(String3)
|
|
766
|
+
}
|
|
767
|
+
})) {
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
class ProgressNotification extends (/* @__PURE__ */ make2("notifications/progress", {
|
|
771
|
+
payload: {
|
|
772
|
+
...NotificationMeta.fields,
|
|
773
|
+
progressToken: ProgressToken,
|
|
774
|
+
progress: Finite,
|
|
775
|
+
total: /* @__PURE__ */ optional2(Finite),
|
|
776
|
+
message: /* @__PURE__ */ optional2(String3)
|
|
777
|
+
}
|
|
778
|
+
})) {
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
class Resource extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/Resource")({
|
|
782
|
+
uri: String3,
|
|
783
|
+
name: String3,
|
|
784
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
785
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
786
|
+
mimeType: /* @__PURE__ */ optional2(String3),
|
|
787
|
+
annotations: /* @__PURE__ */ optional2(Annotations),
|
|
788
|
+
icons: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(Icon)),
|
|
789
|
+
size: /* @__PURE__ */ optional2(Int2),
|
|
790
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
791
|
+
})) {
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
class ResourceTemplate extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ResourceTemplate")({
|
|
795
|
+
uriTemplate: String3,
|
|
796
|
+
name: String3,
|
|
797
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
798
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
799
|
+
mimeType: /* @__PURE__ */ optional2(String3),
|
|
800
|
+
annotations: /* @__PURE__ */ optional2(Annotations),
|
|
801
|
+
icons: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(Icon)),
|
|
802
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
803
|
+
})) {
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
class ResourceContents extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
807
|
+
uri: String3,
|
|
808
|
+
mimeType: /* @__PURE__ */ optional2(String3),
|
|
809
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
810
|
+
}))) {
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
class TextResourceContents extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
814
|
+
...ResourceContents.fields,
|
|
815
|
+
text: String3
|
|
816
|
+
}))) {
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
class BlobResourceContents extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
820
|
+
...ResourceContents.fields,
|
|
821
|
+
blob: Uint8ArrayFromBase64
|
|
822
|
+
}))) {
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
class ListResourcesResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ListResourcesResult")({
|
|
826
|
+
...PaginatedResultMeta.fields,
|
|
827
|
+
resources: /* @__PURE__ */ ArraySchema(Resource)
|
|
828
|
+
})) {
|
|
829
|
+
}
|
|
830
|
+
class ListResourceTemplatesResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ListResourceTemplatesResult")({
|
|
831
|
+
...PaginatedResultMeta.fields,
|
|
832
|
+
resourceTemplates: /* @__PURE__ */ ArraySchema(ResourceTemplate)
|
|
833
|
+
})) {
|
|
834
|
+
}
|
|
835
|
+
class ReadResourceResult extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
836
|
+
...ResultMeta.fields,
|
|
837
|
+
contents: /* @__PURE__ */ ArraySchema(/* @__PURE__ */ Union([TextResourceContents, BlobResourceContents]))
|
|
838
|
+
}))) {
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
class ReadResource extends (/* @__PURE__ */ make2("resources/read", {
|
|
842
|
+
success: ReadResourceResult,
|
|
843
|
+
error: McpError,
|
|
844
|
+
payload: {
|
|
845
|
+
...RequestMeta.fields,
|
|
846
|
+
uri: String3
|
|
847
|
+
}
|
|
848
|
+
})) {
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
class ResourceListChangedNotification extends (/* @__PURE__ */ make2("notifications/resources/list_changed", {
|
|
852
|
+
payload: /* @__PURE__ */ UndefinedOr(NotificationMeta)
|
|
853
|
+
})) {
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
class Subscribe extends (/* @__PURE__ */ make2("resources/subscribe", {
|
|
857
|
+
success: /* @__PURE__ */ Struct({}),
|
|
858
|
+
error: McpError,
|
|
859
|
+
payload: {
|
|
860
|
+
...RequestMeta.fields,
|
|
861
|
+
uri: String3
|
|
862
|
+
}
|
|
863
|
+
})) {
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
class Unsubscribe extends (/* @__PURE__ */ make2("resources/unsubscribe", {
|
|
867
|
+
success: /* @__PURE__ */ Struct({}),
|
|
868
|
+
error: McpError,
|
|
869
|
+
payload: {
|
|
870
|
+
...RequestMeta.fields,
|
|
871
|
+
uri: String3
|
|
872
|
+
}
|
|
873
|
+
})) {
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
class ResourceUpdatedNotification extends (/* @__PURE__ */ make2("notifications/resources/updated", {
|
|
877
|
+
payload: {
|
|
878
|
+
...NotificationMeta.fields,
|
|
879
|
+
uri: String3
|
|
880
|
+
}
|
|
881
|
+
})) {
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
class PromptArgument extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
885
|
+
name: String3,
|
|
886
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
887
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
888
|
+
required: /* @__PURE__ */ optional2(Boolean3)
|
|
889
|
+
}))) {
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
class Prompt extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/Prompt")({
|
|
893
|
+
name: String3,
|
|
894
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
895
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
896
|
+
arguments: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(PromptArgument)),
|
|
897
|
+
icons: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(Icon)),
|
|
898
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
899
|
+
})) {
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
class TextContent extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
903
|
+
type: /* @__PURE__ */ tag("text"),
|
|
904
|
+
text: String3,
|
|
905
|
+
annotations: /* @__PURE__ */ optional2(Annotations),
|
|
906
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
907
|
+
}))) {
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
class ImageContent extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
911
|
+
type: /* @__PURE__ */ tag("image"),
|
|
912
|
+
data: Uint8ArrayFromBase64,
|
|
913
|
+
mimeType: String3,
|
|
914
|
+
annotations: /* @__PURE__ */ optional2(Annotations),
|
|
915
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
916
|
+
}))) {
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
class AudioContent extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
920
|
+
type: /* @__PURE__ */ tag("audio"),
|
|
921
|
+
data: Uint8ArrayFromBase64,
|
|
922
|
+
mimeType: String3,
|
|
923
|
+
annotations: /* @__PURE__ */ optional2(Annotations),
|
|
924
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
925
|
+
}))) {
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
class EmbeddedResource extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
929
|
+
type: /* @__PURE__ */ tag("resource"),
|
|
930
|
+
resource: /* @__PURE__ */ Union([TextResourceContents, BlobResourceContents]),
|
|
931
|
+
annotations: /* @__PURE__ */ optional2(Annotations),
|
|
932
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
933
|
+
}))) {
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
class ResourceLink extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
937
|
+
...Resource.fields,
|
|
938
|
+
type: /* @__PURE__ */ tag("resource_link")
|
|
939
|
+
}))) {
|
|
940
|
+
}
|
|
941
|
+
var ContentBlock = /* @__PURE__ */ Union([TextContent, ImageContent, AudioContent, EmbeddedResource, ResourceLink]);
|
|
942
|
+
|
|
943
|
+
class PromptMessage extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
944
|
+
role: Role,
|
|
945
|
+
content: ContentBlock
|
|
946
|
+
}))) {
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
class ListPromptsResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ListPromptsResult")({
|
|
950
|
+
...PaginatedResultMeta.fields,
|
|
951
|
+
prompts: /* @__PURE__ */ ArraySchema(Prompt)
|
|
952
|
+
})) {
|
|
953
|
+
}
|
|
954
|
+
class GetPromptResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/GetPromptResult")({
|
|
955
|
+
...ResultMeta.fields,
|
|
956
|
+
messages: /* @__PURE__ */ ArraySchema(PromptMessage),
|
|
957
|
+
description: /* @__PURE__ */ optional2(String3)
|
|
958
|
+
})) {
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
class GetPrompt extends (/* @__PURE__ */ make2("prompts/get", {
|
|
962
|
+
success: GetPromptResult,
|
|
963
|
+
error: McpError,
|
|
964
|
+
payload: {
|
|
965
|
+
...RequestMeta.fields,
|
|
966
|
+
name: String3,
|
|
967
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
968
|
+
arguments: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(String3, String3))
|
|
969
|
+
}
|
|
970
|
+
})) {
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
class PromptListChangedNotification extends (/* @__PURE__ */ make2("notifications/prompts/list_changed", {
|
|
974
|
+
payload: /* @__PURE__ */ UndefinedOr(NotificationMeta)
|
|
975
|
+
})) {
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
class ToolAnnotations extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
979
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
980
|
+
readOnlyHint: /* @__PURE__ */ optionalWithDefault(Boolean3, constFalse),
|
|
981
|
+
destructiveHint: /* @__PURE__ */ optionalWithDefault(Boolean3, constTrue),
|
|
982
|
+
idempotentHint: /* @__PURE__ */ optionalWithDefault(Boolean3, constFalse),
|
|
983
|
+
openWorldHint: /* @__PURE__ */ optionalWithDefault(Boolean3, constTrue)
|
|
984
|
+
}))) {
|
|
985
|
+
}
|
|
986
|
+
var ToolJson = /* @__PURE__ */ StructWithRest(/* @__PURE__ */ Struct({
|
|
987
|
+
type: /* @__PURE__ */ Literal("object"),
|
|
988
|
+
properties: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(String3, JsonObject)),
|
|
989
|
+
required: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3))
|
|
990
|
+
}), [JsonObject]);
|
|
991
|
+
var ToolOutputJson = JsonObject;
|
|
992
|
+
|
|
993
|
+
class Tool extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/Tool")({
|
|
994
|
+
name: String3,
|
|
995
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
996
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
997
|
+
inputSchema: ToolJson,
|
|
998
|
+
outputSchema: /* @__PURE__ */ optional2(ToolOutputJson),
|
|
999
|
+
annotations: /* @__PURE__ */ optional2(ToolAnnotations),
|
|
1000
|
+
icons: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(Icon)),
|
|
1001
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
1002
|
+
})) {
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
class ListToolsResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ListToolsResult")({
|
|
1006
|
+
...PaginatedResultMeta.fields,
|
|
1007
|
+
tools: /* @__PURE__ */ ArraySchema(Tool)
|
|
1008
|
+
})) {
|
|
1009
|
+
}
|
|
1010
|
+
class CallToolResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/CallToolResult")({
|
|
1011
|
+
...ResultMeta.fields,
|
|
1012
|
+
content: /* @__PURE__ */ ArraySchema(ContentBlock),
|
|
1013
|
+
structuredContent: /* @__PURE__ */ optional2(Json),
|
|
1014
|
+
isError: /* @__PURE__ */ optional2(Boolean3)
|
|
1015
|
+
})) {
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
class CallTool extends (/* @__PURE__ */ make2("tools/call", {
|
|
1019
|
+
success: CallToolResult,
|
|
1020
|
+
error: McpError,
|
|
1021
|
+
payload: {
|
|
1022
|
+
...RequestMeta.fields,
|
|
1023
|
+
name: String3,
|
|
1024
|
+
arguments: /* @__PURE__ */ optionalWithDefault(/* @__PURE__ */ Record(String3, Any), () => ({}))
|
|
1025
|
+
}
|
|
1026
|
+
})) {
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
class ToolListChangedNotification extends (/* @__PURE__ */ make2("notifications/tools/list_changed", {
|
|
1030
|
+
payload: /* @__PURE__ */ UndefinedOr(NotificationMeta)
|
|
1031
|
+
})) {
|
|
1032
|
+
}
|
|
1033
|
+
var LoggingLevel = /* @__PURE__ */ Literals(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
|
|
1034
|
+
|
|
1035
|
+
class SetLevel extends (/* @__PURE__ */ make2("logging/setLevel", {
|
|
1036
|
+
payload: {
|
|
1037
|
+
...RequestMeta.fields,
|
|
1038
|
+
level: LoggingLevel
|
|
1039
|
+
},
|
|
1040
|
+
success: /* @__PURE__ */ Struct({}),
|
|
1041
|
+
error: McpError
|
|
1042
|
+
})) {
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
class LoggingMessageNotification extends (/* @__PURE__ */ make2("notifications/message", {
|
|
1046
|
+
payload: /* @__PURE__ */ Struct({
|
|
1047
|
+
...NotificationMeta.fields,
|
|
1048
|
+
level: LoggingLevel,
|
|
1049
|
+
logger: /* @__PURE__ */ optional2(String3),
|
|
1050
|
+
data: Any
|
|
1051
|
+
})
|
|
1052
|
+
})) {
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
class ToolUseContent extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ToolUseContent")({
|
|
1056
|
+
type: /* @__PURE__ */ tag("tool_use"),
|
|
1057
|
+
id: String3,
|
|
1058
|
+
name: String3,
|
|
1059
|
+
input: /* @__PURE__ */ Record(String3, Unknown),
|
|
1060
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
1061
|
+
})) {
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
class ToolResultContent extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ToolResultContent")({
|
|
1065
|
+
type: /* @__PURE__ */ tag("tool_result"),
|
|
1066
|
+
toolUseId: String3,
|
|
1067
|
+
content: /* @__PURE__ */ ArraySchema(ContentBlock),
|
|
1068
|
+
structuredContent: /* @__PURE__ */ optional2(Json),
|
|
1069
|
+
isError: /* @__PURE__ */ optional2(Boolean3),
|
|
1070
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
1071
|
+
})) {
|
|
1072
|
+
}
|
|
1073
|
+
var SamplingMessageContentBlock = /* @__PURE__ */ Union([TextContent, ImageContent, AudioContent, ToolUseContent, ToolResultContent]);
|
|
1074
|
+
|
|
1075
|
+
class SamplingMessage extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
1076
|
+
role: Role,
|
|
1077
|
+
content: /* @__PURE__ */ Union([SamplingMessageContentBlock, /* @__PURE__ */ ArraySchema(SamplingMessageContentBlock)]),
|
|
1078
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
1079
|
+
}))) {
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
class ToolChoice extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ToolChoice")({
|
|
1083
|
+
mode: /* @__PURE__ */ optional2(/* @__PURE__ */ Literals(["auto", "required", "none"]))
|
|
1084
|
+
})) {
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
class ModelHint extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
1088
|
+
name: /* @__PURE__ */ optional2(String3)
|
|
1089
|
+
}))) {
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
class ModelPreferences extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ModelPreferences")({
|
|
1093
|
+
hints: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(ModelHint)),
|
|
1094
|
+
costPriority: /* @__PURE__ */ optional2(/* @__PURE__ */ Finite.check(/* @__PURE__ */ isBetween({
|
|
1095
|
+
minimum: 0,
|
|
1096
|
+
maximum: 1
|
|
1097
|
+
}))),
|
|
1098
|
+
speedPriority: /* @__PURE__ */ optional2(/* @__PURE__ */ Finite.check(/* @__PURE__ */ isBetween({
|
|
1099
|
+
minimum: 0,
|
|
1100
|
+
maximum: 1
|
|
1101
|
+
}))),
|
|
1102
|
+
intelligencePriority: /* @__PURE__ */ optional2(/* @__PURE__ */ Finite.check(/* @__PURE__ */ isBetween({
|
|
1103
|
+
minimum: 0,
|
|
1104
|
+
maximum: 1
|
|
1105
|
+
})))
|
|
1106
|
+
})) {
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
class CreateMessageResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/CreateMessageResult")({
|
|
1110
|
+
role: Role,
|
|
1111
|
+
content: /* @__PURE__ */ Union([SamplingMessageContentBlock, /* @__PURE__ */ ArraySchema(SamplingMessageContentBlock)]),
|
|
1112
|
+
_meta: /* @__PURE__ */ optional2(JsonObject),
|
|
1113
|
+
model: String3,
|
|
1114
|
+
stopReason: /* @__PURE__ */ optional2(String3)
|
|
1115
|
+
})) {
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
class CreateMessage extends (/* @__PURE__ */ make2("sampling/createMessage", {
|
|
1119
|
+
success: CreateMessageResult,
|
|
1120
|
+
error: McpError,
|
|
1121
|
+
payload: {
|
|
1122
|
+
messages: /* @__PURE__ */ ArraySchema(SamplingMessage),
|
|
1123
|
+
modelPreferences: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct(ModelPreferences.fields)),
|
|
1124
|
+
systemPrompt: /* @__PURE__ */ optional2(String3),
|
|
1125
|
+
includeContext: /* @__PURE__ */ optional2(/* @__PURE__ */ Literals(["none", "thisServer", "allServers"])),
|
|
1126
|
+
temperature: /* @__PURE__ */ optional2(Finite),
|
|
1127
|
+
maxTokens: Int2,
|
|
1128
|
+
stopSequences: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3)),
|
|
1129
|
+
metadata: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(String3, Unknown)),
|
|
1130
|
+
tools: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(/* @__PURE__ */ Struct(Tool.fields))),
|
|
1131
|
+
toolChoice: /* @__PURE__ */ optional2(/* @__PURE__ */ Struct(ToolChoice.fields))
|
|
1132
|
+
}
|
|
1133
|
+
})) {
|
|
1134
|
+
}
|
|
1135
|
+
class CompleteResult extends (/* @__PURE__ */ Opaque()(/* @__PURE__ */ Struct({
|
|
1136
|
+
...ResultMeta.fields,
|
|
1137
|
+
completion: /* @__PURE__ */ Struct({
|
|
1138
|
+
values: /* @__PURE__ */ ArraySchema(String3),
|
|
1139
|
+
total: /* @__PURE__ */ optional2(Int2),
|
|
1140
|
+
hasMore: /* @__PURE__ */ optional2(Boolean3)
|
|
1141
|
+
})
|
|
1142
|
+
}))) {
|
|
1143
|
+
static empty = /* @__PURE__ */ CompleteResult.make({
|
|
1144
|
+
completion: {
|
|
1145
|
+
values: [],
|
|
1146
|
+
total: 0,
|
|
1147
|
+
hasMore: false
|
|
1148
|
+
}
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
class Root extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/Root")({
|
|
1152
|
+
uri: String3,
|
|
1153
|
+
name: /* @__PURE__ */ optional2(String3),
|
|
1154
|
+
_meta: /* @__PURE__ */ optional2(JsonObject)
|
|
1155
|
+
})) {
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
class ListRootsResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ListRootsResult")({
|
|
1159
|
+
roots: /* @__PURE__ */ ArraySchema(Root)
|
|
1160
|
+
})) {
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
class ListRoots extends (/* @__PURE__ */ make2("roots/list", {
|
|
1164
|
+
success: ListRootsResult,
|
|
1165
|
+
error: McpError,
|
|
1166
|
+
payload: /* @__PURE__ */ UndefinedOr(RequestMeta)
|
|
1167
|
+
})) {
|
|
1168
|
+
}
|
|
1169
|
+
class ElicitationString extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitationString")({
|
|
1170
|
+
type: /* @__PURE__ */ tag("string"),
|
|
1171
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
1172
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
1173
|
+
minLength: /* @__PURE__ */ optional2(Int2),
|
|
1174
|
+
maxLength: /* @__PURE__ */ optional2(Int2),
|
|
1175
|
+
format: /* @__PURE__ */ optional2(/* @__PURE__ */ Literals(["email", "uri", "date", "date-time"])),
|
|
1176
|
+
default: /* @__PURE__ */ optional2(String3)
|
|
1177
|
+
})) {
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
class ElicitationNumber extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitationNumber")({
|
|
1181
|
+
type: /* @__PURE__ */ Literals(["number", "integer"]),
|
|
1182
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
1183
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
1184
|
+
minimum: /* @__PURE__ */ optional2(Finite),
|
|
1185
|
+
maximum: /* @__PURE__ */ optional2(Finite),
|
|
1186
|
+
default: /* @__PURE__ */ optional2(Finite)
|
|
1187
|
+
})) {
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
class ElicitationBoolean extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitationBoolean")({
|
|
1191
|
+
type: /* @__PURE__ */ tag("boolean"),
|
|
1192
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
1193
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
1194
|
+
default: /* @__PURE__ */ optional2(Boolean3)
|
|
1195
|
+
})) {
|
|
1196
|
+
}
|
|
14
1197
|
|
|
1198
|
+
class UntitledSingleSelectEnum extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/UntitledSingleSelectEnum")({
|
|
1199
|
+
type: /* @__PURE__ */ tag("string"),
|
|
1200
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
1201
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
1202
|
+
enum: /* @__PURE__ */ ArraySchema(String3),
|
|
1203
|
+
default: /* @__PURE__ */ optional2(String3)
|
|
1204
|
+
})) {
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
class TitledSingleSelectEnum extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/TitledSingleSelectEnum")({
|
|
1208
|
+
type: /* @__PURE__ */ tag("string"),
|
|
1209
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
1210
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
1211
|
+
oneOf: /* @__PURE__ */ ArraySchema(/* @__PURE__ */ Struct({
|
|
1212
|
+
const: String3,
|
|
1213
|
+
title: String3
|
|
1214
|
+
})),
|
|
1215
|
+
default: /* @__PURE__ */ optional2(String3)
|
|
1216
|
+
})) {
|
|
1217
|
+
}
|
|
1218
|
+
var SingleSelectEnum = /* @__PURE__ */ Union([UntitledSingleSelectEnum, TitledSingleSelectEnum]);
|
|
1219
|
+
|
|
1220
|
+
class UntitledMultiSelectEnum extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/UntitledMultiSelectEnum")({
|
|
1221
|
+
type: /* @__PURE__ */ tag("array"),
|
|
1222
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
1223
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
1224
|
+
minItems: /* @__PURE__ */ optional2(Int2),
|
|
1225
|
+
maxItems: /* @__PURE__ */ optional2(Int2),
|
|
1226
|
+
items: /* @__PURE__ */ Struct({
|
|
1227
|
+
type: /* @__PURE__ */ tag("string"),
|
|
1228
|
+
enum: /* @__PURE__ */ ArraySchema(String3)
|
|
1229
|
+
}),
|
|
1230
|
+
default: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3))
|
|
1231
|
+
})) {
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
class TitledMultiSelectEnum extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/TitledMultiSelectEnum")({
|
|
1235
|
+
type: /* @__PURE__ */ tag("array"),
|
|
1236
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
1237
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
1238
|
+
minItems: /* @__PURE__ */ optional2(Int2),
|
|
1239
|
+
maxItems: /* @__PURE__ */ optional2(Int2),
|
|
1240
|
+
items: /* @__PURE__ */ Struct({
|
|
1241
|
+
anyOf: /* @__PURE__ */ ArraySchema(/* @__PURE__ */ Struct({
|
|
1242
|
+
const: String3,
|
|
1243
|
+
title: String3
|
|
1244
|
+
}))
|
|
1245
|
+
}),
|
|
1246
|
+
default: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3))
|
|
1247
|
+
})) {
|
|
1248
|
+
}
|
|
1249
|
+
var MultiSelectEnum = /* @__PURE__ */ Union([UntitledMultiSelectEnum, TitledMultiSelectEnum]);
|
|
1250
|
+
|
|
1251
|
+
class LegacyTitledEnum extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/LegacyTitledEnum")({
|
|
1252
|
+
type: /* @__PURE__ */ tag("string"),
|
|
1253
|
+
title: /* @__PURE__ */ optional2(String3),
|
|
1254
|
+
description: /* @__PURE__ */ optional2(String3),
|
|
1255
|
+
enum: /* @__PURE__ */ ArraySchema(String3),
|
|
1256
|
+
enumNames: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3)),
|
|
1257
|
+
default: /* @__PURE__ */ optional2(String3)
|
|
1258
|
+
})) {
|
|
1259
|
+
}
|
|
1260
|
+
var ElicitationEnum = /* @__PURE__ */ Union([LegacyTitledEnum, SingleSelectEnum, MultiSelectEnum]);
|
|
1261
|
+
var PrimitiveSchemaDefinition = /* @__PURE__ */ Union([ElicitationEnum, ElicitationString, ElicitationNumber, ElicitationBoolean]);
|
|
1262
|
+
var ElicitationForm = /* @__PURE__ */ Struct({
|
|
1263
|
+
$schema: /* @__PURE__ */ optional2(String3),
|
|
1264
|
+
type: /* @__PURE__ */ tag("object"),
|
|
1265
|
+
properties: /* @__PURE__ */ Record(String3, PrimitiveSchemaDefinition),
|
|
1266
|
+
required: /* @__PURE__ */ optional2(/* @__PURE__ */ ArraySchema(String3))
|
|
1267
|
+
});
|
|
1268
|
+
|
|
1269
|
+
class ElicitRequestFormParams extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitRequestFormParams")({
|
|
1270
|
+
...RequestMeta.fields,
|
|
1271
|
+
mode: /* @__PURE__ */ optional2(/* @__PURE__ */ Literal("form")),
|
|
1272
|
+
message: String3,
|
|
1273
|
+
requestedSchema: ElicitationForm
|
|
1274
|
+
})) {
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
class ElicitRequestURLParams extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitRequestURLParams")({
|
|
1278
|
+
...RequestMeta.fields,
|
|
1279
|
+
mode: /* @__PURE__ */ Literal("url"),
|
|
1280
|
+
message: String3,
|
|
1281
|
+
elicitationId: String3,
|
|
1282
|
+
url: String3
|
|
1283
|
+
})) {
|
|
1284
|
+
}
|
|
1285
|
+
var ElicitRequestParams = /* @__PURE__ */ Union([ElicitRequestFormParams, ElicitRequestURLParams]);
|
|
1286
|
+
|
|
1287
|
+
class ElicitAcceptResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitAcceptResult")({
|
|
1288
|
+
...ResultMeta.fields,
|
|
1289
|
+
action: /* @__PURE__ */ Literal("accept"),
|
|
1290
|
+
content: /* @__PURE__ */ optional2(/* @__PURE__ */ Record(String3, /* @__PURE__ */ Union([String3, Finite, Boolean3, /* @__PURE__ */ ArraySchema(String3)])))
|
|
1291
|
+
})) {
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
class ElicitDeclineResult extends (/* @__PURE__ */ Class2("@effect/ai/McpSchema/ElicitDeclineResult")({
|
|
1295
|
+
...ResultMeta.fields,
|
|
1296
|
+
action: /* @__PURE__ */ Literals(["cancel", "decline"])
|
|
1297
|
+
})) {
|
|
1298
|
+
}
|
|
1299
|
+
var ElicitResult = /* @__PURE__ */ Union([ElicitAcceptResult, ElicitDeclineResult]);
|
|
1300
|
+
class Elicit extends (/* @__PURE__ */ make2("elicitation/create", {
|
|
1301
|
+
success: ElicitResult,
|
|
1302
|
+
error: McpError,
|
|
1303
|
+
payload: ElicitRequestParams
|
|
1304
|
+
})) {
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
class ElicitationCompleteNotification extends (/* @__PURE__ */ make2("notifications/elicitation/complete", {
|
|
1308
|
+
payload: {
|
|
1309
|
+
elicitationId: String3
|
|
1310
|
+
}
|
|
1311
|
+
})) {
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
class ElicitationDeclined extends (/* @__PURE__ */ Error2("@effect/ai/McpSchema/ElicitationDeclined")({
|
|
1315
|
+
_tag: /* @__PURE__ */ tag("ElicitationDeclined"),
|
|
1316
|
+
request: Elicit.payloadSchema,
|
|
1317
|
+
cause: /* @__PURE__ */ optional2(/* @__PURE__ */ Defect())
|
|
1318
|
+
})) {
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
class McpReverseOperationUnsupported extends (/* @__PURE__ */ TaggedError("McpReverseOperationUnsupported")) {
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
class McpReverseOperationError extends (/* @__PURE__ */ TaggedError("McpReverseOperationError")) {
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
class McpRequestContext extends (/* @__PURE__ */ Service2()("effect/ai/McpSchema/McpRequestContext")) {
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
class McpServerClient extends (/* @__PURE__ */ Service2()("effect/ai/McpSchema/McpServerClient")) {
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
class McpServerClientMiddleware extends (/* @__PURE__ */ Service()("effect/ai/McpSchema/McpServerClientMiddleware")) {
|
|
1334
|
+
}
|
|
1335
|
+
class ServerNotificationRpcs extends (/* @__PURE__ */ make3(CancelledNotification, ProgressNotification, LoggingMessageNotification, ResourceUpdatedNotification, ResourceListChangedNotification, ToolListChangedNotification, PromptListChangedNotification, ElicitationCompleteNotification)) {
|
|
1336
|
+
}
|
|
1337
|
+
class EnabledWhen extends (/* @__PURE__ */ Service2()("effect/ai/McpSchema/EnabledWhen")) {
|
|
1338
|
+
}
|
|
15
1339
|
// src/relay/user-settings.ts
|
|
16
1340
|
var settingKeys = ["window", "grouping", "idleMinutes", "cursor", "humanInput", "handoffNotifications", "autoUpdate"];
|
|
17
1341
|
var relaySettingKeys = ["autoUpdate"];
|
|
@@ -136,8 +1460,6 @@ function formatSettings(settings) {
|
|
|
136
1460
|
}
|
|
137
1461
|
|
|
138
1462
|
// src/mcp/schema.ts
|
|
139
|
-
import { Effect, Predicate } from "effect";
|
|
140
|
-
import { McpSchema } from "effect/ai";
|
|
141
1463
|
function browsersNote2(browsers) {
|
|
142
1464
|
if (browsers.length < 2)
|
|
143
1465
|
return "";
|
|
@@ -164,13 +1486,13 @@ var sessionAliasSchemaProperty = { type: "string", description: "Same as id." };
|
|
|
164
1486
|
var sessionOnlyInputSchema = objectSchema({
|
|
165
1487
|
session: sessionSchemaProperty
|
|
166
1488
|
});
|
|
167
|
-
var ensureSessionExists =
|
|
1489
|
+
var ensureSessionExists = fnUntraced(function* (relay, id) {
|
|
168
1490
|
const sessions = yield* relay.sessions;
|
|
169
1491
|
const exists = sessions.some((session) => {
|
|
170
1492
|
return session.id === id;
|
|
171
1493
|
});
|
|
172
1494
|
if (!exists) {
|
|
173
|
-
return yield*
|
|
1495
|
+
return yield* fail4(new Error(`Session not found: ${id}`));
|
|
174
1496
|
}
|
|
175
1497
|
});
|
|
176
1498
|
function parseExecuteArguments(input) {
|
|
@@ -222,13 +1544,13 @@ function optionalStringField(input, field) {
|
|
|
222
1544
|
}
|
|
223
1545
|
function optionalBooleanField(input, field) {
|
|
224
1546
|
const value = requireObject(input)[field];
|
|
225
|
-
return
|
|
1547
|
+
return isBoolean(value) ? value : undefined;
|
|
226
1548
|
}
|
|
227
1549
|
function optionalPositiveIntegerField(input, field) {
|
|
228
1550
|
const value = requireObject(input)[field];
|
|
229
1551
|
if (value === undefined)
|
|
230
1552
|
return;
|
|
231
|
-
if (!
|
|
1553
|
+
if (!isNumber(value) || !Number.isInteger(value) || value <= 0) {
|
|
232
1554
|
throw new Error(`${field} must be a positive integer`);
|
|
233
1555
|
}
|
|
234
1556
|
return value;
|
|
@@ -237,7 +1559,7 @@ function optionalNonNegativeIntegerField(input, field) {
|
|
|
237
1559
|
const value = requireObject(input)[field];
|
|
238
1560
|
if (value === undefined)
|
|
239
1561
|
return;
|
|
240
|
-
if (!
|
|
1562
|
+
if (!isNumber(value) || !Number.isInteger(value) || value < 0) {
|
|
241
1563
|
throw new Error(`${field} must be a non-negative integer`);
|
|
242
1564
|
}
|
|
243
1565
|
return value;
|
|
@@ -246,7 +1568,7 @@ function optionalStringArrayField(input, field) {
|
|
|
246
1568
|
const value = requireObject(input)[field];
|
|
247
1569
|
if (value === undefined)
|
|
248
1570
|
return;
|
|
249
|
-
if (!Array.isArray(value) || !value.every((item) =>
|
|
1571
|
+
if (!Array.isArray(value) || !value.every((item) => isString(item) && item.length > 0)) {
|
|
250
1572
|
throw new Error(`${field} must be an array of non-empty strings`);
|
|
251
1573
|
}
|
|
252
1574
|
return value;
|
|
@@ -259,7 +1581,7 @@ function requireObject(input) {
|
|
|
259
1581
|
return object;
|
|
260
1582
|
}
|
|
261
1583
|
function stringifyResult(value) {
|
|
262
|
-
if (
|
|
1584
|
+
if (isString(value)) {
|
|
263
1585
|
return value;
|
|
264
1586
|
}
|
|
265
1587
|
return JSON.stringify(value, null, 2);
|
|
@@ -277,10 +1599,10 @@ function toolResultForValue2(value) {
|
|
|
277
1599
|
if (media.length > 0) {
|
|
278
1600
|
const { media: _media, ...structuredContent } = object ?? {};
|
|
279
1601
|
const text = errorText ?? stringifyResult(structuredContent);
|
|
280
|
-
return new
|
|
1602
|
+
return new CallToolResult({
|
|
281
1603
|
content: [
|
|
282
|
-
|
|
283
|
-
...media.map((image) =>
|
|
1604
|
+
TextContent.make({ text }),
|
|
1605
|
+
...media.map((image) => ImageContent.make({
|
|
284
1606
|
data: new Uint8Array(Buffer.from(image.data, "base64")),
|
|
285
1607
|
mimeType: image.mimeType
|
|
286
1608
|
}))
|
|
@@ -299,460 +1621,23 @@ function mcpErrorMessage2(tool, message) {
|
|
|
299
1621
|
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.`;
|
|
300
1622
|
}
|
|
301
1623
|
function toolResult(options) {
|
|
302
|
-
return new
|
|
303
|
-
content: [
|
|
1624
|
+
return new CallToolResult({
|
|
1625
|
+
content: [TextContent.make({ text: options.text })],
|
|
304
1626
|
structuredContent: options.structuredContent,
|
|
305
1627
|
isError: options.isError
|
|
306
1628
|
});
|
|
307
1629
|
}
|
|
308
1630
|
|
|
309
|
-
// src/auth/deadbolt.ts
|
|
310
|
-
import { spawn, spawnSync } from "node:child_process";
|
|
311
|
-
import crypto from "node:crypto";
|
|
312
|
-
import fs from "node:fs";
|
|
313
|
-
import net from "node:net";
|
|
314
|
-
import os from "node:os";
|
|
315
|
-
import path from "node:path";
|
|
316
|
-
class DeadboltError extends Error {
|
|
317
|
-
name = "DeadboltError";
|
|
318
|
-
code;
|
|
319
|
-
detail;
|
|
320
|
-
constructor(code, message, detail = {}) {
|
|
321
|
-
super(message);
|
|
322
|
-
this.code = code;
|
|
323
|
-
this.detail = detail;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
var clientFileName = "deadbolt-client.json";
|
|
327
|
-
function clientFilePath(root = dataRoot()) {
|
|
328
|
-
return path.join(root, clientFileName);
|
|
329
|
-
}
|
|
330
|
-
function readClientFile(root = dataRoot()) {
|
|
331
|
-
let text;
|
|
332
|
-
try {
|
|
333
|
-
const file = clientFilePath(root);
|
|
334
|
-
const stat = fs.statSync(file);
|
|
335
|
-
if (process.platform !== "win32" && (stat.mode & 63) !== 0)
|
|
336
|
-
fs.chmodSync(file, 384);
|
|
337
|
-
text = fs.readFileSync(file, "utf8");
|
|
338
|
-
} catch {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
try {
|
|
342
|
-
const value = JSON.parse(text);
|
|
343
|
-
if (typeof value.id !== "string" || !value.id || typeof value.token !== "string" || !value.token)
|
|
344
|
-
return;
|
|
345
|
-
return {
|
|
346
|
-
version: 1,
|
|
347
|
-
id: value.id,
|
|
348
|
-
token: value.token,
|
|
349
|
-
connectedAt: typeof value.connectedAt === "string" ? value.connectedAt : ""
|
|
350
|
-
};
|
|
351
|
-
} catch {
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
function readClient(root = dataRoot()) {
|
|
356
|
-
const file = readClientFile(root);
|
|
357
|
-
return file ? { id: file.id, token: file.token } : undefined;
|
|
358
|
-
}
|
|
359
|
-
async function saveClient(client, root = dataRoot()) {
|
|
360
|
-
const value = { version: 1, id: client.id, token: client.token, connectedAt: new Date().toISOString() };
|
|
361
|
-
await writeJsonFileAtomically(clientFilePath(root), value, { dirMode: 448 });
|
|
362
|
-
}
|
|
363
|
-
function removeClient(root = dataRoot()) {
|
|
364
|
-
const file = clientFilePath(root);
|
|
365
|
-
if (!fs.existsSync(file))
|
|
366
|
-
return false;
|
|
367
|
-
fs.rmSync(file, { force: true });
|
|
368
|
-
return true;
|
|
369
|
-
}
|
|
370
|
-
function computedSocketPath(env = process.env) {
|
|
371
|
-
const nonEmpty = (name) => env[name] ? env[name] : undefined;
|
|
372
|
-
const deadboltHome = nonEmpty("DEADBOLT_HOME");
|
|
373
|
-
const suffix = deadboltHome ? `-${blake3Hex(Buffer.from(deadboltHome, "utf8")).slice(0, 8)}` : "";
|
|
374
|
-
const uid = typeof process.getuid === "function" ? process.getuid() : 0;
|
|
375
|
-
const runtime = nonEmpty("XDG_RUNTIME_DIR") ?? userRuntimeDir(uid);
|
|
376
|
-
const directory = runtime ? path.join(runtime, `deadbolt${suffix}`) : path.join(nonEmpty("TMPDIR") ?? os.tmpdir(), `deadbolt${suffix}-${uid}`);
|
|
377
|
-
return path.join(directory, "agent.sock");
|
|
378
|
-
}
|
|
379
|
-
function userRuntimeDir(uid) {
|
|
380
|
-
const directory = `/run/user/${uid}`;
|
|
381
|
-
try {
|
|
382
|
-
const stat = fs.statSync(directory);
|
|
383
|
-
return stat.isDirectory() && stat.uid === uid ? directory : undefined;
|
|
384
|
-
} catch {
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
function socketPath(options = {}) {
|
|
389
|
-
const env = options.env ?? process.env;
|
|
390
|
-
return env.OPENCODE_BROWSER_DEADBOLT_SOCKET || computedSocketPath(env);
|
|
391
|
-
}
|
|
392
|
-
var requestTimeoutMs = 15000;
|
|
393
|
-
var maxReplyBytes = 4 * 1024 * 1024;
|
|
394
|
-
function errorCode(code) {
|
|
395
|
-
const normalized = typeof code === "string" ? code.replace(/-/g, "_") : "";
|
|
396
|
-
switch (normalized) {
|
|
397
|
-
case "locked":
|
|
398
|
-
case "not_granted":
|
|
399
|
-
case "forbidden":
|
|
400
|
-
case "rate_limited":
|
|
401
|
-
case "domain_mismatch":
|
|
402
|
-
case "not_found":
|
|
403
|
-
case "choose_passkey":
|
|
404
|
-
return normalized;
|
|
405
|
-
case "not_initialized":
|
|
406
|
-
return "locked";
|
|
407
|
-
default:
|
|
408
|
-
return "failed";
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
var errorHints = {
|
|
412
|
-
locked: "Deadbolt is locked, so agent sign-ins are paused until the user unlocks it.",
|
|
413
|
-
forbidden: "Deadbolt doesn't know this browse install (its client was removed or revoked). Ask the user to run `opencode-browser deadbolt connect`.",
|
|
414
|
-
rate_limited: "Deadbolt is rate-limiting this client; wait before trying again."
|
|
415
|
-
};
|
|
416
|
-
function rawRequest(socket, request, timeoutMs = requestTimeoutMs) {
|
|
417
|
-
return new Promise((resolve, reject) => {
|
|
418
|
-
const connection = net.createConnection(socket);
|
|
419
|
-
let buffer = "";
|
|
420
|
-
let settled = false;
|
|
421
|
-
const finish = (error, value) => {
|
|
422
|
-
if (settled)
|
|
423
|
-
return;
|
|
424
|
-
settled = true;
|
|
425
|
-
clearTimeout(timer);
|
|
426
|
-
connection.destroy();
|
|
427
|
-
if (error)
|
|
428
|
-
reject(error);
|
|
429
|
-
else
|
|
430
|
-
resolve(value);
|
|
431
|
-
};
|
|
432
|
-
const timer = setTimeout(() => finish(new DeadboltError("unavailable", `Deadbolt did not answer ${String(request.cmd)} within ${timeoutMs} ms`)), timeoutMs);
|
|
433
|
-
connection.setEncoding("utf8");
|
|
434
|
-
connection.on("connect", () => connection.write(`${JSON.stringify(request)}
|
|
435
|
-
`));
|
|
436
|
-
connection.on("error", (cause) => {
|
|
437
|
-
const missing = cause.code === "ENOENT" || cause.code === "ECONNREFUSED";
|
|
438
|
-
finish(new DeadboltError("unavailable", missing ? "Deadbolt isn't running (no agent socket). Ask the user to start or unlock Deadbolt." : `Could not reach Deadbolt: ${cause.message}`));
|
|
439
|
-
});
|
|
440
|
-
connection.on("data", (chunk) => {
|
|
441
|
-
buffer += chunk;
|
|
442
|
-
if (buffer.length > maxReplyBytes)
|
|
443
|
-
return finish(new DeadboltError("failed", "Deadbolt's reply was too large"));
|
|
444
|
-
let newline;
|
|
445
|
-
while ((newline = buffer.indexOf(`
|
|
446
|
-
`)) !== -1) {
|
|
447
|
-
const line = buffer.slice(0, newline).trim();
|
|
448
|
-
buffer = buffer.slice(newline + 1);
|
|
449
|
-
if (!line)
|
|
450
|
-
continue;
|
|
451
|
-
let message;
|
|
452
|
-
try {
|
|
453
|
-
message = JSON.parse(line);
|
|
454
|
-
} catch {
|
|
455
|
-
return finish(new DeadboltError("failed", "Deadbolt sent a reply that isn't JSON"));
|
|
456
|
-
}
|
|
457
|
-
if (message.type === "ok")
|
|
458
|
-
return finish(undefined, message.reply ?? {});
|
|
459
|
-
if (message.type === "error") {
|
|
460
|
-
const code = errorCode(message.code);
|
|
461
|
-
const text = typeof message.message === "string" ? message.message : String(message.code);
|
|
462
|
-
const detail = message.grant ?? {};
|
|
463
|
-
const choices = passkeyList(message.choices ?? message.passkeys);
|
|
464
|
-
return finish(new DeadboltError(code, errorHints[code] ? `${text.replace(/[\s.]*$/, ".")} ${errorHints[code]}` : text, {
|
|
465
|
-
...typeof detail.site === "string" ? { site: detail.site } : {},
|
|
466
|
-
...typeof detail.login === "string" ? { login: detail.login } : {},
|
|
467
|
-
...choices.length > 0 ? { choices } : {}
|
|
468
|
-
}));
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
connection.on("end", () => finish(new DeadboltError("failed", "Deadbolt closed the connection without a reply")));
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
var str = (value) => typeof value === "string" ? value : undefined;
|
|
476
|
-
function passkeyList(value) {
|
|
477
|
-
if (!Array.isArray(value))
|
|
478
|
-
return [];
|
|
479
|
-
return value.filter((entry) => entry !== null && typeof entry === "object").map((entry) => {
|
|
480
|
-
const username = str(entry.username);
|
|
481
|
-
const displayName = str(entry.display_name) ?? str(entry.displayName);
|
|
482
|
-
return { ref: entry.ref ?? entry.login, ...username ? { username } : {}, ...displayName ? { displayName } : {}, granted: entry.granted !== false };
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
function toLogin(raw) {
|
|
486
|
-
const signIn = raw.sign_in;
|
|
487
|
-
const fields = Array.isArray(raw.fields) ? raw.fields.filter((field) => typeof field === "string") : undefined;
|
|
488
|
-
const username = str(raw.username);
|
|
489
|
-
return {
|
|
490
|
-
ref: raw.ref ?? raw.login,
|
|
491
|
-
title: str(raw.title) ?? "",
|
|
492
|
-
...username ? { username } : {},
|
|
493
|
-
hasPassword: raw.has_password === true,
|
|
494
|
-
hasTotp: raw.has_totp === true || raw.has_otp === true,
|
|
495
|
-
hasPasskey: raw.has_passkey === true,
|
|
496
|
-
granted: fields !== undefined && fields.length > 0 || raw.passkeys === true,
|
|
497
|
-
passkeys: raw.passkeys === true,
|
|
498
|
-
...fields ? { fields } : {},
|
|
499
|
-
...signIn && typeof signIn.provider === "string" ? { signIn: { provider: signIn.provider, ...str(signIn.account) ? { account: str(signIn.account) } : {} } } : {}
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
function connect(options = {}) {
|
|
503
|
-
const client = options.client ?? readClient(options.root);
|
|
504
|
-
if (!client) {
|
|
505
|
-
throw new DeadboltError("not_connected", "browse isn't connected to Deadbolt. Ask the user to run `opencode-browser deadbolt connect` and to allow the logins agents may use with `deadbolt agents allow <site>`.");
|
|
506
|
-
}
|
|
507
|
-
const socket = options.socket ?? socketPath();
|
|
508
|
-
let protocol;
|
|
509
|
-
const version = async () => {
|
|
510
|
-
if (protocol === undefined) {
|
|
511
|
-
const status = await rawRequest(socket, { v: 0, cmd: "status" });
|
|
512
|
-
protocol = typeof status.protocol === "number" ? status.protocol : 0;
|
|
513
|
-
}
|
|
514
|
-
return protocol;
|
|
515
|
-
};
|
|
516
|
-
const send = async (cmd, fields) => rawRequest(socket, { v: await version(), cmd, client: { id: client.id, token: client.token }, ...fields });
|
|
517
|
-
const site = async (origin) => {
|
|
518
|
-
const reply = await send("agent-logins", { origin });
|
|
519
|
-
const raw = (Array.isArray(reply.logins) ? reply.logins : []).filter((login) => login !== null && typeof login === "object");
|
|
520
|
-
const logins = raw.map(toLogin);
|
|
521
|
-
let passkeys = passkeyList(reply.passkeys);
|
|
522
|
-
if (!Array.isArray(reply.passkeys)) {
|
|
523
|
-
passkeys = logins.filter((login) => login.hasPasskey).map((login) => ({ ref: login.ref, ...login.username ? { username: login.username } : {}, granted: login.passkeys }));
|
|
524
|
-
}
|
|
525
|
-
return { logins, passkeys };
|
|
526
|
-
};
|
|
527
|
-
return {
|
|
528
|
-
socket,
|
|
529
|
-
client,
|
|
530
|
-
status: async () => {
|
|
531
|
-
const status = await rawRequest(socket, { v: 0, cmd: "status" });
|
|
532
|
-
protocol = typeof status.protocol === "number" ? status.protocol : 0;
|
|
533
|
-
return { protocol, unlocked: status.unlocked === true, ...str(status.version) ? { version: str(status.version) } : {} };
|
|
534
|
-
},
|
|
535
|
-
logins: async (origin) => (await site(origin)).logins,
|
|
536
|
-
site: (origin) => site(origin),
|
|
537
|
-
fill: async (origin, login, want) => {
|
|
538
|
-
const reply = await send("agent-fill", { origin, login: login.ref, want: [...want] });
|
|
539
|
-
const values = reply.values ?? reply;
|
|
540
|
-
return {
|
|
541
|
-
...str(values.username) !== undefined ? { username: str(values.username) } : {},
|
|
542
|
-
...str(values.password) !== undefined ? { password: str(values.password) } : {},
|
|
543
|
-
...str(values.totp) !== undefined ? { totp: str(values.totp) } : {}
|
|
544
|
-
};
|
|
545
|
-
},
|
|
546
|
-
passkeyGet: async (request) => {
|
|
547
|
-
const reply = await send("agent-passkey-get", {
|
|
548
|
-
origin: request.origin,
|
|
549
|
-
...request.rpId ? { rp_id: request.rpId } : {},
|
|
550
|
-
challenge: request.challenge,
|
|
551
|
-
allow_credentials: [...request.allowCredentials],
|
|
552
|
-
user_verification: request.userVerification,
|
|
553
|
-
...request.login !== undefined ? { login: request.login } : {}
|
|
554
|
-
});
|
|
555
|
-
if (reply.reply === "choose-passkey") {
|
|
556
|
-
throw new DeadboltError("choose_passkey", "Several passkeys could sign in here; name one by its username.", { choices: passkeyList(reply.choices ?? reply.passkeys) });
|
|
557
|
-
}
|
|
558
|
-
const credentialId = str(reply.credential_id);
|
|
559
|
-
const clientDataJson = str(reply.client_data_json);
|
|
560
|
-
const authenticatorData = str(reply.authenticator_data);
|
|
561
|
-
const signature = str(reply.signature);
|
|
562
|
-
if (!credentialId || !clientDataJson || !authenticatorData || !signature)
|
|
563
|
-
throw new DeadboltError("failed", "Deadbolt's passkey assertion is incomplete");
|
|
564
|
-
return { credentialId, clientDataJson, authenticatorData, signature, ...str(reply.user_handle) ? { userHandle: str(reply.user_handle) } : {} };
|
|
565
|
-
}
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
var deadboltNamePrefix = "deadbolt:";
|
|
569
|
-
function parseDeadboltName(name) {
|
|
570
|
-
if (!name.startsWith(deadboltNamePrefix))
|
|
571
|
-
return;
|
|
572
|
-
const rest = name.slice(deadboltNamePrefix.length).trim();
|
|
573
|
-
const origin = /^https?:\/\/[^/]+/i.exec(rest);
|
|
574
|
-
const site = origin ? origin[0] : rest.split("/")[0];
|
|
575
|
-
const username = rest.slice(site.length + 1);
|
|
576
|
-
if (!site)
|
|
577
|
-
return;
|
|
578
|
-
return { site: site.toLowerCase(), ...username ? { username } : {} };
|
|
579
|
-
}
|
|
580
|
-
function originOnSite(origin, site) {
|
|
581
|
-
let url;
|
|
582
|
-
try {
|
|
583
|
-
url = new URL(origin);
|
|
584
|
-
} catch {
|
|
585
|
-
return false;
|
|
586
|
-
}
|
|
587
|
-
if (/^https?:\/\//i.test(site)) {
|
|
588
|
-
try {
|
|
589
|
-
return new URL(site).origin === url.origin;
|
|
590
|
-
} catch {
|
|
591
|
-
return false;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
const host = url.hostname.toLowerCase();
|
|
595
|
-
const bare = site.replace(/^\*\./, "").replace(/:\d+$/, "").toLowerCase();
|
|
596
|
-
const local = host === "localhost" || host === "127.0.0.1" || host === "[::1]" || host.endsWith(".localhost");
|
|
597
|
-
if (url.protocol !== "https:" && !(url.protocol === "http:" && local))
|
|
598
|
-
return false;
|
|
599
|
-
return host === bare || host.endsWith(`.${bare}`);
|
|
600
|
-
}
|
|
601
|
-
function pickLogin(logins, site, username, field) {
|
|
602
|
-
const granted = logins.filter((login) => login.granted && (field === undefined || login.fields === undefined || login.fields.includes(field)));
|
|
603
|
-
const candidates = username === undefined ? granted : granted.filter((login) => login.username?.toLowerCase() === username.toLowerCase());
|
|
604
|
-
if (candidates.length === 1)
|
|
605
|
-
return candidates[0];
|
|
606
|
-
if (candidates.length === 0) {
|
|
607
|
-
throw new DeadboltError("not_granted", username === undefined ? `No Deadbolt login is granted to browse for ${site}${field ? ` (${field})` : ""}. Ask the user to allow one with \`deadbolt agents allow ${site}\`.` : `No Deadbolt login for ${username} is granted to browse for ${site}${field ? ` (${field})` : ""}. Ask the user to allow it with \`deadbolt agents allow ${site} --login ${username}\`.`, { site, ...username ? { login: username } : {} });
|
|
608
|
-
}
|
|
609
|
-
throw new DeadboltError("failed", `Several Deadbolt logins are granted for ${site}; name one: deadbolt:${site}/<username> (${candidates.map((login) => login.username ?? login.title).join(", ")})`);
|
|
610
|
-
}
|
|
611
|
-
function originsFromPatterns(patterns) {
|
|
612
|
-
const origins = new Set;
|
|
613
|
-
for (const pattern of patterns) {
|
|
614
|
-
const scheme = /^(https?):\/\//i.exec(pattern)?.[1]?.toLowerCase() ?? "https";
|
|
615
|
-
const host = pattern.replace(/^https?:\/\//i, "").replace(/^\*\./, "").replace(/\/$/, "");
|
|
616
|
-
try {
|
|
617
|
-
origins.add(new URL(`${scheme}://${host}`).origin);
|
|
618
|
-
} catch {}
|
|
619
|
-
}
|
|
620
|
-
return [...origins];
|
|
621
|
-
}
|
|
622
|
-
async function listLogins(origins, connection) {
|
|
623
|
-
let deadbolt;
|
|
624
|
-
try {
|
|
625
|
-
deadbolt = connection ?? connect();
|
|
626
|
-
} catch (error) {
|
|
627
|
-
return { connected: false, logins: [], passkeys: [], error: { code: error instanceof DeadboltError ? error.code : "failed", message: error instanceof Error ? error.message : String(error) } };
|
|
628
|
-
}
|
|
629
|
-
const logins = [];
|
|
630
|
-
const passkeys = [];
|
|
631
|
-
for (const origin of origins.slice(0, 20)) {
|
|
632
|
-
try {
|
|
633
|
-
const found = await deadbolt.site(origin);
|
|
634
|
-
for (const { ref: _ref, ...login } of found.logins)
|
|
635
|
-
logins.push({ ...login, origin });
|
|
636
|
-
for (const { ref: _ref, ...passkey } of found.passkeys)
|
|
637
|
-
passkeys.push({ ...passkey, origin });
|
|
638
|
-
} catch (error) {
|
|
639
|
-
if (error instanceof DeadboltError && (error.code === "domain_mismatch" || error.code === "not_found" || error.code === "not_granted"))
|
|
640
|
-
continue;
|
|
641
|
-
return { connected: true, logins, passkeys, error: { code: error instanceof DeadboltError ? error.code : "failed", message: error instanceof Error ? error.message : String(error) } };
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
return { connected: true, logins, passkeys };
|
|
645
|
-
}
|
|
646
|
-
function pickPasskey(passkeys, username) {
|
|
647
|
-
const wanted = username.toLowerCase();
|
|
648
|
-
const granted = passkeys.filter((passkey) => passkey.granted);
|
|
649
|
-
return granted.find((passkey) => passkey.username?.toLowerCase() === wanted) ?? granted.find((passkey) => passkey.displayName?.toLowerCase() === wanted);
|
|
650
|
-
}
|
|
651
|
-
async function pair(options = {}) {
|
|
652
|
-
const command = options.command ?? (process.env.OPENCODE_BROWSER_DEADBOLT_CLI || "deadbolt");
|
|
653
|
-
const stdout = await new Promise((resolve, reject) => {
|
|
654
|
-
const child = spawn(command, ["agents", "add-client", options.name ?? "browse", "--json"], { stdio: ["inherit", "pipe", "inherit"] });
|
|
655
|
-
let output = "";
|
|
656
|
-
child.stdout.setEncoding("utf8");
|
|
657
|
-
child.stdout.on("data", (chunk) => {
|
|
658
|
-
output += chunk;
|
|
659
|
-
});
|
|
660
|
-
child.on("error", (cause) => reject(new DeadboltError("unavailable", cause.code === "ENOENT" ? `${command} isn't installed or on PATH. Install Deadbolt first.` : `Could not run ${command}: ${cause.message}`)));
|
|
661
|
-
child.on("close", (code) => code === 0 ? resolve(output) : reject(new DeadboltError("failed", `deadbolt agents add-client exited with status ${code}`)));
|
|
662
|
-
});
|
|
663
|
-
let parsed;
|
|
664
|
-
try {
|
|
665
|
-
const line = stdout.trim().split(`
|
|
666
|
-
`).filter(Boolean).at(-1) ?? "";
|
|
667
|
-
parsed = JSON.parse(line);
|
|
668
|
-
} catch {
|
|
669
|
-
throw new DeadboltError("failed", "deadbolt agents add-client --json didn't print a client");
|
|
670
|
-
}
|
|
671
|
-
const client = parsed.client ?? parsed;
|
|
672
|
-
const id = str(client.id);
|
|
673
|
-
const token = str(client.token) ?? str(parsed.token);
|
|
674
|
-
if (!id || !token)
|
|
675
|
-
throw new DeadboltError("failed", "deadbolt agents add-client --json printed no id and token");
|
|
676
|
-
await saveClient({ id, token }, options.root);
|
|
677
|
-
return { id };
|
|
678
|
-
}
|
|
679
|
-
function unpair(options = {}) {
|
|
680
|
-
const client = readClient(options.root);
|
|
681
|
-
if (!client)
|
|
682
|
-
return { removed: false, revoked: false };
|
|
683
|
-
const command = options.command ?? (process.env.OPENCODE_BROWSER_DEADBOLT_CLI || "deadbolt");
|
|
684
|
-
const result = spawnSync(command, ["agents", "remove-client", client.id], { stdio: ["inherit", "ignore", "inherit"], timeout: 120000 });
|
|
685
|
-
return { removed: removeClient(options.root), revoked: result.status === 0 };
|
|
686
|
-
}
|
|
687
|
-
function isBase64Url(value, maxLength = 8192) {
|
|
688
|
-
return typeof value === "string" && value.length <= maxLength && /^[A-Za-z0-9_-]*$/.test(value);
|
|
689
|
-
}
|
|
690
|
-
function randomName(prefix) {
|
|
691
|
-
return `${prefix}${crypto.randomBytes(12).toString("hex")}`;
|
|
692
|
-
}
|
|
693
|
-
var blake3Iv = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225];
|
|
694
|
-
var blake3Permutation = [2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12, 5, 9, 14, 15, 8];
|
|
695
|
-
function blake3Compress(cv, block, blockLength, flags) {
|
|
696
|
-
const s = new Uint32Array([...cv, blake3Iv[0], blake3Iv[1], blake3Iv[2], blake3Iv[3], 0, 0, blockLength, flags]);
|
|
697
|
-
let m = Uint32Array.from(block);
|
|
698
|
-
const rotr = (x, n) => x >>> n | x << 32 - n;
|
|
699
|
-
const g = (a, b, c, d, x, y) => {
|
|
700
|
-
s[a] = s[a] + s[b] + x;
|
|
701
|
-
s[d] = rotr(s[d] ^ s[a], 16);
|
|
702
|
-
s[c] = s[c] + s[d];
|
|
703
|
-
s[b] = rotr(s[b] ^ s[c], 12);
|
|
704
|
-
s[a] = s[a] + s[b] + y;
|
|
705
|
-
s[d] = rotr(s[d] ^ s[a], 8);
|
|
706
|
-
s[c] = s[c] + s[d];
|
|
707
|
-
s[b] = rotr(s[b] ^ s[c], 7);
|
|
708
|
-
};
|
|
709
|
-
for (let round = 0;round < 7; round++) {
|
|
710
|
-
g(0, 4, 8, 12, m[0], m[1]);
|
|
711
|
-
g(1, 5, 9, 13, m[2], m[3]);
|
|
712
|
-
g(2, 6, 10, 14, m[4], m[5]);
|
|
713
|
-
g(3, 7, 11, 15, m[6], m[7]);
|
|
714
|
-
g(0, 5, 10, 15, m[8], m[9]);
|
|
715
|
-
g(1, 6, 11, 12, m[10], m[11]);
|
|
716
|
-
g(2, 7, 8, 13, m[12], m[13]);
|
|
717
|
-
g(3, 4, 9, 14, m[14], m[15]);
|
|
718
|
-
if (round < 6)
|
|
719
|
-
m = Uint32Array.from(blake3Permutation, (index) => m[index]);
|
|
720
|
-
}
|
|
721
|
-
return Array.from({ length: 8 }, (_, index) => (s[index] ^ s[index + 8]) >>> 0);
|
|
722
|
-
}
|
|
723
|
-
function blake3Hex(input) {
|
|
724
|
-
if (input.length > 1024)
|
|
725
|
-
throw new Error("blake3Hex handles inputs up to 1024 bytes (DEADBOLT_HOME is longer: set OPENCODE_BROWSER_DEADBOLT_SOCKET)");
|
|
726
|
-
const blocks = Math.max(1, Math.ceil(input.length / 64));
|
|
727
|
-
let cv = [...blake3Iv];
|
|
728
|
-
for (let index = 0;index < blocks; index++) {
|
|
729
|
-
const bytes = new Uint8Array(64);
|
|
730
|
-
const chunk = input.subarray(index * 64, index * 64 + 64);
|
|
731
|
-
bytes.set(chunk);
|
|
732
|
-
const words = new Uint32Array(16);
|
|
733
|
-
const view = new DataView(bytes.buffer);
|
|
734
|
-
for (let word = 0;word < 16; word++)
|
|
735
|
-
words[word] = view.getUint32(word * 4, true);
|
|
736
|
-
const flags = (index === 0 ? 1 : 0) | (index === blocks - 1 ? 2 | 8 : 0);
|
|
737
|
-
cv = blake3Compress(cv, words, chunk.length, flags);
|
|
738
|
-
}
|
|
739
|
-
const out = Buffer.alloc(32);
|
|
740
|
-
cv.forEach((word, index) => out.writeUInt32LE(word, index * 4));
|
|
741
|
-
return out.toString("hex");
|
|
742
|
-
}
|
|
743
|
-
|
|
744
1631
|
// src/auth/site-secrets.ts
|
|
745
|
-
import
|
|
746
|
-
import fs3 from "node:fs/promises";
|
|
747
|
-
import path3 from "node:path";
|
|
748
|
-
import { Effect as Effect3, Schema as Schema2 } from "effect";
|
|
749
|
-
|
|
750
|
-
// src/auth/profile.ts
|
|
751
|
-
import { Effect as Effect2, Schema, Semaphore } from "effect";
|
|
752
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
1632
|
+
import crypto from "node:crypto";
|
|
753
1633
|
import fs2 from "node:fs/promises";
|
|
754
1634
|
import path2 from "node:path";
|
|
755
1635
|
|
|
1636
|
+
// src/auth/profile.ts
|
|
1637
|
+
import { spawn } from "node:child_process";
|
|
1638
|
+
import fs from "node:fs/promises";
|
|
1639
|
+
import path from "node:path";
|
|
1640
|
+
|
|
756
1641
|
// src/update/child-process.ts
|
|
757
1642
|
async function terminateChildProcess(options) {
|
|
758
1643
|
const isExited = options.isExited ?? (() => options.child.exitCode !== null || options.child.signalCode !== null);
|
|
@@ -784,7 +1669,6 @@ function signalChildProcess(child, signal) {
|
|
|
784
1669
|
}
|
|
785
1670
|
|
|
786
1671
|
// src/network-capture/redaction.ts
|
|
787
|
-
import { Predicate as Predicate2 } from "effect";
|
|
788
1672
|
var secretNamePattern = /auth(?:orization)?|cookie|credential|csrf|xsrf|token|secret|session|password|passwd|pwd|passcode|otp|(?:^|[-_.])code(?:$|[-_.])|(?:api|access|refresh)[-_.]?key|signature|(?:^|[-_.])sig(?:$|[-_.])/i;
|
|
789
1673
|
var oneTimeFieldPattern = /pass(?:word|wd|code|phrase)|(?:^|[-_.])pwd(?:$|[-_.])|otp|totp|(?:^|[-_.])(?:mfa_?|2fa_?|verification_?|auth_?)?code(?:$|[-_.])|(?:^|[-_.])pin(?:$|[-_.])/i;
|
|
790
1674
|
var referencePattern = String.raw`BC_(?:SECRET|REDACTED)_\d+`;
|
|
@@ -891,7 +1775,7 @@ class SecretCollector {
|
|
|
891
1775
|
return redactKnownValue(value, this.redactionSlots());
|
|
892
1776
|
}
|
|
893
1777
|
redactExactValue(value, minimumLength) {
|
|
894
|
-
if (!
|
|
1778
|
+
if (!isString(value) && !isNumber(value) && !isBoolean(value))
|
|
895
1779
|
return value;
|
|
896
1780
|
const serialized = String(value);
|
|
897
1781
|
if (serialized.length < minimumLength)
|
|
@@ -982,7 +1866,7 @@ class SecretCollector {
|
|
|
982
1866
|
if (Array.isArray(value)) {
|
|
983
1867
|
return value.map((item, index) => this.protectJson(item, location, [...path, String(index)], inSecret));
|
|
984
1868
|
}
|
|
985
|
-
if (
|
|
1869
|
+
if (isObject(value)) {
|
|
986
1870
|
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
987
1871
|
key,
|
|
988
1872
|
this.protectJson(item, location, [...path, key], inSecret || secretNamePattern.test(key))
|
|
@@ -1176,15 +2060,15 @@ function redactKnownValues(text, slots) {
|
|
|
1176
2060
|
return [...slots].sort((left, right) => right.value.length - left.value.length).reduce((output, slot) => replaceOutsideReferences(output, slot.value, `\${${slot.ref}}`), text);
|
|
1177
2061
|
}
|
|
1178
2062
|
function redactKnownValue(value, slots) {
|
|
1179
|
-
if (
|
|
2063
|
+
if (isString(value))
|
|
1180
2064
|
return redactKnownValues(value, slots);
|
|
1181
|
-
if (
|
|
2065
|
+
if (isNumber(value) || isBoolean(value)) {
|
|
1182
2066
|
const slot = slots.find((candidate) => candidate.value === String(value));
|
|
1183
2067
|
return slot ? `\${${slot.ref}}` : value;
|
|
1184
2068
|
}
|
|
1185
2069
|
if (Array.isArray(value))
|
|
1186
2070
|
return value.map((item) => redactKnownValue(item, slots));
|
|
1187
|
-
if (!
|
|
2071
|
+
if (!isObject(value))
|
|
1188
2072
|
return value;
|
|
1189
2073
|
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
1190
2074
|
key,
|
|
@@ -1194,7 +2078,7 @@ function redactKnownValue(value, slots) {
|
|
|
1194
2078
|
function redactSecretValue(value) {
|
|
1195
2079
|
if (Array.isArray(value))
|
|
1196
2080
|
return value.map(redactSecretValue);
|
|
1197
|
-
if (
|
|
2081
|
+
if (isObject(value)) {
|
|
1198
2082
|
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, redactSecretValue(item)]));
|
|
1199
2083
|
}
|
|
1200
2084
|
return value === null || value === "" ? value : "[REDACTED]";
|
|
@@ -1219,26 +2103,26 @@ function jwtExpiration(value) {
|
|
|
1219
2103
|
return;
|
|
1220
2104
|
try {
|
|
1221
2105
|
const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
|
|
1222
|
-
return
|
|
2106
|
+
return isNumber(payload.exp) ? new Date(payload.exp * 1000).toISOString() : undefined;
|
|
1223
2107
|
} catch {
|
|
1224
2108
|
return;
|
|
1225
2109
|
}
|
|
1226
2110
|
}
|
|
1227
2111
|
|
|
1228
2112
|
// src/auth/profile.ts
|
|
1229
|
-
var StoredCredentialSlot =
|
|
1230
|
-
ref:
|
|
1231
|
-
value:
|
|
1232
|
-
sources:
|
|
1233
|
-
expiresAt:
|
|
2113
|
+
var StoredCredentialSlot = Struct({
|
|
2114
|
+
ref: String3.check(isPattern(/^BC_SECRET_[1-9][0-9]*$/)),
|
|
2115
|
+
value: String3,
|
|
2116
|
+
sources: ArraySchema(String3),
|
|
2117
|
+
expiresAt: optionalKey(String3)
|
|
1234
2118
|
});
|
|
1235
|
-
var StoredAuthProfile =
|
|
1236
|
-
version:
|
|
1237
|
-
name:
|
|
1238
|
-
createdAt:
|
|
1239
|
-
updatedAt:
|
|
1240
|
-
slots:
|
|
1241
|
-
}).check(
|
|
2119
|
+
var StoredAuthProfile = Struct({
|
|
2120
|
+
version: Literal(1),
|
|
2121
|
+
name: String3,
|
|
2122
|
+
createdAt: String3,
|
|
2123
|
+
updatedAt: String3,
|
|
2124
|
+
slots: ArraySchema(StoredCredentialSlot)
|
|
2125
|
+
}).check(makeFilter((profile) => {
|
|
1242
2126
|
const refs = profile.slots.map((slot) => slot.ref);
|
|
1243
2127
|
if (new Set(refs).size !== refs.length)
|
|
1244
2128
|
return "Auth profile refs must be unique";
|
|
@@ -1246,46 +2130,46 @@ var StoredAuthProfile = Schema.Struct({
|
|
|
1246
2130
|
return new Set(sources).size === sources.length ? undefined : "Auth profile sources must be unique";
|
|
1247
2131
|
}));
|
|
1248
2132
|
|
|
1249
|
-
class AuthProfileError extends
|
|
1250
|
-
message:
|
|
1251
|
-
operation:
|
|
1252
|
-
reason:
|
|
1253
|
-
cause:
|
|
2133
|
+
class AuthProfileError extends TaggedError2()("AuthProfile.Error", {
|
|
2134
|
+
message: String3,
|
|
2135
|
+
operation: String3,
|
|
2136
|
+
reason: Literals(["invalid-name", "not-found", "read-failed", "invalid-json", "invalid-profile", "write-failed", "run-failed"]),
|
|
2137
|
+
cause: optionalKey(Defect())
|
|
1254
2138
|
}) {
|
|
1255
2139
|
}
|
|
1256
|
-
var defaultBaseDir = () =>
|
|
1257
|
-
var writeLock =
|
|
2140
|
+
var defaultBaseDir = () => path.join(dataRoot(), "secrets");
|
|
2141
|
+
var writeLock = makeUnsafe(1);
|
|
1258
2142
|
var profileLockTimeoutMs = 30000;
|
|
1259
2143
|
var staleProfileLockMs = 60000;
|
|
1260
2144
|
var maximumRunOutputBytes = 1e7;
|
|
1261
2145
|
var maximumTimeoutMs = 2147483647;
|
|
1262
|
-
var read =
|
|
2146
|
+
var read = fn("AuthProfile.read")(function* (name, options = {}) {
|
|
1263
2147
|
const filePath = yield* profilePath(options.baseDir ?? defaultBaseDir(), name);
|
|
1264
|
-
const text = yield*
|
|
1265
|
-
try: () =>
|
|
2148
|
+
const text = yield* tryPromise({
|
|
2149
|
+
try: () => fs.readFile(filePath, "utf8"),
|
|
1266
2150
|
catch: (cause) => isNodeError(cause) && cause.code === "ENOENT" ? new AuthProfileError({ message: `Auth profile not found: ${name}`, operation: "read", reason: "not-found", cause }) : new AuthProfileError({ message: `Could not read auth profile: ${name}`, operation: "read", reason: "read-failed", cause })
|
|
1267
2151
|
});
|
|
1268
|
-
return yield*
|
|
2152
|
+
return yield* decodeUnknownEffect2(StoredAuthProfile)(yield* try_({
|
|
1269
2153
|
try: () => JSON.parse(text),
|
|
1270
2154
|
catch: (cause) => new AuthProfileError({ message: `Auth profile is not valid JSON: ${name}`, operation: "read", reason: "invalid-json", cause })
|
|
1271
|
-
})).pipe(
|
|
2155
|
+
})).pipe(mapError((cause) => cause instanceof AuthProfileError ? cause : new AuthProfileError({ message: `Auth profile has an invalid shape: ${name}`, operation: "read", reason: "invalid-profile", cause })));
|
|
1272
2156
|
});
|
|
1273
|
-
var readOptional =
|
|
1274
|
-
return yield* read(name, options).pipe(
|
|
2157
|
+
var readOptional = fn("AuthProfile.readOptional")(function* (name, options = {}) {
|
|
2158
|
+
return yield* read(name, options).pipe(catchIf((error) => error.reason === "not-found", () => succeed6(undefined)));
|
|
1275
2159
|
});
|
|
1276
2160
|
function withLock(name, options, effect) {
|
|
1277
2161
|
const baseDir = options.baseDir ?? defaultBaseDir();
|
|
1278
|
-
const acquire =
|
|
2162
|
+
const acquire = gen(function* () {
|
|
1279
2163
|
const filePath = yield* profilePath(baseDir, name);
|
|
1280
2164
|
const lockPath = `${filePath}.lock`;
|
|
1281
|
-
yield*
|
|
2165
|
+
yield* tryPromise({
|
|
1282
2166
|
try: async () => {
|
|
1283
|
-
await
|
|
1284
|
-
await
|
|
2167
|
+
await fs.mkdir(baseDir, { recursive: true, mode: 448 });
|
|
2168
|
+
await fs.chmod(baseDir, 448);
|
|
1285
2169
|
const deadline = Date.now() + profileLockTimeoutMs;
|
|
1286
2170
|
while (true) {
|
|
1287
2171
|
try {
|
|
1288
|
-
const handle = await
|
|
2172
|
+
const handle = await fs.open(lockPath, "wx", 384);
|
|
1289
2173
|
let written = false;
|
|
1290
2174
|
try {
|
|
1291
2175
|
await handle.writeFile(`${process.pid}
|
|
@@ -1294,17 +2178,17 @@ function withLock(name, options, effect) {
|
|
|
1294
2178
|
} finally {
|
|
1295
2179
|
await handle.close();
|
|
1296
2180
|
if (!written)
|
|
1297
|
-
await
|
|
2181
|
+
await fs.unlink(lockPath).catch(() => {});
|
|
1298
2182
|
}
|
|
1299
2183
|
return;
|
|
1300
2184
|
} catch (cause) {
|
|
1301
2185
|
if (!isNodeError(cause) || cause.code !== "EEXIST")
|
|
1302
2186
|
throw cause;
|
|
1303
|
-
const stat = await
|
|
2187
|
+
const stat = await fs.stat(lockPath).catch(() => {
|
|
1304
2188
|
return;
|
|
1305
2189
|
});
|
|
1306
2190
|
if (stat && Date.now() - stat.mtimeMs > staleProfileLockMs) {
|
|
1307
|
-
await
|
|
2191
|
+
await fs.unlink(lockPath).catch(() => {});
|
|
1308
2192
|
continue;
|
|
1309
2193
|
}
|
|
1310
2194
|
if (Date.now() >= deadline)
|
|
@@ -1317,12 +2201,12 @@ function withLock(name, options, effect) {
|
|
|
1317
2201
|
});
|
|
1318
2202
|
return lockPath;
|
|
1319
2203
|
});
|
|
1320
|
-
return
|
|
1321
|
-
try: () =>
|
|
2204
|
+
return acquireUseRelease(acquire, () => effect, (lockPath) => tryPromise({
|
|
2205
|
+
try: () => fs.unlink(lockPath).catch(() => {}).then(() => {}),
|
|
1322
2206
|
catch: (cause) => new AuthProfileError({ message: `Could not release auth profile lock: ${name}`, operation: "lock", reason: "write-failed", cause })
|
|
1323
2207
|
}));
|
|
1324
2208
|
}
|
|
1325
|
-
var writeProfile =
|
|
2209
|
+
var writeProfile = fnUntraced(function* (options) {
|
|
1326
2210
|
const baseDir = options.baseDir ?? defaultBaseDir();
|
|
1327
2211
|
const filePath = yield* profilePath(baseDir, options.name);
|
|
1328
2212
|
const existing = yield* readOptional(options.name, { baseDir });
|
|
@@ -1339,22 +2223,22 @@ var writeProfile = Effect2.fnUntraced(function* (options) {
|
|
|
1339
2223
|
...slot.expiresAt ? { expiresAt: slot.expiresAt } : {}
|
|
1340
2224
|
}))
|
|
1341
2225
|
};
|
|
1342
|
-
yield*
|
|
2226
|
+
yield* decodeUnknownEffect2(StoredAuthProfile)(profile).pipe(mapError((cause) => new AuthProfileError({ message: `Auth profile has an invalid shape: ${options.name}`, operation: "write", reason: "invalid-profile", cause })));
|
|
1343
2227
|
if (existing && sameSlots(existing.slots, profile.slots))
|
|
1344
2228
|
return summary(existing);
|
|
1345
|
-
yield*
|
|
2229
|
+
yield* tryPromise({
|
|
1346
2230
|
try: () => writeJsonFileAtomically(filePath, profile, { dirMode: 448 }),
|
|
1347
2231
|
catch: (cause) => new AuthProfileError({ message: `Could not write auth profile: ${options.name}`, operation: "write", reason: "write-failed", cause })
|
|
1348
2232
|
});
|
|
1349
2233
|
return summary(profile);
|
|
1350
2234
|
});
|
|
1351
|
-
var write =
|
|
2235
|
+
var write = fn("AuthProfile.write")(function* (options) {
|
|
1352
2236
|
return yield* writeLock.withPermit(writeProfile(options));
|
|
1353
2237
|
});
|
|
1354
|
-
var status =
|
|
2238
|
+
var status = fn("AuthProfile.status")(function* (name, options = {}) {
|
|
1355
2239
|
return summary(yield* read(name, options));
|
|
1356
2240
|
});
|
|
1357
|
-
var run =
|
|
2241
|
+
var run = fn("AuthProfile.run")(function* (options) {
|
|
1358
2242
|
if (!options.command.trim()) {
|
|
1359
2243
|
return yield* new AuthProfileError({ message: "Auth command must not be empty", operation: "run", reason: "run-failed" });
|
|
1360
2244
|
}
|
|
@@ -1376,7 +2260,7 @@ var run = Effect2.fn("AuthProfile.run")(function* (options) {
|
|
|
1376
2260
|
timeoutMs,
|
|
1377
2261
|
maxOutputBytes: maxOutputBytes + maxSecretBytes,
|
|
1378
2262
|
env: Object.fromEntries(profile.slots.map((slot) => [slot.ref, slot.value]))
|
|
1379
|
-
}).pipe(
|
|
2263
|
+
}).pipe(mapError((cause) => new AuthProfileError({ message: `Could not run command with auth profile ${options.name}`, operation: "run", reason: "run-failed", cause })));
|
|
1380
2264
|
const stdout = redactOutput(result.stdout, profile.slots, maxOutputBytes);
|
|
1381
2265
|
const stderr = redactOutput(result.stderr, profile.slots, maxOutputBytes);
|
|
1382
2266
|
return {
|
|
@@ -1405,7 +2289,7 @@ function summary(profile) {
|
|
|
1405
2289
|
}
|
|
1406
2290
|
var profileNamePattern = /^[a-z0-9][a-z0-9._-]{0,63}$/i;
|
|
1407
2291
|
function profilePath(baseDir, name) {
|
|
1408
|
-
return profileNamePattern.test(name) ?
|
|
2292
|
+
return profileNamePattern.test(name) ? succeed6(path.join(baseDir, `${name}.json`)) : fail4(new AuthProfileError({ message: `Invalid auth profile name: ${name}`, operation: "path", reason: "invalid-name" }));
|
|
1409
2293
|
}
|
|
1410
2294
|
function sameSlots(left, right) {
|
|
1411
2295
|
return JSON.stringify(left) === JSON.stringify(right);
|
|
@@ -1437,8 +2321,8 @@ function redactOutput(text, slots, maxBytes) {
|
|
|
1437
2321
|
};
|
|
1438
2322
|
}
|
|
1439
2323
|
function runChild(options) {
|
|
1440
|
-
return
|
|
1441
|
-
const child =
|
|
2324
|
+
return callback2((resume) => {
|
|
2325
|
+
const child = spawn(options.command, [...options.args], {
|
|
1442
2326
|
...options.cwd ? { cwd: options.cwd } : {},
|
|
1443
2327
|
env: childEnvironment(options.env),
|
|
1444
2328
|
detached: process.platform !== "win32",
|
|
@@ -1483,7 +2367,7 @@ function runChild(options) {
|
|
|
1483
2367
|
if (settled)
|
|
1484
2368
|
return;
|
|
1485
2369
|
settled = true;
|
|
1486
|
-
resume(
|
|
2370
|
+
resume(fail4(cause));
|
|
1487
2371
|
});
|
|
1488
2372
|
child.once("close", (code, signal) => {
|
|
1489
2373
|
clearTimeout(timeout);
|
|
@@ -1492,7 +2376,7 @@ function runChild(options) {
|
|
|
1492
2376
|
if (settled)
|
|
1493
2377
|
return;
|
|
1494
2378
|
settled = true;
|
|
1495
|
-
resume(
|
|
2379
|
+
resume(succeed6({
|
|
1496
2380
|
exitCode: code ?? 1,
|
|
1497
2381
|
signal,
|
|
1498
2382
|
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
@@ -1501,7 +2385,7 @@ function runChild(options) {
|
|
|
1501
2385
|
stderrTruncated
|
|
1502
2386
|
}));
|
|
1503
2387
|
});
|
|
1504
|
-
return
|
|
2388
|
+
return promise(() => terminateChildProcess({ child, exit: closePromise, graceMs: 1000, isExited: () => closed }));
|
|
1505
2389
|
});
|
|
1506
2390
|
}
|
|
1507
2391
|
function childEnvironment(profile) {
|
|
@@ -1511,7 +2395,7 @@ function childEnvironment(profile) {
|
|
|
1511
2395
|
|
|
1512
2396
|
// src/auth/domain-policy.ts
|
|
1513
2397
|
import dns from "node:dns/promises";
|
|
1514
|
-
import
|
|
2398
|
+
import net from "node:net";
|
|
1515
2399
|
|
|
1516
2400
|
class OriginPatternError extends Error {
|
|
1517
2401
|
name = "OriginPatternError";
|
|
@@ -1547,7 +2431,7 @@ function parseOriginPattern(raw) {
|
|
|
1547
2431
|
throw new OriginPatternError(`Origin pattern ${JSON.stringify(raw)} must be a host or origin`);
|
|
1548
2432
|
}
|
|
1549
2433
|
const host = unbracket(parsed.hostname.toLowerCase());
|
|
1550
|
-
if (wildcard &&
|
|
2434
|
+
if (wildcard && net.isIP(host))
|
|
1551
2435
|
throw new OriginPatternError(`Origin pattern ${JSON.stringify(raw)}: wildcards don't apply to IP addresses`);
|
|
1552
2436
|
if (wildcard && !host.includes("."))
|
|
1553
2437
|
throw new OriginPatternError(`Origin pattern ${JSON.stringify(raw)}: "*." needs a domain with a dot, like *.example.com`);
|
|
@@ -1592,14 +2476,14 @@ var privateIpv4Ranges = [
|
|
|
1592
2476
|
];
|
|
1593
2477
|
function isPrivateAddress(address) {
|
|
1594
2478
|
const ip = unbracket(address.toLowerCase()).replace(/%.*$/, "");
|
|
1595
|
-
if (
|
|
2479
|
+
if (net.isIPv4(ip)) {
|
|
1596
2480
|
const value = ipv4ToNumber(ip);
|
|
1597
2481
|
return privateIpv4Ranges.some(([base, bits]) => {
|
|
1598
2482
|
const mask = bits === 0 ? 0 : 4294967295 << 32 - bits >>> 0;
|
|
1599
2483
|
return (value & mask) >>> 0 === (ipv4ToNumber(base) & mask) >>> 0;
|
|
1600
2484
|
});
|
|
1601
2485
|
}
|
|
1602
|
-
if (
|
|
2486
|
+
if (net.isIPv6(ip)) {
|
|
1603
2487
|
if (ip === "::" || ip === "::1")
|
|
1604
2488
|
return true;
|
|
1605
2489
|
const mapped = /^(?:0*:)*:?ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(ip) ?? /^::(\d+\.\d+\.\d+\.\d+)$/.exec(ip);
|
|
@@ -1625,7 +2509,7 @@ function isLocalhostName(host) {
|
|
|
1625
2509
|
}
|
|
1626
2510
|
function isPrivateHost(host) {
|
|
1627
2511
|
const bare = unbracket(host.toLowerCase());
|
|
1628
|
-
return isLocalhostName(bare) ||
|
|
2512
|
+
return isLocalhostName(bare) || net.isIP(bare) !== 0 && isPrivateAddress(bare);
|
|
1629
2513
|
}
|
|
1630
2514
|
function defaultPort(protocol) {
|
|
1631
2515
|
return protocol === "https:" ? "443" : "80";
|
|
@@ -1676,7 +2560,7 @@ function checkUrl(rawUrl, rules, options = {}) {
|
|
|
1676
2560
|
}
|
|
1677
2561
|
async function resolvesToPrivateAddress(host, timeoutMs = 2000) {
|
|
1678
2562
|
const bare = unbracket(host);
|
|
1679
|
-
if (
|
|
2563
|
+
if (net.isIP(bare) || isLocalhostName(bare))
|
|
1680
2564
|
return isPrivateHost(bare) ? bare : undefined;
|
|
1681
2565
|
let timer;
|
|
1682
2566
|
try {
|
|
@@ -1706,45 +2590,45 @@ async function checkNavigationUrl(rawUrl, rules) {
|
|
|
1706
2590
|
}
|
|
1707
2591
|
|
|
1708
2592
|
// src/auth/site-secrets.ts
|
|
1709
|
-
var StoredSiteSecret =
|
|
1710
|
-
version:
|
|
1711
|
-
name:
|
|
1712
|
-
kind:
|
|
1713
|
-
value:
|
|
1714
|
-
allowedOrigins:
|
|
1715
|
-
createdAt:
|
|
1716
|
-
updatedAt:
|
|
2593
|
+
var StoredSiteSecret = Struct({
|
|
2594
|
+
version: Literal(1),
|
|
2595
|
+
name: String3,
|
|
2596
|
+
kind: Literals(["password", "totp"]),
|
|
2597
|
+
value: String3,
|
|
2598
|
+
allowedOrigins: ArraySchema(String3),
|
|
2599
|
+
createdAt: String3,
|
|
2600
|
+
updatedAt: String3
|
|
1717
2601
|
});
|
|
1718
2602
|
|
|
1719
|
-
class SiteSecretError extends
|
|
1720
|
-
message:
|
|
1721
|
-
reason:
|
|
1722
|
-
cause:
|
|
2603
|
+
class SiteSecretError extends TaggedError2()("SiteSecret.Error", {
|
|
2604
|
+
message: String3,
|
|
2605
|
+
reason: Literals(["invalid-name", "invalid-origins", "invalid-value", "not-found", "read-failed", "write-failed"]),
|
|
2606
|
+
cause: optionalKey(Defect())
|
|
1723
2607
|
}) {
|
|
1724
2608
|
}
|
|
1725
|
-
var defaultSiteSecretsDir = () =>
|
|
2609
|
+
var defaultSiteSecretsDir = () => path2.join(dataRoot(), "site-secrets");
|
|
1726
2610
|
function secretPath(baseDir, name) {
|
|
1727
|
-
return profileNamePattern.test(name) ?
|
|
2611
|
+
return profileNamePattern.test(name) ? succeed6(path2.join(baseDir, `${name}.json`)) : fail4(new SiteSecretError({ message: `Invalid secret name: ${name} (letters, digits, ".", "_" and "-", up to 64)`, reason: "invalid-name" }));
|
|
1728
2612
|
}
|
|
1729
2613
|
function summary2(secret) {
|
|
1730
2614
|
return { name: secret.name, kind: secret.kind, allowedOrigins: [...secret.allowedOrigins], createdAt: secret.createdAt, updatedAt: secret.updatedAt };
|
|
1731
2615
|
}
|
|
1732
|
-
var readSecret =
|
|
2616
|
+
var readSecret = fn("SiteSecrets.read")(function* (name, options = {}) {
|
|
1733
2617
|
const filePath = yield* secretPath(options.baseDir ?? defaultSiteSecretsDir(), name);
|
|
1734
|
-
const text = yield*
|
|
1735
|
-
try: () =>
|
|
2618
|
+
const text = yield* tryPromise({
|
|
2619
|
+
try: () => fs2.readFile(filePath, "utf8"),
|
|
1736
2620
|
catch: (cause) => isNodeError(cause) && cause.code === "ENOENT" ? new SiteSecretError({ message: `Secret not found: ${name}. Ask the user to add it with \`opencode-browser secrets add ${name} --origin <origin>\`.`, reason: "not-found" }) : new SiteSecretError({ message: `Could not read secret ${name}`, reason: "read-failed", cause })
|
|
1737
2621
|
});
|
|
1738
|
-
return yield*
|
|
1739
|
-
try: () =>
|
|
2622
|
+
return yield* try_({
|
|
2623
|
+
try: () => decodeUnknownSync(StoredSiteSecret)(JSON.parse(text)),
|
|
1740
2624
|
catch: (cause) => new SiteSecretError({ message: `Secret ${name} is not a valid secret file`, reason: "read-failed", cause })
|
|
1741
2625
|
});
|
|
1742
2626
|
});
|
|
1743
|
-
var addSecret =
|
|
2627
|
+
var addSecret = fn("SiteSecrets.add")(function* (options) {
|
|
1744
2628
|
const baseDir = options.baseDir ?? defaultSiteSecretsDir();
|
|
1745
2629
|
const filePath = yield* secretPath(baseDir, options.name);
|
|
1746
2630
|
const kind = options.kind ?? "password";
|
|
1747
|
-
const allowedOrigins = yield*
|
|
2631
|
+
const allowedOrigins = yield* try_({
|
|
1748
2632
|
try: () => normalizeOriginPatterns(options.allowedOrigins),
|
|
1749
2633
|
catch: (cause) => new SiteSecretError({ message: cause instanceof Error ? cause.message : "Invalid origins", reason: "invalid-origins", cause })
|
|
1750
2634
|
});
|
|
@@ -1755,43 +2639,43 @@ var addSecret = Effect3.fn("SiteSecrets.add")(function* (options) {
|
|
|
1755
2639
|
if (!value)
|
|
1756
2640
|
return yield* new SiteSecretError({ message: "The secret value is empty", reason: "invalid-value" });
|
|
1757
2641
|
if (kind === "totp")
|
|
1758
|
-
yield*
|
|
2642
|
+
yield* try_({
|
|
1759
2643
|
try: () => totpCode(value),
|
|
1760
2644
|
catch: (cause) => new SiteSecretError({ message: `Not a TOTP seed or otpauth:// URI: ${cause instanceof Error ? cause.message : "invalid"}`, reason: "invalid-value", cause })
|
|
1761
2645
|
});
|
|
1762
|
-
const write =
|
|
1763
|
-
const existing = yield* readSecret(options.name, { baseDir }).pipe(
|
|
2646
|
+
const write = gen(function* () {
|
|
2647
|
+
const existing = yield* readSecret(options.name, { baseDir }).pipe(catchIf((error) => error.reason === "not-found", () => succeed6(undefined)));
|
|
1764
2648
|
const now = new Date().toISOString();
|
|
1765
2649
|
const secret = { version: 1, name: options.name, kind, value, allowedOrigins: [...allowedOrigins], createdAt: existing?.createdAt ?? now, updatedAt: now };
|
|
1766
|
-
yield*
|
|
2650
|
+
yield* tryPromise({
|
|
1767
2651
|
try: () => writeJsonFileAtomically(filePath, secret, { dirMode: 448 }),
|
|
1768
2652
|
catch: (cause) => new SiteSecretError({ message: `Could not write secret ${options.name}`, reason: "write-failed", cause })
|
|
1769
2653
|
});
|
|
1770
2654
|
return summary2(secret);
|
|
1771
2655
|
});
|
|
1772
|
-
return yield* withLock(options.name, { baseDir }, write).pipe(
|
|
2656
|
+
return yield* withLock(options.name, { baseDir }, write).pipe(mapError((error) => error instanceof SiteSecretError ? error : new SiteSecretError({ message: error.message, reason: "write-failed", cause: error })));
|
|
1773
2657
|
});
|
|
1774
|
-
var listSecrets =
|
|
2658
|
+
var listSecrets = fn("SiteSecrets.list")(function* (options = {}) {
|
|
1775
2659
|
const baseDir = options.baseDir ?? defaultSiteSecretsDir();
|
|
1776
|
-
const names = yield*
|
|
1777
|
-
try: () =>
|
|
2660
|
+
const names = yield* tryPromise({
|
|
2661
|
+
try: () => fs2.readdir(baseDir).catch((cause) => isNodeError(cause) && cause.code === "ENOENT" ? [] : Promise.reject(cause)),
|
|
1778
2662
|
catch: (cause) => new SiteSecretError({ message: "Could not list secrets", reason: "read-failed", cause })
|
|
1779
2663
|
});
|
|
1780
2664
|
const secrets = [];
|
|
1781
2665
|
for (const file of names.filter((entry) => entry.endsWith(".json")).sort()) {
|
|
1782
|
-
const secret = yield* readSecret(file.slice(0, -".json".length), { baseDir }).pipe(
|
|
2666
|
+
const secret = yield* readSecret(file.slice(0, -".json".length), { baseDir }).pipe(option2);
|
|
1783
2667
|
if (secret._tag === "Some")
|
|
1784
2668
|
secrets.push(summary2(secret.value));
|
|
1785
2669
|
}
|
|
1786
2670
|
return secrets;
|
|
1787
2671
|
});
|
|
1788
|
-
var removeSecret =
|
|
2672
|
+
var removeSecret = fn("SiteSecrets.remove")(function* (name, options = {}) {
|
|
1789
2673
|
const baseDir = options.baseDir ?? defaultSiteSecretsDir();
|
|
1790
2674
|
const filePath = yield* secretPath(baseDir, name);
|
|
1791
|
-
return yield* withLock(name, { baseDir },
|
|
1792
|
-
try: () =>
|
|
2675
|
+
return yield* withLock(name, { baseDir }, tryPromise({
|
|
2676
|
+
try: () => fs2.rm(filePath).then(() => true, (cause) => isNodeError(cause) && cause.code === "ENOENT" ? false : Promise.reject(cause)),
|
|
1793
2677
|
catch: (cause) => new SiteSecretError({ message: `Could not remove secret ${name}`, reason: "write-failed", cause })
|
|
1794
|
-
})).pipe(
|
|
2678
|
+
})).pipe(mapError((error) => error instanceof SiteSecretError ? error : new SiteSecretError({ message: error.message, reason: "write-failed", cause: error })));
|
|
1795
2679
|
});
|
|
1796
2680
|
function base32Decode(input) {
|
|
1797
2681
|
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
@@ -1831,7 +2715,7 @@ function totpCode(seed, now = Date.now()) {
|
|
|
1831
2715
|
const { key, digits, period, algorithm } = totpParameters(seed);
|
|
1832
2716
|
const counter = Buffer.alloc(8);
|
|
1833
2717
|
counter.writeBigUInt64BE(BigInt(Math.floor(now / 1000 / period)));
|
|
1834
|
-
const hmac =
|
|
2718
|
+
const hmac = crypto.createHmac(algorithm, key).update(counter).digest();
|
|
1835
2719
|
const offset = hmac[hmac.length - 1] & 15;
|
|
1836
2720
|
const binary = (hmac.readUInt32BE(offset) & 2147483647) % 10 ** digits;
|
|
1837
2721
|
return String(binary).padStart(digits, "0");
|
|
@@ -1840,4 +2724,4 @@ function secretText(secret) {
|
|
|
1840
2724
|
return secret.kind === "totp" ? totpCode(secret.value) : secret.value;
|
|
1841
2725
|
}
|
|
1842
2726
|
|
|
1843
|
-
export { settingKeys, settingSpecs, securityVariables, SettingsInputError, parseSettingChanges, settingsFromExtension, settingsToExtension, describeSettings, describeChanges, formatSettings, browsersNote2, mcpUpdateNote2, objectSchema, emptyInputSchema, sessionSchemaProperty, sessionAliasSchemaProperty, sessionOnlyInputSchema, ensureSessionExists, parseExecuteArguments, parseAdoptArguments, requiredStringField, optionalStringField, optionalBooleanField, optionalPositiveIntegerField, optionalStringArrayField, requireObject, toolResultForValue2, mcpErrorMessage2, toolResult,
|
|
2727
|
+
export { makeUnsafe, make, isStreamSchema, getStreamSchemas, ClientAbort, ServerClient, make2, exitSchema, isWrapper, make3, 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, 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, browsersNote2, mcpUpdateNote2, objectSchema, emptyInputSchema, sessionSchemaProperty, sessionAliasSchemaProperty, sessionOnlyInputSchema, ensureSessionExists, parseExecuteArguments, parseAdoptArguments, requiredStringField, optionalStringField, optionalBooleanField, optionalPositiveIntegerField, optionalStringArrayField, requireObject, toolResultForValue2, mcpErrorMessage2, toolResult, terminateChildProcess, SecretCollector, looksLikeTokenSegment, AuthProfileError, read, readOptional, withLock, write, status, run, OriginPatternError, parseOriginPatterns, normalizeOriginPatterns, isPrivateAddress, explicitlyAllowsHost, checkUrl, checkNavigationUrl, readSecret, addSecret, listSecrets, removeSecret, secretText };
|