@yeaft/webchat-agent 0.1.198 → 0.1.200
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/connection/message-router.js +5 -1
- package/conversation.js +61 -0
- package/expert-roles.js +368 -368
- package/package.json +1 -1
- package/sdk/query.js +2 -0
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
createConversation, resumeConversation, deleteConversation,
|
|
13
13
|
handleRefreshConversation, handleCancelExecution,
|
|
14
14
|
handleUserInput, handleUpdateConversationSettings, handleAskUserAnswer,
|
|
15
|
-
sendConversationList
|
|
15
|
+
sendConversationList, handleBtwQuestion
|
|
16
16
|
} from '../conversation.js';
|
|
17
17
|
import {
|
|
18
18
|
createCrewSession, handleCrewHumanInput, handleCrewControl,
|
|
@@ -98,6 +98,10 @@ export async function handleMessage(msg) {
|
|
|
98
98
|
await handleUserInput(msg);
|
|
99
99
|
break;
|
|
100
100
|
|
|
101
|
+
case 'btw_question':
|
|
102
|
+
await handleBtwQuestion(msg);
|
|
103
|
+
break;
|
|
104
|
+
|
|
101
105
|
case 'cancel_execution':
|
|
102
106
|
await handleCancelExecution(msg);
|
|
103
107
|
break;
|
package/conversation.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ctx from './context.js';
|
|
2
|
+
import { query } from './sdk/index.js';
|
|
2
3
|
import { loadSessionHistory } from './history.js';
|
|
3
4
|
import { startClaudeQuery } from './claude.js';
|
|
4
5
|
import { crewSessions, loadCrewIndex } from './crew.js';
|
|
@@ -584,3 +585,63 @@ export function handleAskUserAnswer(msg) {
|
|
|
584
585
|
console.log(`[AskUser] No pending question for requestId: ${msg.requestId}`);
|
|
585
586
|
}
|
|
586
587
|
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Handle /btw side question — ephemeral, no history pollution.
|
|
591
|
+
* Spawns an independent CLI process with --resume + --fork-session so
|
|
592
|
+
* the answer has full context but writes nothing back to the original session.
|
|
593
|
+
*/
|
|
594
|
+
export async function handleBtwQuestion(msg) {
|
|
595
|
+
const { conversationId, question } = msg;
|
|
596
|
+
const state = ctx.conversations.get(conversationId);
|
|
597
|
+
|
|
598
|
+
if (!state?.claudeSessionId) {
|
|
599
|
+
ctx.sendToServer({ type: 'btw_error', conversationId, question, error: 'No active session' });
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
console.log(`[btw] ${conversationId} question: ${question.substring(0, 80)}`);
|
|
604
|
+
|
|
605
|
+
try {
|
|
606
|
+
const btwQuery = query({
|
|
607
|
+
prompt: question,
|
|
608
|
+
options: {
|
|
609
|
+
cwd: state.workDir,
|
|
610
|
+
resume: state.claudeSessionId,
|
|
611
|
+
forkSession: true,
|
|
612
|
+
maxTurns: 1,
|
|
613
|
+
permissionMode: 'bypassPermissions',
|
|
614
|
+
disallowedTools: [
|
|
615
|
+
'Bash', 'Edit', 'Write', 'Read', 'Glob', 'Grep',
|
|
616
|
+
'Agent', 'NotebookEdit', 'WebFetch', 'WebSearch', 'TodoWrite',
|
|
617
|
+
'EnterPlanMode', 'ExitPlanMode', 'EnterWorktree', 'ExitWorktree',
|
|
618
|
+
'CronCreate', 'CronDelete', 'CronList', 'TaskOutput', 'TaskStop',
|
|
619
|
+
'AskUserQuestion', 'Skill'
|
|
620
|
+
]
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
for await (const message of btwQuery) {
|
|
625
|
+
if (message.type === 'assistant') {
|
|
626
|
+
const content = message.message?.content;
|
|
627
|
+
let delta = '';
|
|
628
|
+
if (typeof content === 'string') {
|
|
629
|
+
delta = content;
|
|
630
|
+
} else if (Array.isArray(content)) {
|
|
631
|
+
for (const block of content) {
|
|
632
|
+
if (block.type === 'text') delta += block.text;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
if (delta) {
|
|
636
|
+
ctx.sendToServer({ type: 'btw_stream', conversationId, delta });
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
// result / system messages — ignored (no usage tracking for btw)
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
ctx.sendToServer({ type: 'btw_done', conversationId, question });
|
|
643
|
+
} catch (err) {
|
|
644
|
+
console.error(`[btw] ${conversationId} error:`, err.message);
|
|
645
|
+
ctx.sendToServer({ type: 'btw_error', conversationId, question, error: err.message });
|
|
646
|
+
}
|
|
647
|
+
}
|