@wirecat/cli-core 0.649.0 → 0.651.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 (81) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/dist/analysis/anthropic.js +2 -1
  3. package/dist/cli/account-remove.d.ts +2 -0
  4. package/dist/cli/account-remove.js +54 -13
  5. package/dist/cli/compact.d.ts +5 -0
  6. package/dist/cli/compact.js +7 -3
  7. package/dist/cli/doctor-reports-command.d.ts +11 -0
  8. package/dist/cli/doctor-reports-command.js +57 -5
  9. package/dist/cli/help/first-screen.js +5 -0
  10. package/dist/cli/messenger/messages-search-command.js +6 -1
  11. package/dist/cli/messenger/search-answers.d.ts +3 -1
  12. package/dist/cli/messenger/search-answers.js +3 -1
  13. package/dist/cli/program.js +3 -1
  14. package/dist/cli/schedule/schedule-command.js +9 -3
  15. package/dist/cli/steps.js +9 -0
  16. package/dist/cli/unknown-profile.d.ts +4 -3
  17. package/dist/cli/unknown-profile.js +14 -6
  18. package/dist/constants/index.d.ts +7 -0
  19. package/dist/constants/index.js +16 -0
  20. package/dist/crm/cli/index.js +30 -5
  21. package/dist/crm/source.d.ts +8 -1
  22. package/dist/crm/stage-tasks.d.ts +3 -1
  23. package/dist/crm/stage-tasks.js +8 -4
  24. package/dist/crm/sync.d.ts +1 -1
  25. package/dist/crm/sync.js +54 -0
  26. package/dist/domain/crm.d.ts +15 -0
  27. package/dist/domain/phones.d.ts +2 -0
  28. package/dist/domain/phones.js +3 -0
  29. package/dist/entities/contact-context.d.ts +6 -0
  30. package/dist/entities/contact-context.js +3 -0
  31. package/dist/entities/deal.d.ts +4 -0
  32. package/dist/entities/deal.js +3 -0
  33. package/dist/entities/index.d.ts +12 -0
  34. package/dist/entities/recorded-meeting.d.ts +17 -0
  35. package/dist/entities/recorded-meeting.js +15 -0
  36. package/dist/errors/reasons.js +9 -5
  37. package/dist/index.d.ts +1 -1
  38. package/dist/kit/own-catalogue.d.ts +1 -1
  39. package/dist/kit/own-catalogue.js +3 -3
  40. package/dist/meetings/answers.d.ts +5 -0
  41. package/dist/meetings/answers.js +3 -0
  42. package/dist/meetings/index.d.ts +1 -1
  43. package/dist/meetings/participant-search.d.ts +5 -0
  44. package/dist/meetings/pull.js +21 -1
  45. package/dist/meetings/read-answers.d.ts +4 -0
  46. package/dist/meetings/read-answers.js +1 -0
  47. package/dist/meetings/source.d.ts +5 -0
  48. package/dist/meetings/store.d.ts +12 -1
  49. package/dist/models/ai.js +2 -2
  50. package/dist/models/endpoint.d.ts +7 -0
  51. package/dist/models/endpoint.js +44 -0
  52. package/dist/models/index.js +2 -2
  53. package/dist/oauth/keeper.js +1 -1
  54. package/dist/sends/guard.js +8 -6
  55. package/dist/services/communications.d.ts +2 -2
  56. package/dist/services/communications.js +24 -2
  57. package/dist/services/meeting-model.js +2 -1
  58. package/dist/services/person-context.d.ts +3 -0
  59. package/dist/services/person-context.js +9 -1
  60. package/dist/services/person-meetings.d.ts +36 -0
  61. package/dist/services/person-meetings.js +57 -0
  62. package/dist/speech/openai.js +5 -2
  63. package/dist/store/path.d.ts +2 -0
  64. package/dist/store/path.js +1 -1
  65. package/dist/store/sqlite/crm-settings.d.ts +5 -1
  66. package/dist/store/sqlite/crm-settings.js +8 -0
  67. package/dist/store/sqlite/crm-stage-entries.d.ts +15 -0
  68. package/dist/store/sqlite/crm-stage-entries.js +74 -0
  69. package/dist/store/sqlite/crm.d.ts +8 -1
  70. package/dist/store/sqlite/crm.js +7 -1
  71. package/dist/store/sqlite/identities.js +3 -1
  72. package/dist/store/sqlite/involvements.d.ts +2 -0
  73. package/dist/store/sqlite/involvements.js +4 -1
  74. package/dist/store/sqlite/meeting-participant-search.js +9 -3
  75. package/dist/store/sqlite/meeting-projects.js +3 -3
  76. package/dist/store/sqlite/meetings.js +16 -2
  77. package/dist/store/sqlite/person-match-scan.d.ts +5 -0
  78. package/dist/store/sqlite/person-match-scan.js +60 -15
  79. package/dist/update/index.d.ts +1 -1
  80. package/dist/update/index.js +4 -2
  81. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,123 @@ 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.651.0 — 13.11.2026
9
+
10
+ ### Added
11
+
12
+ - **The first screen and first run list `pbx`**, the Asterisk tool (`@wirecat/asterisk-cli`), under "Works with" and
13
+ among the tools first run offers to install.
14
+ - **`doctor reports create` gives a pre-filled issue link** in `issue_url` and in its note, when the CLI's app
15
+ definition names `issues`. The title and body hold only the version, the platform and the failed run's error code
16
+ and provider key; the report file stays on the computer until the person attaches it.
17
+ - **`RowShape.oneLine` draws one thing as one line under `--compact`.** An item answer then prints as the row a list
18
+ of it prints, and its `sections` still follow as rows, so a decision result can list one line per decision. Opt-in:
19
+ a row without it prints `key: value` lines as before.
20
+ - **`doctor reports show` and `create` find the issue page in the CLI's package.json** when its app definition names
21
+ no `issues`: the GitHub repository in `bugs` or `repository`, as `<repository>/issues/new`. A repository elsewhere
22
+ gives no link, since the link fills the issue through GitHub's own parameters.
23
+ - **A meetings sync links the callers it saved to their people by number**, without memo's `people scan`. It runs the
24
+ scan's phone rule alone, for those callers only, and moves no scan cursor
25
+ ([MEETINGS.md](docs/dev/MEETINGS.md#calls-and-the-people-they-link-to)). `MeetingStore.linkCallers` is optional;
26
+ the shared store has it.
27
+
28
+ ### Changed — may break callers
29
+
30
+ - **A stale meeting project fingerprint is `conflict`, not `configuration_error`** (reason `meeting-project.stale`).
31
+ A caller that checks the code moves to `conflict`.
32
+ - **`CORE_HOSTS` is cli-base's `SHARED_HOSTS` and the two default model providers.** It gains `*.huggingface.co` and
33
+ `*.githubusercontent.com` (in place of `release-assets.githubusercontent.com`), and a test keeps it equal to cli-base's
34
+ list. No published CLI reads it. cli-core's own tests and checks move to `@wirecat/cli-base` 0.99.0.
35
+
36
+ ### Fixed
37
+
38
+ - **A mistyped profile in `<PREFIX>_PROFILE` gets the profiles here too** (`profile.unknown`), as a mistyped first
39
+ word does, and a CLI's own "no profile named …" is no longer said twice in the message.
40
+ - **`ownCatalogue` keeps a generated Bot API command as the CLI's own**, as `commands --json` marks it, so a
41
+ bot's contract test pins its generated commands.
42
+ - **`session start` and `setup` keep a provider's refusal.** A sign-in that failed for a new profile was reported as
43
+ `profile.unknown` ("no profile named …"), hiding why the provider refused it.
44
+ - **`schedule command` saves PATH without its relative folders.** Under pnpm, PATH holds `./node_modules/.bin`, and
45
+ `schedule exec` refused the saved schedule; a schedule saved this way runs again once it is saved again.
46
+ - **Confirming a proposed meeting project keeps the owner's reason.** `linkMeetingProject` with
47
+ `expectedFingerprint` and `provenance` now stores the owner's reason; before, the agent's stayed.
48
+ - **An IPv6 model address such as `https://[fd00::1]` is reached again.** It was refused as "not a host", because
49
+ `hostFetch` takes no IPv6 literal. It now goes only to that host, with the same deadline and no redirect followed.
50
+ As for IPv4, plain http is allowed only to this computer (`[::1]`).
51
+
52
+ ### Security
53
+
54
+ - **`account remove` in a run with only the config folder moved no longer runs the tool's own sign-out.** With
55
+ `<PREFIX>_CONFIG_DIR` (or the cache folder) moved, the state folder is the owner's, and the tool's `signOut` hook
56
+ deleted the session there: the owner's own (WC-SECR-24). The sign-in is now listed under `kept` with the moved-run
57
+ reason. The check of the owner's folders also follows links, so a moved config folder that is a link to the owner's
58
+ own no longer rewrites the owner's `config.json`. A tool's own guard, such as wa's `device.owners`, can stay.
59
+
60
+ ## 0.650.0 — 13.11.2026
61
+
62
+ ### Added
63
+
64
+ - **A call links to the CRM contact with the same phone.** A meeting source gives a participant's number
65
+ in `SourceParticipant.phone` (written with `+`); the store keeps it in `identities.phone`. The people scan then
66
+ joins the call's person and one other person when exactly the two hold the number, one of them is keyed by the
67
+ number itself (`phone:<E.164>`, as a phone line keeps a call's other side) and the number is a mobile; a landline
68
+ only proposes the pair, since an office's main line is everyone's who works there. The scan reads a CRM's number
69
+ written without `+` (`8 (912) 345-67-89`) in the store's `phone_countries`, and the contact's other numbers too.
70
+ See [MEETINGS.md, "Calls and the people they link to"](docs/dev/MEETINGS.md#calls-and-the-people-they-link-to).
71
+ - **`meetings show` and `meetings people` name each participant's person**: `person: { ref, name }`, `null` when the
72
+ identity is linked to no one; `meetings people` also finds a participant by that name.
73
+ - **A person's, an organization's and a deal's context list their recorded calls.** `contacts context` and the
74
+ canonical person context answer `meetings[]` (`personMeetings`); `communicationsOf`, and so the deal and
75
+ organization contexts, counts each call as a `meeting` touch with its `meeting:` ref; `deals show` and `leads show`
76
+ of a CRM copy answer `meetings[]`, the newest 10 of the people on it. Each item opens with `meetings show
77
+ <meeting_id>` of the CLI that owns its `account`.
78
+ - **`CORE_HOSTS` in `@wirecat/cli-core/constants`**: the hosts cli-core itself reaches in any tool (npm for
79
+ `upgrade`, the default model providers, the model downloads and the hosts they redirect to). A tool spreads them
80
+ into its WCAT identity's `hosts`, so `cli-dev manifest` lists them.
81
+ - **Stage tasks open on every stage a deal or lead entered, also one passed between two syncs.** A CRM source may
82
+ give `stageHistory(kind, since, after, context)`: the CRM's own record of each entry into a stage. While the
83
+ account has `stage-tasks` rules for the kind, `sync` reads it after the last entry it read (the first read from
84
+ when stage tasks last ran), keeps the entries on kept deals and leads as `crm.stage-entry` records, and the stage
85
+ tasks open from them: a deal moved A→B→C between two syncs gets the tasks of B and C. A source without it keeps
86
+ comparing the copy between syncs. A failed read is the issue `crm.stage-history-failed`; the deals and leads are
87
+ still synced. The funnel still counts the copy's own stage changes.
88
+
89
+ ### Changed — may break callers
90
+
91
+ - **`oauth.missing` is now `session.missing`, and `ai.address-refused` is now `model.address-refused`.**
92
+ One reason for each: a profile that is not signed in, and a model address WireCat refuses. A CLI that raises or
93
+ checks the old names moves to the new ones.
94
+ - **The output schemas of `meetings show`, `meetings people`, `contacts context`, the person context and `deals
95
+ show` / `leads show` gain the fields above.** A CLI that pins its MCP output schemas updates its contract.
96
+
97
+ ### Fixed
98
+
99
+ - **The read-only lock lets server search and fetches through.** `<PREFIX>_READ_ONLY` promises "can read and sync but
100
+ never send", yet it refused every key the send guard checks, reads included: `search messages --backend server`
101
+ failed with `permission_error`, and the default `--backend both` dropped the server without a word. The keys that
102
+ only read from the messenger or work locally (`messages.server-search`, `messages.sync-first`, the stats syncs,
103
+ `conversations.embeddings`, `conversations.links`, `attachments.extract`, `store.gaps.repair`) now pass the lock, as
104
+ they already passed a flood hold. The profile's permission level still applies to each. Found by an agent test in
105
+ which tg under `TG_READ_ONLY` answered 6 of 10 questions and a Telegram MCP server 9
106
+ (tg-cli [#874](https://github.com/WireCatLabs/tg-cli/issues/874)).
107
+ - **An archive-only search over a partial history points at the server's search.** `search messages --backend
108
+ archive` on a messenger with its own search now leads `next` with `search.server` (the same query, `--backend
109
+ server`) when the local store misses part of a chat. Agents told to stay on the archive stopped there and answered
110
+ "not found" for messages the store never held
111
+ (tg-cli [#873](https://github.com/WireCatLabs/tg-cli/issues/873)).
112
+
113
+ ### Security
114
+
115
+ - **The update check, the model calls, the meeting embeddings and OpenAI transcription reach only their own host.**
116
+ They go through cli-base's `hostFetch`: npm's registry, or the host of the model address the person set. A
117
+ redirect to another host is refused, and each exchange has a deadline (2 minutes; 10 for a transcription).
118
+
119
+ - **A run with moved folders removes nothing in the owner's folders (WC-SECR-24).** With only `<PREFIX>_CONFIG_DIR`
120
+ moved, `account remove` deleted the account file, the profile files and a stale serve lock in the owner's real
121
+ state folder, and `--delete-data` purged the account from the owner's store. Now each of them is kept, with its
122
+ reason under `kept`; the serve unit and schedules stay while `HOME` is the owner's.
123
+ [ACCOUNT-REMOVAL.md](docs/dev/ACCOUNT-REMOVAL.md)
124
+
8
125
  ## 0.649.0 — 13.11.2026
9
126
 
10
127
  ### Added
@@ -1,2 +1,3 @@
1
1
  import { anthropic } from "../models/anthropic.js";
2
- export const analyze = async (target, system, input, maxTokens) => anthropic.complete(target, { purpose: "analysis", system, prompt: input, maxTokens }, {}, target.apiKey, fetch);
2
+ import { endpointFetch } from "../models/endpoint.js";
3
+ export const analyze = async (target, system, input, maxTokens) => anthropic.complete(target, { purpose: "analysis", system, prompt: input, maxTokens }, {}, target.apiKey, endpointFetch(target.baseUrl, 120_000));
@@ -63,6 +63,8 @@ export interface AccountRemoveOptions {
63
63
  provider?: Provider;
64
64
  /** Unset: the one `run()` set. */
65
65
  resolveSettings?: (flags: GlobalFlags, options?: ResolveOptions) => Settings;
66
+ /** The owner's own home; unset, the account's from the user database. A test names its sandbox. */
67
+ ownerHome?: string;
66
68
  }
67
69
  /**
68
70
  * `<tool> <profile> account remove --keep-data|--delete-data`: signs the profile out the tool's way, forgets it on
@@ -11,7 +11,7 @@ import { thisMachine } from "../background/system.js";
11
11
  import { locationVariables, platformFor } from "../background/units.js";
12
12
  import { httpLockFile } from "../mcp/http/state.js";
13
13
  import { sendsPathFor } from "../sends/journal.js";
14
- import { storePath } from "../store/path.js";
14
+ import { accountHome, inOwnerFolder, settled, storePath } from "../store/path.js";
15
15
  import { openStore } from "../store/store.js";
16
16
  import { readConfigFile, withoutPath } from "./config-issues.js";
17
17
  import { baseContext, environmentOf } from "./context.js";
@@ -46,6 +46,21 @@ const insideOwnFolders = (app, env, extra) => {
46
46
  return full;
47
47
  };
48
48
  };
49
+ const under = (path, root) => path === root || path.startsWith(`${root}${sep}`);
50
+ const within = (path, root) => under(path, root) || under(settled(path), settled(root));
51
+ /**
52
+ * WC-SECR-24: the tool's folders as the owner's own run has them. A run with moved folders shares the rest with the
53
+ * owner (only the config folder moved leaves the state folder the owner's), so it removes nothing inside these.
54
+ */
55
+ const ownerFolders = (app, removal, hooks, home) => {
56
+ if (home === undefined)
57
+ return [];
58
+ const env = { HOME: home, USERPROFILE: home };
59
+ return [
60
+ ...Object.values(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env })),
61
+ ...(removal.ownFolders?.({ ...hooks, env }) ?? []),
62
+ ].map((root) => absolute(root));
63
+ };
49
64
  /** The profile's own serve unit, by its exact name, when one is installed; never a pattern over the unit folder. */
50
65
  const serveUnit = (app, system, profile, env) => {
51
66
  if (!env.HOME)
@@ -142,16 +157,32 @@ export const accountRemoveCommand = (app, removal, options = {}) => logsInOrOut(
142
157
  if (holder)
143
158
  throw new CliError("conflict", `${holder} is running for ${profile} — stop it first (\`${app.command} ${profile} server stop\`), then remove the account`, { reason: "account-remove.busy" });
144
159
  const own = insideOwnFolders(app, env, removal.ownFolders?.(hooks) ?? []);
145
- const schedules = listSchedules(state).filter((schedule) => schedule.environment[`${app.envPrefix}_PROFILE`] === profile);
160
+ const ownerHome = options.ownerHome ?? accountHome();
161
+ const movedFolders = isMovedRun({ appName: app.appName, prefix: app.envPrefix, env });
162
+ const owners = movedFolders ? ownerFolders(app, removal, hooks, ownerHome) : [];
163
+ const inOwners = (path) => owners.some((root) => within(absolute(path), root));
164
+ const ownerHomeHere = movedFolders && ownerHome !== undefined && absolute(env.HOME ?? "") === absolute(ownerHome);
165
+ const ownersReason = "a run with moved folders never removes what lies in the owner's own folders";
166
+ const ownersKept = [];
167
+ const theRun = (paths) => paths.flatMap((path) => {
168
+ if (!inOwners(path))
169
+ return [own(path)];
170
+ if (existsSync(path))
171
+ ownersKept.push({ kind: "file", target: absolute(path), reason: ownersReason });
172
+ return [];
173
+ });
174
+ const schedules = movedFolders && (inOwners(state) || ownerHomeHere)
175
+ ? []
176
+ : listSchedules(state).filter((schedule) => schedule.environment[`${app.envPrefix}_PROFILE`] === profile);
146
177
  const serveLock = lockPath(app, profile, env);
147
178
  const staleLock = readLock(serveLock);
148
- const stateFiles = [
179
+ const stateFiles = theRun([
149
180
  accountFile,
150
181
  ...profileFiles(app, profile, env, listSchedules(state)),
151
182
  ...(staleLock && !alive(staleLock.pid) ? [serveLock] : []),
152
183
  ...(removal.stateFiles?.(profile, hooks) ?? []),
153
- ].map(own);
154
- const dataFiles = (removal.dataFiles?.(profile, hooks) ?? []).map(own);
184
+ ]);
185
+ const dataFiles = theRun(removal.dataFiles?.(profile, hooks) ?? []);
155
186
  const account = removal.account?.(profile, hooks) ??
156
187
  (options.provider === undefined ? undefined : recalledAccount(app, options.provider, profile, env));
157
188
  const secrets = (removal.secrets?.(profile, hooks) ?? []).map(({ credentials, accounts }) => ({
@@ -163,14 +194,21 @@ export const accountRemoveCommand = (app, removal, options = {}) => logsInOrOut(
163
194
  }),
164
195
  accounts,
165
196
  }));
166
- const sections = removal.forgetConfig ? [] : configSections(settings.configPath, profile);
197
+ const ownersConfig = inOwners(settings.configPath);
198
+ const sections = removal.forgetConfig || ownersConfig ? [] : configSections(settings.configPath, profile);
199
+ if (ownersConfig)
200
+ ownersKept.push({ kind: "config", target: settings.configPath, reason: ownersReason });
201
+ const ownersStore = movedFolders && inOwnerFolder(storePath(env), ownerHome);
167
202
  const storeHere = existsSync(storePath(env));
168
203
  const system = environmentOf(this).system ?? thisMachine();
169
- const unit = serveUnit(app, system, profile, env);
204
+ const unit = ownerHomeHere ? undefined : serveUnit(app, system, profile, env);
170
205
  if (unit && (await platformFor(app, system, env).state(unit)).active)
171
206
  throw new CliError("conflict", `${unit.name} is running for ${profile} — stop it first (\`${app.command} ${profile} server stop\`), then remove the account`, { reason: "account-remove.busy" });
172
- const removed = [{ kind: "sign_in", target: `${app.command} sign-in of ${profile}` }];
173
- const kept = [];
207
+ const signIn = { kind: "sign_in", target: `${app.command} sign-in of ${profile}` };
208
+ // The tool's own sign-out deletes its session where the run's state folder says; here that folder is the owner's.
209
+ const signsOut = !(movedFolders && inOwners(state));
210
+ const removed = signsOut ? [signIn] : [];
211
+ const kept = [...ownersKept, ...(signsOut ? [] : [{ ...signIn, reason: ownersReason }])];
174
212
  // An entry the environment supplies is not this tool's to remove.
175
213
  const saved = (store, name) => (store.read(name)?.source ?? "environment") !== "environment";
176
214
  for (const { store, accounts } of secrets)
@@ -193,7 +231,9 @@ export const accountRemoveCommand = (app, removal, options = {}) => logsInOrOut(
193
231
  if (data === "deleted") {
194
232
  for (const file of dataFiles.filter(present))
195
233
  removed.push({ kind: "file", target: file });
196
- if (accountName && storeHere)
234
+ if (accountName && storeHere && ownersStore)
235
+ kept.push({ kind: "store", target: accountName, reason: ownersReason });
236
+ else if (accountName && storeHere)
197
237
  removed.push({ kind: "store", target: accountName });
198
238
  else
199
239
  kept.push({
@@ -240,8 +280,9 @@ export const accountRemoveCommand = (app, removal, options = {}) => logsInOrOut(
240
280
  throw new CliError("cancelled", `cancelled — ${profile} is unchanged`);
241
281
  }
242
282
  await context.run(async () => {
243
- const signedOut = await removal.signOut(profile, hooks);
244
- removed.splice(0, 1, ...signedOut.removed.map((target) => ({ kind: "sign_in", target })));
283
+ const signedOut = signsOut ? await removal.signOut(profile, hooks) : undefined;
284
+ if (signedOut)
285
+ removed.splice(0, 1, ...signedOut.removed.map((target) => ({ kind: "sign_in", target })));
245
286
  const keyringEntries = removed.filter((one) => one.kind === "keyring");
246
287
  const gone = new Set();
247
288
  for (const { store, accounts } of secrets)
@@ -276,7 +317,7 @@ export const accountRemoveCommand = (app, removal, options = {}) => logsInOrOut(
276
317
  for (const entry of removed)
277
318
  if (entry.kind === "file")
278
319
  rmSync(entry.target, { recursive: true, force: true });
279
- if (removal.forgetConfig)
320
+ if (removal.forgetConfig && !ownersConfig)
280
321
  for (const target of removal.forgetConfig(profile, hooks))
281
322
  removed.push({ kind: "config", target });
282
323
  else if (sections.length > 0)
@@ -22,6 +22,11 @@ export interface RowShape {
22
22
  whole?: readonly string[];
23
23
  /** An item answer's fields left out: bookkeeping an agent reads in `--json` if it ever needs it. */
24
24
  hidden?: readonly string[];
25
+ /**
26
+ * An item answer drawn as the one row a list of it draws, not as `key: value` lines; its `sections` still follow
27
+ * as rows. Opt-in: a `show` whose help promises one line under `--compact`.
28
+ */
29
+ oneLine?: boolean;
25
30
  }
26
31
  export interface CompactOptions {
27
32
  /** IANA zone for times; the answer's `meta.timezone` wins. */
@@ -390,8 +390,9 @@ export const compactText = (body, shape, options, rowsOf = rowsOfEntity()) => {
390
390
  else if (isFields(body.item)) {
391
391
  const sections = shape.sections ?? {};
392
392
  const rest = Object.fromEntries(Object.entries(body.item).filter(([name]) => !Object.hasOwn(sections, name) && !shape.hidden?.includes(name)));
393
- lines = blockOf(rest, chars, "", shape.whole).map(guarded);
394
- let dates = [];
393
+ const own = shape.oneLine ? rowsOfItems([rest], shape, clock, chars) : undefined;
394
+ lines = own ? own.lines.filter((line) => line !== "") : blockOf(rest, chars, "", shape.whole).map(guarded);
395
+ let dates = own?.dates ?? [];
395
396
  let drawn = [];
396
397
  for (const [name, entity] of Object.entries(sections)) {
397
398
  const list = body.item[name];
@@ -402,7 +403,10 @@ export const compactText = (body, shape, options, rowsOf = rowsOfEntity()) => {
402
403
  drawn = drawn.concat([`# ${[`${clean(name)}: ${list.length}`, ...header].join(" · ")}`], rows);
403
404
  }
404
405
  const when = spanOf(dates, clock);
405
- lines = lines.concat(when.length ? [`# ${when.join(" · ")}`] : [], drawn);
406
+ const head = [...(own?.header ?? []), ...when];
407
+ lines = own
408
+ ? (head.length ? [`# ${head.join(" · ")}`] : []).concat(lines, drawn)
409
+ : lines.concat(when.length ? [`# ${when.join(" · ")}`] : [], drawn);
406
410
  }
407
411
  else if (present(body.item))
408
412
  lines = [guarded(cut(clean(String(body.item)), chars))];
@@ -1,5 +1,6 @@
1
1
  import { Command } from "commander";
2
2
  import type { AppIdentity } from "../ports/app.js";
3
+ import type { RunMetadata } from "../runs/run.js";
3
4
  import type { SendEntry } from "../sends/journal.js";
4
5
  import { type BaseContext } from "./context.js";
5
6
  export interface DoctorReportsSource {
@@ -18,5 +19,15 @@ export interface DoctorReportsSource {
18
19
  renderer?: BaseContext["renderer"];
19
20
  }>;
20
21
  }
22
+ /**
23
+ * The new-issue page: the app definition's `issues`, else the GitHub repository its installed package names in
24
+ * `bugs` or `repository`. Only GitHub's: the link fills the issue through GitHub's own parameters.
25
+ */
26
+ export declare const issuesPage: (app: AppIdentity, script?: string | undefined) => string | undefined;
27
+ /**
28
+ * A new issue with its title and body filled in through GitHub's `title` and `body` parameters. An issue is public, so
29
+ * the body holds only the version, the platform and the failed run's codes; the person attaches the file.
30
+ */
31
+ export declare const issueUrlFor: (app: AppIdentity, run: RunMetadata | undefined, platform?: NodeJS.Platform, arch?: NodeJS.Architecture) => string;
21
32
  /** `doctor reports show|create`: one file for the author, the same for every CLI; `collect` says what it holds. */
22
33
  export declare const doctorReportsCommand: (source: DoctorReportsSource) => Command;
@@ -1,5 +1,5 @@
1
- import { mkdirSync, writeFileSync } from "node:fs";
2
- import { dirname, resolve } from "node:path";
1
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { dirname, join, resolve } from "node:path";
3
3
  import { CliError } from "@wirecat/cli-base";
4
4
  import { annotate } from "@wirecat/cli-base/commands";
5
5
  import { Command } from "commander";
@@ -8,6 +8,7 @@ import { environmentOf, outputFor } from "./context.js";
8
8
  import { destroysNothing, LOCAL_WRITE, NO_EFFECTS } from "./effects.js";
9
9
  import { itemOf, renderAnswer } from "./envelope.js";
10
10
  import { buildReport, reportFileName } from "./messenger/report.js";
11
+ import { ownPackageRoot } from "./messenger/serve-outdated.js";
11
12
  import { lineOf, nextStep, rootOf } from "./steps.js";
12
13
  const writeNew = (path, text) => {
13
14
  mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
@@ -22,6 +23,50 @@ const writeNew = (path, text) => {
22
23
  });
23
24
  }
24
25
  };
26
+ const urlOf = (field) => {
27
+ const url = typeof field === "string" ? field : field?.url;
28
+ return typeof url === "string" ? url : undefined;
29
+ };
30
+ /**
31
+ * The new-issue page: the app definition's `issues`, else the GitHub repository its installed package names in
32
+ * `bugs` or `repository`. Only GitHub's: the link fills the issue through GitHub's own parameters.
33
+ */
34
+ export const issuesPage = (app, script = process.argv[1]) => {
35
+ if (app.issues)
36
+ return app.issues;
37
+ const root = ownPackageRoot(app.version, script);
38
+ if (!root)
39
+ return undefined;
40
+ try {
41
+ const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
42
+ const repository = /github\.com[/:]([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:\/issues)?\/?$/.exec(urlOf(manifest.bugs) ?? urlOf(manifest.repository) ?? "");
43
+ return repository ? `https://github.com/${repository[1]}/${repository[2]}/issues/new` : undefined;
44
+ }
45
+ catch {
46
+ return undefined;
47
+ }
48
+ };
49
+ /**
50
+ * A new issue with its title and body filled in through GitHub's `title` and `body` parameters. An issue is public, so
51
+ * the body holds only the version, the platform and the failed run's codes; the person attaches the file.
52
+ */
53
+ export const issueUrlFor = (app, run, platform = process.platform, arch = process.arch) => {
54
+ const code = run ? (run.errorCode ?? "failed") : undefined;
55
+ const body = [
56
+ "What I did:",
57
+ "",
58
+ "What I expected:",
59
+ "",
60
+ "What happened:",
61
+ "",
62
+ "---",
63
+ `${app.command} ${app.version}, ${platform} ${arch}`,
64
+ ...(code ? [`error: ${code}${run?.providerError ? ` (${run.providerError})` : ""}`] : []),
65
+ "The problem report file is attached.",
66
+ ].join("\n");
67
+ const title = `${app.command} ${app.version}: ${code ?? "problem report"}`;
68
+ return `${app.issues}?title=${encodeURIComponent(title)}&body=${encodeURIComponent(body)}`;
69
+ };
25
70
  /** `doctor reports show|create`: one file for the author, the same for every CLI; `collect` says what it holds. */
26
71
  export const doctorReportsCommand = (source) => {
27
72
  const { app, includes, excludes } = source;
@@ -34,7 +79,8 @@ export const doctorReportsCommand = (source) => {
34
79
  .summary("what a report holds and never holds, and where to send it; writes nothing")
35
80
  .action(function () {
36
81
  const create = lineOf(this, "doctor reports create");
37
- renderAnswer(this, outputFor(this), itemOf({ includes, excludes, ...(app.issues ? { send_to: app.issues } : {}) }, { next: [nextStep("doctor.report-create", { args: {} })] }), () => [
82
+ const page = issuesPage(app);
83
+ renderAnswer(this, outputFor(this), itemOf({ includes, excludes, ...(page ? { send_to: page } : {}) }, { next: [nextStep("doctor.report-create", { args: {} })] }), () => [
38
84
  `A problem report is one file for the author of ${app.command}.`,
39
85
  "",
40
86
  "It holds:",
@@ -73,10 +119,16 @@ export const doctorReportsCommand = (source) => {
73
119
  writeNew(path, `${JSON.stringify(built, null, 2)}\n`);
74
120
  const output = outputFor(this);
75
121
  const out = renderer ?? output.renderer;
76
- renderAnswer(this, { ...output, renderer: out }, itemOf({ path, run: built.run?.metadata.runId ?? null, ...(app.issues ? { send_to: app.issues } : {}) }));
122
+ const page = issuesPage(app);
123
+ const issue = page ? issueUrlFor({ ...app, issues: page }, built.run?.metadata) : undefined;
124
+ renderAnswer(this, { ...output, renderer: out }, itemOf({
125
+ path,
126
+ run: built.run?.metadata.runId ?? null,
127
+ ...(issue ? { send_to: page, issue_url: issue } : {}),
128
+ }));
77
129
  if (!built.run)
78
130
  out.note("no failed run is recorded — run the failing command again, and the failure is kept by itself");
79
- out.note(`read it before sending: ${source.check}${app.issues ? ` — attach it to a new issue at ${app.issues}` : ""}`);
131
+ out.note(`read it before sending: ${source.check}${issue ? ` — then open ${issue} and attach the file; the issue is public` : ""}`);
80
132
  });
81
133
  return reports;
82
134
  };
@@ -53,6 +53,11 @@ export const WIRECAT_TOOLS = [
53
53
  package: "@wirecat/bitrix24-cli",
54
54
  does: "Bitrix24 CRM: deals, leads and pipelines, searchable with your other WireCat data",
55
55
  },
56
+ {
57
+ command: "pbx",
58
+ package: "@wirecat/asterisk-cli",
59
+ does: "Asterisk PBX calls and recordings, searchable with your other WireCat data",
60
+ },
56
61
  ];
57
62
  const WIDTH = 100;
58
63
  const widest = (texts) => texts.reduce((most, text) => Math.max(most, text.length), 0);
@@ -215,7 +215,12 @@ const searchAction = (messenger) => async function (given) {
215
215
  const skips = await context
216
216
  .withStore((store) => historySkipsOf(store, found.coverage?.accounts ?? found.accounts ?? []))
217
217
  .catch(() => []);
218
- renderAnswer(this, context, messagesAnswer("search messages", found, { limit, page: page ?? 1, again }, given.join(" "), skips), view);
218
+ renderAnswer(this, context, messagesAnswer("search messages", found, {
219
+ limit,
220
+ page: page ?? 1,
221
+ again,
222
+ archiveOnly: !discover && Boolean(messenger.serverSearch) && backendRequest(this).backend === "archive",
223
+ }, given.join(" "), skips), view);
219
224
  };
220
225
  const withOffset = (page, limit) => {
221
226
  const offset = offsetOf(page, limit);
@@ -40,11 +40,13 @@ export interface Paging {
40
40
  page?: number;
41
41
  /** The query and options `page.next` repeats. */
42
42
  again?: Record<string, unknown>;
43
+ /** Asked for the archive alone where the messenger's server could search too. */
44
+ archiveOnly?: boolean;
43
45
  }
44
46
  /** "showing 20 of 144", for the human view under a page of hits; `+` when the total is a lower bound. */
45
47
  export declare const shownOf: (shown: number, offset: number, total: SearchTotal | undefined) => string | undefined;
46
48
  /** `search messages` and `search mail`, CLI and MCP alike. */
47
- export declare const messagesAnswer: (command: string, found: SearchFound, { limit, page, again }: Paging, query?: string, skips?: StoredHistorySkip[]) => ListBody<MessageHitItem>;
49
+ export declare const messagesAnswer: (command: string, found: SearchFound, { limit, page, again, archiveOnly }: Paging, query?: string, skips?: StoredHistorySkip[]) => ListBody<MessageHitItem>;
48
50
  export declare const noteHitItem: (hit: FoundNote) => NoteHitItem;
49
51
  export declare const allHitItem: (item: SearchAllItem) => HitItem;
50
52
  /** `search notes`, CLI and MCP alike. */
@@ -258,10 +258,12 @@ export const shownOf = (shown, offset, total) => total === undefined || shown ==
258
258
  ? undefined
259
259
  : `showing ${offset + 1}–${offset + shown} of ${total.value}${total.relation === "gte" ? "+" : ""}`;
260
260
  /** `search messages` and `search mail`, CLI and MCP alike. */
261
- export const messagesAnswer = (command, found, { limit, page, again }, query = "", skips = []) => {
261
+ export const messagesAnswer = (command, found, { limit, page, again, archiveOnly }, query = "", skips = []) => {
262
262
  const accounts = found.coverage?.accounts ?? found.accounts ?? [];
263
263
  const gaps = gapsOf(found);
264
264
  const limited = historyLimitGaps(skips);
265
+ if (archiveOnly && query !== "" && gaps.missing.length + limited.missing.length > 0)
266
+ gaps.next.unshift(nextStep("search.server", { args: { query, backend: "server" } }));
265
267
  return listOf(command, {
266
268
  items: [...found.items.map((hit) => messageHitItem(hit, query)), ...pictureItems(found)],
267
269
  limit,
@@ -42,7 +42,7 @@ import { assertSharedContracts } from "./shared-contracts.js";
42
42
  import { skillSourceOf } from "./skill-command.js";
43
43
  import { refreshSkills, skipsSkillRefresh } from "./skill-refresh.js";
44
44
  import { commandAt, failureSteps, lineOf, withLines } from "./steps.js";
45
- import { unknownProfile } from "./unknown-profile.js";
45
+ import { isSignIn, unknownProfile } from "./unknown-profile.js";
46
46
  const OUTPUT_OPTIONS = [
47
47
  ["output", "--output"],
48
48
  ["outputDir", "--output-dir"],
@@ -699,6 +699,8 @@ const settleFailure = async (failure, state) => {
699
699
  /** The settings a failed run had, read again without asking for a profile; `undefined` when they do not load. */
700
700
  const failureSettings = (definition, program, rest, profile, options) => {
701
701
  const path = commandPath(program, program.args.length > 0 ? program.args : rest);
702
+ if (isSignIn(path))
703
+ return undefined;
702
704
  const { resolveSettings } = definition.configuration ?? settingsFor(definition.app);
703
705
  try {
704
706
  return resolveSettings({ ...program.opts(), ...(profile === undefined ? {} : { profile }) }, {
@@ -1,5 +1,5 @@
1
1
  import { existsSync, rmSync } from "node:fs";
2
- import { dirname, join } from "node:path";
2
+ import { delimiter, dirname, isAbsolute, join } from "node:path";
3
3
  import { CliError, resolvePaths, writeSecurely } from "@wirecat/cli-base";
4
4
  import { annotate } from "@wirecat/cli-base/commands";
5
5
  import { Argument, Command, Option } from "commander";
@@ -220,15 +220,21 @@ export const backfillScheduleRun = (command, app, env, file, { at, input, agentR
220
220
  };
221
221
  /** The tool's state folder, which holds its schedules. */
222
222
  export const scheduleState = ({ app, env }) => resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state;
223
+ const absolutePath = (path) => (path ?? "")
224
+ .split(delimiter)
225
+ .filter((folder) => folder !== "" && isAbsolute(folder))
226
+ .join(delimiter);
223
227
  /** The variables a run gets on top of the timer's: the profile, where the files are, PATH. Never a credential. */
224
228
  const scheduleEnvironment = ({ app, env, profile }) => {
225
229
  // The command line refuses a schedule under the lock; a caller that gets here still passes the lock on.
226
230
  const readOnly = readOnlyLockOf(app, env);
231
+ const path = absolutePath(env.PATH);
227
232
  return {
228
233
  [`${app.envPrefix}_PROFILE`]: profile,
229
234
  ...locationVariables(app, env),
230
- // The timer starts with almost no PATH; an agent runs the CLI and its own tools by name.
231
- ...(env.PATH ? { PATH: env.PATH } : {}),
235
+ // The timer starts with almost no PATH; an agent runs the CLI and its own tools by name. A relative folder (pnpm's
236
+ // ./node_modules/.bin) means another folder from the timer's, and `schedule exec` refuses it.
237
+ ...(path ? { PATH: path } : {}),
232
238
  ...(readOnly ? { [readOnly]: "1" } : {}),
233
239
  };
234
240
  };
package/dist/cli/steps.js CHANGED
@@ -20,6 +20,15 @@ export const STEPS = defineSteps([
20
20
  ],
21
21
  why: "the local copy is missing messages; syncing brings them in",
22
22
  },
23
+ {
24
+ id: "search.server",
25
+ command: "search messages",
26
+ args: [
27
+ { name: "query", required: true },
28
+ { name: "backend", required: true },
29
+ ],
30
+ why: "only the local copy was searched, and it does not hold every message; the messenger's own search reaches the rest",
31
+ },
23
32
  {
24
33
  id: "messages.transcribe",
25
34
  command: "messages transcribe",
@@ -1,9 +1,10 @@
1
1
  import type { Settings } from "./settings.js";
2
+ /** A sign-in names a new profile on purpose: a refusal there is the provider's, never an unknown profile. */
3
+ export declare const isSignIn: (path: string) => boolean;
2
4
  /**
3
5
  * A "not signed in" failure for a first word this computer has never seen as a profile is most likely a typo: it
4
6
  * answers `not_found` with the profiles here (FIND-2583), and keeps the sign-in hint for a profile that is new on
5
- * purpose. Only after a command failed, so a working profile and the `setup` or `session start` that makes a new one
6
- * never reach it; a profile set in the environment is a script's deliberate choice and keeps its refusal, and a bot
7
- * gets its token with `bot auth set` under any new name.
7
+ * purpose. Only after a command failed, and never for `setup` or `session start`, which make a new one. The first word and `<PREFIX>_PROFILE` are checked, since a typo in either is as likely; a bot gets
8
+ * its token with `bot auth set` under any new name.
8
9
  */
9
10
  export declare const unknownProfile: (error: unknown, settingsOf: () => (Pick<Settings, "profile"> & Partial<Pick<Settings, "sources" | "profilesHere" | "kind">>) | undefined) => unknown;
@@ -1,11 +1,17 @@
1
1
  import { CliError, isCliError } from "@wirecat/cli-base";
2
+ // gcal-cli raised its own oauth.missing before cli-core merged it into session.missing (FIND-2583).
2
3
  const NOT_SIGNED_IN = new Set([undefined, "session.missing", "oauth.missing"]);
4
+ const FROM_ENV = /^[A-Z0-9_]+_PROFILE$/;
5
+ const SIGN_INS = new Set(["session start", "setup"]);
6
+ /** A sign-in names a new profile on purpose: a refusal there is the provider's, never an unknown profile. */
7
+ export const isSignIn = (path) => SIGN_INS.has(path);
8
+ // A script's `<PREFIX>_PROFILE` on a computer with no profile yet names a new one, not a mistyped one.
9
+ const typo = (source, here) => source === "first word" || (source !== undefined && FROM_ENV.test(source) && here.length > 0);
3
10
  /**
4
11
  * A "not signed in" failure for a first word this computer has never seen as a profile is most likely a typo: it
5
12
  * answers `not_found` with the profiles here (FIND-2583), and keeps the sign-in hint for a profile that is new on
6
- * purpose. Only after a command failed, so a working profile and the `setup` or `session start` that makes a new one
7
- * never reach it; a profile set in the environment is a script's deliberate choice and keeps its refusal, and a bot
8
- * gets its token with `bot auth set` under any new name.
13
+ * purpose. Only after a command failed, and never for `setup` or `session start`, which make a new one. The first word and `<PREFIX>_PROFILE` are checked, since a typo in either is as likely; a bot gets
14
+ * its token with `bot auth set` under any new name.
9
15
  */
10
16
  export const unknownProfile = (error, settingsOf) => {
11
17
  if (!isCliError(error) || error.code !== "authentication_error")
@@ -14,10 +20,12 @@ export const unknownProfile = (error, settingsOf) => {
14
20
  return error;
15
21
  const settings = settingsOf();
16
22
  const here = settings?.profilesHere;
17
- if (!settings || !here || settings.kind === "bot" || settings.sources?.profile !== "first word")
23
+ if (!settings || !here || settings.kind === "bot" || !typo(settings.sources?.profile, here))
18
24
  return error;
19
25
  if (here.includes(settings.profile))
20
26
  return error;
21
- return new CliError("not_found", `no profile named ${settings.profile} on this computer — profiles here: ${here.join(", ") || "none"}; ` +
22
- `if ${settings.profile} is a new one: ${error.message}`, { reason: "profile.unknown", profiles: here });
27
+ // A CLI that checks its own profiles already says "no profile named …".
28
+ const sayTheRefusal = !/no profile named/i.test(error.message);
29
+ return new CliError("not_found", `no profile named ${settings.profile} on this computer — profiles here: ${here.join(", ") || "none"}` +
30
+ (sayTheRefusal ? `; if ${settings.profile} is a new one: ${error.message}` : ""), { reason: "profile.unknown", profiles: here });
23
31
  };
@@ -81,3 +81,10 @@ export declare const oauthClientReport: (app: {
81
81
  source?: AppSource | undefined;
82
82
  } | undefined, reason?: string) => OAuthClientReport;
83
83
  export type { AppSource };
84
+ /**
85
+ * The hosts cli-core itself reaches in any tool: the default model providers, then cli-base's `SHARED_HOSTS` (npm for
86
+ * `upgrade`, the model downloads and the hosts they redirect to), which `cli-dev manifest` adds to every CLI's hosts.
87
+ * Typed out, not imported, so a CLI on an older cli-base still loads this module; a test keeps the two equal. A model
88
+ * endpoint or calendar feed the person configures belongs in `userHosts`.
89
+ */
90
+ export declare const CORE_HOSTS: readonly string[];