@evandu/super-pi 0.1.256 → 0.1.258

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.
@@ -1,3 +1,4 @@
1
+ import type { TavilyService } from "./tavily.js";
1
2
  export declare const WEB_SEARCH_TOOL_NAME = "web_search";
2
3
  export declare const WEB_FETCH_TOOL_NAME = "web_fetch";
3
4
  export declare const MAX_WEB_REQUEST_BYTES: number;
@@ -16,6 +17,8 @@ export type WebFetchResult = {
16
17
  /** Parse DuckDuckGo Lite result rows and unwrap their destination URLs. */
17
18
  export declare function parseDuckDuckGoResults(html: string, limit?: number): WebSearchResult[];
18
19
  export declare class WebService {
20
+ private readonly tavily?;
21
+ constructor(tavily?: TavilyService | undefined);
19
22
  search(query: string, limit?: number, signal?: AbortSignal): Promise<{
20
23
  query: string;
21
24
  results: WebSearchResult[];
@@ -162,20 +162,14 @@ function extractHtml(html) {
162
162
  return { title, text };
163
163
  }
164
164
  export class WebService {
165
+ tavily;
166
+ constructor(tavily) {
167
+ this.tavily = tavily;
168
+ }
165
169
  async search(query, limit = 5, signal) {
166
- const clean = query.trim();
167
- if (!clean)
168
- throw new Error("搜索词不能为空");
169
- if (clean.length > 500)
170
- throw new Error("搜索词不能超过 500 个字符");
171
- const url = new URL("https://lite.duckduckgo.com/lite/");
172
- url.searchParams.set("q", clean);
173
- url.searchParams.set("kl", "us-en");
174
- const response = await download(url.href, signal);
175
- const results = parseDuckDuckGoResults(response.body.toString("utf8"), limit);
176
- if (!results.length)
177
- throw new Error("搜索引擎没有返回可解析的结果,可能暂时限流或页面格式已变化");
178
- return { query: clean, results };
170
+ if (!this.tavily)
171
+ throw new Error("网页搜索服务未配置。");
172
+ return this.tavily.search(query, limit, signal);
179
173
  }
180
174
  async fetch(url, signal) {
181
175
  const response = await download(url, signal);
@@ -7,12 +7,26 @@ export type GroupModel = {
7
7
  export type GroupModerator = {
8
8
  model?: GroupModel;
9
9
  prompt: string;
10
+ cloneLimit?: number;
10
11
  };
11
12
  export declare const DEFAULT_GROUP_MEMBER_IDS: readonly ["solution-designer", "code-designer", "code-auditor", "document-organizer"];
12
13
  export type GroupMember = {
13
14
  id: string;
14
15
  name: string;
15
16
  description: string;
17
+ agentId?: string;
18
+ worktreePath?: string;
19
+ };
20
+ export type GroupCloneRequest = {
21
+ id: string;
22
+ topicId: string;
23
+ memberId: string;
24
+ assignment: string;
25
+ reason: string;
26
+ createdAt: string;
27
+ status: "pending" | "created" | "waiting" | "expired";
28
+ cloneId?: string;
29
+ automatic?: boolean;
16
30
  };
17
31
  export type GroupStatus = "queued" | "running" | "completed" | "failed" | "cancelled" | "interrupted";
18
32
  export type GroupExecutionActivity = {
@@ -91,6 +105,7 @@ export type GroupActivityUpdate = {
91
105
  id: string;
92
106
  workspaceId: string;
93
107
  activity: GroupActivity;
108
+ cloneRequests?: GroupCloneRequest[];
94
109
  };
95
110
  type GroupIdentity = {
96
111
  id: string;
@@ -101,12 +116,14 @@ type GroupIdentity = {
101
116
  };
102
117
  export type GroupSummary = GroupIdentity & {
103
118
  activity: GroupActivity;
119
+ cloneRequests?: GroupCloneRequest[];
104
120
  };
105
121
  export type GroupRoom = GroupIdentity & {
106
122
  members: GroupMember[];
107
123
  moderator: GroupModerator;
108
124
  revision: number;
109
125
  messages: GroupMessage[];
126
+ cloneRequests?: GroupCloneRequest[];
110
127
  };
111
128
  export type GroupSnapshot = Omit<GroupRoom, "revision"> & {
112
129
  revision: string;
@@ -0,0 +1,7 @@
1
+ export interface TranscriptItem {
2
+ key: string;
3
+ at: number;
4
+ seq: number;
5
+ }
6
+ /** Preserve persisted message order while placing unanchored activity cards by time. */
7
+ export declare function orderTranscriptItems(items: readonly TranscriptItem[]): string[];
@@ -0,0 +1,12 @@
1
+ /** Preserve persisted message order while placing unanchored activity cards by time. */
2
+ export function orderTranscriptItems(items) {
3
+ let messageTime = 0;
4
+ return items.map(item => {
5
+ if (!item.key.startsWith("m:"))
6
+ return item;
7
+ // Queue acceptance can predate an earlier reply. Use a monotonic placement time without
8
+ // changing the message's real timestamp or breaking the server's causal ordering.
9
+ messageTime = Math.max(messageTime, Number.isFinite(item.at) ? item.at : 0);
10
+ return { ...item, at: messageTime };
11
+ }).sort((a, b) => a.at - b.at || a.seq - b.seq).map(item => item.key);
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evandu/super-pi",
3
- "version": "0.1.256",
3
+ "version": "0.1.258",
4
4
  "description": "Web control plane and companion for Pi",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -95,6 +95,7 @@
95
95
  "scripts/super-pi-tool-names.test.mjs",
96
96
  "scripts/agent-wiring.test.mjs",
97
97
  "scripts/message-timestamps.test.mjs",
98
+ "scripts/transcript-causal-order.test.mjs",
98
99
  "scripts/pi-resolution.test.mjs",
99
100
  "scripts/agent-real-pi.test.mjs",
100
101
  "scripts/image-input-real-pi.test.mjs",