@peer-agent/protocol 0.1.0-rc.28 → 0.1.0-rc.29
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/agent-supervision.d.ts +81 -0
- package/dist/agent-supervision.js +1 -0
- package/dist/delegation-coordination.d.ts +9 -2
- package/dist/delegation.d.ts +19 -0
- package/dist/delegation.js +5 -0
- package/dist/goal.d.ts +1 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.js +2 -0
- package/dist/project-recovery.d.ts +2 -1
- package/dist/session-facts.d.ts +4 -1
- package/dist/session-facts.js +3 -0
- package/dist/system-context.d.ts +6 -0
- package/dist/task-overview.d.ts +27 -11
- package/dist/task-overview.js +92 -3
- package/dist/work-coordination.d.ts +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Local coordination facts. These records never grant project capabilities or human approval. */
|
|
2
|
+
export type AgentDeliveryIntent = 'mailbox_only' | 'ensure_turn';
|
|
3
|
+
export type InterruptionOrigin = 'user' | 'provider' | 'host_handoff' | 'lease_loss' | 'tool' | 'budget' | 'unknown';
|
|
4
|
+
export interface AgentDecisionRequest {
|
|
5
|
+
readonly sessionId: string;
|
|
6
|
+
readonly workId: string;
|
|
7
|
+
readonly parentConversationId: string;
|
|
8
|
+
readonly requestId: string;
|
|
9
|
+
readonly revision: number;
|
|
10
|
+
readonly question: string;
|
|
11
|
+
readonly options?: readonly {
|
|
12
|
+
readonly optionId: string;
|
|
13
|
+
readonly label: string;
|
|
14
|
+
}[];
|
|
15
|
+
readonly multiple?: boolean;
|
|
16
|
+
readonly allowText: boolean;
|
|
17
|
+
readonly responder: 'parent' | 'user';
|
|
18
|
+
readonly status: 'open' | 'answered' | 'cancelled';
|
|
19
|
+
readonly goalRevision: number;
|
|
20
|
+
readonly answerId?: string;
|
|
21
|
+
readonly userRequestRef?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface AgentDecisionAnswer {
|
|
24
|
+
/** Host-issued linkage to a current native user answer; never model arguments. */
|
|
25
|
+
readonly sourceInputId?: string;
|
|
26
|
+
readonly userRequestRef?: string;
|
|
27
|
+
readonly requestId: string;
|
|
28
|
+
readonly expectedRequestRevision: number;
|
|
29
|
+
readonly optionIds?: readonly string[];
|
|
30
|
+
readonly text?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface AgentCommandReceipt {
|
|
33
|
+
readonly workspaceId: string;
|
|
34
|
+
readonly operationId: string;
|
|
35
|
+
readonly messageId: string;
|
|
36
|
+
readonly sessionId: string;
|
|
37
|
+
readonly goalRevision: number;
|
|
38
|
+
readonly executionEpoch?: string;
|
|
39
|
+
readonly delivery: 'queued' | 'observed';
|
|
40
|
+
readonly admission: 'not_requested' | 'pending' | 'admitted' | 'rejected';
|
|
41
|
+
readonly effect: 'not_requested' | 'pending' | 'applied' | 'unknown' | 'rejected';
|
|
42
|
+
readonly error?: string;
|
|
43
|
+
readonly observedAt?: string;
|
|
44
|
+
readonly attemptRef?: string;
|
|
45
|
+
readonly completionRecorded?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface ContextWindowRecord {
|
|
48
|
+
readonly state: 'prepared';
|
|
49
|
+
readonly windowId: string;
|
|
50
|
+
readonly workId: string;
|
|
51
|
+
readonly conversationId: string;
|
|
52
|
+
readonly previousWindowId?: string;
|
|
53
|
+
readonly historyCursor?: string;
|
|
54
|
+
readonly hint: string;
|
|
55
|
+
readonly obligationRefs: readonly string[];
|
|
56
|
+
readonly budgetRef: string;
|
|
57
|
+
readonly at: string;
|
|
58
|
+
}
|
|
59
|
+
export interface WorkNoteRevision {
|
|
60
|
+
readonly noteId: string;
|
|
61
|
+
readonly revision: number;
|
|
62
|
+
readonly workId: string;
|
|
63
|
+
readonly conversationId: string;
|
|
64
|
+
readonly text: string;
|
|
65
|
+
readonly sourceRefs: readonly string[];
|
|
66
|
+
readonly at: string;
|
|
67
|
+
}
|
|
68
|
+
/** Bounded task-detail projection; roster queries do not hydrate the mailbox. */
|
|
69
|
+
export interface AgentSupervisionReport {
|
|
70
|
+
readonly recovery?: {
|
|
71
|
+
readonly state: 'settled' | 'waiting_user' | 'waiting_agent' | 'observing' | 'reconciliation_required' | 'user_stopped' | 'legacy_unbound' | 'blocked' | 'repairable';
|
|
72
|
+
readonly blockers: readonly string[];
|
|
73
|
+
readonly nextAction: 'none' | 'native_user_decision' | 'inspect_original_results' | 'current_user_required' | 'adopt_with_current_user' | 'inspect_blocker_and_change_method' | 'inspect_current_facts' | 'coordinate_resume' | 'answer_agent_request' | 'observe_current_attempt';
|
|
74
|
+
readonly expectedRevision?: number;
|
|
75
|
+
readonly requestId?: string;
|
|
76
|
+
readonly expectedRequestRevision?: number;
|
|
77
|
+
readonly replayAllowed?: false;
|
|
78
|
+
};
|
|
79
|
+
readonly requests: readonly AgentDecisionRequest[];
|
|
80
|
+
readonly receipts: readonly AgentCommandReceipt[];
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Coordination authority is issued by the local host, never by model arguments. */
|
|
2
|
-
export type CoordinationAction = 'parallel' | 'augment' | 'revise' | 'query' | 'answer' | 'cancel' | 'replace' | 'handoff';
|
|
2
|
+
export type CoordinationAction = 'parallel' | 'augment' | 'revise' | 'query' | 'answer' | 'cancel' | 'replace' | 'handoff' | 'resume';
|
|
3
3
|
export type CoordinationLifecycle = 'active' | 'paused' | 'cancelled' | 'fulfilled';
|
|
4
4
|
export interface CoordinationMandate {
|
|
5
5
|
schemaVersion: 1;
|
|
@@ -47,7 +47,11 @@ export interface TaskTransition {
|
|
|
47
47
|
replacementSessionId?: string;
|
|
48
48
|
executionEpoch: string;
|
|
49
49
|
phase: TaskTransitionPhase;
|
|
50
|
-
minimumExecutorVersion: 1;
|
|
50
|
+
minimumExecutorVersion: 1 | 2 | 3;
|
|
51
|
+
executionAdmission?: 'queued' | 'admitted' | 'rejected';
|
|
52
|
+
executionEffect?: 'pending' | 'applied' | 'unknown' | 'rejected';
|
|
53
|
+
executionAttemptRef?: string;
|
|
54
|
+
reconciliationRef?: string;
|
|
51
55
|
updatedAt: string;
|
|
52
56
|
}
|
|
53
57
|
export interface CoordinationExecutionBinding {
|
|
@@ -58,6 +62,9 @@ export interface CoordinationExecutionBinding {
|
|
|
58
62
|
}
|
|
59
63
|
/** Factual view of a durable operation; completed means disposition applied, not task success. */
|
|
60
64
|
export interface CoordinationSessionFacts {
|
|
65
|
+
readonly executionAdmission?: TaskTransition['executionAdmission'];
|
|
66
|
+
readonly executionEffect?: TaskTransition['executionEffect'];
|
|
67
|
+
readonly executionAttemptRef?: string;
|
|
61
68
|
readonly operationId: string;
|
|
62
69
|
readonly action: CoordinationAction;
|
|
63
70
|
readonly phase: TaskTransitionPhase;
|
package/dist/delegation.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface DelegationOrigin {
|
|
|
16
16
|
binding: import('./delegation-coordination.ts').CoordinationExecutionBinding;
|
|
17
17
|
requestedAt: string;
|
|
18
18
|
completedAt?: string;
|
|
19
|
+
repair?: boolean;
|
|
19
20
|
};
|
|
20
21
|
readonly coordinationBinding?: import('./delegation-coordination.ts').CoordinationExecutionBinding;
|
|
21
22
|
readonly cancellation?: {
|
|
@@ -26,6 +27,16 @@ export interface DelegationOrigin {
|
|
|
26
27
|
readonly completedAt?: string;
|
|
27
28
|
readonly evidenceCalls?: readonly string[];
|
|
28
29
|
readonly preserveArtifacts?: boolean;
|
|
30
|
+
readonly disposition?: 'user_withdrawn';
|
|
31
|
+
readonly withdrawal?: {
|
|
32
|
+
readonly workspaceId: string;
|
|
33
|
+
readonly parentConversationId: string;
|
|
34
|
+
readonly sessionId: string;
|
|
35
|
+
readonly planId: string;
|
|
36
|
+
readonly anchorMessageId: string;
|
|
37
|
+
readonly inputId: string;
|
|
38
|
+
readonly admittedAt: string;
|
|
39
|
+
};
|
|
29
40
|
};
|
|
30
41
|
readonly retainedForRecovery?: boolean;
|
|
31
42
|
readonly workId?: string;
|
|
@@ -64,6 +75,7 @@ export interface WorkSessionConversationMeta extends SessionQueueFacts {
|
|
|
64
75
|
readonly origin: DelegationOrigin;
|
|
65
76
|
readonly supersededBy?: string;
|
|
66
77
|
readonly acceptance?: 'auto' | 'confirm';
|
|
78
|
+
readonly resultConfirmationRequired?: boolean;
|
|
67
79
|
readonly accepted?: boolean;
|
|
68
80
|
readonly verifying?: boolean;
|
|
69
81
|
readonly phase?: 'starting' | 'verifying' | 'paused';
|
|
@@ -71,6 +83,7 @@ export interface WorkSessionConversationMeta extends SessionQueueFacts {
|
|
|
71
83
|
readonly executionOwnership?: ExecutionOwnership;
|
|
72
84
|
}
|
|
73
85
|
export interface WorkSession extends SessionQueueFacts {
|
|
86
|
+
readonly followUp?: import('./task-overview.ts').FollowUpProjection;
|
|
74
87
|
readonly verificationProgress?: VerificationProgress;
|
|
75
88
|
readonly completionReviewRequired?: boolean;
|
|
76
89
|
readonly resultConfirmationRequired?: boolean;
|
|
@@ -92,6 +105,7 @@ export interface WorkSession extends SessionQueueFacts {
|
|
|
92
105
|
readonly supersededBy?: string;
|
|
93
106
|
}
|
|
94
107
|
export interface SessionReport {
|
|
108
|
+
readonly agentSupervision?: import('./agent-supervision.ts').AgentSupervisionReport;
|
|
95
109
|
/** Current host verification, loaded with task details; never assistant prose. */
|
|
96
110
|
readonly verification?: SessionVerificationDetail;
|
|
97
111
|
readonly sessionId: string;
|
|
@@ -116,6 +130,11 @@ export interface SessionReport {
|
|
|
116
130
|
export type DelegationEventKind = 'agent_message' | 'session_running' | 'session_spawned' | 'session_progress' | 'session_needs_user' | 'report_available' | 'session_verified' | 'session_ended' | 'user_intervened' | 'objective_signal' | 'digest_due';
|
|
117
131
|
/** Local orchestration facts; never a human authorization or a verified result. */
|
|
118
132
|
export interface AgentMessage {
|
|
133
|
+
readonly deliveryIntent?: import('./agent-supervision.ts').AgentDeliveryIntent;
|
|
134
|
+
readonly decisionRequest?: import('./agent-supervision.ts').AgentDecisionRequest;
|
|
135
|
+
readonly decisionAnswer?: import('./agent-supervision.ts').AgentDecisionAnswer;
|
|
136
|
+
readonly goalRevision?: number;
|
|
137
|
+
readonly executionEpoch?: string;
|
|
119
138
|
readonly replyTo?: string;
|
|
120
139
|
readonly messageId: string;
|
|
121
140
|
readonly workspaceId: string;
|
package/dist/delegation.js
CHANGED
|
@@ -54,6 +54,7 @@ export function projectWorkSession(plan, conversationMeta) {
|
|
|
54
54
|
// `delegated` 必须是真实事实;不能用"这是工作会话"反推,否则会改写非委派历史语义。
|
|
55
55
|
...(plan.delegated === true ? { delegated: true } : {}),
|
|
56
56
|
...(conversationMeta.acceptance ? { acceptance: conversationMeta.acceptance } : {}),
|
|
57
|
+
humanGate: conversationMeta.resultConfirmationRequired === true,
|
|
57
58
|
accepted: conversationMeta.accepted === true ||
|
|
58
59
|
(plan.delegated !== true &&
|
|
59
60
|
plan.status === 'completed' &&
|
|
@@ -66,9 +67,12 @@ export function projectWorkSession(plan, conversationMeta) {
|
|
|
66
67
|
verificationActive: conversationMeta.verifying === true,
|
|
67
68
|
...(conversationMeta.phase ? { phase: conversationMeta.phase } : {}),
|
|
68
69
|
blockedReason: plan.agentWaiting ? 'waiting_parent_agent' : plan.blockedReason,
|
|
70
|
+
interrupted: plan.interrupted,
|
|
71
|
+
interruptionOrigin: plan.interruptionOrigin,
|
|
69
72
|
...(conversationMeta.origin.cancellation?.phase
|
|
70
73
|
? { cancellationPhase: conversationMeta.origin.cancellation.phase }
|
|
71
74
|
: {}),
|
|
75
|
+
...(conversationMeta.origin.cancellation?.disposition ? { cancellationDisposition: conversationMeta.origin.cancellation.disposition } : {}),
|
|
72
76
|
...(conversationMeta.coordination?.phase === 'awaiting_outcome'
|
|
73
77
|
? { takeoverPhase: 'awaiting_outcome' }
|
|
74
78
|
: conversationMeta.origin.takeover?.phase
|
|
@@ -87,6 +91,7 @@ export function projectWorkSession(plan, conversationMeta) {
|
|
|
87
91
|
nextAction: projected.nextAction,
|
|
88
92
|
statusLabel: projected.statusLabel,
|
|
89
93
|
cancelable: projected.cancelable,
|
|
94
|
+
followUp: projected.followUp,
|
|
90
95
|
...(projected.needsYouReason ? { needsYouReason: projected.needsYouReason } : {}),
|
|
91
96
|
...(conversationMeta.coordination ? { coordination: conversationMeta.coordination } : {}),
|
|
92
97
|
spawnedAt: conversationMeta.spawnedAt ?? plan.updatedAt ?? '',
|
package/dist/goal.d.ts
CHANGED
|
@@ -659,6 +659,7 @@ export interface GoalRunnerState {
|
|
|
659
659
|
* 中断在计划状态重派生时被误判为完成。
|
|
660
660
|
*/
|
|
661
661
|
readonly interruption?: {
|
|
662
|
+
readonly origin?: import('./agent-supervision.ts').InterruptionOrigin;
|
|
662
663
|
readonly source: string;
|
|
663
664
|
readonly reason: string;
|
|
664
665
|
readonly interruptedAt: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
export type { AttentionCard, BotDecisionSnapshot, BotAttentionItem, BotAttentionRequest, BotAttentionResult } from './attention.ts';
|
|
2
|
-
export type { ProjectWorkBudgetLimits, ProjectWorkBudgetBoundary, ProjectReplyRecoveryAction, ProjectWorkReceipt, ProjectWorkRecovery, ProjectWorkState, ProjectTurnEnd, ProjectReplyFailureStatus, ProjectAgentSilentWait } from './work-coordination.ts';
|
|
3
|
-
export type { CoordinationAction, CoordinationLifecycle, CoordinationMandate, CoordinationDecision, TaskTransitionPhase, TaskTransition, CoordinationExecutionBinding, CoordinationSessionFacts } from './delegation-coordination.ts';
|
|
2
|
+
export type { ProjectWorkBudgetLimits, ProjectWorkBudgetBoundary, ProjectReplyRecoveryAction, ProjectWorkReceipt, ProjectWorkRecovery, ProjectWorkState, ProjectTurnEnd, ProjectReplyFailureStatus, ProjectAgentSilentWait, } from './work-coordination.ts';
|
|
3
|
+
export type { CoordinationAction, CoordinationLifecycle, CoordinationMandate, CoordinationDecision, TaskTransitionPhase, TaskTransition, CoordinationExecutionBinding, CoordinationSessionFacts, } from './delegation-coordination.ts';
|
|
4
4
|
export { deriveSessionFacts, type SessionFactSnapshot } from './session-facts.ts';
|
|
5
5
|
export { projectAgentFailureKind, classifyProjectAgentFailure, type ProjectRecoveryFailureKind, type ProviderRequestRecovery, type ProjectAgentTurnRecovery, type ReplyAnchorCandidate } from './project-agent-failure.ts';
|
|
6
6
|
export type { EvidenceSourceDescription, EvidenceDeliveryBinding, EvidenceDelivery, ProjectAgentEvidenceReadRequest, ProjectAgentEvidenceReadResult } from './evidence-inspection.ts';
|
|
7
7
|
export { toolActivityPreview, toolActivitySummary } from './tool-activity-preview.ts';
|
|
8
8
|
export { isModelReasoningEffort, modelReasoningLevels, modelDefaultReasoningEffort, type ModelReasoningEffort } from './model-reasoning.ts';
|
|
9
|
-
export type { SelectionRange, SelectionReference, SelectionDraft, SelectionOrigin, SelectionChildSession, SelectionChildSummary, SelectionChildrenPage, SelectionChildRead } from './selection-reference.ts';
|
|
9
|
+
export type { SelectionRange, SelectionReference, SelectionDraft, SelectionOrigin, SelectionChildSession, SelectionChildSummary, SelectionChildrenPage, SelectionChildRead, } from './selection-reference.ts';
|
|
10
10
|
export { buildModelMenuGroups, modelMenuChannelName, type ModelMenuRow } from './model-menu.ts';
|
|
11
11
|
export { evaluateUiDelivery } from './ui-delivery-verification.ts';
|
|
12
12
|
export { DESKTOP_PREVIEW_PROTOCOL, DESKTOP_PREVIEW_CAPABILITY, DESKTOP_PREVIEW_TOOL } from './desktop-preview.ts';
|
|
13
13
|
export type { DesktopPreviewRequest, DesktopPreviewReply } from './desktop-preview.ts';
|
|
14
|
-
export type { UiDeliveryIdentity, UiDeliveryRequirement, UiDeliveryObservation, UiDeliveryJudgment, UiDeliveryGap } from './ui-delivery-verification.ts';
|
|
14
|
+
export type { UiDeliveryIdentity, UiDeliveryRequirement, UiDeliveryObservation, UiDeliveryJudgment, UiDeliveryGap, } from './ui-delivery-verification.ts';
|
|
15
15
|
export { REMOTE_PROTOCOL_VERSION, parseRemoteReadRequest, admitRemoteRead } from './remote-access.ts';
|
|
16
16
|
export type { RemoteReadRequest, RemoteReadContext, RemoteReadRejection, RemoteReadAdmission } from './remote-access.ts';
|
|
17
17
|
export { REMOTE_PROJECT_LIMITS, parseRemoteProjectRequest, admitRemoteProject, parseRemoteDelegationProjection } from './remote-access.ts';
|
|
18
|
-
export type { RemoteProjectGrant, RemoteProjectRequest, RemoteProjectContext, RemoteProjectRejection, RemoteProjectAdmission, RemoteDelegationProjection } from './remote-access.ts';
|
|
18
|
+
export type { RemoteProjectGrant, RemoteProjectRequest, RemoteProjectContext, RemoteProjectRejection, RemoteProjectAdmission, RemoteDelegationProjection, } from './remote-access.ts';
|
|
19
19
|
export type LocalAccessLevel = 'ask_before_local' | 'session_local' | 'restricted_local' | 'full_local';
|
|
20
20
|
export type { BotAccessPolicy, BotAccessPolicyReadRequest, BotAccessPolicyUpdateRequest, BotAccessPolicyResult } from './bot-access-policy.ts';
|
|
21
21
|
export type { ConversationLifetimeUsage, ProviderRequestUsage, RuntimeTurnUsage, UsageAmounts, UsageScope, } from './usage-accounting.ts';
|
|
@@ -439,7 +439,7 @@ export interface LlmOAuthStatus {
|
|
|
439
439
|
readonly accountId?: string;
|
|
440
440
|
readonly expiresAt?: string;
|
|
441
441
|
}
|
|
442
|
-
export type { AccountUsageSource, AccountUsageScope, AccountUsageBalance, AccountUsageSpend, AccountUsageUnavailable, AccountUsageLocal } from './account-usage.js';
|
|
442
|
+
export type { AccountUsageSource, AccountUsageScope, AccountUsageBalance, AccountUsageSpend, AccountUsageUnavailable, AccountUsageLocal, } from './account-usage.js';
|
|
443
443
|
/** 订阅额度窗口(session / weekly / model 等)。 */
|
|
444
444
|
export interface LlmSubscriptionQuotaWindow {
|
|
445
445
|
readonly id: string;
|
|
@@ -899,6 +899,7 @@ export * from './local-image.ts';
|
|
|
899
899
|
export * from './bot-conversation-read.ts';
|
|
900
900
|
export * from './project-recovery.ts';
|
|
901
901
|
export * from './local-git.ts';
|
|
902
|
+
export * from './agent-supervision.ts';
|
|
902
903
|
export type { CapabilityBlocker, DelegationCapabilityAdmission } from './capability-admission.ts';
|
|
903
904
|
export * from './project-input-recovery.ts';
|
|
904
905
|
export { botResourceReferences } from './resource-reference-hints.ts';
|
|
@@ -909,3 +910,4 @@ export * from './resource-feedback.js';
|
|
|
909
910
|
export * from './resource-edit.ts';
|
|
910
911
|
export * from './resource-file-replace.ts';
|
|
911
912
|
export * from './resource-edit-execution.ts';
|
|
913
|
+
export { decideFollowUp, type FollowUpOwner, type FollowUpReason, type FollowUpProjection } from './task-overview.ts';
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ export * from "./local-image.js";
|
|
|
46
46
|
export * from "./bot-conversation-read.js";
|
|
47
47
|
export * from "./project-recovery.js";
|
|
48
48
|
export * from "./local-git.js";
|
|
49
|
+
export * from "./agent-supervision.js";
|
|
49
50
|
export * from "./project-input-recovery.js";
|
|
50
51
|
export { botResourceReferences } from "./resource-reference-hints.js";
|
|
51
52
|
export { normalizeResourceWindowRequest, normalizeResourceWindowOwner, normalizeResourceWindowNavigation } from "./resource-window.js";
|
|
@@ -54,3 +55,4 @@ export * from './resource-feedback.js';
|
|
|
54
55
|
export * from "./resource-edit.js";
|
|
55
56
|
export * from "./resource-file-replace.js";
|
|
56
57
|
export * from "./resource-edit-execution.js";
|
|
58
|
+
export { decideFollowUp } from "./task-overview.js";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** Local maintenance controls. These commands never accept an execution verdict or a filesystem path. */
|
|
2
2
|
export interface ProjectRecoveryRequest {
|
|
3
3
|
readonly workspaceId: string;
|
|
4
|
-
|
|
4
|
+
/** `retain_all` ends every held work and child task in the plan bound by `planToken`; it never accepts ids. */
|
|
5
|
+
readonly action: 'inspect' | 'restore' | 'retain' | 'retain_all';
|
|
5
6
|
readonly planToken?: string;
|
|
6
7
|
readonly workId?: string;
|
|
7
8
|
readonly sessionId?: string;
|
package/dist/session-facts.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ExecutionOwnership, type LifecycleDecision } from './task-overview.ts';
|
|
1
|
+
import { type ExecutionOwnership, type LifecycleDecision, type LifecycleFacts } from './task-overview.ts';
|
|
2
2
|
export type { ExecutionOwnership, LifecycleDecision, LifecycleFacts } from './task-overview.ts';
|
|
3
3
|
export interface SessionFactSnapshot {
|
|
4
4
|
readonly status: LifecycleDecision['status'];
|
|
@@ -20,7 +20,10 @@ export declare function deriveSessionFacts(input: {
|
|
|
20
20
|
blockedReason?: string;
|
|
21
21
|
verificationActive?: boolean;
|
|
22
22
|
interrupted?: boolean;
|
|
23
|
+
interruptionOrigin?: LifecycleFacts['interruptionOrigin'];
|
|
24
|
+
delegated?: boolean;
|
|
23
25
|
cancellationPhase?: string;
|
|
26
|
+
cancellationDisposition?: LifecycleFacts['cancellationDisposition'];
|
|
24
27
|
takeoverPhase?: string;
|
|
25
28
|
executionOwnership?: ExecutionOwnership;
|
|
26
29
|
}): SessionFactSnapshot;
|
package/dist/session-facts.js
CHANGED
|
@@ -20,7 +20,10 @@ export function deriveSessionFacts(input) {
|
|
|
20
20
|
...(input.blockedReason ? { blockedReason: input.blockedReason } : {}),
|
|
21
21
|
...(input.verificationActive !== undefined ? { verificationActive: input.verificationActive } : {}),
|
|
22
22
|
...(input.interrupted !== undefined ? { interrupted: input.interrupted } : {}),
|
|
23
|
+
...(input.interruptionOrigin ? { interruptionOrigin: input.interruptionOrigin } : {}),
|
|
24
|
+
...(input.delegated !== undefined ? { delegated: input.delegated } : {}),
|
|
23
25
|
...(input.cancellationPhase ? { cancellationPhase: input.cancellationPhase } : {}),
|
|
26
|
+
...(input.cancellationDisposition ? { cancellationDisposition: input.cancellationDisposition } : {}),
|
|
24
27
|
...(input.takeoverPhase ? { takeoverPhase: input.takeoverPhase } : {}),
|
|
25
28
|
});
|
|
26
29
|
return {
|
package/dist/system-context.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export type AttachmentContextKind = 'image' | 'text' | 'unsupported';
|
|
2
|
+
/** Host failure facts retained with an interrupted reply; never execution authority. */
|
|
3
|
+
export interface ChatStreamFailure {
|
|
4
|
+
readonly code: string;
|
|
5
|
+
readonly causeCode?: string;
|
|
6
|
+
readonly precedingCode?: string;
|
|
7
|
+
}
|
|
2
8
|
export type AttachmentContextTransport = 'provider_image_part' | 'user_text_part' | 'metadata_only' | string;
|
|
3
9
|
/**
|
|
4
10
|
* 全局「兜底多模态模型」配置。
|
package/dist/task-overview.d.ts
CHANGED
|
@@ -265,6 +265,7 @@ export interface GoalPlanProjectionSnapshot {
|
|
|
265
265
|
readonly interrupted?: boolean;
|
|
266
266
|
/** 持久化中断事实中的用户可展示原因。 */
|
|
267
267
|
readonly interruptionReason?: string;
|
|
268
|
+
readonly interruptionOrigin?: import('./agent-supervision.ts').InterruptionOrigin;
|
|
268
269
|
readonly title: string;
|
|
269
270
|
readonly workspaceLabel?: string;
|
|
270
271
|
/** 用户可见的交付路由;缺目标分支时写「未确认」。 */
|
|
@@ -394,6 +395,7 @@ export type ExecutionOwnership = 'live' | 'ended' | 'unknown';
|
|
|
394
395
|
* 的唯一出口;任何适配器都不得自行改写生命周期结论。
|
|
395
396
|
*/
|
|
396
397
|
export interface LifecycleFacts {
|
|
398
|
+
readonly humanGate?: boolean;
|
|
397
399
|
readonly executionOwnership?: ExecutionOwnership;
|
|
398
400
|
readonly phase?: string;
|
|
399
401
|
readonly delegated?: boolean;
|
|
@@ -403,13 +405,15 @@ export interface LifecycleFacts {
|
|
|
403
405
|
readonly needsUser?: boolean;
|
|
404
406
|
/** 未消费的执行中断是当前行动权事实,优先于 completed/结果就绪。 */
|
|
405
407
|
readonly interrupted?: boolean;
|
|
408
|
+
readonly interruptionOrigin?: import('./agent-supervision.ts').InterruptionOrigin;
|
|
406
409
|
readonly verificationActive?: boolean;
|
|
407
410
|
readonly blockedReason?: string;
|
|
408
411
|
readonly cancellationPhase?: string;
|
|
412
|
+
readonly cancellationDisposition?: 'user_withdrawn';
|
|
409
413
|
readonly takeoverPhase?: string;
|
|
410
414
|
readonly coordinationPhase?: string;
|
|
411
415
|
}
|
|
412
|
-
export interface
|
|
416
|
+
export interface LifecycleCoreDecision extends ProjectionDecision {
|
|
413
417
|
readonly status: WorkSessionStatus;
|
|
414
418
|
readonly cancelable: boolean;
|
|
415
419
|
readonly needsUser: boolean;
|
|
@@ -417,16 +421,28 @@ export interface LifecycleDecision extends ProjectionDecision {
|
|
|
417
421
|
readonly blockedReason?: string;
|
|
418
422
|
}
|
|
419
423
|
/**
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
424
|
+
* 当前跟进责任(ADR 110)。`bot` = 主 Bot 自己收口的技术跟进;`user` = 真实人工/策略门槛;
|
|
425
|
+
* `none` = 退出当前待办(已签收、已被完成替换承接、用户停止已确认)。
|
|
426
|
+
* `inCurrentList` 是派生事实,不允许消费端各自按 status 再判一次。
|
|
427
|
+
*/
|
|
428
|
+
export type FollowUpOwner = 'bot' | 'user' | 'none';
|
|
429
|
+
export type FollowUpReason = 'settled' | 'superseded' | 'stop_confirmed' | 'user_withdrawn' | 'stop_unconfirmed' | 'human_request' | 'awaiting_human_gate' | 'technical_block' | 'awaiting_acceptance_technical' | 'verification_failed' | 'live_execution' | 'paused' | 'unknown_facts';
|
|
430
|
+
export interface FollowUpProjection {
|
|
431
|
+
readonly owner: FollowUpOwner;
|
|
432
|
+
readonly inCurrentList: boolean;
|
|
433
|
+
readonly reason: FollowUpReason;
|
|
434
|
+
}
|
|
435
|
+
export interface LifecycleDecision extends LifecycleCoreDecision {
|
|
436
|
+
readonly followUp: FollowUpProjection;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* 责任判定:只读同一份生命周期结论 + 同一份权威事实,不引入第二套状态机。
|
|
440
|
+
* 缺事实一律 fail closed(留在当前列表、责任在 bot),不按文案推断承接或停止。
|
|
441
|
+
*/
|
|
442
|
+
export declare function decideFollowUp(decision: Pick<LifecycleCoreDecision, 'status' | 'needsYouReason'>, facts?: LifecycleFacts, ownership?: ExecutionOwnership): FollowUpProjection;
|
|
443
|
+
/**
|
|
444
|
+
* 公开唯一出口:先取既有生命周期结论,再补同一份事实算出的跟进责任(ADR 110)。
|
|
445
|
+
* 适配器只读 `followUp`,不得按 `status` 自行再判一次列表归属与责任人。
|
|
430
446
|
*/
|
|
431
447
|
export declare function decideLifecycle(snapshot: GoalPlanProjectionSnapshot, facts?: LifecycleFacts): LifecycleDecision;
|
|
432
448
|
/** Conversation → 无计划讨论态(工作台动线 §15)。 */
|
package/dist/task-overview.js
CHANGED
|
@@ -1,4 +1,68 @@
|
|
|
1
1
|
import { projectGoalTiming } from "./goal.js";
|
|
2
|
+
function followUpOf(owner, reason) {
|
|
3
|
+
return { owner, inCurrentList: owner !== 'none', reason };
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* 责任判定:只读同一份生命周期结论 + 同一份权威事实,不引入第二套状态机。
|
|
7
|
+
* 缺事实一律 fail closed(留在当前列表、责任在 bot),不按文案推断承接或停止。
|
|
8
|
+
*/
|
|
9
|
+
export function decideFollowUp(decision, facts = {}, ownership = 'unknown') {
|
|
10
|
+
const status = decision.status;
|
|
11
|
+
const live = ownership === 'live';
|
|
12
|
+
// 停止回执是宿主在 abort + waitForIdle 之后写入的事实,不是从 status 猜的终态;
|
|
13
|
+
// `executionOwnership==='unknown'` 单独(重启残留的 running/idle/paused)不能证明已结束,
|
|
14
|
+
// 只有回执 completed 且没有活体执行才算已确认停止。
|
|
15
|
+
const stopStatus = status === 'cancelled' || status === 'stopping' || status === 'awaiting_outcome';
|
|
16
|
+
const stopPending = stopStatus && !(facts.cancellationPhase === 'completed' && !live);
|
|
17
|
+
const humanNeedsYou = status === 'waiting_user'
|
|
18
|
+
|| (status === 'result_ready' && facts.humanGate === true && facts.accepted !== true);
|
|
19
|
+
// 1) 保护性事实优先:活动执行、真实人工请求、未决停止回执,都不允许被“已签收 / 已被承接”
|
|
20
|
+
// 提前盖掉。`unknown` 本身不构成结束证据;停止只认宿主写入的完成回执。
|
|
21
|
+
if (humanNeedsYou) {
|
|
22
|
+
return status === 'result_ready' || decision.needsYouReason === 'decision'
|
|
23
|
+
? followUpOf('user', 'awaiting_human_gate')
|
|
24
|
+
: followUpOf('user', 'human_request');
|
|
25
|
+
}
|
|
26
|
+
if (live)
|
|
27
|
+
return followUpOf('bot', 'live_execution');
|
|
28
|
+
if (stopPending)
|
|
29
|
+
return followUpOf('bot', 'stop_unconfirmed');
|
|
30
|
+
if (stopStatus && facts.cancellationDisposition === 'user_withdrawn')
|
|
31
|
+
return followUpOf('none', 'user_withdrawn');
|
|
32
|
+
// 2) 退出当前待办:只有上面三类事实都不成立时,承接 / 失败 / 签收 / 已确认停止才生效。
|
|
33
|
+
// 退出只影响“当前列表归属”,不改写原验收、原核验与未完成事实。
|
|
34
|
+
if (facts.superseded === true || status === 'superseded')
|
|
35
|
+
return followUpOf('none', 'superseded');
|
|
36
|
+
// 3) 核验失败/缺证据:即使存在历史 accepted 事实也不能静默(那次验收是旧结论)。
|
|
37
|
+
if (status === 'failed')
|
|
38
|
+
return followUpOf('bot', 'verification_failed');
|
|
39
|
+
if (facts.accepted === true)
|
|
40
|
+
return followUpOf('none', 'settled');
|
|
41
|
+
if (stopStatus)
|
|
42
|
+
return followUpOf('none', 'stop_confirmed');
|
|
43
|
+
// 4) 父代理等技术阻塞:主 Bot 责任,不显示需要用户确认。
|
|
44
|
+
if (status === 'waiting_agent')
|
|
45
|
+
return followUpOf('bot', 'technical_block');
|
|
46
|
+
// 5) 执行交回不等于验收:普通结果由 Bot 自动收口,只有宿主确认过的人工门才换责任人。
|
|
47
|
+
if (status === 'result_ready')
|
|
48
|
+
return followUpOf('bot', 'awaiting_acceptance_technical');
|
|
49
|
+
// 11. 活动执行/核验:保留在当前列表。
|
|
50
|
+
if (status === 'verifying' || status === 'running' || status === 'starting' || status === 'queued') {
|
|
51
|
+
return followUpOf('bot', 'live_execution');
|
|
52
|
+
}
|
|
53
|
+
// 12. 用户暂停:等待用户恢复,维持既有「不在当前待办」表现。
|
|
54
|
+
if (status === 'paused') {
|
|
55
|
+
if (facts.interrupted === true && facts.interruptionOrigin !== 'user') {
|
|
56
|
+
return followUpOf('bot', facts.interruptionOrigin && facts.interruptionOrigin !== 'unknown' ? 'technical_block' : 'unknown_facts');
|
|
57
|
+
}
|
|
58
|
+
return followUpOf('none', 'paused');
|
|
59
|
+
}
|
|
60
|
+
// 13. 已是验收事实的状态。
|
|
61
|
+
if (status === 'accepted')
|
|
62
|
+
return followUpOf('none', 'settled');
|
|
63
|
+
// 14. 事实缺失或未知停止回执:fail closed。
|
|
64
|
+
return followUpOf('bot', 'unknown_facts');
|
|
65
|
+
}
|
|
2
66
|
/** 仍在占用执行体的 runner 状态(持久化字符串本身不构成活体证据)。 */
|
|
3
67
|
const ACTIVE_EXECUTION_RUNNER_STATUSES = new Set([
|
|
4
68
|
'running',
|
|
@@ -29,7 +93,7 @@ const NON_CANCELABLE_STATUSES = new Set([
|
|
|
29
93
|
* 过渡兼容:不传 `executionOwnership` 的旧入口按 `unknown` 处理——
|
|
30
94
|
* `runner.status` 字符串本身不能证明"还在跑";真实入口(S2/S3)应显式传入 live/ended/unknown。
|
|
31
95
|
*/
|
|
32
|
-
|
|
96
|
+
function decideLifecycleCore(snapshot, facts = {}) {
|
|
33
97
|
const declaredOwnership = facts.executionOwnership ?? snapshot.executionOwnership;
|
|
34
98
|
const ownership = declaredOwnership ?? 'unknown';
|
|
35
99
|
const persistedRunner = snapshot.runnerStatus;
|
|
@@ -53,9 +117,11 @@ export function decideLifecycle(snapshot, facts = {}) {
|
|
|
53
117
|
const verificationActive = facts.verificationActive === true;
|
|
54
118
|
const blockedReason = facts.blockedReason ?? snapshot.blockedReason;
|
|
55
119
|
const interrupted = facts.interrupted ?? snapshot.interrupted === true;
|
|
120
|
+
const interruptionOrigin = facts.interruptionOrigin ?? snapshot.interruptionOrigin;
|
|
56
121
|
const delegated = facts.delegated ?? snapshot.delegated === true;
|
|
57
122
|
let status;
|
|
58
|
-
|
|
123
|
+
// A host-confirmed stop wins over stale recovery/takeover fields, never a live owner.
|
|
124
|
+
if (snapshot.status === 'cancelled' || facts.cancellationPhase === 'completed' && ownership !== 'live')
|
|
59
125
|
status = 'cancelled';
|
|
60
126
|
else if (snapshot.status === 'failed')
|
|
61
127
|
status = 'failed';
|
|
@@ -72,6 +138,9 @@ export function decideLifecycle(snapshot, facts = {}) {
|
|
|
72
138
|
status = 'superseded';
|
|
73
139
|
else if ((facts.phase === 'paused' || runnerStatus === 'paused') && snapshot.status !== 'completed')
|
|
74
140
|
status = 'paused';
|
|
141
|
+
// A failed delegated attempt leaves recovery with the parent, not a human pause.
|
|
142
|
+
else if (interrupted && interruptionOrigin !== 'user' && delegated && runnerStatus === 'failed' && !needsUserFacts && !liveExecution)
|
|
143
|
+
status = 'waiting_agent';
|
|
75
144
|
// 未消费中断优先于 completed/结果就绪(decideGoalPlan rule 1 已按此给文案),
|
|
76
145
|
// 但持久化终态(cancelled/failed)和真实验收结论先于它。
|
|
77
146
|
else if (interrupted)
|
|
@@ -139,6 +208,13 @@ export function decideLifecycle(snapshot, facts = {}) {
|
|
|
139
208
|
*/
|
|
140
209
|
function lifecyclePresentation(status, legacy, facts) {
|
|
141
210
|
switch (status) {
|
|
211
|
+
case 'cancelled':
|
|
212
|
+
return {
|
|
213
|
+
actionRight: 'terminal',
|
|
214
|
+
nextAction: 'none',
|
|
215
|
+
statusLabel: '已取消',
|
|
216
|
+
actionLabel: '查看 →',
|
|
217
|
+
};
|
|
142
218
|
case 'waiting_user':
|
|
143
219
|
// completed 只说明计划已落库完成,不等于没有待你消费的决策:旧规则表把
|
|
144
220
|
// completed 放在最前(rule 16),会把预算门/待确认门吞成「已完成 / terminal」。
|
|
@@ -185,7 +261,7 @@ function lifecyclePresentation(status, legacy, facts) {
|
|
|
185
261
|
};
|
|
186
262
|
case 'waiting_agent':
|
|
187
263
|
// 技术阻塞是父代理的跟进项,不是人类待办;具体文案(等待答复/系统中断)沿用旧规则。
|
|
188
|
-
return legacy.actionRight === 'needs_you'
|
|
264
|
+
return legacy.actionRight === 'needs_you' || (facts.delegated && legacy.actionRight === 'paused')
|
|
189
265
|
? {
|
|
190
266
|
actionRight: 'peer_advancing',
|
|
191
267
|
nextAction: 'none',
|
|
@@ -217,6 +293,19 @@ function lifecyclePresentation(status, legacy, facts) {
|
|
|
217
293
|
return legacy;
|
|
218
294
|
}
|
|
219
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* 公开唯一出口:先取既有生命周期结论,再补同一份事实算出的跟进责任(ADR 110)。
|
|
298
|
+
* 适配器只读 `followUp`,不得按 `status` 自行再判一次列表归属与责任人。
|
|
299
|
+
*/
|
|
300
|
+
export function decideLifecycle(snapshot, facts = {}) {
|
|
301
|
+
const core = decideLifecycleCore(snapshot, facts);
|
|
302
|
+
// 与核心同一表达式的读取:不新增事实来源,也不引入第二套规则。
|
|
303
|
+
const ownership = facts.executionOwnership ?? snapshot.executionOwnership ?? 'unknown';
|
|
304
|
+
return { ...core, followUp: decideFollowUp(core, { ...facts,
|
|
305
|
+
interrupted: facts.interrupted ?? snapshot.interrupted,
|
|
306
|
+
interruptionOrigin: facts.interruptionOrigin ?? snapshot.interruptionOrigin,
|
|
307
|
+
}, ownership) };
|
|
308
|
+
}
|
|
220
309
|
/** Conversation → 无计划讨论态(工作台动线 §15)。 */
|
|
221
310
|
/**
|
|
222
311
|
* 会话是否对首页「正在讨论」可见(未读)。
|
|
@@ -47,15 +47,15 @@ export interface ProjectWorkRecovery {
|
|
|
47
47
|
}
|
|
48
48
|
export type ProjectWorkState = 'runnable' | 'waiting_children' | 'waiting_user' | 'retry_wait' | 'paused' | 'budget_limited' | 'blocked_system' | 'delivered' | 'cancelled' | 'coalesced';
|
|
49
49
|
export type ProjectTurnEnd = 'reply_committed' | 'awaiting_children' | 'yielded' | 'awaiting_user' | 'budget_limited' | 'provider_retryable' | 'no_progress' | 'user_stopped' | 'fatal' | 'coalesced';
|
|
50
|
-
/** Host reconciliation closes an interrupted review, never supplies its verdict. */
|
|
50
|
+
/** Host reconciliation closes an interrupted review/query, never supplies its result or verdict. */
|
|
51
51
|
export interface VerificationDispatchReconciliation {
|
|
52
52
|
readonly attemptId: string;
|
|
53
53
|
readonly toolCallId: string;
|
|
54
|
-
readonly capabilityId: 'verify_session' | 'local.delegation.verify_session';
|
|
54
|
+
readonly capabilityId: 'verify_session' | 'local.delegation.verify_session' | 'get_session' | 'local.delegation.get_session' | 'get_verification_detail' | 'local.delegation.get_verification_detail';
|
|
55
55
|
readonly sessionId: string;
|
|
56
56
|
readonly planId: string;
|
|
57
57
|
readonly sourceRevision: string;
|
|
58
|
-
readonly outcome: 'verification_interrupted';
|
|
58
|
+
readonly outcome: 'verification_interrupted' | 'query_interrupted';
|
|
59
59
|
readonly at: string;
|
|
60
60
|
}
|
|
61
61
|
export interface ProjectWorkReceipt {
|