github-router 0.3.126 → 0.3.129

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.
@@ -13,6 +13,7 @@ import process$1 from "node:process";
13
13
  import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
14
14
  import { chmodSync, closeSync, cpSync, existsSync, mkdirSync, openSync, promises, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
15
15
  import { fileURLToPath } from "node:url";
16
+ import { Agent } from "undici";
16
17
  import { performance } from "node:perf_hooks";
17
18
  import { createInterface } from "node:readline";
18
19
  import Parser from "web-tree-sitter";
@@ -1631,6 +1632,21 @@ function createTunnelTokenProvider(runner = realDevtunnelRunner()) {
1631
1632
 
1632
1633
  //#endregion
1633
1634
  //#region src/lib/fleet/client.ts
1635
+ const IS_BUN = typeof globalThis.Bun !== "undefined";
1636
+ let sharedInsecureDispatcher;
1637
+ function insecureDispatcher() {
1638
+ return sharedInsecureDispatcher ??= new Agent({ connect: { rejectUnauthorized: false } });
1639
+ }
1640
+ /**
1641
+ * Attach the runtime-correct TLS-verification-off mechanism to a fetch init for a
1642
+ * single self-signed direct-HTTPS instance: Bun → `tls`, Node → an undici
1643
+ * `dispatcher`. Exported so BOTH runtime branches are unit-testable under one
1644
+ * interpreter (the untested Node branch is exactly what shipped broken).
1645
+ */
1646
+ function applyInsecureTls(init, isBun = IS_BUN) {
1647
+ if (isBun) init.tls = { rejectUnauthorized: false };
1648
+ else init.dispatcher = insecureDispatcher();
1649
+ }
1634
1650
  var FleetError = class extends Error {
1635
1651
  code;
1636
1652
  retryable;
@@ -1667,6 +1683,7 @@ var FleetClient = class {
1667
1683
  fetchFn;
1668
1684
  getTunnelToken;
1669
1685
  onTunnelAuthInvalidate;
1686
+ insecureTLS;
1670
1687
  constructor(options) {
1671
1688
  this.baseUrl = options.url.replace(/\/+$/, "");
1672
1689
  this.origin = new URL(this.baseUrl).origin;
@@ -1674,6 +1691,7 @@ var FleetClient = class {
1674
1691
  this.fetchFn = options.fetchFn ?? globalThis.fetch.bind(globalThis);
1675
1692
  this.getTunnelToken = options.getTunnelToken;
1676
1693
  this.onTunnelAuthInvalidate = options.onTunnelAuthInvalidate;
1694
+ this.insecureTLS = options.insecureTLS === true;
1677
1695
  }
1678
1696
  capabilities(signal) {
1679
1697
  return this.request("GET", "/api/control/capabilities", void 0, void 0, signal);
@@ -1770,13 +1788,15 @@ var FleetClient = class {
1770
1788
  };
1771
1789
  let response;
1772
1790
  try {
1773
- response = await this.fetchFn(url.toString(), {
1791
+ const init = {
1774
1792
  method,
1775
1793
  headers,
1776
1794
  body: body === void 0 ? void 0 : JSON.stringify(body),
1777
1795
  redirect: "error",
1778
1796
  signal
1779
- });
1797
+ };
1798
+ if (this.insecureTLS) applyInsecureTls(init);
1799
+ response = await this.fetchFn(url.toString(), init);
1780
1800
  } catch (err) {
1781
1801
  if (canRetry && method === "GET") {
1782
1802
  this.onTunnelAuthInvalidate();
@@ -2057,6 +2077,12 @@ function parseInstance(raw) {
2057
2077
  if (typeof token !== "string" || token === "") throw new FleetRegistryError("INVALID_CONFIG", `fleet registry instance ${id} token must be a non-empty string`);
2058
2078
  const tunnelId = parseTunnelId(id, instance.tunnelId);
2059
2079
  const tunnelToken = parseTunnelToken(id, instance.tunnelToken);
2080
+ const insecureTLS = parseInsecureTLS(id, instance.insecureTLS);
2081
+ if (insecureTLS) {
2082
+ if (parsedUrl.protocol !== "https:") throw new FleetRegistryError("INVALID_CONFIG", `fleet registry instance ${id} insecureTLS only applies to an https url (an http url has no TLS to relax)`);
2083
+ if (tunnelId !== void 0 || tunnelToken !== void 0) throw new FleetRegistryError("INVALID_CONFIG", `fleet registry instance ${id} insecureTLS must not be combined with a Dev Tunnel (tunnelId/tunnelToken); the relay presents a valid public cert, so disabling verification only exposes the bearer/tunnel token to MITM`);
2084
+ if (!isLocalNetworkHost(parsedUrl.hostname)) throw new FleetRegistryError("INVALID_CONFIG", DEVTUNNEL_HOST_RE.test(parsedUrl.hostname) ? `fleet registry instance ${id} insecureTLS must not be set on a Dev Tunnel host; *.devtunnels.ms presents a valid public cert` : `fleet registry instance ${id} insecureTLS is only allowed for a local-network host (loopback, a private/LAN IP, or a .local name); refusing to disable TLS verification for public host ${parsedUrl.hostname}`);
2085
+ }
2060
2086
  return {
2061
2087
  id: id.trim(),
2062
2088
  label: label.trim(),
@@ -2065,7 +2091,8 @@ function parseInstance(raw) {
2065
2091
  default: instance.default === true ? true : void 0,
2066
2092
  allowExec: instance.allowExec === true ? true : void 0,
2067
2093
  tunnelId,
2068
- tunnelToken
2094
+ tunnelToken,
2095
+ insecureTLS
2069
2096
  };
2070
2097
  }
2071
2098
  const TUNNEL_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
@@ -2083,6 +2110,11 @@ function parseTunnelToken(id, raw) {
2083
2110
  if (t === "" || /\s/.test(t)) throw new FleetRegistryError("INVALID_CONFIG", `fleet registry instance ${id} tunnelToken must be a non-empty single-line token`);
2084
2111
  return t;
2085
2112
  }
2113
+ function parseInsecureTLS(id, raw) {
2114
+ if (raw === void 0) return void 0;
2115
+ if (typeof raw !== "boolean") throw new FleetRegistryError("INVALID_CONFIG", `fleet registry instance ${id} insecureTLS must be a boolean`);
2116
+ return raw === true ? true : void 0;
2117
+ }
2086
2118
  function invalidInstanceUrlError(id) {
2087
2119
  return new FleetRegistryError("INVALID_CONFIG", `${id.trim()} url must be https (or http://localhost for local testing)`);
2088
2120
  }
@@ -2091,6 +2123,36 @@ function isAllowedInstanceUrl(url) {
2091
2123
  if (url.protocol !== "http:") return false;
2092
2124
  return url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "[::1]";
2093
2125
  }
2126
+ function isLocalNetworkHost(hostnameRaw) {
2127
+ const host = hostnameRaw.replace(/^\[/, "").replace(/\]$/, "").toLowerCase();
2128
+ if (host === "localhost") return true;
2129
+ if (host.endsWith(".local")) return true;
2130
+ const v4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(host);
2131
+ if (v4) {
2132
+ const octets = [
2133
+ Number(v4[1]),
2134
+ Number(v4[2]),
2135
+ Number(v4[3]),
2136
+ Number(v4[4])
2137
+ ];
2138
+ if (octets.some((o) => o > 255)) return false;
2139
+ const a = octets[0];
2140
+ const b = octets[1];
2141
+ if (a === 127) return true;
2142
+ if (a === 10) return true;
2143
+ if (a === 172 && b >= 16 && b <= 31) return true;
2144
+ if (a === 192 && b === 168) return true;
2145
+ if (a === 169 && b === 254) return true;
2146
+ return false;
2147
+ }
2148
+ if (host.includes(":")) {
2149
+ if (host === "::1") return true;
2150
+ if (/^fe[89ab]/.test(host)) return true;
2151
+ if (/^f[cd]/.test(host)) return true;
2152
+ return false;
2153
+ }
2154
+ return false;
2155
+ }
2094
2156
  const DEVTUNNEL_HOST_RE = /(?:^|\.)devtunnels\.ms$|(?:^|\.)tunnels\.api\.visualstudio\.com$/i;
2095
2157
  function assertDevTunnelUrlShape(id, url) {
2096
2158
  if (!DEVTUNNEL_HOST_RE.test(url.hostname)) return;
@@ -2109,7 +2171,8 @@ function resolvedInstance(instance) {
2109
2171
  token: instance.token,
2110
2172
  allowExec: instance.allowExec,
2111
2173
  tunnelId: instance.tunnelId,
2112
- tunnelToken: instance.tunnelToken
2174
+ tunnelToken: instance.tunnelToken,
2175
+ insecureTLS: instance.insecureTLS
2113
2176
  };
2114
2177
  }
2115
2178
  function isObject(value) {
@@ -2158,13 +2221,14 @@ function createFleetTools(options = {}) {
2158
2221
  return defaultRegistry;
2159
2222
  }
2160
2223
  function clientFor(instance) {
2161
- const key = `${instance.id}\0${instance.url}\0${instance.token}\0${instance.tunnelId ?? ""}\0${instance.tunnelToken ?? ""}`;
2224
+ const key = `${instance.id}\0${instance.url}\0${instance.token}\0${instance.tunnelId ?? ""}\0${instance.tunnelToken ?? ""}\0${instance.insecureTLS === true ? "1" : "0"}`;
2162
2225
  const existing = clients.get(key);
2163
2226
  if (existing) return existing;
2164
2227
  const created = options.createClient ? options.createClient(instance) : new FleetClient({
2165
2228
  url: instance.url,
2166
2229
  token: instance.token,
2167
2230
  fetchFn: options.fetchFn,
2231
+ insecureTLS: instance.insecureTLS,
2168
2232
  ...tunnelClientOptions(instance, tunnelProvider)
2169
2233
  });
2170
2234
  clients.set(key, created);
@@ -11975,7 +12039,7 @@ var PendingMessageQueue = class {
11975
12039
  * `Agent` owns the current transcript, emits lifecycle events, executes tools,
11976
12040
  * and exposes queueing APIs for steering and follow-up messages.
11977
12041
  */
11978
- var Agent = class {
12042
+ var Agent$1 = class {
11979
12043
  _state;
11980
12044
  listeners = /* @__PURE__ */ new Set();
11981
12045
  steeringQueue;
@@ -18938,7 +19002,7 @@ async function runWorkerAgentOnce(opts) {
18938
19002
  getMessages,
18939
19003
  planState
18940
19004
  });
18941
- const agent = new Agent({
19005
+ const agent = new Agent$1({
18942
19006
  initialState: {
18943
19007
  systemPrompt: systemPromptFor(opts.mode),
18944
19008
  model: makeModelShim(resolved.modelId),
@@ -22620,4 +22684,4 @@ async function runStandInToolCall(args, signal) {
22620
22684
 
22621
22685
  //#endregion
22622
22686
  export { handleMcpDelete as $, IMPLEMENT_DEFAULT_MODEL as A, setupCopilotToken as At, TOOLBELT_TOOLS$1 as B, sleep as Bt, stopGateEnabledForRepo as C, DEFAULT_PORT as Ct, liveExec as D, pickClaudeDefault as Dt, resolveSealedGate as E, generateRandomPort as Et, availableToolCommands as F, cacheVSCodeVersion as Ft, buildAdvisorStream as G, GITHUB_API_BASE_URL as Gt, searchWeb as H, fetchWithTransientRetry as Ht, buildToolbeltAwareness as I, filterBetaHeader as It, buildOpenAIErrorEvent as J, githubHeaders as Jt, injectAdvisorTool as K, copilotBaseUrl as Kt, toolbeltEnabled as L, isNullish as Lt, appendPlanReminder as M, tryRefreshAndRetry as Mt, runWorkerAgent as N, cacheCopilotVersion as Nt, BROWSE_DEFAULT_MODEL as O, getPackageVersion as Ot, withNoOutputRetry as P, cacheModels as Pt, relayAnthropicStream as Q, toolbeltSkipSet as R, resolveCodexModel as Rt, repoRoot as S, DEFAULT_CODEX_MODEL_FALLBACKS as St, trustRepo as T, UPSTREAM_INACTIVITY_TIMEOUT_MS as Tt, ADVISOR_INTERNAL_TOOL_NAME as U, HTTPError as Ut, assetFor as V, getModels as Vt, ADVISOR_TOOL_INSTRUCTIONS as W, forwardError as Wt, logStreamError as X, isControllerClosedError as Y, state as Yt, readIteratorWithTimeout as Z, fileFindingsStore as _, extractZipMember as _t, buildPeerAwarenessSnippet as a, countTokens as at, isSubagentContext as b, DEFAULT_CLAUDE_MODEL_FALLBACKS as bt, buildStopHookCommand as c, createResponses as ct, fileBlockBudget as d, readResponseBodyCapped as dt, handleMcpPost as et, injectStopHookIntoSettingsFile as f, parseJsonOrDiagnose as ft, fileBaselineStore as g, extractTarGzMember as gt, stopReviewEnabled as h, provisionAndIndexColbert as ht, buildAgentPrompt as i, workerToolsEnabled as it, PLAN_DEFAULT_MODEL as j, setupGitHubToken as jt, DEFAULT_MODEL as k, withInstallLock as kt, captureLaunchBaseline as l, createChatCompletions as lt, stopGateId as m, hasSupportedBrowserInstalled as mt, MCP_GROUPS as n, fleetToolsEnabled as nt, personasFor as o, createMessages as ot, launchBaselineKey as p, provisionBrowserAssets as pt, isAdvisorRequested as q, copilotHeaders as qt, assertMcpToolSurfaceConsistent as r, standInToolEnabled as rt, buildSessionBindHookCommand as s, getTokenCount as st, GROUP_META as t, browserToolsEnabled as tt, decideStopHook as u, MAX_RESPONSE_BODY_BYTES as ut, fileLastPromptStore as v, collapsePathKeys as vt, stopReviewStateDir as w, UPSTREAM_FETCH_TIMEOUT_MS as wt, repoFingerprint as x, DEFAULT_CODEX_MODEL as xt, fileReviewDebounce as y, toolbeltPathOverride as yt, vscodeRipgrepPath as z, resolveModel as zt };
22623
- //# sourceMappingURL=peer-mcp-personas-Be4SAgm0.js.map
22687
+ //# sourceMappingURL=peer-mcp-personas-B1Oqydxt.js.map