thatgfsj-code 0.7.2 → 0.7.3
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/cmd/index.js +1 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +13 -1
- package/dist/prompts/index.js.map +1 -1
- package/dist/tui/components/Header.js +1 -1
- package/dist/tui/hooks/useChat.d.ts +1 -1
- package/dist/tui/hooks/useChat.d.ts.map +1 -1
- package/dist/tui/hooks/useChat.js +86 -97
- package/dist/tui/hooks/useChat.js.map +1 -1
- package/package.json +1 -1
- package/src/cmd/index.tsx +1 -1
- package/src/prompts/index.ts +13 -1
- package/src/tui/components/Header.tsx +1 -1
- package/src/tui/hooks/useChat.ts +85 -97
package/dist/cmd/index.js
CHANGED
|
@@ -24,7 +24,7 @@ process.on('unhandledRejection', (reason) => {
|
|
|
24
24
|
program
|
|
25
25
|
.name('gfcode')
|
|
26
26
|
.description('Thatgfsj Code - AI Coding Assistant')
|
|
27
|
-
.version('0.7.
|
|
27
|
+
.version('0.7.3')
|
|
28
28
|
.argument('[prompt]', 'Task to execute (omit to start interactive mode)')
|
|
29
29
|
.option('-m, --model <model>', 'Specify model')
|
|
30
30
|
.option('-i, --interactive', 'Force interactive mode')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;IAC3C,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE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class SystemPromptBuilder {
|
|
|
78
78
|
if (!this.config.includeProjectMd)
|
|
79
79
|
return '';
|
|
80
80
|
const cwd = this.config.cwd;
|
|
81
|
-
const
|
|
81
|
+
const home = process.env.USERPROFILE || process.env.HOME || '';
|
|
82
|
+
const paths = [
|
|
83
|
+
join(cwd, 'CLAUDE.md'),
|
|
84
|
+
join(cwd, '.claude.md'),
|
|
85
|
+
join(cwd, 'AGENTS.md'),
|
|
86
|
+
join(cwd, 'Codex.md'),
|
|
87
|
+
join(cwd, '.Codex.md'),
|
|
88
|
+
join(cwd, 'CODEX.md'),
|
|
89
|
+
join(cwd, '.codex.md'),
|
|
90
|
+
join(home, '.Codex', 'SKILLS.md'),
|
|
91
|
+
join(home, '.agents', 'AGENTS.md'),
|
|
92
|
+
join(home, '.claude', 'CLAUDE.md'),
|
|
93
|
+
];
|
|
82
94
|
for (const path of paths) {
|
|
83
95
|
if (existsSync(path)) {
|
|
84
96
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAY5B,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAA+B;IAE7C,YAAY,SAA6B,EAAE;QACzC,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;YAChC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;YACzB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,IAAI,IAAI;YACjD,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,KAAK;YAC9C,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI,IAAI,EAAE;YAC/B,YAAY,EAAE,MAAM,CAAC,YAAY,IAA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zE,MAAM,CAAC,GAAW,IAAU,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;IACjE,iBAAiB,CAAC,IAA+B,IAAU,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;CAC7G"}
|
|
@@ -3,6 +3,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Box, Text } from 'ink';
|
|
5
5
|
export const Header = React.memo(function Header({ provider, model }) {
|
|
6
|
-
return (_jsxs(Box, { flexDirection: "column", marginBottom: 0, children: [_jsxs(Box, { justifyContent: "space-between", width: "100%", children: [_jsxs(Box, { children: [_jsx(Text, { color: "#06B6D4", bold: true, children: " \u26A1 " }), _jsx(Text, { color: "#22D3EE", bold: true, children: "THATGFSJ CODE" }), _jsx(Text, { dimColor: true, children: " v0.7.
|
|
6
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 0, children: [_jsxs(Box, { justifyContent: "space-between", width: "100%", children: [_jsxs(Box, { children: [_jsx(Text, { color: "#06B6D4", bold: true, children: " \u26A1 " }), _jsx(Text, { color: "#22D3EE", bold: true, children: "THATGFSJ CODE" }), _jsx(Text, { dimColor: true, children: " v0.7.3" })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#06B6D4", bold: true, children: [" ", provider, " "] }), _jsx(Text, { dimColor: true, children: "/" }), _jsxs(Text, { color: "#22D3EE", children: [" ", model, " "] })] })] }), _jsx(Text, { color: "#374151", children: '─'.repeat(80) })] }));
|
|
7
7
|
});
|
|
8
8
|
//# sourceMappingURL=Header.js.map
|
|
@@ -2,7 +2,7 @@ import type { MessageData } from '../components/ChatMessage.js';
|
|
|
2
2
|
import type { ToolCallData } from '../components/ToolCall.js';
|
|
3
3
|
import type { App } from '../../app/index.js';
|
|
4
4
|
export declare function useChat(app: App): {
|
|
5
|
-
sendMessage: (input: string) =>
|
|
5
|
+
sendMessage: (input: string) => void;
|
|
6
6
|
messages: MessageData[];
|
|
7
7
|
isThinking: boolean;
|
|
8
8
|
streaming: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChat.d.ts","sourceRoot":"","sources":["../../../src/tui/hooks/useChat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAS9C,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG;
|
|
1
|
+
{"version":3,"file":"useChat.d.ts","sourceRoot":"","sources":["../../../src/tui/hooks/useChat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAS9C,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG;yBAUU,MAAM;cAhBpC,WAAW,EAAE;gBACX,OAAO;eACR,MAAM;wBACG,YAAY,EAAE;EAoInC"}
|
|
@@ -7,10 +7,12 @@ export function useChat(app) {
|
|
|
7
7
|
streamingToolCalls: [],
|
|
8
8
|
});
|
|
9
9
|
const processingRef = useRef(false);
|
|
10
|
-
const
|
|
10
|
+
const abortRef = useRef(false);
|
|
11
|
+
const sendMessage = useCallback((input) => {
|
|
11
12
|
if (processingRef.current)
|
|
12
13
|
return;
|
|
13
14
|
processingRef.current = true;
|
|
15
|
+
abortRef.current = false;
|
|
14
16
|
// Add user message
|
|
15
17
|
setState(prev => ({
|
|
16
18
|
...prev,
|
|
@@ -20,115 +22,102 @@ export function useChat(app) {
|
|
|
20
22
|
streamingToolCalls: [],
|
|
21
23
|
}));
|
|
22
24
|
app.session.addMessage('user', input);
|
|
25
|
+
// Process stream in background (non-blocking)
|
|
26
|
+
const stream = app.streamResponse();
|
|
23
27
|
let fullContent = '';
|
|
24
28
|
let currentToolCalls = [];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
29
|
+
const processStream = async () => {
|
|
30
|
+
try {
|
|
31
|
+
for await (const chunk of stream) {
|
|
32
|
+
if (abortRef.current)
|
|
33
|
+
break;
|
|
34
|
+
if (chunk.includes('@@TOOL@@')) {
|
|
35
|
+
const parts = chunk.split('\n');
|
|
36
|
+
for (const part of parts) {
|
|
37
|
+
if (part.startsWith('@@TOOL@@')) {
|
|
38
|
+
try {
|
|
39
|
+
const data = JSON.parse(part.slice(8));
|
|
40
|
+
if (data.action === 'call') {
|
|
41
|
+
currentToolCalls.push({ name: data.name, args: data.args || '' });
|
|
42
|
+
setState(prev => ({
|
|
43
|
+
...prev,
|
|
44
|
+
isThinking: false,
|
|
45
|
+
streamingToolCalls: [...currentToolCalls],
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
else if (data.action === 'result') {
|
|
49
|
+
const lastIdx = currentToolCalls.length - 1;
|
|
50
|
+
if (lastIdx >= 0) {
|
|
51
|
+
currentToolCalls[lastIdx] = {
|
|
52
|
+
...currentToolCalls[lastIdx],
|
|
53
|
+
result: data.output || data.error || '',
|
|
54
|
+
isError: !!data.error,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
setState(prev => ({
|
|
58
|
+
...prev,
|
|
59
|
+
streamingToolCalls: [...currentToolCalls],
|
|
60
|
+
isThinking: true,
|
|
61
|
+
}));
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}));
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
fullContent += part;
|
|
66
|
+
setState(prev => ({ ...prev, isThinking: false, streaming: fullContent }));
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
|
-
|
|
65
|
-
// Not a tool message, treat as text
|
|
69
|
+
else if (part) {
|
|
66
70
|
fullContent += part;
|
|
67
|
-
setState(prev => ({
|
|
68
|
-
...prev,
|
|
69
|
-
isThinking: false,
|
|
70
|
-
streaming: fullContent,
|
|
71
|
-
}));
|
|
71
|
+
setState(prev => ({ ...prev, isThinking: false, streaming: fullContent }));
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
isThinking: false,
|
|
79
|
-
streaming: fullContent,
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
fullContent += chunk;
|
|
77
|
+
setState(prev => ({ ...prev, isThinking: false, streaming: fullContent }));
|
|
82
78
|
}
|
|
83
79
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
fullContent
|
|
87
|
-
setState(prev => ({
|
|
88
|
-
...prev,
|
|
89
|
-
isThinking: false,
|
|
90
|
-
streaming: fullContent,
|
|
91
|
-
}));
|
|
80
|
+
// Finalize
|
|
81
|
+
if (fullContent.trim() || currentToolCalls.length > 0) {
|
|
82
|
+
app.session.addMessage('assistant', fullContent);
|
|
92
83
|
}
|
|
84
|
+
setState(prev => ({
|
|
85
|
+
...prev,
|
|
86
|
+
messages: [
|
|
87
|
+
...prev.messages,
|
|
88
|
+
...(fullContent.trim() || currentToolCalls.length > 0
|
|
89
|
+
? [{
|
|
90
|
+
role: 'assistant',
|
|
91
|
+
content: fullContent,
|
|
92
|
+
toolCalls: currentToolCalls.length > 0 ? currentToolCalls : undefined,
|
|
93
|
+
}]
|
|
94
|
+
: []),
|
|
95
|
+
],
|
|
96
|
+
streaming: '',
|
|
97
|
+
streamingToolCalls: [],
|
|
98
|
+
isThinking: false,
|
|
99
|
+
}));
|
|
100
|
+
app.session.truncate();
|
|
93
101
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
102
|
+
catch (error) {
|
|
103
|
+
setState(prev => ({
|
|
104
|
+
...prev,
|
|
105
|
+
messages: [
|
|
106
|
+
...prev.messages,
|
|
107
|
+
...(fullContent.trim()
|
|
108
|
+
? [{ role: 'assistant', content: fullContent }]
|
|
109
|
+
: []),
|
|
110
|
+
{ role: 'assistant', content: `Error: ${error.message}` },
|
|
111
|
+
],
|
|
112
|
+
streaming: '',
|
|
113
|
+
streamingToolCalls: [],
|
|
114
|
+
isThinking: false,
|
|
115
|
+
}));
|
|
97
116
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
...(fullContent.trim() || currentToolCalls.length > 0
|
|
103
|
-
? [{
|
|
104
|
-
role: 'assistant',
|
|
105
|
-
content: fullContent,
|
|
106
|
-
toolCalls: currentToolCalls.length > 0 ? currentToolCalls : undefined,
|
|
107
|
-
}]
|
|
108
|
-
: []),
|
|
109
|
-
],
|
|
110
|
-
streaming: '',
|
|
111
|
-
streamingToolCalls: [],
|
|
112
|
-
isThinking: false,
|
|
113
|
-
}));
|
|
114
|
-
app.session.truncate();
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
setState(prev => ({
|
|
118
|
-
...prev,
|
|
119
|
-
messages: [
|
|
120
|
-
...prev.messages,
|
|
121
|
-
...(fullContent.trim()
|
|
122
|
-
? [{ role: 'assistant', content: fullContent }]
|
|
123
|
-
: []),
|
|
124
|
-
{ role: 'assistant', content: `Error: ${error.message}` },
|
|
125
|
-
],
|
|
126
|
-
streaming: '',
|
|
127
|
-
streamingToolCalls: [],
|
|
128
|
-
isThinking: false,
|
|
129
|
-
}));
|
|
130
|
-
}
|
|
131
|
-
processingRef.current = false;
|
|
117
|
+
processingRef.current = false;
|
|
118
|
+
};
|
|
119
|
+
// Start processing without blocking
|
|
120
|
+
processStream();
|
|
132
121
|
}, [app]);
|
|
133
122
|
return {
|
|
134
123
|
...state,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChat.js","sourceRoot":"","sources":["../../../src/tui/hooks/useChat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useChat.js","sourceRoot":"","sources":["../../../src/tui/hooks/useChat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAa,MAAM,OAAO,CAAC;AAYjE,MAAM,UAAU,OAAO,CAAC,GAAQ;IAC9B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAY;QAC5C,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,EAAE;QACb,kBAAkB,EAAE,EAAE;KACvB,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAE/B,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,KAAa,EAAE,EAAE;QAChD,IAAI,aAAa,CAAC,OAAO;YAAE,OAAO;QAClC,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC;QAC7B,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;QAEzB,mBAAmB;QACnB,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAChB,GAAG,IAAI;YACP,QAAQ,EAAE,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AE,OAAO,EAAE,UAAU,KAAK,CAAC,OAAO,EAAE,EAAE;qBAC1D;oBACD,SAAS,EAAE,EAAE;oBACb,kBAAkB,EAAE,EAAE;oBACtB,UAAU,EAAE,KAAK;iBAClB,CAAC,CAAC,CAAC;YACN,CAAC;YAED,aAAa,CAAC,OAAO,GAAG,KAAK,CAAC;QAChC,CAAC,CAAC;QAEF,oCAAoC;QACpC,aAAa,EAAE,CAAC;IAClB,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEV,OAAO;QACL,GAAG,KAAK;QACR,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/cmd/index.tsx
CHANGED
|
@@ -28,7 +28,7 @@ process.on('unhandledRejection', (reason) => {
|
|
|
28
28
|
program
|
|
29
29
|
.name('gfcode')
|
|
30
30
|
.description('Thatgfsj Code - AI Coding Assistant')
|
|
31
|
-
.version('0.7.
|
|
31
|
+
.version('0.7.3')
|
|
32
32
|
.argument('[prompt]', 'Task to execute (omit to start interactive mode)')
|
|
33
33
|
.option('-m, --model <model>', 'Specify model')
|
|
34
34
|
.option('-i, --interactive', 'Force interactive mode')
|
package/src/prompts/index.ts
CHANGED
|
@@ -99,7 +99,19 @@ export class SystemPromptBuilder {
|
|
|
99
99
|
if (!this.config.includeProjectMd) return '';
|
|
100
100
|
|
|
101
101
|
const cwd = this.config.cwd;
|
|
102
|
-
const
|
|
102
|
+
const home = process.env.USERPROFILE || process.env.HOME || '';
|
|
103
|
+
const paths = [
|
|
104
|
+
join(cwd, 'CLAUDE.md'),
|
|
105
|
+
join(cwd, '.claude.md'),
|
|
106
|
+
join(cwd, 'AGENTS.md'),
|
|
107
|
+
join(cwd, 'Codex.md'),
|
|
108
|
+
join(cwd, '.Codex.md'),
|
|
109
|
+
join(cwd, 'CODEX.md'),
|
|
110
|
+
join(cwd, '.codex.md'),
|
|
111
|
+
join(home, '.Codex', 'SKILLS.md'),
|
|
112
|
+
join(home, '.agents', 'AGENTS.md'),
|
|
113
|
+
join(home, '.claude', 'CLAUDE.md'),
|
|
114
|
+
];
|
|
103
115
|
|
|
104
116
|
for (const path of paths) {
|
|
105
117
|
if (existsSync(path)) {
|
|
@@ -14,7 +14,7 @@ export const Header = React.memo(function Header({ provider, model }: Props) {
|
|
|
14
14
|
<Box>
|
|
15
15
|
<Text color="#06B6D4" bold> ⚡ </Text>
|
|
16
16
|
<Text color="#22D3EE" bold>THATGFSJ CODE</Text>
|
|
17
|
-
<Text dimColor> v0.7.
|
|
17
|
+
<Text dimColor> v0.7.3</Text>
|
|
18
18
|
</Box>
|
|
19
19
|
<Box>
|
|
20
20
|
<Text color="#06B6D4" bold> {provider} </Text>
|
package/src/tui/hooks/useChat.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useCallback, useRef } from 'react';
|
|
1
|
+
import { useState, useCallback, useRef, useEffect } from 'react';
|
|
2
2
|
import type { MessageData } from '../components/ChatMessage.js';
|
|
3
3
|
import type { ToolCallData } from '../components/ToolCall.js';
|
|
4
4
|
import type { App } from '../../app/index.js';
|
|
@@ -18,10 +18,12 @@ export function useChat(app: App) {
|
|
|
18
18
|
streamingToolCalls: [],
|
|
19
19
|
});
|
|
20
20
|
const processingRef = useRef(false);
|
|
21
|
+
const abortRef = useRef(false);
|
|
21
22
|
|
|
22
|
-
const sendMessage = useCallback(
|
|
23
|
+
const sendMessage = useCallback((input: string) => {
|
|
23
24
|
if (processingRef.current) return;
|
|
24
25
|
processingRef.current = true;
|
|
26
|
+
abortRef.current = false;
|
|
25
27
|
|
|
26
28
|
// Add user message
|
|
27
29
|
setState(prev => ({
|
|
@@ -34,117 +36,103 @@ export function useChat(app: App) {
|
|
|
34
36
|
|
|
35
37
|
app.session.addMessage('user', input);
|
|
36
38
|
|
|
39
|
+
// Process stream in background (non-blocking)
|
|
40
|
+
const stream = app.streamResponse();
|
|
37
41
|
let fullContent = '';
|
|
38
42
|
let currentToolCalls: ToolCallData[] = [];
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
const processStream = async () => {
|
|
45
|
+
try {
|
|
46
|
+
for await (const chunk of stream) {
|
|
47
|
+
if (abortRef.current) break;
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
...currentToolCalls
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
};
|
|
49
|
+
if (chunk.includes('@@TOOL@@')) {
|
|
50
|
+
const parts = chunk.split('\n');
|
|
51
|
+
for (const part of parts) {
|
|
52
|
+
if (part.startsWith('@@TOOL@@')) {
|
|
53
|
+
try {
|
|
54
|
+
const data = JSON.parse(part.slice(8));
|
|
55
|
+
if (data.action === 'call') {
|
|
56
|
+
currentToolCalls.push({ name: data.name, args: data.args || '' });
|
|
57
|
+
setState(prev => ({
|
|
58
|
+
...prev,
|
|
59
|
+
isThinking: false,
|
|
60
|
+
streamingToolCalls: [...currentToolCalls],
|
|
61
|
+
}));
|
|
62
|
+
} else if (data.action === 'result') {
|
|
63
|
+
const lastIdx = currentToolCalls.length - 1;
|
|
64
|
+
if (lastIdx >= 0) {
|
|
65
|
+
currentToolCalls[lastIdx] = {
|
|
66
|
+
...currentToolCalls[lastIdx],
|
|
67
|
+
result: data.output || data.error || '',
|
|
68
|
+
isError: !!data.error,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
setState(prev => ({
|
|
72
|
+
...prev,
|
|
73
|
+
streamingToolCalls: [...currentToolCalls],
|
|
74
|
+
isThinking: true,
|
|
75
|
+
}));
|
|
71
76
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
isThinking: true, // Continue thinking after tool
|
|
76
|
-
}));
|
|
77
|
+
} catch {
|
|
78
|
+
fullContent += part;
|
|
79
|
+
setState(prev => ({ ...prev, isThinking: false, streaming: fullContent }));
|
|
77
80
|
}
|
|
78
|
-
}
|
|
79
|
-
// Not a tool message, treat as text
|
|
81
|
+
} else if (part) {
|
|
80
82
|
fullContent += part;
|
|
81
|
-
setState(prev => ({
|
|
82
|
-
...prev,
|
|
83
|
-
isThinking: false,
|
|
84
|
-
streaming: fullContent,
|
|
85
|
-
}));
|
|
83
|
+
setState(prev => ({ ...prev, isThinking: false, streaming: fullContent }));
|
|
86
84
|
}
|
|
87
|
-
} else if (part) {
|
|
88
|
-
fullContent += part;
|
|
89
|
-
setState(prev => ({
|
|
90
|
-
...prev,
|
|
91
|
-
isThinking: false,
|
|
92
|
-
streaming: fullContent,
|
|
93
|
-
}));
|
|
94
85
|
}
|
|
86
|
+
} else {
|
|
87
|
+
fullContent += chunk;
|
|
88
|
+
setState(prev => ({ ...prev, isThinking: false, streaming: fullContent }));
|
|
95
89
|
}
|
|
96
|
-
} else {
|
|
97
|
-
// Regular text chunk
|
|
98
|
-
fullContent += chunk;
|
|
99
|
-
setState(prev => ({
|
|
100
|
-
...prev,
|
|
101
|
-
isThinking: false,
|
|
102
|
-
streaming: fullContent,
|
|
103
|
-
}));
|
|
104
90
|
}
|
|
105
|
-
}
|
|
106
91
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
92
|
+
// Finalize
|
|
93
|
+
if (fullContent.trim() || currentToolCalls.length > 0) {
|
|
94
|
+
app.session.addMessage('assistant', fullContent);
|
|
95
|
+
}
|
|
111
96
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
97
|
+
setState(prev => ({
|
|
98
|
+
...prev,
|
|
99
|
+
messages: [
|
|
100
|
+
...prev.messages,
|
|
101
|
+
...(fullContent.trim() || currentToolCalls.length > 0
|
|
102
|
+
? [{
|
|
103
|
+
role: 'assistant' as const,
|
|
104
|
+
content: fullContent,
|
|
105
|
+
toolCalls: currentToolCalls.length > 0 ? currentToolCalls : undefined,
|
|
106
|
+
}]
|
|
107
|
+
: []),
|
|
108
|
+
],
|
|
109
|
+
streaming: '',
|
|
110
|
+
streamingToolCalls: [],
|
|
111
|
+
isThinking: false,
|
|
112
|
+
}));
|
|
128
113
|
|
|
129
|
-
|
|
114
|
+
app.session.truncate();
|
|
115
|
+
} catch (error: any) {
|
|
116
|
+
setState(prev => ({
|
|
117
|
+
...prev,
|
|
118
|
+
messages: [
|
|
119
|
+
...prev.messages,
|
|
120
|
+
...(fullContent.trim()
|
|
121
|
+
? [{ role: 'assistant' as const, content: fullContent }]
|
|
122
|
+
: []),
|
|
123
|
+
{ role: 'assistant', content: `Error: ${error.message}` },
|
|
124
|
+
],
|
|
125
|
+
streaming: '',
|
|
126
|
+
streamingToolCalls: [],
|
|
127
|
+
isThinking: false,
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
...prev,
|
|
134
|
-
messages: [
|
|
135
|
-
...prev.messages,
|
|
136
|
-
...(fullContent.trim()
|
|
137
|
-
? [{ role: 'assistant' as const, content: fullContent }]
|
|
138
|
-
: []),
|
|
139
|
-
{ role: 'assistant', content: `Error: ${error.message}` },
|
|
140
|
-
],
|
|
141
|
-
streaming: '',
|
|
142
|
-
streamingToolCalls: [],
|
|
143
|
-
isThinking: false,
|
|
144
|
-
}));
|
|
145
|
-
}
|
|
131
|
+
processingRef.current = false;
|
|
132
|
+
};
|
|
146
133
|
|
|
147
|
-
|
|
134
|
+
// Start processing without blocking
|
|
135
|
+
processStream();
|
|
148
136
|
}, [app]);
|
|
149
137
|
|
|
150
138
|
return {
|