@wirecat/cli-core 0.650.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,58 @@ 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
+
8
60
  ## 0.650.0 — 13.11.2026
9
61
 
10
62
  ### Added
@@ -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 { accountHome, inOwnerFolder, 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,7 +46,8 @@ const insideOwnFolders = (app, env, extra) => {
46
46
  return full;
47
47
  };
48
48
  };
49
- const within = (path, root) => path === root || path.startsWith(`${root}${sep}`);
49
+ const under = (path, root) => path === root || path.startsWith(`${root}${sep}`);
50
+ const within = (path, root) => under(path, root) || under(settled(path), settled(root));
50
51
  /**
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
52
53
  * owner (only the config folder moved leaves the state folder the owner's), so it removes nothing inside these.
@@ -203,8 +204,11 @@ export const accountRemoveCommand = (app, removal, options = {}) => logsInOrOut(
203
204
  const unit = ownerHomeHere ? undefined : serveUnit(app, system, profile, env);
204
205
  if (unit && (await platformFor(app, system, env).state(unit)).active)
205
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" });
206
- const removed = [{ kind: "sign_in", target: `${app.command} sign-in of ${profile}` }];
207
- const kept = [...ownersKept];
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 }])];
208
212
  // An entry the environment supplies is not this tool's to remove.
209
213
  const saved = (store, name) => (store.read(name)?.source ?? "environment") !== "environment";
210
214
  for (const { store, accounts } of secrets)
@@ -276,8 +280,9 @@ export const accountRemoveCommand = (app, removal, options = {}) => logsInOrOut(
276
280
  throw new CliError("cancelled", `cancelled — ${profile} is unchanged`);
277
281
  }
278
282
  await context.run(async () => {
279
- const signedOut = await removal.signOut(profile, hooks);
280
- 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 })));
281
286
  const keyringEntries = removed.filter((one) => one.kind === "keyring");
282
287
  const gone = new Set();
283
288
  for (const { store, accounts } of secrets)
@@ -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);
@@ -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
  };
@@ -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,12 +1,17 @@
1
1
  import { CliError, isCliError } from "@wirecat/cli-base";
2
2
  // gcal-cli raised its own oauth.missing before cli-core merged it into session.missing (FIND-2583).
3
3
  const NOT_SIGNED_IN = new Set([undefined, "session.missing", "oauth.missing"]);
4
+ 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);
4
10
  /**
5
11
  * A "not signed in" failure for a first word this computer has never seen as a profile is most likely a typo: it
6
12
  * answers `not_found` with the profiles here (FIND-2583), and keeps the sign-in hint for a profile that is new on
7
- * purpose. Only after a command failed, so a working profile and the `setup` or `session start` that makes a new one
8
- * never reach it; a profile set in the environment is a script's deliberate choice and keeps its refusal, and a bot
9
- * 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.
10
15
  */
11
16
  export const unknownProfile = (error, settingsOf) => {
12
17
  if (!isCliError(error) || error.code !== "authentication_error")
@@ -15,10 +20,12 @@ export const unknownProfile = (error, settingsOf) => {
15
20
  return error;
16
21
  const settings = settingsOf();
17
22
  const here = settings?.profilesHere;
18
- if (!settings || !here || settings.kind === "bot" || settings.sources?.profile !== "first word")
23
+ if (!settings || !here || settings.kind === "bot" || !typo(settings.sources?.profile, here))
19
24
  return error;
20
25
  if (here.includes(settings.profile))
21
26
  return error;
22
- return new CliError("not_found", `no profile named ${settings.profile} on this computer — profiles here: ${here.join(", ") || "none"}; ` +
23
- `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 });
24
31
  };
@@ -82,8 +82,9 @@ export declare const oauthClientReport: (app: {
82
82
  } | undefined, reason?: string) => OAuthClientReport;
83
83
  export type { AppSource };
84
84
  /**
85
- * The hosts cli-core itself reaches in any tool: npm for `upgrade`, the default model providers, and the model
86
- * downloads with the hosts they redirect to. A tool spreads them into its WCAT identity's `hosts`, so `cli-dev manifest`
87
- * lists them; a model endpoint or calendar feed the person configures belongs in `userHosts`.
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`.
88
89
  */
89
90
  export declare const CORE_HOSTS: readonly string[];
@@ -76,16 +76,18 @@ export const oauthClientReport = (app, reason) => app?.source
76
76
  ? { client: app.source === "constants" ? "wirecat" : "own", source: app.source }
77
77
  : { client: null, source: null, ...(reason ? { reason } : {}) };
78
78
  /**
79
- * The hosts cli-core itself reaches in any tool: npm for `upgrade`, the default model providers, and the model
80
- * downloads with the hosts they redirect to. A tool spreads them into its WCAT identity's `hosts`, so `cli-dev manifest`
81
- * lists them; a model endpoint or calendar feed the person configures belongs in `userHosts`.
79
+ * The hosts cli-core itself reaches in any tool: the default model providers, then cli-base's `SHARED_HOSTS` (npm for
80
+ * `upgrade`, the model downloads and the hosts they redirect to), which `cli-dev manifest` adds to every CLI's hosts.
81
+ * Typed out, not imported, so a CLI on an older cli-base still loads this module; a test keeps the two equal. A model
82
+ * endpoint or calendar feed the person configures belongs in `userHosts`.
82
83
  */
83
84
  export const CORE_HOSTS = [
84
- "registry.npmjs.org",
85
85
  "api.openai.com",
86
86
  "api.anthropic.com",
87
+ "registry.npmjs.org",
87
88
  "huggingface.co",
89
+ "*.huggingface.co",
88
90
  "*.hf.co",
89
91
  "github.com",
90
- "release-assets.githubusercontent.com",
92
+ "*.githubusercontent.com",
91
93
  ];
@@ -87,6 +87,11 @@ const OTHERS = [
87
87
  "the model answered nothing; given a picture, it may not read pictures — choose a vision model",
88
88
  ],
89
89
  validation("model.address-refused", "the model address is refused: https, or plain http and Ollama only on this computer"),
90
+ [
91
+ "network.host-undeclared",
92
+ "configuration_error",
93
+ "the request went to a host the CLI does not declare, or not the model address's own; nothing was sent",
94
+ ],
90
95
  [
91
96
  "local-only.refused",
92
97
  "permission_error",
@@ -300,7 +305,7 @@ const OTHERS = [
300
305
  validation("input.empty", "a hidden prompt got an empty answer three times"),
301
306
  validation("input.required", "the command needs an answer and cannot ask for one"),
302
307
  validation("input.too-large", "the input is over its size limit"),
303
- ["meeting-project.stale", "configuration_error", "the meeting's project changed meanwhile"],
308
+ ["meeting-project.stale", "conflict", "the meeting's project changed meanwhile"],
304
309
  validation("fact.not-accepted", "only an accepted fact can be revoked"),
305
310
  validation("fact.owner-written", "the owner wrote this fact; it was never proposed, so it cannot be revoked"),
306
311
  validation("fact.payment-retired", "a payment is a payments row in store.finance, not a fact"),
@@ -2,6 +2,6 @@ import type { Command } from "commander";
2
2
  import { type CatalogueOptions } from "../mcp/agent.js";
3
3
  /**
4
4
  * The MCP catalogue of a CLI's own commands, by path, as `read` or `write`: what cli-core mounted is left out, since
5
- * cli-core pins it. A CLI's contract test pins this and the few shared commands it changes on purpose.
5
+ * cli-core pins it. A generated command (a Bot API method) is the CLI's own, as `commands --json` marks it. A CLI's contract test pins this and the few shared commands it changes on purpose.
6
6
  */
7
7
  export declare const ownCatalogue: (program: Command, options?: CatalogueOptions) => Record<string, "read" | "write">;
@@ -1,9 +1,9 @@
1
- import { describeProgram, hasSharedContract } from "@wirecat/cli-base/commands";
1
+ import { describeProgram, hasSharedContract, metaOf } from "@wirecat/cli-base/commands";
2
2
  import { toolsFromCommands } from "../mcp/agent.js";
3
3
  const sharedPaths = (command, parents = [], into = new Set()) => {
4
4
  for (const child of command.commands) {
5
5
  const path = [...parents, child.name()];
6
- if (hasSharedContract(child))
6
+ if (hasSharedContract(child) && metaOf(child).origin !== "generated")
7
7
  into.add(path.join(" "));
8
8
  sharedPaths(child, path, into);
9
9
  }
@@ -11,7 +11,7 @@ const sharedPaths = (command, parents = [], into = new Set()) => {
11
11
  };
12
12
  /**
13
13
  * The MCP catalogue of a CLI's own commands, by path, as `read` or `write`: what cli-core mounted is left out, since
14
- * cli-core pins it. A CLI's contract test pins this and the few shared commands it changes on purpose.
14
+ * cli-core pins it. A generated command (a Bot API method) is the CLI's own, as `commands --json` marks it. A CLI's contract test pins this and the few shared commands it changes on purpose.
15
15
  */
16
16
  export const ownCatalogue = (program, options = {}) => {
17
17
  const shared = sharedPaths(program);
@@ -38,6 +38,20 @@ export const pull = async (source, store, options) => {
38
38
  let failed = false;
39
39
  /** The start of the first meeting that failed: the cursor of a stopped pull goes no further. */
40
40
  let firstFailed;
41
+ const callers = new Set();
42
+ const linkCallers = async () => {
43
+ if (callers.size === 0 || !store.linkCallers)
44
+ return;
45
+ try {
46
+ await store.linkCallers(source.provider, [...callers]);
47
+ }
48
+ catch (error) {
49
+ report.warnings.push({
50
+ externalId: source.provider,
51
+ message: `callers not linked to people: ${error instanceof Error ? error.message : "failed"}`,
52
+ });
53
+ }
54
+ };
41
55
  const from = timestamp(since) - lookbackMs;
42
56
  // Oldest first, so a stopped pull leaves everything before its cursor done.
43
57
  const meetings = (await source.meetings(lookbackMs === 0 ? since : new Date(from).toISOString())).toSorted((a, b) => startOf(a) - startOf(b));
@@ -49,6 +63,7 @@ export const pull = async (source, store, options) => {
49
63
  const reached = Math.min(startOf(m), firstFailed ?? Number.POSITIVE_INFINITY);
50
64
  if (Number.isFinite(reached) && reached > timestamp(since))
51
65
  await store.setCursor(options.accountId, new Date(reached).toISOString(), now);
66
+ await linkCallers();
52
67
  return report;
53
68
  }
54
69
  const id = m.occurrence.id;
@@ -159,6 +174,9 @@ export const pull = async (source, store, options) => {
159
174
  now,
160
175
  });
161
176
  await linkEvent(store, details, now);
177
+ for (const p of participants)
178
+ if (p.identity.phone)
179
+ callers.add(p.identity.externalId);
162
180
  report.meetings++;
163
181
  report.participants += participants.length;
164
182
  report.transcriptRows += lines?.length ?? 0;
@@ -169,6 +187,7 @@ export const pull = async (source, store, options) => {
169
187
  report.warnings.push({ externalId: id, message: error instanceof Error ? error.message : "Meeting pull failed" });
170
188
  }
171
189
  }
190
+ await linkCallers();
172
191
  // A failed occurrence must remain inside the next pull's retry window.
173
192
  if (!failed)
174
193
  await store.setCursor(options.accountId, new Date(now).toISOString(), now);
@@ -145,6 +145,8 @@ export interface MeetingStore {
145
145
  reviewMeetingLink?(meetingId: number, eventIds: number[], now: number): Promise<void>;
146
146
  cursor(accountId: number): Promise<string | null>;
147
147
  setCursor(accountId: number, value: string, now: number): Promise<void>;
148
+ /** Links the callers a sync saved, by `provider` and identity external id, to the people with their number. */
149
+ linkCallers?(provider: string, externalIds: readonly string[]): Promise<void>;
148
150
  /** Detects the language of the account's transcripts that have none; stores it only with `apply`. */
149
151
  fillTranscriptLanguages?(input: {
150
152
  accountId: number;
@@ -7,7 +7,7 @@ export declare const modelAddressAllowed: (value: string) => boolean;
7
7
  export declare const PLAIN_HTTP_REFUSED = "this address is not allowed: use https, or http only on this computer";
8
8
  /**
9
9
  * `fetch` that reaches only the host of this model address, through `hostFetch`. The address was checked when it was
10
- * saved; its host is the one the person configured. `[::1]` is not a name `hostFetch` takes, and the loopback cannot
11
- * leave this computer, so it goes through the plain `fetch`.
10
+ * saved; its host is the one the person configured. `[::1]` cannot leave this computer, so it goes through the plain
11
+ * `fetch`; any other IPv6 literal through `literalFetch`.
12
12
  */
13
13
  export declare const endpointFetch: (address: string, timeoutMs: number) => FetchLike;
@@ -1,3 +1,4 @@
1
+ import { CliError, isCliError } from "@wirecat/cli-base";
1
2
  import { hostFetch } from "@wirecat/cli-base/http";
2
3
  export const endpoint = (value) => {
3
4
  try {
@@ -21,12 +22,45 @@ export const onThisComputer = (value) => {
21
22
  /** https anywhere; plain http only to this computer, so neither the text nor the key crosses a network unencrypted. */
22
23
  export const modelAddressAllowed = (value) => endpoint(value) && (new URL(value).protocol === "https:" || onThisComputer(value));
23
24
  export const PLAIN_HTTP_REFUSED = "this address is not allowed: use https, or http only on this computer";
25
+ /**
26
+ * `hostFetch`'s rules for an IPv6 literal, which it does not take as a host: only this host, a deadline, and no
27
+ * redirect followed, since a model API has none to give.
28
+ */
29
+ const literalFetch = (hostname, timeoutMs) => async (input, init = {}) => {
30
+ const url = new URL(input instanceof Request ? input.url : String(input));
31
+ if (url.hostname !== hostname)
32
+ throw new CliError("configuration_error", `${url.hostname} is not the model address's host, ${hostname}`, {
33
+ reason: "network.host-undeclared",
34
+ sent: false,
35
+ });
36
+ const deadline = AbortSignal.timeout(timeoutMs);
37
+ const signal = init.signal ? AbortSignal.any([init.signal, deadline]) : deadline;
38
+ try {
39
+ const response = await fetch(input, { ...init, signal, redirect: "manual" });
40
+ if (response.status >= 300 && response.status < 400) {
41
+ void response.body?.cancel().catch(() => { });
42
+ throw new CliError("invalid_response", `${hostname} answered with a redirect, which is not followed`);
43
+ }
44
+ return response;
45
+ }
46
+ catch (error) {
47
+ if (isCliError(error))
48
+ throw error;
49
+ if (init.signal?.aborted)
50
+ throw new CliError("cancelled", "request cancelled");
51
+ if (deadline.aborted)
52
+ throw new CliError("timeout", `${hostname} did not answer within ${timeoutMs} ms`, { retryable: true });
53
+ throw new CliError("network_error", `${hostname} could not be reached`, { retryable: true });
54
+ }
55
+ };
24
56
  /**
25
57
  * `fetch` that reaches only the host of this model address, through `hostFetch`. The address was checked when it was
26
- * saved; its host is the one the person configured. `[::1]` is not a name `hostFetch` takes, and the loopback cannot
27
- * leave this computer, so it goes through the plain `fetch`.
58
+ * saved; its host is the one the person configured. `[::1]` cannot leave this computer, so it goes through the plain
59
+ * `fetch`; any other IPv6 literal through `literalFetch`.
28
60
  */
29
61
  export const endpointFetch = (address, timeoutMs) => {
30
62
  const { hostname } = new URL(address);
31
- return hostname === "[::1]" ? fetch : hostFetch({ hosts: [hostname], timeoutMs });
63
+ if (hostname === "[::1]")
64
+ return fetch;
65
+ return hostname.startsWith("[") ? literalFetch(hostname, timeoutMs) : hostFetch({ hosts: [hostname], timeoutMs });
32
66
  };
@@ -9,5 +9,7 @@ export declare const storePath: (env?: NodeJS.ProcessEnv) => string;
9
9
  export declare const accountHome: () => string | undefined;
10
10
  /** Whether `file` is in the owner's real WireCat folder, whatever HOME or MESSAGING_STORE this process was given. */
11
11
  export declare const inOwnerFolder: (file: string, home?: string | undefined) => boolean;
12
+ /** The path with every link in its existing part followed, so a link into the owner's folder is seen as one. */
13
+ export declare const settled: (path: string) => string;
12
14
  /** Throws when a test is about to open a file in the owner's real WireCat folder. */
13
15
  export declare const refuseOwnerStoreInTests: (file: string, env?: NodeJS.ProcessEnv, home?: string | undefined) => void;
@@ -32,7 +32,7 @@ export const inOwnerFolder = (file, home = accountHome()) => {
32
32
  return within(resolve(file), owner) || within(settled(resolve(file)), settled(owner));
33
33
  };
34
34
  /** The path with every link in its existing part followed, so a link into the owner's folder is seen as one. */
35
- const settled = (path) => {
35
+ export const settled = (path) => {
36
36
  try {
37
37
  return realpathSync(path);
38
38
  }
@@ -64,7 +64,7 @@ export const meetingProjectsStoreOver = ({ database, now }) => {
64
64
  .get(meeting, project);
65
65
  if (options.expectedFingerprint !== undefined &&
66
66
  (!held || linkOf(held, accountId).fingerprint !== options.expectedFingerprint))
67
- throw new CliError("configuration_error", "meeting membership changed since review", {
67
+ throw new CliError("conflict", "meeting membership changed since review", {
68
68
  reason: "meeting-project.stale",
69
69
  });
70
70
  if (held && (Number(held.confirmed) === 1 || by === "agent"))
@@ -75,8 +75,8 @@ export const meetingProjectsStoreOver = ({ database, now }) => {
75
75
  const at = now();
76
76
  if (held)
77
77
  database
78
- .prepare("UPDATE links SET confirmed=1,source='owner',author='owner',updated_at=? WHERE id=?")
79
- .run(at, Number(held.id));
78
+ .prepare("UPDATE links SET confirmed=1,source='owner',author='owner',evidence=COALESCE(?,evidence),updated_at=? WHERE id=?")
79
+ .run(options.provenance ?? null, at, Number(held.id));
80
80
  else
81
81
  database
82
82
  .prepare("INSERT INTO links (from_type,from_id,to_type,to_id,kind,source,confirmed,evidence,author,created_at,updated_at) VALUES ('meeting',?,'project',?,'member-of',?,?,?,?,?,?)")
@@ -23,6 +23,7 @@ import { meetingSeriesHistoryOver } from "./meeting-series-history.js";
23
23
  import { meetingStatsOver } from "./meeting-stats.js";
24
24
  import { invalidateMeetingStems } from "./meeting-stem-state.js";
25
25
  import { meetingOf, transcriptOf, transcriptRowOf } from "./meeting-values.js";
26
+ import { linkPhones } from "./person-match-scan.js";
26
27
  import { queryFilter } from "./query-filter.js";
27
28
  import { read, write } from "./transaction.js";
28
29
  const CURSOR_KEY = "meetings";
@@ -611,6 +612,14 @@ export const meetingStoreOver = (context) => {
611
612
  ...meetingHitIndexOver(context),
612
613
  ...meetingContextLinksOver(context),
613
614
  ...meetingLanguagesOver(context),
615
+ async linkCallers(provider, externalIds) {
616
+ const marks = externalIds.map(() => "?").join(", ");
617
+ const ids = database
618
+ .prepare(`SELECT id FROM identities WHERE provider = ? AND external_id IN (${marks})`)
619
+ .all(provider, ...externalIds)
620
+ .map(({ id }) => Number(id));
621
+ linkPhones(context, new Set(ids));
622
+ },
614
623
  async appendTranscriptsWithReceipt(input) {
615
624
  try {
616
625
  return append(context, input);
@@ -27,3 +27,8 @@ export declare const PROPOSAL_SCORE: {
27
27
  export declare const scanMatches: (context: StoreContext, { full }?: {
28
28
  full?: boolean;
29
29
  }) => MatchScan;
30
+ /**
31
+ * The phone rule alone, for the identities named: a meetings sync that saved callers links them to their CRM contact
32
+ * without memo's `people scan`. It moves no cursor, so the next scan still looks at these identities by every rule.
33
+ */
34
+ export declare const linkPhones: (context: StoreContext, identities: ReadonlySet<number>) => MatchScan;
@@ -572,3 +572,24 @@ export const scanMatches = (context, { full = false } = {}) => {
572
572
  .run(CURSOR, JSON.stringify(started), context.now()));
573
573
  return pass.result;
574
574
  };
575
+ /**
576
+ * The phone rule alone, for the identities named: a meetings sync that saved callers links them to their CRM contact
577
+ * without memo's `people scan`. It moves no cursor, so the next scan still looks at these identities by every rule.
578
+ */
579
+ export const linkPhones = (context, identities) => {
580
+ const { database } = context;
581
+ const people = [...peopleOfIdentities(context, new Set(identities))];
582
+ write(database, () => settleLinks(database, people));
583
+ const pass = {
584
+ context,
585
+ index: linkIndex(database),
586
+ result: { full: false, merged: [], proposed: [], skipped: [] },
587
+ shared: [],
588
+ };
589
+ for (const [phone, holders] of phoneHolders(database))
590
+ if (holders.length > 1 && holders.some(({ identity }) => identities.has(identity)))
591
+ write(database, () => samePhone(pass, phone, holders));
592
+ for (const group of pass.shared)
593
+ write(database, () => proposeShared(pass, group));
594
+ return pass.result;
595
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "0.650.0",
3
+ "version": "0.651.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",
@@ -283,7 +283,7 @@
283
283
  "@types/pngjs": "6.0.5",
284
284
  "@types/ssh2": "1.15.5",
285
285
  "@vitest/coverage-v8": "^5.0.5",
286
- "@wirecat/cli-base": "0.98.0",
286
+ "@wirecat/cli-base": "0.99.0",
287
287
  "@wirecat/cli-core-legacy-tags": "npm:@wirecat/cli-core@0.414.0",
288
288
  "ajv": "8.17.1",
289
289
  "commander": "15.0.0",