@peer-agent/protocol 0.0.1-beta.43

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.
@@ -0,0 +1,257 @@
1
+ export type ExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'waiting_user';
2
+ export type HumanConfirmationDecision = 'approve' | 'reject' | 'revise';
3
+ export type HumanConfirmationTiming = 'before_tool' | 'after_tool' | 'before_dispatch' | 'checkpoint';
4
+ export interface HumanConfirmationStep {
5
+ readonly step?: number;
6
+ readonly title?: string;
7
+ readonly description?: string;
8
+ }
9
+ export interface PendingHumanConfirmation {
10
+ readonly confirmationId: string;
11
+ readonly executionUuid: string;
12
+ readonly title?: string;
13
+ readonly message?: string;
14
+ readonly timing?: HumanConfirmationTiming;
15
+ readonly step?: HumanConfirmationStep;
16
+ readonly exposedContext?: Record<string, unknown>;
17
+ readonly status?: 'pending';
18
+ }
19
+ export interface ResolvedHumanConfirmation {
20
+ readonly confirmationId: string;
21
+ readonly executionUuid: string;
22
+ readonly decision: HumanConfirmationDecision;
23
+ readonly feedback?: string;
24
+ readonly resolvedAt: string;
25
+ readonly status: 'resolved';
26
+ }
27
+ export interface MessageSender {
28
+ readonly id: number;
29
+ readonly name: string;
30
+ readonly type: 'siliconEmployee' | 'agent';
31
+ readonly depth: number;
32
+ readonly orgRole?: string;
33
+ readonly parentId?: number;
34
+ readonly parentMessageUuid?: string;
35
+ readonly dispatchSessionId?: string;
36
+ readonly rootSessionId?: string;
37
+ readonly description?: string;
38
+ }
39
+ export interface DispatchSubtask {
40
+ readonly assigneeId: number;
41
+ readonly name: string;
42
+ readonly instruction: string;
43
+ readonly orgRole?: string;
44
+ readonly description?: string;
45
+ }
46
+ export interface PendingDispatch {
47
+ readonly sessionId: string;
48
+ readonly subtasks: readonly DispatchSubtask[];
49
+ readonly reason?: string;
50
+ readonly sender: MessageSender;
51
+ readonly dispatcherName?: string;
52
+ }
53
+ export interface PendingDispatchResult {
54
+ readonly pending: boolean;
55
+ readonly sessionId?: string;
56
+ readonly subtasks?: readonly DispatchSubtask[];
57
+ readonly reason?: string;
58
+ readonly sender?: MessageSender;
59
+ readonly dispatcherName?: string;
60
+ }
61
+ export interface DispatchConfirmResult {
62
+ readonly success: boolean;
63
+ readonly note?: string;
64
+ readonly [key: string]: unknown;
65
+ }
66
+ export interface ThinkingBlock {
67
+ readonly iteration: number;
68
+ readonly content: string;
69
+ readonly toolCalls?: readonly {
70
+ readonly toolId: string;
71
+ readonly toolName: string;
72
+ readonly status: 'running' | 'completed' | 'error';
73
+ }[];
74
+ }
75
+ export interface SkillStep {
76
+ readonly step: number;
77
+ readonly title: string;
78
+ readonly status: 'pending' | 'running' | 'completed' | 'error';
79
+ readonly durationMs?: number;
80
+ readonly thinkingBlocks?: readonly ThinkingBlock[];
81
+ readonly outputSummary?: string;
82
+ readonly outputData?: unknown;
83
+ readonly collapsed?: boolean;
84
+ readonly nestedSkills?: readonly NestedSkill[];
85
+ }
86
+ export interface NestedSkill {
87
+ readonly skillId: string;
88
+ readonly skillName: string;
89
+ readonly runId?: string;
90
+ readonly depth: number;
91
+ readonly steps: readonly SkillStep[];
92
+ readonly status: 'running' | 'completed' | 'error';
93
+ }
94
+ /**
95
+ * Client local tool 调度生命周期阶段。
96
+ *
97
+ * 对应后端 cbu-xiaoer-node-service/src/service/aiChat/runtime/ClientToolEventTypes.ts
98
+ * CLIENT_TOOL_EVENT_NAMES 的状态机投影:
99
+ * dispatching → acked → (waiting_user_consent →) running → (stdout/stderr) → result_received
100
+ * result_received 落到 completed/failed/denied/timeout/cancelled 之一终态。
101
+ */
102
+ export type ClientToolStatus = 'dispatching' | 'acked' | 'waiting_user_consent' | 'running' | 'completed' | 'failed' | 'denied' | 'timeout' | 'cancelled';
103
+ /**
104
+ * 聚合检索类工具(如 batch_search / local.search.aggregate)的单条子路(lane)状态。
105
+ *
106
+ * 用于还原"批量并行检索"截图式 UI:一个搜索意图被拆成多条子查询并发执行,
107
+ * 每条子路独立显示阶段(检索中 / 已检索 · N 个结果)。所有字段对普通单卡工具
108
+ * 不适用 —— lane 仅在 ToolCard.lanes 上出现,普通工具该字段为 undefined。
109
+ *
110
+ * 进度事件时序:pending → running(started) → completed(+laneResultCount)
111
+ * 异常终态:failed / timeout / cancelled(单路隔离,不阻塞其余子路与最终聚合)。
112
+ */
113
+ export interface ToolCardLane {
114
+ /** 子路稳定标识;同一 toolCallId 下唯一,作为 reducer 折叠 key 的一部分。 */
115
+ readonly laneId: string;
116
+ /** 子路 UI 标签(如"检索仓库")。缺省时渲染层回退到 laneQuery。 */
117
+ readonly laneLabel?: string;
118
+ /** 子路当前阶段。 */
119
+ readonly lanePhase: 'pending' | 'running' | 'completed' | 'failed' | 'timeout' | 'cancelled';
120
+ /** 该子路已检索到的结果数(截图中的"· N 个结果");仅 completed 后有意义。 */
121
+ readonly laneResultCount?: number;
122
+ /** 该子路对应的检索词,便于 UI 展示与无 label 时回退。 */
123
+ readonly laneQuery?: string;
124
+ }
125
+ export interface ToolCard {
126
+ readonly toolCallId: string;
127
+ readonly toolId: string;
128
+ readonly displayName: string;
129
+ readonly status: 'running' | 'completed' | 'error' | 'warning';
130
+ readonly inputArguments?: unknown;
131
+ readonly inputArgumentsSource?: string;
132
+ readonly inputArgumentsNote?: string;
133
+ readonly executionUuid?: string;
134
+ readonly durationMs?: number;
135
+ readonly steps: readonly SkillStep[];
136
+ readonly resultContent?: string;
137
+ readonly resultSummary?: string;
138
+ readonly errorCount?: number;
139
+ readonly warningCount?: number;
140
+ readonly collapsed?: boolean;
141
+ /**
142
+ * 仅当 tool card 对应 client local tool 时填充。能力 ID(如 local.shell.exec),
143
+ * 作为稳定 key 给渲染层做工具名 i18n —— displayName 是后端注入的固定文案,
144
+ * 不能直接翻译;按 capabilityId 映射才能跟界面 locale 一致。
145
+ */
146
+ readonly capabilityId?: string;
147
+ /**
148
+ * 仅当 tool card 对应 client local tool 时填充。表示后端 suspension 状态机
149
+ * 的最新阶段;status 字段仍按 ToolCard 通用语义聚合给 UI 用。
150
+ */
151
+ readonly clientToolStatus?: ClientToolStatus;
152
+ /** Client local tool 流式 stdout 累积;断线丢失不补,由 evidence 兜底。 */
153
+ readonly stdout?: string;
154
+ /** Client local tool 流式 stderr 累积;断线丢失不补,由 evidence 兜底。 */
155
+ readonly stderr?: string;
156
+ /**
157
+ * 仅当 tool card 对应聚合检索类工具(如 batch_search)时填充。承载多条并发
158
+ * 子路(lane)的逐条状态,供 UI 还原截图式"分路检索"。普通单卡工具为 undefined,
159
+ * 行为不变(向后兼容)。断线丢失由最终聚合 evidence 兜底。
160
+ */
161
+ readonly lanes?: readonly ToolCardLane[];
162
+ }
163
+ export interface IterationNode {
164
+ readonly iteration: number;
165
+ readonly label?: string;
166
+ readonly thinkingContent: string;
167
+ readonly toolCards: readonly ToolCard[];
168
+ readonly status: 'thinking' | 'tool_calling' | 'completed';
169
+ /** 该轮所属 execution。与 iteration 组成复合 key,区分本地工具 pause-resume 后
170
+ * 序号重置的不同 execution(防塌缩 + forwardByRun 重放幂等)。 */
171
+ readonly executionUuid?: string;
172
+ }
173
+ export interface ThinkingProcess {
174
+ readonly expanded: boolean;
175
+ readonly iterations: readonly IterationNode[];
176
+ readonly maxIterations: number;
177
+ readonly toolCount: number;
178
+ readonly totalDurationMs?: number;
179
+ readonly totalIterations?: number;
180
+ readonly totalToolCalls?: number;
181
+ readonly loopDetected?: boolean;
182
+ readonly estimatedDurationMs?: number;
183
+ readonly processUuid?: string;
184
+ readonly executionUuid?: string;
185
+ readonly status: 'running' | 'completed' | 'error' | 'waiting' | 'waiting_user';
186
+ readonly pendingHumanConfirmation?: PendingHumanConfirmation;
187
+ }
188
+ export interface ExecutionStatusSnapshot {
189
+ readonly executionUuid: string;
190
+ readonly status: ExecutionStatus;
191
+ readonly progress?: number;
192
+ readonly currentStep?: string;
193
+ readonly pendingConfirmation?: PendingHumanConfirmation;
194
+ readonly lastHeartbeatAt?: number;
195
+ readonly checkpoint?: {
196
+ readonly iteration: number;
197
+ readonly messageCount: number;
198
+ readonly toolCallCount: number;
199
+ readonly phase: 'running' | 'completed' | 'failed';
200
+ readonly savedAt: number;
201
+ };
202
+ }
203
+ export interface ExecutionCotSnapshot {
204
+ readonly executionUuid: string;
205
+ readonly status: ExecutionStatus;
206
+ readonly events: readonly {
207
+ readonly id?: number;
208
+ readonly event: string;
209
+ readonly data: unknown;
210
+ readonly timestamp?: number;
211
+ }[];
212
+ }
213
+ export interface ExecutionDetailData {
214
+ readonly executionUuid?: string;
215
+ readonly status?: ExecutionStatus | string;
216
+ readonly progress?: number;
217
+ readonly currentStep?: string;
218
+ readonly result?: unknown;
219
+ readonly error?: string;
220
+ readonly metadata?: Record<string, unknown>;
221
+ readonly [key: string]: unknown;
222
+ }
223
+ export interface ExecutionResultData {
224
+ readonly executionUuid?: string;
225
+ readonly status?: ExecutionStatus | string;
226
+ readonly result?: unknown;
227
+ readonly resultType?: string;
228
+ readonly error?: string;
229
+ readonly durationMs?: number;
230
+ readonly [key: string]: unknown;
231
+ }
232
+ export interface ExecutionSourceTraceData {
233
+ readonly executionUuid?: string;
234
+ readonly step?: number;
235
+ readonly candidates?: readonly Record<string, unknown>[];
236
+ readonly matches?: readonly Record<string, unknown>[];
237
+ readonly [key: string]: unknown;
238
+ }
239
+ export interface ExecutionListData {
240
+ readonly list?: readonly ExecutionDetailData[];
241
+ readonly items?: readonly ExecutionDetailData[];
242
+ readonly total?: number;
243
+ readonly page?: number;
244
+ readonly pageSize?: number;
245
+ readonly [key: string]: unknown;
246
+ }
247
+ export interface RelatedShadowExecutionListData {
248
+ readonly list?: readonly ExecutionDetailData[];
249
+ readonly items?: readonly ExecutionDetailData[];
250
+ readonly total?: number;
251
+ readonly [key: string]: unknown;
252
+ }
253
+ export interface ExecutionCancelResult {
254
+ readonly success: boolean;
255
+ readonly signalSent?: boolean;
256
+ readonly [key: string]: unknown;
257
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/goal.d.ts ADDED
@@ -0,0 +1,378 @@
1
+ /**
2
+ * Goal 模式协议类型 —— 见 Goal 模式设计。
3
+ *
4
+ * 设计要点(与提案一致):
5
+ * - 计划是持久化的 Evidence/artifact,采用「先规划 → 批准 → 执行」流程。
6
+ * - 子任务(含嵌套)独立追踪完成状态,`status` 只能由 Evidence 回写。
7
+ * - 批准 / 驳回 / 修订作为治理事实记录,复用 execution.ts 的 HumanConfirmation。
8
+ * - 进度(progress)由子任务自底向上聚合,不可手填。
9
+ *
10
+ * 复用既有协议:
11
+ * - 子任务状态复用 ExecutionStatus(execution.ts)。
12
+ * - 批准决策复用 HumanConfirmationDecision(execution.ts)。
13
+ */
14
+ import type { ExecutionStatus, HumanConfirmationDecision } from './execution.ts';
15
+ /** 计划整体状态机,见提案 §2。 */
16
+ export type GoalPlanStatus = 'drafting' | 'awaiting_approval' | 'approved' | 'accepted' | 'executing' | 'paused' | 'completed' | 'cancelled' | 'failed';
17
+ /** Goal artifact 的工作流语义:Plan 审批门 vs Goal 自驱契约。 */
18
+ export type GoalWorkflowKind = 'plan_approval' | 'goal_self_driven';
19
+ /**
20
+ * Goal/Plan 的执行准入事实。
21
+ *
22
+ * `intake` 是 goal 模式下的「判别前置态」:用户首发消息先落成 intake 契约,
23
+ * Runner 在只读/问答/澄清的受限授权下判别真实意图,判定为明确目标后才升级为
24
+ * `accepted_goal` 进入正常自驱;判定为纯问答则由上层静默移除契约。
25
+ */
26
+ export interface GoalActivation {
27
+ readonly kind: 'intake' | 'approval_required' | 'approved_plan' | 'accepted_goal';
28
+ readonly sourceMessageId?: string;
29
+ readonly acceptedAt?: string;
30
+ readonly acceptedBy?: string;
31
+ /** intake 阶段的判别结论;仅在 kind 从 intake 流转时写入,用于溯源。 */
32
+ readonly intakeResolution?: GoalIntakeResolution;
33
+ }
34
+ /** intake 判别的三种结论。 */
35
+ export type GoalIntakeResolution = 'inquiry' | 'clarifying' | 'goal_confirmed';
36
+ export type GoalAskUserReason = 'ambiguous_goal' | 'product_decision' | 'high_risk' | 'irreversible' | 'missing_permission' | 'missing_credentials' | 'verification_conflict' | 'scope_drift';
37
+ /** 执行策略:权限仍由 Runtime Projection / PermissionGrant / adapter enforcement 负责。 */
38
+ export interface GoalExecutionPolicy {
39
+ readonly autonomy: 'approval_gated' | 'self_driven';
40
+ readonly irreversibleRequiresConfirmation: boolean;
41
+ readonly writeScope: 'workspace_and_boundaries';
42
+ readonly askUserOn: readonly GoalAskUserReason[];
43
+ }
44
+ /** 异常处理策略动作。rollback 的 schema 先落地,执行器可后置。 */
45
+ export type ExceptionPolicyAction = 'pause' | 'rollback' | 'skip' | 'ask_user';
46
+ /** 结构化异常处理策略(MVP 必需)。 */
47
+ export interface ExceptionPolicy {
48
+ readonly id: string;
49
+ /** 何种异常触发 */
50
+ readonly trigger: string;
51
+ /** 作用域:'plan' 或某个 taskId */
52
+ readonly scope: 'plan' | string;
53
+ readonly action: ExceptionPolicyAction;
54
+ /** 回滚目标 taskId(仅 action='rollback' 时有意义) */
55
+ readonly rollbackOf?: string;
56
+ }
57
+ /** 计划边界条件。 */
58
+ export interface GoalBoundaries {
59
+ readonly inScope: string[];
60
+ readonly outOfScope: string[];
61
+ }
62
+ /** 子任务(树形,支持嵌套)。 */
63
+ export interface GoalTask {
64
+ readonly taskId: string;
65
+ /** 同层稳定排序 */
66
+ readonly order: number;
67
+ readonly title: string;
68
+ /** 子目标委派关系;历史任务可不含这些字段。 */
69
+ readonly childPlanIds?: readonly string[];
70
+ readonly executionMode?: 'direct' | 'delegated';
71
+ /** 达成路径 / 步骤 */
72
+ readonly path: string[];
73
+ /** 依赖的 taskId(约束见提案 §4:同层或祖先链之外,禁止成环) */
74
+ readonly dependsOn: string[];
75
+ /** 本任务完成判定 */
76
+ readonly acceptanceCriteria: string[];
77
+ readonly involvedFiles: string[];
78
+ /** 预期能力(对齐 Runtime Projection) */
79
+ readonly capabilityHints?: string[];
80
+ /** 子任务状态,复用 ExecutionStatus;只能由 Evidence 回写 */
81
+ readonly status: ExecutionStatus;
82
+ /** 完成的事实依据(Evidence id 列表) */
83
+ readonly evidenceRefs: string[];
84
+ readonly result?: string;
85
+ readonly failureReason?: string;
86
+ readonly blockedReason?: string;
87
+ readonly startedAt?: string;
88
+ readonly completedAt?: string;
89
+ /** 嵌套子任务(MVP 必需) */
90
+ readonly subtasks?: GoalTask[];
91
+ }
92
+ /** Goal 模式的全局 Evidence 索引记录;任务完成只允许引用这里登记过的 refs。 */
93
+ export interface EvidenceIndexRecord {
94
+ readonly evidenceRef: string;
95
+ readonly planId?: string;
96
+ readonly conversationId?: string;
97
+ readonly streamId?: string;
98
+ readonly toolCallId?: string;
99
+ readonly capabilityId?: string;
100
+ readonly toolName?: string;
101
+ readonly createdAt: string;
102
+ readonly artifactRefs?: readonly string[];
103
+ }
104
+ /** 批准事实(Evidence)。 */
105
+ export interface GoalApproval {
106
+ readonly decision: HumanConfirmationDecision;
107
+ /** 绑定 execution.ts 的 confirmationId */
108
+ readonly confirmationId: string;
109
+ readonly decidedBy?: string;
110
+ readonly decidedAt: string;
111
+ readonly feedback?: string;
112
+ }
113
+ /** 进度聚合(派生,由子任务 Evidence 聚合,不可手填)。 */
114
+ export interface GoalProgress {
115
+ readonly total: number;
116
+ readonly completed: number;
117
+ readonly failed: number;
118
+ readonly blocked: number;
119
+ /** 0–100 */
120
+ readonly percent: number;
121
+ }
122
+ /** 修订记录(来自 reject/revise 的 feedback)。 */
123
+ export interface GoalRevision {
124
+ readonly version: number;
125
+ readonly reason: string;
126
+ readonly changedAt: string;
127
+ readonly changedBy?: string;
128
+ }
129
+ /** Goal Runner 托管推进器状态。 */
130
+ export type GoalRunnerStatus = 'idle' | 'running' | 'paused' | 'exploring' | 'blocked' | 'budget_exhausted' | 'completed' | 'failed';
131
+ /** Goal Runner 当前推进意图;只描述编排意图,不替代工具执行 Evidence。 */
132
+ export type GoalRunnerIntent = 'execute' | 'verify' | 'explore' | 'synthesize' | 'block';
133
+ export type GoalRunnerPhase = 'orient' | 'inspect' | 'plan_scaffold' | 'act' | 'verify' | 'repair' | 'synthesize' | 'blocked';
134
+ export interface GoalBlockerAudit {
135
+ readonly fingerprint: string;
136
+ readonly occurrences: number;
137
+ readonly firstSeenAt: string;
138
+ readonly lastSeenAt: string;
139
+ readonly reason: string;
140
+ }
141
+ /** 动态 Explorer 子 Agent 的能力边界。第一版只允许只读探索。 */
142
+ export type GoalExplorerProfile = 'readonly_explorer';
143
+ export type GoalExplorerStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
144
+ /** Runner 动态生成的 Explorer 子 Agent 请求;定义任务实例,不定义固定角色。 */
145
+ export interface GoalExplorerRequest {
146
+ readonly explorerId: string;
147
+ readonly planId: string;
148
+ readonly question: string;
149
+ readonly reason: string;
150
+ readonly scope?: {
151
+ readonly include?: string[];
152
+ readonly exclude?: string[];
153
+ };
154
+ readonly profile: GoalExplorerProfile;
155
+ readonly budget: {
156
+ readonly maxToolCalls: number;
157
+ readonly maxDurationMs: number;
158
+ };
159
+ readonly exitCriteria: string[];
160
+ readonly createdAt: string;
161
+ }
162
+ export interface GoalExplorerFinding {
163
+ readonly claim: string;
164
+ readonly evidenceRefs: string[];
165
+ }
166
+ /** Explorer 子 Agent 的结构化报告;完成报告必须带 Evidence refs。 */
167
+ export interface GoalExplorerReport {
168
+ readonly explorerId: string;
169
+ readonly planId: string;
170
+ readonly question: string;
171
+ readonly findings: GoalExplorerFinding[];
172
+ readonly evidenceRefs: string[];
173
+ readonly confidence: 'low' | 'medium' | 'high';
174
+ readonly recommendedNextAction?: string;
175
+ readonly blockedReason?: string;
176
+ }
177
+ export interface GoalExplorerRun {
178
+ readonly explorerId: string;
179
+ readonly status: GoalExplorerStatus;
180
+ readonly request: GoalExplorerRequest;
181
+ /** Evidence refs produced by this Explorer's projected tool executions. */
182
+ readonly evidenceRefs?: string[];
183
+ readonly report?: GoalExplorerReport;
184
+ readonly failureReason?: string;
185
+ /** 同一 turn 内并发派发的一批 Explorer 共享同一 batchId;用于 UI 精确统计「本轮」进度。 */
186
+ readonly batchId?: string;
187
+ readonly createdAt: string;
188
+ readonly updatedAt: string;
189
+ }
190
+ /** 本轮(最近一批)Explorer 并发进度;供 UI 展示「已完成 / 本轮总数」。 */
191
+ export interface GoalExplorerBatch {
192
+ readonly batchId: string;
193
+ /** 本批派发的 Explorer 总数(分母)。 */
194
+ readonly total: number;
195
+ /** 本批已进入终止态(completed/failed/cancelled)的数量(分子)。 */
196
+ readonly done: number;
197
+ }
198
+ export interface GoalExploreQuestion {
199
+ readonly question: string;
200
+ readonly reason: string;
201
+ readonly scope?: {
202
+ readonly include?: string[];
203
+ readonly exclude?: string[];
204
+ };
205
+ readonly budget?: {
206
+ readonly maxToolCalls?: number;
207
+ readonly maxDurationMs?: number;
208
+ };
209
+ }
210
+ export interface GoalExplorePlan {
211
+ readonly requiredBeforeAct: boolean;
212
+ readonly questions: readonly GoalExploreQuestion[];
213
+ readonly exitCriteria: readonly string[];
214
+ readonly generatedAt: string;
215
+ }
216
+ export type GoalVerifierStatus = 'queued' | 'running' | 'passed' | 'failed' | 'blocked';
217
+ export type GoalVerifierTargetKind = 'plan' | 'task' | 'success_criterion';
218
+ export interface GoalVerifierTarget {
219
+ readonly kind: GoalVerifierTargetKind;
220
+ readonly taskId?: string;
221
+ readonly criterionId?: string;
222
+ }
223
+ export interface GoalVerifierIssue {
224
+ readonly taskId?: string;
225
+ readonly criterionId?: string;
226
+ readonly reason: string;
227
+ readonly evidenceRefs: string[];
228
+ }
229
+ export interface GoalVerifierReport {
230
+ readonly passed: boolean;
231
+ readonly failedCriteria: readonly GoalVerifierIssue[];
232
+ readonly missingEvidence: readonly GoalVerifierIssue[];
233
+ readonly risks: readonly string[];
234
+ readonly evidenceRefs: readonly string[];
235
+ readonly recommendedNextAction?: string;
236
+ }
237
+ /** Verifier 运行事实;记录验证动作与证据,不替代任务 Evidence 或 CriterionResult。 */
238
+ export interface GoalVerifierRun {
239
+ readonly verifierRunId: string;
240
+ readonly planId: string;
241
+ readonly target: GoalVerifierTarget;
242
+ readonly status: GoalVerifierStatus;
243
+ readonly evidenceRefs: string[];
244
+ readonly report?: GoalVerifierReport;
245
+ readonly summary?: string;
246
+ readonly failureReason?: string;
247
+ readonly createdAt: string;
248
+ readonly updatedAt: string;
249
+ readonly completedAt?: string;
250
+ }
251
+ export type GoalRunEventType = 'message_routed' | 'goal_intake_started' | 'goal_created' | 'plan_created' | 'plan_revised' | 'step_started' | 'step_completed' | 'action_started' | 'action_completed' | 'observation_recorded' | 'validation_started' | 'validation_passed' | 'validation_failed' | 'problem_found' | 'user_correction' | 'requirement_override' | 'self_correction' | 'checkpoint_created' | 'network_interrupted' | 'goal_resumed' | 'goal_paused' | 'goal_completed';
252
+ export interface GoalRunEvent {
253
+ readonly id: string;
254
+ readonly goalPlanId: string;
255
+ readonly nodeId?: string;
256
+ readonly parentNodeId?: string;
257
+ readonly type: GoalRunEventType;
258
+ readonly summary: string;
259
+ readonly payload?: Record<string, unknown>;
260
+ readonly evidenceRefs: readonly string[];
261
+ readonly createdAt: string;
262
+ }
263
+ /** Append-only execution ledger for Goal / Plan / Run projection. */
264
+ export interface GoalRunTrace {
265
+ readonly activeNodeId?: string;
266
+ readonly lastCheckpointNodeId?: string;
267
+ readonly events: readonly GoalRunEvent[];
268
+ }
269
+ export type GoalSuccessCriterionKind = 'command' | 'test' | 'file-contains' | 'file-exists' | 'manual';
270
+ export interface GoalSuccessCriterion {
271
+ readonly id: string;
272
+ readonly kind: GoalSuccessCriterionKind;
273
+ readonly description: string;
274
+ readonly command?: string;
275
+ readonly path?: string;
276
+ readonly expect?: string;
277
+ }
278
+ export interface GoalCriterionResult {
279
+ readonly criterionId: string;
280
+ readonly passed: boolean;
281
+ readonly evidenceRef?: string;
282
+ readonly detail?: string;
283
+ readonly checkedAt?: string;
284
+ }
285
+ export type GoalManualConfirmationKind = 'manual_dod';
286
+ export interface GoalManualConfirmation {
287
+ readonly confirmationId: string;
288
+ readonly kind: GoalManualConfirmationKind;
289
+ readonly decision: HumanConfirmationDecision;
290
+ readonly criterionIds: readonly string[];
291
+ readonly decidedBy?: string;
292
+ readonly decidedAt: string;
293
+ readonly feedback?: string;
294
+ }
295
+ /** GoalPlan 内嵌的轻量 runner 状态;不代表工具执行事实,任务完成仍必须由 Evidence 回写。 */
296
+ export interface GoalRunnerState {
297
+ readonly enabled: boolean;
298
+ readonly status: GoalRunnerStatus;
299
+ readonly intent?: GoalRunnerIntent;
300
+ readonly phase?: GoalRunnerPhase;
301
+ readonly currentTaskId?: string;
302
+ /** 预算计数:Runner tick 次数,用于 maxTurns 熔断判定。 */
303
+ readonly turnCount: number;
304
+ /** 展示计数:模型内部对话轮次,随执行实时爬升;与 turnCount(预算)解耦,仅用于 UI 呈现。 */
305
+ readonly roundCount: number;
306
+ readonly toolCallCount: number;
307
+ readonly explorerCount: number;
308
+ readonly maxTurns: number;
309
+ readonly maxToolCalls: number;
310
+ /**
311
+ * @deprecated 语义已弃用:不再作为「每计划累计可派发 Explorer 总数」的闸。
312
+ * 保留字段仅为向后兼容旧持久化数据;并发上限改由 explorerConcurrency 表达,
313
+ * 计划总数由 maxTurns 天然兜底。
314
+ */
315
+ readonly maxExplorers: number;
316
+ /** 每个 turn 内 Explorer 的并发上限(并发池大小)。默认 5,硬上限 8。 */
317
+ readonly explorerConcurrency: number;
318
+ readonly explorers?: GoalExplorerRun[];
319
+ /** 最近一批并发 Explorer 的进度;无进行中批次时可缺省。 */
320
+ readonly explorerBatch?: GoalExplorerBatch;
321
+ /** Deterministic inspect planner output for the current inspect phase. */
322
+ readonly inspectPlan?: GoalExplorePlan;
323
+ /** Verifier 运行历史;用于追踪验证事实,不作为任务完成的唯一事实源。 */
324
+ readonly verifierRuns?: GoalVerifierRun[];
325
+ readonly blockerAudit?: GoalBlockerAudit;
326
+ readonly tokenBudget?: number;
327
+ readonly tokenUsed?: number;
328
+ readonly blockedReason?: string;
329
+ readonly lastError?: string;
330
+ readonly updatedAt: string;
331
+ }
332
+ /** 计划 Artifact 定型版,见提案 §3。 */
333
+ export interface GoalPlan {
334
+ readonly planId: string;
335
+ readonly conversationId?: string;
336
+ readonly threadId?: string;
337
+ readonly agentId?: number;
338
+ /** Workspace where the Goal was initiated and where contextual knowledge came from. */
339
+ readonly originWorkspacePath?: string;
340
+ /** Workspace/repository where the Goal should write and verify changes. */
341
+ readonly targetWorkspacePath?: string;
342
+ /** 派生目标关系;全部可选以兼容历史计划。 */
343
+ readonly parentPlanId?: string;
344
+ readonly sourceTaskId?: string;
345
+ readonly rootPlanId?: string;
346
+ readonly relationType?: 'derived';
347
+ readonly depth?: number;
348
+ readonly title: string;
349
+ readonly goal: string;
350
+ readonly successCriteria: readonly GoalSuccessCriterion[];
351
+ readonly criterionResults: readonly GoalCriterionResult[];
352
+ readonly manualConfirmations?: readonly GoalManualConfirmation[];
353
+ readonly boundaries: GoalBoundaries;
354
+ readonly exceptionPolicies: ExceptionPolicy[];
355
+ /** 顶层汇总(来源于子任务) */
356
+ readonly involvedFiles: string[];
357
+ /** 拆出的子事项(树形) */
358
+ readonly tasks: GoalTask[];
359
+ readonly workflowKind?: GoalWorkflowKind;
360
+ readonly activation?: GoalActivation;
361
+ readonly executionPolicy?: GoalExecutionPolicy;
362
+ readonly status: GoalPlanStatus;
363
+ readonly approval?: GoalApproval;
364
+ /** 由子任务聚合,派生,不可手填 */
365
+ readonly progress: GoalProgress;
366
+ /** Goal Runner 托管推进状态;旧计划可缺省。 */
367
+ readonly runner?: GoalRunnerState;
368
+ /** Execution/event ledger used by the Goal / Plan / Run right-panel projection. */
369
+ readonly runTrace?: GoalRunTrace;
370
+ readonly version: number;
371
+ readonly revisionHistory: GoalRevision[];
372
+ readonly evidenceRefs: string[];
373
+ /** 对齐 system-context.ts 的 epoch */
374
+ readonly promptContextEpochId?: string;
375
+ readonly createdAt: string;
376
+ readonly updatedAt: string;
377
+ readonly createdBy?: string;
378
+ }
package/dist/goal.js ADDED
@@ -0,0 +1 @@
1
+ export {};