@wirecat/cli-core 0.647.0 → 0.648.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 +85 -0
- package/dist/cli/account-remove.d.ts +5 -0
- package/dist/cli/account-remove.js +6 -1
- package/dist/cli/app-doctor-command.js +15 -57
- package/dist/cli/app-store.d.ts +12 -0
- package/dist/cli/app-store.js +25 -0
- package/dist/cli/commands-command.js +10 -3
- package/dist/cli/doctor-reports-command.d.ts +22 -0
- package/dist/cli/doctor-reports-command.js +82 -0
- package/dist/cli/help/command-help.d.ts +1 -0
- package/dist/cli/help/command-help.js +7 -8
- package/dist/cli/index.d.ts +3 -1
- package/dist/cli/index.js +3 -1
- package/dist/cli/messenger/doctor-command.js +21 -64
- package/dist/cli/messenger/stats-command.js +1 -1
- package/dist/cli/messenger/store-maintenance-command.js +3 -3
- package/dist/cli/messenger/tasks-command.js +1 -3
- package/dist/cli/permission-keys.js +4 -2
- package/dist/cli/program.js +26 -10
- package/dist/cli/settings.d.ts +2 -0
- package/dist/cli/settings.js +3 -2
- package/dist/cli/store-recover.js +2 -2
- package/dist/cli/unknown-profile.d.ts +9 -0
- package/dist/cli/unknown-profile.js +23 -0
- package/dist/crm/cli/search-all.js +4 -4
- package/dist/errors/failures.d.ts +2 -0
- package/dist/errors/failures.js +6 -0
- package/dist/errors/reasons.js +17 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/kit/index.d.ts +1 -0
- package/dist/kit/index.js +1 -0
- package/dist/kit/own-catalogue.d.ts +7 -0
- package/dist/kit/own-catalogue.js +21 -0
- package/dist/oauth/index.d.ts +2 -2
- package/dist/oauth/index.js +2 -1
- package/dist/oauth/provider.d.ts +4 -0
- package/dist/oauth/provider.js +16 -1
- package/dist/oauth/storage.d.ts +5 -0
- package/dist/oauth/storage.js +20 -0
- package/dist/runs/error-detail.d.ts +1 -1
- package/dist/runs/error-detail.js +5 -2
- package/dist/runs/events.d.ts +1 -1
- package/dist/runs/secrets.d.ts +5 -4
- package/dist/runs/secrets.js +8 -4
- package/dist/sends/permissions.d.ts +2 -0
- package/dist/sends/permissions.js +4 -1
- package/dist/services/search-all.js +1 -1
- package/dist/sftp/index.d.ts +1 -0
- package/dist/sftp/index.js +1 -0
- package/dist/sftp/session.d.ts +61 -0
- package/dist/sftp/session.js +230 -0
- package/dist/sftp/ssh2.d.ts +38 -0
- package/dist/sftp/ssh2.js +306 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.js +1 -0
- package/dist/store/sqlite/crm-activities.d.ts +2 -0
- package/dist/store/sqlite/crm-activities.js +17 -0
- package/dist/store/sqlite/deals.d.ts +4 -3
- package/dist/store/sqlite/deals.js +8 -2
- package/dist/store/sqlite/open-store.js +14 -1
- package/package.json +14 -4
- package/parity.json +2 -11
|
@@ -18,7 +18,7 @@ import { storePath } from "../../store/path.js";
|
|
|
18
18
|
import { deleteCopy, repairStore } from "../../store/repair.js";
|
|
19
19
|
import { drainNoteIndex, dropAllUnusedVectors, fillSearchIndex, fillStems, involvementStoreOver, noteIndexState, openSqlite, openStore, orphanPointers, pendingNormalization, resetAttachmentWords, resetNoteIndex, resetSearchIndex, resetStems, rollBack, searchIndexState, stemmerCache, stemsState, vectorIndexCounts, } from "../../store/store.js";
|
|
20
20
|
import { environmentOf, outputFor } from "../context.js";
|
|
21
|
-
import { destroysNothing, LOCAL_READ, LOCAL_WRITE } from "../effects.js";
|
|
21
|
+
import { destroysNothing, grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "../effects.js";
|
|
22
22
|
import { itemOf, renderAnswer, snakeKeys } from "../envelope.js";
|
|
23
23
|
import { commandAt, lineOf, nextStep } from "../steps.js";
|
|
24
24
|
import { storeInfoCommand } from "../store-info.js";
|
|
@@ -627,7 +627,7 @@ const decryptCommand = () => annotate(new Command("decrypt"), { output: { entity
|
|
|
627
627
|
* process has the file open — it would go on writing to the file set aside — or while this CLI's
|
|
628
628
|
* `serve` runs: that opens the store on its first write, so until then it holds nothing to see.
|
|
629
629
|
*/
|
|
630
|
-
const restoreCommand = (owner) => annotate(new Command("restore"), { output: { entity: "store_restore" }, effects: LOCAL_WRITE })
|
|
630
|
+
const restoreCommand = (owner) => grantsAuthority(annotate(new Command("restore"), { output: { entity: "store_restore" }, effects: LOCAL_WRITE }))
|
|
631
631
|
.summary("restore a backup and keep the current store, or roll back a breaking upgrade")
|
|
632
632
|
.description("put a backup in place of the store; the store it replaces is kept beside it, never deleted. Given a rollback " +
|
|
633
633
|
"copy (backups/<store>-rollback-schema-<version>-<time>.db, kept for a day before an upgrade older tools " +
|
|
@@ -791,7 +791,7 @@ const quiesce = async (path, owner, then, warn, waitMs = STORE_LOCK_WAIT_MS) =>
|
|
|
791
791
|
* the delete. A new file rather than `DELETE FROM` every table: deleted rows would stay readable in free
|
|
792
792
|
* pages until a VACUUM, and every table comes back in this build's shape.
|
|
793
793
|
*/
|
|
794
|
-
const resetCommand = (owner) => annotate(new Command("reset"), { output: { entity: "store_reset" }, effects: LOCAL_WRITE })
|
|
794
|
+
const resetCommand = (owner) => annotate(new Command("reset"), { output: { entity: "store_reset" }, effects: LOCAL_WRITE, mcp: false })
|
|
795
795
|
.summary(`back up the ${archive(owner)} and replace it with an empty one`)
|
|
796
796
|
.description("back the store up beside itself, then delete it and start an empty one at this build's schema; asks first, or --yes")
|
|
797
797
|
.option("--no-backup", "delete the store without backing it up first")
|
|
@@ -558,19 +558,17 @@ export const tasksStatsCommand = (messenger) => {
|
|
|
558
558
|
.description("tasks per chat, meeting or project: open now, and opened and closed in the period (created: in the query), " +
|
|
559
559
|
"with the median time to close and the mean age of the open ones")
|
|
560
560
|
.option("--by <group>", "chat (default) or meeting: this account's tasks; project: the owner's project tasks, every project", statsByOf)
|
|
561
|
-
.option("--chat <chat>", `only this chat; ${messenger.chatArgument}`)
|
|
562
561
|
.option("--type <type>", "only this type: question, request, mention or promise", taskTypeOf)
|
|
563
562
|
.option("--timezone <zone>", "the IANA timezone for calendar days in the period, such as created>=today")
|
|
564
563
|
.action(async function (words) {
|
|
565
564
|
const context = messengerContext(this, messenger);
|
|
566
|
-
const { by,
|
|
565
|
+
const { by, type, timezone } = this.opts();
|
|
567
566
|
refuseJsonl(context.format);
|
|
568
567
|
const query = listQuery(typedQuery(words), TASK_STATS_QUERY, "stats tasks show");
|
|
569
568
|
const accounts = messenger.accountsOf?.(this);
|
|
570
569
|
const { stats, account } = await context.withServices(async (services) => ({
|
|
571
570
|
stats: await services.tasks.stats({
|
|
572
571
|
...(by === undefined ? {} : { by }),
|
|
573
|
-
...(chat === undefined ? {} : { chat }),
|
|
574
572
|
...(type === undefined ? {} : { kind: type }),
|
|
575
573
|
...(query === undefined ? {} : { query }),
|
|
576
574
|
...(timezone === undefined ? {} : { timezone }),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import { AUTHORITY_KEY, CEILING_KEY, DEFAULT_PERMISSIONS, keyForCommand, WRITE_KEYS, } from "../sends/permissions.js";
|
|
2
|
+
import { AUTHORITY_KEY, CEILING_KEY, DEFAULT_PERMISSIONS, KEYED_UNDER_HOUSEKEEPING, keyForCommand, WRITE_KEYS, } from "../sends/permissions.js";
|
|
3
3
|
import { issueMessage, permissionIssues, publicIssue } from "./config-issues.js";
|
|
4
4
|
const HOUSEKEEPING = new Set([
|
|
5
5
|
"help",
|
|
@@ -15,7 +15,9 @@ const HOUSEKEEPING = new Set([
|
|
|
15
15
|
"runs",
|
|
16
16
|
]);
|
|
17
17
|
/** A command's own path is its key; the commands that look after the tool have none. */
|
|
18
|
-
export const commandPathKey = (path) => path[0] === undefined || HOUSEKEEPING.has(path[0])
|
|
18
|
+
export const commandPathKey = (path) => path[0] === undefined || (HOUSEKEEPING.has(path[0]) && !KEYED_UNDER_HOUSEKEEPING.has(path.join(".")))
|
|
19
|
+
? null
|
|
20
|
+
: path.join(".");
|
|
19
21
|
export const commandPermissions = ({ keyOf = commandPathKey, extra = [], defaults = {}, alsoChecks, } = {}) => ({
|
|
20
22
|
keyOf,
|
|
21
23
|
extra: [AUTHORITY_KEY, ...extra],
|
package/dist/cli/program.js
CHANGED
|
@@ -7,7 +7,7 @@ import { Command, Help } from "commander";
|
|
|
7
7
|
import { relayCommand } from "../background/relay.js";
|
|
8
8
|
import { failingNotice, scheduledRuns } from "../background/schedules.js";
|
|
9
9
|
import { parseDuration } from "../domain/duration.js";
|
|
10
|
-
import { isCliFailure, isCommanderFailure, storeDamaged } from "../errors/failures.js";
|
|
10
|
+
import { isCliFailure, isCommanderFailure, storeDamaged, usageReason } from "../errors/failures.js";
|
|
11
11
|
import { failureContext } from "../errors/reasons.js";
|
|
12
12
|
import { envName, readOnlyLockOf, readOnlyRefusal } from "../ports/app.js";
|
|
13
13
|
import { recorded, wasSettled } from "../runs/recording.js";
|
|
@@ -42,6 +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
46
|
const OUTPUT_OPTIONS = [
|
|
46
47
|
["output", "--output"],
|
|
47
48
|
["outputDir", "--output-dir"],
|
|
@@ -579,12 +580,17 @@ const runOnce = async (argv, definition, options) => {
|
|
|
579
580
|
message = message.trimEnd();
|
|
580
581
|
message += ` — "${profile}" is not a command, so it was read as a profile name — which left "${rest[0]}" to be one.`;
|
|
581
582
|
}
|
|
582
|
-
const
|
|
583
|
+
const reason = usageReason(error.code);
|
|
584
|
+
const failure = new CliError("validation_error", message, reason ? { reason } : {});
|
|
583
585
|
const settled = await settleFailure(failure, { definition, program, rest, argv, profile, options });
|
|
584
586
|
return report(streams, reporting, failed(definition, program, rest, failure, settled, debug));
|
|
585
587
|
}
|
|
586
588
|
const settled = await settleFailure(error, { definition, program, rest, argv, profile, options });
|
|
587
|
-
|
|
589
|
+
// An MCP call's profile is the one its server was started for, not a word typed now.
|
|
590
|
+
const told = options.agent
|
|
591
|
+
? error
|
|
592
|
+
: unknownProfile(error, () => failureSettings(definition, program, rest, profile, options));
|
|
593
|
+
const exit = report(streams, reporting, failed(definition, program, rest, told, settled, debug));
|
|
588
594
|
return signalExit ?? exit;
|
|
589
595
|
}
|
|
590
596
|
finally {
|
|
@@ -690,19 +696,29 @@ const settleFailure = async (failure, state) => {
|
|
|
690
696
|
* Its words are kept as `record_input` says (`maskArgv`); a configuration that did not load masks them, since it may
|
|
691
697
|
* be the one that turned recording input off.
|
|
692
698
|
*/
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
return;
|
|
696
|
-
const env = options.env ?? process.env;
|
|
699
|
+
/** The settings a failed run had, read again without asking for a profile; `undefined` when they do not load. */
|
|
700
|
+
const failureSettings = (definition, program, rest, profile, options) => {
|
|
697
701
|
const path = commandPath(program, program.args.length > 0 ? program.args : rest);
|
|
698
702
|
const { resolveSettings } = definition.configuration ?? settingsFor(definition.app);
|
|
699
|
-
let settings;
|
|
700
703
|
try {
|
|
701
|
-
|
|
704
|
+
return resolveSettings({ ...program.opts(), ...(profile === undefined ? {} : { profile }) }, {
|
|
705
|
+
env: options.env ?? process.env,
|
|
706
|
+
kind: path.split(" ")[0] === "bot" ? "bot" : "personal",
|
|
707
|
+
needsProfile: false,
|
|
708
|
+
readOnly: true,
|
|
709
|
+
});
|
|
702
710
|
}
|
|
703
711
|
catch {
|
|
704
|
-
|
|
712
|
+
return undefined;
|
|
705
713
|
}
|
|
714
|
+
};
|
|
715
|
+
const keepFailure = async (failure, { definition, program, rest, argv, profile, options }) => {
|
|
716
|
+
if (wasSettled(failure))
|
|
717
|
+
return;
|
|
718
|
+
const env = options.env ?? process.env;
|
|
719
|
+
const path = commandPath(program, program.args.length > 0 ? program.args : rest);
|
|
720
|
+
// A configuration that will not load is a failure worth keeping too; the flags are all there is to go on.
|
|
721
|
+
const settings = failureSettings(definition, program, rest, profile, options);
|
|
706
722
|
const command = `${options.agent ? "mcp " : ""}${path || definition.app.command}`;
|
|
707
723
|
await recorded({
|
|
708
724
|
app: definition.app,
|
package/dist/cli/settings.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export interface SettingsExtension<T extends object = Record<never, never>> {
|
|
|
31
31
|
sources: Record<string, Source>;
|
|
32
32
|
};
|
|
33
33
|
profile?: v.ObjectEntries;
|
|
34
|
+
/** Like `profile`, but a bot's section refuses them: settings only a personal account reads. */
|
|
35
|
+
personal?: v.ObjectEntries;
|
|
34
36
|
/** For the whole program only, never per profile. */
|
|
35
37
|
defaults?: v.ObjectEntries;
|
|
36
38
|
/** Its own scalar settings, written into the file's `defaults` beside the shared ones (WC-CMD-30). */
|
package/dist/cli/settings.js
CHANGED
|
@@ -227,11 +227,12 @@ export const fromFile = (settings, key, fallback) => first([
|
|
|
227
227
|
*/
|
|
228
228
|
export const settingsFor = (app, extension = {}) => {
|
|
229
229
|
const declared = extension.permissions;
|
|
230
|
-
const
|
|
230
|
+
const botEntries = {
|
|
231
231
|
...SHARED_PROFILE_ENTRIES,
|
|
232
232
|
...(declared ? { permissions: v.optional(commandPathLevels) } : {}),
|
|
233
233
|
...extension.profile,
|
|
234
234
|
};
|
|
235
|
+
const profileEntries = { ...botEntries, ...extension.personal };
|
|
235
236
|
const defaultsOnly = { ...SHARED_DEFAULTS_ONLY, ...extension.defaults };
|
|
236
237
|
const defaultsEntries = { ...profileEntries, ...defaultsOnly };
|
|
237
238
|
const strictOf = (entries) => v.strictObject(entries, objectMessage);
|
|
@@ -243,7 +244,7 @@ export const settingsFor = (app, extension = {}) => {
|
|
|
243
244
|
defaults: v.optional(strictOf(defaultsEntries)),
|
|
244
245
|
profiles: v.optional(v.record(v.string(), strictOf(profileEntries), "has to be an object of profiles, by name"), {}),
|
|
245
246
|
personal: v.optional(kindSection(profileEntries)),
|
|
246
|
-
bot: v.optional(kindSection({ ...
|
|
247
|
+
bot: v.optional(kindSection({ ...botEntries, ...BOT_ONLY_ENTRIES })),
|
|
247
248
|
};
|
|
248
249
|
const schema = strictOf(configEntries);
|
|
249
250
|
const defaultsOnlyKeys = Object.keys(defaultsOnly);
|
|
@@ -10,7 +10,7 @@ import { storePath } from "../store/path.js";
|
|
|
10
10
|
import { activeTimers, recoverStore, sqlite3Program, storeHolders, tableRows, } from "../store/recover.js";
|
|
11
11
|
import { openSqlite } from "../store/store.js";
|
|
12
12
|
import { environmentOf, outputFor } from "./context.js";
|
|
13
|
-
import { LOCAL_READ, LOCAL_WRITE } from "./effects.js";
|
|
13
|
+
import { grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "./effects.js";
|
|
14
14
|
import { itemOf, renderAnswer, snakeKeys } from "./envelope.js";
|
|
15
15
|
/** The tables whose counts say what the store holds; every other table is in `store info`. */
|
|
16
16
|
const COUNTED = [
|
|
@@ -173,7 +173,7 @@ export const storeRecoverCommand = ({ command, version }) => {
|
|
|
173
173
|
for (const line of recoveryNotes(answer))
|
|
174
174
|
output.renderer.note(line);
|
|
175
175
|
});
|
|
176
|
-
recover.addCommand(annotate(new Command("run"), { effects: LOCAL_WRITE, examples: [`${command} store recover run`] })
|
|
176
|
+
recover.addCommand(grantsAuthority(annotate(new Command("run"), { effects: LOCAL_WRITE, examples: [`${command} store recover run`] }))
|
|
177
177
|
.summary("rebuild a damaged store from every row it can read")
|
|
178
178
|
.description("copy every readable row into a new file with the sqlite3 program, rebuild the search indexes, mentions and vector index, " +
|
|
179
179
|
"check it, and put it in place of the store; the damaged file is kept beside it. Refuses while a WireCat timer or process has the store")
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Settings } from "./settings.js";
|
|
2
|
+
/**
|
|
3
|
+
* A "not signed in" failure for a first word this computer has never seen as a profile is most likely a typo: it
|
|
4
|
+
* 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.
|
|
8
|
+
*/
|
|
9
|
+
export declare const unknownProfile: (error: unknown, settingsOf: () => (Pick<Settings, "profile"> & Partial<Pick<Settings, "sources" | "profilesHere" | "kind">>) | undefined) => unknown;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CliError, isCliError } from "@wirecat/cli-base";
|
|
2
|
+
const NOT_SIGNED_IN = new Set([undefined, "session.missing", "oauth.missing"]);
|
|
3
|
+
/**
|
|
4
|
+
* A "not signed in" failure for a first word this computer has never seen as a profile is most likely a typo: it
|
|
5
|
+
* answers `not_found` with the profiles here (FIND-2583), and keeps the sign-in hint for a profile that is new on
|
|
6
|
+
* purpose. Only after a command failed, so a working profile and the `setup` or `session start` that makes a new one
|
|
7
|
+
* never reach it; a profile set in the environment is a script's deliberate choice and keeps its refusal, and a bot
|
|
8
|
+
* gets its token with `bot auth set` under any new name.
|
|
9
|
+
*/
|
|
10
|
+
export const unknownProfile = (error, settingsOf) => {
|
|
11
|
+
if (!isCliError(error) || error.code !== "authentication_error")
|
|
12
|
+
return error;
|
|
13
|
+
if (!NOT_SIGNED_IN.has(error.details.reason))
|
|
14
|
+
return error;
|
|
15
|
+
const settings = settingsOf();
|
|
16
|
+
const here = settings?.profilesHere;
|
|
17
|
+
if (!settings || !here || settings.kind === "bot" || settings.sources?.profile !== "first word")
|
|
18
|
+
return error;
|
|
19
|
+
if (here.includes(settings.profile))
|
|
20
|
+
return error;
|
|
21
|
+
return new CliError("not_found", `no profile named ${settings.profile} on this computer — profiles here: ${here.join(", ") || "none"}; ` +
|
|
22
|
+
`if ${settings.profile} is a new one: ${error.message}`, { reason: "profile.unknown", profiles: here });
|
|
23
|
+
};
|
|
@@ -22,10 +22,10 @@ const DEFAULT_LIMIT = 20;
|
|
|
22
22
|
export const addCrmSearchAll = (searches, { within, app, example, }) => {
|
|
23
23
|
const all = annotate(new Command("all"), { effects: LOCAL_READ, partial: true, output: { entity: "hit" } })
|
|
24
24
|
.summary("search stored deals and leads, messages, notes, calendar events and meetings")
|
|
25
|
-
.description("search the CRM's deals and leads by the words of their title, company and
|
|
26
|
-
"calendar events and meetings other WireCat tools stored — best match first. Use it when
|
|
27
|
-
"where something was written")
|
|
28
|
-
.argument("<query...>", 'words and "phrases"; deals and leads match the words of their title, company and
|
|
25
|
+
.description("search the CRM's deals and leads by the words of their title, company, contacts and activities, and the " +
|
|
26
|
+
"messages, notes, calendar events and meetings other WireCat tools stored — best match first. Use it when " +
|
|
27
|
+
"you do not know where something was written")
|
|
28
|
+
.argument("<query...>", 'words and "phrases"; deals and leads match the words of their title, company, contacts and activities')
|
|
29
29
|
.addHelpText("after", SAVE_HELP);
|
|
30
30
|
searches.addCommand(searchAllOptions(all, SEARCHED));
|
|
31
31
|
example(all, "search all Example LLC", "search all website --only crm --json");
|
|
@@ -12,6 +12,8 @@ export declare const isCommanderFailure: (value: unknown) => value is Error & {
|
|
|
12
12
|
code: string;
|
|
13
13
|
exitCode: number;
|
|
14
14
|
};
|
|
15
|
+
/** The reason of a commander usage error a caller matches instead of commander's English, when it has one. */
|
|
16
|
+
export declare const usageReason: (code: string) => string | undefined;
|
|
15
17
|
/** What failed, never what it said: a messenger's refusal can quote the message back. */
|
|
16
18
|
export declare const failureKey: (error: unknown) => string;
|
|
17
19
|
/**
|
package/dist/errors/failures.js
CHANGED
|
@@ -14,6 +14,12 @@ export const isCommanderFailure = (value) => {
|
|
|
14
14
|
const { code, exitCode } = (value ?? {});
|
|
15
15
|
return (value instanceof Error && typeof code === "string" && code.startsWith("commander.") && typeof exitCode === "number");
|
|
16
16
|
};
|
|
17
|
+
const USAGE_REASONS = {
|
|
18
|
+
"commander.unknownCommand": "usage.unknown-command",
|
|
19
|
+
"commander.unknownOption": "usage.unknown-option",
|
|
20
|
+
};
|
|
21
|
+
/** The reason of a commander usage error a caller matches instead of commander's English, when it has one. */
|
|
22
|
+
export const usageReason = (code) => USAGE_REASONS[code];
|
|
17
23
|
/** What failed, never what it said: a messenger's refusal can quote the message back. */
|
|
18
24
|
export const failureKey = (error) => isCliFailure(error) ? error.code : error instanceof Error ? error.name : "error";
|
|
19
25
|
const SQLITE_CORRUPT = 11;
|
package/dist/errors/reasons.js
CHANGED
|
@@ -41,6 +41,7 @@ const SIGN_IN = [
|
|
|
41
41
|
["sign-in.secret-without-id", "configuration_error", "an OAuth client secret is set without its client id"],
|
|
42
42
|
validation("account-remove.no-choice", "account remove needs --keep-data or --delete-data, one of them"),
|
|
43
43
|
["account-remove.unknown-profile", "not_found", "no profile by this name on this computer"],
|
|
44
|
+
["profile.unknown", "not_found", "no profile by this name on this computer; details.profiles lists the ones here"],
|
|
44
45
|
["account-remove.busy", "conflict", "a serve or a sync runs for this profile; stop it first"],
|
|
45
46
|
["account-remove.unconfirmed", "confirmation_required", "removing an account asks first; add --yes"],
|
|
46
47
|
["account-remove.path-outside", "configuration_error", "the tool named a path outside its own folders"],
|
|
@@ -60,7 +61,21 @@ const PROVIDER_API = [
|
|
|
60
61
|
validation("file.not-a-file", "the path names a folder or another thing that is not a file"),
|
|
61
62
|
["file.denied", "permission_error", "the file cannot be opened: permission denied"],
|
|
62
63
|
];
|
|
64
|
+
/** The read-only SFTP client (`./sftp`). */
|
|
65
|
+
const SFTP = [
|
|
66
|
+
["sftp.host-key-missing", "configuration_error", "no host key is pinned for the SFTP server"],
|
|
67
|
+
["sftp.host-key-mismatch", "authentication_error", "the SFTP server's host key is not the pinned one"],
|
|
68
|
+
["sftp.auth-missing", "configuration_error", "an SFTP connection needs a password or a private key"],
|
|
69
|
+
["sftp.key-invalid", "configuration_error", "the SFTP private key or its passphrase cannot be read"],
|
|
70
|
+
["sftp.library-missing", "configuration_error", "SFTP needs the ssh2 package in the CLI's dependencies"],
|
|
71
|
+
["sftp.timeout", "timeout", "the SFTP server did not answer in time"],
|
|
72
|
+
validation("sftp.too-large", "the file is larger than the read's byte limit"),
|
|
73
|
+
validation("sftp.closed", "the SFTP connection was closed before the operation"),
|
|
74
|
+
];
|
|
63
75
|
const OTHERS = [
|
|
76
|
+
validation("doctor.report-exists", "the report's file exists; a problem report never overwrites a file"),
|
|
77
|
+
validation("usage.unknown-command", "no command by this name; the CLI's help lists them"),
|
|
78
|
+
validation("usage.unknown-option", "the command takes no option by this name; its help lists them"),
|
|
64
79
|
["query.time-limit", "timeout", "the search took longer than its time limit; the query itself is valid"],
|
|
65
80
|
["enrichment.owner-only", "permission_error", "only the owner turns enrichment on, not an agent"],
|
|
66
81
|
["search-harder.owner-only", "permission_error", "only the owner allows search all --harder, not an agent"],
|
|
@@ -251,6 +266,7 @@ const OTHERS = [
|
|
|
251
266
|
"another program deleted or replaced the store's journal file while it was open; store recover says what to do",
|
|
252
267
|
],
|
|
253
268
|
validation("store.file-damaged", "the named store file is damaged or not a database"),
|
|
269
|
+
["store.unopenable", "configuration_error", "the store file cannot be opened at its path; details.path names it"],
|
|
254
270
|
[
|
|
255
271
|
"store.unreadable",
|
|
256
272
|
"configuration_error",
|
|
@@ -572,7 +588,7 @@ export const INPUT_FIELD_REASONS = defineReasons([
|
|
|
572
588
|
export const REASONS = defineReasons([
|
|
573
589
|
...QUERY_REASONS,
|
|
574
590
|
...INPUT_FIELD_REASONS,
|
|
575
|
-
...[...QUERY, ...SIGN_IN, ...PROVIDER_API, ...OTHERS].map(([reason, code, message]) => ({
|
|
591
|
+
...[...QUERY, ...SIGN_IN, ...PROVIDER_API, ...SFTP, ...OTHERS].map(([reason, code, message]) => ({
|
|
576
592
|
reason,
|
|
577
593
|
code,
|
|
578
594
|
message,
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type { MessageLink, MessagePermalink } from "./domain/message-link.js";
|
|
|
16
16
|
export type * from "./domain/models.js";
|
|
17
17
|
export { CURRENCY_SCALES, currencyOf, formatDecimal, type Money, minorUnits, moneyLabel, moneyOf, signedMinorUnits, } from "./domain/money.js";
|
|
18
18
|
export { ORDER_PURPOSES, ORDER_STATUSES, type OrderPurpose, type OrderStatus, } from "./domain/orders.js";
|
|
19
|
+
export { e164Of, PHONE_COUNTRIES, type PhoneCountry } from "./domain/phones.js";
|
|
19
20
|
export { countedPoll } from "./domain/polls.js";
|
|
20
21
|
export { ADDED_ACCOUNT, ADDED_PROVIDER, CRM_OPENS, FOLDER_PROVIDERS, holdsKind, isFolderProvider, isKind, KINDS, type Kind, kindIn, kindOf, kindsIn, PROVIDERS, type ProviderEntry, providerNamed, providers, UNKNOWN_PROVIDER, useProviders, } from "./domain/providers.js";
|
|
21
22
|
export type { RankingGraphEvidence, RankingGraphLink } from "./domain/rankings-graph.js";
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export { parseMarkdown } from "./domain/markdown.js";
|
|
|
13
13
|
export { parseMarkdownSpans } from "./domain/markdown-spans.js";
|
|
14
14
|
export { CURRENCY_SCALES, currencyOf, formatDecimal, minorUnits, moneyLabel, moneyOf, signedMinorUnits, } from "./domain/money.js";
|
|
15
15
|
export { ORDER_PURPOSES, ORDER_STATUSES, } from "./domain/orders.js";
|
|
16
|
+
export { e164Of, PHONE_COUNTRIES } from "./domain/phones.js";
|
|
16
17
|
export { countedPoll } from "./domain/polls.js";
|
|
17
18
|
export { ADDED_ACCOUNT, ADDED_PROVIDER, CRM_OPENS, FOLDER_PROVIDERS, holdsKind, isFolderProvider, isKind, KINDS, kindIn, kindOf, kindsIn, PROVIDERS, providerNamed, providers, UNKNOWN_PROVIDER, useProviders, } from "./domain/providers.js";
|
|
18
19
|
export { rankingOptions } from "./domain/rankings-options.js";
|
package/dist/kit/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { ARGV_LOG, argvLogSetup } from "./argv-log.js";
|
|
|
2
2
|
export { type ContractCase, type ContractOptions, contractCases, OPTIONAL_METHODS } from "./contract.js";
|
|
3
3
|
export { type FakeAdapter, fakeAdapter } from "./fake.js";
|
|
4
4
|
export { type McpStdio, type McpStdioStreams, type McpToolResult, mcpOverStdio } from "./mcp-stdio.js";
|
|
5
|
+
export { ownCatalogue } from "./own-catalogue.js";
|
|
5
6
|
export { neverAnswers, type RunScopeCase, type RunScopeOptions, runScopeCases } from "./run-scope.js";
|
|
6
7
|
export { type SearchRecipes, searchRecipes, seedSearchRecipes } from "./search-recipes.js";
|
|
7
8
|
export { BUSY_PAGE, contractSeed, digitIds, type IdKind, type IdMaker, type Seed, wordIds } from "./seed.js";
|
package/dist/kit/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { ARGV_LOG, argvLogSetup } from "./argv-log.js";
|
|
|
2
2
|
export { contractCases, OPTIONAL_METHODS } from "./contract.js";
|
|
3
3
|
export { fakeAdapter } from "./fake.js";
|
|
4
4
|
export { mcpOverStdio } from "./mcp-stdio.js";
|
|
5
|
+
export { ownCatalogue } from "./own-catalogue.js";
|
|
5
6
|
export { neverAnswers, runScopeCases } from "./run-scope.js";
|
|
6
7
|
export { searchRecipes, seedSearchRecipes } from "./search-recipes.js";
|
|
7
8
|
export { BUSY_PAGE, contractSeed, digitIds, wordIds } from "./seed.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import { type CatalogueOptions } from "../mcp/agent.js";
|
|
3
|
+
/**
|
|
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.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ownCatalogue: (program: Command, options?: CatalogueOptions) => Record<string, "read" | "write">;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describeProgram, hasSharedContract } from "@wirecat/cli-base/commands";
|
|
2
|
+
import { toolsFromCommands } from "../mcp/agent.js";
|
|
3
|
+
const sharedPaths = (command, parents = [], into = new Set()) => {
|
|
4
|
+
for (const child of command.commands) {
|
|
5
|
+
const path = [...parents, child.name()];
|
|
6
|
+
if (hasSharedContract(child))
|
|
7
|
+
into.add(path.join(" "));
|
|
8
|
+
sharedPaths(child, path, into);
|
|
9
|
+
}
|
|
10
|
+
return into;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
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.
|
|
15
|
+
*/
|
|
16
|
+
export const ownCatalogue = (program, options = {}) => {
|
|
17
|
+
const shared = sharedPaths(program);
|
|
18
|
+
return Object.fromEntries(toolsFromCommands(describeProgram(program), options)
|
|
19
|
+
.filter((tool) => !shared.has([...(options.root ?? []), tool.command].join(" ")))
|
|
20
|
+
.map((tool) => [tool.command, tool.writes ? "write" : "read"]));
|
|
21
|
+
};
|
package/dist/oauth/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { type Authorization, type AuthorizeOptions, authorize } from "./authorize.js";
|
|
2
2
|
export { type ClientFileOptions, readClientFile } from "./client-file.js";
|
|
3
3
|
export { type SignInOptions, type TokenKeeper, type TokenKeeperOptions, type TokensOptions, tokenKeeper, } from "./keeper.js";
|
|
4
|
-
export type
|
|
4
|
+
export { type AppSource, type ExchangeContext, googleProvider, type OAuthClient, type OAuthProvider, type RequestContext, type TokenSet, } from "./provider.js";
|
|
5
5
|
export { requestTokens, revokeToken, TOKEN_LOG_ALLOW, TOKEN_LOG_EVENT } from "./requests.js";
|
|
6
|
-
export { type CredentialStorageOptions, credentialStorage, driveSessionCodec, type EncodeInput, oauthAccount, type StoredTokens, standardCodec, type TokenCodec, type TokenStorage, zoomTokenCodec, } from "./storage.js";
|
|
6
|
+
export { type CredentialStorageOptions, credentialStorage, driveSessionCodec, type EncodeInput, googleTokenCodec, oauthAccount, type StoredTokens, standardCodec, type TokenCodec, type TokenStorage, zoomTokenCodec, } from "./storage.js";
|
package/dist/oauth/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { authorize } from "./authorize.js";
|
|
2
2
|
export { readClientFile } from "./client-file.js";
|
|
3
3
|
export { tokenKeeper, } from "./keeper.js";
|
|
4
|
+
export { googleProvider, } from "./provider.js";
|
|
4
5
|
export { requestTokens, revokeToken, TOKEN_LOG_ALLOW, TOKEN_LOG_EVENT } from "./requests.js";
|
|
5
|
-
export { credentialStorage, driveSessionCodec, oauthAccount, standardCodec, zoomTokenCodec, } from "./storage.js";
|
|
6
|
+
export { credentialStorage, driveSessionCodec, googleTokenCodec, oauthAccount, standardCodec, zoomTokenCodec, } from "./storage.js";
|
package/dist/oauth/provider.d.ts
CHANGED
|
@@ -59,3 +59,7 @@ export interface OAuthProvider {
|
|
|
59
59
|
exchange?: (params: Record<string, string>, context: ExchangeContext) => Promise<TokenSet>;
|
|
60
60
|
revoke?: (tokens: TokenSet, context: RequestContext) => Promise<void>;
|
|
61
61
|
}
|
|
62
|
+
/** Google's endpoints for a Desktop client; `loginHint` preselects the account the browser offers. */
|
|
63
|
+
export declare const googleProvider: (client: OAuthClient, { loginHint }?: {
|
|
64
|
+
loginHint?: string;
|
|
65
|
+
}) => OAuthProvider;
|
package/dist/oauth/provider.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/** Google's endpoints for a Desktop client; `loginHint` preselects the account the browser offers. */
|
|
2
|
+
export const googleProvider = (client, { loginHint } = {}) => ({
|
|
3
|
+
id: "google",
|
|
4
|
+
name: "Google",
|
|
5
|
+
authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth",
|
|
6
|
+
tokenUrl: "https://oauth2.googleapis.com/token",
|
|
7
|
+
revokeUrl: "https://oauth2.googleapis.com/revoke",
|
|
8
|
+
client,
|
|
9
|
+
redirect: { kind: "loopback" },
|
|
10
|
+
// Without offline access Google returns no refresh token; without consent it does not return one again.
|
|
11
|
+
authorizeParams: {
|
|
12
|
+
access_type: "offline",
|
|
13
|
+
prompt: "select_account consent",
|
|
14
|
+
...(loginHint ? { login_hint: loginHint } : {}),
|
|
15
|
+
},
|
|
16
|
+
});
|
package/dist/oauth/storage.d.ts
CHANGED
|
@@ -41,6 +41,11 @@ export declare const standardCodec: (providerId: string) => TokenCodec;
|
|
|
41
41
|
* refresh_token, expiry_date, scope, token_type, …}}`. A write keeps every field it does not own.
|
|
42
42
|
*/
|
|
43
43
|
export declare const driveSessionCodec: TokenCodec;
|
|
44
|
+
/**
|
|
45
|
+
* Google's entry: the standard one plus the client secret, which a Google Desktop client needs to refresh while its
|
|
46
|
+
* client file is read only at sign-in. A client without a secret drops the one the profile signed in with before.
|
|
47
|
+
*/
|
|
48
|
+
export declare const googleTokenCodec: TokenCodec;
|
|
44
49
|
/** zm's entry as zoom-cli writes it today: `{accessToken, refreshToken, expiresAt, scopes}`, all four required. */
|
|
45
50
|
export declare const zoomTokenCodec: TokenCodec;
|
|
46
51
|
export interface CredentialStorageOptions {
|
package/dist/oauth/storage.js
CHANGED
|
@@ -122,6 +122,26 @@ export const driveSessionCodec = {
|
|
|
122
122
|
return JSON.stringify(session);
|
|
123
123
|
},
|
|
124
124
|
};
|
|
125
|
+
const googleStandard = standardCodec("google");
|
|
126
|
+
/**
|
|
127
|
+
* Google's entry: the standard one plus the client secret, which a Google Desktop client needs to refresh while its
|
|
128
|
+
* client file is read only at sign-in. A client without a secret drops the one the profile signed in with before.
|
|
129
|
+
*/
|
|
130
|
+
export const googleTokenCodec = {
|
|
131
|
+
decode: (raw) => {
|
|
132
|
+
const stored = googleStandard.decode(raw);
|
|
133
|
+
const clientSecret = text(parse(raw).clientSecret);
|
|
134
|
+
return clientSecret ? { ...stored, client: { clientId: stored.client?.clientId ?? "", clientSecret } } : stored;
|
|
135
|
+
},
|
|
136
|
+
encode: (input) => {
|
|
137
|
+
const entry = parse(googleStandard.encode(input));
|
|
138
|
+
if (input.client.clientSecret)
|
|
139
|
+
entry.clientSecret = input.client.clientSecret;
|
|
140
|
+
else
|
|
141
|
+
delete entry.clientSecret;
|
|
142
|
+
return JSON.stringify(entry);
|
|
143
|
+
},
|
|
144
|
+
};
|
|
125
145
|
/** zm's entry as zoom-cli writes it today: `{accessToken, refreshToken, expiresAt, scopes}`, all four required. */
|
|
126
146
|
export const zoomTokenCodec = {
|
|
127
147
|
decode: (raw) => {
|
|
@@ -33,7 +33,7 @@ export declare const errorDetailOf: (error: unknown, response?: RequestEvent) =>
|
|
|
33
33
|
export declare const framesOf: (error: unknown, limit?: number) => string[];
|
|
34
34
|
/**
|
|
35
35
|
* Where a request went, with nothing in it that names a person or opens an account: no query string, no user, an id
|
|
36
|
-
* or a token in the path as `:id` / `:token
|
|
36
|
+
* or a token in the path as `:id` / `:token`, a webhook's secret after `/rest/<user id>/` among them. The host stays — which service refused is the point.
|
|
37
37
|
*/
|
|
38
38
|
export declare const endpointTemplate: (raw: string) => string;
|
|
39
39
|
/** A phone number as people type it with its country code, and one written as digits only without the "+". */
|
|
@@ -94,16 +94,19 @@ const fileOf = (path) => {
|
|
|
94
94
|
};
|
|
95
95
|
/**
|
|
96
96
|
* Where a request went, with nothing in it that names a person or opens an account: no query string, no user, an id
|
|
97
|
-
* or a token in the path as `:id` / `:token
|
|
97
|
+
* or a token in the path as `:id` / `:token`, a webhook's secret after `/rest/<user id>/` among them. The host stays — which service refused is the point.
|
|
98
98
|
*/
|
|
99
99
|
export const endpointTemplate = (raw) => {
|
|
100
100
|
const trimmed = raw.trim().split(/[?#]/)[0] ?? "";
|
|
101
101
|
const origin = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]*@)?([^/]*)/i.exec(trimmed);
|
|
102
102
|
const path = origin ? trimmed.slice(origin[0].length) : trimmed;
|
|
103
103
|
const scheme = origin ? `${trimmed.slice(0, trimmed.indexOf("://"))}://${origin[1]}` : "";
|
|
104
|
-
const
|
|
104
|
+
const parts = path.split("/");
|
|
105
|
+
const segments = parts.map((segment, at) => {
|
|
105
106
|
if (segment === "" || /^[:{].+/.test(segment))
|
|
106
107
|
return segment;
|
|
108
|
+
if (at >= 2 && parts[at - 2] === "rest" && /^\d+$/.test(parts[at - 1] ?? ""))
|
|
109
|
+
return ":token";
|
|
107
110
|
if (/^bot\d+:/.test(segment) || /^\d{6,}:[\w-]{20,}$/.test(segment))
|
|
108
111
|
return ":token";
|
|
109
112
|
if (/^-?\d+$/.test(segment) || /^[0-9a-f-]{16,}$/i.test(segment))
|
package/dist/runs/events.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export interface RequestEvent {
|
|
|
37
37
|
* requests when it has any, so one operation over three frames is three requests, never four.
|
|
38
38
|
*/
|
|
39
39
|
level?: "operation" | "wire";
|
|
40
|
-
transport?: "http" | "mtproto" | "max-ws" | "wa-engine";
|
|
40
|
+
transport?: "http" | "mtproto" | "max-ws" | "wa-engine" | "sftp";
|
|
41
41
|
/** 1 for the first try, 2 and up for a retry of the same call. */
|
|
42
42
|
attempt?: number;
|
|
43
43
|
/** How long the client waited before this attempt: a flood wait or a `Retry-After`. */
|
package/dist/runs/secrets.d.ts
CHANGED
|
@@ -7,9 +7,10 @@ export declare const holdsCredential: (text: string) => boolean;
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const looksRandom: (run: string) => boolean;
|
|
9
9
|
/**
|
|
10
|
-
* Text with each secret inside it replaced by `mark` and the words around it kept: a
|
|
11
|
-
* a private key, a `Bearer`/`Basic` credential, the value of a secret-named
|
|
12
|
-
* or `name value`, a random-looking string of 20 or more printable
|
|
13
|
-
* lower-case hex characters with a Shannon entropy of 3 bits per
|
|
10
|
+
* Text with each secret inside it replaced by `mark` and the words around it kept: a webhook secret in a URL path, a
|
|
11
|
+
* token of a known vendor format, a private key, a `Bearer`/`Basic` credential, the value of a secret-named
|
|
12
|
+
* `name=value`, `name: value`, `name => value` or `name value`, a random-looking string of 20 or more printable
|
|
13
|
+
* characters (`looksRandom`), and a run of 20 or more lower-case hex characters with a Shannon entropy of 3 bits per
|
|
14
|
+
* character or more.
|
|
14
15
|
*/
|
|
15
16
|
export declare const withoutSecrets: (text: string, mark?: string) => string;
|
package/dist/runs/secrets.js
CHANGED
|
@@ -49,6 +49,8 @@ const KNOWN_TOKENS = new RegExp(`${[
|
|
|
49
49
|
]
|
|
50
50
|
.map((pattern) => `${START}${pattern}${END}`)
|
|
51
51
|
.join("|")}|(?<!\\d)\\d{8,10}:[A-Za-z0-9_-]{35}${END}`, "g");
|
|
52
|
+
// A Bitrix24 inbound webhook carries its secret as a path segment: `/rest/<user id>/<secret>/<method>`.
|
|
53
|
+
const WEBHOOK_PATH = /(\/rest\/\d+\/)[^/\s?#"']+/g;
|
|
52
54
|
const PRIVATE_KEY = /-----BEGIN[A-Z ]* PRIVATE KEY-----[\s\S]*?(?:-----END[A-Z ]* PRIVATE KEY-----|$)/g;
|
|
53
55
|
// Capitalised, as in a header, and not followed by a plain word: "the Basic plan" is somebody's words.
|
|
54
56
|
const SCHEME = /(?<![A-Za-z])(Bearer|Basic)(\s+)(?![A-Z]?[a-z]+(?![A-Za-z0-9]))[A-Za-z0-9._~+/=-]{8,}/g;
|
|
@@ -89,12 +91,14 @@ const entropy = (text) => {
|
|
|
89
91
|
return bits;
|
|
90
92
|
};
|
|
91
93
|
/**
|
|
92
|
-
* Text with each secret inside it replaced by `mark` and the words around it kept: a
|
|
93
|
-
* a private key, a `Bearer`/`Basic` credential, the value of a secret-named
|
|
94
|
-
* or `name value`, a random-looking string of 20 or more printable
|
|
95
|
-
* lower-case hex characters with a Shannon entropy of 3 bits per
|
|
94
|
+
* Text with each secret inside it replaced by `mark` and the words around it kept: a webhook secret in a URL path, a
|
|
95
|
+
* token of a known vendor format, a private key, a `Bearer`/`Basic` credential, the value of a secret-named
|
|
96
|
+
* `name=value`, `name: value`, `name => value` or `name value`, a random-looking string of 20 or more printable
|
|
97
|
+
* characters (`looksRandom`), and a run of 20 or more lower-case hex characters with a Shannon entropy of 3 bits per
|
|
98
|
+
* character or more.
|
|
96
99
|
*/
|
|
97
100
|
export const withoutSecrets = (text, mark = "[redacted]") => text
|
|
101
|
+
.replace(WEBHOOK_PATH, `$1${mark}`)
|
|
98
102
|
.replace(PRIVATE_KEY, mark)
|
|
99
103
|
.replace(KNOWN_TOKENS, mark)
|
|
100
104
|
.replace(SCHEME, `$1$2${mark}`)
|
|
@@ -8,6 +8,8 @@ export type PermissionKey = string;
|
|
|
8
8
|
export declare const skipFlagFor: (key: string) => "--allow-dangerous" | "--yes";
|
|
9
9
|
/** Only what cannot be undone asks; the tool is meant to work without questions (owner, NEED-460). */
|
|
10
10
|
export declare const DEFAULT_PERMISSIONS: Readonly<Record<PermissionKey, Level>>;
|
|
11
|
+
/** Commands under a housekeeping word, or store maintenance, that still have a key of their own: their path. */
|
|
12
|
+
export declare const KEYED_UNDER_HOUSEKEEPING: ReadonlySet<PermissionKey>;
|
|
11
13
|
/** Lets an MCP server offer the commands that change what a later run may do (`grantsAuthority`). */
|
|
12
14
|
export declare const AUTHORITY_KEY: PermissionKey;
|
|
13
15
|
/** Whether these levels let an agent run a command that changes what a later run may do; `ask` does, as for any write. */
|
|
@@ -28,6 +28,7 @@ export const DEFAULT_PERMISSIONS = {
|
|
|
28
28
|
"store.clear": "ask",
|
|
29
29
|
"store.decrypt": "ask",
|
|
30
30
|
"store.copies.delete": "ask",
|
|
31
|
+
"store.recover.run": "ask",
|
|
31
32
|
"server.start": "ask",
|
|
32
33
|
"server.stop": "ask",
|
|
33
34
|
"server.restart": "ask",
|
|
@@ -42,7 +43,7 @@ export const DEFAULT_PERMISSIONS = {
|
|
|
42
43
|
"doctor.reports.create": "ask",
|
|
43
44
|
};
|
|
44
45
|
/** Commands under a housekeeping word, or store maintenance, that still have a key of their own: their path. */
|
|
45
|
-
const KEYED_UNDER_HOUSEKEEPING = new Set(Object.keys(DEFAULT_PERMISSIONS).filter((key) => /^(store|server|models|images|schedule|doctor)\./.test(key)));
|
|
46
|
+
export const KEYED_UNDER_HOUSEKEEPING = new Set(Object.keys(DEFAULT_PERMISSIONS).filter((key) => /^(store|server|models|images|schedule|doctor)\./.test(key)));
|
|
46
47
|
/** Lets an MCP server offer the commands that change what a later run may do (`grantsAuthority`). */
|
|
47
48
|
export const AUTHORITY_KEY = "mcp.authority";
|
|
48
49
|
/** Whether these levels let an agent run a command that changes what a later run may do; `ask` does, as for any write. */
|
|
@@ -350,6 +351,8 @@ export const readKeysForCommand = (path) => {
|
|
|
350
351
|
// Checked as `messages` before they had keys of their own: `deny messages` keeps stopping them.
|
|
351
352
|
if (path[0] === "store" && ["reset", "clear", "decrypt"].includes(path[1] ?? ""))
|
|
352
353
|
return [key, "messages"];
|
|
354
|
+
if (key === "store.recover.run")
|
|
355
|
+
return [key, "messages"];
|
|
353
356
|
// A search shows what people wrote, so `deny messages` reaches every leaf that reads messages.
|
|
354
357
|
if (path[0] === "search") {
|
|
355
358
|
if (path[1] === "notes")
|