@wirecat/cli-core 1.2.0 → 1.3.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,31 @@ 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
+ ## 1.3.0 — 26.11.2026
9
+
10
+ ### Changed — experimental
11
+
12
+ - **A messenger's profiles are listed by `session list`, and `account list` is gone (WC-CMD-8, WC-ACCT-12).** The
13
+ shared messenger `account` group no longer has `list`, with no alias. `session list` answers the same rows. The
14
+ shared `session` contract (`sharedCommandTemplate(app, "session")`) now has `status` and `list` beside `start` and
15
+ `end`, so a messenger CLI mounts `messengerSessionCommands(messenger)` in its own `session` group, or its session
16
+ shell no longer matches the contract. The parity manifest lists `session list` and `session status` in tg, max and
17
+ wa, and the first help screen points at `<tool> session list`. Like the rest of the `session` group, `session list`
18
+ is not an MCP tool: the all-profiles MCP server already names every profile, and whether it is signed in, in each
19
+ tool's `profile` field. The commands a CLI mounts are not part of the stable API: `accountCommand` and
20
+ `messengerSessionCommands` keep their signatures, so this ships in a minor.
21
+ - **slk loses its duplicate `account list`** on its next cli-core bump: it mounts the shared `account` group, and its
22
+ own `session list` stays. Every CLI with a `session list` (drive, gcal, zm, mail, b24, slk and others) gains the
23
+ line `<tool> session list your profiles and their logged-in accounts` on its first help screen, so its
24
+ `contracts/help.snap` changes on that bump.
25
+
26
+ ### Fixed
27
+
28
+ - **A store another process holds is `store.busy`, not a crash.** When a scheduled sync of one account kept the write
29
+ lock past the busy timeout, the other account's sync failed with SQLite's raw `database is locked`, reported as
30
+ `command.crashed`, "this is a bug", exit 1. It is now a `conflict` (exit 15) with the reason `store.busy`, in the CLI,
31
+ over MCP and in the run record; `storeBusy` does the same for a caller's own error path.
32
+
8
33
  ## 1.2.0 — 25.11.2026
9
34
 
10
35
  ### Added
@@ -9,6 +9,7 @@ import { unfilteredQuery, withQuery } from "./list-query.js";
9
9
  import { doctorCommand } from "./messenger/doctor-command.js";
10
10
  import { mcpCommand } from "./messenger/mcp-command.js";
11
11
  import { searchCommand } from "./messenger/search-command.js";
12
+ import { messengerSessionCommands } from "./messenger/session-commands.js";
12
13
  import { pagingOf } from "./paging.js";
13
14
  import { settingsFor } from "./settings.js";
14
15
  /**
@@ -91,6 +92,8 @@ export const sharedCommandTemplate = (app, name) => {
91
92
  .description("link this account")
92
93
  .argument("[method]", "login method");
93
94
  annotate(session.command("end"), { effects: REMOTE_WRITE }).description("end this account's login");
95
+ for (const command of messengerSessionCommands(messenger))
96
+ session.addCommand(command);
94
97
  return session;
95
98
  }
96
99
  const notes = annotate(new Command("notes"), { effects: NO_EFFECTS }).description("notes kept in the shared store");
@@ -32,8 +32,8 @@ const pointers = (program, cli, start, profile) => {
32
32
  ].filter((row) => row !== undefined);
33
33
  const rows = [
34
34
  ...(start ? [["Start here:", start, profile ? "(any profile name works)" : ""]] : []),
35
- ...(has("account list")
36
- ? [["", `${cli} account list`, "your profiles and their logged-in accounts"]]
35
+ ...(has("session list")
36
+ ? [["", `${cli} session list`, "your profiles and their logged-in accounts"]]
37
37
  : []),
38
38
  ...next.map(([command = "", does = ""], at) => [at === 0 ? "Next:" : "", command, does]),
39
39
  ...(has("skill show") ? [["For agents:", `${cli} skill show`, "rules and the discovery loop"]] : []),
@@ -8,7 +8,7 @@ export { dealBrief as dealBriefSchema, dealContext as dealContextSchema, organiz
8
8
  export { botTemplate } from "../entities/list-results.js";
9
9
  export { documentEntry, documentEntryDetails, documentSource, LISTING_ENTITIES, meetingEntry, meetingEntryDetails, } from "../entities/listings.js";
10
10
  export { syncProgress } from "../entities/store-records.js";
11
- export { isCliFailure, isCommanderFailure, storeDamaged } from "../errors/failures.js";
11
+ export { isCliFailure, isCommanderFailure, storeBusy, storeDamaged } from "../errors/failures.js";
12
12
  export { type AppErrors, failureContext } from "../errors/reasons.js";
13
13
  export { linkFetch } from "../http/link-fetch.js";
14
14
  export { type TimeLimit, timeLimit, withTimeLimit } from "../http/time-limit.js";
package/dist/cli/index.js CHANGED
@@ -8,7 +8,7 @@ export { dealBrief as dealBriefSchema, dealContext as dealContextSchema, organiz
8
8
  export { botTemplate } from "../entities/list-results.js";
9
9
  export { documentEntry, documentEntryDetails, documentSource, LISTING_ENTITIES, meetingEntry, meetingEntryDetails, } from "../entities/listings.js";
10
10
  export { syncProgress } from "../entities/store-records.js";
11
- export { isCliFailure, isCommanderFailure, storeDamaged } from "../errors/failures.js";
11
+ export { isCliFailure, isCommanderFailure, storeBusy, storeDamaged } from "../errors/failures.js";
12
12
  export { failureContext } from "../errors/reasons.js";
13
13
  export { linkFetch } from "../http/link-fetch.js";
14
14
  export { timeLimit, withTimeLimit } from "../http/time-limit.js";
@@ -5,26 +5,16 @@ import { accountRemoveCommand } from "../account-remove.js";
5
5
  import { accountRenameCommand } from "../account-rename.js";
6
6
  import { REMOTE_READ, REMOTE_WRITE } from "../effects.js";
7
7
  import { itemOf, renderAnswer } from "../envelope.js";
8
- import { withQuery } from "../list-query.js";
9
- import { ACCOUNT_PROFILES_QUERY } from "./account-profile-query.js";
10
8
  import { accountSessionsCommand } from "./account-sessions-command.js";
11
9
  import { photoHelp, readProfilePhoto } from "./admin-commands.js";
12
10
  import { accountAnswer, renderItem } from "./chat-answers.js";
13
11
  import { messengerContext } from "./context.js";
14
12
  import { hideNever } from "./lacks.js";
15
13
  import { privacyCommand } from "./records-command.js";
16
- import { listProfiles } from "./session-commands.js";
17
14
  export const accountCommand = (messenger) => {
18
15
  const tool = `${messenger.app.command} personal`;
19
16
  const account = new Command("account")
20
17
  .description("the logged-in account")
21
- .addCommand(withQuery(annotate(new Command("list"), { effects: REMOTE_READ, examples: [`${tool} account list`] }), ACCOUNT_PROFILES_QUERY)
22
- .summary("profiles on this computer and their signed-in accounts")
23
- .description("every account profile on this computer, and the account each is logged in as; a name that is only a bot " +
24
- "is left out (`bot list` has it), one that is a bot too says `bot: true`; asks the messenger nothing")
25
- .action(async function (words) {
26
- await listProfiles(this, messenger, words, "account list");
27
- }))
28
18
  .addCommand(annotate(new Command("show"), {
29
19
  effects: REMOTE_READ,
30
20
  output: { entity: "account" },
@@ -7,5 +7,5 @@ export declare const rememberAccount: (app: AppIdentity, profile: string, id: st
7
7
  export declare const recalledAccount: (app: AppIdentity, provider: Provider, profile: string, env: NodeJS.ProcessEnv) => AccountKey | undefined;
8
8
  /** Profiles somebody has logged in to, whether or not the configuration file names them. */
9
9
  export declare const profilesWithAccounts: (app: AppIdentity, env: NodeJS.ProcessEnv) => string[];
10
- /** The profiles on this computer, as `account list` shows them: named in the configuration file, or logged in to. */
10
+ /** The profiles on this computer, as `session list` shows them: named in the configuration file, or logged in to. */
11
11
  export declare const profilesHere: (app: AppIdentity, configured: readonly string[], env: NodeJS.ProcessEnv) => string[];
@@ -22,5 +22,5 @@ export const profilesWithAccounts = (app, env) => {
22
22
  .filter((name) => name.endsWith(".json"))
23
23
  .map((name) => name.slice(0, -".json".length));
24
24
  };
25
- /** The profiles on this computer, as `account list` shows them: named in the configuration file, or logged in to. */
25
+ /** The profiles on this computer, as `session list` shows them: named in the configuration file, or logged in to. */
26
26
  export const profilesHere = (app, configured, env) => [...new Set([...configured, ...profilesWithAccounts(app, env)])].sort();
@@ -72,7 +72,7 @@ export interface Messenger extends ServiceMessenger {
72
72
  /**
73
73
  * A profile's state, read from the messenger's own files without connecting: `signed-in` has a session, `signed-out`
74
74
  * has none yet, `bot` speaks for a bot. `<tool> mcp` with no profile offers the personal ones and marks those not
75
- * signed in; `account list` and the profile errors say so too. Unset: every profile counts as signed in.
75
+ * signed in; `session list` and the profile errors say so too. Unset: every profile counts as signed in.
76
76
  */
77
77
  profileState?: (profile: string, env: NodeJS.ProcessEnv) => ProfileState;
78
78
  /** Opts in to `account remove`: what signing out and forgetting a profile means for this messenger. */
@@ -1,6 +1,6 @@
1
1
  import { Command } from "commander";
2
2
  import { type Messenger } from "./context.js";
3
- /** What `account list` and `session list` answer: the profiles here and the account each is logged in as. */
3
+ /** What `session list` answers: the profiles here and the account each is logged in as. */
4
4
  export declare const listProfiles: (command: Command, messenger: Messenger, words: string[], label: string) => Promise<void>;
5
5
  /**
6
6
  * `session status` and `session list`, for a messenger's own `session` group beside its `start` and `end`
@@ -14,7 +14,7 @@ import { recalledAccount } from "./accounts.js";
14
14
  import { accountAnswer, wholeList } from "./chat-answers.js";
15
15
  import { messengerContext } from "./context.js";
16
16
  const storeOf = async (env) => existsSync(storePath(env)) ? await openStore({ env }).catch(() => undefined) : undefined;
17
- /** What `account list` and `session list` answer: the profiles here and the account each is logged in as. */
17
+ /** What `session list` answers: the profiles here and the account each is logged in as. */
18
18
  export const listProfiles = async (command, messenger, words, label) => {
19
19
  const terms = queryTerms(words, ACCOUNT_PROFILES_QUERY, label);
20
20
  const context = messengerContext(command, messenger, { needsProfile: false });
@@ -7,7 +7,7 @@ import { Command, Help } from "commander";
7
7
  import { relayCommand } from "../background/relay.js";
8
8
  import { failingNotice, scheduledRuns } from "../background/schedules.js";
9
9
  import { parseDuration } from "../domain/duration.js";
10
- import { isCliFailure, isCommanderFailure, storeDamaged, usageReason } from "../errors/failures.js";
10
+ import { isCliFailure, isCommanderFailure, storeBusy, storeDamaged, usageReason } from "../errors/failures.js";
11
11
  import { failureContext } from "../errors/reasons.js";
12
12
  import { envName, readOnlyLockOf, readOnlyRefusal } from "../ports/app.js";
13
13
  import { recorded, wasSettled } from "../runs/recording.js";
@@ -780,7 +780,7 @@ const failed = ({ app }, program, rest, error, settled, debug) => {
780
780
  const path = typedCommandPath(program, program.args.length > 0 ? program.args : rest);
781
781
  const told = error instanceof NoProfileHere && !commandAt(program, "setup")
782
782
  ? error.withoutSetup(path)
783
- : storeDamaged(error, damageStep(program, app.command));
783
+ : storeBusy(storeDamaged(error, damageStep(program, app.command)));
784
784
  const failure = settled.settlementFailed && isCliFailure(told)
785
785
  ? new CliError(told.code, told.message, { ...told.details, settlement_failed: true })
786
786
  : told;
@@ -168,12 +168,12 @@ export interface Settings extends AISettings {
168
168
  /** Every profile on this computer, bots included — what a missing profile's error lists. */
169
169
  profilesHere: string[];
170
170
  /**
171
- * The profiles here that are an account, not only a bot — what `account list` shows. A name only the file's bot
171
+ * The profiles here that are an account, not only a bot — what `session list` shows. A name only the file's bot
172
172
  * section names, with no personal section, recorded login or messenger profile of its own, is a bot. Absent for an
173
173
  * app that builds `Settings` itself; `profilesHere` stands in.
174
174
  */
175
175
  accountProfiles?: string[];
176
- /** Every name with a bot: the file's bot section, or a bot's own files. `account list` marks these. */
176
+ /** Every name with a bot: the file's bot section, or a bot's own files. `session list` marks these. */
177
177
  botProfiles?: string[];
178
178
  /** Where each value came from — `config show` prints it. */
179
179
  sources: Record<string, Source>;
@@ -200,7 +200,7 @@ export interface ResolveOptions {
200
200
  /** `personal` unless given. */
201
201
  kind?: ProfileKind;
202
202
  /**
203
- * `false` for a command that touches no account — `account list`, `config show` — so it still runs
203
+ * `false` for a command that touches no account — `session list`, `config show` — so it still runs
204
204
  * when no profile is named. Its `profile` is then `default`, from `none named`.
205
205
  */
206
206
  needsProfile?: boolean;
@@ -45,7 +45,7 @@ const perAccount = { chats: count, messages: count, emails: count, documents: co
45
45
  const contents = {
46
46
  by_provider: v.optional(v.array(v.strictObject({ provider: text, accounts: count, ...perAccount }))),
47
47
  by_chat_kind: v.optional(v.array(v.strictObject({ provider: text, kind: text, chats: count, messages: count }))),
48
- /** `name` is the one `account list` shows; the messenger's own id for the account is left out. */
48
+ /** `name` is the one `session list` shows; the messenger's own id for the account is left out. */
49
49
  by_account: v.optional(v.array(v.strictObject({ provider: text, account_id: count, name: v.nullable(text), ...perAccount }))),
50
50
  /** Calendar years in UTC. */
51
51
  by_year: v.optional(v.array(v.strictObject({ provider: text, year: count, messages: count }))),
@@ -30,6 +30,12 @@ export declare const sqliteCode: (error: unknown) => number | undefined;
30
30
  * @experimental
31
31
  */
32
32
  export declare const storeDamaged: (error: unknown, next?: string) => unknown;
33
+ /**
34
+ * Another process (a scheduled sync of another account, memo's import) held the store's write lock past the busy
35
+ * timeout: `store.busy`, not a crash. Not marked safe to retry, as the command may have written before it waited.
36
+ * @experimental
37
+ */
38
+ export declare const storeBusy: (error: unknown) => unknown;
33
39
  /** Runs `work` on store files the owner named, so a damaged one is named rather than taken for the CLI's own. */
34
40
  export declare const damagedFile: <T>(files: readonly string[], work: () => Promise<T>) => Promise<T>;
35
41
  /** Whether `error` is SQLite saying the database file is damaged. */
@@ -23,6 +23,7 @@ const USAGE_REASONS = {
23
23
  export const usageReason = (code) => USAGE_REASONS[code];
24
24
  /** What failed, never what it said: a messenger's refusal can quote the message back. */
25
25
  export const failureKey = (error) => isCliFailure(error) ? error.code : error instanceof Error ? error.name : "error";
26
+ const SQLITE_BUSY = 5;
26
27
  const SQLITE_CORRUPT = 11;
27
28
  const SQLITE_NOTADB = 26;
28
29
  const DAMAGED_TEXT = /database disk image is malformed|file is not a database|fts5: corruption/i;
@@ -35,19 +36,22 @@ export const sqliteCode = (error) => {
35
36
  const code = typeof errcode === "number" ? errcode : name === "SQLiteError" && typeof errno === "number" ? errno : null;
36
37
  return code === null ? undefined : code & 0xff;
37
38
  };
38
- /** The SQLite failure that says the database file is damaged, on the error or up to five `cause`s behind it. */
39
- const damageIn = (error) => {
39
+ /** The SQLite failure `matches` picks, on the error or up to five `cause`s behind it. */
40
+ const sqliteFailureIn = (error, matches) => {
40
41
  if (isCliFailure(error) || isCommanderFailure(error))
41
42
  return undefined;
42
43
  let at = error;
43
44
  for (let depth = 0; depth < 5 && at instanceof Error; depth += 1) {
44
- const code = sqliteCode(at);
45
- if ((code !== undefined && [SQLITE_CORRUPT, SQLITE_NOTADB].includes(code)) || DAMAGED_TEXT.test(at.message))
45
+ if (matches(at))
46
46
  return at;
47
47
  at = at.cause;
48
48
  }
49
49
  return undefined;
50
50
  };
51
+ const damageIn = (error) => sqliteFailureIn(error, (at) => {
52
+ const code = sqliteCode(at);
53
+ return (code !== undefined && [SQLITE_CORRUPT, SQLITE_NOTADB].includes(code)) || DAMAGED_TEXT.test(at.message);
54
+ });
51
55
  // The record's frames are where SQLite failed, not where the failure was renamed.
52
56
  const wrapping = (error, original) => {
53
57
  Object.defineProperty(error, "cause", { value: original, configurable: true, writable: true });
@@ -65,6 +69,16 @@ const wrapping = (error, original) => {
65
69
  export const storeDamaged = (error, next) => damageIn(error)
66
70
  ? wrapping(new CliError("configuration_error", `the store file is damaged${next ? `; \`${next}\` says what is damaged and what to do` : ""}`, { reason: "store.damaged" }), error)
67
71
  : error;
72
+ /**
73
+ * Another process (a scheduled sync of another account, memo's import) held the store's write lock past the busy
74
+ * timeout: `store.busy`, not a crash. Not marked safe to retry, as the command may have written before it waited.
75
+ * @experimental
76
+ */
77
+ export const storeBusy = (error) => sqliteFailureIn(error, (at) => sqliteCode(at) === SQLITE_BUSY)
78
+ ? wrapping(new CliError("conflict", "another process held the store for longer than this command waits; run it again", {
79
+ reason: "store.busy",
80
+ }), error)
81
+ : error;
68
82
  /** Runs `work` on store files the owner named, so a damaged one is named rather than taken for the CLI's own. */
69
83
  export const damagedFile = async (files, work) => {
70
84
  try {
@@ -13,6 +13,7 @@ export const STORE = [
13
13
  "conflict",
14
14
  "another program deleted or replaced the store's journal file while it was open; store recover says what to do",
15
15
  ],
16
+ ["store.busy", "conflict", "another process held the store for longer than this command waits; run it again"],
16
17
  validation("store.file-damaged", "the named store file is damaged or not a database"),
17
18
  ["store.unopenable", "configuration_error", "the store file cannot be opened at its path; details.path names it"],
18
19
  [
package/dist/mcp/tool.js CHANGED
@@ -8,7 +8,7 @@ import { DEFAULT_OUTPUT_BYTES } from "../cli/execution.js";
8
8
  import { MAX_BUFFERED_INPUT } from "../cli/input-policy.js";
9
9
  import { refuseLacking } from "../cli/messenger/lacks.js";
10
10
  import { ENTITIES } from "../entities/index.js";
11
- import { storeDamaged } from "../errors/failures.js";
11
+ import { storeBusy, storeDamaged } from "../errors/failures.js";
12
12
  import { failureContext } from "../errors/reasons.js";
13
13
  import { startRecording } from "../runs/recording.js";
14
14
  import { newRunId } from "../runs/run.js";
@@ -320,7 +320,7 @@ export const answered = (answer, maxBytes = DEFAULT_OUTPUT_BYTES, targets) => {
320
320
  export const failed = (error, errors, effects) => {
321
321
  const judged = judgedEffects(effects);
322
322
  const context = { ...failureContext(errors), ...(judged ? { effects: judged } : {}) };
323
- return mcpErrorResult(JSON.parse(agentJson(errorObjectOf(storeDamaged(error), context))));
323
+ return mcpErrorResult(JSON.parse(agentJson(errorObjectOf(storeBusy(storeDamaged(error)), context))));
324
324
  };
325
325
  /** An option's name as an MCP argument: `beforeId` is `before_id`. */
326
326
  export const snakeOf = (key) => key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
@@ -1,5 +1,5 @@
1
1
  import { processStreams } from "@wirecat/cli-base";
2
- import { isCliFailure, storeDamaged } from "../errors/failures.js";
2
+ import { isCliFailure, storeBusy, storeDamaged } from "../errors/failures.js";
3
3
  import { markStoreDamaged } from "../store/marks.js";
4
4
  import { storePath } from "../store/path.js";
5
5
  import { endpointTemplate, errorDetailOf, framesOf } from "./error-detail.js";
@@ -118,7 +118,7 @@ export const startRecording = (options) => {
118
118
  });
119
119
  },
120
120
  fail: async (thrown) => {
121
- const error = storeDamaged(thrown);
121
+ const error = storeBusy(storeDamaged(thrown));
122
122
  markStoreDamaged(thrown, {
123
123
  store: storePath(options.env),
124
124
  command: `${options.app.command} ${options.command}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Viacheslav Ptsarev",
package/parity.json CHANGED
@@ -1226,9 +1226,6 @@
1226
1226
  "account": {
1227
1227
  "in": "all"
1228
1228
  },
1229
- "account list": {
1230
- "in": "all"
1231
- },
1232
1229
  "account privacy": {
1233
1230
  "in": ["max"],
1234
1231
  "planned": {
@@ -4525,6 +4522,9 @@
4525
4522
  "session end": {
4526
4523
  "in": "all"
4527
4524
  },
4525
+ "session list": {
4526
+ "in": "all"
4527
+ },
4528
4528
  "session start": {
4529
4529
  "in": "all",
4530
4530
  "options": {
@@ -4548,6 +4548,12 @@
4548
4548
  }
4549
4549
  }
4550
4550
  },
4551
+ "session status": {
4552
+ "in": "all",
4553
+ "options": {
4554
+ "--check": "all"
4555
+ }
4556
+ },
4551
4557
  "setup": {
4552
4558
  "in": "all",
4553
4559
  "options": {