@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
@@ -1,10 +1,12 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import { annotate } from "@wirecat/cli-base/commands";
3
3
  import { Command } from "commander";
4
+ import { parseDuration } from "../domain/duration.js";
5
+ import { refuseModelAddress } from "../models/local-only.js";
4
6
  import { agentOf } from "../runs/run-context.js";
5
7
  import { keyLookup, keyVariable } from "../services/enrichment.js";
6
8
  import { ENRICHMENT_PROVIDERS, enrichmentEndpoint, enrichmentPrice, isEnrichmentProvider, readEnrichmentSetting, } from "../services/enrichment-setting.js";
7
- import { HARDER_CANDIDATES, HARDER_CHARS, HARDER_MODELS, readHarderSetting, writeHarderSetting, } from "../services/search-harder.js";
9
+ import { HARDER_CANDIDATES, HARDER_CHARS, HARDER_MODELS, HARDER_TIMEOUT_S, harderTimeoutSeconds, readHarderSetting, readHarderTimeout, writeHarderSetting, writeHarderTimeout, } from "../services/search-harder.js";
8
10
  import { grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "./effects.js";
9
11
  import { itemOf } from "./envelope.js";
10
12
  // One search: 30 hits of up to 400 characters plus the prompt, and a short list of hit numbers back.
@@ -45,6 +47,8 @@ const state = (app, options, given) => {
45
47
  endpoint: enrichmentEndpoint(chosen),
46
48
  ...(enrichment ? { proposed_from: "enrichment" } : {}),
47
49
  consented_at: setting?.consented_at ?? null,
50
+ timeout_s: harderTimeoutSeconds(env, enrichmentEndpoint(chosen)),
51
+ timeout_set: readHarderTimeout(env) !== undefined,
48
52
  candidates: HARDER_CANDIDATES,
49
53
  chars_per_hit: HARDER_CHARS,
50
54
  usd_per_million: price
@@ -55,6 +59,12 @@ const state = (app, options, given) => {
55
59
  off_command: `${app.command} models search-consents revoke`,
56
60
  };
57
61
  };
62
+ const seconds = (value) => {
63
+ const ms = parseDuration(value, "--timeout");
64
+ if (ms < 1000 || ms > 600_000)
65
+ throw new CliError("validation_error", "--timeout takes 1s to 10m");
66
+ return Math.round(ms / 1000);
67
+ };
58
68
  /**
59
69
  * The owner's consent that `search all --harder` may send a question and its hits to a hosted model. Off until
60
70
  * `set … --yes`; with it, still only a search that asks with --harder sends anything.
@@ -77,6 +87,8 @@ export const harderConsentsCommand = (app, options) => {
77
87
  .argument("<provider>", `the provider that receives the question and hits: ${ENRICHMENT_PROVIDERS.join(" or ")}`)
78
88
  .option("--model <model>", `the provider's model; ${HARDER_MODELS.anthropic} or ${HARDER_MODELS.openai} if left out`)
79
89
  .option("--base-url <url>", "the address of an OpenAI-compatible model API (OpenRouter…); needs --model")
90
+ .option("--timeout <duration>", `how long a --harder search waits for the model, 1s to 10m (30s, 2m); ${HARDER_TIMEOUT_S.hosted} s for a hosted model, ` +
91
+ `${HARDER_TIMEOUT_S.local} s for one on this computer until one is set; kept until set again`, seconds)
80
92
  .option("--yes", "agree that a --harder search sends its question and hits, and allow it")
81
93
  .action(function (provider, given) {
82
94
  if (!isEnrichmentProvider(provider))
@@ -95,6 +107,7 @@ export const harderConsentsCommand = (app, options) => {
95
107
  model: given.model ?? HARDER_MODELS[provider],
96
108
  ...(given.baseUrl === undefined ? {} : { base_url: given.baseUrl }),
97
109
  };
110
+ refuseModelAddress(env, enrichmentEndpoint(chosen), "a --harder search's question and hits");
98
111
  if (!given.yes) {
99
112
  const now = state(app, options, chosen);
100
113
  options.diagnostic(`${now.consent}\nNothing changed — add --yes to allow it.`);
@@ -102,6 +115,8 @@ export const harderConsentsCommand = (app, options) => {
102
115
  return;
103
116
  }
104
117
  writeHarderSetting(env, { ...chosen, consented_at: new Date().toISOString() });
118
+ if (given.timeout !== undefined)
119
+ writeHarderTimeout(env, given.timeout);
105
120
  options.diagnostic(`search all --harder may now call ${provider} ${chosen.model}`);
106
121
  options.output(itemOf({ ...state(app, options), changed: true }), this);
107
122
  });
@@ -184,6 +184,192 @@ export declare const appDoctorCommand: (app: import("./entry.js").AppIdentity, c
184
184
  }, (issue: import("valibot").StrictObjectIssue) => string>;
185
185
  permissions?: import("./permission-keys.js").CommandPermissions | undefined;
186
186
  }, options?: import("./app-doctor-command.js").AppDoctorOptions | undefined) => import("commander").Command;
187
+ export declare const appCompleteCommand: (app: Pick<import("./entry.js").AppIdentity, "command" | "envPrefix">, config: Pick<{
188
+ resolveSettings: (flags?: import("./settings.js").GlobalFlags, options?: import("./settings.js").ResolveOptions) => import("./settings.js").Settings & object;
189
+ configuredProfiles: (options?: import("./settings.js").ResolveOptions) => string[];
190
+ changeSetting: (path: string, { profile, setting, value, kind, root, }: {
191
+ profile: string | undefined;
192
+ setting: string;
193
+ value: string | undefined;
194
+ kind?: import("./settings.js").ProfileKind | undefined;
195
+ root?: boolean;
196
+ }) => unknown;
197
+ migrate: (path: string) => string[];
198
+ declaredSettings: import("./setting-defaults.js").DeclaredSetting[];
199
+ allSettings: string[];
200
+ defaultsOnlyKeys: string[];
201
+ schema: import("valibot").StrictObjectSchema<{
202
+ defaults: import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
203
+ embedding_provider: ({
204
+ embeddingProvider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["local", "openai"], undefined>, undefined>;
205
+ embeddingModel: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
206
+ embeddingBaseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
207
+ embeddingDims: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>, import("valibot").MaxValueAction<number, 65536, undefined>]>, undefined>;
208
+ models: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").RegexAction<string, undefined>]>, import("valibot").StrictObjectSchema<{
209
+ readonly provider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["off", "openai", "anthropic"], undefined>, undefined>;
210
+ readonly model: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
211
+ readonly base_url: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
212
+ }, undefined>, undefined>, undefined>;
213
+ })["embeddingProvider"];
214
+ embedding_model: ({
215
+ embeddingProvider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["local", "openai"], undefined>, undefined>;
216
+ embeddingModel: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
217
+ embeddingBaseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
218
+ embeddingDims: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>, import("valibot").MaxValueAction<number, 65536, undefined>]>, undefined>;
219
+ models: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").RegexAction<string, undefined>]>, import("valibot").StrictObjectSchema<{
220
+ readonly provider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["off", "openai", "anthropic"], undefined>, undefined>;
221
+ readonly model: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
222
+ readonly base_url: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
223
+ }, undefined>, undefined>, undefined>;
224
+ })["embeddingModel"];
225
+ embedding_base_url: ({
226
+ embeddingProvider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["local", "openai"], undefined>, undefined>;
227
+ embeddingModel: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
228
+ embeddingBaseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
229
+ embeddingDims: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>, import("valibot").MaxValueAction<number, 65536, undefined>]>, undefined>;
230
+ models: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").RegexAction<string, undefined>]>, import("valibot").StrictObjectSchema<{
231
+ readonly provider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["off", "openai", "anthropic"], undefined>, undefined>;
232
+ readonly model: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
233
+ readonly base_url: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
234
+ }, undefined>, undefined>, undefined>;
235
+ })["embeddingBaseUrl"];
236
+ embedding_dims: ({
237
+ embeddingProvider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["local", "openai"], undefined>, undefined>;
238
+ embeddingModel: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
239
+ embeddingBaseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
240
+ embeddingDims: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>, import("valibot").MaxValueAction<number, 65536, undefined>]>, undefined>;
241
+ models: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").RegexAction<string, undefined>]>, import("valibot").StrictObjectSchema<{
242
+ readonly provider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["off", "openai", "anthropic"], undefined>, undefined>;
243
+ readonly model: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
244
+ readonly base_url: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
245
+ }, undefined>, undefined>, undefined>;
246
+ })["embeddingDims"];
247
+ models: ({
248
+ embeddingProvider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["local", "openai"], undefined>, undefined>;
249
+ embeddingModel: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
250
+ embeddingBaseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
251
+ embeddingDims: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>, import("valibot").MaxValueAction<number, 65536, undefined>]>, undefined>;
252
+ models: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").RegexAction<string, undefined>]>, import("valibot").StrictObjectSchema<{
253
+ readonly provider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["off", "openai", "anthropic"], undefined>, undefined>;
254
+ readonly model: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
255
+ readonly base_url: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
256
+ }, undefined>, undefined>, undefined>;
257
+ })["models"];
258
+ limit: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
259
+ timeout_ms: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
260
+ color: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
261
+ sender_colors: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
262
+ record: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
263
+ record_input: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").BooleanSchema<undefined>, import("valibot").LiteralSchema<"failed", undefined>], (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
264
+ keep_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
265
+ keep_successful_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
266
+ keep_store_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
267
+ runs_size_limit_mb: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
268
+ permissions: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").GenericSchema<string>, import("valibot").PicklistSchema<readonly ["deny", "readonly", "ask", "allow"], (issue: import("valibot").PicklistIssue) => string>, (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
269
+ sends_per_hour: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
270
+ requests_per_minute: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 0, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
271
+ transcribe_with: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["auto", "messenger", "local"], (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
272
+ speech_model: import("valibot").OptionalSchema<import("valibot").StringSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
273
+ search_catch_up: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
274
+ history_dialog_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MaxValueAction<number, 1095, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
275
+ history_group_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MaxValueAction<number, 1095, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
276
+ history_group_members_max: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
277
+ history_muted: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
278
+ picture_search: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
279
+ search_reranker: import("valibot").OptionalSchema<import("valibot").PicklistSchema<[...string[], "off"], (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
280
+ update_check: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
281
+ skill_hint: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
282
+ }, (issue: import("valibot").StrictObjectIssue) => string>, undefined>;
283
+ profiles: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").StringSchema<undefined>, import("valibot").StrictObjectSchema<{
284
+ embedding_provider: ({
285
+ embeddingProvider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["local", "openai"], undefined>, undefined>;
286
+ embeddingModel: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
287
+ embeddingBaseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
288
+ embeddingDims: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>, import("valibot").MaxValueAction<number, 65536, undefined>]>, undefined>;
289
+ models: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").RegexAction<string, undefined>]>, import("valibot").StrictObjectSchema<{
290
+ readonly provider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["off", "openai", "anthropic"], undefined>, undefined>;
291
+ readonly model: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
292
+ readonly base_url: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
293
+ }, undefined>, undefined>, undefined>;
294
+ })["embeddingProvider"];
295
+ embedding_model: ({
296
+ embeddingProvider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["local", "openai"], undefined>, undefined>;
297
+ embeddingModel: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
298
+ embeddingBaseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
299
+ embeddingDims: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>, import("valibot").MaxValueAction<number, 65536, undefined>]>, undefined>;
300
+ models: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").RegexAction<string, undefined>]>, import("valibot").StrictObjectSchema<{
301
+ readonly provider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["off", "openai", "anthropic"], undefined>, undefined>;
302
+ readonly model: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
303
+ readonly base_url: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
304
+ }, undefined>, undefined>, undefined>;
305
+ })["embeddingModel"];
306
+ embedding_base_url: ({
307
+ embeddingProvider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["local", "openai"], undefined>, undefined>;
308
+ embeddingModel: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
309
+ embeddingBaseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
310
+ embeddingDims: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>, import("valibot").MaxValueAction<number, 65536, undefined>]>, undefined>;
311
+ models: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").RegexAction<string, undefined>]>, import("valibot").StrictObjectSchema<{
312
+ readonly provider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["off", "openai", "anthropic"], undefined>, undefined>;
313
+ readonly model: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
314
+ readonly base_url: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
315
+ }, undefined>, undefined>, undefined>;
316
+ })["embeddingBaseUrl"];
317
+ embedding_dims: ({
318
+ embeddingProvider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["local", "openai"], undefined>, undefined>;
319
+ embeddingModel: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
320
+ embeddingBaseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
321
+ embeddingDims: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>, import("valibot").MaxValueAction<number, 65536, undefined>]>, undefined>;
322
+ models: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").RegexAction<string, undefined>]>, import("valibot").StrictObjectSchema<{
323
+ readonly provider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["off", "openai", "anthropic"], undefined>, undefined>;
324
+ readonly model: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
325
+ readonly base_url: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
326
+ }, undefined>, undefined>, undefined>;
327
+ })["embeddingDims"];
328
+ models: ({
329
+ embeddingProvider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["local", "openai"], undefined>, undefined>;
330
+ embeddingModel: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
331
+ embeddingBaseUrl: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
332
+ embeddingDims: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<undefined>, import("valibot").IntegerAction<number, undefined>, import("valibot").MinValueAction<number, 1, undefined>, import("valibot").MaxValueAction<number, 65536, undefined>]>, undefined>;
333
+ models: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").RegexAction<string, undefined>]>, import("valibot").StrictObjectSchema<{
334
+ readonly provider: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["off", "openai", "anthropic"], undefined>, undefined>;
335
+ readonly model: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").TrimAction, import("valibot").MinLengthAction<string, 1, undefined>, import("valibot").MaxLengthAction<string, 200, undefined>]>, undefined>;
336
+ readonly base_url: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").StringSchema<undefined>, import("valibot").CheckAction<string, "use an HTTP/S endpoint without credentials, query or fragment">]>, undefined>;
337
+ }, undefined>, undefined>, undefined>;
338
+ })["models"];
339
+ limit: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
340
+ timeout_ms: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
341
+ color: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
342
+ sender_colors: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
343
+ record: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
344
+ record_input: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").BooleanSchema<undefined>, import("valibot").LiteralSchema<"failed", undefined>], (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
345
+ keep_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
346
+ keep_successful_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
347
+ keep_store_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
348
+ runs_size_limit_mb: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
349
+ permissions: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").GenericSchema<string>, import("valibot").PicklistSchema<readonly ["deny", "readonly", "ask", "allow"], (issue: import("valibot").PicklistIssue) => string>, (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
350
+ sends_per_hour: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
351
+ requests_per_minute: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 0, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
352
+ transcribe_with: import("valibot").OptionalSchema<import("valibot").PicklistSchema<["auto", "messenger", "local"], (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
353
+ speech_model: import("valibot").OptionalSchema<import("valibot").StringSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
354
+ search_catch_up: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
355
+ history_dialog_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MaxValueAction<number, 1095, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
356
+ history_group_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MaxValueAction<number, 1095, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
357
+ history_group_members_max: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
358
+ history_muted: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
359
+ picture_search: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
360
+ search_reranker: import("valibot").OptionalSchema<import("valibot").PicklistSchema<[...string[], "off"], (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
361
+ }, (issue: import("valibot").StrictObjectIssue) => string>, "has to be an object of profiles, by name">, {}>;
362
+ personal: import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
363
+ readonly defaults: import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<import("valibot").ObjectEntries, (issue: import("valibot").StrictObjectIssue) => string>, undefined>;
364
+ readonly profiles: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").StringSchema<undefined>, import("valibot").StrictObjectSchema<import("valibot").ObjectEntries, (issue: import("valibot").StrictObjectIssue) => string>, "has to be an object of profiles, by name">, undefined>;
365
+ }, (issue: import("valibot").StrictObjectIssue) => string>, undefined>;
366
+ bot: import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<{
367
+ readonly defaults: import("valibot").OptionalSchema<import("valibot").StrictObjectSchema<import("valibot").ObjectEntries, (issue: import("valibot").StrictObjectIssue) => string>, undefined>;
368
+ readonly profiles: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").StringSchema<undefined>, import("valibot").StrictObjectSchema<import("valibot").ObjectEntries, (issue: import("valibot").StrictObjectIssue) => string>, "has to be an object of profiles, by name">, undefined>;
369
+ }, (issue: import("valibot").StrictObjectIssue) => string>, undefined>;
370
+ }, (issue: import("valibot").StrictObjectIssue) => string>;
371
+ permissions?: import("./permission-keys.js").CommandPermissions | undefined;
372
+ }, "configuredProfiles">, options?: import("./complete-command.js").AppCompletionOptions | undefined) => import("commander").Command;
187
373
  export declare const appMcpCommand: (app: import("./entry.js").AppIdentity, configuration: {
188
374
  resolveSettings: (flags?: import("./settings.js").GlobalFlags, options?: import("./settings.js").ResolveOptions) => import("./settings.js").Settings & object;
189
375
  configuredProfiles: (options?: import("./settings.js").ResolveOptions) => string[];
@@ -6,6 +6,7 @@ import { botCommand as botCommandDefinition } from "./bot/command.js";
6
6
  import { botMcpCommand as botMcpCommandDefinition } from "./bot/mcp.js";
7
7
  import { botMessagesCommand as botMessagesCommandDefinition } from "./bot/messages.js";
8
8
  import { commandsCommand as commandsCommandDefinition } from "./commands-command.js";
9
+ import { appCompleteCommand as appCompleteCommandDefinition } from "./complete-command.js";
9
10
  import { configCommand as configCommandDefinition } from "./config-command.js";
10
11
  import { honoursDryRun } from "./dry-run-guard.js";
11
12
  import { guideCommand as guideCommandDefinition } from "./guide.js";
@@ -58,6 +59,7 @@ import { skillCommand as skillCommandDefinition } from "./skill-command.js";
58
59
  import { upgradeCommand as upgradeCommandDefinition } from "./upgrade-command.js";
59
60
  const sharedCommand = (factory) => honoursDryRun(protectedCommand(factory));
60
61
  export const appDoctorCommand = sharedCommand(appDoctorCommandDefinition);
62
+ export const appCompleteCommand = sharedCommand(appCompleteCommandDefinition);
61
63
  export const appMcpCommand = sharedCommand(appMcpCommandDefinition);
62
64
  export const botAdminsCommand = sharedCommand(botAdminsCommandDefinition);
63
65
  export const botMembersCommand = sharedCommand(botMembersCommandDefinition);
@@ -0,0 +1,25 @@
1
+ import type { Command } from "commander";
2
+ import { type AppIdentity } from "../ports/app.js";
3
+ /**
4
+ * The mark a scheduled agent's run put on the CLIs it may run, or nothing outside such a run. It is read from the
5
+ * agent's own start, so a command the agent runs cannot name another, and only a locked run has one.
6
+ */
7
+ export declare const untrustedMarkOf: (app: AppIdentity, env: NodeJS.ProcessEnv) => string | undefined;
8
+ /** Other people's text between the run's markers, with every bracket and the mark taken out, so it can close none. */
9
+ export declare const marked: (text: string, mark: string, source: string, id?: string) => string;
10
+ /**
11
+ * The answer with each field an object names in its `untrusted` list between the run's markers, at any depth. Other
12
+ * fields, and the shape, stay as they are.
13
+ */
14
+ export declare const withUntrustedMarked: <T>(value: T, mark: string, id?: string) => T;
15
+ /**
16
+ * Other people's text in a message or an email at any depth of an answer: its text and transcript, who sent it and to
17
+ * whom, the chat's title, the subject, and the attachments' names and text. The fields a read lists here are not in
18
+ * its answer's own `untrusted` list, which would change what every caller reads.
19
+ */
20
+ export declare const MESSAGE_UNTRUSTED: readonly ["text", "transcript", "excerpt", "sender_name", "sender_username", "chat_title", "subject", "snippet", "attachments.name", "attachments.title", "attachments.text", "from.name", "to.name", "cc.name", "bcc.name", "reply_addresses.name"];
21
+ /** Declares the fields of a read's answer that hold other people's text, at any depth, for a scheduled agent's run. */
22
+ export declare const marksUntrusted: <T extends Command>(command: T, fields?: readonly string[]) => T;
23
+ export declare const untrustedFieldsOf: (command: Command) => readonly string[] | undefined;
24
+ /** The answer with each of `fields` marked wherever an object in it has that path. */
25
+ export declare const withFieldsMarked: <T>(value: T, fields: readonly string[], mark: string, id?: string) => T;
@@ -0,0 +1,102 @@
1
+ import { ancestorValue, envName, readOnlyLockOf } from "../ports/app.js";
2
+ const OPEN = "⟦";
3
+ const CLOSE = "⟧";
4
+ /**
5
+ * The mark a scheduled agent's run put on the CLIs it may run, or nothing outside such a run. It is read from the
6
+ * agent's own start, so a command the agent runs cannot name another, and only a locked run has one.
7
+ */
8
+ export const untrustedMarkOf = (app, env) => {
9
+ if (readOnlyLockOf(app, env) === undefined)
10
+ return undefined;
11
+ const mark = ancestorValue(envName(app, "UNTRUSTED_MARK"), env);
12
+ return mark && /^[0-9a-f]{16}$/.test(mark) ? mark : undefined;
13
+ };
14
+ /** Other people's text between the run's markers, with every bracket and the mark taken out, so it can close none. */
15
+ export const marked = (text, mark, source, id) => {
16
+ const inside = text.replaceAll(OPEN, "").replaceAll(CLOSE, "").replaceAll(mark, "");
17
+ const named = id === undefined ? "" : ` id=${id.replaceAll(OPEN, "").replaceAll(CLOSE, "").replace(/\s/g, "")}`;
18
+ return `${OPEN}untrusted:${mark} source=${source}${named}${CLOSE}${inside}${OPEN}/untrusted:${mark}${CLOSE}`;
19
+ };
20
+ const idOf = (value) => {
21
+ const id = value.ref ?? value.id;
22
+ return typeof id === "string" || typeof id === "number" ? String(id) : undefined;
23
+ };
24
+ const markAt = (value, path, mark, source, id) => {
25
+ if (Array.isArray(value))
26
+ return value.map((one) => markAt(one, path, mark, source, id));
27
+ // A text a nested answer already marked holds no bracket of its own, so its opening one is the mark's.
28
+ if (path.length === 0)
29
+ return typeof value === "string" && !value.startsWith(`${OPEN}untrusted:${mark} `)
30
+ ? marked(value, mark, source, id)
31
+ : value;
32
+ if (value === null || typeof value !== "object")
33
+ return value;
34
+ const [key = "", ...rest] = path;
35
+ const record = value;
36
+ if (!(key in record))
37
+ return value;
38
+ return { ...record, [key]: markAt(record[key], rest, mark, source, idOf(record) ?? id) };
39
+ };
40
+ /**
41
+ * The answer with each field an object names in its `untrusted` list between the run's markers, at any depth. Other
42
+ * fields, and the shape, stay as they are.
43
+ */
44
+ export const withUntrustedMarked = (value, mark, id) => {
45
+ if (Array.isArray(value))
46
+ return value.map((one) => withUntrustedMarked(one, mark, id));
47
+ if (value === null || typeof value !== "object")
48
+ return value;
49
+ const record = value;
50
+ const own = idOf(record) ?? id;
51
+ let result = Object.fromEntries(Object.entries(record).map(([key, child]) => [
52
+ key,
53
+ key === "untrusted" ? child : withUntrustedMarked(child, mark, own),
54
+ ]));
55
+ const fields = Array.isArray(record.untrusted) ? record.untrusted.filter((one) => typeof one === "string") : [];
56
+ for (const field of fields)
57
+ result = markAt(result, field.split("."), mark, field, own);
58
+ return result;
59
+ };
60
+ /**
61
+ * Other people's text in a message or an email at any depth of an answer: its text and transcript, who sent it and to
62
+ * whom, the chat's title, the subject, and the attachments' names and text. The fields a read lists here are not in
63
+ * its answer's own `untrusted` list, which would change what every caller reads.
64
+ */
65
+ export const MESSAGE_UNTRUSTED = [
66
+ "text",
67
+ "transcript",
68
+ "excerpt",
69
+ "sender_name",
70
+ "sender_username",
71
+ "chat_title",
72
+ "subject",
73
+ "snippet",
74
+ "attachments.name",
75
+ "attachments.title",
76
+ "attachments.text",
77
+ "from.name",
78
+ "to.name",
79
+ "cc.name",
80
+ "bcc.name",
81
+ "reply_addresses.name",
82
+ ];
83
+ const DECLARED = new WeakMap();
84
+ /** Declares the fields of a read's answer that hold other people's text, at any depth, for a scheduled agent's run. */
85
+ export const marksUntrusted = (command, fields = MESSAGE_UNTRUSTED) => {
86
+ DECLARED.set(command, fields);
87
+ return command;
88
+ };
89
+ export const untrustedFieldsOf = (command) => DECLARED.get(command);
90
+ /** The answer with each of `fields` marked wherever an object in it has that path. */
91
+ export const withFieldsMarked = (value, fields, mark, id) => {
92
+ if (Array.isArray(value))
93
+ return value.map((one) => withFieldsMarked(one, fields, mark, id));
94
+ if (value === null || typeof value !== "object")
95
+ return value;
96
+ const record = value;
97
+ const own = idOf(record) ?? id;
98
+ let result = Object.fromEntries(Object.entries(record).map(([key, child]) => [key, withFieldsMarked(child, fields, mark, own)]));
99
+ for (const field of fields)
100
+ result = markAt(result, field.split("."), mark, field, own);
101
+ return result;
102
+ };
@@ -7,6 +7,7 @@ import type { CrmSource } from "../source.js";
7
7
  import type { CrmWriteCapabilities } from "../writer.js";
8
8
  import { type CrmWrites } from "../writes.js";
9
9
  export { type CsvField, type CsvPage, csvColumnPaths, csvFormatOption, DEAL_CSV_COLUMNS, printCsv, refuseCsvConflict, } from "./csv.js";
10
+ export { type CrmStoreOptions, openCrmStore } from "./store.js";
10
11
  /**
11
12
  * The selected profile's CRM account, opened by the app for one command and closed once its answer is built, before
12
13
  * anything is printed (WC-LIFE-4).
@@ -22,6 +22,7 @@ import { csvFormatOption, renderCsv } from "./csv.js";
22
22
  import { pipelineView } from "./pipeline-view.js";
23
23
  import { addCrmSearchAll } from "./search-all.js";
24
24
  export { csvColumnPaths, csvFormatOption, DEAL_CSV_COLUMNS, printCsv, refuseCsvConflict, } from "./csv.js";
25
+ export { openCrmStore } from "./store.js";
25
26
  const MOST = 500;
26
27
  /** A stage by the store's reference, as memo's `stages list` and a deal's `base_stage` name it. */
27
28
  const STAGE_REF = /^stage:\d+$/;
@@ -295,26 +296,26 @@ const addCrmCommandsDefinition = (program, options) => {
295
296
  ...(terms.has("stage") ? { stage: terms.get("stage") } : {}),
296
297
  ...(terms.has("pipeline") ? { pipeline: terms.get("pipeline") } : {}),
297
298
  ...(terms.has("organization") ? { organization: terms.get("organization") } : {}),
298
- limit: Math.min(opts.limit + 1, MOST),
299
+ limit: Math.min(opts.limit, MOST),
299
300
  offset: (opts.page - 1) * opts.limit,
300
301
  });
301
302
  if (opts.format === "csv")
302
303
  return renderCsv(command, options.open, async (run) => {
303
304
  const found = await read(run);
304
305
  return {
305
- items: marked(found.slice(0, opts.limit), DEAL_UNTRUSTED),
306
+ items: marked(found.items, DEAL_UNTRUSTED),
306
307
  fields: await run.store.crm.fields(run.account, kind),
307
308
  page: opts.page,
308
- hasMore: found.length > opts.limit,
309
+ hasMore: found.hasMore,
309
310
  };
310
311
  });
311
312
  await within(command, async (run) => {
312
313
  const found = await read(run);
313
314
  return listOf(pathOf(command).join(" "), {
314
- items: marked(found.slice(0, opts.limit), DEAL_UNTRUSTED),
315
+ items: marked(found.items, DEAL_UNTRUSTED),
315
316
  limit: opts.limit,
316
317
  page: opts.page,
317
- has_more: found.length > opts.limit,
318
+ has_more: found.hasMore,
318
319
  ...(words.length ? { args: { query: words } } : {}),
319
320
  });
320
321
  });
@@ -0,0 +1,30 @@
1
+ import { type AppIdentity } from "../../ports/app.js";
2
+ import type { MessageStore } from "../../store/store.js";
3
+ import type { AccountKey } from "../../store/types.js";
4
+ export interface CrmStoreOptions {
5
+ app: AppIdentity;
6
+ env: NodeJS.ProcessEnv;
7
+ profile: string;
8
+ /** The command only reads the store: `CrmCommandOptions.open`'s `readOnly`. */
9
+ readOnly: boolean;
10
+ /** The CRM's provider, as the store names it: the empty store's account under the read-only lock. */
11
+ provider: string;
12
+ /** Opens the shared store as the CLI does; a writable open also registers its provider. */
13
+ open: (env: NodeJS.ProcessEnv, options?: {
14
+ readOnly?: boolean;
15
+ }) => Promise<MessageStore>;
16
+ /** The profile's account from its sign-in; asked only when no earlier run saved it. */
17
+ account: () => AccountKey;
18
+ }
19
+ /**
20
+ * The store a CRM command reads, and the profile's account in it. A read takes the account an earlier run saved, so it
21
+ * never reads the sign-in; the first read of a profile, a store that is missing or needs a migration, and every sync
22
+ * and write open it for writing and save the account (scope work: a CRM is the owner's work) and the profile.
23
+ *
24
+ * Under `<PREFIX>_READ_ONLY` a read with no store or no saved profile reads an empty store in a temporary folder, so
25
+ * the lock creates no `wirecat.db`; the folder goes when the store closes. A sync still writes, as a fetch may.
26
+ */
27
+ export declare const openCrmStore: (options: CrmStoreOptions) => Promise<{
28
+ store: MessageStore;
29
+ account: AccountKey;
30
+ }>;
@@ -0,0 +1,63 @@
1
+ import { mkdtempSync, rmSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { isCliError } from "@wirecat/cli-base";
5
+ import { readOnlyLockOf } from "../../ports/app.js";
6
+ /**
7
+ * The store a CRM command reads, and the profile's account in it. A read takes the account an earlier run saved, so it
8
+ * never reads the sign-in; the first read of a profile, a store that is missing or needs a migration, and every sync
9
+ * and write open it for writing and save the account (scope work: a CRM is the owner's work) and the profile.
10
+ *
11
+ * Under `<PREFIX>_READ_ONLY` a read with no store or no saved profile reads an empty store in a temporary folder, so
12
+ * the lock creates no `wirecat.db`; the folder goes when the store closes. A sync still writes, as a fetch may.
13
+ */
14
+ export const openCrmStore = async (options) => {
15
+ const { app, env, profile, readOnly, open } = options;
16
+ const locked = readOnly && readOnlyLockOf(app, env) !== undefined;
17
+ if (readOnly) {
18
+ const store = await open(env, { readOnly: true }).catch((error) => {
19
+ if (locked && !(isCliError(error) && error.code === "not_found"))
20
+ throw error;
21
+ return undefined;
22
+ });
23
+ if (store) {
24
+ const saved = await store.accounts
25
+ .profiles()
26
+ .then((all) => all[app.command]?.[profile])
27
+ .catch(() => undefined);
28
+ if (saved)
29
+ return { store, account: { provider: saved.provider, account: saved.account } };
30
+ await store.close();
31
+ }
32
+ }
33
+ if (!locked)
34
+ return withProfile(options, env, options.account());
35
+ const folder = mkdtempSync(join(tmpdir(), `${app.command}-empty-`));
36
+ const removing = () => rmSync(folder, { recursive: true, force: true });
37
+ try {
38
+ const empty = await withProfile(options, { ...env, MESSAGING_STORE: join(folder, "wirecat.db") }, {
39
+ provider: options.provider,
40
+ account: profile,
41
+ });
42
+ const close = empty.store.close.bind(empty.store);
43
+ empty.store.close = () => close().finally(removing);
44
+ return empty;
45
+ }
46
+ catch (error) {
47
+ removing();
48
+ throw error;
49
+ }
50
+ };
51
+ const withProfile = async ({ app, profile, open }, env, account) => {
52
+ const store = await open(env);
53
+ try {
54
+ // An account already stored keeps the scope the owner gave it.
55
+ await store.accounts.saveAccount(account, { name: null, scope: "work" });
56
+ await store.accounts.saveProfile(app.command, profile, account);
57
+ return { store, account };
58
+ }
59
+ catch (error) {
60
+ await store.close();
61
+ throw error;
62
+ }
63
+ };