@epoch-agent/tui 0.8.1 → 0.10.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/dist/index.d.ts +12 -2
- package/dist/index.js +34 -21
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import { ModelRef, PermissionLevel, SelectionContext, SetSelectionResult, ModelSelection, ExpandedCommand, MentionSet, EpochFilePart, EpochSessionPart, BackgroundTaskInfo, ApprovalRequest, ApprovalOutcome, ContextBreakdown, CustomCommandSource, EpochUserContent, AgentEvent, CustomCommandDef, KeybindingTable, ToolArtifact, TokenUsage, Translate, TranslateVars, KeyChord, KeyContext, KeyAction } from '@epoch-agent/protocol';
|
|
3
|
+
import { ModelRef, PermissionLevel, SelectionContext, SetSelectionResult, ModelSelection, ExpandedCommand, MentionSet, EpochFilePart, EpochSessionPart, BackgroundTaskInfo, ApprovalRequest, ApprovalOutcome, ContextBreakdown, CustomCommandSource, EpochUserContent, AgentEvent, CustomCommandDef, KeybindingTable, ToolArtifact, TokenUsage, Translate, CurrencyDisplay, TranslateVars, KeyChord, KeyContext, KeyAction } from '@epoch-agent/protocol';
|
|
4
4
|
import { HistoryItemWithoutId } from '@epoch-agent/view';
|
|
5
5
|
export { DIFF_CONTEXT_LINES, DIFF_MAX_LINES, DiffLine, DiffResult, HistoryItem, HistoryItemWithoutId, StreamReduceResult, applyStreamEvent, collapseContext, diffLines } from '@epoch-agent/view';
|
|
6
6
|
import { Instance, Key } from 'ink';
|
|
@@ -1263,8 +1263,18 @@ interface RenderAppOptions extends AppProps {
|
|
|
1263
1263
|
* 而那是运行时才看得见的事。必填让它在编译期就红 —— 同 `HostActions` 那条判据。
|
|
1264
1264
|
*/
|
|
1265
1265
|
translate: Translate;
|
|
1266
|
+
/**
|
|
1267
|
+
* 屏幕上那些金额印成什么币种,来自 `config.yaml` 的 `display.currency`。
|
|
1268
|
+
* **缺省 = 美元**(绝大多数用户),所以它和 `translate` 不同,是**可选**的。
|
|
1269
|
+
*
|
|
1270
|
+
* ⚠️ 可选意味着「宿主忘了递」编译期兜不住,而失败形态是**静默**的
|
|
1271
|
+
* (TUI 印美元、web 印人民币,两处对不上还都不报错)。兜住它的是
|
|
1272
|
+
* `__tests__/money-currency.test.ts` 那条读源码的门禁 —— 判据全文在
|
|
1273
|
+
* [money.ts](./money.js) 的文件头。
|
|
1274
|
+
*/
|
|
1275
|
+
currency?: CurrencyDisplay;
|
|
1266
1276
|
}
|
|
1267
|
-
declare function renderApp({ sessionId, app, config, usageScope, translate, ...appProps }: RenderAppOptions): Instance;
|
|
1277
|
+
declare function renderApp({ sessionId, app, config, usageScope, translate, currency, ...appProps }: RenderAppOptions): Instance;
|
|
1268
1278
|
|
|
1269
1279
|
/**
|
|
1270
1280
|
* tui 那份 `t()` —— **只有接线,没有实现**(方案 40 PR-2)。
|
package/dist/index.js
CHANGED
|
@@ -1143,20 +1143,22 @@ function typeLabel(type) {
|
|
|
1143
1143
|
return void 0;
|
|
1144
1144
|
}
|
|
1145
1145
|
}
|
|
1146
|
-
function options() {
|
|
1146
|
+
function options(rememberable) {
|
|
1147
1147
|
return [
|
|
1148
1148
|
{ label: t("tui.approval.allow_once"), value: "allow-once" },
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1149
|
+
...rememberable ? [
|
|
1150
|
+
{
|
|
1151
|
+
label: t("tui.approval.allow_session"),
|
|
1152
|
+
value: "allow-session",
|
|
1153
|
+
description: t("tui.approval.allow_session_desc")
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
label: t("tui.approval.allow_always"),
|
|
1157
|
+
value: "allow-always",
|
|
1158
|
+
description: t("tui.approval.allow_always_desc"),
|
|
1159
|
+
danger: true
|
|
1160
|
+
}
|
|
1161
|
+
] : [],
|
|
1160
1162
|
{ label: t("tui.approval.deny"), value: "deny", description: "Esc", danger: true }
|
|
1161
1163
|
];
|
|
1162
1164
|
}
|
|
@@ -1208,10 +1210,11 @@ function ToolConfirmation({
|
|
|
1208
1210
|
/* @__PURE__ */ jsx9(Text8, { color: WARN, children: request.reason })
|
|
1209
1211
|
] })
|
|
1210
1212
|
] }),
|
|
1213
|
+
request.rememberable === false && /* @__PURE__ */ jsx9(Text8, { color: dim7, dimColor: true, wrap: "wrap", children: t("tui.approval.not_rememberable") }),
|
|
1211
1214
|
/* @__PURE__ */ jsx9(Box8, { marginTop: 1, children: /* @__PURE__ */ jsx9(
|
|
1212
1215
|
SelectList,
|
|
1213
1216
|
{
|
|
1214
|
-
options: options(),
|
|
1217
|
+
options: options(request.rememberable !== false),
|
|
1215
1218
|
onSelect: onRespond,
|
|
1216
1219
|
onCancel: () => onRespond("deny"),
|
|
1217
1220
|
isActive
|
|
@@ -3993,6 +3996,15 @@ var useUIState = () => {
|
|
|
3993
3996
|
if (!ctx) throw new Error("useUIState must be used within UIStateProvider");
|
|
3994
3997
|
return ctx;
|
|
3995
3998
|
};
|
|
3999
|
+
// src/money.ts
|
|
4000
|
+
import { formatMoney } from "@epoch-agent/protocol";
|
|
4001
|
+
var currency;
|
|
4002
|
+
function setDisplayCurrency(next) {
|
|
4003
|
+
currency = next;
|
|
4004
|
+
}
|
|
4005
|
+
function money(usd2, digits) {
|
|
4006
|
+
return formatMoney(usd2, { currency, digits });
|
|
4007
|
+
}
|
|
3996
4008
|
// src/components/status-bar.tsx
|
|
3997
4009
|
import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3998
4010
|
var dim10 = "#6B7280";
|
|
@@ -4052,12 +4064,9 @@ function StatusBar({
|
|
|
4052
4064
|
] }),
|
|
4053
4065
|
cost2 !== void 0 && /* @__PURE__ */ jsxs22(Fragment4, { children: [
|
|
4054
4066
|
/* @__PURE__ */ jsx26(Dot, {}),
|
|
4055
|
-
/* @__PURE__ */
|
|
4056
|
-
"$",
|
|
4057
|
-
cost2.toFixed(4)
|
|
4058
|
-
] })
|
|
4067
|
+
/* @__PURE__ */ jsx26(Text24, { color: dim10, children: money(cost2, 4) })
|
|
4059
4068
|
] }),
|
|
4060
|
-
budgetLeft !== void 0 && /* @__PURE__ */ jsx26(Text24, { color: budgetLeft > 0 ? dim10 : "#EF4444", children: t("tui.status.budget_left", { n: budgetLeft
|
|
4069
|
+
budgetLeft !== void 0 && /* @__PURE__ */ jsx26(Text24, { color: budgetLeft > 0 ? dim10 : "#EF4444", children: t("tui.status.budget_left", { n: money(budgetLeft, 2) }) })
|
|
4061
4070
|
] }),
|
|
4062
4071
|
/* @__PURE__ */ jsxs22(Box23, { flexDirection: "row", children: [
|
|
4063
4072
|
statusLine ? /* @__PURE__ */ jsxs22(Fragment4, { children: [
|
|
@@ -5113,7 +5122,7 @@ function kTokens(n) {
|
|
|
5113
5122
|
return n >= 1e3 ? `${(n / 1e3).toFixed(1)}k` : String(n);
|
|
5114
5123
|
}
|
|
5115
5124
|
function usd(n) {
|
|
5116
|
-
return
|
|
5125
|
+
return money(n, 4);
|
|
5117
5126
|
}
|
|
5118
5127
|
var cost = {
|
|
5119
5128
|
name: "cost",
|
|
@@ -5585,7 +5594,7 @@ var status = {
|
|
|
5585
5594
|
},
|
|
5586
5595
|
run: (ctx) => {
|
|
5587
5596
|
const { info } = ctx;
|
|
5588
|
-
const cost2 = info.costUsd === void 0 ? t("tui.status.cost_unknown") :
|
|
5597
|
+
const cost2 = info.costUsd === void 0 ? t("tui.status.cost_unknown") : money(info.costUsd, 4);
|
|
5589
5598
|
ctx.push({
|
|
5590
5599
|
type: "info",
|
|
5591
5600
|
text: [
|
|
@@ -6445,7 +6454,9 @@ function App({
|
|
|
6445
6454
|
import { collapseContext as collapseContext2, diffLines as diffLines2, DIFF_CONTEXT_LINES, DIFF_MAX_LINES as DIFF_MAX_LINES2 } from "@epoch-agent/view";
|
|
6446
6455
|
// src/render.tsx
|
|
6447
6456
|
import { render } from "ink";
|
|
6448
|
-
import {
|
|
6457
|
+
import {
|
|
6458
|
+
isPermissionLevel as isPermissionLevel2
|
|
6459
|
+
} from "@epoch-agent/protocol";
|
|
6449
6460
|
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
6450
6461
|
function renderApp({
|
|
6451
6462
|
sessionId,
|
|
@@ -6453,9 +6464,11 @@ function renderApp({
|
|
|
6453
6464
|
config,
|
|
6454
6465
|
usageScope,
|
|
6455
6466
|
translate: translate2,
|
|
6467
|
+
currency: currency2,
|
|
6456
6468
|
...appProps
|
|
6457
6469
|
}) {
|
|
6458
6470
|
setTranslator(translate2);
|
|
6471
|
+
setDisplayCurrency(currency2);
|
|
6459
6472
|
const initialPermissionLevel = isPermissionLevel2(config.permissionLevel) ? config.permissionLevel : "default";
|
|
6460
6473
|
const tree = /* @__PURE__ */ jsx31(AppContext.Provider, { value: app, children: /* @__PURE__ */ jsx31(ConfigContext.Provider, { value: config, children: /* @__PURE__ */ jsx31(SessionStatsProvider, { sessionId, usageScope, children: /* @__PURE__ */ jsx31(
|
|
6461
6474
|
UIStateProvider,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epoch-agent/tui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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": "0.
|
|
33
|
-
"@epoch-agent/view": "0.
|
|
32
|
+
"@epoch-agent/protocol": "0.10.0",
|
|
33
|
+
"@epoch-agent/view": "0.10.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^26.1.2",
|