pi-distill 1.9.1 → 1.9.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/package.json +5 -3
- package/src/index.ts +11 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-distill",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "Pi tool-output distillation with file-first configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
|
@@ -61,14 +61,16 @@
|
|
|
61
61
|
"@earendil-works/pi-tui": ">=0.80.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"pi-extensions-i18n": "^0.
|
|
65
|
-
"pi-
|
|
64
|
+
"pi-extensions-i18n": "^0.8.0",
|
|
65
|
+
"pi-model-request": "^0.1.1",
|
|
66
|
+
"pi-extensions-tool-display": "^1.3.2"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"@earendil-works/pi-ai": "0.85.1",
|
|
69
70
|
"@earendil-works/pi-coding-agent": "0.85.1",
|
|
70
71
|
"@earendil-works/pi-tui": "0.85.1",
|
|
71
72
|
"@types/node": "24.12.4",
|
|
73
|
+
"pi-model-request": "^0.1.1",
|
|
72
74
|
"tsx": "4.23.1",
|
|
73
75
|
"typescript": "5.9.3"
|
|
74
76
|
}
|
package/src/index.ts
CHANGED
|
@@ -43,7 +43,8 @@ import { getTextContent, hasNonTextContent, limitReturnedToolResult } from "./ou
|
|
|
43
43
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
44
44
|
import { tmpdir } from "node:os";
|
|
45
45
|
import { dirname, join } from "node:path";
|
|
46
|
-
import { createTranslator, installNoticeRenderer, loadCatalog, notifyWithSource, type NoticeColor, type NoticeSource } from "pi-extensions-i18n";
|
|
46
|
+
import { NOTICE_TAG_COLOR, createTranslator, installNoticeRenderer, loadCatalog, notifyWithSource, type NoticeColor, type NoticeSource } from "pi-extensions-i18n";
|
|
47
|
+
import { createModelRequester } from "pi-model-request";
|
|
47
48
|
import {
|
|
48
49
|
buildSummaryPrompt,
|
|
49
50
|
buildSummarySystemPrompt,
|
|
@@ -112,8 +113,8 @@ const OUTPUT_REQUEST_SYSTEM_GUIDELINE = i18n.t("outputRequestSystemGuideline");
|
|
|
112
113
|
|
|
113
114
|
/** 本扩展的提示标签;短且唯一,便于在会话里定位来源。 */
|
|
114
115
|
const NOTICE_TAG = "distill";
|
|
115
|
-
/**
|
|
116
|
-
const NOTICE_COLOR: NoticeColor =
|
|
116
|
+
/** 提示标签颜色:所有扩展统一用弱化色,来源靠 tag 文本区分,不靠颜色。 */
|
|
117
|
+
const NOTICE_COLOR: NoticeColor = NOTICE_TAG_COLOR;
|
|
117
118
|
/** 本扩展的提示来源。 */
|
|
118
119
|
const NOTICE_SOURCE: NoticeSource = { tag: NOTICE_TAG, color: NOTICE_COLOR };
|
|
119
120
|
|
|
@@ -788,19 +789,19 @@ async function summarizeOutput(
|
|
|
788
789
|
);
|
|
789
790
|
}
|
|
790
791
|
|
|
791
|
-
|
|
792
|
-
|
|
792
|
+
// 摘要请求由扩展自己发出:鉴权与 provider 会话头交给共享请求器,与 Pi 核心行为一致。
|
|
793
|
+
const request = createModelRequester(context.ctx, {
|
|
794
|
+
base: completion,
|
|
795
|
+
authError: (error) => new Error(`Summarizer authentication failed: ${error}`),
|
|
796
|
+
});
|
|
793
797
|
|
|
794
798
|
const completionOptions = {
|
|
795
|
-
apiKey: auth.apiKey,
|
|
796
|
-
headers: auth.headers,
|
|
797
|
-
env: auth.env,
|
|
798
799
|
maxTokens: Math.max(256, Math.ceil(config.maxChars / 2)),
|
|
799
800
|
onPayload: addSummaryJsonResponseFormat,
|
|
800
801
|
signal,
|
|
801
802
|
} satisfies SummaryCompletionOptions;
|
|
802
803
|
const { text: rawResponse, usage } = await completeSummaryMessage(
|
|
803
|
-
|
|
804
|
+
request,
|
|
804
805
|
model,
|
|
805
806
|
[
|
|
806
807
|
buildSummarySystemPrompt(),
|
|
@@ -824,7 +825,7 @@ async function summarizeOutput(
|
|
|
824
825
|
let repaired: { text: string; usage: SummaryUsage | undefined };
|
|
825
826
|
try {
|
|
826
827
|
repaired = await completeSummaryMessage(
|
|
827
|
-
|
|
828
|
+
request,
|
|
828
829
|
model,
|
|
829
830
|
buildJsonRepairPrompt(rawResponse, error.message),
|
|
830
831
|
completionOptions,
|