@wirecat/cli-core 0.466.0 → 0.468.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 +64 -0
- package/README.md +4 -2
- package/dist/cli/bot/mcp.js +2 -1
- package/dist/cli/command-runs.d.ts +38 -10
- package/dist/cli/command-runs.js +51 -17
- package/dist/cli/config-command.d.ts +4 -0
- package/dist/cli/config-command.js +5 -5
- package/dist/cli/context.d.ts +3 -0
- package/dist/cli/context.js +15 -3
- package/dist/cli/effects.d.ts +9 -0
- package/dist/cli/effects.js +27 -0
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +2 -2
- package/dist/cli/messenger/context.js +1 -1
- package/dist/cli/messenger/observed.js +10 -2
- package/dist/cli/messenger/report.js +48 -3
- package/dist/cli/program.d.ts +1 -1
- package/dist/cli/program.js +12 -5
- package/dist/cli/settings.d.ts +24 -6
- package/dist/cli/settings.js +26 -4
- package/dist/cli/shared-command-exports.d.ts +12 -4
- package/dist/cli/skill-command.js +11 -3
- package/dist/cli/steps.d.ts +9 -0
- package/dist/cli/steps.js +16 -0
- package/dist/cli/store-settings.d.ts +6 -0
- package/dist/cli/store-settings.js +6 -0
- package/dist/entities/index.d.ts +39 -0
- package/dist/entities/recorded-run.d.ts +39 -0
- package/dist/entities/recorded-run.js +14 -1
- package/dist/mcp/agent.d.ts +5 -0
- package/dist/mcp/agent.js +3 -1
- package/dist/mcp/all-profiles.d.ts +2 -0
- package/dist/mcp/all-profiles.js +16 -3
- package/dist/mcp/bot/server.d.ts +2 -0
- package/dist/mcp/bot/server.js +9 -3
- package/dist/mcp/caller.d.ts +38 -0
- package/dist/mcp/caller.js +95 -0
- package/dist/mcp/http/oauth.js +5 -1
- package/dist/mcp/server.js +21 -8
- package/dist/mcp/surface.js +11 -2
- package/dist/mcp/tool.d.ts +4 -1
- package/dist/mcp/tool.js +21 -11
- package/dist/runs/events.d.ts +16 -4
- package/dist/runs/events.js +4 -0
- package/dist/runs/log-attributes.js +7 -1
- package/dist/runs/log-events.js +5 -0
- package/dist/runs/recording.d.ts +10 -3
- package/dist/runs/recording.js +59 -15
- package/dist/runs/run-context.d.ts +55 -4
- package/dist/runs/run-context.js +34 -3
- package/dist/runs/run.d.ts +37 -11
- package/dist/runs/run.js +201 -52
- package/dist/runs/scope.d.ts +12 -0
- package/dist/runs/scope.js +6 -0
- package/dist/services/embeddings-maintenance.js +4 -6
- package/dist/services/patience.js +5 -1
- package/package.json +1 -1
|
@@ -17,6 +17,14 @@ const EVENT_FIELDS = [
|
|
|
17
17
|
"error_code",
|
|
18
18
|
"provider_error",
|
|
19
19
|
"code",
|
|
20
|
+
"level",
|
|
21
|
+
"transport",
|
|
22
|
+
"attempt",
|
|
23
|
+
"wait_ms",
|
|
24
|
+
"method",
|
|
25
|
+
"endpoint_template",
|
|
26
|
+
"status",
|
|
27
|
+
"dropped",
|
|
20
28
|
];
|
|
21
29
|
/**
|
|
22
30
|
* **Everything a report holds is already free of content** — the doctor, the run log and the send
|
|
@@ -38,7 +46,7 @@ export const buildReport = ({ doctor, runsDir, runId, command, sends, now = new
|
|
|
38
46
|
},
|
|
39
47
|
run: chosen
|
|
40
48
|
? {
|
|
41
|
-
metadata: maskedRun(chosen.metadata, program),
|
|
49
|
+
metadata: maskedRun(chosen.metadata, label, program),
|
|
42
50
|
events: readEvents(chosen.dir).map(eventOf(label, eventFields)),
|
|
43
51
|
}
|
|
44
52
|
: null,
|
|
@@ -46,8 +54,43 @@ export const buildReport = ({ doctor, runsDir, runId, command, sends, now = new
|
|
|
46
54
|
};
|
|
47
55
|
return JSON.parse(hideHome(JSON.stringify(report), home));
|
|
48
56
|
};
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
/**
|
|
58
|
+
* A report leaves the machine, so it masks the typed words as `record_input: false` would, and every id that ties it
|
|
59
|
+
* to a session, a connection, a trace, an app or a chat becomes a label, as the events' ids do.
|
|
60
|
+
*/
|
|
61
|
+
const maskedRun = (metadata, label, program = new Command()) => {
|
|
62
|
+
const { agent, mcp, partial, traceId } = metadata;
|
|
63
|
+
return {
|
|
64
|
+
...metadata,
|
|
65
|
+
...(metadata.argv ? { argv: maskArgv(program, metadata.argv).argv } : {}),
|
|
66
|
+
...(traceId ? { traceId: label(traceId) } : {}),
|
|
67
|
+
...(agent
|
|
68
|
+
? {
|
|
69
|
+
agent: {
|
|
70
|
+
...agent,
|
|
71
|
+
session_id: agent.session_id === null ? null : label(agent.session_id),
|
|
72
|
+
...(agent.client
|
|
73
|
+
? { client: { ...agent.client, ...(agent.client.id ? { id: label(agent.client.id) } : {}) } }
|
|
74
|
+
: {}),
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
: {}),
|
|
78
|
+
...(mcp
|
|
79
|
+
? {
|
|
80
|
+
mcp: {
|
|
81
|
+
...mcp,
|
|
82
|
+
...(mcp.request_id ? { request_id: label(mcp.request_id) } : {}),
|
|
83
|
+
...(mcp.connection_id ? { connection_id: label(mcp.connection_id) } : {}),
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
: {}),
|
|
87
|
+
...(partial
|
|
88
|
+
? {
|
|
89
|
+
partial: { ...partial, failures: partial.failures.map((failure) => ({ ...failure, id: label(failure.id) })) },
|
|
90
|
+
}
|
|
91
|
+
: {}),
|
|
92
|
+
};
|
|
93
|
+
};
|
|
51
94
|
/**
|
|
52
95
|
* Every field of a journal line that names a chat, a message or a write. A send's `operationId` is
|
|
53
96
|
* its `sendId`, so one left raw would undo the other's label.
|
|
@@ -105,6 +148,8 @@ const RECORDED_ID_FIELDS = new Set([
|
|
|
105
148
|
const eventOf = (label, fields) => (event) => {
|
|
106
149
|
const kept = Object.fromEntries(Object.entries(event)
|
|
107
150
|
.filter(([key]) => (fields === "recorded" ? RECORDED_FIELDS.has(key) : EVENT_FIELDS.includes(key)))
|
|
151
|
+
// A line from before records were nested holds pino's numeric `level`, not the request's layer.
|
|
152
|
+
.filter(([key, value]) => key !== "level" || typeof value === "string")
|
|
108
153
|
.map(([key, value]) => [
|
|
109
154
|
key,
|
|
110
155
|
fields === "recorded" && RECORDED_ID_FIELDS.has(key) && value !== undefined && value !== null
|
package/dist/cli/program.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface ProgramDefinition {
|
|
|
13
13
|
permissionKey?: (path: readonly string[]) => string | null | undefined;
|
|
14
14
|
/** A CLI's own keys (`commandPermissions`), from `settingsFor`: its commands are refused by them before they run. */
|
|
15
15
|
permissions?: CommandPermissions | undefined;
|
|
16
|
-
resolveSettings: (flags?: GlobalFlags, options?: ResolveOptions) => Pick<Settings, "profile" | "keepFailedRuns" | "keepRunsForDays" | "skillHint"> & Partial<Pick<Settings, "recordInput" | "permissions" | "permissionSources" | "configPath" | "savedPermissions" | "sources">>;
|
|
16
|
+
resolveSettings: (flags?: GlobalFlags, options?: ResolveOptions) => Pick<Settings, "profile" | "keepFailedRuns" | "keepRunsForDays" | "skillHint"> & Partial<Pick<Settings, "recordInput" | "keepSuccessfulRunsForDays" | "permissions" | "permissionSources" | "configPath" | "savedPermissions" | "sources">>;
|
|
17
17
|
};
|
|
18
18
|
configure?: (program: Command) => void;
|
|
19
19
|
/** The tool's pitch and "what you can do" lines on `--help` and a bare run. */
|
package/dist/cli/program.js
CHANGED
|
@@ -31,7 +31,7 @@ import { commandWords, isProfileName, liftProfile, sampleCommand, takesProfile,
|
|
|
31
31
|
import { absolutePaths, relayTarget } from "./relay-route.js";
|
|
32
32
|
import { NoProfileHere, namedProfile, settingsFor, } from "./settings.js";
|
|
33
33
|
import { assertSharedContracts } from "./shared-contracts.js";
|
|
34
|
-
import { commandAt, lineOf, withLines } from "./steps.js";
|
|
34
|
+
import { commandAt, failureSteps, lineOf, withLines } from "./steps.js";
|
|
35
35
|
/**
|
|
36
36
|
* The command tree, built fresh on each call. Commander is global state by default —
|
|
37
37
|
* `exitOverride` and the write hooks turn it into a value a test can drive.
|
|
@@ -69,8 +69,8 @@ export const createProgram = ({ app, commands, configure, firstScreen }, { out,
|
|
|
69
69
|
.option("--full", `${found} with their whole text and every provider field`)
|
|
70
70
|
.option("--dry-run", "preview parsed arguments and permissions before running the action")
|
|
71
71
|
.option("--yes", "go ahead without the question an ask level puts before a write")
|
|
72
|
-
.option("--record", "keep this run
|
|
73
|
-
.option("--no-record", "do not keep
|
|
72
|
+
.option("--record", "keep this run even where the config says record false; record_input false leaves the typed words out")
|
|
73
|
+
.option("--no-record", "do not keep this run, even if it fails")
|
|
74
74
|
.showHelpAfterError();
|
|
75
75
|
for (const command of mounted)
|
|
76
76
|
program.addCommand(command);
|
|
@@ -617,7 +617,8 @@ const keepFailure = async (failure, { definition, program, rest, argv, profile,
|
|
|
617
617
|
program,
|
|
618
618
|
argv,
|
|
619
619
|
env,
|
|
620
|
-
recordInput: settings ? settings.recordInput
|
|
620
|
+
recordInput: settings ? (settings.recordInput ?? true) : false,
|
|
621
|
+
caller: options.agent?.caller,
|
|
621
622
|
}),
|
|
622
623
|
// Settings that did not load never accepted the word, which may be a refused name or somebody's words.
|
|
623
624
|
profile: settings ? namedProfile(settings) : undefined,
|
|
@@ -628,6 +629,9 @@ const keepFailure = async (failure, { definition, program, rest, argv, profile,
|
|
|
628
629
|
streams: options.streams ?? processStreams,
|
|
629
630
|
env,
|
|
630
631
|
...(settings ? { keepDays: settings.keepRunsForDays } : {}),
|
|
632
|
+
...(settings?.keepSuccessfulRunsForDays === undefined
|
|
633
|
+
? {}
|
|
634
|
+
: { keepSuccessDays: settings.keepSuccessfulRunsForDays }),
|
|
631
635
|
}, async () => {
|
|
632
636
|
throw failure;
|
|
633
637
|
}).catch(() => { });
|
|
@@ -655,11 +659,14 @@ const failed = ({ app }, program, rest, error, settled, debug) => {
|
|
|
655
659
|
? new CliError(told.code, told.message, { ...told.details, settlement_failed: true })
|
|
656
660
|
: told;
|
|
657
661
|
const effects = judgedEffects(path ? metaOf(commandAt(program, path) ?? program).effects : undefined);
|
|
658
|
-
const
|
|
662
|
+
const built = errorObjectOf(failure, {
|
|
659
663
|
...failureContext(app.errors),
|
|
660
664
|
targets: judgedTargets(program),
|
|
661
665
|
...(effects ? { effects } : {}),
|
|
662
666
|
});
|
|
667
|
+
const { next: _named, ...said } = built.error;
|
|
668
|
+
const steps = failureSteps(program, built.error);
|
|
669
|
+
const object = { ...built, error: { ...said, ...(steps.length > 0 ? { next: steps } : {}) } };
|
|
663
670
|
showInputFields(object, (path && commandAt(program, path)) || program);
|
|
664
671
|
const command = path || app.command;
|
|
665
672
|
return {
|
package/dist/cli/settings.d.ts
CHANGED
|
@@ -2,12 +2,20 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
import { type AISettings } from "../analysis/settings.js";
|
|
4
4
|
import { type AppIdentity } from "../ports/app.js";
|
|
5
|
+
import type { RecordInput } from "../runs/run-context.js";
|
|
5
6
|
import { type Level, type PermissionKey } from "../sends/permissions.js";
|
|
6
7
|
import { type ConfigIssue } from "./config-issues.js";
|
|
7
8
|
import type { CommandPermissions } from "./permission-keys.js";
|
|
8
9
|
export declare const plain: (rule: string) => (issue: v.BaseIssue<unknown>) => string;
|
|
9
10
|
export declare const count: v.SchemaWithPipe<readonly [v.NumberSchema<(issue: v.BaseIssue<unknown>) => string>, v.IntegerAction<number, (issue: v.BaseIssue<unknown>) => string>, v.MinValueAction<number, 1, (issue: v.BaseIssue<unknown>) => string>]>;
|
|
10
11
|
export declare const flag: v.BooleanSchema<(issue: v.BaseIssue<unknown>) => string>;
|
|
12
|
+
/** `record_input`: true, false, or "failed" — the words typed kept only in a run that failed. */
|
|
13
|
+
export declare const recordInputSetting: v.UnionSchema<[v.BooleanSchema<undefined>, v.LiteralSchema<"failed", undefined>], (issue: v.BaseIssue<unknown>) => string>;
|
|
14
|
+
/**
|
|
15
|
+
* Settings about messages, senders and bots. A CLI that is not a messenger reads none of them, so it neither lists nor
|
|
16
|
+
* takes them; a file that still has one is read as before.
|
|
17
|
+
*/
|
|
18
|
+
export declare const MESSENGER_ONLY_SETTINGS: readonly string[];
|
|
11
19
|
/**
|
|
12
20
|
* **What one messenger adds to the file**, merged into the one strict schema — a field an adapter
|
|
13
21
|
* reads but the schema did not know would be refused as unknown. Each entry must be optional.
|
|
@@ -102,15 +110,21 @@ export interface Settings extends AISettings {
|
|
|
102
110
|
* differently on purpose — milliseconds in the file, a duration with a unit on the command line.
|
|
103
111
|
*/
|
|
104
112
|
commandTimeoutMs: number | undefined;
|
|
113
|
+
/** Every run is kept unless the config says `record: false` or the command says `--no-record`. */
|
|
105
114
|
record: boolean;
|
|
106
115
|
/**
|
|
107
|
-
* A run record keeps the words typed, secrets hidden; off masks every value that may be content
|
|
108
|
-
* with settings of its own need not return it: left out, the words
|
|
116
|
+
* A run record keeps the words typed, secrets hidden; off masks every value that may be content; `"failed"` keeps
|
|
117
|
+
* them only in a run that failed. Optional so a CLI with settings of its own need not return it: left out, the words
|
|
118
|
+
* are kept.
|
|
109
119
|
*/
|
|
110
|
-
recordInput?:
|
|
111
|
-
/** A failed run is kept even unrecorded, unless
|
|
120
|
+
recordInput?: RecordInput;
|
|
121
|
+
/** A failed run is kept even unrecorded, unless `--no-record` turned recording off for this command. */
|
|
112
122
|
keepFailedRuns: boolean;
|
|
113
123
|
keepRunsForDays: number;
|
|
124
|
+
/** Successful runs go sooner than failed ones. Optional so a CLI with settings of its own need not return it. */
|
|
125
|
+
keepSuccessfulRunsForDays?: number;
|
|
126
|
+
/** The runs folder's size limit, in megabytes. */
|
|
127
|
+
runsSizeLimitMb?: number;
|
|
114
128
|
/** The variable that made this process read-only, above every level and flag (`<PREFIX>_READ_ONLY`). */
|
|
115
129
|
readOnlyLock?: string;
|
|
116
130
|
/**
|
|
@@ -276,8 +290,10 @@ export declare const settingsFor: <T extends object = Record<never, never>>(app:
|
|
|
276
290
|
color: v.OptionalSchema<v.BooleanSchema<(issue: v.BaseIssue<unknown>) => string>, undefined>;
|
|
277
291
|
sender_colors: v.OptionalSchema<v.BooleanSchema<(issue: v.BaseIssue<unknown>) => string>, undefined>;
|
|
278
292
|
record: v.OptionalSchema<v.BooleanSchema<(issue: v.BaseIssue<unknown>) => string>, undefined>;
|
|
279
|
-
record_input: v.OptionalSchema<v.BooleanSchema<(issue: v.BaseIssue<unknown>) => string>, undefined>;
|
|
293
|
+
record_input: v.OptionalSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.LiteralSchema<"failed", undefined>], (issue: v.BaseIssue<unknown>) => string>, undefined>;
|
|
280
294
|
keep_runs_for_days: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<(issue: v.BaseIssue<unknown>) => string>, v.IntegerAction<number, (issue: v.BaseIssue<unknown>) => string>, v.MinValueAction<number, 1, (issue: v.BaseIssue<unknown>) => string>]>, undefined>;
|
|
295
|
+
keep_successful_runs_for_days: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<(issue: v.BaseIssue<unknown>) => string>, v.IntegerAction<number, (issue: v.BaseIssue<unknown>) => string>, v.MinValueAction<number, 1, (issue: v.BaseIssue<unknown>) => string>]>, undefined>;
|
|
296
|
+
runs_size_limit_mb: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<(issue: v.BaseIssue<unknown>) => string>, v.IntegerAction<number, (issue: v.BaseIssue<unknown>) => string>, v.MinValueAction<number, 1, (issue: v.BaseIssue<unknown>) => string>]>, undefined>;
|
|
281
297
|
permissions: v.OptionalSchema<v.RecordSchema<v.GenericSchema<string>, v.PicklistSchema<readonly ["deny", "readonly", "ask", "allow"], (issue: v.PicklistIssue) => string>, (issue: v.BaseIssue<unknown>) => string>, undefined>;
|
|
282
298
|
sends_per_hour: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<(issue: v.BaseIssue<unknown>) => string>, v.IntegerAction<number, (issue: v.BaseIssue<unknown>) => string>, v.MinValueAction<number, 1, (issue: v.BaseIssue<unknown>) => string>]>, undefined>;
|
|
283
299
|
requests_per_minute: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<(issue: v.BaseIssue<unknown>) => string>, v.IntegerAction<number, (issue: v.BaseIssue<unknown>) => string>, v.MinValueAction<number, 0, (issue: v.BaseIssue<unknown>) => string>]>, undefined>;
|
|
@@ -350,8 +366,10 @@ export declare const settingsFor: <T extends object = Record<never, never>>(app:
|
|
|
350
366
|
color: v.OptionalSchema<v.BooleanSchema<(issue: v.BaseIssue<unknown>) => string>, undefined>;
|
|
351
367
|
sender_colors: v.OptionalSchema<v.BooleanSchema<(issue: v.BaseIssue<unknown>) => string>, undefined>;
|
|
352
368
|
record: v.OptionalSchema<v.BooleanSchema<(issue: v.BaseIssue<unknown>) => string>, undefined>;
|
|
353
|
-
record_input: v.OptionalSchema<v.BooleanSchema<(issue: v.BaseIssue<unknown>) => string>, undefined>;
|
|
369
|
+
record_input: v.OptionalSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.LiteralSchema<"failed", undefined>], (issue: v.BaseIssue<unknown>) => string>, undefined>;
|
|
354
370
|
keep_runs_for_days: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<(issue: v.BaseIssue<unknown>) => string>, v.IntegerAction<number, (issue: v.BaseIssue<unknown>) => string>, v.MinValueAction<number, 1, (issue: v.BaseIssue<unknown>) => string>]>, undefined>;
|
|
371
|
+
keep_successful_runs_for_days: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<(issue: v.BaseIssue<unknown>) => string>, v.IntegerAction<number, (issue: v.BaseIssue<unknown>) => string>, v.MinValueAction<number, 1, (issue: v.BaseIssue<unknown>) => string>]>, undefined>;
|
|
372
|
+
runs_size_limit_mb: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<(issue: v.BaseIssue<unknown>) => string>, v.IntegerAction<number, (issue: v.BaseIssue<unknown>) => string>, v.MinValueAction<number, 1, (issue: v.BaseIssue<unknown>) => string>]>, undefined>;
|
|
355
373
|
permissions: v.OptionalSchema<v.RecordSchema<v.GenericSchema<string>, v.PicklistSchema<readonly ["deny", "readonly", "ask", "allow"], (issue: v.PicklistIssue) => string>, (issue: v.BaseIssue<unknown>) => string>, undefined>;
|
|
356
374
|
sends_per_hour: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<(issue: v.BaseIssue<unknown>) => string>, v.IntegerAction<number, (issue: v.BaseIssue<unknown>) => string>, v.MinValueAction<number, 1, (issue: v.BaseIssue<unknown>) => string>]>, undefined>;
|
|
357
375
|
requests_per_minute: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<(issue: v.BaseIssue<unknown>) => string>, v.IntegerAction<number, (issue: v.BaseIssue<unknown>) => string>, v.MinValueAction<number, 0, (issue: v.BaseIssue<unknown>) => string>]>, undefined>;
|
package/dist/cli/settings.js
CHANGED
|
@@ -5,6 +5,7 @@ import { AI_ENTRIES, resolveAISettings } from "../analysis/settings.js";
|
|
|
5
5
|
import { parseDuration } from "../domain/duration.js";
|
|
6
6
|
import { DEFAULT_RERANK_MODEL, RERANK_MODELS } from "../embeddings/models.js";
|
|
7
7
|
import { envName, readOnlyLockOf } from "../ports/app.js";
|
|
8
|
+
import { KEEP_SUCCESSFUL_RUNS_FOR_DAYS, RUNS_SIZE_LIMIT_MB } from "../runs/run.js";
|
|
8
9
|
import { assertOverridesTighten, CEILING_KEY, COMMAND_PATH_KEY, LEVELS, layerPermissions, permissionOverrides, RESOURCE_KEY, RESOURCES, } from "../sends/permissions.js";
|
|
9
10
|
import { storePath } from "../store/path.js";
|
|
10
11
|
import { sharedConfigPath } from "../store/shared-config.js";
|
|
@@ -33,6 +34,8 @@ export const count = v.pipe(v.number(wholeNumber), v.integer(wholeNumber), v.min
|
|
|
33
34
|
const zeroOrMore = plain("has to be a whole number, 0 or more");
|
|
34
35
|
const countOrZero = v.pipe(v.number(zeroOrMore), v.integer(zeroOrMore), v.minValue(0, zeroOrMore));
|
|
35
36
|
export const flag = v.boolean(plain("has to be true or false"));
|
|
37
|
+
/** `record_input`: true, false, or "failed" — the words typed kept only in a run that failed. */
|
|
38
|
+
export const recordInputSetting = v.union([v.boolean(), v.literal("failed")], plain('has to be true, false or "failed"'));
|
|
36
39
|
const wholeOrZero = (text, name) => {
|
|
37
40
|
const value = Number(text);
|
|
38
41
|
if (!Number.isInteger(value) || value < 0)
|
|
@@ -58,8 +61,10 @@ const SHARED_PROFILE_ENTRIES = {
|
|
|
58
61
|
color: v.optional(flag),
|
|
59
62
|
sender_colors: v.optional(flag),
|
|
60
63
|
record: v.optional(flag),
|
|
61
|
-
record_input: v.optional(
|
|
64
|
+
record_input: v.optional(recordInputSetting),
|
|
62
65
|
keep_runs_for_days: v.optional(count),
|
|
66
|
+
keep_successful_runs_for_days: v.optional(count),
|
|
67
|
+
runs_size_limit_mb: v.optional(count),
|
|
63
68
|
permissions: v.optional(permissionLevels),
|
|
64
69
|
sends_per_hour: v.optional(count),
|
|
65
70
|
requests_per_minute: v.optional(countOrZero),
|
|
@@ -77,6 +82,17 @@ const SHARED_PROFILE_ENTRIES = {
|
|
|
77
82
|
const BOT_ONLY_ENTRIES = {
|
|
78
83
|
read_other_bots: v.optional(v.union([flag, v.array(v.string(), plain("has to be a list of profile names"))], plain("has to be true, false or a list of profile names"))),
|
|
79
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* Settings about messages, senders and bots. A CLI that is not a messenger reads none of them, so it neither lists nor
|
|
87
|
+
* takes them; a file that still has one is read as before.
|
|
88
|
+
*/
|
|
89
|
+
export const MESSENGER_ONLY_SETTINGS = [
|
|
90
|
+
"sender_colors",
|
|
91
|
+
"sends_per_hour",
|
|
92
|
+
"transcribe_with",
|
|
93
|
+
"search_catch_up",
|
|
94
|
+
"read_other_bots",
|
|
95
|
+
];
|
|
80
96
|
/** One program, one version: whether to look for a newer one is not a per-profile matter. */
|
|
81
97
|
const SHARED_DEFAULTS_ONLY = {
|
|
82
98
|
update_check: v.optional(flag),
|
|
@@ -146,7 +162,7 @@ export const settingsFor = (app, extension = {}) => {
|
|
|
146
162
|
const schema = strictOf(configEntries);
|
|
147
163
|
const defaultsOnlyKeys = Object.keys(defaultsOnly);
|
|
148
164
|
const botOnlyKeys = Object.keys(BOT_ONLY_ENTRIES);
|
|
149
|
-
const allSettings = [...Object.keys(profileEntries), ...botOnlyKeys, ...defaultsOnlyKeys];
|
|
165
|
+
const allSettings = [...Object.keys(profileEntries), ...botOnlyKeys, ...defaultsOnlyKeys].filter((setting) => app.messenger !== false || !MESSENGER_ONLY_SETTINGS.includes(setting));
|
|
150
166
|
const PROFILE = envName(app, "PROFILE");
|
|
151
167
|
const PROFILE_LOCK = envName(app, "PROFILE_LOCK");
|
|
152
168
|
const TIMEOUT = envName(app, "TIMEOUT");
|
|
@@ -232,7 +248,7 @@ export const settingsFor = (app, extension = {}) => {
|
|
|
232
248
|
const fromLayers = (key, fallback, only = layers) => first(only.map(([from, scope]) => [from, scope?.[key]]), fallback);
|
|
233
249
|
const kindLayers = layers.filter(([from]) => from.startsWith(`config file: ${kind}.`));
|
|
234
250
|
const limit = flags.limit === undefined ? fromLayers("limit", DEFAULT_LIMIT) : { value: flags.limit, from: "flag" };
|
|
235
|
-
const record = flags.record === undefined ? fromLayers("record",
|
|
251
|
+
const record = flags.record === undefined ? fromLayers("record", true) : { value: flags.record, from: "flag" };
|
|
236
252
|
const timeoutMs = fromLayers("timeout_ms", undefined);
|
|
237
253
|
const color = fromLayers("color", undefined);
|
|
238
254
|
const senderColors = fromLayers("sender_colors", false);
|
|
@@ -241,6 +257,8 @@ export const settingsFor = (app, extension = {}) => {
|
|
|
241
257
|
const searchReranker = fromLayers("search_reranker", DEFAULT_RERANK_MODEL);
|
|
242
258
|
const recordInput = fromLayers("record_input", true);
|
|
243
259
|
const keepRunsForDays = fromLayers("keep_runs_for_days", DEFAULT_KEEP_RUNS_FOR_DAYS);
|
|
260
|
+
const keepSuccessfulRunsForDays = fromLayers("keep_successful_runs_for_days", KEEP_SUCCESSFUL_RUNS_FOR_DAYS);
|
|
261
|
+
const runsSizeLimitMb = fromLayers("runs_size_limit_mb", RUNS_SIZE_LIMIT_MB);
|
|
244
262
|
// Set where an agent runs unattended; the config file and `--permission` cannot undo it.
|
|
245
263
|
const readOnlyLock = readOnlyLockOf(app, env);
|
|
246
264
|
// A bot has no hourly limit unless the bot section gives it one: a bot that answers people is
|
|
@@ -297,8 +315,10 @@ export const settingsFor = (app, extension = {}) => {
|
|
|
297
315
|
: (extension.parseDuration ?? parseDuration)(timeout.value, timeout.from === TIMEOUT ? TIMEOUT : "--timeout"),
|
|
298
316
|
record: record.value,
|
|
299
317
|
recordInput: recordInput.value,
|
|
300
|
-
keepFailedRuns: record.value || record.from
|
|
318
|
+
keepFailedRuns: record.value || record.from !== "flag",
|
|
301
319
|
keepRunsForDays: keepRunsForDays.value,
|
|
320
|
+
keepSuccessfulRunsForDays: keepSuccessfulRunsForDays.value,
|
|
321
|
+
runsSizeLimitMb: runsSizeLimitMb.value,
|
|
302
322
|
...(readOnlyLock ? { readOnlyLock } : {}),
|
|
303
323
|
permissions: permissions.levels,
|
|
304
324
|
permissionSources: permissions.sources,
|
|
@@ -326,6 +346,8 @@ export const settingsFor = (app, extension = {}) => {
|
|
|
326
346
|
record: record.from,
|
|
327
347
|
recordInput: recordInput.from,
|
|
328
348
|
keepRunsForDays: keepRunsForDays.from,
|
|
349
|
+
keepSuccessfulRunsForDays: keepSuccessfulRunsForDays.from,
|
|
350
|
+
runsSizeLimitMb: runsSizeLimitMb.from,
|
|
329
351
|
sendsPerHour: sendsPerHour.from,
|
|
330
352
|
requestsPerMinute: requestsPerMinute.from,
|
|
331
353
|
readOtherBots: readOtherBots.from,
|
|
@@ -79,8 +79,10 @@ export declare const configCommand: (app: import("./entry.js").AppIdentity, conf
|
|
|
79
79
|
color: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
80
80
|
sender_colors: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
81
81
|
record: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
82
|
-
record_input: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
82
|
+
record_input: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").BooleanSchema<undefined>, import("valibot").LiteralSchema<"failed", undefined>], (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
83
83
|
keep_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
84
|
+
keep_successful_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
85
|
+
runs_size_limit_mb: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
84
86
|
permissions: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").GenericSchema<string>, import("valibot").PicklistSchema<readonly ["deny", "readonly", "ask", "allow"], (issue: import("valibot").PicklistIssue) => string>, (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
85
87
|
sends_per_hour: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
86
88
|
requests_per_minute: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 0, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
@@ -153,8 +155,10 @@ export declare const configCommand: (app: import("./entry.js").AppIdentity, conf
|
|
|
153
155
|
color: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
154
156
|
sender_colors: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
155
157
|
record: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
156
|
-
record_input: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
158
|
+
record_input: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").BooleanSchema<undefined>, import("valibot").LiteralSchema<"failed", undefined>], (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
157
159
|
keep_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
160
|
+
keep_successful_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
161
|
+
runs_size_limit_mb: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
158
162
|
permissions: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").GenericSchema<string>, import("valibot").PicklistSchema<readonly ["deny", "readonly", "ask", "allow"], (issue: import("valibot").PicklistIssue) => string>, (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
159
163
|
sends_per_hour: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
160
164
|
requests_per_minute: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 0, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
@@ -283,8 +287,10 @@ export declare const completeCommand: (messenger: import("./index.js").Messenger
|
|
|
283
287
|
color: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
284
288
|
sender_colors: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
285
289
|
record: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
286
|
-
record_input: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
290
|
+
record_input: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").BooleanSchema<undefined>, import("valibot").LiteralSchema<"failed", undefined>], (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
287
291
|
keep_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
292
|
+
keep_successful_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
293
|
+
runs_size_limit_mb: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
288
294
|
permissions: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").GenericSchema<string>, import("valibot").PicklistSchema<readonly ["deny", "readonly", "ask", "allow"], (issue: import("valibot").PicklistIssue) => string>, (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
289
295
|
sends_per_hour: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
290
296
|
requests_per_minute: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 0, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
@@ -357,8 +363,10 @@ export declare const completeCommand: (messenger: import("./index.js").Messenger
|
|
|
357
363
|
color: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
358
364
|
sender_colors: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
359
365
|
record: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
360
|
-
record_input: import("valibot").OptionalSchema<import("valibot").BooleanSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
366
|
+
record_input: import("valibot").OptionalSchema<import("valibot").UnionSchema<[import("valibot").BooleanSchema<undefined>, import("valibot").LiteralSchema<"failed", undefined>], (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
361
367
|
keep_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
368
|
+
keep_successful_runs_for_days: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
369
|
+
runs_size_limit_mb: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
362
370
|
permissions: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").GenericSchema<string>, import("valibot").PicklistSchema<readonly ["deny", "readonly", "ask", "allow"], (issue: import("valibot").PicklistIssue) => string>, (issue: import("valibot").BaseIssue<unknown>) => string>, undefined>;
|
|
363
371
|
sends_per_hour: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 1, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
364
372
|
requests_per_minute: import("valibot").OptionalSchema<import("valibot").SchemaWithPipe<readonly [import("valibot").NumberSchema<(issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").IntegerAction<number, (issue: import("valibot").BaseIssue<unknown>) => string>, import("valibot").MinValueAction<number, 0, (issue: import("valibot").BaseIssue<unknown>) => string>]>, undefined>;
|
|
@@ -14,7 +14,7 @@ export const skillCommand = (app, skill) => {
|
|
|
14
14
|
// cli-base prints each answer bare; the envelope is cli-core's.
|
|
15
15
|
const renderer = { ...output.renderer, result: (value) => printItem(output, value) };
|
|
16
16
|
return { ...output, renderer, ...(env ? { env } : {}) };
|
|
17
|
-
}, SHARED_SKILLS);
|
|
17
|
+
}, app.messenger === false ? {} : SHARED_SKILLS);
|
|
18
18
|
// An installed skill is instructions every later agent follows.
|
|
19
19
|
const install = command.commands.find((sub) => sub.name() === "install");
|
|
20
20
|
if (install) {
|
|
@@ -23,10 +23,18 @@ export const skillCommand = (app, skill) => {
|
|
|
23
23
|
}
|
|
24
24
|
const show = command.commands.find((sub) => sub.name() === "show");
|
|
25
25
|
if (show)
|
|
26
|
-
annotate(show, {
|
|
26
|
+
annotate(show, {
|
|
27
|
+
examples: [
|
|
28
|
+
`${app.command} skill show`,
|
|
29
|
+
...(app.messenger === false ? [] : [`${app.command} skill show follow-ups`]),
|
|
30
|
+
],
|
|
31
|
+
});
|
|
27
32
|
return command;
|
|
28
33
|
};
|
|
29
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Skills this package ships for the messenger CLIs, printed by `skill show <name>`: `skills/` beside `dist/` and `src/`.
|
|
36
|
+
* Both work on chats, so a CLI without them offers neither.
|
|
37
|
+
*/
|
|
30
38
|
const SHARED_SKILLS = {
|
|
31
39
|
"follow-ups": new URL("../../skills/follow-ups/SKILL.md", import.meta.url),
|
|
32
40
|
"link-conversations": new URL("../../skills/link-conversations/SKILL.md", import.meta.url),
|
package/dist/cli/steps.d.ts
CHANGED
|
@@ -35,6 +35,15 @@ type Targets = NonNullable<StepInput["targets"]>;
|
|
|
35
35
|
* remotely.
|
|
36
36
|
*/
|
|
37
37
|
export declare const runnable: (root: Command, steps: readonly NextStep[] | undefined) => NextStep[];
|
|
38
|
+
/**
|
|
39
|
+
* The step a failure names, where its reason has one and this CLI has the command: a model that is not downloaded
|
|
40
|
+
* names its download only in a CLI with `models`. A step the error already carries is kept, also only if runnable.
|
|
41
|
+
*/
|
|
42
|
+
export declare const failureSteps: (root: Command, error: {
|
|
43
|
+
reason?: string;
|
|
44
|
+
details?: Record<string, unknown>;
|
|
45
|
+
next?: readonly NextStep[];
|
|
46
|
+
}) => NextStep[];
|
|
38
47
|
/** Each command step judged by its command's effects: safe to run unasked only when it writes nothing remotely. */
|
|
39
48
|
export declare const withSafety: (steps: readonly NextStep[], targets: Targets) => NextStep[];
|
|
40
49
|
/** Each command step with `line`, the whole command to type — only the CLI knows the profile, so MCP gets none. */
|
package/dist/cli/steps.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { STEPS as BASE_STEPS, defineSteps, MAX_NEXT_STEPS, stepOf, writes, } from "@wirecat/cli-base/standards";
|
|
2
|
+
import { IMAGE_MODELS } from "../images/picture/models.js";
|
|
2
3
|
import { typedCommand } from "../runs/scope.js";
|
|
3
4
|
import { judgedTargets } from "./effects.js";
|
|
4
5
|
/**
|
|
@@ -245,6 +246,21 @@ export const commandAt = (root, path) => {
|
|
|
245
246
|
export const runnable = (root, steps) => withSafety((steps ?? [])
|
|
246
247
|
.filter((step) => step.kind === "user_action" || commandAt(root, step.command) !== undefined)
|
|
247
248
|
.slice(0, MAX_NEXT_STEPS), judgedTargets(root));
|
|
249
|
+
/**
|
|
250
|
+
* The step a failure names, where its reason has one and this CLI has the command: a model that is not downloaded
|
|
251
|
+
* names its download only in a CLI with `models`. A step the error already carries is kept, also only if runnable.
|
|
252
|
+
*/
|
|
253
|
+
export const failureSteps = (root, error) => {
|
|
254
|
+
const model = error.details?.model;
|
|
255
|
+
const own = error.reason === "model.not-downloaded" && typeof model === "string"
|
|
256
|
+
? [
|
|
257
|
+
nextStep(IMAGE_MODELS.some((one) => one.id === model) ? "models.download-image" : "models.download", {
|
|
258
|
+
args: { model },
|
|
259
|
+
}),
|
|
260
|
+
]
|
|
261
|
+
: [];
|
|
262
|
+
return runnable(root, [...(error.next ?? []), ...own]);
|
|
263
|
+
};
|
|
248
264
|
/** Each command step judged by its command's effects: safe to run unasked only when it writes nothing remotely. */
|
|
249
265
|
export const withSafety = (steps, targets) => steps.map((step) => {
|
|
250
266
|
if (step.kind === "user_action")
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { AppIdentity } from "../ports/app.js";
|
|
2
2
|
/** Settings of the store file, not of a profile: the store is one file for every profile, tg and MAX. */
|
|
3
3
|
export declare const STORE_SETTINGS: string[];
|
|
4
|
+
/**
|
|
5
|
+
* The store settings a CLI offers. Phone countries, task rules and account groups belong to messages; a CLI that is
|
|
6
|
+
* not a messenger would change them for tg and MAX without reading them itself.
|
|
7
|
+
*/
|
|
8
|
+
export declare const storeSettingsOf: (app: Pick<AppIdentity, "messenger">) => string[];
|
|
9
|
+
export declare const offersStoreSetting: (app: Pick<AppIdentity, "messenger">, setting: string) => boolean;
|
|
4
10
|
export declare const isStoreSetting: (setting: string) => boolean;
|
|
5
11
|
export declare const changeStoreSetting: (app: AppIdentity, env: NodeJS.ProcessEnv, setting: string, value: string | undefined) => Promise<{
|
|
6
12
|
result: {
|
|
@@ -29,6 +29,12 @@ export const STORE_SETTINGS = [
|
|
|
29
29
|
FIRST_PASS,
|
|
30
30
|
];
|
|
31
31
|
const GROUP_PREFIX = `${ACCOUNT_GROUPS_SETTING}.`;
|
|
32
|
+
/**
|
|
33
|
+
* The store settings a CLI offers. Phone countries, task rules and account groups belong to messages; a CLI that is
|
|
34
|
+
* not a messenger would change them for tg and MAX without reading them itself.
|
|
35
|
+
*/
|
|
36
|
+
export const storeSettingsOf = (app) => app.messenger === false ? Object.keys(SCRIPTS) : [...STORE_SETTINGS, `${GROUP_PREFIX}<name>`];
|
|
37
|
+
export const offersStoreSetting = (app, setting) => app.messenger !== false || setting in SCRIPTS;
|
|
32
38
|
export const isStoreSetting = (setting) => setting in SCRIPTS ||
|
|
33
39
|
setting === PHONE_COUNTRIES ||
|
|
34
40
|
setting === TASK_CATEGORIES ||
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -6312,7 +6312,20 @@ export declare const ENTITIES: {
|
|
|
6312
6312
|
readonly kind: v.StringSchema<undefined>;
|
|
6313
6313
|
readonly session_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6314
6314
|
readonly from_chat: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
6315
|
+
readonly client: v.OptionalSchema<v.StrictObjectSchema<{
|
|
6316
|
+
readonly name: v.StringSchema<undefined>;
|
|
6317
|
+
readonly version: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6318
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6319
|
+
}, undefined>, undefined>;
|
|
6315
6320
|
}, undefined>, undefined>;
|
|
6321
|
+
readonly via: v.OptionalSchema<v.PicklistSchema<["cli", "mcp-stdio", "mcp-http", "desktop"], undefined>, undefined>;
|
|
6322
|
+
readonly mcp: v.OptionalSchema<v.StrictObjectSchema<{
|
|
6323
|
+
readonly tool: v.StringSchema<undefined>;
|
|
6324
|
+
readonly request_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6325
|
+
readonly connection_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6326
|
+
readonly proxied: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
6327
|
+
}, undefined>, undefined>;
|
|
6328
|
+
readonly events_dropped: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
6316
6329
|
readonly error: v.OptionalSchema<v.StrictObjectSchema<{
|
|
6317
6330
|
readonly class: v.StringSchema<undefined>;
|
|
6318
6331
|
readonly code: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -6375,7 +6388,20 @@ export declare const ENTITIES: {
|
|
|
6375
6388
|
readonly kind: v.StringSchema<undefined>;
|
|
6376
6389
|
readonly session_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6377
6390
|
readonly from_chat: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
6391
|
+
readonly client: v.OptionalSchema<v.StrictObjectSchema<{
|
|
6392
|
+
readonly name: v.StringSchema<undefined>;
|
|
6393
|
+
readonly version: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6394
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6395
|
+
}, undefined>, undefined>;
|
|
6396
|
+
}, undefined>, undefined>;
|
|
6397
|
+
readonly via: v.OptionalSchema<v.PicklistSchema<["cli", "mcp-stdio", "mcp-http", "desktop"], undefined>, undefined>;
|
|
6398
|
+
readonly mcp: v.OptionalSchema<v.StrictObjectSchema<{
|
|
6399
|
+
readonly tool: v.StringSchema<undefined>;
|
|
6400
|
+
readonly request_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6401
|
+
readonly connection_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6402
|
+
readonly proxied: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
6378
6403
|
}, undefined>, undefined>;
|
|
6404
|
+
readonly events_dropped: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
6379
6405
|
readonly error: v.OptionalSchema<v.StrictObjectSchema<{
|
|
6380
6406
|
readonly class: v.StringSchema<undefined>;
|
|
6381
6407
|
readonly code: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -6437,7 +6463,20 @@ export declare const ENTITIES: {
|
|
|
6437
6463
|
readonly kind: v.StringSchema<undefined>;
|
|
6438
6464
|
readonly session_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6439
6465
|
readonly from_chat: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
6466
|
+
readonly client: v.OptionalSchema<v.StrictObjectSchema<{
|
|
6467
|
+
readonly name: v.StringSchema<undefined>;
|
|
6468
|
+
readonly version: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6469
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6470
|
+
}, undefined>, undefined>;
|
|
6471
|
+
}, undefined>, undefined>;
|
|
6472
|
+
readonly via: v.OptionalSchema<v.PicklistSchema<["cli", "mcp-stdio", "mcp-http", "desktop"], undefined>, undefined>;
|
|
6473
|
+
readonly mcp: v.OptionalSchema<v.StrictObjectSchema<{
|
|
6474
|
+
readonly tool: v.StringSchema<undefined>;
|
|
6475
|
+
readonly request_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6476
|
+
readonly connection_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6477
|
+
readonly proxied: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
6440
6478
|
}, undefined>, undefined>;
|
|
6479
|
+
readonly events_dropped: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
6441
6480
|
readonly error: v.OptionalSchema<v.StrictObjectSchema<{
|
|
6442
6481
|
readonly class: v.StringSchema<undefined>;
|
|
6443
6482
|
readonly code: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -35,7 +35,20 @@ export declare const recordedRun: v.StrictObjectSchema<{
|
|
|
35
35
|
readonly kind: v.StringSchema<undefined>;
|
|
36
36
|
readonly session_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
37
37
|
readonly from_chat: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
38
|
+
readonly client: v.OptionalSchema<v.StrictObjectSchema<{
|
|
39
|
+
readonly name: v.StringSchema<undefined>;
|
|
40
|
+
readonly version: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
41
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
42
|
+
}, undefined>, undefined>;
|
|
43
|
+
}, undefined>, undefined>;
|
|
44
|
+
readonly via: v.OptionalSchema<v.PicklistSchema<["cli", "mcp-stdio", "mcp-http", "desktop"], undefined>, undefined>;
|
|
45
|
+
readonly mcp: v.OptionalSchema<v.StrictObjectSchema<{
|
|
46
|
+
readonly tool: v.StringSchema<undefined>;
|
|
47
|
+
readonly request_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
48
|
+
readonly connection_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
49
|
+
readonly proxied: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
38
50
|
}, undefined>, undefined>;
|
|
51
|
+
readonly events_dropped: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
39
52
|
readonly error: v.OptionalSchema<v.StrictObjectSchema<{
|
|
40
53
|
readonly class: v.StringSchema<undefined>;
|
|
41
54
|
readonly code: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -98,7 +111,20 @@ export declare const runDetails: v.StrictObjectSchema<{
|
|
|
98
111
|
readonly kind: v.StringSchema<undefined>;
|
|
99
112
|
readonly session_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
100
113
|
readonly from_chat: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
114
|
+
readonly client: v.OptionalSchema<v.StrictObjectSchema<{
|
|
115
|
+
readonly name: v.StringSchema<undefined>;
|
|
116
|
+
readonly version: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
117
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
118
|
+
}, undefined>, undefined>;
|
|
101
119
|
}, undefined>, undefined>;
|
|
120
|
+
readonly via: v.OptionalSchema<v.PicklistSchema<["cli", "mcp-stdio", "mcp-http", "desktop"], undefined>, undefined>;
|
|
121
|
+
readonly mcp: v.OptionalSchema<v.StrictObjectSchema<{
|
|
122
|
+
readonly tool: v.StringSchema<undefined>;
|
|
123
|
+
readonly request_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
124
|
+
readonly connection_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
125
|
+
readonly proxied: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
126
|
+
}, undefined>, undefined>;
|
|
127
|
+
readonly events_dropped: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
102
128
|
readonly error: v.OptionalSchema<v.StrictObjectSchema<{
|
|
103
129
|
readonly class: v.StringSchema<undefined>;
|
|
104
130
|
readonly code: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -160,7 +186,20 @@ export declare const runHit: v.StrictObjectSchema<{
|
|
|
160
186
|
readonly kind: v.StringSchema<undefined>;
|
|
161
187
|
readonly session_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
162
188
|
readonly from_chat: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
189
|
+
readonly client: v.OptionalSchema<v.StrictObjectSchema<{
|
|
190
|
+
readonly name: v.StringSchema<undefined>;
|
|
191
|
+
readonly version: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
192
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
193
|
+
}, undefined>, undefined>;
|
|
194
|
+
}, undefined>, undefined>;
|
|
195
|
+
readonly via: v.OptionalSchema<v.PicklistSchema<["cli", "mcp-stdio", "mcp-http", "desktop"], undefined>, undefined>;
|
|
196
|
+
readonly mcp: v.OptionalSchema<v.StrictObjectSchema<{
|
|
197
|
+
readonly tool: v.StringSchema<undefined>;
|
|
198
|
+
readonly request_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
199
|
+
readonly connection_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
200
|
+
readonly proxied: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
163
201
|
}, undefined>, undefined>;
|
|
202
|
+
readonly events_dropped: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
164
203
|
readonly error: v.OptionalSchema<v.StrictObjectSchema<{
|
|
165
204
|
readonly class: v.StringSchema<undefined>;
|
|
166
205
|
readonly code: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|