github-router 0.3.126 → 0.3.130

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";
@@ -1082,6 +1083,9 @@ var ArtifactClient = class {
1082
1083
  agentReply(text, signal) {
1083
1084
  return this.request("POST", `/api/artifact/${encodeURIComponent(this.sessionId)}/agent-reply`, { text }, signal, void 0, true);
1084
1085
  }
1086
+ end(signal) {
1087
+ return this.request("POST", `/api/artifact/${encodeURIComponent(this.sessionId)}/end`, void 0, signal, void 0, true);
1088
+ }
1085
1089
  async request(method, pathname, body, signal, timeoutMsHint, allowEmptyJson = false) {
1086
1090
  let url;
1087
1091
  try {
@@ -1285,6 +1289,15 @@ const ARTIFACT_TOOLS = Object.freeze([
1285
1289
  ...await clientFromEnv(env).agentReply(text, signal),
1286
1290
  next_step: "Wait for further human review, or continue if the review loop is complete."
1287
1291
  });
1292
+ }),
1293
+ tool("artifact_end", "End/close the ai-or-die Artifact review panel when the review loop is complete. Only works inside an ai-or-die tab-backed Claude session.", objectSchema$1({}, []), async (_args, signal) => {
1294
+ const env = readArtifactEnv();
1295
+ if (!env) return missingEnvResult();
1296
+ return ok$1({
1297
+ ok: true,
1298
+ ...await clientFromEnv(env).end(signal),
1299
+ next_step: "Artifact review loop ended."
1300
+ });
1288
1301
  })
1289
1302
  ]);
1290
1303
  function readArtifactEnv() {
@@ -1631,6 +1644,21 @@ function createTunnelTokenProvider(runner = realDevtunnelRunner()) {
1631
1644
 
1632
1645
  //#endregion
1633
1646
  //#region src/lib/fleet/client.ts
1647
+ const IS_BUN = typeof globalThis.Bun !== "undefined";
1648
+ let sharedInsecureDispatcher;
1649
+ function insecureDispatcher() {
1650
+ return sharedInsecureDispatcher ??= new Agent({ connect: { rejectUnauthorized: false } });
1651
+ }
1652
+ /**
1653
+ * Attach the runtime-correct TLS-verification-off mechanism to a fetch init for a
1654
+ * single self-signed direct-HTTPS instance: Bun → `tls`, Node → an undici
1655
+ * `dispatcher`. Exported so BOTH runtime branches are unit-testable under one
1656
+ * interpreter (the untested Node branch is exactly what shipped broken).
1657
+ */
1658
+ function applyInsecureTls(init, isBun = IS_BUN) {
1659
+ if (isBun) init.tls = { rejectUnauthorized: false };
1660
+ else init.dispatcher = insecureDispatcher();
1661
+ }
1634
1662
  var FleetError = class extends Error {
1635
1663
  code;
1636
1664
  retryable;
@@ -1667,6 +1695,7 @@ var FleetClient = class {
1667
1695
  fetchFn;
1668
1696
  getTunnelToken;
1669
1697
  onTunnelAuthInvalidate;
1698
+ insecureTLS;
1670
1699
  constructor(options) {
1671
1700
  this.baseUrl = options.url.replace(/\/+$/, "");
1672
1701
  this.origin = new URL(this.baseUrl).origin;
@@ -1674,6 +1703,7 @@ var FleetClient = class {
1674
1703
  this.fetchFn = options.fetchFn ?? globalThis.fetch.bind(globalThis);
1675
1704
  this.getTunnelToken = options.getTunnelToken;
1676
1705
  this.onTunnelAuthInvalidate = options.onTunnelAuthInvalidate;
1706
+ this.insecureTLS = options.insecureTLS === true;
1677
1707
  }
1678
1708
  capabilities(signal) {
1679
1709
  return this.request("GET", "/api/control/capabilities", void 0, void 0, signal);
@@ -1770,13 +1800,15 @@ var FleetClient = class {
1770
1800
  };
1771
1801
  let response;
1772
1802
  try {
1773
- response = await this.fetchFn(url.toString(), {
1803
+ const init = {
1774
1804
  method,
1775
1805
  headers,
1776
1806
  body: body === void 0 ? void 0 : JSON.stringify(body),
1777
1807
  redirect: "error",
1778
1808
  signal
1779
- });
1809
+ };
1810
+ if (this.insecureTLS) applyInsecureTls(init);
1811
+ response = await this.fetchFn(url.toString(), init);
1780
1812
  } catch (err) {
1781
1813
  if (canRetry && method === "GET") {
1782
1814
  this.onTunnelAuthInvalidate();
@@ -2057,6 +2089,12 @@ function parseInstance(raw) {
2057
2089
  if (typeof token !== "string" || token === "") throw new FleetRegistryError("INVALID_CONFIG", `fleet registry instance ${id} token must be a non-empty string`);
2058
2090
  const tunnelId = parseTunnelId(id, instance.tunnelId);
2059
2091
  const tunnelToken = parseTunnelToken(id, instance.tunnelToken);
2092
+ const insecureTLS = parseInsecureTLS(id, instance.insecureTLS);
2093
+ if (insecureTLS) {
2094
+ 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)`);
2095
+ 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`);
2096
+ 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}`);
2097
+ }
2060
2098
  return {
2061
2099
  id: id.trim(),
2062
2100
  label: label.trim(),
@@ -2065,7 +2103,8 @@ function parseInstance(raw) {
2065
2103
  default: instance.default === true ? true : void 0,
2066
2104
  allowExec: instance.allowExec === true ? true : void 0,
2067
2105
  tunnelId,
2068
- tunnelToken
2106
+ tunnelToken,
2107
+ insecureTLS
2069
2108
  };
2070
2109
  }
2071
2110
  const TUNNEL_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
@@ -2083,6 +2122,11 @@ function parseTunnelToken(id, raw) {
2083
2122
  if (t === "" || /\s/.test(t)) throw new FleetRegistryError("INVALID_CONFIG", `fleet registry instance ${id} tunnelToken must be a non-empty single-line token`);
2084
2123
  return t;
2085
2124
  }
2125
+ function parseInsecureTLS(id, raw) {
2126
+ if (raw === void 0) return void 0;
2127
+ if (typeof raw !== "boolean") throw new FleetRegistryError("INVALID_CONFIG", `fleet registry instance ${id} insecureTLS must be a boolean`);
2128
+ return raw === true ? true : void 0;
2129
+ }
2086
2130
  function invalidInstanceUrlError(id) {
2087
2131
  return new FleetRegistryError("INVALID_CONFIG", `${id.trim()} url must be https (or http://localhost for local testing)`);
2088
2132
  }
@@ -2091,6 +2135,36 @@ function isAllowedInstanceUrl(url) {
2091
2135
  if (url.protocol !== "http:") return false;
2092
2136
  return url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "[::1]";
2093
2137
  }
2138
+ function isLocalNetworkHost(hostnameRaw) {
2139
+ const host = hostnameRaw.replace(/^\[/, "").replace(/\]$/, "").toLowerCase();
2140
+ if (host === "localhost") return true;
2141
+ if (host.endsWith(".local")) return true;
2142
+ const v4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(host);
2143
+ if (v4) {
2144
+ const octets = [
2145
+ Number(v4[1]),
2146
+ Number(v4[2]),
2147
+ Number(v4[3]),
2148
+ Number(v4[4])
2149
+ ];
2150
+ if (octets.some((o) => o > 255)) return false;
2151
+ const a = octets[0];
2152
+ const b = octets[1];
2153
+ if (a === 127) return true;
2154
+ if (a === 10) return true;
2155
+ if (a === 172 && b >= 16 && b <= 31) return true;
2156
+ if (a === 192 && b === 168) return true;
2157
+ if (a === 169 && b === 254) return true;
2158
+ return false;
2159
+ }
2160
+ if (host.includes(":")) {
2161
+ if (host === "::1") return true;
2162
+ if (/^fe[89ab]/.test(host)) return true;
2163
+ if (/^f[cd]/.test(host)) return true;
2164
+ return false;
2165
+ }
2166
+ return false;
2167
+ }
2094
2168
  const DEVTUNNEL_HOST_RE = /(?:^|\.)devtunnels\.ms$|(?:^|\.)tunnels\.api\.visualstudio\.com$/i;
2095
2169
  function assertDevTunnelUrlShape(id, url) {
2096
2170
  if (!DEVTUNNEL_HOST_RE.test(url.hostname)) return;
@@ -2109,7 +2183,8 @@ function resolvedInstance(instance) {
2109
2183
  token: instance.token,
2110
2184
  allowExec: instance.allowExec,
2111
2185
  tunnelId: instance.tunnelId,
2112
- tunnelToken: instance.tunnelToken
2186
+ tunnelToken: instance.tunnelToken,
2187
+ insecureTLS: instance.insecureTLS
2113
2188
  };
2114
2189
  }
2115
2190
  function isObject(value) {
@@ -2158,13 +2233,14 @@ function createFleetTools(options = {}) {
2158
2233
  return defaultRegistry;
2159
2234
  }
2160
2235
  function clientFor(instance) {
2161
- const key = `${instance.id}\0${instance.url}\0${instance.token}\0${instance.tunnelId ?? ""}\0${instance.tunnelToken ?? ""}`;
2236
+ const key = `${instance.id}\0${instance.url}\0${instance.token}\0${instance.tunnelId ?? ""}\0${instance.tunnelToken ?? ""}\0${instance.insecureTLS === true ? "1" : "0"}`;
2162
2237
  const existing = clients.get(key);
2163
2238
  if (existing) return existing;
2164
2239
  const created = options.createClient ? options.createClient(instance) : new FleetClient({
2165
2240
  url: instance.url,
2166
2241
  token: instance.token,
2167
2242
  fetchFn: options.fetchFn,
2243
+ insecureTLS: instance.insecureTLS,
2168
2244
  ...tunnelClientOptions(instance, tunnelProvider)
2169
2245
  });
2170
2246
  clients.set(key, created);
@@ -11975,7 +12051,7 @@ var PendingMessageQueue = class {
11975
12051
  * `Agent` owns the current transcript, emits lifecycle events, executes tools,
11976
12052
  * and exposes queueing APIs for steering and follow-up messages.
11977
12053
  */
11978
- var Agent = class {
12054
+ var Agent$1 = class {
11979
12055
  _state;
11980
12056
  listeners = /* @__PURE__ */ new Set();
11981
12057
  steeringQueue;
@@ -18938,7 +19014,7 @@ async function runWorkerAgentOnce(opts) {
18938
19014
  getMessages,
18939
19015
  planState
18940
19016
  });
18941
- const agent = new Agent({
19017
+ const agent = new Agent$1({
18942
19018
  initialState: {
18943
19019
  systemPrompt: systemPromptFor(opts.mode),
18944
19020
  model: makeModelShim(resolved.modelId),
@@ -22620,4 +22696,4 @@ async function runStandInToolCall(args, signal) {
22620
22696
 
22621
22697
  //#endregion
22622
22698
  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
22699
+ //# sourceMappingURL=peer-mcp-personas-YFzQuogX.js.map