@wirecat/cli-core 0.642.0 → 0.643.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 (258) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/dist/attachments/ocr.js +27 -18
  3. package/dist/attachments/picture-reading.d.ts +51 -0
  4. package/dist/attachments/picture-reading.js +207 -0
  5. package/dist/background/backfill.d.ts +4 -2
  6. package/dist/background/backfill.js +3 -3
  7. package/dist/background/schedules.d.ts +23 -1
  8. package/dist/background/schedules.js +45 -17
  9. package/dist/background/units.d.ts +2 -0
  10. package/dist/background/units.js +8 -9
  11. package/dist/calendar/cli/index.js +10 -2
  12. package/dist/calendar/feeds.js +2 -2
  13. package/dist/calendar/server-search.js +2 -2
  14. package/dist/calendar/source.d.ts +4 -3
  15. package/dist/calendar/sync.js +12 -10
  16. package/dist/calendar/testing/source-contract.js +5 -4
  17. package/dist/calendar/testing/source.js +3 -2
  18. package/dist/cli/complete-command.d.ts +23 -0
  19. package/dist/cli/complete-command.js +80 -0
  20. package/dist/cli/context.js +7 -1
  21. package/dist/cli/effects.d.ts +2 -0
  22. package/dist/cli/effects.js +2 -0
  23. package/dist/cli/envelope.js +6 -1
  24. package/dist/cli/help/first-screen.js +5 -0
  25. package/dist/cli/index.d.ts +4 -2
  26. package/dist/cli/index.js +2 -1
  27. package/dist/cli/list-query.d.ts +3 -1
  28. package/dist/cli/list-query.js +5 -3
  29. package/dist/cli/local-only-command.js +9 -0
  30. package/dist/cli/messenger/backfill-command.js +1 -1
  31. package/dist/cli/messenger/chat-queries.js +2 -1
  32. package/dist/cli/messenger/complete-command.d.ts +4 -7
  33. package/dist/cli/messenger/complete-command.js +31 -98
  34. package/dist/cli/messenger/contacts-command.js +4 -0
  35. package/dist/cli/messenger/guard-commands.js +1 -1
  36. package/dist/cli/messenger/images-command.js +32 -0
  37. package/dist/cli/messenger/list-result-queries.d.ts +1 -0
  38. package/dist/cli/messenger/list-result-queries.js +2 -1
  39. package/dist/cli/messenger/mentions-command.js +3 -3
  40. package/dist/cli/messenger/message-items.js +1 -0
  41. package/dist/cli/messenger/messages-command.js +7 -6
  42. package/dist/cli/messenger/people-queries.d.ts +2 -2
  43. package/dist/cli/messenger/people-queries.js +4 -4
  44. package/dist/cli/messenger/search-answers.js +2 -2
  45. package/dist/cli/messenger/search-command.js +3 -3
  46. package/dist/cli/messenger/searches-command.js +1 -1
  47. package/dist/cli/messenger/store-maintenance-command.js +4 -0
  48. package/dist/cli/messenger/tasks-analysis-command.js +1 -1
  49. package/dist/cli/messenger/tasks-command.js +2 -2
  50. package/dist/cli/model-catalogue-command.js +2 -0
  51. package/dist/cli/picture-reading-command.d.ts +12 -0
  52. package/dist/cli/picture-reading-command.js +82 -0
  53. package/dist/cli/program.d.ts +6 -0
  54. package/dist/cli/program.js +28 -2
  55. package/dist/cli/schedule/agent-start.d.ts +23 -0
  56. package/dist/cli/schedule/agent-start.js +115 -0
  57. package/dist/cli/schedule/harnesses.d.ts +203 -0
  58. package/dist/cli/schedule/harnesses.js +278 -0
  59. package/dist/cli/schedule/schedule-command.d.ts +9 -5
  60. package/dist/cli/schedule/schedule-command.js +89 -79
  61. package/dist/cli/shared-command-exports.d.ts +186 -0
  62. package/dist/cli/shared-command-exports.js +2 -0
  63. package/dist/cli/untrusted-marks.d.ts +25 -0
  64. package/dist/cli/untrusted-marks.js +102 -0
  65. package/dist/crm/cli/index.d.ts +1 -0
  66. package/dist/crm/cli/index.js +6 -5
  67. package/dist/crm/cli/store.d.ts +30 -0
  68. package/dist/crm/cli/store.js +63 -0
  69. package/dist/crm/source.d.ts +6 -4
  70. package/dist/crm/sync.js +10 -6
  71. package/dist/crm/testing/source-contract.js +9 -7
  72. package/dist/crm/testing/source.js +6 -2
  73. package/dist/crm/testing/sync-contract.js +4 -4
  74. package/dist/crm/writes.d.ts +5 -2
  75. package/dist/crm/writes.js +1 -1
  76. package/dist/documents.d.ts +1 -0
  77. package/dist/documents.js +1 -0
  78. package/dist/domain/addresses.d.ts +2 -0
  79. package/dist/domain/addresses.js +7 -0
  80. package/dist/domain/attachments.d.ts +2 -0
  81. package/dist/domain/attachments.js +2 -1
  82. package/dist/domain/models.d.ts +2 -0
  83. package/dist/entities/attachment-results.d.ts +3 -0
  84. package/dist/entities/attachment-results.js +3 -0
  85. package/dist/entities/attachment.d.ts +2 -0
  86. package/dist/entities/attachment.js +8 -1
  87. package/dist/entities/hit.d.ts +1 -0
  88. package/dist/entities/index.d.ts +21 -4
  89. package/dist/entities/index.js +3 -2
  90. package/dist/entities/list-results.d.ts +33 -5
  91. package/dist/entities/list-results.js +33 -5
  92. package/dist/errors/reasons.js +30 -1
  93. package/dist/mail/cli/index.js +7 -6
  94. package/dist/mcp/agent.d.ts +2 -1
  95. package/dist/mcp/agent.js +5 -0
  96. package/dist/mcp/app-server.js +10 -0
  97. package/dist/mcp/surface.d.ts +7 -2
  98. package/dist/mcp/surface.js +49 -10
  99. package/dist/meetings/cli/index.js +6 -1
  100. package/dist/meetings/mcp/index.d.ts +15 -15
  101. package/dist/meetings/mcp/index.js +6 -3
  102. package/dist/meetings/participant-search.d.ts +2 -2
  103. package/dist/meetings/project-discovery.d.ts +1 -1
  104. package/dist/meetings/project-evidence-answer.js +2 -2
  105. package/dist/meetings/reads.d.ts +2 -2
  106. package/dist/meetings/reads.js +6 -6
  107. package/dist/meetings/store.d.ts +2 -1
  108. package/dist/meetings/testing/contract.js +6 -6
  109. package/dist/meetings/testing/memory.js +7 -2
  110. package/dist/models/ai.d.ts +1 -1
  111. package/dist/models/ai.js +3 -1
  112. package/dist/models/anthropic.js +15 -9
  113. package/dist/models/index.js +5 -3
  114. package/dist/models/openai.js +24 -11
  115. package/dist/models/types.d.ts +8 -0
  116. package/dist/models/types.js +11 -1
  117. package/dist/ports/app.d.ts +17 -1
  118. package/dist/ports/app.js +63 -3
  119. package/dist/search/lucene/plain.js +45 -3
  120. package/dist/search/lucene/registry.d.ts +15 -4
  121. package/dist/search/lucene/registry.js +70 -12
  122. package/dist/search/lucene/types.d.ts +2 -0
  123. package/dist/search/lucene/types.js +12 -0
  124. package/dist/sends/upload.d.ts +8 -1
  125. package/dist/sends/upload.js +35 -14
  126. package/dist/services/account-groups.d.ts +11 -0
  127. package/dist/services/account-groups.js +29 -0
  128. package/dist/services/agenda.js +1 -0
  129. package/dist/services/attachments.d.ts +18 -4
  130. package/dist/services/attachments.js +66 -15
  131. package/dist/services/conversations.d.ts +2 -4
  132. package/dist/services/conversations.js +1 -1
  133. package/dist/services/deal-context.js +5 -5
  134. package/dist/services/documents/ingestion.js +3 -3
  135. package/dist/services/documents/knowledge.d.ts +6 -6
  136. package/dist/services/documents/knowledge.js +1 -2
  137. package/dist/services/events-search.d.ts +3 -3
  138. package/dist/services/events-search.js +7 -7
  139. package/dist/services/index.d.ts +1 -1
  140. package/dist/services/index.js +1 -1
  141. package/dist/services/meeting-project-discovery.js +1 -1
  142. package/dist/services/message-resolution.js +10 -3
  143. package/dist/services/messages-search.js +6 -4
  144. package/dist/services/metadata.d.ts +1 -1
  145. package/dist/services/notes-search.d.ts +3 -3
  146. package/dist/services/notes-search.js +3 -3
  147. package/dist/services/organization-context.js +12 -9
  148. package/dist/services/people.d.ts +2 -0
  149. package/dist/services/people.js +4 -2
  150. package/dist/services/pictures.d.ts +9 -0
  151. package/dist/services/pictures.js +34 -28
  152. package/dist/services/project-status/index.js +1 -1
  153. package/dist/services/project-status/signals/payments.js +4 -2
  154. package/dist/services/project-status/signals/promises.js +5 -2
  155. package/dist/services/proposals/kinds/action.js +1 -1
  156. package/dist/services/proposals/kinds/fact.js +1 -1
  157. package/dist/services/proposals/kinds/findings.d.ts +2 -1
  158. package/dist/services/proposals/kinds/findings.js +12 -5
  159. package/dist/services/proposals/kinds/identity-link.js +1 -1
  160. package/dist/services/proposals/kinds/identity-split.js +1 -1
  161. package/dist/services/proposals/kinds/key-document.js +1 -1
  162. package/dist/services/proposals/kinds/mail-findings.d.ts +1 -1
  163. package/dist/services/proposals/kinds/mail-findings.js +11 -5
  164. package/dist/services/proposals/kinds/meeting-findings.js +10 -4
  165. package/dist/services/proposals/kinds/memory.js +1 -1
  166. package/dist/services/proposals/kinds/organization.js +1 -1
  167. package/dist/services/proposals/kinds/relationship-update.js +1 -1
  168. package/dist/services/proposals/kinds/relationship.js +1 -1
  169. package/dist/services/proposals/kinds/shared.d.ts +3 -2
  170. package/dist/services/proposals/kinds/shared.js +4 -4
  171. package/dist/services/proposals/kinds/source-review.js +1 -1
  172. package/dist/services/proposals/kinds/task-close.js +2 -2
  173. package/dist/services/proposals/registry.js +1 -1
  174. package/dist/services/proposals/types.d.ts +2 -1
  175. package/dist/services/search-all-business.js +3 -4
  176. package/dist/services/search-all.js +13 -14
  177. package/dist/services/searches.d.ts +2 -4
  178. package/dist/services/searches.js +1 -4
  179. package/dist/services/stored-project-gathering.js +6 -1
  180. package/dist/services/tags.d.ts +2 -4
  181. package/dist/services/tags.js +1 -1
  182. package/dist/services/tasks.d.ts +1 -1
  183. package/dist/services/tasks.js +4 -3
  184. package/dist/store/account-store.d.ts +2 -1
  185. package/dist/store/account-store.js +3 -1
  186. package/dist/store/accounts.d.ts +2 -0
  187. package/dist/store/accounts.js +8 -0
  188. package/dist/store/chats.d.ts +5 -0
  189. package/dist/store/chats.js +4 -0
  190. package/dist/store/evidence-findings.d.ts +9 -0
  191. package/dist/store/exports.d.ts +1 -1
  192. package/dist/store/exports.js +1 -1
  193. package/dist/store/identity-links.d.ts +3 -1
  194. package/dist/store/mail-findings.d.ts +9 -0
  195. package/dist/store/meeting-findings.d.ts +9 -0
  196. package/dist/store/searches.d.ts +3 -2
  197. package/dist/store/sqlite/accounts.js +37 -0
  198. package/dist/store/sqlite/agent-actions.d.ts +2 -1
  199. package/dist/store/sqlite/agent-actions.js +10 -4
  200. package/dist/store/sqlite/business-contracts.d.ts +3 -1
  201. package/dist/store/sqlite/business-contracts.js +7 -3
  202. package/dist/store/sqlite/business-search.d.ts +2 -1
  203. package/dist/store/sqlite/business-search.js +6 -4
  204. package/dist/store/sqlite/deals.d.ts +6 -4
  205. package/dist/store/sqlite/deals.js +12 -7
  206. package/dist/store/sqlite/evidence-findings.js +78 -9
  207. package/dist/store/sqlite/facts.d.ts +2 -1
  208. package/dist/store/sqlite/facts.js +6 -2
  209. package/dist/store/sqlite/finance.d.ts +4 -2
  210. package/dist/store/sqlite/finance.js +13 -6
  211. package/dist/store/sqlite/findings-core.d.ts +56 -2
  212. package/dist/store/sqlite/findings-core.js +109 -22
  213. package/dist/store/sqlite/identities.d.ts +4 -0
  214. package/dist/store/sqlite/identities.js +12 -3
  215. package/dist/store/sqlite/identity-proposals.js +34 -4
  216. package/dist/store/sqlite/lucene-fields.d.ts +2 -0
  217. package/dist/store/sqlite/lucene-fields.js +28 -2
  218. package/dist/store/sqlite/lucene.js +21 -10
  219. package/dist/store/sqlite/mail-findings.js +60 -22
  220. package/dist/store/sqlite/meeting-findings.js +53 -7
  221. package/dist/store/sqlite/meeting-participant-search.js +4 -5
  222. package/dist/store/sqlite/meetings.js +7 -3
  223. package/dist/store/sqlite/memories.d.ts +4 -2
  224. package/dist/store/sqlite/memories.js +13 -6
  225. package/dist/store/sqlite/money-transactions.d.ts +3 -1
  226. package/dist/store/sqlite/money-transactions.js +7 -3
  227. package/dist/store/sqlite/name-traces.d.ts +3 -3
  228. package/dist/store/sqlite/name-traces.js +29 -2
  229. package/dist/store/sqlite/orders.d.ts +3 -1
  230. package/dist/store/sqlite/orders.js +5 -2
  231. package/dist/store/sqlite/people-list.js +67 -22
  232. package/dist/store/sqlite/person-match-scan.d.ts +3 -1
  233. package/dist/store/sqlite/person-match-scan.js +97 -7
  234. package/dist/store/sqlite/products.d.ts +3 -1
  235. package/dist/store/sqlite/products.js +5 -2
  236. package/dist/store/sqlite/proposed-actions.d.ts +2 -1
  237. package/dist/store/sqlite/proposed-actions.js +7 -3
  238. package/dist/store/sqlite/query-filter.d.ts +4 -0
  239. package/dist/store/sqlite/query-filter.js +14 -0
  240. package/dist/store/sqlite/reads.d.ts +1 -0
  241. package/dist/store/sqlite/reads.js +14 -0
  242. package/dist/store/sqlite/records.d.ts +3 -1
  243. package/dist/store/sqlite/records.js +7 -5
  244. package/dist/store/sqlite/rows-page.d.ts +3 -0
  245. package/dist/store/sqlite/rows-page.js +4 -0
  246. package/dist/store/sqlite/searches.d.ts +2 -1
  247. package/dist/store/sqlite/searches.js +3 -1
  248. package/dist/store/sqlite/subscriptions.d.ts +5 -2
  249. package/dist/store/sqlite/subscriptions.js +13 -6
  250. package/dist/store/sqlite/task-board.js +27 -0
  251. package/dist/store/sqlite/task-find.d.ts +15 -0
  252. package/dist/store/sqlite/task-find.js +1 -0
  253. package/dist/store/sqlite/wallets.d.ts +3 -1
  254. package/dist/store/sqlite/wallets.js +7 -3
  255. package/dist/store/sqlite/work-tasks.d.ts +3 -11
  256. package/dist/store/sqlite/work-tasks.js +8 -4
  257. package/package.json +2 -2
  258. package/parity.json +24 -0
@@ -1,7 +1,8 @@
1
1
  import { spawn } from "node:child_process";
2
- import { createHash } from "node:crypto";
3
- import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
- import { basename, join } from "node:path";
2
+ import { createHash, randomBytes } from "node:crypto";
3
+ import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync, } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { basename, dirname, join, relative } from "node:path";
5
6
  import { CliError, errorCodes, writeSecurely } from "@wirecat/cli-base";
6
7
  import { linkConfigOf, linkFor } from "../domain/links.js";
7
8
  import { mailHolderVariable, readOnlyLockOf } from "../ports/app.js";
@@ -14,6 +15,10 @@ import { causeOf, gapsView, noticeView, weeklyGapsOf } from "./report/messages.j
14
15
  import { prepareMessage, prepareReport, } from "./report/render.js";
15
16
  export { launchdTimer, systemdTimer, timerFor, windowsTimer } from "./timers.js";
16
17
  export { calendarOf, describeWhen, isCalendar, nextRun, previousRun, runsBetween, slotsOf, WEEKDAYS, } from "./when.js";
18
+ /** Stands for an agent run's own work folder in its harness's variables and files; the run puts the real path in. */
19
+ export const WORK_FOLDER = "{wirecat-work-folder}";
20
+ /** Stands for the run's own mark in an agent's prompt, which the CLIs put around other people's text in that run. */
21
+ export const UNTRUSTED_MARK = "{wirecat-untrusted-mark}";
17
22
  export const NOTIFY_WHEN = ["always", "failures", "never"];
18
23
  /** A repeating agent would otherwise notify on every tick; any other schedule runs rarely enough to say each result. */
19
24
  export const notifyOf = (schedule) => schedule.notify ?? (schedule.kind === "agent" && "every" in schedule.when ? "failures" : "always");
@@ -38,7 +43,7 @@ const addSpend = (folder, usd, at) => {
38
43
  };
39
44
  /**
40
45
  * Claude reports a run's cost only in its JSON answer, so a scheduled claude run asks for it; the report kept is the
41
- * answer's text. Codex reports none.
46
+ * answer's text. No other agent reports one.
42
47
  */
43
48
  const priced = (argv) => {
44
49
  const [program = ""] = argv;
@@ -47,6 +52,7 @@ const priced = (argv) => {
47
52
  ? [...argv, "--output-format", "json"]
48
53
  : argv;
49
54
  };
55
+ /** `failed`: claude answered an error, such as no credit left, which it may do with exit 0. */
50
56
  const reportOf = (stdout) => {
51
57
  try {
52
58
  const answer = JSON.parse(stdout.toString("utf8"));
@@ -55,6 +61,7 @@ const reportOf = (stdout) => {
55
61
  return {
56
62
  text: typeof answer.result === "string" ? Buffer.from(answer.result) : stdout,
57
63
  ...(typeof answer.total_cost_usd === "number" ? { costUsd: answer.total_cost_usd } : {}),
64
+ ...(answer.is_error === true ? { failed: true } : {}),
58
65
  };
59
66
  }
60
67
  catch {
@@ -72,6 +79,7 @@ export const SKIP_REASONS = {
72
79
  mailNone: "mail.none-new",
73
80
  mailBelowThreshold: "mail.below-threshold",
74
81
  mailSameInput: "mail.same-input",
82
+ agentRefused: "agent.refused",
75
83
  };
76
84
  const REASON_ID = /^[a-z0-9][a-z0-9.-]{0,79}$/;
77
85
  /**
@@ -313,8 +321,8 @@ const pause = (ms, signal) => new Promise((resolve) => {
313
321
  * 12 hours. A run the provider asked to wait (`rate_limited` with `retry.after_ms`, up to 6 hours) waits that long
314
322
  * and runs once more. A schedule that repeats every few minutes is left to its next tick; a run by hand fails at once.
315
323
  */
316
- export const runSchedule = async (app, system, env, file, { now = () => new Date(), timer, signal, killAfterMs = KILL_AFTER_MS, untilUnlocked = false, wait = pause, agentRuns = [], agentInput, ownerLanguage = async () => "ru", reportTemplates, skipRepeatedInput = false, routes: chosen, } = {}) => {
317
- const schedule = readSchedule(file);
324
+ export const runSchedule = async (app, system, env, file, { now = () => new Date(), timer, signal, killAfterMs = KILL_AFTER_MS, untilUnlocked = false, wait = pause, agentRuns = [], agentInput, ownerLanguage = async () => "ru", reportTemplates, skipRepeatedInput = false, routes: chosen, schedule: checked, } = {}) => {
325
+ const schedule = checked ?? readSchedule(file);
318
326
  const folder = join(file, "..");
319
327
  const runs = join(folder, "runs");
320
328
  mkdirSync(runs, { recursive: true, mode: 0o700 });
@@ -527,22 +535,29 @@ export const attemptSchedule = async (app, system, env, schedule, folder, { now,
527
535
  const agent = schedule.kind === "agent";
528
536
  const output = join(runs, `${stamp}.${agent ? "md" : "log"}`);
529
537
  const errors = agent ? join(runs, `${stamp}.log`) : output;
530
- const [program = "", ...args] = agent ? priced(schedule.argv) : [...system.entry, ...schedule.argv];
531
538
  const trace = childTrace();
539
+ // An agent works in an empty folder of its own: one that could write where it runs never reaches its schedule file.
540
+ const work = agent ? mkdtempSync(join(tmpdir(), "wirecat-agent-")) : folder;
541
+ const mark = randomBytes(8).toString("hex");
542
+ const inWork = (text) => text.replaceAll(WORK_FOLDER, work).replaceAll(UNTRUSTED_MARK, mark);
543
+ const [program = "", ...args] = agent ? priced(schedule.argv).map(inWork) : [...system.entry, ...schedule.argv];
544
+ const agentOnly = (one) => [
545
+ [`${one.envPrefix}_READ_ONLY`, "1"],
546
+ [`${one.envPrefix}_SCHEDULED`, schedule.name],
547
+ [`${one.envPrefix}_WORK_FOLDER`, work],
548
+ [`${one.envPrefix}_UNTRUSTED_MARK`, mark],
549
+ ];
532
550
  const childEnv = {
533
551
  ...env,
534
- ...schedule.environment,
552
+ ...(agent
553
+ ? Object.fromEntries(Object.entries(schedule.environment).map(([name, value]) => [name, inWork(value)]))
554
+ : schedule.environment),
535
555
  TRACEPARENT: trace.traceparent,
536
556
  [`${app.envPrefix}_SCHEDULED`]: schedule.name,
537
557
  ...(schedule.onNewMail ? { [mailHolderVariable(app)]: schedule.onNewMail } : {}),
538
558
  // A run started under the lock stays under it, whatever the schedule file says.
539
559
  ...(agent || readOnlyLockOf(app, env) ? { [`${app.envPrefix}_READ_ONLY`]: "1" } : {}),
540
- ...(agent
541
- ? Object.fromEntries(agentRuns.flatMap((other) => [
542
- [`${other.envPrefix}_READ_ONLY`, "1"],
543
- [`${other.envPrefix}_SCHEDULED`, schedule.name],
544
- ]))
545
- : {}),
560
+ ...(agent ? Object.fromEntries([app, ...agentRuns].flatMap(agentOnly)) : {}),
546
561
  };
547
562
  // The child's output is data, and an agent's is another program's: it is kept as it came. These lines say
548
563
  // only when it ran and how it ended.
@@ -556,11 +571,20 @@ export const attemptSchedule = async (app, system, env, schedule, folder, { now,
556
571
  if (before?.exitCode === 0 && before.inputHash === inputHash) {
557
572
  // A skip every few minutes would otherwise push the kept runs' files out of runs/.
558
573
  rmSync(join(runs, `${stamp}.jsonl`), { force: true });
574
+ if (agent)
575
+ rmSync(work, { recursive: true, force: true });
559
576
  return { repeated: before };
560
577
  }
578
+ for (const [path, body] of Object.entries(agent ? (schedule.files ?? {}) : {})) {
579
+ const file = join(work, path);
580
+ if (relative(work, file).startsWith(".."))
581
+ continue;
582
+ mkdirSync(dirname(file), { recursive: true });
583
+ writeFileSync(file, inWork(body), { mode: 0o600 });
584
+ }
561
585
  let costUsd;
562
586
  const exitCode = await new Promise((resolve) => {
563
- const child = spawn(program, args, { env: childEnv, cwd: folder, stdio: ["pipe", "pipe", "pipe"] });
587
+ const child = spawn(program, args, { env: childEnv, cwd: work, stdio: ["pipe", "pipe", "pipe"] });
564
588
  // An agent that stops reading its stdin may close it first; that is no failure of the run.
565
589
  child.stdin?.on("error", () => { });
566
590
  child.stdin?.end(input);
@@ -589,11 +613,15 @@ export const attemptSchedule = async (app, system, env, schedule, folder, { now,
589
613
  const report = agent ? reportOf(Buffer.concat(out)) : { text: Buffer.concat([...out, ...err]) };
590
614
  costUsd = report.costUsd;
591
615
  writeFileSync(output, report.text, { mode: 0o600 });
616
+ // The error is the agent's answer, so the log keeps it beside its stderr.
592
617
  if (agent)
593
- writeFileSync(errors, Buffer.concat(err), { mode: 0o600 });
594
- resolve(code ?? (killedBy === "SIGKILL" ? 137 : killedBy === "SIGTERM" ? 143 : 1));
618
+ writeFileSync(errors, Buffer.concat([...err, ...("failed" in report ? [report.text] : [])]), { mode: 0o600 });
619
+ const exited = code ?? (killedBy === "SIGKILL" ? 137 : killedBy === "SIGTERM" ? 143 : 1);
620
+ resolve("failed" in report && exited === 0 ? 1 : exited);
595
621
  });
596
622
  });
623
+ if (agent)
624
+ rmSync(work, { recursive: true, force: true });
597
625
  const ended = now();
598
626
  if (costUsd !== undefined)
599
627
  addSpend(folder, costUsd, ended);
@@ -22,6 +22,8 @@ export interface Unit {
22
22
  * development checkout must open that checkout's session and store, never the owner's real ones.
23
23
  * Nothing that could hold a credential is copied.
24
24
  */
25
+ /** The variables that move a CLI's files elsewhere. */
26
+ export declare const locationNames: (app: AppIdentity) => string[];
25
27
  export declare const locationVariables: (app: AppIdentity, env: NodeJS.ProcessEnv) => Record<string, string>;
26
28
  /**
27
29
  * A unit written with location variables runs another installation — a development checkout — so
@@ -7,15 +7,14 @@ import { CliError } from "@wirecat/cli-base";
7
7
  * development checkout must open that checkout's session and store, never the owner's real ones.
8
8
  * Nothing that could hold a credential is copied.
9
9
  */
10
- export const locationVariables = (app, env) => {
11
- const names = [
12
- ...["CONFIG_DIR", "STATE_DIR", "CACHE_DIR"].map((name) => `${app.envPrefix}_${name}`),
13
- "MESSAGING_STORE",
14
- "MESSAGING_STATE_DIR",
15
- "WIRECAT_STATE_DIR",
16
- ];
17
- return Object.fromEntries(names.flatMap((name) => (env[name] === undefined ? [] : [[name, env[name]]])));
18
- };
10
+ /** The variables that move a CLI's files elsewhere. */
11
+ export const locationNames = (app) => [
12
+ ...["CONFIG_DIR", "STATE_DIR", "CACHE_DIR"].map((name) => `${app.envPrefix}_${name}`),
13
+ "MESSAGING_STORE",
14
+ "MESSAGING_STATE_DIR",
15
+ "WIRECAT_STATE_DIR",
16
+ ];
17
+ export const locationVariables = (app, env) => Object.fromEntries(locationNames(app).flatMap((name) => (env[name] === undefined ? [] : [[name, env[name]]])));
19
18
  /**
20
19
  * A unit written with location variables runs another installation — a development checkout — so
21
20
  * its name says which: under the bare name, `server start` there drove the owner's real unit.
@@ -409,8 +409,16 @@ const addCalendarCommandsDefinition = (program, options) => {
409
409
  ...(opts.exact ? { exact: true } : {}),
410
410
  ...(opts.newest ? { newest: true } : {}),
411
411
  });
412
- if (!server)
413
- return hitsBody(command, { ...(await archived()), untrusted: SEARCH_UNTRUSTED });
412
+ if (!server) {
413
+ const { items, hasMore, nextOffset, ...found } = await archived();
414
+ return hitsBody(command, {
415
+ ...found,
416
+ hits: items,
417
+ has_more: hasMore,
418
+ ...(nextOffset === undefined ? {} : { next_offset: nextOffset }),
419
+ untrusted: SEARCH_UNTRUSTED,
420
+ });
421
+ }
414
422
  const served = await serverSearchAnswer(run.source(), run.store, {
415
423
  accountId: run.accountId,
416
424
  account: run.account,
@@ -292,7 +292,7 @@ export const icsFeeds = (options) => {
292
292
  if (got === "unchanged") {
293
293
  const [events, skipped] = [held?.events ?? 0, held?.skipped ?? 0];
294
294
  stats.set(calendar.id, { calendarId: calendar.id, events, skipped, unchanged: true });
295
- return { entries: [], removed: [], cursor, unchanged: true };
295
+ return { items: [], hasMore: false, removed: [], cursor, unchanged: true };
296
296
  }
297
297
  const { text, validators } = got;
298
298
  const found = readFeed(text, calendar.timezone ?? options.zone, window);
@@ -305,7 +305,7 @@ export const icsFeeds = (options) => {
305
305
  const next = validators.etag || validators.lastModified
306
306
  ? { v: 1, validators, window, events: found.events, skipped: found.skipped }
307
307
  : null;
308
- return { entries: found.entries, removed: [], cursor: next && JSON.stringify(next) };
308
+ return { items: found.entries, hasMore: false, removed: [], cursor: next && JSON.stringify(next) };
309
309
  },
310
310
  };
311
311
  return {
@@ -51,7 +51,7 @@ const groupOf = (eventId, eventSeriesId) => eventSeriesId !== null ? `s${eventSe
51
51
  */
52
52
  export const bothSearchAnswer = async (store, accountId, archived, served, limit) => {
53
53
  const calendars = new Map((await store.calendars(accountId)).map((calendar) => [calendar.externalId, calendar]));
54
- const hits = archived.hits.map((hit) => ({ ...hit }));
54
+ const hits = archived.items.map((hit) => ({ ...hit }));
55
55
  const byGroup = new Map();
56
56
  for (const hit of hits) {
57
57
  const details = await store.event(Number(hit.ref.slice("event:".length)));
@@ -76,6 +76,6 @@ export const bothSearchAnswer = async (store, accountId, archived, served, limit
76
76
  by: "both",
77
77
  ...(archived.meaning_skipped === undefined ? {} : { meaning_skipped: archived.meaning_skipped }),
78
78
  hits: merged.slice(0, limit),
79
- has_more: archived.has_more || served.has_more || merged.length > limit,
79
+ has_more: archived.hasMore || served.has_more || merged.length > limit,
80
80
  };
81
81
  };
@@ -20,14 +20,15 @@ export interface CalendarSourceTraits {
20
20
  fullListOnly: boolean;
21
21
  }
22
22
  export interface ChangePage {
23
- entries: EntryInput[];
23
+ items: EntryInput[];
24
24
  /**
25
25
  * Entries the provider confirmed deleted, known only by `externalId` (CalDAV 404; Graph `@removed` that a GET by id
26
26
  * answered 404). Never an entry that only left the window.
27
27
  */
28
28
  removed: string[];
29
- /** More pages in this round. */
30
- nextPage?: string;
29
+ /** More pages in this round, read from `nextCursor`. */
30
+ hasMore: boolean;
31
+ nextCursor?: string;
31
32
  /** On the last page: the cursor for the next run; `null` when the source has none. */
32
33
  cursor?: string | null;
33
34
  /**
@@ -198,16 +198,16 @@ const syncOne = async ({ source, store, calendar, window, now, expand, budget, s
198
198
  if (signal?.aborted)
199
199
  return "cancelled";
200
200
  const groups = [];
201
- const listed = page.entries.filter((entry) => entry.kind === "series" && entry.status !== "cancelled");
201
+ const listed = page.items.filter((entry) => entry.kind === "series" && entry.status !== "cancelled");
202
202
  const kept = new Set();
203
203
  if (source.traits.expands === "on-request")
204
204
  for (const entry of listed)
205
205
  if (await unchanged(entry))
206
206
  kept.add(entry.externalId);
207
- if (page.entries.length) {
208
- await store.saveEntries(calendar.id, page.entries, now);
209
- result.saved += page.entries.length;
210
- cursor = { ...cursor, done: cursor.done + page.entries.length };
207
+ if (page.items.length) {
208
+ await store.saveEntries(calendar.id, page.items, now);
209
+ result.saved += page.items.length;
210
+ cursor = { ...cursor, done: cursor.done + page.items.length };
211
211
  for (const entry of listed) {
212
212
  if (source.traits.expands === "local")
213
213
  groups.push({ series: entry.externalId, slots: await expand(entry, round.window) });
@@ -219,15 +219,17 @@ const syncOne = async ({ source, store, calendar, window, now, expand, budget, s
219
219
  }
220
220
  if (page.removed.length)
221
221
  result.removed += await store.removeEntries(calendar.id, page.removed, now);
222
- if (page.unchanged && source.traits.fullListOnly && page.entries.length === 0 && page.nextPage === undefined)
222
+ if (page.unchanged && source.traits.fullListOnly && page.items.length === 0 && !page.hasMore)
223
223
  round = { ...round, page: null, listed: true, next: page.cursor ?? null, unchanged: true };
224
- else if (page.nextPage === undefined)
224
+ else if (!page.hasMore)
225
225
  round = { ...round, page: null, listed: true, next: page.cursor ?? null };
226
226
  else {
227
- if (seen.has(page.nextPage))
227
+ if (page.nextCursor === undefined)
228
+ throw new CliError("invalid_response", `${source.provider} said there are more pages but gave no cursor`);
229
+ if (seen.has(page.nextCursor))
228
230
  throw new CliError("invalid_response", `${source.provider} returned the same page twice`);
229
- seen.add(page.nextPage);
230
- round = { ...round, page: page.nextPage };
231
+ seen.add(page.nextCursor);
232
+ round = { ...round, page: page.nextCursor };
231
233
  }
232
234
  await commit(groups);
233
235
  moved();
@@ -36,14 +36,15 @@ const round = async (source, calendar, cursor, window) => {
36
36
  const result = await source.changes(calendar, { cursor, window, ...(page === undefined ? {} : { page }) });
37
37
  if ("reset" in result)
38
38
  return "reset";
39
- const { entries, removed, nextPage, cursor: next } = result;
40
- listed.entries.push(...entries);
39
+ const { items, removed, hasMore, nextCursor, cursor: next } = result;
40
+ listed.entries.push(...items);
41
41
  listed.removed.push(...removed);
42
- if (nextPage === undefined) {
42
+ assert.equal(hasMore, nextCursor !== undefined, "a page names its next cursor exactly when it has more");
43
+ if (!hasMore) {
43
44
  listed.cursor = next ?? null;
44
45
  return listed;
45
46
  }
46
- page = nextPage;
47
+ page = nextCursor;
47
48
  }
48
49
  throw new assert.AssertionError({ message: "the source never stopped paging" });
49
50
  };
@@ -71,9 +71,10 @@ export const fakeCalendarSource = (options = {}) => {
71
71
  const slice = entries.slice(from, from + pageSize);
72
72
  const more = from + pageSize < entries.length;
73
73
  return {
74
- entries: slice.map((entry) => structuredClone(entry)),
74
+ items: slice.map((entry) => structuredClone(entry)),
75
+ hasMore: more,
75
76
  removed: from === 0 ? removed : [],
76
- ...(more ? { nextPage: `p${pages}:${from + pageSize}` } : { cursor: token(window) }),
77
+ ...(more ? { nextCursor: `p${pages}:${from + pageSize}` } : { cursor: token(window) }),
77
78
  };
78
79
  },
79
80
  ...(traits.expands === "on-request"
@@ -0,0 +1,23 @@
1
+ import { type CompletionSources } from "@wirecat/cli-base/completion";
2
+ import { Command } from "commander";
3
+ import type { AppIdentity } from "../ports/app.js";
4
+ import type { Configuration } from "./settings.js";
5
+ /** What the words being completed name: the profile a Tab reads names for, and the words after it. */
6
+ export interface CompletionRequest {
7
+ /** The profile typed, or the locked or session one; unset when none is usable. */
8
+ profile: string | undefined;
9
+ words: string[];
10
+ env: NodeJS.ProcessEnv;
11
+ }
12
+ export interface AppCompletionOptions {
13
+ /** Names for arguments and options, read locally; never a connection, and never an error a shell would show. */
14
+ sources?: (request: CompletionRequest) => CompletionSources | undefined | Promise<CompletionSources | undefined>;
15
+ }
16
+ /**
17
+ * `<app> complete zsh` prints the script a shell sources; the script then runs `<app> complete -- <words>` on every
18
+ * Tab, and this answers from the command registry, the profiles in the config and the CLI's own `sources`.
19
+ *
20
+ * ⚠ **A Tab never connects and never creates anything**, and nothing goes to stderr: a shell shows whatever it is
21
+ * given.
22
+ */
23
+ export declare const appCompleteCommand: (app: Pick<AppIdentity, "command" | "envPrefix">, config: Pick<Configuration, "configuredProfiles">, options?: AppCompletionOptions) => Command;
@@ -0,0 +1,80 @@
1
+ import { script } from "@bomb.sh/tab";
2
+ import { CliError } from "@wirecat/cli-base";
3
+ import { annotate, describeOptions, describeProgram } from "@wirecat/cli-base/commands";
4
+ import { formatSuggestions, suggest } from "@wirecat/cli-base/completion";
5
+ import { Command } from "commander";
6
+ import { environmentOf, outputFor } from "./context.js";
7
+ import { LOCAL_READ } from "./effects.js";
8
+ import { commandWords, liftProfile, rootOf, usableProfileName } from "./profile.js";
9
+ const SHELLS = ["zsh", "bash", "fish", "powershell"];
10
+ /**
11
+ * `<app> complete zsh` prints the script a shell sources; the script then runs `<app> complete -- <words>` on every
12
+ * Tab, and this answers from the command registry, the profiles in the config and the CLI's own `sources`.
13
+ *
14
+ * ⚠ **A Tab never connects and never creates anything**, and nothing goes to stderr: a shell shows whatever it is
15
+ * given.
16
+ */
17
+ export const appCompleteCommand = (app, config, options = {}) => annotate(new Command("complete"), {
18
+ literal_after_dashes: true,
19
+ effects: LOCAL_READ,
20
+ mcp: false,
21
+ examples: [`${app.command} complete zsh`],
22
+ })
23
+ .description(`shell completion: \`${app.command} complete zsh\` prints the script to source`)
24
+ .argument("[words...]", "zsh for the shell script, or command words to complete")
25
+ .allowUnknownOption()
26
+ .helpOption(false)
27
+ .action(async function (words) {
28
+ const root = rootOf(this);
29
+ const { streams } = outputFor(this);
30
+ const env = environmentOf(this).env ?? process.env;
31
+ // Commander drops the `--` from the operands, so only the raw words tell a request from a shell name.
32
+ const raw = root.rawArgs;
33
+ if (!raw.includes("--")) {
34
+ if (words.includes("--help") || words.includes("-h"))
35
+ this.help();
36
+ const [shell] = words;
37
+ if (!shell || !SHELLS.includes(shell)) {
38
+ throw new CliError("validation_error", `name a shell: ${app.command} complete ${SHELLS.join(" | ")}`);
39
+ }
40
+ // tab writes the script through console.log; stdout is where a `source <(…)` reads it.
41
+ script(shell, app.command, app.command);
42
+ return;
43
+ }
44
+ // The last word is still being typed, so it is never taken for a profile: `mess` is on its way to `messages`.
45
+ const { profile, rest } = words.length > 1 ? liftProfile(words, commandWords(root)) : { profile: undefined, rest: words };
46
+ const lock = env[`${app.envPrefix}_PROFILE_LOCK`];
47
+ const wanted = profile ?? lock ?? env[`${app.envPrefix}_PROFILE`];
48
+ const usable = wanted && readable(wanted, lock) ? wanted : undefined;
49
+ const own = await (async () => options.sources?.({ profile: usable, words: rest, env }))().catch(() => undefined);
50
+ const suggestions = suggest({
51
+ commands: describeProgram(root),
52
+ globalOptions: describeOptions(root),
53
+ words: rest.length > 0 ? rest : [""],
54
+ sources: {
55
+ ...(profile === undefined ? { firstWord: () => profileNames(config, env) } : {}),
56
+ ...own,
57
+ },
58
+ });
59
+ streams.data(formatSuggestions(suggestions));
60
+ });
61
+ /** A half-typed or odd first word, or another profile than a locked one, gets no names rather than an error. */
62
+ const readable = (profile, lock) => {
63
+ if (lock && profile !== lock)
64
+ return false;
65
+ try {
66
+ usableProfileName(profile);
67
+ return true;
68
+ }
69
+ catch {
70
+ return false;
71
+ }
72
+ };
73
+ const profileNames = (config, env) => {
74
+ try {
75
+ return config.configuredProfiles({ env });
76
+ }
77
+ catch {
78
+ return [];
79
+ }
80
+ };
@@ -94,6 +94,9 @@ export const baseContext = (command, resolveSettings) => {
94
94
  });
95
95
  const closeables = [];
96
96
  const ranFor = namedProfile(settings);
97
+ // A command can open several runs: `messages sync` fetches, then applies task rules, then counts mentions.
98
+ // Its answer's meta.run_id names the first, the one with the requests; a named side run never takes it.
99
+ let namedTheAnswer = false;
97
100
  return {
98
101
  settings,
99
102
  renderer,
@@ -109,6 +112,9 @@ export const baseContext = (command, resolveSettings) => {
109
112
  return withAbort(environment.commandSignal, () => withDeadline(unbounded ? undefined : settings.commandTimeoutMs, closeables, () => body(() => { })));
110
113
  // An agent's run is named `mcp <command>`, so `search runs` and `sends list` tell it from the owner's.
111
114
  const runName = name ?? `${environment.agent ? "mcp " : ""}${commandPath(command)}`;
115
+ const answersFor = !environment.agent && name === undefined && !namedTheAnswer;
116
+ if (answersFor)
117
+ namedTheAnswer = true;
112
118
  return recorded({
113
119
  app: environment.app,
114
120
  command: runName,
@@ -137,7 +143,7 @@ export const baseContext = (command, resolveSettings) => {
137
143
  : { keepSuccessDays: settings.keepSuccessfulRunsForDays }),
138
144
  ...(settings.keepStoreRunsForDays === undefined ? {} : { keepStoreDays: settings.keepStoreRunsForDays }),
139
145
  ...(settings.runsSizeLimitMb === undefined ? {} : { maxBytes: settings.runsSizeLimitMb * 1024 * 1024 }),
140
- processRun: !environment.agent,
146
+ processRun: answersFor,
141
147
  format,
142
148
  streams,
143
149
  env,
@@ -82,6 +82,8 @@ export declare const writesFileOnlyWith: <T extends Command>(command: T, option:
82
82
  * destroys nothing, and the read-only lock lets it through (`meetings export --output`).
83
83
  */
84
84
  export declare const writesNewFileOnlyWith: <T extends Command>(command: T, option: string) => T;
85
+ /** The option a command writes its one file through, as `writesFileOnlyWith` named it. */
86
+ export declare const fileOptionOf: (command: Command) => string | undefined;
85
87
  /**
86
88
  * What an MCP server runs through `read`: a command that only fetches into the store (`fetchesOnly`), and one whose
87
89
  * only write is a file the tool cannot name (`writesFileOnlyWith`).
@@ -150,6 +150,8 @@ export const writesFileOnlyWith = (command, option) => {
150
150
  * destroys nothing, and the read-only lock lets it through (`meetings export --output`).
151
151
  */
152
152
  export const writesNewFileOnlyWith = (command, option) => destroysNothing(writesFileOnlyWith(command, option));
153
+ /** The option a command writes its one file through, as `writesFileOnlyWith` named it. */
154
+ export const fileOptionOf = (command) => FILE_OPTION.get(command);
153
155
  const writesFileNow = (command) => {
154
156
  const option = FILE_OPTION.get(command);
155
157
  return option === undefined || command.opts()[option] !== undefined;
@@ -8,6 +8,7 @@ import { environmentOf, setExitCode } from "./context.js";
8
8
  import { largeAnswerSteps, SOFT_OUTPUT_BYTES } from "./output-budget.js";
9
9
  import { withoutProviderRefs } from "./provider-refs.js";
10
10
  import { nextStep, rootOf, runnable, stepLine, withLines, withSafety } from "./steps.js";
11
+ import { untrustedFieldsOf, untrustedMarkOf, withFieldsMarked, withUntrustedMarked } from "./untrusted-marks.js";
11
12
  /** Every answer: a list or one thing, with items of `item` — any value where the command declares no entity. */
12
13
  export const answerSchema = (item = v.unknown()) => v.union([listEnvelopeSchema(item), itemEnvelopeSchema(item)]);
13
14
  const capped = (steps) => (steps.length > 0 ? { next: steps.slice(0, MAX_NEXT_STEPS) } : {});
@@ -159,7 +160,11 @@ export const renderAnswer = (command, { renderer, format, streams, compact, full
159
160
  const root = rootOf(command);
160
161
  const runnableSteps = runnable(root, body.next);
161
162
  const next = environmentOf(command).agent ? runnableSteps : withLines(root, runnableSteps);
162
- const kept = withoutProviderRefs({ ...body, ...(next.length > 0 ? { next } : {}) });
163
+ const { app, env } = environmentOf(command);
164
+ const mark = app ? untrustedMarkOf(app, env ?? process.env) : undefined;
165
+ const declared = untrustedFieldsOf(command);
166
+ const shown = mark === undefined ? body : withUntrustedMarked(declared ? withFieldsMarked(body, declared, mark) : body, mark);
167
+ const kept = withoutProviderRefs({ ...shown, ...(next.length > 0 ? { next } : {}) });
163
168
  if (next.length === 0)
164
169
  delete kept.next;
165
170
  const sealedBody = sealed(kept);
@@ -48,6 +48,11 @@ export const WIRECAT_TOOLS = [
48
48
  package: "@wirecat/mail-cli",
49
49
  does: "IMAP mail in the same local store: search your mailbox offline, next to your other WireCat data",
50
50
  },
51
+ {
52
+ command: "b24",
53
+ package: "@wirecat/bitrix24-cli",
54
+ does: "Bitrix24 CRM: deals, leads and pipelines, searchable with your other WireCat data",
55
+ },
51
56
  ];
52
57
  const WIDTH = 100;
53
58
  const widest = (texts) => texts.reduce((most, text) => Math.max(most, text.length), 0);
@@ -68,6 +68,7 @@ export { commandContract, type JsonSchema, SCHEMA_DIALECT } from "./command-cont
68
68
  export { type CommandRunOptions, type CommandRuns, commandRuns, type ProviderAnswer, type ProviderCall, providerEvent, providerRequest, type RunSettings, recordRuns, runSettings, type SavedRunSettings, } from "./command-runs.js";
69
69
  export { CONTRACT } from "./commands-command.js";
70
70
  export { type CompactOptions, compactText, entityRows, GENERIC_ROW, type RowColumn, type RowShape, type RowsResolver, type RowTable, type RowValue, rowShapeOf, rowsOfEntity, SHARED_ROWS, } from "./compact.js";
71
+ export type { AppCompletionOptions, CompletionRequest } from "./complete-command.js";
71
72
  export { refuseUnknownKey } from "./config-command.js";
72
73
  export { type ConfigIssue, type ConfigIssueKind, checkConfigText, issueMessage, readConfigFile, readConfigText, settingPathOf, withoutSetting, } from "./config-issues.js";
73
74
  export { loadSnakeCaseConfig } from "./config-keys.js";
@@ -134,13 +135,14 @@ export { type ProjectTextHints, projectAnswerParts, projectCutoffTime, projectEv
134
135
  export { type ProjectStatusHints, type ProjectStatusItem, projectStatusAnswer, projectStatusRow, projectStatusSchema, projectStatusText, } from "./project-status.js";
135
136
  export { STATUS_ROWS, STATUS_SIGNAL_ROWS } from "./project-status-rows.js";
136
137
  export { fieldsOf, projectFields } from "./result-fields.js";
137
- export { type AgentScheduleSpec, agentSchedule, backfillScheduleRun, type Harness, pauseSchedule, removeSchedule, runScheduleNow, SCHEDULE_SETTINGS, type ScheduleHost, type ScheduleLimits, type ScheduleSite, scheduleLimitsOf, scheduleState, slotsOfAt, writeSchedule, } from "./schedule/schedule-command.js";
138
+ export { HARNESSES, type Harness, harnessesOn, harnessInfo, harnessOfArgv, isHarness, reportsCost, } from "./schedule/harnesses.js";
139
+ export { type AgentScheduleSpec, agentSchedule, backfillScheduleRun, pauseSchedule, removeSchedule, runScheduleNow, SCHEDULE_SETTINGS, type ScheduleHost, type ScheduleLimits, type ScheduleSite, scheduleLimitsOf, scheduleState, slotsOfAt, writeSchedule, } from "./schedule/schedule-command.js";
138
140
  export { deniedKinds, deniedKindsOf, type LeftOut, type SearchedKind } from "./search-left-out.js";
139
141
  export { type DeclaredSetting, type SettingRow, settingRows, withSettingDefaults } from "./setting-defaults.js";
140
142
  export { type Config, type Configuration, count, first, flag, fromFile, type GlobalFlags, NONE_NAMED, namedProfile, type ProfileKind, plain, type ResolveOptions, type Settings, type SettingsExtension, type SettingsExtensionContext, type Source, settingsFor, } from "./settings.js";
141
143
  export { type PermissionAnswer, readSetupAnswers, type SetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
142
144
  export { AGENTS, type Agent, agentFor, screenFor } from "./setup-screen.js";
143
- export { accountCommand, addMeetingBatchCommand, addMeetingPreparationCommand, addMeetingProjectCandidatesCommand, addMeetingSeriesInventoryCommand, appDoctorCommand, appMcpCommand, attachmentsCommand, botAdminsCommand, botCommand, botMcpCommand, botMembersCommand, botMessagesCommand, callsCommand, chatsCommand, commandsCommand, completeCommand, configCommand, contactsCommand, conversationsCommand, deleteCommand, doctorCommand, editCommand, floodCommand, forwardCommand, generatedApiCommand, guideCommand, imagesCommand, inboxCommand, markReadCommand, mcpCommand, mentionsCommand, messagesCommand, metadataCommand, modelCatalogueCommand, modelsCommand, pinCommand, pollsCommand, projectsCommand, reactionsCommand, recipientsCommand, repliesCommand, reviewCommand, runsCommand, scheduleCommand, scheduleCommandFor, searchCommand, searchesCommand, sendCommand, sendsCommand, serveCommand, serverCommand, skillCommand, starCommands, statsCommand, stickersCommand, storeCommand, tagsCommand, tasksCommand, tasksStatsCommand, templatesCommand, topicsCommand, unpinCommand, upgradeCommand, watchCommand, } from "./shared-command-exports.js";
145
+ export { accountCommand, addMeetingBatchCommand, addMeetingPreparationCommand, addMeetingProjectCandidatesCommand, addMeetingSeriesInventoryCommand, appCompleteCommand, appDoctorCommand, appMcpCommand, attachmentsCommand, botAdminsCommand, botCommand, botMcpCommand, botMembersCommand, botMessagesCommand, callsCommand, chatsCommand, commandsCommand, completeCommand, configCommand, contactsCommand, conversationsCommand, deleteCommand, doctorCommand, editCommand, floodCommand, forwardCommand, generatedApiCommand, guideCommand, imagesCommand, inboxCommand, markReadCommand, mcpCommand, mentionsCommand, messagesCommand, metadataCommand, modelCatalogueCommand, modelsCommand, pinCommand, pollsCommand, projectsCommand, reactionsCommand, recipientsCommand, repliesCommand, reviewCommand, runsCommand, scheduleCommand, scheduleCommandFor, searchCommand, searchesCommand, sendCommand, sendsCommand, serveCommand, serverCommand, skillCommand, starCommands, statsCommand, stickersCommand, storeCommand, tagsCommand, tasksCommand, tasksStatsCommand, templatesCommand, topicsCommand, unpinCommand, upgradeCommand, watchCommand, } from "./shared-command-exports.js";
144
146
  export { assertSharedContracts, customizeSharedCommand, hasSharedContract, overrideSharedContract, type SharedContractOverride, sharedContractOverrides, sharedContracts, } from "./shared-contracts.js";
145
147
  export { runnable, withSafety } from "./steps.js";
146
148
  export { type StoreInfo, sharedStoreCommand, storeInfo, storeInfoCommand } from "./store-info.js";
package/dist/cli/index.js CHANGED
@@ -124,13 +124,14 @@ export { projectAnswerParts, projectCutoffTime, projectEvidenceText, projectWind
124
124
  export { projectStatusAnswer, projectStatusRow, projectStatusSchema, projectStatusText, } from "./project-status.js";
125
125
  export { STATUS_ROWS, STATUS_SIGNAL_ROWS } from "./project-status-rows.js";
126
126
  export { fieldsOf, projectFields } from "./result-fields.js";
127
+ export { HARNESSES, harnessesOn, harnessInfo, harnessOfArgv, isHarness, reportsCost, } from "./schedule/harnesses.js";
127
128
  export { agentSchedule, backfillScheduleRun, pauseSchedule, removeSchedule, runScheduleNow, SCHEDULE_SETTINGS, scheduleLimitsOf, scheduleState, slotsOfAt, writeSchedule, } from "./schedule/schedule-command.js";
128
129
  export { deniedKinds, deniedKindsOf } from "./search-left-out.js";
129
130
  export { settingRows, withSettingDefaults } from "./setting-defaults.js";
130
131
  export { count, first, flag, fromFile, NONE_NAMED, namedProfile, plain, settingsFor, } from "./settings.js";
131
132
  export { readSetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
132
133
  export { AGENTS, agentFor, screenFor } from "./setup-screen.js";
133
- export { accountCommand, addMeetingBatchCommand, addMeetingPreparationCommand, addMeetingProjectCandidatesCommand, addMeetingSeriesInventoryCommand, appDoctorCommand, appMcpCommand, attachmentsCommand, botAdminsCommand, botCommand, botMcpCommand, botMembersCommand, botMessagesCommand, callsCommand, chatsCommand, commandsCommand, completeCommand, configCommand, contactsCommand, conversationsCommand, deleteCommand, doctorCommand, editCommand, floodCommand, forwardCommand, generatedApiCommand, guideCommand, imagesCommand, inboxCommand, markReadCommand, mcpCommand, mentionsCommand, messagesCommand, metadataCommand, modelCatalogueCommand, modelsCommand, pinCommand, pollsCommand, projectsCommand, reactionsCommand, recipientsCommand, repliesCommand, reviewCommand, runsCommand, scheduleCommand, scheduleCommandFor, searchCommand, searchesCommand, sendCommand, sendsCommand, serveCommand, serverCommand, skillCommand, starCommands, statsCommand, stickersCommand, storeCommand, tagsCommand, tasksCommand, tasksStatsCommand, templatesCommand, topicsCommand, unpinCommand, upgradeCommand, watchCommand, } from "./shared-command-exports.js";
134
+ export { accountCommand, addMeetingBatchCommand, addMeetingPreparationCommand, addMeetingProjectCandidatesCommand, addMeetingSeriesInventoryCommand, appCompleteCommand, appDoctorCommand, appMcpCommand, attachmentsCommand, botAdminsCommand, botCommand, botMcpCommand, botMembersCommand, botMessagesCommand, callsCommand, chatsCommand, commandsCommand, completeCommand, configCommand, contactsCommand, conversationsCommand, deleteCommand, doctorCommand, editCommand, floodCommand, forwardCommand, generatedApiCommand, guideCommand, imagesCommand, inboxCommand, markReadCommand, mcpCommand, mentionsCommand, messagesCommand, metadataCommand, modelCatalogueCommand, modelsCommand, pinCommand, pollsCommand, projectsCommand, reactionsCommand, recipientsCommand, repliesCommand, reviewCommand, runsCommand, scheduleCommand, scheduleCommandFor, searchCommand, searchesCommand, sendCommand, sendsCommand, serveCommand, serverCommand, skillCommand, starCommands, statsCommand, stickersCommand, storeCommand, tagsCommand, tasksCommand, tasksStatsCommand, templatesCommand, topicsCommand, unpinCommand, upgradeCommand, watchCommand, } from "./shared-command-exports.js";
134
135
  export { assertSharedContracts, customizeSharedCommand, hasSharedContract, overrideSharedContract, sharedContractOverrides, sharedContracts, } from "./shared-contracts.js";
135
136
  export { runnable, withSafety } from "./steps.js";
136
137
  export { sharedStoreCommand, storeInfo, storeInfoCommand } from "./store-info.js";
@@ -31,7 +31,9 @@ export declare const pageOf: ({ limit, page, all }: Pick<Settings, "limit" | "pa
31
31
  offset: number;
32
32
  };
33
33
  /** A page-numbered list's answer; under `--all` its limit is what it holds. */
34
- export declare const pagedList: <T>(command: string, { limit, page, all }: Pick<Settings, "limit" | "page" | "all">, { items, has_more, ...rest }: Omit<ListInput<T>, "limit" | "page" | "cursor">) => ListBody<T>;
34
+ export declare const pagedList: <T>(command: string, { limit, page, all }: Pick<Settings, "limit" | "page" | "all">, { items, hasMore, ...rest }: Omit<ListInput<T>, "limit" | "page" | "cursor" | "has_more"> & {
35
+ hasMore: boolean;
36
+ }) => ListBody<T>;
35
37
  /** An MCP list's `query` argument: the language the CLI list takes after its arguments. */
36
38
  export declare const queryArgument: (registry: QueryRegistry) => v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 8192, undefined>, v.DescriptionAction<string, string>]>, undefined>;
37
39
  /** The fields a native list can also leave out, `-field:value`: what `nativeTermLists` keeps under `-field`. */
@@ -58,7 +58,9 @@ const withTomorrow = (query, registry, zone = timezoneOf(), now = Date.now()) =>
58
58
  };
59
59
  export const listQuery = (text, registry, command, { defaultField = "none" } = {}) => {
60
60
  const context = { command, guide: LIST_QUERY_GUIDE };
61
- const parsed = text.trim() === "" ? undefined : parseLucene(text, { defaultField, ...context });
61
+ // `phone:+34`: a `+` right after a field's colon can only be the value's own sign, never Lucene's "required".
62
+ const signed = text.replace(/(^|[\s(])([\p{L}_][\p{L}\p{N}_.]*:)\+([^\s()"]+)/gu, '$1$2"+$3"');
63
+ const parsed = signed.trim() === "" ? undefined : parseLucene(signed, { defaultField, ...context });
62
64
  const typed = parsed && withTomorrow(parsed, registry);
63
65
  if (typed)
64
66
  validateQuery(typed, registry, context);
@@ -87,11 +89,11 @@ const EVERY = Number.MAX_SAFE_INTEGER - 1;
87
89
  /** The rows a page-numbered list asks its store for; `--all` asks for every one. */
88
90
  export const pageOf = ({ limit, page, all }) => all ? { limit: EVERY, offset: 0 } : { limit, offset: (page - 1) * limit };
89
91
  /** A page-numbered list's answer; under `--all` its limit is what it holds. */
90
- export const pagedList = (command, { limit, page, all }, { items, has_more, ...rest }) => listOf(command, {
92
+ export const pagedList = (command, { limit, page, all }, { items, hasMore, ...rest }) => listOf(command, {
91
93
  ...rest,
92
94
  items,
93
95
  limit: all ? Math.max(1, items.length) : limit,
94
- has_more: all ? false : has_more,
96
+ has_more: all ? false : hasMore,
95
97
  page,
96
98
  });
97
99
  /** The fields a list can be narrowed by: a provider list only those its source answers. */