@peer-agent/protocol 0.1.0-rc.3 → 0.1.0-rc.31
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 +76 -0
- package/dist/delegation-coordination.js +1 -0
- package/dist/delegation.d.ts +189 -6
- package/dist/delegation.js +39 -39
- package/dist/document-reference.d.ts +83 -0
- package/dist/document-reference.js +1 -0
- package/dist/evidence-inspection.d.ts +51 -0
- package/dist/evidence-inspection.js +1 -0
- package/dist/goal.d.ts +49 -2
- package/dist/index.d.ts +46 -5
- package/dist/index.js +19 -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 +36 -2
- package/dist/model-routing.js +30 -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 +63 -0
- package/dist/project.js +2 -5
- 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.d.ts +91 -0
- package/dist/resource-feedback.js +120 -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 +138 -0
- package/dist/resource-window.js +116 -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 +89 -0
- package/dist/task-overview.js +317 -17
- package/dist/tool-activity-preview.d.ts +4 -0
- package/dist/tool-activity-preview.js +72 -0
- package/dist/work-coordination.d.ts +136 -0
- package/dist/work-coordination.js +1 -0
- package/package.json +1 -1
package/dist/delegation.d.ts
CHANGED
|
@@ -1,13 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Project-agent delegation contracts. Pure projections only; nothing here runs a tool.
|
|
3
|
-
* The user-visible conclusion of a work session is
|
|
3
|
+
* The user-visible conclusion of a work session is `decideLifecycle`'s conclusion.
|
|
4
4
|
*/
|
|
5
5
|
import type { ModelSelectionSnapshot } from './model-routing.ts';
|
|
6
|
-
import { type GoalPlanProjectionSnapshot, type TaskOverviewItem } from './task-overview.ts';
|
|
7
|
-
export type WorkSessionStatus = 'paused' | 'queued' | 'starting' | 'running' | 'waiting_user' | 'verifying' | 'result_ready' | 'accepted' | 'failed' | 'cancelled' | 'superseded';
|
|
8
|
-
export declare const WORK_SESSION_STATUSES: readonly ["paused", "queued", "starting", "running", "waiting_user", "verifying", "result_ready", "accepted", "failed", "cancelled", "superseded"];
|
|
6
|
+
import { type ExecutionOwnership, type GoalPlanProjectionSnapshot, type TaskOverviewItem } from './task-overview.ts';
|
|
7
|
+
export type WorkSessionStatus = 'paused' | 'queued' | 'starting' | 'running' | 'waiting_user' | 'waiting_agent' | 'stopping' | 'awaiting_outcome' | 'verifying' | 'result_ready' | 'accepted' | 'failed' | 'cancelled' | 'superseded';
|
|
8
|
+
export declare const WORK_SESSION_STATUSES: readonly ["paused", "queued", "starting", "running", "waiting_user", "waiting_agent", "stopping", "awaiting_outcome", "verifying", "result_ready", "accepted", "failed", "cancelled", "superseded"];
|
|
9
9
|
export type InputSurface = 'desktop' | 'quick_chat' | 'tui' | 'remote';
|
|
10
10
|
export interface DelegationOrigin {
|
|
11
|
+
readonly capabilityAdmission?: import('./capability-admission.ts').DelegationCapabilityAdmission;
|
|
12
|
+
readonly takeover?: {
|
|
13
|
+
operationId: string;
|
|
14
|
+
phase: 'stopping' | 'completed';
|
|
15
|
+
text: string;
|
|
16
|
+
binding: import('./delegation-coordination.ts').CoordinationExecutionBinding;
|
|
17
|
+
requestedAt: string;
|
|
18
|
+
completedAt?: string;
|
|
19
|
+
repair?: boolean;
|
|
20
|
+
};
|
|
21
|
+
readonly coordinationBinding?: import('./delegation-coordination.ts').CoordinationExecutionBinding;
|
|
22
|
+
readonly cancellation?: {
|
|
23
|
+
readonly operationId: string;
|
|
24
|
+
readonly reason: string;
|
|
25
|
+
readonly phase: 'stopping' | 'awaiting_outcome' | 'completed';
|
|
26
|
+
readonly requestedAt: string;
|
|
27
|
+
readonly completedAt?: string;
|
|
28
|
+
readonly evidenceCalls?: readonly string[];
|
|
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
|
+
};
|
|
40
|
+
};
|
|
41
|
+
readonly retainedForRecovery?: boolean;
|
|
42
|
+
readonly workId?: string;
|
|
11
43
|
readonly anchorMessageId: string;
|
|
12
44
|
readonly inputId: string;
|
|
13
45
|
readonly surface: InputSurface;
|
|
@@ -35,6 +67,7 @@ export interface SessionQueueFacts {
|
|
|
35
67
|
readonly queueReason?: 'dependencies' | 'dependency_missing' | 'dependency_failed' | 'read_slot' | 'write_slot' | 'disk_space' | 'isolation_failed' | null;
|
|
36
68
|
}
|
|
37
69
|
export interface WorkSessionConversationMeta extends SessionQueueFacts {
|
|
70
|
+
readonly coordination?: import('./delegation-coordination.ts').CoordinationSessionFacts;
|
|
38
71
|
readonly sessionId?: string;
|
|
39
72
|
readonly conversationId?: string;
|
|
40
73
|
readonly workspaceId: string;
|
|
@@ -42,11 +75,19 @@ export interface WorkSessionConversationMeta extends SessionQueueFacts {
|
|
|
42
75
|
readonly origin: DelegationOrigin;
|
|
43
76
|
readonly supersededBy?: string;
|
|
44
77
|
readonly acceptance?: 'auto' | 'confirm';
|
|
78
|
+
readonly resultConfirmationRequired?: boolean;
|
|
45
79
|
readonly accepted?: boolean;
|
|
46
80
|
readonly verifying?: boolean;
|
|
47
81
|
readonly phase?: 'starting' | 'verifying' | 'paused';
|
|
82
|
+
/** 进程内执行所有权(runtime 采集);缺省表示该入口尚未接入所有权事实。 */
|
|
83
|
+
readonly executionOwnership?: ExecutionOwnership;
|
|
48
84
|
}
|
|
49
85
|
export interface WorkSession extends SessionQueueFacts {
|
|
86
|
+
readonly followUp?: import('./task-overview.ts').FollowUpProjection;
|
|
87
|
+
readonly verificationProgress?: VerificationProgress;
|
|
88
|
+
readonly completionReviewRequired?: boolean;
|
|
89
|
+
readonly resultConfirmationRequired?: boolean;
|
|
90
|
+
readonly coordination?: import('./delegation-coordination.ts').CoordinationSessionFacts;
|
|
50
91
|
readonly sessionId: string;
|
|
51
92
|
readonly workspaceId: string;
|
|
52
93
|
readonly title: string;
|
|
@@ -55,6 +96,8 @@ export interface WorkSession extends SessionQueueFacts {
|
|
|
55
96
|
readonly actionRight: TaskOverviewItem['actionRight'];
|
|
56
97
|
readonly nextAction: TaskOverviewItem['nextAction'];
|
|
57
98
|
readonly statusLabel: string;
|
|
99
|
+
/** 是否可取消;由生命周期决策统一给出,renderer 不再自行推断。 */
|
|
100
|
+
readonly cancelable?: boolean;
|
|
58
101
|
readonly needsYouReason?: TaskOverviewItem['needsYouReason'];
|
|
59
102
|
readonly spawnedAt: string;
|
|
60
103
|
readonly conversationId?: string;
|
|
@@ -62,18 +105,61 @@ export interface WorkSession extends SessionQueueFacts {
|
|
|
62
105
|
readonly supersededBy?: string;
|
|
63
106
|
}
|
|
64
107
|
export interface SessionReport {
|
|
108
|
+
readonly agentSupervision?: import('./agent-supervision.ts').AgentSupervisionReport;
|
|
109
|
+
/** Current host verification, loaded with task details; never assistant prose. */
|
|
110
|
+
readonly verification?: SessionVerificationDetail;
|
|
65
111
|
readonly sessionId: string;
|
|
66
112
|
readonly planId: string | null;
|
|
67
113
|
readonly status: WorkSessionStatus;
|
|
68
114
|
readonly summary: string;
|
|
115
|
+
readonly taskBrief?: string;
|
|
69
116
|
readonly keyFindings: readonly string[];
|
|
70
117
|
readonly changedFiles: readonly {
|
|
71
118
|
readonly path: string;
|
|
72
119
|
readonly summary: string;
|
|
73
120
|
}[];
|
|
74
121
|
readonly evidenceRefs: readonly string[];
|
|
122
|
+
/** Persisted worker output is a claim; verification still comes from host Evidence. */
|
|
123
|
+
readonly contentSource?: {
|
|
124
|
+
readonly kind: 'worker_message' | 'task_results';
|
|
125
|
+
readonly conversationId?: string;
|
|
126
|
+
readonly messageId?: string;
|
|
127
|
+
readonly verification: 'unverified';
|
|
128
|
+
};
|
|
129
|
+
}
|
|
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';
|
|
131
|
+
/** Local orchestration facts; never a human authorization or a verified result. */
|
|
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;
|
|
138
|
+
readonly replyTo?: string;
|
|
139
|
+
readonly messageId: string;
|
|
140
|
+
readonly workspaceId: string;
|
|
141
|
+
readonly sessionId: string;
|
|
142
|
+
readonly senderConversationId: string;
|
|
143
|
+
readonly recipientConversationId: string;
|
|
144
|
+
readonly direction: 'parent_to_child' | 'child_to_parent';
|
|
145
|
+
readonly purpose: 'update' | 'question' | 'answer';
|
|
146
|
+
readonly text: string;
|
|
147
|
+
readonly at: string;
|
|
148
|
+
}
|
|
149
|
+
export interface VerificationProgress {
|
|
150
|
+
readonly continuationId: string;
|
|
151
|
+
readonly startedAt: string;
|
|
152
|
+
readonly lastProgressAt: string;
|
|
153
|
+
readonly observationCount: number;
|
|
154
|
+
readonly phase: 'ready' | 'requesting' | 'tools' | 'completed';
|
|
155
|
+
}
|
|
156
|
+
export interface AgentActivity {
|
|
157
|
+
readonly verificationProgress?: VerificationProgress;
|
|
158
|
+
readonly eventId: string;
|
|
159
|
+
readonly sessionId: string;
|
|
160
|
+
readonly name: string;
|
|
161
|
+
readonly state: 'queued' | 'started' | 'update' | 'question' | 'answer' | 'reported' | 'verified' | 'verifying' | 'ended' | 'cancelled' | 'blocked';
|
|
75
162
|
}
|
|
76
|
-
export type DelegationEventKind = 'session_spawned' | 'session_progress' | 'session_needs_user' | 'session_verified' | 'session_ended' | 'user_intervened' | 'objective_signal' | 'digest_due';
|
|
77
163
|
export type JsonValue = null | string | number | boolean | readonly JsonValue[] | {
|
|
78
164
|
readonly [key: string]: JsonValue;
|
|
79
165
|
};
|
|
@@ -101,6 +187,9 @@ export interface AgentReplyMeta {
|
|
|
101
187
|
readonly surfacing: 'interrupt' | 'message' | 'digest' | 'silent';
|
|
102
188
|
}
|
|
103
189
|
export interface ReplySessionState {
|
|
190
|
+
readonly sourceRevision?: string;
|
|
191
|
+
/** Stable reporting facts, including a changed verifier failure; not acceptance authority. */
|
|
192
|
+
readonly observationRevision?: string;
|
|
104
193
|
readonly sessionId: string;
|
|
105
194
|
readonly status: WorkSessionStatus;
|
|
106
195
|
}
|
|
@@ -155,6 +244,26 @@ export interface DispositionEvent {
|
|
|
155
244
|
readonly replyMessageId?: string;
|
|
156
245
|
}
|
|
157
246
|
export type VerificationOutcome = 'passed' | 'failed' | 'partial' | 'unverifiable';
|
|
247
|
+
/** Host-bound manual completion review; distinct from acceptance of a completed result. */
|
|
248
|
+
export interface SessionCompletionReview {
|
|
249
|
+
readonly sessionId: string;
|
|
250
|
+
readonly reviewToken: string;
|
|
251
|
+
readonly criteria: readonly {
|
|
252
|
+
readonly id: string;
|
|
253
|
+
readonly description: string;
|
|
254
|
+
}[];
|
|
255
|
+
readonly report: string;
|
|
256
|
+
readonly confirmed?: boolean;
|
|
257
|
+
}
|
|
258
|
+
export type SessionConfirmationInput = {
|
|
259
|
+
readonly workspaceId: string;
|
|
260
|
+
readonly sessionId: string;
|
|
261
|
+
} & ({
|
|
262
|
+
readonly stage?: 'result_acceptance';
|
|
263
|
+
} | {
|
|
264
|
+
readonly stage: 'manual_completion';
|
|
265
|
+
readonly reviewToken: string;
|
|
266
|
+
});
|
|
158
267
|
export type IndependentVerifierState = 'passed' | 'failed' | 'not_required' | 'missing';
|
|
159
268
|
export interface VerificationCheck {
|
|
160
269
|
readonly name: string;
|
|
@@ -169,6 +278,49 @@ export interface VerificationVerdict {
|
|
|
169
278
|
readonly checks: readonly VerificationCheck[];
|
|
170
279
|
readonly evidenceRefs: readonly string[];
|
|
171
280
|
}
|
|
281
|
+
export interface SessionVerificationDetail {
|
|
282
|
+
readonly sessionId: string;
|
|
283
|
+
readonly outcome: VerificationOutcome;
|
|
284
|
+
readonly checks: readonly {
|
|
285
|
+
readonly name: string;
|
|
286
|
+
readonly result: 'passed' | 'failed';
|
|
287
|
+
readonly evidenceRefs: readonly string[];
|
|
288
|
+
readonly reason?: string;
|
|
289
|
+
}[];
|
|
290
|
+
readonly workerModel: string | null;
|
|
291
|
+
readonly verifierModel: string | null;
|
|
292
|
+
readonly sameSource: boolean;
|
|
293
|
+
readonly reviewAttempts: readonly VerificationAttemptDiagnostic[];
|
|
294
|
+
readonly outputs: readonly {
|
|
295
|
+
readonly name: string;
|
|
296
|
+
readonly evidenceRef: string;
|
|
297
|
+
readonly summary: string;
|
|
298
|
+
readonly truncated: boolean;
|
|
299
|
+
}[];
|
|
300
|
+
}
|
|
301
|
+
/** Bounded persisted diagnostics, never an input to acceptance or Evidence authority. */
|
|
302
|
+
export interface VerificationAttemptDiagnostic {
|
|
303
|
+
readonly verifierRunId: string;
|
|
304
|
+
readonly status: 'passed' | 'failed';
|
|
305
|
+
readonly diagnosticOnly: true;
|
|
306
|
+
/** null means this historical run has no source-version binding. */
|
|
307
|
+
readonly matchesCurrentSource: boolean | null;
|
|
308
|
+
readonly completedAt: string;
|
|
309
|
+
readonly failureReason: string;
|
|
310
|
+
readonly failedCriteria: readonly {
|
|
311
|
+
readonly criterionId: string;
|
|
312
|
+
readonly reason: string;
|
|
313
|
+
readonly evidenceRefs: readonly string[];
|
|
314
|
+
}[];
|
|
315
|
+
readonly missingEvidence: readonly {
|
|
316
|
+
readonly taskId: string;
|
|
317
|
+
readonly reason: string;
|
|
318
|
+
readonly evidenceRefs: readonly string[];
|
|
319
|
+
}[];
|
|
320
|
+
readonly risks: readonly string[];
|
|
321
|
+
readonly recommendedNextAction: string;
|
|
322
|
+
readonly evidenceRefs: readonly string[];
|
|
323
|
+
}
|
|
172
324
|
export type AcceptancePolicy = 'auto' | 'confirm';
|
|
173
325
|
export type AcceptanceReason = 'verdict_not_passed' | 'manual_criteria_pending' | 'external_side_effects' | 'destructive_operation' | 'out_of_scope_write' | 'project_requires_confirm' | 'user_requested_review' | 'verification_below_floor';
|
|
174
326
|
export interface AcceptanceDecision {
|
|
@@ -200,6 +352,22 @@ export interface SurfacingEvent {
|
|
|
200
352
|
readonly severity: 'info' | 'notable' | 'urgent';
|
|
201
353
|
readonly deadlineImminent?: boolean;
|
|
202
354
|
}
|
|
355
|
+
/** Explicit user uploads are factual user context, never execution authority. */
|
|
356
|
+
export type ProjectInputAttachment = {
|
|
357
|
+
readonly id: string;
|
|
358
|
+
readonly name: string;
|
|
359
|
+
readonly mimeType: string;
|
|
360
|
+
readonly size: number;
|
|
361
|
+
readonly sourceKind: 'user_upload';
|
|
362
|
+
} & ({
|
|
363
|
+
readonly kind: 'image';
|
|
364
|
+
readonly dataUrl: string;
|
|
365
|
+
} | {
|
|
366
|
+
readonly kind: 'text';
|
|
367
|
+
readonly text: string;
|
|
368
|
+
} | {
|
|
369
|
+
readonly kind: 'unsupported';
|
|
370
|
+
});
|
|
203
371
|
export interface ProjectInput {
|
|
204
372
|
readonly inputId: string;
|
|
205
373
|
readonly workspaceId: string;
|
|
@@ -208,10 +376,23 @@ export interface ProjectInput {
|
|
|
208
376
|
readonly anchorRefs: readonly string[];
|
|
209
377
|
readonly quoteRefs: readonly string[];
|
|
210
378
|
readonly attachmentRefs: readonly string[];
|
|
379
|
+
readonly attachments?: readonly ProjectInputAttachment[];
|
|
380
|
+
readonly resourceFeedback?: readonly import('./resource-feedback.ts').ResourceFeedback[];
|
|
211
381
|
readonly createdAt: string;
|
|
212
382
|
}
|
|
213
|
-
|
|
383
|
+
/** Existing durable input receipt. A later handoff can fail after input was saved. */
|
|
384
|
+
export interface ProjectAgentSubmitInputResult {
|
|
385
|
+
readonly ok: boolean;
|
|
386
|
+
readonly code?: string;
|
|
387
|
+
readonly message?: string;
|
|
388
|
+
readonly input?: ProjectInput;
|
|
389
|
+
readonly delivery?: 'queued' | 'user_intervened';
|
|
390
|
+
}
|
|
391
|
+
export type PendingApprovalState = 'open' | 'approved' | 'denied' | 'expired' | 'stale' | 'cancelled';
|
|
214
392
|
export interface PendingApproval {
|
|
393
|
+
readonly policyRevision?: string;
|
|
394
|
+
readonly imageReadScope?: import('./local-image.ts').LocalImagePermissionScope;
|
|
395
|
+
readonly imageReadGrant?: import('./local-image.ts').ImageReadGrant;
|
|
215
396
|
readonly approvalId: string;
|
|
216
397
|
readonly workspaceId: string | null;
|
|
217
398
|
readonly sessionId?: string | null;
|
|
@@ -225,6 +406,8 @@ export interface PendingApproval {
|
|
|
225
406
|
readonly argsDigest: string;
|
|
226
407
|
readonly createdAt: string;
|
|
227
408
|
readonly state: PendingApprovalState;
|
|
409
|
+
readonly deadlineAt?: string;
|
|
410
|
+
readonly decisionReason?: 'permission_cancelled' | 'permission_timeout' | 'permission_unavailable' | 'local_user_denied' | 'permission_policy_changed';
|
|
228
411
|
readonly decidedAt?: string;
|
|
229
412
|
readonly decidedBy?: 'local_ui' | 'policy';
|
|
230
413
|
}
|
package/dist/delegation.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Project-agent delegation contracts. Pure projections only; nothing here runs a tool.
|
|
3
|
-
* The user-visible conclusion of a work session is
|
|
3
|
+
* The user-visible conclusion of a work session is `decideLifecycle`'s conclusion.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
export const WORK_SESSION_STATUSES = ['paused', 'queued', 'starting', 'running', 'waiting_user', 'verifying',
|
|
5
|
+
import { decideLifecycle, } from "./task-overview.js";
|
|
6
|
+
export const WORK_SESSION_STATUSES = ['paused', 'queued', 'starting', 'running', 'waiting_user', 'waiting_agent', 'stopping', 'awaiting_outcome', 'verifying',
|
|
7
7
|
'result_ready', 'accepted', 'failed', 'cancelled', 'superseded'];
|
|
8
8
|
function fnv1a(text) {
|
|
9
9
|
let hash = 0x811c9dc5;
|
|
@@ -43,57 +43,57 @@ export function createDelegationEvent(input) {
|
|
|
43
43
|
payload,
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
function delegationStatus(snapshot, meta, projected) {
|
|
47
|
-
if (snapshot.status === 'failed')
|
|
48
|
-
return 'failed';
|
|
49
|
-
if (snapshot.status === 'cancelled')
|
|
50
|
-
return 'cancelled';
|
|
51
|
-
if (snapshot.status === 'completed') {
|
|
52
|
-
if (meta.verifying || meta.phase === 'verifying')
|
|
53
|
-
return 'verifying';
|
|
54
|
-
if (meta.acceptance === 'confirm' && meta.accepted !== true)
|
|
55
|
-
return 'result_ready';
|
|
56
|
-
return 'accepted';
|
|
57
|
-
}
|
|
58
|
-
if (meta.supersededBy)
|
|
59
|
-
return 'superseded';
|
|
60
|
-
if (meta.phase === 'paused')
|
|
61
|
-
return 'paused';
|
|
62
|
-
// 复核进行中盖过「需要你」。草稿、待批准、等回答的计划在独立复核时都显示 verifying。
|
|
63
|
-
if (meta.verifying || meta.phase === 'verifying')
|
|
64
|
-
return 'verifying';
|
|
65
|
-
if (projected.actionRight === 'needs_you')
|
|
66
|
-
return 'waiting_user';
|
|
67
|
-
if (snapshot.runnerStatus === 'exploring')
|
|
68
|
-
return 'verifying';
|
|
69
|
-
if (meta.phase === 'starting')
|
|
70
|
-
return 'starting';
|
|
71
|
-
if (snapshot.status === 'approved'
|
|
72
|
-
|| snapshot.status === 'accepted'
|
|
73
|
-
|| snapshot.status === 'paused'
|
|
74
|
-
|| snapshot.status === 'interrupted'
|
|
75
|
-
|| projected.actionRight === 'paused') {
|
|
76
|
-
return 'queued';
|
|
77
|
-
}
|
|
78
|
-
return 'running';
|
|
79
|
-
}
|
|
80
46
|
/**
|
|
81
47
|
* Project a GoalPlan snapshot into a work session.
|
|
82
48
|
* actionRight / nextAction / statusLabel come from projectGoalPlan, so the two projections cannot disagree.
|
|
83
49
|
* A paused plan has no delegation status of its own; it is queued, and the visible conclusion stays paused.
|
|
84
50
|
*/
|
|
85
51
|
export function projectWorkSession(plan, conversationMeta) {
|
|
86
|
-
const projected =
|
|
52
|
+
const projected = decideLifecycle(plan, {
|
|
53
|
+
...(conversationMeta.executionOwnership ? { executionOwnership: conversationMeta.executionOwnership } : {}),
|
|
54
|
+
// `delegated` 必须是真实事实;不能用"这是工作会话"反推,否则会改写非委派历史语义。
|
|
55
|
+
...(plan.delegated === true ? { delegated: true } : {}),
|
|
56
|
+
...(conversationMeta.acceptance ? { acceptance: conversationMeta.acceptance } : {}),
|
|
57
|
+
humanGate: conversationMeta.resultConfirmationRequired === true,
|
|
58
|
+
accepted: conversationMeta.accepted === true ||
|
|
59
|
+
(plan.delegated !== true &&
|
|
60
|
+
plan.status === 'completed' &&
|
|
61
|
+
conversationMeta.acceptance !== 'confirm' &&
|
|
62
|
+
conversationMeta.accepted === undefined &&
|
|
63
|
+
!conversationMeta.verifying &&
|
|
64
|
+
!plan.runnerStatus),
|
|
65
|
+
superseded: Boolean(conversationMeta.supersededBy),
|
|
66
|
+
needsUser: plan.status === 'awaiting_approval' || plan.needsUser === true,
|
|
67
|
+
verificationActive: conversationMeta.verifying === true,
|
|
68
|
+
...(conversationMeta.phase ? { phase: conversationMeta.phase } : {}),
|
|
69
|
+
blockedReason: plan.agentWaiting ? 'waiting_parent_agent' : plan.blockedReason,
|
|
70
|
+
interrupted: plan.interrupted,
|
|
71
|
+
interruptionOrigin: plan.interruptionOrigin,
|
|
72
|
+
...(conversationMeta.origin.cancellation?.phase
|
|
73
|
+
? { cancellationPhase: conversationMeta.origin.cancellation.phase }
|
|
74
|
+
: {}),
|
|
75
|
+
...(conversationMeta.origin.cancellation?.disposition ? { cancellationDisposition: conversationMeta.origin.cancellation.disposition } : {}),
|
|
76
|
+
...(conversationMeta.coordination?.phase === 'awaiting_outcome'
|
|
77
|
+
? { takeoverPhase: 'awaiting_outcome' }
|
|
78
|
+
: conversationMeta.origin.takeover?.phase
|
|
79
|
+
? { takeoverPhase: conversationMeta.origin.takeover.phase }
|
|
80
|
+
: {}),
|
|
81
|
+
});
|
|
82
|
+
const status = projected.status;
|
|
87
83
|
return {
|
|
88
84
|
sessionId: conversationMeta.sessionId ?? plan.conversationId ?? plan.planId,
|
|
89
85
|
workspaceId: conversationMeta.workspaceId,
|
|
90
86
|
title: plan.title,
|
|
91
87
|
planId: plan.planId,
|
|
92
|
-
status
|
|
88
|
+
status,
|
|
89
|
+
// 直接消费同一份决策;这里再改写就等于第二套状态机。
|
|
93
90
|
actionRight: projected.actionRight,
|
|
94
91
|
nextAction: projected.nextAction,
|
|
95
92
|
statusLabel: projected.statusLabel,
|
|
93
|
+
cancelable: projected.cancelable,
|
|
94
|
+
followUp: projected.followUp,
|
|
96
95
|
...(projected.needsYouReason ? { needsYouReason: projected.needsYouReason } : {}),
|
|
96
|
+
...(conversationMeta.coordination ? { coordination: conversationMeta.coordination } : {}),
|
|
97
97
|
spawnedAt: conversationMeta.spawnedAt ?? plan.updatedAt ?? '',
|
|
98
98
|
...(conversationMeta.conversationId ? { conversationId: conversationMeta.conversationId } : {}),
|
|
99
99
|
origin: conversationMeta.origin,
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface GitDocumentRevision {
|
|
2
|
+
readonly kind: 'git';
|
|
3
|
+
/** Complete immutable commit SHA only; never a branch or Git expression. */
|
|
4
|
+
readonly commit: string;
|
|
5
|
+
/** Host-confirmed device-local repository binding, not an authorization ticket. */
|
|
6
|
+
readonly repositoryId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ConfirmedGitDocumentRevision extends GitDocumentRevision {
|
|
9
|
+
readonly repositoryId: string;
|
|
10
|
+
readonly path: string;
|
|
11
|
+
}
|
|
12
|
+
/** Human-initiated preview only. This reference never grants model/tool access. */
|
|
13
|
+
export interface BotDocumentReference {
|
|
14
|
+
readonly workspaceId: string;
|
|
15
|
+
readonly path: string;
|
|
16
|
+
readonly relativeTo?: string;
|
|
17
|
+
/** Host revalidates Session/GoalPlan ownership on every read; never a root or grant. */
|
|
18
|
+
readonly task?: {
|
|
19
|
+
readonly sessionId: string;
|
|
20
|
+
readonly planId: string;
|
|
21
|
+
};
|
|
22
|
+
/** Explicit UI navigation intent; never an authorization root. */
|
|
23
|
+
readonly kind?: 'file' | 'directory';
|
|
24
|
+
/** Resolve/stat only; never returns file contents. */
|
|
25
|
+
readonly metadataOnly?: boolean;
|
|
26
|
+
/** Conditional text/image read only; an observation never grants access. */
|
|
27
|
+
readonly expectedObservation?: {
|
|
28
|
+
readonly resourceId: string;
|
|
29
|
+
readonly contentVersion?: string;
|
|
30
|
+
};
|
|
31
|
+
readonly revision?: GitDocumentRevision;
|
|
32
|
+
}
|
|
33
|
+
/** Device-local locator identity, revalidated by the host on every access. */
|
|
34
|
+
export interface LocalDocumentIdentity {
|
|
35
|
+
readonly sourceId: string;
|
|
36
|
+
readonly resourceId: string;
|
|
37
|
+
readonly relativePath: string;
|
|
38
|
+
}
|
|
39
|
+
/** Version of the actual bytes returned by a successful read; not a saved snapshot. */
|
|
40
|
+
export interface LocalDocumentObservation extends LocalDocumentIdentity {
|
|
41
|
+
readonly contentVersion: string;
|
|
42
|
+
}
|
|
43
|
+
export interface LocalDocumentReadResult {
|
|
44
|
+
readonly metadataOnly?: boolean;
|
|
45
|
+
readonly ok: boolean;
|
|
46
|
+
readonly status: 'ok' | 'not_found' | 'not_file' | 'too_large' | 'binary' | 'invalid_path' | 'error' | 'permission_denied' | 'scope_denied' | 'ambiguous_path' | 'workspace_unavailable' | 'relative_base_required' | 'version_changed' | 'source_changed' | 'version_unavailable' | 'not_git_repo' | 'invalid_ref' | 'revision_unavailable' | 'unsupported_entry';
|
|
47
|
+
readonly content: string;
|
|
48
|
+
readonly size?: number;
|
|
49
|
+
readonly resolvedFrom?: string;
|
|
50
|
+
readonly resolvedPath?: string;
|
|
51
|
+
readonly identity?: LocalDocumentIdentity;
|
|
52
|
+
readonly observation?: LocalDocumentObservation;
|
|
53
|
+
readonly revision?: ConfirmedGitDocumentRevision;
|
|
54
|
+
/** Confirmed locations for an explicit human choice; never an authorization ticket. */
|
|
55
|
+
readonly candidates?: readonly {
|
|
56
|
+
readonly path: string;
|
|
57
|
+
readonly root: string;
|
|
58
|
+
}[];
|
|
59
|
+
/** Bot project root used when a file citation was not found. Not an authorization root. */
|
|
60
|
+
readonly attemptedRoot?: string;
|
|
61
|
+
readonly error?: string;
|
|
62
|
+
}
|
|
63
|
+
/** Bounded presentation metadata from a known local file Tool Result in the same turn.
|
|
64
|
+
* A restored hint must be re-resolved under the current Bot scope before reading. */
|
|
65
|
+
export interface BotResourceReferenceHint {
|
|
66
|
+
readonly path: string;
|
|
67
|
+
readonly tool: 'read_file' | 'write_file' | 'edit_file';
|
|
68
|
+
}
|
|
69
|
+
/** Human-initiated, bounded filename discovery; every selected hit is re-authorized on read. */
|
|
70
|
+
export interface BotResourceSearchResult {
|
|
71
|
+
readonly ok: boolean;
|
|
72
|
+
readonly status: LocalDocumentReadResult['status'] | 'not_dir';
|
|
73
|
+
readonly scoped?: boolean;
|
|
74
|
+
readonly workspacePath?: string;
|
|
75
|
+
readonly files: readonly {
|
|
76
|
+
readonly relPath: string;
|
|
77
|
+
readonly name: string;
|
|
78
|
+
readonly kind: 'file' | 'directory';
|
|
79
|
+
}[];
|
|
80
|
+
readonly truncated?: boolean;
|
|
81
|
+
readonly visited?: number;
|
|
82
|
+
readonly error?: string;
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { BotDocumentReference } from './document-reference.ts';
|
|
2
|
+
/** Read-only display facts. A saved operation is not proof that its task completed. */
|
|
3
|
+
export interface EvidenceSourceDescription {
|
|
4
|
+
readonly evidenceRef: string;
|
|
5
|
+
readonly toolName?: string;
|
|
6
|
+
readonly createdAt?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ProjectAgentEvidenceReadRequest {
|
|
9
|
+
readonly context?: {
|
|
10
|
+
readonly workspaceId: string;
|
|
11
|
+
readonly task?: BotDocumentReference['task'];
|
|
12
|
+
};
|
|
13
|
+
readonly evidenceRef?: string;
|
|
14
|
+
/** Source descriptions only; at most 100 unique references, no body or artifact reads. */
|
|
15
|
+
readonly evidenceRefs?: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
export interface ProjectAgentEvidenceReadResult {
|
|
18
|
+
readonly deliveryStatus?: 'available' | 'scope_denied' | 'unavailable';
|
|
19
|
+
readonly deliveries?: readonly EvidenceDelivery[];
|
|
20
|
+
readonly ok: boolean;
|
|
21
|
+
readonly code?: string;
|
|
22
|
+
readonly evidenceRef?: string;
|
|
23
|
+
readonly kind?: 'file' | 'command' | 'diff' | 'screenshot' | 'observation';
|
|
24
|
+
readonly summary?: string;
|
|
25
|
+
readonly truncated?: boolean;
|
|
26
|
+
readonly availability?: 'available' | 'metadata_only' | 'not_found' | 'unavailable';
|
|
27
|
+
readonly source?: EvidenceSourceDescription;
|
|
28
|
+
readonly items?: readonly EvidenceSourceDescription[];
|
|
29
|
+
}
|
|
30
|
+
/** Navigation provenance only; revalidated against the canonical index after restore. */
|
|
31
|
+
export interface EvidenceDeliveryBinding {
|
|
32
|
+
readonly evidenceRef: string;
|
|
33
|
+
readonly artifactRef: string;
|
|
34
|
+
}
|
|
35
|
+
export interface EvidenceDelivery extends EvidenceDeliveryBinding {
|
|
36
|
+
readonly kind: 'file' | 'code-change' | 'image';
|
|
37
|
+
readonly label: string;
|
|
38
|
+
/** A locator, never a grant or proof of historical bytes. Read through the existing scoped service. */
|
|
39
|
+
readonly reference?: BotDocumentReference;
|
|
40
|
+
readonly savedPreview?: {
|
|
41
|
+
readonly kind: 'diff-summary';
|
|
42
|
+
readonly text: string;
|
|
43
|
+
readonly truncated: true;
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: 'image';
|
|
46
|
+
readonly dataUrl: string;
|
|
47
|
+
readonly width: number;
|
|
48
|
+
readonly height: number;
|
|
49
|
+
};
|
|
50
|
+
readonly previewUnavailable?: boolean;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/goal.d.ts
CHANGED
|
@@ -166,7 +166,7 @@ export interface EvidenceIndexRecord {
|
|
|
166
166
|
readonly artifactRefs?: readonly string[];
|
|
167
167
|
/** Redacted, bounded execution-time snapshot of a successful local Tool Result. */
|
|
168
168
|
readonly bodyPreview?: {
|
|
169
|
-
readonly kind: 'file' | 'command';
|
|
169
|
+
readonly kind: 'file' | 'command' | 'observation';
|
|
170
170
|
readonly text: string;
|
|
171
171
|
readonly truncated: boolean;
|
|
172
172
|
};
|
|
@@ -444,14 +444,30 @@ export interface GoalRunTrace {
|
|
|
444
444
|
readonly lastCheckpointNodeId?: string;
|
|
445
445
|
readonly events: readonly GoalRunEvent[];
|
|
446
446
|
}
|
|
447
|
-
export type GoalSuccessCriterionKind = 'command' | 'test' | 'file-contains' | 'file-exists' | 'manual';
|
|
447
|
+
export type GoalSuccessCriterionKind = 'command' | 'test' | 'file-contains' | 'file-exists' | 'model_review' | 'manual';
|
|
448
448
|
export interface GoalSuccessCriterion {
|
|
449
|
+
readonly requiredCapabilities?: readonly string[];
|
|
449
450
|
readonly id: string;
|
|
450
451
|
readonly kind: GoalSuccessCriterionKind;
|
|
451
452
|
readonly description: string;
|
|
452
453
|
readonly command?: string;
|
|
453
454
|
readonly path?: string;
|
|
454
455
|
readonly expect?: string;
|
|
456
|
+
readonly authority?: {
|
|
457
|
+
readonly source: 'model' | 'user' | 'project_policy' | 'legacy_unknown';
|
|
458
|
+
readonly sourceRef?: string;
|
|
459
|
+
readonly version: number;
|
|
460
|
+
readonly verifier: 'mechanical' | 'host_model' | 'human';
|
|
461
|
+
readonly rationale: string;
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
export interface GoalModelReview {
|
|
465
|
+
readonly criterionId: string;
|
|
466
|
+
readonly sourceRevision: string;
|
|
467
|
+
readonly verifierRunId: string;
|
|
468
|
+
readonly passed: boolean;
|
|
469
|
+
readonly evidenceRefs: readonly string[];
|
|
470
|
+
readonly checkedAt: string;
|
|
455
471
|
}
|
|
456
472
|
export interface GoalCriterionResult {
|
|
457
473
|
readonly criterionId: string;
|
|
@@ -567,6 +583,33 @@ export interface GoalExecutionCheckpoint {
|
|
|
567
583
|
}
|
|
568
584
|
/** GoalPlan 内嵌的轻量 runner 状态;不代表工具执行事实,任务完成仍必须由 Evidence 回写。 */
|
|
569
585
|
export interface GoalRunnerState {
|
|
586
|
+
/** Host-owned readonly review continuity. Native messages stay in registered checkpoint storage. */
|
|
587
|
+
readonly verificationContinuation?: {
|
|
588
|
+
readonly schemaVersion: 1;
|
|
589
|
+
readonly policyVersion?: 2;
|
|
590
|
+
readonly planId: string;
|
|
591
|
+
readonly continuationId: string;
|
|
592
|
+
readonly sourceRevision: string;
|
|
593
|
+
readonly modelKey: string;
|
|
594
|
+
readonly workId?: string;
|
|
595
|
+
readonly phase: 'ready' | 'requesting' | 'tools' | 'completed';
|
|
596
|
+
/** Current slice deadline; legacy review-wide deadlines are renewed only on safe admission. */
|
|
597
|
+
readonly deadlineAt: string;
|
|
598
|
+
readonly modelRequests: number;
|
|
599
|
+
readonly toolCalls: number;
|
|
600
|
+
readonly formatAttempt: number;
|
|
601
|
+
readonly previousText?: string;
|
|
602
|
+
readonly checkpointRef?: string;
|
|
603
|
+
readonly evidenceRefs: readonly string[];
|
|
604
|
+
readonly fingerprint?: string;
|
|
605
|
+
readonly repeats?: number;
|
|
606
|
+
readonly progressFacts?: readonly string[];
|
|
607
|
+
readonly startedAt?: string;
|
|
608
|
+
readonly lastProgressAt?: string;
|
|
609
|
+
readonly observationCount?: number;
|
|
610
|
+
readonly observationFacts?: readonly string[];
|
|
611
|
+
readonly formatRequests?: number;
|
|
612
|
+
};
|
|
570
613
|
readonly enabled: boolean;
|
|
571
614
|
readonly status: GoalRunnerStatus;
|
|
572
615
|
readonly intent?: GoalRunnerIntent;
|
|
@@ -616,6 +659,7 @@ export interface GoalRunnerState {
|
|
|
616
659
|
* 中断在计划状态重派生时被误判为完成。
|
|
617
660
|
*/
|
|
618
661
|
readonly interruption?: {
|
|
662
|
+
readonly origin?: import('./agent-supervision.ts').InterruptionOrigin;
|
|
619
663
|
readonly source: string;
|
|
620
664
|
readonly reason: string;
|
|
621
665
|
readonly interruptedAt: string;
|
|
@@ -678,6 +722,9 @@ export interface GoalPlan {
|
|
|
678
722
|
readonly successCriteria: readonly GoalSuccessCriterion[];
|
|
679
723
|
readonly criterionResults: readonly GoalCriterionResult[];
|
|
680
724
|
readonly manualConfirmations?: readonly GoalManualConfirmation[];
|
|
725
|
+
readonly modelReviews?: readonly GoalModelReview[];
|
|
726
|
+
/** Host-derived current revision for checking semantic review freshness. */
|
|
727
|
+
readonly modelReviewSourceRevision?: string;
|
|
681
728
|
readonly boundaries: GoalBoundaries;
|
|
682
729
|
readonly exceptionPolicies: ExceptionPolicy[];
|
|
683
730
|
/** 顶层汇总(来源于子任务) */
|