agent-comms 8.7.0 → 8.8.0

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 (92) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +8 -3
  4. package/dist/account-cli.js +5 -5
  5. package/dist/account-cli.js.map +1 -1
  6. package/dist/account-join-cli.d.ts +1 -1
  7. package/dist/account-join-cli.d.ts.map +1 -1
  8. package/dist/account-join-cli.js +8 -4
  9. package/dist/account-join-cli.js.map +1 -1
  10. package/dist/bridges/user/web/dist/mesh-worker.js +1 -1
  11. package/dist/bridges/user/web/dist/sw.js +1 -1
  12. package/dist/core/account-bundle.d.ts +13 -8
  13. package/dist/core/account-bundle.d.ts.map +1 -1
  14. package/dist/core/account-bundle.js +44 -14
  15. package/dist/core/account-bundle.js.map +1 -1
  16. package/dist/core/account-join.d.ts +11 -3
  17. package/dist/core/account-join.d.ts.map +1 -1
  18. package/dist/core/account-join.js +47 -14
  19. package/dist/core/account-join.js.map +1 -1
  20. package/dist/core/agent-registry.d.ts.map +1 -1
  21. package/dist/core/agent-registry.js +2 -0
  22. package/dist/core/agent-registry.js.map +1 -1
  23. package/dist/core/bridge.d.ts +1 -0
  24. package/dist/core/bridge.d.ts.map +1 -1
  25. package/dist/core/bridge.js +6 -0
  26. package/dist/core/bridge.js.map +1 -1
  27. package/dist/core/gossip-directory.d.ts +4 -2
  28. package/dist/core/gossip-directory.d.ts.map +1 -1
  29. package/dist/core/gossip-directory.js +4 -5
  30. package/dist/core/gossip-directory.js.map +1 -1
  31. package/dist/core/gossip-extensions.d.ts +2 -0
  32. package/dist/core/gossip-extensions.d.ts.map +1 -1
  33. package/dist/core/gossip-extensions.js +3 -0
  34. package/dist/core/gossip-extensions.js.map +1 -1
  35. package/dist/core/group-proofs.d.ts +10 -6
  36. package/dist/core/group-proofs.d.ts.map +1 -1
  37. package/dist/core/group-proofs.js +69 -18
  38. package/dist/core/group-proofs.js.map +1 -1
  39. package/dist/core/issuer-grouping.d.ts +52 -0
  40. package/dist/core/issuer-grouping.d.ts.map +1 -0
  41. package/dist/core/{machine-grouping.js → issuer-grouping.js} +33 -33
  42. package/dist/core/issuer-grouping.js.map +1 -0
  43. package/dist/core/mesh-store.d.ts.map +1 -1
  44. package/dist/core/mesh-store.js +3 -1
  45. package/dist/core/mesh-store.js.map +1 -1
  46. package/dist/core/naming-actions.d.ts +5 -1
  47. package/dist/core/naming-actions.d.ts.map +1 -1
  48. package/dist/core/naming-actions.js +13 -1
  49. package/dist/core/naming-actions.js.map +1 -1
  50. package/dist/core/naming.d.ts +9 -5
  51. package/dist/core/naming.d.ts.map +1 -1
  52. package/dist/core/naming.js +14 -4
  53. package/dist/core/naming.js.map +1 -1
  54. package/dist/core/self-name-claim.d.ts +27 -0
  55. package/dist/core/self-name-claim.d.ts.map +1 -0
  56. package/dist/core/{machine-name-claim.js → self-name-claim.js} +7 -8
  57. package/dist/core/self-name-claim.js.map +1 -0
  58. package/dist/core/tool.d.ts.map +1 -1
  59. package/dist/core/tool.js +11 -7
  60. package/dist/core/tool.js.map +1 -1
  61. package/dist/core/types.d.ts +6 -0
  62. package/dist/core/types.d.ts.map +1 -1
  63. package/dist/core/types.js +5 -0
  64. package/dist/core/types.js.map +1 -1
  65. package/dist/core/user-identity.d.ts +9 -4
  66. package/dist/core/user-identity.d.ts.map +1 -1
  67. package/dist/core/user-identity.js +38 -9
  68. package/dist/core/user-identity.js.map +1 -1
  69. package/dist/test/account-join.integration.test.js +98 -1
  70. package/dist/test/account-join.integration.test.js.map +1 -1
  71. package/dist/test/account-transfer.unit.test.js +41 -13
  72. package/dist/test/account-transfer.unit.test.js.map +1 -1
  73. package/dist/test/issuer-grouping.unit.test.d.ts +2 -0
  74. package/dist/test/issuer-grouping.unit.test.d.ts.map +1 -0
  75. package/dist/test/issuer-grouping.unit.test.js +137 -0
  76. package/dist/test/issuer-grouping.unit.test.js.map +1 -0
  77. package/dist/test/naming.integration.test.d.ts +1 -1
  78. package/dist/test/naming.integration.test.js +45 -1
  79. package/dist/test/naming.integration.test.js.map +1 -1
  80. package/dist/test/user-identity.unit.test.js +25 -1
  81. package/dist/test/user-identity.unit.test.js.map +1 -1
  82. package/package.json +1 -1
  83. package/dist/core/machine-grouping.d.ts +0 -47
  84. package/dist/core/machine-grouping.d.ts.map +0 -1
  85. package/dist/core/machine-grouping.js.map +0 -1
  86. package/dist/core/machine-name-claim.d.ts +0 -22
  87. package/dist/core/machine-name-claim.d.ts.map +0 -1
  88. package/dist/core/machine-name-claim.js.map +0 -1
  89. package/dist/test/machine-grouping.unit.test.d.ts +0 -2
  90. package/dist/test/machine-grouping.unit.test.d.ts.map +0 -1
  91. package/dist/test/machine-grouping.unit.test.js +0 -68
  92. package/dist/test/machine-grouping.unit.test.js.map +0 -1
@@ -15,7 +15,7 @@
15
15
  "source": "url",
16
16
  "url": "https://github.com/ExaDev/agent-comms.git"
17
17
  },
18
- "version": "8.7.0"
18
+ "version": "8.8.0"
19
19
  }
20
20
  ]
21
21
  }
@@ -18,5 +18,5 @@
18
18
  },
19
19
  "name": "agent-comms",
20
20
  "repository": "https://github.com/ExaDev/agent-comms",
21
- "version": "8.7.0"
21
+ "version": "8.8.0"
22
22
  }
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![GitHub](https://img.shields.io/badge/GitHub-181717?logo=github&logoColor=white)](https://github.com/ExaDev/agent-comms)
4
4
  [![npm](https://img.shields.io/badge/npm-CB3837?logo=npm&logoColor=white)](https://www.npmjs.com/package/agent-comms)
5
- [![version](https://img.shields.io/badge/version-8.7.0-blue)](https://github.com/ExaDev/agent-comms/releases/tag/v8.7.0)
5
+ [![version](https://img.shields.io/badge/version-8.8.0-blue)](https://github.com/ExaDev/agent-comms/releases/tag/v8.8.0)
6
6
  [![CI](https://img.shields.io/github/actions/workflow/status/ExaDev/agent-comms/ci.yml?branch=main)](https://github.com/ExaDev/agent-comms/actions)
7
7
 
8
8
  Cross-harness communication mesh for LLM agents: rooms, DMs, presence, and visibility over TCP with zero filesystem dependencies.
@@ -347,7 +347,7 @@ To let a device DM you without deciding on the spot, admit it ahead of time. `dm
347
347
 
348
348
  Everything identified by a device-id, an agent, a machine, a principal or a trusted device, is shown the same way everywhere: your own name for it first, then the name it gives itself in quotes, then a short id, as in `work laptop "joe-mbp" 3a8b8ebc6dd3`. The short id is a prefix; tool actions take the full id, so listings whose entries you act on print the full id followed by the names alone, without a short id that would only repeat its start.
349
349
 
350
- An agent names itself with `register` and `update`. A machine names itself with `machine_name`, which every bridge the account runs on the host then signs with the machine key and gossips beside its machine proof, so peers see the name the machine chose and know which key chose it; what the name says is still the machine's own claim.
350
+ An agent names itself with `register` and `update`. A machine names itself with `machine_name`, which every bridge the account runs on the host then signs with the machine key and gossips beside its machine proof, so peers see the name the machine chose and know which key chose it; what the name says is still the machine's own claim. An account names itself the same way with `principal_name`: the name is kept in `user-identity.json`, signed with the user key beside the membership proof, and shown next to the principal id (in `whoami`, `gateway_list_trusted` and the "vouched for by" column) only when it verifies against the principal that device's proof names. Because the name belongs to the account, an account export and an account join carry it to the new machine; a rename made afterwards is not replicated, so it is made again wherever it is wanted.
351
351
 
352
352
  Your own names, petnames, are yours alone. They live in `~/.agent-comms/petnames.json`, shared by your bridges on this machine, and are never gossiped or sent to anyone. A petname is set for a full device-id only, since a label on a typo or a short id would apply to nothing. An entry in the file that is not a usable name for a full device-id is ignored on its own, and a file that is not a JSON object is reported as an error rather than written over.
353
353
 
@@ -355,13 +355,16 @@ Your own names, petnames, are yours alone. They live in `~/.agent-comms/petnames
355
355
  # Name this machine for everyone who can see it (omit name to clear it)
356
356
  agent_comms({ action: "machine_name", name: "joe-mbp" })
357
357
 
358
+ # Name the account every one of your machines shares (omit name to clear it)
359
+ agent_comms({ action: "principal_name", name: "work account" })
360
+
358
361
  # Give any id your own name, and take it away again
359
362
  agent_comms({ action: "petname_set", device: "3a8b8e...", name: "work laptop" })
360
363
  agent_comms({ action: "petname_clear", device: "3a8b8e..." })
361
364
  agent_comms({ action: "petname_list" })
362
365
  ```
363
366
 
364
- Names must be non-empty, at most 64 characters, and free of control characters. `register`, `update`, `machine_name` and `petname_set` refuse a name that breaks those rules, an agent that gossips one is not listed, and any other name that breaks them is left out wherever it would be shown. A name shown in quotes has any quote inside it escaped, so it cannot pass part of itself off as a separate label.
367
+ Names must be non-empty, at most 64 characters, and free of control characters. `register`, `update`, `machine_name`, `principal_name` and `petname_set` refuse a name that breaks those rules, an agent that gossips one is not listed, and any other name that breaks them is left out wherever it would be shown. A name shown in quotes has any quote inside it escaped, so it cannot pass part of itself off as a separate label.
365
368
 
366
369
  ## Room types
367
370
 
@@ -531,6 +534,8 @@ npx agent-comms account invite # on a machine that holds the account; keep it
531
534
  npx agent-comms account join # on the new machine; paste the invite at the prompt
532
535
  ```
533
536
 
537
+ `account join --label <name>` also tells the issuing machine what you call the new one: it keeps the label as its own petname for that machine (see Names), so the machine you just admitted is listed by that name from then on. The label follows the ordinary name rules and is refused before anything is redeemed when it breaks them; it never leaves the issuing machine's petnames file.
538
+
534
539
  Both are commands you run, not `agent_comms` tool actions: an invite is the account key to whoever redeems it first, and a join replaces the account the machine holds, so nothing an agent is told can do either, and the invite is printed only to your terminal, never into an agent's transcript. `join` reads the invite at a prompt that does not echo, so it stays out of shell history.
535
540
 
536
541
  `account invite` runs a store of its own and keeps it up until the invite is redeemed or expires, since the issuing device keeps invites only in memory and answers each one once and never after it expires. An invite is valid for as long as a connection code, and can be made shorter with `--ttl-minutes <n>` but not longer. Redeeming it trusts the issuing device, exactly as `gateway_redeem_connection_code` does, then asks that device for the account key over the mesh's end-to-end authenticated request path, directly or relayed by the hub; the key comes back sealed under a key derived from the invite, which only its holder can open. A join the issuing device refuses or never answers withdraws that trust again, so a failed join leaves the new machine trusting no one it did not trust before. An invite can be PGP-signed with `--sign-key <armored private key file>`, and a signed one is checked on `join` against `--public-key <file>`, pinned to `--fingerprint <hex>` when you give one. Issuing an invite also trusts your own principal on the issuing machine, and joining trusts it on the new one, so the two list each other's devices from then on. The account the new machine held before is kept beside it as `user-identity.replaced-<id>.json`, since its key is still the only one that can revoke what it issued, and the machine's running bridges pick up the account when they restart.
@@ -5,7 +5,7 @@ import * as fs from "node:fs";
5
5
  import { deviceIdToHex } from "wire-mesh-core/domain/device-id";
6
6
  import { inviteToAccount, joinAccount, } from "./account-join-cli.js";
7
7
  import { openAccountBundle, sealAccountBundle } from "./core/account-bundle.js";
8
- import { importAccountKey, loadOrCreateUserIdentity, readAccountPrivateKey, } from "./core/user-identity.js";
8
+ import { importAccountKey, loadOrCreateUserIdentity, readAccountContents, } from "./core/user-identity.js";
9
9
  /** Where a script supplies the passphrase instead of typing it. */
10
10
  export const ACCOUNT_PASSPHRASE_ENV = "AGENT_COMMS_ACCOUNT_PASSPHRASE";
11
11
  /** A bundle holds the account key, so its file is readable by its owner alone. */
@@ -14,7 +14,7 @@ export const ACCOUNT_USAGE = [
14
14
  "Usage: agent-comms account export <file>",
15
15
  " agent-comms account import <file>",
16
16
  " agent-comms account invite [--ttl-minutes <n>] [--sign-key <file>]",
17
- " agent-comms account join [--public-key <file>] [--fingerprint <hex>]",
17
+ " agent-comms account join [--public-key <file>] [--fingerprint <hex>] [--label <name>]",
18
18
  ].join("\n");
19
19
  async function passphrase(io, confirm) {
20
20
  const fromEnv = io.env[ACCOUNT_PASSPHRASE_ENV];
@@ -47,7 +47,7 @@ export async function runAccountCommand(args, io, userIdentityOptions = {}) {
47
47
  throw new Error(ACCOUNT_USAGE);
48
48
  if (subcommand === "export") {
49
49
  const identity = loadOrCreateUserIdentity(userIdentityOptions);
50
- const bundle = sealAccountBundle(readAccountPrivateKey(userIdentityOptions), await passphrase(io, true));
50
+ const bundle = sealAccountBundle(readAccountContents(userIdentityOptions), await passphrase(io, true));
51
51
  fs.writeFileSync(file, `${bundle}\n`, {
52
52
  encoding: "utf-8",
53
53
  mode: BUNDLE_FILE_MODE,
@@ -57,8 +57,8 @@ export async function runAccountCommand(args, io, userIdentityOptions = {}) {
57
57
  return;
58
58
  }
59
59
  if (subcommand === "import") {
60
- const privateKeyPem = openAccountBundle(fs.readFileSync(file, "utf-8"), await passphrase(io, false));
61
- const { identity, replacedFile } = importAccountKey(userIdentityOptions, privateKeyPem);
60
+ const contents = openAccountBundle(fs.readFileSync(file, "utf-8"), await passphrase(io, false));
61
+ const { identity, replacedFile } = importAccountKey(userIdentityOptions, contents);
62
62
  io.log(`This machine now holds account ${principalOf(identity)}.`);
63
63
  if (replacedFile !== undefined) {
64
64
  io.log(`The account it held before was moved to ${replacedFile}; it is still the only key that can revoke what that account issued.`);
@@ -1 +1 @@
1
- {"version":3,"file":"account-cli.js","sourceRoot":"","sources":["../src/account-cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EACL,eAAe,EACf,WAAW,GAEZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAEjC,mEAAmE;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,gCAAgC,CAAC;AAEvE,kFAAkF;AAClF,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,0CAA0C;IAC1C,0CAA0C;IAC1C,2EAA2E;IAC3E,6EAA6E;CAC9E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAWb,KAAK,UAAU,UAAU,CACvB,EAA0B,EAC1B,OAAgB;IAEhB,MAAM,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;IAC/C,IAAI,OAAO,KAAK,SAAS;QAAE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AAW,CAAC,OAAO,CAAC,CAAC;IAC3B,KAAK,CAAC,MAAM,EAAE,CAAC;IACf,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,wEAAwE;QACxE,IAAI,MAAM,GAAG,GAAS,EAAE,CAAC,SAAS,CAAC;QACnC,MAAM,MAAM,GAAG,CAAC,KAAa,EAAQ,EAAE;YACrC,KAAK,MAAM,SAAS,IAAI,KAAK,EAAE,CAAC;gBAC9B,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;gBAC9C,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC3B,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;oBACnB,SAAS;gBACX,CAAC;gBACD,MAAM,EAAE,CAAC;gBACT,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;oBAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;;oBACzC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBACrC,OAAO;YACT,CAAC;QACH,CAAC,CAAC;QACF,MAAM,GAAG,GAAS,EAAE;YAClB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC1B,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACxB,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC,CAAC;QACF,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -12,6 +12,6 @@ export interface AccountCliStore {
12
12
  export declare function openMachineAccountStore(): Promise<AccountCliStore>;
13
13
  /** Issues an invite, prints it, and returns once it has been redeemed or has expired. */
14
14
  export declare function inviteToAccount(args: readonly string[], io: Readonly<AccountCliIo>): Promise<void>;
15
- /** Reads an invite at a prompt and makes this machine hold the account it came from. */
15
+ /** Reads an invite at a prompt and makes this machine hold the account it came from. With --label, the issuing machine keeps the label as its own name for this one. */
16
16
  export declare function joinAccount(args: readonly string[], io: Readonly<AccountCliIo>): Promise<void>;
17
17
  //# sourceMappingURL=account-join-cli.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"account-join-cli.d.ts","sourceRoot":"","sources":["../src/account-join-cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAU1D,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEpE,gEAAgE;AAChE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC;IAC9C,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAKD,4OAA4O;AAC5O,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,eAAe,CAAC,CAwBxE;AAwDD,yFAAyF;AACzF,wBAAsB,eAAe,CACnC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,EAAE,QAAQ,CAAC,YAAY,CAAC,GACzB,OAAO,CAAC,IAAI,CAAC,CAuBf;AA+BD,wFAAwF;AACxF,wBAAsB,WAAW,CAC/B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,EAAE,QAAQ,CAAC,YAAY,CAAC,GACzB,OAAO,CAAC,IAAI,CAAC,CAiBf"}
1
+ {"version":3,"file":"account-join-cli.d.ts","sourceRoot":"","sources":["../src/account-join-cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAU1D,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEpE,gEAAgE;AAChE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC;IAC9C,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAKD,4OAA4O;AAC5O,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,eAAe,CAAC,CAwBxE;AAwDD,yFAAyF;AACzF,wBAAsB,eAAe,CACnC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,EAAE,QAAQ,CAAC,YAAY,CAAC,GACzB,OAAO,CAAC,IAAI,CAAC,CAuBf;AA+BD,wKAAwK;AACxK,wBAAsB,WAAW,CAC/B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,EAAE,QAAQ,CAAC,YAAY,CAAC,GACzB,OAAO,CAAC,IAAI,CAAC,CAqBf"}
@@ -119,14 +119,18 @@ function verifyingOptions(options) {
119
119
  ...(fingerprint !== undefined && { expectedFingerprint: fingerprint }),
120
120
  };
121
121
  }
122
- /** Reads an invite at a prompt and makes this machine hold the account it came from. */
122
+ /** Reads an invite at a prompt and makes this machine hold the account it came from. With --label, the issuing machine keeps the label as its own name for this one. */
123
123
  export async function joinAccount(args, io) {
124
- const options = parseOptions(args, ["public-key", "fingerprint"]);
125
- const redeemOptions = verifyingOptions(options);
124
+ const options = parseOptions(args, ["public-key", "fingerprint", "label"]);
125
+ const label = options.get("label");
126
+ const joinOptions = {
127
+ ...verifyingOptions(options),
128
+ ...(label !== undefined && { label }),
129
+ };
126
130
  const invite = parseInvite(await io.readSecret("Account invite: "));
127
131
  const store = await io.openStore();
128
132
  try {
129
- const result = await store.account.join(invite, redeemOptions);
133
+ const result = await store.account.join(invite, joinOptions);
130
134
  io.log(`This machine now holds account ${result.principal}.`);
131
135
  if (result.replacedFile !== undefined) {
132
136
  io.log(`The account it held before was moved to ${result.replacedFile}; it is still the only key that can revoke what that account issued.`);
@@ -1 +1 @@
1
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MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAC7D,EAAE,CAAC,GAAG,CAAC,kCAAkC,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC;QAC9D,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACtC,EAAE,CAAC,GAAG,CACJ,2CAA2C,MAAM,CAAC,YAAY,sEAAsE,CACrI,CAAC;QACJ,CAAC;QACD,EAAE,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IAChE,CAAC;YAAS,CAAC;QACT,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;AACH,CAAC"}
@@ -61,4 +61,4 @@ var AgentCommsMeshWorker=(function(e){Object.defineProperty(e,Symbol.toStringTag
61
61
 
62
62
  `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=fr,s=!er.jitless,c=s&&pr.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?ka([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Ma(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Dr(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>P(e,r,k())))}),t)}var Na=O(`$ZodUnion`,(e,t)=>{I.init(e,t),A(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),A(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),A(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),A(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>ar(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Ma(t,r,e,i)):Ma(o,r,e,i)}}),Pa=O(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Na.init(e,t);let n=e._zod.parse;A(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=rr(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!fr(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Fa=O(`$ZodIntersection`,(e,t)=>{I.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>La(e,t,n)):La(e,i,a)}});function Ia(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(mr(e)&&mr(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Ia(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ia(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function La(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Dr(e))return e;let o=Ia(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Ra=O(`$ZodRecord`,(e,t)=>{I.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!mr(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>P(e,r,k())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...kr(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...kr(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Ti.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>P(e,r,k())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...kr(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...kr(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),za=O(`$ZodEnum`,(e,t)=>{I.init(e,t);let n=tr(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>gr.has(typeof e)).map(e=>typeof e==`string`?_r(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ba=O(`$ZodLiteral`,(e,t)=>{if(I.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?_r(e):e?_r(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Va=O(`$ZodTransform`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $n(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Qn;return n.value=i,n.fallback=!0,n}});function Ha(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ua=O(`$ZodOptional`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,A(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),A(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ar(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Ha(e,r)):Ha(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Wa=O(`$ZodExactOptional`,(e,t)=>{Ua.init(e,t),A(e._zod,`values`,()=>t.innerType._zod.values),A(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ga=O(`$ZodNullable`,(e,t)=>{I.init(e,t),A(e._zod,`optin`,()=>t.innerType._zod.optin),A(e._zod,`optout`,()=>t.innerType._zod.optout),A(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ar(e.source)}|null)$`):void 0}),A(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ka=O(`$ZodDefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,A(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>qa(e,t)):qa(r,t)}});function qa(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ja=O(`$ZodPrefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,A(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ya=O(`$ZodNonOptional`,(e,t)=>{I.init(e,t),A(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Xa(t,e)):Xa(i,e)}});function Xa(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Za=O(`$ZodCatch`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,A(e._zod,`optout`,()=>t.innerType._zod.optout),A(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>P(e,n,k()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>P(e,n,k()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Qa=O(`$ZodPipe`,(e,t)=>{I.init(e,t),A(e._zod,`values`,()=>t.in._zod.values),A(e._zod,`optin`,()=>t.in._zod.optin),A(e._zod,`optout`,()=>t.out._zod.optout),A(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>$a(e,t.in,n)):$a(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>$a(e,t.out,n)):$a(r,t.out,n)}});function $a(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var eo=O(`$ZodReadonly`,(e,t)=>{I.init(e,t),A(e._zod,`propValues`,()=>t.innerType._zod.propValues),A(e._zod,`values`,()=>t.innerType._zod.values),A(e._zod,`optin`,()=>t.innerType?._zod?.optin),A(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(to):to(r)}});function to(e){return e.value=Object.freeze(e.value),e}var no=O(`$ZodCustom`,(e,t)=>{F.init(e,t),I.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>ro(t,n,r,e));ro(i,n,r,e)}});function ro(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Mr(e))}}var io,ao=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function oo(){return new ao}(io=globalThis).__zod_globalRegistry??(io.__zod_globalRegistry=oo());var so=globalThis.__zod_globalRegistry;function co(e,t){return new e({type:`string`,...N(t)})}function lo(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...N(t)})}function uo(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...N(t)})}function fo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...N(t)})}function po(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...N(t)})}function mo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...N(t)})}function ho(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...N(t)})}function go(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...N(t)})}function _o(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...N(t)})}function vo(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...N(t)})}function yo(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...N(t)})}function bo(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...N(t)})}function xo(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...N(t)})}function So(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...N(t)})}function Co(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...N(t)})}function wo(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...N(t)})}function To(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...N(t)})}function Eo(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...N(t)})}function Do(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...N(t)})}function Oo(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...N(t)})}function ko(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...N(t)})}function Ao(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...N(t)})}function jo(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...N(t)})}function Mo(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...N(t)})}function No(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...N(t)})}function Po(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...N(t)})}function Fo(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...N(t)})}function Io(e,t){return new e({type:`number`,checks:[],...N(t)})}function Lo(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...N(t)})}function Ro(e,t){return new e({type:`boolean`,...N(t)})}function zo(e){return new e({type:`unknown`})}function Bo(e,t){return new e({type:`never`,...N(t)})}function Vo(e,t){return new Ai({check:`less_than`,...N(t),value:e,inclusive:!1})}function Ho(e,t){return new Ai({check:`less_than`,...N(t),value:e,inclusive:!0})}function Uo(e,t){return new ji({check:`greater_than`,...N(t),value:e,inclusive:!1})}function Wo(e,t){return new ji({check:`greater_than`,...N(t),value:e,inclusive:!0})}function Go(e,t){return new Mi({check:`multiple_of`,...N(t),value:e})}function Ko(e,t){return new Pi({check:`max_length`,...N(t),maximum:e})}function qo(e,t){return new Fi({check:`min_length`,...N(t),minimum:e})}function Jo(e,t){return new Ii({check:`length_equals`,...N(t),length:e})}function Yo(e,t){return new Ri({check:`string_format`,format:`regex`,...N(t),pattern:e})}function Xo(e){return new zi({check:`string_format`,format:`lowercase`,...N(e)})}function Zo(e){return new Bi({check:`string_format`,format:`uppercase`,...N(e)})}function Qo(e,t){return new Vi({check:`string_format`,format:`includes`,...N(t),includes:e})}function $o(e,t){return new Hi({check:`string_format`,format:`starts_with`,...N(t),prefix:e})}function es(e,t){return new Ui({check:`string_format`,format:`ends_with`,...N(t),suffix:e})}function ts(e){return new Wi({check:`overwrite`,tx:e})}function ns(e){return ts(t=>t.normalize(e))}function rs(){return ts(e=>e.trim())}function is(){return ts(e=>e.toLowerCase())}function as(){return ts(e=>e.toUpperCase())}function os(){return ts(e=>ur(e))}function ss(e,t,n){return new e({type:`array`,element:t,...N(n)})}function cs(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...N(n)})}function ls(e,t){let n=us(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Mr(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Mr(r))}},e(t.value,t)),t);return n}function us(e,t){let n=new F({check:`custom`,...N(t)});return n._zod.check=e,n}function ds(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??so,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function R(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,R(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&z(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function fs(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
63
63
 
64
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function ps(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:hs(t,`input`,e.processors),output:hs(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function z(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return z(r.element,n);if(r.type===`set`)return z(r.valueType,n);if(r.type===`lazy`)return z(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return z(r.innerType,n);if(r.type===`intersection`)return z(r.left,n)||z(r.right,n);if(r.type===`record`||r.type===`map`)return z(r.keyType,n)||z(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:z(r.in,n)||z(r.out,n);if(r.type===`object`){for(let e in r.shape)if(z(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(z(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(z(e,n))return!0;return!!(r.rest&&z(r.rest,n))}return!1}var ms=(e,t={})=>n=>{let r=ds({...n,processors:t});return R(e,r),fs(r,e),ps(r,e)},hs=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ds({...i??{},target:a,io:t,processors:n});return R(e,o),fs(o,e),ps(o,e)},gs={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},_s=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=gs[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},vs=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},ys=(e,t,n,r)=>{n.type=`boolean`},bs=(e,t,n,r)=>{n.not={}},xs=(e,t,n,r)=>{let i=e._zod.def,a=tr(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ss=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Cs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ws=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Ts=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=R(a.element,t,{...r,path:[...r.path,`items`]})},Es=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=R(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=R(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ds=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>R(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Os=(e,t,n,r)=>{let i=e._zod.def,a=R(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=R(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},ks=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=R(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=R(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=R(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},As=(e,t,n,r)=>{let i=e._zod.def,a=R(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},js=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ms=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ns=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Ps=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Fs=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;R(o,t,r);let s=t.seen.get(e);s.ref=o},Is=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ls=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Rs=O(`ZodISODateTime`,(e,t)=>{aa.init(e,t),U.init(e,t)});function zs(e){return Mo(Rs,e)}var Bs=O(`ZodISODate`,(e,t)=>{oa.init(e,t),U.init(e,t)});function Vs(e){return No(Bs,e)}var Hs=O(`ZodISOTime`,(e,t)=>{sa.init(e,t),U.init(e,t)});function Us(e){return Po(Hs,e)}var Ws=O(`ZodISODuration`,(e,t)=>{ca.init(e,t),U.init(e,t)});function Gs(e){return Fo(Ws,e)}var B=O(`ZodError`,(e,t)=>{Pr.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Lr(e,t)},flatten:{value:t=>Ir(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,nr,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,nr,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ks=Rr(B),qs=zr(B),Js=Br(B),Ys=Hr(B),Xs=Wr(B),Zs=Gr(B),Qs=Kr(B),$s=qr(B),ec=Jr(B),tc=Yr(B),nc=Xr(B),rc=Zr(B),ic=new WeakMap;function ac(e,t,n){let r=Object.getPrototypeOf(e),i=ic.get(r);if(i||(i=new Set,ic.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var V=O(`ZodType`,(e,t)=>(I.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:hs(e,`input`),output:hs(e,`output`)}}),e.toJSONSchema=ms(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ks(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Js(e,t,n),e.parseAsync=async(t,n)=>qs(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ys(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Xs(e,t,n),e.decode=(t,n)=>Zs(e,t,n),e.encodeAsync=async(t,n)=>Qs(e,t,n),e.decodeAsync=async(t,n)=>$s(e,t,n),e.safeEncode=(t,n)=>ec(e,t,n),e.safeDecode=(t,n)=>tc(e,t,n),e.safeEncodeAsync=async(t,n)=>nc(e,t,n),e.safeDecodeAsync=async(t,n)=>rc(e,t,n),ac(e,`ZodType`,{check(...e){let t=this.def;return this.clone(j(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return M(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ml(e,t))},superRefine(e,t){return this.check(hl(e,t))},overwrite(e){return this.check(ts(e))},optional(){return Xc(this)},exactOptional(){return Qc(this)},nullable(){return el(this)},nullish(){return Xc(el(this))},nonoptional(e){return ol(this,e)},array(){return G(this)},or(e){return q([this,e])},and(e){return Hc(this,e)},transform(e){return ul(this,Jc(e))},default(e){return nl(this,e)},prefault(e){return il(this,e)},catch(e){return cl(this,e)},pipe(e){return ul(this,e)},readonly(){return fl(this)},describe(e){let t=this.clone();return so.add(t,{description:e}),t},meta(...e){if(e.length===0)return so.get(this);let t=this.clone();return so.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return so.get(e)?.description},configurable:!0}),e)),oc=O(`_ZodString`,(e,t)=>{qi.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ac(e,`_ZodString`,{regex(...e){return this.check(Yo(...e))},includes(...e){return this.check(Qo(...e))},startsWith(...e){return this.check($o(...e))},endsWith(...e){return this.check(es(...e))},min(...e){return this.check(qo(...e))},max(...e){return this.check(Ko(...e))},length(...e){return this.check(Jo(...e))},nonempty(...e){return this.check(qo(1,...e))},lowercase(e){return this.check(Xo(e))},uppercase(e){return this.check(Zo(e))},trim(){return this.check(rs())},normalize(...e){return this.check(ns(...e))},toLowerCase(){return this.check(is())},toUpperCase(){return this.check(as())},slugify(){return this.check(os())}})}),sc=O(`ZodString`,(e,t)=>{qi.init(e,t),oc.init(e,t),e.email=t=>e.check(lo(cc,t)),e.url=t=>e.check(go(dc,t)),e.jwt=t=>e.check(jo(Ec,t)),e.emoji=t=>e.check(_o(fc,t)),e.guid=t=>e.check(uo(lc,t)),e.uuid=t=>e.check(fo(uc,t)),e.uuidv4=t=>e.check(po(uc,t)),e.uuidv6=t=>e.check(mo(uc,t)),e.uuidv7=t=>e.check(ho(uc,t)),e.nanoid=t=>e.check(vo(pc,t)),e.guid=t=>e.check(uo(lc,t)),e.cuid=t=>e.check(yo(mc,t)),e.cuid2=t=>e.check(bo(hc,t)),e.ulid=t=>e.check(xo(gc,t)),e.base64=t=>e.check(Oo(Cc,t)),e.base64url=t=>e.check(ko(wc,t)),e.xid=t=>e.check(So(_c,t)),e.ksuid=t=>e.check(Co(vc,t)),e.ipv4=t=>e.check(wo(yc,t)),e.ipv6=t=>e.check(To(bc,t)),e.cidrv4=t=>e.check(Eo(xc,t)),e.cidrv6=t=>e.check(Do(Sc,t)),e.e164=t=>e.check(Ao(Tc,t)),e.datetime=t=>e.check(zs(t)),e.date=t=>e.check(Vs(t)),e.time=t=>e.check(Us(t)),e.duration=t=>e.check(Gs(t))});function H(e){return co(sc,e)}var U=O(`ZodStringFormat`,(e,t)=>{L.init(e,t),oc.init(e,t)}),cc=O(`ZodEmail`,(e,t)=>{Xi.init(e,t),U.init(e,t)}),lc=O(`ZodGUID`,(e,t)=>{Ji.init(e,t),U.init(e,t)}),uc=O(`ZodUUID`,(e,t)=>{Yi.init(e,t),U.init(e,t)}),dc=O(`ZodURL`,(e,t)=>{Zi.init(e,t),U.init(e,t)}),fc=O(`ZodEmoji`,(e,t)=>{Qi.init(e,t),U.init(e,t)}),pc=O(`ZodNanoID`,(e,t)=>{$i.init(e,t),U.init(e,t)}),mc=O(`ZodCUID`,(e,t)=>{ea.init(e,t),U.init(e,t)}),hc=O(`ZodCUID2`,(e,t)=>{ta.init(e,t),U.init(e,t)}),gc=O(`ZodULID`,(e,t)=>{na.init(e,t),U.init(e,t)}),_c=O(`ZodXID`,(e,t)=>{ra.init(e,t),U.init(e,t)}),vc=O(`ZodKSUID`,(e,t)=>{ia.init(e,t),U.init(e,t)}),yc=O(`ZodIPv4`,(e,t)=>{la.init(e,t),U.init(e,t)}),bc=O(`ZodIPv6`,(e,t)=>{ua.init(e,t),U.init(e,t)}),xc=O(`ZodCIDRv4`,(e,t)=>{da.init(e,t),U.init(e,t)}),Sc=O(`ZodCIDRv6`,(e,t)=>{fa.init(e,t),U.init(e,t)}),Cc=O(`ZodBase64`,(e,t)=>{ma.init(e,t),U.init(e,t)}),wc=O(`ZodBase64URL`,(e,t)=>{ga.init(e,t),U.init(e,t)}),Tc=O(`ZodE164`,(e,t)=>{_a.init(e,t),U.init(e,t)}),Ec=O(`ZodJWT`,(e,t)=>{ya.init(e,t),U.init(e,t)}),Dc=O(`ZodNumber`,(e,t)=>{ba.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),ac(e,`ZodNumber`,{gt(e,t){return this.check(Uo(e,t))},gte(e,t){return this.check(Wo(e,t))},min(e,t){return this.check(Wo(e,t))},lt(e,t){return this.check(Vo(e,t))},lte(e,t){return this.check(Ho(e,t))},max(e,t){return this.check(Ho(e,t))},int(e){return this.check(kc(e))},safe(e){return this.check(kc(e))},positive(e){return this.check(Uo(0,e))},nonnegative(e){return this.check(Wo(0,e))},negative(e){return this.check(Vo(0,e))},nonpositive(e){return this.check(Ho(0,e))},multipleOf(e,t){return this.check(Go(e,t))},step(e,t){return this.check(Go(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function W(e){return Io(Dc,e)}var Oc=O(`ZodNumberFormat`,(e,t)=>{xa.init(e,t),Dc.init(e,t)});function kc(e){return Lo(Oc,e)}var Ac=O(`ZodBoolean`,(e,t)=>{Sa.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r)});function jc(e){return Ro(Ac,e)}var Mc=O(`ZodUnknown`,(e,t)=>{Ca.init(e,t),V.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Nc(){return zo(Mc)}var Pc=O(`ZodNever`,(e,t)=>{wa.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r)});function Fc(e){return Bo(Pc,e)}var Ic=O(`ZodArray`,(e,t)=>{Ea.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.element=t.element,ac(e,`ZodArray`,{min(e,t){return this.check(qo(e,t))},nonempty(e){return this.check(qo(1,e))},max(e,t){return this.check(Ko(e,t))},length(e,t){return this.check(Jo(e,t))},unwrap(){return this.element}})});function G(e,t){return ss(Ic,e,t)}var Lc=O(`ZodObject`,(e,t)=>{ja.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),A(e,`shape`,()=>t.shape),ac(e,`ZodObject`,{keyof(){return Gc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Nc()})},loose(){return this.clone({...this._zod.def,catchall:Nc()})},strict(){return this.clone({...this._zod.def,catchall:Fc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Sr(this,e)},safeExtend(e){return Cr(this,e)},merge(e){return wr(this,e)},pick(e){return br(this,e)},omit(e){return xr(this,e)},partial(...e){return Tr(Yc,this,e[0])},required(...e){return Er(al,this,e[0])}})});function K(e,t){return new Lc({type:`object`,shape:e??{},...N(t)})}var Rc=O(`ZodUnion`,(e,t)=>{Na.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.options=t.options});function q(e,t){return new Rc({type:`union`,options:e,...N(t)})}var zc=O(`ZodDiscriminatedUnion`,(e,t)=>{Rc.init(e,t),Pa.init(e,t)});function Bc(e,t,n){return new zc({type:`union`,options:t,discriminator:e,...N(n)})}var Vc=O(`ZodIntersection`,(e,t)=>{Fa.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r)});function Hc(e,t){return new Vc({type:`intersection`,left:e,right:t})}var Uc=O(`ZodRecord`,(e,t)=>{Ra.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function J(e,t,n){return!t||!t._zod?new Uc({type:`record`,keyType:H(),valueType:e,...N(t)}):new Uc({type:`record`,keyType:e,valueType:t,...N(n)})}var Wc=O(`ZodEnum`,(e,t)=>{za.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Wc({...t,checks:[],...N(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Wc({...t,checks:[],...N(r),entries:i})}});function Gc(e,t){return new Wc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...N(t)})}var Kc=O(`ZodLiteral`,(e,t)=>{Ba.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Y(e,t){return new Kc({type:`literal`,values:Array.isArray(e)?e:[e],...N(t)})}var qc=O(`ZodTransform`,(e,t)=>{Va.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $n(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Mr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Mr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Jc(e){return new qc({type:`transform`,transform:e})}var Yc=O(`ZodOptional`,(e,t)=>{Ua.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xc(e){return new Yc({type:`optional`,innerType:e})}var Zc=O(`ZodExactOptional`,(e,t)=>{Wa.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new Zc({type:`optional`,innerType:e})}var $c=O(`ZodNullable`,(e,t)=>{Ga.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function el(e){return new $c({type:`nullable`,innerType:e})}var tl=O(`ZodDefault`,(e,t)=>{Ka.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function nl(e,t){return new tl({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():hr(t)}})}var rl=O(`ZodPrefault`,(e,t)=>{Ja.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function il(e,t){return new rl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():hr(t)}})}var al=O(`ZodNonOptional`,(e,t)=>{Ya.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ol(e,t){return new al({type:`nonoptional`,innerType:e,...N(t)})}var sl=O(`ZodCatch`,(e,t)=>{Za.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function cl(e,t){return new sl({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var ll=O(`ZodPipe`,(e,t)=>{Qa.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fs(e,t,n,r),e.in=t.in,e.out=t.out});function ul(e,t){return new ll({type:`pipe`,in:e,out:t})}var dl=O(`ZodReadonly`,(e,t)=>{eo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Is(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fl(e){return new dl({type:`readonly`,innerType:e})}var pl=O(`ZodCustom`,(e,t)=>{no.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r)});function ml(e,t={}){return cs(pl,e,t)}function hl(e,t){return ls(e,t)}function gl(e){return`is`in e&&typeof e.is==`function`}function X(e){if(Object.defineProperty(e,"is",{value:t=>e.safeParse(t).success,enumerable:!0}),!gl(e))throw Error(`unreachable: is was just defined above`);return e}var _l=X(q([Y(`discoverable`),Y(`quiet`),Y(`dark`)])),vl=X(q([Y(`visible`),Y(`hidden`),Y(`ghost`)])),yl=X(q([Y(`active`),Y(`idle`),Y(`busy`),Y(`offline`)])),bl=X(q([Y(`public`),Y(`private`),Y(`secret`)])),xl=X(q([Y(`steer`),Y(`followUp`),Y(`info`)])),Sl=X(K({id:H(),version:W(),name:H(),harness:H(),cwd:H(),pid:W(),startedAt:H(),visibility:vl,status:yl,tags:G(H()),subscribedRooms:G(H())})),Cl=X(K({id:H(),version:W(),name:H(),type:bl,owner:H(),createdAt:H(),description:H(),members:G(H()),invited:G(H()),memberJoins:J(H(),W()),memberLeaves:J(H(),W()),invitedJoins:J(H(),W()),invitedLeaves:J(H(),W())})),wl=X(K({id:H(),from:H(),room:H(),content:H(),timestamp:H(),replyTo:H().optional(),readBy:G(H()),streamingBehavior:xl.optional()})),Tl=X(K({id:H(),from:H(),to:H(),content:H(),timestamp:H(),readBy:G(H()),streamingBehavior:xl.optional()})),El=X(q([Y(`timeout`),Y(`not_connected`),Y(`connection_lost`)])),Dl=X(Bc(`status`,[K({status:Y(`delivered`)}),K({status:Y(`read`)}),K({status:Y(`queued`),reason:El}),K({status:Y(`refused`),code:H()}),K({status:Y(`dropped`)}),K({status:Y(`expired`)})])),Ol=X(K({id:H(),name:H(),status:yl})),kl=X(Bc(`type`,[K({type:Y(`room_message`),message:wl}),K({type:Y(`dm`),message:Tl}),K({type:Y(`room_invite`),room:H(),roomDescription:H(),from:H(),fromName:H(),fromCwd:H()}),K({type:Y(`member_joined`),room:H(),agent:H()}),K({type:Y(`member_left`),room:H(),agent:H()}),K({type:Y(`room_members`),room:H(),members:G(Ol)}),K({type:Y(`member_status`),room:H(),agent:H(),status:yl}),K({type:Y(`delivery_status`),messageId:H(),agent:H(),delivery:Dl,room:H().optional()}),K({type:Y(`invite_declined`),room:H(),agent:H(),agentName:H(),reason:H()}),K({type:Y(`name_changed`),agent:H(),oldName:H(),newName:H()}),K({type:Y(`connection_request`),connectionId:H(),peerId:H(),dataPort:W(),name:H(),fingerprint:H()}),K({type:Y(`room_join_request`),room:H(),requesterId:H()}),K({type:Y(`capability_request`),requestId:H(),capability:H(),scopeKind:H(),scopePath:H().optional(),requesterDevice:H()})]));X(K({code:H(),expiresAt:H(),deviceId:H(),signature:H().optional()})),X(Bc(`action`,[K({action:Y(`register`),name:H(),visibility:vl,tags:G(H())}),K({action:Y(`update`),visibility:vl.optional(),status:yl.optional(),name:H().optional(),tags:G(H()).optional()}),K({action:Y(`whoami`)}),K({action:Y(`web_url`)}),K({action:Y(`create_room`),name:H(),type:bl,description:H()}),K({action:Y(`list_rooms`)}),K({action:Y(`join_room`),room:H()}),K({action:Y(`leave_room`),room:H()}),K({action:Y(`send`),target:H(),content:H(),replyTo:H().optional(),streamingBehavior:xl.optional()}),K({action:Y(`dm`),target:H(),content:H(),streamingBehavior:xl.optional()}),K({action:Y(`list_agents`)}),K({action:Y(`read_room`),room:H(),since:H().optional()}),K({action:Y(`invite`),room:H(),agent:H()}),K({action:Y(`kick`),room:H(),agent:H()}),K({action:Y(`decline_invite`),room:H(),reason:H()}),K({action:Y(`destroy_room`),room:H()}),K({action:Y(`mesh_connect`),host:H(),port:W(),policy:H().optional()}),K({action:Y(`mesh_accept`),connectionId:H()}),K({action:Y(`mesh_reject`),connectionId:H(),reason:H()}),K({action:Y(`mesh_pending`)}),K({action:Y(`room_accept`),room:H(),requesterId:H()}),K({action:Y(`room_reject`),room:H(),requesterId:H(),reason:H().optional()}),K({action:Y(`room_pending`)}),K({action:Y(`capability_accept`),requestId:H(),expires:W(),delegationsRemaining:W().optional(),capability:H().optional()}),K({action:Y(`capability_reject`),requestId:H(),reason:H().optional()}),K({action:Y(`capability_pending`)}),K({action:Y(`mesh_discover`),method:H().optional()}),K({action:Y(`mesh_advertise`),method:H(),name:H(),port:W().optional(),adapter:H().optional()}),K({action:Y(`mesh_unadvertise`),id:H()}),K({action:Y(`mesh_interfaces`)}),K({action:Y(`mesh_listen`),host:H(),port:W().optional(),policy:H().optional()}),K({action:Y(`mesh_unlisten`),id:H()}),K({action:Y(`mesh_listeners`)}),K({action:Y(`mesh_set_visibility`),visibility:_l,adapter:H().optional()}),K({action:Y(`mesh_get_visibility`)}),K({action:Y(`gateway_trust`),device:H(),principal:jc().optional(),machine:jc().optional()}),K({action:Y(`gateway_untrust`),device:H(),principal:jc().optional(),machine:jc().optional()}),K({action:Y(`gateway_list_trusted`)}),K({action:Y(`petname_set`),device:H(),name:H()}),K({action:Y(`petname_clear`),device:H()}),K({action:Y(`petname_list`)}),K({action:Y(`machine_name`),name:H().optional()}),K({action:Y(`dm_admit`),target:H(),principal:jc().optional()}),K({action:Y(`dm_use_grant`),target:H(),grant:H()}),K({action:Y(`dm_revoke`),target:H()}),K({action:Y(`gateway_generate_connection_code`),ttlMs:W().optional(),privateKey:H().optional(),passphrase:H().optional()}),K({action:Y(`gateway_redeem_connection_code`),code:H(),expiresAt:H(),device:H(),signature:H().optional(),publicKey:H().optional(),fingerprint:H().optional()}),K({action:Y(`query_version`),device:H()}),K({action:Y(`mesh_graph`)}),K({action:Y(`mesh_trace`),target:H(),timeoutMs:W().optional()})]));var Z=K({content:H(),isError:jc()}),Al=q([Y(`public`),Y(`private`),Y(`secret`)]),jl=K({kind:q([Y(`direct`),Y(`relay`)]),from:H(),to:H(),via:H().optional()}),Ml=K({nodes:G(H()),edges:G(jl)}),Nl=K({id:H(),petname:H().optional(),selfName:H().optional()}),Pl=K({relayed:jc(),hubAddress:H().optional()}),Fl=K({rttMs:W(),local:Pl,remote:Pl.optional(),outcome:K({result:H(),code:H().optional()}).loose()}),Il=Bc(`type`,[K({type:Y(`agent_upsert`),agent:Sl}),K({type:Y(`agent_offline`),agentId:H()}),K({type:Y(`room_upsert`),room:Cl}),K({type:Y(`room_delete`),roomId:H()}),K({type:Y(`message_add`),roomId:H(),message:wl}),K({type:Y(`dm_add`),key:H(),message:Tl}),K({type:Y(`delivery`),agentId:H(),event:kl})]),Ll=K({agents:J(H(),Sl),rooms:J(H(),Cl),messages:J(H(),G(wl)),dms:J(H(),G(Tl))}),Rl=Bc(`kind`,[K({kind:Y(`state_sync`),state:Ll}),K({kind:Y(`state_patch`),patch:Il}),K({kind:Y(`delivery`),event:kl})]),zl=K({endpoint:H(),keys:K({p256dh:H(),auth:H()})}),Bl={send:w.input(K({target:H(),content:H()})).output(Z),dm:w.input(K({target:H(),content:H()})).output(Z),joinRoom:w.input(K({room:H()})).output(Z),leaveRoom:w.input(K({room:H().optional()})).output(Z),createRoom:w.input(K({name:H(),type:Al,description:H().optional()})).output(Z),listRooms:w.input(K({})).output(Z),listAgents:w.input(K({})).output(Z),readRoom:w.input(K({room:H().optional()})).output(Z),destroyRoom:w.input(K({room:H()})).output(Z),invite:w.input(K({room:H(),agent:H()})).output(Z),declineInvite:w.input(K({room:H(),reason:H()})).output(Z),kick:w.input(K({room:H(),agent:H()})).output(Z),renameAgent:w.input(K({agent:H(),name:H()})).output(Z),pushSubscribe:w.input(K({subscription:zl,agentId:H().optional()})).output(Z),pushUnsubscribe:w.input(K({agentId:H().optional()})).output(Z),subscribeEvents:w.input(K({lastEventId:H().optional()})).output(pn(Rl)),getRoomMessages:w.input(K({room:H(),since:H().optional()})).output(G(wl)),getMeshGraph:w.input(K({})).output(Ml),getDisplayNames:w.input(K({})).output(G(Nl)),getMeshTrace:w.input(K({target:H(),timeoutMs:W().optional()})).output(Fl),disconnect:w.input(K({})).output(K({}))};function Vl(e){if(typeof e!=`object`||!e||!(`endpoint`in e)||typeof e.endpoint!=`string`||!(`keys`in e))return!1;let t=e.keys;return!(typeof t!=`object`||!t||!(`p256dh`in t)||typeof t.p256dh!=`string`||!(`auth`in t)||typeof t.auth!=`string`)}async function Hl(e,t){let n=e=>{let n=t[e];return typeof n==`string`?n:``},r=e=>{let n=t[e];return typeof n==`string`?n:void 0},i=()=>{let e=t.type;return e===`public`||e===`private`||e===`secret`?e:`public`};switch(t.action){case`send`:return e.send({target:n(`target`),content:n(`content`)});case`dm`:return e.dm({target:n(`target`),content:n(`content`)});case`join_room`:return e.joinRoom({room:n(`room`)});case`leave_room`:return e.leaveRoom({room:r(`room`)});case`create_room`:return e.createRoom({name:n(`name`),type:i(),description:r(`description`)});case`list_rooms`:return e.listRooms({});case`list_agents`:return e.listAgents({});case`read_room`:return e.readRoom({room:r(`room`)});case`destroy_room`:return e.destroyRoom({room:n(`room`)});case`invite`:return e.invite({room:n(`room`),agent:n(`agent`)});case`decline_invite`:return e.declineInvite({room:n(`room`),reason:n(`reason`)});case`kick`:return e.kick({room:n(`room`),agent:n(`agent`)});case`rename_agent`:return e.renameAgent({agent:n(`agent`),name:n(`name`)});case`push_subscribe`:{let n=t.subscription;return Vl(n)?e.pushSubscribe({subscription:n,agentId:r(`agentId`)}):{content:`Invalid push subscription`,isError:!0}}case`push_unsubscribe`:return e.pushUnsubscribe({agentId:r(`agentId`)});default:return{content:`Unknown action: ${String(t.action)}`,isError:!0}}}var Ul=new Map,Wl=new Map,Gl=new Map,Kl=new Map;function ql(e){for(let[t,n]of Object.entries(e.agents))Ul.set(t,n);for(let[t,n]of Object.entries(e.rooms))Wl.set(t,n);for(let[t,n]of Object.entries(e.messages))Gl.set(t,n);for(let[t,n]of Object.entries(e.dms))Kl.set(t,n)}function Jl(e){switch(e.type){case`agent_upsert`:Ul.set(e.agent.id,e.agent);break;case`agent_offline`:{let t=Ul.get(e.agentId);t&&(t.status=`offline`,Ul.set(e.agentId,t));break}case`room_upsert`:Wl.set(e.room.id,e.room);break;case`room_delete`:Wl.delete(e.roomId);break;case`message_add`:{let t=Gl.get(e.roomId)??[];t.push(e.message),Gl.set(e.roomId,t);break}case`dm_add`:{let t=Kl.get(e.key)??[];t.push(e.message),Kl.set(e.key,t);break}case`delivery`:break;case`message_read`:if(e.room!==void 0){let t=Gl.get(e.room);if(t){let n=t.find(t=>t.id===e.messageId);n&&!n.readBy.includes(e.readBy)&&n.readBy.push(e.readBy)}}else for(let[,t]of Kl){let n=t.find(t=>t.id===e.messageId);n&&!n.readBy.includes(e.readBy)&&n.readBy.push(e.readBy)}}}function Yl(){return{agents:[...Ul.values()],rooms:[...Wl.values()]}}var Xl,Zl=0,Ql,$l=new Xn,eu=1e3,tu=3e4;function nu(e){let t=Ct(new nn({connect:async()=>{let t=new WebSocket(e);return Ql=t,t.addEventListener(`open`,()=>{ou({type:`connected`})}),t.addEventListener(`close`,()=>{ou({type:`disconnected`})}),new Promise((e,n)=>{t.addEventListener(`open`,()=>{e(t)},{once:!0}),t.addEventListener(`error`,n,{once:!0})})},reconnect:{enabled:!0,delay:e=>e.attempt===1?0:Math.min(eu*2**e.attempt,tu)},plugins:[new rn]}));Xl=t,iu(t,++Zl)}function ru(){++Zl,Xl=void 0,Ql?.close(),Ql=void 0}async function iu(e,t){let n;for(;t===Zl;)try{let r=await e.subscribeEvents(n===void 0?{}:{lastEventId:n});for await(let e of r){if(t!==Zl)return;let r=qe(e);switch(r?.id!==void 0&&(n=r.id),$l.publish(e),e.kind){case`state_sync`:ql(e.state),ou({type:`state`,state:Yl()});break;case`state_patch`:Jl(e.patch),ou({type:`patch`,patch:e.patch})}}return}catch{}}var au=new Set;function ou(e){let t=JSON.stringify(e);for(let e of au)try{e.postMessage(t)}catch{}}function su(e){switch(e.type){case`init`:nu(e.url);break;case`action`:{let t=Xl;if(!t)break;let n=e.id;Hl(t,e.action).then(e=>{ou({type:`actionResult`,id:n,result:e})}).catch(e=>{ou({type:`actionError`,id:n,message:e instanceof Error?e.message:String(e)})});break}case`getState`:ou({type:`state`,state:Yl()})}}function cu(e){if(typeof e!=`object`||!e||!(`type`in e))return!1;let t=e.type;return typeof t==`string`&&(t===`init`||t===`action`||t===`getState`)}function lu(){return{agents:Object.fromEntries(Ul),rooms:Object.fromEntries(Wl),messages:Object.fromEntries(Gl),dms:Object.fromEntries(Kl)}}async function Q(e){return Xl?Hl(Xl,e):{content:`Not connected to mesh yet`,isError:!0}}function uu(){if(!Xl)throw Error(`Not connected to mesh yet`);return Xl}var $=Fn(Bl).$context(),du={};du.current=new qn({send:$.send.handler(async({input:e})=>Q({action:`send`,...e})),dm:$.dm.handler(async({input:e})=>Q({action:`dm`,...e})),joinRoom:$.joinRoom.handler(async({input:e})=>Q({action:`join_room`,room:e.room})),leaveRoom:$.leaveRoom.handler(async({input:e})=>Q({action:`leave_room`,room:e.room})),createRoom:$.createRoom.handler(async({input:e})=>Q({action:`create_room`,name:e.name,type:e.type,description:e.description})),listRooms:$.listRooms.handler(async()=>Q({action:`list_rooms`})),listAgents:$.listAgents.handler(async()=>Q({action:`list_agents`})),readRoom:$.readRoom.handler(async({input:e})=>Q({action:`read_room`,room:e.room})),destroyRoom:$.destroyRoom.handler(async({input:e})=>Q({action:`destroy_room`,room:e.room})),invite:$.invite.handler(async({input:e})=>Q({action:`invite`,room:e.room,agent:e.agent})),declineInvite:$.declineInvite.handler(async({input:e})=>Q({action:`decline_invite`,room:e.room,reason:e.reason})),kick:$.kick.handler(async({input:e})=>Q({action:`kick`,room:e.room,agent:e.agent})),renameAgent:$.renameAgent.handler(async({input:e})=>Q({action:`rename_agent`,agent:e.agent,name:e.name})),pushSubscribe:$.pushSubscribe.handler(async({input:e})=>Q({action:`push_subscribe`,subscription:e.subscription,agentId:e.agentId})),pushUnsubscribe:$.pushUnsubscribe.handler(async({input:e})=>Q({action:`push_unsubscribe`,agentId:e.agentId})),getRoomMessages:$.getRoomMessages.handler(async({input:e})=>uu().getRoomMessages(e)),getMeshGraph:$.getMeshGraph.handler(async()=>uu().getMeshGraph({})),getDisplayNames:$.getDisplayNames.handler(async()=>uu().getDisplayNames({})),getMeshTrace:$.getMeshTrace.handler(async({input:e})=>uu().getMeshTrace(e)),subscribeEvents:$.subscribeEvents.handler(async function*({input:e,signal:t}){e.lastEventId===void 0&&(yield{kind:`state_sync`,state:lu()}),yield*$l.subscribe({...t?{signal:t}:{},...e.lastEventId===void 0?{}:{lastEventId:e.lastEventId}})}),disconnect:$.disconnect.handler(({context:e})=>(setTimeout(()=>{du.current?.close(e.port)},0),{}))});function fu(e){du.current?.upgrade(e,{context:{port:e}})}return typeof self<`u`&&self.addEventListener(`connect`,e=>{let t=e.ports[0];if(t!==void 0){au.add(t);try{t.postMessage(JSON.stringify({type:`state`,state:Yl()}))}catch{}t.onmessage=e=>{let t=JSON.parse(typeof e.data==`string`?e.data:String(e.data));cu(t)&&su(t)},fu(t)}}),e.agents=Ul,e.applyPatch=Jl,e.applyStateSync=ql,e.connect=nu,e.disconnect=ru,e.dms=Kl,e.getStateSnapshot=Yl,e.localPublisher=$l,e.messages=Gl,e.ports=au,e.rooms=Wl,e.upgradeTabRpcPort=fu,e})({});
64
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function ps(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:hs(t,`input`,e.processors),output:hs(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function z(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return z(r.element,n);if(r.type===`set`)return z(r.valueType,n);if(r.type===`lazy`)return z(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return z(r.innerType,n);if(r.type===`intersection`)return z(r.left,n)||z(r.right,n);if(r.type===`record`||r.type===`map`)return z(r.keyType,n)||z(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:z(r.in,n)||z(r.out,n);if(r.type===`object`){for(let e in r.shape)if(z(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(z(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(z(e,n))return!0;return!!(r.rest&&z(r.rest,n))}return!1}var ms=(e,t={})=>n=>{let r=ds({...n,processors:t});return R(e,r),fs(r,e),ps(r,e)},hs=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ds({...i??{},target:a,io:t,processors:n});return R(e,o),fs(o,e),ps(o,e)},gs={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},_s=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=gs[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},vs=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},ys=(e,t,n,r)=>{n.type=`boolean`},bs=(e,t,n,r)=>{n.not={}},xs=(e,t,n,r)=>{let i=e._zod.def,a=tr(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ss=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Cs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ws=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Ts=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=R(a.element,t,{...r,path:[...r.path,`items`]})},Es=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=R(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=R(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ds=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>R(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Os=(e,t,n,r)=>{let i=e._zod.def,a=R(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=R(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},ks=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=R(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=R(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=R(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},As=(e,t,n,r)=>{let i=e._zod.def,a=R(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},js=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ms=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ns=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Ps=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Fs=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;R(o,t,r);let s=t.seen.get(e);s.ref=o},Is=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ls=(e,t,n,r)=>{let i=e._zod.def;R(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Rs=O(`ZodISODateTime`,(e,t)=>{aa.init(e,t),U.init(e,t)});function zs(e){return Mo(Rs,e)}var Bs=O(`ZodISODate`,(e,t)=>{oa.init(e,t),U.init(e,t)});function Vs(e){return No(Bs,e)}var Hs=O(`ZodISOTime`,(e,t)=>{sa.init(e,t),U.init(e,t)});function Us(e){return Po(Hs,e)}var Ws=O(`ZodISODuration`,(e,t)=>{ca.init(e,t),U.init(e,t)});function Gs(e){return Fo(Ws,e)}var B=O(`ZodError`,(e,t)=>{Pr.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Lr(e,t)},flatten:{value:t=>Ir(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,nr,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,nr,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ks=Rr(B),qs=zr(B),Js=Br(B),Ys=Hr(B),Xs=Wr(B),Zs=Gr(B),Qs=Kr(B),$s=qr(B),ec=Jr(B),tc=Yr(B),nc=Xr(B),rc=Zr(B),ic=new WeakMap;function ac(e,t,n){let r=Object.getPrototypeOf(e),i=ic.get(r);if(i||(i=new Set,ic.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var V=O(`ZodType`,(e,t)=>(I.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:hs(e,`input`),output:hs(e,`output`)}}),e.toJSONSchema=ms(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ks(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Js(e,t,n),e.parseAsync=async(t,n)=>qs(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ys(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Xs(e,t,n),e.decode=(t,n)=>Zs(e,t,n),e.encodeAsync=async(t,n)=>Qs(e,t,n),e.decodeAsync=async(t,n)=>$s(e,t,n),e.safeEncode=(t,n)=>ec(e,t,n),e.safeDecode=(t,n)=>tc(e,t,n),e.safeEncodeAsync=async(t,n)=>nc(e,t,n),e.safeDecodeAsync=async(t,n)=>rc(e,t,n),ac(e,`ZodType`,{check(...e){let t=this.def;return this.clone(j(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return M(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ml(e,t))},superRefine(e,t){return this.check(hl(e,t))},overwrite(e){return this.check(ts(e))},optional(){return Xc(this)},exactOptional(){return Qc(this)},nullable(){return el(this)},nullish(){return Xc(el(this))},nonoptional(e){return ol(this,e)},array(){return G(this)},or(e){return q([this,e])},and(e){return Hc(this,e)},transform(e){return ul(this,Jc(e))},default(e){return nl(this,e)},prefault(e){return il(this,e)},catch(e){return cl(this,e)},pipe(e){return ul(this,e)},readonly(){return fl(this)},describe(e){let t=this.clone();return so.add(t,{description:e}),t},meta(...e){if(e.length===0)return so.get(this);let t=this.clone();return so.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return so.get(e)?.description},configurable:!0}),e)),oc=O(`_ZodString`,(e,t)=>{qi.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_s(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ac(e,`_ZodString`,{regex(...e){return this.check(Yo(...e))},includes(...e){return this.check(Qo(...e))},startsWith(...e){return this.check($o(...e))},endsWith(...e){return this.check(es(...e))},min(...e){return this.check(qo(...e))},max(...e){return this.check(Ko(...e))},length(...e){return this.check(Jo(...e))},nonempty(...e){return this.check(qo(1,...e))},lowercase(e){return this.check(Xo(e))},uppercase(e){return this.check(Zo(e))},trim(){return this.check(rs())},normalize(...e){return this.check(ns(...e))},toLowerCase(){return this.check(is())},toUpperCase(){return this.check(as())},slugify(){return this.check(os())}})}),sc=O(`ZodString`,(e,t)=>{qi.init(e,t),oc.init(e,t),e.email=t=>e.check(lo(cc,t)),e.url=t=>e.check(go(dc,t)),e.jwt=t=>e.check(jo(Ec,t)),e.emoji=t=>e.check(_o(fc,t)),e.guid=t=>e.check(uo(lc,t)),e.uuid=t=>e.check(fo(uc,t)),e.uuidv4=t=>e.check(po(uc,t)),e.uuidv6=t=>e.check(mo(uc,t)),e.uuidv7=t=>e.check(ho(uc,t)),e.nanoid=t=>e.check(vo(pc,t)),e.guid=t=>e.check(uo(lc,t)),e.cuid=t=>e.check(yo(mc,t)),e.cuid2=t=>e.check(bo(hc,t)),e.ulid=t=>e.check(xo(gc,t)),e.base64=t=>e.check(Oo(Cc,t)),e.base64url=t=>e.check(ko(wc,t)),e.xid=t=>e.check(So(_c,t)),e.ksuid=t=>e.check(Co(vc,t)),e.ipv4=t=>e.check(wo(yc,t)),e.ipv6=t=>e.check(To(bc,t)),e.cidrv4=t=>e.check(Eo(xc,t)),e.cidrv6=t=>e.check(Do(Sc,t)),e.e164=t=>e.check(Ao(Tc,t)),e.datetime=t=>e.check(zs(t)),e.date=t=>e.check(Vs(t)),e.time=t=>e.check(Us(t)),e.duration=t=>e.check(Gs(t))});function H(e){return co(sc,e)}var U=O(`ZodStringFormat`,(e,t)=>{L.init(e,t),oc.init(e,t)}),cc=O(`ZodEmail`,(e,t)=>{Xi.init(e,t),U.init(e,t)}),lc=O(`ZodGUID`,(e,t)=>{Ji.init(e,t),U.init(e,t)}),uc=O(`ZodUUID`,(e,t)=>{Yi.init(e,t),U.init(e,t)}),dc=O(`ZodURL`,(e,t)=>{Zi.init(e,t),U.init(e,t)}),fc=O(`ZodEmoji`,(e,t)=>{Qi.init(e,t),U.init(e,t)}),pc=O(`ZodNanoID`,(e,t)=>{$i.init(e,t),U.init(e,t)}),mc=O(`ZodCUID`,(e,t)=>{ea.init(e,t),U.init(e,t)}),hc=O(`ZodCUID2`,(e,t)=>{ta.init(e,t),U.init(e,t)}),gc=O(`ZodULID`,(e,t)=>{na.init(e,t),U.init(e,t)}),_c=O(`ZodXID`,(e,t)=>{ra.init(e,t),U.init(e,t)}),vc=O(`ZodKSUID`,(e,t)=>{ia.init(e,t),U.init(e,t)}),yc=O(`ZodIPv4`,(e,t)=>{la.init(e,t),U.init(e,t)}),bc=O(`ZodIPv6`,(e,t)=>{ua.init(e,t),U.init(e,t)}),xc=O(`ZodCIDRv4`,(e,t)=>{da.init(e,t),U.init(e,t)}),Sc=O(`ZodCIDRv6`,(e,t)=>{fa.init(e,t),U.init(e,t)}),Cc=O(`ZodBase64`,(e,t)=>{ma.init(e,t),U.init(e,t)}),wc=O(`ZodBase64URL`,(e,t)=>{ga.init(e,t),U.init(e,t)}),Tc=O(`ZodE164`,(e,t)=>{_a.init(e,t),U.init(e,t)}),Ec=O(`ZodJWT`,(e,t)=>{ya.init(e,t),U.init(e,t)}),Dc=O(`ZodNumber`,(e,t)=>{ba.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),ac(e,`ZodNumber`,{gt(e,t){return this.check(Uo(e,t))},gte(e,t){return this.check(Wo(e,t))},min(e,t){return this.check(Wo(e,t))},lt(e,t){return this.check(Vo(e,t))},lte(e,t){return this.check(Ho(e,t))},max(e,t){return this.check(Ho(e,t))},int(e){return this.check(kc(e))},safe(e){return this.check(kc(e))},positive(e){return this.check(Uo(0,e))},nonnegative(e){return this.check(Wo(0,e))},negative(e){return this.check(Vo(0,e))},nonpositive(e){return this.check(Ho(0,e))},multipleOf(e,t){return this.check(Go(e,t))},step(e,t){return this.check(Go(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function W(e){return Io(Dc,e)}var Oc=O(`ZodNumberFormat`,(e,t)=>{xa.init(e,t),Dc.init(e,t)});function kc(e){return Lo(Oc,e)}var Ac=O(`ZodBoolean`,(e,t)=>{Sa.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r)});function jc(e){return Ro(Ac,e)}var Mc=O(`ZodUnknown`,(e,t)=>{Ca.init(e,t),V.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Nc(){return zo(Mc)}var Pc=O(`ZodNever`,(e,t)=>{wa.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r)});function Fc(e){return Bo(Pc,e)}var Ic=O(`ZodArray`,(e,t)=>{Ea.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.element=t.element,ac(e,`ZodArray`,{min(e,t){return this.check(qo(e,t))},nonempty(e){return this.check(qo(1,e))},max(e,t){return this.check(Ko(e,t))},length(e,t){return this.check(Jo(e,t))},unwrap(){return this.element}})});function G(e,t){return ss(Ic,e,t)}var Lc=O(`ZodObject`,(e,t)=>{ja.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),A(e,`shape`,()=>t.shape),ac(e,`ZodObject`,{keyof(){return Gc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Nc()})},loose(){return this.clone({...this._zod.def,catchall:Nc()})},strict(){return this.clone({...this._zod.def,catchall:Fc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Sr(this,e)},safeExtend(e){return Cr(this,e)},merge(e){return wr(this,e)},pick(e){return br(this,e)},omit(e){return xr(this,e)},partial(...e){return Tr(Yc,this,e[0])},required(...e){return Er(al,this,e[0])}})});function K(e,t){return new Lc({type:`object`,shape:e??{},...N(t)})}var Rc=O(`ZodUnion`,(e,t)=>{Na.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.options=t.options});function q(e,t){return new Rc({type:`union`,options:e,...N(t)})}var zc=O(`ZodDiscriminatedUnion`,(e,t)=>{Rc.init(e,t),Pa.init(e,t)});function Bc(e,t,n){return new zc({type:`union`,options:t,discriminator:e,...N(n)})}var Vc=O(`ZodIntersection`,(e,t)=>{Fa.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r)});function Hc(e,t){return new Vc({type:`intersection`,left:e,right:t})}var Uc=O(`ZodRecord`,(e,t)=>{Ra.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ks(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function J(e,t,n){return!t||!t._zod?new Uc({type:`record`,keyType:H(),valueType:e,...N(t)}):new Uc({type:`record`,keyType:e,valueType:t,...N(n)})}var Wc=O(`ZodEnum`,(e,t)=>{za.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Wc({...t,checks:[],...N(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Wc({...t,checks:[],...N(r),entries:i})}});function Gc(e,t){return new Wc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...N(t)})}var Kc=O(`ZodLiteral`,(e,t)=>{Ba.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ss(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Y(e,t){return new Kc({type:`literal`,values:Array.isArray(e)?e:[e],...N(t)})}var qc=O(`ZodTransform`,(e,t)=>{Va.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $n(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Mr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Mr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Jc(e){return new qc({type:`transform`,transform:e})}var Yc=O(`ZodOptional`,(e,t)=>{Ua.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xc(e){return new Yc({type:`optional`,innerType:e})}var Zc=O(`ZodExactOptional`,(e,t)=>{Wa.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new Zc({type:`optional`,innerType:e})}var $c=O(`ZodNullable`,(e,t)=>{Ga.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>As(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function el(e){return new $c({type:`nullable`,innerType:e})}var tl=O(`ZodDefault`,(e,t)=>{Ka.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function nl(e,t){return new tl({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():hr(t)}})}var rl=O(`ZodPrefault`,(e,t)=>{Ja.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function il(e,t){return new rl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():hr(t)}})}var al=O(`ZodNonOptional`,(e,t)=>{Ya.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ol(e,t){return new al({type:`nonoptional`,innerType:e,...N(t)})}var sl=O(`ZodCatch`,(e,t)=>{Za.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function cl(e,t){return new sl({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var ll=O(`ZodPipe`,(e,t)=>{Qa.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fs(e,t,n,r),e.in=t.in,e.out=t.out});function ul(e,t){return new ll({type:`pipe`,in:e,out:t})}var dl=O(`ZodReadonly`,(e,t)=>{eo.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Is(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fl(e){return new dl({type:`readonly`,innerType:e})}var pl=O(`ZodCustom`,(e,t)=>{no.init(e,t),V.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r)});function ml(e,t={}){return cs(pl,e,t)}function hl(e,t){return ls(e,t)}function gl(e){return`is`in e&&typeof e.is==`function`}function X(e){if(Object.defineProperty(e,"is",{value:t=>e.safeParse(t).success,enumerable:!0}),!gl(e))throw Error(`unreachable: is was just defined above`);return e}var _l=X(q([Y(`discoverable`),Y(`quiet`),Y(`dark`)])),vl=X(q([Y(`visible`),Y(`hidden`),Y(`ghost`)])),yl=X(q([Y(`active`),Y(`idle`),Y(`busy`),Y(`offline`)])),bl=X(q([Y(`public`),Y(`private`),Y(`secret`)])),xl=X(q([Y(`steer`),Y(`followUp`),Y(`info`)])),Sl=X(K({id:H(),version:W(),name:H(),harness:H(),cwd:H(),pid:W(),startedAt:H(),visibility:vl,status:yl,tags:G(H()),subscribedRooms:G(H())})),Cl=X(K({id:H(),version:W(),name:H(),type:bl,owner:H(),createdAt:H(),description:H(),members:G(H()),invited:G(H()),memberJoins:J(H(),W()),memberLeaves:J(H(),W()),invitedJoins:J(H(),W()),invitedLeaves:J(H(),W())})),wl=X(K({id:H(),from:H(),room:H(),content:H(),timestamp:H(),replyTo:H().optional(),readBy:G(H()),streamingBehavior:xl.optional()})),Tl=X(K({id:H(),from:H(),to:H(),content:H(),timestamp:H(),readBy:G(H()),streamingBehavior:xl.optional()})),El=X(q([Y(`timeout`),Y(`not_connected`),Y(`connection_lost`)])),Dl=X(Bc(`status`,[K({status:Y(`delivered`)}),K({status:Y(`read`)}),K({status:Y(`queued`),reason:El}),K({status:Y(`refused`),code:H()}),K({status:Y(`dropped`)}),K({status:Y(`expired`)})])),Ol=X(K({id:H(),name:H(),status:yl})),kl=X(Bc(`type`,[K({type:Y(`room_message`),message:wl}),K({type:Y(`dm`),message:Tl}),K({type:Y(`room_invite`),room:H(),roomDescription:H(),from:H(),fromName:H(),fromCwd:H()}),K({type:Y(`member_joined`),room:H(),agent:H()}),K({type:Y(`member_left`),room:H(),agent:H()}),K({type:Y(`room_members`),room:H(),members:G(Ol)}),K({type:Y(`member_status`),room:H(),agent:H(),status:yl}),K({type:Y(`delivery_status`),messageId:H(),agent:H(),delivery:Dl,room:H().optional()}),K({type:Y(`invite_declined`),room:H(),agent:H(),agentName:H(),reason:H()}),K({type:Y(`name_changed`),agent:H(),oldName:H(),newName:H()}),K({type:Y(`connection_request`),connectionId:H(),peerId:H(),dataPort:W(),name:H(),fingerprint:H()}),K({type:Y(`room_join_request`),room:H(),requesterId:H()}),K({type:Y(`capability_request`),requestId:H(),capability:H(),scopeKind:H(),scopePath:H().optional(),requesterDevice:H()})]));X(K({code:H(),expiresAt:H(),deviceId:H(),signature:H().optional()})),X(Bc(`action`,[K({action:Y(`register`),name:H(),visibility:vl,tags:G(H())}),K({action:Y(`update`),visibility:vl.optional(),status:yl.optional(),name:H().optional(),tags:G(H()).optional()}),K({action:Y(`whoami`)}),K({action:Y(`web_url`)}),K({action:Y(`create_room`),name:H(),type:bl,description:H()}),K({action:Y(`list_rooms`)}),K({action:Y(`join_room`),room:H()}),K({action:Y(`leave_room`),room:H()}),K({action:Y(`send`),target:H(),content:H(),replyTo:H().optional(),streamingBehavior:xl.optional()}),K({action:Y(`dm`),target:H(),content:H(),streamingBehavior:xl.optional()}),K({action:Y(`list_agents`)}),K({action:Y(`read_room`),room:H(),since:H().optional()}),K({action:Y(`invite`),room:H(),agent:H()}),K({action:Y(`kick`),room:H(),agent:H()}),K({action:Y(`decline_invite`),room:H(),reason:H()}),K({action:Y(`destroy_room`),room:H()}),K({action:Y(`mesh_connect`),host:H(),port:W(),policy:H().optional()}),K({action:Y(`mesh_accept`),connectionId:H()}),K({action:Y(`mesh_reject`),connectionId:H(),reason:H()}),K({action:Y(`mesh_pending`)}),K({action:Y(`room_accept`),room:H(),requesterId:H()}),K({action:Y(`room_reject`),room:H(),requesterId:H(),reason:H().optional()}),K({action:Y(`room_pending`)}),K({action:Y(`capability_accept`),requestId:H(),expires:W(),delegationsRemaining:W().optional(),capability:H().optional()}),K({action:Y(`capability_reject`),requestId:H(),reason:H().optional()}),K({action:Y(`capability_pending`)}),K({action:Y(`mesh_discover`),method:H().optional()}),K({action:Y(`mesh_advertise`),method:H(),name:H(),port:W().optional(),adapter:H().optional()}),K({action:Y(`mesh_unadvertise`),id:H()}),K({action:Y(`mesh_interfaces`)}),K({action:Y(`mesh_listen`),host:H(),port:W().optional(),policy:H().optional()}),K({action:Y(`mesh_unlisten`),id:H()}),K({action:Y(`mesh_listeners`)}),K({action:Y(`mesh_set_visibility`),visibility:_l,adapter:H().optional()}),K({action:Y(`mesh_get_visibility`)}),K({action:Y(`gateway_trust`),device:H(),principal:jc().optional(),machine:jc().optional()}),K({action:Y(`gateway_untrust`),device:H(),principal:jc().optional(),machine:jc().optional()}),K({action:Y(`gateway_list_trusted`)}),K({action:Y(`petname_set`),device:H(),name:H()}),K({action:Y(`petname_clear`),device:H()}),K({action:Y(`petname_list`)}),K({action:Y(`machine_name`),name:H().optional()}),K({action:Y(`principal_name`),name:H().optional()}),K({action:Y(`dm_admit`),target:H(),principal:jc().optional()}),K({action:Y(`dm_use_grant`),target:H(),grant:H()}),K({action:Y(`dm_revoke`),target:H()}),K({action:Y(`gateway_generate_connection_code`),ttlMs:W().optional(),privateKey:H().optional(),passphrase:H().optional()}),K({action:Y(`gateway_redeem_connection_code`),code:H(),expiresAt:H(),device:H(),signature:H().optional(),publicKey:H().optional(),fingerprint:H().optional()}),K({action:Y(`query_version`),device:H()}),K({action:Y(`mesh_graph`)}),K({action:Y(`mesh_trace`),target:H(),timeoutMs:W().optional()})]));var Z=K({content:H(),isError:jc()}),Al=q([Y(`public`),Y(`private`),Y(`secret`)]),jl=K({kind:q([Y(`direct`),Y(`relay`)]),from:H(),to:H(),via:H().optional()}),Ml=K({nodes:G(H()),edges:G(jl)}),Nl=K({id:H(),petname:H().optional(),selfName:H().optional()}),Pl=K({relayed:jc(),hubAddress:H().optional()}),Fl=K({rttMs:W(),local:Pl,remote:Pl.optional(),outcome:K({result:H(),code:H().optional()}).loose()}),Il=Bc(`type`,[K({type:Y(`agent_upsert`),agent:Sl}),K({type:Y(`agent_offline`),agentId:H()}),K({type:Y(`room_upsert`),room:Cl}),K({type:Y(`room_delete`),roomId:H()}),K({type:Y(`message_add`),roomId:H(),message:wl}),K({type:Y(`dm_add`),key:H(),message:Tl}),K({type:Y(`delivery`),agentId:H(),event:kl})]),Ll=K({agents:J(H(),Sl),rooms:J(H(),Cl),messages:J(H(),G(wl)),dms:J(H(),G(Tl))}),Rl=Bc(`kind`,[K({kind:Y(`state_sync`),state:Ll}),K({kind:Y(`state_patch`),patch:Il}),K({kind:Y(`delivery`),event:kl})]),zl=K({endpoint:H(),keys:K({p256dh:H(),auth:H()})}),Bl={send:w.input(K({target:H(),content:H()})).output(Z),dm:w.input(K({target:H(),content:H()})).output(Z),joinRoom:w.input(K({room:H()})).output(Z),leaveRoom:w.input(K({room:H().optional()})).output(Z),createRoom:w.input(K({name:H(),type:Al,description:H().optional()})).output(Z),listRooms:w.input(K({})).output(Z),listAgents:w.input(K({})).output(Z),readRoom:w.input(K({room:H().optional()})).output(Z),destroyRoom:w.input(K({room:H()})).output(Z),invite:w.input(K({room:H(),agent:H()})).output(Z),declineInvite:w.input(K({room:H(),reason:H()})).output(Z),kick:w.input(K({room:H(),agent:H()})).output(Z),renameAgent:w.input(K({agent:H(),name:H()})).output(Z),pushSubscribe:w.input(K({subscription:zl,agentId:H().optional()})).output(Z),pushUnsubscribe:w.input(K({agentId:H().optional()})).output(Z),subscribeEvents:w.input(K({lastEventId:H().optional()})).output(pn(Rl)),getRoomMessages:w.input(K({room:H(),since:H().optional()})).output(G(wl)),getMeshGraph:w.input(K({})).output(Ml),getDisplayNames:w.input(K({})).output(G(Nl)),getMeshTrace:w.input(K({target:H(),timeoutMs:W().optional()})).output(Fl),disconnect:w.input(K({})).output(K({}))};function Vl(e){if(typeof e!=`object`||!e||!(`endpoint`in e)||typeof e.endpoint!=`string`||!(`keys`in e))return!1;let t=e.keys;return!(typeof t!=`object`||!t||!(`p256dh`in t)||typeof t.p256dh!=`string`||!(`auth`in t)||typeof t.auth!=`string`)}async function Hl(e,t){let n=e=>{let n=t[e];return typeof n==`string`?n:``},r=e=>{let n=t[e];return typeof n==`string`?n:void 0},i=()=>{let e=t.type;return e===`public`||e===`private`||e===`secret`?e:`public`};switch(t.action){case`send`:return e.send({target:n(`target`),content:n(`content`)});case`dm`:return e.dm({target:n(`target`),content:n(`content`)});case`join_room`:return e.joinRoom({room:n(`room`)});case`leave_room`:return e.leaveRoom({room:r(`room`)});case`create_room`:return e.createRoom({name:n(`name`),type:i(),description:r(`description`)});case`list_rooms`:return e.listRooms({});case`list_agents`:return e.listAgents({});case`read_room`:return e.readRoom({room:r(`room`)});case`destroy_room`:return e.destroyRoom({room:n(`room`)});case`invite`:return e.invite({room:n(`room`),agent:n(`agent`)});case`decline_invite`:return e.declineInvite({room:n(`room`),reason:n(`reason`)});case`kick`:return e.kick({room:n(`room`),agent:n(`agent`)});case`rename_agent`:return e.renameAgent({agent:n(`agent`),name:n(`name`)});case`push_subscribe`:{let n=t.subscription;return Vl(n)?e.pushSubscribe({subscription:n,agentId:r(`agentId`)}):{content:`Invalid push subscription`,isError:!0}}case`push_unsubscribe`:return e.pushUnsubscribe({agentId:r(`agentId`)});default:return{content:`Unknown action: ${String(t.action)}`,isError:!0}}}var Ul=new Map,Wl=new Map,Gl=new Map,Kl=new Map;function ql(e){for(let[t,n]of Object.entries(e.agents))Ul.set(t,n);for(let[t,n]of Object.entries(e.rooms))Wl.set(t,n);for(let[t,n]of Object.entries(e.messages))Gl.set(t,n);for(let[t,n]of Object.entries(e.dms))Kl.set(t,n)}function Jl(e){switch(e.type){case`agent_upsert`:Ul.set(e.agent.id,e.agent);break;case`agent_offline`:{let t=Ul.get(e.agentId);t&&(t.status=`offline`,Ul.set(e.agentId,t));break}case`room_upsert`:Wl.set(e.room.id,e.room);break;case`room_delete`:Wl.delete(e.roomId);break;case`message_add`:{let t=Gl.get(e.roomId)??[];t.push(e.message),Gl.set(e.roomId,t);break}case`dm_add`:{let t=Kl.get(e.key)??[];t.push(e.message),Kl.set(e.key,t);break}case`delivery`:break;case`message_read`:if(e.room!==void 0){let t=Gl.get(e.room);if(t){let n=t.find(t=>t.id===e.messageId);n&&!n.readBy.includes(e.readBy)&&n.readBy.push(e.readBy)}}else for(let[,t]of Kl){let n=t.find(t=>t.id===e.messageId);n&&!n.readBy.includes(e.readBy)&&n.readBy.push(e.readBy)}}}function Yl(){return{agents:[...Ul.values()],rooms:[...Wl.values()]}}var Xl,Zl=0,Ql,$l=new Xn,eu=1e3,tu=3e4;function nu(e){let t=Ct(new nn({connect:async()=>{let t=new WebSocket(e);return Ql=t,t.addEventListener(`open`,()=>{ou({type:`connected`})}),t.addEventListener(`close`,()=>{ou({type:`disconnected`})}),new Promise((e,n)=>{t.addEventListener(`open`,()=>{e(t)},{once:!0}),t.addEventListener(`error`,n,{once:!0})})},reconnect:{enabled:!0,delay:e=>e.attempt===1?0:Math.min(eu*2**e.attempt,tu)},plugins:[new rn]}));Xl=t,iu(t,++Zl)}function ru(){++Zl,Xl=void 0,Ql?.close(),Ql=void 0}async function iu(e,t){let n;for(;t===Zl;)try{let r=await e.subscribeEvents(n===void 0?{}:{lastEventId:n});for await(let e of r){if(t!==Zl)return;let r=qe(e);switch(r?.id!==void 0&&(n=r.id),$l.publish(e),e.kind){case`state_sync`:ql(e.state),ou({type:`state`,state:Yl()});break;case`state_patch`:Jl(e.patch),ou({type:`patch`,patch:e.patch})}}return}catch{}}var au=new Set;function ou(e){let t=JSON.stringify(e);for(let e of au)try{e.postMessage(t)}catch{}}function su(e){switch(e.type){case`init`:nu(e.url);break;case`action`:{let t=Xl;if(!t)break;let n=e.id;Hl(t,e.action).then(e=>{ou({type:`actionResult`,id:n,result:e})}).catch(e=>{ou({type:`actionError`,id:n,message:e instanceof Error?e.message:String(e)})});break}case`getState`:ou({type:`state`,state:Yl()})}}function cu(e){if(typeof e!=`object`||!e||!(`type`in e))return!1;let t=e.type;return typeof t==`string`&&(t===`init`||t===`action`||t===`getState`)}function lu(){return{agents:Object.fromEntries(Ul),rooms:Object.fromEntries(Wl),messages:Object.fromEntries(Gl),dms:Object.fromEntries(Kl)}}async function Q(e){return Xl?Hl(Xl,e):{content:`Not connected to mesh yet`,isError:!0}}function uu(){if(!Xl)throw Error(`Not connected to mesh yet`);return Xl}var $=Fn(Bl).$context(),du={};du.current=new qn({send:$.send.handler(async({input:e})=>Q({action:`send`,...e})),dm:$.dm.handler(async({input:e})=>Q({action:`dm`,...e})),joinRoom:$.joinRoom.handler(async({input:e})=>Q({action:`join_room`,room:e.room})),leaveRoom:$.leaveRoom.handler(async({input:e})=>Q({action:`leave_room`,room:e.room})),createRoom:$.createRoom.handler(async({input:e})=>Q({action:`create_room`,name:e.name,type:e.type,description:e.description})),listRooms:$.listRooms.handler(async()=>Q({action:`list_rooms`})),listAgents:$.listAgents.handler(async()=>Q({action:`list_agents`})),readRoom:$.readRoom.handler(async({input:e})=>Q({action:`read_room`,room:e.room})),destroyRoom:$.destroyRoom.handler(async({input:e})=>Q({action:`destroy_room`,room:e.room})),invite:$.invite.handler(async({input:e})=>Q({action:`invite`,room:e.room,agent:e.agent})),declineInvite:$.declineInvite.handler(async({input:e})=>Q({action:`decline_invite`,room:e.room,reason:e.reason})),kick:$.kick.handler(async({input:e})=>Q({action:`kick`,room:e.room,agent:e.agent})),renameAgent:$.renameAgent.handler(async({input:e})=>Q({action:`rename_agent`,agent:e.agent,name:e.name})),pushSubscribe:$.pushSubscribe.handler(async({input:e})=>Q({action:`push_subscribe`,subscription:e.subscription,agentId:e.agentId})),pushUnsubscribe:$.pushUnsubscribe.handler(async({input:e})=>Q({action:`push_unsubscribe`,agentId:e.agentId})),getRoomMessages:$.getRoomMessages.handler(async({input:e})=>uu().getRoomMessages(e)),getMeshGraph:$.getMeshGraph.handler(async()=>uu().getMeshGraph({})),getDisplayNames:$.getDisplayNames.handler(async()=>uu().getDisplayNames({})),getMeshTrace:$.getMeshTrace.handler(async({input:e})=>uu().getMeshTrace(e)),subscribeEvents:$.subscribeEvents.handler(async function*({input:e,signal:t}){e.lastEventId===void 0&&(yield{kind:`state_sync`,state:lu()}),yield*$l.subscribe({...t?{signal:t}:{},...e.lastEventId===void 0?{}:{lastEventId:e.lastEventId}})}),disconnect:$.disconnect.handler(({context:e})=>(setTimeout(()=>{du.current?.close(e.port)},0),{}))});function fu(e){du.current?.upgrade(e,{context:{port:e}})}return typeof self<`u`&&self.addEventListener(`connect`,e=>{let t=e.ports[0];if(t!==void 0){au.add(t);try{t.postMessage(JSON.stringify({type:`state`,state:Yl()}))}catch{}t.onmessage=e=>{let t=JSON.parse(typeof e.data==`string`?e.data:String(e.data));cu(t)&&su(t)},fu(t)}}),e.agents=Ul,e.applyPatch=Jl,e.applyStateSync=ql,e.connect=nu,e.disconnect=ru,e.dms=Kl,e.getStateSnapshot=Yl,e.localPublisher=$l,e.messages=Gl,e.ports=au,e.rooms=Wl,e.upgradeTabRpcPort=fu,e})({});
@@ -1 +1 @@
1
- (function(){var e=`agent-comms-v1`,t=[{"revision":"3da1f3070845d19a79e092c6e0f06449","url":"mesh-worker.js"},{"revision":"f1ee3afb8c9e8f0d7315fd93d6457316","url":"index.html"},{"revision":"c4980321fd64db69691943e01338b717","url":"bundle.js"}].map(e=>e.url);self.addEventListener(`install`,n=>{n.waitUntil(self.caches.open(e).then(async e=>e.addAll(t)).then(async()=>self.skipWaiting()))}),self.addEventListener(`activate`,t=>{t.waitUntil(self.caches.keys().then(async t=>Promise.all(t.filter(t=>t!==e).map(async e=>self.caches.delete(e)))))});var n=200,r=300;function i(e,t){return e.method===`GET`&&t.status>=n&&t.status<r}self.addEventListener(`fetch`,t=>{if(new URL(t.request.url).pathname.startsWith(`/api/`)){t.respondWith(fetch(t.request).then(n=>{if(i(t.request,n)){let r=n.clone();self.caches.open(e).then(async e=>e.put(t.request,r))}return n}).catch(async()=>self.caches.open(e).then(async e=>e.match(t.request)).then(e=>e??new Response(`Offline`,{status:503}))));return}t.respondWith(self.caches.open(e).then(async e=>e.match(t.request)).then(async n=>n||fetch(t.request).then(n=>{if(i(t.request,n)){let r=n.clone();self.caches.open(e).then(async e=>e.put(t.request,r))}return n})))}),self.addEventListener(`push`,e=>{let t=`Agent Comms`,n=`New message`;if(e.data)try{let r=e.data.json();typeof r.title==`string`&&(t=r.title),typeof r.body==`string`&&(n=r.body)}catch{let t=e.data.text();t&&(n=t)}e.waitUntil(self.registration.showNotification(t,{body:n,data:{url:self.location.origin}}))}),self.addEventListener(`notificationclick`,e=>{e.notification.close();let t=e.notification.data,n=typeof t==`object`&&t&&`url`in t&&typeof t.url==`string`?t.url:self.location.origin;e.waitUntil(self.clients.matchAll({type:`window`,includeUncontrolled:!0}).then(async e=>{for(let t of e)if(t.url===n&&`focus`in t)return t.focus();return self.clients.openWindow(n)}))})})();
1
+ (function(){var e=`agent-comms-v1`,t=[{"revision":"010610a7633e7ced924748b981ff8d3c","url":"mesh-worker.js"},{"revision":"f1ee3afb8c9e8f0d7315fd93d6457316","url":"index.html"},{"revision":"c4980321fd64db69691943e01338b717","url":"bundle.js"}].map(e=>e.url);self.addEventListener(`install`,n=>{n.waitUntil(self.caches.open(e).then(async e=>e.addAll(t)).then(async()=>self.skipWaiting()))}),self.addEventListener(`activate`,t=>{t.waitUntil(self.caches.keys().then(async t=>Promise.all(t.filter(t=>t!==e).map(async e=>self.caches.delete(e)))))});var n=200,r=300;function i(e,t){return e.method===`GET`&&t.status>=n&&t.status<r}self.addEventListener(`fetch`,t=>{if(new URL(t.request.url).pathname.startsWith(`/api/`)){t.respondWith(fetch(t.request).then(n=>{if(i(t.request,n)){let r=n.clone();self.caches.open(e).then(async e=>e.put(t.request,r))}return n}).catch(async()=>self.caches.open(e).then(async e=>e.match(t.request)).then(e=>e??new Response(`Offline`,{status:503}))));return}t.respondWith(self.caches.open(e).then(async e=>e.match(t.request)).then(async n=>n||fetch(t.request).then(n=>{if(i(t.request,n)){let r=n.clone();self.caches.open(e).then(async e=>e.put(t.request,r))}return n})))}),self.addEventListener(`push`,e=>{let t=`Agent Comms`,n=`New message`;if(e.data)try{let r=e.data.json();typeof r.title==`string`&&(t=r.title),typeof r.body==`string`&&(n=r.body)}catch{let t=e.data.text();t&&(n=t)}e.waitUntil(self.registration.showNotification(t,{body:n,data:{url:self.location.origin}}))}),self.addEventListener(`notificationclick`,e=>{e.notification.close();let t=e.notification.data,n=typeof t==`object`&&t&&`url`in t&&typeof t.url==`string`?t.url:self.location.origin;e.waitUntil(self.clients.matchAll({type:`window`,includeUncontrolled:!0}).then(async e=>{for(let t of e)if(t.url===n&&`focus`in t)return t.focus();return self.clients.openWindow(n)}))})})();
@@ -5,18 +5,23 @@
5
5
  export declare const ACCOUNT_BUNDLE_PREFIX = "agent-comms-account:v1:";
6
6
  /** The shortest passphrase an export accepts. Twelve characters is the length NCSC and NIST guidance treat as the floor for a passphrase protecting something offline-attackable; the scrypt cost above does the rest. */
7
7
  export declare const MIN_ACCOUNT_PASSPHRASE_LENGTH = 12;
8
- /** Seals the account's PEM private key under a passphrase, as one line of text. Throws WEAK_PASSPHRASE for a passphrase shorter than MIN_ACCOUNT_PASSPHRASE_LENGTH. */
9
- export declare function sealAccountBundle(privateKeyPem: string, passphrase: string): string;
10
- /** The PEM private key a bundle holds. Throws INVALID_BUNDLE for text that is not a bundle this build can read, and WRONG_PASSPHRASE when the passphrase does not open it. The cost parameters are read from the bundle but capped at this build's own, so a crafted bundle cannot make an import run for hours. */
11
- export declare function openAccountBundle(bundle: string, passphrase: string): string;
8
+ /** What an account export or a join carries: the PEM private key and the name the account asserts for itself, if it has one. */
9
+ export interface AccountContents {
10
+ privateKey: string;
11
+ displayName?: string;
12
+ }
13
+ /** Seals the account's contents under a passphrase, as one line of text. Throws WEAK_PASSPHRASE for a passphrase shorter than MIN_ACCOUNT_PASSPHRASE_LENGTH. */
14
+ export declare function sealAccountBundle(contents: Readonly<AccountContents>, passphrase: string): string;
15
+ /** The account contents a bundle holds. Throws INVALID_BUNDLE for text that is not a bundle this build can read, and WRONG_PASSPHRASE when the passphrase does not open it. The cost parameters are read from the bundle but capped at this build's own, so a crafted bundle cannot make an import run for hours. */
16
+ export declare function openAccountBundle(bundle: string, passphrase: string): AccountContents;
12
17
  /** The fields of an account invite both ends know: the invite's own single-use nonce is the secret, and the expiry and issuing device are bound in so a sealed key cannot be replayed under a different invite. */
13
18
  export interface AccountInviteSecret {
14
19
  code: string;
15
20
  expiresAt: string;
16
21
  deviceId: string;
17
22
  }
18
- /** Seals the account's PEM private key for the machine redeeming `invite`. The invite's nonce carries enough entropy to key it directly, with no passphrase stretching needed. */
19
- export declare function sealAccountKeyForInvite(privateKeyPem: string, invite: Readonly<AccountInviteSecret>): string;
20
- /** The PEM private key sealed for `invite`. Throws INVALID_BUNDLE when the text does not open under that invite. */
21
- export declare function openAccountKeyFromInvite(sealed: string, invite: Readonly<AccountInviteSecret>): string;
23
+ /** Seals the account's contents for the machine redeeming `invite`. The invite's nonce carries enough entropy to key it directly, with no passphrase stretching needed. */
24
+ export declare function sealAccountKeyForInvite(contents: Readonly<AccountContents>, invite: Readonly<AccountInviteSecret>): string;
25
+ /** The account contents sealed for `invite`. Throws INVALID_BUNDLE when the text does not open under that invite. */
26
+ export declare function openAccountKeyFromInvite(sealed: string, invite: Readonly<AccountInviteSecret>): AccountContents;
22
27
  //# sourceMappingURL=account-bundle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"account-bundle.d.ts","sourceRoot":"","sources":["../../src/core/account-bundle.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,8HAA8H;AAC9H,eAAO,MAAM,qBAAqB,4BAA4B,CAAC;AAgB/D,0NAA0N;AAC1N,eAAO,MAAM,6BAA6B,KAAK,CAAC;AA0EhD,uKAAuK;AACvK,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,GACjB,MAAM,CAgBR;AAED,oTAAoT;AACpT,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAsC5E;AAED,mNAAmN;AACnN,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAA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@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { createCipheriv, createDecipheriv, hkdfSync, randomBytes, scryptSync, } from "node:crypto";
5
5
  import { z } from "zod";
6
+ import { parseDisplayName } from "./display-name.js";
6
7
  import { CommsError } from "./store.js";
7
8
  /** The text an exported bundle starts with, so a file can be recognised for what it is before any decryption is attempted. */
8
9
  export const ACCOUNT_BUNDLE_PREFIX = "agent-comms-account:v1:";
@@ -24,6 +25,35 @@ export const MIN_ACCOUNT_PASSPHRASE_LENGTH = 12;
24
25
  const INVITE_KEY_INFO = "agent-comms/account-invite/v1";
25
26
  const BUNDLE_AAD = Buffer.from(ACCOUNT_BUNDLE_PREFIX);
26
27
  const base64url = z.string().regex(/^[A-Za-z0-9_-]*$/);
28
+ const accountContentsSchema = z
29
+ .object({ privateKey: z.string(), displayName: z.string().optional() })
30
+ .strict();
31
+ /** The contents as the plaintext a bundle or a join seals. */
32
+ function contentsText(contents) {
33
+ return JSON.stringify(contents);
34
+ }
35
+ /** The contents a sealed plaintext holds. Throws INVALID_BUNDLE for a plaintext that is not account contents or whose name breaks the display-name rules, since a name from outside is shown to people. */
36
+ function parseContents(plaintext, damaged) {
37
+ let decoded;
38
+ try {
39
+ decoded = JSON.parse(plaintext);
40
+ }
41
+ catch {
42
+ throw new CommsError(damaged, "INVALID_BUNDLE");
43
+ }
44
+ const contents = accountContentsSchema.safeParse(decoded);
45
+ if (!contents.success ||
46
+ (contents.data.displayName !== undefined &&
47
+ parseDisplayName(contents.data.displayName) !== contents.data.displayName)) {
48
+ throw new CommsError(damaged, "INVALID_BUNDLE");
49
+ }
50
+ return {
51
+ privateKey: contents.data.privateKey,
52
+ ...(contents.data.displayName === undefined
53
+ ? {}
54
+ : { displayName: contents.data.displayName }),
55
+ };
56
+ }
27
57
  const passphraseEnvelopeSchema = z
28
58
  .object({
29
59
  kdf: z.literal("scrypt"),
@@ -73,8 +103,8 @@ function passphraseKey(passphrase, salt, cost) {
73
103
  maxmem: SCRYPT_MAX_MEMORY,
74
104
  });
75
105
  }
76
- /** Seals the account's PEM private key under a passphrase, as one line of text. Throws WEAK_PASSPHRASE for a passphrase shorter than MIN_ACCOUNT_PASSPHRASE_LENGTH. */
77
- export function sealAccountBundle(privateKeyPem, passphrase) {
106
+ /** Seals the account's contents under a passphrase, as one line of text. Throws WEAK_PASSPHRASE for a passphrase shorter than MIN_ACCOUNT_PASSPHRASE_LENGTH. */
107
+ export function sealAccountBundle(contents, passphrase) {
78
108
  if (passphrase.length < MIN_ACCOUNT_PASSPHRASE_LENGTH) {
79
109
  throw new CommsError(`An account export passphrase must be at least ${String(MIN_ACCOUNT_PASSPHRASE_LENGTH)} characters`, "WEAK_PASSPHRASE");
80
110
  }
@@ -84,11 +114,11 @@ export function sealAccountBundle(privateKeyPem, passphrase) {
84
114
  kdf: "scrypt",
85
115
  ...cost,
86
116
  salt: salt.toString("base64url"),
87
- ...seal(passphraseKey(passphrase, salt, cost), privateKeyPem),
117
+ ...seal(passphraseKey(passphrase, salt, cost), contentsText(contents)),
88
118
  };
89
119
  return `${ACCOUNT_BUNDLE_PREFIX}${Buffer.from(JSON.stringify(envelope)).toString("base64url")}`;
90
120
  }
91
- /** The PEM private key a bundle holds. Throws INVALID_BUNDLE for text that is not a bundle this build can read, and WRONG_PASSPHRASE when the passphrase does not open it. The cost parameters are read from the bundle but capped at this build's own, so a crafted bundle cannot make an import run for hours. */
121
+ /** The account contents a bundle holds. Throws INVALID_BUNDLE for text that is not a bundle this build can read, and WRONG_PASSPHRASE when the passphrase does not open it. The cost parameters are read from the bundle but capped at this build's own, so a crafted bundle cannot make an import run for hours. */
92
122
  export function openAccountBundle(bundle, passphrase) {
93
123
  const text = bundle.trim();
94
124
  if (!text.startsWith(ACCOUNT_BUNDLE_PREFIX)) {
@@ -109,20 +139,20 @@ export function openAccountBundle(bundle, passphrase) {
109
139
  throw new CommsError("The account bundle is damaged", "INVALID_BUNDLE");
110
140
  }
111
141
  const key = passphraseKey(passphrase, Buffer.from(envelope.data.salt, "base64url"), envelope.data);
112
- const privateKeyPem = open(key, envelope.data);
113
- if (privateKeyPem === undefined) {
142
+ const plaintext = open(key, envelope.data);
143
+ if (plaintext === undefined) {
114
144
  throw new CommsError("The passphrase does not open this account bundle", "WRONG_PASSPHRASE");
115
145
  }
116
- return privateKeyPem;
146
+ return parseContents(plaintext, "The account bundle is damaged");
117
147
  }
118
148
  function inviteKey(invite) {
119
149
  return Buffer.from(hkdfSync("sha256", Buffer.from(invite.code), Buffer.from(`${invite.expiresAt}:${invite.deviceId}`), INVITE_KEY_INFO, KEY_BYTES));
120
150
  }
121
- /** Seals the account's PEM private key for the machine redeeming `invite`. The invite's nonce carries enough entropy to key it directly, with no passphrase stretching needed. */
122
- export function sealAccountKeyForInvite(privateKeyPem, invite) {
123
- return Buffer.from(JSON.stringify(seal(inviteKey(invite), privateKeyPem))).toString("base64url");
151
+ /** Seals the account's contents for the machine redeeming `invite`. The invite's nonce carries enough entropy to key it directly, with no passphrase stretching needed. */
152
+ export function sealAccountKeyForInvite(contents, invite) {
153
+ return Buffer.from(JSON.stringify(seal(inviteKey(invite), contentsText(contents)))).toString("base64url");
124
154
  }
125
- /** The PEM private key sealed for `invite`. Throws INVALID_BUNDLE when the text does not open under that invite. */
155
+ /** The account contents sealed for `invite`. Throws INVALID_BUNDLE when the text does not open under that invite. */
126
156
  export function openAccountKeyFromInvite(sealed, invite) {
127
157
  let decoded;
128
158
  try {
@@ -132,12 +162,12 @@ export function openAccountKeyFromInvite(sealed, invite) {
132
162
  throw new CommsError("The sealed account key is damaged", "INVALID_BUNDLE");
133
163
  }
134
164
  const envelope = inviteEnvelopeSchema.safeParse(decoded);
135
- const privateKeyPem = envelope.success
165
+ const plaintext = envelope.success
136
166
  ? open(inviteKey(invite), envelope.data)
137
167
  : undefined;
138
- if (privateKeyPem === undefined) {
168
+ if (plaintext === undefined) {
139
169
  throw new CommsError("The sealed account key does not open under this invite", "INVALID_BUNDLE");
140
170
  }
141
- return privateKeyPem;
171
+ return parseContents(plaintext, "The sealed account key is damaged");
142
172
  }
143
173
  //# sourceMappingURL=account-bundle.js.map