stitchkit 0.107.0 → 0.108.1

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 (102) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/README.md +2 -0
  3. package/darwin-native.cjs +1 -0
  4. package/dist/agent-runtime/sandbox-process-owner.d.ts +3 -3
  5. package/dist/agent-runtime/sandbox-process-owner.d.ts.map +1 -1
  6. package/dist/agent-runtime/sandbox-process.d.ts +2 -2
  7. package/dist/agent-runtime/sandbox-process.d.ts.map +1 -1
  8. package/dist/agent-runtime/store-conformance-support.d.ts +5 -5
  9. package/dist/browser/stream.d.ts +38 -12
  10. package/dist/browser/stream.d.ts.map +1 -1
  11. package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
  12. package/dist/entrypoints/agent-runtime/sandbox.js +2 -2
  13. package/dist/entrypoints/application/diagnostic-journal.js +2 -2
  14. package/dist/entrypoints/application/directory-inbox.js +4 -4
  15. package/dist/entrypoints/bin/upgrade-cli.d.ts +32 -0
  16. package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -1
  17. package/dist/entrypoints/bin/upgrade-cli.js +451 -8
  18. package/dist/entrypoints/cli/publish.js +3 -3
  19. package/dist/entrypoints/files/packaging.d.ts +3 -1
  20. package/dist/entrypoints/files/packaging.d.ts.map +1 -1
  21. package/dist/entrypoints/files/packaging.js +105 -41
  22. package/dist/entrypoints/files.js +3 -3
  23. package/dist/entrypoints/index.d.ts +1 -1
  24. package/dist/entrypoints/index.d.ts.map +1 -1
  25. package/dist/entrypoints/index.js +7 -1
  26. package/dist/entrypoints/process.js +2 -2
  27. package/dist/entrypoints/remote.js +1 -1
  28. package/dist/entrypoints/server.js +4 -4
  29. package/dist/entrypoints/telegram/screens.js +1 -1
  30. package/dist/entrypoints/telegram.d.ts +2 -0
  31. package/dist/entrypoints/telegram.d.ts.map +1 -1
  32. package/dist/entrypoints/telegram.js +337 -3
  33. package/dist/entrypoints/testing.d.ts +1 -0
  34. package/dist/entrypoints/testing.d.ts.map +1 -1
  35. package/dist/entrypoints/testing.js +131 -1
  36. package/dist/files/native-artifact.d.ts +14 -0
  37. package/dist/files/native-artifact.d.ts.map +1 -0
  38. package/dist/files/native-packaging-layout.d.ts +5 -0
  39. package/dist/files/native-packaging-layout.d.ts.map +1 -1
  40. package/dist/files/native-packaging-plugin.d.ts +53 -0
  41. package/dist/files/native-packaging-plugin.d.ts.map +1 -0
  42. package/dist/files/native-packaging.d.ts +1 -35
  43. package/dist/files/native-packaging.d.ts.map +1 -1
  44. package/dist/index-a5qr2rj6.js +26 -0
  45. package/dist/{index-7r74re56.js → index-bh2ht9y5.js} +12 -6
  46. package/dist/{index-dwf0gymy.js → index-e35py42g.js} +1 -1
  47. package/dist/{index-4q9jvqg7.js → index-epg514ys.js} +182 -13
  48. package/dist/{index-mbf4h8kp.js → index-nx49x0tw.js} +1 -1
  49. package/dist/{index-zsqt5q98.js → index-p5kx5vqd.js} +209 -54
  50. package/dist/{index-bnf8s6v3.js → index-t2bsd0hm.js} +1 -1
  51. package/dist/{index-4f37d3bg.js → index-w9mqgnz9.js} +1 -1
  52. package/dist/{index-e05cjgtf.js → index-xvj9h8yh.js} +28 -1
  53. package/dist/internal/bounded-lines.d.ts +46 -2
  54. package/dist/internal/bounded-lines.d.ts.map +1 -1
  55. package/dist/internal/process-identity.d.ts.map +1 -1
  56. package/dist/internal/until-aborted.d.ts +9 -0
  57. package/dist/internal/until-aborted.d.ts.map +1 -0
  58. package/dist/internal/upgrade-affects.d.ts +58 -0
  59. package/dist/internal/upgrade-affects.d.ts.map +1 -0
  60. package/dist/internal/upgrade-plan.d.ts +20 -0
  61. package/dist/internal/upgrade-plan.d.ts.map +1 -1
  62. package/dist/internal/upgrade-usage.d.ts +61 -0
  63. package/dist/internal/upgrade-usage.d.ts.map +1 -0
  64. package/dist/process/bun-child.d.ts +38 -0
  65. package/dist/process/bun-child.d.ts.map +1 -0
  66. package/dist/process/command-owner.d.ts +2 -2
  67. package/dist/process/command-owner.d.ts.map +1 -1
  68. package/dist/process/launch.d.ts +2 -2
  69. package/dist/process/launch.d.ts.map +1 -1
  70. package/dist/process/owned-child.d.ts +2 -1
  71. package/dist/process/owned-child.d.ts.map +1 -1
  72. package/dist/telegram/bot-api.d.ts +10 -4
  73. package/dist/telegram/bot-api.d.ts.map +1 -1
  74. package/dist/telegram/broadcast.d.ts +2 -1
  75. package/dist/telegram/broadcast.d.ts.map +1 -1
  76. package/dist/telegram/not-dispatched.d.ts +26 -0
  77. package/dist/telegram/not-dispatched.d.ts.map +1 -0
  78. package/dist/telegram/operator-channel.d.ts +2 -1
  79. package/dist/telegram/operator-channel.d.ts.map +1 -1
  80. package/dist/telegram/send-failure.d.ts +4 -3
  81. package/dist/telegram/send-failure.d.ts.map +1 -1
  82. package/dist/telegram/transport-connect.d.ts +38 -0
  83. package/dist/telegram/transport-connect.d.ts.map +1 -0
  84. package/dist/telegram/transport.d.ts +43 -0
  85. package/dist/telegram/transport.d.ts.map +1 -0
  86. package/dist/telegram/webhook.d.ts +2 -1
  87. package/dist/telegram/webhook.d.ts.map +1 -1
  88. package/dist/testing/manual-clock.d.ts +82 -0
  89. package/dist/testing/manual-clock.d.ts.map +1 -0
  90. package/llms/files-packaging.txt +4 -1
  91. package/llms/process.txt +19 -5
  92. package/llms/stitchkit.2.txt +211 -628
  93. package/llms/stitchkit.txt +635 -10
  94. package/llms/telegram.txt +36 -3
  95. package/llms/testing.txt +47 -0
  96. package/llms/{upgrading-0.98.0-0.107.0.txt → upgrading-0.100.0-0.108.0.txt} +59 -64
  97. package/llms/{upgrading-0.72.0-0.97.0.txt → upgrading-0.72.0-0.99.0.txt} +64 -3
  98. package/llms/upgrading.txt +34 -2
  99. package/llms-full.txt +246 -17
  100. package/llms.txt +8 -8
  101. package/package.json +1 -1
  102. package/llms/stitchkit.3.txt +0 -177
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { type NativePackagingPlugin } from './native-packaging-plugin.js';
2
3
  declare const ArchitectureSchema: z.ZodEnum<{
3
4
  arm64: "arm64";
4
5
  x64: "x64";
@@ -111,41 +112,6 @@ export type NativePackagingAsset<Multiple extends boolean = false> = Multiple ex
111
112
  * `sha256`, for qualification. The plugin hands Bun these bytes; there is nothing to write.
112
113
  */
113
114
  export type NativePackagingEmbeddedAsset = z.infer<typeof EmbeddedAssetSchema>;
114
- /**
115
- * Structural Bun plugin protocol: declarations need no Bun runtime or ambient types.
116
- */
117
- export type NativePackagingPlugin = {
118
- name: string;
119
- setup: (build: {
120
- config: {
121
- splitting?: boolean;
122
- naming?: string | {
123
- entry?: string;
124
- };
125
- entrypoints: string[];
126
- };
127
- onLoad: (options: {
128
- filter: RegExp;
129
- }, callback: (args: {
130
- path: string;
131
- }) => {
132
- contents: string;
133
- loader: 'js';
134
- } | {
135
- contents: Uint8Array;
136
- loader: 'napi';
137
- } | undefined) => unknown;
138
- onResolve: (options: {
139
- filter: RegExp;
140
- }, callback: (args: {
141
- path: string;
142
- importer: string;
143
- }) => {
144
- path: string;
145
- external: boolean;
146
- } | undefined) => unknown;
147
- }) => void;
148
- };
149
115
  /**
150
116
  * `ready` with the verified assets to write and the Bun plugin to add, or a refusal naming an
151
117
  * unsupported architecture, a missing asset or an asset whose bytes differ from the published
@@ -1 +1 @@
1
- {"version":3,"file":"native-packaging.d.ts","sourceRoot":"","sources":["../../src/files/native-packaging.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,QAAA,MAAM,kBAAkB;;;EAA2B,CAAC;AACpD,mGAAmG;AACnG,QAAA,MAAM,cAAc;;EAAqB,CAAC;AAe1C,QAAA,MAAM,mBAAmB;;;;;;;;iBAKvB,CAAC;AACH;;;GAGG;AACH,QAAA,MAAM,qBAAqB;;;;;;kBAIzB,CAAC;AACH,QAAA,MAAM,qBAAqB;;;;;;;;iBAOzB,CAAC;AAwCH,QAAA,MAAM,mBAAmB;;;;iBAIvB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AM,MAAM,6BAA6B,GACrC,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAC7B;IACE,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;IACzC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;IACjD,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,4BAA4B,EAAE,CAAC;IACvC,MAAM,EAAE,qBAAqB,CAAC;CAC/B,CAAC;AAsLN;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,8BAA8B,GACtC,6BAA6B,CAAC;AACjC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,qBAAqB,CAAC;AAC9F,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,CAAC,IAAI,CAAC,GACpC,qBAAqB,CAAC,IAAI,CAAC,CAAC;AAC/B,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,CAAC,OAAO,CAAC,GACvC,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAClC,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,CAAC,OAAO,CAAC,GAAG,8BAA8B,GACxE,qBAAqB,CAAC,OAAO,CAAC,GAAG,6BAA6B,CAAC"}
@@ -0,0 +1,26 @@
1
+ // src/internal/until-aborted.ts
2
+ function abortReason(signal) {
3
+ return signal.reason ?? new DOMException("The operation was aborted", "AbortError");
4
+ }
5
+ function untilAborted(pending, signal) {
6
+ return new Promise((resolve, reject) => {
7
+ const abort = () => reject(abortReason(signal));
8
+ if (signal.aborted) {
9
+ pending.catch(() => {
10
+ return;
11
+ });
12
+ abort();
13
+ return;
14
+ }
15
+ signal.addEventListener("abort", abort, { once: true });
16
+ pending.then((value) => {
17
+ signal.removeEventListener("abort", abort);
18
+ resolve(value);
19
+ }, (error) => {
20
+ signal.removeEventListener("abort", abort);
21
+ reject(error);
22
+ });
23
+ });
24
+ }
25
+
26
+ export { abortReason, untilAborted };
@@ -14,7 +14,6 @@ import { z } from "zod";
14
14
  import { execFile } from "node:child_process";
15
15
  import { readFile } from "node:fs/promises";
16
16
  import { platform } from "node:os";
17
- import { promisify } from "node:util";
18
17
  var detectedIdentity;
19
18
  async function firstReadableLine(paths) {
20
19
  for (const path of paths) {
@@ -26,7 +25,16 @@ async function firstReadableLine(paths) {
26
25
  }
27
26
  return null;
28
27
  }
29
- var run = promisify(execFile);
28
+ function run(file, args, options) {
29
+ return new Promise((resolve, reject) => {
30
+ execFile(file, args, { ...options, encoding: "utf8" }, (error, stdout) => {
31
+ if (error)
32
+ reject(error);
33
+ else
34
+ resolve({ stdout });
35
+ });
36
+ });
37
+ }
30
38
  function parsePlatformUuid(dump) {
31
39
  return /"IOPlatformUUID"\s*=\s*"([^"]+)"/.exec(dump)?.[1] ?? null;
32
40
  }
@@ -34,8 +42,7 @@ async function readDarwinPlatformUuid(command = "ioreg") {
34
42
  try {
35
43
  const { stdout } = await run(command, ["-rd1", "-c", "IOPlatformExpertDevice"], {
36
44
  timeout: 2000,
37
- maxBuffer: 1 << 20,
38
- encoding: "utf8"
45
+ maxBuffer: 1 << 20
39
46
  });
40
47
  return parsePlatformUuid(stdout);
41
48
  } catch {
@@ -67,8 +74,7 @@ async function isZombieProcess(pid, seam = {}) {
67
74
  try {
68
75
  const { stdout } = await run(psCommand, ["-o", "state=", "-p", String(pid)], {
69
76
  timeout: 2000,
70
- maxBuffer: 1 << 16,
71
- encoding: "utf8"
77
+ maxBuffer: 1 << 16
72
78
  });
73
79
  return stdout.trim().startsWith("Z");
74
80
  } catch {
@@ -5,7 +5,7 @@ import {
5
5
  NativeCommandError2,
6
6
  CommandStopped,
7
7
  startNativeCommand
8
- } from "./index-4q9jvqg7.js";
8
+ } from "./index-epg514ys.js";
9
9
  import {
10
10
  probeAgentProcessSandboxOutcome,
11
11
  missingSandboxRestrictions2,
@@ -395,21 +395,190 @@ function createCommandLifetime(input) {
395
395
  }
396
396
 
397
397
  // src/process/launch.ts
398
- import { Readable as Readable2 } from "node:stream";
398
+ import { Readable as Readable3 } from "node:stream";
399
399
 
400
400
  // src/process/owned-child.ts
401
401
  import { spawn } from "node:child_process";
402
+
403
+ // src/process/bun-child.ts
404
+ import { EventEmitter } from "node:events";
405
+ import { Readable, Writable } from "node:stream";
406
+ function hostIsBun() {
407
+ return typeof Bun !== "undefined";
408
+ }
409
+ function readableOf(source) {
410
+ const reader = source.getReader();
411
+ let reading = false;
412
+ return new Readable({
413
+ read() {
414
+ if (reading)
415
+ return;
416
+ reading = true;
417
+ reader.read().then(({ done, value }) => {
418
+ reading = false;
419
+ if (done)
420
+ this.push(null);
421
+ else
422
+ this.push(value);
423
+ }, (error) => {
424
+ reading = false;
425
+ this.destroy(error instanceof Error ? error : new Error(String(error)));
426
+ });
427
+ },
428
+ destroy(error, done) {
429
+ reader.cancel().then(() => done(error), () => done(error));
430
+ }
431
+ });
432
+ }
433
+ var REPORTED_SPAWN_CODES = new Set(["ENOENT", "EACCES", "EAGAIN", "EMFILE", "ENFILE"]);
434
+ function reportedSpawnFailure(cause) {
435
+ return typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" && REPORTED_SPAWN_CODES.has(cause.code);
436
+ }
437
+ var waitClosed = (stream) => stream.closed ? Promise.resolve() : new Promise((resolve) => stream.once("close", () => resolve()));
438
+ function defineBunChildren() {
439
+
440
+ class BunProcess extends EventEmitter {
441
+ pipes;
442
+ pid;
443
+ exitCode = null;
444
+ signalCode = null;
445
+ #subprocess;
446
+ constructor(pipes) {
447
+ super();
448
+ this.pipes = pipes;
449
+ }
450
+ watch(subprocess) {
451
+ this.pid = subprocess.pid;
452
+ this.#subprocess = subprocess;
453
+ subprocess.exited.then(() => {
454
+ this.exitCode = subprocess.exitCode;
455
+ this.signalCode = subprocess.signalCode;
456
+ this.emit("exit", this.exitCode, this.signalCode);
457
+ for (const pipe of this.pipes)
458
+ if (pipe.readableFlowing === null)
459
+ pipe.resume();
460
+ this.closeAfterPipes();
461
+ });
462
+ }
463
+ fail(cause) {
464
+ for (const pipe of this.pipes)
465
+ pipe.resume();
466
+ setImmediate(() => {
467
+ this.emit("error", cause);
468
+ this.closeAfterPipes();
469
+ });
470
+ }
471
+ kill(signal) {
472
+ const subprocess = this.#subprocess;
473
+ if (!subprocess || this.exitCode !== null || this.signalCode !== null)
474
+ return false;
475
+ try {
476
+ subprocess.kill(signal);
477
+ return true;
478
+ } catch {
479
+ return false;
480
+ }
481
+ }
482
+ closeAfterPipes() {
483
+ Promise.all(this.pipes.map(waitClosed)).then(() => this.emit("close", this.exitCode, this.signalCode));
484
+ }
485
+ }
486
+
487
+ class BunChild extends BunProcess {
488
+ stdin;
489
+ stdout;
490
+ stderr;
491
+ constructor(stdin, stdout, stderr) {
492
+ super([stdout, stderr]);
493
+ this.stdin = stdin;
494
+ this.stdout = stdout;
495
+ this.stderr = stderr;
496
+ }
497
+ }
498
+ return { BunProcess, BunChild };
499
+ }
500
+ var bunChildren;
501
+ function children() {
502
+ bunChildren ??= defineBunChildren();
503
+ return bunChildren;
504
+ }
505
+ function sinkWritable(sink) {
506
+ let ended = false;
507
+ const end = () => {
508
+ if (ended)
509
+ return Promise.resolve(0);
510
+ ended = true;
511
+ return Promise.resolve().then(() => sink.end());
512
+ };
513
+ return new Writable({
514
+ write(chunk, _encoding, done) {
515
+ Promise.resolve().then(() => sink.write(chunk)).then(() => done(), done);
516
+ },
517
+ final(done) {
518
+ end().then(() => done(), done);
519
+ },
520
+ destroy(error, done) {
521
+ end().then(() => done(error), () => done(error));
522
+ }
523
+ });
524
+ }
525
+ function spawnBunChild(input) {
526
+ const { BunChild } = children();
527
+ try {
528
+ const subprocess = Bun.spawn([input.executable, ...input.args], {
529
+ cwd: input.cwd,
530
+ env: input.env,
531
+ detached: input.group,
532
+ stdin: "pipe",
533
+ stdout: "pipe",
534
+ stderr: "pipe"
535
+ });
536
+ const child = new BunChild(sinkWritable(subprocess.stdin), readableOf(subprocess.stdout), readableOf(subprocess.stderr));
537
+ child.watch(subprocess);
538
+ return child;
539
+ } catch (cause) {
540
+ if (!reportedSpawnFailure(cause))
541
+ throw cause;
542
+ const child = new BunChild(new Writable({ write: (_chunk, _encoding, done) => done() }), Readable.from([]), Readable.from([]));
543
+ child.fail(cause);
544
+ return child;
545
+ }
546
+ }
547
+ function spawnBunInheritedChild(input) {
548
+ const { BunProcess } = children();
549
+ const child = new BunProcess([]);
550
+ try {
551
+ child.watch(Bun.spawn([input.executable, ...input.args], {
552
+ cwd: input.cwd,
553
+ env: input.env,
554
+ detached: input.group,
555
+ stdin: "inherit",
556
+ stdout: "inherit",
557
+ stderr: "inherit"
558
+ }));
559
+ } catch (cause) {
560
+ if (!reportedSpawnFailure(cause))
561
+ throw cause;
562
+ child.fail(cause);
563
+ }
564
+ return child;
565
+ }
566
+
567
+ // src/process/owned-child.ts
402
568
  var groups = new WeakSet;
403
569
  function spawnOwnedCommand(input) {
404
- const child = spawn(input.executable, [...input.args], {
570
+ const child = hostIsBun() ? spawnBunChild(input) : nodeChild(input);
571
+ if (input.group)
572
+ groups.add(child);
573
+ return child;
574
+ }
575
+ function nodeChild(input) {
576
+ return spawn(input.executable, [...input.args], {
405
577
  cwd: input.cwd,
406
578
  env: input.env,
407
579
  detached: input.group,
408
580
  stdio: ["pipe", "pipe", "pipe"]
409
581
  });
410
- if (input.group)
411
- groups.add(child);
412
- return child;
413
582
  }
414
583
  var INHERITED_OUTPUT = {
415
584
  destroyed: true,
@@ -445,7 +614,7 @@ class InheritedChild {
445
614
  }
446
615
  }
447
616
  function spawnInheritedCommand(input) {
448
- const child = new InheritedChild(spawn(input.executable, [...input.args], {
617
+ const child = new InheritedChild(hostIsBun() ? spawnBunInheritedChild(input) : spawn(input.executable, [...input.args], {
449
618
  cwd: input.cwd,
450
619
  env: input.env,
451
620
  detached: input.group,
@@ -460,7 +629,7 @@ function ownsCommandGroup(child) {
460
629
  }
461
630
 
462
631
  // src/process/transport.ts
463
- import { Readable, Writable } from "node:stream";
632
+ import { Readable as Readable2, Writable as Writable2 } from "node:stream";
464
633
  function createCommandTransport(child) {
465
634
  const leader = Promise.withResolvers();
466
635
  const closed = Promise.withResolvers();
@@ -517,17 +686,17 @@ function createCommandTransport(child) {
517
686
  stderr = child.stderr;
518
687
  destructors.set("stderr", () => stderr?.destroy());
519
688
  const input = "stdin" in child ? child.stdin : undefined;
520
- if (input instanceof Writable) {
689
+ if (input instanceof Writable2) {
521
690
  stdin = input;
522
691
  pendingHandles.add("stdin");
523
692
  destructors.set("stdin", () => input.destroy());
524
693
  pipe("stdin", input);
525
694
  }
526
- if (stdout instanceof Readable)
695
+ if (stdout instanceof Readable2)
527
696
  pipe("stdout", stdout);
528
- if (stderr instanceof Readable)
697
+ if (stderr instanceof Readable2)
529
698
  pipe("stderr", stderr);
530
- if (stdout instanceof Readable && stderr instanceof Readable)
699
+ if (stdout instanceof Readable2 && stderr instanceof Readable2)
531
700
  release("launcher");
532
701
  return { stdout, stderr };
533
702
  },
@@ -545,7 +714,7 @@ function createCommandTransport(child) {
545
714
  child.stdout.destroy();
546
715
  else if (name === "stderr")
547
716
  child.stderr.destroy();
548
- else if ("stdin" in child && child.stdin instanceof Writable)
717
+ else if ("stdin" in child && child.stdin instanceof Writable2)
549
718
  child.stdin.destroy();
550
719
  } catch (cause) {
551
720
  failures.push(cause);
@@ -578,7 +747,7 @@ function nativeCommandOwner(child) {
578
747
  return owners.get(child);
579
748
  }
580
749
  function outputStream(source, closed, maxBufferedBytes) {
581
- if (source instanceof Readable2)
750
+ if (source instanceof Readable3)
582
751
  return {
583
752
  bytes: source,
584
753
  destroy() {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withExclusiveLock2
3
- } from "./index-4f37d3bg.js";
3
+ } from "./index-w9mqgnz9.js";
4
4
  import {
5
5
  readBoundedFile
6
6
  } from "./index-m616f0yz.js";