@epoch-agent/tui 0.9.0 → 0.10.1
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 +18 -8
- 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
|
@@ -3996,6 +3996,15 @@ var useUIState = () => {
|
|
|
3996
3996
|
if (!ctx) throw new Error("useUIState must be used within UIStateProvider");
|
|
3997
3997
|
return ctx;
|
|
3998
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
|
+
}
|
|
3999
4008
|
// src/components/status-bar.tsx
|
|
4000
4009
|
import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4001
4010
|
var dim10 = "#6B7280";
|
|
@@ -4055,12 +4064,9 @@ function StatusBar({
|
|
|
4055
4064
|
] }),
|
|
4056
4065
|
cost2 !== void 0 && /* @__PURE__ */ jsxs22(Fragment4, { children: [
|
|
4057
4066
|
/* @__PURE__ */ jsx26(Dot, {}),
|
|
4058
|
-
/* @__PURE__ */
|
|
4059
|
-
"$",
|
|
4060
|
-
cost2.toFixed(4)
|
|
4061
|
-
] })
|
|
4067
|
+
/* @__PURE__ */ jsx26(Text24, { color: dim10, children: money(cost2, 4) })
|
|
4062
4068
|
] }),
|
|
4063
|
-
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) }) })
|
|
4064
4070
|
] }),
|
|
4065
4071
|
/* @__PURE__ */ jsxs22(Box23, { flexDirection: "row", children: [
|
|
4066
4072
|
statusLine ? /* @__PURE__ */ jsxs22(Fragment4, { children: [
|
|
@@ -5116,7 +5122,7 @@ function kTokens(n) {
|
|
|
5116
5122
|
return n >= 1e3 ? `${(n / 1e3).toFixed(1)}k` : String(n);
|
|
5117
5123
|
}
|
|
5118
5124
|
function usd(n) {
|
|
5119
|
-
return
|
|
5125
|
+
return money(n, 4);
|
|
5120
5126
|
}
|
|
5121
5127
|
var cost = {
|
|
5122
5128
|
name: "cost",
|
|
@@ -5588,7 +5594,7 @@ var status = {
|
|
|
5588
5594
|
},
|
|
5589
5595
|
run: (ctx) => {
|
|
5590
5596
|
const { info } = ctx;
|
|
5591
|
-
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);
|
|
5592
5598
|
ctx.push({
|
|
5593
5599
|
type: "info",
|
|
5594
5600
|
text: [
|
|
@@ -6448,7 +6454,9 @@ function App({
|
|
|
6448
6454
|
import { collapseContext as collapseContext2, diffLines as diffLines2, DIFF_CONTEXT_LINES, DIFF_MAX_LINES as DIFF_MAX_LINES2 } from "@epoch-agent/view";
|
|
6449
6455
|
// src/render.tsx
|
|
6450
6456
|
import { render } from "ink";
|
|
6451
|
-
import {
|
|
6457
|
+
import {
|
|
6458
|
+
isPermissionLevel as isPermissionLevel2
|
|
6459
|
+
} from "@epoch-agent/protocol";
|
|
6452
6460
|
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
6453
6461
|
function renderApp({
|
|
6454
6462
|
sessionId,
|
|
@@ -6456,9 +6464,11 @@ function renderApp({
|
|
|
6456
6464
|
config,
|
|
6457
6465
|
usageScope,
|
|
6458
6466
|
translate: translate2,
|
|
6467
|
+
currency: currency2,
|
|
6459
6468
|
...appProps
|
|
6460
6469
|
}) {
|
|
6461
6470
|
setTranslator(translate2);
|
|
6471
|
+
setDisplayCurrency(currency2);
|
|
6462
6472
|
const initialPermissionLevel = isPermissionLevel2(config.permissionLevel) ? config.permissionLevel : "default";
|
|
6463
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(
|
|
6464
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.1",
|
|
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.1",
|
|
33
|
+
"@epoch-agent/view": "0.10.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^26.1.2",
|