@wirecat/cli-core 0.673.0 → 0.674.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 (71) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/background/daily-archive-timer.d.ts +1 -1
  3. package/dist/cli/config-command.d.ts +6 -0
  4. package/dist/cli/config-command.js +1 -1
  5. package/dist/cli/first-run.js +2 -1
  6. package/dist/cli/help/sections.js +1 -0
  7. package/dist/cli/index.d.ts +3 -1
  8. package/dist/cli/index.js +3 -1
  9. package/dist/cli/messenger/projects-command.js +12 -4
  10. package/dist/cli/project-evidence.js +1 -1
  11. package/dist/cli/project-status.js +1 -1
  12. package/dist/cli/settings.d.ts +1 -0
  13. package/dist/cli/settings.js +6 -3
  14. package/dist/cli/setup-command.d.ts +4 -0
  15. package/dist/cli/setup-command.js +394 -0
  16. package/dist/cli/shared-command-exports.d.ts +6 -0
  17. package/dist/cli/shared-command-exports.js +2 -0
  18. package/dist/cli/unknown-profile.js +1 -1
  19. package/dist/crm/cli/index.js +1 -0
  20. package/dist/entities/recorded-meeting.d.ts +2 -0
  21. package/dist/entities/recorded-meeting.js +3 -0
  22. package/dist/errors/reasons.js +7 -0
  23. package/dist/kit/index.d.ts +1 -0
  24. package/dist/kit/index.js +1 -0
  25. package/dist/meetings/answers.d.ts +1 -0
  26. package/dist/meetings/index.d.ts +3 -2
  27. package/dist/meetings/index.js +2 -1
  28. package/dist/meetings/item.d.ts +17 -1
  29. package/dist/meetings/item.js +16 -0
  30. package/dist/meetings/model.d.ts +23 -0
  31. package/dist/meetings/model.js +2 -1
  32. package/dist/meetings/pull.js +1 -0
  33. package/dist/meetings/store.d.ts +1 -1
  34. package/dist/oauth/storage.js +3 -1
  35. package/dist/services/metadata.d.ts +1 -1
  36. package/dist/services/person-meetings.d.ts +3 -0
  37. package/dist/services/person-meetings.js +3 -1
  38. package/dist/services/project-purposes.d.ts +1 -1
  39. package/dist/services/project-purposes.js +2 -2
  40. package/dist/setup/answers.d.ts +58 -0
  41. package/dist/setup/answers.js +194 -0
  42. package/dist/setup/define.d.ts +60 -0
  43. package/dist/setup/define.js +214 -0
  44. package/dist/setup/document.d.ts +205 -0
  45. package/dist/setup/document.js +215 -0
  46. package/dist/setup/files.d.ts +6 -0
  47. package/dist/setup/files.js +46 -0
  48. package/dist/store/index.d.ts +1 -0
  49. package/dist/store/people.d.ts +14 -0
  50. package/dist/store/people.js +8 -1
  51. package/dist/store/sqlite/facts.d.ts +28 -4
  52. package/dist/store/sqlite/facts.js +56 -6
  53. package/dist/store/sqlite/identity-rekey.d.ts +46 -0
  54. package/dist/store/sqlite/identity-rekey.js +191 -0
  55. package/dist/store/sqlite/manifest.js +1 -0
  56. package/dist/store/sqlite/meeting-reads.js +1 -1
  57. package/dist/store/sqlite/meeting-values.d.ts +2 -1
  58. package/dist/store/sqlite/meeting-values.js +23 -1
  59. package/dist/store/sqlite/meetings.js +10 -3
  60. package/dist/store/sqlite/migrations.generated.js +9 -0
  61. package/dist/store/sqlite/note-search.js +2 -2
  62. package/dist/store/sqlite/notes.d.ts +3 -1
  63. package/dist/store/sqlite/notes.js +8 -6
  64. package/dist/store/sqlite/schema.d.ts +153 -0
  65. package/dist/store/sqlite/schema.js +12 -0
  66. package/dist/store/sqlite/things.d.ts +2 -0
  67. package/dist/store/sqlite/things.js +5 -0
  68. package/dist/terminal/sign-in-steps.d.ts +12 -1
  69. package/dist/terminal/sign-in-steps.js +3 -3
  70. package/package.json +2 -2
  71. package/parity.json +3 -3
@@ -0,0 +1,394 @@
1
+ import { toJsonSchema } from "@valibot/to-json-schema";
2
+ import { CliError, isCliError } from "@wirecat/cli-base";
3
+ import { annotate } from "@wirecat/cli-base/commands";
4
+ import { Command } from "commander";
5
+ import { agentOf } from "../runs/run-context.js";
6
+ import { checkField, holds, nextOf, walk, } from "../setup/answers.js";
7
+ import { SETUP_LIMITS } from "../setup/document.js";
8
+ import { answerStdinOption, lineReader, signInSteps } from "../terminal/sign-in-steps.js";
9
+ import { refuseGuardedKey } from "./config-command.js";
10
+ import { baseContext, environmentOf, secretInputOf } from "./context.js";
11
+ import { FETCH, LOCAL_READ, logsInOrOut, refuseUnderReadOnly } from "./effects.js";
12
+ import { itemOf, renderAnswer } from "./envelope.js";
13
+ import { systemLanguage } from "./first-run.js";
14
+ import { bufferedInput } from "./input-policy.js";
15
+ import { rememberAccount } from "./messenger/accounts.js";
16
+ import { ProfileTokenStore } from "./profile-token.js";
17
+ import { fromFile, NONE_NAMED } from "./settings.js";
18
+ const fieldsOf = (blocks = []) => blocks.flatMap((block) => block.type === "group" ? fieldsOf(block.blocks) : block.type === "input" || block.type === "choice" ? [block] : []);
19
+ const allFields = (document) => Object.values(document.steps).flatMap((step) => fieldsOf(step.blocks));
20
+ const secretOf = (field) => (field.type === "input" ? field.secret : undefined);
21
+ /** `token` is the profile's own token, as `session start` keeps it; any other name is a secret beside it. */
22
+ const readKept = (store, profile, name) => name === "token" ? store.read(profile) : store.readSecret(profile, name);
23
+ const settingJsonSchema = (schema) => {
24
+ const inner = "wrapped" in schema ? schema.wrapped : schema;
25
+ const { $schema: _, ...json } = toJsonSchema(inner, { errorMode: "ignore" });
26
+ return json;
27
+ };
28
+ /** The setup group a CLI gets by describing its flow: `show`, `apply`, `run` and the terminal walk-through. */
29
+ export const setupCommand = (setup) => {
30
+ const { app, configuration, check, ownerOnly = {} } = setup.definition;
31
+ const cli = app.command;
32
+ const { document } = setup;
33
+ // A read never creates the settings file, and a file with a bad key still shows the flow.
34
+ const contextFor = (command, needsProfile, readOnly = false) => baseContext(command, (flags, options) => configuration.resolveSettings(flags, {
35
+ ...options,
36
+ needsProfile,
37
+ ...(readOnly ? { readOnly, withIssues: true } : {}),
38
+ }));
39
+ const storeFor = (command, warn) => {
40
+ const environment = environmentOf(command);
41
+ return new ProfileTokenStore({
42
+ app,
43
+ env: environment.env ?? process.env,
44
+ ...(environment.keyring ? { keyring: environment.keyring } : {}),
45
+ warn,
46
+ });
47
+ };
48
+ const currentOf = (command, context) => {
49
+ const { settings, renderer } = context;
50
+ const current = {};
51
+ const store = storeFor(command, renderer.warn);
52
+ for (const field of allFields(document)) {
53
+ if (field.setting !== undefined) {
54
+ const value = fromFile(settings, field.setting, undefined).value;
55
+ if (value !== undefined)
56
+ current[field.setting] = value;
57
+ }
58
+ const secret = secretOf(field);
59
+ if (secret === undefined || current[secret])
60
+ continue;
61
+ try {
62
+ if (readKept(store, settings.profile, secret))
63
+ current[secret] = { set: true };
64
+ }
65
+ catch {
66
+ // A keyring that cannot be read says nothing about the secret; the flow asks for it again.
67
+ }
68
+ }
69
+ return current;
70
+ };
71
+ const described = () => {
72
+ const withSchema = (blocks = []) => blocks.map((block) => {
73
+ if (block.type === "group")
74
+ return { ...block, blocks: withSchema(block.blocks) };
75
+ if ((block.type !== "input" && block.type !== "choice") || block.setting === undefined)
76
+ return block;
77
+ const schema = configuration.settingSchema(block.setting);
78
+ return schema ? { ...block, schema: settingJsonSchema(schema) } : block;
79
+ });
80
+ const steps = Object.fromEntries(Object.entries(document.steps).map(([id, step]) => [
81
+ id,
82
+ step.blocks ? { ...step, blocks: withSchema(step.blocks) } : step,
83
+ ]));
84
+ return { ...document, steps };
85
+ };
86
+ const readAnswers = async (command, lines) => {
87
+ const input = environmentOf(command).stdin ?? process.stdin;
88
+ if (!lines && input.isTTY)
89
+ throw new CliError("validation_error", `pipe the answers as one JSON object on stdin: echo '{…}' | ${cli} …`, {
90
+ reason: "input.required",
91
+ });
92
+ const text = lines ? await lines() : (await bufferedInput(input, { maxBytes: SETUP_LIMITS.bytes })).toString("utf8");
93
+ let parsed;
94
+ try {
95
+ parsed = JSON.parse(text);
96
+ }
97
+ catch {
98
+ throw new CliError("validation_error", "the answers on stdin are not JSON — one object, input id → value", {
99
+ reason: "input.invalid",
100
+ });
101
+ }
102
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
103
+ throw new CliError("validation_error", "the answers on stdin are one object, input id → value", {
104
+ reason: "input.invalid",
105
+ });
106
+ return parsed;
107
+ };
108
+ /** The one way answers are checked and saved, for `apply`, `run apply` and the terminal alike. */
109
+ const apply = async (command, answers, { dryRun, steps }) => {
110
+ const context = contextFor(command, true, dryRun);
111
+ const { settings, env } = context;
112
+ const profile = settings.profile;
113
+ const path = walk(setup, answers, { current: currentOf(command, context) });
114
+ const reached = path.stopped === "run" || path.stopped === "done";
115
+ const told = {
116
+ profile,
117
+ path: path.path,
118
+ at: path.at,
119
+ errors: path.errors,
120
+ dropped: path.dropped,
121
+ };
122
+ if (dryRun)
123
+ return { valid: path.errors.length === 0, complete: reached, ...told };
124
+ if (path.errors.length > 0)
125
+ throw new CliError("validation_error", path.errors.map(({ input, message }) => `${input} ${message}`).join("; "), { reason: "input.invalid", ...told });
126
+ if (!reached)
127
+ throw new CliError("validation_error", `the answers stop at ${path.at}, before the flow's check`, {
128
+ reason: "input.incomplete",
129
+ ...told,
130
+ });
131
+ refuseUnderReadOnly(command, "setup");
132
+ // An agent's own shell counts too, as for `config set` (SEC-116).
133
+ if (environmentOf(command).agent || agentOf(env))
134
+ for (const [setting, value] of Object.entries(path.settings))
135
+ refuseGuardedKey(setting, String(value), ownerOnly);
136
+ steps.progress("check", `checking ${profile}'s settings`);
137
+ const checked = (await check?.({
138
+ command,
139
+ profile,
140
+ settings: { ...settings, configured: { ...settings.configured, ...path.settings } },
141
+ secrets: path.secrets,
142
+ answers: path.kept,
143
+ steps,
144
+ })) ?? {};
145
+ for (const [setting, value] of Object.entries(path.settings))
146
+ configuration.changeSetting(settings.configPath, { profile, setting, value: JSON.stringify(value) });
147
+ const store = storeFor(command, context.renderer.warn);
148
+ const kept = Object.entries(path.secrets).map(([name, secret]) => name === "token" ? store.write(profile, secret) : store.writeSecret(profile, name, secret));
149
+ rememberAccount(app, profile, profile, env);
150
+ return {
151
+ outcome: "ok",
152
+ ...told,
153
+ saved: Object.keys(path.settings),
154
+ secrets: Object.keys(path.secrets),
155
+ stored_in: kept[0] ?? null,
156
+ ...checked,
157
+ };
158
+ };
159
+ const stepsFor = (command, json, lines) => signInSteps({
160
+ diagnostic: contextFor(command, false, true).streams.diagnostic,
161
+ json,
162
+ answers: lines !== undefined,
163
+ ...(lines ? { lines } : {}),
164
+ });
165
+ const show = annotate(new Command("show"), {
166
+ effects: LOCAL_READ,
167
+ examples: [`${cli} setup show --json`, `${cli} office setup show --json`],
168
+ })
169
+ .summary("print the connection flow as JSON, for WireCat Desktop")
170
+ .description("print the connection flow as a WireCat setup document: steps, texts in every language, and each setting's " +
171
+ "own JSON Schema; with a profile it adds the profile's current values, a secret only as { set: true }")
172
+ .action(function () {
173
+ const context = contextFor(this, false, true);
174
+ const named = context.settings.sources.profile !== NONE_NAMED;
175
+ const body = { ...described(), ...(named ? { values: currentOf(this, context) } : {}) };
176
+ renderAnswer(this, context, itemOf(body));
177
+ });
178
+ const applyCommand = annotate(new Command("apply"), {
179
+ effects: FETCH,
180
+ mcp: false,
181
+ examples: [`${cli} office setup apply --dry-run --json`, `${cli} office setup apply --json`],
182
+ })
183
+ .summary("check the answers on stdin against the flow, and save them")
184
+ .description("read the answers as one JSON object on stdin (input id → value), keep only those on the path they lead to, " +
185
+ "check each with its setting's own schema, then run the CLI's check and save the settings and secrets; " +
186
+ "--dry-run only checks and saves nothing")
187
+ .option("--dry-run", "check the answers, and save nothing")
188
+ .action(async function ({ dryRun }) {
189
+ const answers = await readAnswers(this);
190
+ const result = await apply(this, answers, { dryRun: dryRun === true, steps: stepsFor(this, false) });
191
+ renderAnswer(this, contextFor(this, false, true), itemOf(result));
192
+ });
193
+ const runCommand = logsInOrOut(annotate(new Command("run"), {
194
+ effects: FETCH,
195
+ lifetime: "interactive",
196
+ mcp: false,
197
+ examples: [`${cli} office setup run apply --json --answer-stdin`],
198
+ }))
199
+ .summary("run one step of the flow, as WireCat Desktop does")
200
+ .description("run one run step of the flow: apply checks the answers, runs the CLI's check and saves; the sign-in events " +
201
+ "go to stderr as JSON lines and the result to stdout; with --answer-stdin the answers are stdin's first line")
202
+ .argument("<action>", "the step's action: apply")
203
+ .addOption(answerStdinOption())
204
+ .action(async function (action, { answerStdin }) {
205
+ if (action !== "apply")
206
+ throw new CliError("validation_error", `setup run takes apply; ${action} is not a run action of v1`, {
207
+ reason: "input.invalid",
208
+ });
209
+ const json = this.optsWithGlobals();
210
+ const machine = json.json === true || json.jsonl === true;
211
+ const input = environmentOf(this).stdin ?? process.stdin;
212
+ const lines = answerStdin ? lineReader(input) : undefined;
213
+ const steps = stepsFor(this, machine, lines);
214
+ const answers = await readAnswers(this, lines);
215
+ renderAnswer(this, contextFor(this, false, true), itemOf(await apply(this, answers, { dryRun: false, steps })));
216
+ });
217
+ const group = logsInOrOut(annotate(new Command("setup"), {
218
+ effects: FETCH,
219
+ lifetime: "interactive",
220
+ mcp: false,
221
+ examples: [`${cli} office setup`, `${cli} setup show --json`],
222
+ }))
223
+ .summary("connect this profile, question by question")
224
+ .description(`connect this profile to ${cli}: the same questions WireCat Desktop shows, asked in the terminal, checked, ` +
225
+ "and saved only when the check succeeds; show, apply and run are the same flow for programs")
226
+ .action(async function () {
227
+ await walkThrough(this);
228
+ });
229
+ group.addCommand(show);
230
+ group.addCommand(applyCommand);
231
+ group.addCommand(runCommand);
232
+ const walkThrough = async (command) => {
233
+ const context = contextFor(command, true);
234
+ const { renderer, env } = context;
235
+ const current = currentOf(command, context);
236
+ const language = systemLanguage(env) ?? "en";
237
+ const text = (id, params = {}) => id === undefined
238
+ ? ""
239
+ : (document.texts[language]?.[id] ?? document.texts.en[id] ?? id).replace(/\{([a-z][a-z0-9_]*)\}/g, (all, name) => params[name] ?? all);
240
+ const say = (line) => renderer.note(line);
241
+ const environment = environmentOf(command);
242
+ const input = secretInputOf(command);
243
+ const ask = async (prompt, hidden) => {
244
+ if (environment.answer) {
245
+ const answer = await environment.answer(prompt);
246
+ if (answer === null)
247
+ throw new CliError("validation_error", `${cli} setup asks questions — run it in a terminal, or pipe the answers to setup apply`, {
248
+ reason: "input.required",
249
+ });
250
+ return answer;
251
+ }
252
+ const { readSecret } = await import("../terminal/prompt.js");
253
+ return readSecret(prompt, { ...input, echo: !hidden });
254
+ };
255
+ const answers = {};
256
+ const results = {};
257
+ const known = {
258
+ field: (id) => {
259
+ if (Object.hasOwn(answers, id))
260
+ return answers[id];
261
+ const setting = allFields(document).find((field) => field.id === id)?.setting;
262
+ return setting === undefined ? undefined : current[setting];
263
+ },
264
+ result: (name) => results[name],
265
+ };
266
+ const coerce = (field, typed) => {
267
+ const raw = typed.trim();
268
+ if (raw === "")
269
+ return undefined;
270
+ const options = field.options ?? [];
271
+ const pick = (one) => options[Number(one) - 1]?.value ?? one;
272
+ const kind = field.type === "choice" ? "select" : field.input;
273
+ if (kind === "select")
274
+ return pick(raw);
275
+ if (kind === "multiselect" || kind === "countries")
276
+ return raw
277
+ .split(",")
278
+ .map((one) => one.trim())
279
+ .filter(Boolean)
280
+ .map((one) => (kind === "countries" ? one.toUpperCase() : pick(one)));
281
+ if (kind === "number" || kind === "port")
282
+ return Number.isNaN(Number(raw)) ? raw : Number(raw);
283
+ if (kind === "toggle")
284
+ return /^(y|yes|true)$/i.test(raw) ? true : /^(n|no|false)$/i.test(raw) ? false : raw;
285
+ return raw;
286
+ };
287
+ const askField = async (field) => {
288
+ const bound = field.setting ?? secretOf(field);
289
+ const now = bound === undefined ? undefined : current[bound];
290
+ const options = field.options ?? [];
291
+ for (const [index, option] of options.entries())
292
+ say(` ${index + 1}) ${text(option.label)}${option.hint ? ` — ${text(option.hint)}` : ""}`);
293
+ if (field.hint)
294
+ say(text(field.hint));
295
+ const kept = now === undefined || secretOf(field) !== undefined
296
+ ? field.default === undefined
297
+ ? ""
298
+ : ` [${field.default}]`
299
+ : ` [${now}]`;
300
+ const label = field.label ? text(field.label) : options.length ? "Your choice" : field.id;
301
+ // A hidden prompt takes no empty answer, so keeping a saved secret is its own question.
302
+ if (secretOf(field) !== undefined && now !== undefined) {
303
+ const change = await ask(`${label}: change the saved one? [y/N] `, false);
304
+ if (!/^\s*y(es)?\s*$/i.test(change))
305
+ return;
306
+ }
307
+ const toggle = field.type === "input" && field.input === "toggle" ? " (y/n)" : "";
308
+ for (let tries = 1;; tries++) {
309
+ const typed = await ask(`${label}${toggle}${kept}: `, field.type === "input" && field.input === "password");
310
+ const checked = checkField(field, coerce(field, typed), {
311
+ current,
312
+ settingSchema: configuration.settingSchema,
313
+ });
314
+ if (!checked.problem) {
315
+ if (checked.value !== undefined)
316
+ answers[field.id] = checked.value;
317
+ return;
318
+ }
319
+ if (tries >= 3)
320
+ throw new CliError("validation_error", `${label} ${checked.problem}`, { reason: "input.invalid" });
321
+ renderer.warn(`${label} ${checked.problem}`);
322
+ }
323
+ };
324
+ const show = async (blocks = []) => {
325
+ for (const block of blocks) {
326
+ if (block.when && !holds(block.when, known))
327
+ continue;
328
+ switch (block.type) {
329
+ case "text":
330
+ case "note":
331
+ say(text(block.text, block.params));
332
+ break;
333
+ case "heading":
334
+ say(`\n${text(block.text, block.params)}`);
335
+ break;
336
+ case "code":
337
+ say(` ${block.code}`);
338
+ break;
339
+ case "image":
340
+ if (block.caption)
341
+ say(text(block.caption));
342
+ break;
343
+ case "link":
344
+ say(`${text(block.text)}: ${block.href}`);
345
+ break;
346
+ case "requirement":
347
+ say(`${text(block.text)}${block.fix ? ` — ${text(block.fix)}` : ""}`);
348
+ break;
349
+ case "group":
350
+ if (block.title)
351
+ say(`\n${text(block.title)}`);
352
+ await show(block.blocks);
353
+ break;
354
+ case "input":
355
+ case "choice":
356
+ await askField(block);
357
+ break;
358
+ default:
359
+ if (block.fallback)
360
+ say(text(block.fallback));
361
+ }
362
+ }
363
+ };
364
+ const visited = [];
365
+ let at = document.start;
366
+ for (let moves = 0; at !== undefined && moves < SETUP_LIMITS.transitions; moves++) {
367
+ const step = document.steps[at];
368
+ visited.push(at);
369
+ say(`\n${text(step.title)}`);
370
+ await show(step.blocks);
371
+ if (step.kind === "done") {
372
+ renderAnswer(command, context, itemOf({ profile: context.settings.profile, finished: at, path: visited, results }));
373
+ return;
374
+ }
375
+ if (step.kind === "run") {
376
+ const name = step.result ?? at;
377
+ try {
378
+ await apply(command, answers, { dryRun: false, steps: stepsFor(command, false) });
379
+ results[name] = { outcome: "ok" };
380
+ say("saved");
381
+ }
382
+ catch (error) {
383
+ if (!isCliError(error))
384
+ throw error;
385
+ results[name] = { outcome: "error", code: error.code };
386
+ renderer.warn(error.message);
387
+ }
388
+ }
389
+ at = nextOf(step, known);
390
+ }
391
+ throw new CliError("validation_error", `${cli}'s setup flow stopped at ${at ?? visited.at(-1)} with no way on`);
392
+ };
393
+ return group;
394
+ };
@@ -2,6 +2,7 @@ export declare const addStoreMaintenanceCommands: (store: import("commander").Co
2
2
  export declare const appDoctorCommand: (app: import("./entry.js").AppIdentity, configuration: {
3
3
  resolveSettings: (flags?: import("./settings.js").GlobalFlags, options?: import("./settings.js").ResolveOptions) => import("./settings.js").Settings & object;
4
4
  configuredProfiles: (options?: import("./settings.js").ResolveOptions) => string[];
5
+ settingSchema: (key: string) => import("valibot").GenericSchema | undefined;
5
6
  changeSetting: (path: string, { profile, setting, value, kind, root, }: {
6
7
  profile: string | undefined;
7
8
  setting: string;
@@ -188,6 +189,7 @@ export declare const appDoctorCommand: (app: import("./entry.js").AppIdentity, c
188
189
  export declare const appCompleteCommand: (app: Pick<import("./entry.js").AppIdentity, "command" | "envPrefix">, config: Pick<{
189
190
  resolveSettings: (flags?: import("./settings.js").GlobalFlags, options?: import("./settings.js").ResolveOptions) => import("./settings.js").Settings & object;
190
191
  configuredProfiles: (options?: import("./settings.js").ResolveOptions) => string[];
192
+ settingSchema: (key: string) => import("valibot").GenericSchema | undefined;
191
193
  changeSetting: (path: string, { profile, setting, value, kind, root, }: {
192
194
  profile: string | undefined;
193
195
  setting: string;
@@ -374,6 +376,7 @@ export declare const appCompleteCommand: (app: Pick<import("./entry.js").AppIden
374
376
  export declare const appMcpCommand: (app: import("./entry.js").AppIdentity, configuration: {
375
377
  resolveSettings: (flags?: import("./settings.js").GlobalFlags, options?: import("./settings.js").ResolveOptions) => import("./settings.js").Settings & object;
376
378
  configuredProfiles: (options?: import("./settings.js").ResolveOptions) => string[];
379
+ settingSchema: (key: string) => import("valibot").GenericSchema | undefined;
377
380
  changeSetting: (path: string, { profile, setting, value, kind, root, }: {
378
381
  profile: string | undefined;
379
382
  setting: string;
@@ -567,6 +570,7 @@ export declare const commandsCommand: (app: import("./entry.js").AppIdentity) =>
567
570
  export declare const configCommand: (app: import("./entry.js").AppIdentity, config: {
568
571
  resolveSettings: (flags?: import("./settings.js").GlobalFlags, options?: import("./settings.js").ResolveOptions) => import("./settings.js").Settings & object;
569
572
  configuredProfiles: (options?: import("./settings.js").ResolveOptions) => string[];
573
+ settingSchema: (key: string) => import("valibot").GenericSchema | undefined;
570
574
  changeSetting: (path: string, { profile, setting, value, kind, root, }: {
571
575
  profile: string | undefined;
572
576
  setting: string;
@@ -753,6 +757,7 @@ export declare const configCommand: (app: import("./entry.js").AppIdentity, conf
753
757
  permissionKey?: import("./permission-keys.js").PermissionKeySource | undefined;
754
758
  ownerOnly?: import("./config-command.js").OwnerOnlySettings;
755
759
  } | undefined) => import("commander").Command;
760
+ export declare const setupCommand: (setup: import("./index.js").Setup) => import("commander").Command;
756
761
  export declare const guideCommand: (app: Pick<import("./entry.js").AppIdentity, "command">, options: import("./guide.js").GuideOptions) => import("commander").Command;
757
762
  export declare const addMeetingBatchCommand: (program: import("commander").Command, deps: {
758
763
  reader: import("../meetings/batch.js").MeetingBatchReader;
@@ -788,6 +793,7 @@ export declare const markReadCommand: (messenger: import("./index.js").Messenger
788
793
  export declare const completeCommand: (messenger: import("./index.js").Messenger, config: Pick<{
789
794
  resolveSettings: (flags?: import("./settings.js").GlobalFlags, options?: import("./settings.js").ResolveOptions) => import("./settings.js").Settings & object;
790
795
  configuredProfiles: (options?: import("./settings.js").ResolveOptions) => string[];
796
+ settingSchema: (key: string) => import("valibot").GenericSchema | undefined;
791
797
  changeSetting: (path: string, { profile, setting, value, kind, root, }: {
792
798
  profile: string | undefined;
793
799
  setting: string;
@@ -55,6 +55,7 @@ import { topicsCommand as topicsCommandDefinition } from "./messenger/topics-com
55
55
  import { watchCommand as watchCommandDefinition } from "./messenger/watch-command.js";
56
56
  import { runsCommand as runsCommandDefinition } from "./runs/command.js";
57
57
  import { scheduleCommandFor as scheduleCommandForDefinition } from "./schedule/schedule-command.js";
58
+ import { setupCommand as setupCommandDefinition } from "./setup-command.js";
58
59
  import { sharedCommand as protectedCommand } from "./shared-contracts.js";
59
60
  import { skillCommand as skillCommandDefinition } from "./skill-command.js";
60
61
  import { upgradeCommand as upgradeCommandDefinition } from "./upgrade-command.js";
@@ -71,6 +72,7 @@ export const botMcpCommand = sharedCommand(botMcpCommandDefinition);
71
72
  export const botMessagesCommand = sharedCommand(botMessagesCommandDefinition);
72
73
  export const commandsCommand = sharedCommand(commandsCommandDefinition);
73
74
  export const configCommand = sharedCommand(configCommandDefinition);
75
+ export const setupCommand = sharedCommand(setupCommandDefinition);
74
76
  export const guideCommand = sharedCommand(guideCommandDefinition);
75
77
  export const addMeetingBatchCommand = sharedCommand(addMeetingBatchCommandDefinition);
76
78
  export const addMeetingPreparationCommand = sharedCommand(addMeetingPreparationCommandDefinition);
@@ -2,7 +2,7 @@ import { CliError, isCliError } from "@wirecat/cli-base";
2
2
  // gcal-cli raised its own oauth.missing before cli-core merged it into session.missing (FIND-2583).
3
3
  const NOT_SIGNED_IN = new Set([undefined, "session.missing", "oauth.missing"]);
4
4
  const FROM_ENV = /^[A-Z0-9_]+_PROFILE$/;
5
- const SIGN_INS = new Set(["session start", "setup"]);
5
+ const SIGN_INS = new Set(["session start", "setup", "setup apply", "setup run"]);
6
6
  /** A sign-in names a new profile on purpose: a refusal there is the provider's, never an unknown profile. */
7
7
  export const isSignIn = (path) => SIGN_INS.has(path);
8
8
  // A script's `<PREFIX>_PROFILE` on a computer with no profile yet names a new one, not a mistyped one.
@@ -363,6 +363,7 @@ const addCrmCommandsDefinition = (program, options) => {
363
363
  has_transcript: one.hasTranscript,
364
364
  event: one.event,
365
365
  people: one.people,
366
+ ...(one.call ? { call: one.call } : {}),
366
367
  }));
367
368
  return itemOf({
368
369
  ...dealKeys(found),
@@ -1,4 +1,5 @@
1
1
  import * as v from "valibot";
2
+ import { type MeetingCallItem } from "../meetings/index.js";
2
3
  export interface RecordedMeeting {
3
4
  ref: string;
4
5
  meeting_id: number;
@@ -12,6 +13,7 @@ export interface RecordedMeeting {
12
13
  has_transcript: boolean;
13
14
  event: string | null;
14
15
  people: string[];
16
+ call?: MeetingCallItem;
15
17
  }
16
18
  /** A recorded meeting or call some of the people took part in: `meetings show <meeting_id>` of `account` opens it. */
17
19
  export declare const recordedMeeting: v.GenericSchema<RecordedMeeting>;
@@ -1,4 +1,5 @@
1
1
  import * as v from "valibot";
2
+ import { meetingCall } from "../meetings/index.js";
2
3
  import { count, reference, text, time } from "./fields.js";
3
4
  // Typed by name, as a deal's activity is: inferred, the entity maps that hold it grow too long for the compiler.
4
5
  /** A recorded meeting or call some of the people took part in: `meetings show <meeting_id>` of `account` opens it. */
@@ -12,4 +13,6 @@ export const recordedMeeting = v.strictObject({
12
13
  has_transcript: v.boolean(),
13
14
  event: v.nullable(reference),
14
15
  people: v.array(reference),
16
+ /** Present only on a phone call: its direction, manager and the other side's number. */
17
+ call: v.optional(meetingCall),
15
18
  });
@@ -46,6 +46,7 @@ const SIGN_IN = [
46
46
  ["sign-in.secret-without-id", "configuration_error", "an OAuth client secret is set without its client id"],
47
47
  validation("account-remove.no-choice", "account remove needs --keep-data or --delete-data, one of them"),
48
48
  ["account-remove.unknown-profile", "not_found", "no profile by this name on this computer"],
49
+ validation("profile.missing", "no profile named, and none is picked for the owner; details.profiles lists the ones here"),
49
50
  ["profile.unknown", "not_found", "no profile by this name on this computer; details.profiles lists the ones here"],
50
51
  ["account-remove.busy", "conflict", "a serve or a sync runs for this profile; stop it first"],
51
52
  ["account-remove.unconfirmed", "confirmation_required", "removing an account asks first; add --yes"],
@@ -359,6 +360,7 @@ const OTHERS = [
359
360
  validation("index.not-ready", "the search index is still being built"),
360
361
  validation("input.closed", "the input closed before the answer"),
361
362
  validation("input.empty", "a hidden prompt got an empty answer three times"),
363
+ validation("input.incomplete", "the answers stop before the step that checks them"),
362
364
  validation("input.required", "the command needs an answer and cannot ask for one"),
363
365
  validation("input.too-large", "the input is over its size limit"),
364
366
  ["meeting-project.stale", "conflict", "the meeting's project changed meanwhile"],
@@ -526,6 +528,11 @@ const OTHERS = [
526
528
  "conflict",
527
529
  "the people a merge or a proposed link names changed since; undo the later merge, or propose the link again",
528
530
  ],
531
+ [
532
+ "identity.merge-conflict",
533
+ "conflict",
534
+ "a row of the renamed identity has no counterpart on the identity it merges into; the pair is left as it was",
535
+ ],
529
536
  ["identity.no-merge", "not_found", "nothing of that person is merged into the other; people show lists the merges"],
530
537
  validation("identity.held-elsewhere", "the identity sits on another person than the one named; name that person to take it off them"),
531
538
  validation("identity.several-persons", "the identities that leave a person are all of that one person"),
@@ -1,3 +1,4 @@
1
+ export { setupFileProblems } from "../setup/files.js";
1
2
  export { ARGV_LOG, argvLogSetup } from "./argv-log.js";
2
3
  export { type ContractCase, type ContractOptions, contractCases, OPTIONAL_METHODS } from "./contract.js";
3
4
  export { type FakeAdapter, fakeAdapter } from "./fake.js";
package/dist/kit/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { setupFileProblems } from "../setup/files.js";
1
2
  export { ARGV_LOG, argvLogSetup } from "./argv-log.js";
2
3
  export { contractCases, OPTIONAL_METHODS } from "./contract.js";
3
4
  export { fakeAdapter } from "./fake.js";
@@ -96,6 +96,7 @@ declare const meetingDetailsEntries: {
96
96
  duration_ms: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
97
97
  timezone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
98
98
  participants_count: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
99
+ call: v.OptionalSchema<v.GenericSchema<import("./item.js").MeetingCallItem>, undefined>;
99
100
  issues: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["time_without_zone"], undefined>, undefined>, undefined>;
100
101
  found_in: v.OptionalSchema<v.PicklistSchema<["archive", "server", "both"], undefined>, undefined>;
101
102
  untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
@@ -16,13 +16,14 @@ export { type FindingEvidence, type FindingOutcome, findingHash, MEETING_FINDING
16
16
  export { type FactFinding, type Finding, type FindingsInput, type FindingsReceipt, type FindingsRules, findingFields, findingFingerprint, findingId, findingNeeds, findingText, type PaymentFinding, snakeCase, type TaskFinding, validateBatch, validateFinding, validateFindings, validEvidence, } from "./findings-rules.js";
17
17
  export { liftMeetingFields, MEETING_FIELD_NAMES, MEETING_HIT_QUERY, meetingWordsQuery, parseMeetingQuery, } from "./hit-query.js";
18
18
  export { type ImportFile, importFiles } from "./import.js";
19
- export { MEETING_ISSUES, MEETING_QUERY, type MeetingIssue, type MeetingItem, type MeetingOwner, meeting, meetingIssuesOf, meetingItem, } from "./item.js";
19
+ export { MEETING_ISSUES, MEETING_QUERY, type MeetingCallItem, type MeetingIssue, type MeetingItem, type MeetingOwner, meeting, meetingCall, meetingCallItem, meetingIssuesOf, meetingItem, } from "./item.js";
20
20
  export { joinKeyOf, joinUrlWithoutQuery } from "./join-key.js";
21
21
  export { transcriptLanguage } from "./language.js";
22
22
  export { CHAT_MESSAGES_READ, type MeetingChatLine, type MeetingChatLinesInput, type MeetingChatLinesStore, type MeetingLink, } from "./links.js";
23
23
  export { createMeetingContext, type MeetingContextAction, type MeetingContextChange, type MeetingContextOperation, type MeetingContextPorts, type MeetingContextReceipt, validateMeetingContextChange, } from "./meeting-context.js";
24
24
  export { createMeetingManagement, type DeclaredMeetingFields, declareMeetingFields, dispatchMeetingMutation, type ManagedMeeting, type ManagedMeetingChange, MEETING_FIELD_KEYS, MEETING_FIELDS, type MeetingChangeRules, type MeetingField, type MeetingFields, type MeetingManagement, type MeetingManagementPorts, type MeetingMutationOptions, type MeetingMutationProposal, type MeetingMutationReceipt, type MeetingOperationOptions, type MeetingProviderContext, type MeetingSetting, meetingFieldFlag, validateMeetingChange, } from "./meeting-management.js";
25
- export type { Attachment, ChatLine, Event, EventSeries, JsonValue, Meeting, MeetingSeries, Metadata, Occurrence, Participant, RecordTimes, SourceChatLine, SourceMeeting, Summary, SummaryContent, Transcript, TranscriptLine, TranscriptRow, } from "./model.js";
25
+ export type { Attachment, CallManager, ChatLine, Event, EventSeries, JsonValue, Meeting, MeetingCallDirection, MeetingSeries, Metadata, Occurrence, Participant, RecordTimes, SourceChatLine, SourceMeeting, Summary, SummaryContent, Transcript, TranscriptLine, TranscriptRow, } from "./model.js";
26
+ export { MEETING_CALL_DIRECTIONS } from "./model.js";
26
27
  export { type MeetingParticipantCandidate, type MeetingParticipantPage, type MeetingParticipantReader, type MeetingParticipantSearchOptions, type MeetingParticipantSearchStore, normalizeMeetingParticipantQuery, validateMeetingParticipantSearch, } from "./participant-search.js";
27
28
  export { MEETING_CUE_UNTRUSTED, type MeetingContextCue, type MeetingHitContextOptions, type MeetingHitContextPacket, type MeetingPassageOutputFormat, type MeetingPassageReader, type MeetingPassageRequest, type MeetingPassageResult, markedPassage, meetingHitContextLimits, validateMeetingPassage, } from "./passage.js";
28
29
  export { FACT_TYPES, PAYMENT_DIRECTIONS, PAYMENT_STATES, type Payment, paymentTitle, validatePayment, } from "./payment.js";
@@ -13,12 +13,13 @@ export { findingHash, MEETING_FINDINGS_KIND, meetingFindingFingerprint, validate
13
13
  export { findingFields, findingFingerprint, findingId, findingNeeds, findingText, snakeCase, validateBatch, validateFinding, validateFindings, validEvidence, } from "./findings-rules.js";
14
14
  export { liftMeetingFields, MEETING_FIELD_NAMES, MEETING_HIT_QUERY, meetingWordsQuery, parseMeetingQuery, } from "./hit-query.js";
15
15
  export { importFiles } from "./import.js";
16
- export { MEETING_ISSUES, MEETING_QUERY, meeting, meetingIssuesOf, meetingItem, } from "./item.js";
16
+ export { MEETING_ISSUES, MEETING_QUERY, meeting, meetingCall, meetingCallItem, meetingIssuesOf, meetingItem, } from "./item.js";
17
17
  export { joinKeyOf, joinUrlWithoutQuery } from "./join-key.js";
18
18
  export { transcriptLanguage } from "./language.js";
19
19
  export { CHAT_MESSAGES_READ, } from "./links.js";
20
20
  export { createMeetingContext, validateMeetingContextChange, } from "./meeting-context.js";
21
21
  export { createMeetingManagement, declareMeetingFields, dispatchMeetingMutation, MEETING_FIELD_KEYS, MEETING_FIELDS, meetingFieldFlag, validateMeetingChange, } from "./meeting-management.js";
22
+ export { MEETING_CALL_DIRECTIONS } from "./model.js";
22
23
  export { normalizeMeetingParticipantQuery, validateMeetingParticipantSearch, } from "./participant-search.js";
23
24
  export { MEETING_CUE_UNTRUSTED, markedPassage, meetingHitContextLimits, validateMeetingPassage, } from "./passage.js";
24
25
  export { FACT_TYPES, PAYMENT_DIRECTIONS, PAYMENT_STATES, paymentTitle, validatePayment, } from "./payment.js";
@@ -1,5 +1,5 @@
1
1
  import * as v from "valibot";
2
- import type { Meeting } from "./model.js";
2
+ import { type Meeting, type MeetingCallDirection } from "./model.js";
3
3
  /**
4
4
  * Why a stored meeting's facts may be off, kept so the data stays but a reader knows to doubt it.
5
5
  * `time_without_zone`: the provider sent a time with no zone, and it was read in the computer's zone.
@@ -8,6 +8,20 @@ export declare const MEETING_ISSUES: readonly ["time_without_zone"];
8
8
  export type MeetingIssue = (typeof MEETING_ISSUES)[number];
9
9
  /** The issues a provider adapter put in `metadata.issues`, the known ones only, in their listed order. */
10
10
  export declare const meetingIssuesOf: (metadata: Meeting["metadata"]) => MeetingIssue[];
11
+ export interface MeetingCallItem {
12
+ direction: MeetingCallDirection | null;
13
+ /** The participant who took or made the call for the owner, and their person once linked. */
14
+ manager: {
15
+ name: string | null;
16
+ person: string | null;
17
+ } | null;
18
+ /** The other side's number, as the source wrote it. */
19
+ client_phone: string | null;
20
+ }
21
+ /** A phone call's fields, which a phone-line source sets; a meeting has none. */
22
+ export declare const meetingCall: v.GenericSchema<MeetingCallItem>;
23
+ /** A call's fields as answers give them; `undefined` for a meeting, so its answer has no `call`. */
24
+ export declare const meetingCallItem: (row: Pick<Meeting, "direction" | "clientPhone" | "manager">) => MeetingCallItem | undefined;
11
25
  declare const meetingEntries: {
12
26
  ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
13
27
  id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
@@ -25,6 +39,8 @@ declare const meetingEntries: {
25
39
  duration_ms: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
26
40
  timezone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
27
41
  participants_count: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
42
+ /** Present only on a phone call. */
43
+ call: v.OptionalSchema<v.GenericSchema<MeetingCallItem>, undefined>;
28
44
  /** Present only when something about this meeting is doubtful. */
29
45
  issues: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["time_without_zone"], undefined>, undefined>, undefined>;
30
46
  /**