@peer-agent/protocol 0.0.6 → 0.0.8
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/dist/acceptance-close-gate.d.ts +6 -0
- package/dist/acceptance-close-gate.js +5 -3
- package/dist/goal.d.ts +5 -0
- package/dist/task-overview.d.ts +14 -15
- package/dist/task-overview.js +35 -43
- package/package.json +1 -1
|
@@ -26,6 +26,11 @@ export interface AcceptanceClosePlanLike {
|
|
|
26
26
|
readonly evidenceRefs?: readonly string[] | null;
|
|
27
27
|
}[] | null;
|
|
28
28
|
} | null;
|
|
29
|
+
readonly resultAcceptance?: {
|
|
30
|
+
readonly acceptedAt?: string | null;
|
|
31
|
+
readonly acceptedBy?: string | null;
|
|
32
|
+
readonly userOverride?: boolean | null;
|
|
33
|
+
} | null;
|
|
29
34
|
}
|
|
30
35
|
export declare class AcceptanceCloseGateError extends Error {
|
|
31
36
|
readonly code = "acceptance_evidence_incomplete";
|
|
@@ -46,4 +51,5 @@ export declare function isAcceptanceClosePatch(previous: {
|
|
|
46
51
|
readonly acceptedAt?: string | null;
|
|
47
52
|
} | null | undefined, next: {
|
|
48
53
|
readonly acceptedAt?: string | null;
|
|
54
|
+
readonly userOverride?: boolean | null;
|
|
49
55
|
} | null | undefined): boolean;
|
|
@@ -55,13 +55,15 @@ function gapMessage(gaps, locale) {
|
|
|
55
55
|
if (gaps.length === 0)
|
|
56
56
|
return '';
|
|
57
57
|
if (locale === 'en') {
|
|
58
|
-
|
|
58
|
+
const head = gaps.length === 1
|
|
59
59
|
? `Cannot accept yet: ${gaps[0].description} still lacks resolvable evidence.`
|
|
60
60
|
: `Cannot accept yet: ${gaps.length} success criteria still lack resolvable evidence.`;
|
|
61
|
+
return `${head} Use Follow up to reopen the task and supply the missing evidence.`;
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
+
const head = gaps.length === 1
|
|
63
64
|
? `还不能验收:${gaps[0].description} 还缺可解析的对照证据。`
|
|
64
65
|
: `还不能验收:还有 ${gaps.length} 条成功标准缺少可解析的对照证据。`;
|
|
66
|
+
return `${head} 点「继续追问」重开任务去补证据。`;
|
|
65
67
|
}
|
|
66
68
|
export function evaluateAcceptanceCloseGate(plan, options = {}) {
|
|
67
69
|
const locale = options.locale === 'en' ? 'en' : 'zh';
|
|
@@ -106,7 +108,7 @@ export function evaluateAcceptanceCloseGate(plan, options = {}) {
|
|
|
106
108
|
}
|
|
107
109
|
export function assertAcceptanceCloseGate(plan, options = {}) {
|
|
108
110
|
const verdict = evaluateAcceptanceCloseGate(plan, options);
|
|
109
|
-
if (!verdict.ok) {
|
|
111
|
+
if (!verdict.ok && plan?.resultAcceptance?.userOverride !== true) {
|
|
110
112
|
throw new AcceptanceCloseGateError(verdict.message, verdict.gaps);
|
|
111
113
|
}
|
|
112
114
|
}
|
package/dist/goal.d.ts
CHANGED
|
@@ -646,6 +646,11 @@ export interface GoalPlan {
|
|
|
646
646
|
readonly resultAcceptance?: {
|
|
647
647
|
readonly acceptedAt: string;
|
|
648
648
|
readonly acceptedBy?: 'user' | string;
|
|
649
|
+
/**
|
|
650
|
+
* 用户在证据不全时二次确认后的强制归档覆盖。
|
|
651
|
+
* 为 true 时关闭门禁可放行,但仍应保留缺口提示供事后回看。
|
|
652
|
+
*/
|
|
653
|
+
readonly userOverride?: boolean;
|
|
649
654
|
};
|
|
650
655
|
/** 验收后交回目标分支的结果;缺字段表示尚未交回。 */
|
|
651
656
|
readonly deliveryHandoff?: GoalDeliveryHandoff;
|
package/dist/task-overview.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ import type { AutomationLifecycleStatus, AutomationRunStatus } from './automatio
|
|
|
25
25
|
*
|
|
26
26
|
* - needs_you:阻塞点在用户(待批准 / 待授权 / 待回答 / 待决策)。
|
|
27
27
|
* - peer_advancing:Peer 正在推进,用户无需介入。
|
|
28
|
-
* - result_ready
|
|
28
|
+
* - result_ready:遗留行动权(Goal 完成不再进入;交回中改挂 peer_advancing / needs_you)。
|
|
29
29
|
* - paused:用户或系统主动暂停,等待恢复。
|
|
30
30
|
* - terminal:终态,进历史页。
|
|
31
31
|
*/
|
|
@@ -143,7 +143,7 @@ export interface TaskOverviewItem {
|
|
|
143
143
|
/**
|
|
144
144
|
* 任务完成时间(ISO 字符串)。
|
|
145
145
|
* GoalPlan:优先 GoalTiming.completedAt;终态缺省时回落 updatedAt。
|
|
146
|
-
*
|
|
146
|
+
* 历史完成卡片用它展示「何时完成」,与 lastActiveAt(最近活跃)语义分离。
|
|
147
147
|
*/
|
|
148
148
|
readonly completedAt?: string;
|
|
149
149
|
/**
|
|
@@ -176,8 +176,8 @@ export interface TaskOverviewItem {
|
|
|
176
176
|
readonly actionLabel: string;
|
|
177
177
|
/**
|
|
178
178
|
* 目标线(Goal Thread)关系 —— 仅 source === 'goal_plan' 且计划携带
|
|
179
|
-
* 关系字段时出现。UI 依据 rootPlanId
|
|
180
|
-
*
|
|
179
|
+
* 关系字段时出现。UI 依据 rootPlanId 把同线 Goal 归组;
|
|
180
|
+
* 缺字段的历史计划无这些键,仍按单卡平铺(向后兼容)。
|
|
181
181
|
*/
|
|
182
182
|
readonly rootPlanId?: string;
|
|
183
183
|
readonly parentPlanId?: string;
|
|
@@ -262,12 +262,11 @@ export interface GoalPlanProjectionSnapshot {
|
|
|
262
262
|
*/
|
|
263
263
|
readonly providerLabel?: string;
|
|
264
264
|
/**
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* result_ready,由用户在 Result Review 页手动归档)。
|
|
265
|
+
* 遗留字段:用户验收戳。Goal 完成不再据此进入 result_ready;
|
|
266
|
+
* 完成即终态,交回/自检未结束仍走 peer_advancing 或 needs_you。
|
|
268
267
|
*/
|
|
269
268
|
readonly accepted?: boolean;
|
|
270
|
-
/**
|
|
269
|
+
/** 有代码副作用时,完成门之后还要质量自检过线才能进终态。 */
|
|
271
270
|
readonly requiresQualityReview?: boolean;
|
|
272
271
|
readonly qualityReviewStatus?: 'reviewing' | 'passed' | 'failed';
|
|
273
272
|
/**
|
|
@@ -341,16 +340,16 @@ export declare function projectConversation(snapshot: ConversationProjectionSnap
|
|
|
341
340
|
* 2. plan drafting → needs_you/plan_approval
|
|
342
341
|
* 4. runner waiting_user → needs_you/user_input
|
|
343
342
|
* 5. runner blocked | budget_exhausted → needs_you/decision
|
|
344
|
-
* 6. plan completed
|
|
343
|
+
* 6. plan completed:
|
|
344
|
+
* - 交回进行中 → peer_advancing;交回失败 → needs_you/decision
|
|
345
|
+
* - 否则直接 terminal(不再因未验收 / 自检缺口进入 result_ready)
|
|
345
346
|
* 8. plan executing → peer_advancing
|
|
346
347
|
* 9. runner running/compacting/resuming/exploring → peer_advancing
|
|
347
348
|
* 11. plan approved/accepted(Runner 未启动)→ peer_advancing
|
|
348
349
|
* 12. plan paused → paused
|
|
349
350
|
* 13. runner paused → paused
|
|
350
351
|
* 14. runner idle 且 plan executing → paused(异常态,提示诊断)
|
|
351
|
-
* 16. plan
|
|
352
|
-
* 已验收但交回仍在进行(delivering / idle)或失败(stopped)时
|
|
353
|
-
* 暂不进终态;仅有 deliveryRoute 不算正在交回。
|
|
352
|
+
* 16. plan cancelled/failed → terminal
|
|
354
353
|
*
|
|
355
354
|
* 注意 rule 14 在 rule 8 之前不会命中(executing 已被 rule 8 拦截),
|
|
356
355
|
* 因此实现时将 rule 14 放在 rule 8 之后、仅当 runner 显式 idle 时生效。
|
|
@@ -364,14 +363,14 @@ export declare function projectGoalPlan(snapshot: GoalPlanProjectionSnapshot, op
|
|
|
364
363
|
* 判定顺序(首个命中生效):
|
|
365
364
|
* 3. run waiting_permission → needs_you/user_input(授权权限)
|
|
366
365
|
* 4. run waiting_user → needs_you/user_input(回答问题)
|
|
367
|
-
* 7. 产品方案 A:run succeeded → terminal
|
|
366
|
+
* 7. 产品方案 A:run succeeded → terminal(定时/触发成功默认归档,不进工作台)
|
|
368
367
|
* 15. definition paused/disabled → paused
|
|
369
368
|
* 10. run scheduled/queued/preparing/running → peer_advancing
|
|
370
369
|
* 17. run 终态(succeeded/failed/cancelled/skipped/timed_out/blocked)→ terminal
|
|
371
370
|
* 18. definition completed/archived → terminal
|
|
372
371
|
*
|
|
373
|
-
* 说明:
|
|
374
|
-
* Automation 仅在 needs_you
|
|
372
|
+
* 说明:Goal 完成即终态,Automation 成功也直接终态。
|
|
373
|
+
* Automation 仅在 needs_you(权限/提问)时必须进工作台。
|
|
375
374
|
*/
|
|
376
375
|
export declare function projectAutomationRun(snapshot: AutomationProjectionSnapshot): TaskOverviewItem;
|
|
377
376
|
/**
|
package/dist/task-overview.js
CHANGED
|
@@ -78,16 +78,16 @@ export function projectConversation(snapshot) {
|
|
|
78
78
|
* 2. plan drafting → needs_you/plan_approval
|
|
79
79
|
* 4. runner waiting_user → needs_you/user_input
|
|
80
80
|
* 5. runner blocked | budget_exhausted → needs_you/decision
|
|
81
|
-
* 6. plan completed
|
|
81
|
+
* 6. plan completed:
|
|
82
|
+
* - 交回进行中 → peer_advancing;交回失败 → needs_you/decision
|
|
83
|
+
* - 否则直接 terminal(不再因未验收 / 自检缺口进入 result_ready)
|
|
82
84
|
* 8. plan executing → peer_advancing
|
|
83
85
|
* 9. runner running/compacting/resuming/exploring → peer_advancing
|
|
84
86
|
* 11. plan approved/accepted(Runner 未启动)→ peer_advancing
|
|
85
87
|
* 12. plan paused → paused
|
|
86
88
|
* 13. runner paused → paused
|
|
87
89
|
* 14. runner idle 且 plan executing → paused(异常态,提示诊断)
|
|
88
|
-
* 16. plan
|
|
89
|
-
* 已验收但交回仍在进行(delivering / idle)或失败(stopped)时
|
|
90
|
-
* 暂不进终态;仅有 deliveryRoute 不算正在交回。
|
|
90
|
+
* 16. plan cancelled/failed → terminal
|
|
91
91
|
*
|
|
92
92
|
* 注意 rule 14 在 rule 8 之前不会命中(executing 已被 rule 8 拦截),
|
|
93
93
|
* 因此实现时将 rule 14 放在 rule 8 之后、仅当 runner 显式 idle 时生效。
|
|
@@ -164,7 +164,7 @@ export function projectGoalPlan(snapshot, options) {
|
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
function decideGoalPlan(snapshot) {
|
|
167
|
-
const { status, runnerStatus, interrupted,
|
|
167
|
+
const { status, runnerStatus, interrupted, deliveryHandoffStatus } = snapshot;
|
|
168
168
|
// 未消费的网络/流式中断是当前行动权事实,优先于 completed/result_ready。
|
|
169
169
|
// 用户显式 resume 后 store 会原子清除此事实,再按正常计划状态投影。
|
|
170
170
|
if (interrupted === true) {
|
|
@@ -189,48 +189,40 @@ function decideGoalPlan(snapshot) {
|
|
|
189
189
|
}
|
|
190
190
|
// rule 16 first: 其他终态计划优先于 runner 残留态
|
|
191
191
|
// (历史 failed/cancelled/completed 上的 runner.blocked 不得再进 needs_you)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
192
|
+
// Goal 完成不再卡「待用户验收」;Evidence / criteria 仍在完成闸门约束。
|
|
193
|
+
if (status === 'completed') {
|
|
194
|
+
if (deliveryHandoffStatus && deliveryHandoffStatus !== 'delivered') {
|
|
195
|
+
if (deliveryHandoffStatus === 'stopped') {
|
|
196
|
+
return {
|
|
197
|
+
actionRight: 'needs_you',
|
|
198
|
+
needsYouReason: 'decision',
|
|
199
|
+
nextAction: 'decide_blocked',
|
|
200
|
+
statusLabel: '交回未完成',
|
|
201
|
+
actionLabel: '查看进度',
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
// 只有真实交回进行中才占工作台。仅有 deliveryRoute 不算正在交回。
|
|
205
|
+
if (deliveryHandoffStatus === 'delivering' || deliveryHandoffStatus === 'idle') {
|
|
206
|
+
return {
|
|
207
|
+
actionRight: 'peer_advancing',
|
|
208
|
+
nextAction: 'none',
|
|
209
|
+
statusLabel: '正在交回目标分支',
|
|
210
|
+
actionLabel: '查看 →',
|
|
211
|
+
};
|
|
212
|
+
}
|
|
201
213
|
}
|
|
202
|
-
// rule 6: 完成且未验收 → 结果就绪
|
|
203
214
|
return {
|
|
204
|
-
actionRight: '
|
|
205
|
-
nextAction: '
|
|
206
|
-
statusLabel: '
|
|
207
|
-
actionLabel: '
|
|
215
|
+
actionRight: 'terminal',
|
|
216
|
+
nextAction: 'none',
|
|
217
|
+
statusLabel: '已完成',
|
|
218
|
+
actionLabel: '查看 →',
|
|
208
219
|
};
|
|
209
220
|
}
|
|
210
|
-
if (status === '
|
|
211
|
-
if (deliveryHandoffStatus === 'stopped') {
|
|
212
|
-
return {
|
|
213
|
-
actionRight: 'result_ready',
|
|
214
|
-
nextAction: 'review_result',
|
|
215
|
-
statusLabel: '交回未完成',
|
|
216
|
-
actionLabel: '查看进度',
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
// 只有真实交回进行中才占工作台。仅有 deliveryRoute 不算正在交回。
|
|
220
|
-
if (deliveryHandoffStatus === 'delivering' || deliveryHandoffStatus === 'idle') {
|
|
221
|
-
return {
|
|
222
|
-
actionRight: 'result_ready',
|
|
223
|
-
nextAction: 'none',
|
|
224
|
-
statusLabel: '正在交回目标分支',
|
|
225
|
-
actionLabel: '查看 →',
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
if (status === 'completed' || status === 'cancelled' || status === 'failed') {
|
|
221
|
+
if (status === 'cancelled' || status === 'failed') {
|
|
230
222
|
return {
|
|
231
223
|
actionRight: 'terminal',
|
|
232
224
|
nextAction: 'none',
|
|
233
|
-
statusLabel: status === '
|
|
225
|
+
statusLabel: status === 'cancelled' ? '已取消' : '已失败',
|
|
234
226
|
actionLabel: '查看 →',
|
|
235
227
|
};
|
|
236
228
|
}
|
|
@@ -360,14 +352,14 @@ function decideGoalPlan(snapshot) {
|
|
|
360
352
|
* 判定顺序(首个命中生效):
|
|
361
353
|
* 3. run waiting_permission → needs_you/user_input(授权权限)
|
|
362
354
|
* 4. run waiting_user → needs_you/user_input(回答问题)
|
|
363
|
-
* 7. 产品方案 A:run succeeded → terminal
|
|
355
|
+
* 7. 产品方案 A:run succeeded → terminal(定时/触发成功默认归档,不进工作台)
|
|
364
356
|
* 15. definition paused/disabled → paused
|
|
365
357
|
* 10. run scheduled/queued/preparing/running → peer_advancing
|
|
366
358
|
* 17. run 终态(succeeded/failed/cancelled/skipped/timed_out/blocked)→ terminal
|
|
367
359
|
* 18. definition completed/archived → terminal
|
|
368
360
|
*
|
|
369
|
-
* 说明:
|
|
370
|
-
* Automation 仅在 needs_you
|
|
361
|
+
* 说明:Goal 完成即终态,Automation 成功也直接终态。
|
|
362
|
+
* Automation 仅在 needs_you(权限/提问)时必须进工作台。
|
|
371
363
|
*/
|
|
372
364
|
export function projectAutomationRun(snapshot) {
|
|
373
365
|
const decision = decideAutomation(snapshot);
|