@agentconnect.md/desktop 2.6.0-rc.57 → 2.6.0-rc.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -171,7 +171,9 @@ inside the desktop session, as the desktop user, not root. It needs Node.js ≥
171
171
  tarball or your distribution's package).
172
172
 
173
173
  ```bash
174
- npx -y @agentconnect.md/cli computer install --register <token> --cp-url <exchange URL>
174
+ npx -y @agentconnect.md/cli@latest computer install --register <token> --cp-url <exchange URL>
175
+ # against a release-candidate Control Plane, which the console detects and shows:
176
+ npx -y @agentconnect.md/cli@rc computer install --channel rc --register <token> --cp-url <exchange URL>
175
177
  ```
176
178
 
177
179
  The CLI downloads `@agentconnect.md/desktop` from npm, verifies its integrity, unpacks it into
@@ -191,7 +193,7 @@ agentconnect computer uninstall # service, autostart entry and versions; --purge
191
193
 
192
194
  (`npx -y @agentconnect.md/cli` stands in for `agentconnect` without a global install.) Config, the
193
195
  Computer key and the grants stay in `~/.agentconnect/desktop`, so an upgrade keeps the
194
- registration; a desktop installed by the earlier `install.sh` keeps its data, and `computer install`
196
+ registration; a desktop installed by the retired Control Plane `install.sh` keeps its data, and `computer install`
195
197
  moves its service onto the store. `AGENTCONNECT_NPM_REGISTRY` points the CLI at another registry.
196
198
 
197
199
  Requirements for running from source: Node.js ≥ 24.12 (the official tarball in `~/.local/node` works), a logged-in
@@ -30567,7 +30567,7 @@ var require_websocket = __commonJS({
30567
30567
  const request2 = isSecure ? https.request : http.request;
30568
30568
  const protocolSet = /* @__PURE__ */ new Set();
30569
30569
  let perMessageDeflate;
30570
- opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
30570
+ opts.createConnection = opts.createConnection || (isSecure ? tlsConnect2 : netConnect2);
30571
30571
  opts.defaultPort = opts.defaultPort || defaultPort2;
30572
30572
  opts.port = parsedUrl.port || defaultPort2;
30573
30573
  opts.host = parsedUrl.hostname.startsWith("[") ? parsedUrl.hostname.slice(1, -1) : parsedUrl.hostname;
@@ -30765,11 +30765,11 @@ var require_websocket = __commonJS({
30765
30765
  websocket.emit("error", err5);
30766
30766
  websocket.emitClose();
30767
30767
  }
30768
- function netConnect(options) {
30768
+ function netConnect2(options) {
30769
30769
  options.path = options.socketPath;
30770
30770
  return net2.connect(options);
30771
30771
  }
30772
- function tlsConnect(options) {
30772
+ function tlsConnect2(options) {
30773
30773
  options.path = void 0;
30774
30774
  if (!options.servername && options.servername !== "") {
30775
30775
  options.servername = net2.isIP(options.host) ? "" : options.host;
@@ -59957,7 +59957,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
59957
59957
  query: void 0,
59958
59958
  fragment: void 0
59959
59959
  };
59960
- let isIP5 = false;
59960
+ let isIP6 = false;
59961
59961
  if (options.reference === "suffix") if (options.scheme) uri = options.scheme + ":" + uri;
59962
59962
  else uri = "//" + uri;
59963
59963
  const matches = uri.match(URI_PARSE);
@@ -59973,8 +59973,8 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
59973
59973
  if (parsed.host) if (isIPv45(parsed.host) === false) {
59974
59974
  const ipv6result = normalizeIPv6(parsed.host);
59975
59975
  parsed.host = ipv6result.host.toLowerCase();
59976
- isIP5 = ipv6result.isIPV6;
59977
- } else isIP5 = true;
59976
+ isIP6 = ipv6result.isIPV6;
59977
+ } else isIP6 = true;
59978
59978
  if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && parsed.query === void 0 && !parsed.path) parsed.reference = "same-document";
59979
59979
  else if (parsed.scheme === void 0) parsed.reference = "relative";
59980
59980
  else if (parsed.fragment === void 0) parsed.reference = "absolute";
@@ -59982,7 +59982,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
59982
59982
  if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
59983
59983
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
59984
59984
  if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
59985
- if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP5 === false && nonSimpleDomain(parsed.host)) try {
59985
+ if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP6 === false && nonSimpleDomain(parsed.host)) try {
59986
59986
  parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
59987
59987
  } catch (e) {
59988
59988
  parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
@@ -65705,6 +65705,10 @@ var ComputerIceServer = external_exports.object({
65705
65705
  }).strict();
65706
65706
  var COMPUTER_ICE_SERVERS_MAX = 2;
65707
65707
  var ComputerStunUrl = external_exports.string().max(256).regex(/^stun:(\[[0-9a-fA-F:.]+\]|[A-Za-z0-9.-]+)(:\d{1,5})?$/, "expected stun:<host>[:<port>]");
65708
+ var ComputerTurnUrl = external_exports.string().max(256).regex(
65709
+ /^turns?:(\[[0-9a-fA-F:.]+\]|[A-Za-z0-9.-]+)(:\d{1,5})?(\?transport=(udp|tcp))?$/,
65710
+ "expected turn:<host>[:<port>][?transport=udp|tcp] or turns:"
65711
+ );
65708
65712
  var COMPUTER_STUN_URLS_MAX = 2;
65709
65713
  var ComputerViewerCandidate = external_exports.object({
65710
65714
  id: external_exports.string().min(1).max(64),
@@ -66049,6 +66053,8 @@ var ComputerCapabilitiesSchema = external_exports.object({
66049
66053
  viewer: external_exports.boolean().default(false),
66050
66054
  // The viewer accepts a view token's `stun` claim; desktops before relay STUN refuse such a token.
66051
66055
  viewerStun: external_exports.boolean().optional(),
66056
+ // The browser's traffic leaves through the desktop's egress forwarder, which applies `computer/egress` (§15.4).
66057
+ egress: external_exports.boolean().optional(),
66052
66058
  displays: external_exports.array(
66053
66059
  external_exports.object({
66054
66060
  id: external_exports.string().min(1).max(128),
@@ -66081,6 +66087,24 @@ var ComputerChannelCredential = external_exports.object({
66081
66087
  issuedAt: external_exports.string().datetime(),
66082
66088
  expiresAt: external_exports.string().datetime()
66083
66089
  });
66090
+ var ComputerEgressProxyUrl = external_exports.string().max(512).refine((raw) => {
66091
+ try {
66092
+ const u = new URL(raw);
66093
+ return (u.protocol === "http:" || u.protocol === "https:") && u.hostname !== "" && u.username === "" && u.password === "" && (u.pathname === "" || u.pathname === "/") && u.search === "" && u.hash === "";
66094
+ } catch {
66095
+ return false;
66096
+ }
66097
+ }, "expected http://host:port or https://host:port without credentials or a path");
66098
+ var ComputerEgress = external_exports.discriminatedUnion("mode", [
66099
+ external_exports.object({ mode: external_exports.literal("direct") }),
66100
+ external_exports.object({
66101
+ mode: external_exports.literal("proxy"),
66102
+ url: ComputerEgressProxyUrl,
66103
+ username: external_exports.string().min(1).max(256).optional(),
66104
+ password: external_exports.string().min(1).max(512).optional()
66105
+ })
66106
+ ]);
66107
+ var COMPUTER_EGRESS_FEATURE = "computer-egress-v1";
66084
66108
  var ComputerAuth = external_exports.object({
66085
66109
  apiKey: external_exports.string().min(1).max(256),
66086
66110
  desktopDaemonVersion: external_exports.string().trim().min(1).max(64)
@@ -66096,7 +66120,9 @@ var ComputerAuthOk = external_exports.object({
66096
66120
  // What this CP accepts on the channel beyond the base frames, such as `computer-audit-v1`.
66097
66121
  features: external_exports.array(external_exports.string().min(1).max(64)).max(32).optional(),
66098
66122
  // The retention in effect for this Computer's screenshots (§9); 0 or absent means none are stored.
66099
- screenshotRetentionDays: external_exports.number().int().min(0).max(COMPUTER_SCREENSHOT_RETENTION_MAX_DAYS).optional()
66123
+ screenshotRetentionDays: external_exports.number().int().min(0).max(COMPUTER_SCREENSHOT_RETENTION_MAX_DAYS).optional(),
66124
+ // A managed desktop's egress (§15.4); absent means direct unless `computer-egress-v1` is advertised. Secret, never logged.
66125
+ egress: ComputerEgress.optional()
66100
66126
  });
66101
66127
  var ComputerHeartbeat = external_exports.object({
66102
66128
  status: external_exports.enum(COMPUTER_LIVE_STATUSES),
@@ -66125,6 +66151,7 @@ var ComputerRevoke = external_exports.object({
66125
66151
  var ComputerLeasePush = external_exports.object({ lease: ComputerControlLease.nullable() });
66126
66152
  var ComputerRelaysPush = external_exports.object({ relays: external_exports.array(ComputerRelayEntry).max(COMPUTER_RELAYS_MAX) });
66127
66153
  var ComputerStopPush = external_exports.object({ stop: external_exports.object({ at: external_exports.string().datetime() }).nullable() });
66154
+ var ComputerEgressPush = external_exports.object({ egress: ComputerEgress });
66128
66155
  var COMPUTER_CP_SCHEMAS = {
66129
66156
  "computer/auth": ComputerAuth,
66130
66157
  "computer/auth/ok": ComputerAuthOk,
@@ -66135,6 +66162,7 @@ var COMPUTER_CP_SCHEMAS = {
66135
66162
  "computer/lease": ComputerLeasePush,
66136
66163
  "computer/relays": ComputerRelaysPush,
66137
66164
  "computer/stop": ComputerStopPush,
66165
+ "computer/egress": ComputerEgressPush,
66138
66166
  "computer/audit": ComputerAuditReport,
66139
66167
  "computer/audit/ok": ComputerAuditAck,
66140
66168
  "computer/screenshot/put": ComputerScreenshotPut,
@@ -66154,6 +66182,7 @@ var ComputerCpFrame = external_exports.discriminatedUnion("type", [
66154
66182
  frameSchema("computer/lease", COMPUTER_CP_SCHEMAS["computer/lease"]),
66155
66183
  frameSchema("computer/relays", COMPUTER_CP_SCHEMAS["computer/relays"]),
66156
66184
  frameSchema("computer/stop", COMPUTER_CP_SCHEMAS["computer/stop"]),
66185
+ frameSchema("computer/egress", COMPUTER_CP_SCHEMAS["computer/egress"]),
66157
66186
  frameSchema("computer/audit", COMPUTER_CP_SCHEMAS["computer/audit"]),
66158
66187
  frameSchema("computer/audit/ok", COMPUTER_CP_SCHEMAS["computer/audit/ok"]),
66159
66188
  frameSchema("computer/screenshot/put", COMPUTER_CP_SCHEMAS["computer/screenshot/put"]),
@@ -74328,7 +74357,7 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
74328
74357
  query: void 0,
74329
74358
  fragment: void 0
74330
74359
  };
74331
- let isIP5 = false;
74360
+ let isIP6 = false;
74332
74361
  if (options.reference === "suffix") if (options.scheme) uri = options.scheme + ":" + uri;
74333
74362
  else uri = "//" + uri;
74334
74363
  const matches = uri.match(URI_PARSE);
@@ -74344,8 +74373,8 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
74344
74373
  if (parsed.host) if (isIPv45(parsed.host) === false) {
74345
74374
  const ipv6result = normalizeIPv6(parsed.host);
74346
74375
  parsed.host = ipv6result.host.toLowerCase();
74347
- isIP5 = ipv6result.isIPV6;
74348
- } else isIP5 = true;
74376
+ isIP6 = ipv6result.isIPV6;
74377
+ } else isIP6 = true;
74349
74378
  if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && parsed.query === void 0 && !parsed.path) parsed.reference = "same-document";
74350
74379
  else if (parsed.scheme === void 0) parsed.reference = "relative";
74351
74380
  else if (parsed.fragment === void 0) parsed.reference = "absolute";
@@ -74353,7 +74382,7 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
74353
74382
  if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
74354
74383
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
74355
74384
  if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
74356
- if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP5 === false && nonSimpleDomain(parsed.host)) try {
74385
+ if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP6 === false && nonSimpleDomain(parsed.host)) try {
74357
74386
  parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
74358
74387
  } catch (e) {
74359
74388
  parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
@@ -84717,7 +84746,7 @@ var managedEntry = () => process.env[SERVICE_ENTRY_ENV]?.trim() || void 0;
84717
84746
  var serviceEntry = () => managedEntry() ?? resolve(process.argv[1]);
84718
84747
 
84719
84748
  // src/version.ts
84720
- var DESKTOP_DAEMON_VERSION = true ? "2.6.0-rc.57" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
84749
+ var DESKTOP_DAEMON_VERSION = true ? "2.6.0-rc.62" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
84721
84750
 
84722
84751
  // src/http-server.ts
84723
84752
  var CONTROL_HEADER = "x-agentconnect-desktop";
@@ -109079,6 +109108,8 @@ var ComputerCpClient = class {
109079
109108
  this.deps.authority.syncClock(ok.serverTime);
109080
109109
  this.deps.authority.accept(ok.credential);
109081
109110
  this.deps.onPolicy?.(ok.policy);
109111
+ const egress = ok.egress ?? (this.features.has(COMPUTER_EGRESS_FEATURE) ? void 0 : { mode: "direct" });
109112
+ if (egress) this.deps.onEgress?.(egress);
109082
109113
  this.heartbeatMs = ok.heartbeatSec * 1e3;
109083
109114
  this.deps.log(`computer channel: connected as ${ok.name} (${ok.computerId})`);
109084
109115
  this.deps.onReady?.(ok);
@@ -109114,6 +109145,9 @@ var ComputerCpClient = class {
109114
109145
  case "computer/stop":
109115
109146
  this.deps.onStop?.(frame.payload.stop);
109116
109147
  return;
109148
+ case "computer/egress":
109149
+ this.deps.onEgress?.(frame.payload.egress);
109150
+ return;
109117
109151
  case "computer/revoke":
109118
109152
  return this.revoked(`${frame.payload.reason} by the Control Plane`);
109119
109153
  case "error":
@@ -109628,6 +109662,7 @@ function capabilitiesFrom(checks, display, options = {}) {
109628
109662
  accessibilityTree: false,
109629
109663
  viewer: options.webrtc !== false && ok("ffmpeg") && ok("screen capture"),
109630
109664
  viewerStun: true,
109665
+ ...options.egress ? { egress: true } : {},
109631
109666
  displays: display && display.screenWidth > 0 && display.screenHeight > 0 ? [
109632
109667
  {
109633
109668
  id: "primary",
@@ -109767,9 +109802,210 @@ async function startPoolBootstrap(options) {
109767
109802
  };
109768
109803
  }
109769
109804
 
109805
+ // src/egress.ts
109806
+ import { request as httpRequest, createServer as createServer4 } from "node:http";
109807
+ import { request as httpsRequest } from "node:https";
109808
+ import { connect as netConnect, isIP as isIP4 } from "node:net";
109809
+ import { connect as tlsConnect } from "node:tls";
109810
+ var EGRESS_PORT_ENV = "AGENTCONNECT_EGRESS_PORT";
109811
+ var CONNECT_TIMEOUT_MS = 15e3;
109812
+ var MAX_PROXY_HEADER_BYTES = 16 * 1024;
109813
+ var HOP_BY_HOP = /* @__PURE__ */ new Set([
109814
+ "connection",
109815
+ "keep-alive",
109816
+ "proxy-authenticate",
109817
+ "proxy-authorization",
109818
+ "proxy-connection",
109819
+ "te",
109820
+ "trailer",
109821
+ "transfer-encoding",
109822
+ "upgrade"
109823
+ ]);
109824
+ function egressPort(env = process.env) {
109825
+ const raw = env[EGRESS_PORT_ENV]?.trim();
109826
+ if (!raw) return void 0;
109827
+ const port = Number(raw);
109828
+ if (!Number.isInteger(port) || port < 1 || port > 65535)
109829
+ throw new Error(`${EGRESS_PORT_ENV} is not a valid port: ${raw}`);
109830
+ return port;
109831
+ }
109832
+ function connectTarget(authority) {
109833
+ const match = /^\[?([^\]]+?)\]?:(\d{1,5})$/.exec(authority ?? "");
109834
+ if (!match) return void 0;
109835
+ const port = Number(match[2]);
109836
+ return port > 0 && port <= 65535 ? { host: match[1], port } : void 0;
109837
+ }
109838
+ var basic = (egress) => egress.username !== void 0 || egress.password !== void 0 ? `Basic ${Buffer.from(`${egress.username ?? ""}:${egress.password ?? ""}`).toString("base64")}` : void 0;
109839
+ function forwardHeaders(headers) {
109840
+ const out = {};
109841
+ for (const [name, value] of Object.entries(headers)) {
109842
+ if (value !== void 0 && !HOP_BY_HOP.has(name.toLowerCase())) out[name] = value;
109843
+ }
109844
+ return out;
109845
+ }
109846
+ var EgressForwarder = class {
109847
+ constructor(opts) {
109848
+ this.opts = opts;
109849
+ }
109850
+ opts;
109851
+ policy = { mode: "pending" };
109852
+ server;
109853
+ sockets = /* @__PURE__ */ new Set();
109854
+ get mode() {
109855
+ return this.policy.mode;
109856
+ }
109857
+ /** Apply the organization's egress; open connections keep the route they started on. */
109858
+ apply(policy) {
109859
+ const before = this.describe();
109860
+ this.policy = policy;
109861
+ const after = this.describe();
109862
+ if (after !== before) this.opts.log(`egress: ${after}`);
109863
+ }
109864
+ // Never the credentials: the proxy's origin is enough to tell which one is in use.
109865
+ describe() {
109866
+ if (this.policy.mode !== "proxy") return this.policy.mode;
109867
+ return `proxy ${new URL(this.policy.url).origin}`;
109868
+ }
109869
+ async start() {
109870
+ const server = createServer4((req, res) => this.onRequest(req, res));
109871
+ server.on("connect", (req, socket, head) => this.onConnect(req, socket, head));
109872
+ server.on("connection", (socket) => {
109873
+ this.sockets.add(socket);
109874
+ socket.once("close", () => this.sockets.delete(socket));
109875
+ });
109876
+ server.on("clientError", (_err, socket) => socket.destroy());
109877
+ await new Promise((resolve2, reject) => {
109878
+ server.once("error", reject);
109879
+ server.listen(this.opts.port, this.opts.host ?? "127.0.0.1", () => resolve2());
109880
+ });
109881
+ this.server = server;
109882
+ const address = server.address();
109883
+ return typeof address === "object" && address ? address.port : this.opts.port;
109884
+ }
109885
+ async stop() {
109886
+ for (const socket of this.sockets) socket.destroy();
109887
+ await new Promise((resolve2) => this.server ? this.server.close(() => resolve2()) : resolve2());
109888
+ this.server = void 0;
109889
+ }
109890
+ // A tunnel (HTTPS and WebSocket traffic): straight to the target, or a CONNECT through the organization's proxy.
109891
+ onConnect(req, client, head) {
109892
+ const policy = this.policy;
109893
+ const target = connectTarget(req.url);
109894
+ const refuse = (status) => {
109895
+ client.end(`HTTP/1.1 ${status}\r
109896
+ Connection: close\r
109897
+ Content-Length: 0\r
109898
+ \r
109899
+ `);
109900
+ };
109901
+ if (!target) return refuse("400 Bad Request");
109902
+ if (policy.mode === "pending") return refuse("503 Service Unavailable");
109903
+ client.on("error", () => {
109904
+ });
109905
+ const upstream = policy.mode === "direct" ? netConnect(target.port, target.host) : this.dialProxy(new URL(policy.url));
109906
+ let opened = false;
109907
+ upstream.setTimeout(CONNECT_TIMEOUT_MS, () => upstream.destroy(new Error("timeout")));
109908
+ upstream.on("error", () => {
109909
+ if (opened) client.destroy();
109910
+ else if (!client.destroyed) refuse("502 Bad Gateway");
109911
+ });
109912
+ client.once("close", () => upstream.destroy());
109913
+ const open3 = (rest) => {
109914
+ opened = true;
109915
+ upstream.setTimeout(0);
109916
+ client.write("HTTP/1.1 200 Connection Established\r\n\r\n");
109917
+ if (rest.length > 0) client.write(rest);
109918
+ if (head.length > 0) upstream.write(head);
109919
+ upstream.pipe(client);
109920
+ client.pipe(upstream);
109921
+ };
109922
+ if (policy.mode === "direct") {
109923
+ upstream.once("connect", () => open3(Buffer.alloc(0)));
109924
+ return;
109925
+ }
109926
+ const auth = basic(policy);
109927
+ const authority = target.host.includes(":") ? `[${target.host}]:${target.port}` : `${target.host}:${target.port}`;
109928
+ upstream.once(policy.url.startsWith("https:") ? "secureConnect" : "connect", () => {
109929
+ upstream.write(
109930
+ `CONNECT ${authority} HTTP/1.1\r
109931
+ Host: ${authority}\r
109932
+ ${auth ? `Proxy-Authorization: ${auth}\r
109933
+ ` : ""}\r
109934
+ `
109935
+ );
109936
+ });
109937
+ let buffered = Buffer.alloc(0);
109938
+ const onData = (chunk) => {
109939
+ buffered = Buffer.concat([buffered, chunk]);
109940
+ const end = buffered.indexOf("\r\n\r\n");
109941
+ if (end < 0) {
109942
+ if (buffered.length > MAX_PROXY_HEADER_BYTES) upstream.destroy(new Error("oversized proxy reply"));
109943
+ return;
109944
+ }
109945
+ upstream.off("data", onData);
109946
+ const status = /^HTTP\/1\.[01] (\d{3})/.exec(buffered.subarray(0, end).toString("latin1"))?.[1];
109947
+ if (status !== "200") {
109948
+ upstream.destroy();
109949
+ return refuse(status === "407" ? "502 Bad Gateway (egress proxy refused the credentials)" : "502 Bad Gateway");
109950
+ }
109951
+ open3(buffered.subarray(end + 4));
109952
+ };
109953
+ upstream.on("data", onData);
109954
+ }
109955
+ // A plain HTTP request in absolute form: fetched directly, or handed to the organization's proxy as is.
109956
+ onRequest(req, res) {
109957
+ const policy = this.policy;
109958
+ let target;
109959
+ try {
109960
+ target = new URL(req.url ?? "");
109961
+ } catch {
109962
+ res.writeHead(400).end();
109963
+ return;
109964
+ }
109965
+ if (target.protocol !== "http:") return void res.writeHead(400).end();
109966
+ if (policy.mode === "pending") return void res.writeHead(503).end("egress is not configured yet");
109967
+ const headers = forwardHeaders(req.headers);
109968
+ let upstream;
109969
+ if (policy.mode === "direct") {
109970
+ upstream = httpRequest({
109971
+ host: target.hostname,
109972
+ port: target.port || 80,
109973
+ method: req.method,
109974
+ path: `${target.pathname}${target.search}`,
109975
+ headers
109976
+ });
109977
+ } else {
109978
+ const proxy = new URL(policy.url);
109979
+ const auth = basic(policy);
109980
+ upstream = (proxy.protocol === "https:" ? httpsRequest : httpRequest)({
109981
+ host: proxy.hostname,
109982
+ port: proxy.port || (proxy.protocol === "https:" ? 443 : 80),
109983
+ method: req.method,
109984
+ path: target.href,
109985
+ headers: { ...headers, ...auth ? { "proxy-authorization": auth } : {} }
109986
+ });
109987
+ }
109988
+ upstream.setTimeout(CONNECT_TIMEOUT_MS, () => upstream.destroy(new Error("timeout")));
109989
+ upstream.on("response", (answer) => {
109990
+ upstream.setTimeout(0);
109991
+ res.writeHead(answer.statusCode ?? 502, forwardHeaders(answer.headers));
109992
+ answer.pipe(res);
109993
+ });
109994
+ upstream.on("error", () => {
109995
+ if (!res.headersSent) res.writeHead(502).end();
109996
+ else res.destroy();
109997
+ });
109998
+ req.pipe(upstream);
109999
+ }
110000
+ dialProxy(proxy) {
110001
+ const port = Number(proxy.port || (proxy.protocol === "https:" ? 443 : 80));
110002
+ return proxy.protocol === "https:" ? tlsConnect({ host: proxy.hostname, port, ...isIP4(proxy.hostname) ? {} : { servername: proxy.hostname } }) : netConnect(port, proxy.hostname);
110003
+ }
110004
+ };
110005
+
109770
110006
  // src/public-address.ts
109771
110007
  import { lookup } from "node:dns/promises";
109772
- import { isIP as isIP4 } from "node:net";
110008
+ import { isIP as isIP5 } from "node:net";
109773
110009
  function publicBaseUrl(config2) {
109774
110010
  if (config2.publicUrl) return config2.publicUrl.replace(/\/+$/, "");
109775
110011
  if (config2.rtcAddress) return `http://${urlHost(config2.rtcAddress)}:${config2.port}`;
@@ -109779,7 +110015,7 @@ async function rtcAdvertiseAddress(config2, resolve2 = async (host) => (await lo
109779
110015
  if (config2.rtcAddress) return config2.rtcAddress;
109780
110016
  if (!config2.publicUrl) return void 0;
109781
110017
  const host = new URL(config2.publicUrl).hostname.replace(/^\[(.*)\]$/, "$1");
109782
- if (isIP4(host)) return host;
110018
+ if (isIP5(host)) return host;
109783
110019
  try {
109784
110020
  return await resolve2(host);
109785
110021
  } catch (error62) {
@@ -110609,6 +110845,8 @@ Commands:
110609
110845
  H defaults to 127.0.0.1, --host 0.0.0.0 opens every interface;
110610
110846
  registers first when ${REGISTER_TOKEN_ENV}(_FILE) and
110611
110847
  AGENTCONNECT_CP_URL are set and no key for that CP is stored
110848
+ (AGENTCONNECT_EGRESS_PORT runs the browser's egress forwarder,
110849
+ as managed pods do)
110612
110850
  stdio [--expose-driver-tools] serve MCP over stdio (agent runs on this machine)
110613
110851
  token add NAME | token list | token remove NAME
110614
110852
  status | pause | resume owner controls for the running daemon (loopback)
@@ -110899,7 +111137,8 @@ function startCpChannel(options) {
110899
111137
  capabilities: capabilitiesFrom(checks, display ?? startupDisplay, {
110900
111138
  session,
110901
111139
  webrtc: config2.webrtc,
110902
- keyboardActivity: local?.keyboard() ?? false
111140
+ keyboardActivity: local?.keyboard() ?? false,
111141
+ egress: options.egress !== void 0
110903
111142
  }),
110904
111143
  doctor: doctorReport([...checks, ...local?.checks() ?? []], doctorAt)
110905
111144
  } : {}
@@ -110914,6 +111153,7 @@ function startCpChannel(options) {
110914
111153
  onReady: (ok) => computer.rename(ok.name),
110915
111154
  onRelays: (relays) => relayLinks.converge(relays),
110916
111155
  onStop: (stop) => applyConsoleStop(stop),
111156
+ onEgress: (egress) => options.egress?.apply(egress),
110917
111157
  onRevoked: (reason) => {
110918
111158
  relayLinks.stop();
110919
111159
  markRevoked(dir, reason);
@@ -111035,9 +111275,13 @@ async function registerFromPool(dir) {
111035
111275
  }
111036
111276
  async function run2(dir, initial, clientName) {
111037
111277
  let config2 = initial;
111278
+ const egressAt = egressPort();
111279
+ const egress = egressAt !== void 0 ? new EgressForwarder({ port: egressAt, log: log39 }) : void 0;
111280
+ if (egress) log39(`egress forwarder on 127.0.0.1:${await egress.start()}`);
111038
111281
  await registerFromPool(dir);
111039
111282
  await registerFromEnvironment(dir);
111040
111283
  const registration = loadRegistration(dir);
111284
+ if (!registration) egress?.apply({ mode: "direct" });
111041
111285
  if (config2.clients.length === 0 && !registration) {
111042
111286
  const issued = issueClientToken(config2, clientName);
111043
111287
  config2 = issued.config;
@@ -111149,7 +111393,8 @@ async function run2(dir, initial, clientName) {
111149
111393
  screenSize,
111150
111394
  createMcpServer,
111151
111395
  viewer,
111152
- local: () => live2.local
111396
+ local: () => live2.local,
111397
+ egress
111153
111398
  });
111154
111399
  const publicBase = publicBaseUrl(config2);
111155
111400
  const urls = publicBase ? [`${publicBase}/mcp`] : isWildcardHost(config2.host) ? [server.url, ...lanAddresses().map((ip) => `http://${ip}:${config2.port}/mcp`)] : [server.url];
@@ -111178,7 +111423,7 @@ async function run2(dir, initial, clientName) {
111178
111423
  live2.local?.close();
111179
111424
  authority.close();
111180
111425
  releaseDisplay();
111181
- await Promise.allSettled([server.close(), driver.close()]);
111426
+ await Promise.allSettled([server.close(), driver.close(), egress?.stop()]);
111182
111427
  process.exit(exitCode);
111183
111428
  };
111184
111429
  process.once("SIGINT", () => void shutdown());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentconnect.md/desktop",
3
- "version": "2.6.0-rc.57",
3
+ "version": "2.6.0-rc.62",
4
4
  "description": "AgentConnect computer daemon: drives a desktop through Cua Driver and serves the computer_* tools over MCP; installed and upgraded by agentconnect computer",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -16,20 +16,6 @@
16
16
  "dist/agentconnect-desktop.mjs",
17
17
  "dist/agentconnect-desktop.mjs.LEGAL.txt"
18
18
  ],
19
- "scripts": {
20
- "build": "pnpm --filter \"{.}...\" build:package",
21
- "build:package": "node scripts/bundle.mjs --dist",
22
- "bundle": "node scripts/bundle.mjs",
23
- "bundle:macos": "node scripts/build-macos-app.mjs",
24
- "clean": "rm -rf dist bundle",
25
- "dev": "tsx src/cli.ts run",
26
- "license-scan": "tsx scripts/license-scan.ts",
27
- "prepack": "pnpm run build",
28
- "test": "vitest run",
29
- "test:unit": "vitest run",
30
- "test:xvfb": "node scripts/bundle.mjs && vitest run -c vitest.xvfb.config.ts",
31
- "typecheck": "tsc -p tsconfig.typecheck.json"
32
- },
33
19
  "dependencies": {},
34
20
  "devDependencies": {
35
21
  "@types/node": "^24.19.1",
@@ -52,5 +38,18 @@
52
38
  },
53
39
  "publishConfig": {
54
40
  "access": "public"
41
+ },
42
+ "scripts": {
43
+ "build": "pnpm --filter \"{.}...\" build:package",
44
+ "build:package": "node scripts/bundle.mjs --dist",
45
+ "bundle": "node scripts/bundle.mjs",
46
+ "bundle:macos": "node scripts/build-macos-app.mjs",
47
+ "clean": "rm -rf dist bundle",
48
+ "dev": "tsx src/cli.ts run",
49
+ "license-scan": "tsx scripts/license-scan.ts",
50
+ "test": "vitest run",
51
+ "test:unit": "vitest run",
52
+ "test:xvfb": "node scripts/bundle.mjs && vitest run -c vitest.xvfb.config.ts",
53
+ "typecheck": "tsc -p tsconfig.typecheck.json"
55
54
  }
56
- }
55
+ }