@dexto/tui 1.7.2 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/Footer.cjs +3 -2
- package/dist/components/Footer.d.ts.map +1 -1
- package/dist/components/Footer.js +2 -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/ApiKeyInput.d.ts +1 -1
- package/dist/components/overlays/ApiKeyInput.d.ts.map +1 -1
- package/dist/components/overlays/CustomModelWizard.d.ts.map +1 -1
- 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/components/overlays/ModelSelectorRefactored.cjs +4 -3
- package/dist/components/overlays/ModelSelectorRefactored.d.ts +1 -1
- package/dist/components/overlays/ModelSelectorRefactored.d.ts.map +1 -1
- package/dist/components/overlays/ModelSelectorRefactored.js +1 -2
- package/dist/components/overlays/ReasoningOverlay.cjs +3 -3
- package/dist/components/overlays/ReasoningOverlay.js +1 -1
- package/dist/components/overlays/custom-model-wizard/provider-config.cjs +4 -3
- package/dist/components/overlays/custom-model-wizard/provider-config.d.ts.map +1 -1
- package/dist/components/overlays/custom-model-wizard/provider-config.js +2 -4
- package/dist/containers/InputContainer.cjs +121 -20
- package/dist/containers/InputContainer.d.ts +6 -2
- package/dist/containers/InputContainer.d.ts.map +1 -1
- package/dist/containers/InputContainer.js +120 -19
- package/dist/containers/OverlayContainer.cjs +6 -5
- package/dist/containers/OverlayContainer.d.ts.map +1 -1
- package/dist/containers/OverlayContainer.js +2 -7
- package/dist/hooks/useAgentEvents.cjs +29 -6
- package/dist/hooks/useAgentEvents.d.ts +3 -2
- package/dist/hooks/useAgentEvents.d.ts.map +1 -1
- package/dist/hooks/useAgentEvents.js +29 -9
- package/dist/hooks/useCLIState.cjs +12 -5
- package/dist/hooks/useCLIState.d.ts +2 -0
- package/dist/hooks/useCLIState.d.ts.map +1 -1
- package/dist/hooks/useCLIState.js +12 -5
- 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 +9 -18
- 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 +11 -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 +4 -1
- package/dist/state/types.d.ts.map +1 -1
- package/dist/utils/chatgpt-rate-limit.cjs +4 -4
- package/dist/utils/chatgpt-rate-limit.d.ts.map +1 -1
- package/dist/utils/chatgpt-rate-limit.js +1 -1
- package/dist/utils/llm-provider-display.d.ts +1 -1
- package/dist/utils/llm-provider-display.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 +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OverlayContainer.d.ts","sourceRoot":"","sources":["../../src/containers/OverlayContainer.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAyE,MAAM,OAAO,CAAC;AAI9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AAE5D,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAGH,KAAK,eAAe,EACvB,MAAM,iCAAiC,CAAC;AAmGzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"OverlayContainer.d.ts","sourceRoot":"","sources":["../../src/containers/OverlayContainer.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAyE,MAAM,OAAO,CAAC;AAI9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AAE5D,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAGH,KAAK,eAAe,EACvB,MAAM,iCAAiC,CAAC;AAmGzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBA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ClE;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,sGA06F5B,CAAC"}
|
|
@@ -56,13 +56,8 @@ import MarketplaceBrowser from "../components/overlays/MarketplaceBrowser.js";
|
|
|
56
56
|
import MarketplaceAddPrompt from "../components/overlays/MarketplaceAddPrompt.js";
|
|
57
57
|
import LoginOverlay from "../components/overlays/LoginOverlay.js";
|
|
58
58
|
import LogoutOverlay from "../components/overlays/LogoutOverlay.js";
|
|
59
|
-
import {
|
|
60
|
-
|
|
61
|
-
LLMErrorCode,
|
|
62
|
-
LLM_PROVIDERS,
|
|
63
|
-
getModelDisplayName,
|
|
64
|
-
getReasoningProfile
|
|
65
|
-
} from "@dexto/core";
|
|
59
|
+
import { LLM_PROVIDERS, getModelDisplayName, getReasoningProfile } from "@dexto/llm";
|
|
60
|
+
import { DextoValidationError, LLMErrorCode } from "@dexto/core";
|
|
66
61
|
import { createUserMessage, convertHistoryToUIMessages } from "../utils/messageFormatting.js";
|
|
67
62
|
import { generateMessageId } from "../utils/idGenerator.js";
|
|
68
63
|
import { canUseDextoProvider, captureAnalytics } from "../host/index.js";
|
|
@@ -24,6 +24,7 @@ module.exports = __toCommonJS(useAgentEvents_exports);
|
|
|
24
24
|
var import_react = require("react");
|
|
25
25
|
var import_events = require("events");
|
|
26
26
|
var import_core = require("@dexto/core");
|
|
27
|
+
var import_llm = require("@dexto/llm");
|
|
27
28
|
var import_idGenerator = require("../utils/idGenerator.js");
|
|
28
29
|
function extractTextContent(content) {
|
|
29
30
|
return content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
@@ -37,6 +38,7 @@ function useAgentEvents({
|
|
|
37
38
|
setInput,
|
|
38
39
|
setApproval,
|
|
39
40
|
setApprovalQueue,
|
|
41
|
+
setSteerMessages,
|
|
40
42
|
setQueuedMessages,
|
|
41
43
|
currentSessionId,
|
|
42
44
|
buffer
|
|
@@ -46,13 +48,24 @@ function useAgentEvents({
|
|
|
46
48
|
const controller = new AbortController();
|
|
47
49
|
const { signal } = controller;
|
|
48
50
|
(0, import_events.setMaxListeners)(25, signal);
|
|
51
|
+
const syncQueue = (sessionId, queue) => {
|
|
52
|
+
const getMessages = queue === "steer" ? agent.getSteerMessages(sessionId) : agent.getFollowUpMessages(sessionId);
|
|
53
|
+
void getMessages.then((messages) => {
|
|
54
|
+
if (queue === "steer") {
|
|
55
|
+
setSteerMessages(messages);
|
|
56
|
+
} else {
|
|
57
|
+
setQueuedMessages(messages);
|
|
58
|
+
}
|
|
59
|
+
}).catch(() => {
|
|
60
|
+
});
|
|
61
|
+
};
|
|
49
62
|
agent.on(
|
|
50
63
|
"llm:switched",
|
|
51
64
|
(payload) => {
|
|
52
65
|
if (payload.newConfig?.model) {
|
|
53
66
|
setSession((prev) => ({
|
|
54
67
|
...prev,
|
|
55
|
-
modelName: (0,
|
|
68
|
+
modelName: (0, import_llm.getModelDisplayName)(
|
|
56
69
|
payload.newConfig.model,
|
|
57
70
|
payload.newConfig.provider
|
|
58
71
|
)
|
|
@@ -163,6 +176,7 @@ function useAgentEvents({
|
|
|
163
176
|
setMessages([]);
|
|
164
177
|
setApproval(null);
|
|
165
178
|
setApprovalQueue([]);
|
|
179
|
+
setSteerMessages([]);
|
|
166
180
|
setQueuedMessages([]);
|
|
167
181
|
setUi((prev) => ({
|
|
168
182
|
...prev,
|
|
@@ -184,6 +198,7 @@ function useAgentEvents({
|
|
|
184
198
|
setPendingMessages([]);
|
|
185
199
|
setApproval(null);
|
|
186
200
|
setApprovalQueue([]);
|
|
201
|
+
setSteerMessages([]);
|
|
187
202
|
setQueuedMessages([]);
|
|
188
203
|
buffer.setText("");
|
|
189
204
|
setInput((prev) => ({
|
|
@@ -192,6 +207,7 @@ function useAgentEvents({
|
|
|
192
207
|
history: [],
|
|
193
208
|
historyIndex: -1,
|
|
194
209
|
draftBeforeHistory: "",
|
|
210
|
+
editingQueuedFollowUp: false,
|
|
195
211
|
images: [],
|
|
196
212
|
pastedBlocks: [],
|
|
197
213
|
pasteCounter: 0
|
|
@@ -227,6 +243,7 @@ function useAgentEvents({
|
|
|
227
243
|
() => {
|
|
228
244
|
setApproval(null);
|
|
229
245
|
setApprovalQueue([]);
|
|
246
|
+
setSteerMessages([]);
|
|
230
247
|
setQueuedMessages([]);
|
|
231
248
|
setUi((prev) => ({
|
|
232
249
|
...prev,
|
|
@@ -272,17 +289,22 @@ function useAgentEvents({
|
|
|
272
289
|
"message:queued",
|
|
273
290
|
(payload) => {
|
|
274
291
|
if (!payload.sessionId) return;
|
|
275
|
-
|
|
276
|
-
setQueuedMessages(messages);
|
|
277
|
-
}).catch(() => {
|
|
278
|
-
});
|
|
292
|
+
syncQueue(payload.sessionId, payload.queue);
|
|
279
293
|
},
|
|
280
294
|
{ signal }
|
|
281
295
|
);
|
|
282
296
|
agent.on(
|
|
283
297
|
"message:removed",
|
|
284
298
|
(payload) => {
|
|
285
|
-
|
|
299
|
+
if (!payload.sessionId) {
|
|
300
|
+
if (payload.queue === "steer") {
|
|
301
|
+
setSteerMessages((prev) => prev.filter((m) => m.id !== payload.id));
|
|
302
|
+
} else {
|
|
303
|
+
setQueuedMessages((prev) => prev.filter((m) => m.id !== payload.id));
|
|
304
|
+
}
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
syncQueue(payload.sessionId, payload.queue);
|
|
286
308
|
},
|
|
287
309
|
{ signal }
|
|
288
310
|
);
|
|
@@ -405,6 +427,7 @@ function useAgentEvents({
|
|
|
405
427
|
setInput,
|
|
406
428
|
setApproval,
|
|
407
429
|
setApprovalQueue,
|
|
430
|
+
setSteerMessages,
|
|
408
431
|
setQueuedMessages,
|
|
409
432
|
currentSessionId,
|
|
410
433
|
buffer
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* llm:error, run:complete, message:dequeued) are handled via agent.stream() iterator in processStream.
|
|
6
6
|
*
|
|
7
7
|
* This hook handles:
|
|
8
|
-
* - approval:request - Tool/command
|
|
8
|
+
* - approval:request - Tool/command approval requests
|
|
9
9
|
* - llm:switched - Model change notifications
|
|
10
10
|
* - session:reset - Conversation reset
|
|
11
11
|
* - session:created - New session creation (e.g., from /clear)
|
|
@@ -33,6 +33,7 @@ interface UseAgentEventsProps {
|
|
|
33
33
|
setInput: React.Dispatch<React.SetStateAction<InputState>>;
|
|
34
34
|
setApproval: React.Dispatch<React.SetStateAction<ApprovalRequest | null>>;
|
|
35
35
|
setApprovalQueue: React.Dispatch<React.SetStateAction<ApprovalRequest[]>>;
|
|
36
|
+
setSteerMessages: React.Dispatch<React.SetStateAction<QueuedMessage[]>>;
|
|
36
37
|
setQueuedMessages: React.Dispatch<React.SetStateAction<QueuedMessage[]>>;
|
|
37
38
|
/** Current session ID for filtering events */
|
|
38
39
|
currentSessionId: string | null;
|
|
@@ -45,6 +46,6 @@ interface UseAgentEventsProps {
|
|
|
45
46
|
*
|
|
46
47
|
* Also handles external triggers (run:invoke) from scheduler, A2A, etc.
|
|
47
48
|
*/
|
|
48
|
-
export declare function useAgentEvents({ agent, setMessages, setPendingMessages, setUi, setSession, setInput, setApproval, setApprovalQueue, setQueuedMessages, currentSessionId, buffer, }: UseAgentEventsProps): void;
|
|
49
|
+
export declare function useAgentEvents({ agent, setMessages, setPendingMessages, setUi, setSession, setInput, setApproval, setApprovalQueue, setSteerMessages, setQueuedMessages, currentSessionId, buffer, }: UseAgentEventsProps): void;
|
|
49
50
|
export {};
|
|
50
51
|
//# sourceMappingURL=useAgentEvents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAgentEvents.d.ts","sourceRoot":"","sources":["../../src/hooks/useAgentEvents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,
|
|
1
|
+
{"version":3,"file":"useAgentEvents.d.ts","sourceRoot":"","sources":["../../src/hooks/useAgentEvents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO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,KAAK,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IACzE,8CAA8C;IAC9C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iFAAiF;IACjF,MAAM,EAAE,UAAU,CAAC;CACtB;AAYD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC3B,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,KAAK,EACL,UAAU,EACV,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,GACT,EAAE,mBAAmB,GAAG,IAAI,CAgiB5B"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
import { setMaxListeners } from "events";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
parseCodexBaseURL
|
|
6
|
-
} from "@dexto/core";
|
|
3
|
+
import { parseCodexBaseURL } from "@dexto/core";
|
|
4
|
+
import { getModelDisplayName } from "@dexto/llm";
|
|
7
5
|
import { generateMessageId } from "../utils/idGenerator.js";
|
|
8
6
|
function extractTextContent(content) {
|
|
9
7
|
return content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
@@ -17,6 +15,7 @@ function useAgentEvents({
|
|
|
17
15
|
setInput,
|
|
18
16
|
setApproval,
|
|
19
17
|
setApprovalQueue,
|
|
18
|
+
setSteerMessages,
|
|
20
19
|
setQueuedMessages,
|
|
21
20
|
currentSessionId,
|
|
22
21
|
buffer
|
|
@@ -26,6 +25,17 @@ function useAgentEvents({
|
|
|
26
25
|
const controller = new AbortController();
|
|
27
26
|
const { signal } = controller;
|
|
28
27
|
setMaxListeners(25, signal);
|
|
28
|
+
const syncQueue = (sessionId, queue) => {
|
|
29
|
+
const getMessages = queue === "steer" ? agent.getSteerMessages(sessionId) : agent.getFollowUpMessages(sessionId);
|
|
30
|
+
void getMessages.then((messages) => {
|
|
31
|
+
if (queue === "steer") {
|
|
32
|
+
setSteerMessages(messages);
|
|
33
|
+
} else {
|
|
34
|
+
setQueuedMessages(messages);
|
|
35
|
+
}
|
|
36
|
+
}).catch(() => {
|
|
37
|
+
});
|
|
38
|
+
};
|
|
29
39
|
agent.on(
|
|
30
40
|
"llm:switched",
|
|
31
41
|
(payload) => {
|
|
@@ -143,6 +153,7 @@ function useAgentEvents({
|
|
|
143
153
|
setMessages([]);
|
|
144
154
|
setApproval(null);
|
|
145
155
|
setApprovalQueue([]);
|
|
156
|
+
setSteerMessages([]);
|
|
146
157
|
setQueuedMessages([]);
|
|
147
158
|
setUi((prev) => ({
|
|
148
159
|
...prev,
|
|
@@ -164,6 +175,7 @@ function useAgentEvents({
|
|
|
164
175
|
setPendingMessages([]);
|
|
165
176
|
setApproval(null);
|
|
166
177
|
setApprovalQueue([]);
|
|
178
|
+
setSteerMessages([]);
|
|
167
179
|
setQueuedMessages([]);
|
|
168
180
|
buffer.setText("");
|
|
169
181
|
setInput((prev) => ({
|
|
@@ -172,6 +184,7 @@ function useAgentEvents({
|
|
|
172
184
|
history: [],
|
|
173
185
|
historyIndex: -1,
|
|
174
186
|
draftBeforeHistory: "",
|
|
187
|
+
editingQueuedFollowUp: false,
|
|
175
188
|
images: [],
|
|
176
189
|
pastedBlocks: [],
|
|
177
190
|
pasteCounter: 0
|
|
@@ -207,6 +220,7 @@ function useAgentEvents({
|
|
|
207
220
|
() => {
|
|
208
221
|
setApproval(null);
|
|
209
222
|
setApprovalQueue([]);
|
|
223
|
+
setSteerMessages([]);
|
|
210
224
|
setQueuedMessages([]);
|
|
211
225
|
setUi((prev) => ({
|
|
212
226
|
...prev,
|
|
@@ -252,17 +266,22 @@ function useAgentEvents({
|
|
|
252
266
|
"message:queued",
|
|
253
267
|
(payload) => {
|
|
254
268
|
if (!payload.sessionId) return;
|
|
255
|
-
|
|
256
|
-
setQueuedMessages(messages);
|
|
257
|
-
}).catch(() => {
|
|
258
|
-
});
|
|
269
|
+
syncQueue(payload.sessionId, payload.queue);
|
|
259
270
|
},
|
|
260
271
|
{ signal }
|
|
261
272
|
);
|
|
262
273
|
agent.on(
|
|
263
274
|
"message:removed",
|
|
264
275
|
(payload) => {
|
|
265
|
-
|
|
276
|
+
if (!payload.sessionId) {
|
|
277
|
+
if (payload.queue === "steer") {
|
|
278
|
+
setSteerMessages((prev) => prev.filter((m) => m.id !== payload.id));
|
|
279
|
+
} else {
|
|
280
|
+
setQueuedMessages((prev) => prev.filter((m) => m.id !== payload.id));
|
|
281
|
+
}
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
syncQueue(payload.sessionId, payload.queue);
|
|
266
285
|
},
|
|
267
286
|
{ signal }
|
|
268
287
|
);
|
|
@@ -385,6 +404,7 @@ function useAgentEvents({
|
|
|
385
404
|
setInput,
|
|
386
405
|
setApproval,
|
|
387
406
|
setApprovalQueue,
|
|
407
|
+
setSteerMessages,
|
|
388
408
|
setQueuedMessages,
|
|
389
409
|
currentSessionId,
|
|
390
410
|
buffer
|
|
@@ -23,6 +23,7 @@ __export(useCLIState_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(useCLIState_exports);
|
|
24
24
|
var import_react = require("react");
|
|
25
25
|
var import_ink = require("ink");
|
|
26
|
+
var import_llm = require("@dexto/llm");
|
|
26
27
|
var import_core = require("@dexto/core");
|
|
27
28
|
var import_useAgentEvents = require("./useAgentEvents.js");
|
|
28
29
|
var import_useInputOrchestrator = require("./useInputOrchestrator.js");
|
|
@@ -39,6 +40,7 @@ function useCLIState({
|
|
|
39
40
|
const [messages, setMessages] = (0, import_react.useState)([]);
|
|
40
41
|
const [pendingMessages, setPendingMessages] = (0, import_react.useState)([]);
|
|
41
42
|
const [dequeuedBuffer, setDequeuedBuffer] = (0, import_react.useState)([]);
|
|
43
|
+
const [steerMessages, setSteerMessages] = (0, import_react.useState)([]);
|
|
42
44
|
const [queuedMessages, setQueuedMessages] = (0, import_react.useState)([]);
|
|
43
45
|
const [todos, setTodos] = (0, import_react.useState)([]);
|
|
44
46
|
const [ui, setUi] = (0, import_react.useState)({
|
|
@@ -82,13 +84,14 @@ function useCLIState({
|
|
|
82
84
|
draftBeforeHistory: "",
|
|
83
85
|
images: [],
|
|
84
86
|
pastedBlocks: [],
|
|
85
|
-
pasteCounter: 0
|
|
87
|
+
pasteCounter: 0,
|
|
88
|
+
editingQueuedFollowUp: false
|
|
86
89
|
});
|
|
87
90
|
const initialConfig = agent.getCurrentLLMConfig();
|
|
88
91
|
const [session, setSession] = (0, import_react.useState)({
|
|
89
92
|
id: initialSessionId,
|
|
90
93
|
hasActiveSession: initialSessionId !== null,
|
|
91
|
-
modelName: (0,
|
|
94
|
+
modelName: (0, import_llm.getModelDisplayName)(initialConfig.model, initialConfig.provider)
|
|
92
95
|
});
|
|
93
96
|
const [approval, setApproval] = (0, import_react.useState)(null);
|
|
94
97
|
const [approvalQueue, setApprovalQueue] = (0, import_react.useState)([]);
|
|
@@ -118,6 +121,7 @@ function useCLIState({
|
|
|
118
121
|
setInput,
|
|
119
122
|
setApproval,
|
|
120
123
|
setApprovalQueue,
|
|
124
|
+
setSteerMessages,
|
|
121
125
|
setQueuedMessages,
|
|
122
126
|
currentSessionId: session.id,
|
|
123
127
|
buffer
|
|
@@ -133,13 +137,13 @@ function useCLIState({
|
|
|
133
137
|
approval,
|
|
134
138
|
input,
|
|
135
139
|
session,
|
|
136
|
-
|
|
140
|
+
steerMessages,
|
|
137
141
|
buffer,
|
|
138
142
|
setUi,
|
|
139
143
|
setInput,
|
|
140
144
|
setMessages,
|
|
141
145
|
setPendingMessages,
|
|
142
|
-
|
|
146
|
+
setSteerMessages,
|
|
143
147
|
agent,
|
|
144
148
|
handlers: {
|
|
145
149
|
approval: approvalHandler,
|
|
@@ -168,7 +172,8 @@ function useCLIState({
|
|
|
168
172
|
setInput((prev) => ({
|
|
169
173
|
...prev,
|
|
170
174
|
history: userInputHistory,
|
|
171
|
-
historyIndex: -1
|
|
175
|
+
historyIndex: -1,
|
|
176
|
+
editingQueuedFollowUp: false
|
|
172
177
|
}));
|
|
173
178
|
} catch (error) {
|
|
174
179
|
if (cancelled) return;
|
|
@@ -195,6 +200,8 @@ function useCLIState({
|
|
|
195
200
|
setPendingMessages,
|
|
196
201
|
dequeuedBuffer,
|
|
197
202
|
setDequeuedBuffer,
|
|
203
|
+
steerMessages,
|
|
204
|
+
setSteerMessages,
|
|
198
205
|
queuedMessages,
|
|
199
206
|
setQueuedMessages,
|
|
200
207
|
todos,
|
|
@@ -28,6 +28,8 @@ export interface CLIStateReturn {
|
|
|
28
28
|
setPendingMessages: React.Dispatch<React.SetStateAction<Message[]>>;
|
|
29
29
|
dequeuedBuffer: Message[];
|
|
30
30
|
setDequeuedBuffer: React.Dispatch<React.SetStateAction<Message[]>>;
|
|
31
|
+
steerMessages: QueuedMessage[];
|
|
32
|
+
setSteerMessages: React.Dispatch<React.SetStateAction<QueuedMessage[]>>;
|
|
31
33
|
queuedMessages: QueuedMessage[];
|
|
32
34
|
setQueuedMessages: React.Dispatch<React.SetStateAction<QueuedMessage[]>>;
|
|
33
35
|
todos: TodoItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCLIState.d.ts","sourceRoot":"","sources":["../../src/hooks/useCLIState.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useCLIState.d.ts","sourceRoot":"","sources":["../../src/hooks/useCLIState.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AAGjF,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EACR,OAAO,EACP,WAAW,EACX,OAAO,EACP,UAAU,EACV,YAAY,EACZ,QAAQ,EACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGvE,OAAO,EAAE,YAAY,EAAE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,gBAAgB,GAAG,cAAc,CAqPnC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState, useMemo, useEffect, useRef, useCallback } from "react";
|
|
2
2
|
import { useStdout } from "ink";
|
|
3
|
-
import { getModelDisplayName
|
|
3
|
+
import { getModelDisplayName } from "@dexto/llm";
|
|
4
|
+
import { isUserMessage } from "@dexto/core";
|
|
4
5
|
import { useAgentEvents } from "./useAgentEvents.js";
|
|
5
6
|
import { useInputOrchestrator } from "./useInputOrchestrator.js";
|
|
6
7
|
import { InputService, MessageService } from "../services/index.js";
|
|
@@ -16,6 +17,7 @@ function useCLIState({
|
|
|
16
17
|
const [messages, setMessages] = useState([]);
|
|
17
18
|
const [pendingMessages, setPendingMessages] = useState([]);
|
|
18
19
|
const [dequeuedBuffer, setDequeuedBuffer] = useState([]);
|
|
20
|
+
const [steerMessages, setSteerMessages] = useState([]);
|
|
19
21
|
const [queuedMessages, setQueuedMessages] = useState([]);
|
|
20
22
|
const [todos, setTodos] = useState([]);
|
|
21
23
|
const [ui, setUi] = useState({
|
|
@@ -59,7 +61,8 @@ function useCLIState({
|
|
|
59
61
|
draftBeforeHistory: "",
|
|
60
62
|
images: [],
|
|
61
63
|
pastedBlocks: [],
|
|
62
|
-
pasteCounter: 0
|
|
64
|
+
pasteCounter: 0,
|
|
65
|
+
editingQueuedFollowUp: false
|
|
63
66
|
});
|
|
64
67
|
const initialConfig = agent.getCurrentLLMConfig();
|
|
65
68
|
const [session, setSession] = useState({
|
|
@@ -95,6 +98,7 @@ function useCLIState({
|
|
|
95
98
|
setInput,
|
|
96
99
|
setApproval,
|
|
97
100
|
setApprovalQueue,
|
|
101
|
+
setSteerMessages,
|
|
98
102
|
setQueuedMessages,
|
|
99
103
|
currentSessionId: session.id,
|
|
100
104
|
buffer
|
|
@@ -110,13 +114,13 @@ function useCLIState({
|
|
|
110
114
|
approval,
|
|
111
115
|
input,
|
|
112
116
|
session,
|
|
113
|
-
|
|
117
|
+
steerMessages,
|
|
114
118
|
buffer,
|
|
115
119
|
setUi,
|
|
116
120
|
setInput,
|
|
117
121
|
setMessages,
|
|
118
122
|
setPendingMessages,
|
|
119
|
-
|
|
123
|
+
setSteerMessages,
|
|
120
124
|
agent,
|
|
121
125
|
handlers: {
|
|
122
126
|
approval: approvalHandler,
|
|
@@ -145,7 +149,8 @@ function useCLIState({
|
|
|
145
149
|
setInput((prev) => ({
|
|
146
150
|
...prev,
|
|
147
151
|
history: userInputHistory,
|
|
148
|
-
historyIndex: -1
|
|
152
|
+
historyIndex: -1,
|
|
153
|
+
editingQueuedFollowUp: false
|
|
149
154
|
}));
|
|
150
155
|
} catch (error) {
|
|
151
156
|
if (cancelled) return;
|
|
@@ -172,6 +177,8 @@ function useCLIState({
|
|
|
172
177
|
setPendingMessages,
|
|
173
178
|
dequeuedBuffer,
|
|
174
179
|
setDequeuedBuffer,
|
|
180
|
+
steerMessages,
|
|
181
|
+
setSteerMessages,
|
|
175
182
|
queuedMessages,
|
|
176
183
|
setQueuedMessages,
|
|
177
184
|
todos,
|
|
@@ -72,13 +72,13 @@ function useInputOrchestrator({
|
|
|
72
72
|
approval,
|
|
73
73
|
input,
|
|
74
74
|
session,
|
|
75
|
-
|
|
75
|
+
steerMessages,
|
|
76
76
|
buffer,
|
|
77
77
|
setUi,
|
|
78
78
|
setInput,
|
|
79
79
|
setMessages,
|
|
80
80
|
setPendingMessages,
|
|
81
|
-
|
|
81
|
+
setSteerMessages,
|
|
82
82
|
agent,
|
|
83
83
|
handlers
|
|
84
84
|
}) {
|
|
@@ -87,7 +87,7 @@ function useInputOrchestrator({
|
|
|
87
87
|
const approvalRef = (0, import_react.useRef)(approval);
|
|
88
88
|
const inputRef = (0, import_react.useRef)(input);
|
|
89
89
|
const sessionRef = (0, import_react.useRef)(session);
|
|
90
|
-
const
|
|
90
|
+
const steerMessagesRef = (0, import_react.useRef)(steerMessages);
|
|
91
91
|
const bufferRef = (0, import_react.useRef)(buffer);
|
|
92
92
|
const handlersRef = (0, import_react.useRef)(handlers);
|
|
93
93
|
(0, import_react.useEffect)(() => {
|
|
@@ -95,10 +95,10 @@ function useInputOrchestrator({
|
|
|
95
95
|
approvalRef.current = approval;
|
|
96
96
|
inputRef.current = input;
|
|
97
97
|
sessionRef.current = session;
|
|
98
|
-
|
|
98
|
+
steerMessagesRef.current = steerMessages;
|
|
99
99
|
bufferRef.current = buffer;
|
|
100
100
|
handlersRef.current = handlers;
|
|
101
|
-
}, [ui, approval, input, session,
|
|
101
|
+
}, [ui, approval, input, session, steerMessages, buffer, handlers]);
|
|
102
102
|
(0, import_react.useEffect)(() => {
|
|
103
103
|
if (!ui.exitWarningShown || !ui.exitWarningTimestamp) return;
|
|
104
104
|
const elapsed = Date.now() - ui.exitWarningTimestamp;
|
|
@@ -138,7 +138,7 @@ function useInputOrchestrator({
|
|
|
138
138
|
const currentUi = uiRef.current;
|
|
139
139
|
const currentApproval = approvalRef.current;
|
|
140
140
|
const currentSession = sessionRef.current;
|
|
141
|
-
const
|
|
141
|
+
const currentSteerMessages = steerMessagesRef.current;
|
|
142
142
|
const currentBuffer = bufferRef.current;
|
|
143
143
|
if (currentApproval !== null) {
|
|
144
144
|
return false;
|
|
@@ -167,8 +167,9 @@ function useInputOrchestrator({
|
|
|
167
167
|
if (currentSession.id) {
|
|
168
168
|
void agent.cancel(currentSession.id).catch(() => {
|
|
169
169
|
});
|
|
170
|
-
void agent.
|
|
170
|
+
void agent.clearSteerQueue(currentSession.id).catch(() => {
|
|
171
171
|
});
|
|
172
|
+
setSteerMessages([]);
|
|
172
173
|
}
|
|
173
174
|
setPendingMessages((pending) => {
|
|
174
175
|
if (pending.length > 0) {
|
|
@@ -202,8 +203,8 @@ function useInputOrchestrator({
|
|
|
202
203
|
timestamp: /* @__PURE__ */ new Date()
|
|
203
204
|
}
|
|
204
205
|
]);
|
|
205
|
-
if (
|
|
206
|
-
const coalescedText =
|
|
206
|
+
if (currentSteerMessages.length > 0) {
|
|
207
|
+
const coalescedText = currentSteerMessages.map(
|
|
207
208
|
(msg) => msg.content.filter(
|
|
208
209
|
(part) => part.type === "text"
|
|
209
210
|
).map((part) => part.text).join("\n")
|
|
@@ -212,7 +213,7 @@ function useInputOrchestrator({
|
|
|
212
213
|
currentBuffer.setText(coalescedText);
|
|
213
214
|
setInput((prev) => ({ ...prev, value: coalescedText }));
|
|
214
215
|
}
|
|
215
|
-
|
|
216
|
+
setSteerMessages([]);
|
|
216
217
|
}
|
|
217
218
|
return true;
|
|
218
219
|
}
|
|
@@ -220,7 +221,7 @@ function useInputOrchestrator({
|
|
|
220
221
|
return false;
|
|
221
222
|
}
|
|
222
223
|
return false;
|
|
223
|
-
}, [agent, setUi, setMessages, setPendingMessages,
|
|
224
|
+
}, [agent, setUi, setMessages, setPendingMessages, setSteerMessages, setInput]);
|
|
224
225
|
const handleKeypress = (0, import_react.useCallback)(
|
|
225
226
|
(rawKey) => {
|
|
226
227
|
const currentUi = uiRef.current;
|
|
@@ -431,7 +432,7 @@ function createApprovalInputHandler({
|
|
|
431
432
|
onCancel,
|
|
432
433
|
selectedOption,
|
|
433
434
|
setSelectedOption,
|
|
434
|
-
|
|
435
|
+
isCommandApproval
|
|
435
436
|
}) {
|
|
436
437
|
return (_input, key) => {
|
|
437
438
|
if (key.upArrow) {
|
|
@@ -440,13 +441,13 @@ function createApprovalInputHandler({
|
|
|
440
441
|
} else if (selectedOption === "yes-session") {
|
|
441
442
|
setSelectedOption("yes");
|
|
442
443
|
} else {
|
|
443
|
-
setSelectedOption(
|
|
444
|
+
setSelectedOption(isCommandApproval ? "yes" : "yes-session");
|
|
444
445
|
}
|
|
445
446
|
return true;
|
|
446
447
|
}
|
|
447
448
|
if (key.downArrow) {
|
|
448
449
|
if (selectedOption === "yes") {
|
|
449
|
-
setSelectedOption(
|
|
450
|
+
setSelectedOption(isCommandApproval ? "no" : "yes-session");
|
|
450
451
|
} else if (selectedOption === "yes-session") {
|
|
451
452
|
setSelectedOption("no");
|
|
452
453
|
} else {
|
|
@@ -62,15 +62,15 @@ export interface UseInputOrchestratorProps {
|
|
|
62
62
|
approval: ApprovalRequest | null;
|
|
63
63
|
input: InputState;
|
|
64
64
|
session: SessionState;
|
|
65
|
-
/**
|
|
66
|
-
|
|
65
|
+
/** Active-turn steer messages (for cancel handling) */
|
|
66
|
+
steerMessages: QueuedMessage[];
|
|
67
67
|
/** Text buffer for clearing input on first Ctrl+C */
|
|
68
68
|
buffer: TextBuffer;
|
|
69
69
|
setUi: React.Dispatch<React.SetStateAction<UIState>>;
|
|
70
70
|
setInput: React.Dispatch<React.SetStateAction<InputState>>;
|
|
71
71
|
setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
|
|
72
72
|
setPendingMessages: React.Dispatch<React.SetStateAction<Message[]>>;
|
|
73
|
-
|
|
73
|
+
setSteerMessages: React.Dispatch<React.SetStateAction<QueuedMessage[]>>;
|
|
74
74
|
agent: TuiAgentBackend;
|
|
75
75
|
handlers: InputHandlers;
|
|
76
76
|
}
|
|
@@ -81,7 +81,7 @@ export interface UseInputOrchestratorProps {
|
|
|
81
81
|
* All keyboard handling is routed through this single point.
|
|
82
82
|
* Mouse events are handled separately by MouseProvider/ScrollProvider.
|
|
83
83
|
*/
|
|
84
|
-
export declare function useInputOrchestrator({ ui, approval, input, session,
|
|
84
|
+
export declare function useInputOrchestrator({ ui, approval, input, session, steerMessages, buffer, setUi, setInput, setMessages, setPendingMessages, setSteerMessages, agent, handlers, }: UseInputOrchestratorProps): void;
|
|
85
85
|
/**
|
|
86
86
|
* Create an input handler for the approval prompt
|
|
87
87
|
*/
|
|
@@ -91,9 +91,9 @@ export interface ApprovalHandlerProps {
|
|
|
91
91
|
onCancel: () => void;
|
|
92
92
|
selectedOption: 'yes' | 'yes-session' | 'no';
|
|
93
93
|
setSelectedOption: (option: 'yes' | 'yes-session' | 'no') => void;
|
|
94
|
-
|
|
94
|
+
isCommandApproval: boolean;
|
|
95
95
|
}
|
|
96
|
-
export declare function createApprovalInputHandler({ onApprove, onDeny, onCancel, selectedOption, setSelectedOption,
|
|
96
|
+
export declare function createApprovalInputHandler({ onApprove, onDeny, onCancel, selectedOption, setSelectedOption, isCommandApproval, }: ApprovalHandlerProps): InputHandler;
|
|
97
97
|
/**
|
|
98
98
|
* Create an input handler for selector components (BaseSelector pattern)
|
|
99
99
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInputOrchestrator.d.ts","sourceRoot":"","sources":["../../src/hooks/useInputOrchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAe,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D;;;GAGG;AACH,MAAM,WAAW,GAAG;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,uEAAuE;IACvE,KAAK,EAAE,OAAO,CAAC;CAClB;AAyCD;;;GAGG;AACH,MAAM,M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