@unikode/cli 1.0.20 → 1.0.21
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.js +51 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3078,9 +3078,11 @@ function SessionShell({
|
|
|
3078
3078
|
onSubmit,
|
|
3079
3079
|
inputDisabled = false,
|
|
3080
3080
|
loading = false,
|
|
3081
|
-
interruptible = false
|
|
3081
|
+
interruptible = false,
|
|
3082
|
+
tokenCount
|
|
3082
3083
|
}) {
|
|
3083
3084
|
const { mode } = usePromptConfig();
|
|
3085
|
+
const { colors } = useTheme();
|
|
3084
3086
|
return /* @__PURE__ */ jsxDEV21("box", {
|
|
3085
3087
|
flexDirection: "column",
|
|
3086
3088
|
flexGrow: 1,
|
|
@@ -3099,6 +3101,37 @@ function SessionShell({
|
|
|
3099
3101
|
children
|
|
3100
3102
|
}, undefined, false, undefined, this)
|
|
3101
3103
|
}, undefined, false, undefined, this),
|
|
3104
|
+
tokenCount !== undefined && /* @__PURE__ */ jsxDEV21("box", {
|
|
3105
|
+
flexShrink: 0,
|
|
3106
|
+
flexDirection: "row",
|
|
3107
|
+
justifyContent: "flex-end",
|
|
3108
|
+
alignItems: "center",
|
|
3109
|
+
width: "100%",
|
|
3110
|
+
paddingX: 1,
|
|
3111
|
+
children: /* @__PURE__ */ jsxDEV21("box", {
|
|
3112
|
+
flexDirection: "row",
|
|
3113
|
+
alignItems: "center",
|
|
3114
|
+
gap: 1,
|
|
3115
|
+
paddingX: 1,
|
|
3116
|
+
backgroundColor: colors.surface,
|
|
3117
|
+
children: [
|
|
3118
|
+
/* @__PURE__ */ jsxDEV21("text", {
|
|
3119
|
+
fg: mode === Mode.PLAN ? colors.planMode : colors.primary,
|
|
3120
|
+
children: "\u26A1"
|
|
3121
|
+
}, undefined, false, undefined, this),
|
|
3122
|
+
/* @__PURE__ */ jsxDEV21("text", {
|
|
3123
|
+
attributes: TextAttributes8.DIM,
|
|
3124
|
+
fg: colors.info,
|
|
3125
|
+
children: "Tokens:"
|
|
3126
|
+
}, undefined, false, undefined, this),
|
|
3127
|
+
/* @__PURE__ */ jsxDEV21("text", {
|
|
3128
|
+
fg: mode === Mode.PLAN ? colors.planMode : colors.primary,
|
|
3129
|
+
attributes: TextAttributes8.BOLD,
|
|
3130
|
+
children: tokenCount.toLocaleString()
|
|
3131
|
+
}, undefined, false, undefined, this)
|
|
3132
|
+
]
|
|
3133
|
+
}, undefined, true, undefined, this)
|
|
3134
|
+
}, undefined, false, undefined, this),
|
|
3102
3135
|
/* @__PURE__ */ jsxDEV21("box", {
|
|
3103
3136
|
flexShrink: 0,
|
|
3104
3137
|
children: /* @__PURE__ */ jsxDEV21(InputBar, {
|
|
@@ -4406,7 +4439,24 @@ function SessionChat({ session, initialPrompt }) {
|
|
|
4406
4439
|
model: initialPrompt.model
|
|
4407
4440
|
});
|
|
4408
4441
|
}, [initialPrompt, submit]);
|
|
4442
|
+
const totalTokenCount = useMemo6(() => {
|
|
4443
|
+
let initialUsageSum = 0;
|
|
4444
|
+
let currentUsageSum = 0;
|
|
4445
|
+
for (let i = 0;i < messages.length; i++) {
|
|
4446
|
+
const msg = messages[i];
|
|
4447
|
+
const metadata = msg?.metadata;
|
|
4448
|
+
const tokens = metadata?.usage?.totalTokens ?? 0;
|
|
4449
|
+
currentUsageSum += tokens;
|
|
4450
|
+
if (i < initialMessages.length) {
|
|
4451
|
+
initialUsageSum += tokens;
|
|
4452
|
+
}
|
|
4453
|
+
}
|
|
4454
|
+
const baseTokens = Math.max(session.tokenCount ?? 0, initialUsageSum);
|
|
4455
|
+
const newTokens = currentUsageSum - initialUsageSum;
|
|
4456
|
+
return baseTokens + newTokens;
|
|
4457
|
+
}, [messages, initialMessages.length, session.tokenCount]);
|
|
4409
4458
|
return /* @__PURE__ */ jsxDEV28(SessionShell, {
|
|
4459
|
+
tokenCount: totalTokenCount,
|
|
4410
4460
|
onSubmit: (text) => {
|
|
4411
4461
|
deactivateQuestionPrompts();
|
|
4412
4462
|
submit({ userText: text, mode, model });
|