@dexto/tui 1.6.22 → 1.6.25
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/agent-backend.d.ts +1 -1
- package/dist/agent-backend.d.ts.map +1 -1
- package/dist/components/overlays/InsufficientCreditsOverlay.cjs +264 -0
- package/dist/components/overlays/InsufficientCreditsOverlay.d.ts +14 -0
- package/dist/components/overlays/InsufficientCreditsOverlay.d.ts.map +1 -0
- package/dist/components/overlays/InsufficientCreditsOverlay.js +252 -0
- package/dist/components/overlays/custom-model-wizard/provider-config.cjs +1 -1
- package/dist/components/overlays/custom-model-wizard/provider-config.js +1 -1
- package/dist/containers/OverlayContainer.cjs +75 -22
- package/dist/containers/OverlayContainer.d.ts.map +1 -1
- package/dist/containers/OverlayContainer.js +75 -22
- package/dist/hooks/useAgentEvents.cjs +5 -2
- package/dist/hooks/useAgentEvents.d.ts.map +1 -1
- package/dist/hooks/useAgentEvents.js +5 -2
- package/dist/hooks/useCLIState.cjs +1 -0
- package/dist/hooks/useCLIState.d.ts.map +1 -1
- package/dist/hooks/useCLIState.js +1 -0
- package/dist/host/index.cjs +16 -0
- package/dist/host/index.d.ts +12 -0
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +14 -0
- package/dist/index.d.cts +7 -1
- package/dist/services/processStream.cjs +74 -14
- package/dist/services/processStream.d.ts.map +1 -1
- package/dist/services/processStream.js +75 -15
- package/dist/services/processStream.test.cjs +94 -0
- package/dist/services/processStream.test.js +95 -1
- package/dist/state/initialState.cjs +1 -0
- package/dist/state/initialState.d.ts.map +1 -1
- package/dist/state/initialState.js +1 -0
- package/dist/state/types.d.ts +5 -1
- package/dist/state/types.d.ts.map +1 -1
- package/dist/utils/dexto-auth-refresh.cjs +55 -0
- package/dist/utils/dexto-auth-refresh.d.ts +3 -0
- package/dist/utils/dexto-auth-refresh.d.ts.map +1 -0
- package/dist/utils/dexto-auth-refresh.js +31 -0
- package/dist/utils/dexto-auth-refresh.test.cjs +122 -0
- package/dist/utils/dexto-auth-refresh.test.d.ts +2 -0
- package/dist/utils/dexto-auth-refresh.test.d.ts.map +1 -0
- package/dist/utils/dexto-auth-refresh.test.js +121 -0
- package/package.json +4 -4
package/dist/agent-backend.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export interface TuiEffectiveConfig {
|
|
|
33
33
|
prompts?: unknown[] | undefined;
|
|
34
34
|
[key: string]: unknown;
|
|
35
35
|
}
|
|
36
|
-
export interface TuiAgentBackend extends Pick<DextoAgent, 'stream' | 'stop' | 'run' | 'listSessions' | 'getSessionMetadata' | 'getSessionHistory' | 'getSessionTitle' | 'setSessionTitle' | 'generateSessionTitle' | 'forkSession' | 'getCurrentLLMConfig' | 'switchLLM' | 'getSupportedProviders' | 'getSupportedModels' | 'getContextStats' | 'clearContext' | 'compactContext' | 'queueMessage' | 'getQueuedMessages' | 'removeQueuedMessage' | 'clearMessageQueue' | 'cancel' | 'searchMessages' | 'listPrompts' | 'refreshPrompts' | 'resolvePrompt' | 'getSystemPrompt' | 'loadToolkits' | 'listResources' | 'setLogLevel' | 'getAllTools' | 'getEnabledTools' | 'getAllMcpTools' | 'setGlobalDisabledTools' | 'setSessionDisabledTools' | 'setSessionAutoApproveTools' | 'getSessionAutoApproveTools' | 'getMcpServersWithStatus' | 'addMcpServer' | 'enableMcpServer' | 'disableMcpServer' | 'removeMcpServer' | 'restartMcpServer' | 'getMcpClients' | 'getMcpFailedConnections'> {
|
|
36
|
+
export interface TuiAgentBackend extends Pick<DextoAgent, 'stream' | 'stop' | 'run' | 'listSessions' | 'getSessionMetadata' | 'getSessionHistory' | 'getSessionTitle' | 'setSessionTitle' | 'generateSessionTitle' | 'forkSession' | 'getCurrentLLMConfig' | 'hasSessionLLMOverride' | 'switchLLM' | 'getSupportedProviders' | 'getSupportedModels' | 'getContextStats' | 'clearContext' | 'compactContext' | 'queueMessage' | 'getQueuedMessages' | 'removeQueuedMessage' | 'clearMessageQueue' | 'cancel' | 'searchMessages' | 'listPrompts' | 'refreshPrompts' | 'resolvePrompt' | 'getSystemPrompt' | 'loadToolkits' | 'listResources' | 'setLogLevel' | 'getAllTools' | 'getEnabledTools' | 'getAllMcpTools' | 'setGlobalDisabledTools' | 'setSessionDisabledTools' | 'setSessionAutoApproveTools' | 'getSessionAutoApproveTools' | 'getMcpServersWithStatus' | 'addMcpServer' | 'enableMcpServer' | 'disableMcpServer' | 'removeMcpServer' | 'restartMcpServer' | 'getMcpClients' | 'getMcpFailedConnections'> {
|
|
37
37
|
createSession: (sessionId?: string) => Promise<{
|
|
38
38
|
id: string;
|
|
39
39
|
logger: Pick<RootLogger, 'getLevel' | 'getLogFilePath'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-backend.d.ts","sourceRoot":"","sources":["../src/agent-backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAElF,MAAM,WAAW,oBAAoB;IACjC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,KAAK,UAAU,GAAG,IAAI,CAClB,UAAU,CAAC,QAAQ,CAAC,EACpB,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,gBAAgB,CACtE,CAAC;AAEF,UAAU,eAAe;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACv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AAC,EAAE,oBAAoB,CAAC;CACvC;AAiCD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,oBAAoB,CAU/E;AAED,wBAAgB,kBAAkB,CAC9B,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC,GACzD,OAAO,CA0BT;AAED,wBAAgB,4BAA4B,CACxC,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC,GACxD,OAAO,CAET;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAE/D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAEjE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAEnE;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAEtE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAEpE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAEnE"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var InsufficientCreditsOverlay_exports = {};
|
|
20
|
+
__export(InsufficientCreditsOverlay_exports, {
|
|
21
|
+
default: () => InsufficientCreditsOverlay_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(InsufficientCreditsOverlay_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_ink = require("ink");
|
|
27
|
+
var import_BaseSelector = require("../base/BaseSelector.js");
|
|
28
|
+
var import_host = require("../../host/index.js");
|
|
29
|
+
const TOP_UP_OPTIONS = [
|
|
30
|
+
{
|
|
31
|
+
id: "top-up-25",
|
|
32
|
+
label: "Top up $25",
|
|
33
|
+
description: "Recommended quick recharge",
|
|
34
|
+
amountUsd: 25
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "top-up-10",
|
|
38
|
+
label: "Top up $10",
|
|
39
|
+
description: "Small top-up",
|
|
40
|
+
amountUsd: 10
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "top-up-50",
|
|
44
|
+
label: "Top up $50",
|
|
45
|
+
description: "Larger credit pack",
|
|
46
|
+
amountUsd: 50
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "open-billing",
|
|
50
|
+
label: "Open billing page",
|
|
51
|
+
description: "View full billing dashboard"
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
const WAITING_OPTIONS = [
|
|
55
|
+
{
|
|
56
|
+
id: "reopen",
|
|
57
|
+
label: "Open billing page again",
|
|
58
|
+
description: "Return to billing or sign in in your browser"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "different-amount",
|
|
62
|
+
label: "Choose a different amount",
|
|
63
|
+
description: "Open billing with another amount prefilled"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "done",
|
|
67
|
+
label: "Close and retry manually",
|
|
68
|
+
description: "Return to chat once billing is handled"
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
function formatBalance(balanceUsd) {
|
|
72
|
+
if (balanceUsd === null) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return `$${balanceUsd.toFixed(2)}`;
|
|
76
|
+
}
|
|
77
|
+
function getErrorMessage(error) {
|
|
78
|
+
return error instanceof Error ? error.message : String(error);
|
|
79
|
+
}
|
|
80
|
+
const InsufficientCreditsOverlay = (0, import_react.forwardRef)(function InsufficientCreditsOverlay2({ isVisible, initialBalanceUsd, onResolved, onClose }, ref) {
|
|
81
|
+
const selectorRef = (0, import_react.useRef)(null);
|
|
82
|
+
const isActiveRef = (0, import_react.useRef)(false);
|
|
83
|
+
const [step, setStep] = (0, import_react.useState)("select");
|
|
84
|
+
const [selectedIndex, setSelectedIndex] = (0, import_react.useState)(0);
|
|
85
|
+
const [balanceUsd, setBalanceUsd] = (0, import_react.useState)(initialBalanceUsd);
|
|
86
|
+
const [openedBillingTarget, setOpenedBillingTarget] = (0, import_react.useState)(null);
|
|
87
|
+
const [statusMessage, setStatusMessage] = (0, import_react.useState)(
|
|
88
|
+
"Choose a top-up option. Dexto will open billing in your browser."
|
|
89
|
+
);
|
|
90
|
+
const [errorMessage, setErrorMessage] = (0, import_react.useState)(null);
|
|
91
|
+
const [loadingMessage, setLoadingMessage] = (0, import_react.useState)("Working...");
|
|
92
|
+
const [isLoading, setIsLoading] = (0, import_react.useState)(false);
|
|
93
|
+
const options = (0, import_react.useMemo)(() => {
|
|
94
|
+
return step === "select" ? TOP_UP_OPTIONS : WAITING_OPTIONS;
|
|
95
|
+
}, [step]);
|
|
96
|
+
const selectorTitle = step === "select" ? "Billing Options" : "Next Step";
|
|
97
|
+
const resetToSelection = (0, import_react.useCallback)(() => {
|
|
98
|
+
setStep("select");
|
|
99
|
+
setSelectedIndex(0);
|
|
100
|
+
setOpenedBillingTarget(null);
|
|
101
|
+
setErrorMessage(null);
|
|
102
|
+
setStatusMessage("Choose a top-up option. Dexto will open billing in your browser.");
|
|
103
|
+
setIsLoading(false);
|
|
104
|
+
setLoadingMessage("Working...");
|
|
105
|
+
}, []);
|
|
106
|
+
(0, import_react.useEffect)(() => {
|
|
107
|
+
if (!isVisible) {
|
|
108
|
+
isActiveRef.current = false;
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
isActiveRef.current = true;
|
|
112
|
+
setBalanceUsd(initialBalanceUsd);
|
|
113
|
+
resetToSelection();
|
|
114
|
+
return () => {
|
|
115
|
+
isActiveRef.current = false;
|
|
116
|
+
};
|
|
117
|
+
}, [initialBalanceUsd, isVisible, resetToSelection]);
|
|
118
|
+
const openBillingTarget = (0, import_react.useCallback)(
|
|
119
|
+
async (options2) => {
|
|
120
|
+
setErrorMessage(null);
|
|
121
|
+
setIsLoading(true);
|
|
122
|
+
setLoadingMessage(options2.loadingMessage);
|
|
123
|
+
try {
|
|
124
|
+
await (0, import_host.openDextoBillingPage)({ url: options2.url });
|
|
125
|
+
if (!isActiveRef.current) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
setOpenedBillingTarget(options2.url ?? null);
|
|
129
|
+
setStep("waiting");
|
|
130
|
+
setSelectedIndex(0);
|
|
131
|
+
setStatusMessage(options2.statusMessage);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if (!isActiveRef.current) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
setOpenedBillingTarget(options2.url ?? null);
|
|
137
|
+
setStep("waiting");
|
|
138
|
+
setSelectedIndex(0);
|
|
139
|
+
setErrorMessage(getErrorMessage(error));
|
|
140
|
+
setStatusMessage("Billing is ready to open again once your browser is available.");
|
|
141
|
+
} finally {
|
|
142
|
+
if (isActiveRef.current) {
|
|
143
|
+
setIsLoading(false);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
[]
|
|
148
|
+
);
|
|
149
|
+
const openBillingDashboard = (0, import_react.useCallback)(async () => {
|
|
150
|
+
await openBillingTarget({
|
|
151
|
+
loadingMessage: "Opening billing page...",
|
|
152
|
+
statusMessage: "Billing opened in your browser. If needed, the site will ask you to sign in before you continue. Once payment is complete, close this prompt and retry your request here."
|
|
153
|
+
});
|
|
154
|
+
}, [openBillingTarget]);
|
|
155
|
+
const openPrefilledBilling = (0, import_react.useCallback)(
|
|
156
|
+
async (creditsUsd) => {
|
|
157
|
+
const billingUrl = (0, import_host.buildDextoBillingUrl)({ creditsUsd });
|
|
158
|
+
await openBillingTarget({
|
|
159
|
+
url: billingUrl,
|
|
160
|
+
loadingMessage: `Opening $${creditsUsd} billing page...`,
|
|
161
|
+
statusMessage: `Opened a $${creditsUsd} top-up flow in your browser. If needed, the site will ask you to sign in before you continue. Once payment is complete, close this prompt and retry your request here.`
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
[openBillingTarget]
|
|
165
|
+
);
|
|
166
|
+
const reopenBilling = (0, import_react.useCallback)(async () => {
|
|
167
|
+
setErrorMessage(null);
|
|
168
|
+
setIsLoading(true);
|
|
169
|
+
setLoadingMessage("Opening billing page...");
|
|
170
|
+
try {
|
|
171
|
+
await (0, import_host.openDextoBillingPage)({ url: openedBillingTarget ?? void 0 });
|
|
172
|
+
} catch (error) {
|
|
173
|
+
if (!isActiveRef.current) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
setErrorMessage(getErrorMessage(error));
|
|
177
|
+
} finally {
|
|
178
|
+
if (isActiveRef.current) {
|
|
179
|
+
setIsLoading(false);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}, [openedBillingTarget]);
|
|
183
|
+
const handleSelect = (0, import_react.useCallback)(
|
|
184
|
+
(option) => {
|
|
185
|
+
if (typeof option.amountUsd === "number") {
|
|
186
|
+
void openPrefilledBilling(option.amountUsd);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
switch (option.id) {
|
|
190
|
+
case "open-billing":
|
|
191
|
+
void openBillingDashboard();
|
|
192
|
+
return;
|
|
193
|
+
case "reopen":
|
|
194
|
+
void reopenBilling();
|
|
195
|
+
return;
|
|
196
|
+
case "different-amount":
|
|
197
|
+
resetToSelection();
|
|
198
|
+
return;
|
|
199
|
+
case "done":
|
|
200
|
+
onResolved();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
[onResolved, openBillingDashboard, openPrefilledBilling, reopenBilling, resetToSelection]
|
|
205
|
+
);
|
|
206
|
+
const formatItem = (0, import_react.useCallback)((option, isSelected) => {
|
|
207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
208
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: isSelected ? "yellow" : "gray", bold: isSelected, children: option.label }),
|
|
209
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: isSelected ? "white" : "gray", children: [
|
|
210
|
+
" - ",
|
|
211
|
+
option.description
|
|
212
|
+
] })
|
|
213
|
+
] });
|
|
214
|
+
}, []);
|
|
215
|
+
(0, import_react.useImperativeHandle)(
|
|
216
|
+
ref,
|
|
217
|
+
() => ({
|
|
218
|
+
handleInput: (input, key) => {
|
|
219
|
+
if (!isVisible) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
return selectorRef.current?.handleInput(input, key) ?? false;
|
|
223
|
+
}
|
|
224
|
+
}),
|
|
225
|
+
[isVisible]
|
|
226
|
+
);
|
|
227
|
+
if (!isVisible) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "column", children: [
|
|
231
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "yellow", bold: true, children: "Out of Dexto Nova credits" }) }),
|
|
232
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "column", marginTop: 1, children: [
|
|
233
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "gray", children: "This request stopped because your Dexto Nova balance ran out." }),
|
|
234
|
+
formatBalance(balanceUsd) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Text, { color: "gray", children: [
|
|
235
|
+
"Current balance: ",
|
|
236
|
+
formatBalance(balanceUsd)
|
|
237
|
+
] })
|
|
238
|
+
] }),
|
|
239
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ink.Box, { flexDirection: "column", marginTop: 1, children: [
|
|
240
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { children: statusMessage }),
|
|
241
|
+
errorMessage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Text, { color: "red", children: errorMessage })
|
|
242
|
+
] }),
|
|
243
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ink.Box, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
244
|
+
import_BaseSelector.BaseSelector,
|
|
245
|
+
{
|
|
246
|
+
ref: selectorRef,
|
|
247
|
+
items: options,
|
|
248
|
+
isVisible: true,
|
|
249
|
+
isLoading,
|
|
250
|
+
selectedIndex,
|
|
251
|
+
onSelectIndex: setSelectedIndex,
|
|
252
|
+
onSelect: handleSelect,
|
|
253
|
+
onClose,
|
|
254
|
+
formatItem,
|
|
255
|
+
title: selectorTitle,
|
|
256
|
+
borderColor: "yellow",
|
|
257
|
+
maxVisibleItems: 6,
|
|
258
|
+
loadingMessage,
|
|
259
|
+
emptyMessage: "No billing actions available"
|
|
260
|
+
}
|
|
261
|
+
) })
|
|
262
|
+
] });
|
|
263
|
+
});
|
|
264
|
+
var InsufficientCreditsOverlay_default = InsufficientCreditsOverlay;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Key } from '../../hooks/useInputOrchestrator.js';
|
|
3
|
+
export interface InsufficientCreditsOverlayProps {
|
|
4
|
+
isVisible: boolean;
|
|
5
|
+
initialBalanceUsd: number | null;
|
|
6
|
+
onResolved: () => void;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface InsufficientCreditsOverlayHandle {
|
|
10
|
+
handleInput: (input: string, key: Key) => boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const InsufficientCreditsOverlay: React.ForwardRefExoticComponent<InsufficientCreditsOverlayProps & React.RefAttributes<InsufficientCreditsOverlayHandle>>;
|
|
13
|
+
export default InsufficientCreditsOverlay;
|
|
14
|
+
//# sourceMappingURL=InsufficientCreditsOverlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InsufficientCreditsOverlay.d.ts","sourceRoot":"","sources":["../../../src/components/overlays/InsufficientCreditsOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AA6E/D,MAAM,WAAW,+BAA+B;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,gCAAgC;IAC7C,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC;CACrD;AAED,QAAA,MAAM,0BAA0B,0HAiO9B,CAAC;AAEH,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
forwardRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState
|
|
10
|
+
} from "react";
|
|
11
|
+
import { Box, Text } from "ink";
|
|
12
|
+
import { BaseSelector } from "../base/BaseSelector.js";
|
|
13
|
+
import { buildDextoBillingUrl, openDextoBillingPage } from "../../host/index.js";
|
|
14
|
+
const TOP_UP_OPTIONS = [
|
|
15
|
+
{
|
|
16
|
+
id: "top-up-25",
|
|
17
|
+
label: "Top up $25",
|
|
18
|
+
description: "Recommended quick recharge",
|
|
19
|
+
amountUsd: 25
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: "top-up-10",
|
|
23
|
+
label: "Top up $10",
|
|
24
|
+
description: "Small top-up",
|
|
25
|
+
amountUsd: 10
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "top-up-50",
|
|
29
|
+
label: "Top up $50",
|
|
30
|
+
description: "Larger credit pack",
|
|
31
|
+
amountUsd: 50
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "open-billing",
|
|
35
|
+
label: "Open billing page",
|
|
36
|
+
description: "View full billing dashboard"
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
const WAITING_OPTIONS = [
|
|
40
|
+
{
|
|
41
|
+
id: "reopen",
|
|
42
|
+
label: "Open billing page again",
|
|
43
|
+
description: "Return to billing or sign in in your browser"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "different-amount",
|
|
47
|
+
label: "Choose a different amount",
|
|
48
|
+
description: "Open billing with another amount prefilled"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "done",
|
|
52
|
+
label: "Close and retry manually",
|
|
53
|
+
description: "Return to chat once billing is handled"
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
function formatBalance(balanceUsd) {
|
|
57
|
+
if (balanceUsd === null) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return `$${balanceUsd.toFixed(2)}`;
|
|
61
|
+
}
|
|
62
|
+
function getErrorMessage(error) {
|
|
63
|
+
return error instanceof Error ? error.message : String(error);
|
|
64
|
+
}
|
|
65
|
+
const InsufficientCreditsOverlay = forwardRef(function InsufficientCreditsOverlay2({ isVisible, initialBalanceUsd, onResolved, onClose }, ref) {
|
|
66
|
+
const selectorRef = useRef(null);
|
|
67
|
+
const isActiveRef = useRef(false);
|
|
68
|
+
const [step, setStep] = useState("select");
|
|
69
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
70
|
+
const [balanceUsd, setBalanceUsd] = useState(initialBalanceUsd);
|
|
71
|
+
const [openedBillingTarget, setOpenedBillingTarget] = useState(null);
|
|
72
|
+
const [statusMessage, setStatusMessage] = useState(
|
|
73
|
+
"Choose a top-up option. Dexto will open billing in your browser."
|
|
74
|
+
);
|
|
75
|
+
const [errorMessage, setErrorMessage] = useState(null);
|
|
76
|
+
const [loadingMessage, setLoadingMessage] = useState("Working...");
|
|
77
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
78
|
+
const options = useMemo(() => {
|
|
79
|
+
return step === "select" ? TOP_UP_OPTIONS : WAITING_OPTIONS;
|
|
80
|
+
}, [step]);
|
|
81
|
+
const selectorTitle = step === "select" ? "Billing Options" : "Next Step";
|
|
82
|
+
const resetToSelection = useCallback(() => {
|
|
83
|
+
setStep("select");
|
|
84
|
+
setSelectedIndex(0);
|
|
85
|
+
setOpenedBillingTarget(null);
|
|
86
|
+
setErrorMessage(null);
|
|
87
|
+
setStatusMessage("Choose a top-up option. Dexto will open billing in your browser.");
|
|
88
|
+
setIsLoading(false);
|
|
89
|
+
setLoadingMessage("Working...");
|
|
90
|
+
}, []);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!isVisible) {
|
|
93
|
+
isActiveRef.current = false;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
isActiveRef.current = true;
|
|
97
|
+
setBalanceUsd(initialBalanceUsd);
|
|
98
|
+
resetToSelection();
|
|
99
|
+
return () => {
|
|
100
|
+
isActiveRef.current = false;
|
|
101
|
+
};
|
|
102
|
+
}, [initialBalanceUsd, isVisible, resetToSelection]);
|
|
103
|
+
const openBillingTarget = useCallback(
|
|
104
|
+
async (options2) => {
|
|
105
|
+
setErrorMessage(null);
|
|
106
|
+
setIsLoading(true);
|
|
107
|
+
setLoadingMessage(options2.loadingMessage);
|
|
108
|
+
try {
|
|
109
|
+
await openDextoBillingPage({ url: options2.url });
|
|
110
|
+
if (!isActiveRef.current) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
setOpenedBillingTarget(options2.url ?? null);
|
|
114
|
+
setStep("waiting");
|
|
115
|
+
setSelectedIndex(0);
|
|
116
|
+
setStatusMessage(options2.statusMessage);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
if (!isActiveRef.current) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
setOpenedBillingTarget(options2.url ?? null);
|
|
122
|
+
setStep("waiting");
|
|
123
|
+
setSelectedIndex(0);
|
|
124
|
+
setErrorMessage(getErrorMessage(error));
|
|
125
|
+
setStatusMessage("Billing is ready to open again once your browser is available.");
|
|
126
|
+
} finally {
|
|
127
|
+
if (isActiveRef.current) {
|
|
128
|
+
setIsLoading(false);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
[]
|
|
133
|
+
);
|
|
134
|
+
const openBillingDashboard = useCallback(async () => {
|
|
135
|
+
await openBillingTarget({
|
|
136
|
+
loadingMessage: "Opening billing page...",
|
|
137
|
+
statusMessage: "Billing opened in your browser. If needed, the site will ask you to sign in before you continue. Once payment is complete, close this prompt and retry your request here."
|
|
138
|
+
});
|
|
139
|
+
}, [openBillingTarget]);
|
|
140
|
+
const openPrefilledBilling = useCallback(
|
|
141
|
+
async (creditsUsd) => {
|
|
142
|
+
const billingUrl = buildDextoBillingUrl({ creditsUsd });
|
|
143
|
+
await openBillingTarget({
|
|
144
|
+
url: billingUrl,
|
|
145
|
+
loadingMessage: `Opening $${creditsUsd} billing page...`,
|
|
146
|
+
statusMessage: `Opened a $${creditsUsd} top-up flow in your browser. If needed, the site will ask you to sign in before you continue. Once payment is complete, close this prompt and retry your request here.`
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
[openBillingTarget]
|
|
150
|
+
);
|
|
151
|
+
const reopenBilling = useCallback(async () => {
|
|
152
|
+
setErrorMessage(null);
|
|
153
|
+
setIsLoading(true);
|
|
154
|
+
setLoadingMessage("Opening billing page...");
|
|
155
|
+
try {
|
|
156
|
+
await openDextoBillingPage({ url: openedBillingTarget ?? void 0 });
|
|
157
|
+
} catch (error) {
|
|
158
|
+
if (!isActiveRef.current) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
setErrorMessage(getErrorMessage(error));
|
|
162
|
+
} finally {
|
|
163
|
+
if (isActiveRef.current) {
|
|
164
|
+
setIsLoading(false);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}, [openedBillingTarget]);
|
|
168
|
+
const handleSelect = useCallback(
|
|
169
|
+
(option) => {
|
|
170
|
+
if (typeof option.amountUsd === "number") {
|
|
171
|
+
void openPrefilledBilling(option.amountUsd);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
switch (option.id) {
|
|
175
|
+
case "open-billing":
|
|
176
|
+
void openBillingDashboard();
|
|
177
|
+
return;
|
|
178
|
+
case "reopen":
|
|
179
|
+
void reopenBilling();
|
|
180
|
+
return;
|
|
181
|
+
case "different-amount":
|
|
182
|
+
resetToSelection();
|
|
183
|
+
return;
|
|
184
|
+
case "done":
|
|
185
|
+
onResolved();
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
[onResolved, openBillingDashboard, openPrefilledBilling, reopenBilling, resetToSelection]
|
|
190
|
+
);
|
|
191
|
+
const formatItem = useCallback((option, isSelected) => {
|
|
192
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
193
|
+
/* @__PURE__ */ jsx(Text, { color: isSelected ? "yellow" : "gray", bold: isSelected, children: option.label }),
|
|
194
|
+
/* @__PURE__ */ jsxs(Text, { color: isSelected ? "white" : "gray", children: [
|
|
195
|
+
" - ",
|
|
196
|
+
option.description
|
|
197
|
+
] })
|
|
198
|
+
] });
|
|
199
|
+
}, []);
|
|
200
|
+
useImperativeHandle(
|
|
201
|
+
ref,
|
|
202
|
+
() => ({
|
|
203
|
+
handleInput: (input, key) => {
|
|
204
|
+
if (!isVisible) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
return selectorRef.current?.handleInput(input, key) ?? false;
|
|
208
|
+
}
|
|
209
|
+
}),
|
|
210
|
+
[isVisible]
|
|
211
|
+
);
|
|
212
|
+
if (!isVisible) {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
216
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { color: "yellow", bold: true, children: "Out of Dexto Nova credits" }) }),
|
|
217
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
218
|
+
/* @__PURE__ */ jsx(Text, { color: "gray", children: "This request stopped because your Dexto Nova balance ran out." }),
|
|
219
|
+
formatBalance(balanceUsd) && /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
|
|
220
|
+
"Current balance: ",
|
|
221
|
+
formatBalance(balanceUsd)
|
|
222
|
+
] })
|
|
223
|
+
] }),
|
|
224
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
225
|
+
/* @__PURE__ */ jsx(Text, { children: statusMessage }),
|
|
226
|
+
errorMessage && /* @__PURE__ */ jsx(Text, { color: "red", children: errorMessage })
|
|
227
|
+
] }),
|
|
228
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(
|
|
229
|
+
BaseSelector,
|
|
230
|
+
{
|
|
231
|
+
ref: selectorRef,
|
|
232
|
+
items: options,
|
|
233
|
+
isVisible: true,
|
|
234
|
+
isLoading,
|
|
235
|
+
selectedIndex,
|
|
236
|
+
onSelectIndex: setSelectedIndex,
|
|
237
|
+
onSelect: handleSelect,
|
|
238
|
+
onClose,
|
|
239
|
+
formatItem,
|
|
240
|
+
title: selectorTitle,
|
|
241
|
+
borderColor: "yellow",
|
|
242
|
+
maxVisibleItems: 6,
|
|
243
|
+
loadingMessage,
|
|
244
|
+
emptyMessage: "No billing actions available"
|
|
245
|
+
}
|
|
246
|
+
) })
|
|
247
|
+
] });
|
|
248
|
+
});
|
|
249
|
+
var InsufficientCreditsOverlay_default = InsufficientCreditsOverlay;
|
|
250
|
+
export {
|
|
251
|
+
InsufficientCreditsOverlay_default as default
|
|
252
|
+
};
|
|
@@ -499,7 +499,7 @@ const PROVIDER_CONFIGS = {
|
|
|
499
499
|
},
|
|
500
500
|
setupInfo: {
|
|
501
501
|
title: "Dexto Nova Setup",
|
|
502
|
-
description: "Add OpenRouter-format models that use your Dexto Nova credits. Requires login: run
|
|
502
|
+
description: "Add OpenRouter-format models that use your Dexto Nova credits. Requires login: run `/login` first.",
|
|
503
503
|
docsUrl: "https://openrouter.ai/models"
|
|
504
504
|
}
|
|
505
505
|
}
|
|
@@ -467,7 +467,7 @@ const PROVIDER_CONFIGS = {
|
|
|
467
467
|
},
|
|
468
468
|
setupInfo: {
|
|
469
469
|
title: "Dexto Nova Setup",
|
|
470
|
-
description: "Add OpenRouter-format models that use your Dexto Nova credits. Requires login: run
|
|
470
|
+
description: "Add OpenRouter-format models that use your Dexto Nova credits. Requires login: run `/login` first.",
|
|
471
471
|
docsUrl: "https://openrouter.ai/models"
|
|
472
472
|
}
|
|
473
473
|
}
|