@evandu/super-pi 0.1.289 → 0.1.290

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.
@@ -0,0 +1,82 @@
1
+ import { parseStreamingJson } from "@earendil-works/pi-ai";
2
+ export const MODEL_STREAM_PROTOCOL = "compact-v1";
3
+ /** Pi partials are live mutable helpers. Reconstruct event-time content from deltas. */
4
+ export class ModelWireEncoder {
5
+ previousMeta = "";
6
+ encode(event) {
7
+ if (!("partial" in event))
8
+ return event;
9
+ const { partial, ...value } = event;
10
+ const { content, ...meta } = partial;
11
+ const serialized = JSON.stringify(meta);
12
+ const frame = { wire: 1, event: value };
13
+ if (serialized !== this.previousMeta) {
14
+ frame.meta = meta;
15
+ this.previousMeta = serialized;
16
+ }
17
+ if ("contentIndex" in event && !event.type.endsWith("_delta")) {
18
+ const block = content[event.contentIndex];
19
+ if (block)
20
+ frame.block = block;
21
+ }
22
+ return frame;
23
+ }
24
+ }
25
+ export class ModelWireDecoder {
26
+ partial;
27
+ arguments = new Map();
28
+ decode(value) {
29
+ const frame = value;
30
+ if (frame.wire !== 1)
31
+ return value;
32
+ if (frame.meta)
33
+ this.partial = { ...frame.meta, content: this.partial?.content ?? [] };
34
+ const partial = this.partial;
35
+ if (!partial)
36
+ throw new Error("模型通道增量事件缺少初始消息信息。");
37
+ const event = frame.event;
38
+ const type = event.type, index = event.contentIndex;
39
+ if (type === "start")
40
+ partial.content = [];
41
+ else if (type.endsWith("_start") && frame.block) {
42
+ const block = { ...frame.block };
43
+ if (block.type === "text")
44
+ block.text = "";
45
+ if (block.type === "thinking" && !block.redacted)
46
+ block.thinking = "";
47
+ partial.content[index] = block;
48
+ if (block.type === "toolCall")
49
+ this.arguments.delete(index);
50
+ }
51
+ else if (type === "text_delta" || type === "thinking_delta") {
52
+ const kind = type === "text_delta" ? "text" : "thinking";
53
+ let block = partial.content[index];
54
+ if (!block || block.type !== kind)
55
+ block = kind === "text" ? { type: "text", text: "" } : { type: "thinking", thinking: "" };
56
+ if (block.type === "text")
57
+ block.text += event.delta;
58
+ else if (block.type === "thinking")
59
+ block.thinking += event.delta;
60
+ partial.content[index] = block;
61
+ }
62
+ else if (type === "toolcall_delta") {
63
+ const text = (this.arguments.get(index) ?? "") + event.delta;
64
+ this.arguments.set(index, text);
65
+ const block = partial.content[index];
66
+ if (block?.type === "toolCall")
67
+ block.arguments = parseStreamingJson(text);
68
+ }
69
+ else if (type.endsWith("_end")) {
70
+ if (frame.block)
71
+ partial.content[index] = frame.block;
72
+ if (type === "text_end" && partial.content[index]?.type === "text")
73
+ partial.content[index].text = event.content;
74
+ if (type === "thinking_end" && partial.content[index]?.type === "thinking")
75
+ partial.content[index].thinking = event.content;
76
+ if (type === "toolcall_end")
77
+ partial.content[index] = event.toolCall;
78
+ this.arguments.delete(index);
79
+ }
80
+ return { ...event, partial };
81
+ }
82
+ }
@@ -33,7 +33,7 @@ export function formatTurnFailure(error) {
33
33
  const raw = error instanceof Error ? error.message : typeof error === "string" ? error : "";
34
34
  if (/^上下文(?:自动)?压缩失败/.test(raw))
35
35
  return raw;
36
- if (/^(本地模型通道|模型通道在回复完成前断开)/.test(raw))
36
+ if (/^(本地模型通道|模型通道|入口模型)/.test(raw))
37
37
  return raw;
38
38
  const lower = raw.toLowerCase();
39
39
  // PROVIDER QUOTA / RATE LIMIT - the only reason the user is in this branch is because Pi was
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "superPi": {
4
4
  "managedDirectListener": true
5
5
  },
6
- "version": "0.1.289",
6
+ "version": "0.1.290",
7
7
  "description": "Web control plane and companion for Pi",
8
8
  "license": "MIT",
9
9
  "type": "module",
@@ -83,6 +83,7 @@
83
83
  "scripts/desktop-runtime.test.mjs",
84
84
  "scripts/managed-ssh.test.mjs",
85
85
  "scripts/managed-model.test.mjs",
86
+ "scripts/managed-model-flow.test.mjs",
86
87
  "scripts/multi-server.test.mjs",
87
88
  "scripts/native-tools.test.mjs",
88
89
  "scripts/markdown-syntax.test.mjs",
@@ -336,6 +337,7 @@
336
337
  "scripts/session-reminder-pmo-rights.test.mjs"
337
338
  ],
338
339
  "check:browser": [
340
+ "scripts/managed-model-errors-browser.test.mjs",
339
341
  "scripts/git-panel-upgrade-browser.test.mjs",
340
342
  "scripts/welcome-workspace-git-browser.test.mjs",
341
343
  "scripts/editor-search-design-browser.test.mjs",
@@ -1,4 +0,0 @@
1
- {
2
- "hash": "4c7d5aa30d52b5bd7795cdfb59961b6ac8ad8e6104e4386b416fb51c1af60e4e",
3
- "recordedAt": "2026-11-24T04:36:08.441Z"
4
- }