@evandu/super-pi 0.1.183 → 0.1.186
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/agents/coder.md +1 -1
- package/agents/planner.md +1 -1
- package/agents/project-leader.md +2 -2
- package/agents/reviewer.md +1 -1
- package/agents/super-pi-task/core.ts +164 -7
- package/agents/super-pi-task/index.ts +33 -1
- package/dist/client/.super-pi-client-sources.json +7 -7
- package/dist/client/assets/{CodeMirrorEditor-DUyqaSOB.js → CodeMirrorEditor-Cmx7-z0f.js} +2 -2
- package/dist/client/assets/{dist-CPmDYAQT.js → dist-B8CAEuXW.js} +1 -1
- package/dist/client/assets/{dist-nbHIDjzw.js → dist-BKx3CpQJ.js} +1 -1
- package/dist/client/assets/{dist-CB124C6Z.js → dist-BMSVWA_A.js} +1 -1
- package/dist/client/assets/{dist-CU8JEI5K.js → dist-BdiInYmk.js} +1 -1
- package/dist/client/assets/{dist-D3HMZhM-.js → dist-Bq7p17eF.js} +1 -1
- package/dist/client/assets/{dist-CvLzvDh7.js → dist-BzqUlzAf.js} +1 -1
- package/dist/client/assets/{dist-Dkm31GRe.js → dist-C0PMHwdm.js} +1 -1
- package/dist/client/assets/{dist-CeU4Svbh.js → dist-C2ltv_8u.js} +1 -1
- package/dist/client/assets/{dist-DTd2PCza.js → dist-CDSDxXju.js} +1 -1
- package/dist/client/assets/{dist-DLOUy-hB.js → dist-CKZOnuRU.js} +1 -1
- package/dist/client/assets/{dist-ka17rnWs.js → dist-CWlI6qO0.js} +1 -1
- package/dist/client/assets/{dist-AQ8CYp6b.js → dist-CXDhHY7N.js} +1 -1
- package/dist/client/assets/{dist-Dnx8LlEL.js → dist-Cblc22Ag.js} +1 -1
- package/dist/client/assets/{dist-Bj218gfa.js → dist-CcuBp_Kn.js} +1 -1
- package/dist/client/assets/{dist-CNem2r_T.js → dist-DHFt0Hvo.js} +1 -1
- package/dist/client/assets/{dist-NLNoAzKl.js → dist-D_7x3oZt.js} +1 -1
- package/dist/client/assets/{dist-D4lWO1EF.js → dist-RHYiODih.js} +1 -1
- package/dist/client/assets/{dist-CkTZUfAR.js → dist-V27Fcf8p.js} +1 -1
- package/dist/client/assets/{dist-Dlg4MpdE.js → dist-WfagMkC4.js} +1 -1
- package/dist/client/assets/{dist-dnyR0Vf6.js → dist-akJoBtjs.js} +1 -1
- package/dist/client/assets/{dist-C7PhA7pe.js → dist-frBiV55p.js} +1 -1
- package/dist/client/assets/{dist-TX6Uhfee.js → dist-ibsGPa_S.js} +1 -1
- package/dist/client/assets/{index-Ui6aXMVV.css → index-BXQjUHV_.css} +1 -1
- package/dist/client/assets/{index-BplDWdZp.js → index-Dx7HAZ5j.js} +14 -13
- package/dist/client/index.html +2 -2
- package/dist/server/agents.d.ts +1 -1
- package/dist/server/agents.js +1 -1
- package/dist/server/application/conversation-service.d.ts +13 -0
- package/dist/server/application/conversation-service.js +21 -0
- package/dist/server/application/project-service.d.ts +2 -70
- package/dist/server/application/project-service.js +102 -205
- package/dist/server/application/run-service.d.ts +39 -3
- package/dist/server/application/run-service.js +166 -18
- package/dist/server/application/session-orchestrator-service.d.ts +38 -5
- package/dist/server/application/session-orchestrator-service.js +167 -5
- package/dist/server/command-handler.js +5 -1
- package/dist/server/http-server.js +45 -18
- package/dist/server/index.js +1 -1
- package/dist/server/pi-session.d.ts +3 -2
- package/dist/server/runtime.js +9 -6
- package/dist/server/session-tree-scope.d.ts +1 -1
- package/dist/server/store.d.ts +24 -0
- package/dist/server/store.js +229 -4
- package/dist/server/task-tool.d.ts +5 -2
- package/dist/server/task-tool.js +25 -2
- package/dist/server/types.d.ts +43 -13
- package/dist/server/upload.d.ts +2 -6
- package/dist/server/upload.js +7 -5
- package/dist/shared/session-reporting.d.ts +13 -2
- package/dist/shared/session-reporting.js +62 -15
- package/package.json +8 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { deriveReportingState, deriveSessionState, sessionStateWord, } from "../../shared/session-reporting.js";
|
|
2
3
|
const stamp = () => new Date().toISOString();
|
|
3
4
|
/**
|
|
4
5
|
* WHAT THE PROJECT LEADER IS TOLD WHEN IT STARTS.
|
|
@@ -18,8 +19,8 @@ const stamp = () => new Date().toISOString();
|
|
|
18
19
|
* leader has no subordinates at all, so it is told the second half only - it must not decide
|
|
19
20
|
* alone either - and is never told about subordinates it does not have.
|
|
20
21
|
*/
|
|
21
|
-
export const STANDARD_LEADER_PROMPT = "你是直接向 Boss 负责的项目 Leader
|
|
22
|
-
export const LIGHTWEIGHT_LEADER_PROMPT = "你是直接向 Boss 负责的项目 Leader
|
|
22
|
+
export const STANDARD_LEADER_PROMPT = "你是直接向 Boss 负责的项目 Leader,兼任秘书。开篇上下文已给出项目目标、模式、分工与当前任务清单,不必先调用 project(action=get) 就能直接拆解、派活或推进。小项目只拆最少必要任务,大项目按交付边界分工。用 add_task 登记任务(明确目标、交付物、验收标准、依赖);add_task / update_task 时可以带 executorProfile 与 reviewerProfile(支持指定 agentId、cwd、model、thinkingLevel、watchdogTimeoutSeconds),按任务性质将执行与复核委派给最合适的员工,不指定则继承项目默认;需要继续拆解的工作设 role=leader,叶子执行任务设 role=executor,子 Leader 用 parentTaskId 登记自己的子任务,dispatch 立即启动执行子会话;不要用 session_spawn/session_dispatch 或 task/workflow 绕开项目分工与汇报线。收到交付后用 request_review 启动独立复核。派发后子会话会立即开始执行并在完成后自动回报给你,届时继续派发 ready 任务、复核待验收任务或按 review.summary 返工;不要轮询等待,不要反复无进展重试,等待回报时直接结束当前回复。用 report 登记关键进展。你的下属的升级先到你这里:你在自己这一层处理,能自己解决的自己解决;只有确实需要 Boss 决策的(重大偏差、权限或范围变更)才用 escalate 交给 Boss。你不能替 Boss 做决定,也不要把没处理的升级压下去不理。所有任务验收后,用 complete 提交带证据的最终交付总结。上下文有限,明确假设,主动寻找反证。只在本次触发范围内工作。";
|
|
23
|
+
export const LIGHTWEIGHT_LEADER_PROMPT = "你是直接向 Boss 负责的项目 Leader,这是一个轻量项目:这个项目由你亲自完成,不要拆子任务、不要派发给别人、也没有独立复核。开篇上下文已给出项目目标、模式与当前任务清单,不必先调用 project(action=get) 就能直接动手。用 add_task 登记任务(明确目标、交付物、验收标准、依赖),任务一律登记为执行任务:role=leader 或带 parentTaskId 都会被拒绝。dispatch 会把任务交回给你自己,你亲自做完;做完后调用 project(action=submit, projectId, taskId, output, evidenceRefs) 提交交付,提交即完成,不会有人回来复核,证据必须附上。不要用 session_spawn/session_dispatch 或 task/workflow 绕开项目职责与汇报线。不要轮询等待,不要反复无进展重试。用 report 登记关键进展,用 escalate 将重大偏差、权限或范围变更交给 Boss,不得自行解决升级事项。所有任务交付后,用 complete 提交带证据的最终交付总结。上下文有限,明确假设,主动寻找反证。只在本次触发范围内工作。";
|
|
23
24
|
const text = (value, label) => {
|
|
24
25
|
if (typeof value !== "string" || !value.trim())
|
|
25
26
|
throw new Error(`${label} 不能为空`);
|
|
@@ -120,41 +121,11 @@ export const mergeProfile = (taskProfile, projectDefault) => {
|
|
|
120
121
|
const closed = (p) => ["completed", "cancelled", "failed"].includes(p.status);
|
|
121
122
|
const busy = (status) => ["running", "waiting", "awaiting_background"].includes(status ?? "");
|
|
122
123
|
const dependenciesComplete = (p, t) => t.dependencies.every((id) => p.tasks.find((candidate) => candidate.id === id)?.status === "completed");
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
// little more than one (1.25x). Counting them at 1:1 inflates an agent run by an order of
|
|
126
|
-
// magnitude, so a budget written by intuition always blows up. The formula is:
|
|
127
|
-
// input + output + cacheWrite * 1.25 + cacheRead * 0.1
|
|
128
|
-
// and it is shown to the reader, because a budget nobody can predict is a budget nobody trusts.
|
|
124
|
+
// Usage accounting uses billing-equivalent tokens so the panel and report match provider bills,
|
|
125
|
+
// alongside the raw 1:1 components. There is no budget cap or admission gate.
|
|
129
126
|
const CACHE_READ_WEIGHT = 0.1;
|
|
130
127
|
const CACHE_WRITE_WEIGHT = 1.25;
|
|
131
128
|
const tokens = (usage) => usage ? Math.round(usage.input + usage.output + usage.cacheWrite * CACHE_WRITE_WEIGHT + usage.cacheRead * CACHE_READ_WEIGHT) : 0;
|
|
132
|
-
/**
|
|
133
|
-
* THE BUDGET A PROJECT STARTS WITH, AND THE FALLBACK A BUDGETLESS PROJECT IS READ AT.
|
|
134
|
-
*
|
|
135
|
-
* 400,000 equivalent tokens, and the number is measured rather than guessed: one real project
|
|
136
|
-
* with two tasks, each with an independent review, spent 378,424 equivalent tokens (1,448,095
|
|
137
|
-
* raw) and stopped ONE REVIEW SHORT of done at exactly this kind of cap. A task with its review
|
|
138
|
-
* costs about 190,000 equivalent tokens - roughly 20 turns at about 9,500 equivalent tokens a
|
|
139
|
-
* turn - so 400,000 carries a simple project end to end.
|
|
140
|
-
*
|
|
141
|
-
* THE OLD 100,000 WAS NOT A BUDGET, IT WAS A WALL: it could not finish one task and its review,
|
|
142
|
-
* and the project that hit it was closed as cancelled with the work already delivered. A cap that
|
|
143
|
-
* is too low does not slow a project down, it kills it; a cap that is too high only means the
|
|
144
|
-
* ceiling printed on the panel is higher than the spend. So the default is set from what a real
|
|
145
|
-
* project actually costs, and the agent is told to compute its own number on top of it.
|
|
146
|
-
*/
|
|
147
|
-
const DEFAULT_MAX_TOKENS = 400_000;
|
|
148
|
-
/**
|
|
149
|
-
* A REASON THAT SAYS "THIS IS ABOUT THE BUDGET".
|
|
150
|
-
*
|
|
151
|
-
* The word the escalation carries is what tells the reader (and the server) that the case in
|
|
152
|
-
* front of them is a budget case and not a permission case or a scope case. It is matched in
|
|
153
|
-
* both languages because the agent writes in both languages, and it is matched LOOSELY on
|
|
154
|
-
* purpose: an agent that says "撞到上限了" or "tokens" has said the same thing as one that says
|
|
155
|
-
* "预算".
|
|
156
|
-
*/
|
|
157
|
-
const BUDGET_CASE = /(预算|budget|token|上限|额度)/i;
|
|
158
129
|
/**
|
|
159
130
|
* HOW MANY PROJECTS ONE LIST CALL MAY CARRY.
|
|
160
131
|
*
|
|
@@ -342,9 +313,8 @@ const detailItem = (label, prose) => {
|
|
|
342
313
|
* the project flow then exceeds the cost of the work.
|
|
343
314
|
*
|
|
344
315
|
* A lightweight project collapses the flow to the leader session: it IS the worker, and a
|
|
345
|
-
* delivery is accepted on the executor's own evidence.
|
|
346
|
-
*
|
|
347
|
-
* what makes a project a project is the guardrails, not the number of sessions.
|
|
316
|
+
* delivery is accepted on the executor's own evidence. Mandatory evidence, the escalation path,
|
|
317
|
+
* and the event timeline stay the same.
|
|
348
318
|
*/
|
|
349
319
|
const lightweight = (p) => p.mode === "lightweight";
|
|
350
320
|
/** Persist explicit domain fields only; transport credentials never enter project records. */
|
|
@@ -424,54 +394,10 @@ export class ProjectService {
|
|
|
424
394
|
...p,
|
|
425
395
|
status: this.statusWithInterruptions(p),
|
|
426
396
|
resources,
|
|
427
|
-
suggestedMaxTokens: this.suggestedMaxTokens(p, resources.tokens),
|
|
428
397
|
tasks: p.tasks.map((t) => ProjectService.taskView(t, p)),
|
|
429
398
|
escalations: this.filterEscalations(p.escalations ?? [], actor),
|
|
430
399
|
};
|
|
431
400
|
}
|
|
432
|
-
/**
|
|
433
|
-
* THE NUMBER THE ONE-CLICK PATH OFFERS.
|
|
434
|
-
*
|
|
435
|
-
* The Boss does not type a budget when the budget runs out: a number typed in a hurry is a
|
|
436
|
-
* number nobody predicted, and a budget that is guessed wrong is the failure this whole path
|
|
437
|
-
* exists to remove. So the server suggests one instead - double what has already been spent,
|
|
438
|
-
* because an agent run that needed twice its first budget will need twice its second one, and
|
|
439
|
-
* never less than one token more than the current cap, so the offer always really raises it.
|
|
440
|
-
*/
|
|
441
|
-
suggestedMaxTokens(p, usedTokens) {
|
|
442
|
-
const current = p.budget?.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
443
|
-
return Math.max(current + 1, usedTokens * 2);
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* THE BUDGET PARAGRAPH A BUDGET EXCEPTION CARRIES - AND ONLY A BUDGET EXCEPTION.
|
|
447
|
-
*
|
|
448
|
-
* WHY THE EXCEPTION TEXT NEEDS THIS. A budget exception used to reach the Boss as one line -
|
|
449
|
-
* "请批准追加预算派发复核者" - and that line says nothing about WHO is at fault. The Boss reads
|
|
450
|
-
* it as "the Boss did not approve enough", while the truth is often "the agent set the cap too
|
|
451
|
-
* low when the project was created". Only one of those two readings leads to a fix, and the
|
|
452
|
-
* wrong one leads to approving a budget that runs into the same wall one task later.
|
|
453
|
-
*
|
|
454
|
-
* SO THE SERVER WRITES THE NUMBERS, because only the server has them: the effective usage in
|
|
455
|
-
* the §5 unit (输入 + 输出 + 缓存写入 × 1.25 + 缓存读取 × 0.1), the cap, and the number the
|
|
456
|
-
* one-click raise would offer - the very number the panel shows, so the two can never disagree.
|
|
457
|
-
*
|
|
458
|
-
* AND IT SAYS THE UNCOMFORTABLE PART OUT LOUD - 「可能是我一开始把预算填小了」. The words are in
|
|
459
|
-
* the project's own voice, because that is the voice an exception already speaks in, and an
|
|
460
|
-
* exception that never names the possibility is a case written to be approved as it stands.
|
|
461
|
-
*
|
|
462
|
-
* ONLY A BUDGET CASE GETS THESE WORDS. An exception about permissions or about scope must not
|
|
463
|
-
* carry budget numbers: a reader who sees a budget on a permission case stops reading the
|
|
464
|
-
* case. `BUDGET_CASE` decides, and it is matched on the agent's own words - the agent that
|
|
465
|
-
* says 「撞到上限了」 has said the same thing as one that says 「预算」.
|
|
466
|
-
*/
|
|
467
|
-
budgetExceptionNote(p, reason) {
|
|
468
|
-
if (!BUDGET_CASE.test(reason))
|
|
469
|
-
return undefined;
|
|
470
|
-
const used = this.resources(p).tokens;
|
|
471
|
-
const cap = p.budget?.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
472
|
-
const suggested = this.suggestedMaxTokens(p, used);
|
|
473
|
-
return `【预算说明】当前有效用量 ${grouped(used)} 等效 Token,上限 ${grouped(cap)} 等效 Token;建议提到 ${grouped(suggested)} 等效 Token(面板上「提到 N Token 并继续」用的就是这一个数)。口径:输入 + 输出 + 缓存写入 × 1.25 + 缓存读取 × 0.1。可能是我一开始把预算填小了:请按「任务数 × 每任务轮数 × 每轮上下文」重新估算,一个任务连它的独立复核约 190,000 等效 Token,宁可多给 —— 预算不够时项目会被卡住,并以取消收口。`;
|
|
474
|
-
}
|
|
475
401
|
raw(id, workspaceId) {
|
|
476
402
|
const scope = this.workspace(workspaceId);
|
|
477
403
|
const p = this.store.project(id);
|
|
@@ -808,6 +734,20 @@ export class ProjectService {
|
|
|
808
734
|
from the task row - the row says 「已中断」 and the card says 「执行中」, and the reader has
|
|
809
735
|
no way to tell which one to believe. */
|
|
810
736
|
const hasInterruptedTask = p.tasks.some((t) => t.status === "interrupted");
|
|
737
|
+
const openRequesters = new Set((p.escalations ?? [])
|
|
738
|
+
.filter((e) => e.status === "open" && e.requestedByConversationId)
|
|
739
|
+
.map((e) => e.requestedByConversationId));
|
|
740
|
+
const memberIds = new Set([
|
|
741
|
+
p.ownerConversationId,
|
|
742
|
+
...p.tasks.flatMap((t) => [t.ownerConversationId, t.reviewerConversationId]),
|
|
743
|
+
...(p.escalations ?? []).map((e) => e.requestedByConversationId),
|
|
744
|
+
].filter(Boolean));
|
|
745
|
+
for (const memberId of memberIds) {
|
|
746
|
+
const conv = this.store.conversation(memberId);
|
|
747
|
+
if (conv) {
|
|
748
|
+
conv.hasOpenEscalation = openRequesters.has(memberId);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
811
751
|
/* A PROJECT THAT HAS WORK REGISTERED BUT NO LEADER SESSION YET IS NOT RUNNING.
|
|
812
752
|
"active" used to mean "there is at least one task", so a project whose tasks were only
|
|
813
753
|
REGISTERED - nobody had started it, nobody was working on it - claimed on its card to be
|
|
@@ -848,19 +788,61 @@ export class ProjectService {
|
|
|
848
788
|
* "project" by the same rule as everybody else - there is no special case for it. */
|
|
849
789
|
const projectTreeId = p.ownerConversationId ? this.store.conversation(p.ownerConversationId)?.treeId : undefined;
|
|
850
790
|
const memberConversations = state.conversations.filter((c) => c.workspaceId === p.workspaceId && members.has(c.id));
|
|
851
|
-
const
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
791
|
+
const openEscalationRequesters = new Set((p.escalations ?? [])
|
|
792
|
+
.filter((e) => e.status === "open" && e.requestedByConversationId)
|
|
793
|
+
.map((e) => e.requestedByConversationId));
|
|
794
|
+
const snapshotMap = new Map();
|
|
795
|
+
for (const c of memberConversations) {
|
|
796
|
+
snapshotMap.set(c.id, {
|
|
797
|
+
id: c.id,
|
|
798
|
+
parentConversationId: c.parentConversationId,
|
|
799
|
+
status: c.status,
|
|
800
|
+
reportedToParentAt: c.reportedToParentAt,
|
|
801
|
+
archivedAt: c.archivedAt,
|
|
802
|
+
hasOpenEscalation: openEscalationRequesters.has(c.id),
|
|
803
|
+
...(c.hasPendingResult ? { hasPendingResult: true } : {}),
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
const sessions = memberConversations.map((c) => {
|
|
807
|
+
const parent = c.parentConversationId ? this.store.conversation(c.parentConversationId) : undefined;
|
|
808
|
+
const directChildren = memberConversations
|
|
809
|
+
.filter((child) => child.parentConversationId === c.id)
|
|
810
|
+
.map((child) => snapshotMap.get(child.id));
|
|
811
|
+
const snapshot = snapshotMap.get(c.id);
|
|
812
|
+
const reportingState = deriveReportingState({
|
|
813
|
+
conversation: snapshot,
|
|
814
|
+
parent,
|
|
815
|
+
directChildren,
|
|
816
|
+
isTopLevelUnread: false,
|
|
817
|
+
});
|
|
818
|
+
const displayStatus = deriveSessionState({
|
|
819
|
+
status: c.status,
|
|
820
|
+
reportingState,
|
|
821
|
+
});
|
|
822
|
+
const displayWord = sessionStateWord(displayStatus);
|
|
823
|
+
return {
|
|
824
|
+
id: c.id,
|
|
825
|
+
title: c.title,
|
|
826
|
+
status: c.status,
|
|
827
|
+
displayStatus,
|
|
828
|
+
displayWord,
|
|
829
|
+
reportingState,
|
|
830
|
+
hasOpenEscalation: snapshot.hasOpenEscalation,
|
|
831
|
+
reportedToParentAt: c.reportedToParentAt,
|
|
832
|
+
tokens: tokens(c.usage),
|
|
833
|
+
contextPercent: c.contextUsage?.percent,
|
|
834
|
+
// THE TREE SKELETON. The client draws the agents of a project as a tree, and the only
|
|
835
|
+
// thing that knows who spawned whom is the conversation's own parent link. It is sent
|
|
836
|
+
// verbatim (including the undefined case, which means "this session has no parent in
|
|
837
|
+
// this collection" - i.e. it is a root of the tree).
|
|
838
|
+
parentConversationId: c.parentConversationId,
|
|
839
|
+
// WHOSE MEMORY THIS SESSION WORKS FROM. The project's own tree is the one the leader
|
|
840
|
+
// opened; anything else is a session that still shares the initiator's chat memory.
|
|
841
|
+
memoryTreeId: c.treeId,
|
|
842
|
+
memoryScope: projectTreeId && c.treeId === projectTreeId ? "project" : "shared",
|
|
843
|
+
role: c.id === p.ownerConversationId ? "项目负责人" : coordinatorIds.has(c.id) ? "分支 Leader" : p.tasks.some((t) => t.reviewerConversationId === c.id) ? "独立复核" : "执行者",
|
|
844
|
+
};
|
|
845
|
+
});
|
|
864
846
|
const runs = state.subagentRuns.filter((r) => members.has(r.conversationId));
|
|
865
847
|
/* A COORDINATOR IS NOT A WORKER - EXCEPT IN A LIGHTWEIGHT PROJECT, WHERE THE LEADER IS THE
|
|
866
848
|
WORKER. There the leader session does the work itself, so a project that is running must not
|
|
@@ -1073,14 +1055,6 @@ export class ProjectService {
|
|
|
1073
1055
|
lines.push(`- 最后更新时间:${moment(p.updatedAt)}`);
|
|
1074
1056
|
if (p.closedAt)
|
|
1075
1057
|
lines.push(`- 完成时间:${moment(p.closedAt)}`);
|
|
1076
|
-
lines.push(`- 预算上限:${p.budget?.maxTokens ?? DEFAULT_MAX_TOKENS} Token`);
|
|
1077
|
-
// THE USAGE IS REPORTED IN THE SAME BILLING-EQUIVALENT UNITS THE BUDGET IS SPENT IN, and the
|
|
1078
|
-
// formula is printed next to the number: a budget nobody can predict is a budget nobody trusts.
|
|
1079
|
-
// The sentence after the formula says what the number INCLUDES - a one-shot call (a sub-agent)
|
|
1080
|
-
// is part of it, so a reader who dispatches children can see what that cost them.
|
|
1081
|
-
// THE RAW 1:1 FIGURE FOLLOWS IT, because the two differ by a factor of two and a half on a
|
|
1082
|
-
// real run, and a reader who checks the project's cost against their own tooling needs to
|
|
1083
|
-
// see both numbers and the parts they are made of.
|
|
1084
1058
|
const usage = this.resources(p);
|
|
1085
1059
|
lines.push(`- 已用等效 Token:${usage.tokens}(口径:输入 + 输出 + 缓存写入×${CACHE_WRITE_WEIGHT} + 缓存读取×${CACHE_READ_WEIGHT},取整;含项目内的一次性调用(subagent))`);
|
|
1086
1060
|
lines.push(`- 原始口径(1:1):${usage.rawTokens}(输入 ${usage.usage?.input ?? 0} + 输出 ${usage.usage?.output ?? 0} + 缓存写入 ${usage.usage?.cacheWrite ?? 0} + 缓存读取 ${usage.usage?.cacheRead ?? 0})`);
|
|
@@ -1190,14 +1164,6 @@ export class ProjectService {
|
|
|
1190
1164
|
// project the standard shape, because the standard shape is the one with the reviewer.
|
|
1191
1165
|
if (input.mode !== undefined && input.mode !== "standard" && input.mode !== "lightweight")
|
|
1192
1166
|
throw new Error("项目模式不合法:只能是 standard 或 lightweight");
|
|
1193
|
-
if (input.budget !== undefined && (!input.budget || typeof input.budget !== "object" || Array.isArray(input.budget)))
|
|
1194
|
-
throw new Error("资源预算不合法");
|
|
1195
|
-
for (const [key, value] of Object.entries(input.budget ?? {})) {
|
|
1196
|
-
if (value === undefined)
|
|
1197
|
-
continue;
|
|
1198
|
-
if (!["maxTokens", "maxConcurrent"].includes(key) || !Number.isSafeInteger(value) || value <= 0)
|
|
1199
|
-
throw new Error("资源预算必须是正整数");
|
|
1200
|
-
}
|
|
1201
1167
|
const defaultLeaderProfile = profile(input.defaultLeaderProfile, "默认 Leader 配置");
|
|
1202
1168
|
const defaultExecutorProfile = profile(input.defaultExecutorProfile, "默认执行配置");
|
|
1203
1169
|
const defaultReviewerProfile = profile(input.defaultReviewerProfile, "默认复核配置");
|
|
@@ -1211,7 +1177,7 @@ export class ProjectService {
|
|
|
1211
1177
|
const now = stamp();
|
|
1212
1178
|
const p = { id: `project_${randomUUID()}`, workspaceId, title: text(input.title, "项目标题"), objective: text(input.objective, "项目目标"),
|
|
1213
1179
|
deliverables: strings(input.deliverables, "交付物"), acceptanceCriteria: strings(input.acceptanceCriteria, "验收标准"), constraints: strings(input.constraints, "约束"),
|
|
1214
|
-
risk: input.risk ?? "low", status: "planning",
|
|
1180
|
+
risk: input.risk ?? "low", status: "planning",
|
|
1215
1181
|
// A project without a mode is a standard project: the mode is written down only when it was
|
|
1216
1182
|
// asked for, so every project that existed before the mode existed reads as standard.
|
|
1217
1183
|
...(input.mode ? { mode: input.mode } : {}),
|
|
@@ -1229,35 +1195,27 @@ export class ProjectService {
|
|
|
1229
1195
|
const saved = await this.store.setProject(p);
|
|
1230
1196
|
return this.projectView(saved);
|
|
1231
1197
|
}
|
|
1232
|
-
admission(p
|
|
1198
|
+
admission(p) {
|
|
1233
1199
|
this.live(p);
|
|
1234
1200
|
if (p.escalations.some((e) => e.status === "open" && e.severity === "high" && (e.audience === "boss" || !e.audience)))
|
|
1235
1201
|
throw new Error("等待 Boss 处理升级决策后才能继续派发");
|
|
1236
|
-
const r = this.resources(p);
|
|
1237
|
-
if (p.budget?.maxTokens && r.tokens >= p.budget.maxTokens)
|
|
1238
|
-
throw new Error("已达到已报告 Token 预算,拒绝继续派发");
|
|
1239
|
-
const reserved = p.tasks.filter((t) => {
|
|
1240
|
-
if (t.status === "in_progress" && t.role === "leader")
|
|
1241
|
-
return false;
|
|
1242
|
-
const sessionId = t.status === "in_progress" ? t.ownerConversationId : t.status === "awaiting_review" ? t.reviewerConversationId : undefined;
|
|
1243
|
-
const state = sessionId ? this.store.conversation(sessionId)?.status : undefined;
|
|
1244
|
-
if (busy(state))
|
|
1245
|
-
return true;
|
|
1246
|
-
if (state !== "idle")
|
|
1247
|
-
return false;
|
|
1248
|
-
const last = p.events?.filter((e) => e.taskId === t.id && (e.kind === "dispatched" || e.kind === "review_requested")).at(-1);
|
|
1249
|
-
return Boolean(last && Date.now() - Date.parse(last.createdAt) < 5000);
|
|
1250
|
-
}).length;
|
|
1251
|
-
if (checkConcurrency && !coordinator && p.budget?.maxConcurrent && Math.max(r.activeWorkers, reserved) >= p.budget.maxConcurrent)
|
|
1252
|
-
throw new Error("项目执行并发已满,等待任务交付后重试");
|
|
1253
1202
|
}
|
|
1254
1203
|
context(p) {
|
|
1255
|
-
|
|
1204
|
+
const modeLabel = lightweight(p) ? "轻量(由你亲自完成,提交即完成,无独立复核)" : "标准(任务分工 + 独立复核 + 逐级汇报)";
|
|
1205
|
+
const taskLines = p.tasks.length
|
|
1206
|
+
? p.tasks.map((t) => {
|
|
1207
|
+
const deps = t.dependencies.length ? `,依赖:${t.dependencies.join("、")}` : "";
|
|
1208
|
+
const owner = t.ownerConversationId ? `,执行会话:${t.ownerConversationId}` : "";
|
|
1209
|
+
const reviewer = t.reviewerConversationId ? `,复核会话:${t.reviewerConversationId}` : "";
|
|
1210
|
+
return `- ${t.id}|${t.title}|role=${t.role}|status=${t.status}${deps}${owner}${reviewer}`;
|
|
1211
|
+
}).join("\n")
|
|
1212
|
+
: "(暂无已登记任务,可直接用 add_task 拆解登记)";
|
|
1213
|
+
return `项目 ${p.id}:${p.title}\n模式:${modeLabel}\n目标:${p.objective}\n交付物:${p.deliverables.join(";")}\n验收标准:${p.acceptanceCriteria.join(";")}\n约束:${p.constraints.join(";")}\n当前任务分工:\n${taskLines}`;
|
|
1256
1214
|
}
|
|
1257
1215
|
async start(id, workspaceId, actor) {
|
|
1258
1216
|
return this.change(id, workspaceId, async (p) => {
|
|
1259
1217
|
this.topLevelAuthor(p, actor);
|
|
1260
|
-
this.admission(p
|
|
1218
|
+
this.admission(p);
|
|
1261
1219
|
if (!this.orchestrator)
|
|
1262
1220
|
throw new Error("会话编排服务未就绪");
|
|
1263
1221
|
if (p.ownerConversationId && busy(this.store.conversation(p.ownerConversationId)?.status))
|
|
@@ -1288,6 +1246,11 @@ export class ProjectService {
|
|
|
1288
1246
|
...(effective?.watchdogTimeoutSeconds ? { watchdogTimeoutSeconds: effective.watchdogTimeoutSeconds } : {}),
|
|
1289
1247
|
})).conversationId;
|
|
1290
1248
|
}
|
|
1249
|
+
for (const task of p.tasks) {
|
|
1250
|
+
if (!task.parentTaskId && (!task.accountableConversationId || task.accountableConversationId === p.initiatorConversationId)) {
|
|
1251
|
+
task.accountableConversationId = p.ownerConversationId;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1291
1254
|
this.event(p, "started", "项目负责人开始组织执行", undefined, actor);
|
|
1292
1255
|
p.status = "active";
|
|
1293
1256
|
await this.store.setProject(p);
|
|
@@ -1385,7 +1348,7 @@ export class ProjectService {
|
|
|
1385
1348
|
operation accepts. */
|
|
1386
1349
|
if (t.status !== "ready" && t.status !== "interrupted")
|
|
1387
1350
|
throw new Error("仅待派发或已中断的任务可以启动");
|
|
1388
|
-
this.admission(p
|
|
1351
|
+
this.admission(p);
|
|
1389
1352
|
if (t.role === "leader" && !t.ownerConversationId && p.tasks.filter((t) => t.role === "leader" && t.ownerConversationId).length >= 8)
|
|
1390
1353
|
throw new Error("分支 Leader 最多 8 个,请收敛组织层级");
|
|
1391
1354
|
if (!this.orchestrator || !p.ownerConversationId)
|
|
@@ -1432,7 +1395,7 @@ export class ProjectService {
|
|
|
1432
1395
|
this.event(p, "dispatched", `派发执行:${t.title}`, t.id, actor);
|
|
1433
1396
|
this.reconcile(p);
|
|
1434
1397
|
await this.store.setProject(p);
|
|
1435
|
-
const delegation = t.role === "leader" ? `你是分支 Leader,负责这项任务的拆解、委派、集成交付。用 project add_task 时必须带 parentTaskId="${t.id}";可按必要性指定 role="leader" 或 "executor";add_task / update_task 时可以带 executorProfile 与 reviewerProfile(支持指定 agentId、cwd、model、thinkingLevel、watchdogTimeoutSeconds),按任务性质将执行与复核委派给最合适的员工,不指定则继承项目默认。用 project dispatch / request_review
|
|
1398
|
+
const delegation = t.role === "leader" ? `你是分支 Leader,负责这项任务的拆解、委派、集成交付。用 project add_task 时必须带 parentTaskId="${t.id}";可按必要性指定 role="leader" 或 "executor";add_task / update_task 时可以带 executorProfile 与 reviewerProfile(支持指定 agentId、cwd、model、thinkingLevel、watchdogTimeoutSeconds),按任务性质将执行与复核委派给最合适的员工,不指定则继承项目默认。用 project dispatch / request_review 管理直属子任务,派发后子会话立即开始执行并在完成后自动回报给你,不要轮询;等待回报时结束本轮即可。所有必需子任务独立验收后才能 submit 聚合交付,上级还会独立复核你的集成结果。最多 3 层 Leader、8 个分支 Leader;小任务不要继续拆层。你的下属的升级先到你这里;你决定是自己解决还是再向上级转述。` : `你是执行者,直接上级会话是 ${manager},不得自行拆解子任务。`;
|
|
1436
1399
|
/* THE LIGHTWEIGHT TASK SAYS WHAT IS DIFFERENT, because the difference is the point: there is
|
|
1437
1400
|
no reviewer coming back, so the evidence that the reviewer would have demanded is the only
|
|
1438
1401
|
thing that stands behind the delivery. */
|
|
@@ -1731,69 +1694,6 @@ export class ProjectService {
|
|
|
1731
1694
|
await this.orchestrator?.stopSubtree?.(result.ownerConversationId);
|
|
1732
1695
|
return result;
|
|
1733
1696
|
}
|
|
1734
|
-
async updateBudget(id, input, workspaceId) {
|
|
1735
|
-
return this.change(id, workspaceId, (p) => {
|
|
1736
|
-
this.live(p);
|
|
1737
|
-
for (const key of ["maxTokens", "maxConcurrent"])
|
|
1738
|
-
if (input[key] !== undefined) {
|
|
1739
|
-
if (!Number.isSafeInteger(input[key]) || input[key] <= 0)
|
|
1740
|
-
throw new Error("资源预算必须是正整数");
|
|
1741
|
-
(p.budget ??= {})[key] = input[key];
|
|
1742
|
-
}
|
|
1743
|
-
this.event(p, "budget", `Boss 调整派发预算:${p.budget?.maxTokens} Token,并发 ${p.budget?.maxConcurrent}`);
|
|
1744
|
-
return p;
|
|
1745
|
-
});
|
|
1746
|
-
}
|
|
1747
|
-
/**
|
|
1748
|
-
* ONE CLICK: RAISE THE BUDGET AND LET THE WORK CONTINUE.
|
|
1749
|
-
*
|
|
1750
|
-
* Three things happen here, and they happen together: the cap goes up to a number the SERVER
|
|
1751
|
-
* computed, the budget exception that is waiting for a decision is closed, and the work that
|
|
1752
|
-
* was blocked is woken up again. Doing them apart is what made the old path painful - a Boss
|
|
1753
|
-
* had to open a form, type a number, press save, and then wake the leader by hand, and every
|
|
1754
|
-
* one of those steps was a chance to stop halfway.
|
|
1755
|
-
*
|
|
1756
|
-
* IT IS A BOSS OPERATION. A session may not raise the budget of its own project: the budget is
|
|
1757
|
-
* the Boss's stop, and an agent that could lift its own limit would not have one. The HTTP
|
|
1758
|
-
* layer refuses a request that carries a capability for the same reason.
|
|
1759
|
-
*
|
|
1760
|
-
* The manual `updateBudget` stays a SEPARATE intent: adjusting a number is not the same as
|
|
1761
|
-
* asking for the work to continue, so the manual path does not continue anything.
|
|
1762
|
-
*/
|
|
1763
|
-
async raiseBudgetAndContinue(id, workspaceId, callerConversationId) {
|
|
1764
|
-
if (callerConversationId)
|
|
1765
|
-
throw new Error("管理操作仅由 Boss 发起:Agent 不能提高预算,也不能替 Boss 让项目继续");
|
|
1766
|
-
const raised = await this.change(id, workspaceId, (p) => {
|
|
1767
|
-
this.live(p);
|
|
1768
|
-
const previousMaxTokens = p.budget?.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
1769
|
-
const usedTokens = this.resources(p).tokens;
|
|
1770
|
-
const suggestedMaxTokens = Math.max(previousMaxTokens + 1, usedTokens * 2);
|
|
1771
|
-
(p.budget ??= {}).maxTokens = suggestedMaxTokens;
|
|
1772
|
-
const decision = `Boss 提高预算到 ${suggestedMaxTokens} Token 并继续`;
|
|
1773
|
-
let resolvedEscalations = 0;
|
|
1774
|
-
for (const e of p.escalations) {
|
|
1775
|
-
if (e.status !== "open")
|
|
1776
|
-
continue;
|
|
1777
|
-
// ONLY THE BUDGET ONES. An exception about scope or permissions is not the Boss's to
|
|
1778
|
-
// close with a budget decision, and closing it here would hide a question nobody answered.
|
|
1779
|
-
if (!e.reason.includes("预算"))
|
|
1780
|
-
continue;
|
|
1781
|
-
e.status = "resolved";
|
|
1782
|
-
e.decision = decision;
|
|
1783
|
-
e.resolvedAt = stamp();
|
|
1784
|
-
resolvedEscalations += 1;
|
|
1785
|
-
}
|
|
1786
|
-
this.event(p, "budget", `Boss 提高派发预算:${previousMaxTokens} → ${suggestedMaxTokens} Token,并继续执行(已处理 ${resolvedEscalations} 条预算例外)`);
|
|
1787
|
-
this.reconcile(p);
|
|
1788
|
-
return { previousMaxTokens, suggestedMaxTokens, resolvedEscalations };
|
|
1789
|
-
});
|
|
1790
|
-
// AND NOW LET IT MOVE. `start` is the existing way to wake the leader: it dispatches the
|
|
1791
|
-
// leader session when the project has one, and creates one when it has not. Its refusal -
|
|
1792
|
-
// "项目负责人正在执行,请勿重复启动" - is passed through unchanged: a busy leader is a fact
|
|
1793
|
-
// the Boss has to see, not an error to swallow.
|
|
1794
|
-
const project = await this.start(id, workspaceId);
|
|
1795
|
-
return { ...raised, project };
|
|
1796
|
-
}
|
|
1797
1697
|
async addReport(id, input, workspaceId, actor) {
|
|
1798
1698
|
let supervisorToWake;
|
|
1799
1699
|
let taskForWake;
|
|
@@ -1869,16 +1769,11 @@ export class ProjectService {
|
|
|
1869
1769
|
: "执行者";
|
|
1870
1770
|
}
|
|
1871
1771
|
const reason = text(input.reason, "升级原因");
|
|
1872
|
-
/* THE BUDGET CASE GETS ITS NUMBERS HERE, WHERE THEY ARE KNOWN. A budget exception without
|
|
1873
|
-
the usage, the cap and the suggested number leaves the reader to guess, and the guess is
|
|
1874
|
-
always "the Boss did not approve enough". A non-budget exception gets no budget words at
|
|
1875
|
-
all - see `budgetExceptionNote`. */
|
|
1876
|
-
const budgetNote = this.budgetExceptionNote(p, reason);
|
|
1877
1772
|
const e = {
|
|
1878
1773
|
id: randomUUID(),
|
|
1879
1774
|
projectId: id,
|
|
1880
1775
|
taskId: t?.id,
|
|
1881
|
-
reason
|
|
1776
|
+
reason,
|
|
1882
1777
|
/* THE QUESTION IS KEPT BESIDE THE CASE. The title is what the reader decides ON - one
|
|
1883
1778
|
sentence, in the reader's terms - and the reason is the case for it. An escalation
|
|
1884
1779
|
* without a title is still a valid escalation; it simply has to be read in full. */
|
|
@@ -2114,7 +2009,7 @@ export class ProjectService {
|
|
|
2114
2009
|
if (body.action === "create") {
|
|
2115
2010
|
// ONLY A ROOT CONVERSATION MAY OPEN A PROJECT. Every dispatched session - the leader, its
|
|
2116
2011
|
// reviewers, the workers - holds the same tool, and a project opened from one of them would
|
|
2117
|
-
//
|
|
2012
|
+
// escape the parent project's delegation and reporting chain.
|
|
2118
2013
|
const conversation = this.store.conversation(actor);
|
|
2119
2014
|
if (!conversation)
|
|
2120
2015
|
throw new Error("找不到这个会话。");
|
|
@@ -2126,9 +2021,9 @@ export class ProjectService {
|
|
|
2126
2021
|
// membership, and the membership is the real reason. The set of sessions that may open a
|
|
2127
2022
|
// project is the same either way: a session is refused if it is in a project OR has a parent.
|
|
2128
2023
|
if (this.projectForSession(actor))
|
|
2129
|
-
throw new Error("
|
|
2024
|
+
throw new Error("已经在项目里的会话不能另起项目:请专注当前项目分工。");
|
|
2130
2025
|
if (conversation.parentConversationId)
|
|
2131
|
-
throw new Error("
|
|
2026
|
+
throw new Error("只有主对话可以创建项目:派发出来的会话不能另起项目。");
|
|
2132
2027
|
const running = this.store.projects().filter((p) => p.initiatorConversationId === actor && !closed(p));
|
|
2133
2028
|
if (running.length >= 3)
|
|
2134
2029
|
throw new Error("你同时进行的项目超过上限(3 个),先完成或停止一个再新建。");
|
|
@@ -2136,6 +2031,8 @@ export class ProjectService {
|
|
|
2136
2031
|
const plan = this.planTopLevelTasks(batch);
|
|
2137
2032
|
const project = await this.create({ ...input, workspaceId }, actor);
|
|
2138
2033
|
await this.registerTopLevelTasks(project.id, plan, workspaceId, actor);
|
|
2034
|
+
if (this.orchestrator)
|
|
2035
|
+
await this.start(project.id, workspaceId, actor);
|
|
2139
2036
|
return this.get(project.id, workspaceId);
|
|
2140
2037
|
}
|
|
2141
2038
|
if (body.action === "list") {
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { Store } from "../store.js";
|
|
2
2
|
import { type AgentRuntime } from "../runtime.js";
|
|
3
3
|
import type { SubagentRunRecorder } from "../subagent-runs.js";
|
|
4
|
-
import type { Conversation, Message, MessageImage, PiQueueSnapshot, QuestionAnswer, Workspace } from "../types.js";
|
|
4
|
+
import type { Conversation, Message, MessageDeliveryMode, MessageImage, PiQueueSnapshot, QuestionAnswer, Workspace } from "../types.js";
|
|
5
5
|
import type { EventBroadcaster } from "../server-context.js";
|
|
6
6
|
import type { ExtensionUiService } from "./extension-ui-service.js";
|
|
7
7
|
import type { WorkflowEngine } from "../workflow-engine.js";
|
|
8
8
|
import { FileChangeTracker } from "../file-changes.js";
|
|
9
|
+
/**
|
|
10
|
+
* Validates a caller-supplied delivery mode without silently falling back on bogus values.
|
|
11
|
+
* Undefined defaults to `"queue"`; any other value is rejected explicitly.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseMessageDeliveryMode(mode: unknown): MessageDeliveryMode;
|
|
9
14
|
export interface SubagentDispatchRequestBody {
|
|
10
15
|
conversationId?: string;
|
|
11
16
|
subagent_type?: string;
|
|
@@ -364,6 +369,14 @@ export declare class RunService {
|
|
|
364
369
|
* the user asked to be answered NOW - so the ones Pi had not delivered go back in, and clearing the
|
|
365
370
|
* queues for one message does not silently un-steer another.
|
|
366
371
|
*/
|
|
372
|
+
/**
|
|
373
|
+
* Empties Pi's steering and follow-up queues for a conversation, returning any steering message
|
|
374
|
+
* IDs that were intentionally withheld because they appear in `excludeMessageIds`.
|
|
375
|
+
*
|
|
376
|
+
* Remaining steering messages not in `excludeMessageIds` are put back into Pi's steering queue
|
|
377
|
+
* in FIFO order (matching at most once per message ID even when two messages share identical text).
|
|
378
|
+
* Remaining follow-up messages stay in Super Pi's waiting list and run after the active turn.
|
|
379
|
+
*/
|
|
367
380
|
private clearPiQueues;
|
|
368
381
|
/**
|
|
369
382
|
* Opens a turn on a message that is ALREADY IN THE TRANSCRIPT.
|
|
@@ -424,8 +437,11 @@ export declare class RunService {
|
|
|
424
437
|
* and the turn runs on them exactly as before. `composePrompt` is what tells the model who is
|
|
425
438
|
* speaking, so the model is addressed in the same words.
|
|
426
439
|
*/
|
|
427
|
-
enqueueAndRunAsAgent(conversationId: string, content: string
|
|
428
|
-
|
|
440
|
+
enqueueAndRunAsAgent(conversationId: string, content: string, options?: {
|
|
441
|
+
mode?: MessageDeliveryMode;
|
|
442
|
+
onAccepted?: (messageId: string) => void;
|
|
443
|
+
}): Promise<void>;
|
|
444
|
+
enqueueAndRun(conversationId: string, content: string, images?: MessageImage[], attachments?: import("../types.js").MessageAttachments, clientId?: string, mode?: MessageDeliveryMode): Promise<void>;
|
|
429
445
|
/**
|
|
430
446
|
* Steers a queued message into the in-flight turn.
|
|
431
447
|
*/
|
|
@@ -476,11 +492,31 @@ export declare class RunService {
|
|
|
476
492
|
*/
|
|
477
493
|
private processWaitingMessage;
|
|
478
494
|
private steerUnsafe;
|
|
495
|
+
/**
|
|
496
|
+
* Steers a newly queued message into the running turn at the next turn boundary.
|
|
497
|
+
* Mirrors `dispatchBackgroundResult`'s lock-free fallback if the active run ends before the
|
|
498
|
+
* conversation lane is entered.
|
|
499
|
+
*/
|
|
500
|
+
private steerWaitingMessageOnBusyRun;
|
|
479
501
|
/**
|
|
480
502
|
* Withdraws a waiting message.
|
|
481
503
|
*/
|
|
482
504
|
cancelQueued(conversationId: string, messageId: string): Promise<void>;
|
|
483
505
|
private cancelQueuedUnsafe;
|
|
506
|
+
/**
|
|
507
|
+
* Selectively withdraws a specific subset of queued/steered messages by id while preserving
|
|
508
|
+
* all remaining waiting and steered messages.
|
|
509
|
+
*/
|
|
510
|
+
cancelQueuedMany(conversationId: string, messageIds: string[], options?: {
|
|
511
|
+
actor?: "user" | "agent";
|
|
512
|
+
}): Promise<{
|
|
513
|
+
withdrawn: {
|
|
514
|
+
id: string;
|
|
515
|
+
content: string;
|
|
516
|
+
role: "user" | "tool";
|
|
517
|
+
}[];
|
|
518
|
+
missingIds: string[];
|
|
519
|
+
}>;
|
|
484
520
|
/**
|
|
485
521
|
* Rewrites a waiting message, in place, where the user can see it change.
|
|
486
522
|
*/
|