snow-ai 0.6.4 → 0.6.6
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/bundle/cli.mjs +247 -86
- package/bundle/package.json +1 -1
- package/package.json +1 -1
package/bundle/cli.mjs
CHANGED
|
@@ -81046,7 +81046,7 @@ var init_en = __esm({
|
|
|
81046
81046
|
toolRejected: "\u2717 Rejected",
|
|
81047
81047
|
// Parallel execution
|
|
81048
81048
|
parallelStart: "\u250C\u2500 Parallel execution",
|
|
81049
|
-
parallelEnd: "\u2514\u2500
|
|
81049
|
+
parallelEnd: "\u2514\u2500 Execution completed",
|
|
81050
81050
|
// Messages
|
|
81051
81051
|
userMessage: "You",
|
|
81052
81052
|
assistantMessage: "Assistant",
|
|
@@ -82132,7 +82132,7 @@ var init_zh = __esm({
|
|
|
82132
82132
|
toolRejected: "\u2717 \u5DF2\u62D2\u7EDD",
|
|
82133
82133
|
// Parallel execution
|
|
82134
82134
|
parallelStart: "\u250C\u2500 \u5E76\u884C\u6267\u884C",
|
|
82135
|
-
parallelEnd: "\u2514\u2500 \
|
|
82135
|
+
parallelEnd: "\u2514\u2500 \u6267\u884C\u5B8C\u6210",
|
|
82136
82136
|
// Messages
|
|
82137
82137
|
userMessage: "\u4F60",
|
|
82138
82138
|
assistantMessage: "\u52A9\u624B",
|
|
@@ -83218,7 +83218,7 @@ var init_zh_TW = __esm({
|
|
|
83218
83218
|
toolRejected: "\u2717 \u5DF2\u62D2\u7D55",
|
|
83219
83219
|
// Parallel execution
|
|
83220
83220
|
parallelStart: "\u250C\u2500 \u4E26\u884C\u57F7\u884C",
|
|
83221
|
-
parallelEnd: "\u2514\u2500 \
|
|
83221
|
+
parallelEnd: "\u2514\u2500 \u57F7\u884C\u5B8C\u6210",
|
|
83222
83222
|
// Messages
|
|
83223
83223
|
userMessage: "\u4F60",
|
|
83224
83224
|
assistantMessage: "\u52A9\u624B",
|
|
@@ -536474,8 +536474,8 @@ function MessageRenderer({ message, index, isLastMessage, filteredMessages, term
|
|
|
536474
536474
|
const isFirstInGroup = shouldShowParallelIndicator && (index === 0 || ((_a21 = filteredMessages[index - 1]) == null ? void 0 : _a21.parallelGroup) !== message.parallelGroup || // Previous message is time-consuming tool, so this is the first non-time-consuming one
|
|
536475
536475
|
((_b14 = filteredMessages[index - 1]) == null ? void 0 : _b14.toolPending) || ((_c6 = filteredMessages[index - 1]) == null ? void 0 : _c6.messageStatus) === "pending");
|
|
536476
536476
|
const nextMessage = filteredMessages[index + 1];
|
|
536477
|
-
const
|
|
536478
|
-
const isLastInGroup = shouldShowParallelIndicator &&
|
|
536477
|
+
const nextInSameGroup = nextMessage && nextMessage.parallelGroup !== void 0 && nextMessage.parallelGroup !== null && nextMessage.parallelGroup === message.parallelGroup;
|
|
536478
|
+
const isLastInGroup = shouldShowParallelIndicator && !nextInSameGroup;
|
|
536479
536479
|
if (message.role === "assistant" || message.role === "subagent") {
|
|
536480
536480
|
if (message.messageStatus === "pending") {
|
|
536481
536481
|
toolStatusColor = "yellowBright";
|
|
@@ -536493,7 +536493,7 @@ function MessageRenderer({ message, index, isLastMessage, filteredMessages, term
|
|
|
536493
536493
|
isFirstInGroup && import_react77.default.createElement(
|
|
536494
536494
|
Box_default,
|
|
536495
536495
|
{ marginBottom: 0 },
|
|
536496
|
-
import_react77.default.createElement(Text, { color: theme14.colors.menuInfo, dimColor: true },
|
|
536496
|
+
import_react77.default.createElement(Text, { color: theme14.colors.menuInfo, dimColor: true }, t.chatScreen.parallelStart)
|
|
536497
536497
|
),
|
|
536498
536498
|
import_react77.default.createElement(
|
|
536499
536499
|
Box_default,
|
|
@@ -536624,7 +536624,7 @@ function MessageRenderer({ message, index, isLastMessage, filteredMessages, term
|
|
|
536624
536624
|
!message.plainOutput && isLastInGroup && import_react77.default.createElement(
|
|
536625
536625
|
Box_default,
|
|
536626
536626
|
{ marginTop: 0 },
|
|
536627
|
-
import_react77.default.createElement(Text, { color: theme14.colors.menuInfo, dimColor: true },
|
|
536627
|
+
import_react77.default.createElement(Text, { color: theme14.colors.menuInfo, dimColor: true }, t.chatScreen.parallelEnd)
|
|
536628
536628
|
)
|
|
536629
536629
|
));
|
|
536630
536630
|
}
|
|
@@ -542994,10 +542994,20 @@ function TodoTree({ todos }) {
|
|
|
542994
542994
|
}
|
|
542995
542995
|
const completedCount = todos.filter((t) => t.status === "completed").length;
|
|
542996
542996
|
const totalCount = todos.length;
|
|
542997
|
-
const
|
|
542997
|
+
const MAX_VISIBLE_COMPLETED = 5;
|
|
542998
|
+
const pendingTodos = todos.filter((t) => t.status === "pending");
|
|
542999
|
+
const completedTodos = todos.filter((t) => t.status === "completed");
|
|
543000
|
+
const visibleCompletedTodos = completedTodos.slice(-MAX_VISIBLE_COMPLETED);
|
|
543001
|
+
const hiddenCompletedCount = completedTodos.length - visibleCompletedTodos.length;
|
|
543002
|
+
const visibleTodoIds = /* @__PURE__ */ new Set([
|
|
543003
|
+
...pendingTodos.map((t) => t.id),
|
|
543004
|
+
...visibleCompletedTodos.map((t) => t.id)
|
|
543005
|
+
]);
|
|
543006
|
+
const visibleTodos = [...pendingTodos, ...visibleCompletedTodos];
|
|
543007
|
+
const rootTodos = visibleTodos.filter((t) => !t.parentId || !visibleTodoIds.has(t.parentId));
|
|
542998
543008
|
const childTodosMap = /* @__PURE__ */ new Map();
|
|
542999
|
-
|
|
543000
|
-
if (todo.parentId) {
|
|
543009
|
+
visibleTodos.forEach((todo) => {
|
|
543010
|
+
if (todo.parentId && visibleTodoIds.has(todo.parentId)) {
|
|
543001
543011
|
const children = childTodosMap.get(todo.parentId) || [];
|
|
543002
543012
|
children.push(todo);
|
|
543003
543013
|
childTodosMap.set(todo.parentId, children);
|
|
@@ -543054,6 +543064,13 @@ function TodoTree({ todos }) {
|
|
|
543054
543064
|
"/",
|
|
543055
543065
|
totalCount,
|
|
543056
543066
|
")"
|
|
543067
|
+
),
|
|
543068
|
+
hiddenCompletedCount > 0 && import_react101.default.createElement(
|
|
543069
|
+
Text,
|
|
543070
|
+
{ dimColor: true },
|
|
543071
|
+
" +",
|
|
543072
|
+
hiddenCompletedCount,
|
|
543073
|
+
" completed hidden"
|
|
543057
543074
|
)
|
|
543058
543075
|
),
|
|
543059
543076
|
rootTodos.map((todo, index) => renderTodo(todo, 0, index === rootTodos.length - 1, []))
|
|
@@ -544112,9 +544129,10 @@ function BashCommandExecutionStatus({ command, timeout: timeout2 = 3e4, terminal
|
|
|
544112
544129
|
const timeoutSeconds = Math.round(timeout2 / 1e3);
|
|
544113
544130
|
const maxCommandWidth = Math.max(40, terminalWidth - 10);
|
|
544114
544131
|
const displayCommand = truncateCommand2(command, maxCommandWidth);
|
|
544132
|
+
const processedOutput = output2.flatMap((line) => line.split(/\r?\n/)).slice(-5);
|
|
544115
544133
|
return import_react108.default.createElement(
|
|
544116
544134
|
Box_default,
|
|
544117
|
-
{ flexDirection: "column",
|
|
544135
|
+
{ flexDirection: "column", paddingX: 1 },
|
|
544118
544136
|
import_react108.default.createElement(
|
|
544119
544137
|
Box_default,
|
|
544120
544138
|
null,
|
|
@@ -544131,7 +544149,7 @@ function BashCommandExecutionStatus({ command, timeout: timeout2 = 3e4, terminal
|
|
|
544131
544149
|
{ paddingLeft: 2 },
|
|
544132
544150
|
import_react108.default.createElement(Text, { dimColor: true }, displayCommand)
|
|
544133
544151
|
),
|
|
544134
|
-
|
|
544152
|
+
import_react108.default.createElement(Box_default, { flexDirection: "column", paddingLeft: 2, marginTop: 1, height: 5 }, processedOutput.map((line, index) => import_react108.default.createElement(Text, { key: index, wrap: "truncate", dimColor: true }, truncateText(line, maxCommandWidth)))),
|
|
544135
544153
|
import_react108.default.createElement(
|
|
544136
544154
|
Box_default,
|
|
544137
544155
|
{ flexDirection: "column", gap: 0 },
|
|
@@ -544210,7 +544228,7 @@ function CustomCommandExecutionDisplay({ commandName, isRunning, output: output2
|
|
|
544210
544228
|
)
|
|
544211
544229
|
)
|
|
544212
544230
|
),
|
|
544213
|
-
|
|
544231
|
+
import_react109.default.createElement(Box_default, { flexDirection: "column", paddingLeft: 2, height: 5 }, output2.flatMap((line) => line.split(/\r?\n/)).slice(-5).map((line, index) => import_react109.default.createElement(Text, { key: index, wrap: "truncate", dimColor: true }, truncateText2(line, 100)))),
|
|
544214
544232
|
error && import_react109.default.createElement(
|
|
544215
544233
|
Box_default,
|
|
544216
544234
|
{ paddingLeft: 2 },
|
|
@@ -548336,6 +548354,10 @@ var init_toolDisplayConfig = __esm({
|
|
|
548336
548354
|
});
|
|
548337
548355
|
|
|
548338
548356
|
// dist/utils/core/contextCompressor.js
|
|
548357
|
+
var contextCompressor_exports = {};
|
|
548358
|
+
__export(contextCompressor_exports, {
|
|
548359
|
+
compressContext: () => compressContext
|
|
548360
|
+
});
|
|
548339
548361
|
function findPreserveStartIndex(messages) {
|
|
548340
548362
|
if (messages.length === 0) {
|
|
548341
548363
|
return 0;
|
|
@@ -548445,6 +548467,45 @@ function cleanOrphanedToolCalls(messages) {
|
|
|
548445
548467
|
console.log(`[contextCompressor:cleanOrphanedToolCalls] Removed ${indicesToRemove.length} orphaned messages from compression input`);
|
|
548446
548468
|
}
|
|
548447
548469
|
}
|
|
548470
|
+
function formatMessageForTranscript(msg) {
|
|
548471
|
+
var _a21, _b14;
|
|
548472
|
+
if (msg.role === "tool") {
|
|
548473
|
+
return null;
|
|
548474
|
+
}
|
|
548475
|
+
const parts = [];
|
|
548476
|
+
const roleLabel = msg.role === "user" ? "[User]" : "[Assistant]";
|
|
548477
|
+
if (msg.role === "assistant" && msg.tool_calls && msg.tool_calls.length > 0) {
|
|
548478
|
+
if (msg.content) {
|
|
548479
|
+
parts.push(`${roleLabel}
|
|
548480
|
+
${msg.content}`);
|
|
548481
|
+
} else {
|
|
548482
|
+
parts.push(roleLabel);
|
|
548483
|
+
}
|
|
548484
|
+
for (const tc of msg.tool_calls) {
|
|
548485
|
+
const funcName = ((_a21 = tc.function) == null ? void 0 : _a21.name) || "unknown";
|
|
548486
|
+
const args2 = ((_b14 = tc.function) == null ? void 0 : _b14.arguments) || "{}";
|
|
548487
|
+
parts.push(` -> Tool Call: ${funcName}(${args2})`);
|
|
548488
|
+
}
|
|
548489
|
+
return parts.join("\n");
|
|
548490
|
+
}
|
|
548491
|
+
if (msg.content) {
|
|
548492
|
+
parts.push(`${roleLabel}
|
|
548493
|
+
${msg.content}`);
|
|
548494
|
+
}
|
|
548495
|
+
if (msg.thinking) {
|
|
548496
|
+
parts.push(`[Thinking]
|
|
548497
|
+
${msg.thinking}`);
|
|
548498
|
+
}
|
|
548499
|
+
if (msg.reasoning) {
|
|
548500
|
+
parts.push(`[Reasoning]
|
|
548501
|
+
${msg.reasoning}`);
|
|
548502
|
+
}
|
|
548503
|
+
if (msg.reasoning_content) {
|
|
548504
|
+
parts.push(`[Reasoning]
|
|
548505
|
+
${msg.reasoning_content}`);
|
|
548506
|
+
}
|
|
548507
|
+
return parts.length > 0 ? parts.join("\n") : null;
|
|
548508
|
+
}
|
|
548448
548509
|
function prepareMessagesForCompression(conversationMessages, customSystemPrompt) {
|
|
548449
548510
|
const messages = [];
|
|
548450
548511
|
if (customSystemPrompt) {
|
|
@@ -548455,31 +548516,23 @@ function prepareMessagesForCompression(conversationMessages, customSystemPrompt)
|
|
|
548455
548516
|
content: getSystemPromptForMode(false, false)
|
|
548456
548517
|
});
|
|
548457
548518
|
}
|
|
548519
|
+
const transcriptParts = [];
|
|
548458
548520
|
for (const msg of conversationMessages) {
|
|
548459
|
-
if (msg.role
|
|
548460
|
-
|
|
548461
|
-
|
|
548462
|
-
|
|
548463
|
-
|
|
548464
|
-
|
|
548465
|
-
compressMsg.tool_calls = msg.tool_calls;
|
|
548466
|
-
}
|
|
548467
|
-
if (msg.tool_call_id) {
|
|
548468
|
-
compressMsg.tool_call_id = msg.tool_call_id;
|
|
548469
|
-
}
|
|
548470
|
-
if (msg.reasoning) {
|
|
548471
|
-
compressMsg.reasoning = msg.reasoning;
|
|
548472
|
-
}
|
|
548473
|
-
if (msg.thinking) {
|
|
548474
|
-
compressMsg.thinking = msg.thinking;
|
|
548475
|
-
}
|
|
548476
|
-
if (msg.reasoning_content) {
|
|
548477
|
-
compressMsg.reasoning_content = msg.reasoning_content;
|
|
548478
|
-
}
|
|
548479
|
-
messages.push(compressMsg);
|
|
548521
|
+
if (msg.role === "system") {
|
|
548522
|
+
continue;
|
|
548523
|
+
}
|
|
548524
|
+
const formatted = formatMessageForTranscript(msg);
|
|
548525
|
+
if (formatted) {
|
|
548526
|
+
transcriptParts.push(formatted);
|
|
548480
548527
|
}
|
|
548481
548528
|
}
|
|
548482
|
-
|
|
548529
|
+
const conversationTranscript = transcriptParts.join("\n\n---\n\n");
|
|
548530
|
+
messages.push({
|
|
548531
|
+
role: "user",
|
|
548532
|
+
content: `## Conversation History to Compress
|
|
548533
|
+
|
|
548534
|
+
${conversationTranscript}`
|
|
548535
|
+
});
|
|
548483
548536
|
messages.push({
|
|
548484
548537
|
role: "user",
|
|
548485
548538
|
content: COMPRESSION_PROMPT
|
|
@@ -548707,57 +548760,59 @@ var init_contextCompressor = __esm({
|
|
|
548707
548760
|
init_responses();
|
|
548708
548761
|
init_gemini();
|
|
548709
548762
|
init_anthropic();
|
|
548710
|
-
COMPRESSION_PROMPT = `**
|
|
548711
|
-
|
|
548712
|
-
You are a
|
|
548713
|
-
|
|
548714
|
-
|
|
548715
|
-
|
|
548716
|
-
##
|
|
548717
|
-
-
|
|
548718
|
-
-
|
|
548719
|
-
-
|
|
548720
|
-
|
|
548721
|
-
## Technical
|
|
548722
|
-
-
|
|
548723
|
-
-
|
|
548724
|
-
-
|
|
548725
|
-
-
|
|
548726
|
-
|
|
548727
|
-
|
|
548728
|
-
|
|
548729
|
-
-
|
|
548730
|
-
-
|
|
548731
|
-
-
|
|
548732
|
-
|
|
548733
|
-
|
|
548734
|
-
|
|
548735
|
-
|
|
548736
|
-
-
|
|
548737
|
-
|
|
548738
|
-
|
|
548739
|
-
-
|
|
548740
|
-
|
|
548741
|
-
|
|
548742
|
-
-
|
|
548743
|
-
|
|
548744
|
-
|
|
548745
|
-
-
|
|
548746
|
-
|
|
548747
|
-
|
|
548748
|
-
-
|
|
548749
|
-
|
|
548750
|
-
|
|
548751
|
-
|
|
548752
|
-
|
|
548753
|
-
|
|
548754
|
-
|
|
548755
|
-
|
|
548756
|
-
|
|
548757
|
-
|
|
548758
|
-
|
|
548759
|
-
|
|
548760
|
-
|
|
548763
|
+
COMPRESSION_PROMPT = `**TASK: Create a comprehensive handover document from the conversation history above.**
|
|
548764
|
+
|
|
548765
|
+
You are creating a technical handover document. Extract and preserve all critical information with rigorous detail and accuracy. This is NOT a task continuation prompt - this is archival documentation.
|
|
548766
|
+
|
|
548767
|
+
**OUTPUT FORMAT - Structured Handover Document:**
|
|
548768
|
+
|
|
548769
|
+
## Project/Task Overview
|
|
548770
|
+
- Project or task being worked on
|
|
548771
|
+
- Objectives and expected outcomes
|
|
548772
|
+
- Current completion status
|
|
548773
|
+
|
|
548774
|
+
## Technical Environment
|
|
548775
|
+
- Technologies, frameworks, libraries, and tools in use
|
|
548776
|
+
- **EXACT** file paths (full paths, not relative)
|
|
548777
|
+
- **EXACT** function names, class names, variable names
|
|
548778
|
+
- Architecture patterns and design decisions
|
|
548779
|
+
- Configuration details and environment specifics
|
|
548780
|
+
|
|
548781
|
+
## Implementation Details
|
|
548782
|
+
- Technical decisions made and rationale
|
|
548783
|
+
- Chosen approaches and implementation methods
|
|
548784
|
+
- Solutions applied to specific problems
|
|
548785
|
+
- Code patterns and best practices used
|
|
548786
|
+
- **EXACT** code snippets where relevant (preserve syntax)
|
|
548787
|
+
|
|
548788
|
+
## Work Completed
|
|
548789
|
+
- Features implemented (with file references)
|
|
548790
|
+
- Bugs fixed (with root cause analysis)
|
|
548791
|
+
- Code modifications made (with before/after context)
|
|
548792
|
+
- Test results and validation outcomes
|
|
548793
|
+
|
|
548794
|
+
## Work In Progress
|
|
548795
|
+
- Incomplete tasks (with specific blocking reasons)
|
|
548796
|
+
- Known issues and their diagnostic details
|
|
548797
|
+
- Planned next steps (concrete, actionable)
|
|
548798
|
+
- Open questions requiring decisions
|
|
548799
|
+
|
|
548800
|
+
## Critical Reference Data
|
|
548801
|
+
- Important IDs, keys, values (sanitize credentials)
|
|
548802
|
+
- Error messages and stack traces (exact wording)
|
|
548803
|
+
- User requirements and constraints (explicit details)
|
|
548804
|
+
- Edge cases and special handling requirements
|
|
548805
|
+
|
|
548806
|
+
**QUALITY REQUIREMENTS:**
|
|
548807
|
+
1. Preserve EXACT technical terms - never paraphrase code/file names
|
|
548808
|
+
2. Include FULL context - paths, versions, configurations
|
|
548809
|
+
3. Maintain PRECISION - specific line numbers, exact error messages
|
|
548810
|
+
4. NO assumptions - only document what was explicitly discussed
|
|
548811
|
+
5. NO vague summaries - provide actionable, specific details
|
|
548812
|
+
6. Use markdown code blocks for code snippets with language tags
|
|
548813
|
+
7. Structure information hierarchically for easy scanning
|
|
548814
|
+
|
|
548815
|
+
**EXECUTE NOW - Output the handover document immediately.**`;
|
|
548761
548816
|
}
|
|
548762
548817
|
});
|
|
548763
548818
|
|
|
@@ -549197,6 +549252,14 @@ Output: ${combinedOutput}`;
|
|
|
549197
549252
|
commandName
|
|
549198
549253
|
};
|
|
549199
549254
|
options3.setMessages((prev) => [...prev, commandMessage]);
|
|
549255
|
+
} else if (result2.success && result2.action === "showMcpPanel") {
|
|
549256
|
+
options3.setShowMcpPanel(true);
|
|
549257
|
+
const commandMessage = {
|
|
549258
|
+
role: "command",
|
|
549259
|
+
content: "",
|
|
549260
|
+
commandName
|
|
549261
|
+
};
|
|
549262
|
+
options3.setMessages((prev) => [...prev, commandMessage]);
|
|
549200
549263
|
} else if (result2.success && result2.action === "showUsagePanel") {
|
|
549201
549264
|
options3.setShowUsagePanel(true);
|
|
549202
549265
|
const commandMessage = {
|
|
@@ -558579,6 +558642,10 @@ var init_sse_server = __esm({
|
|
|
558579
558642
|
}));
|
|
558580
558643
|
return;
|
|
558581
558644
|
}
|
|
558645
|
+
if (pathname === "/context/compress" && req.method === "POST") {
|
|
558646
|
+
this.handleContextCompress(req, res);
|
|
558647
|
+
return;
|
|
558648
|
+
}
|
|
558582
558649
|
res.writeHead(404);
|
|
558583
558650
|
res.end("Not Found");
|
|
558584
558651
|
}
|
|
@@ -558776,6 +558843,93 @@ var init_sse_server = __esm({
|
|
|
558776
558843
|
}
|
|
558777
558844
|
})();
|
|
558778
558845
|
}
|
|
558846
|
+
/**
|
|
558847
|
+
* 处理上下文压缩请求
|
|
558848
|
+
* POST /context/compress
|
|
558849
|
+
* Body: { messages: ChatMessage[] } 或 { sessionId: string }
|
|
558850
|
+
* Response: { success: true, result: CompressionResult } 或 { success: false, error: string }
|
|
558851
|
+
*/
|
|
558852
|
+
handleContextCompress(req, res) {
|
|
558853
|
+
void (async () => {
|
|
558854
|
+
try {
|
|
558855
|
+
const { compressContext: compressContext2 } = await Promise.resolve().then(() => (init_contextCompressor(), contextCompressor_exports));
|
|
558856
|
+
const { sessionManager: sessionManager2 } = await Promise.resolve().then(() => (init_sessionManager(), sessionManager_exports));
|
|
558857
|
+
const body = await this.readJsonBody(req);
|
|
558858
|
+
let messages;
|
|
558859
|
+
if (body.messages && Array.isArray(body.messages)) {
|
|
558860
|
+
messages = body.messages;
|
|
558861
|
+
} else if (body.sessionId) {
|
|
558862
|
+
const session = await sessionManager2.loadSession(body.sessionId);
|
|
558863
|
+
if (!session) {
|
|
558864
|
+
res.writeHead(404, {
|
|
558865
|
+
"Content-Type": "application/json",
|
|
558866
|
+
"Access-Control-Allow-Origin": "*"
|
|
558867
|
+
});
|
|
558868
|
+
res.end(JSON.stringify({ success: false, error: "Session not found" }));
|
|
558869
|
+
return;
|
|
558870
|
+
}
|
|
558871
|
+
messages = session.messages || [];
|
|
558872
|
+
} else {
|
|
558873
|
+
res.writeHead(400, {
|
|
558874
|
+
"Content-Type": "application/json",
|
|
558875
|
+
"Access-Control-Allow-Origin": "*"
|
|
558876
|
+
});
|
|
558877
|
+
res.end(JSON.stringify({
|
|
558878
|
+
success: false,
|
|
558879
|
+
error: "Missing required field: messages or sessionId"
|
|
558880
|
+
}));
|
|
558881
|
+
return;
|
|
558882
|
+
}
|
|
558883
|
+
if (messages.length === 0) {
|
|
558884
|
+
res.writeHead(400, {
|
|
558885
|
+
"Content-Type": "application/json",
|
|
558886
|
+
"Access-Control-Allow-Origin": "*"
|
|
558887
|
+
});
|
|
558888
|
+
res.end(JSON.stringify({ success: false, error: "No messages to compress" }));
|
|
558889
|
+
return;
|
|
558890
|
+
}
|
|
558891
|
+
const result2 = await compressContext2(messages);
|
|
558892
|
+
if (result2 === null) {
|
|
558893
|
+
res.writeHead(200, {
|
|
558894
|
+
"Content-Type": "application/json",
|
|
558895
|
+
"Access-Control-Allow-Origin": "*"
|
|
558896
|
+
});
|
|
558897
|
+
res.end(JSON.stringify({
|
|
558898
|
+
success: true,
|
|
558899
|
+
result: null,
|
|
558900
|
+
message: "Compression skipped (no history to compress)"
|
|
558901
|
+
}));
|
|
558902
|
+
return;
|
|
558903
|
+
}
|
|
558904
|
+
if (result2.hookFailed) {
|
|
558905
|
+
res.writeHead(200, {
|
|
558906
|
+
"Content-Type": "application/json",
|
|
558907
|
+
"Access-Control-Allow-Origin": "*"
|
|
558908
|
+
});
|
|
558909
|
+
res.end(JSON.stringify({
|
|
558910
|
+
success: false,
|
|
558911
|
+
hookFailed: true,
|
|
558912
|
+
hookErrorDetails: result2.hookErrorDetails
|
|
558913
|
+
}));
|
|
558914
|
+
return;
|
|
558915
|
+
}
|
|
558916
|
+
res.writeHead(200, {
|
|
558917
|
+
"Content-Type": "application/json",
|
|
558918
|
+
"Access-Control-Allow-Origin": "*"
|
|
558919
|
+
});
|
|
558920
|
+
res.end(JSON.stringify({ success: true, result: result2 }));
|
|
558921
|
+
} catch (error) {
|
|
558922
|
+
res.writeHead(500, {
|
|
558923
|
+
"Content-Type": "application/json",
|
|
558924
|
+
"Access-Control-Allow-Origin": "*"
|
|
558925
|
+
});
|
|
558926
|
+
res.end(JSON.stringify({
|
|
558927
|
+
success: false,
|
|
558928
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
558929
|
+
}));
|
|
558930
|
+
}
|
|
558931
|
+
})();
|
|
558932
|
+
}
|
|
558779
558933
|
/**
|
|
558780
558934
|
* 处理 SSE 连接
|
|
558781
558935
|
*/
|
|
@@ -559690,6 +559844,13 @@ var init_SSEServerStatus = __esm({
|
|
|
559690
559844
|
port,
|
|
559691
559845
|
"/session/:sessionId"
|
|
559692
559846
|
),
|
|
559847
|
+
import_react139.default.createElement(
|
|
559848
|
+
Text,
|
|
559849
|
+
{ color: "blue" },
|
|
559850
|
+
" POST http://localhost:",
|
|
559851
|
+
port,
|
|
559852
|
+
"/context/compress"
|
|
559853
|
+
),
|
|
559693
559854
|
import_react139.default.createElement(
|
|
559694
559855
|
Text,
|
|
559695
559856
|
{ color: "blue" },
|
package/bundle/package.json
CHANGED