@epoch-agent/tui 2.8.0 → 3.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.
Files changed (2) hide show
  1. package/dist/index.js +29 -15
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -4021,8 +4021,6 @@ function permStyle(level) {
4021
4021
  switch (level) {
4022
4022
  case "auto":
4023
4023
  return { color: "#22C55E", label: "auto" };
4024
- case "bypass":
4025
- return { color: "#EF4444", label: "YOLO" };
4026
4024
  case "plan":
4027
4025
  return { color: "#22C55E", label: "plan" };
4028
4026
  case "default":
@@ -4647,9 +4645,9 @@ ${t("tui.rewind.screen_note")}`
4647
4645
  import { useCallback as useCallback12, useMemo as useMemo11 } from "react";
4648
4646
  // src/commands/builtin.ts
4649
4647
  import {
4650
- isPermissionLevel,
4651
4648
  parseModelRef,
4652
- PERMISSION_LEVELS
4649
+ PERMISSION_LEVELS,
4650
+ resolvePermissionLevel as resolvePermissionLevel2
4653
4651
  } from "@epoch-agent/protocol";
4654
4652
  // src/commands/goal.ts
4655
4653
  var NULLARY = ["pause", "resume", "clear"];
@@ -4700,6 +4698,7 @@ var goal = {
4700
4698
  };
4701
4699
  var GOAL_COMMANDS = [goal];
4702
4700
  // src/commands/inspect.ts
4701
+ import { approvalPolicyForLevel, resolvePermissionLevel } from "@epoch-agent/protocol";
4703
4702
  function unavailable(ctx, what) {
4704
4703
  ctx.push({ type: "warning", text: t("tui.common.unavailable", { what }) });
4705
4704
  }
@@ -4897,13 +4896,17 @@ function approvalLines(rows) {
4897
4896
  (r) => ` ${padEndByWidth(decisionLabel(r.decision), dw)}${padEndByWidth(r.toolName, tw)}${padEndByWidth(scopeLabel(r.scope), sw)}${atTime(r.createdAt)} ${oneLine2(r.target)}`
4898
4897
  );
4899
4898
  }
4899
+ function neverAsks(level) {
4900
+ const parsed = resolvePermissionLevel(level);
4901
+ return parsed !== void 0 && approvalPolicyForLevel(parsed) === "never";
4902
+ }
4900
4903
  function cacheSection(rows, level, canRevoke) {
4901
4904
  if (rows.length === 0) return ["", t("tui.permissions.cache_none")];
4902
4905
  return [
4903
4906
  "",
4904
4907
  t("tui.permissions.cache_head", { n: rows.length }),
4905
4908
  t("tui.permissions.cache_not_rules"),
4906
- ...level === "bypass" ? [t("tui.permissions.cache_bypass")] : [],
4909
+ ...neverAsks(level) ? [t("tui.permissions.cache_bypass")] : [],
4907
4910
  "",
4908
4911
  ...approvalLines(rows),
4909
4912
  "",
@@ -5383,8 +5386,6 @@ function levelDesc(level) {
5383
5386
  return t("tui.perm.desc_plan");
5384
5387
  case "auto":
5385
5388
  return t("tui.perm.desc_auto");
5386
- case "bypass":
5387
- return t("tui.perm.desc_bypass");
5388
5389
  }
5389
5390
  }
5390
5391
  function unavailable5(ctx, what) {
@@ -5452,7 +5453,8 @@ var permission = {
5452
5453
  },
5453
5454
  run: (ctx) => {
5454
5455
  const apply = (raw) => {
5455
- if (!isPermissionLevel(raw)) {
5456
+ const level = resolvePermissionLevel2(raw);
5457
+ if (!level) {
5456
5458
  ctx.push({
5457
5459
  type: "error",
5458
5460
  text: t("tui.perm.unknown", { raw, levels: PERMISSION_LEVELS.join(" / ") })
@@ -5460,10 +5462,10 @@ var permission = {
5460
5462
  return;
5461
5463
  }
5462
5464
  if (!ctx.host.setPermissionLevel) return unavailable5(ctx, t("tui.perm.what"));
5463
- const result = ctx.host.setPermissionLevel(raw);
5465
+ const result = ctx.host.setPermissionLevel(level);
5464
5466
  ctx.push(
5465
- result.ok ? { type: "info", text: t("tui.perm.switched", { raw, desc: levelDesc(raw) }) } : (
5466
- { type: "error", text: result.reason ?? t("tui.perm.switch_failed", { raw }) }
5467
+ result.ok ? { type: "info", text: t("tui.perm.switched", { raw: level, desc: levelDesc(level) }) } : (
5468
+ { type: "error", text: result.reason ?? t("tui.perm.switch_failed", { raw: level }) }
5467
5469
  )
5468
5470
  );
5469
5471
  };
@@ -5478,7 +5480,7 @@ var permission = {
5478
5480
  label: l,
5479
5481
  value: l,
5480
5482
  description: levelDesc(l),
5481
- danger: l === "bypass"
5483
+ danger: false
5482
5484
  })),
5483
5485
  onPick: apply
5484
5486
  });
@@ -5740,7 +5742,19 @@ var context = {
5740
5742
  ` ${padEndByWidth(t("tui.context.remaining"), width)}${kTokens2(b.remaining).padStart(7)}`
5741
5743
  ] : [];
5742
5744
  const hints = b.hints.length > 0 ? ["", ...b.hints.map((h) => ` \u26A0 ${h}`)] : [];
5743
- ctx.push({ type: "info", text: [head, "", ...lines2, ...tail, ...hints].join("\n") });
5745
+ const cacheLine = b.cache ? [
5746
+ "",
5747
+ ` ${t("tui.context.cache", {
5748
+ hit: kTokens2(b.cache.hit),
5749
+ prompt: kTokens2(b.cache.prompt),
5750
+ pct: b.cache.hitPercent,
5751
+ write: kTokens2(b.cache.write)
5752
+ })}`
5753
+ ] : [];
5754
+ ctx.push({
5755
+ type: "info",
5756
+ text: [head, "", ...lines2, ...tail, ...cacheLine, ...hints].join("\n")
5757
+ });
5744
5758
  }
5745
5759
  };
5746
5760
  var thinking = {
@@ -6469,7 +6483,7 @@ import { collapseContext as collapseContext2, diffLines as diffLines2, DIFF_CONT
6469
6483
  // src/render.tsx
6470
6484
  import { render } from "ink";
6471
6485
  import {
6472
- isPermissionLevel as isPermissionLevel2
6486
+ isPermissionLevel
6473
6487
  } from "@epoch-agent/protocol";
6474
6488
  import { jsx as jsx31 } from "react/jsx-runtime";
6475
6489
  function renderApp({
@@ -6483,7 +6497,7 @@ function renderApp({
6483
6497
  }) {
6484
6498
  setTranslator(translate2);
6485
6499
  setDisplayCurrency(currency2);
6486
- const initialPermissionLevel = isPermissionLevel2(config.permissionLevel) ? config.permissionLevel : "default";
6500
+ const initialPermissionLevel = isPermissionLevel(config.permissionLevel) ? config.permissionLevel : "default";
6487
6501
  const tree = /* @__PURE__ */ jsx31(AppContext.Provider, { value: app, children: /* @__PURE__ */ jsx31(ConfigContext.Provider, { value: config, children: /* @__PURE__ */ jsx31(SessionStatsProvider, { sessionId, usageScope, children: /* @__PURE__ */ jsx31(
6488
6502
  UIStateProvider,
6489
6503
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epoch-agent/tui",
3
- "version": "2.8.0",
3
+ "version": "3.0.0",
4
4
  "private": false,
5
5
  "description": "epoch-agent Ink TUI 界面",
6
6
  "repository": {
@@ -29,8 +29,8 @@
29
29
  "mnemonist": "0",
30
30
  "string-width": "8",
31
31
  "strip-ansi": "7",
32
- "@epoch-agent/protocol": "2.8.0",
33
- "@epoch-agent/view": "2.8.0"
32
+ "@epoch-agent/view": "3.0.0",
33
+ "@epoch-agent/protocol": "3.0.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^26.1.2",