@epoch-agent/cli 0.3.1 → 0.3.2

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.
Files changed (2) hide show
  1. package/dist/index.js +16 -4
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -2957,7 +2957,7 @@ async function runOnce(query, opts, resumeId) {
2957
2957
  sessionId: () => rt?.sessionId,
2958
2958
  preauth: (req) => preauthorizedBy(rt?.config.headless, headless, req)
2959
2959
  }) : createInteractiveApproval({ permission: () => rt?.permission }),
2960
- installSignalHandlers: true,
2960
+ installSignalHandlers: false,
2961
2961
  ...approver ? { interactive: true } : {},
2962
2962
  ...headless ? { headless } : {},
2963
2963
  ...resumeId ? { resumeId } : {}
@@ -2973,6 +2973,7 @@ async function runOnce(query, opts, resumeId) {
2973
2973
  ${detail}` : t22("run_once.err_no_provider_hint")
2974
2974
  );
2975
2975
  }
2976
+ installShutdown(runtime);
2976
2977
  try {
2977
2978
  if (format !== "json") reportDiagnostics(runtime.diagnostics, opts.verbose === true);
2978
2979
  if (resumeId) {
@@ -2996,12 +2997,23 @@ async function runOnce(query, opts, resumeId) {
2996
2997
  }
2997
2998
  const limited = limitExitCode(outcome, limits);
2998
2999
  if (limited !== void 0 && !process.exitCode) process.exitCode = limited;
2999
- if (outcome.aborted && !process.exitCode) process.exitCode = 130;
3000
+ if (outcome.aborted && !process.exitCode) process.exitCode = INTERRUPTED_EXIT_CODE;
3000
3001
  } finally {
3001
3002
  reportHeadlessAudit(runtime.permission);
3002
3003
  await runtime.dispose();
3003
3004
  }
3004
3005
  }
3006
+ var INTERRUPTED_EXIT_CODE = 130;
3007
+ function installShutdown(runtime) {
3008
+ let shuttingDown = false;
3009
+ const onSignal = (code) => () => {
3010
+ if (shuttingDown) process.exit(EXIT_CODES.FAILURE);
3011
+ shuttingDown = true;
3012
+ void runtime.dispose().finally(() => process.exit(code));
3013
+ };
3014
+ process.on("SIGINT", onSignal(INTERRUPTED_EXIT_CODE));
3015
+ process.on("SIGTERM", onSignal(EXIT_CODES.SUCCESS));
3016
+ }
3005
3017
  async function consume(runtime, query, opts, format, limits, emitter) {
3006
3018
  const out2 = emptyOutcome(runtime.diagnostics);
3007
3019
  const streaming = opts.stream !== false && format === "text";
@@ -4744,7 +4756,7 @@ async function runWeb(opts) {
4744
4756
  if (lines.machine) out(lines.machine);
4745
4757
  for (const line of lines.human) say(line);
4746
4758
  if (opts.open && !openInBrowser(server.url)) say(browserFailed());
4747
- installShutdown(server, say);
4759
+ installShutdown2(server, say);
4748
4760
  }
4749
4761
  var missingWebRoot = () => t38("cli.web.missing_root");
4750
4762
  var browserFailed = () => ` ${t38("cli.web.browser_failed")}`;
@@ -4797,7 +4809,7 @@ function announceLines(input2) {
4797
4809
  });
4798
4810
  return { machine, human };
4799
4811
  }
4800
- function installShutdown(server, say) {
4812
+ function installShutdown2(server, say) {
4801
4813
  let shuttingDown = false;
4802
4814
  const onSignal = () => {
4803
4815
  if (shuttingDown) process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epoch-agent/cli",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "private": false,
5
5
  "description": "epoch-agent CLI 入口",
6
6
  "repository": {
@@ -22,12 +22,12 @@
22
22
  "commander": "^15.0.0",
23
23
  "ink": "^7.1.1",
24
24
  "react": "^19.2.8",
25
- "@epoch-agent/infra": "0.3.1",
26
- "@epoch-agent/protocol": "0.3.1",
27
- "@epoch-agent/server": "0.3.1",
28
- "@epoch-agent/tui": "^0.3.1",
29
- "@epoch-agent/core": "0.3.1",
30
- "@epoch-agent/runtime": "0.3.1"
25
+ "@epoch-agent/runtime": "0.3.2",
26
+ "@epoch-agent/infra": "0.3.2",
27
+ "@epoch-agent/core": "0.3.2",
28
+ "@epoch-agent/protocol": "0.3.2",
29
+ "@epoch-agent/server": "0.3.2",
30
+ "@epoch-agent/tui": "^0.3.2"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^22.20.1",