@peer-agent/protocol 0.1.0-rc.14 → 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.
@@ -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
- ...(snapshot.agentWaiting ? { blockedReason: 'waiting_parent_agent' } : {}),
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' ? '正在接手' : projected.statusLabel,
73
- ...(!transitioning && projected.needsYouReason ? { needsYouReason: projected.needsYouReason } : {}),
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';
@@ -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')
@@ -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;
@@ -8,10 +42,22 @@ export interface ProjectWorkRecovery {
8
42
  readonly retryAt?: string;
9
43
  readonly reservationId?: string;
10
44
  readonly deadlineAt?: string;
45
+ readonly dispatchesReconciled?: boolean;
11
46
  readonly blockedCode?: 'RECOVERY_CHECKPOINT_UNAVAILABLE';
12
47
  }
13
48
  export type ProjectWorkState = 'runnable' | 'waiting_children' | 'waiting_user' | 'retry_wait' | 'paused' | 'budget_limited' | 'blocked_system' | 'delivered' | 'cancelled';
14
49
  export type ProjectTurnEnd = 'reply_committed' | 'awaiting_children' | 'yielded' | 'awaiting_user' | 'budget_limited' | 'provider_retryable' | 'no_progress' | 'user_stopped' | 'fatal';
50
+ /** Host reconciliation closes an interrupted review, never supplies its verdict. */
51
+ export interface VerificationDispatchReconciliation {
52
+ readonly attemptId: string;
53
+ readonly toolCallId: string;
54
+ readonly capabilityId: 'verify_session' | 'local.delegation.verify_session';
55
+ readonly sessionId: string;
56
+ readonly planId: string;
57
+ readonly sourceRevision: string;
58
+ readonly outcome: 'verification_interrupted';
59
+ readonly at: string;
60
+ }
15
61
  export interface ProjectWorkReceipt {
16
62
  readonly schemaVersion: 1;
17
63
  readonly workId: string;
@@ -19,6 +65,9 @@ export interface ProjectWorkReceipt {
19
65
  readonly parentConversationId: string;
20
66
  readonly anchorInputIds: readonly string[];
21
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[];
22
71
  readonly state: ProjectWorkState;
23
72
  readonly revision: number;
24
73
  readonly checkpointRef?: string;
@@ -42,13 +91,14 @@ export interface ProjectWorkReceipt {
42
91
  readonly costUsd: number;
43
92
  readonly unknownUsage: boolean;
44
93
  readonly unknownCost: boolean;
45
- readonly limits: {
46
- readonly maxModelRequests: number;
47
- readonly maxToolCalls: number;
48
- readonly maxTokens?: number;
49
- readonly maxCostUsd?: number;
50
- readonly source: string;
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;
51
100
  };
101
+ readonly lastBoundary?: ProjectWorkBudgetBoundary;
52
102
  readonly attempts: Readonly<Record<string, {
53
103
  readonly role: string;
54
104
  readonly requests?: number;
@@ -57,13 +107,16 @@ export interface ProjectWorkReceipt {
57
107
  readonly pendingTools?: readonly {
58
108
  readonly toolCallId: string | null;
59
109
  readonly capabilityId: string | null;
110
+ readonly verificationSessionId?: string;
60
111
  }[];
61
112
  }>>;
113
+ readonly reconciledDispatches?: readonly VerificationDispatchReconciliation[];
62
114
  readonly uncertainDispatches?: readonly {
63
115
  readonly attemptId: string;
64
116
  readonly role: string;
65
117
  readonly toolCallId: string | null;
66
118
  readonly capabilityId: string | null;
119
+ readonly verificationSessionId?: string;
67
120
  }[];
68
121
  };
69
122
  readonly stopScope: 'reply' | 'work';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peer-agent/protocol",
3
- "version": "0.1.0-rc.14",
3
+ "version": "0.1.0-rc.16",
4
4
  "description": "Shared host-neutral protocol contracts for Peer Agent runtimes and clients.",
5
5
  "type": "module",
6
6
  "license": "MIT",