@wirecat/cli-core 0.653.0 → 0.655.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 (49) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dist/cli/bot/mcp.js +2 -1
  3. package/dist/cli/command-availability.d.ts +3 -1
  4. package/dist/cli/command-availability.js +6 -4
  5. package/dist/cli/early-refusal.d.ts +5 -5
  6. package/dist/cli/early-refusal.js +7 -7
  7. package/dist/cli/messenger/search-answers.js +1 -0
  8. package/dist/cli/preview.js +8 -4
  9. package/dist/cli/program.js +3 -7
  10. package/dist/cli/setup-answers.d.ts +3 -2
  11. package/dist/cli/setup-answers.js +5 -6
  12. package/dist/domain/providers.js +2 -0
  13. package/dist/entities/hit.d.ts +2 -0
  14. package/dist/entities/hit.js +2 -0
  15. package/dist/entities/index.d.ts +7 -0
  16. package/dist/google/errors.d.ts +18 -0
  17. package/dist/google/errors.js +71 -0
  18. package/dist/google/index.d.ts +2 -0
  19. package/dist/google/index.js +2 -0
  20. package/dist/google/pages.d.ts +11 -0
  21. package/dist/google/pages.js +23 -0
  22. package/dist/kit/index.d.ts +1 -0
  23. package/dist/kit/index.js +1 -0
  24. package/dist/kit/sync-after-install.d.ts +26 -0
  25. package/dist/kit/sync-after-install.js +72 -0
  26. package/dist/mcp/agent.d.ts +3 -0
  27. package/dist/mcp/agent.js +5 -4
  28. package/dist/mcp/app-server.js +4 -1
  29. package/dist/mcp/bot/server.d.ts +2 -0
  30. package/dist/mcp/bot/server.js +2 -0
  31. package/dist/mcp/server.js +4 -1
  32. package/dist/meetings/answers.d.ts +11 -1
  33. package/dist/meetings/answers.js +17 -0
  34. package/dist/meetings/index.d.ts +3 -3
  35. package/dist/meetings/index.js +1 -1
  36. package/dist/meetings/pull.js +3 -0
  37. package/dist/meetings/source.d.ts +3 -1
  38. package/dist/meetings/store.d.ts +24 -0
  39. package/dist/meetings/store.js +1 -0
  40. package/dist/meetings/transcript-store.d.ts +9 -1
  41. package/dist/oauth/requests.js +22 -4
  42. package/dist/services/search-all.d.ts +2 -0
  43. package/dist/services/search-all.js +30 -11
  44. package/dist/store/sqlite/meeting-documents.d.ts +13 -0
  45. package/dist/store/sqlite/meeting-documents.js +110 -0
  46. package/dist/store/sqlite/meetings.js +5 -2
  47. package/package.json +5 -1
  48. package/dist/store/sqlite/meeting-transcript-documents.d.ts +0 -10
  49. package/dist/store/sqlite/meeting-transcript-documents.js +0 -52
package/CHANGELOG.md CHANGED
@@ -5,6 +5,60 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
5
5
  minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
6
6
  shape of this file.
7
7
 
8
+ ## 0.655.0 — 13.11.2026
9
+
10
+ ### Added
11
+
12
+ - **`@wirecat/cli-core/google`**, what every Google API client shares: `googleError` turns a refusal into a
13
+ `CliError` by Google's reasons, with the codes and reasons gcal uses (`api.disabled`, `oauth.scope-missing`,
14
+ `provider.usage-limit`…) and never Google's own message; `service` names the API in messages. Calendar's
15
+ organizer-only refusal is the generic `access.denied` here; gcal keeps its own. `googlePages` reads every
16
+ `pageToken` page and refuses a repeated token or more than 1,000 pages with `invalid_response`.
17
+ - **A meeting's Drive documents** (`MeetingSave.documents`, `MeetingSource.documents`): a meeting tool names the
18
+ transcript, recording and notes files the service saved, by Drive file id. The store links them whichever arrives
19
+ first, Drive's import or the meeting, from any Drive profile, with no store migration. A file the service stops
20
+ listing stays linked. `meetings show` lists them as `documents[]`: `file_id`, `role`, `title` and `document`, the
21
+ stored `document:<id>` once Drive has the file, else `null`.
22
+ - **A `search all` document hit names its meeting** (`meeting`, `meeting:<account>/<id>`) when it is a meeting's
23
+ transcript, recording or notes and the search read the meeting's account. A listed transcript is shown once with its
24
+ meeting, as a `driveFileId` one is.
25
+ - **`google-meet` among the known providers** (meetings, from the `meet` tool).
26
+
27
+ ### Changed — may break callers
28
+
29
+ - **`MeetingTranscriptDocumentStore` has a new method, `documentMeetings`**: the meeting each document is a
30
+ transcript, recording or notes of. The store implements it; a caller's own implementation of the interface adds it.
31
+
32
+ ### Fixed
33
+
34
+ - **A meeting transcript's Drive file** (`TranscriptInput.driveFileId`): a new version now replaces only the link the
35
+ previous version of the same transcript source named. Before, it dropped every other transcript link of the
36
+ meeting, so two sources in one save kept one link. A version naming a file the meeting tool listed keeps that
37
+ file's role and title.
38
+ - **`account remove` finishes when Google already dropped the sign-in.** `revokeToken` took Google's HTTP 400
39
+ `invalid_token` answer, given for a grant that is no longer valid, as `outcome_unknown` (`oauth.revoke-failed`), so
40
+ the removal stopped with everything kept. That answer now counts as revoked, as RFC 7009 has such a token answered.
41
+ Every other failed answer still stops the removal.
42
+
43
+ ## 0.654.0 — 13.11.2026
44
+
45
+ ### Added
46
+
47
+ - **`syncAfterInstallCases` in `/testing`**: a CLI's sync, run as its own tests run it, with no shared config, a
48
+ broken one, a byte-order mark, a folder, an older `setup` shape and the "read only" answer; each must succeed, and
49
+ an optional local-only write must still be refused under "read only". The kit points `WIRECAT_CONFIG_DIR` at a
50
+ folder of its own, so the owner's config cannot hide the failure.
51
+
52
+ ### Fixed
53
+
54
+ - **A fresh install syncs: only the owner's own "read only" answer limits a tool.** A shared config
55
+ (`~/.config/WireCat/config.json`) that is not JSON, starts with a byte-order mark, is a folder or holds a
56
+ `setup` section in an older shape no longer makes every WireCat tool read-only; each profile's permissions apply.
57
+ Before, such a file refused `sync` with "setup's answer keeps every WireCat tool read-only".
58
+ - **Setup's "read only" answer lets a sync run.** A command that only fetches from the service into the local store
59
+ (`fetchesOnly`) is no longer refused by that answer, on the command line, in `--dry-run` previews and over MCP. A
60
+ profile's own `readonly` level still refuses it, and every other write stays refused under the answer.
61
+
8
62
  ## 0.653.0 — 13.11.2026
9
63
 
10
64
  ### Added
@@ -3,7 +3,7 @@ import { CliError } from "@wirecat/cli-base";
3
3
  import { annotate, describeProgram } from "@wirecat/cli-base/commands";
4
4
  import { Command } from "commander";
5
5
  import { environmentOf } from "../context.js";
6
- import { changesAuthorityAt, LOCAL_READ, REMOTE_WRITE, readsOverMcpAt } from "../effects.js";
6
+ import { changesAuthorityAt, fetchesOnlyAt, LOCAL_READ, REMOTE_WRITE, readsOverMcpAt } from "../effects.js";
7
7
  import { itemOf, renderAnswer } from "../envelope.js";
8
8
  import { serverEntry } from "../messenger/mcp-command.js";
9
9
  import { nextStep, rootOf } from "../steps.js";
@@ -38,6 +38,7 @@ export const botMcpCommand = (bot) => {
38
38
  program: { run, commands: describeProgram(rootOf(this)) },
39
39
  authority: changesAuthorityAt(rootOf(this)),
40
40
  fetchOnly: readsOverMcpAt(rootOf(this)),
41
+ fetches: fetchesOnlyAt(rootOf(this)),
41
42
  settings: context.settings,
42
43
  levels: () => bot.resolveSettings(this.optsWithGlobals(), { env: context.env, kind: "bot" }).permissions,
43
44
  env: context.env,
@@ -15,4 +15,6 @@ export interface CommandAvailability {
15
15
  level?: Level;
16
16
  }
17
17
  /** Discovery and execution use the same permission decision. */
18
- export declare const commandAvailability: (info: AvailabilityCommand, levels: Readonly<Record<PermissionKey, Level>>, keyOf?: (path: readonly string[]) => PermissionKey | null | undefined, authority?: (path: readonly string[]) => boolean, readOnly?: boolean, mcp?: boolean, declared?: CommandPermissions) => CommandAvailability;
18
+ export declare const commandAvailability: (info: AvailabilityCommand, levels: Readonly<Record<PermissionKey, Level>>, keyOf?: (path: readonly string[]) => PermissionKey | null | undefined, authority?: (path: readonly string[]) => boolean, readOnly?: boolean, mcp?: boolean, declared?: CommandPermissions,
19
+ /** Whether a command only fetches into the store (`fetchesOnlyAt`): setup's "read only" answer lets it run. */
20
+ fetches?: (path: readonly string[]) => boolean) => CommandAvailability;
@@ -1,11 +1,13 @@
1
1
  import { writes } from "@wirecat/cli-base/standards";
2
- import { AUTHORITY_KEY, authorityAllowed, BOT_API_KEY, botApiAllowed, isBotApi, keyForCommand, levelFor, readKeysForCommand, } from "../sends/permissions.js";
2
+ import { AUTHORITY_KEY, authorityAllowed, BOT_API_KEY, botApiAllowed, CEILING_KEY, isBotApi, keyForCommand, levelFor, readKeysForCommand, } from "../sends/permissions.js";
3
3
  import { changesMessenger } from "./effects.js";
4
4
  /** Discovery and execution use the same permission decision. */
5
- export const commandAvailability = (info, levels, keyOf, authority, readOnly = false, mcp = true, declared) => {
5
+ export const commandAvailability = (info, levels, keyOf, authority, readOnly = false, mcp = true, declared,
6
+ /** Whether a command only fetches into the store (`fetchesOnlyAt`): setup's "read only" answer lets it run. */
7
+ fetches) => {
6
8
  const declaredKey = declared?.keyOf(info.path);
7
9
  const key = declared ? declaredKey : (keyOf?.(info.path) ?? keyForCommand(info.path));
8
- const level = key ? levelFor(levels, key, declared?.defaults).level : "allow";
10
+ const { level, key: named } = key ? levelFor(levels, key, declared?.defaults) : { level: "allow", key: null };
9
11
  const judged = { ...(key ? { permission: key } : {}), level };
10
12
  const blocked = (reason, permission) => ({
11
13
  available: false,
@@ -25,7 +27,7 @@ export const commandAvailability = (info, levels, keyOf, authority, readOnly = f
25
27
  return blocked(`the profile requires ${BOT_API_KEY}: allow`, BOT_API_KEY);
26
28
  if (level === "deny")
27
29
  return blocked(`the profile denies ${key}`);
28
- if (level === "readonly" && writes(info.effects))
30
+ if (level === "readonly" && writes(info.effects) && !(named === CEILING_KEY && fetches?.(info.path) === true))
29
31
  return blocked(`${key} is readonly in this profile`);
30
32
  const denied = (declared ? [] : readKeysForCommand(info.path)).find((read) => levelFor(levels, read).level === "deny");
31
33
  return denied ? blocked(`the profile denies ${denied}`, denied) : { available: true, ...judged };
@@ -30,11 +30,11 @@ export declare const refuseWriteBeforeConnecting: (action: Command, { app, env,
30
30
  }) => void;
31
31
  /**
32
32
  * A command of a CLI that declares its own keys (`commandPermissions`), refused by its key before anything connects:
33
- * `deny` stops it, `readonly` stops a write, and the read-only lock stops a write to the service; a command that
34
- * declares no effects counts as both. `ask` is left to the write guard, which can put the question. A saved or
35
- * `--permission` key that names no command stops every keyed command; housekeeping still runs, so `config unset` can
36
- * remove it. Under the lock a non-messenger CLI still previews a `--dry-run`, which sends nothing (WC-PERM-12); a
37
- * messenger's preview stays refused (SEC-65).
33
+ * `deny` stops it, `readonly` stops a write (setup's "read only" answer still lets a fetch into the store run), and
34
+ * the read-only lock stops a write to the service; a command that declares no effects counts as both. `ask` is left to the write
35
+ * guard, which can put the question. A saved or `--permission` key that names no command stops every keyed command;
36
+ * housekeeping still runs, so `config unset` can remove it. Under the lock a non-messenger CLI still previews a
37
+ * `--dry-run`, which sends nothing (WC-PERM-12); a messenger's preview stays refused (SEC-65).
38
38
  */
39
39
  export declare const refuseByCommandPermissions: (action: Command, permissions: CommandPermissions, { app, env, dryRun, resolve }: {
40
40
  app: AppIdentity;
@@ -8,7 +8,7 @@ import { CEILING_KEY, keyForCommand, levelFor, writeOfKey } from "../sends/permi
8
8
  import { newOperationId } from "../sends/send-id.js";
9
9
  import { commandPathOf } from "./command-contract.js";
10
10
  import { withAgentLevels } from "./context.js";
11
- import { changesMessenger } from "./effects.js";
11
+ import { changesMessenger, fetchesOnly } from "./effects.js";
12
12
  import { refuseUnknownPermissionKeys } from "./permission-keys.js";
13
13
  import { NONE_NAMED, settingsFor } from "./settings.js";
14
14
  /**
@@ -96,11 +96,11 @@ export const refuseWriteBeforeConnecting = (action, { app, env, dryRun, resolve
96
96
  };
97
97
  /**
98
98
  * A command of a CLI that declares its own keys (`commandPermissions`), refused by its key before anything connects:
99
- * `deny` stops it, `readonly` stops a write, and the read-only lock stops a write to the service; a command that
100
- * declares no effects counts as both. `ask` is left to the write guard, which can put the question. A saved or
101
- * `--permission` key that names no command stops every keyed command; housekeeping still runs, so `config unset` can
102
- * remove it. Under the lock a non-messenger CLI still previews a `--dry-run`, which sends nothing (WC-PERM-12); a
103
- * messenger's preview stays refused (SEC-65).
99
+ * `deny` stops it, `readonly` stops a write (setup's "read only" answer still lets a fetch into the store run), and
100
+ * the read-only lock stops a write to the service; a command that declares no effects counts as both. `ask` is left to the write
101
+ * guard, which can put the question. A saved or `--permission` key that names no command stops every keyed command;
102
+ * housekeeping still runs, so `config unset` can remove it. Under the lock a non-messenger CLI still previews a
103
+ * `--dry-run`, which sends nothing (WC-PERM-12); a messenger's preview stays refused (SEC-65).
104
104
  */
105
105
  export const refuseByCommandPermissions = (action, permissions, { app, env, dryRun, resolve }) => {
106
106
  const key = permissions.keyOf(commandPathOf(action));
@@ -126,7 +126,7 @@ export const refuseByCommandPermissions = (action, permissions, { app, env, dryR
126
126
  throw new CliError("permission_error", `profile ${settings.profile} denies ${key} (permissions.${named} is deny, from the ` +
127
127
  `${settings.permissionSources[named ?? ""] ?? "default"})`, { permission: key });
128
128
  }
129
- if (level === "readonly" && writes(effects))
129
+ if (level === "readonly" && writes(effects) && !(named === CEILING_KEY && fetchesOnly(action)))
130
130
  throw levelRefusal({
131
131
  profile: settings.profile,
132
132
  command: app.command,
@@ -345,6 +345,7 @@ export const allHitItem = (item) => item.kind === "meeting"
345
345
  external_id: item.sourceRecord.externalId,
346
346
  },
347
347
  attachments: item.attachments === undefined ? undefined : nonEmpty(item.attachments),
348
+ meeting: item.meeting,
348
349
  untrusted: ALL_HIT_UNTRUSTED[item.kind],
349
350
  });
350
351
  /** Meaning was not searched because the model is not downloaded; `--exact` leaving it out is no gap. */
@@ -1,8 +1,9 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import { metaOf } from "@wirecat/cli-base/commands";
3
3
  import { writes as writesAnything } from "@wirecat/cli-base/standards";
4
- import { keyForCommand, levelFor, readKeysForCommand, WRITE_KEYS } from "../sends/permissions.js";
4
+ import { CEILING_KEY, keyForCommand, levelFor, readKeysForCommand, WRITE_KEYS, } from "../sends/permissions.js";
5
5
  import { commandPathOf } from "./command-contract.js";
6
+ import { fetchesOnly } from "./effects.js";
6
7
  import { refuseUnknownPermissionKeys } from "./permission-keys.js";
7
8
  export class PreviewComplete extends Error {
8
9
  }
@@ -13,14 +14,17 @@ export const preview = (command, settings, tool, keys, messenger = true) => {
13
14
  const keyOf = typeof keys === "object" ? keys.keyOf : keys;
14
15
  refuseUnknownPermissionKeys(command, settings, tool, declared ?? (keyOf && ((one) => keyOf(commandPathOf(one)))));
15
16
  const key = declared ? declared.keyOf(path) : (keyOf?.(path) ?? keyForCommand(path));
16
- const level = key ? levelFor(permissions, key, declared?.defaults).level : "allow";
17
+ const { level, key: named } = key
18
+ ? levelFor(permissions, key, declared?.defaults)
19
+ : { level: "allow", key: null };
17
20
  for (const source of declared ? [] : readKeysForCommand(path)) {
18
21
  if (levelFor(permissions, source).level === "deny")
19
22
  throw new CliError("permission_error", `this profile does not permit ${source}`, { permission: source });
20
23
  }
21
24
  const meta = metaOf(command);
22
- const writes = (meta.effects !== undefined && writesAnything(meta.effects)) ||
23
- (!declared && key !== null && key !== undefined && WRITE_KEYS.includes(key));
25
+ const writes = ((meta.effects !== undefined && writesAnything(meta.effects)) ||
26
+ (!declared && key !== null && key !== undefined && WRITE_KEYS.includes(key))) &&
27
+ !(named === CEILING_KEY && fetchesOnly(command));
24
28
  if (level === "deny" || (writes && level === "readonly"))
25
29
  throw new CliError("permission_error", `this profile does not permit ${path.join(" ")}`, { permission: key });
26
30
  const also = (declared?.alsoChecks?.(path) ?? []).map((one) => {
@@ -24,7 +24,7 @@ import { exitCodeSet } from "./command-server-request.js";
24
24
  import { entityRows } from "./compact.js";
25
25
  import { outputFor, provide } from "./context.js";
26
26
  import { refuseByCommandPermissions, refuseOfflineCommand, refuseWriteBeforeConnecting } from "./early-refusal.js";
27
- import { admittedUnderLock, changesAuthorityAt, changesAuthorityNow, fileOptionOf, isLogin, isStoreChange, judgedEffects, judgedTargets, storeChangeRefusal, } from "./effects.js";
27
+ import { admittedUnderLock, changesAuthorityAt, changesAuthorityNow, fetchesOnlyAt, fileOptionOf, isLogin, isStoreChange, judgedEffects, judgedTargets, storeChangeRefusal, } from "./effects.js";
28
28
  import { itemOf, renderAnswer, snakeKeys } from "./envelope.js";
29
29
  import { byteCount, DEFAULT_AGENT_COOPERATIVE_MS, DEFAULT_COMMAND_MS, DEFAULT_COOPERATIVE_MS, DEFAULT_OUTPUT_BYTES, DEFAULT_SYNC_MS, execution, } from "./execution.js";
30
30
  import { setupAtStart } from "./first-run.js";
@@ -277,14 +277,10 @@ const runOnce = async (argv, definition, options) => {
277
277
  return undefined;
278
278
  try {
279
279
  const overrides = options.agent?.overrides ?? [];
280
- const settings = (definition.configuration ?? settingsFor(definition.app)).resolveSettings(overrides.length ? { ...flags, permission: [...overrides, ...(flags.permission ?? [])] } : flags, {
281
- env,
282
- needsProfile: false,
283
- kind: info.path[0] === "bot" || flags.bot ? "bot" : "personal",
284
- });
280
+ const settings = (definition.configuration ?? settingsFor(definition.app)).resolveSettings(overrides.length ? { ...flags, permission: [...overrides, ...(flags.permission ?? [])] } : flags, { env, needsProfile: false, kind: info.path[0] === "bot" || flags.bot ? "bot" : "personal" });
285
281
  if (!settings.permissions)
286
282
  return undefined;
287
- return commandAvailability(info, settings.permissions, definition.configuration?.permissionKey ?? definition.configuration?.permissions?.keyOf, changesAuthorityAt(program), readOnlyLockOf(definition.app, env) !== undefined, options.agent !== undefined, definition.configuration?.permissions);
283
+ return commandAvailability(info, settings.permissions, definition.configuration?.permissionKey ?? definition.configuration?.permissions?.keyOf, changesAuthorityAt(program), readOnlyLockOf(definition.app, env) !== undefined, options.agent !== undefined, definition.configuration?.permissions, fetchesOnlyAt(program));
288
284
  }
289
285
  catch {
290
286
  // Help must still work when the configuration needs repair.
@@ -18,8 +18,9 @@ export declare const unanswered: (answers: SetupAnswers) => Question[];
18
18
  /** A section written wrongly is replaced; a file that is not JSON at all still refuses, naming itself. */
19
19
  export declare const writeSetupAnswers: (path: string, answers: SetupAnswers) => void;
20
20
  /**
21
- * The level no command of any WireCat tool goes above, or `undefined` when the owner chose to leave them as they
22
- * are. A file that cannot be read keeps everything read-only: reads still work, and `setup` writes it again.
21
+ * The level no command of any WireCat tool goes above, or `undefined` when the owner did not choose "read only".
22
+ * Only that explicit answer limits: a missing, unreadable or malformed file leaves every tool as each profile
23
+ * allows, so a fresh install syncs (owner ruling, 2026-11-13).
23
24
  */
24
25
  export declare const permissionCeiling: (path: string) => Level | undefined;
25
26
  /** `permissionCeiling` of this machine's shared config, for a tool that keeps its own levels: add it as `CEILING_KEY`. */
@@ -33,18 +33,17 @@ export const writeSetupAnswers = (path, answers) => {
33
33
  writeSharedSection(path, SECTION, { ...kept, ...answers });
34
34
  };
35
35
  /**
36
- * The level no command of any WireCat tool goes above, or `undefined` when the owner chose to leave them as they
37
- * are. A file that cannot be read keeps everything read-only: reads still work, and `setup` writes it again.
36
+ * The level no command of any WireCat tool goes above, or `undefined` when the owner did not choose "read only".
37
+ * Only that explicit answer limits: a missing, unreadable or malformed file leaves every tool as each profile
38
+ * allows, so a fresh install syncs (owner ruling, 2026-11-13).
38
39
  */
39
40
  export const permissionCeiling = (path) => {
40
- let answer;
41
41
  try {
42
- answer = readSetupAnswers(path).permissions;
42
+ return readSetupAnswers(path).permissions === "readonly" ? "readonly" : undefined;
43
43
  }
44
44
  catch {
45
- return "readonly";
45
+ return undefined;
46
46
  }
47
- return answer === "allow" ? undefined : answer;
48
47
  };
49
48
  /** `permissionCeiling` of this machine's shared config, for a tool that keeps its own levels: add it as `CEILING_KEY`. */
50
49
  export const setupPermissionCeiling = (env = process.env) => permissionCeiling(sharedConfigPath(storePath(env), env));
@@ -19,6 +19,7 @@ export const PROVIDERS = [
19
19
  { name: "obsidian", kind: "notes", aliases: [] },
20
20
  { name: "added", kind: "notes", aliases: [] },
21
21
  { name: "zoom", kind: "meetings", aliases: [] },
22
+ { name: "google-meet", kind: "meetings", aliases: [], command: "meet" },
22
23
  // Its meetings come from the notes Telemost mails (`keeper@telemost.yandex.ru`), read by a mail rule.
23
24
  { name: "telemost", kind: "meetings", aliases: [] },
24
25
  // A phone export's records: its SMS and its calls in the one account the import names.
@@ -34,6 +35,7 @@ const LABELS = {
34
35
  whatsapp: "WhatsApp",
35
36
  "whatsapp-bot": "WhatsApp bot",
36
37
  "google-drive": "Google Drive",
38
+ "google-meet": "Google Meet",
37
39
  added: "added by hand",
38
40
  email: "mail",
39
41
  telemost: "Telemost",
@@ -49,6 +49,8 @@ export declare const hit: v.StrictObjectSchema<{
49
49
  readonly account: v.StringSchema<undefined>;
50
50
  readonly external_id: v.StringSchema<undefined>;
51
51
  }, undefined>, undefined>;
52
+ /** A document's: the meeting it is the transcript, recording or notes of. */
53
+ readonly meeting: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
52
54
  /** A message's files; absent when it has none. */
53
55
  readonly attachments: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
54
56
  readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -45,6 +45,8 @@ export const hit = v.strictObject({
45
45
  review: v.optional(v.picklist(["proposed", "confirmed"])),
46
46
  /** A business hit's record in the import that made it; absent for one the owner or an agent wrote. */
47
47
  source_record: v.optional(v.strictObject({ provider: text, account: text, external_id: text })),
48
+ /** A document's: the meeting it is the transcript, recording or notes of. */
49
+ meeting: v.optional(reference),
48
50
  /** A message's files; absent when it has none. */
49
51
  attachments: v.optional(v.array(hitFile)),
50
52
  /** Absent on a note hit: the owner wrote it. */
@@ -4378,6 +4378,7 @@ export declare const ENTITIES: {
4378
4378
  readonly account: v.StringSchema<undefined>;
4379
4379
  readonly external_id: v.StringSchema<undefined>;
4380
4380
  }, undefined>, undefined>;
4381
+ readonly meeting: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
4381
4382
  readonly attachments: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
4382
4383
  readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
4383
4384
  readonly kind: v.StringSchema<undefined>;
@@ -5498,6 +5499,12 @@ export declare const ENTITIES: {
5498
5499
  readonly size: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
5499
5500
  readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
5500
5501
  }, undefined>, undefined>;
5502
+ readonly documents: v.ArraySchema<v.StrictObjectSchema<{
5503
+ readonly file_id: v.StringSchema<undefined>;
5504
+ readonly role: v.PicklistSchema<readonly ["transcript", "recording", "notes"], undefined>;
5505
+ readonly title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
5506
+ readonly document: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
5507
+ }, undefined>, undefined>;
5501
5508
  }, undefined>;
5502
5509
  readonly meeting_hit: v.StrictObjectSchema<{
5503
5510
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
@@ -0,0 +1,18 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ export interface GoogleFailure {
3
+ status: number;
4
+ /** The answer's parsed JSON body, or anything else it held. */
5
+ body: unknown;
6
+ /** The request may have changed something: a 5xx then has no certain outcome. */
7
+ mutates: boolean;
8
+ retryAfterMs?: number | undefined;
9
+ /** The API as people know it, in messages: `Google Calendar`, `Google Meet`. `Google` when left out. */
10
+ service?: string;
11
+ /** The API's errors guide, named when the usage limits are exceeded. */
12
+ errorsGuide?: string;
13
+ }
14
+ /**
15
+ * A Google API refusal as a CliError, from the answer's status and body. Google's own message is never repeated: it
16
+ * can quote the ids and text that were asked for (WC-SECR-6).
17
+ */
18
+ export declare const googleError: ({ status, body, mutates, retryAfterMs, service, errorsGuide, }: GoogleFailure) => CliError;
@@ -0,0 +1,71 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { statusToCode } from "@wirecat/cli-base/http";
3
+ const isRecord = (value) => typeof value === "object" && value !== null;
4
+ const reasonsOf = (body) => {
5
+ const error = isRecord(body) ? body.error : undefined;
6
+ if (!isRecord(error))
7
+ return [];
8
+ return [
9
+ ...(Array.isArray(error.errors) ? error.errors.map((item) => item?.reason) : []),
10
+ ...(Array.isArray(error.details)
11
+ ? error.details
12
+ .filter((detail) => detail?.["@type"] === "type.googleapis.com/google.rpc.ErrorInfo")
13
+ .map((detail) => detail.reason)
14
+ : []),
15
+ error.status,
16
+ ].filter((reason) => typeof reason === "string");
17
+ };
18
+ const RATE = new Set(["rateLimitExceeded", "userRateLimitExceeded", "RESOURCE_EXHAUSTED"]);
19
+ /**
20
+ * A Google API refusal as a CliError, from the answer's status and body. Google's own message is never repeated: it
21
+ * can quote the ids and text that were asked for (WC-SECR-6).
22
+ */
23
+ export const googleError = ({ status, body, mutates, retryAfterMs, service = "Google", errorsGuide, }) => {
24
+ const reasons = reasonsOf(body);
25
+ const wait = retryAfterMs === undefined ? {} : { retry_after_ms: retryAfterMs };
26
+ if (status === 401)
27
+ return new CliError("authentication_error", "Google sign-in expired", {
28
+ reason: "oauth.expired",
29
+ status,
30
+ });
31
+ if (reasons.some((reason) => reason === "accessNotConfigured" || reason === "SERVICE_DISABLED"))
32
+ return new CliError("configuration_error", `the ${service} API is turned off for this OAuth project; its owner turns it on in Google Cloud API Library`, { reason: "api.disabled", status });
33
+ if (reasons.some((reason) => reason === "insufficientPermissions" || reason === "ACCESS_TOKEN_SCOPE_INSUFFICIENT"))
34
+ return new CliError("permission_error", "the sign-in lacks the Google permission this method needs", {
35
+ reason: "oauth.scope-missing",
36
+ status,
37
+ });
38
+ // Google answers it with the Workspace usage limits, not with a retry.
39
+ if (reasons.includes("quotaExceeded"))
40
+ return new CliError("rate_limited", `${service} usage limits are exceeded for this account; wait before trying again` +
41
+ (errorsGuide ? ` (${errorsGuide})` : ""), { reason: "provider.usage-limit", retryable: false, status });
42
+ if (status === 429 || reasons.some((reason) => RATE.has(reason)))
43
+ // Google turned the request away before acting on it, so even a write is safe to send again.
44
+ return new CliError("rate_limited", "Google rate limit reached; retry the command", {
45
+ retryable: true,
46
+ status,
47
+ ...wait,
48
+ });
49
+ if (status >= 500)
50
+ return mutates
51
+ ? new CliError("outcome_unknown", "Google write has no certain outcome; check Google before repeating it", {
52
+ retryable: false,
53
+ status,
54
+ })
55
+ : new CliError(statusToCode(status), `${service} failed (HTTP ${status}); retry the command`, {
56
+ retryable: true,
57
+ status,
58
+ ...wait,
59
+ });
60
+ if (status === 403)
61
+ return new CliError("permission_error", `${service} denied this operation; check this account's access to it`, {
62
+ reason: "access.denied",
63
+ status,
64
+ });
65
+ if (status === 404)
66
+ return new CliError("not_found", `${service} has no such item, or this account cannot see it`, {
67
+ reason: "item.not-found",
68
+ status,
69
+ });
70
+ return new CliError(statusToCode(status), `${service} refused the request (HTTP ${status})`, { status });
71
+ };
@@ -0,0 +1,2 @@
1
+ export { type GoogleFailure, googleError } from "./errors.js";
2
+ export { GOOGLE_MAX_PAGES, type GooglePage, googlePages } from "./pages.js";
@@ -0,0 +1,2 @@
1
+ export { googleError } from "./errors.js";
2
+ export { GOOGLE_MAX_PAGES, googlePages } from "./pages.js";
@@ -0,0 +1,11 @@
1
+ export declare const GOOGLE_MAX_PAGES = 1000;
2
+ /** One page of a Google list, its items under the name `items` whatever the API calls them. */
3
+ export interface GooglePage<T> {
4
+ items?: readonly T[] | null;
5
+ nextPageToken?: string | null;
6
+ }
7
+ /**
8
+ * Every page of one Google list, following `nextPageToken`. A repeated page token or a list past `maxPages` is
9
+ * Google's fault and stops the read with `invalid_response`, instead of looping forever.
10
+ */
11
+ export declare const googlePages: <T>(what: string, read: (pageToken?: string) => Promise<GooglePage<T>>, maxPages?: number) => Promise<T[]>;
@@ -0,0 +1,23 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ export const GOOGLE_MAX_PAGES = 1000;
3
+ /**
4
+ * Every page of one Google list, following `nextPageToken`. A repeated page token or a list past `maxPages` is
5
+ * Google's fault and stops the read with `invalid_response`, instead of looping forever.
6
+ */
7
+ export const googlePages = async (what, read, maxPages = GOOGLE_MAX_PAGES) => {
8
+ const items = [];
9
+ const seen = new Set();
10
+ let pageToken;
11
+ for (let page = 0; page < maxPages; page++) {
12
+ const answer = await read(pageToken);
13
+ for (const item of answer.items ?? [])
14
+ items.push(item);
15
+ if (!answer.nextPageToken)
16
+ return items;
17
+ if (seen.has(answer.nextPageToken))
18
+ throw new CliError("invalid_response", `Google repeated a page token of ${what}`);
19
+ seen.add(answer.nextPageToken);
20
+ pageToken = answer.nextPageToken;
21
+ }
22
+ throw new CliError("invalid_response", `Google listed ${what} past ${maxPages} pages`);
23
+ };
@@ -6,3 +6,4 @@ export { ownCatalogue } from "./own-catalogue.js";
6
6
  export { neverAnswers, type RunScopeCase, type RunScopeOptions, runScopeCases } from "./run-scope.js";
7
7
  export { type SearchRecipes, searchRecipes, seedSearchRecipes } from "./search-recipes.js";
8
8
  export { BUSY_PAGE, contractSeed, digitIds, type IdKind, type IdMaker, type Seed, wordIds } from "./seed.js";
9
+ export { type SyncAfterInstallCase, type SyncAfterInstallOptions, syncAfterInstallCases } from "./sync-after-install.js";
package/dist/kit/index.js CHANGED
@@ -6,3 +6,4 @@ export { ownCatalogue } from "./own-catalogue.js";
6
6
  export { neverAnswers, runScopeCases } from "./run-scope.js";
7
7
  export { searchRecipes, seedSearchRecipes } from "./search-recipes.js";
8
8
  export { BUSY_PAGE, contractSeed, digitIds, wordIds } from "./seed.js";
9
+ export { syncAfterInstallCases } from "./sync-after-install.js";
@@ -0,0 +1,26 @@
1
+ export interface SyncAfterInstallCase {
2
+ name: string;
3
+ /** Throws an `AssertionError` when the command is refused or fails. */
4
+ run(): Promise<void>;
5
+ }
6
+ export interface SyncAfterInstallOptions {
7
+ /** The words that sync a signed-in profile against the CLI's fake service: `["work", "sync"]`. */
8
+ sync: readonly string[];
9
+ /**
10
+ * Runs the CLI as its own tests do, against its fake service, with `env` laid over the test's environment. A CLI
11
+ * on cli-core's program passes `run(argv, definition, { ...fakes, env: { ...process.env, ...env } })`.
12
+ */
13
+ run: (argv: string[], env: NodeJS.ProcessEnv) => Promise<{
14
+ code: number;
15
+ err: string;
16
+ out?: string;
17
+ }>;
18
+ /** Words of a local-only change that the "read only" answer must still refuse, as a check it opens no more. */
19
+ refusedUnderReadOnly?: readonly string[];
20
+ }
21
+ /**
22
+ * Cases that a CLI's sync runs right after install, whatever state the shared config is in. The kit points
23
+ * `WIRECAT_CONFIG_DIR` at a folder of its own, so the owner's config never hides the failure; the store is the one
24
+ * the CLI's own harness gives.
25
+ */
26
+ export declare const syncAfterInstallCases: (options: SyncAfterInstallOptions) => SyncAfterInstallCase[];
@@ -0,0 +1,72 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ /**
6
+ * The shared config (`~/.config/WireCat/config.json`) as a fresh or damaged machine has it. Only an explicit
7
+ * "read only" answer limits a tool, and even then a sync runs: it only reads the service (owner ruling, 2026-11-13).
8
+ */
9
+ const SHARED_CONFIGS = [
10
+ { state: "no shared config, as on a fresh install" },
11
+ { state: "a shared config that is not JSON", write: (dir) => writeFileSync(join(dir, "config.json"), "{ setup: ") },
12
+ {
13
+ state: "a shared config with a byte-order mark",
14
+ write: (dir) => writeFileSync(join(dir, "config.json"), '{"setup":{"permissions":"allow"}}'),
15
+ },
16
+ { state: "a folder where the shared config should be", write: (dir) => mkdirSync(join(dir, "config.json")) },
17
+ {
18
+ state: "a setup section in a shape this version does not take",
19
+ write: (dir) => writeFileSync(join(dir, "config.json"), JSON.stringify({ setup: { languages: ["en"], permissions: "ask" } })),
20
+ },
21
+ {
22
+ state: 'the explicit "read only" answer',
23
+ write: (dir) => writeFileSync(join(dir, "config.json"), JSON.stringify({ setup: { permissions: "readonly" } })),
24
+ readOnly: true,
25
+ },
26
+ ];
27
+ const errorCodeOf = (text) => {
28
+ try {
29
+ return JSON.parse(text.trim()).error?.code;
30
+ }
31
+ catch {
32
+ return undefined;
33
+ }
34
+ };
35
+ /**
36
+ * Cases that a CLI's sync runs right after install, whatever state the shared config is in. The kit points
37
+ * `WIRECAT_CONFIG_DIR` at a folder of its own, so the owner's config never hides the failure; the store is the one
38
+ * the CLI's own harness gives.
39
+ */
40
+ export const syncAfterInstallCases = (options) => {
41
+ const { sync, refusedUnderReadOnly } = options;
42
+ const cli = async (argv, shared) => {
43
+ const configDir = mkdtempSync(join(tmpdir(), "sync-after-install-"));
44
+ shared.write?.(configDir);
45
+ const ran = await options.run(argv.includes("--json") ? [...argv] : [...argv, "--json"], {
46
+ WIRECAT_CONFIG_DIR: configDir,
47
+ });
48
+ return { code: ran.code, out: ran.out ?? "", err: ran.err };
49
+ };
50
+ return [
51
+ ...SHARED_CONFIGS.map((shared) => ({
52
+ name: `${sync.join(" ")} runs with ${shared.state}`,
53
+ run: async () => {
54
+ const ran = await cli(sync, shared);
55
+ assert.notEqual(errorCodeOf(ran.err), "permission_error", `sync was refused: ${ran.err}`);
56
+ assert.equal(ran.code, 0, `sync exited ${ran.code}: ${ran.out}${ran.err}`);
57
+ },
58
+ })),
59
+ ...(refusedUnderReadOnly
60
+ ? [
61
+ {
62
+ name: `${refusedUnderReadOnly.join(" ")} is still refused under the explicit "read only" answer`,
63
+ run: async () => {
64
+ const readOnly = SHARED_CONFIGS.find((one) => one.readOnly);
65
+ const ran = await cli(refusedUnderReadOnly, readOnly);
66
+ assert.equal(errorCodeOf(ran.err), "permission_error", `it was not refused: ${ran.out}${ran.err}`);
67
+ },
68
+ },
69
+ ]
70
+ : []),
71
+ ];
72
+ };
@@ -27,6 +27,7 @@ export interface AgentContext {
27
27
  /** A declared CLI's keys and defaults (`configuration.permissions`); in place of `keyOf`. */
28
28
  permissions?: CommandPermissions | undefined;
29
29
  authority?: CatalogueOptions["authority"];
30
+ fetches?: CatalogueOptions["fetches"];
30
31
  /** The server's one open connection. The command borrows it: it cannot close it, and never opens its own. */
31
32
  connection?: () => Promise<MessengerAdapter>;
32
33
  /** What a command reads on stdin, as the field an agent gives it in. */
@@ -74,6 +75,8 @@ export interface CatalogueOptions {
74
75
  authority?: (path: readonly string[]) => boolean;
75
76
  /** Whether a command only fetches into this machine (`fetchesOnlyAt`): offered as a read. Unset, every write stays one. */
76
77
  fetchOnly?: (path: readonly string[]) => boolean;
78
+ /** Whether a command only fetches into the store (`fetchesOnlyAt`): setup's "read only" answer lets it run. */
79
+ fetches?: (path: readonly string[]) => boolean;
77
80
  /** Arguments left out of every tool, by name. */
78
81
  omit?: readonly string[];
79
82
  /** Offer `offline` on commands that read the messenger: answer from the copy on this machine. */