@wirecat/cli-core 0.420.0 → 0.421.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 +12 -0
- package/dist/cli/bot/context.d.ts +3 -2
- package/dist/cli/bot/context.js +15 -0
- package/dist/cli/config-command.js +1 -2
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +0 -1
- package/dist/cli/messenger/context.js +3 -6
- package/dist/cli/permission-keys.d.ts +2 -0
- package/dist/cli/permission-keys.js +10 -3
- package/dist/cli/preview.d.ts +2 -2
- package/dist/cli/preview.js +4 -3
- package/dist/cli/program.js +4 -8
- package/dist/cli/settings.d.ts +0 -2
- package/dist/cli/settings.js +1 -5
- package/dist/mcp/surface.js +0 -4
- package/dist/mcp/tool.d.ts +1 -3
- package/dist/mcp/tool.js +1 -2
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/parity/manifest.js +0 -4
- package/dist/sends/index.d.ts +1 -1
- package/dist/sends/index.js +1 -1
- package/dist/sends/permissions.d.ts +0 -13
- package/dist/sends/permissions.js +15 -142
- package/package.json +1 -1
- package/dist/cli/moved.d.ts +0 -18
- package/dist/cli/moved.js +0 -72
- package/dist/sends/permission-aliases.d.ts +0 -5
- package/dist/sends/permission-aliases.js +0 -50
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ shape of this file.
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 0.421.0 — 25.10.2026
|
|
11
|
+
|
|
12
|
+
### Changed — may break callers
|
|
13
|
+
|
|
14
|
+
- **Old command names and old permission keys are no longer recognised.** A retired command path (`contacts profile`, `bot store fetch`, `search mail` and the rest) gets the ordinary "unknown command" answer, on the command line and over MCP, with no pointer to a replacement. A saved permission key is read only as written: nothing maps an old key to a new one, and `chats.mute` no longer covers `chats unmute`. Removed with it: `movedCommandError` from `/cli`; `PERMISSIONS`, `Permission`, `permissionFor` and `assertStatsPermissionsCurrent` from `/sends`; the `permission` field of an MCP tool definition; and the `skipMovedPermissions` option of `resolveSettings`. A CLI that imports one of them drops the import; nothing replaces them.
|
|
15
|
+
- **Bot commands and `--dry-run` refuse a saved permission key that no command checks**, as messenger commands already did. They stop with a `configuration_error` that names the key and the `config unset` that removes it: "permissions.bot.store.fetch names no command — remove it with \`tg sales config unset --bot permissions.bot.store.fetch\`". `config show`, `set` and `unset` still run, so the file can be repaired. Before, a bot command did not look at the keys at all, and an old key was quietly renamed or ignored.
|
|
16
|
+
- **`messages sync` and `bot messages sync` are checked as `messages.sync` and `bot.messages.sync`**, their own paths. A level on `messages` or `bot.messages` still applies to them; `commands --json` now reports the longer key.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- **A deny saved on the sync command itself now stops it.** `permissions.bot.messages.sync: deny` was ignored, because `bot messages sync` was checked under `bot.messages`; `permissions.messages.sync: deny` could not be saved at all and was refused as naming no command. Both are now honoured on the command line, in MCP discovery and by the MCP server. Bot commands also refuse a denied read (`bot.messages: deny` stops `bot messages list` and `bot messages sync`) before they connect, as messenger commands already did.
|
|
21
|
+
|
|
10
22
|
## 0.420.0 — 25.10.2026
|
|
11
23
|
|
|
12
24
|
### Changed — may break callers
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
import { SendJournal } from "../../sends/journal.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type Level, type PermissionKey } from "../../sends/permissions.js";
|
|
4
4
|
import { RecipientList } from "../../sends/recipients.js";
|
|
5
|
+
import type { Settings } from "../settings.js";
|
|
5
6
|
import type { BotAdapter, BotChatRef, BotConnectOptions, BotMessenger } from "./port.js";
|
|
6
7
|
import { ChatRegistry } from "./registry.js";
|
|
7
8
|
import { BotTokenStore } from "./token.js";
|
|
@@ -9,7 +10,7 @@ import { BotTokenStore } from "./token.js";
|
|
|
9
10
|
export declare const botWords: (bot: BotMessenger, profile: string) => string;
|
|
10
11
|
/** What a bot command needs, resolved once: the bot's settings, its token, its lists. */
|
|
11
12
|
export declare const botContext: (command: Command, bot: BotMessenger) => {
|
|
12
|
-
settings:
|
|
13
|
+
settings: Settings;
|
|
13
14
|
renderer: import("@wirecat/cli-base").Renderer;
|
|
14
15
|
format: import("@wirecat/cli-base").RenderFormat;
|
|
15
16
|
color: boolean;
|
package/dist/cli/bot/context.js
CHANGED
|
@@ -2,16 +2,30 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
import { pickChat } from "../../resolve.js";
|
|
3
3
|
import { sendGuard } from "../../sends/guard.js";
|
|
4
4
|
import { SendJournal } from "../../sends/journal.js";
|
|
5
|
+
import { levelFor, readKeysForCommand } from "../../sends/permissions.js";
|
|
5
6
|
import { RecipientList } from "../../sends/recipients.js";
|
|
6
7
|
import { readSecret } from "../../terminal/prompt.js";
|
|
8
|
+
import { commandPathOf } from "../command-contract.js";
|
|
7
9
|
import { baseContext, secretInputOf } from "../context.js";
|
|
8
10
|
import { terminalAsker } from "../messenger/ask.js";
|
|
11
|
+
import { refuseUnknownPermissionKeys } from "../permission-keys.js";
|
|
9
12
|
import { asFirstWord } from "../profile.js";
|
|
10
13
|
import { botCopy } from "./copy.js";
|
|
11
14
|
import { botFiles, ChatRegistry } from "./registry.js";
|
|
12
15
|
import { BotTokenStore } from "./token.js";
|
|
13
16
|
/** How the owner types this bot — `max sales bot` — so a refusal names the command that fixes it. */
|
|
14
17
|
export const botWords = (bot, profile) => `${bot.app.command} ${asFirstWord(profile)}bot`;
|
|
18
|
+
/** What a messenger command refuses before it connects, for a bot: an unknown key, then a denied read. */
|
|
19
|
+
const refuseBotPermissions = (command, bot, settings) => {
|
|
20
|
+
refuseUnknownPermissionKeys(command, settings.permissions, `${bot.app.command} ${asFirstWord(settings.profile)}config unset --bot`);
|
|
21
|
+
for (const key of readKeysForCommand(commandPathOf(command))) {
|
|
22
|
+
const { level, key: named } = levelFor(settings.permissions, key);
|
|
23
|
+
if (level !== "deny")
|
|
24
|
+
continue;
|
|
25
|
+
throw new CliError("permission_error", `bot profile ${settings.profile} denies ${key} (permissions.${named} is deny, from the ` +
|
|
26
|
+
`${settings.permissionSources[named ?? ""] ?? "default"})`, { permission: key });
|
|
27
|
+
}
|
|
28
|
+
};
|
|
15
29
|
/** What a bot command needs, resolved once: the bot's settings, its token, its lists. */
|
|
16
30
|
export const botContext = (command, bot) => {
|
|
17
31
|
const base = baseContext(command, (flags, options) => bot.resolveSettings(flags, { ...options, kind: "bot" }));
|
|
@@ -21,6 +35,7 @@ export const botContext = (command, bot) => {
|
|
|
21
35
|
const tokens = bot.tokenStore?.(command, profile) ??
|
|
22
36
|
new BotTokenStore({ app: bot.app, profile, env, ...(keyring ? { keyring } : {}) });
|
|
23
37
|
const words = botWords(bot, profile);
|
|
38
|
+
refuseBotPermissions(command, bot, settings);
|
|
24
39
|
const registry = bot.registry?.(command, profile) ?? new ChatRegistry(bot.app, profile, env);
|
|
25
40
|
const recipients = () => new RecipientList(files.recipients, words);
|
|
26
41
|
const journal = () => new SendJournal(files.journal, { service: bot.app.command, version: bot.app.version });
|
|
@@ -55,7 +55,7 @@ export const configCommand = (app, config, { permissionKey } = {}) => {
|
|
|
55
55
|
.option("--bot", "only for bots — the bot section of the file");
|
|
56
56
|
if (action === "set")
|
|
57
57
|
sub
|
|
58
|
-
.argument("<value>", "a number, true or false
|
|
58
|
+
.argument("<value>", "a number, true or false; for a group tg:work,max:Alice,email:me@x")
|
|
59
59
|
.description("save a setting to the configuration file");
|
|
60
60
|
else
|
|
61
61
|
sub.description("remove a setting from the configuration file");
|
|
@@ -64,7 +64,6 @@ export const configCommand = (app, config, { permissionKey } = {}) => {
|
|
|
64
64
|
const context = baseContext(this, (flags, options) => config.resolveSettings(flags, {
|
|
65
65
|
...options,
|
|
66
66
|
needsProfile: !everyone && setting !== "default_profile" && !isStoreSetting(setting),
|
|
67
|
-
skipMovedPermissions: true,
|
|
68
67
|
}));
|
|
69
68
|
const { settings, renderer, env } = context;
|
|
70
69
|
if (isStoreSetting(setting)) {
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -96,7 +96,6 @@ export type { Running, ServerOptions, ServerProcess, ServerSystem } from "./mess
|
|
|
96
96
|
export { storeSummary } from "./messenger/store-maintenance-command.js";
|
|
97
97
|
export { type Saving, stored } from "./messenger/stored.js";
|
|
98
98
|
export { MODEL_CATALOGUE_QUERY, type ModelCatalogueOptions } from "./model-catalogue-command.js";
|
|
99
|
-
export { movedCommandError } from "./moved.js";
|
|
100
99
|
export { window, withPaging } from "./paging.js";
|
|
101
100
|
export { knownBeside, knownPermissionKeys, type PermissionKeyOf, unknownPermissionKeys } from "./permission-keys.js";
|
|
102
101
|
export { asFirstWord, commandWords, liftProfile, refuseCommandName, rootOf, usableProfileName } from "./profile.js";
|
package/dist/cli/index.js
CHANGED
|
@@ -87,7 +87,6 @@ export { STEMS_EVERY_MS, STEMS_SLICE_MS, stemFills } from "./messenger/serve-ste
|
|
|
87
87
|
export { storeSummary } from "./messenger/store-maintenance-command.js";
|
|
88
88
|
export { stored } from "./messenger/stored.js";
|
|
89
89
|
export { MODEL_CATALOGUE_QUERY } from "./model-catalogue-command.js";
|
|
90
|
-
export { movedCommandError } from "./moved.js";
|
|
91
90
|
export { window, withPaging } from "./paging.js";
|
|
92
91
|
export { knownBeside, knownPermissionKeys, unknownPermissionKeys } from "./permission-keys.js";
|
|
93
92
|
export { asFirstWord, commandWords, liftProfile, refuseCommandName, rootOf, usableProfileName } from "./profile.js";
|
|
@@ -3,12 +3,12 @@ import { servingProfiles } from "../../background/lock.js";
|
|
|
3
3
|
import { FloodMemory, floodPathFor } from "../../sends/flood.js";
|
|
4
4
|
import { ceilingRefusal, guardFor } from "../../sends/guard.js";
|
|
5
5
|
import { DEFAULT_PACE, Pacer, pacePathFor } from "../../sends/pace.js";
|
|
6
|
-
import {
|
|
6
|
+
import { CEILING_KEY, levelFor, readKeysForCommand } from "../../sends/permissions.js";
|
|
7
7
|
import { RecipientList, recipientsPathFor } from "../../sends/recipients.js";
|
|
8
8
|
import { OFFLINE, servicesFor } from "../../services/index.js";
|
|
9
9
|
import { openStore } from "../../store/store.js";
|
|
10
10
|
import { baseContext, environmentOf } from "../context.js";
|
|
11
|
-
import {
|
|
11
|
+
import { refuseUnknownPermissionKeys } from "../permission-keys.js";
|
|
12
12
|
import { asFirstWord } from "../profile.js";
|
|
13
13
|
import { rootOf } from "../steps.js";
|
|
14
14
|
import { recalledAccount, rememberAccount } from "./accounts.js";
|
|
@@ -325,7 +325,6 @@ const pathOf = (command) => {
|
|
|
325
325
|
};
|
|
326
326
|
/** `deny` stops a read too, before anything connects: what the profile may not see is never fetched. */
|
|
327
327
|
const refuseDenied = (command, settings) => {
|
|
328
|
-
assertStatsPermissionsCurrent(pathOf(command), settings.permissions);
|
|
329
328
|
for (const key of readKeysForCommand(pathOf(command))) {
|
|
330
329
|
const { level, key: named } = levelFor(settings.permissions, key);
|
|
331
330
|
if (level !== "deny")
|
|
@@ -356,9 +355,7 @@ export const messengerContext = (command, messenger, resolving = {}) => {
|
|
|
356
355
|
const { profile } = base.settings;
|
|
357
356
|
refuseDenied(command, base.settings);
|
|
358
357
|
refuseLacking(messenger, pathOf(command));
|
|
359
|
-
|
|
360
|
-
throw new CliError("configuration_error", `permissions.${key} names no command — remove it with \`${app.command} ${asFirstWord(profile)}config unset permissions.${key}\``, { permission: key });
|
|
361
|
-
}
|
|
358
|
+
refuseUnknownPermissionKeys(command, base.settings.permissions, `${app.command} ${asFirstWord(profile)}config unset`, messenger.permissionKey);
|
|
362
359
|
// Read when warning, not now: serve swaps the renderer's methods for log records after this.
|
|
363
360
|
const warn = (text, warning) => base.renderer.warn(text, warning);
|
|
364
361
|
const accountFor = () => {
|
|
@@ -9,3 +9,5 @@ export declare const knownPermissionKeys: (command: Command, keyOf?: PermissionK
|
|
|
9
9
|
/** The known keys one level under the unknown key's parent, to name in the refusal. */
|
|
10
10
|
export declare const knownBeside: (key: PermissionKey, known: ReadonlySet<PermissionKey>) => PermissionKey[];
|
|
11
11
|
export declare const unknownPermissionKeys: (levels: Readonly<Record<PermissionKey, unknown>>, known: ReadonlySet<PermissionKey>) => PermissionKey[];
|
|
12
|
+
/** A saved key no command checks would do nothing, so the command refuses to run; `unset` names the fix. */
|
|
13
|
+
export declare const refuseUnknownPermissionKeys: (command: Command, levels: Readonly<Record<PermissionKey, unknown>>, unset: string, keyOf?: PermissionKeyOf) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { CEILING_KEY, keyForCommand, WRITE_KEYS } from "../sends/permissions.js";
|
|
3
3
|
const pathOf = (command) => {
|
|
4
4
|
const words = [];
|
|
@@ -20,12 +20,12 @@ const everyCommand = (command) => [command, ...command.commands.flatMap(everyCom
|
|
|
20
20
|
export const knownPermissionKeys = (command, keyOf = (one) => keyForCommand(pathOf(one)), extra = []) => {
|
|
21
21
|
const known = new Set();
|
|
22
22
|
const add = (key) => {
|
|
23
|
-
key = canonicalPermissionKey(key);
|
|
24
23
|
for (let parts = key.split("."); parts.length > 0; parts = parts.slice(0, -1))
|
|
25
24
|
known.add(parts.join("."));
|
|
26
25
|
};
|
|
27
26
|
for (const one of everyCommand(rootOf(command))) {
|
|
28
|
-
const
|
|
27
|
+
const own = keyOf(one);
|
|
28
|
+
const key = own === undefined ? keyForCommand(pathOf(one)) : own;
|
|
29
29
|
if (key)
|
|
30
30
|
add(key);
|
|
31
31
|
}
|
|
@@ -42,3 +42,10 @@ export const knownBeside = (key, known) => {
|
|
|
42
42
|
.sort();
|
|
43
43
|
};
|
|
44
44
|
export const unknownPermissionKeys = (levels, known) => Object.keys(levels).filter((key) => key !== CEILING_KEY && !known.has(key));
|
|
45
|
+
/** A saved key no command checks would do nothing, so the command refuses to run; `unset` names the fix. */
|
|
46
|
+
export const refuseUnknownPermissionKeys = (command, levels, unset, keyOf) => {
|
|
47
|
+
const [key] = unknownPermissionKeys(levels, knownPermissionKeys(command, keyOf));
|
|
48
|
+
if (key === undefined)
|
|
49
|
+
return;
|
|
50
|
+
throw new CliError("configuration_error", `permissions.${key} names no command — remove it with \`${unset} permissions.${key}\``, { permission: key });
|
|
51
|
+
};
|
package/dist/cli/preview.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
|
-
import { type Level } from "../sends/permissions.js";
|
|
2
|
+
import { type Level, type PermissionKey } from "../sends/permissions.js";
|
|
3
3
|
export declare class PreviewComplete extends Error {
|
|
4
4
|
}
|
|
5
|
-
export declare const preview: (command: Command, permissions: Readonly<Record<string, Level
|
|
5
|
+
export declare const preview: (command: Command, permissions: Readonly<Record<string, Level>>, unset: string, keyOf?: (path: readonly string[]) => PermissionKey | null | undefined) => {
|
|
6
6
|
preview: boolean;
|
|
7
7
|
path: string[];
|
|
8
8
|
permission: {
|
package/dist/cli/preview.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { metaOf } from "@wirecat/cli-base/commands";
|
|
3
3
|
import { writes as writesAnything } from "@wirecat/cli-base/standards";
|
|
4
|
-
import {
|
|
4
|
+
import { keyForCommand, levelFor, readKeysForCommand, WRITE_KEYS, } from "../sends/permissions.js";
|
|
5
5
|
import { commandPathOf } from "./command-contract.js";
|
|
6
|
+
import { refuseUnknownPermissionKeys } from "./permission-keys.js";
|
|
6
7
|
export class PreviewComplete extends Error {
|
|
7
8
|
}
|
|
8
|
-
export const preview = (command, permissions) => {
|
|
9
|
+
export const preview = (command, permissions, unset, keyOf) => {
|
|
9
10
|
const path = commandPathOf(command);
|
|
11
|
+
refuseUnknownPermissionKeys(command, permissions, unset, keyOf && ((one) => keyOf(commandPathOf(one))));
|
|
10
12
|
const key = keyForCommand(path);
|
|
11
13
|
const level = key ? levelFor(permissions, key).level : "allow";
|
|
12
|
-
assertStatsPermissionsCurrent(path, permissions);
|
|
13
14
|
for (const source of readKeysForCommand(path)) {
|
|
14
15
|
if (levelFor(permissions, source).level === "deny")
|
|
15
16
|
throw new CliError("permission_error", `this profile does not permit ${source}`, { permission: source });
|
package/dist/cli/program.js
CHANGED
|
@@ -25,9 +25,8 @@ import { installHelp } from "./help/first-screen.js";
|
|
|
25
25
|
import { showInputFields } from "./input-fields.js";
|
|
26
26
|
import { MAX_BUFFERED_INPUT, provideInputPolicy } from "./input-policy.js";
|
|
27
27
|
import { checkJson, liftJson } from "./json-fields.js";
|
|
28
|
-
import { movedCommandError } from "./moved.js";
|
|
29
28
|
import { PreviewComplete, preview } from "./preview.js";
|
|
30
|
-
import { commandWords, liftProfile, PROFILE_FREE, valuedOptions } from "./profile.js";
|
|
29
|
+
import { asFirstWord, commandWords, liftProfile, PROFILE_FREE, valuedOptions } from "./profile.js";
|
|
31
30
|
import { absolutePaths, relayTarget } from "./relay-route.js";
|
|
32
31
|
import { settingsFor } from "./settings.js";
|
|
33
32
|
import { assertSharedContracts } from "./shared-contracts.js";
|
|
@@ -377,7 +376,9 @@ const runOnce = async (argv, definition, options) => {
|
|
|
377
376
|
needsProfile: keyForCommand(path) !== null,
|
|
378
377
|
});
|
|
379
378
|
const permissions = "permissions" in resolved ? resolved.permissions : {};
|
|
380
|
-
|
|
379
|
+
const unset = `${command} ${asFirstWord(resolved.profile)}config unset${path[0] === "bot" ? " --bot" : ""}`;
|
|
380
|
+
const previewed = preview(action, permissions, unset, definition.configuration?.permissionKey);
|
|
381
|
+
renderAnswer(action, outputFor(action), itemOf(snakeKeys(previewed)));
|
|
381
382
|
throw new PreviewComplete();
|
|
382
383
|
}
|
|
383
384
|
// Not inside the scheduled run itself: its own failure is already on its way to last.json.
|
|
@@ -421,11 +422,6 @@ const runOnce = async (argv, definition, options) => {
|
|
|
421
422
|
const settled = await settleFailure(failure, { definition, program, rest, profile, options });
|
|
422
423
|
return report(streams, reporting, failed(definition, program, rest, failure, settled, debug));
|
|
423
424
|
}
|
|
424
|
-
const failure = movedCommandError(program, rest);
|
|
425
|
-
if (failure !== undefined) {
|
|
426
|
-
const settled = await settleFailure(failure, { definition, program, rest, profile, options });
|
|
427
|
-
return report(streams, reporting, failed(definition, program, rest, failure, settled, debug));
|
|
428
|
-
}
|
|
429
425
|
try {
|
|
430
426
|
await control.race(() => program.parseAsync(rest, { from: "user" }));
|
|
431
427
|
const code = exit.code ?? (process.exitCode === undefined ? 0 : Number(process.exitCode));
|
package/dist/cli/settings.d.ts
CHANGED
|
@@ -140,8 +140,6 @@ export interface ResolveOptions {
|
|
|
140
140
|
needsProfile?: boolean;
|
|
141
141
|
/** Read the config file without writing it: no default file. For a dry run. */
|
|
142
142
|
readOnly?: boolean;
|
|
143
|
-
/** Skip moved permission keys instead of refusing them, so `config set` and `unset` can fix one. */
|
|
144
|
-
skipMovedPermissions?: boolean;
|
|
145
143
|
}
|
|
146
144
|
/** Where `profile` came from when none was named and the command needs none. */
|
|
147
145
|
export declare const NONE_NAMED = "none named";
|
package/dist/cli/settings.js
CHANGED
|
@@ -4,7 +4,6 @@ import * as v from "valibot";
|
|
|
4
4
|
import { AI_ENTRIES, resolveAISettings } from "../analysis/settings.js";
|
|
5
5
|
import { parseDuration } from "../domain/duration.js";
|
|
6
6
|
import { envName, readOnlyLockOf } from "../ports/app.js";
|
|
7
|
-
import { canonicalPermissionKey } from "../sends/permission-aliases.js";
|
|
8
7
|
import { assertOverridesTighten, CEILING_KEY, LEVELS, layerPermissions, permissionOverrides, RESOURCES, } from "../sends/permissions.js";
|
|
9
8
|
import { storePath } from "../store/path.js";
|
|
10
9
|
import { sharedConfigPath } from "../store/shared-config.js";
|
|
@@ -78,7 +77,6 @@ const SHARED_DEFAULTS_ONLY = {
|
|
|
78
77
|
update_check: v.optional(flag),
|
|
79
78
|
skill_hint: v.optional(flag),
|
|
80
79
|
};
|
|
81
|
-
const withoutMoved = (levels) => levels && Object.fromEntries(Object.entries(levels).filter(([key]) => canonicalPermissionKey(key) === key));
|
|
82
80
|
/** Where `profile` came from when none was named and the command needs none. */
|
|
83
81
|
export const NONE_NAMED = "none named";
|
|
84
82
|
/** A name for a command that speaks for no account; never chosen for one that does. */
|
|
@@ -232,9 +230,7 @@ export const settingsFor = (app, extension = {}) => {
|
|
|
232
230
|
: { value: false, from: "default" };
|
|
233
231
|
const fileLayers = layers.map(([from, scope]) => [
|
|
234
232
|
from,
|
|
235
|
-
|
|
236
|
-
? withoutMoved(scope?.permissions)
|
|
237
|
-
: scope?.permissions,
|
|
233
|
+
scope?.permissions,
|
|
238
234
|
]);
|
|
239
235
|
const overrides = permissionOverrides(flags.permission);
|
|
240
236
|
assertOverridesTighten(overrides, layerPermissions(fileLayers).levels);
|
package/dist/mcp/surface.js
CHANGED
|
@@ -2,7 +2,6 @@ import { toJsonSchema, toStandardJsonSchema } from "@valibot/to-json-schema";
|
|
|
2
2
|
import { CliError } from "@wirecat/cli-base";
|
|
3
3
|
import * as v from "valibot";
|
|
4
4
|
import { answerSchema, listOf } from "../cli/envelope.js";
|
|
5
|
-
import { movedPath, movedPointer } from "../cli/moved.js";
|
|
6
5
|
import { ENTITIES } from "../entities/index.js";
|
|
7
6
|
import { agentArguments } from "./text.js";
|
|
8
7
|
import { answered, commandOf, entryRunner, failed, inputOf, outputSchemaOf, READ, syncAllowedFor, UNTRUSTED, WRITE, } from "./tool.js";
|
|
@@ -103,9 +102,6 @@ withheld) => {
|
|
|
103
102
|
const one = command === undefined ? undefined : commands[command];
|
|
104
103
|
if (command === undefined || !one) {
|
|
105
104
|
withheld?.(normal(asked));
|
|
106
|
-
const moved = movedPath(normal(asked).split(" "), (path) => byNormal.has(path));
|
|
107
|
-
if (moved !== undefined)
|
|
108
|
-
throw new CliError("validation_error", `no command "${asked}" here — ${movedPointer(moved)}`);
|
|
109
105
|
const near = nearest(commands, asked);
|
|
110
106
|
throw new CliError("validation_error", `no command "${asked}" here${near.length ? ` — did you mean ${near.map((name) => `"${name}"`).join(", ")}?` : ""}; ${prefix}_tools_search finds one`);
|
|
111
107
|
}
|
package/dist/mcp/tool.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { type EntityName } from "../entities/index.js";
|
|
|
10
10
|
import { type AppErrors } from "../errors/reasons.js";
|
|
11
11
|
import type { MessengerAdapter } from "../ports/messenger.js";
|
|
12
12
|
import type { SendGuard } from "../sends/guard.js";
|
|
13
|
-
import { type
|
|
13
|
+
import { type PermissionKey } from "../sends/permissions.js";
|
|
14
14
|
import { type Services } from "../services/index.js";
|
|
15
15
|
import type { AccountKey, MessageStore } from "../store/store.js";
|
|
16
16
|
import type { MessengerSession } from "./session.js";
|
|
@@ -50,8 +50,6 @@ interface Tool<S extends Input> {
|
|
|
50
50
|
/** What it touches, where its hints cannot say: a read of the messenger kept in the store is not a write there. */
|
|
51
51
|
effects?: Effects;
|
|
52
52
|
_meta?: Record<string, unknown>;
|
|
53
|
-
/** A write, and what the profile's `allow` must name for it to be offered. */
|
|
54
|
-
permission?: Permission;
|
|
55
53
|
/** Writes what the owner keeps, as its command (`isStoreChange`): `<PREFIX>_READ_ONLY` refuses it. */
|
|
56
54
|
changesStore?: true;
|
|
57
55
|
/** The CLI command it answers as, where its name does not spell it: `chats send-as`. Its level is read from it. */
|
package/dist/mcp/tool.js
CHANGED
|
@@ -12,7 +12,7 @@ import { failureContext } from "../errors/reasons.js";
|
|
|
12
12
|
import { partialOutcome, startRecording } from "../runs/recording.js";
|
|
13
13
|
import { newRunId } from "../runs/run.js";
|
|
14
14
|
import { inRun } from "../runs/scope.js";
|
|
15
|
-
import {
|
|
15
|
+
import { keyForCommand, levelFor, readKeysForCommand } from "../sends/permissions.js";
|
|
16
16
|
import { onlineDeps, storeModeDeps } from "../services/deps.js";
|
|
17
17
|
import { servicesFor } from "../services/index.js";
|
|
18
18
|
import { agentJson } from "./text.js";
|
|
@@ -178,7 +178,6 @@ const callRunner = ({ messenger, session, withStore, withServices, defaults, aro
|
|
|
178
178
|
definition.check?.(args);
|
|
179
179
|
if (definition.changesStore)
|
|
180
180
|
refuseStoreChange(messenger.app, defaults.env);
|
|
181
|
-
assertStatsPermissionsCurrent(path, defaults.settings.permissions ?? {});
|
|
182
181
|
refuseLacking(messenger, path);
|
|
183
182
|
for (const permission of readKeysForCommand(path)) {
|
|
184
183
|
if (levelFor(defaults.settings.permissions ?? {}, permission).level === "deny")
|
|
@@ -38,6 +38,7 @@ export declare const meetingTools: ({
|
|
|
38
38
|
max_read_bytes?: undefined;
|
|
39
39
|
cursor?: undefined;
|
|
40
40
|
} | {
|
|
41
|
+
limit?: undefined;
|
|
41
42
|
event_id?: undefined;
|
|
42
43
|
series_id?: undefined;
|
|
43
44
|
page?: undefined;
|
|
@@ -53,11 +54,11 @@ export declare const meetingTools: ({
|
|
|
53
54
|
format?: undefined;
|
|
54
55
|
transcript_id?: undefined;
|
|
55
56
|
query?: undefined;
|
|
56
|
-
limit?: undefined;
|
|
57
57
|
scan_limit?: undefined;
|
|
58
58
|
max_read_bytes?: undefined;
|
|
59
59
|
cursor?: undefined;
|
|
60
60
|
} | {
|
|
61
|
+
limit?: undefined;
|
|
61
62
|
event_id?: undefined;
|
|
62
63
|
series_id?: undefined;
|
|
63
64
|
page?: undefined;
|
|
@@ -75,11 +76,11 @@ export declare const meetingTools: ({
|
|
|
75
76
|
format?: undefined;
|
|
76
77
|
transcript_id?: undefined;
|
|
77
78
|
query?: undefined;
|
|
78
|
-
limit?: undefined;
|
|
79
79
|
scan_limit?: undefined;
|
|
80
80
|
max_read_bytes?: undefined;
|
|
81
81
|
cursor?: undefined;
|
|
82
82
|
} | {
|
|
83
|
+
limit?: undefined;
|
|
83
84
|
event_id?: undefined;
|
|
84
85
|
series_id?: undefined;
|
|
85
86
|
page?: undefined;
|
|
@@ -101,7 +102,6 @@ export declare const meetingTools: ({
|
|
|
101
102
|
minimum: number;
|
|
102
103
|
};
|
|
103
104
|
query?: undefined;
|
|
104
|
-
limit?: undefined;
|
|
105
105
|
scan_limit?: undefined;
|
|
106
106
|
max_read_bytes?: undefined;
|
|
107
107
|
cursor?: undefined;
|
|
@@ -188,6 +188,7 @@ export declare const meetingTools: ({
|
|
|
188
188
|
max_read_bytes?: undefined;
|
|
189
189
|
cursor?: undefined;
|
|
190
190
|
} | {
|
|
191
|
+
limit?: undefined;
|
|
191
192
|
event_id?: undefined;
|
|
192
193
|
series_id?: undefined;
|
|
193
194
|
page?: undefined;
|
|
@@ -203,11 +204,11 @@ export declare const meetingTools: ({
|
|
|
203
204
|
format?: undefined;
|
|
204
205
|
transcript_id?: undefined;
|
|
205
206
|
query?: undefined;
|
|
206
|
-
limit?: undefined;
|
|
207
207
|
scan_limit?: undefined;
|
|
208
208
|
max_read_bytes?: undefined;
|
|
209
209
|
cursor?: undefined;
|
|
210
210
|
} | {
|
|
211
|
+
limit?: undefined;
|
|
211
212
|
event_id?: undefined;
|
|
212
213
|
series_id?: undefined;
|
|
213
214
|
page?: undefined;
|
|
@@ -225,11 +226,11 @@ export declare const meetingTools: ({
|
|
|
225
226
|
format?: undefined;
|
|
226
227
|
transcript_id?: undefined;
|
|
227
228
|
query?: undefined;
|
|
228
|
-
limit?: undefined;
|
|
229
229
|
scan_limit?: undefined;
|
|
230
230
|
max_read_bytes?: undefined;
|
|
231
231
|
cursor?: undefined;
|
|
232
232
|
} | {
|
|
233
|
+
limit?: undefined;
|
|
233
234
|
event_id?: undefined;
|
|
234
235
|
series_id?: undefined;
|
|
235
236
|
page?: undefined;
|
|
@@ -251,7 +252,6 @@ export declare const meetingTools: ({
|
|
|
251
252
|
minimum: number;
|
|
252
253
|
};
|
|
253
254
|
query?: undefined;
|
|
254
|
-
limit?: undefined;
|
|
255
255
|
scan_limit?: undefined;
|
|
256
256
|
max_read_bytes?: undefined;
|
|
257
257
|
cursor?: undefined;
|
|
@@ -338,6 +338,7 @@ export declare const meetingTools: ({
|
|
|
338
338
|
max_read_bytes?: undefined;
|
|
339
339
|
cursor?: undefined;
|
|
340
340
|
} | {
|
|
341
|
+
limit?: undefined;
|
|
341
342
|
event_id?: undefined;
|
|
342
343
|
series_id?: undefined;
|
|
343
344
|
page?: undefined;
|
|
@@ -353,11 +354,11 @@ export declare const meetingTools: ({
|
|
|
353
354
|
format?: undefined;
|
|
354
355
|
transcript_id?: undefined;
|
|
355
356
|
query?: undefined;
|
|
356
|
-
limit?: undefined;
|
|
357
357
|
scan_limit?: undefined;
|
|
358
358
|
max_read_bytes?: undefined;
|
|
359
359
|
cursor?: undefined;
|
|
360
360
|
} | {
|
|
361
|
+
limit?: undefined;
|
|
361
362
|
event_id?: undefined;
|
|
362
363
|
series_id?: undefined;
|
|
363
364
|
page?: undefined;
|
|
@@ -375,11 +376,11 @@ export declare const meetingTools: ({
|
|
|
375
376
|
format?: undefined;
|
|
376
377
|
transcript_id?: undefined;
|
|
377
378
|
query?: undefined;
|
|
378
|
-
limit?: undefined;
|
|
379
379
|
scan_limit?: undefined;
|
|
380
380
|
max_read_bytes?: undefined;
|
|
381
381
|
cursor?: undefined;
|
|
382
382
|
} | {
|
|
383
|
+
limit?: undefined;
|
|
383
384
|
event_id?: undefined;
|
|
384
385
|
series_id?: undefined;
|
|
385
386
|
page?: undefined;
|
|
@@ -401,7 +402,6 @@ export declare const meetingTools: ({
|
|
|
401
402
|
minimum: number;
|
|
402
403
|
};
|
|
403
404
|
query?: undefined;
|
|
404
|
-
limit?: undefined;
|
|
405
405
|
scan_limit?: undefined;
|
|
406
406
|
max_read_bytes?: undefined;
|
|
407
407
|
cursor?: undefined;
|
|
@@ -488,6 +488,7 @@ export declare const meetingTools: ({
|
|
|
488
488
|
max_read_bytes?: undefined;
|
|
489
489
|
cursor?: undefined;
|
|
490
490
|
} | {
|
|
491
|
+
limit?: undefined;
|
|
491
492
|
event_id?: undefined;
|
|
492
493
|
series_id?: undefined;
|
|
493
494
|
page?: undefined;
|
|
@@ -503,11 +504,11 @@ export declare const meetingTools: ({
|
|
|
503
504
|
format?: undefined;
|
|
504
505
|
transcript_id?: undefined;
|
|
505
506
|
query?: undefined;
|
|
506
|
-
limit?: undefined;
|
|
507
507
|
scan_limit?: undefined;
|
|
508
508
|
max_read_bytes?: undefined;
|
|
509
509
|
cursor?: undefined;
|
|
510
510
|
} | {
|
|
511
|
+
limit?: undefined;
|
|
511
512
|
event_id?: undefined;
|
|
512
513
|
series_id?: undefined;
|
|
513
514
|
page?: undefined;
|
|
@@ -525,11 +526,11 @@ export declare const meetingTools: ({
|
|
|
525
526
|
format?: undefined;
|
|
526
527
|
transcript_id?: undefined;
|
|
527
528
|
query?: undefined;
|
|
528
|
-
limit?: undefined;
|
|
529
529
|
scan_limit?: undefined;
|
|
530
530
|
max_read_bytes?: undefined;
|
|
531
531
|
cursor?: undefined;
|
|
532
532
|
} | {
|
|
533
|
+
limit?: undefined;
|
|
533
534
|
event_id?: undefined;
|
|
534
535
|
series_id?: undefined;
|
|
535
536
|
page?: undefined;
|
|
@@ -551,7 +552,6 @@ export declare const meetingTools: ({
|
|
|
551
552
|
minimum: number;
|
|
552
553
|
};
|
|
553
554
|
query?: undefined;
|
|
554
|
-
limit?: undefined;
|
|
555
555
|
scan_limit?: undefined;
|
|
556
556
|
max_read_bytes?: undefined;
|
|
557
557
|
cursor?: undefined;
|
|
@@ -638,6 +638,7 @@ export declare const meetingTools: ({
|
|
|
638
638
|
max_read_bytes?: undefined;
|
|
639
639
|
cursor?: undefined;
|
|
640
640
|
} | {
|
|
641
|
+
limit?: undefined;
|
|
641
642
|
event_id?: undefined;
|
|
642
643
|
series_id?: undefined;
|
|
643
644
|
page?: undefined;
|
|
@@ -653,11 +654,11 @@ export declare const meetingTools: ({
|
|
|
653
654
|
format?: undefined;
|
|
654
655
|
transcript_id?: undefined;
|
|
655
656
|
query?: undefined;
|
|
656
|
-
limit?: undefined;
|
|
657
657
|
scan_limit?: undefined;
|
|
658
658
|
max_read_bytes?: undefined;
|
|
659
659
|
cursor?: undefined;
|
|
660
660
|
} | {
|
|
661
|
+
limit?: undefined;
|
|
661
662
|
event_id?: undefined;
|
|
662
663
|
series_id?: undefined;
|
|
663
664
|
page?: undefined;
|
|
@@ -675,11 +676,11 @@ export declare const meetingTools: ({
|
|
|
675
676
|
format?: undefined;
|
|
676
677
|
transcript_id?: undefined;
|
|
677
678
|
query?: undefined;
|
|
678
|
-
limit?: undefined;
|
|
679
679
|
scan_limit?: undefined;
|
|
680
680
|
max_read_bytes?: undefined;
|
|
681
681
|
cursor?: undefined;
|
|
682
682
|
} | {
|
|
683
|
+
limit?: undefined;
|
|
683
684
|
event_id?: undefined;
|
|
684
685
|
series_id?: undefined;
|
|
685
686
|
page?: undefined;
|
|
@@ -701,7 +702,6 @@ export declare const meetingTools: ({
|
|
|
701
702
|
minimum: number;
|
|
702
703
|
};
|
|
703
704
|
query?: undefined;
|
|
704
|
-
limit?: undefined;
|
|
705
705
|
scan_limit?: undefined;
|
|
706
706
|
max_read_bytes?: undefined;
|
|
707
707
|
cursor?: undefined;
|
package/dist/parity/manifest.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MOVED_TO_MEMO } from "../cli/moved.js";
|
|
2
1
|
export const longName = (flags) => flags.split(/[\s,|]+/).find((part) => part.startsWith("--")) ?? flags;
|
|
3
2
|
const presence = (entry) => (typeof entry === "string" ? { in: entry } : entry);
|
|
4
3
|
/** `true` the CLI must have it, `false` it must not, `undefined` it is planned and either passes. */
|
|
@@ -93,9 +92,6 @@ export const manifestProblems = (manifest) => {
|
|
|
93
92
|
}
|
|
94
93
|
optionEntries(path, row.options ?? {});
|
|
95
94
|
}
|
|
96
|
-
for (const path of Object.keys(manifest.commands))
|
|
97
|
-
if (Object.keys(MOVED_TO_MEMO).some((moved) => path === moved || path.startsWith(`${moved} `)))
|
|
98
|
-
problems.push(`${path}: moved to memo (src/cli/moved.ts), so a source tool has no row for it`);
|
|
99
95
|
for (const [name, option] of Object.entries(manifest.options)) {
|
|
100
96
|
if (!option.meaning)
|
|
101
97
|
problems.push(`options ${name}: no meaning`);
|
package/dist/sends/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { type FloodDeadline, FloodMemory, type FloodState, FROZEN_HOLD_MS, flood
|
|
|
3
3
|
export { type Asker, type GuardRequest, guardFor, type SendGuard, type SendGuardOptions, sendGuard, sharedJournal, } from "./guard.js";
|
|
4
4
|
export { currentOperation, guardedWrite, type Operated } from "./guarded.js";
|
|
5
5
|
export { type AccountAction, type ChatAction, type SendEntry, SendJournal, type SendKind, type SendOutcome, sendsPathFor, } from "./journal.js";
|
|
6
|
-
export {
|
|
6
|
+
export { CEILING_KEY, DEFAULT_PERMISSIONS, keyForCommand, keyForWrite, LEVELS, type Level, layerPermissions, levelFor, type PermissionKey, permissionOverrides, readKeysForCommand, skipFlagFor, WRITE_KEYS, } from "./permissions.js";
|
|
7
7
|
export { type Recipient, RecipientList, recipientsPathFor } from "./recipients.js";
|
|
8
8
|
export { newOperationId, newSendId } from "./send-id.js";
|
|
9
9
|
export { MAX_BUFFERED_UPLOAD_BYTES, readUpload, refusedPlace, uploadBlob, uploadBytes, uploadSize, } from "./upload.js";
|
package/dist/sends/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { FloodMemory, FROZEN_HOLD_MS, floodPathFor, LIMITED_HOLD_MS, } from "./f
|
|
|
2
2
|
export { guardFor, sendGuard, sharedJournal, } from "./guard.js";
|
|
3
3
|
export { currentOperation, guardedWrite } from "./guarded.js";
|
|
4
4
|
export { SendJournal, sendsPathFor, } from "./journal.js";
|
|
5
|
-
export {
|
|
5
|
+
export { CEILING_KEY, DEFAULT_PERMISSIONS, keyForCommand, keyForWrite, LEVELS, layerPermissions, levelFor, permissionOverrides, readKeysForCommand, skipFlagFor, WRITE_KEYS, } from "./permissions.js";
|
|
6
6
|
export { RecipientList, recipientsPathFor } from "./recipients.js";
|
|
7
7
|
export { newOperationId, newSendId } from "./send-id.js";
|
|
8
8
|
export { MAX_BUFFERED_UPLOAD_BYTES, readUpload, refusedPlace, uploadBlob, uploadBytes, uploadSize, } from "./upload.js";
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import type { AccountAction, ChatAction, SendKind } from "./journal.js";
|
|
2
|
-
/**
|
|
3
|
-
* What a profile may be allowed to do (max-cli `CLI-37`, `NEED-251`). One name per thing the owner would
|
|
4
|
-
* recognise, so `sessions` — which logs the owner out of their phone — never rides along with
|
|
5
|
-
* adding a contact. There is no `*`: "everything" is not setting `allow` at all, and a wildcard
|
|
6
|
-
* would switch on `delete` without anyone naming it.
|
|
7
|
-
*/
|
|
8
|
-
export declare const PERMISSIONS: readonly ["send", "forward", "reaction", "edit", "pin", "read", "delete", "groups", "contacts", "profile", "folders", "sessions"];
|
|
9
|
-
export type Permission = (typeof PERMISSIONS)[number];
|
|
10
|
-
export declare const permissionFor: (kind: SendKind, action?: string) => Permission;
|
|
11
2
|
/** What a profile may do with one command path — the standard's "Permissions". */
|
|
12
3
|
export declare const LEVELS: readonly ["deny", "readonly", "ask", "allow"];
|
|
13
4
|
export type Level = (typeof LEVELS)[number];
|
|
@@ -32,8 +23,6 @@ export declare const isBotApi: (path: readonly string[]) => boolean;
|
|
|
32
23
|
export declare const botApiAllowed: (levels: Readonly<Record<PermissionKey, Level>>) => boolean;
|
|
33
24
|
/** The resources at the top of the command tree, which `readOnly` and `allow` turn read-only as a whole. */
|
|
34
25
|
export declare const RESOURCES: readonly ["messages", "drafts", "reactions", "polls", "topics", "chats", "contacts", "account", "bot", "conversations", "tags", "mentions", "search", "searches", "tasks", "replies", "attachments", "stats", "store", "metadata", "mcp", "server", "models", "schedule", "doctor", "images"];
|
|
35
|
-
/** The command path an old `allow` word stood for, as one key — what an MCP tool's `permission` is checked against. */
|
|
36
|
-
export declare const keyOfWord: (word: Permission) => PermissionKey;
|
|
37
26
|
/**
|
|
38
27
|
* Layers come nearest first. A key a nearer layer sets hides that key and every key under it in the
|
|
39
28
|
* farther layers, so a profile's `messages: readonly` is not undone by `messages.delete: allow` in
|
|
@@ -67,8 +56,6 @@ export declare const writeOfKey: (key: PermissionKey) => {
|
|
|
67
56
|
};
|
|
68
57
|
/** Every key a write is checked against that a command path may not spell out. */
|
|
69
58
|
export declare const WRITE_KEYS: readonly PermissionKey[];
|
|
70
|
-
/** Statistics and searches moved; a deny under an old path would stop applying unseen, so the command refuses. */
|
|
71
|
-
export declare const assertStatsPermissionsCurrent: (path: readonly string[], permissions: Readonly<Record<string, Level>>) => void;
|
|
72
59
|
export declare const readKeysForCommand: (path: readonly string[]) => PermissionKey[];
|
|
73
60
|
/**
|
|
74
61
|
* The key a command path is checked against: `null` for housekeeping, which no level stops, and
|
|
@@ -1,66 +1,4 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import { canonicalPermissionKey, canonicalPermissions } from "./permission-aliases.js";
|
|
3
|
-
/**
|
|
4
|
-
* What a profile may be allowed to do (max-cli `CLI-37`, `NEED-251`). One name per thing the owner would
|
|
5
|
-
* recognise, so `sessions` — which logs the owner out of their phone — never rides along with
|
|
6
|
-
* adding a contact. There is no `*`: "everything" is not setting `allow` at all, and a wildcard
|
|
7
|
-
* would switch on `delete` without anyone naming it.
|
|
8
|
-
*/
|
|
9
|
-
export const PERMISSIONS = [
|
|
10
|
-
"send",
|
|
11
|
-
"forward",
|
|
12
|
-
"reaction",
|
|
13
|
-
"edit",
|
|
14
|
-
"pin",
|
|
15
|
-
"read",
|
|
16
|
-
"delete",
|
|
17
|
-
"groups",
|
|
18
|
-
"contacts",
|
|
19
|
-
"profile",
|
|
20
|
-
"folders",
|
|
21
|
-
"sessions",
|
|
22
|
-
];
|
|
23
|
-
const ACCOUNT = {
|
|
24
|
-
"contact-add": "contacts",
|
|
25
|
-
"contact-remove": "contacts",
|
|
26
|
-
"contact-import": "contacts",
|
|
27
|
-
"contact-rename": "contacts",
|
|
28
|
-
"contact-block": "contacts",
|
|
29
|
-
"contact-unblock": "contacts",
|
|
30
|
-
profile: "profile",
|
|
31
|
-
"folder-create": "folders",
|
|
32
|
-
"folder-update": "folders",
|
|
33
|
-
"folder-delete": "folders",
|
|
34
|
-
"folder-order": "folders",
|
|
35
|
-
"folder-join": "folders",
|
|
36
|
-
"sessions-end": "sessions",
|
|
37
|
-
"chat-mute": "profile",
|
|
38
|
-
"chat-unmute": "profile",
|
|
39
|
-
"chat-archive": "profile",
|
|
40
|
-
"chat-unarchive": "profile",
|
|
41
|
-
"chat-pin": "profile",
|
|
42
|
-
"chat-unpin": "profile",
|
|
43
|
-
"chat-mark-unread": "profile",
|
|
44
|
-
"message-star": "profile",
|
|
45
|
-
"message-unstar": "profile",
|
|
46
|
-
privacy: "profile",
|
|
47
|
-
};
|
|
48
|
-
export const permissionFor = (kind, action) => {
|
|
49
|
-
switch (kind) {
|
|
50
|
-
case "message":
|
|
51
|
-
return "send";
|
|
52
|
-
case "chat":
|
|
53
|
-
return "groups";
|
|
54
|
-
case "account": {
|
|
55
|
-
const permission = ACCOUNT[action];
|
|
56
|
-
if (!permission)
|
|
57
|
-
throw new Error(`an account change without a known action: ${action}`);
|
|
58
|
-
return permission;
|
|
59
|
-
}
|
|
60
|
-
default:
|
|
61
|
-
return kind;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
2
|
/** What a profile may do with one command path — the standard's "Permissions". */
|
|
65
3
|
export const LEVELS = ["deny", "readonly", "ask", "allow"];
|
|
66
4
|
/** The deletions nobody gets back: the word that skips their question is `--allow-dangerous`, never `--yes`. */
|
|
@@ -148,47 +86,6 @@ export const RESOURCES = [
|
|
|
148
86
|
"doctor",
|
|
149
87
|
"images",
|
|
150
88
|
];
|
|
151
|
-
const OLD_WORDS = {
|
|
152
|
-
send: ["messages.send", "polls.create", "chats.start"],
|
|
153
|
-
forward: ["messages.forward"],
|
|
154
|
-
reaction: ["reactions", "polls.vote", "messages.press", "chats.app"],
|
|
155
|
-
edit: ["messages.edit", "polls.close"],
|
|
156
|
-
pin: ["messages.pin", "messages.unpin"],
|
|
157
|
-
read: ["chats.mark-read"],
|
|
158
|
-
delete: ["messages.delete", "chats.delete", "chats.clear"],
|
|
159
|
-
groups: [
|
|
160
|
-
"chats.create",
|
|
161
|
-
"chats.update",
|
|
162
|
-
"chats.join",
|
|
163
|
-
"chats.leave",
|
|
164
|
-
"chats.members",
|
|
165
|
-
"chats.admins",
|
|
166
|
-
"chats.links",
|
|
167
|
-
"chats.requests",
|
|
168
|
-
"chats.moderate",
|
|
169
|
-
"topics.enable",
|
|
170
|
-
"topics.create",
|
|
171
|
-
"topics.edit",
|
|
172
|
-
"topics.delete",
|
|
173
|
-
],
|
|
174
|
-
contacts: ["contacts"],
|
|
175
|
-
profile: ["account.update", "account.privacy.set", "chats.mute", "messages.star", "messages.unstar"],
|
|
176
|
-
folders: ["chats.folders"],
|
|
177
|
-
sessions: ["account.sessions.end"],
|
|
178
|
-
};
|
|
179
|
-
/** The command path an old `allow` word stood for, as one key — what an MCP tool's `permission` is checked against. */
|
|
180
|
-
export const keyOfWord = (word) => OLD_WORDS[word][0];
|
|
181
|
-
/**
|
|
182
|
-
* A bot's old words meant its own writes: `profile` was its command menu, and `read` was taking
|
|
183
|
-
* updates, which every level but `deny` allows now.
|
|
184
|
-
*/
|
|
185
|
-
const botKeysOf = (word) => {
|
|
186
|
-
if (word === "profile")
|
|
187
|
-
return ["bot.commands"];
|
|
188
|
-
if (word === "read")
|
|
189
|
-
return [];
|
|
190
|
-
return OLD_WORDS[word].map((key) => `bot.${key}`);
|
|
191
|
-
};
|
|
192
89
|
/**
|
|
193
90
|
* Layers come nearest first. A key a nearer layer sets hides that key and every key under it in the
|
|
194
91
|
* farther layers, so a profile's `messages: readonly` is not undone by `messages.delete: allow` in
|
|
@@ -199,7 +96,7 @@ export const layerPermissions = (layers) => {
|
|
|
199
96
|
const sources = {};
|
|
200
97
|
for (const [from, layer] of layers) {
|
|
201
98
|
const nearer = Object.keys(levels);
|
|
202
|
-
for (const [key, level] of Object.entries(
|
|
99
|
+
for (const [key, level] of Object.entries(layer ?? {})) {
|
|
203
100
|
if (nearer.some((named) => key === named || key.startsWith(`${named}.`)))
|
|
204
101
|
continue;
|
|
205
102
|
levels[key] = level;
|
|
@@ -224,11 +121,6 @@ const nearest = (levels, key) => {
|
|
|
224
121
|
}
|
|
225
122
|
return undefined;
|
|
226
123
|
};
|
|
227
|
-
/**
|
|
228
|
-
* `chats unmute` was checked as `chats.mute` before it had its own key; a config that names only the old key
|
|
229
|
-
* keeps meaning it, so a `chats.mute: readonly` written then still stops an unmute.
|
|
230
|
-
*/
|
|
231
|
-
const FORMER_KEYS = { "chats.unmute": "chats.mute" };
|
|
232
124
|
/**
|
|
233
125
|
* The most specific key the owner set wins. A built-in default (`DEFAULT_PERMISSIONS`) only ever
|
|
234
126
|
* tightens: against a broader key of the owner's, the stricter of the two holds — so
|
|
@@ -236,16 +128,11 @@ const FORMER_KEYS = { "chats.unmute": "chats.mute" };
|
|
|
236
128
|
* A path nothing names is allowed.
|
|
237
129
|
*/
|
|
238
130
|
export const levelFor = (permissions, key, defaults = DEFAULT_PERMISSIONS) => {
|
|
239
|
-
permissions = canonicalPermissions(permissions);
|
|
240
|
-
key = canonicalPermissionKey(key);
|
|
241
131
|
const found = profileLevel(permissions, key, defaults);
|
|
242
132
|
const ceiling = permissions[CEILING_KEY];
|
|
243
133
|
return ceiling && ORDER[ceiling] < ORDER[found.level] ? { level: ceiling, key: CEILING_KEY } : found;
|
|
244
134
|
};
|
|
245
135
|
const profileLevel = (permissions, key, defaults) => {
|
|
246
|
-
const former = FORMER_KEYS[key];
|
|
247
|
-
if (former !== undefined && permissions[key] === undefined)
|
|
248
|
-
return profileLevel(permissions, former, defaults);
|
|
249
136
|
const own = nearest(permissions, key);
|
|
250
137
|
const builtIn = nearest(defaults, key);
|
|
251
138
|
if (!builtIn || (own && own.depth >= builtIn.depth))
|
|
@@ -254,7 +141,15 @@ const profileLevel = (permissions, key, defaults) => {
|
|
|
254
141
|
return { level: builtIn.level, key: builtIn.key };
|
|
255
142
|
return { level: own.level, key: own.key };
|
|
256
143
|
};
|
|
257
|
-
const CHAT_KEYS = {
|
|
144
|
+
const CHAT_KEYS = {
|
|
145
|
+
settings: "chats.update",
|
|
146
|
+
"requests.accept": "chats.requests.confirm",
|
|
147
|
+
"requests.decline": "chats.requests.reject",
|
|
148
|
+
"link.create": "chats.links.create",
|
|
149
|
+
"link.reset": "chats.links.reset",
|
|
150
|
+
"link.revoke": "chats.links.remove",
|
|
151
|
+
"link.update": "chats.links.update",
|
|
152
|
+
};
|
|
258
153
|
const ACCOUNT_KEYS = {
|
|
259
154
|
"contact-add": "contacts.add",
|
|
260
155
|
"contact-remove": "contacts.remove",
|
|
@@ -292,7 +187,7 @@ const KIND_KEYS = {
|
|
|
292
187
|
/** The command path a guarded write belongs to, when the caller did not name it. */
|
|
293
188
|
export const keyForWrite = (kind, action) => {
|
|
294
189
|
if (kind === "chat")
|
|
295
|
-
return
|
|
190
|
+
return CHAT_KEYS[action] ?? `chats.${action ?? "update"}`;
|
|
296
191
|
if (kind === "account") {
|
|
297
192
|
const key = ACCOUNT_KEYS[action];
|
|
298
193
|
if (!key)
|
|
@@ -303,7 +198,6 @@ export const keyForWrite = (kind, action) => {
|
|
|
303
198
|
};
|
|
304
199
|
/** `keyForWrite` read backwards, as far as a command's key says it: an unpin is a `pin`, a chat change names its action. */
|
|
305
200
|
export const writeOfKey = (key) => {
|
|
306
|
-
key = canonicalPermissionKey(key);
|
|
307
201
|
const account = Object.entries(ACCOUNT_KEYS).find(([, named]) => named === key)?.[0];
|
|
308
202
|
if (account)
|
|
309
203
|
return { kind: "account", action: account };
|
|
@@ -399,8 +293,7 @@ export const WRITE_KEYS = [
|
|
|
399
293
|
...Object.values(KIND_KEYS),
|
|
400
294
|
...Object.values(ACCOUNT_KEYS),
|
|
401
295
|
...Object.values(CHAT_KEYS),
|
|
402
|
-
|
|
403
|
-
].map(canonicalPermissionKey)),
|
|
296
|
+
]),
|
|
404
297
|
];
|
|
405
298
|
/** Commands that look after the tool and its files and never show a message: no level stops them. */
|
|
406
299
|
const HOUSEKEEPING = new Set([
|
|
@@ -430,21 +323,6 @@ const BOT_HOUSEKEEPING = new Set(["auth", "list", "sends", "recipients", "mcp"])
|
|
|
430
323
|
const STORE_MAINTENANCE = new Set(["info", "check", "copies"]);
|
|
431
324
|
/** Commands outside `messages` that print what people wrote, so `deny messages` reaches them too. */
|
|
432
325
|
const SHOW_MESSAGES = new Set(["inbox", "review", "watch", "serve", "store", "conversations"]);
|
|
433
|
-
/** Before every search moved under `search` (2026-10-09). */
|
|
434
|
-
const OLD_SEARCH_KEY = /^(bot\.)?(messages|conversations|topics)\.search(?:\.|$)/;
|
|
435
|
-
/** Statistics and searches moved; a deny under an old path would stop applying unseen, so the command refuses. */
|
|
436
|
-
export const assertStatsPermissionsCurrent = (path, permissions) => {
|
|
437
|
-
if (path[0] === "bot") {
|
|
438
|
-
assertStatsPermissionsCurrent(path.slice(1), permissions);
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
if (path[0] === "search" && Object.keys(permissions).some((key) => OLD_SEARCH_KEY.test(key)))
|
|
442
|
-
throw new CliError("configuration_error", "search permission paths have moved — rename messages.search, conversations.search and topics.search to search.messages, search.conversations and search.topics", { retryable: false });
|
|
443
|
-
if (path[0] !== "stats")
|
|
444
|
-
return;
|
|
445
|
-
if (Object.keys(permissions).some((key) => /^(bot\.)?(messages|chats|tasks)\.stats(?:\.|$)/.test(key)))
|
|
446
|
-
throw new CliError("configuration_error", "statistics permission paths have moved — rename messages.stats, chats.stats and tasks.stats to stats.messages.show, stats.chats.show and stats.tasks.show", { retryable: false });
|
|
447
|
-
};
|
|
448
326
|
export const readKeysForCommand = (path) => {
|
|
449
327
|
if (path[0] === "bot")
|
|
450
328
|
return readKeysForCommand(path.slice(1)).map((key) => `bot.${key}`);
|
|
@@ -488,7 +366,6 @@ export const readKeysForCommand = (path) => {
|
|
|
488
366
|
export const keyForCommand = (path) => {
|
|
489
367
|
if (path.length === 0)
|
|
490
368
|
return null;
|
|
491
|
-
path = canonicalPermissionKey(path.join(".")).split(".");
|
|
492
369
|
const [top, next] = path;
|
|
493
370
|
if (top === "bot") {
|
|
494
371
|
if (next === undefined || BOT_HOUSEKEEPING.has(next))
|
|
@@ -500,7 +377,7 @@ export const keyForCommand = (path) => {
|
|
|
500
377
|
return path.join(".");
|
|
501
378
|
if (top === undefined || HOUSEKEEPING.has(top) || (top === "search" && next === "runs"))
|
|
502
379
|
return null;
|
|
503
|
-
//
|
|
380
|
+
// A model is housekeeping wherever it is listed.
|
|
504
381
|
if (top === "images" && next === "models")
|
|
505
382
|
return null;
|
|
506
383
|
if (top === "attachments" && (next === "check" || next === "jobs"))
|
|
@@ -513,7 +390,7 @@ export const keyForCommand = (path) => {
|
|
|
513
390
|
if (top === "conversations" && next === "links")
|
|
514
391
|
return path[2] === "rebuild" ? "conversations.links.rebuild" : "conversations.links";
|
|
515
392
|
// Vectors are written to the local store only, and the text never leaves the machine (phase 5 E10).
|
|
516
|
-
if ((top === "conversations" && next === "embeddings") ||
|
|
393
|
+
if ((top === "conversations" && (next === "embeddings" || next === "embed")) ||
|
|
517
394
|
(top === "images" && next === "embed") ||
|
|
518
395
|
(top === "conversations" && next === "rebuild"))
|
|
519
396
|
return "conversations.embeddings";
|
|
@@ -526,8 +403,6 @@ export const keyForCommand = (path) => {
|
|
|
526
403
|
return next === "rebuild" || next === "confirm" || next === "reject" ? `mentions.${next}` : "messages";
|
|
527
404
|
if (top === "store" && (next === "gaps" || next === "jobs"))
|
|
528
405
|
return path.join(".");
|
|
529
|
-
if (top === "messages" && next === "sync")
|
|
530
|
-
return "messages";
|
|
531
406
|
if (SHOW_MESSAGES.has(top) || (top === "contacts" && (next === "context" || next === "prepare" || next === "events")))
|
|
532
407
|
return "messages";
|
|
533
408
|
if (RESOURCES.includes(top))
|
|
@@ -544,12 +419,10 @@ export const permissionOverrides = (entries = []) => {
|
|
|
544
419
|
throw new CliError("validation_error", "--permission takes a command path and level, e.g. messages.send=allow (deny, readonly, ask, allow)");
|
|
545
420
|
levels[key] = level;
|
|
546
421
|
}
|
|
547
|
-
return
|
|
422
|
+
return levels;
|
|
548
423
|
};
|
|
549
424
|
/** No startup flag grants access: an override may narrow the profile's level, never lift it or a key under it. */
|
|
550
425
|
export const assertOverridesTighten = (overrides, profile) => {
|
|
551
|
-
overrides = canonicalPermissions(overrides);
|
|
552
|
-
profile = canonicalPermissions(profile);
|
|
553
426
|
for (const [key, level] of Object.entries(overrides)) {
|
|
554
427
|
const under = Object.keys(profile).filter((named) => named.startsWith(`${key}.`));
|
|
555
428
|
const lifted = [key, ...under].find((named) => ORDER[level] > ORDER[levelFor(profile, named).level]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.421.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/dist/cli/moved.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import type { Command } from "commander";
|
|
3
|
-
/**
|
|
4
|
-
* Commands a source tool no longer has, each with the memo command that does the job
|
|
5
|
-
* (docs/dev/TOOL-BOUNDARIES.md). The CLI and the MCP server answer with the pointer instead of
|
|
6
|
-
* "unknown command"; a path the program still mounts never reaches it.
|
|
7
|
-
*/
|
|
8
|
-
export declare const MOVED_TO_MEMO: Readonly<Record<string, {
|
|
9
|
-
what: string;
|
|
10
|
-
memo: string;
|
|
11
|
-
}>>;
|
|
12
|
-
/** Retired spellings are guidance only; none is mounted as a command alias. */
|
|
13
|
-
export declare const RENAMED_COMMANDS: Readonly<Record<string, string>>;
|
|
14
|
-
export declare const movedPointer: (path: string) => string | undefined;
|
|
15
|
-
/** The longest moved path the words start with, unless the program still has it. */
|
|
16
|
-
export declare const movedPath: (words: readonly string[], has: (path: string) => boolean) => string | undefined;
|
|
17
|
-
/** The pointer for a moved or renamed path in `args`, for a CLI that parses without `run`. */
|
|
18
|
-
export declare const movedCommandError: (program: Command, args: readonly string[]) => CliError | undefined;
|
package/dist/cli/moved.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import { commandAt } from "./steps.js";
|
|
3
|
-
/**
|
|
4
|
-
* Commands a source tool no longer has, each with the memo command that does the job
|
|
5
|
-
* (docs/dev/TOOL-BOUNDARIES.md). The CLI and the MCP server answer with the pointer instead of
|
|
6
|
-
* "unknown command"; a path the program still mounts never reaches it.
|
|
7
|
-
*/
|
|
8
|
-
export const MOVED_TO_MEMO = {
|
|
9
|
-
"search mail": { what: "mail is searched by the separate memo CLI", memo: "memo search mail …" },
|
|
10
|
-
};
|
|
11
|
-
/** Retired spellings are guidance only; none is mounted as a command alias. */
|
|
12
|
-
export const RENAMED_COMMANDS = {
|
|
13
|
-
"contacts alias rm": "contacts aliases remove",
|
|
14
|
-
"contacts alias": "contacts aliases",
|
|
15
|
-
"contacts profile": "contacts info",
|
|
16
|
-
"contacts timeline": "contacts events",
|
|
17
|
-
"chats link revoke": "chats links remove",
|
|
18
|
-
"chats link": "chats links",
|
|
19
|
-
"chats members audit": "chats members check",
|
|
20
|
-
"chats requests accept": "chats requests confirm",
|
|
21
|
-
"chats requests decline": "chats requests reject",
|
|
22
|
-
"metadata get": "metadata show",
|
|
23
|
-
"metadata refresh": "metadata sync",
|
|
24
|
-
"tasks plan": "tasks update",
|
|
25
|
-
"tags auto": "tags rebuild",
|
|
26
|
-
"attachments text set": "attachments update",
|
|
27
|
-
"conversations build": "conversations links rebuild",
|
|
28
|
-
"conversations embed status": "conversations embeddings status",
|
|
29
|
-
"conversations embed clear": "conversations embeddings clear",
|
|
30
|
-
"conversations batches next": "conversations batches show",
|
|
31
|
-
"conversations consents revoke": "conversations consents remove",
|
|
32
|
-
"doctor report create": "doctor reports create",
|
|
33
|
-
"doctor report": "doctor reports show",
|
|
34
|
-
"mcp setup": "mcp add",
|
|
35
|
-
"mcp doctor": "mcp check",
|
|
36
|
-
"commands schema": "commands info",
|
|
37
|
-
"bot store fetch": "bot messages sync",
|
|
38
|
-
"store gaps plan": "store gaps show",
|
|
39
|
-
"store reindex": "store rebuild",
|
|
40
|
-
"stats messages counters refresh": "stats messages counters sync",
|
|
41
|
-
"models text key": "models keys",
|
|
42
|
-
"models audio list": "models list kind:audio",
|
|
43
|
-
"models text list": "models list kind:text",
|
|
44
|
-
"models audio download": "models download",
|
|
45
|
-
"models text download": "models download",
|
|
46
|
-
};
|
|
47
|
-
export const movedPointer = (path) => {
|
|
48
|
-
const renamed = RENAMED_COMMANDS[path];
|
|
49
|
-
if (renamed)
|
|
50
|
-
return `use \`${renamed}\``;
|
|
51
|
-
const moved = MOVED_TO_MEMO[path];
|
|
52
|
-
return moved && `${moved.what}: install @wirecat/cli-memo, then \`${moved.memo}\``;
|
|
53
|
-
};
|
|
54
|
-
/** The longest moved path the words start with, unless the program still has it. */
|
|
55
|
-
export const movedPath = (words, has) => [...Object.keys(MOVED_TO_MEMO), ...Object.keys(RENAMED_COMMANDS)]
|
|
56
|
-
.filter((path) => path.split(" ").every((word, at) => words[at] === word))
|
|
57
|
-
.sort((a, b) => b.length - a.length)
|
|
58
|
-
.find((path) => !has(path));
|
|
59
|
-
const mountedOrArgument = (program, path) => {
|
|
60
|
-
const words = path.split(" ");
|
|
61
|
-
return words.some((_, at) => {
|
|
62
|
-
const command = commandAt(program, words.slice(0, at + 1).join(" "));
|
|
63
|
-
return command !== undefined && (at === words.length - 1 || command.commands.length === 0);
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
/** The pointer for a moved or renamed path in `args`, for a CLI that parses without `run`. */
|
|
67
|
-
export const movedCommandError = (program, args) => {
|
|
68
|
-
const moved = movedPath(args.filter((word) => !word.startsWith("-")), (path) => mountedOrArgument(program, path));
|
|
69
|
-
return moved === undefined
|
|
70
|
-
? undefined
|
|
71
|
-
: new CliError("validation_error", `\`${program.name()} ${moved}\` is not here — ${movedPointer(moved)}`);
|
|
72
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Level } from "./permissions.js";
|
|
2
|
-
/** Canonical names for internal permission keys; saved moved paths are refused below. */
|
|
3
|
-
export declare const canonicalPermissionKey: (key: string) => string;
|
|
4
|
-
/** WC-PERM-8: a moved saved path must name the replacement before any command runs. */
|
|
5
|
-
export declare const canonicalPermissions: (levels: Readonly<Record<string, Level>>) => Record<string, Level>;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
const RENAMED = [
|
|
3
|
-
["models.audio.download", "models.download"],
|
|
4
|
-
["models.text.download", "models.download"],
|
|
5
|
-
["models.text.key", "models.keys"],
|
|
6
|
-
["models.audio", "models"],
|
|
7
|
-
["models.text", "models"],
|
|
8
|
-
["doctor.report", "doctor.reports"],
|
|
9
|
-
["contacts.aliases.rm", "contacts.aliases.remove"],
|
|
10
|
-
["contacts.alias.rm", "contacts.aliases.remove"],
|
|
11
|
-
["contacts.alias", "contacts.aliases"],
|
|
12
|
-
["contacts.profile", "contacts.info"],
|
|
13
|
-
["contacts.timeline", "contacts.events"],
|
|
14
|
-
["chats.links.revoke", "chats.links.remove"],
|
|
15
|
-
["chats.link.revoke", "chats.links.remove"],
|
|
16
|
-
["chats.link", "chats.links"],
|
|
17
|
-
["chats.members.audit", "chats.members.check"],
|
|
18
|
-
["chats.requests.accept", "chats.requests.confirm"],
|
|
19
|
-
["chats.requests.decline", "chats.requests.reject"],
|
|
20
|
-
["metadata.get", "metadata.show"],
|
|
21
|
-
["metadata.refresh", "metadata.sync"],
|
|
22
|
-
["tasks.plan", "tasks.update"],
|
|
23
|
-
["tags.auto", "tags.rebuild"],
|
|
24
|
-
["attachments.text.set", "attachments.update"],
|
|
25
|
-
["attachments.text", "attachments.update"],
|
|
26
|
-
["conversations.build", "conversations.links.rebuild"],
|
|
27
|
-
["conversations.embed", "conversations.embeddings"],
|
|
28
|
-
["conversations.batches.next", "conversations.batches.show"],
|
|
29
|
-
["conversations.consents.revoke", "conversations.consents.remove"],
|
|
30
|
-
["stats.messages.counters.refresh", "stats.messages.counters.sync"],
|
|
31
|
-
["store.fetch", "messages.sync"],
|
|
32
|
-
["store.gaps.plan", "store.gaps.show"],
|
|
33
|
-
["store.reindex", "store.rebuild"],
|
|
34
|
-
];
|
|
35
|
-
/** Canonical names for internal permission keys; saved moved paths are refused below. */
|
|
36
|
-
export const canonicalPermissionKey = (key) => {
|
|
37
|
-
if (key.startsWith("bot."))
|
|
38
|
-
return `bot.${canonicalPermissionKey(key.slice(4))}`;
|
|
39
|
-
const renamed = RENAMED.find(([old]) => key === old || key.startsWith(`${old}.`));
|
|
40
|
-
return renamed ? renamed[1] + key.slice(renamed[0].length) : key;
|
|
41
|
-
};
|
|
42
|
-
/** WC-PERM-8: a moved saved path must name the replacement before any command runs. */
|
|
43
|
-
export const canonicalPermissions = (levels) => {
|
|
44
|
-
for (const key of Object.keys(levels)) {
|
|
45
|
-
const canonical = canonicalPermissionKey(key);
|
|
46
|
-
if (key !== canonical)
|
|
47
|
-
throw new CliError("configuration_error", `permission path moved — rename permissions.${key} to permissions.${canonical}`, { permission: key, replacement: canonical, retryable: false });
|
|
48
|
-
}
|
|
49
|
-
return { ...levels };
|
|
50
|
-
};
|