@alpic-ai/sdk 0.0.0-dev.g99a887e → 0.0.0-dev.g99caa18

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.
@@ -5,129 +5,123 @@ const OFFLINE_TIMEOUT_MS = 30_000;
5
5
  const FLAP_WINDOW_MS = 5_000;
6
6
  const FLAP_MIN_SPAN_MS = 2_000;
7
7
  const FLAP_THRESHOLD = 15;
8
- export function createTunnel(deps) {
9
- return {
10
- async open(opts) {
11
- // Load the patched pipenet bundle lazily so non-tunnel consumers (every
12
- // `alpic` command, the skybridge dev server) don't pay its ~500KB load
13
- // cost at startup — only when a tunnel is actually opened.
14
- const pipenet = deps.pipenet ?? (await import("../vendor/pipenet.js")).pipenet;
15
- const accessToken = await deps.ensureToken({
16
- autoLogin: opts.autoLogin,
17
- onLoginUrl: opts.onLoginUrl,
18
- });
19
- const ticket = await deps.api.tunnels.getTicket.v1(undefined, {
20
- context: {
21
- request: { headers: { Authorization: `Bearer ${accessToken}` } },
22
- },
23
- });
24
- // ALPIC_TUNNEL_HOST points a real ticket at a locally-run tunnel server. It's a dev
25
- // override for a local (plain-HTTP) server, so default to http regardless of the host;
26
- // pass an explicit https:// to force TLS.
27
- const hostOverride = process.env.ALPIC_TUNNEL_HOST;
28
- let tunnelHost;
29
- let proto;
30
- if (hostOverride) {
31
- proto = hostOverride.startsWith("https://") ? "https" : "http";
32
- tunnelHost = hostOverride.replace(/^https?:\/\//, "");
8
+ export class Tunnel {
9
+ deps;
10
+ constructor(deps) {
11
+ this.deps = deps;
12
+ }
13
+ async open(opts) {
14
+ // Load the patched pipenet bundle lazily so non-tunnel consumers (every
15
+ // `alpic` command, the skybridge dev server) don't pay its ~500KB load
16
+ // cost at startup — only when a tunnel is actually opened.
17
+ const pipenet = this.deps.pipenet ?? (await import("../vendor/pipenet.js")).pipenet;
18
+ const ticket = await this.deps.api.tunnels.getTicket.v1();
19
+ // ALPIC_TUNNEL_HOST points a real ticket at a locally-run tunnel server. It's a dev
20
+ // override for a local (plain-HTTP) server, so default to http regardless of the host;
21
+ // pass an explicit https:// to force TLS.
22
+ const hostOverride = process.env.ALPIC_TUNNEL_HOST;
23
+ let tunnelHost;
24
+ let proto;
25
+ if (hostOverride) {
26
+ proto = hostOverride.startsWith("https://") ? "https" : "http";
27
+ tunnelHost = hostOverride.replace(/^https?:\/\//, "");
28
+ }
29
+ else {
30
+ tunnelHost = ticket.tunnelHost;
31
+ proto = tunnelHost.startsWith("localhost") ? "http" : "https";
32
+ }
33
+ let timeoutId;
34
+ const socket = await Promise.race([
35
+ pipenet({
36
+ port: opts.port,
37
+ host: `${proto}://${tunnelHost}`,
38
+ subdomain: ticket.subdomain,
39
+ headers: { Authorization: `Bearer ${ticket.ticket}` },
40
+ keepAliveDelayMs: KEEPALIVE_DELAY_MS,
41
+ offlineTimeoutMs: OFFLINE_TIMEOUT_MS,
42
+ }).then((socket) => {
43
+ clearTimeout(timeoutId);
44
+ return socket;
45
+ }),
46
+ new Promise((_, reject) => {
47
+ timeoutId = setTimeout(() => reject(new Error("Failed to connect to tunnel server")), CONNECT_TIMEOUT_MS);
48
+ timeoutId.unref?.();
49
+ }),
50
+ ]);
51
+ const url = `${proto}://${ticket.subdomain}.${tunnelHost}`;
52
+ const requestListeners = new Set();
53
+ const errorListeners = new Set();
54
+ const closeListeners = new Set();
55
+ let lastRequestAt = 0;
56
+ let displaced = false;
57
+ let closed = false;
58
+ socket.on("request", (req) => {
59
+ lastRequestAt = Date.now();
60
+ for (const listener of requestListeners) {
61
+ listener(req);
33
62
  }
34
- else {
35
- tunnelHost = ticket.tunnelHost;
36
- proto = tunnelHost.startsWith("localhost") ? "http" : "https";
63
+ });
64
+ socket.on("error", (err) => {
65
+ for (const listener of errorListeners) {
66
+ listener(err);
37
67
  }
38
- let timeoutId;
39
- const socket = await Promise.race([
40
- pipenet({
41
- port: opts.port,
42
- host: `${proto}://${tunnelHost}`,
43
- subdomain: ticket.subdomain,
44
- headers: { Authorization: `Bearer ${ticket.ticket}` },
45
- keepAliveDelayMs: KEEPALIVE_DELAY_MS,
46
- offlineTimeoutMs: OFFLINE_TIMEOUT_MS,
47
- }).then((socket) => {
48
- clearTimeout(timeoutId);
49
- return socket;
50
- }),
51
- new Promise((_, reject) => {
52
- timeoutId = setTimeout(() => reject(new Error("Failed to connect to tunnel server")), CONNECT_TIMEOUT_MS);
53
- timeoutId.unref?.();
54
- }),
55
- ]);
56
- const url = `${proto}://${ticket.subdomain}.${tunnelHost}`;
57
- const requestListeners = new Set();
58
- const errorListeners = new Set();
59
- const closeListeners = new Set();
60
- let lastRequestAt = 0;
61
- let displaced = false;
62
- let closed = false;
63
- socket.on("request", (req) => {
64
- lastRequestAt = Date.now();
65
- for (const listener of requestListeners) {
66
- listener(req);
67
- }
68
- });
69
- socket.on("error", (err) => {
70
- for (const listener of errorListeners) {
71
- listener(err);
72
- }
73
- });
74
- socket.on("close", () => {
75
- closed = true;
76
- const info = displaced ? { displaced: true } : undefined;
77
- for (const listener of closeListeners) {
78
- listener(info);
79
- }
80
- });
81
- // Detect being displaced by a newer tunnel. When another tunnel takes over this
82
- // account's subdomain, the server closes our tunnel and rejects our reconnections
83
- // (they target a session id that no longer exists), so each one connects and is
84
- // dropped within milliseconds. pipenet's offlineTimeoutMs never fires for this — it
85
- // only triggers when the server is unreachable entirely (failed connects emit no
86
- // "dead"). A "dead" with a prior "open" means a socket reached the server and was
87
- // dropped, so a sustained storm of them is the takeover signature.
88
- //
89
- // Normal serving also churns sockets: with the server's small keep-alive pool, most
90
- // concurrent requests get their socket destroyed right after serving, emitting a
91
- // "dead" each. A heavy page load can fire 15+ in a few seconds and look identical to
92
- // a takeover. The discriminator: a real takeover routes all traffic to the new
93
- // tunnel, so we serve zero requests during the storm. Ignore it while requests flow.
94
- let drops = [];
95
- socket.tunnelCluster?.on("dead", () => {
96
- if (displaced || closed) {
97
- return;
68
+ });
69
+ socket.on("close", () => {
70
+ closed = true;
71
+ const info = displaced ? { displaced: true } : undefined;
72
+ for (const listener of closeListeners) {
73
+ listener(info);
74
+ }
75
+ });
76
+ // Detect being displaced by a newer tunnel. When another tunnel takes over this
77
+ // account's subdomain, the server closes our tunnel and rejects our reconnections
78
+ // (they target a session id that no longer exists), so each one connects and is
79
+ // dropped within milliseconds. pipenet's offlineTimeoutMs never fires for this — it
80
+ // only triggers when the server is unreachable entirely (failed connects emit no
81
+ // "dead"). A "dead" with a prior "open" means a socket reached the server and was
82
+ // dropped, so a sustained storm of them is the takeover signature.
83
+ //
84
+ // Normal serving also churns sockets: with the server's small keep-alive pool, most
85
+ // concurrent requests get their socket destroyed right after serving, emitting a
86
+ // "dead" each. A heavy page load can fire 15+ in a few seconds and look identical to
87
+ // a takeover. The discriminator: a real takeover routes all traffic to the new
88
+ // tunnel, so we serve zero requests during the storm. Ignore it while requests flow.
89
+ let drops = [];
90
+ socket.tunnelCluster?.on("dead", () => {
91
+ if (displaced || closed) {
92
+ return;
93
+ }
94
+ const now = Date.now();
95
+ if (now - lastRequestAt < FLAP_WINDOW_MS) {
96
+ drops = [];
97
+ return;
98
+ }
99
+ drops.push(now);
100
+ drops = drops.filter((at) => now - at < FLAP_WINDOW_MS);
101
+ const oldest = drops[0] ?? now;
102
+ if (drops.length >= FLAP_THRESHOLD && now - oldest >= FLAP_MIN_SPAN_MS) {
103
+ displaced = true;
104
+ socket.close();
105
+ }
106
+ });
107
+ return {
108
+ url,
109
+ on(event, listener) {
110
+ if (event === "request") {
111
+ requestListeners.add(listener);
98
112
  }
99
- const now = Date.now();
100
- if (now - lastRequestAt < FLAP_WINDOW_MS) {
101
- drops = [];
102
- return;
113
+ else if (event === "error") {
114
+ errorListeners.add(listener);
103
115
  }
104
- drops.push(now);
105
- drops = drops.filter((at) => now - at < FLAP_WINDOW_MS);
106
- const oldest = drops[0] ?? now;
107
- if (drops.length >= FLAP_THRESHOLD && now - oldest >= FLAP_MIN_SPAN_MS) {
108
- displaced = true;
109
- socket.close();
116
+ else {
117
+ closeListeners.add(listener);
110
118
  }
111
- });
112
- return {
113
- url,
114
- on(event, listener) {
115
- if (event === "request") {
116
- requestListeners.add(listener);
117
- }
118
- else if (event === "error") {
119
- errorListeners.add(listener);
120
- }
121
- else {
122
- closeListeners.add(listener);
123
- }
124
- },
125
- close() {
126
- closed = true;
127
- socket.close();
128
- },
129
- };
130
- },
131
- };
119
+ },
120
+ close() {
121
+ closed = true;
122
+ socket.close();
123
+ },
124
+ };
125
+ }
132
126
  }
133
127
  //# sourceMappingURL=tunnel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tunnel.js","sourceRoot":"","sources":["../../src/tunnel/tunnel.ts"],"names":[],"mappings":"AAEA,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAClC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,qEAAqE;AACrE,MAAM,cAAc,GAAG,KAAK,CAAC;AAC7B,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,MAAM,cAAc,GAAG,EAAE,CAAC;AAmC1B,MAAM,UAAU,YAAY,CAAC,IAI5B;IACC,OAAO;QACL,KAAK,CAAC,IAAI,CAAC,IAAuB;YAChC,wEAAwE;YACxE,uEAAuE;YACvE,2DAA2D;YAC3D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAK,CAAC,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,OAA8B,CAAC;YAEvG,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC;gBACzC,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,UAAU,EAAE,IAAI,CAAC,UAAU;aAC5B,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE;gBAC5D,OAAO,EAAE;oBACP,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,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BACxB,OAAO;YACT,CAAC;YACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,IAAI,GAAG,GAAG,aAAa,GAAG,cAAc,EAAE,CAAC;gBACzC,KAAK,GAAG,EAAE,CAAC;gBACX,OAAO;YACT,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAChB,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,EAAE,GAAG,cAAc,CAAC,CAAC;YACxD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;YAC/B,IAAI,KAAK,CAAC,MAAM,IAAI,cAAc,IAAI,GAAG,GAAG,MAAM,IAAI,gBAAgB,EAAE,CAAC;gBACvE,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,GAAG;YACH,EAAE,CAAC,KAAK,EAAE,QAAQ;gBAChB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBACxB,gBAAgB,CAAC,GAAG,CAAC,QAAwC,CAAC,CAAC;gBACjE,CAAC;qBAAM,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;oBAC7B,cAAc,CAAC,GAAG,CAAC,QAAgC,CAAC,CAAC;gBACvD,CAAC;qBAAM,CAAC;oBACN,cAAc,CAAC,GAAG,CAAC,QAA4C,CAAC,CAAC;gBACnE,CAAC;YACH,CAAC;YACD,KAAK;gBACH,MAAM,GAAG,IAAI,CAAC;gBACd,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -9978,9 +9978,20 @@ var require_es_set_tostringtag = __commonJS({
9978
9978
  }
9979
9979
  });
9980
9980
 
9981
- // ../../node_modules/.pnpm/form-data@4.0.5/node_modules/form-data/lib/populate.js
9981
+ // ../../node_modules/.pnpm/hasown@2.0.4/node_modules/hasown/index.js
9982
+ var require_hasown2 = __commonJS({
9983
+ "../../node_modules/.pnpm/hasown@2.0.4/node_modules/hasown/index.js"(exports, module) {
9984
+ "use strict";
9985
+ var call = Function.prototype.call;
9986
+ var $hasOwn = Object.prototype.hasOwnProperty;
9987
+ var bind2 = require_function_bind();
9988
+ module.exports = bind2.call(call, $hasOwn);
9989
+ }
9990
+ });
9991
+
9992
+ // ../../node_modules/.pnpm/form-data@4.0.6/node_modules/form-data/lib/populate.js
9982
9993
  var require_populate = __commonJS({
9983
- "../../node_modules/.pnpm/form-data@4.0.5/node_modules/form-data/lib/populate.js"(exports, module) {
9994
+ "../../node_modules/.pnpm/form-data@4.0.6/node_modules/form-data/lib/populate.js"(exports, module) {
9984
9995
  "use strict";
9985
9996
  module.exports = function(dst, src) {
9986
9997
  Object.keys(src).forEach(function(prop) {
@@ -9991,9 +10002,9 @@ var require_populate = __commonJS({
9991
10002
  }
9992
10003
  });
9993
10004
 
9994
- // ../../node_modules/.pnpm/form-data@4.0.5/node_modules/form-data/lib/form_data.js
10005
+ // ../../node_modules/.pnpm/form-data@4.0.6/node_modules/form-data/lib/form_data.js
9995
10006
  var require_form_data = __commonJS({
9996
- "../../node_modules/.pnpm/form-data@4.0.5/node_modules/form-data/lib/form_data.js"(exports, module) {
10007
+ "../../node_modules/.pnpm/form-data@4.0.6/node_modules/form-data/lib/form_data.js"(exports, module) {
9997
10008
  "use strict";
9998
10009
  var CombinedStream = require_combined_stream();
9999
10010
  var util3 = __require("util");
@@ -10007,8 +10018,11 @@ var require_form_data = __commonJS({
10007
10018
  var mime = require_mime_types();
10008
10019
  var asynckit = require_asynckit();
10009
10020
  var setToStringTag = require_es_set_tostringtag();
10010
- var hasOwn = require_hasown();
10021
+ var hasOwn = require_hasown2();
10011
10022
  var populate = require_populate();
10023
+ function escapeHeaderParam(str) {
10024
+ return String(str).replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/"/g, "%22");
10025
+ }
10012
10026
  function FormData3(options) {
10013
10027
  if (!(this instanceof FormData3)) {
10014
10028
  return new FormData3(options);
@@ -10098,7 +10112,7 @@ var require_form_data = __commonJS({
10098
10112
  var contents = "";
10099
10113
  var headers = {
10100
10114
  // add custom disposition as third element or keep it two elements if not
10101
- "Content-Disposition": ["form-data", 'name="' + field + '"'].concat(contentDisposition || []),
10115
+ "Content-Disposition": ["form-data", 'name="' + escapeHeaderParam(field) + '"'].concat(contentDisposition || []),
10102
10116
  // if no content type. allow it to be empty array
10103
10117
  "Content-Type": [].concat(contentType || [])
10104
10118
  };
@@ -10132,7 +10146,7 @@ var require_form_data = __commonJS({
10132
10146
  filename = path.basename(value.client._httpMessage.path || "");
10133
10147
  }
10134
10148
  if (filename) {
10135
- return 'filename="' + filename + '"';
10149
+ return 'filename="' + escapeHeaderParam(filename) + '"';
10136
10150
  }
10137
10151
  };
10138
10152
  FormData3.prototype._getContentType = function(value, options) {
@@ -10426,9 +10440,9 @@ var require_ms = __commonJS({
10426
10440
  }
10427
10441
  });
10428
10442
 
10429
- // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
10443
+ // ../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js
10430
10444
  var require_common = __commonJS({
10431
- "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports, module) {
10445
+ "../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js"(exports, module) {
10432
10446
  function setup(env) {
10433
10447
  createDebug.debug = createDebug;
10434
10448
  createDebug.default = createDebug;
@@ -10603,9 +10617,9 @@ var require_common = __commonJS({
10603
10617
  }
10604
10618
  });
10605
10619
 
10606
- // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
10620
+ // ../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js
10607
10621
  var require_browser = __commonJS({
10608
- "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports, module) {
10622
+ "../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js"(exports, module) {
10609
10623
  exports.formatArgs = formatArgs;
10610
10624
  exports.save = save;
10611
10625
  exports.load = load;
@@ -10900,9 +10914,9 @@ var require_supports_color = __commonJS({
10900
10914
  }
10901
10915
  });
10902
10916
 
10903
- // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
10917
+ // ../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js
10904
10918
  var require_node = __commonJS({
10905
- "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports, module) {
10919
+ "../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js"(exports, module) {
10906
10920
  var tty = __require("tty");
10907
10921
  var util3 = __require("util");
10908
10922
  exports.init = init;
@@ -11074,9 +11088,9 @@ var require_node = __commonJS({
11074
11088
  }
11075
11089
  });
11076
11090
 
11077
- // ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
11091
+ // ../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js
11078
11092
  var require_src = __commonJS({
11079
- "../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports, module) {
11093
+ "../../node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js"(exports, module) {
11080
11094
  if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
11081
11095
  module.exports = require_browser();
11082
11096
  } else {
@@ -16571,18 +16585,18 @@ var {
16571
16585
  create
16572
16586
  } = axios_default;
16573
16587
 
16574
- // ../../node_modules/.pnpm/pipenet@1.4.0_patch_hash=24bd89f8b5bea6a63243b7a7d4ad888dcf7049e36eac19b10006403b29758c35/node_modules/pipenet/dist/Tunnel.js
16588
+ // ../../node_modules/.pnpm/pipenet@1.4.2_patch_hash=4a969c2edb33b7885d9a25490aa8b87f86e8fd86455a95c8e3c8aa4bdac720b9/node_modules/pipenet/dist/Tunnel.js
16575
16589
  var import_debug2 = __toESM(require_src(), 1);
16576
16590
  import { EventEmitter as EventEmitter3 } from "events";
16577
16591
 
16578
- // ../../node_modules/.pnpm/pipenet@1.4.0_patch_hash=24bd89f8b5bea6a63243b7a7d4ad888dcf7049e36eac19b10006403b29758c35/node_modules/pipenet/dist/TunnelCluster.js
16592
+ // ../../node_modules/.pnpm/pipenet@1.4.2_patch_hash=4a969c2edb33b7885d9a25490aa8b87f86e8fd86455a95c8e3c8aa4bdac720b9/node_modules/pipenet/dist/TunnelCluster.js
16579
16593
  var import_debug = __toESM(require_src(), 1);
16580
16594
  import { EventEmitter as EventEmitter2 } from "events";
16581
16595
  import fs from "fs";
16582
16596
  import net from "net";
16583
16597
  import tls from "tls";
16584
16598
 
16585
- // ../../node_modules/.pnpm/pipenet@1.4.0_patch_hash=24bd89f8b5bea6a63243b7a7d4ad888dcf7049e36eac19b10006403b29758c35/node_modules/pipenet/dist/HeaderHostTransformer.js
16599
+ // ../../node_modules/.pnpm/pipenet@1.4.2_patch_hash=4a969c2edb33b7885d9a25490aa8b87f86e8fd86455a95c8e3c8aa4bdac720b9/node_modules/pipenet/dist/HeaderHostTransformer.js
16586
16600
  import { Transform } from "stream";
16587
16601
  var HeaderHostTransformer = class extends Transform {
16588
16602
  host;
@@ -16600,7 +16614,7 @@ var HeaderHostTransformer = class extends Transform {
16600
16614
  }
16601
16615
  };
16602
16616
 
16603
- // ../../node_modules/.pnpm/pipenet@1.4.0_patch_hash=24bd89f8b5bea6a63243b7a7d4ad888dcf7049e36eac19b10006403b29758c35/node_modules/pipenet/dist/TunnelCluster.js
16617
+ // ../../node_modules/.pnpm/pipenet@1.4.2_patch_hash=4a969c2edb33b7885d9a25490aa8b87f86e8fd86455a95c8e3c8aa4bdac720b9/node_modules/pipenet/dist/TunnelCluster.js
16604
16618
  var log = (0, import_debug.default)("pipenet:client");
16605
16619
  var TunnelCluster = class extends EventEmitter2 {
16606
16620
  opts;
@@ -16633,18 +16647,10 @@ var TunnelCluster = class extends EventEmitter2 {
16633
16647
  }
16634
16648
  remote.end();
16635
16649
  });
16636
- let deadEmitted = false;
16637
- const emitDead = () => {
16638
- if (deadEmitted) {
16639
- return;
16640
- }
16641
- deadEmitted = true;
16642
- this.emit("dead", remote);
16643
- };
16644
16650
  const connLocal = () => {
16645
16651
  if (remote.destroyed) {
16646
16652
  log("remote destroyed");
16647
- emitDead();
16653
+ this.emit("dead", remote);
16648
16654
  return;
16649
16655
  }
16650
16656
  log("connecting locally to %s://%s:%d", localProtocol, localHost, localPort);
@@ -16660,7 +16666,7 @@ var TunnelCluster = class extends EventEmitter2 {
16660
16666
  const local = opt.localHttps ? tls.connect({ host: localHost, port: localPort, ...getLocalCertOpts() }) : net.connect({ host: localHost, port: localPort });
16661
16667
  const remoteClose = () => {
16662
16668
  log("remote close");
16663
- emitDead();
16669
+ this.emit("dead", remote);
16664
16670
  local.end();
16665
16671
  };
16666
16672
  remote.once("close", remoteClose);
@@ -16708,7 +16714,7 @@ var TunnelCluster = class extends EventEmitter2 {
16708
16714
  }
16709
16715
  };
16710
16716
 
16711
- // ../../node_modules/.pnpm/pipenet@1.4.0_patch_hash=24bd89f8b5bea6a63243b7a7d4ad888dcf7049e36eac19b10006403b29758c35/node_modules/pipenet/dist/Tunnel.js
16717
+ // ../../node_modules/.pnpm/pipenet@1.4.2_patch_hash=4a969c2edb33b7885d9a25490aa8b87f86e8fd86455a95c8e3c8aa4bdac720b9/node_modules/pipenet/dist/Tunnel.js
16712
16718
  var log2 = (0, import_debug2.default)("pipenet:client");
16713
16719
  var Tunnel = class extends EventEmitter3 {
16714
16720
  cachedUrl;
@@ -16856,7 +16862,7 @@ var Tunnel = class extends EventEmitter3 {
16856
16862
  }
16857
16863
  };
16858
16864
 
16859
- // ../../node_modules/.pnpm/pipenet@1.4.0_patch_hash=24bd89f8b5bea6a63243b7a7d4ad888dcf7049e36eac19b10006403b29758c35/node_modules/pipenet/dist/pipenet.js
16865
+ // ../../node_modules/.pnpm/pipenet@1.4.2_patch_hash=4a969c2edb33b7885d9a25490aa8b87f86e8fd86455a95c8e3c8aa4bdac720b9/node_modules/pipenet/dist/pipenet.js
16860
16866
  function pipenet(arg1, arg2, arg3) {
16861
16867
  const options = typeof arg1 === "object" ? arg1 : { ...arg2, port: arg1 };
16862
16868
  const callback = typeof arg1 === "object" ? arg2 : arg3;