@canonry/canonry 7.51.1 → 7.51.3

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.
@@ -29,7 +29,7 @@ import {
29
29
  persistSiteCrawlGraphLayout,
30
30
  prepareSiteCrawlGraphLayout,
31
31
  recordedSharePct
32
- } from "./chunk-W43I4JKI.js";
32
+ } from "./chunk-6GNV6VF4.js";
33
33
  import {
34
34
  CanonryMcpToolNames,
35
35
  PACKAGE_VERSION,
@@ -241,7 +241,7 @@ import {
241
241
  webhookResponseReason,
242
242
  webhookTargetRefusalReason,
243
243
  writeAuditLog
244
- } from "./chunk-QQP7OQTW.js";
244
+ } from "./chunk-KUS7M65J.js";
245
245
  import {
246
246
  AGENT_MEMORY_VALUE_MAX_BYTES,
247
247
  AGENT_NONE,
@@ -698,7 +698,9 @@ function getServerUpdateStatus(opts) {
698
698
 
699
699
  // src/telemetry.ts
700
700
  import crypto from "crypto";
701
+ import fs3 from "fs";
701
702
  import os2 from "os";
703
+ import path2 from "path";
702
704
 
703
705
  // src/telemetry-environment.ts
704
706
  import fs2 from "fs";
@@ -908,9 +910,38 @@ function hostDerivedId(prefix) {
908
910
  }
909
911
  var machineId;
910
912
  function getMachineId() {
911
- machineId ??= { value: hostDerivedId("canonry-machine") };
913
+ machineId ??= {
914
+ value: resolveMachineId({
915
+ filePath: path2.join(os2.homedir(), ".canonry", "machine-id"),
916
+ inContainer: telemetryEnvironment().includes("container"),
917
+ derive: () => hostDerivedId("canonry-machine")
918
+ })
919
+ };
912
920
  return machineId.value;
913
921
  }
922
+ function resolveMachineId(opts) {
923
+ if (opts.inContainer) return void 0;
924
+ const saved = readMachineIdFile(opts.filePath);
925
+ if (saved) return saved;
926
+ const derived = opts.derive();
927
+ if (!derived) return void 0;
928
+ try {
929
+ fs3.mkdirSync(path2.dirname(opts.filePath), { recursive: true });
930
+ fs3.writeFileSync(opts.filePath, `${derived}
931
+ `, { flag: "wx" });
932
+ return derived;
933
+ } catch {
934
+ return readMachineIdFile(opts.filePath) ?? derived;
935
+ }
936
+ }
937
+ function readMachineIdFile(filePath) {
938
+ try {
939
+ const value = fs3.readFileSync(filePath, "utf8").trim().toLowerCase();
940
+ return ANON_ID_PATTERN.test(value) ? value : void 0;
941
+ } catch {
942
+ return void 0;
943
+ }
944
+ }
914
945
  function firstNonInternalMac() {
915
946
  try {
916
947
  const interfaces = os2.networkInterfaces();
@@ -1718,12 +1749,12 @@ var GoogleAdsClient = class {
1718
1749
  }
1719
1750
  };
1720
1751
  }
1721
- async #requestJson(operation, path11, init, includeLoginCustomerId) {
1752
+ async #requestJson(operation, path12, init, includeLoginCustomerId) {
1722
1753
  const maxRetries = this.#retry.maxRetries ?? GOOGLE_ADS_MAX_RETRIES;
1723
1754
  const baseDelayMs = this.#retry.baseDelayMs ?? GOOGLE_ADS_RETRY_BASE_DELAY_MS;
1724
1755
  const maxDelayMs = this.#retry.maxDelayMs ?? GOOGLE_ADS_RETRY_MAX_DELAY_MS;
1725
1756
  return withRetry(
1726
- () => this.#requestJsonOnce(operation, path11, init, includeLoginCustomerId),
1757
+ () => this.#requestJsonOnce(operation, path12, init, includeLoginCustomerId),
1727
1758
  {
1728
1759
  maxRetries,
1729
1760
  baseDelayMs,
@@ -1735,7 +1766,7 @@ var GoogleAdsClient = class {
1735
1766
  }
1736
1767
  );
1737
1768
  }
1738
- async #requestJsonOnce(operation, path11, init, includeLoginCustomerId) {
1769
+ async #requestJsonOnce(operation, path12, init, includeLoginCustomerId) {
1739
1770
  const headers = {
1740
1771
  Authorization: `Bearer ${this.#accessToken}`,
1741
1772
  "Content-Type": "application/json",
@@ -1744,7 +1775,7 @@ var GoogleAdsClient = class {
1744
1775
  if (includeLoginCustomerId && this.#loginCustomerId) {
1745
1776
  headers["login-customer-id"] = this.#loginCustomerId;
1746
1777
  }
1747
- const url = `${GOOGLE_ADS_API_BASE}${path11}`;
1778
+ const url = `${GOOGLE_ADS_API_BASE}${path12}`;
1748
1779
  let response;
1749
1780
  try {
1750
1781
  response = await this.#fetch(url, {
@@ -2137,24 +2168,24 @@ function assertAccessToken(accessToken) {
2137
2168
  throw new GtmApiError("OAuth access token is required", 400, { reason: "INVALID_ACCESS_TOKEN" });
2138
2169
  }
2139
2170
  }
2140
- function assertPath(path11, kind) {
2141
- if (!PATH_PATTERNS[kind].test(path11)) {
2171
+ function assertPath(path12, kind) {
2172
+ if (!PATH_PATTERNS[kind].test(path12)) {
2142
2173
  throw new GtmApiError(`Invalid Tag Manager ${kind} resource path`, 400, {
2143
2174
  reason: "INVALID_RESOURCE_PATH"
2144
2175
  });
2145
2176
  }
2146
2177
  }
2147
- function apiUrl(path11, pageToken) {
2148
- const url = new URL(`${GTM_API_BASE}/${path11}`);
2178
+ function apiUrl(path12, pageToken) {
2179
+ const url = new URL(`${GTM_API_BASE}/${path12}`);
2149
2180
  if (pageToken !== void 0) url.searchParams.set("pageToken", pageToken);
2150
2181
  return url.toString();
2151
2182
  }
2152
- async function listCollection(accessToken, path11, responseKey, options) {
2183
+ async function listCollection(accessToken, path12, responseKey, options) {
2153
2184
  const collected = [];
2154
2185
  const seenTokens = /* @__PURE__ */ new Set();
2155
2186
  let pageToken;
2156
2187
  for (let page = 0; page < GTM_MAX_PAGES; page++) {
2157
- const response = await gtmFetchGet(apiUrl(path11, pageToken), accessToken, options);
2188
+ const response = await gtmFetchGet(apiUrl(path12, pageToken), accessToken, options);
2158
2189
  const values = response[responseKey];
2159
2190
  if (values !== void 0 && !Array.isArray(values)) {
2160
2191
  throw new GtmApiError(`Tag Manager returned an invalid ${responseKey} list`, 502, {
@@ -2449,8 +2480,8 @@ function required(value, label) {
2449
2480
  }
2450
2481
  return value;
2451
2482
  }
2452
- function finalPathSegment(path11) {
2453
- return path11?.split("/").filter(Boolean).at(-1);
2483
+ function finalPathSegment(path12) {
2484
+ return path12?.split("/").filter(Boolean).at(-1);
2454
2485
  }
2455
2486
  function uniqueStrings(values) {
2456
2487
  return [...new Set(values.filter((value) => typeof value === "string"))].sort();
@@ -3708,8 +3739,8 @@ function createGoogleMarketingRuntime(options) {
3708
3739
  // src/server.ts
3709
3740
  import { createRequire as createRequire4 } from "module";
3710
3741
  import crypto29 from "crypto";
3711
- import fs11 from "fs";
3712
- import path10 from "path";
3742
+ import fs12 from "fs";
3743
+ import path11 from "path";
3713
3744
  import { isIP } from "net";
3714
3745
  import { fileURLToPath as fileURLToPath3 } from "url";
3715
3746
  import { setImmediate as yieldToEventLoop4 } from "timers/promises";
@@ -3928,8 +3959,8 @@ import { createHash as createHash3, randomUUID } from "crypto";
3928
3959
  import { and, asc, eq, gt } from "drizzle-orm";
3929
3960
 
3930
3961
  // src/outcome-telemetry.ts
3931
- import fs3 from "fs";
3932
- import path2 from "path";
3962
+ import fs4 from "fs";
3963
+ import path3 from "path";
3933
3964
 
3934
3965
  // src/usage-telemetry.ts
3935
3966
  var API_REQUEST_BUCKET_CAPACITY = 20;
@@ -4042,11 +4073,11 @@ var claimed = /* @__PURE__ */ new Set();
4042
4073
  function isFirstSuccess(key) {
4043
4074
  try {
4044
4075
  if (!isTelemetryEnabled() || claimed.has(key)) return false;
4045
- const dir = path2.join(getConfigDir(), MILESTONES_DIR);
4046
- fs3.mkdirSync(dir, { recursive: true });
4076
+ const dir = path3.join(getConfigDir(), MILESTONES_DIR);
4077
+ fs4.mkdirSync(dir, { recursive: true });
4047
4078
  const name = key.replace(/[^\w.-]/g, (c) => `~${c.charCodeAt(0).toString(16)}`);
4048
4079
  claimed.add(key);
4049
- fs3.closeSync(fs3.openSync(path2.join(dir, name), "wx"));
4080
+ fs4.closeSync(fs4.openSync(path3.join(dir, name), "wx"));
4050
4081
  return true;
4051
4082
  } catch {
4052
4083
  return false;
@@ -4390,11 +4421,11 @@ function createSentimentPoller(tick, onError, schedule = setImmediate) {
4390
4421
  }
4391
4422
 
4392
4423
  // src/sentiment-config.ts
4393
- import fs4 from "fs";
4424
+ import fs5 from "fs";
4394
4425
  import { parse } from "yaml";
4395
4426
  function loadSentimentInstallConfig() {
4396
4427
  try {
4397
- const document = parse(fs4.readFileSync(getConfigPath(), "utf8"));
4428
+ const document = parse(fs5.readFileSync(getConfigPath(), "utf8"));
4398
4429
  const sentiment = isRecord(document) ? document.sentiment : void 0;
4399
4430
  if (!isRecord(document) || sentiment != null && !isRecord(sentiment)) return invalidSentimentInstallConfig();
4400
4431
  return resolveSentimentInstallConfig(process.env, sentiment ?? void 0);
@@ -6439,7 +6470,7 @@ var localAdapter = {
6439
6470
  };
6440
6471
 
6441
6472
  // ../provider-cdp/src/adapter.ts
6442
- import path4 from "path";
6473
+ import path5 from "path";
6443
6474
  import os3 from "os";
6444
6475
 
6445
6476
  // ../provider-cdp/src/connection.ts
@@ -6810,12 +6841,12 @@ function sleep2(ms) {
6810
6841
  }
6811
6842
 
6812
6843
  // ../provider-cdp/src/screenshot.ts
6813
- import fs5 from "fs";
6814
- import path3 from "path";
6844
+ import fs6 from "fs";
6845
+ import path4 from "path";
6815
6846
  async function captureElementScreenshot(client, selector, outputPath) {
6816
- const dir = path3.dirname(outputPath);
6817
- if (!fs5.existsSync(dir)) {
6818
- fs5.mkdirSync(dir, { recursive: true });
6847
+ const dir = path4.dirname(outputPath);
6848
+ if (!fs6.existsSync(dir)) {
6849
+ fs6.mkdirSync(dir, { recursive: true });
6819
6850
  }
6820
6851
  let clip;
6821
6852
  try {
@@ -6849,7 +6880,7 @@ async function captureElementScreenshot(client, selector, outputPath) {
6849
6880
  }
6850
6881
  const { data } = await client.Page.captureScreenshot(screenshotParams);
6851
6882
  const buffer = Buffer.from(data, "base64");
6852
- fs5.writeFileSync(outputPath, buffer);
6883
+ fs6.writeFileSync(outputPath, buffer);
6853
6884
  return outputPath;
6854
6885
  }
6855
6886
 
@@ -6905,7 +6936,7 @@ function getConnection(config) {
6905
6936
  return conn;
6906
6937
  }
6907
6938
  function getScreenshotDir() {
6908
- return path4.join(os3.homedir(), ".canonry", "screenshots");
6939
+ return path5.join(os3.homedir(), ".canonry", "screenshots");
6909
6940
  }
6910
6941
  var cdpChatgptAdapter = {
6911
6942
  name: "cdp:chatgpt",
@@ -6972,7 +7003,7 @@ var cdpChatgptAdapter = {
6972
7003
  const answerText = await target.extractAnswer(client);
6973
7004
  const groundingSources = await target.extractCitations(client);
6974
7005
  const screenshotId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
6975
- const screenshotPath = path4.join(getScreenshotDir(), `${screenshotId}.png`);
7006
+ const screenshotPath = path5.join(getScreenshotDir(), `${screenshotId}.png`);
6976
7007
  let capturedScreenshotPath;
6977
7008
  try {
6978
7009
  capturedScreenshotPath = await captureElementScreenshot(
@@ -8625,7 +8656,7 @@ function nonBlank(value) {
8625
8656
  return trimmed ? trimmed : void 0;
8626
8657
  }
8627
8658
  function resolveBuildCommit(env = process.env) {
8628
- const embedded = true ? "3670fc2cb7d325827885188a8c94669d11a5f758" : void 0;
8659
+ const embedded = true ? "153d084b0895cf3d9cdb74a0ef9197a29ce0fe02" : void 0;
8629
8660
  return nonBlank(embedded) ?? nonBlank(env.CANONRY_COMMIT);
8630
8661
  }
8631
8662
  function resolveInstanceIdentity(env = process.env) {
@@ -8637,8 +8668,8 @@ function resolveInstanceIdentity(env = process.env) {
8637
8668
 
8638
8669
  // src/job-runner.ts
8639
8670
  import crypto7 from "crypto";
8640
- import fs6 from "fs";
8641
- import path5 from "path";
8671
+ import fs7 from "fs";
8672
+ import path6 from "path";
8642
8673
  import os4 from "os";
8643
8674
  import { setImmediate as yieldToEventLoop } from "timers/promises";
8644
8675
  import { and as and3, asc as asc2, count, desc, eq as eq3, inArray, isNotNull, isNull, lt, ne, sql as sql2 } from "drizzle-orm";
@@ -9542,12 +9573,12 @@ var JobRunner = class {
9542
9573
  );
9543
9574
  const answerLocation = runLocation && isSearchLocationIgnored(providerName, normalized.retrievalStatus) ? { location: null, requestedContext: runLocation, supportedContext: { status: "ignored" } } : { location: runLocation?.label ?? null };
9544
9575
  let screenshotRelPath = null;
9545
- if (raw.screenshotPath && fs6.existsSync(raw.screenshotPath)) {
9576
+ if (raw.screenshotPath && fs7.existsSync(raw.screenshotPath)) {
9546
9577
  const snapshotId = crypto7.randomUUID();
9547
- const screenshotDir = path5.join(os4.homedir(), ".canonry", "screenshots", runId);
9548
- if (!fs6.existsSync(screenshotDir)) fs6.mkdirSync(screenshotDir, { recursive: true });
9549
- const destPath = path5.join(screenshotDir, `${snapshotId}.png`);
9550
- fs6.renameSync(raw.screenshotPath, destPath);
9578
+ const screenshotDir = path6.join(os4.homedir(), ".canonry", "screenshots", runId);
9579
+ if (!fs7.existsSync(screenshotDir)) fs7.mkdirSync(screenshotDir, { recursive: true });
9580
+ const destPath = path6.join(screenshotDir, `${snapshotId}.png`);
9581
+ fs7.renameSync(raw.screenshotPath, destPath);
9551
9582
  screenshotRelPath = `${runId}/${snapshotId}.png`;
9552
9583
  this.db.insert(querySnapshots).values({
9553
9584
  id: snapshotId,
@@ -10896,11 +10927,11 @@ var JobRunner = class {
10896
10927
  const answerContext = supportedContext && isSearchLocationIgnored(providerName, normalized.retrievalStatus) ? { status: "ignored" } : supportedContext;
10897
10928
  const snapshotId = crypto7.randomUUID();
10898
10929
  let screenshotRelPath = null;
10899
- if (raw.screenshotPath && fs6.existsSync(raw.screenshotPath)) {
10900
- const screenshotDir = path5.join(os4.homedir(), ".canonry", "screenshots", ctx.runId);
10901
- if (!fs6.existsSync(screenshotDir)) fs6.mkdirSync(screenshotDir, { recursive: true });
10902
- const destPath = path5.join(screenshotDir, `${snapshotId}.png`);
10903
- fs6.renameSync(raw.screenshotPath, destPath);
10930
+ if (raw.screenshotPath && fs7.existsSync(raw.screenshotPath)) {
10931
+ const screenshotDir = path6.join(os4.homedir(), ".canonry", "screenshots", ctx.runId);
10932
+ if (!fs7.existsSync(screenshotDir)) fs7.mkdirSync(screenshotDir, { recursive: true });
10933
+ const destPath = path6.join(screenshotDir, `${snapshotId}.png`);
10934
+ fs7.renameSync(raw.screenshotPath, destPath);
10904
10935
  screenshotRelPath = `${ctx.runId}/${snapshotId}.png`;
10905
10936
  }
10906
10937
  const snapshot = {
@@ -12388,12 +12419,12 @@ function adsClientLog(level, action, ctx) {
12388
12419
  const stream = level === "error" ? process.stderr : process.stdout;
12389
12420
  stream.write(JSON.stringify(entry) + "\n");
12390
12421
  }
12391
- function buildUrl(path11, queryPairs) {
12422
+ function buildUrl(path12, queryPairs) {
12392
12423
  const qs = queryPairs.join("&");
12393
- return qs ? `${OPENAI_ADS_API_BASE}/${path11}?${qs}` : `${OPENAI_ADS_API_BASE}/${path11}`;
12424
+ return qs ? `${OPENAI_ADS_API_BASE}/${path12}?${qs}` : `${OPENAI_ADS_API_BASE}/${path12}`;
12394
12425
  }
12395
- async function adsFetch(apiKey, path11, queryPairs = [], method = "GET", body) {
12396
- const url = buildUrl(path11, queryPairs);
12426
+ async function adsFetch(apiKey, path12, queryPairs = [], method = "GET", body) {
12427
+ const url = buildUrl(path12, queryPairs);
12397
12428
  let res;
12398
12429
  try {
12399
12430
  res = await fetch(url, {
@@ -12410,18 +12441,18 @@ async function adsFetch(apiKey, path11, queryPairs = [], method = "GET", body) {
12410
12441
  }
12411
12442
  if (res.status === 401 || res.status === 403) {
12412
12443
  const { code } = parseErrorEnvelope(await res.text());
12413
- adsClientLog("error", "http.auth-failed", { path: path11, httpStatus: res.status, code });
12444
+ adsClientLog("error", "http.auth-failed", { path: path12, httpStatus: res.status, code });
12414
12445
  throw new OpenAiAdsApiError("OpenAI Ads API key is invalid or unauthorized", res.status, code);
12415
12446
  }
12416
12447
  if (res.status === 429) {
12417
12448
  const { code } = parseErrorEnvelope(await res.text());
12418
- adsClientLog("error", "http.rate-limited", { path: path11, httpStatus: 429, code });
12449
+ adsClientLog("error", "http.rate-limited", { path: path12, httpStatus: 429, code });
12419
12450
  throw new OpenAiAdsApiError("OpenAI Ads API rate limit exceeded", 429, code);
12420
12451
  }
12421
12452
  if (!res.ok) {
12422
12453
  const body2 = await res.text();
12423
12454
  const { message, code } = parseErrorEnvelope(body2);
12424
- adsClientLog("error", "http.error", { path: path11, httpStatus: res.status, code });
12455
+ adsClientLog("error", "http.error", { path: path12, httpStatus: res.status, code });
12425
12456
  const detail = message ?? (body2.length <= 500 ? body2 : `${body2.slice(0, 500)}... [truncated]`);
12426
12457
  throw new OpenAiAdsApiError(`OpenAI Ads API error (${res.status}): ${detail}`, res.status, code);
12427
12458
  }
@@ -12432,12 +12463,12 @@ async function adsFetch(apiKey, path11, queryPairs = [], method = "GET", body) {
12432
12463
  throw new OpenAiAdsApiError("OpenAI Ads API returned invalid JSON", 502);
12433
12464
  }
12434
12465
  }
12435
- async function fetchAllPages(apiKey, path11, queryPairs, maxPages = OPENAI_ADS_MAX_PAGES) {
12466
+ async function fetchAllPages(apiKey, path12, queryPairs, maxPages = OPENAI_ADS_MAX_PAGES) {
12436
12467
  const items = [];
12437
12468
  let after = null;
12438
12469
  for (let page = 0; page < maxPages; page++) {
12439
12470
  const pairs = after ? [...queryPairs, `after=${encodeURIComponent(after)}`] : [...queryPairs];
12440
- const response = await adsFetch(apiKey, path11, pairs);
12471
+ const response = await adsFetch(apiKey, path12, pairs);
12441
12472
  items.push(...response.data);
12442
12473
  if (!response.has_more || !response.last_id) {
12443
12474
  return items;
@@ -12445,7 +12476,7 @@ async function fetchAllPages(apiKey, path11, queryPairs, maxPages = OPENAI_ADS_M
12445
12476
  after = response.last_id;
12446
12477
  }
12447
12478
  if (maxPages < OPENAI_ADS_MAX_PAGES) return items;
12448
- adsClientLog("error", "pagination.cap-reached", { path: path11, pages: OPENAI_ADS_MAX_PAGES, items: items.length });
12479
+ adsClientLog("error", "pagination.cap-reached", { path: path12, pages: OPENAI_ADS_MAX_PAGES, items: items.length });
12449
12480
  throw new OpenAiAdsApiError(
12450
12481
  `OpenAI Ads API collection remained incomplete after the ${OPENAI_ADS_MAX_PAGES}-page safety cap`,
12451
12482
  502,
@@ -13643,7 +13674,7 @@ async function maybeRefreshGscCoverage(db, config, projectId, deps = defaultDeps
13643
13674
 
13644
13675
  // src/commoncrawl-sync.ts
13645
13676
  import crypto17 from "crypto";
13646
- import path6 from "path";
13677
+ import path7 from "path";
13647
13678
  import { and as and10, eq as eq13, sql as sql5 } from "drizzle-orm";
13648
13679
  var log11 = createLogger("CommonCrawlSync");
13649
13680
  var INSERT_CHUNK_SIZE = 1e4;
@@ -13671,6 +13702,7 @@ async function executeReleaseSync(db, syncId, opts) {
13671
13702
  invalidRelease = true;
13672
13703
  throw new Error(`Invalid release id: ${release}`);
13673
13704
  }
13705
+ if (db.select({ id: projects.id }).from(projects).limit(1).get()) deps.loadDuckdb();
13674
13706
  const downloadStartedAt = deps.now().toISOString();
13675
13707
  db.update(ccReleaseSyncs).set({
13676
13708
  status: CcReleaseSyncStatuses.downloading,
@@ -13680,9 +13712,9 @@ async function executeReleaseSync(db, syncId, opts) {
13680
13712
  error: null
13681
13713
  }).where(eq13(ccReleaseSyncs.id, syncId)).run();
13682
13714
  const paths = ccReleasePaths(release);
13683
- const releaseCacheDir = path6.join(deps.cacheDir, release);
13684
- const vertexPath = path6.join(releaseCacheDir, paths.vertexFilename);
13685
- const edgesPath = path6.join(releaseCacheDir, paths.edgesFilename);
13715
+ const releaseCacheDir = path7.join(deps.cacheDir, release);
13716
+ const vertexPath = path7.join(releaseCacheDir, paths.vertexFilename);
13717
+ const edgesPath = path7.join(releaseCacheDir, paths.edgesFilename);
13686
13718
  const [vertex, edges] = await Promise.all([
13687
13719
  deps.downloadFile({ url: paths.vertexUrl, destPath: vertexPath }),
13688
13720
  deps.downloadFile({ url: paths.edgesUrl, destPath: edgesPath })
@@ -13820,11 +13852,14 @@ async function executeReleaseSync(db, syncId, opts) {
13820
13852
  ...outcome,
13821
13853
  status: OutcomeStatuses.failed,
13822
13854
  durationBucket: elapsed(),
13823
- ...outcomeFailure(err, invalidRelease ? OutcomeReasonCodes.VALIDATION : void 0)
13855
+ ...outcomeFailure(err, invalidRelease ? OutcomeReasonCodes.VALIDATION : isMissingDependency(err) ? OutcomeReasonCodes.NOT_CONNECTED : void 0)
13824
13856
  });
13825
13857
  throw err;
13826
13858
  }
13827
13859
  }
13860
+ function isMissingDependency(err) {
13861
+ return typeof err === "object" && err !== null && "code" in err && err.code === "MISSING_DEPENDENCY";
13862
+ }
13828
13863
  async function syncLatestReleaseOnSchedule(projectName, deps) {
13829
13864
  const elapsed = startOutcomeTimer();
13830
13865
  const report = (outcome) => trackFeatureCompleted({
@@ -13855,8 +13890,7 @@ async function syncLatestReleaseOnSchedule(projectName, deps) {
13855
13890
  await deps.requestSync(probed.release);
13856
13891
  } catch (err) {
13857
13892
  deps.log.error({ projectName, release: probed.release, err: describeError(err) }, "Scheduled backlinks sync failed");
13858
- const missingPlugin = typeof err === "object" && err !== null && "code" in err && err.code === "MISSING_DEPENDENCY";
13859
- report({ status: OutcomeStatuses.failed, ...outcomeFailure(err, missingPlugin ? OutcomeReasonCodes.NOT_CONNECTED : void 0) });
13893
+ report({ status: OutcomeStatuses.failed, ...outcomeFailure(err, isMissingDependency(err) ? OutcomeReasonCodes.NOT_CONNECTED : void 0) });
13860
13894
  } finally {
13861
13895
  deps.scheduledReleases.delete(probed.release);
13862
13896
  }
@@ -13877,7 +13911,7 @@ function groupByProject(rows, projectsByDomain) {
13877
13911
 
13878
13912
  // src/backlink-extract.ts
13879
13913
  import crypto18 from "crypto";
13880
- import fs7 from "fs";
13914
+ import fs8 from "fs";
13881
13915
  import { and as and11, desc as desc7, eq as eq14 } from "drizzle-orm";
13882
13916
  var log12 = createLogger("BacklinkExtract");
13883
13917
  function defaultDeps3() {
@@ -13910,7 +13944,7 @@ async function executeBacklinkExtract(db, runId, projectId, opts = {}) {
13910
13944
  if (!sync.vertexPath || !sync.edgesPath) {
13911
13945
  throw new Error(`Release ${sync.release} is missing cached file paths`);
13912
13946
  }
13913
- if (!fs7.existsSync(sync.vertexPath) || !fs7.existsSync(sync.edgesPath)) {
13947
+ if (!fs8.existsSync(sync.vertexPath) || !fs8.existsSync(sync.edgesPath)) {
13914
13948
  throw new Error(
13915
13949
  `Cache for release ${sync.release} is missing from disk (expected at ${sync.vertexPath}). The sync record exists in the database, but the ~16 GB dump was deleted or never present on this machine. Re-sync this release from the Backlinks admin page to restore the cache.`
13916
13950
  );
@@ -14777,9 +14811,9 @@ function pagePath(page) {
14777
14811
  }
14778
14812
  }
14779
14813
  function parentPath(page) {
14780
- const path11 = pagePath(page);
14781
- if (path11 === "/") return "/";
14782
- const trimmed = path11.endsWith("/") ? path11.slice(0, -1) : path11;
14814
+ const path12 = pagePath(page);
14815
+ if (path12 === "/") return "/";
14816
+ const trimmed = path12.endsWith("/") ? path12.slice(0, -1) : path12;
14783
14817
  const slash = trimmed.lastIndexOf("/");
14784
14818
  return slash <= 0 ? "/" : trimmed.slice(0, slash) || "/";
14785
14819
  }
@@ -15683,31 +15717,31 @@ function recordLlmUsageEvent(args) {
15683
15717
  }
15684
15718
 
15685
15719
  // src/agent/session.ts
15686
- import fs10 from "fs";
15687
- import path9 from "path";
15720
+ import fs11 from "fs";
15721
+ import path10 from "path";
15688
15722
  import { Agent } from "@earendil-works/pi-agent-core";
15689
15723
 
15690
15724
  // src/agent/skill-paths.ts
15691
- import fs8 from "fs";
15692
- import path7 from "path";
15725
+ import fs9 from "fs";
15726
+ import path8 from "path";
15693
15727
  import { fileURLToPath as fileURLToPath2 } from "url";
15694
15728
  function resolveAeroSkillDir(pkgDir) {
15695
- const here = pkgDir ?? path7.dirname(fileURLToPath2(import.meta.url));
15729
+ const here = pkgDir ?? path8.dirname(fileURLToPath2(import.meta.url));
15696
15730
  const candidates = [
15697
- path7.join(here, "../assets/agent-workspace/skills/aero"),
15698
- path7.join(here, "../../assets/agent-workspace/skills/aero"),
15699
- path7.join(here, "../../../../skills/aero")
15731
+ path8.join(here, "../assets/agent-workspace/skills/aero"),
15732
+ path8.join(here, "../../assets/agent-workspace/skills/aero"),
15733
+ path8.join(here, "../../../../skills/aero")
15700
15734
  ];
15701
15735
  for (const candidate of candidates) {
15702
- if (fs8.existsSync(path7.join(candidate, "SKILL.md"))) return candidate;
15736
+ if (fs9.existsSync(path8.join(candidate, "SKILL.md"))) return candidate;
15703
15737
  }
15704
15738
  throw new Error(`Aero skill not found. Searched:
15705
15739
  ${candidates.join("\n ")}`);
15706
15740
  }
15707
15741
 
15708
15742
  // src/agent/skill-tools.ts
15709
- import fs9 from "fs";
15710
- import path8 from "path";
15743
+ import fs10 from "fs";
15744
+ import path9 from "path";
15711
15745
  import { Type } from "@earendil-works/pi-ai";
15712
15746
  var MAX_DOC_CHARS = 2e4;
15713
15747
  function textResult(details) {
@@ -15728,13 +15762,13 @@ function parseDescription(body) {
15728
15762
  return "(no description)";
15729
15763
  }
15730
15764
  function scanSkillDocs(skillDir) {
15731
- const refsDir = path8.join(skillDir ?? resolveAeroSkillDir(), "references");
15732
- if (!fs9.existsSync(refsDir)) return [];
15765
+ const refsDir = path9.join(skillDir ?? resolveAeroSkillDir(), "references");
15766
+ if (!fs10.existsSync(refsDir)) return [];
15733
15767
  const entries = [];
15734
- for (const file of fs9.readdirSync(refsDir)) {
15768
+ for (const file of fs10.readdirSync(refsDir)) {
15735
15769
  if (!file.endsWith(".md")) continue;
15736
- const filePath = path8.join(refsDir, file);
15737
- const body = fs9.readFileSync(filePath, "utf-8");
15770
+ const filePath = path9.join(refsDir, file);
15771
+ const body = fs10.readFileSync(filePath, "utf-8");
15738
15772
  entries.push({
15739
15773
  slug: file.replace(/\.md$/, ""),
15740
15774
  description: parseDescription(body),
@@ -15777,8 +15811,8 @@ function buildReadSkillDocTool() {
15777
15811
  availableSlugs: docs.map((d) => d.slug)
15778
15812
  });
15779
15813
  }
15780
- const filePath = path8.join(skillDir, "references", `${match.slug}.md`);
15781
- const content = fs9.readFileSync(filePath, "utf-8");
15814
+ const filePath = path9.join(skillDir, "references", `${match.slug}.md`);
15815
+ const content = fs10.readFileSync(filePath, "utf-8");
15782
15816
  if (content.length > MAX_DOC_CHARS) {
15783
15817
  return textResult({
15784
15818
  slug: match.slug,
@@ -15923,10 +15957,10 @@ function isRecord8(value) {
15923
15957
  }
15924
15958
  function keptSummary(counts, cursors = {}) {
15925
15959
  const summary = { droppedKeys: [], keptItems: {} };
15926
- for (const [path11, { kept, total }] of counts) {
15960
+ for (const [path12, { kept, total }] of counts) {
15927
15961
  if (kept >= total) continue;
15928
- if (kept === 0) summary.droppedKeys.push(path11);
15929
- summary.keptItems[path11] = `${kept} of ${total}`;
15962
+ if (kept === 0) summary.droppedKeys.push(path12);
15963
+ summary.keptItems[path12] = `${kept} of ${total}`;
15930
15964
  }
15931
15965
  if (Object.keys(cursors).length > 0) summary.cursors = cursors;
15932
15966
  return summary;
@@ -15989,7 +16023,7 @@ function bareTotal(numbers) {
15989
16023
  }
15990
16024
  function partialLists(root) {
15991
16025
  const notes = [];
15992
- const visit = (object, path11, depth) => {
16026
+ const visit = (object, path12, depth) => {
15993
16027
  const lists = [];
15994
16028
  const numbers = [];
15995
16029
  for (const [key, value] of Object.entries(object)) {
@@ -15999,16 +16033,16 @@ function partialLists(root) {
15999
16033
  }
16000
16034
  let noted = false;
16001
16035
  if (lists.length <= MAX_SUMMARY_KEYS) {
16002
- const counts = lists.map(([key]) => ownListTotal(numbers, key) ?? cursorForList(object, path11, key, root)?.total);
16036
+ const counts = lists.map(([key]) => ownListTotal(numbers, key) ?? cursorForList(object, path12, key, root)?.total);
16003
16037
  const uncounted = counts.flatMap((count4, index) => count4 ? [] : [index]);
16004
16038
  if (uncounted.length === 1) {
16005
16039
  const index = uncounted[0];
16006
16040
  const key = lists[index][0];
16007
- const paged = object === root || cursorForList(object, path11, key, root) || typeof object.truncated === "boolean" || typeof object[`${key}Truncated`] === "boolean" || ["items", "rows", "results"].includes(key);
16041
+ const paged = object === root || cursorForList(object, path12, key, root) || typeof object.truncated === "boolean" || typeof object[`${key}Truncated`] === "boolean" || ["items", "rows", "results"].includes(key);
16008
16042
  if (paged) counts[index] = bareTotal(numbers);
16009
16043
  }
16010
16044
  for (const [index, [key, rows]] of lists.entries()) {
16011
- const label = path11 ? `${path11}.${key}` : key;
16045
+ const label = path12 ? `${path12}.${key}` : key;
16012
16046
  const count4 = counts[index];
16013
16047
  const ownFlag = object[`${key}Truncated`];
16014
16048
  if (count4) {
@@ -16021,10 +16055,10 @@ function partialLists(root) {
16021
16055
  }
16022
16056
  }
16023
16057
  }
16024
- if (object.truncated === true && !noted) notes.push([path11 || "(root)", "the tool cut the lists here"]);
16058
+ if (object.truncated === true && !noted) notes.push([path12 || "(root)", "the tool cut the lists here"]);
16025
16059
  if (depth >= MAX_PARTIAL_DEPTH || notes.length >= MAX_PARTIAL_NOTES) return;
16026
16060
  for (const [key, value] of Object.entries(object)) {
16027
- if (!key.startsWith("__") && isRecord8(value)) visit(value, path11 ? `${path11}.${key}` : key, depth + 1);
16061
+ if (!key.startsWith("__") && isRecord8(value)) visit(value, path12 ? `${path12}.${key}` : key, depth + 1);
16028
16062
  }
16029
16063
  };
16030
16064
  visit(root, "", 1);
@@ -16036,19 +16070,19 @@ function withPartialLists(value) {
16036
16070
  const notes = partialLists(value);
16037
16071
  if (!notes && !hadNote && value.nextAttemptCursor == null && !CURSOR_KEYS.some((key) => value[key] !== void 0 && value[key] !== null) && !Object.values(value).some((child) => isRecord8(child) && CURSOR_KEYS.some((key) => child[key] !== void 0 && child[key] !== null))) return value;
16038
16072
  const pagination = {};
16039
- const visit = (owner, path11, depth) => {
16073
+ const visit = (owner, path12, depth) => {
16040
16074
  const lists = Object.entries(owner).filter((entry) => Array.isArray(entry[1]));
16041
16075
  const numbers = Object.entries(owner).filter((entry) => typeof entry[1] === "number");
16042
16076
  for (const [key, rows] of lists) {
16043
- const cursor = cursorForList(owner, path11, key, value);
16077
+ const cursor = cursorForList(owner, path12, key, value);
16044
16078
  if (!cursor || key.startsWith("__") || Object.keys(pagination).length >= MAX_PARTIAL_NOTES) continue;
16045
- const label = path11 ? `${path11}.${key}` : key;
16079
+ const label = path12 ? `${path12}.${key}` : key;
16046
16080
  const total = cursor.total ?? ownListTotal(numbers, key) ?? (lists.length === 1 ? bareTotal(numbers) : void 0);
16047
16081
  const incomplete = owner.__truncated === true || isRecord8(owner.__omittedRowsByField) && typeof owner.__omittedRowsByField[key] === "number";
16048
16082
  pagination[label] = `showing ${rows.length}${total ? ` of ${total.text}` : " rows"}; ${incomplete ? `incomplete page: re-request the original cursor with a smaller ${cursor.limit}; the next cursor skips omitted rows` : `pass ${cursor.parameter} ${JSON.stringify(cursor.value)}`}`;
16049
16083
  }
16050
16084
  if (depth >= MAX_PARTIAL_DEPTH) return;
16051
- for (const [key, child] of Object.entries(owner)) if (!key.startsWith("__") && isRecord8(child)) visit(child, path11 ? `${path11}.${key}` : key, depth + 1);
16085
+ for (const [key, child] of Object.entries(owner)) if (!key.startsWith("__") && isRecord8(child)) visit(child, path12 ? `${path12}.${key}` : key, depth + 1);
16052
16086
  };
16053
16087
  visit(value, "", 1);
16054
16088
  const { [PARTIAL_LISTS_KEY]: _previous, __pagination: _pagination, ...rest } = value;
@@ -16130,10 +16164,10 @@ function listTrimmer(lists) {
16130
16164
  }
16131
16165
  function collectCollections(root) {
16132
16166
  const found = [];
16133
- const visit = (object, path11, nested) => {
16167
+ const visit = (object, path12, nested) => {
16134
16168
  for (const [key, value] of Object.entries(object)) {
16135
16169
  if (object === root && (key === TRUNCATION_SUMMARY_KEY || key === PARTIAL_LISTS_KEY)) continue;
16136
- const valuePath = path11 ? `${path11}.${key}` : key;
16170
+ const valuePath = path12 ? `${path12}.${key}` : key;
16137
16171
  if (Array.isArray(value)) {
16138
16172
  let records = false;
16139
16173
  for (const row of value) {
@@ -16165,11 +16199,11 @@ var TRIM_STAGES = [
16165
16199
  function currentSummary(root, owned) {
16166
16200
  const counts = /* @__PURE__ */ new Map();
16167
16201
  const cursors = {};
16168
- const visit = (object, path11) => {
16202
+ const visit = (object, path12) => {
16169
16203
  const lists = owned.get(object);
16170
16204
  for (const [key, value] of Object.entries(object)) {
16171
16205
  if (object === root && (key === TRUNCATION_SUMMARY_KEY || key === PARTIAL_LISTS_KEY)) continue;
16172
- const valuePath = path11 ? `${path11}.${key}` : key;
16206
+ const valuePath = path12 ? `${path12}.${key}` : key;
16173
16207
  if (Array.isArray(value)) {
16174
16208
  const list = lists?.get(key);
16175
16209
  if (list) {
@@ -16177,7 +16211,7 @@ function currentSummary(root, owned) {
16177
16211
  count4.kept += value.length;
16178
16212
  count4.total += list.rows.length;
16179
16213
  counts.set(list.path, count4);
16180
- noteCursor(object, path11, list.path, value.length, list.rows.length, cursors, root);
16214
+ noteCursor(object, path12, list.path, value.length, list.rows.length, cursors, root);
16181
16215
  }
16182
16216
  for (const row of value) if (isRecord8(row)) visit(row, `${valuePath}[]`);
16183
16217
  } else if (isRecord8(value)) {
@@ -16280,10 +16314,10 @@ function hasOtherLists(value, primary) {
16280
16314
  }
16281
16315
  return isRecord8(value) && Object.values(value).some((child) => hasOtherLists(child, primary));
16282
16316
  }
16283
- function projectionPath(path11) {
16284
- if (path11.length <= MAX_SUMMARY_PATH_CHARS) return path11;
16285
- const digest = createHash5("sha256").update(path11).digest("hex").slice(0, 12);
16286
- return `${truncateUtf16(path11, 48)}...#${digest}${path11.slice(-24)}`;
16317
+ function projectionPath(path12) {
16318
+ if (path12.length <= MAX_SUMMARY_PATH_CHARS) return path12;
16319
+ const digest = createHash5("sha256").update(path12).digest("hex").slice(0, 12);
16320
+ return `${truncateUtf16(path12, 48)}...#${digest}${path12.slice(-24)}`;
16287
16321
  }
16288
16322
  function boundedProjection(full, partialRows, reserve = 0) {
16289
16323
  const value = JSON.parse(full);
@@ -16295,12 +16329,12 @@ function boundedProjection(full, partialRows, reserve = 0) {
16295
16329
  const skippedMetadata = () => {
16296
16330
  summary.moreMetadataEntries = (summary.moreMetadataEntries ?? 0) + 1;
16297
16331
  };
16298
- const record2 = (entries, path11, value2) => {
16332
+ const record2 = (entries, path12, value2) => {
16299
16333
  if (Object.keys(entries).length >= MAX_SUMMARY_KEYS) {
16300
16334
  skippedMetadata();
16301
16335
  return false;
16302
16336
  }
16303
- const key = projectionPath(path11);
16337
+ const key = projectionPath(path12);
16304
16338
  entries[key] = value2;
16305
16339
  if (serializeResult(summary).length <= PROJECTION_METADATA_CHARS) return true;
16306
16340
  delete entries[key];
@@ -16308,16 +16342,16 @@ function boundedProjection(full, partialRows, reserve = 0) {
16308
16342
  return false;
16309
16343
  };
16310
16344
  let dropped = 0;
16311
- const omit = (path11) => {
16345
+ const omit = (path12) => {
16312
16346
  dropped++;
16313
16347
  if (summary.droppedKeys.length < MAX_SUMMARY_KEYS) {
16314
- summary.droppedKeys.push(projectionPath(path11));
16348
+ summary.droppedKeys.push(projectionPath(path12));
16315
16349
  if (serializeResult(summary).length > PROJECTION_METADATA_CHARS) summary.droppedKeys.pop();
16316
16350
  }
16317
16351
  if (dropped > summary.droppedKeys.length) summary.moreDroppedKeys = dropped - summary.droppedKeys.length;
16318
16352
  };
16319
16353
  const cutOwners = /* @__PURE__ */ new Set();
16320
- const project = (input, budget, path11, owner, ownerPath = "") => {
16354
+ const project = (input, budget, path12, owner, ownerPath = "") => {
16321
16355
  if (Array.isArray(input)) {
16322
16356
  const rows = [];
16323
16357
  let used2 = 2;
@@ -16331,9 +16365,9 @@ function boundedProjection(full, partialRows, reserve = 0) {
16331
16365
  }
16332
16366
  if (partialRows && (rows.length === 0 || text.length > MAX_TOOL_RESULT_CHARS)) {
16333
16367
  const before = { summary: serializeResult(summary), dropped };
16334
- const partial = project(row, budget - used2 - (rows.length > 0 ? 1 : 0), `${path11 || "items"}[${rows.length}]`);
16368
+ const partial = project(row, budget - used2 - (rows.length > 0 ? 1 : 0), `${path12 || "items"}[${rows.length}]`);
16335
16369
  if (partial !== void 0 && partial !== "{}" && partial !== "[]") {
16336
- partialRows.set(path11 || "items", rows.length);
16370
+ partialRows.set(path12 || "items", rows.length);
16337
16371
  rows.push(partial);
16338
16372
  } else {
16339
16373
  summary = JSON.parse(before.summary);
@@ -16344,13 +16378,13 @@ function boundedProjection(full, partialRows, reserve = 0) {
16344
16378
  }
16345
16379
  if (rows.length < input.length) {
16346
16380
  if (partialRows && owner) cutOwners.add(owner);
16347
- record2(summary.keptItems, path11 || "items", `${rows.length} of ${input.length}`);
16348
- if (rows.length === 0) omit(path11 || "items");
16381
+ record2(summary.keptItems, path12 || "items", `${rows.length} of ${input.length}`);
16382
+ if (rows.length === 0) omit(path12 || "items");
16349
16383
  if (owner) {
16350
16384
  const cursors = {};
16351
- noteCursor(owner, ownerPath, path11, rows.length, input.length, cursors, isRecord8(value) ? value : owner);
16385
+ noteCursor(owner, ownerPath, path12, rows.length, input.length, cursors, isRecord8(value) ? value : owner);
16352
16386
  for (const [cursor, note] of Object.entries(cursors)) {
16353
- record2(summary.cursors ??= {}, cursor, note.replace(path11, projectionPath(path11)));
16387
+ record2(summary.cursors ??= {}, cursor, note.replace(path12, projectionPath(path12)));
16354
16388
  }
16355
16389
  }
16356
16390
  }
@@ -16362,9 +16396,9 @@ function boundedProjection(full, partialRows, reserve = 0) {
16362
16396
  if (typeof input === "string" && budget > 2) {
16363
16397
  const kept = largestFitting(Math.min(input.length, budget - 2), (length) => serializeResult(truncateUtf16(input, length)).length <= budget);
16364
16398
  const prefix = truncateUtf16(input, kept);
16365
- if (prefix.length > 0 && record2(summary.slicedKeys ??= {}, path11 || "(root)", { keptChars: prefix.length, totalChars: input.length })) return serializeResult(prefix);
16399
+ if (prefix.length > 0 && record2(summary.slicedKeys ??= {}, path12 || "(root)", { keptChars: prefix.length, totalChars: input.length })) return serializeResult(prefix);
16366
16400
  }
16367
- omit(path11 || "(root)");
16401
+ omit(path12 || "(root)");
16368
16402
  return void 0;
16369
16403
  }
16370
16404
  const priority = ([key, child]) => key === "queryPage" && isRecord8(child) ? 0 : typeof child === "string" && child.length > budget ? 2 : typeof child !== "object" || child === null ? 0 : partialRows && serializeResult(child).length > budget ? 2 : 1;
@@ -16372,19 +16406,19 @@ function boundedProjection(full, partialRows, reserve = 0) {
16372
16406
  const shown2 = [];
16373
16407
  let used = 2;
16374
16408
  for (const [key, child] of fields) {
16375
- const childPath = path11 ? `${path11}.${key}` : key;
16409
+ const childPath = path12 ? `${path12}.${key}` : key;
16376
16410
  const prefix = `${JSON.stringify(key)}:`;
16377
16411
  const allowance = budget - used - prefix.length - (shown2.length > 0 ? 1 : 0);
16378
16412
  if (allowance < 2) {
16379
16413
  omit(childPath);
16380
16414
  continue;
16381
16415
  }
16382
- const text = project(child, allowance, childPath, input, path11);
16416
+ const text = project(child, allowance, childPath, input, path12);
16383
16417
  if (text === void 0) continue;
16384
16418
  shown2.push(prefix + text);
16385
16419
  used += prefix.length + text.length + (shown2.length > 1 ? 1 : 0);
16386
16420
  }
16387
- if (path11 && cutOwners.has(input)) shown2.push('"__truncated":true');
16421
+ if (path12 && cutOwners.has(input)) shown2.push('"__truncated":true');
16388
16422
  return `{${shown2.join(",")}}`;
16389
16423
  };
16390
16424
  const projected = project(value, MAX_TOOL_RESULT_CHARS - PROJECTION_SUMMARY_CHARS - reserve, "");
@@ -16393,9 +16427,9 @@ function boundedProjection(full, partialRows, reserve = 0) {
16393
16427
  const result2 = { ...output, __truncated: true, [TRUNCATION_SUMMARY_KEY]: summary };
16394
16428
  return serializeResult(partialRows ? withPartialLists(result2) : result2);
16395
16429
  }
16396
- function rowsShown(cut, path11) {
16397
- if (path11.includes("[")) return Infinity;
16398
- const list = path11.split(".").reduce((owner, key) => isRecord8(owner) ? owner[key] : void 0, cut);
16430
+ function rowsShown(cut, path12) {
16431
+ if (path12.includes("[")) return Infinity;
16432
+ const list = path12.split(".").reduce((owner, key) => isRecord8(owner) ? owner[key] : void 0, cut);
16399
16433
  return Array.isArray(list) ? list.length : 0;
16400
16434
  }
16401
16435
  function withPartialRows(full, whole2) {
@@ -16408,7 +16442,7 @@ function withPartialRows(full, whole2) {
16408
16442
  }
16409
16443
  if (!fitsCap(partial)) return whole2;
16410
16444
  const cut = JSON.parse(whole2);
16411
- return [...rescued].some(([path11, index]) => rowsShown(cut, path11) <= index) ? partial : whole2;
16445
+ return [...rescued].some(([path12, index]) => rowsShown(cut, path12) <= index) ? partial : whole2;
16412
16446
  }
16413
16447
  function truncateToolResult(details, options = {}) {
16414
16448
  const annotated = withPartialLists(details);
@@ -17048,9 +17082,9 @@ function resolvePageReferences(runtime, tool, params) {
17048
17082
  }
17049
17083
  return resolved;
17050
17084
  }
17051
- function pageOwner(value, path11) {
17085
+ function pageOwner(value, path12) {
17052
17086
  let owner = value;
17053
- for (const key of path11) {
17087
+ for (const key of path12) {
17054
17088
  if (owner === null || typeof owner !== "object" || Array.isArray(owner)) return void 0;
17055
17089
  owner = owner[key];
17056
17090
  }
@@ -17085,8 +17119,8 @@ function referencePages(runtime, tool, params, value) {
17085
17119
  });
17086
17120
  owner[cursor.key] = reference;
17087
17121
  const pagination = pageOwner(root.__pagination, []);
17088
- for (const [path11, note] of Object.entries(pagination ?? {})) {
17089
- if (typeof note === "string") pagination[path11] = note.split(token).join(reference);
17122
+ for (const [path12, note] of Object.entries(pagination ?? {})) {
17123
+ if (typeof note === "string") pagination[path12] = note.split(token).join(reference);
17090
17124
  }
17091
17125
  changed = true;
17092
17126
  }
@@ -17584,9 +17618,9 @@ function ensureBuiltinsRegistered() {
17584
17618
  }
17585
17619
  function loadAeroSystemPrompt(pkgDir, opts = {}) {
17586
17620
  const skillDir = resolveAeroSkillDir(pkgDir);
17587
- const skillBody = fs10.readFileSync(path9.join(skillDir, "SKILL.md"), "utf-8");
17588
- const soulPath = path9.join(skillDir, "soul.md");
17589
- const base = fs10.existsSync(soulPath) ? `${fs10.readFileSync(soulPath, "utf-8").trimEnd()}
17621
+ const skillBody = fs11.readFileSync(path10.join(skillDir, "SKILL.md"), "utf-8");
17622
+ const soulPath = path10.join(skillDir, "soul.md");
17623
+ const base = fs11.existsSync(soulPath) ? `${fs11.readFileSync(soulPath, "utf-8").trimEnd()}
17590
17624
 
17591
17625
  ---
17592
17626
 
@@ -17599,7 +17633,7 @@ function appendSystemPromptExtras(base, env = process.env) {
17599
17633
  const filePath = env.AERO_SYSTEM_PROMPT_FILE?.trim();
17600
17634
  if (filePath) {
17601
17635
  try {
17602
- fileBody = fs10.readFileSync(filePath, "utf-8").trim();
17636
+ fileBody = fs11.readFileSync(filePath, "utf-8").trim();
17603
17637
  } catch {
17604
17638
  fileBody = "";
17605
17639
  }
@@ -21484,7 +21518,7 @@ function mcpTransportPaths() {
21484
21518
  }
21485
21519
  function mcpHttpHealth(app, apiPrefix) {
21486
21520
  const available = mcpTransportPaths().every(
21487
- (path11) => ["POST", "GET", "DELETE"].every((method) => app.hasRoute({ method, url: `${apiPrefix}${path11}` }))
21521
+ (path12) => ["POST", "GET", "DELETE"].every((method) => app.hasRoute({ method, url: `${apiPrefix}${path12}` }))
21488
21522
  );
21489
21523
  return { status: available ? "available" : "unavailable" };
21490
21524
  }
@@ -22192,13 +22226,13 @@ var USER_AGENT2 = "Canonry/1.0 (site-analysis)";
22192
22226
  function fetchWithPinnedAddress(target) {
22193
22227
  return new Promise((resolve2) => {
22194
22228
  const port = target.url.port ? Number(target.url.port) : 443;
22195
- const path11 = target.url.pathname + target.url.search;
22229
+ const path12 = target.url.pathname + target.url.search;
22196
22230
  const req = https2.request(
22197
22231
  {
22198
22232
  hostname: target.address,
22199
22233
  family: target.family,
22200
22234
  port,
22201
- path: path11,
22235
+ path: path12,
22202
22236
  method: "GET",
22203
22237
  timeout: FETCH_TIMEOUT_MS2,
22204
22238
  servername: target.url.hostname,
@@ -23394,13 +23428,13 @@ function providerSummaries(registry, config, includeBrowser = false) {
23394
23428
  }
23395
23429
  function runtimePathIdentity(runtimePath) {
23396
23430
  if (runtimePath === ":memory:") return runtimePath;
23397
- const resolved = path10.resolve(runtimePath);
23398
- let directory = path10.dirname(resolved);
23431
+ const resolved = path11.resolve(runtimePath);
23432
+ let directory = path11.dirname(resolved);
23399
23433
  try {
23400
- directory = fs11.realpathSync(directory);
23434
+ directory = fs12.realpathSync(directory);
23401
23435
  } catch {
23402
23436
  }
23403
- return path10.join(directory, path10.basename(resolved));
23437
+ return path11.join(directory, path11.basename(resolved));
23404
23438
  }
23405
23439
  var DASHBOARD_SCRYPT_KEYLEN = 64;
23406
23440
  var DASHBOARD_SCRYPT_COST = 1 << 15;
@@ -23712,7 +23746,7 @@ function createGoogleMarketingConfigCredentialStore(input) {
23712
23746
  };
23713
23747
  }
23714
23748
  async function createServer(opts) {
23715
- const runtimeConfigPath = path10.resolve(getConfigPath());
23749
+ const runtimeConfigPath = path11.resolve(getConfigPath());
23716
23750
  const runtimeConfigIdentity = runtimePathIdentity(runtimeConfigPath);
23717
23751
  const runtimeDatabasePath = opts.config.database;
23718
23752
  const runtimeDatabaseIdentity = runtimePathIdentity(runtimeDatabasePath);
@@ -23960,8 +23994,8 @@ async function createServer(opts) {
23960
23994
  app.log.error({ runId, projectId }, "GTM sync failed");
23961
23995
  });
23962
23996
  };
23963
- const orphanedOpenClawDir = path10.join(os5.homedir(), ".openclaw-aero");
23964
- if (fs11.existsSync(orphanedOpenClawDir)) {
23997
+ const orphanedOpenClawDir = path11.join(os5.homedir(), ".openclaw-aero");
23998
+ if (fs12.existsSync(orphanedOpenClawDir)) {
23965
23999
  app.log.warn(
23966
24000
  { path: orphanedOpenClawDir },
23967
24001
  "OpenClaw gateway is no longer used. Remove ~/.openclaw-aero/ manually to reclaim the directory."
@@ -24794,7 +24828,7 @@ async function createServer(opts) {
24794
24828
  });
24795
24829
  }
24796
24830
  if (verification.needsRehash) {
24797
- if (fs11.existsSync(getConfigPath()) && (!onDisk || typeof onDisk !== "object" || Array.isArray(onDisk) || !onDisk.apiUrl || !onDisk.database || !onDisk.apiKey)) {
24831
+ if (fs12.existsSync(getConfigPath()) && (!onDisk || typeof onDisk !== "object" || Array.isArray(onDisk) || !onDisk.apiUrl || !onDisk.database || !onDisk.apiKey)) {
24798
24832
  throw new Error("Cannot migrate dashboard password: config.yaml is unreadable or invalid");
24799
24833
  }
24800
24834
  const migratedHash = hashDashboardPassword(password);
@@ -25085,7 +25119,7 @@ async function createServer(opts) {
25085
25119
  // a config and shouldn't get 503s from a stub-missing file.
25086
25120
  runtimeStatePaths: {
25087
25121
  databasePath: runtimeDatabasePath,
25088
- configPath: fs11.existsSync(runtimeConfigPath) ? runtimeConfigPath : null
25122
+ configPath: fs12.existsSync(runtimeConfigPath) ? runtimeConfigPath : null
25089
25123
  },
25090
25124
  // Snapshot the bundled skill trees (version + file hashes) so the
25091
25125
  // `agent.skills.current` doctor check can flag a `~/.claude/skills/` install
@@ -25492,7 +25526,7 @@ async function createServer(opts) {
25492
25526
  ...existing?.pricing ? { pricing: existing.pricing } : {}
25493
25527
  };
25494
25528
  try {
25495
- saveConfigPatch(fs11.existsSync(runtimeConfigPath) ? { providers: { [name]: opts.config.providers[name] } } : opts.config);
25529
+ saveConfigPatch(fs12.existsSync(runtimeConfigPath) ? { providers: { [name]: opts.config.providers[name] } } : opts.config);
25496
25530
  } catch (err) {
25497
25531
  app.log.error({ err }, "Failed to save config");
25498
25532
  return null;
@@ -25649,10 +25683,10 @@ async function createServer(opts) {
25649
25683
  return snapshotService.createReport(input);
25650
25684
  }
25651
25685
  });
25652
- const dirname = path10.dirname(fileURLToPath3(import.meta.url));
25653
- const assetsDir = opts.assetsDir ?? path10.join(dirname, "..", "assets");
25654
- if (fs11.existsSync(assetsDir)) {
25655
- const indexPath = path10.join(assetsDir, "index.html");
25686
+ const dirname = path11.dirname(fileURLToPath3(import.meta.url));
25687
+ const assetsDir = opts.assetsDir ?? path11.join(dirname, "..", "assets");
25688
+ if (fs12.existsSync(assetsDir)) {
25689
+ const indexPath = path11.join(assetsDir, "index.html");
25656
25690
  const injectConfig = (html, projectTabsOverride, themeOverride, renderTokenOverride) => {
25657
25691
  const clientConfig = {};
25658
25692
  if (basePath) clientConfig.basePath = basePath;
@@ -25721,8 +25755,8 @@ async function createServer(opts) {
25721
25755
  // Without this, the browser hits the server for every JS chunk on
25722
25756
  // every page load, defeating most of the dashboard's first-paint
25723
25757
  // budget.
25724
- setHeaders: (res, path11) => {
25725
- if (path11.endsWith(".html")) {
25758
+ setHeaders: (res, path12) => {
25759
+ if (path12.endsWith(".html")) {
25726
25760
  res.setHeader("Cache-Control", "no-cache, must-revalidate");
25727
25761
  } else {
25728
25762
  res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
@@ -25730,8 +25764,8 @@ async function createServer(opts) {
25730
25764
  }
25731
25765
  });
25732
25766
  const serveIndex = (_request, reply) => {
25733
- if (fs11.existsSync(indexPath)) {
25734
- const html = fs11.readFileSync(indexPath, "utf-8");
25767
+ if (fs12.existsSync(indexPath)) {
25768
+ const html = fs12.readFileSync(indexPath, "utf-8");
25735
25769
  return sendSpaDocument(reply, html);
25736
25770
  }
25737
25771
  return reply.status(404).send({ error: "Dashboard not built" });
@@ -25762,8 +25796,8 @@ async function createServer(opts) {
25762
25796
  if (basePath && !url.startsWith(basePath)) {
25763
25797
  return reply.status(404).send({ error: "Not found", path: request.url });
25764
25798
  }
25765
- if (fs11.existsSync(indexPath)) {
25766
- const html = fs11.readFileSync(indexPath, "utf-8");
25799
+ if (fs12.existsSync(indexPath)) {
25800
+ const html = fs12.readFileSync(indexPath, "utf-8");
25767
25801
  return sendSpaDocument(reply, html);
25768
25802
  }
25769
25803
  return reply.status(404).send({ error: "Not found" });