@peer-agent/protocol 0.1.0-rc.15 → 0.1.0-rc.16
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/delegation.js +8 -6
- package/dist/goal.d.ts +22 -0
- package/dist/index.d.ts +1 -1
- package/dist/session-facts.js +7 -6
- package/dist/task-overview.d.ts +2 -0
- package/dist/work-coordination.d.ts +44 -6
- package/package.json +1 -1
package/dist/delegation.js
CHANGED
|
@@ -47,8 +47,8 @@ function delegationStatus(snapshot, meta, projected) {
|
|
|
47
47
|
accepted: meta.accepted === true || (snapshot.status === 'completed' && meta.acceptance !== 'confirm'
|
|
48
48
|
&& meta.accepted === undefined && !meta.verifying && !snapshot.runnerStatus),
|
|
49
49
|
superseded: Boolean(meta.supersededBy), phase: meta.phase,
|
|
50
|
-
needsUser: snapshot.status === 'awaiting_approval', verificationActive: meta.verifying === true,
|
|
51
|
-
|
|
50
|
+
needsUser: snapshot.status === 'awaiting_approval' || snapshot.needsUser === true, verificationActive: meta.verifying === true,
|
|
51
|
+
blockedReason: snapshot.agentWaiting ? 'waiting_parent_agent' : snapshot.blockedReason,
|
|
52
52
|
}).status;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
@@ -59,6 +59,7 @@ function delegationStatus(snapshot, meta, projected) {
|
|
|
59
59
|
export function projectWorkSession(plan, conversationMeta) {
|
|
60
60
|
const projected = projectGoalPlan(plan);
|
|
61
61
|
const status = delegationStatus(plan, conversationMeta, projected);
|
|
62
|
+
const parentFollowing = status === 'waiting_agent' || status === 'verifying';
|
|
62
63
|
const transitioning = ['stopping', 'awaiting_outcome'].includes(status) || conversationMeta.origin.takeover?.phase === 'stopping';
|
|
63
64
|
return {
|
|
64
65
|
sessionId: conversationMeta.sessionId ?? plan.conversationId ?? plan.planId,
|
|
@@ -66,11 +67,12 @@ export function projectWorkSession(plan, conversationMeta) {
|
|
|
66
67
|
title: plan.title,
|
|
67
68
|
planId: plan.planId,
|
|
68
69
|
status,
|
|
69
|
-
actionRight: transitioning ? 'peer_advancing' : projected.actionRight,
|
|
70
|
-
nextAction: transitioning ? 'none' : projected.nextAction,
|
|
70
|
+
actionRight: transitioning || parentFollowing ? 'peer_advancing' : projected.actionRight,
|
|
71
|
+
nextAction: transitioning || parentFollowing ? 'none' : projected.nextAction,
|
|
71
72
|
statusLabel: status === 'stopping' ? '正在停止' : status === 'awaiting_outcome' ? '执行结果待核实'
|
|
72
|
-
: conversationMeta.origin.takeover?.phase === 'stopping' ? '正在接手'
|
|
73
|
-
|
|
73
|
+
: conversationMeta.origin.takeover?.phase === 'stopping' ? '正在接手'
|
|
74
|
+
: status === 'waiting_agent' ? '由主 Bot 跟进' : status === 'verifying' ? '核验中' : projected.statusLabel,
|
|
75
|
+
...(!transitioning && !parentFollowing && projected.needsYouReason ? { needsYouReason: projected.needsYouReason } : {}),
|
|
74
76
|
...(conversationMeta.coordination ? { coordination: conversationMeta.coordination } : {}),
|
|
75
77
|
spawnedAt: conversationMeta.spawnedAt ?? plan.updatedAt ?? '',
|
|
76
78
|
...(conversationMeta.conversationId ? { conversationId: conversationMeta.conversationId } : {}),
|
package/dist/goal.d.ts
CHANGED
|
@@ -582,6 +582,28 @@ export interface GoalExecutionCheckpoint {
|
|
|
582
582
|
}
|
|
583
583
|
/** GoalPlan 内嵌的轻量 runner 状态;不代表工具执行事实,任务完成仍必须由 Evidence 回写。 */
|
|
584
584
|
export interface GoalRunnerState {
|
|
585
|
+
/** Host-owned readonly review continuity. Native messages stay in registered checkpoint storage. */
|
|
586
|
+
readonly verificationContinuation?: {
|
|
587
|
+
readonly schemaVersion: 1;
|
|
588
|
+
readonly policyVersion?: 2;
|
|
589
|
+
readonly planId: string;
|
|
590
|
+
readonly continuationId: string;
|
|
591
|
+
readonly sourceRevision: string;
|
|
592
|
+
readonly modelKey: string;
|
|
593
|
+
readonly workId?: string;
|
|
594
|
+
readonly phase: 'ready' | 'requesting' | 'tools' | 'completed';
|
|
595
|
+
/** Current slice deadline; legacy review-wide deadlines are renewed only on safe admission. */
|
|
596
|
+
readonly deadlineAt: string;
|
|
597
|
+
readonly modelRequests: number;
|
|
598
|
+
readonly toolCalls: number;
|
|
599
|
+
readonly formatAttempt: number;
|
|
600
|
+
readonly previousText?: string;
|
|
601
|
+
readonly checkpointRef?: string;
|
|
602
|
+
readonly evidenceRefs: readonly string[];
|
|
603
|
+
readonly fingerprint?: string;
|
|
604
|
+
readonly repeats?: number;
|
|
605
|
+
readonly progressFacts?: readonly string[];
|
|
606
|
+
};
|
|
585
607
|
readonly enabled: boolean;
|
|
586
608
|
readonly status: GoalRunnerStatus;
|
|
587
609
|
readonly intent?: GoalRunnerIntent;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { ProjectWorkReceipt, ProjectWorkRecovery, ProjectWorkState, ProjectTurnEnd } from './work-coordination.ts';
|
|
1
|
+
export type { ProjectWorkBudgetLimits, ProjectWorkBudgetBoundary, ProjectReplyRecoveryAction, ProjectWorkReceipt, ProjectWorkRecovery, ProjectWorkState, ProjectTurnEnd, ProjectReplyFailureStatus, ProjectAgentSilentWait } from './work-coordination.ts';
|
|
2
2
|
export type { CoordinationAction, CoordinationLifecycle, CoordinationMandate, CoordinationDecision, TaskTransitionPhase, TaskTransition, CoordinationExecutionBinding, CoordinationSessionFacts } from './delegation-coordination.ts';
|
|
3
3
|
export { deriveSessionFacts, type SessionFactSnapshot } from './session-facts.ts';
|
|
4
4
|
export { projectAgentFailureKind, classifyProjectAgentFailure, type ProjectRecoveryFailureKind, type ProviderRequestRecovery, type ProjectAgentTurnRecovery, type ReplyAnchorCandidate } from './project-agent-failure.ts';
|
package/dist/session-facts.js
CHANGED
|
@@ -13,22 +13,23 @@ export function deriveSessionFacts(input) {
|
|
|
13
13
|
status = 'stopping';
|
|
14
14
|
else if (input.takeoverPhase === 'stopping')
|
|
15
15
|
status = 'starting';
|
|
16
|
+
else if (input.superseded && input.status !== 'completed')
|
|
17
|
+
status = 'superseded';
|
|
18
|
+
else if ((input.phase === 'paused' || input.runnerStatus === 'paused') && input.status !== 'completed')
|
|
19
|
+
status = 'paused';
|
|
16
20
|
else if (input.needsUser || input.runnerStatus === 'waiting_user')
|
|
17
21
|
status = 'waiting_user';
|
|
18
22
|
else if (input.blockedReason === 'waiting_parent_agent' && input.phase !== 'paused' && !input.superseded && input.runnerStatus !== 'paused')
|
|
19
23
|
status = 'waiting_agent';
|
|
20
|
-
else if (input.runnerStatus === 'blocked')
|
|
21
|
-
status = 'waiting_user';
|
|
22
24
|
else if (verificationActive)
|
|
23
25
|
status = 'verifying';
|
|
26
|
+
// A technical blocker is work for the parent Agent. It is not a human question.
|
|
27
|
+
else if (input.runnerStatus === 'blocked')
|
|
28
|
+
status = 'waiting_agent';
|
|
24
29
|
else if (input.status === 'completed' && ['running', 'starting', 'waiting_provider', 'resuming_after_compaction'].includes(input.runnerStatus || ''))
|
|
25
30
|
status = 'running';
|
|
26
31
|
else if (input.status === 'completed')
|
|
27
32
|
status = 'result_ready';
|
|
28
|
-
else if (input.superseded)
|
|
29
|
-
status = 'superseded';
|
|
30
|
-
else if (input.phase === 'paused')
|
|
31
|
-
status = 'paused';
|
|
32
33
|
else if (input.phase === 'starting')
|
|
33
34
|
status = 'starting';
|
|
34
35
|
else if (['approved', 'accepted', 'paused', 'interrupted'].includes(input.status || '') || input.phase === 'queued')
|
package/dist/task-overview.d.ts
CHANGED
|
@@ -240,6 +240,8 @@ export interface ConversationProjectionSnapshot {
|
|
|
240
240
|
readonly providerLabel?: string;
|
|
241
241
|
}
|
|
242
242
|
export interface GoalPlanProjectionSnapshot {
|
|
243
|
+
readonly needsUser?: boolean;
|
|
244
|
+
readonly blockedReason?: string;
|
|
243
245
|
readonly planId: string;
|
|
244
246
|
readonly status: GoalPlanStatus;
|
|
245
247
|
/** Runner 实时态;Plan 未进入自驱时为 undefined。 */
|
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
import type { ProjectRecoveryFailureKind } from './project-agent-failure.ts';
|
|
2
|
+
export interface ProjectWorkBudgetLimits {
|
|
3
|
+
readonly schemaVersion?: 2;
|
|
4
|
+
readonly source: string;
|
|
5
|
+
readonly maxModelRequests?: number;
|
|
6
|
+
readonly maxToolCalls?: number;
|
|
7
|
+
readonly maxTokens?: number;
|
|
8
|
+
readonly maxCostUsd?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ProjectWorkBudgetBoundary {
|
|
11
|
+
readonly metric: 'modelRequests' | 'toolCalls' | 'tokens' | 'costUsd';
|
|
12
|
+
readonly used: number | null;
|
|
13
|
+
readonly limit: number;
|
|
14
|
+
readonly source: string;
|
|
15
|
+
readonly reason: 'limit_reached' | 'usage_unknown' | 'reservation_pending';
|
|
16
|
+
}
|
|
17
|
+
/** Current host admission; a card action never grants execution authority. */
|
|
18
|
+
export interface ProjectReplyRecoveryAction {
|
|
19
|
+
readonly canContinue: boolean;
|
|
20
|
+
readonly blockedReason?: string;
|
|
21
|
+
readonly budget?: ProjectWorkBudgetBoundary;
|
|
22
|
+
}
|
|
23
|
+
/** A reply attempt and delegated execution have independent outcomes. Host facts only. */
|
|
24
|
+
export interface ProjectReplyFailureStatus {
|
|
25
|
+
readonly phase: 'current' | 'retrying' | 'superseded' | 'recovered' | 'cancelled' | 'paused';
|
|
26
|
+
readonly turnKind: 'user' | 'wake';
|
|
27
|
+
readonly workId?: string;
|
|
28
|
+
readonly activeSessionIds: readonly string[];
|
|
29
|
+
readonly recoveredByReplyId?: string;
|
|
30
|
+
}
|
|
31
|
+
/** Persisted on agent_turn.meta and the protected outcome; not a delivered reply. */
|
|
32
|
+
export interface ProjectAgentSilentWait {
|
|
33
|
+
readonly source: 'host' | 'tool';
|
|
34
|
+
readonly sessionIds: readonly string[];
|
|
35
|
+
}
|
|
2
36
|
/** Local host reservation; neither model text nor a UI timer owns recovery. */
|
|
3
37
|
export interface ProjectWorkRecovery {
|
|
4
38
|
readonly failureKind: ProjectRecoveryFailureKind;
|
|
@@ -31,6 +65,9 @@ export interface ProjectWorkReceipt {
|
|
|
31
65
|
readonly parentConversationId: string;
|
|
32
66
|
readonly anchorInputIds: readonly string[];
|
|
33
67
|
readonly sessionIds: readonly string[];
|
|
68
|
+
/** Current owned technical blockers; a public progress update does not discharge them. */
|
|
69
|
+
readonly repairSessionIds?: readonly string[];
|
|
70
|
+
readonly progressFacts?: readonly string[];
|
|
34
71
|
readonly state: ProjectWorkState;
|
|
35
72
|
readonly revision: number;
|
|
36
73
|
readonly checkpointRef?: string;
|
|
@@ -54,13 +91,14 @@ export interface ProjectWorkReceipt {
|
|
|
54
91
|
readonly costUsd: number;
|
|
55
92
|
readonly unknownUsage: boolean;
|
|
56
93
|
readonly unknownCost: boolean;
|
|
57
|
-
readonly limits:
|
|
58
|
-
|
|
59
|
-
readonly
|
|
60
|
-
readonly
|
|
61
|
-
readonly
|
|
62
|
-
readonly
|
|
94
|
+
readonly limits: ProjectWorkBudgetLimits;
|
|
95
|
+
readonly policyMigration?: {
|
|
96
|
+
readonly version: 2;
|
|
97
|
+
readonly reason: 'legacy_system_default_removed';
|
|
98
|
+
readonly previousLimits: ProjectWorkBudgetLimits;
|
|
99
|
+
readonly at: string;
|
|
63
100
|
};
|
|
101
|
+
readonly lastBoundary?: ProjectWorkBudgetBoundary;
|
|
64
102
|
readonly attempts: Readonly<Record<string, {
|
|
65
103
|
readonly role: string;
|
|
66
104
|
readonly requests?: number;
|