@canonry/canonry 7.130.1 → 7.131.0

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.
Files changed (105) hide show
  1. package/assets/agent-workspace/skills/canonry/references/canonry-cli.md +5 -3
  2. package/dist/{activity-VIJVNTMK.js → activity-URKAZ4QI.js} +4 -4
  3. package/dist/{ads-PLZRG4BQ.js → ads-OEKDHREI.js} +4 -4
  4. package/dist/{agent-RFRMOTLE.js → agent-TBU46LO6.js} +6 -6
  5. package/dist/{agent-ask-CB756SUB.js → agent-ask-EDJZGROO.js} +25 -21
  6. package/dist/agent-conversations-BQKCD4CA.js +44 -0
  7. package/dist/{agent-journeys-PLYAVLGB.js → agent-journeys-ASY5XCAJ.js} +3 -3
  8. package/dist/agent-memory-HAGNNLCP.js +74 -0
  9. package/dist/agent-providers-WUDOCAHF.js +49 -0
  10. package/dist/agent-transcript-4MAQ7NCM.js +62 -0
  11. package/dist/{analytics-W6B2FQSA.js → analytics-RYRF5TFC.js} +3 -3
  12. package/dist/{answerability-BDOOPOJF.js → answerability-7VPMCZHE.js} +3 -3
  13. package/dist/{apply-LCANKKT5.js → apply-BNTPH5FW.js} +8 -5
  14. package/dist/{backfill-AM2VXWLI.js → backfill-2DYJLCOU.js} +3 -3
  15. package/dist/{backlinks-ZXSN3XNV.js → backlinks-5HZTCZFW.js} +11 -6
  16. package/dist/{bing-FMDKRCXN.js → bing-S6BOIOTS.js} +31 -17
  17. package/dist/{bootstrap-IHKKYDBO.js → bootstrap-EITWL66P.js} +6 -6
  18. package/dist/{cdp-ASPLW35M.js → cdp-TY2TZB7J.js} +13 -7
  19. package/dist/{chunk-6UU2I6AG.js → chunk-3CDHCDCE.js} +22 -21
  20. package/dist/{chunk-JUZ4ZCOX.js → chunk-3GAJD5NP.js} +3 -3
  21. package/dist/{chunk-MARIMDMX.js → chunk-3LXRY57V.js} +60 -48
  22. package/dist/{chunk-56TGVPRB.js → chunk-3STPYNCP.js} +3 -3
  23. package/dist/{chunk-Z77D43M5.js → chunk-623X526L.js} +1 -1
  24. package/dist/{chunk-M3BKRPB7.js → chunk-63FHJJUO.js} +435 -444
  25. package/dist/chunk-APKBR2BP.js +40 -0
  26. package/dist/{chunk-VEDGR4LZ.js → chunk-BJWPYUKT.js} +1 -1
  27. package/dist/{chunk-NUYKLS2R.js → chunk-CUXA47XW.js} +2 -2
  28. package/dist/{chunk-HH6FQW5W.js → chunk-DYDATNE5.js} +6 -3
  29. package/dist/{chunk-S6X3HHSN.js → chunk-IPUZGRSN.js} +2 -2
  30. package/dist/{chunk-WZPKPA6I.js → chunk-KJX5CMPC.js} +1 -1
  31. package/dist/{chunk-4ISL4JNK.js → chunk-LXFLUFQT.js} +2 -2
  32. package/dist/{chunk-ZZSKYOHV.js → chunk-NK4G4JPQ.js} +2 -2
  33. package/dist/{chunk-JMJSAK2H.js → chunk-NYZH7SM2.js} +2 -2
  34. package/dist/{chunk-MQFH765X.js → chunk-P4ETUNQR.js} +3 -3
  35. package/dist/{chunk-VON4PHNS.js → chunk-RGT2S3VS.js} +35 -15
  36. package/dist/{chunk-KQQERQJ2.js → chunk-RSB3X7UR.js} +2 -2
  37. package/dist/{chunk-52J7GFCK.js → chunk-T6CABZ3N.js} +1 -1
  38. package/dist/{chunk-GVCL4XBU.js → chunk-UFVVOJU3.js} +2 -2
  39. package/dist/{chunk-N5GK27RW.js → chunk-WIQBXZMU.js} +3 -3
  40. package/dist/{chunk-ZHWJJVCT.js → chunk-X3ES2XOJ.js} +1 -1
  41. package/dist/{chunk-QRIKJT6Y.js → chunk-Y7JEJNNS.js} +32 -3
  42. package/dist/{chunk-VEBSXHB2.js → chunk-ZSVQTHX3.js} +4 -3
  43. package/dist/{citations-YWXR3WBL.js → citations-ERRYYKNY.js} +7 -5
  44. package/dist/{cli-catalog-RT3QPDLR.js → cli-catalog-ETUQDYOX.js} +3 -3
  45. package/dist/{cli-commands-PSZFKTZM.js → cli-commands-ORLKC2XM.js} +7 -6
  46. package/dist/cli.js +30 -19
  47. package/dist/{competitor-6ZTA2SZH.js → competitor-IC6KRZAD.js} +7 -4
  48. package/dist/{content-DJYGQ5CP.js → content-3Y6ZKQHG.js} +6 -5
  49. package/dist/{dashboard-QNOTLZUI.js → dashboard-XBS4EVSA.js} +3 -3
  50. package/dist/{demo-FVTIXDAO.js → demo-7D4W32J6.js} +2 -2
  51. package/dist/{demo-server-R7LG5BRB.js → demo-server-CGOD7EPX.js} +3 -3
  52. package/dist/{discover-3E7QM2TL.js → discover-34E5JIM5.js} +3 -3
  53. package/dist/{discover-eval-NAZPA6PV.js → discover-eval-TLH2MMNK.js} +41 -16
  54. package/dist/{doctor-OFFSPNBK.js → doctor-SGJQPWRI.js} +3 -3
  55. package/dist/{evidence-VOSSML2G.js → evidence-TFFVSNEL.js} +6 -5
  56. package/dist/{export-cmd-IVACTDSV.js → export-cmd-YRG7CEVX.js} +3 -3
  57. package/dist/{ga-BX4C7TPI.js → ga-VVJWYWQX.js} +6 -5
  58. package/dist/{gbp-SV3J2VG3.js → gbp-RYA62WDX.js} +23 -10
  59. package/dist/{google-J23OD7TR.js → google-5HRSXPUF.js} +13 -12
  60. package/dist/{google-marketing-TTLXMDMD.js → google-marketing-UGMDLFPE.js} +1 -1
  61. package/dist/{health-cmd-26AHD5XL.js → health-cmd-WUBFEQX6.js} +3 -3
  62. package/dist/{history-QWBRFDQR.js → history-5GFG76UO.js} +5 -3
  63. package/dist/index.d.ts +15 -15
  64. package/dist/index.js +12 -12
  65. package/dist/{init-IZVPCO36.js → init-CHZSBQOK.js} +10 -9
  66. package/dist/{insights-PMTHHZ2H.js → insights-LWLKXKNO.js} +3 -3
  67. package/dist/{journeys-IA7TF753.js → journeys-IQLWLZBY.js} +3 -3
  68. package/dist/{keys-DOHLZTRI.js → keys-3VVORLK2.js} +3 -3
  69. package/dist/{keyword-3C2ZU6OB.js → keyword-3MWGUBHL.js} +7 -4
  70. package/dist/{logs-P7VRVZ5N.js → logs-PSV4DZ6F.js} +3 -3
  71. package/dist/{mcp-6NA62OAY.js → mcp-NNBM3MLW.js} +5 -4
  72. package/dist/mcp.js +8 -8
  73. package/dist/{measurement-plan-RHKCARVE.js → measurement-plan-M4VLA2ZN.js} +5 -4
  74. package/dist/{notify-ODCY7TD3.js → notify-EDSJINE5.js} +3 -3
  75. package/dist/{organic-evidence-76P5AYB3.js → organic-evidence-VBT6URMQ.js} +3 -3
  76. package/dist/{overview-5T776SEB.js → overview-LRNI342W.js} +6 -6
  77. package/dist/{project-ITMGW45M.js → project-HO4GOEC4.js} +3 -3
  78. package/dist/{project-setup-A3Q6ZX73.js → project-setup-AXVIZND6.js} +4 -4
  79. package/dist/{query-3QAQITK3.js → query-E2D2K6MD.js} +8 -5
  80. package/dist/{research-R74N3VRL.js → research-Z3IZQH2M.js} +3 -3
  81. package/dist/{results-export-23GY45AY.js → results-export-TVWWLJQA.js} +3 -3
  82. package/dist/{run-ID66JYBN.js → run-RJDJPROH.js} +4 -4
  83. package/dist/{schedule-HZ2CRUAL.js → schedule-NVDN72YG.js} +3 -3
  84. package/dist/{search-DM5WWMTE.js → search-A4PBZ53D.js} +3 -3
  85. package/dist/{serve-PKDK7ZWB.js → serve-7WPMQUVW.js} +13 -13
  86. package/dist/{session-EZ6I5VUF.js → session-VPJH4TRC.js} +7 -7
  87. package/dist/{settings-SIEKVYD7.js → settings-EYEXRKTM.js} +5 -5
  88. package/dist/{sitemaps-M4IAZLK2.js → sitemaps-4HCWZJOZ.js} +3 -3
  89. package/dist/{skills-J6LWTNU5.js → skills-GPYMDDRH.js} +2 -2
  90. package/dist/{snapshot-SM3BVX5M.js → snapshot-SNR7KBK4.js} +3 -3
  91. package/dist/{status-BHJJOUCK.js → status-VTQJVZFU.js} +12 -6
  92. package/dist/{support-FPXXXJPZ.js → support-H7ANOX67.js} +1 -1
  93. package/dist/{technical-aeo-4DJWWPUN.js → technical-aeo-IDMFUDXP.js} +7 -5
  94. package/dist/{telemetry-LKVQUSO7.js → telemetry-DA43ILAA.js} +4 -4
  95. package/dist/{tools-NFVIW4YP.js → tools-F3FZEG5K.js} +6 -6
  96. package/dist/{traffic-QSZYZHFW.js → traffic-EPWP3D2K.js} +21 -29
  97. package/dist/{trends-WIHWJVJR.js → trends-IVYSKMND.js} +3 -3
  98. package/dist/{users-HQOPQRTP.js → users-ZJMBGWUF.js} +3 -3
  99. package/dist/{visibility-stats-MCY5CAUC.js → visibility-stats-M2I3SUES.js} +11 -5
  100. package/dist/{wordpress-IB5YOJSM.js → wordpress-BGIOJPIF.js} +3 -3
  101. package/package.json +1 -1
  102. package/dist/agent-conversations-RRI7T74B.js +0 -51
  103. package/dist/agent-memory-R5Q7DLRZ.js +0 -91
  104. package/dist/agent-providers-HNMGZ7GY.js +0 -58
  105. package/dist/agent-transcript-N6ZBTF72.js +0 -76
@@ -0,0 +1,40 @@
1
+ import {
2
+ CliError
3
+ } from "./chunk-Y7JEJNNS.js";
4
+ import {
5
+ describeError
6
+ } from "./chunk-FGEBFVHB.js";
7
+
8
+ // src/cli-input.ts
9
+ import fs from "fs";
10
+ import { parse as parseYaml } from "yaml";
11
+ function readInputText(source, what) {
12
+ try {
13
+ return fs.readFileSync(source === "-" ? 0 : source, "utf8");
14
+ } catch (error) {
15
+ throw new CliError({
16
+ code: "FILE_READ_ERROR",
17
+ message: `${what} could not be read: ${describeError(error)}`,
18
+ details: { source }
19
+ });
20
+ }
21
+ }
22
+ function parseInputDocument(content, what, syntax, details = {}) {
23
+ try {
24
+ return syntax === "json" ? JSON.parse(content) : parseYaml(content);
25
+ } catch (error) {
26
+ throw new CliError({
27
+ code: "VALIDATION_ERROR",
28
+ message: `${what} is not valid ${syntax === "json" ? "JSON" : "YAML"}: ${describeError(error)}`,
29
+ details
30
+ });
31
+ }
32
+ }
33
+ function readInputDocument(source, what, syntax) {
34
+ return parseInputDocument(readInputText(source, what), what, syntax, { source });
35
+ }
36
+
37
+ export {
38
+ readInputText,
39
+ readInputDocument
40
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CliError,
3
3
  EXIT_SYSTEM_ERROR
4
- } from "./chunk-QRIKJT6Y.js";
4
+ } from "./chunk-Y7JEJNNS.js";
5
5
  import {
6
6
  describeError
7
7
  } from "./chunk-FGEBFVHB.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  trackIntegrationConnection
3
- } from "./chunk-4ISL4JNK.js";
3
+ } from "./chunk-LXFLUFQT.js";
4
4
  import {
5
5
  cliRuntimeContext
6
- } from "./chunk-WZPKPA6I.js";
6
+ } from "./chunk-KJX5CMPC.js";
7
7
 
8
8
  // src/cli-connection-telemetry.ts
9
9
  function trackCliConnection(properties) {
@@ -2,13 +2,16 @@ import {
2
2
  findMcpClient,
3
3
  listMcpClientIds
4
4
  } from "./chunk-VJWDBFSL.js";
5
+ import {
6
+ readInputText
7
+ } from "./chunk-APKBR2BP.js";
5
8
  import {
6
9
  createApiClient
7
- } from "./chunk-KQQERQJ2.js";
10
+ } from "./chunk-RSB3X7UR.js";
8
11
  import {
9
12
  CliError,
10
13
  isMachineFormat
11
- } from "./chunk-QRIKJT6Y.js";
14
+ } from "./chunk-Y7JEJNNS.js";
12
15
  import {
13
16
  describeError
14
17
  } from "./chunk-FGEBFVHB.js";
@@ -64,7 +67,7 @@ function renderClientSnippet(client, serverName, entry) {
64
67
  }
65
68
  function readJsonConfig(configPath) {
66
69
  if (!fs.existsSync(configPath)) return {};
67
- const raw = fs.readFileSync(configPath, "utf-8").trim();
70
+ const raw = readInputText(configPath, `The MCP client config ${configPath}`).trim();
68
71
  if (!raw) return {};
69
72
  try {
70
73
  const parsed = JSON.parse(raw);
@@ -5,14 +5,14 @@ import {
5
5
  dedupeGscSitemapUrls,
6
6
  resolveDiscoveredGscSitemapUrls,
7
7
  submitGscSitemapBatches
8
- } from "./chunk-VEDGR4LZ.js";
8
+ } from "./chunk-BJWPYUKT.js";
9
9
  import {
10
10
  measurementDraftOperationSchema,
11
11
  runMeasurementDraftAction
12
12
  } from "./chunk-ZHXPH7WB.js";
13
13
  import {
14
14
  CliError
15
- } from "./chunk-QRIKJT6Y.js";
15
+ } from "./chunk-Y7JEJNNS.js";
16
16
  import {
17
17
  AGENT_MEMORY_KEY_MAX_LENGTH,
18
18
  AGENT_MEMORY_VALUE_MAX_BYTES,
@@ -5,7 +5,7 @@ import {
5
5
  loadConfig,
6
6
  loadConfigRaw,
7
7
  saveConfigPatch
8
- } from "./chunk-52J7GFCK.js";
8
+ } from "./chunk-T6CABZ3N.js";
9
9
  import {
10
10
  CANONRY_NPM_PACKAGE_URL,
11
11
  compareSemver,
@@ -2,10 +2,10 @@ import {
2
2
  bucketCliCommandDuration,
3
3
  isTelemetryEnabled,
4
4
  trackEvent
5
- } from "./chunk-WZPKPA6I.js";
5
+ } from "./chunk-KJX5CMPC.js";
6
6
  import {
7
7
  getConfigDir
8
- } from "./chunk-52J7GFCK.js";
8
+ } from "./chunk-T6CABZ3N.js";
9
9
  import {
10
10
  currentOutcomeAttribution
11
11
  } from "./chunk-C4JM5HJW.js";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  configExists,
6
6
  loadConfigRaw
7
- } from "./chunk-52J7GFCK.js";
7
+ } from "./chunk-T6CABZ3N.js";
8
8
 
9
9
  // src/setup-state.ts
10
10
  import fs from "fs";
@@ -47,7 +47,7 @@ function queueServeHandoff() {
47
47
  async function runPendingServeHandoff(format) {
48
48
  if (!pendingServeHandoff) return;
49
49
  pendingServeHandoff = false;
50
- const { serveCommand } = await import("./serve-PKDK7ZWB.js");
50
+ const { serveCommand } = await import("./serve-7WPMQUVW.js");
51
51
  await serveCommand(format);
52
52
  }
53
53
 
@@ -2,11 +2,11 @@ import {
2
2
  configExists,
3
3
  loadConfigRaw,
4
4
  saveConfigPatch
5
- } from "./chunk-52J7GFCK.js";
5
+ } from "./chunk-T6CABZ3N.js";
6
6
  import {
7
7
  BUNDLED_SKILL_NAMES,
8
8
  installSkills
9
- } from "./chunk-Z77D43M5.js";
9
+ } from "./chunk-623X526L.js";
10
10
  import {
11
11
  PACKAGE_VERSION
12
12
  } from "./chunk-AOJU5LKX.js";
@@ -3,7 +3,7 @@ import {
3
3
  resolveCliAccess,
4
4
  resolveCliAccessForInvocation,
5
5
  windowOptions
6
- } from "./chunk-ZHWJJVCT.js";
6
+ } from "./chunk-X3ES2XOJ.js";
7
7
  import {
8
8
  emitJsonl
9
9
  } from "./chunk-Z7IUAJOF.js";
@@ -11,7 +11,7 @@ import {
11
11
  CliError,
12
12
  EXIT_USER_ERROR,
13
13
  usageError
14
- } from "./chunk-QRIKJT6Y.js";
14
+ } from "./chunk-Y7JEJNNS.js";
15
15
  import {
16
16
  OperationAccesses
17
17
  } from "./chunk-FGEBFVHB.js";
@@ -122,7 +122,7 @@ async function dispatchRegisteredCommand(args, fallbackFormat, specs) {
122
122
  const accessValue = accessFilterFromArgs(argsWithoutHelp);
123
123
  validateAccessFilter(accessValue);
124
124
  if (fallbackFormat !== "text") {
125
- const { printCliCatalog: printCliCatalog2 } = await import("./cli-catalog-RT3QPDLR.js");
125
+ const { printCliCatalog: printCliCatalog2 } = await import("./cli-catalog-ETUQDYOX.js");
126
126
  const group2 = argsWithoutHelp.find((arg) => !arg.startsWith("--"));
127
127
  printCliCatalog2(specs, fallbackFormat, group2, accessValue);
128
128
  return true;
@@ -5,15 +5,19 @@ import {
5
5
  } from "./chunk-QHQZ2226.js";
6
6
  import {
7
7
  createApiClient
8
- } from "./chunk-KQQERQJ2.js";
8
+ } from "./chunk-RSB3X7UR.js";
9
9
  import {
10
10
  emitJsonl
11
11
  } from "./chunk-Z7IUAJOF.js";
12
12
  import {
13
13
  CliError,
14
14
  EXIT_SYSTEM_ERROR,
15
- isMachineFormat
16
- } from "./chunk-QRIKJT6Y.js";
15
+ errorCodeFor,
16
+ exitCodeFor,
17
+ isMachineFormat,
18
+ mostSevereExitCode,
19
+ systemError
20
+ } from "./chunk-Y7JEJNNS.js";
17
21
  import {
18
22
  MentionIdentities,
19
23
  OUTSTANDING_PROVIDER_BATCH_STATUSES,
@@ -22,7 +26,8 @@ import {
22
26
  describeError,
23
27
  formatMicros,
24
28
  formatRunErrorOneLine,
25
- resolveProviderInput
29
+ resolveProviderInput,
30
+ shellQuote
26
31
  } from "./chunk-FGEBFVHB.js";
27
32
 
28
33
  // src/commands/run.ts
@@ -56,9 +61,6 @@ async function previewRun(project, format) {
56
61
  console.log(preview.blockedReason === null ? " Ready to start." : ` ${reasons[preview.blockedReason]}`);
57
62
  }
58
63
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["completed", "partial", "failed", "cancelled"]);
59
- function shellArg(value) {
60
- return /^[\w.-]+$/.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
61
- }
62
64
  function providerAccountStreakLine(provider, streak) {
63
65
  return `${provider} (${streak.code}): failed on its account in each of its last ${streak.consecutiveRuns} runs; called again after ${streak.retryAfter}`;
64
66
  }
@@ -66,7 +68,7 @@ function providersThatKeepFailing(count) {
66
68
  return count === 1 ? "a provider that keeps failing on its account" : `${count} providers that keep failing on their accounts`;
67
69
  }
68
70
  function providerAccountFixLine(project) {
69
- return `Fix the key, access or billing in the provider's console. Saving a new key, model or endpoint (canonry settings provider <name>) retries at once; canonry run ${shellArg(project)} --force calls every provider now.`;
71
+ return `Fix the key, access or billing in the provider's console. Saving a new key, model or endpoint (\`canonry settings provider <name> --api-key <key>\`, or \`--model <model>\` or \`--base-url <url>\` in place of the key) retries at once; \`canonry run ${shellQuote(project)} --force\` calls every provider now.`;
70
72
  }
71
73
  function admissionDecisionKey(admission) {
72
74
  return JSON.stringify([
@@ -98,15 +100,19 @@ Not calling ${providersThatKeepFailing(held.length)}:`);
98
100
  for (const [provider, streak] of held) console.log(` ${providerAccountStreakLine(provider, streak)}`);
99
101
  console.log(providerAccountFixLine(project));
100
102
  }
101
- function throwIfWaitedRunFailed(waited) {
103
+ function notStartedSentence({ projectCount, projects }) {
104
+ return `Could not start a run for ${projects.length} of ${projectCount} project${projectCount === 1 ? "" : "s"}: ` + projects.map((p) => `${p.project}: ${p.error}`).join("; ");
105
+ }
106
+ function throwIfWaitedRunFailed(waited, notStarted) {
102
107
  const failed = waited.filter((r) => r.status === RunStatuses.failed);
103
108
  if (failed.length === 0) return;
104
109
  const reason = (r) => r.error ? formatRunErrorOneLine(r.error) : null;
105
110
  const label = (r) => [r.project, r.location ? `(${r.location})` : null, `run ${r.runId}`].filter(Boolean).join(" ");
106
111
  const message = waited.length === 1 ? `Run ${failed[0].runId} failed${reason(failed[0]) ? `: ${reason(failed[0])}` : ""}` : `${failed.length} of ${waited.length} runs failed: ${failed.map((r) => `${label(r)}${reason(r) ? `: ${reason(r)}` : ""}`).join("; ")}`;
112
+ const alsoNotStarted = notStarted && notStarted.projects.length > 0 ? notStarted : null;
107
113
  throw new CliError({
108
114
  code: "RUN_FAILED",
109
- message,
115
+ message: alsoNotStarted ? `${message.replace(/\.$/, "")}. ${notStartedSentence(alsoNotStarted)}` : message,
110
116
  exitCode: EXIT_SYSTEM_ERROR,
111
117
  details: {
112
118
  waitedRunCount: waited.length,
@@ -115,10 +121,21 @@ function throwIfWaitedRunFailed(waited) {
115
121
  ...r.project ? { project: r.project } : {},
116
122
  ...r.location ? { location: r.location } : {},
117
123
  error: reason(r)
118
- }))
124
+ })),
125
+ ...alsoNotStarted ? { notStarted: alsoNotStarted.projects } : {}
119
126
  }
120
127
  });
121
128
  }
129
+ function throwIfRunAllFailed(notStarted, waited) {
130
+ if (waited) throwIfWaitedRunFailed(waited, notStarted);
131
+ if (notStarted.projects.length === 0) return;
132
+ throw new CliError({
133
+ code: "RUNS_NOT_STARTED",
134
+ message: notStartedSentence(notStarted),
135
+ exitCode: mostSevereExitCode(notStarted.projects.map((p) => p.exitCode)),
136
+ details: { projectCount: notStarted.projectCount, notStarted: notStarted.projects }
137
+ });
138
+ }
122
139
  async function triggerRun(project, opts) {
123
140
  const client = getClient();
124
141
  const body = {};
@@ -282,6 +299,7 @@ async function triggerRunAll(opts) {
282
299
  baseBody.force = true;
283
300
  }
284
301
  const results = [];
302
+ const notStartedProjects = [];
285
303
  for (const p of projects) {
286
304
  const body = { ...baseBody };
287
305
  if (body.allLocations && p.locations.length === 0) {
@@ -301,6 +319,7 @@ async function triggerRunAll(opts) {
301
319
  } catch (err) {
302
320
  const msg = describeError(err);
303
321
  results.push({ project: p.name, runId: "", status: "error", location: null, error: msg });
322
+ notStartedProjects.push({ project: p.name, code: errorCodeFor(err), exitCode: exitCodeFor(err), error: msg });
304
323
  }
305
324
  }
306
325
  const errors = /* @__PURE__ */ new Map();
@@ -320,10 +339,11 @@ async function triggerRunAll(opts) {
320
339
  if (showProgress) process.stderr.write("\n");
321
340
  }
322
341
  }
323
- const waited = results.filter((r) => r.runId).map((r) => ({ runId: r.runId, status: r.status, project: r.project, location: r.location, error: errors.get(r.runId) }));
342
+ const waited = opts?.wait ? results.filter((r) => r.runId).map((r) => ({ runId: r.runId, status: r.status, project: r.project, location: r.location, error: errors.get(r.runId) })) : null;
343
+ const notStarted = { projectCount: projects.length, projects: notStartedProjects };
324
344
  if (isMachineFormat(opts?.format)) {
325
345
  console.log(JSON.stringify(results, null, 2));
326
- if (opts?.wait) throwIfWaitedRunFailed(waited);
346
+ throwIfRunAllFailed(notStarted, waited);
327
347
  return;
328
348
  }
329
349
  const showLocationColumn = results.some((r) => r.location !== null);
@@ -353,7 +373,7 @@ async function triggerRunAll(opts) {
353
373
  const waiting = batchWaits.get(r.runId);
354
374
  if (waiting) console.log(` ${r.location ? `${r.project} (${r.location})` : r.project}: ${waiting}`);
355
375
  }
356
- if (opts?.wait) throwIfWaitedRunFailed(waited);
376
+ throwIfRunAllFailed(notStarted, waited);
357
377
  }
358
378
  async function cancelRun(project, runId, format) {
359
379
  const client = getClient();
@@ -445,7 +465,7 @@ async function pollRun(client, runId, showProgress = true) {
445
465
  for (; ; ) {
446
466
  await new Promise((r) => setTimeout(r, 2e3));
447
467
  if (Date.now() > deadline) {
448
- throw new Error(`Timed out waiting for run ${runId} after ${POLL_TIMEOUT_MS / 1e3}s`);
468
+ throw systemError(`Timed out waiting for run ${runId} after ${POLL_TIMEOUT_MS / 1e3}s`, { details: { runId } });
449
469
  }
450
470
  const run = await client.getRun(runId);
451
471
  if (showProgress) process.stderr.write(".");
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  loadConfig
3
- } from "./chunk-52J7GFCK.js";
3
+ } from "./chunk-T6CABZ3N.js";
4
4
  import {
5
5
  PACKAGE_VERSION
6
6
  } from "./chunk-AOJU5LKX.js";
@@ -8,7 +8,7 @@ import {
8
8
  CliError,
9
9
  EXIT_SYSTEM_ERROR,
10
10
  EXIT_USER_ERROR
11
- } from "./chunk-QRIKJT6Y.js";
11
+ } from "./chunk-Y7JEJNNS.js";
12
12
  import {
13
13
  CANONRY_NPM_PACKAGE_URL,
14
14
  OPERATIONAL_LOG_FIELDS_HEADER,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CliError
3
- } from "./chunk-QRIKJT6Y.js";
3
+ } from "./chunk-Y7JEJNNS.js";
4
4
  import {
5
5
  AGENT_PROVIDER_IDS,
6
6
  AgentProviderIds,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createApiClient
3
- } from "./chunk-KQQERQJ2.js";
3
+ } from "./chunk-RSB3X7UR.js";
4
4
  import {
5
5
  isMachineFormat
6
- } from "./chunk-QRIKJT6Y.js";
6
+ } from "./chunk-Y7JEJNNS.js";
7
7
  import {
8
8
  formatRunErrorOneLine
9
9
  } from "./chunk-FGEBFVHB.js";
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  runWithUsageTags
3
- } from "./chunk-KQQERQJ2.js";
3
+ } from "./chunk-RSB3X7UR.js";
4
4
  import {
5
5
  CanonryMcpToolNames,
6
6
  DEPRECATED_MCP_TOOL_ALIAS_NAMES,
7
7
  canonryMcpTools
8
- } from "./chunk-S6X3HHSN.js";
8
+ } from "./chunk-IPUZGRSN.js";
9
9
  import {
10
10
  CliError
11
- } from "./chunk-QRIKJT6Y.js";
11
+ } from "./chunk-Y7JEJNNS.js";
12
12
  import {
13
13
  buildOpenApiDocument
14
14
  } from "./chunk-HMCDVKHS.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  usageError
3
- } from "./chunk-QRIKJT6Y.js";
3
+ } from "./chunk-Y7JEJNNS.js";
4
4
  import {
5
5
  AppError,
6
6
  parseWindowIn,
@@ -1,5 +1,7 @@
1
1
  import {
2
- CANONRY_COMMUNITY_LINKS
2
+ AppError,
3
+ CANONRY_COMMUNITY_LINKS,
4
+ formatValidationIssues
3
5
  } from "./chunk-FGEBFVHB.js";
4
6
 
5
7
  // src/cli-error.ts
@@ -31,6 +33,17 @@ function usageError(displayMessage, options) {
31
33
  details: options?.details
32
34
  });
33
35
  }
36
+ function parseCliInput(schema, input, what, details) {
37
+ const parsed = schema.safeParse(input);
38
+ if (parsed.success) return parsed.data;
39
+ const { issues } = parsed.error;
40
+ throw new CliError({
41
+ code: "VALIDATION_ERROR",
42
+ message: `${what} is not valid: ${formatValidationIssues(issues)}`,
43
+ // The MCP envelope's shape for the same refusal (`mcp/results.ts`).
44
+ details: { ...details, issues: issues.map((issue) => ({ path: issue.path.map(String).join("."), message: issue.message })) }
45
+ });
46
+ }
34
47
  function isEndpointMissing(err) {
35
48
  if (!(err instanceof CliError)) return false;
36
49
  const status = err.details?.httpStatus;
@@ -45,9 +58,21 @@ function systemError(message, options) {
45
58
  exitCode: EXIT_SYSTEM_ERROR
46
59
  });
47
60
  }
61
+ function exitCodeFor(err) {
62
+ if (err instanceof CliError) return err.exitCode;
63
+ if (err instanceof AppError) return err.statusCode < 500 ? EXIT_USER_ERROR : EXIT_SYSTEM_ERROR;
64
+ return EXIT_SYSTEM_ERROR;
65
+ }
66
+ function errorCodeFor(err) {
67
+ return err instanceof CliError || err instanceof AppError ? err.code : "CLI_ERROR";
68
+ }
69
+ function mostSevereExitCode(codes) {
70
+ for (const code of codes) if (code === EXIT_SYSTEM_ERROR) return EXIT_SYSTEM_ERROR;
71
+ return EXIT_USER_ERROR;
72
+ }
48
73
  function printCliError(err, format) {
49
74
  if (isMachineFormat(format)) {
50
- const envelope = err instanceof CliError ? { error: { code: err.code, message: err.message, ...err.details ? { details: err.details } : {} } } : { error: { code: "CLI_ERROR", message: err instanceof Error ? err.message : "An unexpected error occurred" } };
75
+ const envelope = err instanceof CliError || err instanceof AppError ? { error: { code: errorCodeFor(err), message: err.message, ...err.details ? { details: err.details } : {} } } : { error: { code: errorCodeFor(err), message: err instanceof Error ? err.message : "An unexpected error occurred" } };
51
76
  console.error(JSON.stringify(envelope, null, format === "jsonl" ? 0 : 2));
52
77
  return;
53
78
  }
@@ -58,7 +83,7 @@ function printCliError(err, format) {
58
83
  } else {
59
84
  console.error("An unexpected error occurred");
60
85
  }
61
- const unexpected = !(err instanceof CliError) || err.exitCode === EXIT_SYSTEM_ERROR;
86
+ const unexpected = exitCodeFor(err) === EXIT_SYSTEM_ERROR;
62
87
  if (unexpected && process.stderr.isTTY) {
63
88
  console.error(`
64
89
  Need help? Run 'canonry support' or ask in the Canonry Discord: ${CANONRY_COMMUNITY_LINKS.discord}`);
@@ -71,7 +96,11 @@ export {
71
96
  EXIT_SYSTEM_ERROR,
72
97
  CliError,
73
98
  usageError,
99
+ parseCliInput,
74
100
  isEndpointMissing,
75
101
  systemError,
102
+ exitCodeFor,
103
+ errorCodeFor,
104
+ mostSevereExitCode,
76
105
  printCliError
77
106
  };
@@ -11,11 +11,11 @@ import {
11
11
  } from "./chunk-CBREBUUV.js";
12
12
  import {
13
13
  loadConfig
14
- } from "./chunk-52J7GFCK.js";
14
+ } from "./chunk-T6CABZ3N.js";
15
15
  import {
16
16
  CliError,
17
17
  isMachineFormat
18
- } from "./chunk-QRIKJT6Y.js";
18
+ } from "./chunk-Y7JEJNNS.js";
19
19
  import {
20
20
  determineCitationState
21
21
  } from "./chunk-LJ65QBRP.js";
@@ -51,6 +51,7 @@ import {
51
51
  effectiveDomains,
52
52
  extractRecommendedCompetitors,
53
53
  normalizeUrlPath,
54
+ notFound,
54
55
  openRouterRouteModel
55
56
  } from "./chunk-FGEBFVHB.js";
56
57
 
@@ -591,7 +592,7 @@ async function backfillSnapshotAttributionCommand(opts) {
591
592
  migrate(db);
592
593
  const project = db.select().from(projects).where(eq(projects.name, opts.project)).get();
593
594
  if (!project) {
594
- throw new Error(`Project "${opts.project}" not found`);
595
+ throw notFound("Project", opts.project);
595
596
  }
596
597
  const isJson = isMachineFormat(opts.format);
597
598
  const isDryRun = opts.dryRun === true;
@@ -6,16 +6,18 @@ import {
6
6
  } from "./chunk-QHQZ2226.js";
7
7
  import {
8
8
  createApiClient
9
- } from "./chunk-KQQERQJ2.js";
10
- import "./chunk-52J7GFCK.js";
9
+ } from "./chunk-RSB3X7UR.js";
10
+ import "./chunk-T6CABZ3N.js";
11
11
  import {
12
12
  emitJsonl
13
13
  } from "./chunk-Z7IUAJOF.js";
14
14
  import "./chunk-AOJU5LKX.js";
15
15
  import {
16
16
  isMachineFormat
17
- } from "./chunk-QRIKJT6Y.js";
18
- import "./chunk-FGEBFVHB.js";
17
+ } from "./chunk-Y7JEJNNS.js";
18
+ import {
19
+ shellQuote
20
+ } from "./chunk-FGEBFVHB.js";
19
21
 
20
22
  // src/commands/citations.ts
21
23
  async function showCitationVisibility(project, opts) {
@@ -27,7 +29,7 @@ async function showCitationVisibility(project, opts) {
27
29
  }
28
30
  if (data.status === "no-data") {
29
31
  if (data.reason === "no-queries") {
30
- console.log("No queries configured. Add some with `canonry query add`.");
32
+ console.log(`No queries configured. Add some with \`canonry query add ${shellQuote(project)} <query>\`.`);
31
33
  } else {
32
34
  console.log("No citation data yet \u2014 run a sweep first (canonry run <project>).");
33
35
  }
@@ -3,10 +3,10 @@ import {
3
3
  buildCliCatalog,
4
4
  printCliCatalog,
5
5
  renderTopLevelHelp
6
- } from "./chunk-MQFH765X.js";
7
- import "./chunk-ZHWJJVCT.js";
6
+ } from "./chunk-P4ETUNQR.js";
7
+ import "./chunk-X3ES2XOJ.js";
8
8
  import "./chunk-Z7IUAJOF.js";
9
- import "./chunk-QRIKJT6Y.js";
9
+ import "./chunk-Y7JEJNNS.js";
10
10
  import "./chunk-FGEBFVHB.js";
11
11
  export {
12
12
  CLI_ROOT_SUMMARIES,
@@ -1,17 +1,18 @@
1
1
  import {
2
2
  REGISTERED_CLI_COMMANDS
3
- } from "./chunk-M3BKRPB7.js";
3
+ } from "./chunk-63FHJJUO.js";
4
4
  import "./chunk-6GO5VVAC.js";
5
5
  import "./chunk-VJWDBFSL.js";
6
- import "./chunk-MARIMDMX.js";
6
+ import "./chunk-3LXRY57V.js";
7
+ import "./chunk-APKBR2BP.js";
7
8
  import "./chunk-TSENU4GG.js";
8
- import "./chunk-KQQERQJ2.js";
9
- import "./chunk-52J7GFCK.js";
10
- import "./chunk-ZHWJJVCT.js";
9
+ import "./chunk-RSB3X7UR.js";
10
+ import "./chunk-T6CABZ3N.js";
11
+ import "./chunk-X3ES2XOJ.js";
11
12
  import "./chunk-Z7IUAJOF.js";
12
13
  import "./chunk-ZHXPH7WB.js";
13
14
  import "./chunk-AOJU5LKX.js";
14
- import "./chunk-QRIKJT6Y.js";
15
+ import "./chunk-Y7JEJNNS.js";
15
16
  import "./chunk-FGEBFVHB.js";
16
17
  export {
17
18
  REGISTERED_CLI_COMMANDS