@wirecat/cli-core 0.664.0 → 0.666.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 (47) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/calendar/index.d.ts +1 -1
  3. package/dist/calendar/index.js +1 -1
  4. package/dist/calendar/prepare.d.ts +2 -2
  5. package/dist/calendar/reads.d.ts +5 -5
  6. package/dist/calendar/writes.d.ts +4 -4
  7. package/dist/cli/documents/catalog.d.ts +87 -0
  8. package/dist/cli/documents/catalog.js +246 -0
  9. package/dist/cli/documents/documents.d.ts +32 -0
  10. package/dist/cli/documents/documents.js +76 -0
  11. package/dist/cli/documents/folders.d.ts +22 -0
  12. package/dist/cli/documents/folders.js +45 -0
  13. package/dist/cli/documents/index.d.ts +36 -0
  14. package/dist/cli/documents/index.js +32 -0
  15. package/dist/cli/documents/knowledge.d.ts +36 -0
  16. package/dist/cli/documents/knowledge.js +235 -0
  17. package/dist/cli/documents/mirrors.d.ts +46 -0
  18. package/dist/cli/documents/mirrors.js +198 -0
  19. package/dist/cli/documents/queries.d.ts +120 -0
  20. package/dist/cli/documents/queries.js +156 -0
  21. package/dist/cli/documents/search.d.ts +25 -0
  22. package/dist/cli/documents/search.js +34 -0
  23. package/dist/cli/documents/sync.d.ts +31 -0
  24. package/dist/cli/documents/sync.js +41 -0
  25. package/dist/cli/documents/testing/commands-contract.d.ts +35 -0
  26. package/dist/cli/documents/testing/commands-contract.js +205 -0
  27. package/dist/cli/documents/testing/index.d.ts +3 -0
  28. package/dist/cli/documents/testing/index.js +3 -0
  29. package/dist/cli/documents/testing/source-contract.d.ts +18 -0
  30. package/dist/cli/documents/testing/source-contract.js +112 -0
  31. package/dist/cli/documents/testing/source.d.ts +13 -0
  32. package/dist/cli/documents/testing/source.js +67 -0
  33. package/dist/cli/documents/words.d.ts +87 -0
  34. package/dist/cli/documents/words.js +79 -0
  35. package/dist/entities/listings.d.ts +60 -0
  36. package/dist/entities/listings.js +15 -0
  37. package/dist/errors/reasons.js +15 -2
  38. package/dist/meetings/event-store.d.ts +2 -1
  39. package/dist/meetings/event-store.js +6 -0
  40. package/dist/meetings/index.d.ts +1 -1
  41. package/dist/meetings/index.js +1 -1
  42. package/dist/search/question-plan.d.ts +4 -1
  43. package/dist/search/question-plan.js +5 -2
  44. package/dist/services/listings.js +17 -2
  45. package/dist/store/sqlite/meeting-listing.d.ts +12 -0
  46. package/dist/store/sqlite/meeting-listing.js +20 -5
  47. package/package.json +9 -1
@@ -0,0 +1,18 @@
1
+ import type { DocumentSource, SourceFile } from "../../../documents.js";
2
+ import type { ContractCase } from "../../../meetings/index.js";
3
+ /** One adapter over recorded or faked responses, fresh for each case. */
4
+ export interface DocumentSourceFixture<M extends SourceFile = SourceFile> {
5
+ source: DocumentSource<M>;
6
+ /** A folder the account can read, with at least one file somewhere below it. */
7
+ root: string;
8
+ /** The provider's folder test, as the CLI passes it to `syncDocuments`. */
9
+ isFolder(file: M): boolean;
10
+ /** A folder that is also a document (a page with sub-pages), as the CLI passes it to `syncDocuments`. */
11
+ isDocument?(file: M): boolean;
12
+ /** Makes a change on the provider's side (a new or edited file) for the change feed to list; absent skips that check. */
13
+ change?(): Promise<void>;
14
+ /** An id the provider does not know; absent skips that case. */
15
+ missing?: string;
16
+ }
17
+ /** What every documents adapter answers, whatever the provider: run each case in the adapter's tests. */
18
+ export declare const documentSourceContract: <M extends SourceFile>(make: () => DocumentSourceFixture<M> | Promise<DocumentSourceFixture<M>>) => ContractCase[];
@@ -0,0 +1,112 @@
1
+ import assert from "node:assert/strict";
2
+ import { isCliError } from "@wirecat/cli-base";
3
+ const MAX_ENTRIES = 500;
4
+ const walk = async ({ source, root, isFolder }) => {
5
+ const seen = new Map();
6
+ const stack = [root];
7
+ while (stack.length) {
8
+ const parent = stack.pop();
9
+ for (const child of await source.children(parent)) {
10
+ assert.ok(child.parents.includes(parent), `${child.id} is a child of ${parent} and names it among its parents`);
11
+ if (seen.has(child.id))
12
+ continue;
13
+ seen.set(child.id, child);
14
+ assert.ok(seen.size <= MAX_ENTRIES, `more than ${MAX_ENTRIES} entries under the fixture's root`);
15
+ if (isFolder(child))
16
+ stack.push(child.id);
17
+ }
18
+ }
19
+ return [...seen.values()];
20
+ };
21
+ /** What the sync imports: a file, or a folder the provider calls a document too. */
22
+ const isImported = (fixture, entry) => !fixture.isFolder(entry) || fixture.isDocument?.(entry) === true;
23
+ const isTime = (value) => value === undefined || !Number.isNaN(Date.parse(value));
24
+ /** What every documents adapter answers, whatever the provider: run each case in the adapter's tests. */
25
+ export const documentSourceContract = (make) => {
26
+ const cases = [
27
+ {
28
+ name: "identity: the signed-in account, the same on every call",
29
+ async run() {
30
+ const { source } = await make();
31
+ const first = await source.identity();
32
+ assert.equal(typeof first, "string");
33
+ assert.ok(first.trim(), "identity() names the account");
34
+ assert.equal(await source.identity(), first, "identity() does not change between calls");
35
+ },
36
+ },
37
+ {
38
+ name: "metadata: the root is a readable folder under its own id",
39
+ async run() {
40
+ const fixture = await make();
41
+ const root = await fixture.source.metadata(fixture.root);
42
+ assert.equal(root.id, fixture.root);
43
+ assert.ok(fixture.isFolder(root), "the root is a folder");
44
+ assert.equal(root.trashed, false);
45
+ },
46
+ },
47
+ {
48
+ name: "children: every entry has an id, a name, a URL and times that parse, and metadata gives it back",
49
+ async run() {
50
+ const fixture = await make();
51
+ const entries = await walk(fixture);
52
+ assert.ok(entries.some((entry) => isImported(fixture, entry)), "the root has at least one document below it");
53
+ for (const entry of entries) {
54
+ assert.ok(entry.id && entry.name.trim(), `${entry.id} has an id and a name`);
55
+ assert.equal(typeof entry.url, "string", `${entry.id} has a URL`);
56
+ assert.equal(typeof entry.canDownload, "boolean", `${entry.id} says whether it can be downloaded`);
57
+ assert.ok(isTime(entry.modifiedAt) && isTime(entry.createdAt), `${entry.id}'s times parse`);
58
+ assert.equal((await fixture.source.metadata(entry.id)).id, entry.id, `metadata(${entry.id}) is the same file`);
59
+ }
60
+ },
61
+ },
62
+ {
63
+ name: "content: a document's text, Markdown, tabs and bytes, under its own metadata",
64
+ async run() {
65
+ const fixture = await make();
66
+ const files = (await walk(fixture)).filter((entry) => isImported(fixture, entry) && entry.canDownload);
67
+ assert.ok(files.length > 0, "the root has a file that can be downloaded");
68
+ for (const file of files.slice(0, 5)) {
69
+ const content = await fixture.source.content(file.id);
70
+ assert.equal(content.metadata.id, file.id);
71
+ assert.equal(typeof content.text, "string");
72
+ assert.equal(typeof content.markdown, "string");
73
+ assert.ok(Array.isArray(content.tabs), "tabs is a list, empty for a document without tabs");
74
+ for (const tab of content.tabs)
75
+ assert.ok(typeof tab.id === "string" && typeof tab.title === "string" && typeof tab.text === "string");
76
+ const bytes = await fixture.source.bytes(file.id);
77
+ assert.ok(bytes instanceof Uint8Array, `bytes(${file.id}) is a Uint8Array`);
78
+ }
79
+ },
80
+ },
81
+ {
82
+ name: "changes: a start token, then pages that each give the next cursor and say what was removed",
83
+ async run() {
84
+ const fixture = await make();
85
+ const { source } = fixture;
86
+ const token = await source.startToken();
87
+ assert.ok(typeof token === "string" && token, "startToken() gives a cursor");
88
+ await fixture.change?.();
89
+ const page = await source.changes(token);
90
+ assert.ok(Array.isArray(page.items), "a change page has items");
91
+ if (fixture.change)
92
+ assert.ok(page.items.length > 0, "the change made after startToken() is in the feed");
93
+ assert.ok(typeof page.cursor === "string" && page.cursor, "a change page gives the next cursor");
94
+ for (const item of page.items) {
95
+ assert.equal(typeof item.removed, "boolean", `change ${item.id} says whether it was removed`);
96
+ if (!item.removed && item.file)
97
+ assert.equal(item.file.id, item.id, `change ${item.id} carries its file`);
98
+ }
99
+ },
100
+ },
101
+ ];
102
+ cases.push({
103
+ name: "metadata: an id the provider does not know is not_found",
104
+ async run() {
105
+ const { source, missing } = await make();
106
+ if (missing === undefined)
107
+ return;
108
+ await assert.rejects(source.metadata(missing), (error) => isCliError(error) && error.code === "not_found");
109
+ },
110
+ });
111
+ return cases;
112
+ };
@@ -0,0 +1,13 @@
1
+ import type { DocumentSource, SourceFile } from "../../../documents.js";
2
+ /** The folder type of the fake source: no provider's own. */
3
+ export declare const FAKE_FOLDER = "inode/directory";
4
+ export declare const fakeFile: (id: string, parents?: string[], mime?: string) => SourceFile;
5
+ export interface FakeDocumentSource extends DocumentSource {
6
+ files: Map<string, SourceFile>;
7
+ /** Puts a file or folder in, or changes it, and lists it in the next change feed. */
8
+ put(file: SourceFile, text?: string): void;
9
+ /** Takes one out, and lists it as removed in the next change feed. */
10
+ remove(id: string): void;
11
+ }
12
+ /** A provider in memory: a root folder, a nested folder and two text files, with a change feed and a cursor. */
13
+ export declare const fakeDocumentSource: (account?: string) => FakeDocumentSource;
@@ -0,0 +1,67 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ /** The folder type of the fake source: no provider's own. */
3
+ export const FAKE_FOLDER = "inode/directory";
4
+ export const fakeFile = (id, parents = ["root"], mime = "text/plain") => ({
5
+ id,
6
+ name: id,
7
+ parents,
8
+ mime,
9
+ url: `https://example.invalid/${id}`,
10
+ trashed: false,
11
+ canDownload: true,
12
+ version: "1",
13
+ modifiedAt: "2026-10-16T00:00:00.000Z",
14
+ });
15
+ /** A provider in memory: a root folder, a nested folder and two text files, with a change feed and a cursor. */
16
+ export const fakeDocumentSource = (account = "alpha") => {
17
+ const files = new Map();
18
+ const texts = new Map();
19
+ let feed = [];
20
+ let cursor = 0;
21
+ const metadata = async (id) => {
22
+ const found = files.get(id);
23
+ if (!found)
24
+ throw new CliError("not_found", "no such synthetic file", { reason: "document.not-found" });
25
+ return structuredClone(found);
26
+ };
27
+ const source = {
28
+ files,
29
+ put(file, text) {
30
+ files.set(file.id, file);
31
+ if (text !== undefined)
32
+ texts.set(file.id, text);
33
+ feed.push({ id: file.id, removed: false, file: structuredClone(file) });
34
+ },
35
+ remove(id) {
36
+ files.delete(id);
37
+ texts.delete(id);
38
+ feed.push({ id, removed: true });
39
+ },
40
+ identity: async () => account,
41
+ metadata,
42
+ children: async (id) => [...files.values()].filter((item) => item.parents.includes(id)).map((item) => structuredClone(item)),
43
+ startToken: async () => `cursor-${cursor}`,
44
+ changes: async (token) => {
45
+ if (!/^cursor-\d+$/.test(token))
46
+ throw new CliError("validation_error", "unknown synthetic cursor");
47
+ const items = feed;
48
+ feed = [];
49
+ cursor += 1;
50
+ return { items, cursor: `cursor-${cursor}` };
51
+ },
52
+ content: async (id, maxChars) => {
53
+ const file = await metadata(id);
54
+ if (file.mime === FAKE_FOLDER)
55
+ throw new CliError("validation_error", "a folder has no content");
56
+ const text = (texts.get(id) ?? `budget ${id}`).slice(0, maxChars);
57
+ return { metadata: file, markdown: `# ${file.name}\n\n${text}\n`, text, tabs: [] };
58
+ },
59
+ bytes: async (id) => new TextEncoder().encode((await source.content(id)).text),
60
+ };
61
+ source.put(fakeFile("root", [], FAKE_FOLDER));
62
+ source.put(fakeFile("nested", ["root"], FAKE_FOLDER));
63
+ source.put(fakeFile("a", ["nested"]), "quarterly budget for the alpha team");
64
+ source.put(fakeFile("b"), "notes from the planning review");
65
+ feed = [];
66
+ return source;
67
+ };
@@ -0,0 +1,87 @@
1
+ import { type Command } from "commander";
2
+ import { type ListBody } from "../envelope.js";
3
+ /** How a documents CLI names itself and its provider in the shared commands' help, examples and answers. */
4
+ export interface DocumentWords {
5
+ /** The command: the first word of every example (`drive`). */
6
+ app: string;
7
+ /** The profile examples name. */
8
+ profile?: string;
9
+ /** The provider's side, as the user types it: `mirrors sync --keep local|<remote>|both`, `<remote>-id`. */
10
+ remote: string;
11
+ /** The provider in sentences (`Google`). */
12
+ provider: string;
13
+ /** The place files live, in sentences (`Google Drive`); the provider when absent. */
14
+ place?: string;
15
+ /** The store's provider name, which an issue names as its `source` (`google-drive`). */
16
+ source: string;
17
+ /** Texts that differ from the ones made from the words above. */
18
+ text?: Partial<DocumentTexts>;
19
+ }
20
+ export interface DocumentTexts {
21
+ documents: string;
22
+ documentsList: string;
23
+ documentArgument: string;
24
+ knowledgeArgument: string;
25
+ catalog: string;
26
+ catalogArgument: string;
27
+ treeArgument: string;
28
+ folders: string;
29
+ folderArgument: string;
30
+ syncLimit: string;
31
+ identities: string;
32
+ identitiesList: string;
33
+ identitiesLink: string;
34
+ identityArgument: string;
35
+ mirrors: string;
36
+ mirrorsAdd: string;
37
+ mirrorsSync: string;
38
+ mirrorParent: string;
39
+ }
40
+ export interface Words extends Required<Omit<DocumentWords, "text">> {
41
+ text: DocumentTexts;
42
+ /** `drive personal`: what every example starts with. */
43
+ prefix: string;
44
+ }
45
+ export declare const wordsOf: (words: DocumentWords) => Words;
46
+ export declare const examples: (command: Command, lines: string[]) => Command;
47
+ export declare const positive: (input: string) => number;
48
+ export declare const nonnegative: (input: string) => number;
49
+ /** A list that is never paged: everything there is, in one answer. */
50
+ export declare const allOf: <T>(items: T[]) => ListBody<T>;
51
+ /** The `documents` group, made once: the shared commands and the CLI's live ones join it in the order they are added. */
52
+ export declare const documentsGroup: (program: Command, words: Words) => Command;
53
+ export interface CopyAge {
54
+ synced_at: string | null;
55
+ age_days: number | null;
56
+ }
57
+ export declare const ageOf: (lastSync: string | undefined, now?: number) => CopyAge;
58
+ export declare const staleCopy: (provider: string, lastSync: string | undefined, now?: number) => {
59
+ readonly missing?: undefined;
60
+ meta?: undefined;
61
+ next?: undefined;
62
+ } | {
63
+ missing: {
64
+ field: string;
65
+ why: string;
66
+ step: string;
67
+ }[];
68
+ next: ({
69
+ kind: "command";
70
+ step: string;
71
+ command: string;
72
+ args: {
73
+ [x: string]: unknown;
74
+ };
75
+ line?: string | undefined;
76
+ why: string;
77
+ safe_to_auto_execute: boolean;
78
+ } | {
79
+ kind: "user_action";
80
+ step: string;
81
+ why: string;
82
+ safe_to_auto_execute: false;
83
+ })[];
84
+ meta: {
85
+ complete: false;
86
+ };
87
+ };
@@ -0,0 +1,79 @@
1
+ import { annotate } from "@wirecat/cli-base/commands";
2
+ import { defineSteps, stepOf } from "@wirecat/cli-base/standards";
3
+ import { InvalidArgumentError } from "commander";
4
+ import { listOf } from "../envelope.js";
5
+ export const wordsOf = (words) => {
6
+ const profile = words.profile ?? "personal";
7
+ const place = words.place ?? words.provider;
8
+ const { provider } = words;
9
+ return {
10
+ ...words,
11
+ profile,
12
+ place,
13
+ prefix: `${words.app} ${profile}`,
14
+ text: {
15
+ documents: `read imported documents and ${provider} documents`,
16
+ documentsList: `list imported documents with their ${provider} URLs`,
17
+ documentArgument: `document id, ${provider} URL, or a search hit's document: ref`,
18
+ knowledgeArgument: `${provider} file or folder id or URL in the local catalog, or a document:<n> ref`,
19
+ catalog: `browse stored ${place} files and folders offline`,
20
+ catalogArgument: `${provider} file or folder id, or its URL`,
21
+ treeArgument: `${provider} folder id or URL; defaults to the explicitly selected profile's roots`,
22
+ folders: `choose the ${place} folders that sync imports`,
23
+ folderArgument: `folder id or ${place} URL`,
24
+ syncLimit: `how many documents to read from ${provider} in this run`,
25
+ identities: `the ${provider} accounts seen on a document, and the people they belong to`,
26
+ identitiesList: `list the people ${provider} shows for a document`,
27
+ identitiesLink: `record that a ${provider} account belongs to a known person`,
28
+ identityArgument: `${provider} account id, as identities list prints it`,
29
+ mirrors: `keep local folders mirrored into ${place}`,
30
+ mirrorsAdd: `mirror a local folder into ${place}`,
31
+ mirrorsSync: `sync both ways with ${place}; a part changed on both sides is reported`,
32
+ mirrorParent: `the ${place} folder to write into, by id or URL`,
33
+ ...words.text,
34
+ },
35
+ };
36
+ };
37
+ export const examples = (command, lines) => annotate(command, { examples: lines });
38
+ export const positive = (input) => {
39
+ const n = Number(input);
40
+ if (!Number.isSafeInteger(n) || n < 1)
41
+ throw new InvalidArgumentError("use a positive integer");
42
+ return n;
43
+ };
44
+ export const nonnegative = (input) => {
45
+ const n = Number(input);
46
+ if (!Number.isSafeInteger(n) || n < 0)
47
+ throw new InvalidArgumentError("use a nonnegative integer");
48
+ return n;
49
+ };
50
+ /** A list that is never paged: everything there is, in one answer. */
51
+ export const allOf = (items) => listOf("", { items, limit: Math.max(1, items.length), has_more: false });
52
+ /** The `documents` group, made once: the shared commands and the CLI's live ones join it in the order they are added. */
53
+ export const documentsGroup = (program, words) => program.commands.find((command) => command.name() === "documents") ??
54
+ annotate(program.command("documents"), { effects: { remote: "none", local: "read" } }).description(words.text.documents);
55
+ const DAY = 24 * 60 * 60 * 1000;
56
+ export const ageOf = (lastSync, now = Date.now()) => {
57
+ const at = lastSync ? Date.parse(lastSync) : Number.NaN;
58
+ return Number.isNaN(at)
59
+ ? { synced_at: null, age_days: null }
60
+ : { synced_at: lastSync ?? null, age_days: Math.max(0, Math.floor((now - at) / DAY)) };
61
+ };
62
+ // Only the local copy is read: when it is older than a day, say so instead of letting it pass for current.
63
+ export const staleCopy = (provider, lastSync, now = Date.now()) => {
64
+ const sync = defineSteps([
65
+ { id: "sync.run", command: "sync", args: [], why: `copy the changes ${provider} has made into the local store` },
66
+ ])[0];
67
+ const { synced_at, age_days } = ageOf(lastSync, now);
68
+ const old = synced_at === null || now - Date.parse(synced_at) > DAY;
69
+ if (!old)
70
+ return {};
71
+ const why = age_days === null
72
+ ? `the local copy has no sync time; ${provider} may have changed the document since it was copied`
73
+ : `the local copy was synced ${age_days} day${age_days === 1 ? "" : "s"} ago; ${provider} may have changed the document since`;
74
+ return {
75
+ missing: [{ field: "synced_at", why, step: sync.id }],
76
+ next: [stepOf(sync)],
77
+ meta: { complete: false },
78
+ };
79
+ };
@@ -135,6 +135,12 @@ export declare const meetingEntry: v.StrictObjectSchema<{
135
135
  readonly via: v.PicklistSchema<["calendar", "meeting"], undefined>;
136
136
  readonly calendar: v.NullableSchema<v.StringSchema<undefined>, undefined>;
137
137
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
138
+ /** A calendar copy's own page at its provider (Google's `htmlLink`); a meeting's record keeps none. */
139
+ readonly page_url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
140
+ /** How this calendar's owner answered the invitation. */
141
+ readonly own_response: v.NullableSchema<v.PicklistSchema<readonly ["needs-action", "accepted", "tentative", "declined", "delegated"], undefined>, undefined>;
142
+ /** The conference's product, as the calendar names it (`Google Meet`, `Zoom Meeting`). */
143
+ readonly conference: v.NullableSchema<v.StringSchema<undefined>, undefined>;
138
144
  }, undefined>, undefined>;
139
145
  /** The meeting records on this row, `meeting:<account>/<id>`. */
140
146
  readonly meetings: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
@@ -146,6 +152,8 @@ export declare const meetingEntry: v.StrictObjectSchema<{
146
152
  readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
147
153
  }, undefined>, undefined>;
148
154
  readonly organizer: v.BooleanSchema<undefined>;
155
+ /** The answer to a calendar's invitation; `null` for a meeting's participant, who was not asked. */
156
+ readonly response: v.NullableSchema<v.PicklistSchema<readonly ["needs-action", "accepted", "tentative", "declined", "delegated"], undefined>, undefined>;
149
157
  }, undefined>, undefined>;
150
158
  readonly participants_count: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
151
159
  readonly has_recording: v.BooleanSchema<undefined>;
@@ -156,6 +164,10 @@ export declare const meetingEntry: v.StrictObjectSchema<{
156
164
  readonly title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
157
165
  readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
158
166
  }, undefined>, undefined>;
167
+ /** The calendar series the event is an occurrence of. */
168
+ readonly series_id: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
169
+ /** That series' repeat rule, its RFC 5545 `RRULE:` line. */
170
+ readonly recurrence: v.NullableSchema<v.StringSchema<undefined>, undefined>;
159
171
  /** Findings waiting for the owner (`meetings actions`) that cite one of its meetings. */
160
172
  readonly pending_findings: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
161
173
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
@@ -189,6 +201,12 @@ export declare const meetingEntryDetails: v.StrictObjectSchema<{
189
201
  readonly via: v.PicklistSchema<["calendar", "meeting"], undefined>;
190
202
  readonly calendar: v.NullableSchema<v.StringSchema<undefined>, undefined>;
191
203
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
204
+ /** A calendar copy's own page at its provider (Google's `htmlLink`); a meeting's record keeps none. */
205
+ readonly page_url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
206
+ /** How this calendar's owner answered the invitation. */
207
+ readonly own_response: v.NullableSchema<v.PicklistSchema<readonly ["needs-action", "accepted", "tentative", "declined", "delegated"], undefined>, undefined>;
208
+ /** The conference's product, as the calendar names it (`Google Meet`, `Zoom Meeting`). */
209
+ readonly conference: v.NullableSchema<v.StringSchema<undefined>, undefined>;
192
210
  }, undefined>, undefined>;
193
211
  /** The meeting records on this row, `meeting:<account>/<id>`. */
194
212
  readonly meetings: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
@@ -200,6 +218,8 @@ export declare const meetingEntryDetails: v.StrictObjectSchema<{
200
218
  readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
201
219
  }, undefined>, undefined>;
202
220
  readonly organizer: v.BooleanSchema<undefined>;
221
+ /** The answer to a calendar's invitation; `null` for a meeting's participant, who was not asked. */
222
+ readonly response: v.NullableSchema<v.PicklistSchema<readonly ["needs-action", "accepted", "tentative", "declined", "delegated"], undefined>, undefined>;
203
223
  }, undefined>, undefined>;
204
224
  readonly participants_count: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
205
225
  readonly has_recording: v.BooleanSchema<undefined>;
@@ -210,11 +230,21 @@ export declare const meetingEntryDetails: v.StrictObjectSchema<{
210
230
  readonly title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
211
231
  readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
212
232
  }, undefined>, undefined>;
233
+ /** The calendar series the event is an occurrence of. */
234
+ readonly series_id: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
235
+ /** That series' repeat rule, its RFC 5545 `RRULE:` line. */
236
+ readonly recurrence: v.NullableSchema<v.StringSchema<undefined>, undefined>;
213
237
  /** Findings waiting for the owner (`meetings actions`) that cite one of its meetings. */
214
238
  readonly pending_findings: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
215
239
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
216
240
  readonly description: v.NullableSchema<v.StringSchema<undefined>, undefined>;
217
241
  readonly location: v.NullableSchema<v.StringSchema<undefined>, undefined>;
242
+ /** The calendar's Drive files; `document` once a Drive account has stored the file. */
243
+ readonly attachments: v.ArraySchema<v.StrictObjectSchema<{
244
+ readonly file_id: v.StringSchema<undefined>;
245
+ readonly title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
246
+ readonly document: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
247
+ }, undefined>, undefined>;
218
248
  readonly summaries: v.ArraySchema<v.StrictObjectSchema<{
219
249
  readonly meeting: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
220
250
  readonly source: v.StringSchema<undefined>;
@@ -392,6 +422,12 @@ export declare const LISTING_ENTITIES: {
392
422
  readonly via: v.PicklistSchema<["calendar", "meeting"], undefined>;
393
423
  readonly calendar: v.NullableSchema<v.StringSchema<undefined>, undefined>;
394
424
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
425
+ /** A calendar copy's own page at its provider (Google's `htmlLink`); a meeting's record keeps none. */
426
+ readonly page_url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
427
+ /** How this calendar's owner answered the invitation. */
428
+ readonly own_response: v.NullableSchema<v.PicklistSchema<readonly ["needs-action", "accepted", "tentative", "declined", "delegated"], undefined>, undefined>;
429
+ /** The conference's product, as the calendar names it (`Google Meet`, `Zoom Meeting`). */
430
+ readonly conference: v.NullableSchema<v.StringSchema<undefined>, undefined>;
395
431
  }, undefined>, undefined>;
396
432
  /** The meeting records on this row, `meeting:<account>/<id>`. */
397
433
  readonly meetings: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
@@ -403,6 +439,8 @@ export declare const LISTING_ENTITIES: {
403
439
  readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
404
440
  }, undefined>, undefined>;
405
441
  readonly organizer: v.BooleanSchema<undefined>;
442
+ /** The answer to a calendar's invitation; `null` for a meeting's participant, who was not asked. */
443
+ readonly response: v.NullableSchema<v.PicklistSchema<readonly ["needs-action", "accepted", "tentative", "declined", "delegated"], undefined>, undefined>;
406
444
  }, undefined>, undefined>;
407
445
  readonly participants_count: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
408
446
  readonly has_recording: v.BooleanSchema<undefined>;
@@ -413,6 +451,10 @@ export declare const LISTING_ENTITIES: {
413
451
  readonly title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
414
452
  readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
415
453
  }, undefined>, undefined>;
454
+ /** The calendar series the event is an occurrence of. */
455
+ readonly series_id: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
456
+ /** That series' repeat rule, its RFC 5545 `RRULE:` line. */
457
+ readonly recurrence: v.NullableSchema<v.StringSchema<undefined>, undefined>;
416
458
  /** Findings waiting for the owner (`meetings actions`) that cite one of its meetings. */
417
459
  readonly pending_findings: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
418
460
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
@@ -445,6 +487,12 @@ export declare const LISTING_ENTITIES: {
445
487
  readonly via: v.PicklistSchema<["calendar", "meeting"], undefined>;
446
488
  readonly calendar: v.NullableSchema<v.StringSchema<undefined>, undefined>;
447
489
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
490
+ /** A calendar copy's own page at its provider (Google's `htmlLink`); a meeting's record keeps none. */
491
+ readonly page_url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
492
+ /** How this calendar's owner answered the invitation. */
493
+ readonly own_response: v.NullableSchema<v.PicklistSchema<readonly ["needs-action", "accepted", "tentative", "declined", "delegated"], undefined>, undefined>;
494
+ /** The conference's product, as the calendar names it (`Google Meet`, `Zoom Meeting`). */
495
+ readonly conference: v.NullableSchema<v.StringSchema<undefined>, undefined>;
448
496
  }, undefined>, undefined>;
449
497
  /** The meeting records on this row, `meeting:<account>/<id>`. */
450
498
  readonly meetings: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
@@ -456,6 +504,8 @@ export declare const LISTING_ENTITIES: {
456
504
  readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
457
505
  }, undefined>, undefined>;
458
506
  readonly organizer: v.BooleanSchema<undefined>;
507
+ /** The answer to a calendar's invitation; `null` for a meeting's participant, who was not asked. */
508
+ readonly response: v.NullableSchema<v.PicklistSchema<readonly ["needs-action", "accepted", "tentative", "declined", "delegated"], undefined>, undefined>;
459
509
  }, undefined>, undefined>;
460
510
  readonly participants_count: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
461
511
  readonly has_recording: v.BooleanSchema<undefined>;
@@ -466,11 +516,21 @@ export declare const LISTING_ENTITIES: {
466
516
  readonly title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
467
517
  readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
468
518
  }, undefined>, undefined>;
519
+ /** The calendar series the event is an occurrence of. */
520
+ readonly series_id: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
521
+ /** That series' repeat rule, its RFC 5545 `RRULE:` line. */
522
+ readonly recurrence: v.NullableSchema<v.StringSchema<undefined>, undefined>;
469
523
  /** Findings waiting for the owner (`meetings actions`) that cite one of its meetings. */
470
524
  readonly pending_findings: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
471
525
  readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
472
526
  readonly description: v.NullableSchema<v.StringSchema<undefined>, undefined>;
473
527
  readonly location: v.NullableSchema<v.StringSchema<undefined>, undefined>;
528
+ /** The calendar's Drive files; `document` once a Drive account has stored the file. */
529
+ readonly attachments: v.ArraySchema<v.StrictObjectSchema<{
530
+ readonly file_id: v.StringSchema<undefined>;
531
+ readonly title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
532
+ readonly document: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
533
+ }, undefined>, undefined>;
474
534
  readonly summaries: v.ArraySchema<v.StrictObjectSchema<{
475
535
  readonly meeting: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
476
536
  readonly source: v.StringSchema<undefined>;
@@ -1,4 +1,5 @@
1
1
  import * as v from "valibot";
2
+ import { PARTICIPANT_RESPONSES } from "../meetings/index.js";
2
3
  import { DOCUMENT_KINDS } from "../store/sqlite/document-listing.js";
3
4
  import { MEETING_ROW_KINDS } from "../store/sqlite/meeting-listing.js";
4
5
  import { count, id, reference, text, time, untrusted } from "./fields.js";
@@ -71,6 +72,8 @@ const participant = v.strictObject({
71
72
  email: v.nullable(text),
72
73
  person: v.nullable(personLink),
73
74
  organizer: v.boolean(),
75
+ /** The answer to a calendar's invitation; `null` for a meeting's participant, who was not asked. */
76
+ response: v.nullable(v.picklist(PARTICIPANT_RESPONSES)),
74
77
  });
75
78
  /** One real meeting, call or calendar event: a calendar's event and its Zoom or Meet record are one row. */
76
79
  export const meetingEntry = v.strictObject({
@@ -94,6 +97,12 @@ export const meetingEntry = v.strictObject({
94
97
  via: v.picklist(["calendar", "meeting"]),
95
98
  calendar: v.nullable(text),
96
99
  ref: reference,
100
+ /** A calendar copy's own page at its provider (Google's `htmlLink`); a meeting's record keeps none. */
101
+ page_url: v.nullable(text),
102
+ /** How this calendar's owner answered the invitation. */
103
+ own_response: v.nullable(v.picklist(PARTICIPANT_RESPONSES)),
104
+ /** The conference's product, as the calendar names it (`Google Meet`, `Zoom Meeting`). */
105
+ conference: v.nullable(text),
97
106
  })),
98
107
  /** The meeting records on this row, `meeting:<account>/<id>`. */
99
108
  meetings: v.array(reference),
@@ -103,6 +112,10 @@ export const meetingEntry = v.strictObject({
103
112
  has_transcript: v.boolean(),
104
113
  has_summary: v.boolean(),
105
114
  documents: v.array(v.strictObject({ ref: reference, title: v.nullable(text), role: v.nullable(text) })),
115
+ /** The calendar series the event is an occurrence of. */
116
+ series_id: v.nullable(id),
117
+ /** That series' repeat rule, its RFC 5545 `RRULE:` line. */
118
+ recurrence: v.nullable(text),
106
119
  /** Findings waiting for the owner (`meetings actions`) that cite one of its meetings. */
107
120
  pending_findings: count,
108
121
  untrusted,
@@ -112,6 +125,8 @@ export const meetingEntryDetails = v.strictObject({
112
125
  ...meetingEntry.entries,
113
126
  description: v.nullable(text),
114
127
  location: v.nullable(text),
128
+ /** The calendar's Drive files; `document` once a Drive account has stored the file. */
129
+ attachments: v.array(v.strictObject({ file_id: text, title: v.nullable(text), document: v.nullable(reference) })),
115
130
  summaries: v.array(v.strictObject({
116
131
  meeting: reference,
117
132
  source: text,
@@ -182,6 +182,7 @@ const OTHERS = [
182
182
  ["document.not-imported", "not_found", "the document is not imported in this source account"],
183
183
  ["document.not-found", "not_found", "no listed document has that reference"],
184
184
  ["meeting.not-found", "not_found", "no meeting row has that event or meeting reference"],
185
+ ["listing.too-large", "provider_error", "the listing is over its bound; the checkpoint was kept"],
185
186
  ["listing.source-not-found", "not_found", "a source: term names no account holding what is listed"],
186
187
  validation("query.empty-window", "the time window ends before it starts, so no row can fall in it"),
187
188
  ["extraction.invalid-proposals", "invalid_response", "the model's memory proposals could not be used"],
@@ -199,6 +200,15 @@ const OTHERS = [
199
200
  "the email could not be read again, so its skipped attachments have no text",
200
201
  ],
201
202
  ["mirror.partial", "provider_error", "some mirrored files were not synced"],
203
+ ["mirror.none", "not_found", "the profile has no mirrors; add one with mirrors add"],
204
+ ["mirror.not-found", "not_found", "no such mirror in this profile; see mirrors list"],
205
+ validation("mirror.not-folder", "the path to mirror is not a folder"),
206
+ ["catalog.unavailable", "configuration_error", "the store has no shared catalog for this account"],
207
+ ["catalog.not-found", "not_found", "the file or folder is not in the local catalog; run catalog import or sync"],
208
+ validation("catalog.depth-invalid", "tree depth must be between 0 and 50"),
209
+ ["catalog.cycle", "invalid_response", "local folder ancestry contains a cycle"],
210
+ validation("catalog.tree-limit", "the tree is over 10000 entries; name a smaller folder or lower --depth"),
211
+ validation("export.exists", "the output file already exists"),
202
212
  ["profile.wrong-account", "authentication_error", "the signed-in source account does not match this profile"],
203
213
  validation("push.too-many-files", "the folder holds more files than one push takes"),
204
214
  validation("push.unreadable", "the folder to push could not be read"),
@@ -209,7 +219,7 @@ const OTHERS = [
209
219
  "the settings file's damage has more than one reading; nothing was changed, so it is fixed by hand",
210
220
  ],
211
221
  ["state.invalid", "configuration_error", "the saved sync state is unreadable or invalid; it is kept, not reset"],
212
- ["sync.partial", "provider_error", "some calendars did not sync; the next sync retries them"],
222
+ ["sync.partial", "provider_error", "some sources did not sync; the next sync retries them"],
213
223
  validation("event.conflict", "the event changed at the provider since the last sync; sync and try again"),
214
224
  validation("event.notify-required", "the event has other attendees; say whether to notify them"),
215
225
  validation("remind.window", "--due-within is outside 1m to 1d"),
@@ -712,6 +722,9 @@ export const DETAILS = [
712
722
  ];
713
723
  const SHARED = { reasons: REASONS, details: DETAILS };
714
724
  const merged = new WeakMap();
725
+ const coreCodes = new Map(REASONS.map((entry) => [entry.reason, entry.code]));
726
+ // A CLI still lists a reason it raised before the command moved into cli-core; the same code is the same failure.
727
+ const sameAsCore = (entry) => coreCodes.get(entry.reason) === entry.code;
715
728
  /** The registry every error handler reads — the CLI's, MCP's and the meeting tools' — so none drops an app's keys. */
716
729
  export const failureContext = (errors) => {
717
730
  if (!errors)
@@ -723,7 +736,7 @@ export const failureContext = (errors) => {
723
736
  if (unnamed.length > 0)
724
737
  throw new Error(`error details must be snake_case: ${unnamed.join(", ")}`);
725
738
  const context = {
726
- reasons: defineReasons([...REASONS, ...(errors.reasons ?? [])]),
739
+ reasons: defineReasons([...REASONS, ...(errors.reasons ?? []).filter((entry) => !sameAsCore(entry))]),
727
740
  details: [...new Set([...DETAILS, ...(errors.details ?? [])])],
728
741
  };
729
742
  merged.set(errors, context);
@@ -1,6 +1,7 @@
1
1
  import type { Event } from "./model.js";
2
2
  /** RFC 5545 PARTSTAT: a participant's answer, and the owner's own. */
3
- export type ParticipantResponse = "needs-action" | "accepted" | "tentative" | "declined" | "delegated";
3
+ export declare const PARTICIPANT_RESPONSES: readonly ["needs-action", "accepted", "tentative", "declined", "delegated"];
4
+ export type ParticipantResponse = (typeof PARTICIPANT_RESPONSES)[number];
4
5
  /** What kind of entry it is. `default`, `from-mail` and `call` are searched (requirements 3.4); `call` is a phone's. */
5
6
  export type EntryEventType = "default" | "out-of-office" | "focus" | "working-location" | "birthday" | "from-mail" | "call";
6
7
  /** RFC 5545 TRANSP. */