@peer-agent/protocol 0.1.0-rc.4 → 0.1.0-rc.41
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 +10 -1
- package/dist/acceptance-close-gate.js +12 -0
- package/dist/agent-supervision.d.ts +81 -0
- package/dist/agent-supervision.js +1 -0
- package/dist/attention.d.ts +44 -0
- package/dist/attention.js +1 -0
- package/dist/bot-access-policy.d.ts +29 -0
- package/dist/bot-access-policy.js +1 -0
- package/dist/bot-conversation-read.d.ts +25 -0
- package/dist/bot-conversation-read.js +9 -0
- package/dist/bot-model-selection.d.ts +13 -0
- package/dist/bot-model-selection.js +1 -0
- package/dist/browser-window.d.ts +48 -0
- package/dist/browser-window.js +23 -0
- package/dist/capability-admission.d.ts +20 -0
- package/dist/capability-admission.js +1 -0
- package/dist/delegation-coordination.d.ts +81 -0
- package/dist/delegation-coordination.js +1 -0
- package/dist/delegation.d.ts +216 -7
- package/dist/delegation.js +43 -39
- package/dist/document-reference.d.ts +83 -0
- package/dist/document-reference.js +1 -0
- package/dist/evidence-inspection.d.ts +64 -0
- package/dist/evidence-inspection.js +1 -0
- package/dist/goal.d.ts +50 -2
- package/dist/index.d.ts +56 -5
- package/dist/index.js +25 -0
- package/dist/input-prediction.d.ts +86 -0
- package/dist/input-prediction.js +48 -0
- package/dist/intent-coordination.d.ts +201 -0
- package/dist/intent-coordination.js +1 -0
- package/dist/interactive-result.d.ts +363 -0
- package/dist/interactive-result.js +215 -0
- package/dist/interactive-verification.d.ts +41 -0
- package/dist/interactive-verification.js +65 -0
- package/dist/local-git.d.ts +44 -0
- package/dist/local-git.js +3 -0
- package/dist/local-image.d.ts +53 -0
- package/dist/local-image.js +5 -0
- package/dist/model-reasoning.d.ts +13 -0
- package/dist/model-reasoning.js +18 -0
- package/dist/model-routing.d.ts +37 -3
- package/dist/model-routing.js +31 -5
- package/dist/project-agent-failure.d.ts +30 -0
- package/dist/project-agent-failure.js +44 -0
- package/dist/project-input-recovery.d.ts +65 -0
- package/dist/project-input-recovery.js +5 -0
- package/dist/project-recovery.d.ts +43 -0
- package/dist/project-recovery.js +1 -0
- package/dist/project.d.ts +81 -0
- package/dist/project.js +8 -5
- package/dist/remote-access.d.ts +15 -0
- package/dist/remote-access.js +1 -1
- package/dist/reply-delivery.d.ts +28 -0
- package/dist/reply-delivery.js +1 -0
- package/dist/resource-edit-execution.d.ts +68 -0
- package/dist/resource-edit-execution.js +96 -0
- package/dist/resource-edit.d.ts +237 -0
- package/dist/resource-edit.js +134 -0
- package/dist/resource-feedback-transport.d.ts +25 -0
- package/dist/resource-feedback-transport.js +93 -0
- package/dist/resource-feedback.d.ts +98 -0
- package/dist/resource-feedback.js +151 -0
- package/dist/resource-file-replace.d.ts +36 -0
- package/dist/resource-file-replace.js +40 -0
- package/dist/resource-reference-hints.d.ts +3 -0
- package/dist/resource-reference-hints.js +58 -0
- package/dist/resource-window.d.ts +222 -0
- package/dist/resource-window.js +252 -0
- package/dist/runtime-session-facts.d.ts +58 -0
- package/dist/runtime-session-facts.js +55 -0
- package/dist/session-control.d.ts +196 -0
- package/dist/session-control.js +48 -0
- package/dist/session-facts.d.ts +29 -0
- package/dist/session-facts.js +35 -0
- package/dist/system-context.d.ts +6 -0
- package/dist/task-overview.d.ts +90 -0
- package/dist/task-overview.js +322 -17
- package/dist/tool-activity-preview.d.ts +4 -0
- package/dist/tool-activity-preview.js +72 -0
- package/dist/usage-accounting.d.ts +1 -1
- package/dist/user-anchor.d.ts +17 -0
- package/dist/user-anchor.js +1 -0
- package/dist/work-coordination.d.ts +165 -0
- package/dist/work-coordination.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/** Host-issued control and resource facts. None of these receipts grants tool permission. */
|
|
2
|
+
/** Dispatch-declared protection scopes (ADR 127). Only 'directory' is produced today; the narrower kinds arrive with claim scope convergence. */
|
|
3
|
+
export type ExecutionResourceScope = {
|
|
4
|
+
readonly kind: 'directory';
|
|
5
|
+
readonly path: string;
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'file';
|
|
8
|
+
readonly path: string;
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: 'git_ref';
|
|
11
|
+
readonly ref: string;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'remote_object';
|
|
14
|
+
readonly ref: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function normalizeExecutionResourceScope(raw: unknown): ExecutionResourceScope | undefined;
|
|
17
|
+
export interface SessionExecutionIdentity {
|
|
18
|
+
readonly planId: string;
|
|
19
|
+
readonly sessionId: string;
|
|
20
|
+
readonly executionEpoch: string;
|
|
21
|
+
readonly goalRevision?: number;
|
|
22
|
+
readonly generation?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Shape only; a host must still compare it with the current canonical plan. */
|
|
25
|
+
export declare function normalizeSessionExecutionIdentity(raw: unknown): SessionExecutionIdentity | undefined;
|
|
26
|
+
export interface StopBarrierReceipt {
|
|
27
|
+
readonly receiptId: string;
|
|
28
|
+
readonly operationId: string;
|
|
29
|
+
readonly execution: SessionExecutionIdentity;
|
|
30
|
+
readonly admissionClosed: true;
|
|
31
|
+
readonly runnerIdle: true;
|
|
32
|
+
readonly schedulerIdle: true;
|
|
33
|
+
readonly resourceClaims: readonly {
|
|
34
|
+
readonly claimId: string;
|
|
35
|
+
readonly revision: number;
|
|
36
|
+
}[];
|
|
37
|
+
readonly unknownCalls: readonly string[];
|
|
38
|
+
readonly completedAt: string;
|
|
39
|
+
readonly scope: 'managed_execution';
|
|
40
|
+
}
|
|
41
|
+
export interface SessionControlOperation {
|
|
42
|
+
readonly operationId: string;
|
|
43
|
+
readonly requestDigest: string;
|
|
44
|
+
readonly revision: number;
|
|
45
|
+
readonly workspaceId: string;
|
|
46
|
+
readonly parentConversationId: string;
|
|
47
|
+
readonly sessionId: string;
|
|
48
|
+
readonly planId: string;
|
|
49
|
+
readonly kind: 'pause' | 'cancel' | 'takeover' | 'resume';
|
|
50
|
+
readonly authorityRef: string;
|
|
51
|
+
readonly hostEpoch?: string;
|
|
52
|
+
/** Pid of the process that recorded the operation. By itself this is not a death proof. */
|
|
53
|
+
readonly hostPid?: number;
|
|
54
|
+
readonly recorder?: {
|
|
55
|
+
readonly bootId: string;
|
|
56
|
+
readonly pid: number;
|
|
57
|
+
readonly pidStart: string;
|
|
58
|
+
readonly hostId: string;
|
|
59
|
+
readonly acquiredAt: string;
|
|
60
|
+
};
|
|
61
|
+
readonly unproven?: boolean;
|
|
62
|
+
readonly recoveryFactsDigest?: string;
|
|
63
|
+
readonly priorStopReceiptId?: string;
|
|
64
|
+
readonly expectedExecution: SessionExecutionIdentity;
|
|
65
|
+
readonly phase: 'recorded' | 'draining' | 'reconciling' | 'settled';
|
|
66
|
+
readonly outcome?: 'applied' | 'superseded' | 'rejected';
|
|
67
|
+
readonly supersededBy?: string;
|
|
68
|
+
readonly nextAction?: string;
|
|
69
|
+
readonly stopReceipt?: StopBarrierReceipt;
|
|
70
|
+
readonly updatedAt: string;
|
|
71
|
+
}
|
|
72
|
+
export type ExecutionResourceBlocker = {
|
|
73
|
+
readonly kind: 'owner';
|
|
74
|
+
readonly code: 'resource_busy';
|
|
75
|
+
readonly resourceRef: string;
|
|
76
|
+
readonly claimId: string;
|
|
77
|
+
readonly sessionId: string;
|
|
78
|
+
readonly title: string;
|
|
79
|
+
} | {
|
|
80
|
+
readonly kind: 'protection';
|
|
81
|
+
readonly nextAction?: 'reconcile_execution_outcome' | 'confirm_execution_stopped' | 'close_execution_claim';
|
|
82
|
+
readonly code: 'execution_outcome_unknown' | 'execution_stop_unconfirmed';
|
|
83
|
+
readonly resourceRef: string;
|
|
84
|
+
readonly claimId: string;
|
|
85
|
+
readonly sessionId?: string;
|
|
86
|
+
readonly operationId?: string;
|
|
87
|
+
readonly evidenceCalls: readonly string[];
|
|
88
|
+
readonly closeClaimAvailable?: boolean;
|
|
89
|
+
readonly scope?: ExecutionResourceScope;
|
|
90
|
+
readonly unknownOutcomePolicy?: UnknownOutcomePolicyTier;
|
|
91
|
+
readonly reconciliationAvailable?: boolean;
|
|
92
|
+
readonly resolutionTier?: UnknownOutcomeResolutionTier;
|
|
93
|
+
} | {
|
|
94
|
+
readonly kind: 'recovery';
|
|
95
|
+
readonly nextAction?: 'inspect_resource_recovery';
|
|
96
|
+
readonly code: string;
|
|
97
|
+
readonly resourceRef?: string;
|
|
98
|
+
};
|
|
99
|
+
/** A user-authorized end to one resource claim. It is not a stop receipt or a tool result. */
|
|
100
|
+
export interface ExecutionClaimClosure {
|
|
101
|
+
readonly closureId: string;
|
|
102
|
+
readonly claimId: string;
|
|
103
|
+
readonly claimRevision: number;
|
|
104
|
+
readonly execution: SessionExecutionIdentity;
|
|
105
|
+
readonly resourceRef: string;
|
|
106
|
+
readonly unknownCalls: readonly string[];
|
|
107
|
+
readonly authorityRef: string;
|
|
108
|
+
readonly proof: 'verified_dead' | 'legacy_user_confirmed';
|
|
109
|
+
/** ADR 127: present when reconciliation evidence, not a user card, authorized this closure. */
|
|
110
|
+
readonly resolution?: {
|
|
111
|
+
readonly resolutionId: string;
|
|
112
|
+
readonly tier: 'user_confirmed' | 'bot_verified';
|
|
113
|
+
readonly verdict: 'no_effect_observed' | 'effect_observed';
|
|
114
|
+
readonly evidenceDigest: string;
|
|
115
|
+
readonly policyRef?: string;
|
|
116
|
+
};
|
|
117
|
+
readonly scope: 'managed_execution';
|
|
118
|
+
readonly at: string;
|
|
119
|
+
}
|
|
120
|
+
/** ADR 127: user-delegated closure policy for unknown outcomes. Bound to the bot subject (ADR 101); the model reads it but can never write it. */
|
|
121
|
+
export type UnknownOutcomePolicyTier = 'ask' | 'bot_verified';
|
|
122
|
+
export interface UnknownOutcomePolicy {
|
|
123
|
+
readonly workspaceId: string;
|
|
124
|
+
readonly agentConversationId: string;
|
|
125
|
+
readonly tier: UnknownOutcomePolicyTier;
|
|
126
|
+
readonly policyId: string;
|
|
127
|
+
readonly revision: number;
|
|
128
|
+
readonly delegatedAt?: string;
|
|
129
|
+
readonly updatedAt: string;
|
|
130
|
+
}
|
|
131
|
+
export type ReconciliationVerdict = 'no_effect_observed' | 'effect_observed' | 'inconclusive' | 'unfenced_external';
|
|
132
|
+
export type ReconciliationProbeKind = 'process' | 'handle' | 'workspace' | 'git' | 'receipt';
|
|
133
|
+
export interface ReconciliationProbe {
|
|
134
|
+
readonly kind: ReconciliationProbeKind;
|
|
135
|
+
readonly ref: string;
|
|
136
|
+
readonly result: string;
|
|
137
|
+
readonly observedAt: string;
|
|
138
|
+
readonly digest: string;
|
|
139
|
+
}
|
|
140
|
+
/** Host-computed probe bundle. Its verdict can end occupancy at most; it never turns an unknown call into a success. */
|
|
141
|
+
export interface ReconciliationEvidence {
|
|
142
|
+
readonly execution: SessionExecutionIdentity;
|
|
143
|
+
readonly claimId: string;
|
|
144
|
+
readonly claimRevision: number;
|
|
145
|
+
readonly scope: ExecutionResourceScope;
|
|
146
|
+
readonly probes: readonly ReconciliationProbe[];
|
|
147
|
+
readonly verdict: ReconciliationVerdict;
|
|
148
|
+
readonly evidenceDigest: string;
|
|
149
|
+
}
|
|
150
|
+
export type UnknownOutcomeResolutionTier = 'user_confirmed' | 'bot_verified';
|
|
151
|
+
/** Ends occupancy for one claim (ADR 127). Unknown calls stay retained; this is not a tool result, a stop receipt or a success claim. */
|
|
152
|
+
export interface UnknownOutcomeResolution {
|
|
153
|
+
readonly resolutionId: string;
|
|
154
|
+
readonly claimId: string;
|
|
155
|
+
readonly claimRevision: number;
|
|
156
|
+
readonly execution: SessionExecutionIdentity;
|
|
157
|
+
readonly scope: ExecutionResourceScope;
|
|
158
|
+
readonly verdict: ReconciliationVerdict;
|
|
159
|
+
readonly evidenceDigest: string;
|
|
160
|
+
readonly tier: UnknownOutcomeResolutionTier;
|
|
161
|
+
readonly policyRef?: string;
|
|
162
|
+
readonly authorityRef: string;
|
|
163
|
+
readonly unknownCalls: readonly string[];
|
|
164
|
+
readonly at: string;
|
|
165
|
+
}
|
|
166
|
+
export interface ExecutionResourceClaim {
|
|
167
|
+
readonly claimId: string;
|
|
168
|
+
readonly resourceRef: string;
|
|
169
|
+
readonly execution: SessionExecutionIdentity;
|
|
170
|
+
readonly workspaceId: string;
|
|
171
|
+
readonly hostEpoch: string;
|
|
172
|
+
readonly state: 'reserved' | 'active' | 'draining' | 'reconciling' | 'released';
|
|
173
|
+
readonly revision: number;
|
|
174
|
+
readonly handles?: Readonly<Record<string, {
|
|
175
|
+
readonly handleId: string;
|
|
176
|
+
readonly toolCallId: string;
|
|
177
|
+
readonly state: 'active' | 'ended' | 'unknown';
|
|
178
|
+
readonly completedAt?: string;
|
|
179
|
+
}>>;
|
|
180
|
+
readonly evidenceCalls: readonly string[];
|
|
181
|
+
/** Absent means the legacy directory scope derived from resourceRef; dispatch-declared scopes arrive with claim scope convergence. */
|
|
182
|
+
readonly scope?: ExecutionResourceScope;
|
|
183
|
+
}
|
|
184
|
+
/** Feed the existing lifecycle projector; a stale compatibility mirror cannot revive an old stop. */
|
|
185
|
+
export declare function controlPhasesForOrigin(origin: {
|
|
186
|
+
readonly executionControl?: SessionControlOperation;
|
|
187
|
+
readonly cancellation?: {
|
|
188
|
+
readonly phase: string;
|
|
189
|
+
};
|
|
190
|
+
readonly takeover?: {
|
|
191
|
+
readonly phase: string;
|
|
192
|
+
};
|
|
193
|
+
}): {
|
|
194
|
+
cancellationPhase?: string;
|
|
195
|
+
takeoverPhase?: string;
|
|
196
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function normalizeExecutionResourceScope(raw) {
|
|
2
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw) || ![Object.prototype, null].includes(Object.getPrototypeOf(raw)))
|
|
3
|
+
return;
|
|
4
|
+
const value = raw;
|
|
5
|
+
if (Object.keys(value).length !== 2)
|
|
6
|
+
return;
|
|
7
|
+
if ((value.kind === 'directory' || value.kind === 'file') && typeof value.path === 'string'
|
|
8
|
+
&& value.path.length > 0 && value.path.length <= 2048 && !/[\u0000-\u001f]/.test(value.path))
|
|
9
|
+
return { kind: value.kind, path: value.path };
|
|
10
|
+
if ((value.kind === 'git_ref' || value.kind === 'remote_object') && typeof value.ref === 'string'
|
|
11
|
+
&& /^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,511}$/.test(value.ref) && !value.ref.includes('..'))
|
|
12
|
+
return { kind: value.kind, ref: value.ref };
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
/** Shape only; a host must still compare it with the current canonical plan. */
|
|
16
|
+
export function normalizeSessionExecutionIdentity(raw) {
|
|
17
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw) || ![Object.prototype, null].includes(Object.getPrototypeOf(raw)))
|
|
18
|
+
return;
|
|
19
|
+
const value = raw;
|
|
20
|
+
const token = (item) => typeof item === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,255}$/.test(item) && !item.includes('..');
|
|
21
|
+
if (Object.entries(Object.getOwnPropertyDescriptors(value)).some(([key, descriptor]) => !['planId', 'sessionId', 'executionEpoch', 'goalRevision', 'generation'].includes(key) || !('value' in descriptor))
|
|
22
|
+
|| !token(value.planId) || !token(value.sessionId) || typeof value.executionEpoch !== 'string' || !value.executionEpoch.length || value.executionEpoch.length > 512
|
|
23
|
+
|| /[\u0000-\u001f]/.test(value.executionEpoch) || value.generation !== undefined && !token(value.generation)
|
|
24
|
+
|| value.goalRevision !== undefined && (!Number.isSafeInteger(value.goalRevision) || Number(value.goalRevision) < 0))
|
|
25
|
+
return;
|
|
26
|
+
return { planId: value.planId, sessionId: value.sessionId, executionEpoch: value.executionEpoch,
|
|
27
|
+
...(value.generation !== undefined ? { generation: value.generation } : {}), ...(value.goalRevision !== undefined ? { goalRevision: Number(value.goalRevision) } : {}) };
|
|
28
|
+
}
|
|
29
|
+
/** Feed the existing lifecycle projector; a stale compatibility mirror cannot revive an old stop. */
|
|
30
|
+
export function controlPhasesForOrigin(origin) {
|
|
31
|
+
const control = origin.executionControl;
|
|
32
|
+
if (!control)
|
|
33
|
+
return { cancellationPhase: origin.cancellation?.phase, takeoverPhase: origin.takeover?.phase };
|
|
34
|
+
// A barrier that has already recorded why it cannot confirm the stop is not still stopping.
|
|
35
|
+
// Draining remains the in-progress label. This does not turn the refusal into a completed stop.
|
|
36
|
+
const refused = control.phase === 'reconciling' && (Boolean(control.stopReceipt?.unknownCalls.length)
|
|
37
|
+
|| control.nextAction === 'execution_stop_unconfirmed'
|
|
38
|
+
|| control.nextAction === 'execution_outcome_unknown'
|
|
39
|
+
|| control.nextAction === 'reconcile_execution_outcome');
|
|
40
|
+
const stopping = refused ? 'awaiting_outcome' : 'stopping';
|
|
41
|
+
return {
|
|
42
|
+
cancellationPhase: control.kind === 'cancel'
|
|
43
|
+
? control.phase === 'settled' && control.outcome === 'applied' ? 'completed' : stopping
|
|
44
|
+
: origin.cancellation?.phase,
|
|
45
|
+
takeoverPhase: control.phase === 'settled' && control.stopReceipt ? undefined
|
|
46
|
+
: control.kind === 'takeover' ? stopping : origin.takeover?.phase,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ExecutionOwnership, type LifecycleDecision, type LifecycleFacts } from './task-overview.ts';
|
|
2
|
+
export type { ExecutionOwnership, LifecycleDecision, LifecycleFacts } from './task-overview.ts';
|
|
3
|
+
export interface SessionFactSnapshot {
|
|
4
|
+
readonly status: LifecycleDecision['status'];
|
|
5
|
+
readonly verificationActive: boolean;
|
|
6
|
+
readonly needsUser: boolean;
|
|
7
|
+
readonly blockedReason?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 兼容入口:把扁平事实交给唯一的生命周期决策器。
|
|
11
|
+
* 旧的直接判定逻辑已删除,`status / needsUser / blockedReason` 全部来自 `decideLifecycle`。
|
|
12
|
+
*/
|
|
13
|
+
export declare function deriveSessionFacts(input: {
|
|
14
|
+
status?: string;
|
|
15
|
+
phase?: string;
|
|
16
|
+
runnerStatus?: string;
|
|
17
|
+
accepted?: boolean;
|
|
18
|
+
superseded?: boolean;
|
|
19
|
+
needsUser?: boolean;
|
|
20
|
+
blockedReason?: string;
|
|
21
|
+
verificationActive?: boolean;
|
|
22
|
+
interrupted?: boolean;
|
|
23
|
+
interruptionOrigin?: LifecycleFacts['interruptionOrigin'];
|
|
24
|
+
delegated?: boolean;
|
|
25
|
+
cancellationPhase?: string;
|
|
26
|
+
cancellationDisposition?: LifecycleFacts['cancellationDisposition'];
|
|
27
|
+
takeoverPhase?: string;
|
|
28
|
+
executionOwnership?: ExecutionOwnership;
|
|
29
|
+
}): SessionFactSnapshot;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { decideLifecycle, } from "./task-overview.js";
|
|
2
|
+
/**
|
|
3
|
+
* 兼容入口:把扁平事实交给唯一的生命周期决策器。
|
|
4
|
+
* 旧的直接判定逻辑已删除,`status / needsUser / blockedReason` 全部来自 `decideLifecycle`。
|
|
5
|
+
*/
|
|
6
|
+
export function deriveSessionFacts(input) {
|
|
7
|
+
const snapshot = {
|
|
8
|
+
conversationId: '',
|
|
9
|
+
title: '',
|
|
10
|
+
planId: '',
|
|
11
|
+
status: (input.status ?? 'executing'),
|
|
12
|
+
...(input.runnerStatus ? { runnerStatus: input.runnerStatus } : {}),
|
|
13
|
+
};
|
|
14
|
+
const decision = decideLifecycle(snapshot, {
|
|
15
|
+
...(input.executionOwnership ? { executionOwnership: input.executionOwnership } : {}),
|
|
16
|
+
...(input.phase ? { phase: input.phase } : {}),
|
|
17
|
+
...(input.accepted !== undefined ? { accepted: input.accepted } : {}),
|
|
18
|
+
...(input.superseded !== undefined ? { superseded: input.superseded } : {}),
|
|
19
|
+
...(input.needsUser !== undefined ? { needsUser: input.needsUser } : {}),
|
|
20
|
+
...(input.blockedReason ? { blockedReason: input.blockedReason } : {}),
|
|
21
|
+
...(input.verificationActive !== undefined ? { verificationActive: input.verificationActive } : {}),
|
|
22
|
+
...(input.interrupted !== undefined ? { interrupted: input.interrupted } : {}),
|
|
23
|
+
...(input.interruptionOrigin ? { interruptionOrigin: input.interruptionOrigin } : {}),
|
|
24
|
+
...(input.delegated !== undefined ? { delegated: input.delegated } : {}),
|
|
25
|
+
...(input.cancellationPhase ? { cancellationPhase: input.cancellationPhase } : {}),
|
|
26
|
+
...(input.cancellationDisposition ? { cancellationDisposition: input.cancellationDisposition } : {}),
|
|
27
|
+
...(input.takeoverPhase ? { takeoverPhase: input.takeoverPhase } : {}),
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
status: decision.status,
|
|
31
|
+
verificationActive: decision.verificationActive,
|
|
32
|
+
needsUser: decision.needsUser,
|
|
33
|
+
...(decision.blockedReason ? { blockedReason: decision.blockedReason } : {}),
|
|
34
|
+
};
|
|
35
|
+
}
|
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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WorkSessionStatus } from './delegation.ts';
|
|
1
2
|
/**
|
|
2
3
|
* TaskOverview 行动权投影契约 —— Peer 2.0 阶段 0 协议层。
|
|
3
4
|
*
|
|
@@ -103,6 +104,11 @@ export interface TaskOverviewItem {
|
|
|
103
104
|
readonly source: TaskOverviewSourceKind;
|
|
104
105
|
/** 行动权归属。 */
|
|
105
106
|
readonly actionRight: TaskActionRight;
|
|
107
|
+
/**
|
|
108
|
+
* 本投影是否真的可取消(生命周期决策给出)。
|
|
109
|
+
* 缺省表示来自尚未接入决策的旧入口;renderer 不得自行再写一套生命周期规则。
|
|
110
|
+
*/
|
|
111
|
+
readonly cancelable?: boolean;
|
|
106
112
|
/** needs_you 细分桶;仅 actionRight === 'needs_you' 时有值。 */
|
|
107
113
|
readonly needsYouReason?: TaskNeedsYouReason;
|
|
108
114
|
/** 下一步动作标识。 */
|
|
@@ -240,12 +246,16 @@ export interface ConversationProjectionSnapshot {
|
|
|
240
246
|
readonly providerLabel?: string;
|
|
241
247
|
}
|
|
242
248
|
export interface GoalPlanProjectionSnapshot {
|
|
249
|
+
readonly needsUser?: boolean;
|
|
250
|
+
readonly blockedReason?: string;
|
|
243
251
|
readonly planId: string;
|
|
244
252
|
readonly status: GoalPlanStatus;
|
|
245
253
|
/** Runner 实时态;Plan 未进入自驱时为 undefined。 */
|
|
246
254
|
readonly runnerStatus?: GoalRunnerStatus;
|
|
247
255
|
/** Runner 阻塞是否由系统基础设施持有,而不是用户行动权。 */
|
|
248
256
|
readonly systemBlocked?: boolean;
|
|
257
|
+
/** A delegated worker is coordinating with its parent, not asking the human. */
|
|
258
|
+
readonly agentWaiting?: boolean;
|
|
249
259
|
/**
|
|
250
260
|
* 同一会话此刻是否有前台活流(正在输出 / 调工具 / compact)。
|
|
251
261
|
* 由聚合层从 listActiveStreams 写入;协议层只认这个布尔事实。
|
|
@@ -255,6 +265,7 @@ export interface GoalPlanProjectionSnapshot {
|
|
|
255
265
|
readonly interrupted?: boolean;
|
|
256
266
|
/** 持久化中断事实中的用户可展示原因。 */
|
|
257
267
|
readonly interruptionReason?: string;
|
|
268
|
+
readonly interruptionOrigin?: import('./agent-supervision.ts').InterruptionOrigin;
|
|
258
269
|
readonly title: string;
|
|
259
270
|
readonly workspaceLabel?: string;
|
|
260
271
|
/** 用户可见的交付路由;缺目标分支时写「未确认」。 */
|
|
@@ -300,6 +311,15 @@ export interface GoalPlanProjectionSnapshot {
|
|
|
300
311
|
* 完成即终态,合回/自检未结束仍走 peer_advancing 或 needs_you。
|
|
301
312
|
*/
|
|
302
313
|
readonly accepted?: boolean;
|
|
314
|
+
/**
|
|
315
|
+
* 进程内执行所有权(runtime → protocol 事实)。
|
|
316
|
+
* 只有 `live` 能证明"还在跑";重启后缺 token 只能 `unknown`,既不是活体也不是已结束。
|
|
317
|
+
*/
|
|
318
|
+
readonly executionOwnership?: ExecutionOwnership;
|
|
319
|
+
/** 是否委派会话;委派任务的 accepted 只能来自真实落盘的验收结论。 */
|
|
320
|
+
readonly delegated?: boolean;
|
|
321
|
+
/** 归一化后的活体执行事实,仅由 decideLifecycle 计算,调用方不得直接写。 */
|
|
322
|
+
readonly liveExecution?: boolean;
|
|
303
323
|
/** 有代码副作用时,完成门之后还要质量自检过线才能进终态。 */
|
|
304
324
|
readonly requiresQualityReview?: boolean;
|
|
305
325
|
readonly qualityReviewStatus?: 'reviewing' | 'passed' | 'failed';
|
|
@@ -357,6 +377,75 @@ export interface ShellBackgroundProjectionSnapshot {
|
|
|
357
377
|
readonly toolCallId?: string;
|
|
358
378
|
readonly conversationId?: string;
|
|
359
379
|
}
|
|
380
|
+
interface ProjectionDecision {
|
|
381
|
+
readonly actionRight: TaskActionRight;
|
|
382
|
+
readonly needsYouReason?: TaskNeedsYouReason;
|
|
383
|
+
readonly nextAction: TaskNextAction;
|
|
384
|
+
readonly statusLabel: string;
|
|
385
|
+
readonly actionLabel: string;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* 进程内执行所有权。`live` 只能由本进程持有的执行/核验 token 产生;
|
|
389
|
+
* 重启后持久化标记只能算 `unknown`(不许当活体,也不许当已结束)。
|
|
390
|
+
*/
|
|
391
|
+
export type ExecutionOwnership = 'live' | 'ended' | 'unknown';
|
|
392
|
+
/**
|
|
393
|
+
* 生命周期事实:runtime 只提供事实,不提供结论。
|
|
394
|
+
* `decideLifecycle` 是 `status / statusLabel / actionRight / nextAction / cancelable`
|
|
395
|
+
* 的唯一出口;任何适配器都不得自行改写生命周期结论。
|
|
396
|
+
*/
|
|
397
|
+
export interface LifecycleFacts {
|
|
398
|
+
readonly humanGate?: boolean;
|
|
399
|
+
readonly executionOwnership?: ExecutionOwnership;
|
|
400
|
+
readonly phase?: string;
|
|
401
|
+
readonly delegated?: boolean;
|
|
402
|
+
readonly acceptance?: string;
|
|
403
|
+
readonly accepted?: boolean;
|
|
404
|
+
readonly superseded?: boolean;
|
|
405
|
+
readonly needsUser?: boolean;
|
|
406
|
+
/** 未消费的执行中断是当前行动权事实,优先于 completed/结果就绪。 */
|
|
407
|
+
readonly interrupted?: boolean;
|
|
408
|
+
readonly interruptionOrigin?: import('./agent-supervision.ts').InterruptionOrigin;
|
|
409
|
+
readonly verificationActive?: boolean;
|
|
410
|
+
readonly blockedReason?: string;
|
|
411
|
+
readonly cancellationPhase?: string;
|
|
412
|
+
readonly cancellationDisposition?: 'user_withdrawn';
|
|
413
|
+
readonly obligationDisposition?: 'indexed' | 'suspended' | 'current';
|
|
414
|
+
readonly takeoverPhase?: string;
|
|
415
|
+
readonly coordinationPhase?: string;
|
|
416
|
+
}
|
|
417
|
+
export interface LifecycleCoreDecision extends ProjectionDecision {
|
|
418
|
+
readonly status: WorkSessionStatus;
|
|
419
|
+
readonly cancelable: boolean;
|
|
420
|
+
readonly needsUser: boolean;
|
|
421
|
+
readonly verificationActive: boolean;
|
|
422
|
+
readonly blockedReason?: string;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* 当前跟进责任(ADR 110)。`bot` = 主 Bot 自己收口的技术跟进;`user` = 真实人工/策略门槛;
|
|
426
|
+
* `none` = 退出当前待办(已签收、已被完成替换承接、用户停止已确认)。
|
|
427
|
+
* `inCurrentList` 是派生事实,不允许消费端各自按 status 再判一次。
|
|
428
|
+
*/
|
|
429
|
+
export type FollowUpOwner = 'bot' | 'user' | 'none';
|
|
430
|
+
export type FollowUpReason = 'settled' | 'superseded' | 'stop_confirmed' | 'user_withdrawn' | 'stop_unconfirmed' | 'human_request' | 'awaiting_human_gate' | 'technical_block' | 'local_persistence_failed' | 'awaiting_acceptance_technical' | 'verification_failed' | 'live_execution' | 'paused' | 'unknown_facts' | 'obligation_indexed';
|
|
431
|
+
export interface FollowUpProjection {
|
|
432
|
+
readonly owner: FollowUpOwner;
|
|
433
|
+
readonly inCurrentList: boolean;
|
|
434
|
+
readonly reason: FollowUpReason;
|
|
435
|
+
}
|
|
436
|
+
export interface LifecycleDecision extends LifecycleCoreDecision {
|
|
437
|
+
readonly followUp: FollowUpProjection;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* 责任判定:只读同一份生命周期结论 + 同一份权威事实,不引入第二套状态机。
|
|
441
|
+
* 缺事实一律 fail closed(留在当前列表、责任在 bot),不按文案推断承接或停止。
|
|
442
|
+
*/
|
|
443
|
+
export declare function decideFollowUp(decision: Pick<LifecycleCoreDecision, 'status' | 'needsYouReason'>, facts?: LifecycleFacts, ownership?: ExecutionOwnership): FollowUpProjection;
|
|
444
|
+
/**
|
|
445
|
+
* 公开唯一出口:先取既有生命周期结论,再补同一份事实算出的跟进责任(ADR 110)。
|
|
446
|
+
* 适配器只读 `followUp`,不得按 `status` 自行再判一次列表归属与责任人。
|
|
447
|
+
*/
|
|
448
|
+
export declare function decideLifecycle(snapshot: GoalPlanProjectionSnapshot, facts?: LifecycleFacts): LifecycleDecision;
|
|
360
449
|
/** Conversation → 无计划讨论态(工作台动线 §15)。 */
|
|
361
450
|
/**
|
|
362
451
|
* 会话是否对首页「正在讨论」可见(未读)。
|
|
@@ -420,3 +509,4 @@ export declare function areTaskOverviewItemsEqual(current: TaskOverviewItem, nex
|
|
|
420
509
|
* 首页无 conversationId,只能整表重拉;复用后单路进度不会拖垮其余卡。
|
|
421
510
|
*/
|
|
422
511
|
export declare function reuseUnchangedTaskOverviewItems(current: readonly TaskOverviewItem[], next: readonly TaskOverviewItem[]): TaskOverviewItem[];
|
|
512
|
+
export {};
|