@wirecat/cli-core 0.641.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 (287) hide show
  1. package/CHANGELOG.md +218 -0
  2. package/dist/analysis/provider.d.ts +1 -1
  3. package/dist/analysis/provider.js +2 -1
  4. package/dist/attachments/gateway-ocr.js +13 -8
  5. package/dist/attachments/ocr.js +27 -18
  6. package/dist/attachments/picture-reading.d.ts +51 -0
  7. package/dist/attachments/picture-reading.js +207 -0
  8. package/dist/background/backfill.d.ts +4 -2
  9. package/dist/background/backfill.js +3 -3
  10. package/dist/background/schedules.d.ts +28 -2
  11. package/dist/background/schedules.js +73 -20
  12. package/dist/background/units.d.ts +2 -0
  13. package/dist/background/units.js +8 -9
  14. package/dist/calendar/cli/index.js +10 -2
  15. package/dist/calendar/feeds.js +2 -2
  16. package/dist/calendar/mcp/index.d.ts +12 -12
  17. package/dist/calendar/server-search.js +2 -2
  18. package/dist/calendar/source.d.ts +4 -3
  19. package/dist/calendar/sync.js +12 -10
  20. package/dist/calendar/testing/source-contract.js +5 -4
  21. package/dist/calendar/testing/source.js +3 -2
  22. package/dist/cli/ai-model-command.js +6 -3
  23. package/dist/cli/analysis-choice.js +20 -4
  24. package/dist/cli/complete-command.d.ts +23 -0
  25. package/dist/cli/complete-command.js +80 -0
  26. package/dist/cli/context.js +7 -1
  27. package/dist/cli/effects.d.ts +2 -0
  28. package/dist/cli/effects.js +2 -0
  29. package/dist/cli/enrichment-consents-command.js +2 -0
  30. package/dist/cli/envelope.js +6 -1
  31. package/dist/cli/help/first-screen.js +5 -0
  32. package/dist/cli/index.d.ts +4 -2
  33. package/dist/cli/index.js +2 -1
  34. package/dist/cli/list-query.d.ts +3 -1
  35. package/dist/cli/list-query.js +5 -3
  36. package/dist/cli/local-only-command.d.ts +10 -0
  37. package/dist/cli/local-only-command.js +112 -0
  38. package/dist/cli/messenger/backfill-command.js +1 -1
  39. package/dist/cli/messenger/chat-queries.js +2 -1
  40. package/dist/cli/messenger/complete-command.d.ts +4 -7
  41. package/dist/cli/messenger/complete-command.js +31 -98
  42. package/dist/cli/messenger/contacts-command.js +4 -0
  43. package/dist/cli/messenger/conversations-command.js +1 -1
  44. package/dist/cli/messenger/guard-commands.js +1 -1
  45. package/dist/cli/messenger/images-command.js +32 -0
  46. package/dist/cli/messenger/list-result-queries.d.ts +1 -0
  47. package/dist/cli/messenger/list-result-queries.js +2 -1
  48. package/dist/cli/messenger/mentions-command.js +3 -3
  49. package/dist/cli/messenger/message-items.js +1 -0
  50. package/dist/cli/messenger/messages-command.js +7 -6
  51. package/dist/cli/messenger/people-queries.d.ts +2 -2
  52. package/dist/cli/messenger/people-queries.js +4 -4
  53. package/dist/cli/messenger/replies-consents-command.js +12 -6
  54. package/dist/cli/messenger/search-answers.js +2 -2
  55. package/dist/cli/messenger/search-command.js +3 -3
  56. package/dist/cli/messenger/searches-command.js +1 -1
  57. package/dist/cli/messenger/store-maintenance-command.js +4 -0
  58. package/dist/cli/messenger/tasks-analysis-command.js +1 -1
  59. package/dist/cli/messenger/tasks-command.js +2 -2
  60. package/dist/cli/model-catalogue-command.js +4 -0
  61. package/dist/cli/picture-reading-command.d.ts +12 -0
  62. package/dist/cli/picture-reading-command.js +82 -0
  63. package/dist/cli/program.d.ts +6 -0
  64. package/dist/cli/program.js +28 -2
  65. package/dist/cli/schedule/agent-start.d.ts +23 -0
  66. package/dist/cli/schedule/agent-start.js +115 -0
  67. package/dist/cli/schedule/harnesses.d.ts +203 -0
  68. package/dist/cli/schedule/harnesses.js +278 -0
  69. package/dist/cli/schedule/schedule-command.d.ts +9 -5
  70. package/dist/cli/schedule/schedule-command.js +89 -79
  71. package/dist/cli/search-harder-consents-command.js +16 -1
  72. package/dist/cli/shared-command-exports.d.ts +186 -0
  73. package/dist/cli/shared-command-exports.js +2 -0
  74. package/dist/cli/untrusted-marks.d.ts +25 -0
  75. package/dist/cli/untrusted-marks.js +102 -0
  76. package/dist/crm/cli/index.d.ts +1 -0
  77. package/dist/crm/cli/index.js +6 -5
  78. package/dist/crm/cli/store.d.ts +30 -0
  79. package/dist/crm/cli/store.js +63 -0
  80. package/dist/crm/source.d.ts +6 -4
  81. package/dist/crm/sync.js +10 -6
  82. package/dist/crm/testing/source-contract.js +9 -7
  83. package/dist/crm/testing/source.js +6 -2
  84. package/dist/crm/testing/sync-contract.js +4 -4
  85. package/dist/crm/writes.d.ts +5 -2
  86. package/dist/crm/writes.js +1 -1
  87. package/dist/documents.d.ts +2 -1
  88. package/dist/documents.js +2 -1
  89. package/dist/domain/addresses.d.ts +2 -0
  90. package/dist/domain/addresses.js +7 -0
  91. package/dist/domain/attachments.d.ts +2 -0
  92. package/dist/domain/attachments.js +2 -1
  93. package/dist/domain/models.d.ts +2 -0
  94. package/dist/embeddings/remote.d.ts +2 -1
  95. package/dist/embeddings/remote.js +5 -3
  96. package/dist/entities/attachment-results.d.ts +3 -0
  97. package/dist/entities/attachment-results.js +3 -0
  98. package/dist/entities/attachment.d.ts +2 -0
  99. package/dist/entities/attachment.js +8 -1
  100. package/dist/entities/hit.d.ts +1 -0
  101. package/dist/entities/index.d.ts +21 -4
  102. package/dist/entities/index.js +3 -2
  103. package/dist/entities/list-results.d.ts +33 -5
  104. package/dist/entities/list-results.js +33 -5
  105. package/dist/errors/reasons.js +38 -1
  106. package/dist/mail/cli/index.js +7 -6
  107. package/dist/mcp/agent.d.ts +2 -1
  108. package/dist/mcp/agent.js +5 -0
  109. package/dist/mcp/app-server.js +10 -0
  110. package/dist/mcp/surface.d.ts +7 -2
  111. package/dist/mcp/surface.js +49 -10
  112. package/dist/meetings/cli/index.js +6 -1
  113. package/dist/meetings/mcp/index.js +6 -3
  114. package/dist/meetings/participant-search.d.ts +2 -2
  115. package/dist/meetings/project-discovery.d.ts +1 -1
  116. package/dist/meetings/project-evidence-answer.js +2 -2
  117. package/dist/meetings/reads.d.ts +2 -2
  118. package/dist/meetings/reads.js +6 -6
  119. package/dist/meetings/store.d.ts +2 -1
  120. package/dist/meetings/testing/contract.js +6 -6
  121. package/dist/meetings/testing/memory.js +7 -2
  122. package/dist/models/ai.d.ts +17 -4
  123. package/dist/models/ai.js +22 -14
  124. package/dist/models/anthropic.js +15 -9
  125. package/dist/models/endpoint.d.ts +5 -0
  126. package/dist/models/endpoint.js +13 -0
  127. package/dist/models/index.d.ts +4 -0
  128. package/dist/models/index.js +14 -4
  129. package/dist/models/local-only.d.ts +17 -0
  130. package/dist/models/local-only.js +42 -0
  131. package/dist/models/openai.js +24 -11
  132. package/dist/models/purpose.d.ts +24 -0
  133. package/dist/models/purpose.js +26 -0
  134. package/dist/models/types.d.ts +8 -0
  135. package/dist/models/types.js +11 -1
  136. package/dist/ports/app.d.ts +17 -1
  137. package/dist/ports/app.js +63 -3
  138. package/dist/replies/rendering.js +10 -10
  139. package/dist/search/lucene/plain.js +45 -3
  140. package/dist/search/lucene/registry.d.ts +15 -4
  141. package/dist/search/lucene/registry.js +70 -12
  142. package/dist/search/lucene/types.d.ts +2 -0
  143. package/dist/search/lucene/types.js +12 -0
  144. package/dist/sends/upload.d.ts +8 -1
  145. package/dist/sends/upload.js +35 -14
  146. package/dist/services/account-groups.d.ts +11 -0
  147. package/dist/services/account-groups.js +29 -0
  148. package/dist/services/agenda.js +1 -0
  149. package/dist/services/attachments.d.ts +18 -4
  150. package/dist/services/attachments.js +66 -15
  151. package/dist/services/conversations.d.ts +2 -4
  152. package/dist/services/conversations.js +1 -1
  153. package/dist/services/deal-context.js +5 -5
  154. package/dist/services/documents/ingestion.js +3 -3
  155. package/dist/services/documents/knowledge.d.ts +6 -6
  156. package/dist/services/documents/knowledge.js +1 -2
  157. package/dist/services/embeddings-maintenance.js +4 -1
  158. package/dist/services/enrichment.d.ts +1 -1
  159. package/dist/services/enrichment.js +27 -0
  160. package/dist/services/events-search.d.ts +3 -3
  161. package/dist/services/events-search.js +7 -7
  162. package/dist/services/index.d.ts +1 -1
  163. package/dist/services/index.js +1 -1
  164. package/dist/services/meeting-model.js +1 -1
  165. package/dist/services/meeting-project-discovery.js +1 -1
  166. package/dist/services/message-resolution.js +10 -3
  167. package/dist/services/messages-search.js +6 -4
  168. package/dist/services/metadata.d.ts +1 -1
  169. package/dist/services/notes-search.d.ts +3 -3
  170. package/dist/services/notes-search.js +3 -3
  171. package/dist/services/organization-context.js +12 -9
  172. package/dist/services/people.d.ts +2 -0
  173. package/dist/services/people.js +4 -2
  174. package/dist/services/pictures.d.ts +9 -0
  175. package/dist/services/pictures.js +34 -28
  176. package/dist/services/project-status/index.js +1 -1
  177. package/dist/services/project-status/signals/payments.js +4 -2
  178. package/dist/services/project-status/signals/promises.js +5 -2
  179. package/dist/services/proposals/kinds/action.js +1 -1
  180. package/dist/services/proposals/kinds/fact.js +1 -1
  181. package/dist/services/proposals/kinds/findings.d.ts +2 -1
  182. package/dist/services/proposals/kinds/findings.js +12 -5
  183. package/dist/services/proposals/kinds/identity-link.js +1 -1
  184. package/dist/services/proposals/kinds/identity-split.js +1 -1
  185. package/dist/services/proposals/kinds/key-document.js +1 -1
  186. package/dist/services/proposals/kinds/mail-findings.d.ts +1 -1
  187. package/dist/services/proposals/kinds/mail-findings.js +11 -5
  188. package/dist/services/proposals/kinds/meeting-findings.js +10 -4
  189. package/dist/services/proposals/kinds/memory.js +1 -1
  190. package/dist/services/proposals/kinds/organization.js +1 -1
  191. package/dist/services/proposals/kinds/relationship-update.js +1 -1
  192. package/dist/services/proposals/kinds/relationship.js +1 -1
  193. package/dist/services/proposals/kinds/shared.d.ts +3 -2
  194. package/dist/services/proposals/kinds/shared.js +4 -4
  195. package/dist/services/proposals/kinds/source-review.js +1 -1
  196. package/dist/services/proposals/kinds/task-close.js +2 -2
  197. package/dist/services/proposals/registry.js +1 -1
  198. package/dist/services/proposals/types.d.ts +2 -1
  199. package/dist/services/search-all-business.js +3 -4
  200. package/dist/services/search-all.js +13 -14
  201. package/dist/services/search-harder.d.ts +11 -1
  202. package/dist/services/search-harder.js +38 -5
  203. package/dist/services/searches.d.ts +2 -4
  204. package/dist/services/searches.js +1 -4
  205. package/dist/services/stored-project-gathering.js +6 -1
  206. package/dist/services/tags.d.ts +2 -4
  207. package/dist/services/tags.js +1 -1
  208. package/dist/services/tasks.d.ts +1 -1
  209. package/dist/services/tasks.js +4 -3
  210. package/dist/speech/openai.js +2 -0
  211. package/dist/speech/transcribe.d.ts +5 -2
  212. package/dist/speech/transcribe.js +14 -5
  213. package/dist/store/account-store.d.ts +2 -1
  214. package/dist/store/account-store.js +3 -1
  215. package/dist/store/accounts.d.ts +2 -0
  216. package/dist/store/accounts.js +8 -0
  217. package/dist/store/chats.d.ts +5 -0
  218. package/dist/store/chats.js +4 -0
  219. package/dist/store/evidence-findings.d.ts +9 -0
  220. package/dist/store/exports.d.ts +1 -1
  221. package/dist/store/exports.js +1 -1
  222. package/dist/store/identity-links.d.ts +3 -1
  223. package/dist/store/mail-findings.d.ts +9 -0
  224. package/dist/store/meeting-findings.d.ts +9 -0
  225. package/dist/store/searches.d.ts +3 -2
  226. package/dist/store/sqlite/accounts.js +37 -0
  227. package/dist/store/sqlite/agent-actions.d.ts +2 -1
  228. package/dist/store/sqlite/agent-actions.js +10 -4
  229. package/dist/store/sqlite/business-contracts.d.ts +3 -1
  230. package/dist/store/sqlite/business-contracts.js +7 -3
  231. package/dist/store/sqlite/business-search.d.ts +2 -1
  232. package/dist/store/sqlite/business-search.js +6 -4
  233. package/dist/store/sqlite/deals.d.ts +6 -4
  234. package/dist/store/sqlite/deals.js +12 -7
  235. package/dist/store/sqlite/evidence-findings.js +78 -9
  236. package/dist/store/sqlite/facts.d.ts +2 -1
  237. package/dist/store/sqlite/facts.js +6 -2
  238. package/dist/store/sqlite/finance.d.ts +4 -2
  239. package/dist/store/sqlite/finance.js +13 -6
  240. package/dist/store/sqlite/findings-core.d.ts +56 -2
  241. package/dist/store/sqlite/findings-core.js +109 -22
  242. package/dist/store/sqlite/identities.d.ts +4 -0
  243. package/dist/store/sqlite/identities.js +12 -3
  244. package/dist/store/sqlite/identity-proposals.js +34 -4
  245. package/dist/store/sqlite/lucene-fields.d.ts +2 -0
  246. package/dist/store/sqlite/lucene-fields.js +28 -2
  247. package/dist/store/sqlite/lucene.js +21 -10
  248. package/dist/store/sqlite/mail-findings.js +60 -22
  249. package/dist/store/sqlite/meeting-findings.js +53 -7
  250. package/dist/store/sqlite/meeting-participant-search.js +4 -5
  251. package/dist/store/sqlite/meetings.js +7 -3
  252. package/dist/store/sqlite/memories.d.ts +4 -2
  253. package/dist/store/sqlite/memories.js +13 -6
  254. package/dist/store/sqlite/money-transactions.d.ts +3 -1
  255. package/dist/store/sqlite/money-transactions.js +7 -3
  256. package/dist/store/sqlite/name-traces.d.ts +3 -3
  257. package/dist/store/sqlite/name-traces.js +29 -2
  258. package/dist/store/sqlite/orders.d.ts +3 -1
  259. package/dist/store/sqlite/orders.js +5 -2
  260. package/dist/store/sqlite/people-list.js +67 -22
  261. package/dist/store/sqlite/person-match-scan.d.ts +3 -1
  262. package/dist/store/sqlite/person-match-scan.js +97 -7
  263. package/dist/store/sqlite/products.d.ts +3 -1
  264. package/dist/store/sqlite/products.js +5 -2
  265. package/dist/store/sqlite/proposed-actions.d.ts +2 -1
  266. package/dist/store/sqlite/proposed-actions.js +7 -3
  267. package/dist/store/sqlite/query-filter.d.ts +4 -0
  268. package/dist/store/sqlite/query-filter.js +14 -0
  269. package/dist/store/sqlite/reads.d.ts +1 -0
  270. package/dist/store/sqlite/reads.js +14 -0
  271. package/dist/store/sqlite/records.d.ts +3 -1
  272. package/dist/store/sqlite/records.js +7 -5
  273. package/dist/store/sqlite/rows-page.d.ts +3 -0
  274. package/dist/store/sqlite/rows-page.js +4 -0
  275. package/dist/store/sqlite/searches.d.ts +2 -1
  276. package/dist/store/sqlite/searches.js +3 -1
  277. package/dist/store/sqlite/subscriptions.d.ts +5 -2
  278. package/dist/store/sqlite/subscriptions.js +13 -6
  279. package/dist/store/sqlite/task-board.js +27 -0
  280. package/dist/store/sqlite/task-find.d.ts +15 -0
  281. package/dist/store/sqlite/task-find.js +1 -0
  282. package/dist/store/sqlite/wallets.d.ts +3 -1
  283. package/dist/store/sqlite/wallets.js +7 -3
  284. package/dist/store/sqlite/work-tasks.d.ts +3 -11
  285. package/dist/store/sqlite/work-tasks.js +8 -4
  286. package/package.json +2 -2
  287. package/parity.json +24 -0
@@ -13,8 +13,9 @@ export interface CrmPage<T> {
13
13
  items: T[];
14
14
  /** Ids the CRM says it deleted since the cursor; never one that only left a filter. */
15
15
  removed?: string[];
16
- /** More pages in this round. */
17
- nextPage?: string;
16
+ /** More pages in this round, read from `nextCursor`. */
17
+ hasMore: boolean;
18
+ nextCursor?: string;
18
19
  /** On the last page: the cursor the next run reads changes after; `null` when the CRM keeps none. */
19
20
  cursor?: string | null;
20
21
  }
@@ -23,8 +24,9 @@ export type CrmChanges<T> = CrmPage<T> | {
23
24
  reset: true;
24
25
  };
25
26
  export interface CrmIdPage {
26
- ids: string[];
27
- nextPage?: string;
27
+ items: string[];
28
+ hasMore: boolean;
29
+ nextCursor?: string;
28
30
  }
29
31
  /**
30
32
  * What a CRM account did not report in the last sync, so an answer can name it: a kind it has not, users or departments
package/dist/crm/sync.js CHANGED
@@ -315,15 +315,17 @@ const syncKind = async (run, kind, options, result) => {
315
315
  result.outOfScope += await store.crm.remove(account, kind, left);
316
316
  }
317
317
  run.moved();
318
- if (page.nextPage === undefined) {
318
+ if (!page.hasMore) {
319
319
  listed = true;
320
320
  await save({ token: page.cursor ?? null });
321
321
  break;
322
322
  }
323
- if (pages.has(page.nextPage))
323
+ if (page.nextCursor === undefined)
324
+ throw new CliError("invalid_response", `${source.provider} said there are more pages but gave no cursor`);
325
+ if (pages.has(page.nextCursor))
324
326
  throw new CliError("invalid_response", `${source.provider} returned the same page twice`);
325
- pages.add(page.nextPage);
326
- round = { ...round, page: page.nextPage };
327
+ pages.add(page.nextCursor);
328
+ round = { ...round, page: page.nextCursor };
327
329
  await save();
328
330
  if (stop)
329
331
  return stop;
@@ -343,9 +345,11 @@ const syncKind = async (run, kind, options, result) => {
343
345
  const page = await ids.call(source, kind, pass.page ?? undefined, run.context);
344
346
  if (signal?.aborted)
345
347
  return "cancelled";
346
- pass = { ...pass, seen: [...pass.seen, ...page.ids], page: page.nextPage ?? null };
348
+ if (page.hasMore && page.nextCursor === undefined)
349
+ throw new CliError("invalid_response", `${source.provider} said there are more ids but gave no cursor`);
350
+ pass = { ...pass, seen: [...pass.seen, ...page.items], page: page.hasMore ? (page.nextCursor ?? null) : null };
347
351
  run.moved();
348
- if (page.nextPage === undefined)
352
+ if (!page.hasMore)
349
353
  break;
350
354
  await save({ pass });
351
355
  }
@@ -15,13 +15,15 @@ const listAll = async (source, kind, cursor) => {
15
15
  const listed = answer;
16
16
  assert.ok(Array.isArray(listed.items), `${kind}: a page has items`);
17
17
  items.push(...listed.items);
18
- if (listed.nextPage === undefined) {
18
+ assert.equal(listed.hasMore, listed.nextCursor !== undefined, `${kind}: a next cursor exactly when there is more`);
19
+ if (!listed.hasMore) {
19
20
  assert.ok(listed.cursor === null || typeof listed.cursor === "string", `${kind}: the last page gives a cursor`);
20
21
  return { items, cursor: listed.cursor ?? null };
21
22
  }
22
- assert.ok(!pages.has(listed.nextPage), `${kind}: the same page twice`);
23
- pages.add(listed.nextPage);
24
- page = listed.nextPage;
23
+ const next = listed.nextCursor;
24
+ assert.ok(!pages.has(next), `${kind}: the same page twice`);
25
+ pages.add(next);
26
+ page = next;
25
27
  }
26
28
  throw new assert.AssertionError({ message: `${kind}: more than ${MAX_PAGES} pages` });
27
29
  };
@@ -150,11 +152,11 @@ export const crmSourceContract = (make) => {
150
152
  let page;
151
153
  for (let read = 0; read < MAX_PAGES; read += 1) {
152
154
  const answer = await ids.call(source, kind, page);
153
- for (const id of answer.ids)
155
+ for (const id of answer.items)
154
156
  listed.add(id);
155
- if (answer.nextPage === undefined)
157
+ if (!answer.hasMore)
156
158
  break;
157
- page = answer.nextPage;
159
+ page = answer.nextCursor;
158
160
  }
159
161
  for (const item of items)
160
162
  assert.ok(listed.has(item.externalId), `${kind} ${item.externalId} is missing from ids()`);
@@ -249,14 +249,18 @@ export const fakeCrmSource = (options = {}) => {
249
249
  return {
250
250
  items: slice.filter(([, held]) => !held.deleted).map(([, held]) => held.record),
251
251
  ...(traits.removedInChanges ? { removed: slice.filter(([, held]) => held.deleted).map(([id]) => id) } : {}),
252
- ...(nextPage === undefined ? { cursor: String(version) } : { nextPage }),
252
+ ...(nextPage === undefined
253
+ ? { hasMore: false, cursor: String(version) }
254
+ : { hasMore: true, nextCursor: nextPage }),
253
255
  };
254
256
  },
255
257
  async ids(kind, page) {
256
258
  calls.ids += 1;
257
259
  const listed = hidden ? [] : [...of(kind).entries()].filter(([, held]) => !held.deleted).map(([id]) => id);
258
260
  const { slice, nextPage } = window(listed, page);
259
- return { ids: slice, ...(nextPage === undefined ? {} : { nextPage }) };
261
+ return nextPage === undefined
262
+ ? { items: slice, hasMore: false }
263
+ : { items: slice, hasMore: true, nextCursor: nextPage };
260
264
  },
261
265
  };
262
266
  return fake;
@@ -19,7 +19,7 @@ export const crmSyncContract = (make) => CRM_TRAIT_COMBINATIONS.flatMap((traits)
19
19
  const fixture = await make();
20
20
  const source = fakeCrmSource({ traits });
21
21
  const sync = (options = {}) => syncCrm(source, fixture.store, fixture.account, { now, ...options });
22
- const deals = async () => (await fixture.store.deals.list({ account: fixture.account, kind: "deal" }))
22
+ const deals = async () => (await fixture.store.deals.list({ account: fixture.account, kind: "deal" })).items
23
23
  .map(({ externalId }) => externalId)
24
24
  .sort();
25
25
  await check({ ...fixture, source, sync, deals });
@@ -38,7 +38,7 @@ export const crmSyncContract = (make) => CRM_TRAIT_COMBINATIONS.flatMap((traits)
38
38
  const first = await sync();
39
39
  assert.equal(first.state, "complete");
40
40
  assert.deepEqual(await deals(), ["d1", "d2", "d3"]);
41
- assert.equal((await store.deals.list({ account, kind: "lead" })).length, 1);
41
+ assert.equal((await store.deals.list({ account, kind: "lead" })).items.length, 1);
42
42
  assert.ok(first.synced.every(({ round }) => round === "full"));
43
43
  source.put("deal", exampleDeal("d2", { stage: "won", title: "Example deal won" }));
44
44
  const second = await sync();
@@ -48,7 +48,7 @@ export const crmSyncContract = (make) => CRM_TRAIT_COMBINATIONS.flatMap((traits)
48
48
  ["deal", "changes", 1],
49
49
  ["lead", "changes", 0],
50
50
  ]);
51
- const [won] = await store.deals.list({ account, status: "won" });
51
+ const { items: [won], } = await store.deals.list({ account, status: "won" });
52
52
  assert.equal(won?.title, "Example deal won");
53
53
  }),
54
54
  test("marks deleted what the CRM deleted, after a complete list at the latest", async ({ source, sync, deals, }) => {
@@ -163,7 +163,7 @@ export const crmSyncContract = (make) => CRM_TRAIT_COMBINATIONS.flatMap((traits)
163
163
  source.put("person", examplePerson("p1", { email: "person@example.com" }));
164
164
  source.put("deal", exampleDeal("d1", { organization: "c1", people: [{ externalId: "p1", role: "contact" }] }));
165
165
  await sync();
166
- const [deal] = await store.deals.list({ account });
166
+ const { items: [deal], } = await store.deals.list({ account });
167
167
  assert.notEqual(deal?.organization?.ref, own.ref);
168
168
  assert.equal(deal?.organization?.name, "Example company c1");
169
169
  const person = await store.people.personOf({ provider: "email", id: "person@example.com" });
@@ -14,8 +14,11 @@ import { type CrmVerb, type CrmWriter } from "./writer.js";
14
14
  export interface CrmWrites {
15
15
  writer: CrmWriter;
16
16
  app: AppIdentity;
17
- /** The profile's levels, read on every write so a config change applies at once. */
18
- settings: () => GuardSettings;
17
+ /**
18
+ * The profile's levels, read on every write so a config change applies at once. A CRM limits its own rate, so
19
+ * `sendsPerHour` is not read: the guard is there for the levels and the journal.
20
+ */
21
+ settings: () => Omit<GuardSettings, "sendsPerHour"> & Partial<Pick<GuardSettings, "sendsPerHour">>;
19
22
  /** The CRM user the sign-in acts as. An owner other than it checks `crm.assign-others`; left out, every owner does. */
20
23
  self?: string;
21
24
  env?: NodeJS.ProcessEnv;
@@ -226,7 +226,7 @@ const keysOf = (context, kind, verb, { stage, owner }) => {
226
226
  const guardOf = (context, extra) => {
227
227
  const settings = context.writes.settings();
228
228
  const defaults = { ...DEFAULT_PERMISSIONS, ...CRM_WRITE_DEFAULTS, ...settings.permissionDefaults };
229
- return keyedGuard((ask) => guardFor(context.writes.app, { ...settings, permissionDefaults: defaults }, context.writes.warn ?? (() => { }), context.writes.env, ask), context.ask, (key) => levelFor(settings.permissions, key, defaults).level, extra);
229
+ return keyedGuard((ask) => guardFor(context.writes.app, { ...settings, sendsPerHour: Number.MAX_SAFE_INTEGER, permissionDefaults: defaults }, context.writes.warn ?? (() => { }), context.writes.env, ask), context.ask, (key) => levelFor(settings.permissions, key, defaults).level, extra);
230
230
  };
231
231
  /** Sends the write once, never again: a lost answer is `outcome_unknown`, with what the owner may do about it. */
232
232
  const written = async (context, { key, extra }, operationId, act) => {
@@ -3,11 +3,12 @@ export type { Engine, Extraction, FileHint, LoadEngine } from "./attachments/ext
3
3
  export { extractText, importEngine, MAX_FILE_BYTES, MAX_TEXT_CHARS } from "./attachments/extract.js";
4
4
  export { attachmentMaxBytes } from "./attachments/limits.js";
5
5
  export { type OcrPipeline, ocrImage } from "./attachments/ocr.js";
6
+ export { agentPictureReader, PICTURE_AGENTS, type PictureAgent, type PictureReadingSetting, pictureExtractor, pictureReaderOf, readPictureReading, readPictureWithAgent, } from "./attachments/picture-reading.js";
6
7
  export type { Sheet, SheetCell } from "./attachments/sheets.js";
7
8
  export { columnName, sheetText } from "./attachments/sheets.js";
8
9
  export * from "./documents/index.js";
9
10
  export { isPublicAddress } from "./fetch/addresses.js";
10
11
  export { type FetchedPage, type FetchPageOptions, fetchPage, nodeTransport, PAGE_LIMITS, PAGE_USER_AGENT, type PageLimits, type PageLookup, type PageRequest, type PageResponse, type PageTransport, type ResolvedAddress, } from "./fetch/page.js";
11
- export { AI_PROVIDERS, type AiImageRefusal, type AiProvider, type AiSetting, type AiTextReader, type AiTextRefusal, aiImageReader, aiLeavesComputer, aiSettingPath, aiTextReader, readAiSetting, } from "./models/ai.js";
12
+ export { AI_PROVIDERS, type AiImageRefusal, type AiProvider, type AiSetting, type AiTextReader, type AiTextRefusal, aiImageReader, aiLeavesComputer, aiSettingPath, aiTextReader, readAiSetting, sharedModel, } from "./models/ai.js";
12
13
  export { registerReader } from "./readers/registry.js";
13
14
  export type { ReadContext, Reader, Section } from "./readers/types.js";
package/dist/documents.js CHANGED
@@ -2,9 +2,10 @@ export { readSpreadsheet } from "./attachments/documents.js";
2
2
  export { extractText, importEngine, MAX_FILE_BYTES, MAX_TEXT_CHARS } from "./attachments/extract.js";
3
3
  export { attachmentMaxBytes } from "./attachments/limits.js";
4
4
  export { ocrImage } from "./attachments/ocr.js";
5
+ export { agentPictureReader, PICTURE_AGENTS, pictureExtractor, pictureReaderOf, readPictureReading, readPictureWithAgent, } from "./attachments/picture-reading.js";
5
6
  export { columnName, sheetText } from "./attachments/sheets.js";
6
7
  export * from "./documents/index.js";
7
8
  export { isPublicAddress } from "./fetch/addresses.js";
8
9
  export { fetchPage, nodeTransport, PAGE_LIMITS, PAGE_USER_AGENT, } from "./fetch/page.js";
9
- export { AI_PROVIDERS, aiImageReader, aiLeavesComputer, aiSettingPath, aiTextReader, readAiSetting, } from "./models/ai.js";
10
+ export { AI_PROVIDERS, aiImageReader, aiLeavesComputer, aiSettingPath, aiTextReader, readAiSetting, sharedModel, } from "./models/ai.js";
10
11
  export { registerReader } from "./readers/registry.js";
@@ -9,5 +9,7 @@ export declare const ROLE_ADDRESS_WORDS: {
9
9
  };
10
10
  /** Whether the whole local part, `+tag` and `.`/`-`/`_` aside, is a role word: `info@`, `Hello+news@`, `no_reply@`. */
11
11
  export declare const isRoleAddress: (address: string) => boolean;
12
+ /** Whether the address is a role address that one person often reads alone, such as `hr@`. */
13
+ export declare const isPersonLikeRoleAddress: (address: string) => boolean;
12
14
  /** Whether the address is a no-reply one, which belongs to no person. */
13
15
  export declare const isNoReplyAddress: (address: string) => boolean;
@@ -59,5 +59,12 @@ const localWord = (address) => {
59
59
  };
60
60
  /** Whether the whole local part, `+tag` and `.`/`-`/`_` aside, is a role word: `info@`, `Hello+news@`, `no_reply@`. */
61
61
  export const isRoleAddress = (address) => ROLE.has(localWord(address));
62
+ /**
63
+ * Role words that one person often reads alone: a small company's `hr@` is its HR manager. Still a role address, so it
64
+ * joins no one, but weaker evidence of a company's mailbox than `info@`, and it never makes a contact a company.
65
+ */
66
+ const PERSON_LIKE = new Set(["hr"]);
67
+ /** Whether the address is a role address that one person often reads alone, such as `hr@`. */
68
+ export const isPersonLikeRoleAddress = (address) => PERSON_LIKE.has(localWord(address));
62
69
  /** Whether the address is a no-reply one, which belongs to no person. */
63
70
  export const isNoReplyAddress = (address) => NO_REPLY.has(localWord(address));
@@ -7,6 +7,8 @@ export interface HitFile {
7
7
  kind: string;
8
8
  name?: string;
9
9
  size?: number;
10
+ /** The saved copy on this computer, once `messages download` fetched it. */
11
+ local_path?: string;
10
12
  }
11
13
  export declare const hitFiles: (attachments: readonly Attachment[] | undefined) => HitFile[];
12
14
  /** The stored kinds `has:<kind>` matches: MAX stores a file as `file`, Telegram as `document`. */
@@ -11,7 +11,7 @@ export const NOT_FILES = new Set([
11
11
  ]);
12
12
  // The position is taken before the filter: the store numbers every attachment, and `--attachment` takes that number.
13
13
  // A server search hit built by an adapter may come without attachments at all.
14
- export const hitFiles = (attachments) => (attachments ?? []).flatMap(({ kind, name, size }, index) => NOT_FILES.has(kind)
14
+ export const hitFiles = (attachments) => (attachments ?? []).flatMap(({ kind, name, size, localPath }, index) => NOT_FILES.has(kind)
15
15
  ? []
16
16
  : [
17
17
  {
@@ -19,6 +19,7 @@ export const hitFiles = (attachments) => (attachments ?? []).flatMap(({ kind, na
19
19
  kind,
20
20
  ...(name === undefined ? {} : { name }),
21
21
  ...(size === undefined ? {} : { size }),
22
+ ...(localPath === undefined ? {} : { local_path: localPath }),
22
23
  },
23
24
  ]);
24
25
  /** The stored kinds `has:<kind>` matches: MAX stores a file as `file`, Telegram as `document`. */
@@ -191,6 +191,8 @@ export interface Attachment {
191
191
  duration?: number;
192
192
  /** What the adapter needs to fetch the bytes later. Opaque above the adapter. */
193
193
  providerRef?: ProviderMetadata;
194
+ /** Where `messages download` saved the file on this computer; only the store knows it. */
195
+ localPath?: string;
194
196
  /** A bot's keyboard under the message, row by row. */
195
197
  buttons?: Button[][];
196
198
  /** The poll the message carries, as it stood when read; drawn for a person, not part of the JSON answer. */
@@ -35,8 +35,9 @@ export declare const remoteModel: ({ model, baseUrl, dims, }: {
35
35
  export declare const remoteKey: ({ provider, model, dims }: RemoteModel) => string;
36
36
  export type Fetch = (url: string, init: RequestInit) => Promise<Response>;
37
37
  /** Up to `concurrency` requests at once; a 429 waits for `Retry-After`, a server error is tried again. */
38
- export declare const openRemote: (remote: RemoteModel, apiKey: string | undefined, { concurrency, fetch: post, tries }?: {
38
+ export declare const openRemote: (remote: RemoteModel, apiKey: string | undefined, { concurrency, fetch: post, tries, env, }: {
39
39
  concurrency?: number;
40
40
  fetch?: Fetch;
41
41
  tries?: number;
42
+ env?: NodeJS.ProcessEnv;
42
43
  }) => Embedder;
@@ -1,5 +1,7 @@
1
1
  import { setTimeout } from "node:timers/promises";
2
2
  import { CliError } from "@wirecat/cli-base";
3
+ import { onThisComputer } from "../models/endpoint.js";
4
+ import { refuseModelAddress } from "../models/local-only.js";
3
5
  import { unit } from "./embed.js";
4
6
  export const OPENAI_URL = "https://api.openai.com/v1";
5
7
  /** OpenAI's models, from its pricing page as read on 2026-10-02. */
@@ -10,9 +12,8 @@ export const OPENAI_MODELS = {
10
12
  export const DEFAULT_OPENAI_MODEL = "text-embedding-3-small";
11
13
  /** OpenAI's limits per request (2,048 inputs, 300,000 tokens); a chunk is at most ~400 tokens. */
12
14
  const PER_REQUEST = 256;
13
- const LOCAL = new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
14
15
  /** A server on this machine: nothing leaves it, so nothing is asked. */
15
- export const isLocal = (baseUrl) => LOCAL.has(new URL(baseUrl).hostname);
16
+ export const isLocal = (baseUrl) => onThisComputer(baseUrl);
16
17
  export const remoteModel = ({ model = DEFAULT_OPENAI_MODEL, baseUrl, dims, }) => {
17
18
  const known = baseUrl === undefined ? OPENAI_MODELS[model] : undefined;
18
19
  if (baseUrl === undefined && !known) {
@@ -34,7 +35,8 @@ export const remoteModel = ({ model = DEFAULT_OPENAI_MODEL, baseUrl, dims, }) =>
34
35
  /** The vector key of a remote model, beside `local:<model>:<dims>`. */
35
36
  export const remoteKey = ({ provider, model, dims }) => `${provider}:${model}:${dims}`;
36
37
  /** Up to `concurrency` requests at once; a 429 waits for `Retry-After`, a server error is tried again. */
37
- export const openRemote = (remote, apiKey, { concurrency = 4, fetch: post = fetch, tries = 5 } = {}) => {
38
+ export const openRemote = (remote, apiKey, { concurrency = 4, fetch: post = fetch, tries = 5, env, }) => {
39
+ refuseModelAddress(env ?? process.env, remote.baseUrl, "text to embed");
38
40
  const request = async (input) => {
39
41
  for (let attempt = 1;; attempt++) {
40
42
  let response;
@@ -93,4 +93,7 @@ export declare const attachmentTextChange: v.StrictObjectSchema<{
93
93
  readonly origin: v.LiteralSchema<"agent", undefined>;
94
94
  readonly chars: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
95
95
  readonly replaced: v.NullableSchema<v.PicklistSchema<["extracted", "agent"], undefined>, undefined>;
96
+ /** `images read` only: who read the picture, `agent:claude` or `agent:codex/<model>`, and what it read. */
97
+ readonly extractor: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
98
+ readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
96
99
  }, undefined>;
@@ -28,4 +28,7 @@ export const attachmentTextChange = v.strictObject({
28
28
  origin: v.literal("agent"),
29
29
  chars: count,
30
30
  replaced: v.nullable(v.picklist(["extracted", "agent"])),
31
+ /** `images read` only: who read the picture, `agent:claude` or `agent:codex/<model>`, and what it read. */
32
+ extractor: v.optional(text),
33
+ text: v.optional(text),
31
34
  });
@@ -45,4 +45,6 @@ export declare const hitFile: v.StrictObjectSchema<{
45
45
  readonly kind: v.StringSchema<undefined>;
46
46
  readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
47
47
  readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
48
+ /** The saved copy on this computer, once `messages download` fetched it; absent until then. */
49
+ readonly local_path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
48
50
  }, undefined>;
@@ -36,4 +36,11 @@ export const attachment = v.strictObject({
36
36
  })))),
37
37
  });
38
38
  /** A file named on a search hit: `position` is the one `attachments show` and `messages download` take. */
39
- export const hitFile = v.strictObject({ position: count, kind: text, name: v.optional(text), size: v.optional(count) });
39
+ export const hitFile = v.strictObject({
40
+ position: count,
41
+ kind: text,
42
+ name: v.optional(text),
43
+ size: v.optional(count),
44
+ /** The saved copy on this computer, once `messages download` fetched it; absent until then. */
45
+ local_path: v.optional(text),
46
+ });
@@ -55,6 +55,7 @@ export declare const hit: v.StrictObjectSchema<{
55
55
  readonly kind: v.StringSchema<undefined>;
56
56
  readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
57
57
  readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
58
+ readonly local_path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
58
59
  }, undefined>, undefined>, undefined>;
59
60
  /** Absent on a note hit: the owner wrote it. */
60
61
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
@@ -40,7 +40,7 @@ import { inviteLink } from "./invite-link.js";
40
40
  import { job } from "./job.js";
41
41
  import { joinRequest } from "./join-request.js";
42
42
  import { organization, project, reminder } from "./knowledge-lists.js";
43
- import { botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, callRecord, scheduledJob, stickerInventory, topicIcon } from "./list-results.js";
43
+ import { botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, callRecord, scheduledJob, scheduleHarness, stickerInventory, topicIcon } from "./list-results.js";
44
44
  import { messageEvent, serveSummary, watchedMessage, watchItem } from "./listener.js";
45
45
  import { mailCounts } from "./mail-counts.js";
46
46
  import { mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer } from "./media-archive.js";
@@ -91,7 +91,7 @@ import { topic } from "./topic.js";
91
91
  * subset of its fields, never a renamed one. Commands move onto these one by one; until then, a schema
92
92
  * is the target, not a description of today's output.
93
93
  */
94
- export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledJob, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeImport, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, template, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
94
+ export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledJob, scheduleHarness, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeImport, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, template, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
95
95
  export declare const ENTITIES: {
96
96
  readonly meeting_ingestion: v.StrictObjectSchema<{
97
97
  readonly meetings: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -1459,6 +1459,7 @@ export declare const ENTITIES: {
1459
1459
  readonly kind: v.StringSchema<undefined>;
1460
1460
  readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1461
1461
  readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
1462
+ readonly local_path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
1462
1463
  }, undefined>, undefined>, undefined>;
1463
1464
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
1464
1465
  }, undefined>;
@@ -4248,9 +4249,22 @@ export declare const ENTITIES: {
4248
4249
  readonly error: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4249
4250
  }, undefined>, undefined>, undefined>;
4250
4251
  }, undefined>, undefined>;
4251
- readonly spent_today_usd: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
4252
+ readonly harness: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
4253
+ readonly reports_cost: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4254
+ readonly spent_today_usd: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
4252
4255
  readonly max_cost_usd: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
4253
- readonly max_cost_per_day_usd: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
4256
+ readonly max_cost_per_day_usd: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
4257
+ }, undefined>;
4258
+ readonly schedule_harness: v.StrictObjectSchema<{
4259
+ readonly id: v.StringSchema<undefined>;
4260
+ readonly name: v.StringSchema<undefined>;
4261
+ readonly programs: v.ArraySchema<v.StringSchema<undefined>, undefined>;
4262
+ readonly reports_cost: v.BooleanSchema<undefined>;
4263
+ readonly restricted: v.BooleanSchema<undefined>;
4264
+ readonly restricted_reason: v.NullableSchema<v.StringSchema<undefined>, undefined>;
4265
+ readonly allowed_with_ack: v.BooleanSchema<undefined>;
4266
+ readonly installed: v.BooleanSchema<undefined>;
4267
+ readonly path: v.NullableSchema<v.StringSchema<undefined>, undefined>;
4254
4268
  }, undefined>;
4255
4269
  readonly call_record: v.StrictObjectSchema<{
4256
4270
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
@@ -4363,6 +4377,7 @@ export declare const ENTITIES: {
4363
4377
  readonly kind: v.StringSchema<undefined>;
4364
4378
  readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4365
4379
  readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
4380
+ readonly local_path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4366
4381
  }, undefined>, undefined>, undefined>;
4367
4382
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
4368
4383
  }, undefined>;
@@ -4521,6 +4536,8 @@ export declare const ENTITIES: {
4521
4536
  readonly origin: v.LiteralSchema<"agent", undefined>;
4522
4537
  readonly chars: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
4523
4538
  readonly replaced: v.NullableSchema<v.PicklistSchema<["extracted", "agent"], undefined>, undefined>;
4539
+ readonly extractor: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4540
+ readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4524
4541
  }, undefined>;
4525
4542
  readonly media_archive: v.StrictObjectSchema<{
4526
4543
  readonly directory: v.StringSchema<undefined>;
@@ -44,7 +44,7 @@ import { inviteLink } from "./invite-link.js";
44
44
  import { job } from "./job.js";
45
45
  import { joinRequest } from "./join-request.js";
46
46
  import { organization, project, reminder } from "./knowledge-lists.js";
47
- import { botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, callRecord, scheduledJob, stickerInventory, topicIcon, } from "./list-results.js";
47
+ import { botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, callRecord, scheduledJob, scheduleHarness, stickerInventory, topicIcon, } from "./list-results.js";
48
48
  import { messageEvent, serveSummary, watchedMessage, watchItem } from "./listener.js";
49
49
  import { mailCounts } from "./mail-counts.js";
50
50
  import { mailFindings } from "./mail-findings.js";
@@ -100,7 +100,7 @@ import { topic } from "./topic.js";
100
100
  * subset of its fields, never a renamed one. Commands move onto these one by one; until then, a schema
101
101
  * is the target, not a description of today's output.
102
102
  */
103
- export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledJob, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeImport, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, template, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
103
+ export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledJob, scheduleHarness, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeImport, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, template, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
104
104
  export const ENTITIES = {
105
105
  sync_progress: syncProgress,
106
106
  deal,
@@ -207,6 +207,7 @@ export const ENTITIES = {
207
207
  topic_icon: topicIcon,
208
208
  bot_webhook: botWebhook,
209
209
  scheduled_job: scheduledJob,
210
+ schedule_harness: scheduleHarness,
210
211
  call_record: callRecord,
211
212
  sticker_inventory: stickerInventory,
212
213
  note,
@@ -81,12 +81,40 @@ export declare const scheduledJob: v.StrictObjectSchema<{
81
81
  readonly error: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
82
82
  }, undefined>, undefined>, undefined>;
83
83
  }, undefined>, undefined>;
84
- /** Agent schedules: what today's runs cost, in US dollars. */
85
- readonly spent_today_usd: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
86
- /** Agent schedules: the cap on one run (`--max-cost`), null when none. */
84
+ /** Agent schedules: the agent it starts, as `schedule agents list` names it; null for a program no agent here runs. */
85
+ readonly harness: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
86
+ /** Agent schedules: whether the agent reports what a run cost; when it does not, the cost fields are null. */
87
+ readonly reports_cost: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
88
+ /** Agent schedules: what today's runs cost, in US dollars; null when the agent reports no cost (unknown, not 0). */
89
+ readonly spent_today_usd: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
90
+ /** Agent schedules: the cap on one run (`--max-cost`), null when none or when the agent reports no cost. */
87
91
  readonly max_cost_usd: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
88
- /** Agent schedules: the daily cap in force, the schedule's `--max-cost-per-day` or the config's; 0 for none. */
89
- readonly max_cost_per_day_usd: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
92
+ /**
93
+ * Agent schedules: the daily cap in force, the schedule's `--max-cost-per-day` or the config's; 0 for none; null when
94
+ * the agent reports no cost, so no cap can stop it.
95
+ */
96
+ readonly max_cost_per_day_usd: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
97
+ }, undefined>;
98
+ /** One agent `schedule agents list` answers: an id `schedule agent` takes, and whether its program is on PATH. */
99
+ export declare const scheduleHarness: v.StrictObjectSchema<{
100
+ readonly id: v.StringSchema<undefined>;
101
+ readonly name: v.StringSchema<undefined>;
102
+ /** The program names it is found by on PATH, the first found wins. */
103
+ readonly programs: v.ArraySchema<v.StringSchema<undefined>, undefined>;
104
+ /** It reports what a run costs, so `--max-cost` and `--max-cost-per-day` hold. */
105
+ readonly reports_cost: v.BooleanSchema<undefined>;
106
+ /** The agent's own limits hold a one-shot run to the CLIs' commands (claude, gemini, opencode). */
107
+ readonly restricted: v.BooleanSchema<undefined>;
108
+ /** Why an agent that is not restricted is not, and what it may still do: a client shows it before the owner picks. */
109
+ readonly restricted_reason: v.NullableSchema<v.StringSchema<undefined>, undefined>;
110
+ /**
111
+ * Not restricted, yet a schedule starts it once the owner accepts that with `--allow-dangerous` (codex, whose sandbox
112
+ * blocks the network and most writes); refused without it (`agent.unrestricted`). False for the rest.
113
+ */
114
+ readonly allowed_with_ack: v.BooleanSchema<undefined>;
115
+ readonly installed: v.BooleanSchema<undefined>;
116
+ /** Where its program is, or null when it is not on PATH. */
117
+ readonly path: v.NullableSchema<v.StringSchema<undefined>, undefined>;
90
118
  }, undefined>;
91
119
  export declare const botTemplate: v.StrictObjectSchema<{
92
120
  readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -65,12 +65,40 @@ export const scheduledJob = v.strictObject({
65
65
  error: v.optional(text),
66
66
  }))),
67
67
  })),
68
- /** Agent schedules: what today's runs cost, in US dollars. */
69
- spent_today_usd: v.optional(v.number()),
70
- /** Agent schedules: the cap on one run (`--max-cost`), null when none. */
68
+ /** Agent schedules: the agent it starts, as `schedule agents list` names it; null for a program no agent here runs. */
69
+ harness: v.optional(v.nullable(text)),
70
+ /** Agent schedules: whether the agent reports what a run cost; when it does not, the cost fields are null. */
71
+ reports_cost: v.optional(v.boolean()),
72
+ /** Agent schedules: what today's runs cost, in US dollars; null when the agent reports no cost (unknown, not 0). */
73
+ spent_today_usd: v.optional(v.nullable(v.number())),
74
+ /** Agent schedules: the cap on one run (`--max-cost`), null when none or when the agent reports no cost. */
71
75
  max_cost_usd: v.optional(v.nullable(v.number())),
72
- /** Agent schedules: the daily cap in force, the schedule's `--max-cost-per-day` or the config's; 0 for none. */
73
- max_cost_per_day_usd: v.optional(v.number()),
76
+ /**
77
+ * Agent schedules: the daily cap in force, the schedule's `--max-cost-per-day` or the config's; 0 for none; null when
78
+ * the agent reports no cost, so no cap can stop it.
79
+ */
80
+ max_cost_per_day_usd: v.optional(v.nullable(v.number())),
81
+ });
82
+ /** One agent `schedule agents list` answers: an id `schedule agent` takes, and whether its program is on PATH. */
83
+ export const scheduleHarness = v.strictObject({
84
+ id: text,
85
+ name: text,
86
+ /** The program names it is found by on PATH, the first found wins. */
87
+ programs: v.array(text),
88
+ /** It reports what a run costs, so `--max-cost` and `--max-cost-per-day` hold. */
89
+ reports_cost: v.boolean(),
90
+ /** The agent's own limits hold a one-shot run to the CLIs' commands (claude, gemini, opencode). */
91
+ restricted: v.boolean(),
92
+ /** Why an agent that is not restricted is not, and what it may still do: a client shows it before the owner picks. */
93
+ restricted_reason: v.nullable(text),
94
+ /**
95
+ * Not restricted, yet a schedule starts it once the owner accepts that with `--allow-dangerous` (codex, whose sandbox
96
+ * blocks the network and most writes); refused without it (`agent.unrestricted`). False for the rest.
97
+ */
98
+ allowed_with_ack: v.boolean(),
99
+ installed: v.boolean(),
100
+ /** Where its program is, or null when it is not on PATH. */
101
+ path: v.nullable(text),
74
102
  });
75
103
  export const botTemplate = v.strictObject({
76
104
  name: v.nullable(text),