@dual-os/adyen-api 0.0.0-stage → 6.0.4

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