@epoch-agent/cli 5.0.0 → 6.0.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/README.md +3 -4
- package/dist/index.js +380 -531
- package/dist/tui-entry.js +141 -291
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// src/index.ts
|
|
3
3
|
import { Command } from "commander";
|
|
4
|
-
import { t as
|
|
4
|
+
import { t as t39 } from "@epoch-agent/infra";
|
|
5
5
|
// src/commands/agents.ts
|
|
6
6
|
import { AGENT_ROLE_DIAG_MODULE, findRole, roleSourceLabel } from "@epoch-agent/core";
|
|
7
7
|
import { t as t2, UNLIMITED_TURNS } from "@epoch-agent/infra";
|
|
@@ -648,8 +648,8 @@ function registerConfigCommand(program2) {
|
|
|
648
648
|
}
|
|
649
649
|
function registerSchemaCommand(cmd) {
|
|
650
650
|
cmd.command("schema").description(t6("cli.config.schema")).action(async () => {
|
|
651
|
-
const { resolveProjectRoot:
|
|
652
|
-
const root =
|
|
651
|
+
const { resolveProjectRoot: resolveProjectRoot3 } = await import("@epoch-agent/core");
|
|
652
|
+
const root = resolveProjectRoot3(process.cwd());
|
|
653
653
|
const { writeProjectSchemas } = await import("./schema-file-DH6X4N4K.js");
|
|
654
654
|
const written = await writeProjectSchemas(root);
|
|
655
655
|
for (const entry of written) log4(`\u2705 ${entry.path}`);
|
|
@@ -684,8 +684,8 @@ async function printSecretStatus(store) {
|
|
|
684
684
|
for (const name of names) log4(` ${name}`);
|
|
685
685
|
}
|
|
686
686
|
async function exportSecrets(store) {
|
|
687
|
-
const { isNonInteractive:
|
|
688
|
-
if (
|
|
687
|
+
const { isNonInteractive: isNonInteractive8 } = await import("@epoch-agent/core");
|
|
688
|
+
if (isNonInteractive8()) {
|
|
689
689
|
throw new CliError(t6("cli.config.export_needs_tty"), 1, t6("cli.config.export_needs_tty_hint"));
|
|
690
690
|
}
|
|
691
691
|
const { confirm } = await import("@inquirer/prompts");
|
|
@@ -1054,12 +1054,12 @@ function isHttpUrl(value) {
|
|
|
1054
1054
|
}
|
|
1055
1055
|
}
|
|
1056
1056
|
async function pickModel(models) {
|
|
1057
|
-
const
|
|
1058
|
-
if (
|
|
1057
|
+
const choices2 = modelChoices(models);
|
|
1058
|
+
if (choices2.length > 0) {
|
|
1059
1059
|
const picked = await select({
|
|
1060
1060
|
message: t8("model.pick_model"),
|
|
1061
|
-
choices:
|
|
1062
|
-
pageSize: listPageSize(
|
|
1061
|
+
choices: choices2,
|
|
1062
|
+
pageSize: listPageSize(choices2.length)
|
|
1063
1063
|
});
|
|
1064
1064
|
if (picked !== CUSTOM) return picked;
|
|
1065
1065
|
}
|
|
@@ -1509,8 +1509,8 @@ async function packDir(dir, out2) {
|
|
|
1509
1509
|
import { existsSync as existsSync6 } from "fs";
|
|
1510
1510
|
import { dirname as dirname4, join as join5 } from "path";
|
|
1511
1511
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
1512
|
-
import { isNonInteractive as
|
|
1513
|
-
import { guardSpawn as guardSpawn3, t as
|
|
1512
|
+
import { isNonInteractive as isNonInteractive7, OPERATION_TYPES as OPERATION_TYPES3, PERMISSION_LEVELS as PERMISSION_LEVELS3 } from "@epoch-agent/core";
|
|
1513
|
+
import { guardSpawn as guardSpawn3, t as t25 } from "@epoch-agent/infra";
|
|
1514
1514
|
import { HEADLESS_INPUT_FORMATS as HEADLESS_INPUT_FORMATS2, HEADLESS_OUTPUT_FORMATS as HEADLESS_OUTPUT_FORMATS2 } from "@epoch-agent/protocol";
|
|
1515
1515
|
// src/headless/session.ts
|
|
1516
1516
|
import { OPERATION_TYPES } from "@epoch-agent/core";
|
|
@@ -1787,7 +1787,7 @@ function initInfoOf(runtime, cwd) {
|
|
|
1787
1787
|
model: runtime.model?.get().model ?? runtime.config.model ?? "",
|
|
1788
1788
|
...provider ? { provider } : {},
|
|
1789
1789
|
permissionLevel: runtime.permissions.level(),
|
|
1790
|
-
tools: runtime.tools.map((
|
|
1790
|
+
tools: runtime.tools.map((t40) => t40.name),
|
|
1791
1791
|
usageScope: runtime.usageScope,
|
|
1792
1792
|
diagnostics: runtime.diagnostics
|
|
1793
1793
|
};
|
|
@@ -2649,7 +2649,7 @@ async function askRemove(session) {
|
|
|
2649
2649
|
}
|
|
2650
2650
|
// src/commands/run-once.ts
|
|
2651
2651
|
import { formatUsd, imageFromPath, OPERATION_TYPES as OPERATION_TYPES2 } from "@epoch-agent/core";
|
|
2652
|
-
import { t as
|
|
2652
|
+
import { t as t22 } from "@epoch-agent/infra";
|
|
2653
2653
|
import {
|
|
2654
2654
|
promptTokens
|
|
2655
2655
|
} from "@epoch-agent/protocol";
|
|
@@ -2738,7 +2738,7 @@ function approvalChoices(req) {
|
|
|
2738
2738
|
}
|
|
2739
2739
|
async function askPlan(proposal) {
|
|
2740
2740
|
const { input: input2, select: select2 } = await import("@inquirer/prompts");
|
|
2741
|
-
const
|
|
2741
|
+
const choices2 = [
|
|
2742
2742
|
...proposal.canExecute ? [
|
|
2743
2743
|
{
|
|
2744
2744
|
name: t18("approval.plan_execute_back", {
|
|
@@ -2753,7 +2753,7 @@ async function askPlan(proposal) {
|
|
|
2753
2753
|
{ name: t18("approval.deny"), value: "deny" }
|
|
2754
2754
|
];
|
|
2755
2755
|
try {
|
|
2756
|
-
const outcome = await select2({ message: t18("approval.plan_ask"), choices:
|
|
2756
|
+
const outcome = await select2({ message: t18("approval.plan_ask"), choices: choices2 });
|
|
2757
2757
|
if (outcome !== "plan-revise") return outcome;
|
|
2758
2758
|
const note = (await input2({ message: t18("approval.plan_revise_ask") })).trim();
|
|
2759
2759
|
return note ? { outcome, note } : outcome;
|
|
@@ -2922,9 +2922,9 @@ function createExternalApproval(opts) {
|
|
|
2922
2922
|
import { describeBackgroundTask } from "@epoch-agent/core";
|
|
2923
2923
|
import { currentLang, t as t20 } from "@epoch-agent/infra";
|
|
2924
2924
|
function backgroundTaskSummary(all) {
|
|
2925
|
-
const tasks = all.filter((
|
|
2925
|
+
const tasks = all.filter((t40) => t40.kind === "command");
|
|
2926
2926
|
if (tasks.length === 0) return "";
|
|
2927
|
-
const running = tasks.filter((
|
|
2927
|
+
const running = tasks.filter((t40) => t40.status === "running").length;
|
|
2928
2928
|
const head = running > 0 ? t20("background_tasks.head_running", { total: tasks.length, running }) : t20("background_tasks.head_done", { total: tasks.length });
|
|
2929
2929
|
return [head, ...tasks.map((task) => ` ${describeBackgroundTask(task, currentLang())}`)].join(
|
|
2930
2930
|
"\n"
|
|
@@ -2934,171 +2934,24 @@ function backgroundTaskSummary(all) {
|
|
|
2934
2934
|
import {
|
|
2935
2935
|
createImportGate,
|
|
2936
2936
|
ImportTrustStore,
|
|
2937
|
-
isNonInteractive as isNonInteractive6,
|
|
2938
|
-
loadConfig as loadConfig5,
|
|
2939
|
-
resolveProjectRoot as resolveProjectRoot2,
|
|
2940
|
-
scanInstructions,
|
|
2941
|
-
setImportGate,
|
|
2942
|
-
TrustManager as TrustManager2
|
|
2943
|
-
} from "@epoch-agent/core";
|
|
2944
|
-
import { t as t22, trustedImportsPath, trustPath as trustPath2 } from "@epoch-agent/infra";
|
|
2945
|
-
// src/trust-prompt.ts
|
|
2946
|
-
import {
|
|
2947
|
-
findProjectInstructions,
|
|
2948
|
-
hasExecTierContent,
|
|
2949
|
-
hasReadTierContent,
|
|
2950
|
-
inventoryProjectExtensions,
|
|
2951
2937
|
isNonInteractive as isNonInteractive5,
|
|
2952
2938
|
loadConfig as loadConfig4,
|
|
2953
2939
|
resolveProjectRoot,
|
|
2940
|
+
scanInstructions,
|
|
2941
|
+
setImportGate,
|
|
2954
2942
|
TrustManager
|
|
2955
2943
|
} from "@epoch-agent/core";
|
|
2956
|
-
import { t as t21, trustPath } from "@epoch-agent/infra";
|
|
2957
|
-
function trustPromptTarget(deps) {
|
|
2958
|
-
if (!deps.gateEnabled) return null;
|
|
2959
|
-
if (!deps.interactive) return null;
|
|
2960
|
-
const root = resolveProjectRoot(deps.workDir);
|
|
2961
|
-
if (deps.store.check(root) !== "unknown") return null;
|
|
2962
|
-
const instructionsPath = findProjectInstructions(root, deps.workDir);
|
|
2963
|
-
const inventory = inventoryProjectExtensions(root);
|
|
2964
|
-
const hasExec = hasExecTierContent(inventory);
|
|
2965
|
-
if (!instructionsPath && !hasReadTierContent(inventory) && !hasExec) return null;
|
|
2966
|
-
return {
|
|
2967
|
-
root,
|
|
2968
|
-
...instructionsPath ? { instructionsPath } : {},
|
|
2969
|
-
inventory,
|
|
2970
|
-
hasExec
|
|
2971
|
-
};
|
|
2972
|
-
}
|
|
2973
|
-
function applyTrustChoice(store, root, choice) {
|
|
2974
|
-
if (choice.kind === "trust") {
|
|
2975
|
-
store.record(root, "trusted", choice.scope, { exec: choice.exec });
|
|
2976
|
-
const suffix = choice.scope === "directory-tree" ? t21("trust_prompt.granted_tree_suffix") : "";
|
|
2977
|
-
return choice.exec ? t21("trust_prompt.granted_exec", { root, suffix }) : t21("trust_prompt.granted", { root, suffix });
|
|
2978
|
-
}
|
|
2979
|
-
if (choice.kind === "never") {
|
|
2980
|
-
store.record(root, "untrusted", "directory");
|
|
2981
|
-
return t21("trust_prompt.denied", { root });
|
|
2982
|
-
}
|
|
2983
|
-
return t21("trust_prompt.skipped");
|
|
2984
|
-
}
|
|
2985
|
-
function trustPromptMessage(target) {
|
|
2986
|
-
const lines = [
|
|
2987
|
-
target.instructionsPath ? `
|
|
2988
|
-
${t21("trust_prompt.head", { path: target.instructionsPath })}` : `
|
|
2989
|
-
${t21("trust_prompt.head_dir", { dir: target.root })}`,
|
|
2990
|
-
` ${t21("trust_prompt.why")}`
|
|
2991
|
-
];
|
|
2992
|
-
const inv = target.inventory;
|
|
2993
|
-
const read = [];
|
|
2994
|
-
if (inv.instructionFiles.length > 0) {
|
|
2995
|
-
read.push(t21("trust_prompt.item_instructions", { n: inv.instructionFiles.length }));
|
|
2996
|
-
}
|
|
2997
|
-
if (inv.skills > 0) read.push(t21("trust_prompt.item_skills", { n: inv.skills }));
|
|
2998
|
-
if (inv.roles > 0) read.push(t21("trust_prompt.item_roles", { n: inv.roles }));
|
|
2999
|
-
if (inv.commands > 0) read.push(t21("trust_prompt.item_commands", { n: inv.commands }));
|
|
3000
|
-
const sep = t21("trust_prompt.item_sep");
|
|
3001
|
-
if (read.length > 0) lines.push(` ${t21("trust_prompt.tier_read_head")} ${read.join(sep)}`);
|
|
3002
|
-
const exec = [];
|
|
3003
|
-
if (inv.hookFiles.length > 0) {
|
|
3004
|
-
exec.push(t21("trust_prompt.item_hooks", { files: inv.hookFiles.join(", ") }));
|
|
3005
|
-
}
|
|
3006
|
-
if (inv.policies > 0) exec.push(t21("trust_prompt.item_policies", { n: inv.policies }));
|
|
3007
|
-
if (inv.settingsFiles.length > 0) {
|
|
3008
|
-
exec.push(t21("trust_prompt.item_settings", { files: inv.settingsFiles.join(", ") }));
|
|
3009
|
-
}
|
|
3010
|
-
if (exec.length > 0) lines.push(` ${t21("trust_prompt.tier_exec_head")} ${exec.join(sep)}`);
|
|
3011
|
-
lines.push("");
|
|
3012
|
-
return lines.join("\n");
|
|
3013
|
-
}
|
|
3014
|
-
function choices() {
|
|
3015
|
-
return [
|
|
3016
|
-
{ name: t21("trust_prompt.choice_skip"), value: { kind: "skip" } },
|
|
3017
|
-
{
|
|
3018
|
-
name: t21("trust_prompt.choice_dir"),
|
|
3019
|
-
value: { kind: "trust", scope: "directory", exec: false }
|
|
3020
|
-
},
|
|
3021
|
-
{
|
|
3022
|
-
name: t21("trust_prompt.choice_tree"),
|
|
3023
|
-
value: { kind: "trust", scope: "directory-tree", exec: false }
|
|
3024
|
-
},
|
|
3025
|
-
{ name: t21("trust_prompt.choice_never"), value: { kind: "never" } }
|
|
3026
|
-
];
|
|
3027
|
-
}
|
|
2944
|
+
import { t as t21, trustedImportsPath, trustPath } from "@epoch-agent/infra";
|
|
3028
2945
|
function restoreStdinDefault() {
|
|
3029
2946
|
const stdin = process.stdin;
|
|
3030
2947
|
if (stdin.isTTY) stdin.setRawMode?.(false);
|
|
3031
2948
|
stdin.resume();
|
|
3032
2949
|
}
|
|
3033
|
-
async function maybePromptForTrust(opts = {}) {
|
|
3034
|
-
const config = opts.config ?? loadConfig4();
|
|
3035
|
-
const store = opts.store ?? new TrustManager(trustPath(config.homeDir));
|
|
3036
|
-
const print = opts.print ?? ((msg) => process.stdout.write(msg + "\n"));
|
|
3037
|
-
const target = trustPromptTarget({
|
|
3038
|
-
store,
|
|
3039
|
-
interactive: (opts.isInteractive ?? (() => !isNonInteractive5()))(),
|
|
3040
|
-
gateEnabled: config.trust?.enabled !== false,
|
|
3041
|
-
workDir: opts.workDir ?? process.cwd()
|
|
3042
|
-
});
|
|
3043
|
-
if (!target) return true;
|
|
3044
|
-
print(trustPromptMessage(target));
|
|
3045
|
-
let choice;
|
|
3046
|
-
try {
|
|
3047
|
-
choice = await (opts.ask ?? askTrustChoice)(target);
|
|
3048
|
-
if (choice?.kind === "trust" && target.hasExec) {
|
|
3049
|
-
const exec = await (opts.askExec ?? askExecChoice)(target);
|
|
3050
|
-
choice = { ...choice, exec: exec === true };
|
|
3051
|
-
}
|
|
3052
|
-
} finally {
|
|
3053
|
-
(opts.restoreStdin ?? restoreStdinDefault)();
|
|
3054
|
-
}
|
|
3055
|
-
if (choice === null) return false;
|
|
3056
|
-
try {
|
|
3057
|
-
print(applyTrustChoice(store, target.root, choice));
|
|
3058
|
-
} catch (err2) {
|
|
3059
|
-
print(
|
|
3060
|
-
t21("trust_prompt.write_failed", {
|
|
3061
|
-
message: err2 instanceof Error ? err2.message : String(err2)
|
|
3062
|
-
})
|
|
3063
|
-
);
|
|
3064
|
-
}
|
|
3065
|
-
return true;
|
|
3066
|
-
}
|
|
3067
|
-
async function askExecChoice(_target) {
|
|
3068
|
-
const { select: select2 } = await import("@inquirer/prompts");
|
|
3069
|
-
try {
|
|
3070
|
-
const options = [
|
|
3071
|
-
{ name: t21("trust_prompt.exec_choice_no"), value: false },
|
|
3072
|
-
{ name: t21("trust_prompt.exec_choice_yes"), value: true }
|
|
3073
|
-
];
|
|
3074
|
-
return await select2({
|
|
3075
|
-
message: t21("trust_prompt.exec_ask"),
|
|
3076
|
-
choices: options,
|
|
3077
|
-
default: options[0]?.value
|
|
3078
|
-
});
|
|
3079
|
-
} catch {
|
|
3080
|
-
return null;
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
|
-
async function askTrustChoice(_target) {
|
|
3084
|
-
const { select: select2 } = await import("@inquirer/prompts");
|
|
3085
|
-
try {
|
|
3086
|
-
const options = choices();
|
|
3087
|
-
return await select2({
|
|
3088
|
-
message: t21("trust_prompt.ask"),
|
|
3089
|
-
choices: [...options],
|
|
3090
|
-
default: options[0]?.value
|
|
3091
|
-
});
|
|
3092
|
-
} catch {
|
|
3093
|
-
return null;
|
|
3094
|
-
}
|
|
3095
|
-
}
|
|
3096
|
-
// src/import-prompt.ts
|
|
3097
2950
|
function externalImportTargets(deps) {
|
|
3098
2951
|
if (!deps.gateEnabled) return [];
|
|
3099
2952
|
if (!deps.interactive) return [];
|
|
3100
2953
|
if (deps.store.deniedAll) return [];
|
|
3101
|
-
const root =
|
|
2954
|
+
const root = resolveProjectRoot(deps.workDir);
|
|
3102
2955
|
if (deps.trust.check(root) !== "trusted") return [];
|
|
3103
2956
|
const scan = scanInstructions(root, deps.workDir, {
|
|
3104
2957
|
allowExternal: (p) => deps.store.isAllowed(p)
|
|
@@ -3118,44 +2971,44 @@ function externalImportTargets(deps) {
|
|
|
3118
2971
|
function importPromptMessage(target) {
|
|
3119
2972
|
return [
|
|
3120
2973
|
`
|
|
3121
|
-
${
|
|
2974
|
+
${t21("import_prompt.head", { from: target.from })}`,
|
|
3122
2975
|
` ${target.path}`,
|
|
3123
|
-
` ${
|
|
3124
|
-
` ${
|
|
2976
|
+
` ${t21("import_prompt.spec", { spec: target.spec })}`,
|
|
2977
|
+
` ${t21("import_prompt.why")}`,
|
|
3125
2978
|
""
|
|
3126
2979
|
].join("\n");
|
|
3127
2980
|
}
|
|
3128
2981
|
function applyImportChoice(store, target, choice) {
|
|
3129
2982
|
if (choice.kind === "once") {
|
|
3130
2983
|
store.allowOnce(target.path);
|
|
3131
|
-
return
|
|
2984
|
+
return t21("import_prompt.once", { path: target.path });
|
|
3132
2985
|
}
|
|
3133
2986
|
if (choice.kind === "remember") {
|
|
3134
2987
|
store.remember(target.path);
|
|
3135
|
-
return
|
|
2988
|
+
return t21("import_prompt.remembered", { path: target.path });
|
|
3136
2989
|
}
|
|
3137
2990
|
if (choice.kind === "never") {
|
|
3138
2991
|
store.denyAll();
|
|
3139
|
-
return
|
|
2992
|
+
return t21("import_prompt.never");
|
|
3140
2993
|
}
|
|
3141
|
-
return
|
|
2994
|
+
return t21("import_prompt.skipped", { path: target.path });
|
|
3142
2995
|
}
|
|
3143
|
-
function
|
|
2996
|
+
function choices() {
|
|
3144
2997
|
return [
|
|
3145
|
-
{ name:
|
|
3146
|
-
{ name:
|
|
3147
|
-
{ name:
|
|
3148
|
-
{ name:
|
|
2998
|
+
{ name: t21("import_prompt.choice_skip"), value: { kind: "skip" } },
|
|
2999
|
+
{ name: t21("import_prompt.choice_once"), value: { kind: "once" } },
|
|
3000
|
+
{ name: t21("import_prompt.choice_remember"), value: { kind: "remember" } },
|
|
3001
|
+
{ name: t21("import_prompt.choice_never"), value: { kind: "never" } }
|
|
3149
3002
|
];
|
|
3150
3003
|
}
|
|
3151
3004
|
async function maybePromptForExternalImports(opts = {}) {
|
|
3152
|
-
const config = opts.config ??
|
|
3005
|
+
const config = opts.config ?? loadConfig4();
|
|
3153
3006
|
const store = opts.store ?? new ImportTrustStore(trustedImportsPath(config.homeDir));
|
|
3154
3007
|
const print = opts.print ?? ((msg) => process.stdout.write(msg + "\n"));
|
|
3155
3008
|
const targets = externalImportTargets({
|
|
3156
3009
|
store,
|
|
3157
|
-
trust: opts.trust ?? new
|
|
3158
|
-
interactive: (opts.isInteractive ?? (() => !
|
|
3010
|
+
trust: opts.trust ?? new TrustManager(trustPath(config.homeDir)),
|
|
3011
|
+
interactive: (opts.isInteractive ?? (() => !isNonInteractive5()))(),
|
|
3159
3012
|
gateEnabled: config.trust?.enabled !== false,
|
|
3160
3013
|
workDir: opts.workDir ?? process.cwd()
|
|
3161
3014
|
});
|
|
@@ -3172,7 +3025,7 @@ async function maybePromptForExternalImports(opts = {}) {
|
|
|
3172
3025
|
print(applyImportChoice(store, target, choice));
|
|
3173
3026
|
} catch (err2) {
|
|
3174
3027
|
print(
|
|
3175
|
-
|
|
3028
|
+
t21("import_prompt.write_failed", {
|
|
3176
3029
|
message: err2 instanceof Error ? err2.message : String(err2)
|
|
3177
3030
|
})
|
|
3178
3031
|
);
|
|
@@ -3188,9 +3041,9 @@ async function maybePromptForExternalImports(opts = {}) {
|
|
|
3188
3041
|
async function askImportChoice(_target) {
|
|
3189
3042
|
const { select: select2 } = await import("@inquirer/prompts");
|
|
3190
3043
|
try {
|
|
3191
|
-
const options =
|
|
3044
|
+
const options = choices();
|
|
3192
3045
|
return await select2({
|
|
3193
|
-
message:
|
|
3046
|
+
message: t21("import_prompt.ask"),
|
|
3194
3047
|
choices: [...options],
|
|
3195
3048
|
default: options[0]?.value
|
|
3196
3049
|
});
|
|
@@ -3279,7 +3132,7 @@ function composeContent(query, images) {
|
|
|
3279
3132
|
throw new CliError(
|
|
3280
3133
|
err2 instanceof Error ? err2.message : String(err2),
|
|
3281
3134
|
EXIT_CODES.FAILURE,
|
|
3282
|
-
|
|
3135
|
+
t22("run_once.err_image")
|
|
3283
3136
|
);
|
|
3284
3137
|
}
|
|
3285
3138
|
}
|
|
@@ -3288,18 +3141,15 @@ async function runOnce(query, opts, resumeId) {
|
|
|
3288
3141
|
const { policy: headless, invalid } = parseHeadlessFlags(opts);
|
|
3289
3142
|
if (invalid.length > 0) {
|
|
3290
3143
|
throw new CliError(
|
|
3291
|
-
|
|
3144
|
+
t22("run_once.err_bad_operation", { values: invalid.join(", ") }),
|
|
3292
3145
|
EXIT_CODES.FAILURE,
|
|
3293
|
-
|
|
3146
|
+
t22("run_once.err_bad_operation_hint", { choices: OPERATION_TYPES2.join(" / ") })
|
|
3294
3147
|
);
|
|
3295
3148
|
}
|
|
3296
3149
|
const format = resolveOutputFormat(opts);
|
|
3297
3150
|
const limits = parseCallLimits(opts);
|
|
3298
3151
|
const approver = resolveApproverProgram(opts.permissionPromptTool);
|
|
3299
3152
|
const content = composeContent(query, opts.image ?? []);
|
|
3300
|
-
if (!await maybePromptForTrust()) {
|
|
3301
|
-
process.exit(EXIT_CODES.FAILURE);
|
|
3302
|
-
}
|
|
3303
3153
|
if (!await maybePromptForExternalImports()) {
|
|
3304
3154
|
process.exit(EXIT_CODES.FAILURE);
|
|
3305
3155
|
}
|
|
@@ -3321,10 +3171,10 @@ async function runOnce(query, opts, resumeId) {
|
|
|
3321
3171
|
const detail = runtime.diagnostics.join("\n ");
|
|
3322
3172
|
await runtime.dispose();
|
|
3323
3173
|
throw new CliError(
|
|
3324
|
-
|
|
3174
|
+
t22("run_once.err_no_provider"),
|
|
3325
3175
|
EXIT_CODES.FAILURE,
|
|
3326
|
-
detail ? `${
|
|
3327
|
-
${detail}` :
|
|
3176
|
+
detail ? `${t22("run_once.err_no_provider_diag")}
|
|
3177
|
+
${detail}` : t22("run_once.err_no_provider_hint")
|
|
3328
3178
|
);
|
|
3329
3179
|
}
|
|
3330
3180
|
installShutdown(runtime);
|
|
@@ -3333,7 +3183,7 @@ async function runOnce(query, opts, resumeId) {
|
|
|
3333
3183
|
if (resumeId) {
|
|
3334
3184
|
const restored = runtime.session.getHistory().length;
|
|
3335
3185
|
process.stderr.write(
|
|
3336
|
-
`${
|
|
3186
|
+
`${t22("run_once.resumed", {
|
|
3337
3187
|
id: resumeId.slice(0, SHORT_ID_LEN),
|
|
3338
3188
|
count: restored
|
|
3339
3189
|
})}
|
|
@@ -3409,7 +3259,7 @@ function collect2(out2, ev, w) {
|
|
|
3409
3259
|
} else if (ev.type === "notice") {
|
|
3410
3260
|
w.notice(ev.text);
|
|
3411
3261
|
} else if (ev.type === "error") {
|
|
3412
|
-
out2.text =
|
|
3262
|
+
out2.text = t22("run_once.error_prefix", { message: ev.message });
|
|
3413
3263
|
w.notice(out2.text);
|
|
3414
3264
|
process.exitCode = EXIT_CODES.FAILURE;
|
|
3415
3265
|
} else if (ev.type === "finish") {
|
|
@@ -3445,14 +3295,14 @@ function emitOutcome(out2, opts, format, emitter, tasks = []) {
|
|
|
3445
3295
|
return;
|
|
3446
3296
|
}
|
|
3447
3297
|
if (out2.reasoning) {
|
|
3448
|
-
process.stderr.write(`${
|
|
3298
|
+
process.stderr.write(`${t22("run_once.reasoning_head")}
|
|
3449
3299
|
${out2.reasoning}
|
|
3450
3300
|
|
|
3451
3301
|
`);
|
|
3452
3302
|
}
|
|
3453
3303
|
if (opts.stream === false && out2.text) process.stdout.write(out2.text + "\n");
|
|
3454
3304
|
if (out2.aborted) process.stderr.write(`
|
|
3455
|
-
${
|
|
3305
|
+
${t22("run_once.aborted")}
|
|
3456
3306
|
`);
|
|
3457
3307
|
if (taskLines) process.stderr.write(taskLines + "\n");
|
|
3458
3308
|
const summary = formatSummary(out2.usage, out2.budgetExceeded);
|
|
@@ -3469,10 +3319,10 @@ function noteworthy(diagnostics, verbose) {
|
|
|
3469
3319
|
}
|
|
3470
3320
|
function formatSummary(usage, budgetExceeded) {
|
|
3471
3321
|
if (!usage) return "";
|
|
3472
|
-
const cached = usage.cacheHitTokens ?
|
|
3322
|
+
const cached = usage.cacheHitTokens ? t22("run_once.cache_hit", { count: usage.cacheHitTokens }) : "";
|
|
3473
3323
|
const tokens = `${promptTokens(usage)} in${cached} / ${usage.outputTokens} out`;
|
|
3474
|
-
const cost = usage.costUsd === void 0 ?
|
|
3475
|
-
const stopped = budgetExceeded ?
|
|
3324
|
+
const cost = usage.costUsd === void 0 ? t22("run_once.cost_unknown") : formatUsd(usage.costUsd);
|
|
3325
|
+
const stopped = budgetExceeded ? t22("run_once.budget_reached") : "";
|
|
3476
3326
|
return `\u2500 ${tokens} \xB7 ${cost}${stopped}`;
|
|
3477
3327
|
}
|
|
3478
3328
|
function reportHeadlessAudit(permission) {
|
|
@@ -3481,7 +3331,7 @@ function reportHeadlessAudit(permission) {
|
|
|
3481
3331
|
for (const e of audit) {
|
|
3482
3332
|
const vars = { tool: e.toolName, target: e.target, reason: e.reason };
|
|
3483
3333
|
process.stderr.write(
|
|
3484
|
-
`${e.outcome === "granted" ?
|
|
3334
|
+
`${e.outcome === "granted" ? t22("run_once.audit_granted", vars) : t22("run_once.audit_denied", vars)}
|
|
3485
3335
|
`
|
|
3486
3336
|
);
|
|
3487
3337
|
}
|
|
@@ -3491,7 +3341,7 @@ function reportHeadlessAudit(permission) {
|
|
|
3491
3341
|
}
|
|
3492
3342
|
// src/commands/run-overrides.ts
|
|
3493
3343
|
import { PERMISSION_LEVELS as PERMISSION_LEVELS2, resolvePermissionLevel as resolvePermissionLevel2 } from "@epoch-agent/core";
|
|
3494
|
-
import { t as
|
|
3344
|
+
import { t as t23 } from "@epoch-agent/infra";
|
|
3495
3345
|
import { parseModelRef as parseModelRef2 } from "@epoch-agent/protocol";
|
|
3496
3346
|
function applyRunFlags(opts) {
|
|
3497
3347
|
applySettingsPath(opts.settings);
|
|
@@ -3510,9 +3360,9 @@ function applyOverrides(opts) {
|
|
|
3510
3360
|
const level = resolvePermissionLevel2(opts.permission);
|
|
3511
3361
|
if (!level) {
|
|
3512
3362
|
throw new CliError(
|
|
3513
|
-
|
|
3363
|
+
t23("flags.permission_unknown", { value: opts.permission }),
|
|
3514
3364
|
1,
|
|
3515
|
-
|
|
3365
|
+
t23("flags.choices", { choices: PERMISSION_LEVELS2.join(", ") })
|
|
3516
3366
|
);
|
|
3517
3367
|
}
|
|
3518
3368
|
process.env.EPOCH_PERMISSION = level;
|
|
@@ -3522,41 +3372,41 @@ function assertModelName(value, flag) {
|
|
|
3522
3372
|
const spec = value.trim();
|
|
3523
3373
|
if (parseModelRef2(spec)) return spec;
|
|
3524
3374
|
throw new CliError(
|
|
3525
|
-
|
|
3375
|
+
t23("flags.model_not_a_name", { flag, value }),
|
|
3526
3376
|
1,
|
|
3527
|
-
|
|
3377
|
+
t23("flags.model_not_a_name_hint", { value: spec })
|
|
3528
3378
|
);
|
|
3529
3379
|
}
|
|
3530
3380
|
// src/commands/sessions.ts
|
|
3531
3381
|
import { writeFileSync as writeFileSync2 } from "fs";
|
|
3532
3382
|
import {
|
|
3533
|
-
isNonInteractive as
|
|
3383
|
+
isNonInteractive as isNonInteractive6,
|
|
3534
3384
|
redactLine,
|
|
3535
|
-
resolveProjectRoot as
|
|
3385
|
+
resolveProjectRoot as resolveProjectRoot2,
|
|
3536
3386
|
SessionManager
|
|
3537
3387
|
} from "@epoch-agent/core";
|
|
3538
|
-
import { dbPath, t as
|
|
3388
|
+
import { dbPath, t as t24, uiDateLocale as uiDateLocale2 } from "@epoch-agent/infra";
|
|
3539
3389
|
var log8 = (msg) => process.stdout.write(msg + "\n");
|
|
3540
3390
|
var SHORT_ID_LEN2 = 8;
|
|
3541
3391
|
var PICK_LIMIT = 20;
|
|
3542
3392
|
var DEFAULT_RETENTION_DAYS = 90;
|
|
3543
3393
|
var VACUUM_MIN_FREELIST_RATIO = 0.25;
|
|
3544
3394
|
function whenOf(startedAt) {
|
|
3545
|
-
return startedAt ? new Date(startedAt).toLocaleString(uiDateLocale2()) :
|
|
3395
|
+
return startedAt ? new Date(startedAt).toLocaleString(uiDateLocale2()) : t24("sessions.when_unknown");
|
|
3546
3396
|
}
|
|
3547
3397
|
function titleOf(s) {
|
|
3548
|
-
return s.title || s.preview ||
|
|
3398
|
+
return s.title || s.preview || t24("sessions.untitled");
|
|
3549
3399
|
}
|
|
3550
3400
|
function registerSessionsCommand(program2) {
|
|
3551
|
-
const cmd = program2.command("sessions").alias("session").description(
|
|
3552
|
-
cmd.command("list").description(
|
|
3401
|
+
const cmd = program2.command("sessions").alias("session").description(t24("sessions.cmd_root"));
|
|
3402
|
+
cmd.command("list").description(t24("sessions.cmd_list")).option("-n, --limit <n>", t24("sessions.opt_limit"), "10").option("-a, --archived", t24("sessions.opt_archived")).action((opts) => {
|
|
3553
3403
|
withSessions((sm) => {
|
|
3554
3404
|
const r = sm.list({
|
|
3555
3405
|
limit: parseInt(opts.limit, 10),
|
|
3556
3406
|
...opts.archived ? { archived: true } : {}
|
|
3557
3407
|
});
|
|
3558
3408
|
if (r.sessions.length === 0) {
|
|
3559
|
-
log8(` ${
|
|
3409
|
+
log8(` ${t24(opts.archived ? "sessions.list_empty_archived" : "sessions.list_empty")}`);
|
|
3560
3410
|
return;
|
|
3561
3411
|
}
|
|
3562
3412
|
for (const s of r.sessions) {
|
|
@@ -3564,27 +3414,27 @@ function registerSessionsCommand(program2) {
|
|
|
3564
3414
|
}
|
|
3565
3415
|
});
|
|
3566
3416
|
});
|
|
3567
|
-
cmd.command("archive").description(
|
|
3417
|
+
cmd.command("archive").description(t24("sessions.cmd_archive")).argument("<id>", t24("sessions.arg_id")).action((id) => {
|
|
3568
3418
|
const resolved = resolveSessionId(id, { includeArchived: true });
|
|
3569
3419
|
if (!resolved.ok) throw new CliError(resolved.error, EXIT_CODES.FAILURE);
|
|
3570
3420
|
withSessions((sm) => sm.archive(resolved.id));
|
|
3571
|
-
log8(
|
|
3421
|
+
log8(t24("sessions.archived_ok", { id: resolved.id.slice(0, SHORT_ID_LEN2) }));
|
|
3572
3422
|
});
|
|
3573
|
-
cmd.command("unarchive").description(
|
|
3423
|
+
cmd.command("unarchive").description(t24("sessions.cmd_unarchive")).argument("<id>", t24("sessions.arg_id")).action((id) => {
|
|
3574
3424
|
const resolved = resolveSessionId(id, { includeArchived: true });
|
|
3575
3425
|
if (!resolved.ok) throw new CliError(resolved.error, EXIT_CODES.FAILURE);
|
|
3576
3426
|
withSessions((sm) => sm.unarchive(resolved.id));
|
|
3577
|
-
log8(
|
|
3427
|
+
log8(t24("sessions.unarchived_ok", { id: resolved.id.slice(0, SHORT_ID_LEN2) }));
|
|
3578
3428
|
});
|
|
3579
|
-
cmd.command("export").description(
|
|
3429
|
+
cmd.command("export").description(t24("sessions.cmd_export")).argument("<id>", t24("sessions.arg_id")).argument("[file]", t24("sessions.arg_export_file")).option("-f, --format <fmt>", t24("sessions.opt_format"), "json").option("--redact", t24("sessions.opt_redact")).action((id, file, opts) => {
|
|
3580
3430
|
const resolved = resolveSessionId(id, { includeArchived: true });
|
|
3581
3431
|
if (!resolved.ok) throw new CliError(resolved.error, EXIT_CODES.FAILURE);
|
|
3582
3432
|
const format = opts.format === "md" ? "markdown" : opts.format === "json" ? "json" : null;
|
|
3583
3433
|
if (format === null) {
|
|
3584
3434
|
throw new CliError(
|
|
3585
|
-
|
|
3435
|
+
t24("sessions.err_format", { format: opts.format }),
|
|
3586
3436
|
EXIT_CODES.FAILURE,
|
|
3587
|
-
|
|
3437
|
+
t24("sessions.err_format_hint")
|
|
3588
3438
|
);
|
|
3589
3439
|
}
|
|
3590
3440
|
const raw = withSessions((sm) => sm.export(resolved.id, format));
|
|
@@ -3594,13 +3444,13 @@ function registerSessionsCommand(program2) {
|
|
|
3594
3444
|
return;
|
|
3595
3445
|
}
|
|
3596
3446
|
writeFileSync2(file, body.endsWith("\n") ? body : body + "\n", "utf8");
|
|
3597
|
-
log8(
|
|
3447
|
+
log8(t24("sessions.export_ok", { file }));
|
|
3598
3448
|
});
|
|
3599
|
-
cmd.command("prune").description(
|
|
3449
|
+
cmd.command("prune").description(t24("sessions.cmd_prune")).option("--older-than <days>", t24("sessions.opt_older_than"), String(DEFAULT_RETENTION_DAYS)).option("--archived-only", t24("sessions.opt_archived_only")).option("--include-pinned", t24("sessions.opt_include_pinned")).option("--yes", t24("sessions.opt_yes")).action(
|
|
3600
3450
|
(opts) => {
|
|
3601
3451
|
const days = Number(opts.olderThan);
|
|
3602
3452
|
if (!Number.isFinite(days) || days <= 0) {
|
|
3603
|
-
throw new CliError(
|
|
3453
|
+
throw new CliError(t24("sessions.err_days", { value: opts.olderThan }), EXIT_CODES.FAILURE);
|
|
3604
3454
|
}
|
|
3605
3455
|
const olderThanMs = Date.now() - days * 24 * 60 * 60 * 1e3;
|
|
3606
3456
|
const select2 = {
|
|
@@ -3610,7 +3460,7 @@ function registerSessionsCommand(program2) {
|
|
|
3610
3460
|
};
|
|
3611
3461
|
const sweepOrphans = () => {
|
|
3612
3462
|
const swept = withSessions((sm) => sm.sweepOrphans({ olderThanMs, now: Date.now() }));
|
|
3613
|
-
if (swept > 0) log8(
|
|
3463
|
+
if (swept > 0) log8(t24("sessions.prune_swept", { count: swept, days }));
|
|
3614
3464
|
};
|
|
3615
3465
|
const { victims, openCount } = withSessions((sm) => ({
|
|
3616
3466
|
victims: sm.pruneCandidates(select2),
|
|
@@ -3621,52 +3471,52 @@ function registerSessionsCommand(program2) {
|
|
|
3621
3471
|
}));
|
|
3622
3472
|
const sweepNote = () => {
|
|
3623
3473
|
if (openCount === 0) return;
|
|
3624
|
-
log8(
|
|
3625
|
-
if (!opts.yes) log8(
|
|
3474
|
+
log8(t24("sessions.prune_open_skipped", { count: openCount }));
|
|
3475
|
+
if (!opts.yes) log8(t24("sessions.prune_sweep_preview", { days }));
|
|
3626
3476
|
};
|
|
3627
3477
|
if (victims.length === 0) {
|
|
3628
|
-
log8(
|
|
3478
|
+
log8(t24("sessions.prune_none", { days }));
|
|
3629
3479
|
sweepNote();
|
|
3630
3480
|
if (opts.yes) sweepOrphans();
|
|
3631
3481
|
return;
|
|
3632
3482
|
}
|
|
3633
|
-
log8(
|
|
3483
|
+
log8(t24("sessions.prune_head"));
|
|
3634
3484
|
for (const s of victims) {
|
|
3635
3485
|
log8(` ${s.id.slice(0, SHORT_ID_LEN2)} ${whenOf(s.updatedAt)} ${titleOf(s)}`);
|
|
3636
3486
|
}
|
|
3637
3487
|
sweepNote();
|
|
3638
3488
|
if (!opts.yes) {
|
|
3639
|
-
log8(
|
|
3489
|
+
log8(t24("sessions.prune_preview", { count: victims.length, days }));
|
|
3640
3490
|
return;
|
|
3641
3491
|
}
|
|
3642
3492
|
let removed = 0;
|
|
3643
3493
|
withSessions((sm) => {
|
|
3644
3494
|
for (const s of victims) if (sm.delete(s.id)) removed++;
|
|
3645
3495
|
});
|
|
3646
|
-
log8(
|
|
3496
|
+
log8(t24("sessions.prune_done", { count: removed }));
|
|
3647
3497
|
sweepOrphans();
|
|
3648
3498
|
if (removed > 0) {
|
|
3649
3499
|
const ratio = withSessions((sm) => sm.freelistRatio());
|
|
3650
3500
|
if (ratio > VACUUM_MIN_FREELIST_RATIO) {
|
|
3651
3501
|
const report = withSessions((sm) => sm.reclaimFts(true));
|
|
3652
|
-
if (report.vacuumed) log8(
|
|
3502
|
+
if (report.vacuumed) log8(t24("sessions.prune_vacuumed"));
|
|
3653
3503
|
}
|
|
3654
3504
|
}
|
|
3655
3505
|
}
|
|
3656
3506
|
);
|
|
3657
|
-
cmd.command("resume").description(
|
|
3507
|
+
cmd.command("resume").description(t24("sessions.cmd_resume")).argument("[id]", t24("sessions.arg_id")).argument("[query]", t24("sessions.arg_query")).action(async (id, query) => {
|
|
3658
3508
|
const resolved = resolveSessionId(id);
|
|
3659
3509
|
if (!resolved.ok) {
|
|
3660
3510
|
throw new CliError(resolved.error, EXIT_CODES.FAILURE);
|
|
3661
3511
|
}
|
|
3662
|
-
await runOnce(query ||
|
|
3512
|
+
await runOnce(query || t24("sessions.default_query"), {}, resolved.id);
|
|
3663
3513
|
});
|
|
3664
3514
|
}
|
|
3665
3515
|
function resolveSessionId(input2, opts = {}) {
|
|
3666
3516
|
return withSessions((sm) => {
|
|
3667
3517
|
if (!input2) {
|
|
3668
3518
|
const latest = sm.getLatest()?.meta.id;
|
|
3669
|
-
return latest ? { ok: true, id: latest } : { ok: false, error:
|
|
3519
|
+
return latest ? { ok: true, id: latest } : { ok: false, error: t24("sessions.err_none") };
|
|
3670
3520
|
}
|
|
3671
3521
|
if (sm.get(input2)) return { ok: true, id: input2 };
|
|
3672
3522
|
const pool = sm.list({ limit: 200 }).sessions;
|
|
@@ -3674,24 +3524,24 @@ function resolveSessionId(input2, opts = {}) {
|
|
|
3674
3524
|
const candidates = all.filter((s) => s.id.startsWith(input2)).map((s) => s.id);
|
|
3675
3525
|
if (candidates.length === 1) return { ok: true, id: candidates[0] };
|
|
3676
3526
|
if (candidates.length === 0) {
|
|
3677
|
-
return { ok: false, error:
|
|
3527
|
+
return { ok: false, error: t24("sessions.err_not_found", { input: input2 }) };
|
|
3678
3528
|
}
|
|
3679
3529
|
return {
|
|
3680
3530
|
ok: false,
|
|
3681
|
-
error:
|
|
3531
|
+
error: t24("sessions.err_ambiguous", { input: input2, count: candidates.length })
|
|
3682
3532
|
};
|
|
3683
3533
|
});
|
|
3684
3534
|
}
|
|
3685
3535
|
function latestSessionIdForProject(cwd = process.cwd()) {
|
|
3686
|
-
const root =
|
|
3536
|
+
const root = resolveProjectRoot2(cwd);
|
|
3687
3537
|
return withSessions((sm) => sm.getLatestByCwd(root)?.meta.id);
|
|
3688
3538
|
}
|
|
3689
3539
|
async function pickSessionId() {
|
|
3690
|
-
if (
|
|
3540
|
+
if (isNonInteractive6()) {
|
|
3691
3541
|
throw new CliError(
|
|
3692
|
-
|
|
3542
|
+
t24("sessions.err_needs_id"),
|
|
3693
3543
|
EXIT_CODES.FAILURE,
|
|
3694
|
-
|
|
3544
|
+
t24("sessions.err_needs_id_hint")
|
|
3695
3545
|
);
|
|
3696
3546
|
}
|
|
3697
3547
|
const rows = withSessions(
|
|
@@ -3699,22 +3549,22 @@ async function pickSessionId() {
|
|
|
3699
3549
|
id: s.id,
|
|
3700
3550
|
title: titleOf(s),
|
|
3701
3551
|
when: whenOf(s.startedAt),
|
|
3702
|
-
where: s.cwd ??
|
|
3552
|
+
where: s.cwd ?? t24("sessions.cwd_unrecorded"),
|
|
3703
3553
|
messageCount: s.messageCount
|
|
3704
3554
|
}))
|
|
3705
3555
|
);
|
|
3706
3556
|
if (rows.length === 0) {
|
|
3707
|
-
log8(
|
|
3557
|
+
log8(t24("sessions.pick_empty"));
|
|
3708
3558
|
return void 0;
|
|
3709
3559
|
}
|
|
3710
3560
|
const { select: select2 } = await import("@inquirer/prompts");
|
|
3711
3561
|
try {
|
|
3712
3562
|
return await select2({
|
|
3713
|
-
message:
|
|
3563
|
+
message: t24("sessions.pick_prompt"),
|
|
3714
3564
|
choices: rows.map((r) => ({
|
|
3715
3565
|
name: `${r.id.slice(0, SHORT_ID_LEN2)} ${r.when} ${r.title}`,
|
|
3716
3566
|
value: r.id,
|
|
3717
|
-
description: `${
|
|
3567
|
+
description: `${t24("tui.resume.message_count", { n: r.messageCount })} \xB7 ${r.where}`
|
|
3718
3568
|
})),
|
|
3719
3569
|
pageSize: 12
|
|
3720
3570
|
});
|
|
@@ -3735,21 +3585,21 @@ var log9 = (msg) => {
|
|
|
3735
3585
|
process.stdout.write(msg + "\n");
|
|
3736
3586
|
};
|
|
3737
3587
|
function registerRunCommand(program2) {
|
|
3738
|
-
program2.argument("[query]",
|
|
3588
|
+
program2.argument("[query]", t25("run.arg_query")).option("--allow-tool <name>", t25("run.opt_allow_tool"), collect, []).option(
|
|
3739
3589
|
"--allow-operation <type>",
|
|
3740
|
-
|
|
3590
|
+
t25("run.opt_allow_operation", { types: OPERATION_TYPES3.join(" / ") }),
|
|
3741
3591
|
collect,
|
|
3742
3592
|
[]
|
|
3743
|
-
).option("-i, --image <path>",
|
|
3593
|
+
).option("-i, --image <path>", t25("run.opt_image"), collect, []).option("-c, --continue", t25("run.opt_continue")).option("-r, --resume [id]", t25("run.opt_resume")).option("-m, --model <name>", t25("run.opt_model")).option("--fallback-model <name>", t25("run.opt_fallback_model")).option(
|
|
3744
3594
|
"--permission <level>",
|
|
3745
|
-
|
|
3746
|
-
).option("--settings <file>",
|
|
3595
|
+
t25("run.opt_permission", { levels: PERMISSION_LEVELS3.join(" / ") })
|
|
3596
|
+
).option("--settings <file>", t25("run.opt_settings")).option("--add-dir <dir>", t25("run.opt_add_dir"), collect, []).option("--agent <role>", t25("run.opt_agent")).option("--worktree", t25("run.opt_worktree")).option("--json", t25("run.opt_json")).option(
|
|
3747
3597
|
"--output-format <fmt>",
|
|
3748
|
-
|
|
3598
|
+
t25("run.opt_output_format", { formats: HEADLESS_OUTPUT_FORMATS2.join(" / ") })
|
|
3749
3599
|
).option(
|
|
3750
3600
|
"--input-format <fmt>",
|
|
3751
|
-
|
|
3752
|
-
).option("--permission-prompt-tool <program>",
|
|
3601
|
+
t25("run.opt_input_format", { formats: HEADLESS_INPUT_FORMATS2.join(" / ") })
|
|
3602
|
+
).option("--permission-prompt-tool <program>", t25("run.opt_permission_prompt_tool")).option("--max-turns <n>", t25("run.opt_max_turns")).option("--max-budget-usd <x>", t25("run.opt_max_budget")).option("--no-stream", t25("run.opt_no_stream")).option("-v, --verbose", t25("run.opt_verbose")).option("-V, --version", t25("run.opt_version")).action(async (query, opts) => {
|
|
3753
3603
|
if (opts.version === true) {
|
|
3754
3604
|
log9(describeVersion(selfPackage().name));
|
|
3755
3605
|
return;
|
|
@@ -3761,30 +3611,30 @@ function registerRunCommand(program2) {
|
|
|
3761
3611
|
if (formats.input === "stream-json") {
|
|
3762
3612
|
if (opts.continue === true || resumeArg.kind !== "off") {
|
|
3763
3613
|
throw new CliError(
|
|
3764
|
-
|
|
3614
|
+
t25("run.conflict_resume"),
|
|
3765
3615
|
EXIT_CODES.FAILURE,
|
|
3766
|
-
|
|
3616
|
+
t25("run.conflict_resume_hint")
|
|
3767
3617
|
);
|
|
3768
3618
|
}
|
|
3769
3619
|
if (opts.worktree === true) {
|
|
3770
3620
|
throw new CliError(
|
|
3771
|
-
|
|
3621
|
+
t25("run.conflict_worktree"),
|
|
3772
3622
|
EXIT_CODES.FAILURE,
|
|
3773
|
-
|
|
3623
|
+
t25("run.conflict_worktree_hint")
|
|
3774
3624
|
);
|
|
3775
3625
|
}
|
|
3776
3626
|
if (opts.permissionPromptTool !== void 0) {
|
|
3777
3627
|
throw new CliError(
|
|
3778
|
-
|
|
3628
|
+
t25("run.conflict_prompt_tool"),
|
|
3779
3629
|
EXIT_CODES.FAILURE,
|
|
3780
|
-
|
|
3630
|
+
t25("run.conflict_prompt_tool_hint")
|
|
3781
3631
|
);
|
|
3782
3632
|
}
|
|
3783
3633
|
if (!hasUsableModel()) {
|
|
3784
3634
|
throw new CliError(
|
|
3785
|
-
|
|
3635
|
+
t25("run.no_credentials_stream"),
|
|
3786
3636
|
EXIT_CODES.FAILURE,
|
|
3787
|
-
|
|
3637
|
+
t25("run.no_credentials_hint")
|
|
3788
3638
|
);
|
|
3789
3639
|
}
|
|
3790
3640
|
process.exitCode = await runStreamJsonSession(opts);
|
|
@@ -3793,17 +3643,17 @@ function registerRunCommand(program2) {
|
|
|
3793
3643
|
const carried = resumeArg.kind === "pick" ? resumeArg.query : void 0;
|
|
3794
3644
|
const prompt = composePrompt(query ?? carried, await readStdin2());
|
|
3795
3645
|
if (!hasUsableModel()) {
|
|
3796
|
-
log9(
|
|
3646
|
+
log9(t25("run.welcome"));
|
|
3797
3647
|
return;
|
|
3798
3648
|
}
|
|
3799
3649
|
const resumeId = await resolveResumeTarget(opts, resumeArg);
|
|
3800
3650
|
const dispatch = async () => {
|
|
3801
3651
|
if (!prompt && (opts.image ?? []).length === 0) {
|
|
3802
|
-
if (refuseEmptyQuery(
|
|
3652
|
+
if (refuseEmptyQuery(isNonInteractive7(), formats.output)) {
|
|
3803
3653
|
throw new CliError(
|
|
3804
|
-
|
|
3654
|
+
t25("run.no_query_noninteractive"),
|
|
3805
3655
|
EXIT_CODES.FAILURE,
|
|
3806
|
-
|
|
3656
|
+
t25("run.no_query_hint")
|
|
3807
3657
|
);
|
|
3808
3658
|
}
|
|
3809
3659
|
return launchTui(resumeId);
|
|
@@ -3811,7 +3661,7 @@ function registerRunCommand(program2) {
|
|
|
3811
3661
|
return runOnce(prompt, opts, resumeId);
|
|
3812
3662
|
};
|
|
3813
3663
|
if (opts.worktree !== true) return dispatch();
|
|
3814
|
-
await inWorktree(!
|
|
3664
|
+
await inWorktree(!isNonInteractive7() && formats.output === "text", dispatch);
|
|
3815
3665
|
});
|
|
3816
3666
|
}
|
|
3817
3667
|
async function inWorktree(interactive, body) {
|
|
@@ -3828,7 +3678,7 @@ async function resolveResumeTarget(opts, resumeArg) {
|
|
|
3828
3678
|
if (opts.continue === true) {
|
|
3829
3679
|
const latest = latestSessionIdForProject();
|
|
3830
3680
|
if (!latest) {
|
|
3831
|
-
process.stderr.write(`${
|
|
3681
|
+
process.stderr.write(`${t25("run.no_history")}
|
|
3832
3682
|
`);
|
|
3833
3683
|
}
|
|
3834
3684
|
return latest;
|
|
@@ -3839,7 +3689,7 @@ async function resolveResumeTarget(opts, resumeArg) {
|
|
|
3839
3689
|
throw new CliError(
|
|
3840
3690
|
resolved.error,
|
|
3841
3691
|
EXIT_CODES.FAILURE,
|
|
3842
|
-
|
|
3692
|
+
t25("run.resume_not_id_hint")
|
|
3843
3693
|
);
|
|
3844
3694
|
}
|
|
3845
3695
|
return resolved.id;
|
|
@@ -3858,7 +3708,7 @@ function resolveTuiEntry(baseDir, exists = existsSync6) {
|
|
|
3858
3708
|
async function launchTui(resumeId) {
|
|
3859
3709
|
const target = resolveTuiEntry(dirname4(fileURLToPath3(import.meta.url)));
|
|
3860
3710
|
if (!target) {
|
|
3861
|
-
process.stderr.write(`${
|
|
3711
|
+
process.stderr.write(`${t25("run.tui_entry_missing")}
|
|
3862
3712
|
`);
|
|
3863
3713
|
process.exitCode = EXIT_CODES.FAILURE;
|
|
3864
3714
|
return;
|
|
@@ -3869,7 +3719,7 @@ async function launchTui(resumeId) {
|
|
|
3869
3719
|
const { spawn: spawn3 } = await import("child_process");
|
|
3870
3720
|
await new Promise((done) => {
|
|
3871
3721
|
const failToStart = (err2) => {
|
|
3872
|
-
process.stderr.write(`${
|
|
3722
|
+
process.stderr.write(`${t25("run.tui_spawn_failed", { message: err2.message })}
|
|
3873
3723
|
`);
|
|
3874
3724
|
process.exitCode = EXIT_CODES.FAILURE;
|
|
3875
3725
|
done();
|
|
@@ -3890,14 +3740,14 @@ async function launchTui(resumeId) {
|
|
|
3890
3740
|
});
|
|
3891
3741
|
}
|
|
3892
3742
|
// src/commands/schedule.ts
|
|
3893
|
-
import { t as
|
|
3743
|
+
import { t as t33 } from "@epoch-agent/infra";
|
|
3894
3744
|
// src/schedule/add.ts
|
|
3895
3745
|
import {
|
|
3896
3746
|
isValidInterval,
|
|
3897
3747
|
SCHEDULE_DEFAULTS,
|
|
3898
3748
|
validateSchedule
|
|
3899
3749
|
} from "@epoch-agent/core";
|
|
3900
|
-
import { automationWorkDir, t as
|
|
3750
|
+
import { automationWorkDir, t as t28 } from "@epoch-agent/infra";
|
|
3901
3751
|
import {
|
|
3902
3752
|
approvalPolicyForLevel,
|
|
3903
3753
|
isOperationType as isOperationType2,
|
|
@@ -3910,7 +3760,7 @@ import {
|
|
|
3910
3760
|
SCHEDULE_INTERVAL_MIN_MINUTES
|
|
3911
3761
|
} from "@epoch-agent/protocol";
|
|
3912
3762
|
// src/schedule/labels.ts
|
|
3913
|
-
import { t as
|
|
3763
|
+
import { t as t26 } from "@epoch-agent/infra";
|
|
3914
3764
|
import {
|
|
3915
3765
|
collectPendingApprovals,
|
|
3916
3766
|
cronTimes
|
|
@@ -3964,35 +3814,35 @@ var DRIFT_KEYS = {
|
|
|
3964
3814
|
"never-registered": "schedule.drift.never_registered"
|
|
3965
3815
|
};
|
|
3966
3816
|
function renderIssues(issues) {
|
|
3967
|
-
return issues.map((i) => ` \xB7 ${
|
|
3817
|
+
return issues.map((i) => ` \xB7 ${t26(ISSUE_KEYS[i.code], { detail: i.detail ?? "" })}`).join("\n");
|
|
3968
3818
|
}
|
|
3969
3819
|
function statusLabel(status) {
|
|
3970
3820
|
const mark = status === "ok" ? "\u2705" : status === "failed" || status === "denied" ? "\u274C" : "\u26A0\uFE0F";
|
|
3971
|
-
return `${mark} ${
|
|
3821
|
+
return `${mark} ${t26(STATUS_KEYS[status])}`;
|
|
3972
3822
|
}
|
|
3973
3823
|
function driftLabel(kind) {
|
|
3974
|
-
return
|
|
3824
|
+
return t26(DRIFT_KEYS[kind]);
|
|
3975
3825
|
}
|
|
3976
3826
|
function describeTrigger(trigger) {
|
|
3977
3827
|
if (trigger.kind === "interval") {
|
|
3978
|
-
return trigger.everyMinutes % 60 === 0 ?
|
|
3828
|
+
return trigger.everyMinutes % 60 === 0 ? t26("schedule.trigger.every_hours", { n: trigger.everyMinutes / 60 }) : t26("schedule.trigger.every_minutes", { n: trigger.everyMinutes });
|
|
3979
3829
|
}
|
|
3980
3830
|
if (trigger.kind === "once") {
|
|
3981
|
-
return
|
|
3831
|
+
return t26("schedule.trigger.once", { date: trigger.date, at: trigger.at });
|
|
3982
3832
|
}
|
|
3983
3833
|
const at = cronTimes(trigger).join("/");
|
|
3984
|
-
if (trigger.cycle === "daily") return
|
|
3834
|
+
if (trigger.cycle === "daily") return t26("schedule.trigger.daily", { at });
|
|
3985
3835
|
if (trigger.cycle === "weekly") {
|
|
3986
|
-
const days = trigger.weekdays.map((d) =>
|
|
3987
|
-
return
|
|
3836
|
+
const days = trigger.weekdays.map((d) => t26(WEEKDAY_KEYS[d])).join("/");
|
|
3837
|
+
return t26("schedule.trigger.weekly", { days, at });
|
|
3988
3838
|
}
|
|
3989
|
-
return
|
|
3839
|
+
return t26("schedule.trigger.monthly", { days: trigger.days.join("/"), at });
|
|
3990
3840
|
}
|
|
3991
3841
|
function permissionLabel(level) {
|
|
3992
|
-
if (level === "plan") return
|
|
3993
|
-
if (level === "acceptEdits") return
|
|
3994
|
-
if (level === "auto") return
|
|
3995
|
-
return
|
|
3842
|
+
if (level === "plan") return t26("schedule.permission.plan");
|
|
3843
|
+
if (level === "acceptEdits") return t26("schedule.permission.accept_edits");
|
|
3844
|
+
if (level === "auto") return t26("schedule.permission.auto");
|
|
3845
|
+
return t26("schedule.permission.default");
|
|
3996
3846
|
}
|
|
3997
3847
|
// src/schedule/shared.ts
|
|
3998
3848
|
import { realpathSync as realpathSync2 } from "fs";
|
|
@@ -4001,7 +3851,7 @@ import {
|
|
|
4001
3851
|
ScheduleRegistrar,
|
|
4002
3852
|
ScheduleStore
|
|
4003
3853
|
} from "@epoch-agent/core";
|
|
4004
|
-
import { dbPath as dbPath2, t as
|
|
3854
|
+
import { dbPath as dbPath2, t as t27, uiDateLocale as uiDateLocale3 } from "@epoch-agent/infra";
|
|
4005
3855
|
var log10 = (msg) => void process.stdout.write(`${msg}
|
|
4006
3856
|
`);
|
|
4007
3857
|
var warn2 = (msg) => void process.stderr.write(`${msg}
|
|
@@ -4030,24 +3880,24 @@ function mustFind(store, idOrPrefix) {
|
|
|
4030
3880
|
if (hits.length === 1) return hits[0];
|
|
4031
3881
|
if (hits.length === 0) {
|
|
4032
3882
|
throw new CliError(
|
|
4033
|
-
|
|
3883
|
+
t27("schedule.err_not_found", { id: idOrPrefix }),
|
|
4034
3884
|
EXIT_CODES.FAILURE,
|
|
4035
|
-
|
|
3885
|
+
t27("schedule.err_not_found_hint")
|
|
4036
3886
|
);
|
|
4037
3887
|
}
|
|
4038
3888
|
throw new CliError(
|
|
4039
|
-
|
|
3889
|
+
t27("schedule.err_ambiguous", { id: idOrPrefix }),
|
|
4040
3890
|
EXIT_CODES.FAILURE,
|
|
4041
3891
|
hits.map((h) => ` ${h.id} ${h.name}`).join("\n")
|
|
4042
3892
|
);
|
|
4043
3893
|
}
|
|
4044
3894
|
function reportRegistration(outcome, fatal) {
|
|
4045
3895
|
if (outcome.ok) {
|
|
4046
|
-
if (outcome.warnings.includes("source")) warn2(
|
|
3896
|
+
if (outcome.warnings.includes("source")) warn2(t27("schedule.warn_source_entry"));
|
|
4047
3897
|
return;
|
|
4048
3898
|
}
|
|
4049
|
-
const message = outcome.reason === "unsupported-platform" ?
|
|
4050
|
-
const hint = outcome.reason === "refused" && outcome.refusal === "npx" ?
|
|
3899
|
+
const message = outcome.reason === "unsupported-platform" ? t27("schedule.err_platform_unsupported") : outcome.reason === "backend-error" ? t27("schedule.err_backend", { detail: outcome.detail }) : outcome.refusal === "npx" ? t27("schedule.err_npx") : t27("schedule.err_no_host_runner");
|
|
3900
|
+
const hint = outcome.reason === "refused" && outcome.refusal === "npx" ? t27("schedule.err_npx_hint") : outcome.reason === "refused" ? t27("schedule.err_no_host_runner_hint") : void 0;
|
|
4051
3901
|
if (!fatal) {
|
|
4052
3902
|
warn2(message);
|
|
4053
3903
|
if (hint) warn2(hint);
|
|
@@ -4084,7 +3934,7 @@ async function runAdd(opts) {
|
|
|
4084
3934
|
});
|
|
4085
3935
|
if (validation.issues.length > 0) {
|
|
4086
3936
|
throw new CliError(
|
|
4087
|
-
|
|
3937
|
+
t28("schedule.err_invalid"),
|
|
4088
3938
|
EXIT_CODES.FAILURE,
|
|
4089
3939
|
renderIssues(validation.issues)
|
|
4090
3940
|
);
|
|
@@ -4114,26 +3964,26 @@ async function fillInteractively(opts) {
|
|
|
4114
3964
|
if (!missing) return opts;
|
|
4115
3965
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
4116
3966
|
throw new CliError(
|
|
4117
|
-
|
|
3967
|
+
t28("schedule.err_missing_flags"),
|
|
4118
3968
|
EXIT_CODES.FAILURE,
|
|
4119
|
-
|
|
3969
|
+
t28("schedule.err_missing_flags_hint")
|
|
4120
3970
|
);
|
|
4121
3971
|
}
|
|
4122
3972
|
const { input: input2, select: select2 } = await import("@inquirer/prompts");
|
|
4123
3973
|
const next = { ...opts };
|
|
4124
|
-
next.name ||= await input2({ message:
|
|
4125
|
-
next.prompt ||= await input2({ message:
|
|
3974
|
+
next.name ||= await input2({ message: t28("schedule.ask_name") });
|
|
3975
|
+
next.prompt ||= await input2({ message: t28("schedule.ask_prompt") });
|
|
4126
3976
|
if (!hasTrigger) {
|
|
4127
|
-
const at = await input2({ message:
|
|
3977
|
+
const at = await input2({ message: t28("schedule.ask_at"), default: "09:00" });
|
|
4128
3978
|
next.daily = at;
|
|
4129
3979
|
}
|
|
4130
3980
|
next.permission ||= await select2({
|
|
4131
|
-
message:
|
|
3981
|
+
message: t28("schedule.ask_permission"),
|
|
4132
3982
|
choices: [
|
|
4133
|
-
{ name:
|
|
4134
|
-
{ name:
|
|
4135
|
-
{ name:
|
|
4136
|
-
{ name:
|
|
3983
|
+
{ name: t28("schedule.permission.auto"), value: "auto" },
|
|
3984
|
+
{ name: t28("schedule.permission.accept_edits"), value: "acceptEdits" },
|
|
3985
|
+
{ name: t28("schedule.permission.default"), value: "default" },
|
|
3986
|
+
{ name: t28("schedule.permission.plan"), value: "plan" }
|
|
4137
3987
|
]
|
|
4138
3988
|
});
|
|
4139
3989
|
return next;
|
|
@@ -4142,8 +3992,8 @@ function parseTrigger(opts) {
|
|
|
4142
3992
|
const given = [opts.daily, opts.weekly, opts.monthly, opts.every, opts.once].filter(
|
|
4143
3993
|
(v) => v !== void 0
|
|
4144
3994
|
);
|
|
4145
|
-
if (given.length === 0) throw new CliError(
|
|
4146
|
-
if (given.length > 1) throw new CliError(
|
|
3995
|
+
if (given.length === 0) throw new CliError(t28("schedule.err_no_trigger"), EXIT_CODES.FAILURE);
|
|
3996
|
+
if (given.length > 1) throw new CliError(t28("schedule.err_many_triggers"), EXIT_CODES.FAILURE);
|
|
4147
3997
|
if (opts.daily !== void 0) return { kind: "cron", cycle: "daily", ...cronAt(opts.daily) };
|
|
4148
3998
|
if (opts.weekly !== void 0) {
|
|
4149
3999
|
return {
|
|
@@ -4164,14 +4014,14 @@ function parseTrigger(opts) {
|
|
|
4164
4014
|
if (opts.once !== void 0) {
|
|
4165
4015
|
const at = requireAt(opts);
|
|
4166
4016
|
if (at.includes(",")) {
|
|
4167
|
-
throw new CliError(
|
|
4017
|
+
throw new CliError(t28("schedule.err_once_single_at", { value: at }), EXIT_CODES.FAILURE);
|
|
4168
4018
|
}
|
|
4169
4019
|
return { kind: "once", date: opts.once, at };
|
|
4170
4020
|
}
|
|
4171
4021
|
return { kind: "interval", everyMinutes: parseEvery(opts.every) };
|
|
4172
4022
|
}
|
|
4173
4023
|
function requireAt(opts) {
|
|
4174
|
-
if (!opts.at) throw new CliError(
|
|
4024
|
+
if (!opts.at) throw new CliError(t28("schedule.err_at_required"), EXIT_CODES.FAILURE);
|
|
4175
4025
|
return opts.at;
|
|
4176
4026
|
}
|
|
4177
4027
|
function cronAt(raw) {
|
|
@@ -4182,7 +4032,7 @@ function parseWeekday(raw) {
|
|
|
4182
4032
|
const idx = WEEKDAY_CODES.indexOf(raw.trim().toUpperCase());
|
|
4183
4033
|
if (idx < 0) {
|
|
4184
4034
|
throw new CliError(
|
|
4185
|
-
|
|
4035
|
+
t28("schedule.err_weekday", { value: raw }),
|
|
4186
4036
|
EXIT_CODES.FAILURE,
|
|
4187
4037
|
WEEKDAY_CODES.join(",")
|
|
4188
4038
|
);
|
|
@@ -4194,9 +4044,9 @@ function parseEvery(raw) {
|
|
|
4194
4044
|
const minutes = m ? Number(m[1]) * (m[2]?.toLowerCase() === "h" ? 60 : 1) : Number.NaN;
|
|
4195
4045
|
if (!isValidInterval(minutes)) {
|
|
4196
4046
|
throw new CliError(
|
|
4197
|
-
|
|
4047
|
+
t28("schedule.err_every", { value: raw }),
|
|
4198
4048
|
EXIT_CODES.FAILURE,
|
|
4199
|
-
|
|
4049
|
+
t28("schedule.err_every_hint", {
|
|
4200
4050
|
min: `${SCHEDULE_INTERVAL_MIN_MINUTES}m`,
|
|
4201
4051
|
max: `${SCHEDULE_INTERVAL_MAX_MINUTES / 60}h`
|
|
4202
4052
|
})
|
|
@@ -4209,7 +4059,7 @@ function parsePermission(raw) {
|
|
|
4209
4059
|
const level = resolvePermissionLevel3(raw);
|
|
4210
4060
|
if (!level) {
|
|
4211
4061
|
throw new CliError(
|
|
4212
|
-
|
|
4062
|
+
t28("schedule.err_permission", { value: raw }),
|
|
4213
4063
|
EXIT_CODES.FAILURE,
|
|
4214
4064
|
PERMISSION_LEVELS4.join(" / ")
|
|
4215
4065
|
);
|
|
@@ -4221,7 +4071,7 @@ function parseOperations(raw) {
|
|
|
4221
4071
|
for (const value of raw ?? []) {
|
|
4222
4072
|
if (!isOperationType2(value)) {
|
|
4223
4073
|
throw new CliError(
|
|
4224
|
-
|
|
4074
|
+
t28("schedule.err_operation", { value }),
|
|
4225
4075
|
EXIT_CODES.FAILURE,
|
|
4226
4076
|
OPERATION_TYPES4.join(" / ")
|
|
4227
4077
|
);
|
|
@@ -4266,35 +4116,35 @@ function applyDefaultAllowlist(store, def, opts) {
|
|
|
4266
4116
|
}) ?? def;
|
|
4267
4117
|
}
|
|
4268
4118
|
function printSummary(def) {
|
|
4269
|
-
log10(
|
|
4119
|
+
log10(t28("schedule.created", { id: def.id, name: def.name }));
|
|
4270
4120
|
log10("");
|
|
4271
|
-
log10(
|
|
4121
|
+
log10(t28("schedule.created_next", { id: def.id.slice(0, 12) }));
|
|
4272
4122
|
}
|
|
4273
4123
|
function assertModelRef(value) {
|
|
4274
4124
|
if (parseModelRef3(value)) return;
|
|
4275
4125
|
throw new CliError(
|
|
4276
|
-
|
|
4126
|
+
t28("schedule.err_model_ref", { value }),
|
|
4277
4127
|
EXIT_CODES.FAILURE,
|
|
4278
|
-
|
|
4128
|
+
t28("schedule.err_model_ref_hint")
|
|
4279
4129
|
);
|
|
4280
4130
|
}
|
|
4281
4131
|
// src/schedule/doctor.ts
|
|
4282
4132
|
import { diagnoseSchedules, pruneSchedules, repairSchedules } from "@epoch-agent/core";
|
|
4283
|
-
import { t as
|
|
4133
|
+
import { t as t29 } from "@epoch-agent/infra";
|
|
4284
4134
|
async function runDoctor(opts) {
|
|
4285
4135
|
const ctx = await openSchedule();
|
|
4286
4136
|
try {
|
|
4287
4137
|
const deps = { store: ctx.store, backend: ctx.backend, registrar: ctx.registrar };
|
|
4288
4138
|
const report = await diagnoseSchedules(deps);
|
|
4289
4139
|
if (report.unsupported) {
|
|
4290
|
-
warn2(
|
|
4140
|
+
warn2(t29("schedule.doctor_unsupported"));
|
|
4291
4141
|
return;
|
|
4292
4142
|
}
|
|
4293
4143
|
if (report.drifts.length === 0) {
|
|
4294
|
-
log10(
|
|
4144
|
+
log10(t29("schedule.doctor_clean", { n: report.checked }));
|
|
4295
4145
|
return;
|
|
4296
4146
|
}
|
|
4297
|
-
log10(
|
|
4147
|
+
log10(t29("schedule.doctor_found", { n: report.drifts.length }));
|
|
4298
4148
|
for (const drift of report.drifts) {
|
|
4299
4149
|
log10(
|
|
4300
4150
|
` \xB7 ${driftLabel(drift.kind)} ${drift.name ?? drift.scheduleId ?? ""} [${drift.osTaskId || "\u2014"}]${drift.detail ? `
|
|
@@ -4303,23 +4153,23 @@ async function runDoctor(opts) {
|
|
|
4303
4153
|
}
|
|
4304
4154
|
if (opts.repair !== true && opts.prune !== true) {
|
|
4305
4155
|
log10("");
|
|
4306
|
-
log10(
|
|
4156
|
+
log10(t29("schedule.doctor_hint"));
|
|
4307
4157
|
return;
|
|
4308
4158
|
}
|
|
4309
4159
|
if (opts.repair === true) {
|
|
4310
4160
|
for (const outcome of await repairSchedules(report.drifts, deps)) {
|
|
4311
4161
|
const label = outcome.drift.name ?? outcome.drift.scheduleId ?? "";
|
|
4312
|
-
if (outcome.ok) log10(
|
|
4162
|
+
if (outcome.ok) log10(t29("schedule.doctor_repaired", { name: label }));
|
|
4313
4163
|
else
|
|
4314
|
-
warn2(
|
|
4164
|
+
warn2(t29("schedule.doctor_repair_failed", { name: label, detail: outcome.detail ?? "" }));
|
|
4315
4165
|
}
|
|
4316
4166
|
}
|
|
4317
4167
|
if (opts.prune === true) {
|
|
4318
4168
|
for (const outcome of await pruneSchedules(report.drifts, deps)) {
|
|
4319
|
-
if (outcome.ok) log10(
|
|
4169
|
+
if (outcome.ok) log10(t29("schedule.doctor_pruned", { id: outcome.drift.osTaskId }));
|
|
4320
4170
|
else {
|
|
4321
4171
|
warn2(
|
|
4322
|
-
|
|
4172
|
+
t29("schedule.doctor_prune_failed", {
|
|
4323
4173
|
id: outcome.drift.osTaskId,
|
|
4324
4174
|
detail: outcome.detail ?? ""
|
|
4325
4175
|
})
|
|
@@ -4334,13 +4184,13 @@ async function runDoctor(opts) {
|
|
|
4334
4184
|
}
|
|
4335
4185
|
// src/schedule/manage.ts
|
|
4336
4186
|
import { removeRecordings, requestScheduleCancel } from "@epoch-agent/core";
|
|
4337
|
-
import { automationLogsDir, t as
|
|
4187
|
+
import { automationLogsDir, t as t30 } from "@epoch-agent/infra";
|
|
4338
4188
|
async function runStop(idOrPrefix) {
|
|
4339
4189
|
const ctx = await openSchedule();
|
|
4340
4190
|
try {
|
|
4341
4191
|
const def = mustFind(ctx.store, idOrPrefix);
|
|
4342
4192
|
const requested = requestScheduleCancel(ctx.store.connection, def.id);
|
|
4343
|
-
log10(requested ?
|
|
4193
|
+
log10(requested ? t30("schedule.stop_requested", { name: def.name }) : t30("schedule.stop_no_run"));
|
|
4344
4194
|
if (!requested) process.exitCode = 1;
|
|
4345
4195
|
} finally {
|
|
4346
4196
|
ctx.close();
|
|
@@ -4353,7 +4203,7 @@ async function runSetEnabled(idOrPrefix, enabled) {
|
|
|
4353
4203
|
const outcome = await ctx.registrar.setEnabled(def, enabled);
|
|
4354
4204
|
reportRegistration(outcome, false);
|
|
4355
4205
|
log10(
|
|
4356
|
-
enabled ?
|
|
4206
|
+
enabled ? t30("schedule.enabled_done", { name: def.name }) : t30("schedule.disabled_done", { name: def.name })
|
|
4357
4207
|
);
|
|
4358
4208
|
} finally {
|
|
4359
4209
|
ctx.close();
|
|
@@ -4366,13 +4216,13 @@ async function runRemove(idOrPrefix) {
|
|
|
4366
4216
|
if (def.osTaskId) reportRegistration(await ctx.registrar.unregister(def), false);
|
|
4367
4217
|
ctx.store.remove(def.id);
|
|
4368
4218
|
removeRecordings(automationLogsDir(def.id, ctx.homeDir));
|
|
4369
|
-
log10(
|
|
4219
|
+
log10(t30("schedule.removed", { name: def.name }));
|
|
4370
4220
|
} finally {
|
|
4371
4221
|
ctx.close();
|
|
4372
4222
|
}
|
|
4373
4223
|
}
|
|
4374
4224
|
// src/schedule/run.ts
|
|
4375
|
-
import { t as
|
|
4225
|
+
import { t as t31 } from "@epoch-agent/infra";
|
|
4376
4226
|
import { unfixedRules } from "@epoch-agent/protocol";
|
|
4377
4227
|
import { fireSchedule } from "@epoch-agent/runtime";
|
|
4378
4228
|
async function runFire(scheduleId, homeDir) {
|
|
@@ -4385,9 +4235,9 @@ async function runFire(scheduleId, homeDir) {
|
|
|
4385
4235
|
ctx.close();
|
|
4386
4236
|
}
|
|
4387
4237
|
if (result.missing) {
|
|
4388
|
-
warn2(
|
|
4238
|
+
warn2(t31("schedule.fire_missing", { id: scheduleId }));
|
|
4389
4239
|
} else if (result.disabled) {
|
|
4390
|
-
warn2(
|
|
4240
|
+
warn2(t31("schedule.fire_disabled", { id: scheduleId }));
|
|
4391
4241
|
} else {
|
|
4392
4242
|
warn2(`${statusLabel(result.status)}${result.detail ? ` ${result.detail}` : ""}`);
|
|
4393
4243
|
}
|
|
@@ -4397,7 +4247,7 @@ async function runManual(idOrPrefix, opts) {
|
|
|
4397
4247
|
const ctx = await openSchedule();
|
|
4398
4248
|
try {
|
|
4399
4249
|
const def = mustFind(ctx.store, idOrPrefix);
|
|
4400
|
-
log10(
|
|
4250
|
+
log10(t31("schedule.run_start", { name: def.name }));
|
|
4401
4251
|
const result = await fireSchedule({
|
|
4402
4252
|
scheduleId: def.id,
|
|
4403
4253
|
homeDir: ctx.homeDir,
|
|
@@ -4413,10 +4263,10 @@ async function runManual(idOrPrefix, opts) {
|
|
|
4413
4263
|
printPending(pending);
|
|
4414
4264
|
if (opts.fix === true) {
|
|
4415
4265
|
const added = applyFix(ctx.store, def.id, pending);
|
|
4416
|
-
log10(added.length > 0 ?
|
|
4266
|
+
log10(added.length > 0 ? t31("schedule.fix_done", { n: added.length }) : t31("schedule.fix_none"));
|
|
4417
4267
|
return;
|
|
4418
4268
|
}
|
|
4419
|
-
log10(
|
|
4269
|
+
log10(t31("schedule.fix_hint", { id: def.id.slice(0, 12) }));
|
|
4420
4270
|
process.exitCode = result.exitCode;
|
|
4421
4271
|
} finally {
|
|
4422
4272
|
ctx.close();
|
|
@@ -4424,9 +4274,9 @@ async function runManual(idOrPrefix, opts) {
|
|
|
4424
4274
|
}
|
|
4425
4275
|
function printPending(pending) {
|
|
4426
4276
|
log10("");
|
|
4427
|
-
log10(
|
|
4277
|
+
log10(t31("schedule.pending_header", { n: pending.length }));
|
|
4428
4278
|
for (const item of pending) {
|
|
4429
|
-
log10(` \xB7 ${
|
|
4279
|
+
log10(` \xB7 ${t31("schedule.pending_line", { tool: item.toolName, target: item.target })}`);
|
|
4430
4280
|
if (item.suggestedRule) log10(` \u2192 ${item.suggestedRule}`);
|
|
4431
4281
|
}
|
|
4432
4282
|
}
|
|
@@ -4439,7 +4289,7 @@ function applyFix(store, scheduleId, pending) {
|
|
|
4439
4289
|
}
|
|
4440
4290
|
// src/schedule/view.ts
|
|
4441
4291
|
import { formatUsd as formatUsd2, nextRunAt, readRecording } from "@epoch-agent/core";
|
|
4442
|
-
import { t as
|
|
4292
|
+
import { t as t32 } from "@epoch-agent/infra";
|
|
4443
4293
|
import {
|
|
4444
4294
|
approvalPolicyForLevel as approvalPolicyForLevel2
|
|
4445
4295
|
} from "@epoch-agent/protocol";
|
|
@@ -4448,17 +4298,17 @@ async function runList() {
|
|
|
4448
4298
|
try {
|
|
4449
4299
|
const defs = ctx.store.list();
|
|
4450
4300
|
if (defs.length === 0) {
|
|
4451
|
-
log10(
|
|
4452
|
-
log10(
|
|
4301
|
+
log10(t32("schedule.list_empty"));
|
|
4302
|
+
log10(t32("schedule.list_empty_hint"));
|
|
4453
4303
|
return;
|
|
4454
4304
|
}
|
|
4455
|
-
log10(
|
|
4305
|
+
log10(t32("schedule.list_header"));
|
|
4456
4306
|
for (const def of defs) {
|
|
4457
|
-
const next = def.enabled ? formatWhen(nextRunAt(def.trigger, Date.now(), def.startDate, def.endDate) ?? void 0) :
|
|
4307
|
+
const next = def.enabled ? formatWhen(nextRunAt(def.trigger, Date.now(), def.startDate, def.endDate) ?? void 0) : t32("schedule.disabled_mark");
|
|
4458
4308
|
const danger = approvalPolicyForLevel2(def.permission) === "never" ? " \u{1F534}" : "";
|
|
4459
4309
|
log10(
|
|
4460
4310
|
` ${def.id.slice(0, 12)} ${def.name}${danger}
|
|
4461
|
-
${describeTrigger(def.trigger)} \xB7 ${
|
|
4311
|
+
${describeTrigger(def.trigger)} \xB7 ${t32("schedule.col_next")} ${next} \xB7 ${t32("schedule.col_last")} ${def.lastStatus ? statusLabel(def.lastStatus) : "\u2014"} \xB7 ${permissionLabel(def.permission)}`
|
|
4462
4312
|
);
|
|
4463
4313
|
}
|
|
4464
4314
|
} finally {
|
|
@@ -4470,49 +4320,49 @@ async function runShow(idOrPrefix) {
|
|
|
4470
4320
|
try {
|
|
4471
4321
|
const def = mustFind(ctx.store, idOrPrefix);
|
|
4472
4322
|
log10(`${def.name} (${def.id})`);
|
|
4473
|
-
log10(` ${
|
|
4474
|
-
log10(` ${
|
|
4323
|
+
log10(` ${t32("schedule.field_enabled")}: ${def.enabled ? t32("schedule.yes") : t32("schedule.no")}`);
|
|
4324
|
+
log10(` ${t32("schedule.field_trigger")}: ${describeTrigger(def.trigger)}`);
|
|
4475
4325
|
if (def.startDate ?? def.endDate) {
|
|
4476
|
-
log10(` ${
|
|
4326
|
+
log10(` ${t32("schedule.field_window")}: ${def.startDate ?? "\u2014"} .. ${def.endDate ?? "\u2014"}`);
|
|
4477
4327
|
}
|
|
4478
4328
|
log10(
|
|
4479
|
-
` ${
|
|
4329
|
+
` ${t32("schedule.field_next")}: ${formatWhen(
|
|
4480
4330
|
nextRunAt(def.trigger, Date.now(), def.startDate, def.endDate) ?? void 0
|
|
4481
4331
|
)}`
|
|
4482
4332
|
);
|
|
4483
|
-
log10(` ${
|
|
4484
|
-
if (def.model) log10(` ${
|
|
4485
|
-
if (def.role) log10(` ${
|
|
4486
|
-
log10(` ${
|
|
4333
|
+
log10(` ${t32("schedule.field_workdir")}: ${def.workDir}`);
|
|
4334
|
+
if (def.model) log10(` ${t32("schedule.field_model")}: ${def.model}`);
|
|
4335
|
+
if (def.role) log10(` ${t32("schedule.field_role")}: ${def.role}`);
|
|
4336
|
+
log10(` ${t32("schedule.field_permission")}: ${permissionLabel(def.permission)}`);
|
|
4487
4337
|
log10(
|
|
4488
|
-
` ${
|
|
4338
|
+
` ${t32("schedule.field_limits")}: ` + t32("schedule.limits_value", {
|
|
4489
4339
|
turns: def.maxTurns,
|
|
4490
4340
|
minutes: Math.round(def.timeoutMs / 6e4)
|
|
4491
4341
|
})
|
|
4492
4342
|
);
|
|
4493
|
-
log10(` ${
|
|
4343
|
+
log10(` ${t32("schedule.field_backend")}: ${def.osBackend} ${def.osTaskId || "\u2014"}`);
|
|
4494
4344
|
log10(
|
|
4495
|
-
` ${
|
|
4345
|
+
` ${t32("schedule.field_session")}: ` + t32(
|
|
4496
4346
|
def.showInSessionList === true ? "schedule.session_listed" : "schedule.session_discarded"
|
|
4497
4347
|
)
|
|
4498
4348
|
);
|
|
4499
|
-
log10(` ${
|
|
4349
|
+
log10(` ${t32("schedule.field_prompt")}:`);
|
|
4500
4350
|
for (const line2 of def.prompt.split("\n")) log10(` ${line2}`);
|
|
4501
4351
|
log10("");
|
|
4502
4352
|
printAllowlist(def);
|
|
4503
4353
|
log10("");
|
|
4504
|
-
log10(
|
|
4354
|
+
log10(t32("schedule.field_last_run", { when: formatWhen(def.lastRunAt) }));
|
|
4505
4355
|
} finally {
|
|
4506
4356
|
ctx.close();
|
|
4507
4357
|
}
|
|
4508
4358
|
}
|
|
4509
4359
|
function printAllowlist(def) {
|
|
4510
4360
|
if (approvalPolicyForLevel2(def.permission) === "never") {
|
|
4511
|
-
log10(
|
|
4361
|
+
log10(t32("schedule.allowlist_bypass"));
|
|
4512
4362
|
return;
|
|
4513
4363
|
}
|
|
4514
4364
|
if (def.permission === "plan") {
|
|
4515
|
-
log10(
|
|
4365
|
+
log10(t32("schedule.allowlist_readonly"));
|
|
4516
4366
|
return;
|
|
4517
4367
|
}
|
|
4518
4368
|
const lines = [
|
|
@@ -4520,9 +4370,9 @@ function printAllowlist(def) {
|
|
|
4520
4370
|
...def.allowOperations.map((v) => ` ${v}`),
|
|
4521
4371
|
...def.allowRules.map((v) => ` ${v}`)
|
|
4522
4372
|
];
|
|
4523
|
-
log10(
|
|
4524
|
-
log10(lines.length > 0 ? lines.join("\n") : ` ${
|
|
4525
|
-
log10(
|
|
4373
|
+
log10(t32("schedule.allowlist_header"));
|
|
4374
|
+
log10(lines.length > 0 ? lines.join("\n") : ` ${t32("schedule.allowlist_empty")}`);
|
|
4375
|
+
log10(t32("schedule.allowlist_scope_note"));
|
|
4526
4376
|
}
|
|
4527
4377
|
async function runLogs(idOrPrefix, limit, tail) {
|
|
4528
4378
|
const ctx = await openSchedule();
|
|
@@ -4530,7 +4380,7 @@ async function runLogs(idOrPrefix, limit, tail) {
|
|
|
4530
4380
|
const def = mustFind(ctx.store, idOrPrefix);
|
|
4531
4381
|
const runs = ctx.store.listRuns(def.id, limit);
|
|
4532
4382
|
if (runs.length === 0) {
|
|
4533
|
-
log10(
|
|
4383
|
+
log10(t32("schedule.logs_empty"));
|
|
4534
4384
|
return;
|
|
4535
4385
|
}
|
|
4536
4386
|
for (const run of runs) printRun(run);
|
|
@@ -4541,26 +4391,26 @@ async function runLogs(idOrPrefix, limit, tail) {
|
|
|
4541
4391
|
}
|
|
4542
4392
|
function printRun(run) {
|
|
4543
4393
|
log10(
|
|
4544
|
-
` ${formatWhen(run.startedAt)} ${statusLabel(run.status)} ` +
|
|
4394
|
+
` ${formatWhen(run.startedAt)} ${statusLabel(run.status)} ` + t32("schedule.run_meta", {
|
|
4545
4395
|
turns: run.turns,
|
|
4546
4396
|
cost: formatUsd2(run.costUsd, 4),
|
|
4547
|
-
manual: run.manual ?
|
|
4397
|
+
manual: run.manual ? t32("schedule.run_manual") : ""
|
|
4548
4398
|
})
|
|
4549
4399
|
);
|
|
4550
4400
|
if (run.reason) log10(` ${run.reason}`);
|
|
4551
4401
|
for (const pending of run.pendingApprovals) {
|
|
4552
4402
|
log10(
|
|
4553
|
-
` \u26A0 ${
|
|
4403
|
+
` \u26A0 ${t32("schedule.pending_line", { tool: pending.toolName, target: pending.target })}`
|
|
4554
4404
|
);
|
|
4555
4405
|
if (pending.suggestedRule) {
|
|
4556
|
-
log10(` ${
|
|
4406
|
+
log10(` ${t32("schedule.pending_fix", { rule: pending.suggestedRule })}`);
|
|
4557
4407
|
}
|
|
4558
4408
|
}
|
|
4559
4409
|
}
|
|
4560
4410
|
function printRecording(run) {
|
|
4561
4411
|
if (!run.logPath) return;
|
|
4562
4412
|
log10("");
|
|
4563
|
-
log10(
|
|
4413
|
+
log10(t32("schedule.logs_recording", { path: run.logPath }));
|
|
4564
4414
|
for (const envelope of readRecording(run.logPath)) {
|
|
4565
4415
|
const event = envelope.event;
|
|
4566
4416
|
if (event.type === "text-delta" && event.text) process.stdout.write(event.text);
|
|
@@ -4572,20 +4422,20 @@ function printRecording(run) {
|
|
|
4572
4422
|
// src/commands/schedule.ts
|
|
4573
4423
|
var DEFAULT_LOG_LIMIT = 10;
|
|
4574
4424
|
function registerScheduleCommand(program2) {
|
|
4575
|
-
const cmd = program2.command("schedule").description(
|
|
4576
|
-
cmd.command("add").description(
|
|
4577
|
-
cmd.command("list", { isDefault: true }).description(
|
|
4578
|
-
cmd.command("show").description(
|
|
4579
|
-
cmd.command("enable").description(
|
|
4580
|
-
cmd.command("disable").description(
|
|
4581
|
-
cmd.command("rm").alias("remove").description(
|
|
4582
|
-
cmd.command("run").description(
|
|
4583
|
-
cmd.command("stop").description(
|
|
4584
|
-
cmd.command("logs").description(
|
|
4425
|
+
const cmd = program2.command("schedule").description(t33("cli.schedule.summary"));
|
|
4426
|
+
cmd.command("add").description(t33("cli.schedule.add")).option("--name <name>", t33("cli.schedule.opt_name")).option("--prompt <text>", t33("cli.schedule.opt_prompt")).option("--daily <HH:mm[,HH:mm]>", t33("cli.schedule.opt_daily")).option("--weekly <days>", t33("cli.schedule.opt_weekly")).option("--monthly <days>", t33("cli.schedule.opt_monthly")).option("--every <interval>", t33("cli.schedule.opt_every")).option("--once <YYYY-MM-DD>", t33("cli.schedule.opt_once")).option("--at <HH:mm[,HH:mm]>", t33("cli.schedule.opt_at")).option("--start <YYYY-MM-DD>", t33("cli.schedule.opt_start")).option("--end <YYYY-MM-DD>", t33("cli.schedule.opt_end")).option("--workdir <dir>", t33("cli.schedule.opt_workdir")).option("--model <model>", t33("cli.schedule.opt_model")).option("--role <name>", t33("cli.schedule.opt_role")).option("--permission <level>", t33("cli.schedule.opt_permission")).option("--allow-tool <name>", t33("cli.schedule.opt_allow_tool"), collect3, []).option("--allow-operation <type>", t33("cli.schedule.opt_allow_operation"), collect3, []).option("--allow-rule <rule>", t33("cli.schedule.opt_allow_rule"), collect3, []).option("--max-turns <n>", t33("cli.schedule.opt_max_turns")).option("--timeout <minutes>", t33("cli.schedule.opt_timeout")).option("--disabled", t33("cli.schedule.opt_disabled")).option("--i-understand-bypass", t33("cli.schedule.opt_bypass_ack")).action((opts) => runAdd(opts));
|
|
4427
|
+
cmd.command("list", { isDefault: true }).description(t33("cli.schedule.list")).action(() => runList());
|
|
4428
|
+
cmd.command("show").description(t33("cli.schedule.show")).argument("<id>", t33("cli.schedule.arg_id")).action((id) => runShow(id));
|
|
4429
|
+
cmd.command("enable").description(t33("cli.schedule.enable")).argument("<id>", t33("cli.schedule.arg_id")).action((id) => runSetEnabled(id, true));
|
|
4430
|
+
cmd.command("disable").description(t33("cli.schedule.disable")).argument("<id>", t33("cli.schedule.arg_id")).action((id) => runSetEnabled(id, false));
|
|
4431
|
+
cmd.command("rm").alias("remove").description(t33("cli.schedule.rm")).argument("<id>", t33("cli.schedule.arg_id")).action((id) => runRemove(id));
|
|
4432
|
+
cmd.command("run").description(t33("cli.schedule.run")).argument("<id>", t33("cli.schedule.arg_id")).option("--fix", t33("cli.schedule.opt_fix")).action((id, opts) => runManual(id, opts));
|
|
4433
|
+
cmd.command("stop").description(t33("cli.schedule.stop")).argument("<id>", t33("cli.schedule.arg_id")).action((id) => runStop(id));
|
|
4434
|
+
cmd.command("logs").description(t33("cli.schedule.logs")).argument("<id>", t33("cli.schedule.arg_id")).option("-n, --limit <n>", t33("cli.schedule.opt_limit"), String(DEFAULT_LOG_LIMIT)).option("--tail", t33("cli.schedule.opt_tail")).action(
|
|
4585
4435
|
(id, opts) => runLogs(id, Number(opts.limit ?? DEFAULT_LOG_LIMIT), opts.tail === true)
|
|
4586
4436
|
);
|
|
4587
|
-
cmd.command("fire").description(
|
|
4588
|
-
cmd.command("doctor").description(
|
|
4437
|
+
cmd.command("fire").description(t33("cli.schedule.fire")).argument("<id>", t33("cli.schedule.arg_id")).option("--home <dir>", t33("cli.schedule.opt_home")).action((id, opts) => runFire(id, opts.home));
|
|
4438
|
+
cmd.command("doctor").description(t33("cli.schedule.doctor")).option("--repair", t33("cli.schedule.opt_repair")).option("--prune", t33("cli.schedule.opt_prune")).action((opts) => runDoctor(opts));
|
|
4589
4439
|
}
|
|
4590
4440
|
function collect3(value, previous) {
|
|
4591
4441
|
return [...previous, value];
|
|
@@ -4596,21 +4446,21 @@ import { statfs } from "fs/promises";
|
|
|
4596
4446
|
import {
|
|
4597
4447
|
describeIsolation,
|
|
4598
4448
|
getConfigIssues,
|
|
4599
|
-
loadConfig as
|
|
4449
|
+
loadConfig as loadConfig5,
|
|
4600
4450
|
SANDBOX_COVERS,
|
|
4601
|
-
|
|
4451
|
+
sandboxExcludes
|
|
4602
4452
|
} from "@epoch-agent/core";
|
|
4603
4453
|
import {
|
|
4604
4454
|
allJobs,
|
|
4605
4455
|
confine,
|
|
4606
4456
|
resolveProfile,
|
|
4607
|
-
t as
|
|
4457
|
+
t as t35
|
|
4608
4458
|
} from "@epoch-agent/infra";
|
|
4609
4459
|
import { hasFailure } from "@epoch-agent/protocol";
|
|
4610
4460
|
// src/statusline.ts
|
|
4611
4461
|
import { execFile as execFile2 } from "child_process";
|
|
4612
4462
|
import { sanitizeToolOutput } from "@epoch-agent/core";
|
|
4613
|
-
import { guardSpawn as guardSpawn4, shellSpawnArgs, t as
|
|
4463
|
+
import { guardSpawn as guardSpawn4, shellSpawnArgs, t as t34 } from "@epoch-agent/infra";
|
|
4614
4464
|
var TIMEOUT_MS2 = 2e3;
|
|
4615
4465
|
var MAX_WIDTH = 60;
|
|
4616
4466
|
var MAX_BUFFER = 64 * 1024;
|
|
@@ -4639,7 +4489,7 @@ function runStatusLineCommand(command, cwd) {
|
|
|
4639
4489
|
const killed = err2.killed === true;
|
|
4640
4490
|
settle({
|
|
4641
4491
|
text: null,
|
|
4642
|
-
error: killed ?
|
|
4492
|
+
error: killed ? t34("statusline.timeout", { ms: TIMEOUT_MS2 }) : err2.message.trim()
|
|
4643
4493
|
});
|
|
4644
4494
|
return;
|
|
4645
4495
|
}
|
|
@@ -4655,7 +4505,7 @@ async function probeStatusLine(config, cwd) {
|
|
|
4655
4505
|
if (!command) return null;
|
|
4656
4506
|
const result = await runStatusLineCommand(command, cwd);
|
|
4657
4507
|
if (result.text === null) {
|
|
4658
|
-
return { command, ok: false, detail: result.error ??
|
|
4508
|
+
return { command, ok: false, detail: result.error ?? t34("statusline.no_output") };
|
|
4659
4509
|
}
|
|
4660
4510
|
return { command, ok: true, detail: result.text };
|
|
4661
4511
|
}
|
|
@@ -4688,10 +4538,10 @@ async function describeDisk(path = ".") {
|
|
|
4688
4538
|
}
|
|
4689
4539
|
}
|
|
4690
4540
|
function describeConfig() {
|
|
4691
|
-
if (!existsSync7(CONFIG_PATH)) return
|
|
4692
|
-
|
|
4541
|
+
if (!existsSync7(CONFIG_PATH)) return t35("cli.status.config_absent");
|
|
4542
|
+
loadConfig5();
|
|
4693
4543
|
const n = getConfigIssues().length;
|
|
4694
|
-
return n === 0 ?
|
|
4544
|
+
return n === 0 ? t35("cli.status.config_present") : t35("cli.status.config_present_with_issues", { count: n });
|
|
4695
4545
|
}
|
|
4696
4546
|
async function describeSecretBackend() {
|
|
4697
4547
|
try {
|
|
@@ -4699,18 +4549,18 @@ async function describeSecretBackend() {
|
|
|
4699
4549
|
const store = await createSecretStore();
|
|
4700
4550
|
return store.encrypted ? store.detail : `\u26A0 ${store.detail}`;
|
|
4701
4551
|
} catch (err2) {
|
|
4702
|
-
return
|
|
4552
|
+
return t35("cli.status.secret_probe_failed", {
|
|
4703
4553
|
message: err2 instanceof Error ? err2.message : String(err2)
|
|
4704
4554
|
});
|
|
4705
4555
|
}
|
|
4706
4556
|
}
|
|
4707
4557
|
function workspaceLines(rt) {
|
|
4708
|
-
const lines = [` ${
|
|
4558
|
+
const lines = [` ${t35("cli.doctor.workspace_root", { root: rt.workspace.root })}`];
|
|
4709
4559
|
lines.push(
|
|
4710
|
-
` ${rt.trusted ?
|
|
4560
|
+
` ${rt.trusted ? t35("cli.doctor.workspace_trusted") : t35("cli.doctor.workspace_untrusted")}`
|
|
4711
4561
|
);
|
|
4712
4562
|
lines.push(
|
|
4713
|
-
` ${rt.workspace.extra.length === 0 ?
|
|
4563
|
+
` ${rt.workspace.extra.length === 0 ? t35("cli.doctor.workspace_no_extra") : t35("cli.doctor.workspace_extra", { count: rt.workspace.extra.length })}`
|
|
4714
4564
|
);
|
|
4715
4565
|
for (const dir of rt.workspace.extra) lines.push(` \xB7 ${dir}`);
|
|
4716
4566
|
return lines;
|
|
@@ -4718,94 +4568,106 @@ function workspaceLines(rt) {
|
|
|
4718
4568
|
function sandboxLines(cwd, sandbox) {
|
|
4719
4569
|
const iso = describeIsolation();
|
|
4720
4570
|
const lines = [`
|
|
4721
|
-
${
|
|
4571
|
+
${t35("cli.doctor.sandbox_head")}`];
|
|
4722
4572
|
if (iso.backend === "none") {
|
|
4723
4573
|
lines.push(` ${STATUS_MARK.skipped} ${iso.detail}`);
|
|
4724
4574
|
lines.push(
|
|
4725
|
-
` ${STATUS_MARK.warn} ${
|
|
4575
|
+
` ${STATUS_MARK.warn} ${t35(
|
|
4726
4576
|
iso.reason === "platform-unsupported" ? "cli.doctor.sandbox_absent_by_design" : "cli.doctor.sandbox_absent_tools"
|
|
4727
4577
|
)}`
|
|
4728
4578
|
);
|
|
4729
4579
|
return lines;
|
|
4730
4580
|
}
|
|
4731
4581
|
lines.push(
|
|
4732
|
-
` ${STATUS_MARK.ok} ${
|
|
4582
|
+
` ${STATUS_MARK.ok} ${t35("cli.doctor.sandbox_backend", { backend: iso.backend, platform: iso.platform })}`
|
|
4733
4583
|
);
|
|
4734
|
-
lines.push(` \xB7 ${
|
|
4584
|
+
lines.push(` \xB7 ${t35("cli.doctor.sandbox_code_exec", { detail: iso.detail })}`);
|
|
4735
4585
|
const probe = (mode) => confine("/bin/sh", ["-c", "true"], { mode, workspaceRoot: cwd, allowNetwork: true });
|
|
4736
4586
|
for (const mode of ["workspace-write", "read-only"]) {
|
|
4737
4587
|
const c = probe(mode);
|
|
4738
4588
|
if (!c.confined) continue;
|
|
4739
|
-
lines.push(` \xB7 ${
|
|
4740
|
-
if (c.enforcement === "partial")
|
|
4589
|
+
lines.push(` \xB7 ${t35("cli.doctor.sandbox_terminal", { mode, enforcement: c.enforcement })}`);
|
|
4590
|
+
if (c.enforcement === "partial") {
|
|
4591
|
+
lines.push(
|
|
4592
|
+
` ${t35(
|
|
4593
|
+
c.backend === "windows-acl" ? "cli.doctor.sandbox_partial_integrity" : "cli.doctor.sandbox_partial_devnull"
|
|
4594
|
+
)}`
|
|
4595
|
+
);
|
|
4596
|
+
}
|
|
4741
4597
|
}
|
|
4742
4598
|
const writable = probe("workspace-write");
|
|
4743
4599
|
if (writable.confined) {
|
|
4744
|
-
lines.push(` \xB7 ${
|
|
4600
|
+
lines.push(` \xB7 ${t35("cli.doctor.sandbox_writable")}`);
|
|
4745
4601
|
for (const dir of writable.writableDirs) lines.push(` \xB7 ${dir}`);
|
|
4746
4602
|
}
|
|
4747
4603
|
lines.push(
|
|
4748
|
-
sandbox?.terminal === false ? ` ${STATUS_MARK.warn} ${
|
|
4749
|
-
);
|
|
4750
|
-
lines.push(` \xB7 ${t36("cli.doctor.sandbox_covers", { tools: SANDBOX_COVERS.join(", ") })}`);
|
|
4751
|
-
lines.push(
|
|
4752
|
-
SANDBOX_EXCLUDES.length === 0 ? ` ${STATUS_MARK.ok} ${t36("cli.doctor.sandbox_excludes_none")}` : ` ${STATUS_MARK.warn} ${t36("cli.doctor.sandbox_excludes", { tools: SANDBOX_EXCLUDES.join(", ") })}`
|
|
4604
|
+
sandbox?.terminal === false ? ` ${STATUS_MARK.warn} ${t35("cli.doctor.sandbox_switch_off")}` : ` ${STATUS_MARK.ok} ${t35("cli.doctor.sandbox_switch_on")}`
|
|
4753
4605
|
);
|
|
4606
|
+
lines.push(` \xB7 ${t35("cli.doctor.sandbox_covers", { tools: SANDBOX_COVERS.join(", ") })}`);
|
|
4607
|
+
const excludes = sandboxExcludes(writable.backend);
|
|
4608
|
+
if (excludes.length === 0) {
|
|
4609
|
+
lines.push(` ${STATUS_MARK.ok} ${t35("cli.doctor.sandbox_excludes_none")}`);
|
|
4610
|
+
} else {
|
|
4611
|
+
lines.push(
|
|
4612
|
+
` ${STATUS_MARK.warn} ${t35("cli.doctor.sandbox_excludes", { tools: excludes.join(", ") })}`
|
|
4613
|
+
);
|
|
4614
|
+
lines.push(` ${t35("cli.doctor.sandbox_writes_only")}`);
|
|
4615
|
+
}
|
|
4754
4616
|
return lines;
|
|
4755
4617
|
}
|
|
4756
4618
|
function ftsLines(health) {
|
|
4757
4619
|
const lines = [`
|
|
4758
|
-
${
|
|
4620
|
+
${t35("cli.doctor.fts_head")}`];
|
|
4759
4621
|
const indexed = health.tables.map((tb) => `${tb.table} ${tb.rows}`).join(" \xB7 ");
|
|
4760
|
-
lines.push(` \xB7 ${
|
|
4622
|
+
lines.push(` \xB7 ${t35("cli.doctor.fts_rows", { messages: health.messages, indexed })}`);
|
|
4761
4623
|
const behind = health.tables.filter((tb) => tb.rows !== health.messages);
|
|
4762
4624
|
lines.push(
|
|
4763
|
-
behind.length === 0 ? ` ${STATUS_MARK.ok} ${
|
|
4764
|
-
` ${STATUS_MARK.warn} ${
|
|
4625
|
+
behind.length === 0 ? ` ${STATUS_MARK.ok} ${t35("cli.doctor.fts_in_sync")}` : (
|
|
4626
|
+
` ${STATUS_MARK.warn} ${t35("cli.doctor.fts_out_of_sync", {
|
|
4765
4627
|
tables: behind.map((tb) => `${tb.table} (${tb.rows - health.messages})`).join(", ")
|
|
4766
4628
|
})}`
|
|
4767
4629
|
)
|
|
4768
4630
|
);
|
|
4769
4631
|
lines.push(
|
|
4770
|
-
health.missingTriggers.length === 0 ? ` ${STATUS_MARK.ok} ${
|
|
4632
|
+
health.missingTriggers.length === 0 ? ` ${STATUS_MARK.ok} ${t35("cli.doctor.fts_triggers_ok")}` : ` ${STATUS_MARK.failed} ${t35("cli.doctor.fts_triggers_missing", {
|
|
4771
4633
|
triggers: health.missingTriggers.join(", ")
|
|
4772
4634
|
})}`
|
|
4773
4635
|
);
|
|
4774
4636
|
for (const tb of health.tables) {
|
|
4775
4637
|
if (tb.error !== null) {
|
|
4776
4638
|
lines.push(
|
|
4777
|
-
` ${STATUS_MARK.failed} ${
|
|
4639
|
+
` ${STATUS_MARK.failed} ${t35("cli.doctor.fts_corrupt", { table: tb.table, detail: tb.error })}`
|
|
4778
4640
|
);
|
|
4779
4641
|
}
|
|
4780
4642
|
if (tb.drift !== null) {
|
|
4781
4643
|
lines.push(
|
|
4782
|
-
` ${STATUS_MARK.warn} ${
|
|
4644
|
+
` ${STATUS_MARK.warn} ${t35("cli.doctor.fts_drift", { table: tb.table, detail: tb.drift })}`
|
|
4783
4645
|
);
|
|
4784
4646
|
}
|
|
4785
4647
|
}
|
|
4786
4648
|
if (health.tables.some((tb) => !tb.external)) {
|
|
4787
|
-
lines.push(` ${STATUS_MARK.warn} ${
|
|
4649
|
+
lines.push(` ${STATUS_MARK.warn} ${t35("cli.doctor.fts_legacy_schema")}`);
|
|
4788
4650
|
}
|
|
4789
4651
|
if (health.indexBytes !== void 0) {
|
|
4790
|
-
lines.push(` \xB7 ${
|
|
4652
|
+
lines.push(` \xB7 ${t35("cli.doctor.fts_size", { size: formatBytes(health.indexBytes) })}`);
|
|
4791
4653
|
}
|
|
4792
4654
|
if (health.space?.fileBytes !== void 0) {
|
|
4793
4655
|
lines.push(
|
|
4794
|
-
` \xB7 ${
|
|
4656
|
+
` \xB7 ${t35("cli.doctor.fts_space", {
|
|
4795
4657
|
file: formatBytes(health.space.fileBytes),
|
|
4796
4658
|
free: formatBytes(health.space.freeBytes)
|
|
4797
4659
|
})}`
|
|
4798
4660
|
);
|
|
4799
|
-
lines.push(` \xB7 ${
|
|
4661
|
+
lines.push(` \xB7 ${t35("cli.doctor.fts_reclaim_hint")}`);
|
|
4800
4662
|
}
|
|
4801
4663
|
return lines;
|
|
4802
4664
|
}
|
|
4803
4665
|
function reclaimLines(report) {
|
|
4804
4666
|
const lines = [`
|
|
4805
|
-
${
|
|
4667
|
+
${t35("cli.doctor.reclaim_head")}`];
|
|
4806
4668
|
const secs = (ms) => `${(ms / 1e3).toFixed(1)}s`;
|
|
4807
4669
|
lines.push(
|
|
4808
|
-
` ${STATUS_MARK.ok} ${
|
|
4670
|
+
` ${STATUS_MARK.ok} ${t35("cli.doctor.reclaim_optimize", {
|
|
4809
4671
|
before: formatBytes(report.before.freeBytes),
|
|
4810
4672
|
after: formatBytes(report.afterOptimize.freeBytes),
|
|
4811
4673
|
ms: secs(report.optimizeMs)
|
|
@@ -4813,7 +4675,7 @@ ${t36("cli.doctor.reclaim_head")}`];
|
|
|
4813
4675
|
);
|
|
4814
4676
|
if (report.vacuumed) {
|
|
4815
4677
|
lines.push(
|
|
4816
|
-
` ${STATUS_MARK.ok} ${
|
|
4678
|
+
` ${STATUS_MARK.ok} ${t35("cli.doctor.reclaim_vacuum", {
|
|
4817
4679
|
before: formatBytes(report.before.pageBytes),
|
|
4818
4680
|
after: formatBytes(report.after.pageBytes),
|
|
4819
4681
|
ms: secs(report.vacuumMs)
|
|
@@ -4821,14 +4683,14 @@ ${t36("cli.doctor.reclaim_head")}`];
|
|
|
4821
4683
|
);
|
|
4822
4684
|
const saved = report.before.pageBytes - report.after.pageBytes;
|
|
4823
4685
|
lines.push(
|
|
4824
|
-
` ${STATUS_MARK.ok} ${
|
|
4686
|
+
` ${STATUS_MARK.ok} ${t35("cli.doctor.reclaim_total", {
|
|
4825
4687
|
saved: formatBytes(saved),
|
|
4826
4688
|
pct: `${(saved / Math.max(1, report.before.pageBytes) * 100).toFixed(1)}%`
|
|
4827
4689
|
})}`
|
|
4828
4690
|
);
|
|
4829
4691
|
} else if (report.vacuumError !== null) {
|
|
4830
4692
|
lines.push(
|
|
4831
|
-
` ${STATUS_MARK.warn} ${
|
|
4693
|
+
` ${STATUS_MARK.warn} ${t35("cli.doctor.reclaim_vacuum_skipped", {
|
|
4832
4694
|
detail: report.vacuumError
|
|
4833
4695
|
})}`
|
|
4834
4696
|
);
|
|
@@ -4848,17 +4710,17 @@ function hookLines(rt) {
|
|
|
4848
4710
|
const { sources } = rt.hook;
|
|
4849
4711
|
if (sources.length === 0) return [];
|
|
4850
4712
|
const lines = [`
|
|
4851
|
-
${
|
|
4713
|
+
${t35("cli.doctor.hook_head")}`];
|
|
4852
4714
|
for (const source of sources) {
|
|
4853
|
-
const label =
|
|
4715
|
+
const label = t35(HOOK_SOURCE_LABEL[source.kind]);
|
|
4854
4716
|
if (source.skipped) {
|
|
4855
4717
|
lines.push(` ${STATUS_MARK.skipped} ${label}: ${source.path}`);
|
|
4856
|
-
lines.push(` ${
|
|
4718
|
+
lines.push(` ${t35("cli.doctor.hook_skipped")}`);
|
|
4857
4719
|
continue;
|
|
4858
4720
|
}
|
|
4859
4721
|
const name = source.plugin === void 0 ? label : `${label} ${source.plugin}`;
|
|
4860
4722
|
lines.push(
|
|
4861
|
-
` ${STATUS_MARK.ok} ${name}: ${source.path}${
|
|
4723
|
+
` ${STATUS_MARK.ok} ${name}: ${source.path}${t35("cli.doctor.hook_count", {
|
|
4862
4724
|
n: source.count
|
|
4863
4725
|
})}`
|
|
4864
4726
|
);
|
|
@@ -4872,65 +4734,65 @@ var JOB_KIND_LABEL = {
|
|
|
4872
4734
|
};
|
|
4873
4735
|
function jobLines(jobs) {
|
|
4874
4736
|
const lines = [`
|
|
4875
|
-
${
|
|
4737
|
+
${t35("cli.doctor.jobs_head")}`];
|
|
4876
4738
|
const running = jobs.filter((job) => job.status === "running");
|
|
4877
4739
|
if (running.length === 0) {
|
|
4878
|
-
lines.push(` ${STATUS_MARK.ok} ${
|
|
4740
|
+
lines.push(` ${STATUS_MARK.ok} ${t35("cli.doctor.jobs_none")}`);
|
|
4879
4741
|
return lines;
|
|
4880
4742
|
}
|
|
4881
|
-
lines.push(` ${STATUS_MARK.warn} ${
|
|
4743
|
+
lines.push(` ${STATUS_MARK.warn} ${t35("cli.doctor.jobs_running", { n: running.length })}`);
|
|
4882
4744
|
for (const job of running) {
|
|
4883
4745
|
lines.push(
|
|
4884
|
-
` \xB7 ${
|
|
4885
|
-
kind:
|
|
4746
|
+
` \xB7 ${t35("cli.doctor.jobs_line", {
|
|
4747
|
+
kind: t35(JOB_KIND_LABEL[job.kind]),
|
|
4886
4748
|
id: job.id,
|
|
4887
4749
|
label: job.label
|
|
4888
4750
|
})}`
|
|
4889
4751
|
);
|
|
4890
4752
|
}
|
|
4891
|
-
lines.push(` \xB7 ${
|
|
4753
|
+
lines.push(` \xB7 ${t35("cli.doctor.jobs_lifetime")}`);
|
|
4892
4754
|
return lines;
|
|
4893
4755
|
}
|
|
4894
4756
|
function terminalLines(result, terminal) {
|
|
4895
4757
|
const head = `
|
|
4896
|
-
${
|
|
4758
|
+
${t35("cli.doctor.terminal_head")}`;
|
|
4897
4759
|
if (!result.ok) {
|
|
4898
4760
|
if (result.failure.kind === "no-tty") {
|
|
4899
4761
|
return [
|
|
4900
4762
|
head,
|
|
4901
|
-
` ${STATUS_MARK.warn} ${
|
|
4902
|
-
` \xB7 ${
|
|
4763
|
+
` ${STATUS_MARK.warn} ${t35("cli.doctor.terminal_no_tty")}`,
|
|
4764
|
+
` \xB7 ${t35("cli.doctor.terminal_alternatives")}`
|
|
4903
4765
|
];
|
|
4904
4766
|
}
|
|
4905
4767
|
return [
|
|
4906
4768
|
head,
|
|
4907
|
-
` ${STATUS_MARK.warn} ${
|
|
4769
|
+
` ${STATUS_MARK.warn} ${t35("cli.doctor.terminal_timeout", { n: result.failure.timeoutMs / 1e3 })}`
|
|
4908
4770
|
];
|
|
4909
4771
|
}
|
|
4910
4772
|
switch (result.sample.kind) {
|
|
4911
4773
|
case "shift-enter":
|
|
4912
|
-
return [head, ` ${STATUS_MARK.ok} ${
|
|
4774
|
+
return [head, ` ${STATUS_MARK.ok} ${t35("cli.doctor.terminal_shift_enter")}`];
|
|
4913
4775
|
case "enter-only":
|
|
4914
4776
|
if (terminal?.kind === "apple-terminal") {
|
|
4915
4777
|
return [
|
|
4916
4778
|
head,
|
|
4917
|
-
` ${STATUS_MARK.warn} ${
|
|
4918
|
-
` \xB7 ${
|
|
4779
|
+
` ${STATUS_MARK.warn} ${t35("cli.doctor.terminal_apple")}`,
|
|
4780
|
+
` \xB7 ${t35("cli.doctor.terminal_alternatives")}`
|
|
4919
4781
|
];
|
|
4920
4782
|
}
|
|
4921
4783
|
return [
|
|
4922
4784
|
head,
|
|
4923
|
-
` ${STATUS_MARK.warn} ${
|
|
4924
|
-
` \xB7 ${
|
|
4925
|
-
` \xB7 ${
|
|
4785
|
+
` ${STATUS_MARK.warn} ${t35("cli.doctor.terminal_enter_only")}`,
|
|
4786
|
+
` \xB7 ${t35("cli.doctor.terminal_alternatives")}`,
|
|
4787
|
+
` \xB7 ${t35("cli.doctor.terminal_setup_hint")}`
|
|
4926
4788
|
];
|
|
4927
4789
|
case "other":
|
|
4928
4790
|
return [
|
|
4929
4791
|
head,
|
|
4930
|
-
` ${STATUS_MARK.warn} ${
|
|
4792
|
+
` ${STATUS_MARK.warn} ${t35("cli.doctor.terminal_other", { hex: result.sample.hex })}`
|
|
4931
4793
|
];
|
|
4932
4794
|
case "interrupted":
|
|
4933
|
-
return [head, ` \xB7 ${
|
|
4795
|
+
return [head, ` \xB7 ${t35("cli.doctor.terminal_interrupted")}`];
|
|
4934
4796
|
}
|
|
4935
4797
|
}
|
|
4936
4798
|
async function statusLineLines(config, cwd) {
|
|
@@ -4938,48 +4800,48 @@ async function statusLineLines(config, cwd) {
|
|
|
4938
4800
|
if (!probe) return [];
|
|
4939
4801
|
return [
|
|
4940
4802
|
`
|
|
4941
|
-
${
|
|
4942
|
-
` ${
|
|
4943
|
-
` ${probe.ok ?
|
|
4803
|
+
${t35("cli.doctor.status_line_head")}`,
|
|
4804
|
+
` ${t35("cli.doctor.status_line_command", { command: probe.command })}`,
|
|
4805
|
+
` ${probe.ok ? t35("cli.doctor.status_line_ok", { detail: probe.detail }) : t35("cli.doctor.status_line_broken", { detail: probe.detail })}`
|
|
4944
4806
|
];
|
|
4945
4807
|
}
|
|
4946
4808
|
function registerStatusCommands(program2) {
|
|
4947
|
-
program2.command("status").description(
|
|
4809
|
+
program2.command("status").description(t35("cli.status.cmd_root")).action(async () => {
|
|
4948
4810
|
log11(
|
|
4949
4811
|
[
|
|
4950
|
-
|
|
4812
|
+
t35("cli.status.version", { version: VERSION }),
|
|
4951
4813
|
`Node: ${process.version} (${process.platform}/${process.arch})`,
|
|
4952
|
-
|
|
4814
|
+
t35("cli.status.home", { path: EPOCH_HOME }),
|
|
4953
4815
|
`Profile: ${resolveProfile()}`,
|
|
4954
|
-
|
|
4955
|
-
state: hasCredentials() ?
|
|
4816
|
+
t35("cli.status.credentials", {
|
|
4817
|
+
state: hasCredentials() ? t35("cli.status.credentials_set") : t35("cli.status.credentials_unset")
|
|
4956
4818
|
}),
|
|
4957
|
-
|
|
4819
|
+
t35("cli.status.secret_backend", { detail: await describeSecretBackend() }),
|
|
4958
4820
|
`config.yaml: ${describeConfig()}`,
|
|
4959
|
-
`.env: ${existsSync7(ENV_PATH) ?
|
|
4821
|
+
`.env: ${existsSync7(ENV_PATH) ? t35("cli.status.env_present") : t35("cli.status.env_absent")}`
|
|
4960
4822
|
].join("\n")
|
|
4961
4823
|
);
|
|
4962
4824
|
});
|
|
4963
|
-
program2.command("doctor").description(
|
|
4964
|
-
log11(
|
|
4825
|
+
program2.command("doctor").description(t35("cli.doctor.cmd_root")).option("--reclaim", t35("cli.doctor.reclaim_opt")).action(async (opts) => {
|
|
4826
|
+
log11(t35("cli.doctor.node", { version: process.version }));
|
|
4965
4827
|
const avail = await describeDisk();
|
|
4966
|
-
if (avail) log11(
|
|
4967
|
-
log11(`${hasCredentials() ? "\u2713" : "\u25CB"} ${
|
|
4968
|
-
const configIssues = existsSync7(CONFIG_PATH) ? (
|
|
4828
|
+
if (avail) log11(t35("cli.doctor.disk", { avail }));
|
|
4829
|
+
log11(`${hasCredentials() ? "\u2713" : "\u25CB"} ${t35("cli.doctor.credentials")}`);
|
|
4830
|
+
const configIssues = existsSync7(CONFIG_PATH) ? (loadConfig5(), getConfigIssues()) : [];
|
|
4969
4831
|
const configMark = !existsSync7(CONFIG_PATH) ? "\u25CB" : configIssues.length > 0 ? "\u26A0" : "\u2713";
|
|
4970
4832
|
log11(`${configMark} config: ${CONFIG_PATH}`);
|
|
4971
4833
|
try {
|
|
4972
4834
|
const { buildRuntime: buildRuntime4 } = await import("@epoch-agent/runtime");
|
|
4973
4835
|
const rt = await buildRuntime4({ installSignalHandlers: true });
|
|
4974
4836
|
log11(`
|
|
4975
|
-
${
|
|
4837
|
+
${t35("cli.doctor.workspace_head")}`);
|
|
4976
4838
|
for (const line2 of workspaceLines(rt)) log11(line2);
|
|
4977
4839
|
for (const line2 of sandboxLines(rt.workspace.root, rt.config.sandbox)) log11(line2);
|
|
4978
4840
|
for (const line2 of hookLines(rt)) log11(line2);
|
|
4979
4841
|
for (const line2 of jobLines(allJobs().map((j) => j.info))) log11(line2);
|
|
4980
4842
|
const { classifyTerminal, probeShiftEnter } = await import("@epoch-agent/tui");
|
|
4981
4843
|
for (const line2 of terminalLines(
|
|
4982
|
-
await probeShiftEnter({ prompt:
|
|
4844
|
+
await probeShiftEnter({ prompt: t35("cli.doctor.terminal_prompt"), timeoutMs: 8e3 }),
|
|
4983
4845
|
classifyTerminal(process.env)
|
|
4984
4846
|
))
|
|
4985
4847
|
log11(line2);
|
|
@@ -4989,9 +4851,9 @@ ${t36("cli.doctor.workspace_head")}`);
|
|
|
4989
4851
|
for (const line2 of ftsLines(rt.sessionStore.ftsHealth())) log11(line2);
|
|
4990
4852
|
} catch (err2) {
|
|
4991
4853
|
log11(`
|
|
4992
|
-
${
|
|
4854
|
+
${t35("cli.doctor.fts_head")}`);
|
|
4993
4855
|
log11(
|
|
4994
|
-
` ${STATUS_MARK.warn} ${
|
|
4856
|
+
` ${STATUS_MARK.warn} ${t35("cli.doctor.fts_probe_failed", {
|
|
4995
4857
|
detail: err2 instanceof Error ? err2.message : String(err2)
|
|
4996
4858
|
})}`
|
|
4997
4859
|
);
|
|
@@ -5001,9 +4863,9 @@ ${t36("cli.doctor.fts_head")}`);
|
|
|
5001
4863
|
for (const line2 of reclaimLines(rt.sessionStore.reclaimFts())) log11(line2);
|
|
5002
4864
|
} catch (err2) {
|
|
5003
4865
|
log11(`
|
|
5004
|
-
${
|
|
4866
|
+
${t35("cli.doctor.reclaim_head")}`);
|
|
5005
4867
|
log11(
|
|
5006
|
-
` ${STATUS_MARK.failed} ${
|
|
4868
|
+
` ${STATUS_MARK.failed} ${t35("cli.doctor.reclaim_failed", {
|
|
5007
4869
|
detail: err2 instanceof Error ? err2.message : String(err2)
|
|
5008
4870
|
})}`
|
|
5009
4871
|
);
|
|
@@ -5011,7 +4873,7 @@ ${t36("cli.doctor.reclaim_head")}`);
|
|
|
5011
4873
|
}
|
|
5012
4874
|
}
|
|
5013
4875
|
log11(`
|
|
5014
|
-
${
|
|
4876
|
+
${t35("cli.doctor.modules_head")}`);
|
|
5015
4877
|
const order = { failed: 0, warn: 1, skipped: 2, ok: 3 };
|
|
5016
4878
|
const sorted = [...rt.diagnosticList].sort(
|
|
5017
4879
|
(a, b) => (order[a.status] ?? 9) - (order[b.status] ?? 9)
|
|
@@ -5021,13 +4883,13 @@ ${t36("cli.doctor.modules_head")}`);
|
|
|
5021
4883
|
if (hasFailure(rt.diagnosticList)) {
|
|
5022
4884
|
const bad = rt.diagnosticList.filter((d) => d.status === "failed").length;
|
|
5023
4885
|
log11(`
|
|
5024
|
-
${
|
|
4886
|
+
${t35("cli.doctor.modules_failed", { count: bad })}`);
|
|
5025
4887
|
process.exitCode = EXIT_CODES.FAILURE;
|
|
5026
4888
|
}
|
|
5027
4889
|
} catch (err2) {
|
|
5028
4890
|
log11(
|
|
5029
4891
|
`
|
|
5030
|
-
${
|
|
4892
|
+
${t35("cli.doctor.build_failed", {
|
|
5031
4893
|
message: err2 instanceof Error ? err2.message : String(err2)
|
|
5032
4894
|
})}`
|
|
5033
4895
|
);
|
|
@@ -5037,30 +4899,21 @@ ${t36("cli.doctor.build_failed", {
|
|
|
5037
4899
|
// src/commands/trust.ts
|
|
5038
4900
|
import { existsSync as existsSync8, realpathSync as realpathSync3 } from "fs";
|
|
5039
4901
|
import { resolve as resolve4 } from "path";
|
|
5040
|
-
import {
|
|
5041
|
-
|
|
5042
|
-
inventoryProjectExtensions as inventoryProjectExtensions2,
|
|
5043
|
-
loadConfig as loadConfig7,
|
|
5044
|
-
TrustManager as TrustManager3
|
|
5045
|
-
} from "@epoch-agent/core";
|
|
5046
|
-
import { t as t37, trustPath as trustPath3, uiDateLocale as uiDateLocale4 } from "@epoch-agent/infra";
|
|
4902
|
+
import { loadConfig as loadConfig6, TrustManager as TrustManager2 } from "@epoch-agent/core";
|
|
4903
|
+
import { t as t36, trustPath as trustPath2, uiDateLocale as uiDateLocale4 } from "@epoch-agent/infra";
|
|
5047
4904
|
var log12 = (msg) => process.stdout.write(msg + "\n");
|
|
5048
4905
|
var warn3 = (msg) => process.stderr.write(msg + "\n");
|
|
5049
4906
|
function scopeLabel(scope) {
|
|
5050
|
-
return scope === "directory-tree" ?
|
|
5051
|
-
}
|
|
5052
|
-
function tierLabel(record) {
|
|
5053
|
-
if (record.level !== "trusted") return t37("trust.tier_none");
|
|
5054
|
-
return record.exec === true ? t37("trust.tier_exec") : t37("trust.tier_read");
|
|
4907
|
+
return scope === "directory-tree" ? t36("trust.scope_tree") : t36("trust.scope_dir");
|
|
5055
4908
|
}
|
|
5056
4909
|
function levelLabel(level) {
|
|
5057
4910
|
switch (level) {
|
|
5058
4911
|
case "trusted":
|
|
5059
|
-
return
|
|
4912
|
+
return t36("trust.level_trusted");
|
|
5060
4913
|
case "untrusted":
|
|
5061
|
-
return
|
|
4914
|
+
return t36("trust.level_untrusted");
|
|
5062
4915
|
case "unknown":
|
|
5063
|
-
return
|
|
4916
|
+
return t36("trust.level_unknown");
|
|
5064
4917
|
}
|
|
5065
4918
|
}
|
|
5066
4919
|
function physicalPath(input2) {
|
|
@@ -5073,110 +4926,107 @@ function physicalPath(input2) {
|
|
|
5073
4926
|
}
|
|
5074
4927
|
}
|
|
5075
4928
|
function registerTrustCommand(program2) {
|
|
5076
|
-
const cmd = program2.command("trust").description(
|
|
5077
|
-
cmd.command("list", { isDefault: true }).description(
|
|
5078
|
-
cmd.command("add").description(
|
|
4929
|
+
const cmd = program2.command("trust").description(t36("trust.cmd_root"));
|
|
4930
|
+
cmd.command("list", { isDefault: true }).description(t36("trust.cmd_list")).action(() => withTrust((tm) => printList3(tm)));
|
|
4931
|
+
cmd.command("add").description(t36("trust.cmd_add")).argument("[path]", t36("trust.arg_path_default")).option("--tree", t36("trust.opt_tree_add")).action((path, opts) => {
|
|
5079
4932
|
withTrust((tm) => {
|
|
5080
4933
|
const dir = physicalPath(path ?? process.cwd());
|
|
5081
4934
|
const scope = opts.tree ? "directory-tree" : "directory";
|
|
5082
|
-
tm.record(dir, "trusted", scope, { exec:
|
|
5083
|
-
log12(`\u2713 ${
|
|
5084
|
-
if (!opts.exec && hasExecTierContent2(inventoryProjectExtensions2(dir))) {
|
|
5085
|
-
log12(t37("trust.added_read_only_hint", { dir }));
|
|
5086
|
-
}
|
|
4935
|
+
tm.record(dir, "trusted", scope, { exec: true });
|
|
4936
|
+
log12(`\u2713 ${t36("trust.added", { dir, scope: scopeLabel(scope) })}`);
|
|
5087
4937
|
});
|
|
5088
4938
|
});
|
|
5089
|
-
cmd.command("deny").description(
|
|
4939
|
+
cmd.command("deny").description(t36("trust.cmd_deny")).argument("[path]", t36("trust.arg_path_default")).option("--tree", t36("trust.opt_tree_deny")).action((path, opts) => {
|
|
5090
4940
|
withTrust((tm) => {
|
|
5091
4941
|
const dir = physicalPath(path ?? process.cwd());
|
|
5092
4942
|
tm.record(dir, "untrusted", opts.tree ? "directory-tree" : "directory");
|
|
5093
4943
|
log12(
|
|
5094
|
-
`\u2717 ${
|
|
4944
|
+
`\u2717 ${t36("trust.denied", {
|
|
5095
4945
|
dir,
|
|
5096
4946
|
scope: scopeLabel(opts.tree ? "directory-tree" : "directory")
|
|
5097
4947
|
})}`
|
|
5098
4948
|
);
|
|
5099
4949
|
});
|
|
5100
4950
|
});
|
|
5101
|
-
cmd.command("remove").alias("rm").description(
|
|
4951
|
+
cmd.command("remove").alias("rm").description(t36("trust.cmd_remove")).argument("<path>", t36("trust.arg_path")).action((path) => {
|
|
5102
4952
|
withTrust((tm) => {
|
|
5103
4953
|
const dir = physicalPath(path);
|
|
5104
4954
|
if (!tm.list().some((r) => resolve4(r.path) === dir)) {
|
|
5105
|
-
warn3(
|
|
4955
|
+
warn3(t36("trust.no_record", { dir }));
|
|
5106
4956
|
process.exit(1);
|
|
5107
4957
|
}
|
|
5108
4958
|
tm.revoke(dir);
|
|
5109
|
-
log12(
|
|
4959
|
+
log12(t36("trust.removed", { dir, level: levelLabel(tm.check(dir)) }));
|
|
5110
4960
|
});
|
|
5111
4961
|
});
|
|
5112
4962
|
}
|
|
5113
4963
|
function printList3(tm) {
|
|
5114
|
-
if (
|
|
5115
|
-
warn3(
|
|
4964
|
+
if (loadConfig6().trust?.enabled === false) {
|
|
4965
|
+
warn3(t36("trust.gate_off"));
|
|
5116
4966
|
}
|
|
5117
|
-
log12(
|
|
4967
|
+
log12(t36("trust.list_head", { path: trustPath2(EPOCH_HOME) }));
|
|
5118
4968
|
const records = [...tm.list()].sort((a, b) => a.path.localeCompare(b.path));
|
|
5119
4969
|
if (records.length === 0) {
|
|
5120
|
-
log12(
|
|
4970
|
+
log12(t36("trust.list_empty"));
|
|
5121
4971
|
}
|
|
5122
4972
|
for (const r of records) {
|
|
5123
4973
|
const mark = r.level === "trusted" ? "\u2713" : "\u2717";
|
|
5124
|
-
const when = r.decidedAt ? new Date(r.decidedAt).toLocaleString(uiDateLocale4()) :
|
|
5125
|
-
log12(` ${mark} ${r.path} [${scopeLabel(r.scope)}]
|
|
4974
|
+
const when = r.decidedAt ? new Date(r.decidedAt).toLocaleString(uiDateLocale4()) : t36("trust.when_unknown");
|
|
4975
|
+
log12(` ${mark} ${r.path} [${scopeLabel(r.scope)}] ${when}`);
|
|
5126
4976
|
}
|
|
5127
4977
|
const cwd = process.cwd();
|
|
5128
4978
|
log12(
|
|
5129
4979
|
`
|
|
5130
|
-
${
|
|
5131
|
-
${
|
|
4980
|
+
${t36("trust.cwd_line", { cwd })}
|
|
4981
|
+
${t36("trust.cwd_verdict", { level: levelLabel(tm.check(cwd)) })}`
|
|
5132
4982
|
);
|
|
5133
4983
|
}
|
|
5134
4984
|
function withTrust(fn) {
|
|
5135
|
-
const tm = new
|
|
4985
|
+
const tm = new TrustManager2(trustPath2(EPOCH_HOME));
|
|
5136
4986
|
for (const err2 of tm.loadErrors) warn3(`\u26A0 ${err2}`);
|
|
5137
4987
|
try {
|
|
5138
4988
|
fn(tm);
|
|
5139
4989
|
} catch (err2) {
|
|
5140
|
-
warn3(
|
|
4990
|
+
warn3(t36("trust.error", { message: err2 instanceof Error ? err2.message : String(err2) }));
|
|
5141
4991
|
process.exit(1);
|
|
5142
4992
|
}
|
|
5143
4993
|
}
|
|
5144
4994
|
// src/commands/upgrade.ts
|
|
5145
|
-
import { t as
|
|
4995
|
+
import { t as t37 } from "@epoch-agent/infra";
|
|
5146
4996
|
var log13 = (msg) => process.stdout.write(`${msg}
|
|
5147
4997
|
`);
|
|
5148
4998
|
function registerUpgradeCommand(program2) {
|
|
5149
|
-
program2.command("upgrade").description(
|
|
4999
|
+
program2.command("upgrade").description(t37("upgrade.cmd_root")).action(async () => {
|
|
5150
5000
|
const self = selfPackage();
|
|
5151
5001
|
const info = getInstallationInfo(self.name);
|
|
5152
|
-
log13(
|
|
5002
|
+
log13(t37("upgrade.current", { version: self.version }));
|
|
5153
5003
|
log13(
|
|
5154
|
-
|
|
5004
|
+
t37("upgrade.installed_via", {
|
|
5155
5005
|
manager: info.packageManager,
|
|
5156
|
-
global: info.isGlobal ?
|
|
5006
|
+
global: info.isGlobal ? t37("installation.global_suffix") : "",
|
|
5157
5007
|
note: info.note
|
|
5158
5008
|
})
|
|
5159
5009
|
);
|
|
5160
5010
|
const notice = isUpdateCheckDisabled() ? readUpdateNotice() : await refreshUpdateCache({ ttlMs: 0 }).catch(() => null);
|
|
5161
5011
|
if (notice) {
|
|
5162
5012
|
log13(`
|
|
5163
|
-
${
|
|
5013
|
+
${t37("upgrade.available", { current: notice.current, latest: notice.latest })}`);
|
|
5164
5014
|
} else log13(`
|
|
5165
|
-
${
|
|
5015
|
+
${t37("upgrade.none")}`);
|
|
5166
5016
|
if (info.updateCommand) {
|
|
5167
5017
|
log13(`
|
|
5168
|
-
${
|
|
5018
|
+
${t37("upgrade.how")}
|
|
5169
5019
|
${info.updateCommand}`);
|
|
5170
5020
|
log13(`
|
|
5171
|
-
${
|
|
5021
|
+
${t37("upgrade.why_manual")}`);
|
|
5172
5022
|
}
|
|
5173
5023
|
});
|
|
5174
|
-
program2.command(UPDATE_CHECK_SUBCOMMAND, { hidden: true }).description(
|
|
5024
|
+
program2.command(UPDATE_CHECK_SUBCOMMAND, { hidden: true }).description(t37("upgrade.cmd_refresh")).action(async () => {
|
|
5175
5025
|
await refreshUpdateCache().catch(() => null);
|
|
5176
5026
|
});
|
|
5177
5027
|
}
|
|
5178
5028
|
// src/commands/web.ts
|
|
5179
|
-
import { t as
|
|
5029
|
+
import { t as t38 } from "@epoch-agent/infra";
|
|
5180
5030
|
import { diagnosticToLine } from "@epoch-agent/protocol";
|
|
5181
5031
|
import { buildRuntime as buildRuntime3 } from "@epoch-agent/runtime";
|
|
5182
5032
|
import {
|
|
@@ -5224,7 +5074,7 @@ var err = (msg) => {
|
|
|
5224
5074
|
`);
|
|
5225
5075
|
};
|
|
5226
5076
|
function registerWebCommand(program2) {
|
|
5227
|
-
program2.command("web").description(
|
|
5077
|
+
program2.command("web").description(t38("cli.web.summary")).option("-p, --port <port>", t38("cli.web.opt_port", { port: DEFAULT_WEB_PORT })).option("--host <host>", t38("cli.web.opt_host", { host: DEFAULT_WEB_HOST })).option("--token <token>", t38("cli.web.opt_token")).option("--no-open", t38("cli.web.opt_no_open")).option("--json", t38("cli.web.opt_json")).action(async (opts, command) => {
|
|
5228
5078
|
await runWeb({ ...opts, json: jsonRequested(opts.json, command.parent?.opts()["json"]) });
|
|
5229
5079
|
});
|
|
5230
5080
|
}
|
|
@@ -5233,14 +5083,13 @@ function jsonRequested(own, fromProgram) {
|
|
|
5233
5083
|
}
|
|
5234
5084
|
async function runWeb(opts) {
|
|
5235
5085
|
const port = parsePort2(opts.port);
|
|
5236
|
-
if (port === null) return fail(
|
|
5086
|
+
if (port === null) return fail(t38("cli.web.err_port", { value: String(opts.port) }));
|
|
5237
5087
|
const binding = decideBinding({
|
|
5238
5088
|
...opts.host === void 0 ? {} : { host: opts.host },
|
|
5239
5089
|
...port === void 0 ? {} : { port },
|
|
5240
5090
|
...opts.token === void 0 ? {} : { token: opts.token }
|
|
5241
5091
|
});
|
|
5242
5092
|
if (!binding.ok) return fail(binding.error);
|
|
5243
|
-
if (!await maybePromptForTrust()) process.exit(1);
|
|
5244
5093
|
if (!await maybePromptForExternalImports()) process.exit(1);
|
|
5245
5094
|
const booted = await boot(binding);
|
|
5246
5095
|
if (!booted) return;
|
|
@@ -5262,8 +5111,8 @@ async function runWeb(opts) {
|
|
|
5262
5111
|
if (opts.open && !openInBrowser(server.url)) say(browserFailed());
|
|
5263
5112
|
installShutdown2(server, say);
|
|
5264
5113
|
}
|
|
5265
|
-
var missingWebRoot = () =>
|
|
5266
|
-
var browserFailed = () => ` ${
|
|
5114
|
+
var missingWebRoot = () => t38("cli.web.missing_root");
|
|
5115
|
+
var browserFailed = () => ` ${t38("cli.web.browser_failed")}`;
|
|
5267
5116
|
async function boot(binding) {
|
|
5268
5117
|
const build = () => buildRuntime3({
|
|
5269
5118
|
installSignalHandlers: false,
|
|
@@ -5291,17 +5140,17 @@ async function boot(binding) {
|
|
|
5291
5140
|
};
|
|
5292
5141
|
}
|
|
5293
5142
|
function noProviderLines(providerDiagnostics) {
|
|
5294
|
-
return [` ${
|
|
5143
|
+
return [` ${t38("cli.web.no_provider_warn")}`, ...providerDiagnostics.map((line2) => ` ${line2}`)];
|
|
5295
5144
|
}
|
|
5296
5145
|
function announceLines(input2) {
|
|
5297
5146
|
const human = [];
|
|
5298
5147
|
if (!input2.json) {
|
|
5299
5148
|
human.push(` Epoch Web http://${input2.host}:${input2.port}`);
|
|
5300
|
-
human.push(` ${
|
|
5149
|
+
human.push(` ${t38("cli.web.open_this")}
|
|
5301
5150
|
${input2.url}`);
|
|
5302
5151
|
}
|
|
5303
5152
|
if (input2.lanExposed) {
|
|
5304
|
-
human.push(` ${
|
|
5153
|
+
human.push(` ${t38("cli.web.lan_exposed")}`);
|
|
5305
5154
|
}
|
|
5306
5155
|
if (input2.placeholder) human.push(` \u26A0 ${missingWebRoot()}`);
|
|
5307
5156
|
if (!input2.json) return { human };
|
|
@@ -5319,7 +5168,7 @@ function installShutdown2(server, say) {
|
|
|
5319
5168
|
if (shuttingDown) process.exit(1);
|
|
5320
5169
|
shuttingDown = true;
|
|
5321
5170
|
say(`
|
|
5322
|
-
${
|
|
5171
|
+
${t38("cli.web.shutting_down")}`);
|
|
5323
5172
|
server.close().then(
|
|
5324
5173
|
() => process.exit(0),
|
|
5325
5174
|
() => process.exit(1)
|
|
@@ -5338,17 +5187,17 @@ function fail(message) {
|
|
|
5338
5187
|
process.exit(1);
|
|
5339
5188
|
}
|
|
5340
5189
|
// src/language.ts
|
|
5341
|
-
import { loadConfig as
|
|
5190
|
+
import { loadConfig as loadConfig7, setDisplayCurrency } from "@epoch-agent/core";
|
|
5342
5191
|
import { resolveLang, setLang } from "@epoch-agent/infra";
|
|
5343
5192
|
function applyConfiguredLanguage() {
|
|
5344
5193
|
try {
|
|
5345
|
-
setLang(resolveLang(
|
|
5194
|
+
setLang(resolveLang(loadConfig7().display?.language));
|
|
5346
5195
|
} catch {
|
|
5347
5196
|
}
|
|
5348
5197
|
}
|
|
5349
5198
|
function applyConfiguredCurrency() {
|
|
5350
5199
|
try {
|
|
5351
|
-
setDisplayCurrency(
|
|
5200
|
+
setDisplayCurrency(loadConfig7().display?.currency);
|
|
5352
5201
|
} catch {
|
|
5353
5202
|
}
|
|
5354
5203
|
}
|
|
@@ -5356,7 +5205,7 @@ function applyConfiguredCurrency() {
|
|
|
5356
5205
|
applyConfiguredLanguage();
|
|
5357
5206
|
applyConfiguredCurrency();
|
|
5358
5207
|
var program = new Command();
|
|
5359
|
-
program.name("epoch").description(
|
|
5208
|
+
program.name("epoch").description(t39("cli.program_description"));
|
|
5360
5209
|
registerConfigCommand(program);
|
|
5361
5210
|
registerMcpCommand(program);
|
|
5362
5211
|
registerModelCommand(program);
|