@narumitw/pi-subagents 3.0.1 → 3.0.2
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/README.md +35 -100
- package/dist/child-communication-bridge.ts +3 -8
- package/dist/child-communication-bridge.ts.map +2 -2
- package/dist/chunks/{chunk-UKTWUQRM.js → chunk-7JQOB375.ts} +7 -22
- package/dist/chunks/chunk-7JQOB375.ts.map +7 -0
- package/dist/index.ts +13 -46
- package/dist/index.ts.map +2 -2
- package/package.json +53 -54
- package/src/broker-credentials.ts +48 -48
- package/src/child-communication-bridge.ts +115 -123
- package/src/child-communication-tools.ts +105 -111
- package/src/completion-renderer.ts +46 -48
- package/src/message-broker.ts +531 -561
- package/src/model-output.ts +25 -28
- package/src/process.ts +595 -616
- package/src/runtime.ts +454 -478
- package/src/subagents.ts +20 -23
- package/src/tools.ts +305 -319
- package/src/types.ts +41 -58
- package/src/widget.ts +85 -91
- package/dist/chunks/chunk-UKTWUQRM.js.map +0 -7
package/src/model-output.ts
CHANGED
|
@@ -6,37 +6,34 @@ export const MAX_MODEL_TEXT_LINES = 2_000;
|
|
|
6
6
|
const TRUNCATION_MARKER = "… [truncated]";
|
|
7
7
|
|
|
8
8
|
export function requireBoundedModelText(text: string, label: string): string {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
const result = sanitizeTerminalText(text);
|
|
10
|
+
if (Buffer.byteLength(result, "utf8") > MAX_MODEL_TEXT_BYTES) {
|
|
11
|
+
throw new Error(`${label} exceeds Pi's ${MAX_MODEL_TEXT_BYTES}-byte model-text limit.`);
|
|
12
|
+
}
|
|
13
|
+
if (result.split("\n").length > MAX_MODEL_TEXT_LINES) {
|
|
14
|
+
throw new Error(`${label} exceeds Pi's ${MAX_MODEL_TEXT_LINES}-line model-text limit.`);
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export function truncateModelText(text: string): string {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
let result = sanitizeTerminalText(text);
|
|
21
|
+
const bytes = Buffer.from(result, "utf8");
|
|
22
|
+
if (bytes.length > MAX_MODEL_TEXT_BYTES) {
|
|
23
|
+
const suffix = `\n${TRUNCATION_MARKER}`;
|
|
24
|
+
const suffixBytes = Buffer.byteLength(suffix, "utf8");
|
|
25
|
+
result = `${bytes
|
|
26
|
+
.subarray(0, Math.max(0, MAX_MODEL_TEXT_BYTES - suffixBytes))
|
|
27
|
+
.toString("utf8")
|
|
28
|
+
.replace(/�+$/gu, "")}${suffix}`;
|
|
29
|
+
}
|
|
30
|
+
const lines = result.split("\n");
|
|
31
|
+
if (lines.length > MAX_MODEL_TEXT_LINES) {
|
|
32
|
+
result = `${lines.slice(0, MAX_MODEL_TEXT_LINES - 1).join("\n")}\n${TRUNCATION_MARKER}`;
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export function modelVisibleJson(
|
|
38
|
-
|
|
39
|
-
options: { prefix?: string; indent?: number } = {},
|
|
40
|
-
): string {
|
|
41
|
-
return truncateModelText(`${options.prefix ?? ""}${JSON.stringify(value, null, options.indent)}`);
|
|
37
|
+
export function modelVisibleJson(value: unknown, options: { prefix?: string; indent?: number } = {}): string {
|
|
38
|
+
return truncateModelText(`${options.prefix ?? ""}${JSON.stringify(value, null, options.indent)}`);
|
|
42
39
|
}
|