@peer-agent/protocol 0.1.0
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/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/chat.d.ts +222 -0
- package/dist/chat.js +29 -0
- package/dist/execution.d.ts +257 -0
- package/dist/execution.js +1 -0
- package/dist/goal.d.ts +378 -0
- package/dist/goal.js +1 -0
- package/dist/index.d.ts +609 -0
- package/dist/index.js +6 -0
- package/dist/memory.d.ts +104 -0
- package/dist/memory.js +1 -0
- package/dist/system-context.d.ts +180 -0
- package/dist/system-context.js +1 -0
- package/dist/updater.d.ts +72 -0
- package/dist/updater.js +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 梁音
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @peer-agent/protocol
|
|
2
|
+
|
|
3
|
+
Host-neutral TypeScript contracts shared by Peer Agent runtimes and clients.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @peer-agent/protocol
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Scope
|
|
12
|
+
|
|
13
|
+
This package owns serializable cross-layer contracts such as capability projection, permission grants, tool calls and results, execution records, chat messages, goals, memory, system context, and updater state.
|
|
14
|
+
|
|
15
|
+
It contains no Electron, filesystem, child-process, network, or UI implementation.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import type {
|
|
19
|
+
ClientToolCall,
|
|
20
|
+
ClientToolResult,
|
|
21
|
+
PermissionGrant,
|
|
22
|
+
RuntimeExecuteRequest,
|
|
23
|
+
} from '@peer-agent/protocol';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Use the package root export only. Deep imports into `src` or `dist` are not public API.
|
|
27
|
+
|
|
28
|
+
## Compatibility
|
|
29
|
+
|
|
30
|
+
`@peer-agent/protocol` follows SemVer independently from the Peer Agent Desktop application. Runtime packages in the same `0.x` minor line declare their supported protocol range explicitly.
|
|
31
|
+
|
|
32
|
+
See `@peer-agent/runtime-sdk` for host-neutral orchestration.
|
package/dist/chat.d.ts
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { PendingDispatch, PendingHumanConfirmation, ResolvedHumanConfirmation, ThinkingProcess } from './execution.ts';
|
|
2
|
+
export type ConversationStatus = 'active' | 'inactive' | 'archived';
|
|
3
|
+
export interface ConversationMetadata {
|
|
4
|
+
readonly source?: string;
|
|
5
|
+
readonly [key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface Conversation {
|
|
8
|
+
readonly id: number;
|
|
9
|
+
readonly conversationUuid: string;
|
|
10
|
+
readonly title: string;
|
|
11
|
+
readonly agentId?: number;
|
|
12
|
+
readonly status: ConversationStatus;
|
|
13
|
+
readonly metadata?: ConversationMetadata;
|
|
14
|
+
readonly spectatorEnabled?: boolean;
|
|
15
|
+
readonly spectatorAclKey?: string | null;
|
|
16
|
+
readonly messageCount?: number;
|
|
17
|
+
readonly gmtCreate?: string;
|
|
18
|
+
readonly gmtModified?: string;
|
|
19
|
+
}
|
|
20
|
+
export type MessageRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
21
|
+
export type MessageStatus = 'sending' | 'streaming' | 'done' | 'error';
|
|
22
|
+
export interface MessageReference {
|
|
23
|
+
readonly scopeId: string;
|
|
24
|
+
readonly label: string;
|
|
25
|
+
readonly text: string;
|
|
26
|
+
readonly metadata?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
export interface MessageImage {
|
|
29
|
+
readonly url: string;
|
|
30
|
+
readonly mimeType?: string;
|
|
31
|
+
readonly width?: number;
|
|
32
|
+
readonly height?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface AssistantAction {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly label: string;
|
|
37
|
+
readonly style?: 'primary' | 'default' | 'danger';
|
|
38
|
+
readonly skillId: string;
|
|
39
|
+
readonly payload: {
|
|
40
|
+
readonly type: string;
|
|
41
|
+
readonly data?: unknown;
|
|
42
|
+
readonly messageUuid?: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface ChatMessage {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly role: MessageRole;
|
|
48
|
+
readonly content: string;
|
|
49
|
+
readonly timestamp: number;
|
|
50
|
+
readonly status?: MessageStatus;
|
|
51
|
+
readonly messageUuid?: string;
|
|
52
|
+
readonly rawMessageId?: number;
|
|
53
|
+
readonly images?: readonly MessageImage[];
|
|
54
|
+
readonly references?: readonly MessageReference[];
|
|
55
|
+
readonly actions?: readonly AssistantAction[];
|
|
56
|
+
readonly skillId?: string | number;
|
|
57
|
+
readonly skillName?: string;
|
|
58
|
+
readonly aiData?: unknown;
|
|
59
|
+
readonly renderData?: unknown;
|
|
60
|
+
readonly thinkingProcess?: ThinkingProcess;
|
|
61
|
+
readonly pendingDispatch?: PendingDispatch;
|
|
62
|
+
readonly pendingHumanConfirmation?: PendingHumanConfirmation;
|
|
63
|
+
readonly resolvedHumanConfirmation?: ResolvedHumanConfirmation;
|
|
64
|
+
readonly humanConfirmationHistory?: readonly ResolvedHumanConfirmation[];
|
|
65
|
+
readonly sender?: {
|
|
66
|
+
readonly id: number;
|
|
67
|
+
readonly name: string;
|
|
68
|
+
readonly type: 'siliconEmployee' | 'agent';
|
|
69
|
+
readonly depth: number;
|
|
70
|
+
readonly orgRole?: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export type MessageSource = {
|
|
74
|
+
readonly kind: 'live';
|
|
75
|
+
readonly conversationId: number;
|
|
76
|
+
} | {
|
|
77
|
+
readonly kind: 'frozen';
|
|
78
|
+
readonly shareUuid: string;
|
|
79
|
+
} | {
|
|
80
|
+
readonly kind: 'hybrid';
|
|
81
|
+
readonly conversationId: number;
|
|
82
|
+
readonly shareUuid: string;
|
|
83
|
+
};
|
|
84
|
+
export interface ConversationCapabilities {
|
|
85
|
+
readonly canSend: boolean;
|
|
86
|
+
readonly canEdit: boolean;
|
|
87
|
+
readonly canBranch: boolean;
|
|
88
|
+
readonly canShare: boolean;
|
|
89
|
+
}
|
|
90
|
+
export type ConversationLineage = {
|
|
91
|
+
readonly kind: 'sharedFrom';
|
|
92
|
+
readonly shareUuid: string;
|
|
93
|
+
readonly ownerWorkId: string;
|
|
94
|
+
readonly title: string;
|
|
95
|
+
readonly snapshotMessageCount: number;
|
|
96
|
+
readonly continuePolicy: 'disabled' | 'fork_only';
|
|
97
|
+
readonly derivationCount?: number;
|
|
98
|
+
} | {
|
|
99
|
+
readonly kind: 'derivedFrom';
|
|
100
|
+
readonly shareUuid: string;
|
|
101
|
+
readonly ownerWorkId: string;
|
|
102
|
+
readonly title: string;
|
|
103
|
+
readonly snapshotMessageCount: number;
|
|
104
|
+
} | null;
|
|
105
|
+
export interface ConversationView {
|
|
106
|
+
readonly source: MessageSource;
|
|
107
|
+
readonly capabilities: ConversationCapabilities;
|
|
108
|
+
readonly lineage: ConversationLineage;
|
|
109
|
+
readonly readOnly: boolean;
|
|
110
|
+
}
|
|
111
|
+
export type MessageNodeOrigin = 'live' | 'frozen';
|
|
112
|
+
export interface MessageActions {
|
|
113
|
+
readonly copy: boolean;
|
|
114
|
+
readonly regenerate: boolean;
|
|
115
|
+
readonly delete: boolean;
|
|
116
|
+
readonly branch: boolean;
|
|
117
|
+
readonly snapshot: boolean;
|
|
118
|
+
}
|
|
119
|
+
export interface ChatRuntimeState {
|
|
120
|
+
readonly conversation: Conversation | null;
|
|
121
|
+
readonly view: ConversationView | null;
|
|
122
|
+
readonly messages: readonly ChatMessage[];
|
|
123
|
+
readonly isStreaming: boolean;
|
|
124
|
+
readonly currentAssistantMessageId?: string;
|
|
125
|
+
readonly currentExecutionUuid?: string;
|
|
126
|
+
/**
|
|
127
|
+
* 当前用户消息触发的 run 标识(= userMessageUuid),由后端 `run_started`
|
|
128
|
+
* SSE 事件设置。main 进程在原 SSE 流断后用它作为重订阅
|
|
129
|
+
* `/api/chat/agent-runs/:runId/stream` 的寻址 key,跨多轮 pause-resume 持久。
|
|
130
|
+
*/
|
|
131
|
+
readonly currentRunId?: string;
|
|
132
|
+
readonly pendingConfirmations: readonly PendingHumanConfirmation[];
|
|
133
|
+
readonly lastEventAt?: string;
|
|
134
|
+
readonly error?: string;
|
|
135
|
+
}
|
|
136
|
+
export interface ChatStreamEvent {
|
|
137
|
+
readonly event: string;
|
|
138
|
+
readonly data: unknown;
|
|
139
|
+
readonly id?: string;
|
|
140
|
+
readonly retry?: number;
|
|
141
|
+
}
|
|
142
|
+
export interface ConversationListData {
|
|
143
|
+
readonly list: readonly Conversation[];
|
|
144
|
+
readonly total: number;
|
|
145
|
+
readonly limit?: number;
|
|
146
|
+
readonly offset?: number;
|
|
147
|
+
}
|
|
148
|
+
export interface MessageListData {
|
|
149
|
+
readonly list: readonly ChatMessage[];
|
|
150
|
+
readonly total: number;
|
|
151
|
+
readonly limit?: number;
|
|
152
|
+
readonly offset?: number;
|
|
153
|
+
readonly hasMore?: boolean;
|
|
154
|
+
}
|
|
155
|
+
export interface ChatStreamStartResult {
|
|
156
|
+
readonly streamId: string;
|
|
157
|
+
}
|
|
158
|
+
export interface ChatStreamEventEnvelope {
|
|
159
|
+
readonly streamId: string;
|
|
160
|
+
readonly event: ChatStreamEvent;
|
|
161
|
+
readonly receivedAt: string;
|
|
162
|
+
}
|
|
163
|
+
export interface ChatStreamDoneEnvelope {
|
|
164
|
+
readonly streamId: string;
|
|
165
|
+
readonly completedAt: string;
|
|
166
|
+
}
|
|
167
|
+
export interface ChatStreamErrorEnvelope {
|
|
168
|
+
readonly streamId: string;
|
|
169
|
+
readonly error: string;
|
|
170
|
+
readonly failedAt: string;
|
|
171
|
+
}
|
|
172
|
+
export interface ConversationMutationResult {
|
|
173
|
+
readonly ok?: boolean;
|
|
174
|
+
readonly code?: string;
|
|
175
|
+
readonly message?: string;
|
|
176
|
+
}
|
|
177
|
+
export interface BranchConversationResult {
|
|
178
|
+
readonly conversation: Conversation;
|
|
179
|
+
readonly messages?: readonly ChatMessage[];
|
|
180
|
+
}
|
|
181
|
+
export interface ThinkingDetailData {
|
|
182
|
+
readonly conversationId?: number;
|
|
183
|
+
readonly messageId?: number;
|
|
184
|
+
readonly messageUuid?: string;
|
|
185
|
+
readonly thinkingProcess?: ThinkingProcess;
|
|
186
|
+
readonly events?: readonly ChatStreamEvent[];
|
|
187
|
+
}
|
|
188
|
+
export interface AgentSummary {
|
|
189
|
+
readonly id: number | string;
|
|
190
|
+
readonly name: string;
|
|
191
|
+
readonly description?: string;
|
|
192
|
+
readonly avatar?: string;
|
|
193
|
+
readonly status?: string;
|
|
194
|
+
readonly metadata?: Record<string, unknown>;
|
|
195
|
+
}
|
|
196
|
+
export interface AgentListData {
|
|
197
|
+
readonly list: readonly AgentSummary[];
|
|
198
|
+
readonly total?: number;
|
|
199
|
+
}
|
|
200
|
+
export interface AssistantSuggestion {
|
|
201
|
+
readonly id: string;
|
|
202
|
+
readonly label: string;
|
|
203
|
+
readonly prompt: string;
|
|
204
|
+
readonly description?: string;
|
|
205
|
+
readonly source?: string;
|
|
206
|
+
}
|
|
207
|
+
export interface AssistantSuggestionListData {
|
|
208
|
+
readonly list: readonly AssistantSuggestion[];
|
|
209
|
+
}
|
|
210
|
+
export interface InlineCompletionData {
|
|
211
|
+
readonly text: string;
|
|
212
|
+
readonly source?: string;
|
|
213
|
+
}
|
|
214
|
+
export declare const FULL_CONVERSATION_CAPABILITIES: ConversationCapabilities;
|
|
215
|
+
export declare const READ_ONLY_CONVERSATION_CAPABILITIES: ConversationCapabilities;
|
|
216
|
+
export declare const STRICT_SPECTATOR_CONVERSATION_CAPABILITIES: ConversationCapabilities;
|
|
217
|
+
export declare function isReadOnlyConversation(capabilities: ConversationCapabilities): boolean;
|
|
218
|
+
export declare function buildConversationView(params: {
|
|
219
|
+
readonly source: MessageSource;
|
|
220
|
+
readonly capabilities: ConversationCapabilities;
|
|
221
|
+
readonly lineage?: ConversationLineage;
|
|
222
|
+
}): ConversationView;
|
package/dist/chat.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const FULL_CONVERSATION_CAPABILITIES = {
|
|
2
|
+
canSend: true,
|
|
3
|
+
canEdit: true,
|
|
4
|
+
canBranch: true,
|
|
5
|
+
canShare: true,
|
|
6
|
+
};
|
|
7
|
+
export const READ_ONLY_CONVERSATION_CAPABILITIES = {
|
|
8
|
+
canSend: false,
|
|
9
|
+
canEdit: false,
|
|
10
|
+
canBranch: true,
|
|
11
|
+
canShare: false,
|
|
12
|
+
};
|
|
13
|
+
export const STRICT_SPECTATOR_CONVERSATION_CAPABILITIES = {
|
|
14
|
+
canSend: false,
|
|
15
|
+
canEdit: false,
|
|
16
|
+
canBranch: false,
|
|
17
|
+
canShare: false,
|
|
18
|
+
};
|
|
19
|
+
export function isReadOnlyConversation(capabilities) {
|
|
20
|
+
return !capabilities.canSend && !capabilities.canEdit && !capabilities.canShare;
|
|
21
|
+
}
|
|
22
|
+
export function buildConversationView(params) {
|
|
23
|
+
return {
|
|
24
|
+
source: params.source,
|
|
25
|
+
capabilities: params.capabilities,
|
|
26
|
+
lineage: params.lineage ?? null,
|
|
27
|
+
readOnly: isReadOnlyConversation(params.capabilities),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -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 {};
|