@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.
@@ -64991,10 +64991,11 @@ function loadDuckdb(opts = {}) {
64991
64991
  try {
64992
64992
  const pluginRequire = createRequire(duckdbPkg);
64993
64993
  return pluginRequire("@duckdb/node-api");
64994
- } catch {
64994
+ } catch (err) {
64995
+ const cause = (err instanceof Error ? err.message : String(err)).split("\n")[0].slice(0, 300);
64995
64996
  throw missingDependency(
64996
- "@duckdb/node-api is installed but failed to load. Re-run `canonry backlinks install`.",
64997
- { pluginDir }
64997
+ `@duckdb/node-api is installed but failed to load (${cause}). Re-run \`canonry backlinks install\`.`,
64998
+ { pluginDir, cause }
64998
64999
  );
64999
65000
  }
65000
65001
  }
@@ -65024,16 +65025,28 @@ async function installDuckdb(opts = {}) {
65024
65025
  const pkgManager = opts.packageManager ?? "npm";
65025
65026
  await ensurePluginDir(pluginDir, pluginPkgJson);
65026
65027
  if (isDuckdbInstalled({ pluginPkgJson })) {
65027
- const version2 = readInstalledVersion({ pluginPkgJson }) ?? "unknown";
65028
- return { alreadyPresent: true, version: version2, path: pluginDir };
65028
+ if (loads(pluginPkgJson)) {
65029
+ const version2 = readInstalledVersion({ pluginPkgJson }) ?? "unknown";
65030
+ return { alreadyPresent: true, version: version2, path: pluginDir };
65031
+ }
65032
+ await fs4.rm(path5.join(pluginDir, "node_modules", "@duckdb"), { recursive: true, force: true });
65029
65033
  }
65030
65034
  await runInstall(pkgManager, spec, pluginDir, opts.onLog);
65031
65035
  if (!isDuckdbInstalled({ pluginPkgJson })) {
65032
65036
  throw new Error(`${pkgManager} install completed but @duckdb/node-api still cannot be resolved from ${pluginDir}`);
65033
65037
  }
65038
+ loadDuckdb({ pluginPkgJson });
65034
65039
  const version = readInstalledVersion({ pluginPkgJson }) ?? "unknown";
65035
65040
  return { alreadyPresent: false, version, path: pluginDir };
65036
65041
  }
65042
+ function loads(pluginPkgJson) {
65043
+ try {
65044
+ loadDuckdb({ pluginPkgJson });
65045
+ return true;
65046
+ } catch {
65047
+ return false;
65048
+ }
65049
+ }
65037
65050
  async function ensurePluginDir(pluginDir, pluginPkgJson) {
65038
65051
  await fs4.mkdir(pluginDir, { recursive: true });
65039
65052
  try {
@@ -65064,7 +65077,12 @@ async function runInstall(pkgManager, spec, pluginDir, onLog) {
65064
65077
  }
65065
65078
  });
65066
65079
  }
65067
- child.on("error", reject);
65080
+ child.on("error", (err) => {
65081
+ reject(err.code === "ENOENT" && process.platform !== "win32" ? missingDependency(
65082
+ `${pkgManager} was not found, so @duckdb/node-api cannot be installed here. The canonry Docker image ships without ${pkgManager}.`,
65083
+ { pluginDir }
65084
+ ) : err);
65085
+ });
65068
65086
  child.on("exit", (code) => {
65069
65087
  if (code === 0) resolve();
65070
65088
  else reject(new Error(`${pkgManager} install exited with code ${code}`));
@@ -31,7 +31,7 @@ import {
31
31
  trackFeatureCompleted,
32
32
  trackIntegrationConnection,
33
33
  waitForServerRuntimeStartup
34
- } from "./chunk-J6WFXMTX.js";
34
+ } from "./chunk-HU4M4EAF.js";
35
35
  import {
36
36
  clearDashboardPassword,
37
37
  configExists,
@@ -122,7 +122,7 @@ import {
122
122
  rawEventSamples,
123
123
  readMarketCompetitorNames,
124
124
  runs
125
- } from "./chunk-QQP7OQTW.js";
125
+ } from "./chunk-KUS7M65J.js";
126
126
  import {
127
127
  AdsDeliverySnapshotStatuses,
128
128
  AdsHistoricalCampaignRollupStatuses,
@@ -586,7 +586,7 @@ function parseDemoTrustedProxies(values) {
586
586
  async function demoCommand(options) {
587
587
  const { host, port } = parseDemoListenOptions(options);
588
588
  const trustProxy = parseDemoTrustedProxies(options.trustProxy);
589
- const { createDemoServer } = await import("./demo-server-AKJZISIL.js");
589
+ const { createDemoServer } = await import("./demo-server-26UUDUM7.js");
590
590
  const app = await createDemoServer({ trustProxy });
591
591
  let stopping = false;
592
592
  const stop = () => {
@@ -1000,7 +1000,7 @@ No DB writes performed. Re-run without --dry-run to apply.`);
1000
1000
  }
1001
1001
  }
1002
1002
  async function backfillInsightsCommand(project2, opts) {
1003
- const { IntelligenceService } = await import("./intelligence-service-7BOU7ZAR.js");
1003
+ const { IntelligenceService } = await import("./intelligence-service-ZGDBVFDE.js");
1004
1004
  const config = loadConfig();
1005
1005
  const db = createClient(config.database);
1006
1006
  migrate(db);
@@ -18170,18 +18170,33 @@ function isProcessAlive(pid) {
18170
18170
  return false;
18171
18171
  }
18172
18172
  }
18173
- async function waitForReady(host, port, maxMs = 1e4) {
18174
- const url = `${operatorHttpUrl(host, port)}/health`;
18173
+ async function answersHealth(url) {
18174
+ try {
18175
+ const res = await fetch(url, { signal: AbortSignal.timeout(1e3) });
18176
+ return res.ok;
18177
+ } catch {
18178
+ return false;
18179
+ }
18180
+ }
18181
+ var START_READY_TIMEOUT_MS = 3e4;
18182
+ async function waitForReady(url, hasExited, maxMs = START_READY_TIMEOUT_MS) {
18175
18183
  const deadline = Date.now() + maxMs;
18176
18184
  while (Date.now() < deadline) {
18177
- try {
18178
- const res = await fetch(url);
18179
- if (res.ok) return true;
18180
- } catch {
18181
- }
18185
+ if (hasExited()) return "exited";
18186
+ if (await answersHealth(url)) return "ready";
18182
18187
  await new Promise((r) => setTimeout(r, 200));
18183
18188
  }
18184
- return false;
18189
+ return hasExited() ? "exited" : "timeout";
18190
+ }
18191
+ function serveCommandLine(entry, execArgv, forwardArgs) {
18192
+ if (!entry) {
18193
+ throw new CliError({
18194
+ code: "DAEMON_START_FAILED",
18195
+ message: 'Cannot find the canonry entry point to start the server. Run "canonry serve" instead.',
18196
+ displayMessage: 'Cannot find the canonry entry point to start the server. Run "canonry serve" instead.'
18197
+ });
18198
+ }
18199
+ return [...execArgv, entry, "serve", ...forwardArgs];
18185
18200
  }
18186
18201
  function resolveDaemonEndpoint(opts, env, configPort) {
18187
18202
  const portInput = opts.port || env.CANONRY_PORT;
@@ -18224,14 +18239,25 @@ async function startDaemon(opts) {
18224
18239
  const endpoint = resolveDaemonEndpoint(opts, process.env, config.port);
18225
18240
  const host = endpoint.host;
18226
18241
  const port = String(endpoint.port);
18227
- const cliPath = path9.resolve(new URL(import.meta.url).pathname);
18228
- const inSourceMode = new URL(import.meta.url).pathname.endsWith(".ts");
18229
- const args = inSourceMode ? ["--import", "tsx", cliPath, "serve"] : [cliPath, "serve"];
18230
- args.push(...buildServeForwardArgs({ ...opts, host, port }));
18242
+ const url = operatorHttpUrl(host, port);
18243
+ const healthUrl = `${url}/health`;
18244
+ if (await answersHealth(healthUrl)) {
18245
+ throw new CliError({
18246
+ code: "DAEMON_ALREADY_RUNNING",
18247
+ message: `A server is already running at ${url}`,
18248
+ displayMessage: `A server is already running at ${url}`,
18249
+ details: { host, port }
18250
+ });
18251
+ }
18252
+ const args = serveCommandLine(process.argv[1], process.execArgv, buildServeForwardArgs({ ...opts, host, port }));
18231
18253
  const child = spawn2(process.execPath, args, {
18232
18254
  detached: true,
18233
18255
  stdio: "ignore"
18234
18256
  });
18257
+ let exit;
18258
+ child.once("exit", (code, signal) => {
18259
+ exit = { code, signal };
18260
+ });
18235
18261
  child.unref();
18236
18262
  if (!child.pid) {
18237
18263
  throw new CliError({
@@ -18248,8 +18274,22 @@ async function startDaemon(opts) {
18248
18274
  if (!isMachineFormat(format)) {
18249
18275
  process.stderr.write("Waiting for server to start...");
18250
18276
  }
18251
- const ready = await waitForReady(host, port);
18252
- if (!ready) {
18277
+ const ready = await waitForReady(healthUrl, () => exit !== void 0);
18278
+ if (ready === "exited") {
18279
+ try {
18280
+ fs16.unlinkSync(pidPath);
18281
+ } catch {
18282
+ }
18283
+ const how = exit?.signal ? `signal ${exit.signal}` : `code ${exit?.code}`;
18284
+ throw new CliError({
18285
+ code: "DAEMON_START_FAILED",
18286
+ message: `Failed to start: the server exited (${how}) before it was ready. Run "canonry serve" to see why.`,
18287
+ displayMessage: `
18288
+ Failed to start: the server exited (${how}) before it was ready. Run "canonry serve" to see why.`,
18289
+ details: { host, port, pid: child.pid, exitCode: exit?.code ?? null, signal: exit?.signal ?? null }
18290
+ });
18291
+ }
18292
+ if (ready === "timeout") {
18253
18293
  try {
18254
18294
  child.kill("SIGTERM");
18255
18295
  } catch {
@@ -18260,8 +18300,9 @@ async function startDaemon(opts) {
18260
18300
  }
18261
18301
  throw new CliError({
18262
18302
  code: "DAEMON_START_TIMEOUT",
18263
- message: "Failed to start: server did not respond within 10s",
18264
- displayMessage: "\nFailed to start: server did not respond within 10s",
18303
+ message: `Failed to start: server did not respond within ${START_READY_TIMEOUT_MS / 1e3}s`,
18304
+ displayMessage: `
18305
+ Failed to start: server did not respond within ${START_READY_TIMEOUT_MS / 1e3}s`,
18265
18306
  details: {
18266
18307
  host,
18267
18308
  port,
@@ -18272,7 +18313,6 @@ async function startDaemon(opts) {
18272
18313
  if (!isMachineFormat(format)) {
18273
18314
  process.stderr.write("\n");
18274
18315
  }
18275
- const url = operatorHttpUrl(host, port);
18276
18316
  if (isMachineFormat(format)) {
18277
18317
  console.log(JSON.stringify({
18278
18318
  started: true,
@@ -19405,7 +19445,7 @@ var SYSTEM_CLI_COMMANDS = [
19405
19445
  options: { access: stringOption() },
19406
19446
  run: async (input) => {
19407
19447
  if (input.positionals.length > 1) throw usageError("Expected at most one command group");
19408
- const [{ printCliCatalog }, { REGISTERED_CLI_COMMANDS: REGISTERED_CLI_COMMANDS2 }] = await Promise.all([import("./cli-catalog-KTQ6BHEU.js"), import("./cli-commands-NAUTCUCJ.js")]);
19448
+ const [{ printCliCatalog }, { REGISTERED_CLI_COMMANDS: REGISTERED_CLI_COMMANDS2 }] = await Promise.all([import("./cli-catalog-KTQ6BHEU.js"), import("./cli-commands-YFC5GT3R.js")]);
19409
19449
  printCliCatalog(REGISTERED_CLI_COMMANDS2, input.format, input.positionals[0], getString(input.values, "access"));
19410
19450
  }
19411
19451
  },
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  REGISTERED_CLI_COMMANDS
3
- } from "./chunk-W3BVUYOR.js";
4
- import "./chunk-J6WFXMTX.js";
3
+ } from "./chunk-LS6RZBPH.js";
4
+ import "./chunk-HU4M4EAF.js";
5
5
  import "./chunk-GZPJ7TSE.js";
6
6
  import "./chunk-KU4TPVZV.js";
7
7
  import "./chunk-RB2F4D3Z.js";
8
- import "./chunk-W43I4JKI.js";
8
+ import "./chunk-6GNV6VF4.js";
9
9
  import "./chunk-RUWELF3K.js";
10
10
  import "./chunk-HGMYEDAQ.js";
11
- import "./chunk-QQP7OQTW.js";
11
+ import "./chunk-KUS7M65J.js";
12
12
  import "./chunk-YOGHHIGE.js";
13
13
  export {
14
14
  REGISTERED_CLI_COMMANDS
package/dist/cli.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  buildSetupState,
14
14
  consumePendingServeHandoff,
15
15
  serveCommand
16
- } from "./chunk-W3BVUYOR.js";
16
+ } from "./chunk-LS6RZBPH.js";
17
17
  import {
18
18
  checkLatestVersionForCli,
19
19
  cliRuntimeContext,
@@ -27,13 +27,13 @@ import {
27
27
  showFirstRunNotice,
28
28
  trackCliCommandFinished,
29
29
  trackEvent
30
- } from "./chunk-J6WFXMTX.js";
30
+ } from "./chunk-HU4M4EAF.js";
31
31
  import "./chunk-GZPJ7TSE.js";
32
32
  import {
33
33
  resolveCliAccess
34
34
  } from "./chunk-KU4TPVZV.js";
35
35
  import "./chunk-RB2F4D3Z.js";
36
- import "./chunk-W43I4JKI.js";
36
+ import "./chunk-6GNV6VF4.js";
37
37
  import "./chunk-RUWELF3K.js";
38
38
  import {
39
39
  CliError,
@@ -42,7 +42,7 @@ import {
42
42
  printCliError,
43
43
  usageError
44
44
  } from "./chunk-HGMYEDAQ.js";
45
- import "./chunk-QQP7OQTW.js";
45
+ import "./chunk-KUS7M65J.js";
46
46
  import {
47
47
  OperationAccesses
48
48
  } from "./chunk-YOGHHIGE.js";
@@ -198,6 +198,12 @@ var TELEMETRY_ERROR_CODES = /* @__PURE__ */ new Set([
198
198
  "CLI_USAGE_ERROR",
199
199
  "CLI_SYSTEM_ERROR",
200
200
  "CONNECTION_ERROR",
201
+ // A doctor run that found failing checks did its job; `start` failures say
202
+ // why the server did not come up. Both used to arrive as CLI_ERROR.
203
+ "DOCTOR_CHECKS_FAILED",
204
+ "DAEMON_ALREADY_RUNNING",
205
+ "DAEMON_START_FAILED",
206
+ "DAEMON_START_TIMEOUT",
201
207
  "UNEXPECTED_RESPONSE_FORMAT",
202
208
  "STORED_ONLY_REFUSED"
203
209
  ]);
@@ -5,7 +5,7 @@ import {
5
5
  computeFactorAverages,
6
6
  layoutSiteCrawlGraphInput,
7
7
  persistSiteCrawlGraphLayout
8
- } from "./chunk-W43I4JKI.js";
8
+ } from "./chunk-6GNV6VF4.js";
9
9
  import {
10
10
  PACKAGE_VERSION,
11
11
  canonryMcpTools
@@ -87,7 +87,7 @@ import {
87
87
  siteCrawlPages,
88
88
  siteCrawlSnapshots,
89
89
  trafficSources
90
- } from "./chunk-QQP7OQTW.js";
90
+ } from "./chunk-KUS7M65J.js";
91
91
  import {
92
92
  AI_ENGINE_DOMAINS,
93
93
  RunKinds,
package/dist/index.js CHANGED
@@ -3,14 +3,14 @@ import {
3
3
  createGoogleMarketingCredentialStore,
4
4
  createGoogleMarketingRuntime,
5
5
  createServer
6
- } from "./chunk-J6WFXMTX.js";
6
+ } from "./chunk-HU4M4EAF.js";
7
7
  import {
8
8
  loadConfig
9
9
  } from "./chunk-GZPJ7TSE.js";
10
- import "./chunk-W43I4JKI.js";
10
+ import "./chunk-6GNV6VF4.js";
11
11
  import "./chunk-RUWELF3K.js";
12
12
  import "./chunk-HGMYEDAQ.js";
13
- import "./chunk-QQP7OQTW.js";
13
+ import "./chunk-KUS7M65J.js";
14
14
  import "./chunk-YOGHHIGE.js";
15
15
  export {
16
16
  GoogleMarketingRuntimeError,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HISTORY_WINDOW_RUNS,
3
3
  IntelligenceService
4
- } from "./chunk-QQP7OQTW.js";
4
+ } from "./chunk-KUS7M65J.js";
5
5
  import "./chunk-YOGHHIGE.js";
6
6
  export {
7
7
  HISTORY_WINDOW_RUNS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonry/canonry",
3
- "version": "7.51.1",
3
+ "version": "7.51.3",
4
4
  "type": "module",
5
5
  "description": "Self-hosted AI visibility (AEO) platform: track how ChatGPT, Claude, Gemini, and Perplexity cite your domain, join it with Search Console, GA4, server-side traffic, and paid media, and fix what you find through agent tools (CLI, REST, MCP). Local SQLite.",
6
6
  "keywords": [
@@ -86,30 +86,30 @@
86
86
  "tsup": "^8.5.1",
87
87
  "tsx": "^4.19.0",
88
88
  "@canonry/canonry-web": "0.0.0",
89
- "@canonry/canonry-api-client": "0.0.0",
90
89
  "@canonry/canonry-api-routes": "0.0.0",
90
+ "@canonry/canonry-api-client": "0.0.0",
91
+ "@canonry/canonry-db": "0.0.0",
91
92
  "@canonry/canonry-config": "0.0.0",
92
93
  "@canonry/canonry-contracts": "0.0.0",
93
- "@canonry/canonry-db": "0.0.0",
94
94
  "@canonry/canonry-integration-bing": "0.0.0",
95
95
  "@canonry/canonry-integration-cloud-run": "0.0.0",
96
+ "@canonry/canonry-integration-cloudflare-queue": "0.0.0",
96
97
  "@canonry/canonry-integration-cloudflare-worker": "0.0.0",
97
- "@canonry/canonry-integration-commoncrawl": "0.0.0",
98
98
  "@canonry/canonry-integration-google": "0.0.0",
99
+ "@canonry/canonry-integration-commoncrawl": "0.0.0",
99
100
  "@canonry/canonry-integration-google-business-profile": "0.0.0",
100
- "@canonry/canonry-integration-google-ads": "0.0.0",
101
101
  "@canonry/canonry-integration-google-places": "0.0.0",
102
- "@canonry/canonry-integration-traffic": "0.0.0",
102
+ "@canonry/canonry-integration-google-ads": "0.0.0",
103
103
  "@canonry/canonry-integration-google-tag-manager": "0.0.0",
104
104
  "@canonry/canonry-integration-openai-ads": "0.0.0",
105
+ "@canonry/canonry-integration-wordpress": "0.0.0",
106
+ "@canonry/canonry-integration-traffic": "0.0.0",
105
107
  "@canonry/canonry-intelligence": "0.0.0",
108
+ "@canonry/canonry-provider-claude": "0.0.0",
106
109
  "@canonry/canonry-provider-cdp": "0.0.0",
107
- "@canonry/canonry-integration-wordpress": "0.0.0",
108
110
  "@canonry/canonry-provider-gemini": "0.0.0",
109
- "@canonry/canonry-provider-claude": "0.0.0",
110
- "@canonry/canonry-provider-muse": "0.0.0",
111
- "@canonry/canonry-integration-cloudflare-queue": "0.0.0",
112
111
  "@canonry/canonry-provider-local": "0.0.0",
112
+ "@canonry/canonry-provider-muse": "0.0.0",
113
113
  "@canonry/canonry-provider-openai": "0.0.0",
114
114
  "@canonry/canonry-provider-perplexity": "0.0.0",
115
115
  "@canonry/canonry-integration-typesafe": "0.0.0"