orquesta-agent 0.2.47 → 0.2.51
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/daemon.d.ts.map +1 -1
- package/dist/daemon.js +23 -8
- package/dist/daemon.js.map +1 -1
- package/dist/executor.d.ts +18 -0
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +196 -42
- package/dist/executor.js.map +1 -1
- package/dist/index.js +148 -23
- package/dist/index.js.map +1 -1
- package/dist/socketio-transport.d.ts +11 -0
- package/dist/socketio-transport.d.ts.map +1 -1
- package/dist/socketio-transport.js +8 -0
- package/dist/socketio-transport.js.map +1 -1
- package/dist/supabase.d.ts +17 -1
- package/dist/supabase.d.ts.map +1 -1
- package/dist/supabase.js +25 -0
- package/dist/supabase.js.map +1 -1
- package/dist/ws-client.d.ts +1 -0
- package/dist/ws-client.d.ts.map +1 -1
- package/dist/ws-client.js +8 -0
- package/dist/ws-client.js.map +1 -1
- package/package.json +1 -1
package/dist/daemon.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon.d.ts","sourceRoot":"","sources":["../src/daemon.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"daemon.d.ts","sourceRoot":"","sources":["../src/daemon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmGH,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAuCD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAiJxD;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC"}
|
package/dist/daemon.js
CHANGED
|
@@ -46,19 +46,34 @@ function getLatestNpmVersion() {
|
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
//
|
|
49
|
+
// Check if sudo can run without a password prompt
|
|
50
|
+
function canSudoWithoutPassword() {
|
|
51
|
+
try {
|
|
52
|
+
execSync('sudo -n true', { stdio: 'pipe', timeout: 5000 });
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Try npm install -g, first without sudo then with passwordless sudo
|
|
50
60
|
function installUpdate(version) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
`
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
// Try without sudo first (works if npm prefix is user-writable)
|
|
62
|
+
try {
|
|
63
|
+
execSync(`npm install -g orquesta-agent@${version}`, { stdio: 'pipe', timeout: 60000 });
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// needs elevated permissions
|
|
68
|
+
}
|
|
69
|
+
// Only try sudo if it won't prompt for a password (non-interactive safe)
|
|
70
|
+
if (canSudoWithoutPassword()) {
|
|
56
71
|
try {
|
|
57
|
-
execSync(
|
|
72
|
+
execSync(`sudo npm install -g orquesta-agent@${version}`, { stdio: 'pipe', timeout: 60000 });
|
|
58
73
|
return true;
|
|
59
74
|
}
|
|
60
75
|
catch {
|
|
61
|
-
//
|
|
76
|
+
// sudo install also failed
|
|
62
77
|
}
|
|
63
78
|
}
|
|
64
79
|
return false;
|
package/dist/daemon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon.js","sourceRoot":"","sources":["../src/daemon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAgB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC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+DAA+D;QACjE,CAAC;IACH,CAAC,EAAE,2BAA2B,CAAC,CAAA;IAC/B,WAAW,CAAC,KAAK,EAAE,CAAA,CAAC,8CAA8C;AACpE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,GAAG,CAAA;AAClD,CAAC"}
|
package/dist/executor.d.ts
CHANGED
|
@@ -114,6 +114,24 @@ export interface GeneratePlanItemsOptions {
|
|
|
114
114
|
* This runs Claude to analyze the request and generate actionable tasks.
|
|
115
115
|
*/
|
|
116
116
|
export declare function generatePlanItems(options: GeneratePlanItemsOptions): Promise<void>;
|
|
117
|
+
export interface AgentChatOptions {
|
|
118
|
+
requestId: string;
|
|
119
|
+
sessionId: string;
|
|
120
|
+
content: string;
|
|
121
|
+
context: Array<{
|
|
122
|
+
role: string;
|
|
123
|
+
content: string;
|
|
124
|
+
}>;
|
|
125
|
+
workingDirectory: string;
|
|
126
|
+
channel: BroadcastChannel;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Agent Chat — conversational mode for discussing the project.
|
|
130
|
+
* Runs Claude CLI in read-only mode (no file edits), streams the response
|
|
131
|
+
* back via Socket.io. Does NOT use the execution queue — safe to run
|
|
132
|
+
* concurrently with prompt execution since it's read-only.
|
|
133
|
+
*/
|
|
134
|
+
export declare function agentChat(options: AgentChatOptions): Promise<void>;
|
|
117
135
|
/** Register a callback to be called when an interactive session ends (PTY exits). */
|
|
118
136
|
export declare function setOnSessionEnded(cb: () => void): void;
|
|
119
137
|
export interface StartSessionOptions {
|
package/dist/executor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAgMtD,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,CAAC,M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AkB,IAAI,MAAM,GAAG,IAAI,CAElD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAUxI;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAcvC"}
|
package/dist/executor.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as fs from 'fs';
|
|
|
4
4
|
import * as path from 'path';
|
|
5
5
|
import * as os from 'os';
|
|
6
6
|
import * as logger from './logger.js';
|
|
7
|
-
import { sendOutput, sendComplete, sendError, sendSupervisionRequest, sendExecutionResumed, updatePromptStatus, persistOutputLogs, clearOutputBuffer, sendRequirement, persistRequirement, sendQAInstructions, persistQAInstructions, sendPlanItemsGenerated, sendSessionOutput, sendSessionStarted, sendSessionEnded, sendSessionError } from './supabase.js';
|
|
7
|
+
import { sendOutput, sendComplete, sendError, sendSupervisionRequest, sendExecutionResumed, updatePromptStatus, persistOutputLogs, clearOutputBuffer, sendRequirement, persistRequirement, sendQAInstructions, persistQAInstructions, sendPlanItemsGenerated, sendSessionOutput, sendSessionStarted, sendSessionEnded, sendSessionError, sendAgentChatOutput } from './supabase.js';
|
|
8
8
|
import { createThinkingLog, createToolCallLog, createToolResultLog, createOutputLog, createErrorLog, createSystemLog, } from './types/agent-logs.js';
|
|
9
9
|
/**
|
|
10
10
|
* Strip ANSI escape sequences and control characters from terminal output.
|
|
@@ -704,18 +704,21 @@ const REQUIREMENT_PATTERNS = [
|
|
|
704
704
|
titleExtractor: (match) => `Waiting: ${match[1].slice(0, 40)}`,
|
|
705
705
|
},
|
|
706
706
|
];
|
|
707
|
-
// Track detected requirements to avoid duplicates
|
|
708
|
-
const
|
|
709
|
-
function detectRequirement(text) {
|
|
707
|
+
// Track detected requirements to avoid duplicates (per-commandId for concurrent execution)
|
|
708
|
+
const detectedRequirementsMap = new Map();
|
|
709
|
+
function detectRequirement(text, commandId) {
|
|
710
|
+
if (!detectedRequirementsMap.has(commandId))
|
|
711
|
+
detectedRequirementsMap.set(commandId, new Set());
|
|
712
|
+
const reqs = detectedRequirementsMap.get(commandId);
|
|
710
713
|
for (const { pattern, type, priority, titleExtractor } of REQUIREMENT_PATTERNS) {
|
|
711
714
|
const match = text.match(pattern);
|
|
712
715
|
if (match) {
|
|
713
716
|
// Create a hash to avoid duplicate detection
|
|
714
717
|
const hash = `${type}-${match[0].toLowerCase().slice(0, 30)}`;
|
|
715
|
-
if (
|
|
718
|
+
if (reqs.has(hash)) {
|
|
716
719
|
continue; // Skip already detected
|
|
717
720
|
}
|
|
718
|
-
|
|
721
|
+
reqs.add(hash);
|
|
719
722
|
const title = titleExtractor ? titleExtractor(match) : `${type} Required`;
|
|
720
723
|
// Get surrounding context (last 300 chars)
|
|
721
724
|
const context = text.slice(-300);
|
|
@@ -734,23 +737,21 @@ function detectRequirement(text) {
|
|
|
734
737
|
}
|
|
735
738
|
return null;
|
|
736
739
|
}
|
|
737
|
-
// Clear detected requirements for
|
|
738
|
-
function clearDetectedRequirements() {
|
|
739
|
-
|
|
740
|
+
// Clear detected requirements for a specific execution
|
|
741
|
+
function clearDetectedRequirements(commandId) {
|
|
742
|
+
detectedRequirementsMap.delete(commandId);
|
|
740
743
|
}
|
|
741
|
-
// QA Instructions detection
|
|
742
|
-
|
|
743
|
-
|
|
744
|
+
// QA Instructions detection (per-commandId for concurrent execution)
|
|
745
|
+
const qaBufferMap = new Map();
|
|
746
|
+
const qaDetectedMap = new Map();
|
|
744
747
|
// Detect QA Instructions in the output
|
|
745
|
-
function detectQAInstructions(text) {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
qaBuffer = qaBuffer.slice(-15000);
|
|
750
|
-
}
|
|
748
|
+
function detectQAInstructions(text, commandId) {
|
|
749
|
+
const buf = (qaBufferMap.get(commandId) || '') + text;
|
|
750
|
+
qaBufferMap.set(commandId, buf.length > 20000 ? buf.slice(-15000) : buf);
|
|
751
|
+
const currentBuf = qaBufferMap.get(commandId);
|
|
751
752
|
// Look for QA Instructions header (## or ###)
|
|
752
|
-
const qaMatch =
|
|
753
|
-
if (!qaMatch ||
|
|
753
|
+
const qaMatch = currentBuf.match(/##\s*QA\s+Instructions\s*([\s\S]*?)(?=\n##[^#]|$)/i);
|
|
754
|
+
if (!qaMatch || qaDetectedMap.get(commandId))
|
|
754
755
|
return null;
|
|
755
756
|
const qaContent = qaMatch[1];
|
|
756
757
|
// Extract feature (accept multiple formats)
|
|
@@ -796,7 +797,7 @@ function detectQAInstructions(text) {
|
|
|
796
797
|
if (steps.length === 0 && expectedBehavior.length === 0 && !finalUrl) {
|
|
797
798
|
return null;
|
|
798
799
|
}
|
|
799
|
-
|
|
800
|
+
qaDetectedMap.set(commandId, true); // Prevent duplicate detection
|
|
800
801
|
// Capture raw content (clean up the QA section for display)
|
|
801
802
|
const rawContent = qaContent.trim();
|
|
802
803
|
logger.success(`QA Instructions detected: ${feature}`);
|
|
@@ -809,24 +810,22 @@ function detectQAInstructions(text) {
|
|
|
809
810
|
rawContent
|
|
810
811
|
};
|
|
811
812
|
}
|
|
812
|
-
function clearQABuffer() {
|
|
813
|
-
|
|
814
|
-
|
|
813
|
+
function clearQABuffer(commandId) {
|
|
814
|
+
qaBufferMap.delete(commandId);
|
|
815
|
+
qaDetectedMap.delete(commandId);
|
|
815
816
|
}
|
|
816
|
-
// Buffer to accumulate output for pattern matching
|
|
817
|
-
|
|
818
|
-
function detectPermissionRequest(text) {
|
|
817
|
+
// Buffer to accumulate output for pattern matching (per-commandId for concurrent execution)
|
|
818
|
+
const outputBufferMap = new Map();
|
|
819
|
+
function detectPermissionRequest(text, commandId) {
|
|
819
820
|
// Accumulate output
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
outputBuffer = outputBuffer.slice(-3000);
|
|
824
|
-
}
|
|
821
|
+
const buf = (outputBufferMap.get(commandId) || '') + text;
|
|
822
|
+
outputBufferMap.set(commandId, buf.length > 5000 ? buf.slice(-3000) : buf);
|
|
823
|
+
const currentBuf = outputBufferMap.get(commandId);
|
|
825
824
|
// Check for permission patterns
|
|
826
825
|
for (const pattern of PERMISSION_PATTERNS) {
|
|
827
|
-
if (pattern.test(
|
|
828
|
-
const content =
|
|
829
|
-
|
|
826
|
+
if (pattern.test(currentBuf)) {
|
|
827
|
+
const content = currentBuf.slice(-500); // Last 500 chars for context
|
|
828
|
+
outputBufferMap.delete(commandId); // Clear buffer after detection
|
|
830
829
|
return { detected: true, content };
|
|
831
830
|
}
|
|
832
831
|
}
|
|
@@ -836,10 +835,10 @@ export async function execute(options) {
|
|
|
836
835
|
const { commandId, promptId, content, workingDirectory, channel, permissionMode, attachments } = options;
|
|
837
836
|
const startTime = Date.now();
|
|
838
837
|
const mode = permissionMode ?? globalPermissionMode;
|
|
839
|
-
// Clear
|
|
840
|
-
|
|
841
|
-
clearDetectedRequirements();
|
|
842
|
-
clearQABuffer();
|
|
838
|
+
// Clear per-execution buffers for new execution (concurrent-safe)
|
|
839
|
+
outputBufferMap.delete(commandId);
|
|
840
|
+
clearDetectedRequirements(commandId);
|
|
841
|
+
clearQABuffer(commandId);
|
|
843
842
|
// Start log persistence for this execution
|
|
844
843
|
startLogPersistence(promptId);
|
|
845
844
|
addLog(promptId, 'info', 'system', `Starting execution: ${content.slice(0, 100)}...`);
|
|
@@ -1293,7 +1292,7 @@ ${content}${attachmentContext}`;
|
|
|
1293
1292
|
}
|
|
1294
1293
|
}
|
|
1295
1294
|
// Detect requirements (API keys, credentials, decisions needed)
|
|
1296
|
-
const requirementResult = detectRequirement(text);
|
|
1295
|
+
const requirementResult = detectRequirement(text, commandId);
|
|
1297
1296
|
if (requirementResult?.detected && requirementResult.requirement) {
|
|
1298
1297
|
logger.warn(`Requirement detected: ${requirementResult.requirement.title}`);
|
|
1299
1298
|
// Send via realtime channel
|
|
@@ -1304,7 +1303,7 @@ ${content}${attachmentContext}`;
|
|
|
1304
1303
|
});
|
|
1305
1304
|
}
|
|
1306
1305
|
// Detect QA instructions
|
|
1307
|
-
const qaInstructions = detectQAInstructions(text);
|
|
1306
|
+
const qaInstructions = detectQAInstructions(text, commandId);
|
|
1308
1307
|
if (qaInstructions) {
|
|
1309
1308
|
logger.success(`QA Instructions detected: ${qaInstructions.feature}`);
|
|
1310
1309
|
// Send via realtime channel
|
|
@@ -1316,7 +1315,7 @@ ${content}${attachmentContext}`;
|
|
|
1316
1315
|
}
|
|
1317
1316
|
// In supervised mode, check for permission requests
|
|
1318
1317
|
if (mode === 'supervised') {
|
|
1319
|
-
const { detected, content: permissionContent } = detectPermissionRequest(text);
|
|
1318
|
+
const { detected, content: permissionContent } = detectPermissionRequest(text, commandId);
|
|
1320
1319
|
if (detected) {
|
|
1321
1320
|
handlePermissionRequest(commandId, promptId, channel, claude, permissionContent);
|
|
1322
1321
|
}
|
|
@@ -1348,6 +1347,11 @@ ${content}${attachmentContext}`;
|
|
|
1348
1347
|
if (promptId)
|
|
1349
1348
|
promptIdToCommandId.delete(promptId);
|
|
1350
1349
|
pendingSupervisionCallbacks.delete(commandId);
|
|
1350
|
+
// Clean up per-execution buffers (concurrent-safe)
|
|
1351
|
+
outputBufferMap.delete(commandId);
|
|
1352
|
+
detectedRequirementsMap.delete(commandId);
|
|
1353
|
+
qaBufferMap.delete(commandId);
|
|
1354
|
+
qaDetectedMap.delete(commandId);
|
|
1351
1355
|
const exitCode = code ?? 0;
|
|
1352
1356
|
const duration = Date.now() - startTime;
|
|
1353
1357
|
const status = exitCode === 0 ? 'completed' : 'failed';
|
|
@@ -1864,6 +1868,156 @@ export async function generatePlanItems(options) {
|
|
|
1864
1868
|
async function sendViaFreshChannel(_channelName, channel, generationId, planId, items, error) {
|
|
1865
1869
|
await sendPlanItemsGenerated(channel, generationId, planId, items, error);
|
|
1866
1870
|
}
|
|
1871
|
+
/**
|
|
1872
|
+
* Agent Chat — conversational mode for discussing the project.
|
|
1873
|
+
* Runs Claude CLI in read-only mode (no file edits), streams the response
|
|
1874
|
+
* back via Socket.io. Does NOT use the execution queue — safe to run
|
|
1875
|
+
* concurrently with prompt execution since it's read-only.
|
|
1876
|
+
*/
|
|
1877
|
+
export async function agentChat(options) {
|
|
1878
|
+
const { requestId, sessionId, content, context, workingDirectory, channel } = options;
|
|
1879
|
+
const cwd = workingDirectory || process.cwd();
|
|
1880
|
+
logger.info(`[AgentChat] Starting chat: ${content.slice(0, 80)}...`);
|
|
1881
|
+
// Build environment
|
|
1882
|
+
const env = {
|
|
1883
|
+
...process.env,
|
|
1884
|
+
...injectedCredentials,
|
|
1885
|
+
CI: 'true',
|
|
1886
|
+
};
|
|
1887
|
+
if (anthropicApiKey) {
|
|
1888
|
+
env.ANTHROPIC_API_KEY = anthropicApiKey;
|
|
1889
|
+
}
|
|
1890
|
+
// Remove Claude Code session detection env vars
|
|
1891
|
+
delete env.CLAUDECODE;
|
|
1892
|
+
delete env.CLAUDE_CODE_ENTRYPOINT;
|
|
1893
|
+
// Build conversational prompt with history
|
|
1894
|
+
let fullPrompt = `You are participating in a team discussion about this project/codebase.
|
|
1895
|
+
You are in READ-ONLY mode — do NOT create, modify, or delete any files.
|
|
1896
|
+
Answer questions, analyze code, explain architecture, suggest approaches, and help plan.
|
|
1897
|
+
Be concise and conversational — this is a meeting, not a formal report.
|
|
1898
|
+
You can read files and explore the codebase to answer questions.
|
|
1899
|
+
|
|
1900
|
+
`;
|
|
1901
|
+
// Include conversation history
|
|
1902
|
+
if (context.length > 0) {
|
|
1903
|
+
fullPrompt += `Previous conversation:\n`;
|
|
1904
|
+
for (const msg of context.slice(-20)) { // Last 20 messages for context
|
|
1905
|
+
const role = msg.role === 'user' ? 'Human' : 'Assistant';
|
|
1906
|
+
fullPrompt += `${role}: ${msg.content}\n\n`;
|
|
1907
|
+
}
|
|
1908
|
+
fullPrompt += `Now respond to:\n`;
|
|
1909
|
+
}
|
|
1910
|
+
fullPrompt += content;
|
|
1911
|
+
// Escape for shell
|
|
1912
|
+
const escapedContent = fullPrompt.replace(/'/g, "'\\''");
|
|
1913
|
+
// Select CLI
|
|
1914
|
+
const { cli: selectedCli } = selectCli();
|
|
1915
|
+
const cliCommand = selectedCli || 'claude';
|
|
1916
|
+
const command = `${cliCommand} -p '${escapedContent}' --dangerously-skip-permissions --output-format stream-json`;
|
|
1917
|
+
const chatProcess = spawn('script', ['-q', '-c', command, '/dev/null'], {
|
|
1918
|
+
cwd,
|
|
1919
|
+
env,
|
|
1920
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1921
|
+
});
|
|
1922
|
+
logger.info(`[AgentChat] Process spawned with PID: ${chatProcess.pid}`);
|
|
1923
|
+
let jsonBuffer = '';
|
|
1924
|
+
let textBuffer = '';
|
|
1925
|
+
const parseAndStream = (text) => {
|
|
1926
|
+
jsonBuffer += text;
|
|
1927
|
+
const lines = jsonBuffer.split('\n');
|
|
1928
|
+
jsonBuffer = lines.pop() || '';
|
|
1929
|
+
for (const line of lines) {
|
|
1930
|
+
if (!line.trim())
|
|
1931
|
+
continue;
|
|
1932
|
+
try {
|
|
1933
|
+
const json = JSON.parse(line);
|
|
1934
|
+
// Handle Claude stream-json format
|
|
1935
|
+
if (json.type === 'assistant' && json.subtype === 'thinking') {
|
|
1936
|
+
// Stream thinking content
|
|
1937
|
+
const thinking = json.thinking || '';
|
|
1938
|
+
if (thinking) {
|
|
1939
|
+
sendAgentChatOutput(channel, requestId, sessionId, 'thinking', thinking)
|
|
1940
|
+
.catch(err => logger.error(`[AgentChat] Failed to send thinking: ${err}`));
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
else if (json.type === 'content_block_delta') {
|
|
1944
|
+
const delta = json.delta;
|
|
1945
|
+
if (delta?.type === 'text_delta' && delta.text) {
|
|
1946
|
+
textBuffer += delta.text;
|
|
1947
|
+
sendAgentChatOutput(channel, requestId, sessionId, 'text', delta.text)
|
|
1948
|
+
.catch(err => logger.error(`[AgentChat] Failed to send text: ${err}`));
|
|
1949
|
+
}
|
|
1950
|
+
else if (delta?.type === 'thinking_delta' && delta.thinking) {
|
|
1951
|
+
sendAgentChatOutput(channel, requestId, sessionId, 'thinking', delta.thinking)
|
|
1952
|
+
.catch(err => logger.error(`[AgentChat] Failed to send thinking: ${err}`));
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
else if (json.type === 'assistant') {
|
|
1956
|
+
// Full assistant message — extract text content
|
|
1957
|
+
if (json.content) {
|
|
1958
|
+
for (const block of json.content) {
|
|
1959
|
+
if (block.type === 'text' && block.text) {
|
|
1960
|
+
textBuffer += block.text;
|
|
1961
|
+
sendAgentChatOutput(channel, requestId, sessionId, 'text', block.text)
|
|
1962
|
+
.catch(err => logger.error(`[AgentChat] Failed to send text: ${err}`));
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
// Also check for thinking at message level
|
|
1967
|
+
if (json.thinking) {
|
|
1968
|
+
sendAgentChatOutput(channel, requestId, sessionId, 'thinking', json.thinking)
|
|
1969
|
+
.catch(err => logger.error(`[AgentChat] Failed to send thinking: ${err}`));
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
else if (json.type === 'result') {
|
|
1973
|
+
// End of response — extract final text if not already streamed
|
|
1974
|
+
if (json.result && !textBuffer) {
|
|
1975
|
+
sendAgentChatOutput(channel, requestId, sessionId, 'text', json.result)
|
|
1976
|
+
.catch(err => logger.error(`[AgentChat] Failed to send result: ${err}`));
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
// Ignore tool_use/tool_result blocks — chat is conversational
|
|
1980
|
+
}
|
|
1981
|
+
catch {
|
|
1982
|
+
// Not valid JSON — might be plain text output
|
|
1983
|
+
if (line.trim() && !line.startsWith('{')) {
|
|
1984
|
+
textBuffer += line + '\n';
|
|
1985
|
+
sendAgentChatOutput(channel, requestId, sessionId, 'text', line + '\n')
|
|
1986
|
+
.catch(err => logger.error(`[AgentChat] Failed to send plain text: ${err}`));
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
};
|
|
1991
|
+
return new Promise((resolve) => {
|
|
1992
|
+
chatProcess.stdout?.on('data', (data) => {
|
|
1993
|
+
parseAndStream(data.toString());
|
|
1994
|
+
});
|
|
1995
|
+
chatProcess.stderr?.on('data', (data) => {
|
|
1996
|
+
const text = data.toString();
|
|
1997
|
+
// Ignore common stderr noise from script command
|
|
1998
|
+
if (!text.includes('Script started') && !text.includes('Script done')) {
|
|
1999
|
+
logger.debug(`[AgentChat] stderr: ${text.slice(0, 200)}`);
|
|
2000
|
+
}
|
|
2001
|
+
});
|
|
2002
|
+
chatProcess.on('close', (exitCode) => {
|
|
2003
|
+
logger.info(`[AgentChat] Process exited with code: ${exitCode}`);
|
|
2004
|
+
// Flush any remaining buffer
|
|
2005
|
+
if (jsonBuffer.trim()) {
|
|
2006
|
+
parseAndStream('\n');
|
|
2007
|
+
}
|
|
2008
|
+
// Send done event
|
|
2009
|
+
sendAgentChatOutput(channel, requestId, sessionId, 'done', textBuffer || '')
|
|
2010
|
+
.catch(err => logger.error(`[AgentChat] Failed to send done: ${err}`))
|
|
2011
|
+
.finally(() => resolve());
|
|
2012
|
+
});
|
|
2013
|
+
chatProcess.on('error', (err) => {
|
|
2014
|
+
logger.error(`[AgentChat] Process error: ${err.message}`);
|
|
2015
|
+
sendAgentChatOutput(channel, requestId, sessionId, 'error', err.message)
|
|
2016
|
+
.catch(e => logger.error(`[AgentChat] Failed to send error: ${e}`))
|
|
2017
|
+
.finally(() => resolve());
|
|
2018
|
+
});
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
1867
2021
|
// Track active interactive session (only one at a time)
|
|
1868
2022
|
let activeSession = null;
|
|
1869
2023
|
// Callback fired when a session ends — allows index.ts to drain the prompt queue
|