@dual-os/github-api 0.0.0-stage → 6.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/LICENSE +4 -0
  2. package/Runner.js +5771 -0
  3. package/Runner.js.map +63 -0
  4. package/bundle-inventory.json +1 -0
  5. package/dist/_virtual/_rolldown/runtime.js +10 -0
  6. package/dist/_virtual/_rolldown/runtime.js.map +9 -0
  7. package/dist/auth.d.ts +37 -0
  8. package/dist/auth.d.ts.map +1 -0
  9. package/dist/auth.js +19 -0
  10. package/dist/auth.js.map +9 -0
  11. package/dist/generated/http.d.ts +81 -0
  12. package/dist/generated/http.d.ts.map +1 -0
  13. package/dist/generated/http.js +64 -0
  14. package/dist/generated/http.js.map +9 -0
  15. package/dist/generated/operations.d.ts +20998 -0
  16. package/dist/generated/operations.d.ts.map +1 -0
  17. package/dist/generated/operations.js +4932 -0
  18. package/dist/generated/operations.js.map +9 -0
  19. package/dist/generated/plugin.d.ts +6318 -0
  20. package/dist/generated/plugin.d.ts.map +1 -0
  21. package/dist/generated/plugin.js +10521 -0
  22. package/dist/generated/plugin.js.map +10 -0
  23. package/dist/triggers.d.ts +127 -0
  24. package/dist/triggers.d.ts.map +1 -0
  25. package/dist/triggers.js +17 -0
  26. package/dist/triggers.js.map +9 -0
  27. package/dual-plugin.json +1 -0
  28. package/licenses/@dual-os_sdk@0.8.1/LICENSE +4 -0
  29. package/licenses/@effect_platform-node-shared@4.1.2/LICENSE +21 -0
  30. package/licenses/@effect_platform-node@4.1.2/LICENSE +21 -0
  31. package/licenses/effect@4.1.2/LICENSE +21 -0
  32. package/package.json +1 -6
  33. package/plugin-2jdfj02n.js +18 -0
  34. package/plugin-2jdfj02n.js.map +10 -0
  35. package/plugin-3mpmm6hc.js +160 -0
  36. package/plugin-3mpmm6hc.js.map +10 -0
  37. package/plugin-ahctqzvj.js +25272 -0
  38. package/plugin-ahctqzvj.js.map +10 -0
  39. package/plugin-gajxsj3f.js +19140 -0
  40. package/plugin-gajxsj3f.js.map +159 -0
  41. package/plugin-t4j28rxn.js +62 -0
  42. package/plugin-t4j28rxn.js.map +10 -0
  43. package/plugin-yzj02c6j.js +1372 -0
  44. package/plugin-yzj02c6j.js.map +18 -0
  45. package/plugin.json +49 -0
  46. package/README.md +0 -3
@@ -0,0 +1,1372 @@
1
+ // @bun
2
+ import {
3
+ __exportAll2
4
+ } from "./plugin-2jdfj02n.js";
5
+ import {
6
+ dual,
7
+ identity,
8
+ pipe,
9
+ flow,
10
+ isString,
11
+ isObject,
12
+ hasProperty,
13
+ equals,
14
+ PipeInspectableProto,
15
+ Number2,
16
+ mapInput,
17
+ none,
18
+ some,
19
+ isNone,
20
+ match2,
21
+ getOrElse,
22
+ orElse,
23
+ fromNullishOr,
24
+ fromUndefinedOr,
25
+ getOrNull,
26
+ getOrUndefined,
27
+ liftThrowable,
28
+ map,
29
+ flatMap,
30
+ filter,
31
+ liftPredicate,
32
+ Reference,
33
+ succeed,
34
+ fail,
35
+ failVoid,
36
+ fromOption,
37
+ try_,
38
+ isSuccess,
39
+ mapError,
40
+ match3,
41
+ all,
42
+ fromEntries,
43
+ toEntries,
44
+ has,
45
+ map2,
46
+ ensure,
47
+ append,
48
+ isArray,
49
+ isReadonlyArrayNonEmpty,
50
+ getUnsafe2,
51
+ headNonEmpty,
52
+ findFirst,
53
+ sort,
54
+ zip,
55
+ contains,
56
+ empty2,
57
+ map3,
58
+ flatMap2,
59
+ filterMap,
60
+ filter2,
61
+ reduce,
62
+ fromNullishOr2,
63
+ every,
64
+ join,
65
+ millis,
66
+ TaggedClass,
67
+ TaggedError,
68
+ increment,
69
+ toLowerCase,
70
+ replace,
71
+ trim,
72
+ slice,
73
+ isEmpty,
74
+ isNonEmpty,
75
+ split,
76
+ startsWith,
77
+ endsWith,
78
+ match4,
79
+ replaceAll,
80
+ isEffect,
81
+ forEach,
82
+ promise,
83
+ succeed4,
84
+ suspend,
85
+ sync,
86
+ void_2,
87
+ gen,
88
+ fail5,
89
+ withFiber,
90
+ fromResult,
91
+ fromOption2,
92
+ flatMap3,
93
+ result,
94
+ map4,
95
+ mapError2,
96
+ orDie,
97
+ ignore,
98
+ serviceOption,
99
+ provideService,
100
+ scoped,
101
+ acquireRelease,
102
+ fnUntraced,
103
+ fn,
104
+ encode2,
105
+ encode3,
106
+ decode,
107
+ makeZoned,
108
+ make3,
109
+ toUtc,
110
+ toDateUtc,
111
+ toEpochMillis,
112
+ formatIso,
113
+ formatIsoOffset,
114
+ empty3,
115
+ empty4,
116
+ InvalidValue,
117
+ compose2,
118
+ transform,
119
+ transformEffect,
120
+ is,
121
+ decodeUnknownEffect,
122
+ decodeOption,
123
+ encodeEffect,
124
+ isSchema,
125
+ optionalKey,
126
+ optional,
127
+ toType,
128
+ Literal,
129
+ Unknown,
130
+ String3,
131
+ Boolean2,
132
+ Struct,
133
+ Record,
134
+ StructWithRest,
135
+ ArraySchema,
136
+ Literals,
137
+ NullOr,
138
+ decodeTo,
139
+ Int,
140
+ Natural,
141
+ NonEmptyString,
142
+ Defect,
143
+ fromJsonString,
144
+ Uint8ArrayFromBase64,
145
+ TaggedError2,
146
+ toEquivalence,
147
+ Json,
148
+ make5,
149
+ get2,
150
+ set,
151
+ update,
152
+ fromEffect,
153
+ fromIterable2,
154
+ paginate,
155
+ unwrap2,
156
+ mapEffect,
157
+ flatMap4,
158
+ filterMap2,
159
+ decodeText,
160
+ runCollect,
161
+ runHead,
162
+ value2,
163
+ discriminatorsExhaustive,
164
+ empty6,
165
+ HttpClientError,
166
+ InvalidUrlError,
167
+ fromString,
168
+ makeWith,
169
+ post,
170
+ put,
171
+ del,
172
+ setMethod,
173
+ setHeader,
174
+ setHeaders,
175
+ basicAuth,
176
+ bearerToken,
177
+ setUrl,
178
+ updateUrl,
179
+ setUrlParam,
180
+ setBody,
181
+ bodyUint8Array,
182
+ bodyJsonUnsafe,
183
+ bodyFormDataRecord,
184
+ HttpClient,
185
+ transformResponse,
186
+ filterStatusOk,
187
+ mapRequest,
188
+ mapRequestEffect,
189
+ RequestInit,
190
+ __exportAll3,
191
+ ActionHandlerError,
192
+ fromHttpClientFailure,
193
+ AuthMethod_exports,
194
+ Schema,
195
+ Key3,
196
+ Event3,
197
+ commandSchema,
198
+ Service2,
199
+ File3,
200
+ read,
201
+ write,
202
+ Plugin_exports
203
+ } from "./plugin-gajxsj3f.js";
204
+
205
+ // ../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/internal/random.js
206
+ var Random = /* @__PURE__ */ Reference("effect/Random", {
207
+ defaultValue: () => ({
208
+ nextIntUnsafe() {
209
+ return Math.floor(Math.random() * (Number.MAX_SAFE_INTEGER - Number.MIN_SAFE_INTEGER + 1)) + Number.MIN_SAFE_INTEGER;
210
+ },
211
+ nextDoubleUnsafe() {
212
+ return Math.random();
213
+ }
214
+ })
215
+ });
216
+
217
+ // ../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Random.js
218
+ var Random2 = Random;
219
+ var randomWith = (f) => withFiber((fiber) => succeed4(f(fiber.getRef(Random2))));
220
+ var nextInt = /* @__PURE__ */ randomWith((r) => r.nextIntUnsafe());
221
+
222
+ // ../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Boolean.js
223
+ var Boolean = globalThis.Boolean;
224
+ var match = /* @__PURE__ */ dual(2, (value, options) => value ? options.onTrue() : options.onFalse());
225
+
226
+ // ../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/Ref.js
227
+ var TypeId = "~effect/Ref";
228
+ var RefProto = {
229
+ [TypeId]: {
230
+ _A: identity
231
+ },
232
+ ...PipeInspectableProto,
233
+ toJSON() {
234
+ return {
235
+ _id: "Ref",
236
+ ref: this.ref
237
+ };
238
+ }
239
+ };
240
+ var makeUnsafe = (value) => {
241
+ const self = Object.create(RefProto);
242
+ self.ref = make5(value);
243
+ return self;
244
+ };
245
+ var make = (value) => sync(() => makeUnsafe(value));
246
+ var get = (self) => sync(() => self.ref.current);
247
+ var set2 = /* @__PURE__ */ dual(2, (self, value) => sync(() => set(self.ref, value)));
248
+ var getAndUpdate = /* @__PURE__ */ dual(2, (self, f) => sync(() => {
249
+ const current = self.ref.current;
250
+ self.ref.current = f(current);
251
+ return current;
252
+ }));
253
+
254
+ // ../../../../node_modules/.bun/effect@4.1.2/node_modules/effect/dist/encoding/Sse.js
255
+ var SseErrorTypeId = "~effect/encoding/Sse/SseError";
256
+
257
+ class EventTooLarge extends (/* @__PURE__ */ TaggedError("EventTooLarge")) {
258
+ get message() {
259
+ return `Pending SSE event exceeded the maximum size of ${this.maxEventSize}`;
260
+ }
261
+ }
262
+
263
+ class SseError extends (/* @__PURE__ */ TaggedError("SseError")) {
264
+ [SseErrorTypeId] = SseErrorTypeId;
265
+ get message() {
266
+ return this.reason.message;
267
+ }
268
+ }
269
+ var defaultMaxEventSize = 10 * 1024 * 1024;
270
+ function makeParser(onParse, options) {
271
+ const maxEventSize = options?.maxEventSize ?? defaultMaxEventSize;
272
+ const dispatchEmptyNamedEvents = options?.dispatchEmptyNamedEvents === true;
273
+ let isFirstChunk;
274
+ let pending;
275
+ let pendingLength;
276
+ let discardTrailingNewline;
277
+ let generation = 0;
278
+ let lastEventId;
279
+ let eventName;
280
+ let data;
281
+ reset();
282
+ return {
283
+ feed,
284
+ reset
285
+ };
286
+ function reset() {
287
+ generation++;
288
+ isFirstChunk = true;
289
+ pending = [];
290
+ pendingLength = 0;
291
+ discardTrailingNewline = false;
292
+ lastEventId = undefined;
293
+ eventName = undefined;
294
+ data = "";
295
+ }
296
+ function feed(chunk) {
297
+ if (chunk.length === 0)
298
+ return;
299
+ if (isFirstChunk && chunk.startsWith(BOM)) {
300
+ chunk = chunk.slice(BOM.length);
301
+ }
302
+ isFirstChunk = false;
303
+ const length = chunk.length;
304
+ const currentGeneration = generation;
305
+ let position = 0;
306
+ while (position < length) {
307
+ if (discardTrailingNewline) {
308
+ discardTrailingNewline = false;
309
+ if (chunk.charCodeAt(position) === LF) {
310
+ ++position;
311
+ continue;
312
+ }
313
+ }
314
+ let lineEnd = position;
315
+ while (lineEnd < length) {
316
+ const code = chunk.charCodeAt(lineEnd);
317
+ if (code === CR || code === LF)
318
+ break;
319
+ ++lineEnd;
320
+ }
321
+ if (lineEnd === length) {
322
+ pending.push(chunk.slice(position));
323
+ pendingLength += length - position;
324
+ break;
325
+ }
326
+ discardTrailingNewline = chunk.charCodeAt(lineEnd) === CR;
327
+ let line = chunk.slice(position, lineEnd);
328
+ if (pending.length > 0) {
329
+ pending.push(line);
330
+ line = pending.join("");
331
+ pending = [];
332
+ pendingLength = 0;
333
+ }
334
+ parseLine(line);
335
+ if (generation !== currentGeneration) {
336
+ return;
337
+ }
338
+ position = lineEnd + 1;
339
+ }
340
+ if (pendingLength + data.length > maxEventSize) {
341
+ const error = new SseError({
342
+ reason: new EventTooLarge({
343
+ maxEventSize
344
+ })
345
+ });
346
+ reset();
347
+ return error;
348
+ }
349
+ }
350
+ function parseLine(line) {
351
+ if (line.length === 0) {
352
+ const named = eventName !== undefined && eventName !== "";
353
+ const event = eventName || "message";
354
+ const eventData = data;
355
+ eventName = undefined;
356
+ data = "";
357
+ if (eventData.length > 0 || dispatchEmptyNamedEvents && named) {
358
+ onParse({
359
+ _tag: "Event",
360
+ id: lastEventId,
361
+ event,
362
+ data: eventData.slice(0, -1)
363
+ });
364
+ }
365
+ return;
366
+ }
367
+ const colon = line.indexOf(":");
368
+ let field = line;
369
+ let value = "";
370
+ if (colon >= 0) {
371
+ field = line.slice(0, colon);
372
+ value = line.slice(line.charCodeAt(colon + 1) === SPACE ? colon + 2 : colon + 1);
373
+ }
374
+ if (field === "data") {
375
+ data += value + `
376
+ `;
377
+ } else if (field === "event") {
378
+ eventName = value;
379
+ } else if (field === "id" && !value.includes("\x00")) {
380
+ lastEventId = value;
381
+ } else if (field === "retry" && /^\d+$/.test(value)) {
382
+ const retry = parseInt(value, 10);
383
+ onParse(new Retry({
384
+ duration: millis(retry),
385
+ lastEventId
386
+ }));
387
+ }
388
+ }
389
+ }
390
+ var BOM = "\uFEFF";
391
+ var LF = 10;
392
+ var CR = 13;
393
+ var SPACE = 32;
394
+ var RetryTypeId = "~effect/encoding/Sse/Retry";
395
+
396
+ class Retry extends (/* @__PURE__ */ TaggedClass("Retry")) {
397
+ [RetryTypeId] = RetryTypeId;
398
+ static is(u) {
399
+ return hasProperty(u, RetryTypeId);
400
+ }
401
+ static filter(u) {
402
+ return Retry.is(u) ? succeed(u) : fail(u);
403
+ }
404
+ }
405
+
406
+ // ../../../../node_modules/.bun/@dual-os+sdk@0.8.1+a827849ded09603e/node_modules/@dual-os/sdk/dist/AgentChannelConformance.js
407
+ var Command = commandSchema(Json);
408
+ var Fixture = Struct({
409
+ activate: Command,
410
+ channelId: Key3,
411
+ connectionId: optionalKey(Key3),
412
+ deactivate: Command,
413
+ definitionSettings: Json,
414
+ deliver: Command,
415
+ deploymentSettings: Json,
416
+ receive: Command
417
+ });
418
+ var ConformanceError = class extends TaggedError2()("AgentChannelConformanceError", {
419
+ command: Literals([
420
+ "activate",
421
+ "deactivate",
422
+ "receive",
423
+ "deliver"
424
+ ]),
425
+ rule: Literals([
426
+ "command_kind",
427
+ "stable_result",
428
+ "stable_events",
429
+ "boundary_rejection"
430
+ ])
431
+ }) {
432
+ };
433
+ var run = fn("AgentChannelConformance.run")(function* (input) {
434
+ const fixture = yield* decodeUnknownEffect(Fixture)(input, { onExcessProperty: "error" });
435
+ const runtime = yield* Service2;
436
+ const definition = yield* runtime.getAgentChannel({ channelId: fixture.channelId });
437
+ const { activate, receive, deliver, deactivate, ...config } = fixture;
438
+ const { connectionId: _connectionId, ...withoutConnection } = config;
439
+ const probes = [
440
+ {
441
+ code: "invalid_input",
442
+ input: {
443
+ ...config,
444
+ channelId: "",
445
+ command: activate
446
+ }
447
+ },
448
+ {
449
+ input: {
450
+ ...config,
451
+ channelId: "conformance/missing/channel",
452
+ command: activate
453
+ },
454
+ code: "not_found"
455
+ },
456
+ {
457
+ code: "invalid_input",
458
+ input: {
459
+ ...config,
460
+ command: {
461
+ ...activate,
462
+ operationKey: ""
463
+ }
464
+ }
465
+ },
466
+ {
467
+ code: "invalid_input",
468
+ input: {
469
+ ...config,
470
+ agent: { id: "synthetic-authority" },
471
+ command: activate
472
+ }
473
+ },
474
+ {
475
+ code: "invalid_auth",
476
+ input: definition.authMethods.length === 0 ? {
477
+ ...config,
478
+ command: activate,
479
+ connectionId: "unexpected"
480
+ } : {
481
+ ...withoutConnection,
482
+ command: activate
483
+ }
484
+ }
485
+ ];
486
+ for (const probe of probes) {
487
+ const outcome = yield* suspend(() => runtime.executeAgentChannel(probe.input)).pipe(result);
488
+ if (outcome._tag !== "Failure" || outcome.failure.code !== probe.code)
489
+ return yield* new ConformanceError({
490
+ command: "activate",
491
+ rule: "boundary_rejection"
492
+ });
493
+ }
494
+ const commands = [
495
+ ["activate", activate],
496
+ ["receive", receive],
497
+ ["deliver", deliver],
498
+ ["deactivate", deactivate]
499
+ ];
500
+ for (const [kind, command] of commands)
501
+ if (command.kind !== kind)
502
+ return yield* new ConformanceError({
503
+ command: kind,
504
+ rule: "command_kind"
505
+ });
506
+ const activated = yield* acquireRelease(runtime.executeAgentChannel({
507
+ ...config,
508
+ command: activate
509
+ }), (result2) => runtime.executeAgentChannel({
510
+ ...config,
511
+ command: {
512
+ ...deactivate,
513
+ ...result2.kind === "activate" ? {
514
+ installationKey: result2.installationKey,
515
+ state: result2.state
516
+ } : {}
517
+ }
518
+ }).pipe(orDie));
519
+ for (const [kind, command] of commands) {
520
+ const first = kind === "activate" ? activated : yield* runtime.executeAgentChannel({
521
+ ...config,
522
+ command
523
+ });
524
+ if (kind === "deliver" && definition.features.deliveryMode === "at-most-once")
525
+ continue;
526
+ const second = yield* runtime.executeAgentChannel({
527
+ ...config,
528
+ command
529
+ });
530
+ const firstJson = yield* decodeUnknownEffect(Json)(first);
531
+ const secondJson = yield* decodeUnknownEffect(Json)(second);
532
+ if (!toEquivalence(Json)(firstJson, secondJson))
533
+ return yield* new ConformanceError({
534
+ command: kind,
535
+ rule: "stable_result"
536
+ });
537
+ if (kind === "receive") {
538
+ const nextReceipt = yield* runtime.executeAgentChannel({
539
+ ...config,
540
+ command: {
541
+ ...command,
542
+ operationKey: `${command.operationKey.slice(0, 500)}:replay`
543
+ }
544
+ });
545
+ if (first.kind !== "receive" || nextReceipt.kind !== "receive" || !toEquivalence(ArraySchema(Event3))(first.events, nextReceipt.events))
546
+ return yield* new ConformanceError({
547
+ command: kind,
548
+ rule: "stable_events"
549
+ });
550
+ }
551
+ }
552
+ }, scoped);
553
+
554
+ // ../../../../node_modules/.bun/@dual-os+sdk@0.8.1+a827849ded09603e/node_modules/@dual-os/sdk/dist/Mcp.js
555
+ var McpError = class extends TaggedError2()("McpError", {
556
+ cause: optional(Defect()),
557
+ message: String3
558
+ }) {
559
+ };
560
+ var protocolVersion = "2025-06-18";
561
+ var Implementation = Struct({
562
+ name: String3,
563
+ title: optionalKey(String3),
564
+ version: String3
565
+ });
566
+ var Tool = Struct({
567
+ annotations: optionalKey(Struct({ title: optionalKey(String3) })),
568
+ description: optionalKey(String3),
569
+ inputSchema: Record(String3, Unknown),
570
+ name: String3,
571
+ outputSchema: optionalKey(Record(String3, Unknown)),
572
+ title: optionalKey(String3)
573
+ });
574
+ var ListToolsResult = Struct({
575
+ nextCursor: optionalKey(String3),
576
+ tools: ArraySchema(Tool)
577
+ });
578
+ var ContentBlock = StructWithRest(Struct({
579
+ text: optionalKey(String3),
580
+ type: String3
581
+ }), [Record(String3, Unknown)]);
582
+ var CallToolResult = Struct({
583
+ content: ArraySchema(ContentBlock),
584
+ isError: optionalKey(Boolean2),
585
+ structuredContent: optionalKey(Unknown)
586
+ });
587
+ var InitializeResult = Struct({
588
+ protocolVersion: String3,
589
+ serverInfo: Implementation
590
+ });
591
+ var Message = Struct({
592
+ error: optionalKey(Struct({ message: String3 })),
593
+ id: optionalKey(Unknown),
594
+ result: optionalKey(Unknown)
595
+ });
596
+ var responseTo = fnUntraced(function* (id, method, response) {
597
+ const payloads = match(pipe(response.headers["content-type"] ?? "", startsWith("text/event-stream")), {
598
+ onFalse: () => fromEffect(response.text),
599
+ onTrue: () => unwrap2(sync(() => {
600
+ const events = make5(empty2());
601
+ const parser = makeParser((event) => {
602
+ if (event._tag === "Event")
603
+ update(events, append(event.data));
604
+ });
605
+ return pipe(response.stream, decodeText(), mapEffect((chunk) => {
606
+ const error = parser.feed(chunk);
607
+ if (error !== undefined)
608
+ return fail5(McpError.make({
609
+ cause: error,
610
+ message: error.message
611
+ }));
612
+ const ready = get2(events);
613
+ set(events, empty2());
614
+ return succeed4(ready);
615
+ }), flatMap4(fromIterable2));
616
+ }))
617
+ });
618
+ const found = yield* pipe(payloads, filterMap2((payload) => fromOption(filter(decodeOption(fromJsonString(Message))(payload), (message) => message.id === id && (message.result !== undefined || message.error !== undefined)), () => payload)), runHead);
619
+ return yield* fromOption2(found, () => McpError.make({ message: `${method} got no response` }));
620
+ });
621
+ var connect = fn("Mcp.connect")(function* (client, endpoint, headers) {
622
+ const checked = filterStatusOk(client);
623
+ const post2 = fnUntraced(function* (version, session, body) {
624
+ return yield* checked.execute(pipe(post(endpoint), setHeaders({
625
+ ...headers,
626
+ accept: "application/json, text/event-stream",
627
+ "mcp-protocol-version": version,
628
+ ...match2(session, {
629
+ onNone: () => ({}),
630
+ onSome: (id) => ({ "mcp-session-id": id })
631
+ })
632
+ }), bodyJsonUnsafe({
633
+ jsonrpc: "2.0",
634
+ ...body
635
+ })));
636
+ });
637
+ const call = fnUntraced(function* (version, session, id, method, params) {
638
+ const response = yield* post2(version, session, {
639
+ id,
640
+ method,
641
+ params
642
+ });
643
+ const message = yield* responseTo(id, method, response);
644
+ if (message.error !== undefined)
645
+ return yield* McpError.make({ message: `${method}: ${message.error.message}` });
646
+ return {
647
+ result: message.result,
648
+ session: orElse(fromNullishOr(response.headers["mcp-session-id"]), () => session)
649
+ };
650
+ });
651
+ const negotiatedVersion = yield* make(protocolVersion);
652
+ const initialized = yield* acquireRelease(call(protocolVersion, none(), 0, "initialize", {
653
+ capabilities: {},
654
+ clientInfo: {
655
+ name: "dual",
656
+ version: "1"
657
+ },
658
+ protocolVersion
659
+ }), (opened) => match2(opened.session, {
660
+ onNone: () => void_2,
661
+ onSome: (id) => flatMap3(get(negotiatedVersion), (version) => ignore(client.execute(pipe(del(endpoint), setHeaders({
662
+ ...headers,
663
+ "mcp-protocol-version": version,
664
+ "mcp-session-id": id
665
+ })))))
666
+ }));
667
+ const server = yield* decodeUnknownEffect(InitializeResult)(initialized.result);
668
+ if (server.protocolVersion !== protocolVersion && server.protocolVersion !== "2025-03-26")
669
+ return yield* McpError.make({ message: `Unsupported MCP protocol version ${server.protocolVersion}` });
670
+ yield* set2(negotiatedVersion, server.protocolVersion);
671
+ yield* post2(server.protocolVersion, initialized.session, { method: "notifications/initialized" });
672
+ const ids = yield* make(1);
673
+ return {
674
+ request: fn("Mcp.request")(function* (method, params) {
675
+ return (yield* call(server.protocolVersion, initialized.session, yield* getAndUpdate(ids, increment), method, params)).result;
676
+ }),
677
+ server: server.serverInfo
678
+ };
679
+ });
680
+ var listTools = fn("Mcp.listTools")(function* (client, endpoint, headers) {
681
+ const session = yield* connect(client, endpoint, headers);
682
+ const tools = yield* runCollect(paginate({}, fnUntraced(function* (params) {
683
+ const page = yield* decodeUnknownEffect(ListToolsResult)(yield* session.request("tools/list", params));
684
+ return [page.tools, map(fromUndefinedOr(page.nextCursor), (cursor) => ({ cursor }))];
685
+ })));
686
+ return {
687
+ server: session.server,
688
+ tools
689
+ };
690
+ }, scoped);
691
+
692
+ // ../../../../node_modules/.bun/@dual-os+sdk@0.8.1+a827849ded09603e/node_modules/@dual-os/sdk/dist/Http.js
693
+ var Http_exports = /* @__PURE__ */ __exportAll3({
694
+ Base64FromFile: () => Base64FromFile2,
695
+ Base64UrlFromFile: () => Base64UrlFromFile2,
696
+ DataUriFromFile: () => DataUriFromFile2,
697
+ DateTimeFromRfc2822: () => DateTimeFromRfc28222,
698
+ DateTimeFromUnixSeconds: () => DateTimeFromUnixSeconds2,
699
+ File: () => File2,
700
+ FileFromBase64: () => FileFromBase642,
701
+ FileFromBase64Url: () => FileFromBase64Url2,
702
+ FileFromDataUri: () => FileFromDataUri2,
703
+ Http: () => Http_exports,
704
+ Rfc2822FromDateTime: () => Rfc2822FromDateTime2,
705
+ UnixSecondsFromDateTime: () => UnixSecondsFromDateTime2,
706
+ continuation: () => continuation2,
707
+ decoded: () => decoded2,
708
+ form: () => form2,
709
+ literal: () => literal2,
710
+ make: () => make2,
711
+ params: () => params2,
712
+ path: () => path2,
713
+ preauthenticated: () => preauthenticated2,
714
+ segments: () => segments2,
715
+ withFile: () => withFile,
716
+ withForm: () => withForm
717
+ });
718
+ function preserveJsonProperties(value, input) {
719
+ if (equals(value, input))
720
+ return value;
721
+ if (isArray(value) && isArray(input))
722
+ for (const entry of zip(value, input))
723
+ preserveJsonProperties(entry[0], entry[1]);
724
+ else if (isObject(value) && isObject(input))
725
+ for (const entry of toEntries(input))
726
+ if (has(value, entry[0]))
727
+ preserveJsonProperties(value[entry[0]], entry[1]);
728
+ else
729
+ Object.defineProperty(value, entry[0], {
730
+ configurable: true,
731
+ enumerable: true,
732
+ value: entry[1],
733
+ writable: true
734
+ });
735
+ return value;
736
+ }
737
+ function decodeResponse(output) {
738
+ return flow(succeed4, flatMap3((input) => pipe(decodeUnknownEffect(output)(input), map4((value) => preserveJsonProperties(value, input)))));
739
+ }
740
+ var File2 = Struct({
741
+ _tag: optionalKey(Literal("ToolFile")),
742
+ contentBase64: Uint8ArrayFromBase64,
743
+ contentType: optionalKey(NullOr(String3)),
744
+ filename: optionalKey(NullOr(String3)),
745
+ sizeBytes: optionalKey(Natural)
746
+ }).annotate({ description: "A ToolFile, such as the result of a download, passed unchanged; or its contentBase64 with an optional contentType and filename." });
747
+ var signatures = [
748
+ ["image/jpeg", [[0, [
749
+ 255,
750
+ 216,
751
+ 255
752
+ ]]]],
753
+ ["image/png", [[0, [
754
+ 137,
755
+ 80,
756
+ 78,
757
+ 71
758
+ ]]]],
759
+ ["image/gif", [[0, [
760
+ 71,
761
+ 73,
762
+ 70,
763
+ 56
764
+ ]]]],
765
+ ["image/webp", [[0, [
766
+ 82,
767
+ 73,
768
+ 70,
769
+ 70
770
+ ]], [8, [
771
+ 87,
772
+ 69,
773
+ 66,
774
+ 80
775
+ ]]]],
776
+ ["application/pdf", [[0, [
777
+ 37,
778
+ 80,
779
+ 68,
780
+ 70
781
+ ]]]],
782
+ ["application/zip", [[0, [
783
+ 80,
784
+ 75,
785
+ 3,
786
+ 4
787
+ ]]]]
788
+ ];
789
+ var utf8 = new TextDecoder("utf-8", { fatal: true });
790
+ function sniff(bytes) {
791
+ return pipe(findFirst(signatures, (signature) => every(signature[1], (part) => every(part[1], (byte, index) => bytes[part[0] + index] === byte))), map((signature) => signature[0]), orElse(() => liftPredicate("text/plain", () => isSuccess(try_(() => utf8.decode(bytes))))), getOrNull);
792
+ }
793
+ function toolFile(bytes, declared, filename) {
794
+ return {
795
+ _tag: "ToolFile",
796
+ contentBase64: encode2(bytes),
797
+ contentType: declared === null || pipe(declared, startsWith("application/octet-stream")) ? sniff(bytes) ?? declared : declared,
798
+ filename,
799
+ sizeBytes: bytes.byteLength
800
+ };
801
+ }
802
+ function invalid(expected, value, options) {
803
+ return fail5(new InvalidValue({ expected }, value, options));
804
+ }
805
+ function decodeBytes(text, options) {
806
+ return match3(decode(pipe(text, replaceAll("+", "-"), replaceAll("/", "_"))), {
807
+ onFailure: () => invalid("a Base64 or Base64Url string", text, options),
808
+ onSuccess: (bytes) => succeed4(bytes)
809
+ });
810
+ }
811
+ function contentOf(carrier) {
812
+ return transformEffect((text, options) => {
813
+ if (carrier !== "data-uri")
814
+ return map4(decodeBytes(text, options), (bytes) => ({
815
+ bytes,
816
+ contentType: null
817
+ }));
818
+ return match2(pipe(text, match4(/^data:([^;,]*)(?:;[^;,]*)*;base64,(.*)$/su)), {
819
+ onNone: () => invalid("a Base64 data URI", text, options),
820
+ onSome: (parts) => map4(decodeBytes(getUnsafe2(parts, 2), options), (bytes) => ({
821
+ bytes,
822
+ contentType: pipe(getUnsafe2(parts, 1), liftPredicate(isNonEmpty), getOrNull)
823
+ }))
824
+ });
825
+ });
826
+ }
827
+ function textOf(carrier, content) {
828
+ if (carrier === "base64")
829
+ return encode2(content.bytes);
830
+ if (carrier === "base64url")
831
+ return encode3(content.bytes);
832
+ return `data:${content.contentType ?? sniff(content.bytes) ?? "application/octet-stream"};base64,${encode2(content.bytes)}`;
833
+ }
834
+ function fileFrom(carrier) {
835
+ return String3.pipe(decodeTo(Schema, {
836
+ decode: compose2(contentOf(carrier), transform((content) => toolFile(content.bytes, content.contentType, null))),
837
+ encode: transformEffect((file, options) => map4(decodeBytes(file.contentBase64, options), (bytes) => textOf(carrier, {
838
+ bytes,
839
+ contentType: file.contentType
840
+ })))
841
+ }));
842
+ }
843
+ function encodedFrom(carrier) {
844
+ return File2.pipe(decodeTo(String3, {
845
+ decode: transform((file) => textOf(carrier, {
846
+ bytes: file.contentBase64,
847
+ contentType: file.contentType ?? null
848
+ })),
849
+ encode: compose2(contentOf(carrier), transform((content) => ({
850
+ contentBase64: content.bytes,
851
+ contentType: content.contentType
852
+ })))
853
+ }));
854
+ }
855
+ var FileFromBase642 = fileFrom("base64");
856
+ var FileFromBase64Url2 = fileFrom("base64url");
857
+ var Base64FromFile2 = encodedFrom("base64");
858
+ var Base64UrlFromFile2 = encodedFrom("base64url");
859
+ var FileFromDataUri2 = fileFrom("data-uri");
860
+ var DataUriFromFile2 = encodedFrom("data-uri");
861
+ var DateTimeText = String3.annotate({ format: "date-time" });
862
+ var rfc3339 = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.\d+)?(?:Z|([+-]\d{2}:\d{2}))$/u;
863
+ function rfc3339Instant(text) {
864
+ return pipe(fromNullishOr(rfc3339.exec(text)), flatMap((match5) => filter(makeZoned(text, { timeZone: match5[2] ?? "+00:00" }), (zoned) => startsWith(match5[1] ?? "")(formatIsoOffset(zoned)))), map(toUtc));
865
+ }
866
+ function instants(wire, expected, read, write) {
867
+ const fromWire = transformEffect((value, options) => match2(read(value), {
868
+ onNone: () => invalid(expected, value, options),
869
+ onSome: (instant) => succeed4(formatIso(instant))
870
+ }));
871
+ const toWire = transformEffect((text, options) => match2(rfc3339Instant(text), {
872
+ onNone: () => invalid("an ISO 8601 date-time", text, options),
873
+ onSome: (instant) => succeed4(write(instant))
874
+ }));
875
+ return {
876
+ input: pipe(DateTimeText, decodeTo(wire, {
877
+ decode: toWire,
878
+ encode: fromWire
879
+ })),
880
+ output: pipe(wire, decodeTo(DateTimeText, {
881
+ decode: fromWire,
882
+ encode: toWire
883
+ }))
884
+ };
885
+ }
886
+ var unixSeconds = instants(Int, "Unix seconds", (seconds) => map(make3(seconds * 1000), toUtc), (instant) => Math.floor(toEpochMillis(instant) / 1000));
887
+ var rfc2822 = instants(String3, "an RFC 2822 date-time", (text) => map(make3(text), toUtc), (instant) => toDateUtc(instant).toUTCString());
888
+ var DateTimeFromUnixSeconds2 = unixSeconds.output;
889
+ var UnixSecondsFromDateTime2 = unixSeconds.input;
890
+ var DateTimeFromRfc28222 = rfc2822.output;
891
+ var Rfc2822FromDateTime2 = rfc2822.input;
892
+ function decoded2(wire) {
893
+ return {
894
+ _tag: "Decoded",
895
+ wire
896
+ };
897
+ }
898
+ var GraphqlResponse = Struct({
899
+ data: optionalKey(NullOr(Record(String3, Unknown))),
900
+ errors: optionalKey(ArraySchema(StructWithRest(Struct({ message: String3 }), [Record(String3, Unknown)])))
901
+ });
902
+ function coerce(value) {
903
+ return isObject(value) ? JSON.stringify(value) : `${value}`;
904
+ }
905
+ function path2(value) {
906
+ return encodeURIComponent(coerce(value));
907
+ }
908
+ function literal2(value) {
909
+ return path2(pipe(coerce(value), replaceAll("'", "''")));
910
+ }
911
+ function segments2(value) {
912
+ return join(map3(split(coerce(value), "/"), encodeURIComponent), "/");
913
+ }
914
+ function deepObject(name, value) {
915
+ if (isArray(value))
916
+ return flatMap2(value, (item, index) => deepObject(`${name}[${index}]`, item));
917
+ if (isObject(value))
918
+ return flatMap2(toEntries(value), (entry) => deepObject(`${name}[${entry[0]}]`, entry[1]));
919
+ return value === undefined ? [] : [[name, coerce(value)]];
920
+ }
921
+ function params2(fields, joined = [], deep = [], exploded = []) {
922
+ return flatMap2(toEntries(fields), (field) => {
923
+ if (field[1] === undefined)
924
+ return [];
925
+ if (contains(deep, field[0]))
926
+ return deepObject(field[0], field[1]);
927
+ const values = field[1];
928
+ if (contains(exploded, field[0]) && isObject(values) && !isArray(values))
929
+ return filterMap(toEntries(values), (entry) => entry[1] === undefined ? failVoid : succeed([entry[0], coerce(entry[1])]));
930
+ if (!isArray(values))
931
+ return [[field[0], coerce(values)]];
932
+ const separator = findFirst(joined, (entry) => {
933
+ const pair = isString(entry) ? [entry, ","] : entry;
934
+ return pair[0] === field[0] ? some(pair[1]) : none();
935
+ });
936
+ return match2(separator, {
937
+ onNone: () => map3(values, (item) => [field[0], coerce(item)]),
938
+ onSome: (value) => [[field[0], join(map3(values, coerce), value)]]
939
+ });
940
+ });
941
+ }
942
+ function filePart(bytes, name, contentType) {
943
+ return new globalThis.File([new Uint8Array(bytes)], name, { type: contentType });
944
+ }
945
+ function form2(payload) {
946
+ return map2(payload, (value, name) => map3(ensure(value), (item) => {
947
+ if (item === undefined)
948
+ return;
949
+ if (!is(File2)(item))
950
+ return coerce(item);
951
+ return filePart(item.contentBase64, item.filename ?? name, item.contentType ?? "application/octet-stream");
952
+ }));
953
+ }
954
+ function fileFailed(error) {
955
+ return ActionHandlerError.make({
956
+ cause: error,
957
+ message: error.message
958
+ });
959
+ }
960
+ function readFile(file) {
961
+ return pipe(read(file), mapError2(fileFailed));
962
+ }
963
+ var withFile = fnUntraced(function* (request, file) {
964
+ return bodyUint8Array(request, yield* readFile(file), file.contentType);
965
+ });
966
+ var withForm = fnUntraced(function* (request, payload) {
967
+ return bodyFormDataRecord(request, fromEntries(yield* forEach(toEntries(payload), (field) => map4(forEach(filter2(ensure(field[1]), (item) => item !== undefined), (item) => gen(function* () {
968
+ if (!is(File3)(item))
969
+ return coerce(item);
970
+ return filePart(yield* readFile(item), item.name, item.contentType);
971
+ })), (parts) => [field[0], parts]))));
972
+ });
973
+ function mediaBytes(media) {
974
+ if (is(File3)(media))
975
+ return map4(readFile(media), (bytes) => ({
976
+ bytes,
977
+ contentType: media.contentType
978
+ }));
979
+ return succeed4({
980
+ bytes: media.contentBase64,
981
+ contentType: getOrNull(fromNullishOr(media.contentType))
982
+ });
983
+ }
984
+ function isSafeUrl(value, origin) {
985
+ if (!URL.canParse(value))
986
+ return false;
987
+ const url = new URL(value);
988
+ return url.protocol === "https:" && url.username === "" && url.password === "" && (origin === undefined || url.origin === origin);
989
+ }
990
+ function refused(message) {
991
+ return fail5(ActionHandlerError.make({ message }));
992
+ }
993
+ function continuation2(request, nextLink) {
994
+ if (nextLink === undefined)
995
+ return succeed4(request);
996
+ const declared = new URL(request.url);
997
+ const next = URL.canParse(nextLink) ? new URL(nextLink) : undefined;
998
+ if (next === undefined || !isSafeUrl(nextLink) || next.pathname !== declared.pathname)
999
+ return refused("A continuation URL must be an HTTPS link to the same operation path");
1000
+ return succeed4(makeWith(request.method, `${declared.origin}${next.pathname}${next.search}`, empty4, none(), request.headers, empty6));
1001
+ }
1002
+ function preauthenticated2(method, url, ...steps) {
1003
+ if (!isSafeUrl(url))
1004
+ return refused("An upload session requires a preauthenticated HTTPS URL");
1005
+ return succeed4(reduce(steps, method(url), (request, step) => step(request)));
1006
+ }
1007
+ function failure(error) {
1008
+ return is(ActionHandlerError)(error) ? error : fromHttpClientFailure(error);
1009
+ }
1010
+ function redirect(response) {
1011
+ const location = response.headers["location"];
1012
+ if (response.status < 300 || response.status >= 400 || location === undefined)
1013
+ return;
1014
+ const sent = response.request;
1015
+ const url = new URL(location, sent.url);
1016
+ const request = response.status === 303 && sent.method !== "GET" && sent.method !== "HEAD" || (response.status === 301 || response.status === 302) && sent.method === "POST" ? setBody(setMethod(sent, "GET"), empty6) : sent;
1017
+ return url.origin === new URL(sent.url).origin ? setUrl(request, url) : setUrl(makeWith(request.method, "", empty4, none(), empty3, request.body), url);
1018
+ }
1019
+ function follow(client, response, redirects) {
1020
+ const next = redirect(response);
1021
+ return next === undefined || redirects === 10 ? succeed4(response) : flatMap3(client.execute(next), (result) => follow(client, result, redirects + 1));
1022
+ }
1023
+ function dispositionName(header) {
1024
+ if (header === undefined)
1025
+ return;
1026
+ const encoded = pipe(match4(/(?:^|;)\s*filename\*\s*=\s*UTF-8'[^']*'([^;]+)/iu)(header), flatMap((match5) => fromUndefinedOr(match5[1])));
1027
+ const decoded = pipe(encoded, flatMap((value) => liftThrowable(() => decodeURIComponent(trim(value)))()));
1028
+ return getOrElse(decoded, () => pipe(match4(/(?:^|;)\s*filename\s*=\s*(?:"((?:\\.|[^"\\])*)"|([^;]*))/iu)(header), flatMap((match5) => orElse(map(fromUndefinedOr(match5[1]), (name) => replace(/\\(.)/gu, "$1")(name)), () => map(fromUndefinedOr(match5[2]), trim))), getOrUndefined));
1029
+ }
1030
+ var read2 = fnUntraced(function* (response, body) {
1031
+ if (body === "json")
1032
+ return yield* response.json;
1033
+ if (body === "text")
1034
+ return yield* response.text;
1035
+ if (body === "void")
1036
+ return {};
1037
+ if (body === "unknown") {
1038
+ const text = yield* response.text;
1039
+ if (isEmpty(trim(text)))
1040
+ return null;
1041
+ return getOrElse(decodeOption(fromJsonString(Json))(text), () => text);
1042
+ }
1043
+ const bytes = new Uint8Array(yield* response.arrayBuffer);
1044
+ const name = dispositionName(response.headers["content-disposition"]);
1045
+ if (body === "file")
1046
+ return yield* pipe(write({
1047
+ bytes,
1048
+ contentType: getOrNull(fromUndefinedOr(response.headers["content-type"])),
1049
+ name: name ?? "file"
1050
+ }), mapError2(fileFailed));
1051
+ return toolFile(bytes, response.headers["content-type"] ?? null, name ?? null);
1052
+ });
1053
+ function make2(auth) {
1054
+ const { authorize, checkResponse = () => void_2 } = auth;
1055
+ const send = fnUntraced(function* (context, request) {
1056
+ const base = yield* HttpClient;
1057
+ const uploadPolicy = context === undefined ? auth.preauthenticatedUploadUrl : undefined;
1058
+ const client = uploadPolicy === undefined ? base : mapRequestEffect(base, (outgoing) => isSafeUrl(outgoing.url) && is(uploadPolicy)(outgoing.url) ? succeed4(outgoing) : fail5(new HttpClientError({ reason: new InvalidUrlError({
1059
+ description: "The upload URL is not an approved provider HTTPS destination",
1060
+ request: outgoing
1061
+ }) })));
1062
+ const transport = transformResponse(client, flatMap3((response) => follow(client, response, 0)));
1063
+ const execution = (context === undefined ? transport : authorize(transport, context)).execute(isEffect(request) ? yield* request : request);
1064
+ const options = yield* serviceOption(RequestInit);
1065
+ const response = yield* match(uploadPolicy !== undefined, {
1066
+ onFalse: () => execution,
1067
+ onTrue: () => provideService(execution, RequestInit, {
1068
+ ...getOrElse(options, () => ({})),
1069
+ redirect: "manual"
1070
+ })
1071
+ });
1072
+ if (response.status < 200 || response.status >= 300)
1073
+ return yield* fail5({
1074
+ cause: yield* response.text,
1075
+ response
1076
+ });
1077
+ yield* checkResponse(response);
1078
+ return response;
1079
+ });
1080
+ function endpoint(contract, run) {
1081
+ if (!isSchema(contract.output)) {
1082
+ const wire = contract.output.wire;
1083
+ return {
1084
+ input: contract.input,
1085
+ output: toType(wire),
1086
+ run: (input, context) => run(input, context, wire),
1087
+ wire
1088
+ };
1089
+ }
1090
+ const output = contract.output;
1091
+ return {
1092
+ input: contract.input,
1093
+ output,
1094
+ run: (input, context) => run(input, context, output)
1095
+ };
1096
+ }
1097
+ function execute(context, output, request, body) {
1098
+ return pipe(send(context, request), flatMap3((response) => read2(response, body)), flatMap3(decodeResponse(output)), mapError2(failure));
1099
+ }
1100
+ const variants = fnUntraced(function* (context, output, request, declared, media) {
1101
+ const response = yield* send(context, request);
1102
+ const exact = flatMap2(declared, (variant) => variant.status === undefined ? [] : [variant.status]);
1103
+ const contentType = pipe(response.headers["content-type"] ?? "", split(";"), headNonEmpty, trim, toLowerCase);
1104
+ const ordered = sort(declared, mapInput(Number2, (variant) => {
1105
+ if (variant.body === "void" || variant.body === "unknown")
1106
+ return 3;
1107
+ if (variant.contentType === "*/*")
1108
+ return 2;
1109
+ return pipe(variant.contentType, endsWith("/*")) ? 1 : 0;
1110
+ }));
1111
+ const variant = findFirst(ordered, (candidate) => {
1112
+ if (!(candidate.status === undefined ? !contains(exact, response.status) : candidate.status === response.status))
1113
+ return false;
1114
+ if (media !== undefined)
1115
+ return (candidate.body === "binary" || candidate.body === "file") === media;
1116
+ if (candidate.body === "void" || candidate.body === "unknown" || candidate.contentType === "*/*")
1117
+ return true;
1118
+ if (pipe(candidate.contentType, endsWith("/*")))
1119
+ return pipe(contentType, startsWith(pipe(candidate.contentType, slice(0, -1))));
1120
+ return contentType === candidate.contentType;
1121
+ });
1122
+ if (isNone(variant))
1123
+ return yield* fail5({
1124
+ cause: "The API returned an undeclared successful response",
1125
+ response
1126
+ });
1127
+ const headers = flatMap2(variant.value.headers ?? [], (name) => {
1128
+ const value = response.headers[toLowerCase(name)];
1129
+ return value === undefined ? [] : [[name, value]];
1130
+ });
1131
+ return yield* decodeResponse(output)({
1132
+ body: yield* read2(response, variant.value.body),
1133
+ contentType: variant.value.contentType,
1134
+ status: response.status,
1135
+ ...variant.value.headers === undefined ? {} : { headers: fromEntries(headers) }
1136
+ });
1137
+ }, mapError2(failure));
1138
+ return {
1139
+ endpoint,
1140
+ execute,
1141
+ googleUpload: fnUntraced(function* (context, output, request, payload, options) {
1142
+ const client = authorize(yield* HttpClient, context);
1143
+ const media = "media" in payload ? yield* mediaBytes(payload.media) : undefined;
1144
+ const size = "totalBytes" in payload ? payload.totalBytes : media?.bytes.byteLength ?? 0;
1145
+ if (size < 0 || options.maxSize !== undefined && size > options.maxSize)
1146
+ return yield* refused("The upload size is outside the API's declared limit");
1147
+ const origin = new URL(request.url).origin;
1148
+ if (payload.mode === "start") {
1149
+ if (options.resumable === undefined)
1150
+ return yield* refused("This API has no resumable upload protocol");
1151
+ const response = yield* client.execute(pipe(setUrl(request, options.resumable), setUrlParam("uploadType", "resumable"), setHeaders({
1152
+ "x-upload-content-length": `${size}`,
1153
+ "x-upload-content-type": payload.contentType
1154
+ }), bodyJsonUnsafe(payload.metadata ?? {})));
1155
+ if (response.status < 200 || response.status >= 300)
1156
+ return yield* fail5({
1157
+ cause: yield* response.text,
1158
+ response
1159
+ });
1160
+ const sessionUrl = response.headers["location"];
1161
+ if (sessionUrl === undefined || !isSafeUrl(sessionUrl, origin))
1162
+ return yield* fail5({
1163
+ cause: "The API returned an invalid upload session URL",
1164
+ response
1165
+ });
1166
+ return yield* decodeResponse(output)({
1167
+ nextOffset: 0,
1168
+ sessionUrl,
1169
+ state: "pending"
1170
+ });
1171
+ }
1172
+ if (payload.mode === "chunk" || payload.mode === "status") {
1173
+ if (!isSafeUrl(payload.sessionUrl, origin))
1174
+ return yield* refused("The upload session URL must use the API's HTTPS origin");
1175
+ const bytes = media?.bytes ?? /* @__PURE__ */ new Uint8Array;
1176
+ const end = payload.mode === "chunk" ? payload.offset + bytes.byteLength : 0;
1177
+ if (payload.mode === "chunk" && (payload.offset < 0 || bytes.byteLength === 0 || end > size || end < size && bytes.byteLength % 262144 !== 0))
1178
+ return yield* refused("Upload chunks must fit the total size and use 256 KiB multiples except for the final chunk");
1179
+ const response = yield* client.execute(pipe(put(payload.sessionUrl), bodyUint8Array(bytes, media?.contentType ?? "application/octet-stream"), setHeader("content-range", payload.mode === "status" ? `bytes */${size}` : `bytes ${payload.offset}-${end - 1}/${size}`)));
1180
+ if (response.status === 308) {
1181
+ const range = response.headers["range"];
1182
+ if (range !== undefined && !/^bytes=0-\d+$/u.test(range))
1183
+ return yield* fail5({
1184
+ cause: "The API returned an invalid upload range",
1185
+ response
1186
+ });
1187
+ const nextOffset = range === undefined ? 0 : Number(pipe(range, slice(8))) + 1;
1188
+ if (nextOffset > size)
1189
+ return yield* fail5({
1190
+ cause: "The API returned an upload offset beyond the total size",
1191
+ response
1192
+ });
1193
+ return yield* decodeResponse(output)({
1194
+ nextOffset,
1195
+ sessionUrl: payload.sessionUrl,
1196
+ state: "pending"
1197
+ });
1198
+ }
1199
+ if (response.status < 200 || response.status >= 300)
1200
+ return yield* fail5({
1201
+ cause: yield* response.text,
1202
+ response
1203
+ });
1204
+ return yield* decodeResponse(output)({
1205
+ resource: yield* response.json,
1206
+ state: "complete"
1207
+ });
1208
+ }
1209
+ const selected = setUrlParam(request, "uploadType", payload.mode);
1210
+ const bytes = media?.bytes ?? /* @__PURE__ */ new Uint8Array;
1211
+ const contentType = media?.contentType ?? "application/octet-stream";
1212
+ const boundary = `dual-${yield* nextInt}-${yield* nextInt}`;
1213
+ const metadata = payload.mode === "multipart" ? yield* encodeEffect(fromJsonString(Unknown))(payload.metadata) : "";
1214
+ const body = payload.mode === "media" ? bodyUint8Array(selected, bytes, contentType) : bodyUint8Array(selected, new Uint8Array(yield* promise(() => new Blob([
1215
+ `--${boundary}\r
1216
+ Content-Type: application/json; charset=UTF-8\r
1217
+ \r
1218
+ ${metadata}\r
1219
+ --${boundary}\r
1220
+ Content-Type: ${contentType}\r
1221
+ \r
1222
+ `,
1223
+ new Uint8Array(bytes),
1224
+ `\r
1225
+ --${boundary}--\r
1226
+ `
1227
+ ]).arrayBuffer())), `multipart/related; boundary=${boundary}`);
1228
+ const response = yield* client.execute(body);
1229
+ if (response.status < 200 || response.status >= 300)
1230
+ return yield* fail5({
1231
+ cause: yield* response.text,
1232
+ response
1233
+ });
1234
+ return yield* decodeResponse(output)({
1235
+ resource: yield* response.json,
1236
+ state: "complete"
1237
+ });
1238
+ }, mapError2(failure)),
1239
+ graphql: fnUntraced(function* (context, output, request, field) {
1240
+ const response = yield* send(context, request);
1241
+ const body = yield* decodeUnknownEffect(GraphqlResponse)(yield* response.json);
1242
+ if (body.errors !== undefined && isReadonlyArrayNonEmpty(body.errors))
1243
+ return yield* ActionHandlerError.make({
1244
+ details: body.errors,
1245
+ message: join(map3(body.errors, (error) => error.message), "; ")
1246
+ });
1247
+ return yield* decodeResponse(output)(body.data?.[field]);
1248
+ }, mapError2(failure)),
1249
+ mcp: fnUntraced(function* (context, output, server, tool, args, structured) {
1250
+ const connection = yield* connect(authorize(yield* HttpClient, context), server, {});
1251
+ const result = yield* decodeUnknownEffect(CallToolResult)(yield* connection.request("tools/call", {
1252
+ arguments: args,
1253
+ name: tool
1254
+ }));
1255
+ if (result.isError === true)
1256
+ return yield* ActionHandlerError.make({
1257
+ details: result.content,
1258
+ message: join(flatMap2(result.content, (block) => fromNullishOr2(block.text)), `
1259
+ `)
1260
+ });
1261
+ return yield* decodeResponse(output)(match(structured, {
1262
+ onFalse: () => ({ content: result.content }),
1263
+ onTrue: () => result.structuredContent
1264
+ }));
1265
+ }, scoped, mapError2((error) => is(McpError)(error) ? ActionHandlerError.make({ message: error.message }) : failure(error))),
1266
+ variants
1267
+ };
1268
+ }
1269
+
1270
+ // dist/auth.js
1271
+ var auth_exports2 = /* @__PURE__ */ __exportAll2({
1272
+ Auth: () => auth_exports2,
1273
+ authMethods: () => authMethods2,
1274
+ authorize: () => authorize2,
1275
+ sandboxAccess: () => sandboxAccess2
1276
+ });
1277
+ var apiBase = "https://api.github.com";
1278
+ function webOrigin(server) {
1279
+ if (server === undefined || server === "")
1280
+ return "https://github.com";
1281
+ const origin = match3(fromString(server), {
1282
+ onFailure: () => replace(/^(https?:\/\/[^/]+).*$/u, "$1")(server),
1283
+ onSuccess: (url) => url.origin
1284
+ });
1285
+ return origin === apiBase ? "https://github.com" : origin;
1286
+ }
1287
+ var authMethods2 = [AuthMethod_exports.make("personal-access-token", {
1288
+ description: "Authenticate with a GitHub personal access token sent as a bearer token; set server for GitHub Enterprise Server",
1289
+ name: "GitHub personal access token",
1290
+ schema: Struct({
1291
+ server: optionalKey(String3),
1292
+ token: NonEmptyString
1293
+ })
1294
+ }), AuthMethod_exports.oauth2("oauth2", {
1295
+ authorizationUrl: (context) => `${webOrigin(context.setup.server)}/login/oauth/authorize`,
1296
+ client: (options) => ({
1297
+ authentication: "post",
1298
+ clientId: options.setup.clientId,
1299
+ clientSecret: options.setup.clientSecret
1300
+ }),
1301
+ description: "Authenticate with a GitHub OAuth app; set server for GitHub Enterprise Server, whose OAuth endpoints are on the same host",
1302
+ material: AuthMethod_exports.OAuth2TokenMaterial,
1303
+ name: "GitHub OAuth app",
1304
+ resolve: (material, context) => ({
1305
+ accessToken: material.accessToken,
1306
+ server: context.setup.server
1307
+ }),
1308
+ scopes: [
1309
+ "repo",
1310
+ "admin:repo_hook",
1311
+ "admin:org",
1312
+ "admin:org_hook",
1313
+ "gist",
1314
+ "notifications",
1315
+ "user",
1316
+ "write:packages",
1317
+ "read:packages",
1318
+ "delete:packages",
1319
+ "workflow"
1320
+ ],
1321
+ setup: Struct({
1322
+ clientId: String3,
1323
+ clientSecret: String3,
1324
+ server: optional(String3)
1325
+ }),
1326
+ tokenUrl: (context) => `${webOrigin(context.setup.server)}/login/oauth/access_token`,
1327
+ value: Struct({
1328
+ accessToken: String3,
1329
+ server: optional(String3)
1330
+ })
1331
+ })];
1332
+ function token(context) {
1333
+ return pipe(value2(context.auth.current), discriminatorsExhaustive("methodId")({
1334
+ oauth2: (binding) => binding.value.accessToken,
1335
+ "personal-access-token": (binding) => binding.value.token
1336
+ }));
1337
+ }
1338
+ function authorize2(client, context) {
1339
+ const server = context.auth.current.value.server;
1340
+ return pipe(client, mapRequest(bearerToken(token(context))), mapRequest(setHeader("X-GitHub-Api-Version", "2022-11-28")), mapRequestEffect(fnUntraced(function* (request) {
1341
+ if (server === undefined || server === "")
1342
+ return request;
1343
+ const urls = yield* pipe(all({
1344
+ base: fromString(server),
1345
+ target: fromString(request.url)
1346
+ }), mapError((cause) => new HttpClientError({ reason: new InvalidUrlError({
1347
+ cause,
1348
+ request
1349
+ }) })), fromResult);
1350
+ const publicApi = urls.base.origin === apiBase && urls.base.pathname === "/";
1351
+ const enterprise = `${urls.base.origin}${pipe(urls.base.pathname, replace(/\/+$/u, ""), replace(/\/api\/v3$/u, ""))}`;
1352
+ if (urls.target.origin === "https://uploads.github.com") {
1353
+ if (publicApi)
1354
+ return request;
1355
+ return updateUrl((url) => `${enterprise}/api/uploads${slice(26)(url)}`)(request);
1356
+ }
1357
+ if (urls.target.origin !== apiBase)
1358
+ return request;
1359
+ return updateUrl((url) => `${replace(/\/+$/u, "")(urls.base.href)}${slice(22)(url)}`)(request);
1360
+ })));
1361
+ }
1362
+ var sandboxAccess2 = {
1363
+ authorize: (request, context) => map(liftPredicate(request, (git) => Plugin_exports.isGitRequest(git) && match3(fromString(git.url), {
1364
+ onFailure: () => false,
1365
+ onSuccess: (url) => !startsWith("/api/")(url.pathname)
1366
+ })), (git) => basicAuth(git, "x-access-token", token(context))),
1367
+ origins: (context) => [webOrigin(context.auth.current.value.server)]
1368
+ };
1369
+ export { match, Http_exports, File2, FileFromBase642, FileFromBase64Url2, Base64FromFile2, Base64UrlFromFile2, FileFromDataUri2, DataUriFromFile2, DateTimeFromUnixSeconds2, UnixSecondsFromDateTime2, DateTimeFromRfc28222, Rfc2822FromDateTime2, decoded2, path2, literal2, segments2, params2, form2, continuation2, preauthenticated2, auth_exports2, authMethods2, authorize2, sandboxAccess2 };
1370
+
1371
+ //# debugId=24FF8839C2DB50A764756E2164756E21
1372
+ //# sourceMappingURL=plugin-yzj02c6j.js.map