@linnlabs/linnkit 0.8.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/CHANGELOG.md +84 -0
- package/LICENSE +21 -0
- package/README.md +178 -0
- package/README.zh-CN.md +182 -0
- package/dist/agent-invocation-BHcNfrBV.d.cts +30 -0
- package/dist/agent-invocation-BznDaXDs.d.ts +30 -0
- package/dist/agentEvents-DEB7Fy_J.d.cts +81 -0
- package/dist/agentEvents-DEB7Fy_J.d.ts +81 -0
- package/dist/agentSpec-EkmviZjy.d.cts +2621 -0
- package/dist/agentSpec-EkmviZjy.d.ts +2621 -0
- package/dist/ai-engine.types-BpeU_XQG.d.cts +158 -0
- package/dist/ai-engine.types-vZRnQcJa.d.ts +158 -0
- package/dist/audit-BaRUGaqv.d.cts +307 -0
- package/dist/audit-BaRUGaqv.d.ts +307 -0
- package/dist/audit-CtcfART1.d.ts +33 -0
- package/dist/audit-LeOrm2hX.d.cts +33 -0
- package/dist/checkpointMarker-DAI3wUQu.d.cts +8 -0
- package/dist/checkpointMarker-DAI3wUQu.d.ts +8 -0
- package/dist/cli.cjs +8028 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +4 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +8025 -0
- package/dist/cli.js.map +1 -0
- package/dist/context-manager.cjs +8704 -0
- package/dist/context-manager.cjs.map +1 -0
- package/dist/context-manager.d.cts +2190 -0
- package/dist/context-manager.d.ts +2190 -0
- package/dist/context-manager.js +8650 -0
- package/dist/context-manager.js.map +1 -0
- package/dist/context-trace-DRi5M4lX.d.ts +239 -0
- package/dist/context-trace-HE2qY5Q-.d.cts +239 -0
- package/dist/contracts.cjs +1333 -0
- package/dist/contracts.cjs.map +1 -0
- package/dist/contracts.d.cts +8 -0
- package/dist/contracts.d.ts +8 -0
- package/dist/contracts.js +1214 -0
- package/dist/contracts.js.map +1 -0
- package/dist/defaultGraphExecutor-BBswR8wn.d.ts +624 -0
- package/dist/defaultGraphExecutor-BIjJj7WF.d.cts +624 -0
- package/dist/execution-CAIypb41.d.cts +129 -0
- package/dist/execution-CAIypb41.d.ts +129 -0
- package/dist/index-CHqwkvGp.d.ts +149 -0
- package/dist/index-CJeWHopy.d.ts +584 -0
- package/dist/index-Cm-JbzTH.d.cts +1450 -0
- package/dist/index-Cvr23YCl.d.cts +23 -0
- package/dist/index-DDzuSb0n.d.ts +23 -0
- package/dist/index-DO4dQgf2.d.cts +584 -0
- package/dist/index-DRBWi1fy.d.ts +1450 -0
- package/dist/index-Dl5PLgAv.d.cts +149 -0
- package/dist/index.cjs +9577 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +89 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +9563 -0
- package/dist/index.js.map +1 -0
- package/dist/messages-XthmnHZ3.d.cts +8007 -0
- package/dist/messages-XthmnHZ3.d.ts +8007 -0
- package/dist/ports-DaatKJXp.d.cts +90 -0
- package/dist/ports-DnLuKfpE.d.ts +90 -0
- package/dist/ports.cjs +4 -0
- package/dist/ports.cjs.map +1 -0
- package/dist/ports.d.cts +7 -0
- package/dist/ports.d.ts +7 -0
- package/dist/ports.js +3 -0
- package/dist/ports.js.map +1 -0
- package/dist/quickstart.cjs +7697 -0
- package/dist/quickstart.cjs.map +1 -0
- package/dist/quickstart.d.cts +24 -0
- package/dist/quickstart.d.ts +24 -0
- package/dist/quickstart.js +7691 -0
- package/dist/quickstart.js.map +1 -0
- package/dist/runAgent-CPj_9e58.d.ts +88 -0
- package/dist/runAgent-HYKlXbVr.d.cts +88 -0
- package/dist/runHandle-CyXvzgzk.d.ts +239 -0
- package/dist/runHandle-D3gPsD7B.d.cts +239 -0
- package/dist/runtime-kernel/events.cjs +1485 -0
- package/dist/runtime-kernel/events.cjs.map +1 -0
- package/dist/runtime-kernel/events.d.cts +8 -0
- package/dist/runtime-kernel/events.d.ts +8 -0
- package/dist/runtime-kernel/events.js +1475 -0
- package/dist/runtime-kernel/events.js.map +1 -0
- package/dist/runtime-kernel.cjs +8656 -0
- package/dist/runtime-kernel.cjs.map +1 -0
- package/dist/runtime-kernel.d.cts +19 -0
- package/dist/runtime-kernel.d.ts +19 -0
- package/dist/runtime-kernel.js +8568 -0
- package/dist/runtime-kernel.js.map +1 -0
- package/dist/sse-vPyrOPa0.d.cts +1687 -0
- package/dist/sse-vPyrOPa0.d.ts +1687 -0
- package/dist/testkit.cjs +10613 -0
- package/dist/testkit.cjs.map +1 -0
- package/dist/testkit.d.cts +284 -0
- package/dist/testkit.d.ts +284 -0
- package/dist/testkit.js +10593 -0
- package/dist/testkit.js.map +1 -0
- package/dist/todo-B1PmDlp3.d.cts +2253 -0
- package/dist/todo-B1PmDlp3.d.ts +2253 -0
- package/dist/tokenizer-DFL4I7-I.d.ts +28 -0
- package/dist/tokenizer-DH_JXv-H.d.cts +28 -0
- package/dist/toolContracts-Blll0241.d.ts +463 -0
- package/dist/toolContracts-CLkQmhTG.d.cts +463 -0
- package/docs/README.md +76 -0
- package/docs/integration/01-installation.md +94 -0
- package/docs/integration/02-quickstart.md +104 -0
- package/docs/integration/README.md +223 -0
- package/docs/integration/agent-registration-guide.md +330 -0
- package/docs/integration/audit.md +64 -0
- package/docs/integration/child-runs.md +87 -0
- package/docs/integration/constraints-and-pitfalls.md +87 -0
- package/docs/integration/context-engineering.md +650 -0
- package/docs/integration/context-fences.md +289 -0
- package/docs/integration/glossary.md +69 -0
- package/docs/integration/llm-provider.md +76 -0
- package/docs/integration/persistence.md +44 -0
- package/docs/integration/realtime.md +76 -0
- package/docs/integration/run-supervisor.md +69 -0
- package/docs/integration/telemetry.md +48 -0
- package/docs/integration/testing.md +95 -0
- package/docs/integration/tool-development-guide.md +362 -0
- package/docs/integration/tool-history.md +202 -0
- package/docs/integration/tools.md +188 -0
- package/package.json +115 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { A as AgentInvocationRequest } from './agent-invocation-BHcNfrBV.cjs';
|
|
2
|
+
import { A as AgentAiEngine, a as AgentAiEngineStreamContent, b as AuditPort } from './audit-LeOrm2hX.cjs';
|
|
3
|
+
import { T as TokenizerPort } from './tokenizer-DH_JXv-H.cjs';
|
|
4
|
+
import { L as LlmCallOptions, a as LlmRequestMessage, b as LlmResponseContent, c as LlmRetryConfig, P as ProviderReasoningDetails, T as ToolCall, d as ToolCallChunk, e as ToolCallExtraContent } from './ai-engine.types-BpeU_XQG.cjs';
|
|
5
|
+
|
|
6
|
+
declare const index_AgentAiEngine: typeof AgentAiEngine;
|
|
7
|
+
declare const index_AgentAiEngineStreamContent: typeof AgentAiEngineStreamContent;
|
|
8
|
+
declare const index_AgentInvocationRequest: typeof AgentInvocationRequest;
|
|
9
|
+
declare const index_AuditPort: typeof AuditPort;
|
|
10
|
+
declare const index_LlmCallOptions: typeof LlmCallOptions;
|
|
11
|
+
declare const index_LlmRequestMessage: typeof LlmRequestMessage;
|
|
12
|
+
declare const index_LlmResponseContent: typeof LlmResponseContent;
|
|
13
|
+
declare const index_LlmRetryConfig: typeof LlmRetryConfig;
|
|
14
|
+
declare const index_ProviderReasoningDetails: typeof ProviderReasoningDetails;
|
|
15
|
+
declare const index_TokenizerPort: typeof TokenizerPort;
|
|
16
|
+
declare const index_ToolCall: typeof ToolCall;
|
|
17
|
+
declare const index_ToolCallChunk: typeof ToolCallChunk;
|
|
18
|
+
declare const index_ToolCallExtraContent: typeof ToolCallExtraContent;
|
|
19
|
+
declare namespace index {
|
|
20
|
+
export { index_AgentAiEngine as AgentAiEngine, index_AgentAiEngineStreamContent as AgentAiEngineStreamContent, index_AgentInvocationRequest as AgentInvocationRequest, index_AuditPort as AuditPort, index_LlmCallOptions as LlmCallOptions, index_LlmRequestMessage as LlmRequestMessage, index_LlmResponseContent as LlmResponseContent, index_LlmRetryConfig as LlmRetryConfig, index_ProviderReasoningDetails as ProviderReasoningDetails, index_TokenizerPort as TokenizerPort, index_ToolCall as ToolCall, index_ToolCallChunk as ToolCallChunk, index_ToolCallExtraContent as ToolCallExtraContent };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { index as i };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { A as AgentInvocationRequest } from './agent-invocation-BznDaXDs.js';
|
|
2
|
+
import { A as AgentAiEngine, a as AgentAiEngineStreamContent, b as AuditPort } from './audit-CtcfART1.js';
|
|
3
|
+
import { T as TokenizerPort } from './tokenizer-DFL4I7-I.js';
|
|
4
|
+
import { L as LlmCallOptions, a as LlmRequestMessage, b as LlmResponseContent, c as LlmRetryConfig, P as ProviderReasoningDetails, T as ToolCall, d as ToolCallChunk, e as ToolCallExtraContent } from './ai-engine.types-vZRnQcJa.js';
|
|
5
|
+
|
|
6
|
+
declare const index_AgentAiEngine: typeof AgentAiEngine;
|
|
7
|
+
declare const index_AgentAiEngineStreamContent: typeof AgentAiEngineStreamContent;
|
|
8
|
+
declare const index_AgentInvocationRequest: typeof AgentInvocationRequest;
|
|
9
|
+
declare const index_AuditPort: typeof AuditPort;
|
|
10
|
+
declare const index_LlmCallOptions: typeof LlmCallOptions;
|
|
11
|
+
declare const index_LlmRequestMessage: typeof LlmRequestMessage;
|
|
12
|
+
declare const index_LlmResponseContent: typeof LlmResponseContent;
|
|
13
|
+
declare const index_LlmRetryConfig: typeof LlmRetryConfig;
|
|
14
|
+
declare const index_ProviderReasoningDetails: typeof ProviderReasoningDetails;
|
|
15
|
+
declare const index_TokenizerPort: typeof TokenizerPort;
|
|
16
|
+
declare const index_ToolCall: typeof ToolCall;
|
|
17
|
+
declare const index_ToolCallChunk: typeof ToolCallChunk;
|
|
18
|
+
declare const index_ToolCallExtraContent: typeof ToolCallExtraContent;
|
|
19
|
+
declare namespace index {
|
|
20
|
+
export { index_AgentAiEngine as AgentAiEngine, index_AgentAiEngineStreamContent as AgentAiEngineStreamContent, index_AgentInvocationRequest as AgentInvocationRequest, index_AuditPort as AuditPort, index_LlmCallOptions as LlmCallOptions, index_LlmRequestMessage as LlmRequestMessage, index_LlmResponseContent as LlmResponseContent, index_LlmRetryConfig as LlmRetryConfig, index_ProviderReasoningDetails as ProviderReasoningDetails, index_TokenizerPort as TokenizerPort, index_ToolCall as ToolCall, index_ToolCallChunk as ToolCallChunk, index_ToolCallExtraContent as ToolCallExtraContent };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { index as i };
|
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
import * as zod from 'zod';
|
|
2
|
+
import { A as AnyAgentEvent } from './agentEvents-DEB7Fy_J.cjs';
|
|
3
|
+
import { e as RuntimeEvent } from './todo-B1PmDlp3.cjs';
|
|
4
|
+
import { A as AiMessage } from './messages-XthmnHZ3.cjs';
|
|
5
|
+
import { a as ToolPresentationPort } from './ports-DaatKJXp.cjs';
|
|
6
|
+
import { a as SSEEvent } from './sse-vPyrOPa0.cjs';
|
|
7
|
+
|
|
8
|
+
interface EventMappingContext {
|
|
9
|
+
conversationId: string;
|
|
10
|
+
turnId: string;
|
|
11
|
+
timestamp?: number;
|
|
12
|
+
/**
|
|
13
|
+
* 事件级扩展元数据(透传到 SSE/RuntimeEvent.metadata)。
|
|
14
|
+
*
|
|
15
|
+
* 中文备注:这里只放跨事件归类信息,不放 ui.hidden 这类单事件展示语义。
|
|
16
|
+
*/
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
interface SSEMappingOptions {
|
|
20
|
+
emitSse?: boolean;
|
|
21
|
+
skipAlreadyDispatched?: boolean;
|
|
22
|
+
toolPresentationPort?: ToolPresentationPort;
|
|
23
|
+
}
|
|
24
|
+
interface RuntimeMappingOptions {
|
|
25
|
+
collectRuntime?: boolean;
|
|
26
|
+
skipIncomplete?: boolean;
|
|
27
|
+
toolPresentationPort?: ToolPresentationPort;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* RuntimeEvent 回放所需的最小会话内存端口。
|
|
31
|
+
*
|
|
32
|
+
* 中文备注:
|
|
33
|
+
* - core 只依赖“写入消息”的最小能力;
|
|
34
|
+
* - 具体产品实现只要结构兼容即可接入。
|
|
35
|
+
*/
|
|
36
|
+
interface ConversationMemoryPort {
|
|
37
|
+
addUserMessage(content: string, id?: string): void;
|
|
38
|
+
addAssistantMessage(content: string | null, type: AiMessage['type'] & ('thought' | 'final_answer' | 'tool_calls'), metadata?: AiMessage['metadata'], id?: string): void;
|
|
39
|
+
addToolResponse(toolCallId: string, content: string, toolName?: string, id?: string): void;
|
|
40
|
+
appendMessage(message: AiMessage): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare function agentEventToRuntime(agentEvent: AnyAgentEvent | RuntimeEvent, context: EventMappingContext, options?: RuntimeMappingOptions): RuntimeEvent | null;
|
|
44
|
+
|
|
45
|
+
declare function applyRuntimeEventToMemory(event: RuntimeEvent, memory: ConversationMemoryPort): void;
|
|
46
|
+
|
|
47
|
+
declare function agentEventToSSE(agentEvent: AnyAgentEvent, context: EventMappingContext, options?: SSEMappingOptions): SSEEvent | null;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 统一的事件映射器。
|
|
51
|
+
*
|
|
52
|
+
* 中文备注:
|
|
53
|
+
* - 保持旧调用方式 `eventMapper.xxx` 不变;
|
|
54
|
+
* - 新逻辑不要继续写回本文件,按职责放到拆分后的模块。
|
|
55
|
+
*/
|
|
56
|
+
declare const eventMapper: {
|
|
57
|
+
/**
|
|
58
|
+
* 将 AgentEvent 转换为 SSEEvent。
|
|
59
|
+
*/
|
|
60
|
+
agentToSse: typeof agentEventToSSE;
|
|
61
|
+
/**
|
|
62
|
+
* 将 AgentEvent 转换为 RuntimeEvent。
|
|
63
|
+
*/
|
|
64
|
+
agentToRuntime: typeof agentEventToRuntime;
|
|
65
|
+
/**
|
|
66
|
+
* 将 RuntimeEvent 应用到 ConversationMemoryPort。
|
|
67
|
+
*/
|
|
68
|
+
applyToMemory: typeof applyRuntimeEventToMemory;
|
|
69
|
+
/**
|
|
70
|
+
* 批量处理 AgentEvent → SSEEvent + RuntimeEvent。
|
|
71
|
+
*/
|
|
72
|
+
agentToBoth: (agentEvent: AnyAgentEvent, context: EventMappingContext, options?: {
|
|
73
|
+
sseOptions?: SSEMappingOptions;
|
|
74
|
+
runtimeOptions?: RuntimeMappingOptions;
|
|
75
|
+
}) => {
|
|
76
|
+
sseEvent: {
|
|
77
|
+
type: "thought";
|
|
78
|
+
id: string;
|
|
79
|
+
timestamp: number;
|
|
80
|
+
conversation_id: string;
|
|
81
|
+
turn_id: string;
|
|
82
|
+
is_complete: boolean;
|
|
83
|
+
content?: string | undefined;
|
|
84
|
+
metadata?: Record<string, unknown> | undefined;
|
|
85
|
+
thought_message_id?: string | undefined;
|
|
86
|
+
delta?: string | undefined;
|
|
87
|
+
} | {
|
|
88
|
+
type: "final_answer_chunk";
|
|
89
|
+
id: string;
|
|
90
|
+
timestamp: number;
|
|
91
|
+
conversation_id: string;
|
|
92
|
+
turn_id: string;
|
|
93
|
+
answer_id: string;
|
|
94
|
+
seq: number;
|
|
95
|
+
chunk: string;
|
|
96
|
+
metadata?: Record<string, unknown> | undefined;
|
|
97
|
+
is_last?: boolean | undefined;
|
|
98
|
+
} | {
|
|
99
|
+
type: "final_answer";
|
|
100
|
+
id: string;
|
|
101
|
+
content: string;
|
|
102
|
+
timestamp: number;
|
|
103
|
+
conversation_id: string;
|
|
104
|
+
turn_id: string;
|
|
105
|
+
answer_id: string;
|
|
106
|
+
metadata?: Record<string, unknown> | undefined;
|
|
107
|
+
meta?: Record<string, any> | undefined;
|
|
108
|
+
} | {
|
|
109
|
+
type: "markdown_chunk";
|
|
110
|
+
id: string;
|
|
111
|
+
timestamp: number;
|
|
112
|
+
conversation_id: string;
|
|
113
|
+
turn_id: string;
|
|
114
|
+
text: string;
|
|
115
|
+
content_type: "code" | "image" | "text" | "table";
|
|
116
|
+
metadata?: Record<string, unknown> | undefined;
|
|
117
|
+
seq?: number | undefined;
|
|
118
|
+
} | {
|
|
119
|
+
type: "tool_call_decision";
|
|
120
|
+
status: "error" | "loading" | "success";
|
|
121
|
+
id: string;
|
|
122
|
+
tool_name: string;
|
|
123
|
+
tool_call_id: string;
|
|
124
|
+
timestamp: number;
|
|
125
|
+
conversation_id: string;
|
|
126
|
+
turn_id: string;
|
|
127
|
+
phase: "start" | "update" | "complete" | "error";
|
|
128
|
+
args?: any;
|
|
129
|
+
metadata?: Record<string, unknown> | undefined;
|
|
130
|
+
payload?: any;
|
|
131
|
+
meta?: Record<string, any> | undefined;
|
|
132
|
+
} | {
|
|
133
|
+
type: "tool_process";
|
|
134
|
+
status: "error" | "loading" | "success";
|
|
135
|
+
id: string;
|
|
136
|
+
tool_name: string;
|
|
137
|
+
tool_call_id: string;
|
|
138
|
+
timestamp: number;
|
|
139
|
+
conversation_id: string;
|
|
140
|
+
turn_id: string;
|
|
141
|
+
phase: "start" | "update" | "complete" | "error";
|
|
142
|
+
args?: any;
|
|
143
|
+
metadata?: Record<string, unknown> | undefined;
|
|
144
|
+
payload?: any;
|
|
145
|
+
meta?: Record<string, any> | undefined;
|
|
146
|
+
} | {
|
|
147
|
+
type: "tool_output";
|
|
148
|
+
status: "error" | "success";
|
|
149
|
+
id: string;
|
|
150
|
+
tool_name: string;
|
|
151
|
+
tool_call_id: string;
|
|
152
|
+
timestamp: number;
|
|
153
|
+
conversation_id: string;
|
|
154
|
+
turn_id: string;
|
|
155
|
+
metadata?: Record<string, unknown> | undefined;
|
|
156
|
+
payload?: Record<string, any> | undefined;
|
|
157
|
+
output?: any;
|
|
158
|
+
duration_ms?: number | undefined;
|
|
159
|
+
} | {
|
|
160
|
+
type: "todo_updated";
|
|
161
|
+
id: string;
|
|
162
|
+
timestamp: number;
|
|
163
|
+
conversation_id: string;
|
|
164
|
+
turn_id: string;
|
|
165
|
+
todo_list_id: string;
|
|
166
|
+
todo_list_version: number;
|
|
167
|
+
items: {
|
|
168
|
+
status: "in_progress" | "completed" | "cancelled" | "pending";
|
|
169
|
+
id: string;
|
|
170
|
+
content: string;
|
|
171
|
+
}[];
|
|
172
|
+
metadata?: Record<string, unknown> | undefined;
|
|
173
|
+
} | {
|
|
174
|
+
type: "subrun_trace";
|
|
175
|
+
id: string;
|
|
176
|
+
timestamp: number;
|
|
177
|
+
kind: "final_answer" | "tool_output" | "tool_call_decision" | "tool_process" | "thought_delta" | "thought_complete" | "final_answer_chunk";
|
|
178
|
+
conversation_id: string;
|
|
179
|
+
turn_id: string;
|
|
180
|
+
parent_tool_call_id: string;
|
|
181
|
+
subrun_id: string;
|
|
182
|
+
status?: "error" | "loading" | "success" | undefined;
|
|
183
|
+
tool_name?: string | undefined;
|
|
184
|
+
args?: unknown;
|
|
185
|
+
tool_call_id?: string | undefined;
|
|
186
|
+
content?: string | undefined;
|
|
187
|
+
metadata?: Record<string, unknown> | undefined;
|
|
188
|
+
delta?: string | undefined;
|
|
189
|
+
phase?: "start" | "update" | "complete" | "error" | undefined;
|
|
190
|
+
meta?: Record<string, unknown> | undefined;
|
|
191
|
+
output?: unknown;
|
|
192
|
+
duration_ms?: number | undefined;
|
|
193
|
+
subrun_parent_id?: string | undefined;
|
|
194
|
+
} | {
|
|
195
|
+
type: "requires_user_interaction";
|
|
196
|
+
id: string;
|
|
197
|
+
timestamp: number;
|
|
198
|
+
conversation_id: string;
|
|
199
|
+
turn_id: string;
|
|
200
|
+
metadata?: Record<string, unknown> | undefined;
|
|
201
|
+
form?: any;
|
|
202
|
+
interaction_type?: string | undefined;
|
|
203
|
+
prompt?: string | undefined;
|
|
204
|
+
} | {
|
|
205
|
+
type: "error";
|
|
206
|
+
id: string;
|
|
207
|
+
timestamp: number;
|
|
208
|
+
conversation_id: string;
|
|
209
|
+
turn_id: string;
|
|
210
|
+
error: string;
|
|
211
|
+
metadata?: Record<string, unknown> | undefined;
|
|
212
|
+
details?: any;
|
|
213
|
+
error_code?: string | undefined;
|
|
214
|
+
retryable?: boolean | undefined;
|
|
215
|
+
} | {
|
|
216
|
+
type: "stream_end";
|
|
217
|
+
id: string;
|
|
218
|
+
timestamp: number;
|
|
219
|
+
conversation_id: string;
|
|
220
|
+
turn_id: string;
|
|
221
|
+
metadata?: Record<string, unknown> | undefined;
|
|
222
|
+
reason?: "complete" | "error" | "interrupted" | "timeout" | undefined;
|
|
223
|
+
reason_message?: string | undefined;
|
|
224
|
+
stats?: {
|
|
225
|
+
duration_ms?: number | undefined;
|
|
226
|
+
total_events?: number | undefined;
|
|
227
|
+
error_count?: number | undefined;
|
|
228
|
+
benchmark?: Record<string, unknown> | undefined;
|
|
229
|
+
} | undefined;
|
|
230
|
+
} | {
|
|
231
|
+
type: "history_summary";
|
|
232
|
+
id: string;
|
|
233
|
+
content: string;
|
|
234
|
+
timestamp: number;
|
|
235
|
+
conversation_id: string;
|
|
236
|
+
turn_id: string;
|
|
237
|
+
summary_seq: number;
|
|
238
|
+
original_message_count: number;
|
|
239
|
+
summary_id: string;
|
|
240
|
+
metadata?: Record<string, unknown> | undefined;
|
|
241
|
+
} | {
|
|
242
|
+
type: "summarization_start";
|
|
243
|
+
id: string;
|
|
244
|
+
timestamp: number;
|
|
245
|
+
conversation_id: string;
|
|
246
|
+
turn_id: string;
|
|
247
|
+
metadata?: Record<string, unknown> | undefined;
|
|
248
|
+
originalMessages?: number | undefined;
|
|
249
|
+
} | {
|
|
250
|
+
type: "summarization_end";
|
|
251
|
+
id: string;
|
|
252
|
+
timestamp: number;
|
|
253
|
+
conversation_id: string;
|
|
254
|
+
turn_id: string;
|
|
255
|
+
compressionRatio?: string | undefined;
|
|
256
|
+
metadata?: Record<string, unknown> | undefined;
|
|
257
|
+
originalMessages?: number | undefined;
|
|
258
|
+
compressedMessages?: number | undefined;
|
|
259
|
+
timeSaved?: string | undefined;
|
|
260
|
+
} | {
|
|
261
|
+
type: "summarization_error";
|
|
262
|
+
id: string;
|
|
263
|
+
timestamp: number;
|
|
264
|
+
conversation_id: string;
|
|
265
|
+
turn_id: string;
|
|
266
|
+
error: string;
|
|
267
|
+
metadata?: Record<string, unknown> | undefined;
|
|
268
|
+
} | null;
|
|
269
|
+
runtimeEvent: {
|
|
270
|
+
type: "user_input";
|
|
271
|
+
id: string;
|
|
272
|
+
content: string;
|
|
273
|
+
timestamp: number;
|
|
274
|
+
version: 1;
|
|
275
|
+
conversation_id: string;
|
|
276
|
+
turn_id: string;
|
|
277
|
+
source: "system" | "user" | "editor";
|
|
278
|
+
metadata?: Record<string, unknown> | undefined;
|
|
279
|
+
ephemeral?: boolean | undefined;
|
|
280
|
+
raw_content?: string | undefined;
|
|
281
|
+
} | {
|
|
282
|
+
type: "thought";
|
|
283
|
+
id: string;
|
|
284
|
+
content: string;
|
|
285
|
+
timestamp: number;
|
|
286
|
+
version: 1;
|
|
287
|
+
conversation_id: string;
|
|
288
|
+
turn_id: string;
|
|
289
|
+
is_complete: boolean;
|
|
290
|
+
metadata?: Record<string, unknown> | undefined;
|
|
291
|
+
ephemeral?: boolean | undefined;
|
|
292
|
+
thought_message_id?: string | undefined;
|
|
293
|
+
delta?: string | undefined;
|
|
294
|
+
} | {
|
|
295
|
+
type: "tool_call_decision";
|
|
296
|
+
status: "error" | "loading" | "success";
|
|
297
|
+
id: string;
|
|
298
|
+
tool_name: string;
|
|
299
|
+
tool_call_id: string;
|
|
300
|
+
timestamp: number;
|
|
301
|
+
version: 1;
|
|
302
|
+
conversation_id: string;
|
|
303
|
+
turn_id: string;
|
|
304
|
+
phase: "start" | "update" | "complete" | "error";
|
|
305
|
+
args?: Record<string, any> | undefined;
|
|
306
|
+
metadata?: Record<string, unknown> | undefined;
|
|
307
|
+
ephemeral?: boolean | undefined;
|
|
308
|
+
payload?: zod.objectOutputType<{
|
|
309
|
+
args: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodAny>>;
|
|
310
|
+
tool_calls: zod.ZodOptional<zod.ZodArray<zod.ZodUnknown, "many">>;
|
|
311
|
+
reasoning_details: zod.ZodOptional<zod.ZodArray<zod.ZodUnknown, "many">>;
|
|
312
|
+
}, zod.ZodTypeAny, "passthrough"> | undefined;
|
|
313
|
+
parent_tool_call_id?: string | undefined;
|
|
314
|
+
meta?: Record<string, any> | undefined;
|
|
315
|
+
} | {
|
|
316
|
+
type: "tool_process";
|
|
317
|
+
status: "error" | "loading" | "success";
|
|
318
|
+
id: string;
|
|
319
|
+
tool_name: string;
|
|
320
|
+
tool_call_id: string;
|
|
321
|
+
timestamp: number;
|
|
322
|
+
version: 1;
|
|
323
|
+
conversation_id: string;
|
|
324
|
+
turn_id: string;
|
|
325
|
+
phase: "start" | "update" | "complete" | "error";
|
|
326
|
+
args?: Record<string, any> | undefined;
|
|
327
|
+
metadata?: Record<string, unknown> | undefined;
|
|
328
|
+
ephemeral?: boolean | undefined;
|
|
329
|
+
payload?: Record<string, any> | undefined;
|
|
330
|
+
parent_tool_call_id?: string | undefined;
|
|
331
|
+
meta?: Record<string, any> | undefined;
|
|
332
|
+
} | {
|
|
333
|
+
type: "tool_output";
|
|
334
|
+
status: "error" | "success";
|
|
335
|
+
id: string;
|
|
336
|
+
tool_name: string;
|
|
337
|
+
tool_call_id: string;
|
|
338
|
+
timestamp: number;
|
|
339
|
+
version: 1;
|
|
340
|
+
conversation_id: string;
|
|
341
|
+
turn_id: string;
|
|
342
|
+
metadata?: Record<string, unknown> | undefined;
|
|
343
|
+
ephemeral?: boolean | undefined;
|
|
344
|
+
error?: string | undefined;
|
|
345
|
+
payload?: Record<string, any> | undefined;
|
|
346
|
+
output?: any;
|
|
347
|
+
duration_ms?: number | undefined;
|
|
348
|
+
} | {
|
|
349
|
+
type: "todo_updated";
|
|
350
|
+
id: string;
|
|
351
|
+
timestamp: number;
|
|
352
|
+
version: 1;
|
|
353
|
+
conversation_id: string;
|
|
354
|
+
turn_id: string;
|
|
355
|
+
todo_list_id: string;
|
|
356
|
+
todo_list_version: number;
|
|
357
|
+
items: {
|
|
358
|
+
status: "in_progress" | "completed" | "cancelled" | "pending";
|
|
359
|
+
id: string;
|
|
360
|
+
content: string;
|
|
361
|
+
}[];
|
|
362
|
+
metadata?: Record<string, unknown> | undefined;
|
|
363
|
+
ephemeral?: boolean | undefined;
|
|
364
|
+
} | {
|
|
365
|
+
type: "subrun_trace";
|
|
366
|
+
id: string;
|
|
367
|
+
timestamp: number;
|
|
368
|
+
kind: "final_answer" | "tool_output" | "tool_call_decision" | "tool_process" | "thought_delta" | "thought_complete" | "final_answer_chunk";
|
|
369
|
+
version: 1;
|
|
370
|
+
conversation_id: string;
|
|
371
|
+
turn_id: string;
|
|
372
|
+
parent_tool_call_id: string;
|
|
373
|
+
subrun_id: string;
|
|
374
|
+
status?: "error" | "loading" | "success" | undefined;
|
|
375
|
+
tool_name?: string | undefined;
|
|
376
|
+
args?: unknown;
|
|
377
|
+
tool_call_id?: string | undefined;
|
|
378
|
+
content?: string | undefined;
|
|
379
|
+
metadata?: Record<string, unknown> | undefined;
|
|
380
|
+
ephemeral?: boolean | undefined;
|
|
381
|
+
delta?: string | undefined;
|
|
382
|
+
phase?: "start" | "update" | "complete" | "error" | undefined;
|
|
383
|
+
meta?: Record<string, unknown> | undefined;
|
|
384
|
+
output?: unknown;
|
|
385
|
+
duration_ms?: number | undefined;
|
|
386
|
+
subrun_parent_id?: string | undefined;
|
|
387
|
+
} | {
|
|
388
|
+
type: "requires_user_interaction";
|
|
389
|
+
id: string;
|
|
390
|
+
timestamp: number;
|
|
391
|
+
version: 1;
|
|
392
|
+
conversation_id: string;
|
|
393
|
+
turn_id: string;
|
|
394
|
+
metadata?: Record<string, unknown> | undefined;
|
|
395
|
+
ephemeral?: boolean | undefined;
|
|
396
|
+
form?: any;
|
|
397
|
+
interaction_type?: string | undefined;
|
|
398
|
+
prompt?: string | undefined;
|
|
399
|
+
} | {
|
|
400
|
+
type: "audit_envelope";
|
|
401
|
+
id: string;
|
|
402
|
+
timestamp: number;
|
|
403
|
+
version: 1;
|
|
404
|
+
conversation_id: string;
|
|
405
|
+
turn_id: string;
|
|
406
|
+
envelope: {
|
|
407
|
+
runId: string;
|
|
408
|
+
envelopeId: string;
|
|
409
|
+
ts: number;
|
|
410
|
+
actor: {
|
|
411
|
+
kind: "system" | "user" | "tool" | "agent" | "host" | "model";
|
|
412
|
+
id?: string | undefined;
|
|
413
|
+
name?: string | undefined;
|
|
414
|
+
};
|
|
415
|
+
action: string;
|
|
416
|
+
parentRunId?: string | undefined;
|
|
417
|
+
decision?: {
|
|
418
|
+
outcome: "requested" | "allowed" | "denied" | "fallback" | "retry" | "cancelled" | "paused" | "resumed" | "recorded";
|
|
419
|
+
metadata?: Record<string, unknown> | undefined;
|
|
420
|
+
reason?: string | undefined;
|
|
421
|
+
policy?: string | undefined;
|
|
422
|
+
} | undefined;
|
|
423
|
+
evidence?: {
|
|
424
|
+
kind: string;
|
|
425
|
+
summary?: string | undefined;
|
|
426
|
+
metadata?: Record<string, unknown> | undefined;
|
|
427
|
+
ref?: string | undefined;
|
|
428
|
+
}[] | undefined;
|
|
429
|
+
costDelta?: {
|
|
430
|
+
tokensInput?: number | undefined;
|
|
431
|
+
tokensOutput?: number | undefined;
|
|
432
|
+
totalCostUsd?: number | undefined;
|
|
433
|
+
latencyMs?: number | undefined;
|
|
434
|
+
} | undefined;
|
|
435
|
+
scope?: {
|
|
436
|
+
metadata?: Record<string, unknown> | undefined;
|
|
437
|
+
toolName?: string | undefined;
|
|
438
|
+
conversationId?: string | undefined;
|
|
439
|
+
runId?: string | undefined;
|
|
440
|
+
parentRunId?: string | undefined;
|
|
441
|
+
turnId?: string | undefined;
|
|
442
|
+
traceId?: string | undefined;
|
|
443
|
+
agentSpecId?: string | undefined;
|
|
444
|
+
toolCallId?: string | undefined;
|
|
445
|
+
modelId?: string | undefined;
|
|
446
|
+
nodeId?: string | undefined;
|
|
447
|
+
} | undefined;
|
|
448
|
+
};
|
|
449
|
+
metadata?: Record<string, unknown> | undefined;
|
|
450
|
+
ephemeral?: boolean | undefined;
|
|
451
|
+
} | {
|
|
452
|
+
type: "final_answer";
|
|
453
|
+
id: string;
|
|
454
|
+
content: string;
|
|
455
|
+
timestamp: number;
|
|
456
|
+
version: 1;
|
|
457
|
+
conversation_id: string;
|
|
458
|
+
turn_id: string;
|
|
459
|
+
is_complete: boolean;
|
|
460
|
+
answer_id: string;
|
|
461
|
+
reasoning_details?: unknown[] | undefined;
|
|
462
|
+
metadata?: Record<string, unknown> | undefined;
|
|
463
|
+
ephemeral?: boolean | undefined;
|
|
464
|
+
meta?: Record<string, any> | undefined;
|
|
465
|
+
} | {
|
|
466
|
+
type: "final_answer_chunk";
|
|
467
|
+
id: string;
|
|
468
|
+
content: string;
|
|
469
|
+
timestamp: number;
|
|
470
|
+
version: 1;
|
|
471
|
+
conversation_id: string;
|
|
472
|
+
turn_id: string;
|
|
473
|
+
answer_id: string;
|
|
474
|
+
seq: number;
|
|
475
|
+
metadata?: Record<string, unknown> | undefined;
|
|
476
|
+
ephemeral?: boolean | undefined;
|
|
477
|
+
is_last?: boolean | undefined;
|
|
478
|
+
} | {
|
|
479
|
+
type: "history_summary";
|
|
480
|
+
id: string;
|
|
481
|
+
content: string;
|
|
482
|
+
timestamp: number;
|
|
483
|
+
version: 1;
|
|
484
|
+
conversation_id: string;
|
|
485
|
+
turn_id: string;
|
|
486
|
+
replaced_message_ids: string[];
|
|
487
|
+
summary_seq: number;
|
|
488
|
+
metadata?: Record<string, unknown> | undefined;
|
|
489
|
+
ephemeral?: boolean | undefined;
|
|
490
|
+
original_message_count?: number | undefined;
|
|
491
|
+
compression_ratio?: number | undefined;
|
|
492
|
+
included_old_summary?: boolean | undefined;
|
|
493
|
+
} | {
|
|
494
|
+
type: "error";
|
|
495
|
+
id: string;
|
|
496
|
+
timestamp: number;
|
|
497
|
+
version: 1;
|
|
498
|
+
conversation_id: string;
|
|
499
|
+
turn_id: string;
|
|
500
|
+
error: string;
|
|
501
|
+
metadata?: Record<string, unknown> | undefined;
|
|
502
|
+
ephemeral?: boolean | undefined;
|
|
503
|
+
details?: any;
|
|
504
|
+
error_code?: string | undefined;
|
|
505
|
+
retryable?: boolean | undefined;
|
|
506
|
+
} | {
|
|
507
|
+
type: "control";
|
|
508
|
+
id: string;
|
|
509
|
+
timestamp: number;
|
|
510
|
+
version: 1;
|
|
511
|
+
conversation_id: string;
|
|
512
|
+
turn_id: string;
|
|
513
|
+
op: "truncate_after" | "replace" | "redo" | "branch";
|
|
514
|
+
metadata?: Record<string, unknown> | undefined;
|
|
515
|
+
reason?: string | undefined;
|
|
516
|
+
ephemeral?: boolean | undefined;
|
|
517
|
+
meta?: any;
|
|
518
|
+
target_id?: string | undefined;
|
|
519
|
+
} | {
|
|
520
|
+
type: "stream_end";
|
|
521
|
+
id: string;
|
|
522
|
+
timestamp: number;
|
|
523
|
+
version: 1;
|
|
524
|
+
conversation_id: string;
|
|
525
|
+
turn_id: string;
|
|
526
|
+
metadata?: Record<string, unknown> | undefined;
|
|
527
|
+
reason?: "complete" | "error" | "interrupted" | "timeout" | undefined;
|
|
528
|
+
ephemeral?: boolean | undefined;
|
|
529
|
+
reason_message?: string | undefined;
|
|
530
|
+
stats?: {
|
|
531
|
+
duration_ms?: number | undefined;
|
|
532
|
+
total_events?: number | undefined;
|
|
533
|
+
error_count?: number | undefined;
|
|
534
|
+
} | undefined;
|
|
535
|
+
} | null;
|
|
536
|
+
};
|
|
537
|
+
/**
|
|
538
|
+
* 批量重建内存。
|
|
539
|
+
*/
|
|
540
|
+
rebuildMemory: (events: RuntimeEvent[], memory: ConversationMemoryPort) => void;
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
type RuntimeEventUiProjectionKind = 'hidden' | 'user_input' | 'thought' | 'final_answer' | 'final_answer_chunk' | 'tool_call_decision' | 'tool_process' | 'tool_output' | 'requires_user_interaction' | 'audit_envelope' | 'todo_updated' | 'subrun_trace' | 'error' | 'stream_end' | 'history_summary' | 'checkpoint_history_summary' | 'unsupported';
|
|
544
|
+
type RuntimeEventRealtimeChannel = 'event_bus_sse' | 'none';
|
|
545
|
+
interface RuntimeEventLifecycleDecision {
|
|
546
|
+
uiProjectionKind: RuntimeEventUiProjectionKind;
|
|
547
|
+
persist: boolean;
|
|
548
|
+
replayToUi: boolean;
|
|
549
|
+
enterAgentContext: boolean;
|
|
550
|
+
realtimeChannel: RuntimeEventRealtimeChannel;
|
|
551
|
+
}
|
|
552
|
+
declare function isToolCallDecisionEvent<T extends {
|
|
553
|
+
type: string;
|
|
554
|
+
}>(event: T): event is T & {
|
|
555
|
+
type: 'tool_call_decision';
|
|
556
|
+
};
|
|
557
|
+
declare function shouldPersistRuntimeEvent(event: RuntimeEvent): boolean;
|
|
558
|
+
declare function shouldReplayRuntimeEventToUi(event: RuntimeEvent): boolean;
|
|
559
|
+
declare function shouldEnterAgentContext(event: RuntimeEvent): boolean;
|
|
560
|
+
declare function isCheckpointHistorySummaryEvent(event: RuntimeEvent): event is Extract<RuntimeEvent, {
|
|
561
|
+
type: 'history_summary';
|
|
562
|
+
}>;
|
|
563
|
+
declare function getRuntimeEventUiProjectionKind(event: RuntimeEvent): RuntimeEventUiProjectionKind;
|
|
564
|
+
declare function describeRuntimeEventLifecycle(event: RuntimeEvent): RuntimeEventLifecycleDecision;
|
|
565
|
+
declare function shouldEmitRuntimeEventToSse(event: RuntimeEvent): boolean;
|
|
566
|
+
|
|
567
|
+
declare const index_AnyAgentEvent: typeof AnyAgentEvent;
|
|
568
|
+
type index_ConversationMemoryPort = ConversationMemoryPort;
|
|
569
|
+
type index_EventMappingContext = EventMappingContext;
|
|
570
|
+
type index_RuntimeEventLifecycleDecision = RuntimeEventLifecycleDecision;
|
|
571
|
+
declare const index_describeRuntimeEventLifecycle: typeof describeRuntimeEventLifecycle;
|
|
572
|
+
declare const index_eventMapper: typeof eventMapper;
|
|
573
|
+
declare const index_getRuntimeEventUiProjectionKind: typeof getRuntimeEventUiProjectionKind;
|
|
574
|
+
declare const index_isCheckpointHistorySummaryEvent: typeof isCheckpointHistorySummaryEvent;
|
|
575
|
+
declare const index_isToolCallDecisionEvent: typeof isToolCallDecisionEvent;
|
|
576
|
+
declare const index_shouldEmitRuntimeEventToSse: typeof shouldEmitRuntimeEventToSse;
|
|
577
|
+
declare const index_shouldEnterAgentContext: typeof shouldEnterAgentContext;
|
|
578
|
+
declare const index_shouldPersistRuntimeEvent: typeof shouldPersistRuntimeEvent;
|
|
579
|
+
declare const index_shouldReplayRuntimeEventToUi: typeof shouldReplayRuntimeEventToUi;
|
|
580
|
+
declare namespace index {
|
|
581
|
+
export { index_AnyAgentEvent as AnyAgentEvent, type index_ConversationMemoryPort as ConversationMemoryPort, type index_EventMappingContext as EventMappingContext, type index_RuntimeEventLifecycleDecision as RuntimeEventLifecycleDecision, index_describeRuntimeEventLifecycle as describeRuntimeEventLifecycle, index_eventMapper as eventMapper, index_getRuntimeEventUiProjectionKind as getRuntimeEventUiProjectionKind, index_isCheckpointHistorySummaryEvent as isCheckpointHistorySummaryEvent, index_isToolCallDecisionEvent as isToolCallDecisionEvent, index_shouldEmitRuntimeEventToSse as shouldEmitRuntimeEventToSse, index_shouldEnterAgentContext as shouldEnterAgentContext, index_shouldPersistRuntimeEvent as shouldPersistRuntimeEvent, index_shouldReplayRuntimeEventToUi as shouldReplayRuntimeEventToUi };
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export { type ConversationMemoryPort as C, type EventMappingContext as E, type RuntimeEventLifecycleDecision as R, isCheckpointHistorySummaryEvent as a, isToolCallDecisionEvent as b, shouldEnterAgentContext as c, describeRuntimeEventLifecycle as d, eventMapper as e, shouldPersistRuntimeEvent as f, getRuntimeEventUiProjectionKind as g, shouldReplayRuntimeEventToUi as h, index as i, shouldEmitRuntimeEventToSse as s };
|