@dexto/tui 1.14.5 → 1.15.0-beta.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/components/Footer.cjs +31 -0
- package/dist/components/Footer.d.ts.map +1 -1
- package/dist/components/Footer.js +31 -0
- package/dist/components/Footer.test.cjs +44 -0
- package/dist/components/Footer.test.js +44 -0
- package/dist/components/overlays/InsufficientCreditsOverlay.cjs +19 -4
- package/dist/components/overlays/InsufficientCreditsOverlay.d.ts +2 -0
- package/dist/components/overlays/InsufficientCreditsOverlay.d.ts.map +1 -1
- package/dist/components/overlays/InsufficientCreditsOverlay.js +19 -4
- package/dist/components/overlays/LoginOverlay.cjs +25 -61
- package/dist/components/overlays/LoginOverlay.d.ts +1 -3
- package/dist/components/overlays/LoginOverlay.d.ts.map +1 -1
- package/dist/components/overlays/LoginOverlay.js +26 -66
- package/dist/components/overlays/LogoutOverlay.cjs +8 -17
- package/dist/components/overlays/LogoutOverlay.d.ts +1 -0
- package/dist/components/overlays/LogoutOverlay.d.ts.map +1 -1
- package/dist/components/overlays/LogoutOverlay.js +10 -31
- package/dist/components/overlays/custom-model-wizard/provider-config.cjs +4 -4
- package/dist/components/overlays/custom-model-wizard/provider-config.js +4 -4
- package/dist/containers/OverlayContainer.cjs +30 -40
- package/dist/containers/OverlayContainer.d.ts.map +1 -1
- package/dist/containers/OverlayContainer.js +30 -40
- package/dist/host/index.cjs +22 -49
- package/dist/host/index.d.ts +18 -72
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +18 -42
- package/dist/host/index.test.cjs +21 -35
- package/dist/host/index.test.js +22 -40
- package/dist/index.d.cts +13 -52
- package/dist/services/processStream.cjs +2 -2
- package/dist/services/processStream.js +2 -2
- package/dist/services/processStream.test.cjs +1 -1
- package/dist/services/processStream.test.js +1 -1
- package/dist/utils/llm-provider-display.cjs +1 -1
- package/dist/utils/llm-provider-display.js +1 -1
- package/package.json +5 -5
package/dist/host/index.cjs
CHANGED
|
@@ -22,21 +22,18 @@ __export(host_exports, {
|
|
|
22
22
|
buildDextoBillingUrl: () => buildDextoBillingUrl,
|
|
23
23
|
canUseDextoProvider: () => canUseDextoProvider,
|
|
24
24
|
captureAnalytics: () => captureAnalytics,
|
|
25
|
-
|
|
25
|
+
currentSignIn: () => currentSignIn,
|
|
26
|
+
dextoCreditBalance: () => dextoCreditBalance,
|
|
26
27
|
getProviderDisplayName: () => getProviderDisplayName,
|
|
27
28
|
getProviderInstructions: () => getProviderInstructions,
|
|
28
29
|
getTuiRuntimeServices: () => getTuiRuntimeServices,
|
|
29
30
|
isUsingDextoCredits: () => isUsingDextoCredits,
|
|
30
31
|
isValidApiKeyFormat: () => isValidApiKeyFormat,
|
|
31
|
-
loadAuth: () => loadAuth,
|
|
32
32
|
openDextoBillingPage: () => openDextoBillingPage,
|
|
33
|
-
performDeviceCodeLogin: () => performDeviceCodeLogin,
|
|
34
|
-
persistDeviceApiKeyLoginResult: () => persistDeviceApiKeyLoginResult,
|
|
35
33
|
registerGracefulShutdown: () => registerGracefulShutdown,
|
|
36
|
-
removeAuth: () => removeAuth,
|
|
37
|
-
removeDextoApiKeyFromEnv: () => removeDextoApiKeyFromEnv,
|
|
38
34
|
setTuiRuntimeServices: () => setTuiRuntimeServices,
|
|
39
|
-
|
|
35
|
+
signIn: () => signIn,
|
|
36
|
+
signOut: () => signOut
|
|
40
37
|
});
|
|
41
38
|
module.exports = __toCommonJS(host_exports);
|
|
42
39
|
let runtimeServices = {};
|
|
@@ -69,47 +66,26 @@ function isValidApiKeyFormat(apiKey, provider) {
|
|
|
69
66
|
function getProviderInstructions(provider) {
|
|
70
67
|
return runtimeServices.getProviderInstructions?.(provider) ?? null;
|
|
71
68
|
}
|
|
72
|
-
async function
|
|
73
|
-
if (!runtimeServices.
|
|
74
|
-
throw missingHostMethod("
|
|
69
|
+
async function currentSignIn() {
|
|
70
|
+
if (!runtimeServices.currentSignIn) {
|
|
71
|
+
throw missingHostMethod("currentSignIn");
|
|
75
72
|
}
|
|
76
|
-
return runtimeServices.
|
|
73
|
+
return runtimeServices.currentSignIn();
|
|
77
74
|
}
|
|
78
|
-
async function
|
|
79
|
-
if (!runtimeServices.
|
|
80
|
-
throw missingHostMethod("
|
|
75
|
+
async function signIn(options) {
|
|
76
|
+
if (!runtimeServices.signIn) {
|
|
77
|
+
throw missingHostMethod("signIn");
|
|
81
78
|
}
|
|
82
|
-
return runtimeServices.
|
|
79
|
+
return runtimeServices.signIn(options);
|
|
83
80
|
}
|
|
84
|
-
async function
|
|
85
|
-
|
|
86
|
-
throw missingHostMethod("ensureDextoApiKeyForAuthToken");
|
|
87
|
-
}
|
|
88
|
-
return runtimeServices.ensureDextoApiKeyForAuthToken(authToken, options);
|
|
89
|
-
}
|
|
90
|
-
async function loadAuth() {
|
|
91
|
-
if (!runtimeServices.loadAuth) {
|
|
92
|
-
throw missingHostMethod("loadAuth");
|
|
93
|
-
}
|
|
94
|
-
return runtimeServices.loadAuth();
|
|
95
|
-
}
|
|
96
|
-
async function storeAuth(config) {
|
|
97
|
-
if (!runtimeServices.storeAuth) {
|
|
98
|
-
throw missingHostMethod("storeAuth");
|
|
99
|
-
}
|
|
100
|
-
await runtimeServices.storeAuth(config);
|
|
101
|
-
}
|
|
102
|
-
async function removeAuth() {
|
|
103
|
-
if (!runtimeServices.removeAuth) {
|
|
104
|
-
throw missingHostMethod("removeAuth");
|
|
105
|
-
}
|
|
106
|
-
await runtimeServices.removeAuth();
|
|
81
|
+
async function dextoCreditBalance() {
|
|
82
|
+
return await runtimeServices.dextoCreditBalance?.() ?? null;
|
|
107
83
|
}
|
|
108
|
-
async function
|
|
109
|
-
if (!runtimeServices.
|
|
110
|
-
throw missingHostMethod("
|
|
84
|
+
async function signOut() {
|
|
85
|
+
if (!runtimeServices.signOut) {
|
|
86
|
+
throw missingHostMethod("signOut");
|
|
111
87
|
}
|
|
112
|
-
return runtimeServices.
|
|
88
|
+
return runtimeServices.signOut();
|
|
113
89
|
}
|
|
114
90
|
async function isUsingDextoCredits() {
|
|
115
91
|
if (!runtimeServices.isUsingDextoCredits) {
|
|
@@ -141,19 +117,16 @@ async function openDextoBillingPage(options) {
|
|
|
141
117
|
buildDextoBillingUrl,
|
|
142
118
|
canUseDextoProvider,
|
|
143
119
|
captureAnalytics,
|
|
144
|
-
|
|
120
|
+
currentSignIn,
|
|
121
|
+
dextoCreditBalance,
|
|
145
122
|
getProviderDisplayName,
|
|
146
123
|
getProviderInstructions,
|
|
147
124
|
getTuiRuntimeServices,
|
|
148
125
|
isUsingDextoCredits,
|
|
149
126
|
isValidApiKeyFormat,
|
|
150
|
-
loadAuth,
|
|
151
127
|
openDextoBillingPage,
|
|
152
|
-
performDeviceCodeLogin,
|
|
153
|
-
persistDeviceApiKeyLoginResult,
|
|
154
128
|
registerGracefulShutdown,
|
|
155
|
-
removeAuth,
|
|
156
|
-
removeDextoApiKeyFromEnv,
|
|
157
129
|
setTuiRuntimeServices,
|
|
158
|
-
|
|
130
|
+
signIn,
|
|
131
|
+
signOut
|
|
159
132
|
});
|
package/dist/host/index.d.ts
CHANGED
|
@@ -3,38 +3,11 @@ import type { TuiAgentBackend } from '../agent-backend.js';
|
|
|
3
3
|
export interface TuiShutdownHandle {
|
|
4
4
|
stop?: (() => Promise<void>) | undefined;
|
|
5
5
|
}
|
|
6
|
-
export interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
expiresAt?: number | undefined;
|
|
12
|
-
createdAt: number;
|
|
13
|
-
dextoApiKey?: string | undefined;
|
|
14
|
-
dextoKeyId?: string | undefined;
|
|
15
|
-
dextoApiKeySource?: 'provisioned' | 'user-supplied' | undefined;
|
|
16
|
-
}
|
|
17
|
-
export interface TuiDeviceApiKeyLoginResult {
|
|
18
|
-
dextoApiKey: string;
|
|
19
|
-
dextoKeyId: string;
|
|
20
|
-
dextoKeyDisplay: string;
|
|
21
|
-
}
|
|
22
|
-
export interface TuiDeviceLoginPrompt {
|
|
23
|
-
userCode: string;
|
|
24
|
-
verificationUrl: string;
|
|
25
|
-
verificationUrlComplete: string | null;
|
|
26
|
-
expiresIn: number;
|
|
27
|
-
}
|
|
28
|
-
export type TuiDextoApiKeyProvisionStatusLevel = 'info' | 'success' | 'warning' | 'error';
|
|
29
|
-
export interface TuiDextoApiKeyProvisionStatus {
|
|
30
|
-
level: TuiDextoApiKeyProvisionStatusLevel;
|
|
31
|
-
message: string;
|
|
32
|
-
}
|
|
33
|
-
export interface TuiPersistedLoginResult {
|
|
34
|
-
email?: string | undefined;
|
|
35
|
-
userId?: string | undefined;
|
|
36
|
-
keyId?: string | undefined;
|
|
37
|
-
hasDextoApiKey: boolean;
|
|
6
|
+
export interface TuiSignInOptions {
|
|
7
|
+
/** Aborts the sign-in, such as when the person presses Esc. */
|
|
8
|
+
signal: AbortSignal;
|
|
9
|
+
/** What to show while signing in: the link, or the code to check. */
|
|
10
|
+
onNote: (text: string) => void;
|
|
38
11
|
}
|
|
39
12
|
export interface TuiRuntimeServices {
|
|
40
13
|
registerGracefulShutdown?: (getAgent: () => TuiShutdownHandle, options: {
|
|
@@ -49,26 +22,14 @@ export interface TuiRuntimeServices {
|
|
|
49
22
|
content: string;
|
|
50
23
|
url?: string | undefined;
|
|
51
24
|
} | null;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
dextoApiKey: string;
|
|
61
|
-
keyId: string | null;
|
|
62
|
-
} | null>;
|
|
63
|
-
loadAuth?: () => Promise<TuiAuthConfig | null>;
|
|
64
|
-
storeAuth?: (config: TuiAuthConfig) => Promise<void>;
|
|
65
|
-
removeAuth?: () => Promise<void>;
|
|
66
|
-
removeDextoApiKeyFromEnv?: (options?: {
|
|
67
|
-
expectedValue?: string;
|
|
68
|
-
}) => Promise<{
|
|
69
|
-
removed: boolean;
|
|
70
|
-
targetEnvPath: string;
|
|
71
|
-
}>;
|
|
25
|
+
/** Who the current profile acts as, in a few words, or null when signed out. */
|
|
26
|
+
currentSignIn?: () => Promise<string | null>;
|
|
27
|
+
/** Signs the current profile in to Dexto, resolving with what to say once signed in. */
|
|
28
|
+
signIn?: (options: TuiSignInOptions) => Promise<string>;
|
|
29
|
+
/** Ends the current profile's sign-in, resolving with what to say. */
|
|
30
|
+
signOut?: () => Promise<string>;
|
|
31
|
+
/** The organization's Dexto credit balance in USD; null when signed out. */
|
|
32
|
+
dextoCreditBalance?: () => Promise<number | null>;
|
|
72
33
|
isUsingDextoCredits?: () => Promise<boolean>;
|
|
73
34
|
canUseDextoProvider?: () => Promise<boolean>;
|
|
74
35
|
buildDextoBillingUrl?: (options: {
|
|
@@ -92,26 +53,11 @@ export declare function getProviderInstructions(provider: LLMProvider): {
|
|
|
92
53
|
content: string;
|
|
93
54
|
url?: string | undefined;
|
|
94
55
|
} | null;
|
|
95
|
-
export declare function
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
export declare function
|
|
100
|
-
export declare function ensureDextoApiKeyForAuthToken(authToken: string, options?: {
|
|
101
|
-
onStatus?: ((status: TuiDextoApiKeyProvisionStatus) => void) | undefined;
|
|
102
|
-
}): Promise<{
|
|
103
|
-
dextoApiKey: string;
|
|
104
|
-
keyId: string | null;
|
|
105
|
-
} | null>;
|
|
106
|
-
export declare function loadAuth(): Promise<TuiAuthConfig | null>;
|
|
107
|
-
export declare function storeAuth(config: TuiAuthConfig): Promise<void>;
|
|
108
|
-
export declare function removeAuth(): Promise<void>;
|
|
109
|
-
export declare function removeDextoApiKeyFromEnv(options?: {
|
|
110
|
-
expectedValue?: string;
|
|
111
|
-
}): Promise<{
|
|
112
|
-
removed: boolean;
|
|
113
|
-
targetEnvPath: string;
|
|
114
|
-
}>;
|
|
56
|
+
export declare function currentSignIn(): Promise<string | null>;
|
|
57
|
+
export declare function signIn(options: TuiSignInOptions): Promise<string>;
|
|
58
|
+
/** The Dexto credit balance, or null when the host can't say. */
|
|
59
|
+
export declare function dextoCreditBalance(): Promise<number | null>;
|
|
60
|
+
export declare function signOut(): Promise<string>;
|
|
115
61
|
export declare function isUsingDextoCredits(): Promise<boolean>;
|
|
116
62
|
export declare function canUseDextoProvider(): Promise<boolean>;
|
|
117
63
|
export declare function buildDextoBillingUrl(options: {
|
package/dist/host/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,WAAW,iBAAiB;IAC9B,IAAI,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;CAC5C;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,WAAW,iBAAiB;IAC9B,IAAI,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;CAC5C;AAED,MAAM,WAAW,gBAAgB;IAC7B,+DAA+D;IAC/D,MAAM,EAAE,WAAW,CAAC;IACpB,qEAAqE;IACrE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,kBAAkB;IAC/B,wBAAwB,CAAC,EAAE,CACvB,QAAQ,EAAE,MAAM,iBAAiB,EACjC,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,KAC5B,IAAI,CAAC;IACV,OAAO,CAAC,EAAE,CAAC,KAAK,E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E;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAK5E;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAK/F"}
|
package/dist/host/index.js
CHANGED
|
@@ -28,47 +28,26 @@ function isValidApiKeyFormat(apiKey, provider) {
|
|
|
28
28
|
function getProviderInstructions(provider) {
|
|
29
29
|
return runtimeServices.getProviderInstructions?.(provider) ?? null;
|
|
30
30
|
}
|
|
31
|
-
async function
|
|
32
|
-
if (!runtimeServices.
|
|
33
|
-
throw missingHostMethod("
|
|
31
|
+
async function currentSignIn() {
|
|
32
|
+
if (!runtimeServices.currentSignIn) {
|
|
33
|
+
throw missingHostMethod("currentSignIn");
|
|
34
34
|
}
|
|
35
|
-
return runtimeServices.
|
|
35
|
+
return runtimeServices.currentSignIn();
|
|
36
36
|
}
|
|
37
|
-
async function
|
|
38
|
-
if (!runtimeServices.
|
|
39
|
-
throw missingHostMethod("
|
|
37
|
+
async function signIn(options) {
|
|
38
|
+
if (!runtimeServices.signIn) {
|
|
39
|
+
throw missingHostMethod("signIn");
|
|
40
40
|
}
|
|
41
|
-
return runtimeServices.
|
|
41
|
+
return runtimeServices.signIn(options);
|
|
42
42
|
}
|
|
43
|
-
async function
|
|
44
|
-
|
|
45
|
-
throw missingHostMethod("ensureDextoApiKeyForAuthToken");
|
|
46
|
-
}
|
|
47
|
-
return runtimeServices.ensureDextoApiKeyForAuthToken(authToken, options);
|
|
48
|
-
}
|
|
49
|
-
async function loadAuth() {
|
|
50
|
-
if (!runtimeServices.loadAuth) {
|
|
51
|
-
throw missingHostMethod("loadAuth");
|
|
52
|
-
}
|
|
53
|
-
return runtimeServices.loadAuth();
|
|
54
|
-
}
|
|
55
|
-
async function storeAuth(config) {
|
|
56
|
-
if (!runtimeServices.storeAuth) {
|
|
57
|
-
throw missingHostMethod("storeAuth");
|
|
58
|
-
}
|
|
59
|
-
await runtimeServices.storeAuth(config);
|
|
60
|
-
}
|
|
61
|
-
async function removeAuth() {
|
|
62
|
-
if (!runtimeServices.removeAuth) {
|
|
63
|
-
throw missingHostMethod("removeAuth");
|
|
64
|
-
}
|
|
65
|
-
await runtimeServices.removeAuth();
|
|
43
|
+
async function dextoCreditBalance() {
|
|
44
|
+
return await runtimeServices.dextoCreditBalance?.() ?? null;
|
|
66
45
|
}
|
|
67
|
-
async function
|
|
68
|
-
if (!runtimeServices.
|
|
69
|
-
throw missingHostMethod("
|
|
46
|
+
async function signOut() {
|
|
47
|
+
if (!runtimeServices.signOut) {
|
|
48
|
+
throw missingHostMethod("signOut");
|
|
70
49
|
}
|
|
71
|
-
return runtimeServices.
|
|
50
|
+
return runtimeServices.signOut();
|
|
72
51
|
}
|
|
73
52
|
async function isUsingDextoCredits() {
|
|
74
53
|
if (!runtimeServices.isUsingDextoCredits) {
|
|
@@ -99,19 +78,16 @@ export {
|
|
|
99
78
|
buildDextoBillingUrl,
|
|
100
79
|
canUseDextoProvider,
|
|
101
80
|
captureAnalytics,
|
|
102
|
-
|
|
81
|
+
currentSignIn,
|
|
82
|
+
dextoCreditBalance,
|
|
103
83
|
getProviderDisplayName,
|
|
104
84
|
getProviderInstructions,
|
|
105
85
|
getTuiRuntimeServices,
|
|
106
86
|
isUsingDextoCredits,
|
|
107
87
|
isValidApiKeyFormat,
|
|
108
|
-
loadAuth,
|
|
109
88
|
openDextoBillingPage,
|
|
110
|
-
performDeviceCodeLogin,
|
|
111
|
-
persistDeviceApiKeyLoginResult,
|
|
112
89
|
registerGracefulShutdown,
|
|
113
|
-
removeAuth,
|
|
114
|
-
removeDextoApiKeyFromEnv,
|
|
115
90
|
setTuiRuntimeServices,
|
|
116
|
-
|
|
91
|
+
signIn,
|
|
92
|
+
signOut
|
|
117
93
|
};
|
package/dist/host/index.test.cjs
CHANGED
|
@@ -1,47 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var import_vitest = require("vitest");
|
|
3
3
|
var import_index = require("./index.js");
|
|
4
|
-
(0, import_vitest.describe)("TUI
|
|
4
|
+
(0, import_vitest.describe)("TUI sign-in runtime services", () => {
|
|
5
5
|
(0, import_vitest.afterEach)(() => {
|
|
6
6
|
(0, import_index.setTuiRuntimeServices)({});
|
|
7
7
|
});
|
|
8
|
-
(0, import_vitest.it)("
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
dextoKeyDisplay: "dxt_abc...",
|
|
13
|
-
dextoKeyId: "key-id"
|
|
14
|
-
});
|
|
15
|
-
const persist = import_vitest.vi.fn().mockResolvedValue({
|
|
16
|
-
keyId: "key-id",
|
|
17
|
-
hasDextoApiKey: true
|
|
18
|
-
});
|
|
8
|
+
(0, import_vitest.it)("signs in, says who, and signs out through the host", async () => {
|
|
9
|
+
const signal = new AbortController().signal;
|
|
10
|
+
const onNote = import_vitest.vi.fn();
|
|
11
|
+
const hostSignIn = import_vitest.vi.fn().mockResolvedValue("Signed in as ada@example.com in Acme.");
|
|
19
12
|
(0, import_index.setTuiRuntimeServices)({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const loginResult = await (0, import_index.performDeviceCodeLogin)({
|
|
24
|
-
onPrompt: prompt
|
|
25
|
-
});
|
|
26
|
-
const persisted = await (0, import_index.persistDeviceApiKeyLoginResult)(loginResult);
|
|
27
|
-
(0, import_vitest.expect)(perform).toHaveBeenCalledWith({ onPrompt: prompt });
|
|
28
|
-
(0, import_vitest.expect)(persist).toHaveBeenCalledWith({
|
|
29
|
-
dextoApiKey: "dxt_full_key",
|
|
30
|
-
dextoKeyDisplay: "dxt_abc...",
|
|
31
|
-
dextoKeyId: "key-id"
|
|
32
|
-
});
|
|
33
|
-
(0, import_vitest.expect)(persisted).toEqual({
|
|
34
|
-
keyId: "key-id",
|
|
35
|
-
hasDextoApiKey: true
|
|
13
|
+
currentSignIn: async () => "ada@example.com in Acme",
|
|
14
|
+
signIn: hostSignIn,
|
|
15
|
+
signOut: async () => "Logged out."
|
|
36
16
|
});
|
|
17
|
+
(0, import_vitest.expect)(await (0, import_index.currentSignIn)()).toBe("ada@example.com in Acme");
|
|
18
|
+
(0, import_vitest.expect)(await (0, import_index.signIn)({ signal, onNote })).toBe("Signed in as ada@example.com in Acme.");
|
|
19
|
+
(0, import_vitest.expect)(hostSignIn).toHaveBeenCalledWith({ signal, onNote });
|
|
20
|
+
(0, import_vitest.expect)(await (0, import_index.signOut)()).toBe("Logged out.");
|
|
37
21
|
});
|
|
38
|
-
(0, import_vitest.it)("fails fast when
|
|
22
|
+
(0, import_vitest.it)("fails fast when the host provides no sign-in", async () => {
|
|
23
|
+
await (0, import_vitest.expect)((0, import_index.currentSignIn)()).rejects.toThrow(
|
|
24
|
+
"TUI runtime services missing required method: currentSignIn"
|
|
25
|
+
);
|
|
39
26
|
await (0, import_vitest.expect)(
|
|
40
|
-
(0, import_index.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
).rejects.toThrow("TUI runtime services missing required method");
|
|
27
|
+
(0, import_index.signIn)({ signal: new AbortController().signal, onNote: () => void 0 })
|
|
28
|
+
).rejects.toThrow("TUI runtime services missing required method: signIn");
|
|
29
|
+
await (0, import_vitest.expect)((0, import_index.signOut)()).rejects.toThrow(
|
|
30
|
+
"TUI runtime services missing required method: signOut"
|
|
31
|
+
);
|
|
46
32
|
});
|
|
47
33
|
});
|
package/dist/host/index.test.js
CHANGED
|
@@ -1,50 +1,32 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
persistDeviceApiKeyLoginResult,
|
|
5
|
-
setTuiRuntimeServices
|
|
6
|
-
} from "./index.js";
|
|
7
|
-
describe("TUI auth runtime services", () => {
|
|
2
|
+
import { currentSignIn, setTuiRuntimeServices, signIn, signOut } from "./index.js";
|
|
3
|
+
describe("TUI sign-in runtime services", () => {
|
|
8
4
|
afterEach(() => {
|
|
9
5
|
setTuiRuntimeServices({});
|
|
10
6
|
});
|
|
11
|
-
it("
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
dextoKeyDisplay: "dxt_abc...",
|
|
16
|
-
dextoKeyId: "key-id"
|
|
17
|
-
});
|
|
18
|
-
const persist = vi.fn().mockResolvedValue({
|
|
19
|
-
keyId: "key-id",
|
|
20
|
-
hasDextoApiKey: true
|
|
21
|
-
});
|
|
7
|
+
it("signs in, says who, and signs out through the host", async () => {
|
|
8
|
+
const signal = new AbortController().signal;
|
|
9
|
+
const onNote = vi.fn();
|
|
10
|
+
const hostSignIn = vi.fn().mockResolvedValue("Signed in as ada@example.com in Acme.");
|
|
22
11
|
setTuiRuntimeServices({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const loginResult = await performDeviceCodeLogin({
|
|
27
|
-
onPrompt: prompt
|
|
28
|
-
});
|
|
29
|
-
const persisted = await persistDeviceApiKeyLoginResult(loginResult);
|
|
30
|
-
expect(perform).toHaveBeenCalledWith({ onPrompt: prompt });
|
|
31
|
-
expect(persist).toHaveBeenCalledWith({
|
|
32
|
-
dextoApiKey: "dxt_full_key",
|
|
33
|
-
dextoKeyDisplay: "dxt_abc...",
|
|
34
|
-
dextoKeyId: "key-id"
|
|
35
|
-
});
|
|
36
|
-
expect(persisted).toEqual({
|
|
37
|
-
keyId: "key-id",
|
|
38
|
-
hasDextoApiKey: true
|
|
12
|
+
currentSignIn: async () => "ada@example.com in Acme",
|
|
13
|
+
signIn: hostSignIn,
|
|
14
|
+
signOut: async () => "Logged out."
|
|
39
15
|
});
|
|
16
|
+
expect(await currentSignIn()).toBe("ada@example.com in Acme");
|
|
17
|
+
expect(await signIn({ signal, onNote })).toBe("Signed in as ada@example.com in Acme.");
|
|
18
|
+
expect(hostSignIn).toHaveBeenCalledWith({ signal, onNote });
|
|
19
|
+
expect(await signOut()).toBe("Logged out.");
|
|
40
20
|
});
|
|
41
|
-
it("fails fast when
|
|
21
|
+
it("fails fast when the host provides no sign-in", async () => {
|
|
22
|
+
await expect(currentSignIn()).rejects.toThrow(
|
|
23
|
+
"TUI runtime services missing required method: currentSignIn"
|
|
24
|
+
);
|
|
42
25
|
await expect(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
).rejects.toThrow("TUI runtime services missing required method");
|
|
26
|
+
signIn({ signal: new AbortController().signal, onNote: () => void 0 })
|
|
27
|
+
).rejects.toThrow("TUI runtime services missing required method: signIn");
|
|
28
|
+
await expect(signOut()).rejects.toThrow(
|
|
29
|
+
"TUI runtime services missing required method: signOut"
|
|
30
|
+
);
|
|
49
31
|
});
|
|
50
32
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -362,38 +362,11 @@ declare function startInkCliRefactored(agent: TuiAgentBackend, initialSessionId:
|
|
|
362
362
|
interface TuiShutdownHandle {
|
|
363
363
|
stop?: (() => Promise<void>) | undefined;
|
|
364
364
|
}
|
|
365
|
-
interface
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
expiresAt?: number | undefined;
|
|
371
|
-
createdAt: number;
|
|
372
|
-
dextoApiKey?: string | undefined;
|
|
373
|
-
dextoKeyId?: string | undefined;
|
|
374
|
-
dextoApiKeySource?: 'provisioned' | 'user-supplied' | undefined;
|
|
375
|
-
}
|
|
376
|
-
interface TuiDeviceApiKeyLoginResult {
|
|
377
|
-
dextoApiKey: string;
|
|
378
|
-
dextoKeyId: string;
|
|
379
|
-
dextoKeyDisplay: string;
|
|
380
|
-
}
|
|
381
|
-
interface TuiDeviceLoginPrompt {
|
|
382
|
-
userCode: string;
|
|
383
|
-
verificationUrl: string;
|
|
384
|
-
verificationUrlComplete: string | null;
|
|
385
|
-
expiresIn: number;
|
|
386
|
-
}
|
|
387
|
-
type TuiDextoApiKeyProvisionStatusLevel = 'info' | 'success' | 'warning' | 'error';
|
|
388
|
-
interface TuiDextoApiKeyProvisionStatus {
|
|
389
|
-
level: TuiDextoApiKeyProvisionStatusLevel;
|
|
390
|
-
message: string;
|
|
391
|
-
}
|
|
392
|
-
interface TuiPersistedLoginResult {
|
|
393
|
-
email?: string | undefined;
|
|
394
|
-
userId?: string | undefined;
|
|
395
|
-
keyId?: string | undefined;
|
|
396
|
-
hasDextoApiKey: boolean;
|
|
365
|
+
interface TuiSignInOptions {
|
|
366
|
+
/** Aborts the sign-in, such as when the person presses Esc. */
|
|
367
|
+
signal: AbortSignal;
|
|
368
|
+
/** What to show while signing in: the link, or the code to check. */
|
|
369
|
+
onNote: (text: string) => void;
|
|
397
370
|
}
|
|
398
371
|
interface TuiRuntimeServices {
|
|
399
372
|
registerGracefulShutdown?: (getAgent: () => TuiShutdownHandle, options: {
|
|
@@ -408,26 +381,14 @@ interface TuiRuntimeServices {
|
|
|
408
381
|
content: string;
|
|
409
382
|
url?: string | undefined;
|
|
410
383
|
} | null;
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
dextoApiKey: string;
|
|
420
|
-
keyId: string | null;
|
|
421
|
-
} | null>;
|
|
422
|
-
loadAuth?: () => Promise<TuiAuthConfig | null>;
|
|
423
|
-
storeAuth?: (config: TuiAuthConfig) => Promise<void>;
|
|
424
|
-
removeAuth?: () => Promise<void>;
|
|
425
|
-
removeDextoApiKeyFromEnv?: (options?: {
|
|
426
|
-
expectedValue?: string;
|
|
427
|
-
}) => Promise<{
|
|
428
|
-
removed: boolean;
|
|
429
|
-
targetEnvPath: string;
|
|
430
|
-
}>;
|
|
384
|
+
/** Who the current profile acts as, in a few words, or null when signed out. */
|
|
385
|
+
currentSignIn?: () => Promise<string | null>;
|
|
386
|
+
/** Signs the current profile in to Dexto, resolving with what to say once signed in. */
|
|
387
|
+
signIn?: (options: TuiSignInOptions) => Promise<string>;
|
|
388
|
+
/** Ends the current profile's sign-in, resolving with what to say. */
|
|
389
|
+
signOut?: () => Promise<string>;
|
|
390
|
+
/** The organization's Dexto credit balance in USD; null when signed out. */
|
|
391
|
+
dextoCreditBalance?: () => Promise<number | null>;
|
|
431
392
|
isUsingDextoCredits?: () => Promise<boolean>;
|
|
432
393
|
canUseDextoProvider?: () => Promise<boolean>;
|
|
433
394
|
buildDextoBillingUrl?: (options: {
|
|
@@ -81,9 +81,9 @@ function extractInsufficientCreditsBalance(error) {
|
|
|
81
81
|
}
|
|
82
82
|
function buildInsufficientCreditsContent(balance) {
|
|
83
83
|
if (balance === null) {
|
|
84
|
-
return "Out of Dexto
|
|
84
|
+
return "Out of Dexto credits.\nUse the billing prompt to top up and retry your request.";
|
|
85
85
|
}
|
|
86
|
-
return `Out of Dexto
|
|
86
|
+
return `Out of Dexto credits. Current balance: $${balance.toFixed(2)}.
|
|
87
87
|
Use the billing prompt to top up and retry your request.`;
|
|
88
88
|
}
|
|
89
89
|
function hasMeaningfulTokenUsageForAnalytics(tokenUsage, estimatedCost) {
|
|
@@ -48,9 +48,9 @@ function extractInsufficientCreditsBalance(error) {
|
|
|
48
48
|
}
|
|
49
49
|
function buildInsufficientCreditsContent(balance) {
|
|
50
50
|
if (balance === null) {
|
|
51
|
-
return "Out of Dexto
|
|
51
|
+
return "Out of Dexto credits.\nUse the billing prompt to top up and retry your request.";
|
|
52
52
|
}
|
|
53
|
-
return `Out of Dexto
|
|
53
|
+
return `Out of Dexto credits. Current balance: $${balance.toFixed(2)}.
|
|
54
54
|
Use the billing prompt to top up and retry your request.`;
|
|
55
55
|
}
|
|
56
56
|
function hasMeaningfulTokenUsageForAnalytics(tokenUsage, estimatedCost) {
|
|
@@ -504,7 +504,7 @@ function createSetters({
|
|
|
504
504
|
(0, import_vitest.expect)(ui.insufficientCredits).toEqual({ balanceUsd: 0 });
|
|
505
505
|
(0, import_vitest.expect)(ui.isProcessing).toBe(false);
|
|
506
506
|
const latestMessage = getMessages().at(-1);
|
|
507
|
-
(0, import_vitest.expect)(latestMessage?.content).toContain("Out of Dexto
|
|
507
|
+
(0, import_vitest.expect)(latestMessage?.content).toContain("Out of Dexto credits");
|
|
508
508
|
(0, import_vitest.expect)(latestMessage?.content).not.toContain("Error:");
|
|
509
509
|
});
|
|
510
510
|
(0, import_vitest.it)("captures analytics cost fields for priced llm responses", async () => {
|
|
@@ -503,7 +503,7 @@ describe("processStream (reasoning)", () => {
|
|
|
503
503
|
expect(ui.insufficientCredits).toEqual({ balanceUsd: 0 });
|
|
504
504
|
expect(ui.isProcessing).toBe(false);
|
|
505
505
|
const latestMessage = getMessages().at(-1);
|
|
506
|
-
expect(latestMessage?.content).toContain("Out of Dexto
|
|
506
|
+
expect(latestMessage?.content).toContain("Out of Dexto credits");
|
|
507
507
|
expect(latestMessage?.content).not.toContain("Error:");
|
|
508
508
|
});
|
|
509
509
|
it("captures analytics cost fields for priced llm responses", async () => {
|
|
@@ -39,7 +39,7 @@ const LLM_PROVIDER_DISPLAY_NAMES = {
|
|
|
39
39
|
bedrock: "Bedrock",
|
|
40
40
|
local: "Local",
|
|
41
41
|
ollama: "Ollama",
|
|
42
|
-
"dexto-nova": "Dexto
|
|
42
|
+
"dexto-nova": "Dexto"
|
|
43
43
|
};
|
|
44
44
|
function getLLMProviderDisplayName(provider, baseURL) {
|
|
45
45
|
if (provider === "openai-compatible") {
|
|
@@ -16,7 +16,7 @@ const LLM_PROVIDER_DISPLAY_NAMES = {
|
|
|
16
16
|
bedrock: "Bedrock",
|
|
17
17
|
local: "Local",
|
|
18
18
|
ollama: "Ollama",
|
|
19
|
-
"dexto-nova": "Dexto
|
|
19
|
+
"dexto-nova": "Dexto"
|
|
20
20
|
};
|
|
21
21
|
function getLLMProviderDisplayName(provider, baseURL) {
|
|
22
22
|
if (provider === "openai-compatible") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/tui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0-beta.0",
|
|
4
4
|
"description": "Interactive terminal UI for Dexto CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"string-width": "^8.1.0",
|
|
29
29
|
"strip-ansi": "^7.1.2",
|
|
30
30
|
"wrap-ansi": "^9.0.2",
|
|
31
|
-
"@dexto/
|
|
32
|
-
"@dexto/
|
|
33
|
-
"@dexto/
|
|
34
|
-
"@dexto/
|
|
31
|
+
"@dexto/core": "1.14.4",
|
|
32
|
+
"@dexto/llm": "1.14.4",
|
|
33
|
+
"@dexto/registry": "1.14.4",
|
|
34
|
+
"@dexto/agent-management": "1.15.0-beta.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/react": "^19.0.0",
|