@memtensor/memos-local-openclaw-plugin 0.1.2 → 0.1.4
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/.env.example +13 -5
- package/README.md +180 -68
- package/dist/capture/index.d.ts +5 -7
- package/dist/capture/index.d.ts.map +1 -1
- package/dist/capture/index.js +72 -43
- package/dist/capture/index.js.map +1 -1
- package/dist/ingest/providers/anthropic.d.ts +2 -0
- package/dist/ingest/providers/anthropic.d.ts.map +1 -1
- package/dist/ingest/providers/anthropic.js +110 -1
- package/dist/ingest/providers/anthropic.js.map +1 -1
- package/dist/ingest/providers/bedrock.d.ts +2 -5
- package/dist/ingest/providers/bedrock.d.ts.map +1 -1
- package/dist/ingest/providers/bedrock.js +110 -6
- package/dist/ingest/providers/bedrock.js.map +1 -1
- package/dist/ingest/providers/gemini.d.ts +2 -0
- package/dist/ingest/providers/gemini.d.ts.map +1 -1
- package/dist/ingest/providers/gemini.js +106 -1
- package/dist/ingest/providers/gemini.js.map +1 -1
- package/dist/ingest/providers/index.d.ts +9 -0
- package/dist/ingest/providers/index.d.ts.map +1 -1
- package/dist/ingest/providers/index.js +66 -4
- package/dist/ingest/providers/index.js.map +1 -1
- package/dist/ingest/providers/openai.d.ts +2 -0
- package/dist/ingest/providers/openai.d.ts.map +1 -1
- package/dist/ingest/providers/openai.js +112 -1
- package/dist/ingest/providers/openai.js.map +1 -1
- package/dist/ingest/task-processor.d.ts +63 -0
- package/dist/ingest/task-processor.d.ts.map +1 -0
- package/dist/ingest/task-processor.js +339 -0
- package/dist/ingest/task-processor.js.map +1 -0
- package/dist/ingest/worker.d.ts +1 -1
- package/dist/ingest/worker.d.ts.map +1 -1
- package/dist/ingest/worker.js +18 -13
- package/dist/ingest/worker.js.map +1 -1
- package/dist/recall/engine.d.ts +1 -0
- package/dist/recall/engine.d.ts.map +1 -1
- package/dist/recall/engine.js +21 -11
- package/dist/recall/engine.js.map +1 -1
- package/dist/recall/mmr.d.ts.map +1 -1
- package/dist/recall/mmr.js +3 -1
- package/dist/recall/mmr.js.map +1 -1
- package/dist/storage/sqlite.d.ts +67 -1
- package/dist/storage/sqlite.d.ts.map +1 -1
- package/dist/storage/sqlite.js +251 -5
- package/dist/storage/sqlite.js.map +1 -1
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/dist/viewer/html.d.ts +1 -1
- package/dist/viewer/html.d.ts.map +1 -1
- package/dist/viewer/html.js +955 -115
- package/dist/viewer/html.js.map +1 -1
- package/dist/viewer/server.d.ts +3 -0
- package/dist/viewer/server.d.ts.map +1 -1
- package/dist/viewer/server.js +59 -1
- package/dist/viewer/server.js.map +1 -1
- package/index.ts +221 -45
- package/openclaw.plugin.json +20 -45
- package/package.json +3 -4
- package/skill/SKILL.md +59 -0
- package/src/capture/index.ts +85 -45
- package/src/ingest/providers/anthropic.ts +128 -1
- package/src/ingest/providers/bedrock.ts +130 -6
- package/src/ingest/providers/gemini.ts +128 -1
- package/src/ingest/providers/index.ts +74 -8
- package/src/ingest/providers/openai.ts +130 -1
- package/src/ingest/task-processor.ts +380 -0
- package/src/ingest/worker.ts +21 -15
- package/src/recall/engine.ts +22 -12
- package/src/recall/mmr.ts +3 -1
- package/src/storage/sqlite.ts +298 -5
- package/src/types.ts +19 -0
- package/src/viewer/html.ts +955 -115
- package/src/viewer/server.ts +63 -1
- package/SKILL.md +0 -43
- package/www/index.html +0 -606
|
@@ -1,7 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.summarizeTaskAnthropic = summarizeTaskAnthropic;
|
|
4
|
+
exports.judgeNewTopicAnthropic = judgeNewTopicAnthropic;
|
|
3
5
|
exports.summarizeAnthropic = summarizeAnthropic;
|
|
4
|
-
const SYSTEM_PROMPT = `Summarize the text in ONE concise sentence (max
|
|
6
|
+
const SYSTEM_PROMPT = `Summarize the text in ONE concise sentence (max 120 characters). IMPORTANT: Use the SAME language as the input text — if the input is Chinese, write Chinese; if English, write English. Preserve exact names, commands, error codes. No bullet points, no preamble — output only the sentence.`;
|
|
7
|
+
const TASK_SUMMARY_PROMPT = `You create a DETAILED task summary from a multi-turn conversation. This summary will be the ONLY record of this conversation, so it must preserve ALL important information.
|
|
8
|
+
|
|
9
|
+
CRITICAL LANGUAGE RULE: You MUST write in the SAME language as the user's messages. Chinese input → Chinese output. English input → English output. NEVER mix languages.
|
|
10
|
+
|
|
11
|
+
Output EXACTLY this structure:
|
|
12
|
+
|
|
13
|
+
📌 Title
|
|
14
|
+
A short, descriptive title (10-30 characters). Like a chat group name.
|
|
15
|
+
|
|
16
|
+
🎯 Goal
|
|
17
|
+
One sentence: what the user wanted to accomplish.
|
|
18
|
+
|
|
19
|
+
📋 Key Steps
|
|
20
|
+
- Describe each meaningful step in detail
|
|
21
|
+
- Include the ACTUAL content produced: code snippets, commands, config blocks, formulas, key paragraphs
|
|
22
|
+
- For code: include the function signature and core logic (up to ~30 lines per block), use fenced code blocks
|
|
23
|
+
- For configs: include the actual config values and structure
|
|
24
|
+
- For lists/instructions: include the actual items, not just "provided a list"
|
|
25
|
+
- Merge only truly trivial back-and-forth (like "ok" / "sure")
|
|
26
|
+
- Do NOT over-summarize: "provided a function" is BAD; show the actual function
|
|
27
|
+
|
|
28
|
+
✅ Result
|
|
29
|
+
What was the final outcome? Include the final version of any code/config/content produced.
|
|
30
|
+
|
|
31
|
+
💡 Key Details
|
|
32
|
+
- Decisions made, trade-offs discussed, caveats noted, alternative approaches mentioned
|
|
33
|
+
- Specific values: numbers, versions, thresholds, URLs, file paths, model names
|
|
34
|
+
- Omit this section only if there truly are no noteworthy details
|
|
35
|
+
|
|
36
|
+
RULES:
|
|
37
|
+
- This summary is a KNOWLEDGE BASE ENTRY, not a brief note. Be thorough.
|
|
38
|
+
- PRESERVE verbatim: code, commands, URLs, file paths, error messages, config values, version numbers, names, amounts
|
|
39
|
+
- DISCARD only: greetings, filler, the assistant explaining what it will do before doing it
|
|
40
|
+
- Replace secrets (API keys, tokens, passwords) with [REDACTED]
|
|
41
|
+
- Target length: 30-50% of the original conversation length. Longer conversations need longer summaries.
|
|
42
|
+
- Output summary only, no preamble.`;
|
|
43
|
+
async function summarizeTaskAnthropic(text, cfg, log) {
|
|
44
|
+
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
|
|
45
|
+
const model = cfg.model ?? "claude-3-haiku-20240307";
|
|
46
|
+
const headers = {
|
|
47
|
+
"Content-Type": "application/json",
|
|
48
|
+
"x-api-key": cfg.apiKey ?? "",
|
|
49
|
+
"anthropic-version": "2023-06-01",
|
|
50
|
+
...cfg.headers,
|
|
51
|
+
};
|
|
52
|
+
const resp = await fetch(endpoint, {
|
|
53
|
+
method: "POST",
|
|
54
|
+
headers,
|
|
55
|
+
body: JSON.stringify({
|
|
56
|
+
model,
|
|
57
|
+
max_tokens: 4096,
|
|
58
|
+
temperature: cfg.temperature ?? 0.1,
|
|
59
|
+
system: TASK_SUMMARY_PROMPT,
|
|
60
|
+
messages: [{ role: "user", content: text }],
|
|
61
|
+
}),
|
|
62
|
+
signal: AbortSignal.timeout(cfg.timeoutMs ?? 60_000),
|
|
63
|
+
});
|
|
64
|
+
if (!resp.ok) {
|
|
65
|
+
const body = await resp.text();
|
|
66
|
+
throw new Error(`Anthropic task-summarize failed (${resp.status}): ${body}`);
|
|
67
|
+
}
|
|
68
|
+
const json = (await resp.json());
|
|
69
|
+
return json.content.find((c) => c.type === "text")?.text?.trim() ?? "";
|
|
70
|
+
}
|
|
71
|
+
const TOPIC_JUDGE_PROMPT = `You are a conversation topic boundary detector. Given a summary of the CURRENT conversation and a NEW user message, determine if the new message starts a DIFFERENT topic/task.
|
|
72
|
+
|
|
73
|
+
Answer ONLY "NEW" or "SAME".
|
|
74
|
+
|
|
75
|
+
Rules:
|
|
76
|
+
- "NEW" = the new message is about a completely different subject, project, or task
|
|
77
|
+
- "SAME" = the new message continues, follows up on, or is closely related to the current topic
|
|
78
|
+
- Follow-up questions, clarifications, refinements, bug fixes, or next steps on the same task = SAME
|
|
79
|
+
- Greetings or meta-questions like "你好" or "谢谢" without new substance = SAME
|
|
80
|
+
- A clearly unrelated request (e.g., current topic is deployment, new message asks about cooking) = NEW
|
|
81
|
+
|
|
82
|
+
Output exactly one word: NEW or SAME`;
|
|
83
|
+
async function judgeNewTopicAnthropic(currentContext, newMessage, cfg, log) {
|
|
84
|
+
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
|
|
85
|
+
const model = cfg.model ?? "claude-3-haiku-20240307";
|
|
86
|
+
const headers = {
|
|
87
|
+
"Content-Type": "application/json",
|
|
88
|
+
"x-api-key": cfg.apiKey ?? "",
|
|
89
|
+
"anthropic-version": "2023-06-01",
|
|
90
|
+
...cfg.headers,
|
|
91
|
+
};
|
|
92
|
+
const userContent = `CURRENT CONVERSATION SUMMARY:\n${currentContext}\n\nNEW USER MESSAGE:\n${newMessage}`;
|
|
93
|
+
const resp = await fetch(endpoint, {
|
|
94
|
+
method: "POST",
|
|
95
|
+
headers,
|
|
96
|
+
body: JSON.stringify({
|
|
97
|
+
model,
|
|
98
|
+
max_tokens: 10,
|
|
99
|
+
temperature: 0,
|
|
100
|
+
system: TOPIC_JUDGE_PROMPT,
|
|
101
|
+
messages: [{ role: "user", content: userContent }],
|
|
102
|
+
}),
|
|
103
|
+
signal: AbortSignal.timeout(cfg.timeoutMs ?? 15_000),
|
|
104
|
+
});
|
|
105
|
+
if (!resp.ok) {
|
|
106
|
+
const body = await resp.text();
|
|
107
|
+
throw new Error(`Anthropic topic-judge failed (${resp.status}): ${body}`);
|
|
108
|
+
}
|
|
109
|
+
const json = (await resp.json());
|
|
110
|
+
const answer = json.content.find((c) => c.type === "text")?.text?.trim().toUpperCase() ?? "";
|
|
111
|
+
log.debug(`Topic judge result: "${answer}"`);
|
|
112
|
+
return answer.startsWith("NEW");
|
|
113
|
+
}
|
|
5
114
|
async function summarizeAnthropic(text, cfg, log) {
|
|
6
115
|
const endpoint = cfg.endpoint ?? "https://api.anthropic.com/v1/messages";
|
|
7
116
|
const model = cfg.model ?? "claude-3-haiku-20240307";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../src/ingest/providers/anthropic.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../src/ingest/providers/anthropic.ts"],"names":[],"mappings":";;AAyCA,wDAkCC;AAeD,wDAuCC;AAED,gDAoCC;AArKD,MAAM,aAAa,GAAG,iSAAiS,CAAC;AAExT,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAmCQ,CAAC;AAE9B,KAAK,UAAU,sBAAsB,CAC1C,IAAY,EACZ,GAAqB,EACrB,GAAW;IAEX,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,uCAAuC,CAAC;IACzE,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,yBAAyB,CAAC;IACrD,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,kBAAkB;QAClC,WAAW,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE;QAC7B,mBAAmB,EAAE,YAAY;QACjC,GAAG,GAAG,CAAC,OAAO;KACf,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE;QACjC,MAAM,EAAE,MAAM;QACd,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,KAAK;YACL,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,GAAG;YACnC,MAAM,EAAE,mBAAmB;YAC3B,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;SAC5C,CAAC;QACF,MAAM,EAAE,WAAW,CAAC,OA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ACd,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,KAAK;YACL,UAAU,EAAE,GAAG;YACf,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC;YACjC,MAAM,EAAE,aAAa;YACrB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;SAC5C,CAAC;QACF,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM,CAAC;KACrD,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,CAAC,MAAM,MAAM,IAAI,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAE9B,CAAC;IACF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { SummarizerConfig, Logger } from "../../types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Expects cfg.endpoint to be the full Bedrock invoke URL and
|
|
5
|
-
* authentication handled via AWS SDK credential chain (env vars / IAM role).
|
|
6
|
-
*/
|
|
2
|
+
export declare function summarizeTaskBedrock(text: string, cfg: SummarizerConfig, log: Logger): Promise<string>;
|
|
3
|
+
export declare function judgeNewTopicBedrock(currentContext: string, newMessage: string, cfg: SummarizerConfig, log: Logger): Promise<boolean>;
|
|
7
4
|
export declare function summarizeBedrock(text: string, cfg: SummarizerConfig, log: Logger): Promise<string>;
|
|
8
5
|
//# sourceMappingURL=bedrock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bedrock.d.ts","sourceRoot":"","sources":["../../../src/ingest/providers/bedrock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"bedrock.d.ts","sourceRoot":"","sources":["../../../src/ingest/providers/bedrock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAyC5D,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CA+BjB;AAeD,wBAAsB,oBAAoB,CACxC,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,OAAO,CAAC,CAmClB;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CAoCjB"}
|
|
@@ -1,12 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.summarizeTaskBedrock = summarizeTaskBedrock;
|
|
4
|
+
exports.judgeNewTopicBedrock = judgeNewTopicBedrock;
|
|
3
5
|
exports.summarizeBedrock = summarizeBedrock;
|
|
4
|
-
const SYSTEM_PROMPT = `Summarize the text in ONE concise sentence (max
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const SYSTEM_PROMPT = `Summarize the text in ONE concise sentence (max 120 characters). IMPORTANT: Use the SAME language as the input text — if the input is Chinese, write Chinese; if English, write English. Preserve exact names, commands, error codes. No bullet points, no preamble — output only the sentence.`;
|
|
7
|
+
const TASK_SUMMARY_PROMPT = `You create a DETAILED task summary from a multi-turn conversation. This summary will be the ONLY record of this conversation, so it must preserve ALL important information.
|
|
8
|
+
|
|
9
|
+
CRITICAL LANGUAGE RULE: You MUST write in the SAME language as the user's messages. Chinese input → Chinese output. English input → English output. NEVER mix languages.
|
|
10
|
+
|
|
11
|
+
Output EXACTLY this structure:
|
|
12
|
+
|
|
13
|
+
📌 Title
|
|
14
|
+
A short, descriptive title (10-30 characters). Like a chat group name.
|
|
15
|
+
|
|
16
|
+
🎯 Goal
|
|
17
|
+
One sentence: what the user wanted to accomplish.
|
|
18
|
+
|
|
19
|
+
📋 Key Steps
|
|
20
|
+
- Describe each meaningful step in detail
|
|
21
|
+
- Include the ACTUAL content produced: code snippets, commands, config blocks, formulas, key paragraphs
|
|
22
|
+
- For code: include the function signature and core logic (up to ~30 lines per block), use fenced code blocks
|
|
23
|
+
- For configs: include the actual config values and structure
|
|
24
|
+
- For lists/instructions: include the actual items, not just "provided a list"
|
|
25
|
+
- Merge only truly trivial back-and-forth (like "ok" / "sure")
|
|
26
|
+
- Do NOT over-summarize: "provided a function" is BAD; show the actual function
|
|
27
|
+
|
|
28
|
+
✅ Result
|
|
29
|
+
What was the final outcome? Include the final version of any code/config/content produced.
|
|
30
|
+
|
|
31
|
+
💡 Key Details
|
|
32
|
+
- Decisions made, trade-offs discussed, caveats noted, alternative approaches mentioned
|
|
33
|
+
- Specific values: numbers, versions, thresholds, URLs, file paths, model names
|
|
34
|
+
- Omit this section only if there truly are no noteworthy details
|
|
35
|
+
|
|
36
|
+
RULES:
|
|
37
|
+
- This summary is a KNOWLEDGE BASE ENTRY, not a brief note. Be thorough.
|
|
38
|
+
- PRESERVE verbatim: code, commands, URLs, file paths, error messages, config values, version numbers, names, amounts
|
|
39
|
+
- DISCARD only: greetings, filler, the assistant explaining what it will do before doing it
|
|
40
|
+
- Replace secrets (API keys, tokens, passwords) with [REDACTED]
|
|
41
|
+
- Target length: 30-50% of the original conversation length. Longer conversations need longer summaries.
|
|
42
|
+
- Output summary only, no preamble.`;
|
|
43
|
+
async function summarizeTaskBedrock(text, cfg, log) {
|
|
44
|
+
const model = cfg.model ?? "anthropic.claude-3-haiku-20240307-v1:0";
|
|
45
|
+
const endpoint = cfg.endpoint;
|
|
46
|
+
if (!endpoint) {
|
|
47
|
+
throw new Error("Bedrock task-summarizer requires 'endpoint'");
|
|
48
|
+
}
|
|
49
|
+
const url = `${endpoint}/model/${model}/converse`;
|
|
50
|
+
const headers = {
|
|
51
|
+
"Content-Type": "application/json",
|
|
52
|
+
...cfg.headers,
|
|
53
|
+
};
|
|
54
|
+
const resp = await fetch(url, {
|
|
55
|
+
method: "POST",
|
|
56
|
+
headers,
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
system: [{ text: TASK_SUMMARY_PROMPT }],
|
|
59
|
+
messages: [{ role: "user", content: [{ text }] }],
|
|
60
|
+
inferenceConfig: { temperature: cfg.temperature ?? 0.1, maxTokens: 4096 },
|
|
61
|
+
}),
|
|
62
|
+
signal: AbortSignal.timeout(cfg.timeoutMs ?? 60_000),
|
|
63
|
+
});
|
|
64
|
+
if (!resp.ok) {
|
|
65
|
+
const body = await resp.text();
|
|
66
|
+
throw new Error(`Bedrock task-summarize failed (${resp.status}): ${body}`);
|
|
67
|
+
}
|
|
68
|
+
const json = (await resp.json());
|
|
69
|
+
return json.output?.message?.content?.[0]?.text?.trim() ?? "";
|
|
70
|
+
}
|
|
71
|
+
const TOPIC_JUDGE_PROMPT = `You are a conversation topic boundary detector. Given a summary of the CURRENT conversation and a NEW user message, determine if the new message starts a DIFFERENT topic/task.
|
|
72
|
+
|
|
73
|
+
Answer ONLY "NEW" or "SAME".
|
|
74
|
+
|
|
75
|
+
Rules:
|
|
76
|
+
- "NEW" = the new message is about a completely different subject, project, or task
|
|
77
|
+
- "SAME" = the new message continues, follows up on, or is closely related to the current topic
|
|
78
|
+
- Follow-up questions, clarifications, refinements, bug fixes, or next steps on the same task = SAME
|
|
79
|
+
- Greetings or meta-questions like "你好" or "谢谢" without new substance = SAME
|
|
80
|
+
- A clearly unrelated request (e.g., current topic is deployment, new message asks about cooking) = NEW
|
|
81
|
+
|
|
82
|
+
Output exactly one word: NEW or SAME`;
|
|
83
|
+
async function judgeNewTopicBedrock(currentContext, newMessage, cfg, log) {
|
|
84
|
+
const model = cfg.model ?? "anthropic.claude-3-haiku-20240307-v1:0";
|
|
85
|
+
const endpoint = cfg.endpoint;
|
|
86
|
+
if (!endpoint) {
|
|
87
|
+
throw new Error("Bedrock topic-judge requires 'endpoint'");
|
|
88
|
+
}
|
|
89
|
+
const url = `${endpoint}/model/${model}/converse`;
|
|
90
|
+
const headers = {
|
|
91
|
+
"Content-Type": "application/json",
|
|
92
|
+
...cfg.headers,
|
|
93
|
+
};
|
|
94
|
+
const userContent = `CURRENT CONVERSATION SUMMARY:\n${currentContext}\n\nNEW USER MESSAGE:\n${newMessage}`;
|
|
95
|
+
const resp = await fetch(url, {
|
|
96
|
+
method: "POST",
|
|
97
|
+
headers,
|
|
98
|
+
body: JSON.stringify({
|
|
99
|
+
system: [{ text: TOPIC_JUDGE_PROMPT }],
|
|
100
|
+
messages: [{ role: "user", content: [{ text: userContent }] }],
|
|
101
|
+
inferenceConfig: { temperature: 0, maxTokens: 10 },
|
|
102
|
+
}),
|
|
103
|
+
signal: AbortSignal.timeout(cfg.timeoutMs ?? 15_000),
|
|
104
|
+
});
|
|
105
|
+
if (!resp.ok) {
|
|
106
|
+
const body = await resp.text();
|
|
107
|
+
throw new Error(`Bedrock topic-judge failed (${resp.status}): ${body}`);
|
|
108
|
+
}
|
|
109
|
+
const json = (await resp.json());
|
|
110
|
+
const answer = json.output?.message?.content?.[0]?.text?.trim().toUpperCase() ?? "";
|
|
111
|
+
log.debug(`Topic judge result: "${answer}"`);
|
|
112
|
+
return answer.startsWith("NEW");
|
|
113
|
+
}
|
|
10
114
|
async function summarizeBedrock(text, cfg, log) {
|
|
11
115
|
const model = cfg.model ?? "anthropic.claude-3-haiku-20240307-v1:0";
|
|
12
116
|
const endpoint = cfg.endpoint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bedrock.js","sourceRoot":"","sources":["../../../src/ingest/providers/bedrock.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"bedrock.js","sourceRoot":"","sources":["../../../src/ingest/providers/bedrock.ts"],"names":[],"mappings":";;AAyCA,oDAmCC;AAeD,oDAwCC;AAED,4CAwCC;AA3KD,MAAM,aAAa,GAAG,iSAAiS,CAAC;AAExT,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAmCQ,CAAC;AAE9B,KAAK,UAAU,oBAAoB,CACxC,IAAY,EACZ,GAAqB,EACrB,GAAW;IAEX,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,wCAAwC,CAAC;IACpE,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC9B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,GAAG,GAAG,GAAG,QAAQ,UAAU,KAAK,WAAW,CAAC;IAClD,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,kBAAkB;QAClC,GAAG,GAAG,CAAC,OAAO;KACf,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAC5B,MAAM,EAAE,MAAM;QACd,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC;YACvC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YACjD,eAAe,EAAE,EAAE,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AAC,yGAAyG,CAAC,CAAC;IAC7H,CAAC;IAED,MAAM,GAAG,GAAG,GAAG,QAAQ,UAAU,KAAK,WAAW,CAAC;IAClD,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,kBAAkB;QAClC,GAAG,GAAG,CAAC,OAAO;KACf,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAC5B,MAAM,EAAE,MAAM;QACd,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;YACjC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YACjD,eAAe,EAAE;gBACf,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC;gBACjC,SAAS,EAAE,GAAG;aACf;SACF,CAAC;QACF,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM,CAAC;KACrD,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,CAAC,MAAM,MAAM,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAE9B,CAAC;IACF,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAChE,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { SummarizerConfig, Logger } from "../../types";
|
|
2
|
+
export declare function summarizeTaskGemini(text: string, cfg: SummarizerConfig, log: Logger): Promise<string>;
|
|
3
|
+
export declare function judgeNewTopicGemini(currentContext: string, newMessage: string, cfg: SummarizerConfig, log: Logger): Promise<boolean>;
|
|
2
4
|
export declare function summarizeGemini(text: string, cfg: SummarizerConfig, log: Logger): Promise<string>;
|
|
3
5
|
//# sourceMappingURL=gemini.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../../src/ingest/providers/gemini.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../../src/ingest/providers/gemini.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAyC5D,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CA8BjB;AAeD,wBAAsB,mBAAmB,CACvC,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,OAAO,CAAC,CAkClB;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CAgCjB"}
|
|
@@ -1,7 +1,112 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.summarizeTaskGemini = summarizeTaskGemini;
|
|
4
|
+
exports.judgeNewTopicGemini = judgeNewTopicGemini;
|
|
3
5
|
exports.summarizeGemini = summarizeGemini;
|
|
4
|
-
const SYSTEM_PROMPT = `Summarize the text in ONE concise sentence (max
|
|
6
|
+
const SYSTEM_PROMPT = `Summarize the text in ONE concise sentence (max 120 characters). IMPORTANT: Use the SAME language as the input text — if the input is Chinese, write Chinese; if English, write English. Preserve exact names, commands, error codes. No bullet points, no preamble — output only the sentence.`;
|
|
7
|
+
const TASK_SUMMARY_PROMPT = `You create a DETAILED task summary from a multi-turn conversation. This summary will be the ONLY record of this conversation, so it must preserve ALL important information.
|
|
8
|
+
|
|
9
|
+
CRITICAL LANGUAGE RULE: You MUST write in the SAME language as the user's messages. Chinese input → Chinese output. English input → English output. NEVER mix languages.
|
|
10
|
+
|
|
11
|
+
Output EXACTLY this structure:
|
|
12
|
+
|
|
13
|
+
📌 Title
|
|
14
|
+
A short, descriptive title (10-30 characters). Like a chat group name.
|
|
15
|
+
|
|
16
|
+
🎯 Goal
|
|
17
|
+
One sentence: what the user wanted to accomplish.
|
|
18
|
+
|
|
19
|
+
📋 Key Steps
|
|
20
|
+
- Describe each meaningful step in detail
|
|
21
|
+
- Include the ACTUAL content produced: code snippets, commands, config blocks, formulas, key paragraphs
|
|
22
|
+
- For code: include the function signature and core logic (up to ~30 lines per block), use fenced code blocks
|
|
23
|
+
- For configs: include the actual config values and structure
|
|
24
|
+
- For lists/instructions: include the actual items, not just "provided a list"
|
|
25
|
+
- Merge only truly trivial back-and-forth (like "ok" / "sure")
|
|
26
|
+
- Do NOT over-summarize: "provided a function" is BAD; show the actual function
|
|
27
|
+
|
|
28
|
+
✅ Result
|
|
29
|
+
What was the final outcome? Include the final version of any code/config/content produced.
|
|
30
|
+
|
|
31
|
+
💡 Key Details
|
|
32
|
+
- Decisions made, trade-offs discussed, caveats noted, alternative approaches mentioned
|
|
33
|
+
- Specific values: numbers, versions, thresholds, URLs, file paths, model names
|
|
34
|
+
- Omit this section only if there truly are no noteworthy details
|
|
35
|
+
|
|
36
|
+
RULES:
|
|
37
|
+
- This summary is a KNOWLEDGE BASE ENTRY, not a brief note. Be thorough.
|
|
38
|
+
- PRESERVE verbatim: code, commands, URLs, file paths, error messages, config values, version numbers, names, amounts
|
|
39
|
+
- DISCARD only: greetings, filler, the assistant explaining what it will do before doing it
|
|
40
|
+
- Replace secrets (API keys, tokens, passwords) with [REDACTED]
|
|
41
|
+
- Target length: 30-50% of the original conversation length. Longer conversations need longer summaries.
|
|
42
|
+
- Output summary only, no preamble.`;
|
|
43
|
+
async function summarizeTaskGemini(text, cfg, log) {
|
|
44
|
+
const model = cfg.model ?? "gemini-1.5-flash";
|
|
45
|
+
const endpoint = cfg.endpoint ??
|
|
46
|
+
`https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent`;
|
|
47
|
+
const url = `${endpoint}?key=${cfg.apiKey}`;
|
|
48
|
+
const headers = {
|
|
49
|
+
"Content-Type": "application/json",
|
|
50
|
+
...cfg.headers,
|
|
51
|
+
};
|
|
52
|
+
const resp = await fetch(url, {
|
|
53
|
+
method: "POST",
|
|
54
|
+
headers,
|
|
55
|
+
body: JSON.stringify({
|
|
56
|
+
systemInstruction: { parts: [{ text: TASK_SUMMARY_PROMPT }] },
|
|
57
|
+
contents: [{ parts: [{ text }] }],
|
|
58
|
+
generationConfig: { temperature: cfg.temperature ?? 0.1, maxOutputTokens: 4096 },
|
|
59
|
+
}),
|
|
60
|
+
signal: AbortSignal.timeout(cfg.timeoutMs ?? 60_000),
|
|
61
|
+
});
|
|
62
|
+
if (!resp.ok) {
|
|
63
|
+
const body = await resp.text();
|
|
64
|
+
throw new Error(`Gemini task-summarize failed (${resp.status}): ${body}`);
|
|
65
|
+
}
|
|
66
|
+
const json = (await resp.json());
|
|
67
|
+
return json.candidates?.[0]?.content?.parts?.[0]?.text?.trim() ?? "";
|
|
68
|
+
}
|
|
69
|
+
const TOPIC_JUDGE_PROMPT = `You are a conversation topic boundary detector. Given a summary of the CURRENT conversation and a NEW user message, determine if the new message starts a DIFFERENT topic/task.
|
|
70
|
+
|
|
71
|
+
Answer ONLY "NEW" or "SAME".
|
|
72
|
+
|
|
73
|
+
Rules:
|
|
74
|
+
- "NEW" = the new message is about a completely different subject, project, or task
|
|
75
|
+
- "SAME" = the new message continues, follows up on, or is closely related to the current topic
|
|
76
|
+
- Follow-up questions, clarifications, refinements, bug fixes, or next steps on the same task = SAME
|
|
77
|
+
- Greetings or meta-questions like "你好" or "谢谢" without new substance = SAME
|
|
78
|
+
- A clearly unrelated request (e.g., current topic is deployment, new message asks about cooking) = NEW
|
|
79
|
+
|
|
80
|
+
Output exactly one word: NEW or SAME`;
|
|
81
|
+
async function judgeNewTopicGemini(currentContext, newMessage, cfg, log) {
|
|
82
|
+
const model = cfg.model ?? "gemini-1.5-flash";
|
|
83
|
+
const endpoint = cfg.endpoint ??
|
|
84
|
+
`https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent`;
|
|
85
|
+
const url = `${endpoint}?key=${cfg.apiKey}`;
|
|
86
|
+
const headers = {
|
|
87
|
+
"Content-Type": "application/json",
|
|
88
|
+
...cfg.headers,
|
|
89
|
+
};
|
|
90
|
+
const userContent = `CURRENT CONVERSATION SUMMARY:\n${currentContext}\n\nNEW USER MESSAGE:\n${newMessage}`;
|
|
91
|
+
const resp = await fetch(url, {
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers,
|
|
94
|
+
body: JSON.stringify({
|
|
95
|
+
systemInstruction: { parts: [{ text: TOPIC_JUDGE_PROMPT }] },
|
|
96
|
+
contents: [{ parts: [{ text: userContent }] }],
|
|
97
|
+
generationConfig: { temperature: 0, maxOutputTokens: 10 },
|
|
98
|
+
}),
|
|
99
|
+
signal: AbortSignal.timeout(cfg.timeoutMs ?? 15_000),
|
|
100
|
+
});
|
|
101
|
+
if (!resp.ok) {
|
|
102
|
+
const body = await resp.text();
|
|
103
|
+
throw new Error(`Gemini topic-judge failed (${resp.status}): ${body}`);
|
|
104
|
+
}
|
|
105
|
+
const json = (await resp.json());
|
|
106
|
+
const answer = json.candidates?.[0]?.content?.parts?.[0]?.text?.trim().toUpperCase() ?? "";
|
|
107
|
+
log.debug(`Topic judge result: "${answer}"`);
|
|
108
|
+
return answer.startsWith("NEW");
|
|
109
|
+
}
|
|
5
110
|
async function summarizeGemini(text, cfg, log) {
|
|
6
111
|
const model = cfg.model ?? "gemini-1.5-flash";
|
|
7
112
|
const endpoint = cfg.endpoint ??
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../../src/ingest/providers/gemini.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../../src/ingest/providers/gemini.ts"],"names":[],"mappings":";;AAyCA,kDAkCC;AAeD,kDAuCC;AAED,0CAoCC;AArKD,MAAM,aAAa,GAAG,iSAAiS,CAAC;AAExT,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAmCQ,CAAC;AAE9B,KAAK,UAAU,mBAAmB,CACvC,IAAY,EACZ,GAAqB,EACrB,GAAW;IAEX,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,kBAAkB,CAAC;IAC9C,MAAM,QAAQ,GACZ,GAAG,CAAC,QAAQ;QACZ,2DAA2D,KAAK,kBAAkB,CAAC;IAErF,MAAM,GAAG,GAAG,GAAG,QAAQ,QAAQ,GAAG,CAAC,MAAM,EAAE,CAAC;IAC5C,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,kBAAkB;QAClC,GAAG,GAAG,CAAC,OAAO;KACf,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAC5B,MAAM,EAAE,MAAM;QACd,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,iBAAiB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC,EAAE;YAC7D,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YACjC,gBAAgB,EAAE,EAAE,WAAW,EAAE,GAAG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CAAC,MAAM,EAAE,CAAC;IAC5C,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,kBAAkB;QAClC,GAAG,GAAG,CAAC,OAAO;KACf,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAC5B,MAAM,EAAE,MAAM;QACd,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,iBAAiB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,EAAE;YACvD,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YACjC,gBAAgB,EAAE,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC,EAAE,eAAe,EAAE,GAAG,EAAE;SAC9E,CAAC;QACF,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM,CAAC;KACrD,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,MAAM,MAAM,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAE9B,CAAC;IACF,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -4,6 +4,15 @@ export declare class Summarizer {
|
|
|
4
4
|
private log;
|
|
5
5
|
constructor(cfg: SummarizerConfig | undefined, log: Logger);
|
|
6
6
|
summarize(text: string): Promise<string>;
|
|
7
|
+
summarizeTask(text: string): Promise<string>;
|
|
7
8
|
private callProvider;
|
|
9
|
+
/**
|
|
10
|
+
* Ask the LLM whether the new message starts a different topic from the current conversation.
|
|
11
|
+
* Returns true if it's a new topic, false if it continues the current one.
|
|
12
|
+
* Returns null if no summarizer is configured (caller should fall back to heuristic).
|
|
13
|
+
*/
|
|
14
|
+
judgeNewTopic(currentContext: string, newMessage: string): Promise<boolean | null>;
|
|
15
|
+
private callTopicJudge;
|
|
16
|
+
private callTaskProvider;
|
|
8
17
|
}
|
|
9
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ingest/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAM5D,qBAAa,UAAU;IAEnB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,GAAG;gBADH,GAAG,EAAE,gBAAgB,GAAG,SAAS,EACjC,GAAG,EAAE,MAAM;IAGf,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ingest/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAM5D,qBAAa,UAAU;IAEnB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,GAAG;gBADH,GAAG,EAAE,gBAAgB,GAAG,SAAS,EACjC,GAAG,EAAE,MAAM;IAGf,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAaxC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAapC,YAAY;IAmB1B;;;;OAIG;IACG,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;YAW1E,cAAc;YAkBd,gBAAgB;CAiB/B"}
|
|
@@ -24,6 +24,18 @@ class Summarizer {
|
|
|
24
24
|
return ruleFallback(text);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
async summarizeTask(text) {
|
|
28
|
+
if (!this.cfg) {
|
|
29
|
+
return taskFallback(text);
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return await this.callTaskProvider(text);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
this.log.warn(`Task summarizer failed, using fallback: ${err}`);
|
|
36
|
+
return taskFallback(text);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
27
39
|
async callProvider(text) {
|
|
28
40
|
const cfg = this.cfg;
|
|
29
41
|
switch (cfg.provider) {
|
|
@@ -42,12 +54,62 @@ class Summarizer {
|
|
|
42
54
|
throw new Error(`Unknown summarizer provider: ${cfg.provider}`);
|
|
43
55
|
}
|
|
44
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Ask the LLM whether the new message starts a different topic from the current conversation.
|
|
59
|
+
* Returns true if it's a new topic, false if it continues the current one.
|
|
60
|
+
* Returns null if no summarizer is configured (caller should fall back to heuristic).
|
|
61
|
+
*/
|
|
62
|
+
async judgeNewTopic(currentContext, newMessage) {
|
|
63
|
+
if (!this.cfg)
|
|
64
|
+
return null;
|
|
65
|
+
try {
|
|
66
|
+
return await this.callTopicJudge(currentContext, newMessage);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
this.log.warn(`Topic judge failed: ${err}`);
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async callTopicJudge(currentContext, newMessage) {
|
|
74
|
+
const cfg = this.cfg;
|
|
75
|
+
switch (cfg.provider) {
|
|
76
|
+
case "openai":
|
|
77
|
+
case "openai_compatible":
|
|
78
|
+
case "azure_openai":
|
|
79
|
+
return (0, openai_1.judgeNewTopicOpenAI)(currentContext, newMessage, cfg, this.log);
|
|
80
|
+
case "anthropic":
|
|
81
|
+
return (0, anthropic_1.judgeNewTopicAnthropic)(currentContext, newMessage, cfg, this.log);
|
|
82
|
+
case "gemini":
|
|
83
|
+
return (0, gemini_1.judgeNewTopicGemini)(currentContext, newMessage, cfg, this.log);
|
|
84
|
+
case "bedrock":
|
|
85
|
+
return (0, bedrock_1.judgeNewTopicBedrock)(currentContext, newMessage, cfg, this.log);
|
|
86
|
+
default:
|
|
87
|
+
throw new Error(`Unknown summarizer provider: ${cfg.provider}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async callTaskProvider(text) {
|
|
91
|
+
const cfg = this.cfg;
|
|
92
|
+
switch (cfg.provider) {
|
|
93
|
+
case "openai":
|
|
94
|
+
case "openai_compatible":
|
|
95
|
+
case "azure_openai":
|
|
96
|
+
return (0, openai_1.summarizeTaskOpenAI)(text, cfg, this.log);
|
|
97
|
+
case "anthropic":
|
|
98
|
+
return (0, anthropic_1.summarizeTaskAnthropic)(text, cfg, this.log);
|
|
99
|
+
case "gemini":
|
|
100
|
+
return (0, gemini_1.summarizeTaskGemini)(text, cfg, this.log);
|
|
101
|
+
case "bedrock":
|
|
102
|
+
return (0, bedrock_1.summarizeTaskBedrock)(text, cfg, this.log);
|
|
103
|
+
default:
|
|
104
|
+
throw new Error(`Unknown summarizer provider: ${cfg.provider}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
45
107
|
}
|
|
46
108
|
exports.Summarizer = Summarizer;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
109
|
+
function taskFallback(text) {
|
|
110
|
+
const lines = text.split("\n").filter((l) => l.trim().length > 10);
|
|
111
|
+
return lines.slice(0, 30).join("\n").slice(0, 2000);
|
|
112
|
+
}
|
|
51
113
|
function ruleFallback(text) {
|
|
52
114
|
const lines = text.split("\n").filter((l) => l.trim().length > 10);
|
|
53
115
|
const first = (lines[0] ?? text).trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ingest/providers/index.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ingest/providers/index.ts"],"names":[],"mappings":";;;AACA,qCAAqF;AACrF,2CAAiG;AACjG,qCAAqF;AACrF,uCAAyF;AAEzF,MAAa,UAAU;IAEX;IACA;IAFV,YACU,GAAiC,EACjC,GAAW;QADX,QAAG,GAAH,GAAG,CAA8B;QACjC,QAAG,GAAH,GAAG,CAAQ;IAClB,CAAC;IAEJ,KAAK,CAAC,SAAS,CAAC,IAAY;QAC1B,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,oDAAoD,GAAG,EAAE,CAAC,CAAC;YACzE,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAY;QAC9B,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,2CAA2C,GAAG,EAAE,CAAC,CAAC;YAChE,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,IAAY;QACrC,MAAM,GAAG,GAAG,IAA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,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IACvE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IACzC,CAAC;IACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { SummarizerConfig, Logger } from "../../types";
|
|
2
|
+
export declare function summarizeTaskOpenAI(text: string, cfg: SummarizerConfig, log: Logger): Promise<string>;
|
|
2
3
|
export declare function summarizeOpenAI(text: string, cfg: SummarizerConfig, log: Logger): Promise<string>;
|
|
4
|
+
export declare function judgeNewTopicOpenAI(currentContext: string, newMessage: string, cfg: SummarizerConfig, log: Logger): Promise<boolean>;
|
|
3
5
|
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/ingest/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/ingest/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAyC5D,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CA+BjB;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,CAgCjB;AAeD,wBAAsB,mBAAmB,CACvC,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,OAAO,CAAC,CAmClB"}
|