@dexto/tui 1.7.1 → 1.8.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/agent-backend.cjs +16 -2
- package/dist/agent-backend.d.ts +5 -2
- package/dist/agent-backend.d.ts.map +1 -1
- package/dist/agent-backend.js +15 -2
- package/dist/agent-backend.test.cjs +28 -2
- package/dist/agent-backend.test.js +28 -2
- package/dist/components/ApprovalPrompt.cjs +6 -5
- package/dist/components/ApprovalPrompt.d.ts +1 -1
- package/dist/components/ApprovalPrompt.d.ts.map +1 -1
- package/dist/components/ApprovalPrompt.js +6 -5
- package/dist/components/TextBufferInput.cjs +14 -1
- package/dist/components/TextBufferInput.d.ts +5 -1
- package/dist/components/TextBufferInput.d.ts.map +1 -1
- package/dist/components/TextBufferInput.js +14 -1
- package/dist/components/chat/QueuedMessagesDisplay.cjs +17 -8
- package/dist/components/chat/QueuedMessagesDisplay.d.ts +7 -1
- package/dist/components/chat/QueuedMessagesDisplay.d.ts.map +1 -1
- package/dist/components/chat/QueuedMessagesDisplay.js +16 -8
- package/dist/components/input/InputArea.cjs +4 -0
- package/dist/components/input/InputArea.d.ts +5 -1
- package/dist/components/input/InputArea.d.ts.map +1 -1
- package/dist/components/input/InputArea.js +4 -0
- package/dist/components/modes/AlternateBufferCLI.cjs +20 -1
- package/dist/components/modes/AlternateBufferCLI.d.ts.map +1 -1
- package/dist/components/modes/AlternateBufferCLI.js +21 -2
- package/dist/components/modes/StaticCLI.cjs +20 -1
- package/dist/components/modes/StaticCLI.d.ts.map +1 -1
- package/dist/components/modes/StaticCLI.js +21 -2
- package/dist/components/overlays/LoginOverlay.cjs +2 -10
- package/dist/components/overlays/LoginOverlay.d.ts.map +1 -1
- package/dist/components/overlays/LoginOverlay.js +3 -11
- package/dist/containers/InputContainer.cjs +119 -18
- package/dist/containers/InputContainer.d.ts +6 -2
- package/dist/containers/InputContainer.d.ts.map +1 -1
- package/dist/containers/InputContainer.js +119 -18
- package/dist/hooks/useAgentEvents.cjs +27 -5
- package/dist/hooks/useAgentEvents.d.ts +3 -2
- package/dist/hooks/useAgentEvents.d.ts.map +1 -1
- package/dist/hooks/useAgentEvents.js +27 -5
- package/dist/hooks/useCLIState.cjs +10 -4
- package/dist/hooks/useCLIState.d.ts +2 -0
- package/dist/hooks/useCLIState.d.ts.map +1 -1
- package/dist/hooks/useCLIState.js +10 -4
- package/dist/hooks/useInputOrchestrator.cjs +15 -14
- package/dist/hooks/useInputOrchestrator.d.ts +6 -6
- package/dist/hooks/useInputOrchestrator.d.ts.map +1 -1
- package/dist/hooks/useInputOrchestrator.js +15 -14
- package/dist/host/index.cjs +6 -6
- package/dist/host/index.d.ts +8 -17
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +5 -5
- package/dist/host/index.test.cjs +47 -0
- package/dist/host/index.test.d.ts +2 -0
- package/dist/host/index.test.d.ts.map +1 -0
- package/dist/host/index.test.js +50 -0
- package/dist/index.d.cts +10 -15
- package/dist/interactive-commands/command-parser.cjs +1 -0
- package/dist/interactive-commands/command-parser.d.ts.map +1 -1
- package/dist/interactive-commands/command-parser.js +1 -0
- package/dist/interactive-commands/commands.cjs +3 -0
- package/dist/interactive-commands/commands.d.ts.map +1 -1
- package/dist/interactive-commands/commands.js +3 -0
- package/dist/interactive-commands/commands.test.cjs +42 -0
- package/dist/interactive-commands/commands.test.js +42 -0
- package/dist/interactive-commands/prompt-commands.cjs +4 -66
- package/dist/interactive-commands/prompt-commands.d.ts +1 -2
- package/dist/interactive-commands/prompt-commands.d.ts.map +1 -1
- package/dist/interactive-commands/prompt-commands.js +4 -66
- package/dist/interactive-commands/skill-commands.cjs +73 -0
- package/dist/interactive-commands/skill-commands.d.ts +9 -0
- package/dist/interactive-commands/skill-commands.d.ts.map +1 -0
- package/dist/interactive-commands/skill-commands.js +49 -0
- package/dist/services/processStream.cjs +23 -4
- package/dist/services/processStream.d.ts +3 -1
- package/dist/services/processStream.d.ts.map +1 -1
- package/dist/services/processStream.js +23 -4
- package/dist/services/processStream.test.cjs +52 -2
- package/dist/services/processStream.test.js +52 -2
- package/dist/state/initialState.cjs +2 -1
- package/dist/state/initialState.d.ts.map +1 -1
- package/dist/state/initialState.js +2 -1
- package/dist/state/reducer.cjs +10 -5
- package/dist/state/reducer.d.ts.map +1 -1
- package/dist/state/reducer.js +10 -5
- package/dist/state/types.d.ts +2 -0
- package/dist/state/types.d.ts.map +1 -1
- package/dist/utils/messageFormatting.cjs +0 -23
- package/dist/utils/messageFormatting.d.ts +0 -13
- package/dist/utils/messageFormatting.d.ts.map +1 -1
- package/dist/utils/messageFormatting.js +0 -21
- package/dist/utils/queuedComposerContent.cjs +148 -0
- package/dist/utils/queuedComposerContent.d.ts +17 -0
- package/dist/utils/queuedComposerContent.d.ts.map +1 -0
- package/dist/utils/queuedComposerContent.js +123 -0
- package/dist/utils/queuedComposerContent.test.cjs +176 -0
- package/dist/utils/queuedComposerContent.test.d.ts +2 -0
- package/dist/utils/queuedComposerContent.test.d.ts.map +1 -0
- package/dist/utils/queuedComposerContent.test.js +175 -0
- package/package.json +4 -4
package/dist/host/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ __export(host_exports, {
|
|
|
31
31
|
loadAuth: () => loadAuth,
|
|
32
32
|
openDextoBillingPage: () => openDextoBillingPage,
|
|
33
33
|
performDeviceCodeLogin: () => performDeviceCodeLogin,
|
|
34
|
-
|
|
34
|
+
persistDeviceApiKeyLoginResult: () => persistDeviceApiKeyLoginResult,
|
|
35
35
|
registerGracefulShutdown: () => registerGracefulShutdown,
|
|
36
36
|
removeAuth: () => removeAuth,
|
|
37
37
|
removeDextoApiKeyFromEnv: () => removeDextoApiKeyFromEnv,
|
|
@@ -75,11 +75,11 @@ async function performDeviceCodeLogin(options) {
|
|
|
75
75
|
}
|
|
76
76
|
return runtimeServices.performDeviceCodeLogin(options);
|
|
77
77
|
}
|
|
78
|
-
async function
|
|
79
|
-
if (!runtimeServices.
|
|
80
|
-
throw missingHostMethod("
|
|
78
|
+
async function persistDeviceApiKeyLoginResult(result) {
|
|
79
|
+
if (!runtimeServices.persistDeviceApiKeyLoginResult) {
|
|
80
|
+
throw missingHostMethod("persistDeviceApiKeyLoginResult");
|
|
81
81
|
}
|
|
82
|
-
return runtimeServices.
|
|
82
|
+
return runtimeServices.persistDeviceApiKeyLoginResult(result);
|
|
83
83
|
}
|
|
84
84
|
async function ensureDextoApiKeyForAuthToken(authToken, options) {
|
|
85
85
|
if (!runtimeServices.ensureDextoApiKeyForAuthToken) {
|
|
@@ -150,7 +150,7 @@ async function openDextoBillingPage(options) {
|
|
|
150
150
|
loadAuth,
|
|
151
151
|
openDextoBillingPage,
|
|
152
152
|
performDeviceCodeLogin,
|
|
153
|
-
|
|
153
|
+
persistDeviceApiKeyLoginResult,
|
|
154
154
|
registerGracefulShutdown,
|
|
155
155
|
removeAuth,
|
|
156
156
|
removeDextoApiKeyFromEnv,
|
package/dist/host/index.d.ts
CHANGED
|
@@ -14,15 +14,10 @@ export interface TuiAuthConfig {
|
|
|
14
14
|
dextoKeyId?: string | undefined;
|
|
15
15
|
dextoApiKeySource?: 'provisioned' | 'user-supplied' | undefined;
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
user?: {
|
|
22
|
-
id: string;
|
|
23
|
-
email: string;
|
|
24
|
-
name?: string | undefined;
|
|
25
|
-
} | undefined;
|
|
17
|
+
export interface TuiDeviceApiKeyLoginResult {
|
|
18
|
+
dextoApiKey: string;
|
|
19
|
+
dextoKeyId: string;
|
|
20
|
+
dextoKeyDisplay: string;
|
|
26
21
|
}
|
|
27
22
|
export interface TuiDeviceLoginPrompt {
|
|
28
23
|
userCode: string;
|
|
@@ -57,10 +52,8 @@ export interface TuiRuntimeServices {
|
|
|
57
52
|
performDeviceCodeLogin?: (options?: {
|
|
58
53
|
signal?: AbortSignal | undefined;
|
|
59
54
|
onPrompt?: ((prompt: TuiDeviceLoginPrompt) => void) | undefined;
|
|
60
|
-
}) => Promise<
|
|
61
|
-
|
|
62
|
-
onProvisionStatus?: ((status: TuiDextoApiKeyProvisionStatus) => void) | undefined;
|
|
63
|
-
}) => Promise<TuiPersistedLoginResult>;
|
|
55
|
+
}) => Promise<TuiDeviceApiKeyLoginResult>;
|
|
56
|
+
persistDeviceApiKeyLoginResult?: (result: TuiDeviceApiKeyLoginResult) => Promise<TuiPersistedLoginResult>;
|
|
64
57
|
ensureDextoApiKeyForAuthToken?: (authToken: string, options?: {
|
|
65
58
|
onStatus?: ((status: TuiDextoApiKeyProvisionStatus) => void) | undefined;
|
|
66
59
|
}) => Promise<{
|
|
@@ -102,10 +95,8 @@ export declare function getProviderInstructions(provider: LLMProvider): {
|
|
|
102
95
|
export declare function performDeviceCodeLogin(options?: {
|
|
103
96
|
signal?: AbortSignal | undefined;
|
|
104
97
|
onPrompt?: ((prompt: TuiDeviceLoginPrompt) => void) | undefined;
|
|
105
|
-
}): Promise<
|
|
106
|
-
export declare function
|
|
107
|
-
onProvisionStatus?: ((status: TuiDextoApiKeyProvisionStatus) => void) | undefined;
|
|
108
|
-
}): Promise<TuiPersistedLoginResult>;
|
|
98
|
+
}): Promise<TuiDeviceApiKeyLoginResult>;
|
|
99
|
+
export declare function persistDeviceApiKeyLoginResult(result: TuiDeviceApiKeyLoginResult): Promise<TuiPersistedLoginResult>;
|
|
109
100
|
export declare function ensureDextoApiKeyForAuthToken(authToken: string, options?: {
|
|
110
101
|
onStatus?: ((status: TuiDextoApiKeyProvisionStatus) => void) | undefined;
|
|
111
102
|
}): Promise<{
|
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,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,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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
|
@@ -34,11 +34,11 @@ async function performDeviceCodeLogin(options) {
|
|
|
34
34
|
}
|
|
35
35
|
return runtimeServices.performDeviceCodeLogin(options);
|
|
36
36
|
}
|
|
37
|
-
async function
|
|
38
|
-
if (!runtimeServices.
|
|
39
|
-
throw missingHostMethod("
|
|
37
|
+
async function persistDeviceApiKeyLoginResult(result) {
|
|
38
|
+
if (!runtimeServices.persistDeviceApiKeyLoginResult) {
|
|
39
|
+
throw missingHostMethod("persistDeviceApiKeyLoginResult");
|
|
40
40
|
}
|
|
41
|
-
return runtimeServices.
|
|
41
|
+
return runtimeServices.persistDeviceApiKeyLoginResult(result);
|
|
42
42
|
}
|
|
43
43
|
async function ensureDextoApiKeyForAuthToken(authToken, options) {
|
|
44
44
|
if (!runtimeServices.ensureDextoApiKeyForAuthToken) {
|
|
@@ -108,7 +108,7 @@ export {
|
|
|
108
108
|
loadAuth,
|
|
109
109
|
openDextoBillingPage,
|
|
110
110
|
performDeviceCodeLogin,
|
|
111
|
-
|
|
111
|
+
persistDeviceApiKeyLoginResult,
|
|
112
112
|
registerGracefulShutdown,
|
|
113
113
|
removeAuth,
|
|
114
114
|
removeDextoApiKeyFromEnv,
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_vitest = require("vitest");
|
|
3
|
+
var import_index = require("./index.js");
|
|
4
|
+
(0, import_vitest.describe)("TUI auth runtime services", () => {
|
|
5
|
+
(0, import_vitest.afterEach)(() => {
|
|
6
|
+
(0, import_index.setTuiRuntimeServices)({});
|
|
7
|
+
});
|
|
8
|
+
(0, import_vitest.it)("uses host-provided API-key device login and persistence services", async () => {
|
|
9
|
+
const prompt = import_vitest.vi.fn();
|
|
10
|
+
const perform = import_vitest.vi.fn().mockResolvedValue({
|
|
11
|
+
dextoApiKey: "dxt_full_key",
|
|
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
|
+
});
|
|
19
|
+
(0, import_index.setTuiRuntimeServices)({
|
|
20
|
+
performDeviceCodeLogin: perform,
|
|
21
|
+
persistDeviceApiKeyLoginResult: persist
|
|
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
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
(0, import_vitest.it)("fails fast when API-key device login persistence is not provided by the host", async () => {
|
|
39
|
+
await (0, import_vitest.expect)(
|
|
40
|
+
(0, import_index.persistDeviceApiKeyLoginResult)({
|
|
41
|
+
dextoApiKey: "dxt_full_key",
|
|
42
|
+
dextoKeyDisplay: "dxt_abc...",
|
|
43
|
+
dextoKeyId: "key-id"
|
|
44
|
+
})
|
|
45
|
+
).rejects.toThrow("TUI runtime services missing required method");
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/host/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
performDeviceCodeLogin,
|
|
4
|
+
persistDeviceApiKeyLoginResult,
|
|
5
|
+
setTuiRuntimeServices
|
|
6
|
+
} from "./index.js";
|
|
7
|
+
describe("TUI auth runtime services", () => {
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
setTuiRuntimeServices({});
|
|
10
|
+
});
|
|
11
|
+
it("uses host-provided API-key device login and persistence services", async () => {
|
|
12
|
+
const prompt = vi.fn();
|
|
13
|
+
const perform = vi.fn().mockResolvedValue({
|
|
14
|
+
dextoApiKey: "dxt_full_key",
|
|
15
|
+
dextoKeyDisplay: "dxt_abc...",
|
|
16
|
+
dextoKeyId: "key-id"
|
|
17
|
+
});
|
|
18
|
+
const persist = vi.fn().mockResolvedValue({
|
|
19
|
+
keyId: "key-id",
|
|
20
|
+
hasDextoApiKey: true
|
|
21
|
+
});
|
|
22
|
+
setTuiRuntimeServices({
|
|
23
|
+
performDeviceCodeLogin: perform,
|
|
24
|
+
persistDeviceApiKeyLoginResult: persist
|
|
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
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
it("fails fast when API-key device login persistence is not provided by the host", async () => {
|
|
42
|
+
await expect(
|
|
43
|
+
persistDeviceApiKeyLoginResult({
|
|
44
|
+
dextoApiKey: "dxt_full_key",
|
|
45
|
+
dextoKeyDisplay: "dxt_abc...",
|
|
46
|
+
dextoKeyId: "key-id"
|
|
47
|
+
})
|
|
48
|
+
).rejects.toThrow("TUI runtime services missing required method");
|
|
49
|
+
});
|
|
50
|
+
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { DextoAgent, AgentEventMap, EventListener, SessionMetadata, LLMProvider } from '@dexto/core';
|
|
2
|
+
import { DextoAgent, AgentEventMap, EventListener, SessionMetadata, SkillManager, LLMProvider } from '@dexto/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Core state types for Ink CLI
|
|
@@ -196,6 +196,7 @@ interface CommandDefinition {
|
|
|
196
196
|
interface TuiAgentCapabilities {
|
|
197
197
|
supportedCommands?: readonly string[];
|
|
198
198
|
prompts?: boolean;
|
|
199
|
+
skills?: boolean;
|
|
199
200
|
resources?: boolean;
|
|
200
201
|
attachments?: boolean;
|
|
201
202
|
reasoningCycle?: boolean;
|
|
@@ -226,7 +227,7 @@ interface TuiEffectiveConfig {
|
|
|
226
227
|
prompts?: unknown[] | undefined;
|
|
227
228
|
[key: string]: unknown;
|
|
228
229
|
}
|
|
229
|
-
interface TuiAgentBackend extends Pick<DextoAgent, 'stream' | 'stop' | 'run' | 'listSessions' | 'getSessionMetadata' | 'getSessionHistory' | 'getSessionTitle' | 'setSessionTitle' | 'generateSessionTitle' | 'forkSession' | 'getCurrentLLMConfig' | 'hasSessionLLMOverride' | 'switchLLM' | 'getSupportedProviders' | 'getSupportedModels' | 'getContextStats' | 'clearContext' | 'compactContext' | '
|
|
230
|
+
interface TuiAgentBackend extends Pick<DextoAgent, 'stream' | 'stop' | 'run' | 'listSessions' | 'getSessionMetadata' | 'getSessionHistory' | 'getSessionTitle' | 'setSessionTitle' | 'generateSessionTitle' | 'forkSession' | 'getCurrentLLMConfig' | 'hasSessionLLMOverride' | 'switchLLM' | 'getSupportedProviders' | 'getSupportedModels' | 'getContextStats' | 'clearContext' | 'compactContext' | 'steer' | 'followUp' | 'getSteerMessages' | 'getFollowUpMessages' | 'removeSteerMessage' | 'removeFollowUpMessage' | 'clearSteerQueue' | 'clearFollowUpQueue' | 'cancel' | 'searchMessages' | 'listPrompts' | 'refreshPrompts' | 'resolvePrompt' | 'getSystemPrompt' | 'loadToolkits' | 'listResources' | 'setLogLevel' | 'getAllTools' | 'getEnabledTools' | 'getAllMcpTools' | 'setGlobalDisabledTools' | 'setSessionDisabledTools' | 'setSessionAutoApproveTools' | 'getSessionAutoApproveTools' | 'getMcpServersWithStatus' | 'addMcpServer' | 'enableMcpServer' | 'disableMcpServer' | 'removeMcpServer' | 'restartMcpServer' | 'getMcpClients' | 'getMcpFailedConnections'> {
|
|
230
231
|
createSession: (sessionId?: string) => Promise<{
|
|
231
232
|
id: string;
|
|
232
233
|
logger: Pick<RootLogger, 'getLevel' | 'getLogFilePath'>;
|
|
@@ -260,6 +261,7 @@ interface TuiAgentBackend extends Pick<DextoAgent, 'stream' | 'stop' | 'run' | '
|
|
|
260
261
|
getHookNames: () => string[];
|
|
261
262
|
};
|
|
262
263
|
};
|
|
264
|
+
skillManager?: SkillManager | undefined;
|
|
263
265
|
capabilities?: TuiAgentCapabilities;
|
|
264
266
|
}
|
|
265
267
|
declare function getTuiCapabilities(agent: TuiAgentBackend): TuiAgentCapabilities;
|
|
@@ -368,15 +370,10 @@ interface TuiAuthConfig {
|
|
|
368
370
|
dextoKeyId?: string | undefined;
|
|
369
371
|
dextoApiKeySource?: 'provisioned' | 'user-supplied' | undefined;
|
|
370
372
|
}
|
|
371
|
-
interface
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
user?: {
|
|
376
|
-
id: string;
|
|
377
|
-
email: string;
|
|
378
|
-
name?: string | undefined;
|
|
379
|
-
} | undefined;
|
|
373
|
+
interface TuiDeviceApiKeyLoginResult {
|
|
374
|
+
dextoApiKey: string;
|
|
375
|
+
dextoKeyId: string;
|
|
376
|
+
dextoKeyDisplay: string;
|
|
380
377
|
}
|
|
381
378
|
interface TuiDeviceLoginPrompt {
|
|
382
379
|
userCode: string;
|
|
@@ -411,10 +408,8 @@ interface TuiRuntimeServices {
|
|
|
411
408
|
performDeviceCodeLogin?: (options?: {
|
|
412
409
|
signal?: AbortSignal | undefined;
|
|
413
410
|
onPrompt?: ((prompt: TuiDeviceLoginPrompt) => void) | undefined;
|
|
414
|
-
}) => Promise<
|
|
415
|
-
|
|
416
|
-
onProvisionStatus?: ((status: TuiDextoApiKeyProvisionStatus) => void) | undefined;
|
|
417
|
-
}) => Promise<TuiPersistedLoginResult>;
|
|
411
|
+
}) => Promise<TuiDeviceApiKeyLoginResult>;
|
|
412
|
+
persistDeviceApiKeyLoginResult?: (result: TuiDeviceApiKeyLoginResult) => Promise<TuiPersistedLoginResult>;
|
|
418
413
|
ensureDextoApiKeyForAuthToken?: (authToken: string, options?: {
|
|
419
414
|
onStatus?: ((status: TuiDextoApiKeyProvisionStatus) => void) | undefined;
|
|
420
415
|
}) => Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-parser.d.ts","sourceRoot":"","sources":["../../src/interactive-commands/command-parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,GAAG,iBAAiB,CAAC;AAEvF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,uDAAuD;IACvD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,yEAAyE;IACzE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAClC,OAAO,EAAE,CACL,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,cAAc,KAClB,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,oBAAoB,CAAS,CAAC;AA4ClF;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAiCvD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAoB9F;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,iBAAiB,EAAE,QAAQ,GAAE,OAAe,GAAG,MAAM,CAmB3F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"command-parser.d.ts","sourceRoot":"","sources":["../../src/interactive-commands/command-parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,KAAK,EAAE,eA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ED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAyDtE"}
|
|
@@ -45,6 +45,7 @@ var import_plugin = require("./plugin/index.js");
|
|
|
45
45
|
var import_system = require("./system/index.js");
|
|
46
46
|
var import_tool_commands = require("./tool-commands.js");
|
|
47
47
|
var import_prompt_commands = require("./prompt-commands.js");
|
|
48
|
+
var import_skill_commands = require("./skill-commands.js");
|
|
48
49
|
var import_documentation_commands = require("./documentation-commands.js");
|
|
49
50
|
var import_auth = require("./auth/index.js");
|
|
50
51
|
const CLI_COMMANDS = [];
|
|
@@ -75,6 +76,8 @@ const baseCommands = [
|
|
|
75
76
|
...import_tool_commands.toolCommands,
|
|
76
77
|
// Prompt management commands
|
|
77
78
|
...import_prompt_commands.promptCommands,
|
|
79
|
+
// Skill management commands
|
|
80
|
+
...import_skill_commands.skillCommands,
|
|
78
81
|
// System commands
|
|
79
82
|
...import_system.systemCommands,
|
|
80
83
|
// Documentation commands
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/interactive-commands/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAIH,KAAK,eAAe,EACvB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/interactive-commands/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAIH,KAAK,eAAe,EACvB,MAAM,qBAAqB,CAAC;AAgB7B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,EAAE,iBAAiB,EAAO,CAAC;AAiDpD;;;;;GAKG;AACH,wBAAsB,cAAc,CAChC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,eAAe,EACtB,SAAS,CAAC,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,GAC/B,OAAO,CAAC,oBAAoB,CAAC,CA+D/B;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,iBAAiB,EAAE,CAEpD;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,GAAG,iBAAiB,EAAE,CAEhF"}
|
|
@@ -13,6 +13,7 @@ import { pluginCommands } from "./plugin/index.js";
|
|
|
13
13
|
import { systemCommands } from "./system/index.js";
|
|
14
14
|
import { toolCommands } from "./tool-commands.js";
|
|
15
15
|
import { promptCommands } from "./prompt-commands.js";
|
|
16
|
+
import { skillCommands } from "./skill-commands.js";
|
|
16
17
|
import { documentationCommands } from "./documentation-commands.js";
|
|
17
18
|
import { loginCommand, logoutCommand } from "./auth/index.js";
|
|
18
19
|
const CLI_COMMANDS = [];
|
|
@@ -43,6 +44,8 @@ const baseCommands = [
|
|
|
43
44
|
...toolCommands,
|
|
44
45
|
// Prompt management commands
|
|
45
46
|
...promptCommands,
|
|
47
|
+
// Skill management commands
|
|
48
|
+
...skillCommands,
|
|
46
49
|
// System commands
|
|
47
50
|
...systemCommands,
|
|
48
51
|
// Documentation commands
|
|
@@ -2,8 +2,17 @@
|
|
|
2
2
|
var import_vitest = require("vitest");
|
|
3
3
|
var import_commands = require("./commands.js");
|
|
4
4
|
function createAgent(capabilities) {
|
|
5
|
+
const skillManager = {
|
|
6
|
+
list: import_vitest.vi.fn().mockResolvedValue([]),
|
|
7
|
+
get: import_vitest.vi.fn().mockResolvedValue(null),
|
|
8
|
+
readFile: import_vitest.vi.fn(),
|
|
9
|
+
invoke: import_vitest.vi.fn(),
|
|
10
|
+
refresh: import_vitest.vi.fn()
|
|
11
|
+
};
|
|
5
12
|
return {
|
|
6
13
|
capabilities,
|
|
14
|
+
listPrompts: import_vitest.vi.fn(),
|
|
15
|
+
skillManager,
|
|
7
16
|
logger: {
|
|
8
17
|
debug: import_vitest.vi.fn(),
|
|
9
18
|
info: import_vitest.vi.fn(),
|
|
@@ -25,4 +34,37 @@ function createAgent(capabilities) {
|
|
|
25
34
|
const result = await (0, import_commands.executeCommand)("prompts", [], agent);
|
|
26
35
|
(0, import_vitest.expect)(result).toBe("\u26A0\uFE0F Command /prompts is not available for this chat target.");
|
|
27
36
|
});
|
|
37
|
+
(0, import_vitest.it)("lists skills through SkillManager when prompt commands are disabled", async () => {
|
|
38
|
+
const agent = createAgent({ prompts: false });
|
|
39
|
+
const skillManager = agent.skillManager;
|
|
40
|
+
if (!skillManager) throw new Error("Expected test agent to have skills");
|
|
41
|
+
import_vitest.vi.mocked(skillManager.list).mockResolvedValue([
|
|
42
|
+
{
|
|
43
|
+
id: "review",
|
|
44
|
+
displayName: "Code Review",
|
|
45
|
+
description: "Review code changes"
|
|
46
|
+
}
|
|
47
|
+
]);
|
|
48
|
+
const result = await (0, import_commands.executeCommand)("skills", [], agent);
|
|
49
|
+
(0, import_vitest.expect)(skillManager.list).toHaveBeenCalled();
|
|
50
|
+
(0, import_vitest.expect)(agent.listPrompts).not.toHaveBeenCalled();
|
|
51
|
+
(0, import_vitest.expect)(result).toContain("Available Skills");
|
|
52
|
+
(0, import_vitest.expect)(result).toContain("Code Review");
|
|
53
|
+
});
|
|
54
|
+
(0, import_vitest.it)("reads one skill through SkillManager", async () => {
|
|
55
|
+
const agent = createAgent();
|
|
56
|
+
const skillManager = agent.skillManager;
|
|
57
|
+
if (!skillManager) throw new Error("Expected test agent to have skills");
|
|
58
|
+
import_vitest.vi.mocked(skillManager.get).mockResolvedValue({
|
|
59
|
+
id: "review",
|
|
60
|
+
displayName: "Code Review",
|
|
61
|
+
description: "Review code changes",
|
|
62
|
+
instructions: "Check tests and edge cases."
|
|
63
|
+
});
|
|
64
|
+
const result = await (0, import_commands.executeCommand)("skills", ["review"], agent);
|
|
65
|
+
(0, import_vitest.expect)(skillManager.get).toHaveBeenCalledWith("review");
|
|
66
|
+
(0, import_vitest.expect)(agent.listPrompts).not.toHaveBeenCalled();
|
|
67
|
+
(0, import_vitest.expect)(result).toContain("Code Review");
|
|
68
|
+
(0, import_vitest.expect)(result).toContain("Check tests and edge cases.");
|
|
69
|
+
});
|
|
28
70
|
});
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { executeCommand } from "./commands.js";
|
|
3
3
|
function createAgent(capabilities) {
|
|
4
|
+
const skillManager = {
|
|
5
|
+
list: vi.fn().mockResolvedValue([]),
|
|
6
|
+
get: vi.fn().mockResolvedValue(null),
|
|
7
|
+
readFile: vi.fn(),
|
|
8
|
+
invoke: vi.fn(),
|
|
9
|
+
refresh: vi.fn()
|
|
10
|
+
};
|
|
4
11
|
return {
|
|
5
12
|
capabilities,
|
|
13
|
+
listPrompts: vi.fn(),
|
|
14
|
+
skillManager,
|
|
6
15
|
logger: {
|
|
7
16
|
debug: vi.fn(),
|
|
8
17
|
info: vi.fn(),
|
|
@@ -24,4 +33,37 @@ describe("executeCommand", () => {
|
|
|
24
33
|
const result = await executeCommand("prompts", [], agent);
|
|
25
34
|
expect(result).toBe("\u26A0\uFE0F Command /prompts is not available for this chat target.");
|
|
26
35
|
});
|
|
36
|
+
it("lists skills through SkillManager when prompt commands are disabled", async () => {
|
|
37
|
+
const agent = createAgent({ prompts: false });
|
|
38
|
+
const skillManager = agent.skillManager;
|
|
39
|
+
if (!skillManager) throw new Error("Expected test agent to have skills");
|
|
40
|
+
vi.mocked(skillManager.list).mockResolvedValue([
|
|
41
|
+
{
|
|
42
|
+
id: "review",
|
|
43
|
+
displayName: "Code Review",
|
|
44
|
+
description: "Review code changes"
|
|
45
|
+
}
|
|
46
|
+
]);
|
|
47
|
+
const result = await executeCommand("skills", [], agent);
|
|
48
|
+
expect(skillManager.list).toHaveBeenCalled();
|
|
49
|
+
expect(agent.listPrompts).not.toHaveBeenCalled();
|
|
50
|
+
expect(result).toContain("Available Skills");
|
|
51
|
+
expect(result).toContain("Code Review");
|
|
52
|
+
});
|
|
53
|
+
it("reads one skill through SkillManager", async () => {
|
|
54
|
+
const agent = createAgent();
|
|
55
|
+
const skillManager = agent.skillManager;
|
|
56
|
+
if (!skillManager) throw new Error("Expected test agent to have skills");
|
|
57
|
+
vi.mocked(skillManager.get).mockResolvedValue({
|
|
58
|
+
id: "review",
|
|
59
|
+
displayName: "Code Review",
|
|
60
|
+
description: "Review code changes",
|
|
61
|
+
instructions: "Check tests and edge cases."
|
|
62
|
+
});
|
|
63
|
+
const result = await executeCommand("skills", ["review"], agent);
|
|
64
|
+
expect(skillManager.get).toHaveBeenCalledWith("review");
|
|
65
|
+
expect(agent.listPrompts).not.toHaveBeenCalled();
|
|
66
|
+
expect(result).toContain("Code Review");
|
|
67
|
+
expect(result).toContain("Check tests and edge cases.");
|
|
68
|
+
});
|
|
27
69
|
});
|
|
@@ -134,7 +134,7 @@ function createPromptCommand(promptInfo) {
|
|
|
134
134
|
description: promptInfo.description || `Execute ${baseName} prompt`,
|
|
135
135
|
usage: `/${commandName} [context]`,
|
|
136
136
|
category: "Dynamic Prompts",
|
|
137
|
-
handler: async (args, agent,
|
|
137
|
+
handler: async (args, agent, _ctx) => {
|
|
138
138
|
try {
|
|
139
139
|
const { argMap, context: contextString } = splitPromptArguments(args);
|
|
140
140
|
const resolveOptions = {};
|
|
@@ -145,58 +145,6 @@ function createPromptCommand(promptInfo) {
|
|
|
145
145
|
resolveOptions.context = contextString;
|
|
146
146
|
}
|
|
147
147
|
const result = await agent.resolvePrompt(internalName, resolveOptions);
|
|
148
|
-
if (ctx.sessionId) {
|
|
149
|
-
if (result.model) {
|
|
150
|
-
try {
|
|
151
|
-
await agent.switchLLM({ model: result.model }, ctx.sessionId);
|
|
152
|
-
} catch (modelError) {
|
|
153
|
-
agent.logger.warn("Failed to switch model for prompt override", {
|
|
154
|
-
model: result.model,
|
|
155
|
-
error: modelError instanceof Error ? modelError.message : String(modelError)
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
if (result.allowedTools && result.allowedTools.length > 0) {
|
|
160
|
-
try {
|
|
161
|
-
agent.toolManager.addSessionAutoApproveTools(
|
|
162
|
-
ctx.sessionId,
|
|
163
|
-
result.allowedTools
|
|
164
|
-
);
|
|
165
|
-
} catch (toolError) {
|
|
166
|
-
agent.logger.warn("Failed to set auto-approve tools for prompt", {
|
|
167
|
-
tools: result.allowedTools,
|
|
168
|
-
error: toolError instanceof Error ? toolError.message : String(toolError)
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (result.context !== "fork" && result.toolkits && result.toolkits.length > 0) {
|
|
174
|
-
if (!agent.loadToolkits) {
|
|
175
|
-
return (0, import_format_output.formatForInkCli)(
|
|
176
|
-
`\u274C Skill '${commandName}' requires toolkits (${result.toolkits.join(", ")}), but this agent does not support dynamic tool loading.`
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
try {
|
|
180
|
-
await agent.loadToolkits(result.toolkits);
|
|
181
|
-
} catch (error) {
|
|
182
|
-
return (0, import_format_output.formatForInkCli)(
|
|
183
|
-
`\u274C Failed to load toolkits for skill '${commandName}': ${error instanceof Error ? error.message : String(error)}`
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
if (result.context === "fork") {
|
|
188
|
-
const skillName = internalName;
|
|
189
|
-
const taskContext = contextString || "";
|
|
190
|
-
const instructionText = `<skill-invocation>
|
|
191
|
-
Execute the fork skill: ${commandName}
|
|
192
|
-
${taskContext ? `Task context: ${taskContext}` : ""}
|
|
193
|
-
|
|
194
|
-
Call the invoke_skill tool immediately with:
|
|
195
|
-
- skill: "${skillName}"
|
|
196
|
-
${taskContext ? `- taskContext: "${taskContext}"` : ""}
|
|
197
|
-
</skill-invocation>`;
|
|
198
|
-
return (0, import_services.createSendMessageMarker)(instructionText);
|
|
199
|
-
}
|
|
200
148
|
let finalText = result.text;
|
|
201
149
|
if (result.resources.length > 0) {
|
|
202
150
|
const resourceRefs = result.resources.map((uri) => `@<${uri}>`).join(" ");
|
|
@@ -205,20 +153,10 @@ ${taskContext ? `- taskContext: "${taskContext}"` : ""}
|
|
|
205
153
|
${resourceRefs}` : resourceRefs;
|
|
206
154
|
}
|
|
207
155
|
if (finalText.trim()) {
|
|
208
|
-
|
|
209
|
-
const wrappedText = `<skill-invocation>
|
|
210
|
-
Execute the inline skill: ${commandName}
|
|
211
|
-
${taskContext ? `Task context: ${taskContext}` : ""}
|
|
212
|
-
|
|
213
|
-
skill: "${internalName}"
|
|
214
|
-
</skill-invocation>
|
|
215
|
-
|
|
216
|
-
${finalText.trim()}`;
|
|
217
|
-
return (0, import_services.createSendMessageMarker)(wrappedText);
|
|
218
|
-
} else {
|
|
219
|
-
const warningMsg = `\u26A0\uFE0F Prompt '${commandName}' returned no content`;
|
|
220
|
-
return (0, import_format_output.formatForInkCli)(warningMsg);
|
|
156
|
+
return (0, import_services.createSendMessageMarker)(finalText.trim());
|
|
221
157
|
}
|
|
158
|
+
const warningMsg = `\u26A0\uFE0F Prompt '${commandName}' returned no content`;
|
|
159
|
+
return (0, import_format_output.formatForInkCli)(warningMsg);
|
|
222
160
|
} catch (error) {
|
|
223
161
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
224
162
|
agent.logger.error(
|
|
@@ -18,8 +18,7 @@ export declare const promptCommands: CommandDefinition[];
|
|
|
18
18
|
/**
|
|
19
19
|
* Get all dynamic prompt commands based on available prompts.
|
|
20
20
|
* Uses pre-computed commandName from PromptManager for collision handling.
|
|
21
|
-
* Filters out prompts with `userInvocable: false` as these are not intended
|
|
22
|
-
* for direct user invocation via slash commands.
|
|
21
|
+
* Filters out prompts with `userInvocable: false` as these are not intended for slash commands.
|
|
23
22
|
*/
|
|
24
23
|
export declare function getDynamicPromptCommands(agent: TuiAgentBackend): Promise<CommandDefinition[]>;
|
|
25
24
|
//# sourceMappingURL=prompt-commands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-commands.d.ts","sourceRoot":"","sources":["../../src/interactive-commands/prompt-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAwC,MAAM,qBAAqB,CAAC;AAGnG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,iBAAiB,EAiI7C,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt-commands.d.ts","sourceRoot":"","sources":["../../src/interactive-commands/prompt-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAwC,MAAM,qBAAqB,CAAC;AAGnG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,iBAAiB,EAiI7C,CAAC;AAqEF;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC1C,KAAK,EAAE,eAAe,GACvB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAe9B"}
|