@rivus/agent 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 +22 -0
- package/README.md +1051 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +22 -0
- package/dist/index.d.ts +3423 -0
- package/dist/index.js +7337 -0
- package/dist/rivus-daemon-cli.js +2599 -0
- package/dist/rivus-plugin-registry.js +316 -0
- package/dist/rivus-plugin-testkit.d.ts +291 -0
- package/dist/rivus-plugin-testkit.js +62 -0
- package/dist/testing/index.d.ts +55 -0
- package/dist/testing/index.js +94 -0
- package/examples/current-weather.mjs +143 -0
- package/examples/html-drive-tools.mjs +262 -0
- package/examples/langfuse-drive-e2e.mjs +175 -0
- package/examples/pi-feishu-deployment.bootstrap.ts +542 -0
- package/examples/pi-feishu.bootstrap.ts +225 -0
- package/examples/rivus-agents.plugin.mjs +238 -0
- package/examples/rivus-langfuse-demo.config.json +36 -0
- package/examples/rivus.config.json +83 -0
- package/package.json +112 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3423 @@
|
|
|
1
|
+
import { A as RivusToolExecutionContext, B as AgentMemorySnapshot, C as RivusPluginCatalogSnapshot, D as RivusSkillDescriptor, E as RivusResolvedToolDescriptor, F as RivusToolInputRejected, G as MemoryScope, H as MemoryBinding, I as RivusToolRisk, J as RIVUS_MEMORY_TOOL_PLUGIN_ID, K as MemoryState, L as requiresToolApproval, M as RivusToolFactoryContext, N as RivusToolGrantSet, O as RivusSkillGrantSet, P as RivusToolIdempotency, Q as restrictMemoryScopesForAudience, R as AgentMemoryAuthority, S as RivusPluginCatalog, T as RivusPluginRegistry, U as MemoryInvocationAudience, V as MEMORY_SCOPES, W as MemoryRecord, X as createMemoryNamespace, Y as RIVUS_MEMORY_TOOL_VERSION, Z as createRivusMemoryToolContract, _ as RivusAutomationInput, a as assertRivusPluginConforms, b as RivusHostToolDescriptor, c as RIVUS_PLUGIN_API_VERSION, d as RegisteredRivusPlugin, f as RegisteredRivusSkill, g as RivusAgentProfile, h as RivusAgentDeployment, i as RivusPluginLifecycleProbe, j as RivusToolExecutor, k as RivusToolDescriptor, l as RegisteredRivusAgentProfile, m as ResolvedRivusAgentDefinition, n as RivusPluginConformanceInput, o as createFakeRivusPlugin, p as RegisteredRivusTool, q as RIVUS_MEMORY_TOOL_ID, r as RivusPluginConformanceReport, s as InvalidRivusPlugin, t as RivusPluginConformanceError, u as RegisteredRivusAutomation, v as RivusAutomationTemplate, w as RivusPluginManifest, x as RivusPlugin, y as RivusAutomationTickContext, z as AgentMemoryIdentity } from "./rivus-plugin-testkit.js";
|
|
2
|
+
import { Effect, Stream } from "effect";
|
|
3
|
+
import { Tracer } from "@opentelemetry/api";
|
|
4
|
+
import { ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
|
|
6
|
+
//#region src/domain/agent-invocation.d.ts
|
|
7
|
+
type AgentMemoryInvocationIdentity = AgentMemoryIdentity;
|
|
8
|
+
interface FeishuAgentInvocationOrigin {
|
|
9
|
+
readonly allowedActorOpenIds: ReadonlyArray<string>;
|
|
10
|
+
readonly endpointId: string;
|
|
11
|
+
readonly kind: "feishu";
|
|
12
|
+
readonly memory?: AgentMemoryInvocationIdentity;
|
|
13
|
+
readonly sourceMessageId: string;
|
|
14
|
+
readonly tenantKey: string;
|
|
15
|
+
}
|
|
16
|
+
interface LocalCliAgentInvocationOrigin {
|
|
17
|
+
readonly allowedActorOpenIds: readonly [];
|
|
18
|
+
readonly endpointId: string;
|
|
19
|
+
readonly kind: "local-cli";
|
|
20
|
+
readonly memory?: AgentMemoryInvocationIdentity;
|
|
21
|
+
readonly sourceMessageId: string;
|
|
22
|
+
readonly tenantKey: "local";
|
|
23
|
+
}
|
|
24
|
+
interface AutomationAgentInvocationOrigin {
|
|
25
|
+
readonly allowedActorOpenIds: readonly [];
|
|
26
|
+
readonly automationId: string;
|
|
27
|
+
readonly endpointId: string;
|
|
28
|
+
readonly kind: "automation";
|
|
29
|
+
readonly memory?: AgentMemoryInvocationIdentity;
|
|
30
|
+
readonly sourceMessageId: string;
|
|
31
|
+
readonly tenantKey: "automation";
|
|
32
|
+
readonly tickId: string;
|
|
33
|
+
}
|
|
34
|
+
type AgentInvocationOrigin = FeishuAgentInvocationOrigin | LocalCliAgentInvocationOrigin | AutomationAgentInvocationOrigin;
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/domain/agent-events.d.ts
|
|
37
|
+
type AgentRunId = string;
|
|
38
|
+
type SessionKey = string;
|
|
39
|
+
interface AgentRunAccepted {
|
|
40
|
+
readonly type: "agent_run_accepted";
|
|
41
|
+
readonly runId: AgentRunId;
|
|
42
|
+
readonly sessionKey: SessionKey;
|
|
43
|
+
readonly prompt: string;
|
|
44
|
+
readonly occurredAt: Date;
|
|
45
|
+
}
|
|
46
|
+
interface AgentTurnStarted {
|
|
47
|
+
readonly type: "agent_turn_started";
|
|
48
|
+
readonly runId: AgentRunId;
|
|
49
|
+
readonly sessionKey: SessionKey;
|
|
50
|
+
readonly occurredAt: Date;
|
|
51
|
+
}
|
|
52
|
+
interface AssistantTextDelta {
|
|
53
|
+
readonly type: "assistant_text_delta";
|
|
54
|
+
readonly runId: AgentRunId;
|
|
55
|
+
readonly delta: string;
|
|
56
|
+
readonly occurredAt: Date;
|
|
57
|
+
}
|
|
58
|
+
interface AssistantThinkingDelta {
|
|
59
|
+
readonly type: "assistant_thinking_delta";
|
|
60
|
+
readonly runId: AgentRunId;
|
|
61
|
+
readonly delta: string;
|
|
62
|
+
readonly occurredAt: Date;
|
|
63
|
+
}
|
|
64
|
+
interface AgentModelExecutionStarted {
|
|
65
|
+
readonly type: "agent_model_execution_started";
|
|
66
|
+
readonly api: string;
|
|
67
|
+
readonly model: string;
|
|
68
|
+
readonly modelCallId: string;
|
|
69
|
+
readonly occurredAt: Date;
|
|
70
|
+
readonly provider: string;
|
|
71
|
+
readonly runId: AgentRunId;
|
|
72
|
+
}
|
|
73
|
+
interface AgentModelUsage {
|
|
74
|
+
readonly cacheRead: number;
|
|
75
|
+
readonly cacheWrite: number;
|
|
76
|
+
readonly cost: number;
|
|
77
|
+
readonly input: number;
|
|
78
|
+
readonly output: number;
|
|
79
|
+
readonly reasoning?: number;
|
|
80
|
+
readonly total: number;
|
|
81
|
+
}
|
|
82
|
+
interface AgentModelExecutionEnded {
|
|
83
|
+
readonly type: "agent_model_execution_ended";
|
|
84
|
+
readonly api: string;
|
|
85
|
+
readonly errorMessage?: string;
|
|
86
|
+
readonly model: string;
|
|
87
|
+
readonly modelCallId: string;
|
|
88
|
+
readonly occurredAt: Date;
|
|
89
|
+
readonly provider: string;
|
|
90
|
+
readonly responseModel?: string;
|
|
91
|
+
readonly runId: AgentRunId;
|
|
92
|
+
readonly stopReason: string;
|
|
93
|
+
readonly usage: AgentModelUsage;
|
|
94
|
+
}
|
|
95
|
+
interface AgentSkillExecutionStarted {
|
|
96
|
+
readonly type: "agent_skill_execution_started";
|
|
97
|
+
readonly occurredAt: Date;
|
|
98
|
+
readonly runId: AgentRunId;
|
|
99
|
+
readonly skillCallId: string;
|
|
100
|
+
readonly skillId: string;
|
|
101
|
+
}
|
|
102
|
+
interface AgentSkillExecutionSucceeded {
|
|
103
|
+
readonly type: "agent_skill_execution_ended";
|
|
104
|
+
readonly contentLength: number;
|
|
105
|
+
readonly digest: string;
|
|
106
|
+
readonly isError: false;
|
|
107
|
+
readonly occurredAt: Date;
|
|
108
|
+
readonly runId: AgentRunId;
|
|
109
|
+
readonly skillCallId: string;
|
|
110
|
+
readonly skillId: string;
|
|
111
|
+
readonly title: string;
|
|
112
|
+
readonly version: string;
|
|
113
|
+
}
|
|
114
|
+
interface AgentSkillExecutionFailed {
|
|
115
|
+
readonly type: "agent_skill_execution_ended";
|
|
116
|
+
readonly isError: true;
|
|
117
|
+
readonly occurredAt: Date;
|
|
118
|
+
readonly runId: AgentRunId;
|
|
119
|
+
readonly skillCallId: string;
|
|
120
|
+
readonly skillId: string;
|
|
121
|
+
}
|
|
122
|
+
type AgentSkillExecutionEnded = AgentSkillExecutionSucceeded | AgentSkillExecutionFailed;
|
|
123
|
+
interface AgentToolExecutionStarted {
|
|
124
|
+
readonly type: "agent_tool_execution_started";
|
|
125
|
+
readonly runId: AgentRunId;
|
|
126
|
+
readonly toolCallId: string;
|
|
127
|
+
readonly toolName: string;
|
|
128
|
+
readonly input: unknown;
|
|
129
|
+
readonly occurredAt: Date;
|
|
130
|
+
}
|
|
131
|
+
interface AgentToolExecutionUpdated {
|
|
132
|
+
readonly type: "agent_tool_execution_updated";
|
|
133
|
+
readonly runId: AgentRunId;
|
|
134
|
+
readonly toolCallId: string;
|
|
135
|
+
readonly toolName: string;
|
|
136
|
+
readonly input: unknown;
|
|
137
|
+
readonly partialResult: unknown;
|
|
138
|
+
readonly occurredAt: Date;
|
|
139
|
+
}
|
|
140
|
+
interface AgentToolExecutionEnded {
|
|
141
|
+
readonly type: "agent_tool_execution_ended";
|
|
142
|
+
readonly runId: AgentRunId;
|
|
143
|
+
readonly toolCallId: string;
|
|
144
|
+
readonly toolName: string;
|
|
145
|
+
readonly result: unknown;
|
|
146
|
+
readonly isError: boolean;
|
|
147
|
+
readonly occurredAt: Date;
|
|
148
|
+
}
|
|
149
|
+
interface AgentTurnCompleted {
|
|
150
|
+
readonly type: "agent_turn_completed";
|
|
151
|
+
readonly runId: AgentRunId;
|
|
152
|
+
readonly finalText: string;
|
|
153
|
+
readonly occurredAt: Date;
|
|
154
|
+
}
|
|
155
|
+
interface AgentRunCompleted {
|
|
156
|
+
readonly type: "agent_run_completed";
|
|
157
|
+
readonly runId: AgentRunId;
|
|
158
|
+
readonly finalText: string;
|
|
159
|
+
readonly occurredAt: Date;
|
|
160
|
+
}
|
|
161
|
+
interface AgentRunFailed {
|
|
162
|
+
readonly type: "agent_run_failed";
|
|
163
|
+
readonly runId: AgentRunId;
|
|
164
|
+
readonly errorMessage: string;
|
|
165
|
+
readonly occurredAt: Date;
|
|
166
|
+
}
|
|
167
|
+
interface AgentRunCancelled$1 {
|
|
168
|
+
readonly type: "agent_run_cancelled";
|
|
169
|
+
readonly runId: AgentRunId;
|
|
170
|
+
readonly reason?: string;
|
|
171
|
+
readonly occurredAt: Date;
|
|
172
|
+
}
|
|
173
|
+
type AgentDomainEvent = AgentRunAccepted | AgentTurnStarted | AssistantTextDelta | AssistantThinkingDelta | AgentModelExecutionStarted | AgentModelExecutionEnded | AgentSkillExecutionStarted | AgentSkillExecutionEnded | AgentToolExecutionStarted | AgentToolExecutionUpdated | AgentToolExecutionEnded | AgentTurnCompleted | AgentRunCompleted | AgentRunFailed | AgentRunCancelled$1;
|
|
174
|
+
type AgentToolExecutionEvent = AgentToolExecutionStarted | AgentToolExecutionUpdated | AgentToolExecutionEnded;
|
|
175
|
+
type AgentModelExecutionEvent = AgentModelExecutionStarted | AgentModelExecutionEnded;
|
|
176
|
+
type TerminalAgentDomainEvent = AgentRunCompleted | AgentRunFailed | AgentRunCancelled$1;
|
|
177
|
+
declare function isAssistantTextDeltaEvent(event: AgentDomainEvent): event is AssistantTextDelta;
|
|
178
|
+
declare function isAssistantThinkingDeltaEvent(event: AgentDomainEvent): event is AssistantThinkingDelta;
|
|
179
|
+
declare function isAgentToolExecutionEvent(event: AgentDomainEvent): event is AgentToolExecutionEvent;
|
|
180
|
+
declare function isTerminalAgentDomainEvent(event: AgentDomainEvent): event is TerminalAgentDomainEvent;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/domain/agent-run-state.d.ts
|
|
183
|
+
type AgentRunPhase = "idle" | "accepted" | "running" | "completed" | "failed" | "cancelled";
|
|
184
|
+
interface AgentRunState {
|
|
185
|
+
readonly phase: AgentRunPhase;
|
|
186
|
+
readonly runId?: AgentRunId;
|
|
187
|
+
readonly sessionKey?: SessionKey;
|
|
188
|
+
readonly prompt?: string;
|
|
189
|
+
readonly finalText: string;
|
|
190
|
+
readonly errorMessage?: string;
|
|
191
|
+
readonly cancellationReason?: string;
|
|
192
|
+
readonly thinkingText?: string;
|
|
193
|
+
readonly skillExecutions: Readonly<Record<string, AgentSkillExecutionState>>;
|
|
194
|
+
readonly toolExecutions: Readonly<Record<string, AgentToolExecutionState>>;
|
|
195
|
+
}
|
|
196
|
+
interface AgentSkillExecutionState {
|
|
197
|
+
readonly contentLength?: number;
|
|
198
|
+
readonly digest?: string;
|
|
199
|
+
readonly isError?: boolean;
|
|
200
|
+
readonly skillCallId: string;
|
|
201
|
+
readonly skillId: string;
|
|
202
|
+
readonly status: "running" | "completed";
|
|
203
|
+
readonly title?: string;
|
|
204
|
+
readonly version?: string;
|
|
205
|
+
}
|
|
206
|
+
interface AgentToolExecutionState {
|
|
207
|
+
readonly toolCallId: string;
|
|
208
|
+
readonly toolName: string;
|
|
209
|
+
readonly input: unknown;
|
|
210
|
+
readonly partialResult?: unknown;
|
|
211
|
+
readonly result?: unknown;
|
|
212
|
+
readonly isError?: boolean;
|
|
213
|
+
readonly status: "running" | "completed";
|
|
214
|
+
}
|
|
215
|
+
declare const initialAgentRunState: AgentRunState;
|
|
216
|
+
declare function isTerminalAgentRunPhase(phase: AgentRunPhase): boolean;
|
|
217
|
+
declare function evolveAgentRun(state: AgentRunState, event: AgentDomainEvent): AgentRunState;
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/domain/agent-history.d.ts
|
|
220
|
+
interface AgentRunSummary {
|
|
221
|
+
readonly acceptedAt?: Date;
|
|
222
|
+
readonly cancellationReason?: string;
|
|
223
|
+
readonly cancelledAt?: Date;
|
|
224
|
+
readonly completedAt?: Date;
|
|
225
|
+
readonly errorMessage?: string;
|
|
226
|
+
readonly eventCount: number;
|
|
227
|
+
readonly failedToolExecutionCount: number;
|
|
228
|
+
readonly failedSkillExecutionCount: number;
|
|
229
|
+
readonly failedAt?: Date;
|
|
230
|
+
readonly finalText: string;
|
|
231
|
+
readonly phase: AgentRunPhase;
|
|
232
|
+
readonly prompt?: string;
|
|
233
|
+
readonly runId: AgentRunId;
|
|
234
|
+
readonly sessionKey?: SessionKey;
|
|
235
|
+
readonly startedAt?: Date;
|
|
236
|
+
readonly state: AgentRunState;
|
|
237
|
+
readonly thinkingText: string;
|
|
238
|
+
readonly skillExecutionCount: number;
|
|
239
|
+
readonly toolExecutionCount: number;
|
|
240
|
+
readonly updatedAt: Date;
|
|
241
|
+
}
|
|
242
|
+
interface AgentSessionSummary {
|
|
243
|
+
readonly failedToolExecutionCount: number;
|
|
244
|
+
readonly failedSkillExecutionCount: number;
|
|
245
|
+
readonly finalText: string;
|
|
246
|
+
readonly latestPhase: AgentRunPhase;
|
|
247
|
+
readonly latestRunId: AgentRunId;
|
|
248
|
+
readonly runCount: number;
|
|
249
|
+
readonly runIds: ReadonlyArray<AgentRunId>;
|
|
250
|
+
readonly sessionKey: SessionKey;
|
|
251
|
+
readonly thinkingText: string;
|
|
252
|
+
readonly skillExecutionCount: number;
|
|
253
|
+
readonly toolExecutionCount: number;
|
|
254
|
+
readonly updatedAt: Date;
|
|
255
|
+
}
|
|
256
|
+
interface AgentHistory {
|
|
257
|
+
readonly runs: ReadonlyArray<AgentRunSummary>;
|
|
258
|
+
readonly sessions: ReadonlyArray<AgentSessionSummary>;
|
|
259
|
+
readonly totalEvents: number;
|
|
260
|
+
}
|
|
261
|
+
declare function replayAgentHistory(events: ReadonlyArray<AgentDomainEvent>): AgentHistory;
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/domain/agent-transcript.d.ts
|
|
264
|
+
interface AgentTranscript {
|
|
265
|
+
readonly latestTurn?: AgentTranscriptTurn;
|
|
266
|
+
readonly sessionKey: SessionKey;
|
|
267
|
+
readonly turnCount: number;
|
|
268
|
+
readonly turns: ReadonlyArray<AgentTranscriptTurn>;
|
|
269
|
+
}
|
|
270
|
+
interface AgentTranscriptTurn {
|
|
271
|
+
readonly acceptedAt?: Date;
|
|
272
|
+
readonly assistantText: string;
|
|
273
|
+
readonly cancellationReason?: string;
|
|
274
|
+
readonly cancelledAt?: Date;
|
|
275
|
+
readonly completedAt?: Date;
|
|
276
|
+
readonly errorMessage?: string;
|
|
277
|
+
readonly failedAt?: Date;
|
|
278
|
+
readonly failedToolExecutionCount: number;
|
|
279
|
+
readonly phase: AgentRunPhase;
|
|
280
|
+
readonly runId: AgentRunId;
|
|
281
|
+
readonly sessionKey: SessionKey;
|
|
282
|
+
readonly thinkingText: string;
|
|
283
|
+
readonly toolExecutionCount: number;
|
|
284
|
+
readonly updatedAt: Date;
|
|
285
|
+
readonly userText: string;
|
|
286
|
+
}
|
|
287
|
+
type AgentTranscriptMessageRole = "assistant" | "user";
|
|
288
|
+
interface AgentTranscriptMessage {
|
|
289
|
+
readonly content: string;
|
|
290
|
+
readonly role: AgentTranscriptMessageRole;
|
|
291
|
+
}
|
|
292
|
+
interface AgentConversationMessagesOptions {
|
|
293
|
+
readonly text: string;
|
|
294
|
+
readonly transcript?: AgentTranscript;
|
|
295
|
+
}
|
|
296
|
+
declare function replayAgentTranscript(events: ReadonlyArray<AgentDomainEvent>, sessionKey: SessionKey): AgentTranscript;
|
|
297
|
+
declare function createAgentTranscriptTurn(summary: AgentRunSummary & {
|
|
298
|
+
readonly sessionKey: SessionKey;
|
|
299
|
+
}): AgentTranscriptTurn;
|
|
300
|
+
declare function createAgentTranscriptMessages(transcript: AgentTranscript): ReadonlyArray<AgentTranscriptMessage>;
|
|
301
|
+
declare function createAgentConversationMessages(options: AgentConversationMessagesOptions): ReadonlyArray<AgentTranscriptMessage>;
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/application/agent/agent-loop.d.ts
|
|
304
|
+
interface AgentLoopInput {
|
|
305
|
+
readonly abortSignal: AbortSignal;
|
|
306
|
+
readonly invocation?: AgentInvocationOrigin;
|
|
307
|
+
readonly messages?: ReadonlyArray<AgentTranscriptMessage>;
|
|
308
|
+
readonly runId: AgentRunId;
|
|
309
|
+
readonly sessionKey: SessionKey;
|
|
310
|
+
readonly text: string;
|
|
311
|
+
readonly previousSessionState?: AgentRunState;
|
|
312
|
+
readonly previousSessionTranscript?: AgentTranscript;
|
|
313
|
+
}
|
|
314
|
+
type AgentLoopEvent = AgentLoopTextDelta | AgentLoopThinkingDelta | AgentLoopModelExecutionStart | AgentLoopModelExecutionEnd | AgentLoopSkillExecutionStart | AgentLoopSkillExecutionEnd | AgentLoopToolExecutionStart | AgentLoopToolExecutionUpdate | AgentLoopToolExecutionEnd;
|
|
315
|
+
type AgentLoopEventLike = AgentLoopEvent | string;
|
|
316
|
+
interface AgentLoopTextDelta {
|
|
317
|
+
readonly type: "assistant_text_delta";
|
|
318
|
+
readonly delta: string;
|
|
319
|
+
}
|
|
320
|
+
interface AgentLoopThinkingDelta {
|
|
321
|
+
readonly type: "assistant_thinking_delta";
|
|
322
|
+
readonly delta: string;
|
|
323
|
+
}
|
|
324
|
+
interface AgentLoopModelExecutionStart {
|
|
325
|
+
readonly type: "model_execution_start";
|
|
326
|
+
readonly api: string;
|
|
327
|
+
readonly model: string;
|
|
328
|
+
readonly modelCallId: string;
|
|
329
|
+
readonly provider: string;
|
|
330
|
+
}
|
|
331
|
+
interface AgentLoopModelExecutionEnd {
|
|
332
|
+
readonly type: "model_execution_end";
|
|
333
|
+
readonly api: string;
|
|
334
|
+
readonly errorMessage?: string;
|
|
335
|
+
readonly model: string;
|
|
336
|
+
readonly modelCallId: string;
|
|
337
|
+
readonly provider: string;
|
|
338
|
+
readonly responseModel?: string;
|
|
339
|
+
readonly stopReason: string;
|
|
340
|
+
readonly usage: AgentModelUsage;
|
|
341
|
+
}
|
|
342
|
+
interface AgentLoopSkillExecutionStart {
|
|
343
|
+
readonly type: "skill_execution_start";
|
|
344
|
+
readonly skillCallId: string;
|
|
345
|
+
readonly skillId: string;
|
|
346
|
+
}
|
|
347
|
+
interface AgentLoopSkillExecutionSucceeded {
|
|
348
|
+
readonly type: "skill_execution_end";
|
|
349
|
+
readonly contentLength: number;
|
|
350
|
+
readonly digest: string;
|
|
351
|
+
readonly isError: false;
|
|
352
|
+
readonly skillCallId: string;
|
|
353
|
+
readonly skillId: string;
|
|
354
|
+
readonly title: string;
|
|
355
|
+
readonly version: string;
|
|
356
|
+
}
|
|
357
|
+
interface AgentLoopSkillExecutionFailed {
|
|
358
|
+
readonly type: "skill_execution_end";
|
|
359
|
+
readonly isError: true;
|
|
360
|
+
readonly skillCallId: string;
|
|
361
|
+
readonly skillId: string;
|
|
362
|
+
}
|
|
363
|
+
type AgentLoopSkillExecutionEnd = AgentLoopSkillExecutionSucceeded | AgentLoopSkillExecutionFailed;
|
|
364
|
+
interface AgentLoopToolExecutionStart {
|
|
365
|
+
readonly type: "tool_execution_start";
|
|
366
|
+
readonly toolCallId: string;
|
|
367
|
+
readonly toolName: string;
|
|
368
|
+
readonly input: unknown;
|
|
369
|
+
}
|
|
370
|
+
interface AgentLoopToolExecutionUpdate {
|
|
371
|
+
readonly type: "tool_execution_update";
|
|
372
|
+
readonly toolCallId: string;
|
|
373
|
+
readonly toolName: string;
|
|
374
|
+
readonly input: unknown;
|
|
375
|
+
readonly partialResult: unknown;
|
|
376
|
+
}
|
|
377
|
+
interface AgentLoopToolExecutionEnd {
|
|
378
|
+
readonly type: "tool_execution_end";
|
|
379
|
+
readonly toolCallId: string;
|
|
380
|
+
readonly toolName: string;
|
|
381
|
+
readonly result: unknown;
|
|
382
|
+
readonly isError: boolean;
|
|
383
|
+
}
|
|
384
|
+
interface AgentLoop {
|
|
385
|
+
run(input: AgentLoopInput): Stream.Stream<AgentLoopEvent, unknown>;
|
|
386
|
+
}
|
|
387
|
+
type AgentLoopCallbackOutput = Iterable<AgentLoopEventLike> | AsyncIterable<AgentLoopEventLike> | Stream.Stream<AgentLoopEventLike, unknown>;
|
|
388
|
+
type AgentLoopCallbackResult = AgentLoopCallbackOutput | PromiseLike<AgentLoopCallbackOutput> | Effect.Effect<AgentLoopCallbackOutput, unknown>;
|
|
389
|
+
type AgentLoopCallback = (input: AgentLoopInput) => AgentLoopCallbackResult;
|
|
390
|
+
interface AsyncIterableAgentLoopOptions {
|
|
391
|
+
readonly run: (input: AgentLoopInput) => AsyncIterable<AgentLoopEventLike>;
|
|
392
|
+
}
|
|
393
|
+
interface EventAgentLoopOptions {
|
|
394
|
+
readonly events: ReadonlyArray<AgentLoopEventLike> | ((input: AgentLoopInput) => ReadonlyArray<AgentLoopEventLike> | Promise<ReadonlyArray<AgentLoopEventLike>>);
|
|
395
|
+
}
|
|
396
|
+
interface TextAgentLoopOptions {
|
|
397
|
+
readonly generate: (input: AgentLoopInput) => Effect.Effect<string, unknown>;
|
|
398
|
+
}
|
|
399
|
+
type TextAgentLoopCallback = (input: AgentLoopInput) => string | Promise<string>;
|
|
400
|
+
type AgentLoopToolExecutionStartOptions = Omit<AgentLoopToolExecutionStart, "type">;
|
|
401
|
+
type AgentLoopToolExecutionUpdateOptions = Omit<AgentLoopToolExecutionUpdate, "type">;
|
|
402
|
+
type AgentLoopToolExecutionEndOptions = Omit<AgentLoopToolExecutionEnd, "type">;
|
|
403
|
+
type AgentLoopModelExecutionStartOptions = Omit<AgentLoopModelExecutionStart, "type">;
|
|
404
|
+
type AgentLoopModelExecutionEndOptions = Omit<AgentLoopModelExecutionEnd, "type">;
|
|
405
|
+
type AgentLoopSkillExecutionStartOptions = Omit<AgentLoopSkillExecutionStart, "type">;
|
|
406
|
+
type AgentLoopSkillExecutionEndOptions = Omit<AgentLoopSkillExecutionSucceeded, "type"> | Omit<AgentLoopSkillExecutionFailed, "type">;
|
|
407
|
+
declare function createAgentLoopTextDelta(delta: string): AgentLoopTextDelta;
|
|
408
|
+
declare function createAgentLoopThinkingDelta(delta: string): AgentLoopThinkingDelta;
|
|
409
|
+
declare function createAgentLoopModelExecutionStart(options: AgentLoopModelExecutionStartOptions): AgentLoopModelExecutionStart;
|
|
410
|
+
declare function createAgentLoopModelExecutionEnd(options: AgentLoopModelExecutionEndOptions): AgentLoopModelExecutionEnd;
|
|
411
|
+
declare function createAgentLoopSkillExecutionStart(options: AgentLoopSkillExecutionStartOptions): AgentLoopSkillExecutionStart;
|
|
412
|
+
declare function createAgentLoopSkillExecutionEnd(options: AgentLoopSkillExecutionEndOptions): AgentLoopSkillExecutionEnd;
|
|
413
|
+
declare function createAgentLoopToolExecutionStart(options: AgentLoopToolExecutionStartOptions): AgentLoopToolExecutionStart;
|
|
414
|
+
declare function createAgentLoopToolExecutionUpdate(options: AgentLoopToolExecutionUpdateOptions): AgentLoopToolExecutionUpdate;
|
|
415
|
+
declare function createAgentLoopToolExecutionEnd(options: AgentLoopToolExecutionEndOptions): AgentLoopToolExecutionEnd;
|
|
416
|
+
declare function createEventAgentLoop(options: EventAgentLoopOptions): AgentLoop;
|
|
417
|
+
declare function createAsyncIterableAgentLoop(options: AsyncIterableAgentLoopOptions): AgentLoop;
|
|
418
|
+
declare function createAgentLoopFromCallback(run: AgentLoopCallback): AgentLoop;
|
|
419
|
+
declare function createTextAgentLoop(options: TextAgentLoopOptions): AgentLoop;
|
|
420
|
+
declare function createTextAgentLoopFromCallback(generate: TextAgentLoopCallback): AgentLoop;
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/application/agent/agent-harness.d.ts
|
|
423
|
+
interface AgentClock {
|
|
424
|
+
readonly now: Effect.Effect<Date>;
|
|
425
|
+
}
|
|
426
|
+
interface RunIdGenerator {
|
|
427
|
+
readonly next: Effect.Effect<AgentRunId>;
|
|
428
|
+
}
|
|
429
|
+
interface AgentHarnessOptions {
|
|
430
|
+
readonly clock: AgentClock;
|
|
431
|
+
readonly eventSinks?: ReadonlyArray<AgentDomainEventSink>;
|
|
432
|
+
readonly initialEvents?: ReadonlyArray<AgentDomainEvent>;
|
|
433
|
+
readonly initialRunStates?: ReadonlyArray<AgentRunState>;
|
|
434
|
+
readonly loop: AgentLoop;
|
|
435
|
+
readonly runIds: RunIdGenerator;
|
|
436
|
+
}
|
|
437
|
+
interface PromptCommand {
|
|
438
|
+
readonly invocation?: AgentInvocationOrigin;
|
|
439
|
+
readonly sessionKey: SessionKey;
|
|
440
|
+
readonly text: string;
|
|
441
|
+
}
|
|
442
|
+
interface AgentPromptResult {
|
|
443
|
+
readonly runId: AgentRunId;
|
|
444
|
+
readonly events: ReadonlyArray<AgentDomainEvent>;
|
|
445
|
+
readonly finalText: string;
|
|
446
|
+
readonly runSnapshot: AgentRunSnapshot;
|
|
447
|
+
readonly snapshot: AgentSessionSnapshot;
|
|
448
|
+
readonly state: AgentRunState;
|
|
449
|
+
readonly turn: AgentTranscriptTurn;
|
|
450
|
+
readonly updates: ReadonlyArray<AgentRunUpdate>;
|
|
451
|
+
}
|
|
452
|
+
interface AgentRunUpdate {
|
|
453
|
+
readonly event: AgentDomainEvent;
|
|
454
|
+
readonly previousState?: AgentRunState;
|
|
455
|
+
readonly state: AgentRunState;
|
|
456
|
+
}
|
|
457
|
+
interface AgentRunSnapshot {
|
|
458
|
+
readonly events: ReadonlyArray<AgentDomainEvent>;
|
|
459
|
+
readonly runId: AgentRunId;
|
|
460
|
+
readonly state?: AgentRunState;
|
|
461
|
+
readonly summary: AgentRunSummary;
|
|
462
|
+
readonly updates: ReadonlyArray<AgentRunUpdate>;
|
|
463
|
+
}
|
|
464
|
+
interface ActiveAgentRun {
|
|
465
|
+
readonly runId: AgentRunId;
|
|
466
|
+
readonly sessionKey: SessionKey;
|
|
467
|
+
}
|
|
468
|
+
type AgentHarnessAvailability = AgentHarnessIdleAvailability | AgentHarnessBusyAvailability;
|
|
469
|
+
type AgentSessionAvailability = AgentHarnessIdleAvailability | AgentSessionBusyAvailability;
|
|
470
|
+
interface AgentHarnessIdleAvailability {
|
|
471
|
+
readonly busy: false;
|
|
472
|
+
}
|
|
473
|
+
interface AgentHarnessBusyAvailability {
|
|
474
|
+
readonly activeRun: ActiveAgentRun;
|
|
475
|
+
readonly activeRunId: AgentRunId;
|
|
476
|
+
readonly activeSessionKey: SessionKey;
|
|
477
|
+
readonly activeState?: AgentRunState;
|
|
478
|
+
readonly busy: true;
|
|
479
|
+
}
|
|
480
|
+
type AgentSessionBusyAvailability = AgentSessionOwnedBusyAvailability | AgentSessionOtherBusyAvailability;
|
|
481
|
+
interface AgentSessionOwnedBusyAvailability {
|
|
482
|
+
readonly activeInSession: true;
|
|
483
|
+
readonly activeRun: ActiveAgentRun;
|
|
484
|
+
readonly activeRunId: AgentRunId;
|
|
485
|
+
readonly activeState?: AgentRunState;
|
|
486
|
+
readonly busy: true;
|
|
487
|
+
}
|
|
488
|
+
interface AgentSessionOtherBusyAvailability {
|
|
489
|
+
readonly activeInSession: false;
|
|
490
|
+
readonly busy: true;
|
|
491
|
+
}
|
|
492
|
+
interface AgentSessionSnapshot {
|
|
493
|
+
readonly availability: AgentSessionAvailability;
|
|
494
|
+
readonly latestRunSummary?: AgentRunSummary;
|
|
495
|
+
readonly runs: ReadonlyArray<AgentRunSummary>;
|
|
496
|
+
readonly sessionKey: SessionKey;
|
|
497
|
+
readonly state?: AgentRunState;
|
|
498
|
+
readonly summary?: AgentSessionSummary;
|
|
499
|
+
readonly transcript: AgentTranscript;
|
|
500
|
+
}
|
|
501
|
+
declare class AgentHarnessBusy {
|
|
502
|
+
readonly activeRun: ActiveAgentRun;
|
|
503
|
+
readonly activeState?: AgentRunState | undefined;
|
|
504
|
+
readonly _tag = "AgentHarnessBusy";
|
|
505
|
+
readonly activeRunId: AgentRunId;
|
|
506
|
+
readonly activeSessionKey: SessionKey;
|
|
507
|
+
constructor(activeRun: ActiveAgentRun, activeState?: AgentRunState | undefined);
|
|
508
|
+
}
|
|
509
|
+
declare class AgentLoopFailed {
|
|
510
|
+
readonly runId: AgentRunId;
|
|
511
|
+
readonly errorMessage: string;
|
|
512
|
+
readonly cause: unknown;
|
|
513
|
+
readonly state?: AgentRunState | undefined;
|
|
514
|
+
readonly _tag = "AgentLoopFailed";
|
|
515
|
+
constructor(runId: AgentRunId, errorMessage: string, cause: unknown, state?: AgentRunState | undefined);
|
|
516
|
+
}
|
|
517
|
+
declare class AgentEventSinkFailed {
|
|
518
|
+
readonly runId: AgentRunId;
|
|
519
|
+
readonly eventType: AgentDomainEvent["type"];
|
|
520
|
+
readonly cause: unknown;
|
|
521
|
+
readonly _tag = "AgentEventSinkFailed";
|
|
522
|
+
constructor(runId: AgentRunId, eventType: AgentDomainEvent["type"], cause: unknown);
|
|
523
|
+
}
|
|
524
|
+
declare class AgentEventHandlerFailed {
|
|
525
|
+
readonly runId: AgentRunId;
|
|
526
|
+
readonly eventType: AgentDomainEvent["type"];
|
|
527
|
+
readonly cause: unknown;
|
|
528
|
+
readonly state?: AgentRunState | undefined;
|
|
529
|
+
readonly _tag = "AgentEventHandlerFailed";
|
|
530
|
+
constructor(runId: AgentRunId, eventType: AgentDomainEvent["type"], cause: unknown, state?: AgentRunState | undefined);
|
|
531
|
+
}
|
|
532
|
+
declare class AgentRunCancelled {
|
|
533
|
+
readonly runId: AgentRunId;
|
|
534
|
+
readonly reason: string | undefined;
|
|
535
|
+
readonly state: AgentRunState;
|
|
536
|
+
readonly _tag = "AgentRunCancelled";
|
|
537
|
+
constructor(runId: AgentRunId, reason: string | undefined, state: AgentRunState);
|
|
538
|
+
}
|
|
539
|
+
type AgentHarnessError = AgentHarnessBusy | AgentLoopFailed | AgentEventSinkFailed | AgentEventHandlerFailed | AgentRunCancelled;
|
|
540
|
+
interface AgentHarness {
|
|
541
|
+
cancelActiveRun(reason?: string): Effect.Effect<boolean>;
|
|
542
|
+
cancelRun(runId: AgentRunId, reason?: string): Effect.Effect<boolean>;
|
|
543
|
+
forSession(sessionKey: SessionKey): AgentSessionHandle;
|
|
544
|
+
getActiveRun(): ActiveAgentRun | undefined;
|
|
545
|
+
getActiveRunId(): AgentRunId | undefined;
|
|
546
|
+
getActiveRunState(): AgentRunState | undefined;
|
|
547
|
+
getAvailability(): AgentHarnessAvailability;
|
|
548
|
+
getHistory(): AgentHistory;
|
|
549
|
+
getRunEvents(runId: AgentRunId): ReadonlyArray<AgentDomainEvent> | undefined;
|
|
550
|
+
getRunSnapshot(runId: AgentRunId): AgentRunSnapshot | undefined;
|
|
551
|
+
getRunSummary(runId: AgentRunId): AgentRunSummary | undefined;
|
|
552
|
+
getRunState(runId: AgentRunId): AgentRunState | undefined;
|
|
553
|
+
getRunUpdates(runId: AgentRunId): ReadonlyArray<AgentRunUpdate> | undefined;
|
|
554
|
+
getSessionHistory(sessionKey: SessionKey): AgentHistory;
|
|
555
|
+
getSessionLatestRunSnapshot(sessionKey: SessionKey): AgentRunSnapshot | undefined;
|
|
556
|
+
getSessionLatestRunSummary(sessionKey: SessionKey): AgentRunSummary | undefined;
|
|
557
|
+
getSessionRuns(sessionKey: SessionKey): ReadonlyArray<AgentRunSummary>;
|
|
558
|
+
getSessionSnapshot(sessionKey: SessionKey): AgentSessionSnapshot;
|
|
559
|
+
getSessionSummary(sessionKey: SessionKey): AgentSessionSummary | undefined;
|
|
560
|
+
getSessionTranscript(sessionKey: SessionKey): AgentTranscript;
|
|
561
|
+
getSessionState(sessionKey: SessionKey): AgentRunState | undefined;
|
|
562
|
+
getState(): AgentRunState;
|
|
563
|
+
prompt(command: PromptCommand): Effect.Effect<AgentPromptResult, AgentHarnessError>;
|
|
564
|
+
promptRunSnapshot(command: PromptCommand): Effect.Effect<AgentRunSnapshot, AgentHarnessError>;
|
|
565
|
+
promptSnapshot(command: PromptCommand): Effect.Effect<AgentSessionSnapshot, AgentHarnessError>;
|
|
566
|
+
promptText(command: PromptCommand): Effect.Effect<string, AgentHarnessError>;
|
|
567
|
+
promptTurn(command: PromptCommand): Effect.Effect<AgentTranscriptTurn, AgentHarnessError>;
|
|
568
|
+
promptWithEvents<R>(command: PromptCommand, onEvent: AgentDomainEventHandler<R>): Effect.Effect<AgentPromptResult, AgentHarnessError, R>;
|
|
569
|
+
promptWithUpdates<R>(command: PromptCommand, onUpdate: AgentRunUpdateHandler<R>): Effect.Effect<AgentPromptResult, AgentHarnessError, R>;
|
|
570
|
+
stream(command: PromptCommand): Stream.Stream<AgentDomainEvent, AgentHarnessError>;
|
|
571
|
+
streamText(command: PromptCommand): Stream.Stream<string, AgentHarnessError>;
|
|
572
|
+
streamUpdates(command: PromptCommand): Stream.Stream<AgentRunUpdate, AgentHarnessError>;
|
|
573
|
+
subscribe(listener: AgentDomainEventListener): () => void;
|
|
574
|
+
subscribeRun(runId: AgentRunId, listener: AgentDomainEventListener): () => void;
|
|
575
|
+
subscribeRunUpdates(runId: AgentRunId, listener: AgentRunUpdateListener): () => void;
|
|
576
|
+
subscribeUpdates(listener: AgentRunUpdateListener): () => void;
|
|
577
|
+
}
|
|
578
|
+
interface AgentSessionHandle {
|
|
579
|
+
readonly sessionKey: SessionKey;
|
|
580
|
+
cancelActiveRun(reason?: string): Effect.Effect<boolean>;
|
|
581
|
+
cancelRun(runId: AgentRunId, reason?: string): Effect.Effect<boolean>;
|
|
582
|
+
getActiveRun(): ActiveAgentRun | undefined;
|
|
583
|
+
getActiveRunState(): AgentRunState | undefined;
|
|
584
|
+
getAvailability(): AgentSessionAvailability;
|
|
585
|
+
getHistory(): AgentHistory;
|
|
586
|
+
getLatestRunSnapshot(): AgentRunSnapshot | undefined;
|
|
587
|
+
getLatestRunSummary(): AgentRunSummary | undefined;
|
|
588
|
+
getRunEvents(runId: AgentRunId): ReadonlyArray<AgentDomainEvent> | undefined;
|
|
589
|
+
getRunSnapshot(runId: AgentRunId): AgentRunSnapshot | undefined;
|
|
590
|
+
getRunSummary(runId: AgentRunId): AgentRunSummary | undefined;
|
|
591
|
+
getRuns(): ReadonlyArray<AgentRunSummary>;
|
|
592
|
+
getSnapshot(): AgentSessionSnapshot;
|
|
593
|
+
getSummary(): AgentSessionSummary | undefined;
|
|
594
|
+
getTranscript(): AgentTranscript;
|
|
595
|
+
getRunState(runId: AgentRunId): AgentRunState | undefined;
|
|
596
|
+
getRunUpdates(runId: AgentRunId): ReadonlyArray<AgentRunUpdate> | undefined;
|
|
597
|
+
getState(): AgentRunState | undefined;
|
|
598
|
+
prompt(text: string): Effect.Effect<AgentPromptResult, AgentHarnessError>;
|
|
599
|
+
promptRunSnapshot(text: string): Effect.Effect<AgentRunSnapshot, AgentHarnessError>;
|
|
600
|
+
promptSnapshot(text: string): Effect.Effect<AgentSessionSnapshot, AgentHarnessError>;
|
|
601
|
+
promptText(text: string): Effect.Effect<string, AgentHarnessError>;
|
|
602
|
+
promptTurn(text: string): Effect.Effect<AgentTranscriptTurn, AgentHarnessError>;
|
|
603
|
+
promptWithEvents<R>(text: string, onEvent: AgentDomainEventHandler<R>): Effect.Effect<AgentPromptResult, AgentHarnessError, R>;
|
|
604
|
+
promptWithUpdates<R>(text: string, onUpdate: AgentRunUpdateHandler<R>): Effect.Effect<AgentPromptResult, AgentHarnessError, R>;
|
|
605
|
+
stream(text: string): Stream.Stream<AgentDomainEvent, AgentHarnessError>;
|
|
606
|
+
streamText(text: string): Stream.Stream<string, AgentHarnessError>;
|
|
607
|
+
streamUpdates(text: string): Stream.Stream<AgentRunUpdate, AgentHarnessError>;
|
|
608
|
+
subscribe(listener: AgentDomainEventListener): () => void;
|
|
609
|
+
subscribeRun(runId: AgentRunId, listener: AgentDomainEventListener): () => void;
|
|
610
|
+
subscribeRunUpdates(runId: AgentRunId, listener: AgentRunUpdateListener): () => void;
|
|
611
|
+
subscribeUpdates(listener: AgentRunUpdateListener): () => void;
|
|
612
|
+
}
|
|
613
|
+
type AgentDomainEventListener = (event: AgentDomainEvent) => void;
|
|
614
|
+
type AgentRunUpdateListener = (update: AgentRunUpdate) => void;
|
|
615
|
+
type AgentDomainEventCallback = (event: AgentDomainEvent) => void | Promise<void>;
|
|
616
|
+
type AgentDomainEventHandler<R = never> = (event: AgentDomainEvent) => Effect.Effect<void, unknown, R>;
|
|
617
|
+
type AgentRunUpdateCallback = (update: AgentRunUpdate) => void | Promise<void>;
|
|
618
|
+
type AgentRunUpdateHandler<R = never> = (update: AgentRunUpdate) => Effect.Effect<void, unknown, R>;
|
|
619
|
+
interface AgentDomainEventSink {
|
|
620
|
+
append(event: AgentDomainEvent): Effect.Effect<void, unknown>;
|
|
621
|
+
}
|
|
622
|
+
type AgentDomainEventSinkCallback = (event: AgentDomainEvent) => void | Promise<void>;
|
|
623
|
+
declare function createAgentDomainEventSink(append: (event: AgentDomainEvent) => Effect.Effect<void, unknown>): AgentDomainEventSink;
|
|
624
|
+
declare function createAgentDomainEventSinkFromCallback(append: AgentDomainEventSinkCallback): AgentDomainEventSink;
|
|
625
|
+
declare function createAgentDomainEventHandler(handle: AgentDomainEventCallback): AgentDomainEventHandler;
|
|
626
|
+
declare function createAgentRunUpdateHandler(handle: AgentRunUpdateCallback): AgentRunUpdateHandler;
|
|
627
|
+
declare function createAgentHarness(options: AgentHarnessOptions): AgentHarness;
|
|
628
|
+
//#endregion
|
|
629
|
+
//#region src/application/feishu/feishu-stream-projector.d.ts
|
|
630
|
+
type FeishuStreamAction = {
|
|
631
|
+
readonly type: "update_text";
|
|
632
|
+
readonly runId: AgentRunId;
|
|
633
|
+
readonly text: string;
|
|
634
|
+
} | {
|
|
635
|
+
readonly type: "finish";
|
|
636
|
+
readonly runId: AgentRunId;
|
|
637
|
+
readonly text: string;
|
|
638
|
+
} | {
|
|
639
|
+
readonly type: "fail";
|
|
640
|
+
readonly runId: AgentRunId;
|
|
641
|
+
readonly errorMessage: string;
|
|
642
|
+
} | {
|
|
643
|
+
readonly type: "cancel";
|
|
644
|
+
readonly runId: AgentRunId;
|
|
645
|
+
readonly reason?: string;
|
|
646
|
+
};
|
|
647
|
+
interface FeishuStreamProjector {
|
|
648
|
+
apply(event: AgentDomainEvent): ReadonlyArray<FeishuStreamAction>;
|
|
649
|
+
applyUpdate(update: AgentRunUpdate): ReadonlyArray<FeishuStreamAction>;
|
|
650
|
+
}
|
|
651
|
+
declare function createFeishuStreamProjector(): FeishuStreamProjector;
|
|
652
|
+
//#endregion
|
|
653
|
+
//#region src/application/feishu/feishu-card-delivery-ledger.d.ts
|
|
654
|
+
interface FeishuCardDeliveryRecord {
|
|
655
|
+
readonly revision: number;
|
|
656
|
+
readonly runId: AgentRunId;
|
|
657
|
+
readonly sequence: number;
|
|
658
|
+
readonly terminalPublished: boolean;
|
|
659
|
+
}
|
|
660
|
+
interface FeishuCardDeliveryLedger {
|
|
661
|
+
isTerminalPublished(runId: AgentRunId): boolean;
|
|
662
|
+
markTerminal(runId: AgentRunId): Effect.Effect<void, unknown>;
|
|
663
|
+
reserveSequence(runId: AgentRunId): Effect.Effect<number, unknown>;
|
|
664
|
+
}
|
|
665
|
+
interface FeishuCardDeliveryLedgerStateOptions {
|
|
666
|
+
readonly initial?: ReadonlyArray<FeishuCardDeliveryRecord>;
|
|
667
|
+
readonly persist?: (record: FeishuCardDeliveryRecord) => Promise<void>;
|
|
668
|
+
}
|
|
669
|
+
interface FeishuCardDeliveryReconciler {
|
|
670
|
+
reconcile(): Effect.Effect<{
|
|
671
|
+
readonly repaired: number;
|
|
672
|
+
readonly terminalRuns: number;
|
|
673
|
+
}, unknown>;
|
|
674
|
+
}
|
|
675
|
+
interface FeishuCardDeliveryReconcilerOptions {
|
|
676
|
+
readonly events: ReadonlyArray<AgentDomainEvent>;
|
|
677
|
+
readonly ledger: FeishuCardDeliveryLedger;
|
|
678
|
+
readonly publish: (action: FeishuStreamAction) => Effect.Effect<void, unknown>;
|
|
679
|
+
}
|
|
680
|
+
declare function createFeishuCardDeliveryLedger(options?: FeishuCardDeliveryLedgerStateOptions): FeishuCardDeliveryLedger;
|
|
681
|
+
declare function createFeishuCardDeliveryReconciler(options: FeishuCardDeliveryReconcilerOptions): FeishuCardDeliveryReconciler;
|
|
682
|
+
//#endregion
|
|
683
|
+
//#region src/infrastructure/persistence/jsonl-feishu-card-delivery-ledger.d.ts
|
|
684
|
+
interface JsonlFeishuCardDeliveryLedgerOptions {
|
|
685
|
+
readonly filePath: string;
|
|
686
|
+
}
|
|
687
|
+
declare function openJsonlFeishuCardDeliveryLedger(options: JsonlFeishuCardDeliveryLedgerOptions): Promise<FeishuCardDeliveryLedger>;
|
|
688
|
+
//#endregion
|
|
689
|
+
//#region src/domain/recovery-action.d.ts
|
|
690
|
+
interface RecoveryAction {
|
|
691
|
+
readonly actorId: string;
|
|
692
|
+
readonly at: string;
|
|
693
|
+
readonly note: string;
|
|
694
|
+
}
|
|
695
|
+
declare class InvalidRecoveryAction extends Error {
|
|
696
|
+
readonly name = "InvalidRecoveryAction";
|
|
697
|
+
}
|
|
698
|
+
declare function createRecoveryAction(input: RecoveryAction): RecoveryAction;
|
|
699
|
+
//#endregion
|
|
700
|
+
//#region src/domain/human-interaction.d.ts
|
|
701
|
+
type HumanInteractionId = string;
|
|
702
|
+
interface HumanInteractionActor {
|
|
703
|
+
readonly openId: string;
|
|
704
|
+
readonly tenantKey: string;
|
|
705
|
+
}
|
|
706
|
+
interface HumanInteractionFact {
|
|
707
|
+
readonly label: string;
|
|
708
|
+
readonly value: string;
|
|
709
|
+
}
|
|
710
|
+
interface ToolApprovalBinding {
|
|
711
|
+
readonly agentId: string;
|
|
712
|
+
readonly callId: string;
|
|
713
|
+
readonly inputDigest: string;
|
|
714
|
+
readonly instanceId: string;
|
|
715
|
+
readonly operationId: string;
|
|
716
|
+
readonly risk: RivusToolRisk;
|
|
717
|
+
readonly runId: string;
|
|
718
|
+
readonly sessionKey: string;
|
|
719
|
+
readonly tenantKey: string;
|
|
720
|
+
readonly toolId: string;
|
|
721
|
+
readonly toolVersion: string;
|
|
722
|
+
}
|
|
723
|
+
interface HumanInteractionBase {
|
|
724
|
+
readonly agentId: string;
|
|
725
|
+
readonly allowedActorOpenIds: ReadonlyArray<string>;
|
|
726
|
+
readonly createdAt: string;
|
|
727
|
+
readonly expiresAt: string;
|
|
728
|
+
readonly facts: ReadonlyArray<HumanInteractionFact>;
|
|
729
|
+
readonly id: HumanInteractionId;
|
|
730
|
+
readonly instanceId: string;
|
|
731
|
+
readonly revision: number;
|
|
732
|
+
readonly runId: string;
|
|
733
|
+
readonly sessionKey: string;
|
|
734
|
+
readonly sourceMessageId: string;
|
|
735
|
+
readonly summary: string;
|
|
736
|
+
readonly tenantKey: string;
|
|
737
|
+
readonly title: string;
|
|
738
|
+
}
|
|
739
|
+
interface PendingHumanInteractionState {
|
|
740
|
+
readonly status: "pending";
|
|
741
|
+
}
|
|
742
|
+
interface ApprovedHumanInteractionState {
|
|
743
|
+
readonly actor: HumanInteractionActor;
|
|
744
|
+
readonly consumedAt?: string;
|
|
745
|
+
readonly resolvedAt: string;
|
|
746
|
+
readonly status: "approved";
|
|
747
|
+
}
|
|
748
|
+
interface RejectedHumanInteractionState {
|
|
749
|
+
readonly actor: HumanInteractionActor;
|
|
750
|
+
readonly resolvedAt: string;
|
|
751
|
+
readonly status: "rejected";
|
|
752
|
+
}
|
|
753
|
+
interface SelectedHumanInteractionState {
|
|
754
|
+
readonly actor: HumanInteractionActor;
|
|
755
|
+
readonly optionId: string;
|
|
756
|
+
readonly resolvedAt: string;
|
|
757
|
+
readonly status: "selected";
|
|
758
|
+
}
|
|
759
|
+
interface ExpiredHumanInteractionState {
|
|
760
|
+
readonly expiredAt: string;
|
|
761
|
+
readonly status: "expired";
|
|
762
|
+
}
|
|
763
|
+
interface CancelledHumanInteractionState {
|
|
764
|
+
readonly cancelledAt: string;
|
|
765
|
+
readonly reason?: string;
|
|
766
|
+
readonly status: "cancelled";
|
|
767
|
+
}
|
|
768
|
+
type ToolApprovalInteractionState = PendingHumanInteractionState | ApprovedHumanInteractionState | RejectedHumanInteractionState | ExpiredHumanInteractionState | CancelledHumanInteractionState;
|
|
769
|
+
interface ToolApprovalInteraction extends HumanInteractionBase {
|
|
770
|
+
readonly kind: "tool-approval";
|
|
771
|
+
readonly request: Omit<ToolApprovalBinding, "agentId" | "instanceId" | "runId" | "sessionKey" | "tenantKey">;
|
|
772
|
+
readonly state: ToolApprovalInteractionState;
|
|
773
|
+
}
|
|
774
|
+
interface UserDecisionOption {
|
|
775
|
+
readonly description: string;
|
|
776
|
+
readonly id: string;
|
|
777
|
+
readonly label: string;
|
|
778
|
+
}
|
|
779
|
+
type UserDecisionInteractionState = PendingHumanInteractionState | SelectedHumanInteractionState | RejectedHumanInteractionState | ExpiredHumanInteractionState | CancelledHumanInteractionState;
|
|
780
|
+
interface UserDecisionInteraction extends HumanInteractionBase {
|
|
781
|
+
readonly kind: "user-decision";
|
|
782
|
+
readonly options: ReadonlyArray<UserDecisionOption>;
|
|
783
|
+
readonly recommendedOptionId?: string;
|
|
784
|
+
readonly state: UserDecisionInteractionState;
|
|
785
|
+
}
|
|
786
|
+
type HumanInteraction = ToolApprovalInteraction | UserDecisionInteraction;
|
|
787
|
+
type HumanInteractionResolutionAction = "approve" | "reject" | "select";
|
|
788
|
+
type HumanInteractionTransition = {
|
|
789
|
+
readonly action: HumanInteractionResolutionAction;
|
|
790
|
+
readonly actor: HumanInteractionActor;
|
|
791
|
+
readonly now: string;
|
|
792
|
+
readonly optionId?: string;
|
|
793
|
+
readonly type: "resolve";
|
|
794
|
+
} | {
|
|
795
|
+
readonly binding: ToolApprovalBinding;
|
|
796
|
+
readonly now: string;
|
|
797
|
+
readonly type: "consume-approval";
|
|
798
|
+
} | {
|
|
799
|
+
readonly now: string;
|
|
800
|
+
readonly reason?: string;
|
|
801
|
+
readonly type: "cancel";
|
|
802
|
+
};
|
|
803
|
+
//#endregion
|
|
804
|
+
//#region src/application/interaction/human-interaction-repository.d.ts
|
|
805
|
+
declare class HumanInteractionRepositoryError extends Error {
|
|
806
|
+
readonly operation: "create" | "get" | "update";
|
|
807
|
+
readonly cause?: unknown | undefined;
|
|
808
|
+
readonly name = "HumanInteractionRepositoryError";
|
|
809
|
+
constructor(operation: "create" | "get" | "update", message: string, cause?: unknown | undefined);
|
|
810
|
+
}
|
|
811
|
+
interface HumanInteractionRepository {
|
|
812
|
+
create(interaction: HumanInteraction): Effect.Effect<void, HumanInteractionRepositoryError>;
|
|
813
|
+
get(id: HumanInteractionId): Effect.Effect<HumanInteraction | undefined, HumanInteractionRepositoryError>;
|
|
814
|
+
update(id: HumanInteractionId, transition: (current: HumanInteraction) => HumanInteraction): Effect.Effect<HumanInteraction, HumanInteractionRepositoryError>;
|
|
815
|
+
}
|
|
816
|
+
declare function createInMemoryHumanInteractionRepository(): HumanInteractionRepository;
|
|
817
|
+
//#endregion
|
|
818
|
+
//#region src/application/interaction/human-interaction-service.d.ts
|
|
819
|
+
interface HumanInteractionClock {
|
|
820
|
+
now(): string;
|
|
821
|
+
}
|
|
822
|
+
interface HumanInteractionPresenter {
|
|
823
|
+
present(interaction: HumanInteraction): Effect.Effect<void, unknown>;
|
|
824
|
+
}
|
|
825
|
+
interface RequestToolApprovalInput {
|
|
826
|
+
readonly agentId: string;
|
|
827
|
+
readonly allowedActorOpenIds: ReadonlyArray<string>;
|
|
828
|
+
readonly expiresAt: string;
|
|
829
|
+
readonly facts: ReadonlyArray<HumanInteractionFact>;
|
|
830
|
+
readonly instanceId: string;
|
|
831
|
+
readonly interactionId: string;
|
|
832
|
+
readonly request: {
|
|
833
|
+
readonly callId: string;
|
|
834
|
+
readonly inputDigest: string;
|
|
835
|
+
readonly operationId: string;
|
|
836
|
+
readonly risk: RivusToolRisk;
|
|
837
|
+
readonly toolId: string;
|
|
838
|
+
readonly toolVersion: string;
|
|
839
|
+
};
|
|
840
|
+
readonly runId: string;
|
|
841
|
+
readonly sessionKey: string;
|
|
842
|
+
readonly sourceMessageId: string;
|
|
843
|
+
readonly summary: string;
|
|
844
|
+
readonly tenantKey: string;
|
|
845
|
+
readonly title: string;
|
|
846
|
+
}
|
|
847
|
+
interface RequestUserDecisionInput {
|
|
848
|
+
readonly agentId: string;
|
|
849
|
+
readonly allowedActorOpenIds: ReadonlyArray<string>;
|
|
850
|
+
readonly expiresAt: string;
|
|
851
|
+
readonly facts: ReadonlyArray<HumanInteractionFact>;
|
|
852
|
+
readonly instanceId: string;
|
|
853
|
+
readonly interactionId: string;
|
|
854
|
+
readonly options: ReadonlyArray<UserDecisionOption>;
|
|
855
|
+
readonly recommendedOptionId?: string;
|
|
856
|
+
readonly runId: string;
|
|
857
|
+
readonly sessionKey: string;
|
|
858
|
+
readonly sourceMessageId: string;
|
|
859
|
+
readonly summary: string;
|
|
860
|
+
readonly tenantKey: string;
|
|
861
|
+
readonly title: string;
|
|
862
|
+
}
|
|
863
|
+
interface ResolveHumanInteractionInput {
|
|
864
|
+
readonly action: HumanInteractionResolutionAction;
|
|
865
|
+
readonly actor: HumanInteractionActor;
|
|
866
|
+
readonly interactionId: string;
|
|
867
|
+
readonly optionId?: string;
|
|
868
|
+
}
|
|
869
|
+
interface ConsumeToolApprovalInput {
|
|
870
|
+
readonly approvalId: string;
|
|
871
|
+
readonly binding: ToolApprovalBinding;
|
|
872
|
+
}
|
|
873
|
+
interface HumanInteractionService {
|
|
874
|
+
consumeToolApproval(input: ConsumeToolApprovalInput): Effect.Effect<boolean, unknown>;
|
|
875
|
+
get(interactionId: string): Effect.Effect<HumanInteraction | undefined, unknown>;
|
|
876
|
+
resolve(input: ResolveHumanInteractionInput): Effect.Effect<HumanInteraction, unknown>;
|
|
877
|
+
requestToolApproval(input: RequestToolApprovalInput): Effect.Effect<ToolApprovalInteraction, unknown>;
|
|
878
|
+
requestUserDecision(input: RequestUserDecisionInput): Effect.Effect<UserDecisionInteraction, unknown>;
|
|
879
|
+
waitForResolution(input: {
|
|
880
|
+
readonly interactionId: string;
|
|
881
|
+
readonly signal?: AbortSignal;
|
|
882
|
+
}): Effect.Effect<HumanInteraction, unknown>;
|
|
883
|
+
}
|
|
884
|
+
interface HumanInteractionServiceOptions {
|
|
885
|
+
readonly clock: HumanInteractionClock;
|
|
886
|
+
readonly presenter: HumanInteractionPresenter;
|
|
887
|
+
readonly repository: HumanInteractionRepository;
|
|
888
|
+
readonly sleep?: (ms: number) => Promise<void>;
|
|
889
|
+
}
|
|
890
|
+
declare function createHumanInteractionService(options: HumanInteractionServiceOptions): HumanInteractionService;
|
|
891
|
+
//#endregion
|
|
892
|
+
//#region src/application/feishu/feishu-session-key.d.ts
|
|
893
|
+
interface FeishuSessionReference {
|
|
894
|
+
readonly tenantKey: string;
|
|
895
|
+
readonly chatId: string;
|
|
896
|
+
readonly threadId?: string;
|
|
897
|
+
readonly agentId: string;
|
|
898
|
+
}
|
|
899
|
+
type FeishuConversationReference = Omit<FeishuSessionReference, "agentId">;
|
|
900
|
+
declare class InvalidFeishuSessionReference {
|
|
901
|
+
readonly field: keyof FeishuSessionReference;
|
|
902
|
+
readonly message: string;
|
|
903
|
+
readonly _tag = "InvalidFeishuSessionReference";
|
|
904
|
+
constructor(field: keyof FeishuSessionReference, message: string);
|
|
905
|
+
}
|
|
906
|
+
declare function createFeishuSessionKey(reference: FeishuSessionReference): Effect.Effect<SessionKey, InvalidFeishuSessionReference>;
|
|
907
|
+
declare function createFeishuConversationId(reference: FeishuConversationReference): Effect.Effect<string, InvalidFeishuSessionReference>;
|
|
908
|
+
//#endregion
|
|
909
|
+
//#region src/application/feishu/feishu-message-intake.d.ts
|
|
910
|
+
interface FeishuMessageIntakeOptions {
|
|
911
|
+
readonly agentId: string;
|
|
912
|
+
}
|
|
913
|
+
interface FeishuReceiveMessagePayload {
|
|
914
|
+
readonly header?: {
|
|
915
|
+
readonly tenant_key?: string;
|
|
916
|
+
};
|
|
917
|
+
readonly event: {
|
|
918
|
+
readonly sender?: {
|
|
919
|
+
readonly sender_id?: {
|
|
920
|
+
readonly open_id?: string;
|
|
921
|
+
};
|
|
922
|
+
readonly sender_type?: string;
|
|
923
|
+
readonly tenant_key?: string;
|
|
924
|
+
};
|
|
925
|
+
readonly message: {
|
|
926
|
+
readonly message_id: string;
|
|
927
|
+
readonly chat_id: string;
|
|
928
|
+
readonly chat_type?: string;
|
|
929
|
+
readonly thread_id?: string;
|
|
930
|
+
readonly message_type: string;
|
|
931
|
+
readonly mentions?: ReadonlyArray<{
|
|
932
|
+
readonly id?: Readonly<Record<string, string>>;
|
|
933
|
+
readonly key?: string;
|
|
934
|
+
readonly name?: string;
|
|
935
|
+
}>;
|
|
936
|
+
readonly content: string;
|
|
937
|
+
};
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
interface FeishuPromptAgentCommand {
|
|
941
|
+
readonly conversationId: string;
|
|
942
|
+
readonly messageId: string;
|
|
943
|
+
readonly command: PromptCommand;
|
|
944
|
+
readonly type: "prompt";
|
|
945
|
+
}
|
|
946
|
+
interface FeishuCancelRunCommand {
|
|
947
|
+
readonly type: "cancel_run";
|
|
948
|
+
readonly messageId: string;
|
|
949
|
+
readonly runId: AgentRunId;
|
|
950
|
+
readonly reason: string;
|
|
951
|
+
readonly sessionKey?: SessionKey;
|
|
952
|
+
readonly token?: string;
|
|
953
|
+
}
|
|
954
|
+
type FeishuAgentCommand = FeishuPromptAgentCommand | FeishuCancelRunCommand;
|
|
955
|
+
type FeishuMessageIntakeSummary = FeishuPromptMessageIntakeSummary | FeishuCancelMessageIntakeSummary;
|
|
956
|
+
interface FeishuMessageIntakeBaseSummary {
|
|
957
|
+
readonly messageId: string;
|
|
958
|
+
readonly sessionKey: SessionKey;
|
|
959
|
+
readonly sessionReference: FeishuSessionReference;
|
|
960
|
+
}
|
|
961
|
+
interface FeishuPromptMessageIntakeSummary extends FeishuMessageIntakeBaseSummary {
|
|
962
|
+
readonly commandType: "prompt";
|
|
963
|
+
readonly text: string;
|
|
964
|
+
}
|
|
965
|
+
interface FeishuCancelMessageIntakeSummary extends FeishuMessageIntakeBaseSummary {
|
|
966
|
+
readonly commandType: "cancel_run";
|
|
967
|
+
readonly reason: string;
|
|
968
|
+
readonly runId: AgentRunId;
|
|
969
|
+
}
|
|
970
|
+
declare class UnsupportedFeishuMessage {
|
|
971
|
+
readonly messageType: string;
|
|
972
|
+
readonly _tag = "UnsupportedFeishuMessage";
|
|
973
|
+
constructor(messageType: string);
|
|
974
|
+
}
|
|
975
|
+
declare class InvalidFeishuMessageContent {
|
|
976
|
+
readonly reason: string;
|
|
977
|
+
readonly _tag = "InvalidFeishuMessageContent";
|
|
978
|
+
constructor(reason: string);
|
|
979
|
+
}
|
|
980
|
+
type FeishuMessageIntakeError = UnsupportedFeishuMessage | InvalidFeishuMessageContent | InvalidFeishuSessionReference;
|
|
981
|
+
declare function createAgentCommandFromFeishuMessage(payload: FeishuReceiveMessagePayload, options: FeishuMessageIntakeOptions): Effect.Effect<FeishuAgentCommand, FeishuMessageIntakeError>;
|
|
982
|
+
declare function describeFeishuMessageIntake(payload: FeishuReceiveMessagePayload, options: FeishuMessageIntakeOptions): Effect.Effect<FeishuMessageIntakeSummary, FeishuMessageIntakeError>;
|
|
983
|
+
//#endregion
|
|
984
|
+
//#region src/application/feishu/feishu-card-action-intake.d.ts
|
|
985
|
+
interface FeishuCardActionTriggerPayload {
|
|
986
|
+
readonly action?: {
|
|
987
|
+
readonly tag?: string;
|
|
988
|
+
readonly value?: unknown;
|
|
989
|
+
};
|
|
990
|
+
readonly context?: {
|
|
991
|
+
readonly chat_id?: string;
|
|
992
|
+
readonly open_chat_id?: string;
|
|
993
|
+
readonly open_message_id?: string;
|
|
994
|
+
};
|
|
995
|
+
readonly event?: FeishuCardActionTriggerPayload;
|
|
996
|
+
readonly event_type?: string;
|
|
997
|
+
readonly operator?: {
|
|
998
|
+
readonly open_id?: string;
|
|
999
|
+
readonly tenant_key?: string;
|
|
1000
|
+
readonly union_id?: string;
|
|
1001
|
+
readonly user_id?: string;
|
|
1002
|
+
};
|
|
1003
|
+
readonly token?: string;
|
|
1004
|
+
}
|
|
1005
|
+
declare class InvalidFeishuCardAction {
|
|
1006
|
+
readonly reason: string;
|
|
1007
|
+
readonly _tag = "InvalidFeishuCardAction";
|
|
1008
|
+
constructor(reason: string);
|
|
1009
|
+
}
|
|
1010
|
+
declare class UnsupportedFeishuCardAction {
|
|
1011
|
+
readonly reason: string;
|
|
1012
|
+
readonly _tag = "UnsupportedFeishuCardAction";
|
|
1013
|
+
constructor(reason: string);
|
|
1014
|
+
}
|
|
1015
|
+
type FeishuCardActionIntakeError = InvalidFeishuCardAction | UnsupportedFeishuCardAction;
|
|
1016
|
+
interface FeishuResolveInteractionCommand {
|
|
1017
|
+
readonly action: HumanInteractionResolutionAction;
|
|
1018
|
+
readonly actor: HumanInteractionActor;
|
|
1019
|
+
readonly interactionId: string;
|
|
1020
|
+
readonly messageId: string;
|
|
1021
|
+
readonly optionId?: string;
|
|
1022
|
+
readonly token: string;
|
|
1023
|
+
readonly type: "resolve_interaction";
|
|
1024
|
+
}
|
|
1025
|
+
type FeishuCardActionCommand = FeishuCancelRunCommand | FeishuResolveInteractionCommand;
|
|
1026
|
+
declare function createAgentCommandFromFeishuCardAction(payload: FeishuCardActionTriggerPayload): Effect.Effect<FeishuCardActionCommand, FeishuCardActionIntakeError>;
|
|
1027
|
+
//#endregion
|
|
1028
|
+
//#region src/application/feishu/feishu-agent-daemon.d.ts
|
|
1029
|
+
interface FeishuAgentDaemonBaseOptions {
|
|
1030
|
+
readonly agentId: string;
|
|
1031
|
+
readonly dedupe?: boolean;
|
|
1032
|
+
readonly interactions?: FeishuHumanInteractionActions;
|
|
1033
|
+
readonly prepareRun?: (run: FeishuAgentRunPreparation) => Effect.Effect<void, unknown>;
|
|
1034
|
+
readonly publish: (action: FeishuStreamAction) => Effect.Effect<void, unknown>;
|
|
1035
|
+
readonly publishRunUpdate?: AgentRunUpdateHandler;
|
|
1036
|
+
readonly resolveInvocation?: (payload: FeishuReceiveMessagePayload, conversationId: string) => AgentInvocationOrigin;
|
|
1037
|
+
}
|
|
1038
|
+
type FeishuAgentDaemonOptions = FeishuAgentDaemonBaseOptions & ({
|
|
1039
|
+
readonly execution: FeishuAgentExecution;
|
|
1040
|
+
readonly harness?: never;
|
|
1041
|
+
} | {
|
|
1042
|
+
readonly execution?: never;
|
|
1043
|
+
readonly harness: AgentHarness;
|
|
1044
|
+
});
|
|
1045
|
+
interface FeishuAgentExecutionResult {
|
|
1046
|
+
readonly finalText: string;
|
|
1047
|
+
readonly runId: AgentRunId;
|
|
1048
|
+
}
|
|
1049
|
+
interface FeishuAgentExecution {
|
|
1050
|
+
cancelRun(input: {
|
|
1051
|
+
readonly reason: string;
|
|
1052
|
+
readonly runId: AgentRunId;
|
|
1053
|
+
readonly sessionKey?: SessionKey;
|
|
1054
|
+
}): Effect.Effect<boolean, unknown>;
|
|
1055
|
+
promptWithUpdates(command: PromptCommand, onUpdate: AgentRunUpdateHandler): Effect.Effect<FeishuAgentExecutionResult, unknown>;
|
|
1056
|
+
}
|
|
1057
|
+
interface FeishuAgentRunPreparation {
|
|
1058
|
+
readonly messageId: string;
|
|
1059
|
+
readonly prompt: string;
|
|
1060
|
+
readonly receiveId: string;
|
|
1061
|
+
readonly runId: AgentRunId;
|
|
1062
|
+
readonly sessionKey: SessionKey;
|
|
1063
|
+
}
|
|
1064
|
+
interface FeishuAgentDaemonRunResult {
|
|
1065
|
+
readonly messageId: string;
|
|
1066
|
+
readonly runId: string;
|
|
1067
|
+
readonly finalText: string;
|
|
1068
|
+
}
|
|
1069
|
+
interface FeishuAgentDaemonSkippedResult {
|
|
1070
|
+
readonly messageId: string;
|
|
1071
|
+
readonly skipped: true;
|
|
1072
|
+
readonly reason: "duplicate";
|
|
1073
|
+
}
|
|
1074
|
+
interface FeishuAgentDaemonCancelResult {
|
|
1075
|
+
readonly cancelled: boolean;
|
|
1076
|
+
readonly messageId: string;
|
|
1077
|
+
readonly runId: AgentRunId;
|
|
1078
|
+
readonly reason?: "not_active";
|
|
1079
|
+
}
|
|
1080
|
+
interface FeishuAgentDaemonInteractionResult {
|
|
1081
|
+
readonly interaction: HumanInteraction;
|
|
1082
|
+
readonly interactionId: string;
|
|
1083
|
+
readonly messageId: string;
|
|
1084
|
+
readonly resolved: true;
|
|
1085
|
+
}
|
|
1086
|
+
interface FeishuHumanInteractionActions {
|
|
1087
|
+
resolve(input: ResolveHumanInteractionInput): Effect.Effect<HumanInteraction, unknown>;
|
|
1088
|
+
}
|
|
1089
|
+
type FeishuAgentDaemonHandleResult = FeishuAgentDaemonRunResult | FeishuAgentDaemonSkippedResult | FeishuAgentDaemonCancelResult | FeishuAgentDaemonInteractionResult;
|
|
1090
|
+
type FeishuAgentMessageSideEffects = "enabled" | "disabled";
|
|
1091
|
+
interface FeishuAgentDaemonHandleMessageOptions {
|
|
1092
|
+
readonly sideEffects?: FeishuAgentMessageSideEffects;
|
|
1093
|
+
}
|
|
1094
|
+
interface FeishuAgentDaemon {
|
|
1095
|
+
handleCardAction(payload: FeishuCardActionTriggerPayload): Effect.Effect<FeishuAgentDaemonHandleResult, unknown>;
|
|
1096
|
+
handleMessage(payload: FeishuReceiveMessagePayload, options?: FeishuAgentDaemonHandleMessageOptions): Effect.Effect<FeishuAgentDaemonHandleResult, unknown>;
|
|
1097
|
+
}
|
|
1098
|
+
declare function createFeishuAgentDaemon(options: FeishuAgentDaemonOptions): FeishuAgentDaemon;
|
|
1099
|
+
//#endregion
|
|
1100
|
+
//#region src/application/feishu/feishu-inbox-repository.d.ts
|
|
1101
|
+
interface FeishuInboxPendingState {
|
|
1102
|
+
readonly availableAt: string;
|
|
1103
|
+
readonly status: "pending";
|
|
1104
|
+
}
|
|
1105
|
+
interface FeishuInboxLeasedState {
|
|
1106
|
+
readonly leaseExpiresAt: string;
|
|
1107
|
+
readonly leaseId: string;
|
|
1108
|
+
readonly leasedAt: string;
|
|
1109
|
+
readonly status: "leased";
|
|
1110
|
+
}
|
|
1111
|
+
interface FeishuInboxCompletedState {
|
|
1112
|
+
readonly completedAt: string;
|
|
1113
|
+
readonly status: "completed";
|
|
1114
|
+
}
|
|
1115
|
+
interface FeishuInboxDeadState {
|
|
1116
|
+
readonly failedAt: string;
|
|
1117
|
+
readonly reason: string;
|
|
1118
|
+
readonly status: "dead";
|
|
1119
|
+
}
|
|
1120
|
+
type FeishuInboxDeliveryState = FeishuInboxPendingState | FeishuInboxLeasedState | FeishuInboxCompletedState | FeishuInboxDeadState;
|
|
1121
|
+
interface FeishuInboxDelivery {
|
|
1122
|
+
readonly acceptedAt: string;
|
|
1123
|
+
readonly attempts: number;
|
|
1124
|
+
readonly id: string;
|
|
1125
|
+
readonly laneKey: string;
|
|
1126
|
+
readonly options?: FeishuAgentDaemonHandleMessageOptions;
|
|
1127
|
+
readonly payload: FeishuReceiveMessagePayload;
|
|
1128
|
+
readonly recovery?: RecoveryAction;
|
|
1129
|
+
readonly revision: number;
|
|
1130
|
+
readonly state: FeishuInboxDeliveryState;
|
|
1131
|
+
}
|
|
1132
|
+
interface FeishuInboxRepository {
|
|
1133
|
+
admit(delivery: FeishuInboxDelivery, maxPending: number): Effect.Effect<"created" | "duplicate" | "capacity", unknown>;
|
|
1134
|
+
claim(input: {
|
|
1135
|
+
readonly leaseExpiresAt: string;
|
|
1136
|
+
readonly leaseId: string;
|
|
1137
|
+
readonly now: string;
|
|
1138
|
+
}): Effect.Effect<FeishuInboxDelivery | undefined, unknown>;
|
|
1139
|
+
complete(input: {
|
|
1140
|
+
readonly completedAt: string;
|
|
1141
|
+
readonly id: string;
|
|
1142
|
+
readonly leaseId: string;
|
|
1143
|
+
}): Effect.Effect<void, unknown>;
|
|
1144
|
+
create(delivery: FeishuInboxDelivery): Effect.Effect<boolean, unknown>;
|
|
1145
|
+
deadLetters(): ReadonlyArray<FeishuInboxDelivery>;
|
|
1146
|
+
fail(input: {
|
|
1147
|
+
readonly availableAt?: string;
|
|
1148
|
+
readonly failedAt: string;
|
|
1149
|
+
readonly id: string;
|
|
1150
|
+
readonly leaseId: string;
|
|
1151
|
+
readonly reason: string;
|
|
1152
|
+
readonly terminal: boolean;
|
|
1153
|
+
}): Effect.Effect<void, unknown>;
|
|
1154
|
+
pendingCount(): number;
|
|
1155
|
+
requeueDeadLetter(input: {
|
|
1156
|
+
readonly availableAt: string;
|
|
1157
|
+
readonly expectedRevision: number;
|
|
1158
|
+
readonly id: string;
|
|
1159
|
+
readonly recovery: RecoveryAction;
|
|
1160
|
+
}): Effect.Effect<FeishuInboxDelivery, unknown>;
|
|
1161
|
+
}
|
|
1162
|
+
interface FeishuInboxRepositoryStateOptions {
|
|
1163
|
+
readonly initial?: ReadonlyArray<FeishuInboxDelivery>;
|
|
1164
|
+
readonly persist?: (delivery: FeishuInboxDelivery) => Promise<void>;
|
|
1165
|
+
}
|
|
1166
|
+
declare function createFeishuInboxRepository(options?: FeishuInboxRepositoryStateOptions): FeishuInboxRepository;
|
|
1167
|
+
//#endregion
|
|
1168
|
+
//#region src/application/delegation/tool-operation-ledger.d.ts
|
|
1169
|
+
interface ToolOperationBinding {
|
|
1170
|
+
readonly agentId: string;
|
|
1171
|
+
readonly inputDigest: string;
|
|
1172
|
+
readonly instanceId: string;
|
|
1173
|
+
readonly sourceMessageId: string;
|
|
1174
|
+
readonly toolId: string;
|
|
1175
|
+
readonly toolVersion: string;
|
|
1176
|
+
}
|
|
1177
|
+
type ToolOperationState = {
|
|
1178
|
+
readonly status: "pending";
|
|
1179
|
+
} | {
|
|
1180
|
+
readonly result: unknown;
|
|
1181
|
+
readonly status: "completed";
|
|
1182
|
+
} | {
|
|
1183
|
+
readonly reason: string;
|
|
1184
|
+
readonly status: "reconciliation-required";
|
|
1185
|
+
} | {
|
|
1186
|
+
readonly status: "aborted";
|
|
1187
|
+
};
|
|
1188
|
+
interface ToolOperationRecord {
|
|
1189
|
+
readonly binding: ToolOperationBinding;
|
|
1190
|
+
readonly operationId: string;
|
|
1191
|
+
readonly reconciliation?: ToolOperationReconciliation;
|
|
1192
|
+
readonly revision: number;
|
|
1193
|
+
readonly state: ToolOperationState;
|
|
1194
|
+
}
|
|
1195
|
+
interface ToolOperationReconciliation extends RecoveryAction {
|
|
1196
|
+
readonly outcome: "applied" | "not-applied";
|
|
1197
|
+
}
|
|
1198
|
+
type ToolOperationReconciliationOutcome = {
|
|
1199
|
+
readonly result: unknown;
|
|
1200
|
+
readonly status: "applied";
|
|
1201
|
+
} | {
|
|
1202
|
+
readonly status: "not-applied";
|
|
1203
|
+
};
|
|
1204
|
+
type ToolOperationBeginResult = {
|
|
1205
|
+
readonly status: "acquired";
|
|
1206
|
+
} | {
|
|
1207
|
+
readonly result: unknown;
|
|
1208
|
+
readonly status: "completed";
|
|
1209
|
+
} | {
|
|
1210
|
+
readonly status: "blocked";
|
|
1211
|
+
readonly reason: string;
|
|
1212
|
+
};
|
|
1213
|
+
type ToolOperationInspectResult = {
|
|
1214
|
+
readonly status: "missing";
|
|
1215
|
+
} | {
|
|
1216
|
+
readonly result: unknown;
|
|
1217
|
+
readonly status: "completed";
|
|
1218
|
+
} | {
|
|
1219
|
+
readonly status: "blocked";
|
|
1220
|
+
readonly reason: string;
|
|
1221
|
+
};
|
|
1222
|
+
interface ToolOperationLedger {
|
|
1223
|
+
abort(operationId: string, binding: ToolOperationBinding): Promise<void>;
|
|
1224
|
+
begin(operationId: string, binding: ToolOperationBinding): Promise<ToolOperationBeginResult>;
|
|
1225
|
+
complete(operationId: string, binding: ToolOperationBinding, result: unknown): Promise<void>;
|
|
1226
|
+
inspect(operationId: string, binding: ToolOperationBinding): Promise<ToolOperationInspectResult>;
|
|
1227
|
+
reconciliationRequired(): ReadonlyArray<ToolOperationRecord>;
|
|
1228
|
+
reconcile(input: {
|
|
1229
|
+
readonly action: RecoveryAction;
|
|
1230
|
+
readonly expectedRevision: number;
|
|
1231
|
+
readonly operationId: string;
|
|
1232
|
+
readonly outcome: ToolOperationReconciliationOutcome;
|
|
1233
|
+
}): Promise<ToolOperationRecord>;
|
|
1234
|
+
requireReconciliation(operationId: string, binding: ToolOperationBinding, reason: string): Promise<void>;
|
|
1235
|
+
unresolvedForSource(sourceMessageId: string): ReadonlyArray<ToolOperationRecord>;
|
|
1236
|
+
}
|
|
1237
|
+
declare function createToolOperationLedger(options?: {
|
|
1238
|
+
readonly initial?: ReadonlyArray<ToolOperationRecord>;
|
|
1239
|
+
readonly persist?: (record: ToolOperationRecord) => Promise<void>;
|
|
1240
|
+
}): ToolOperationLedger;
|
|
1241
|
+
//#endregion
|
|
1242
|
+
//#region src/application/recovery/recovery-control.d.ts
|
|
1243
|
+
interface DeadLetterRecoveryItem {
|
|
1244
|
+
readonly acceptedAt: string;
|
|
1245
|
+
readonly attempts: number;
|
|
1246
|
+
readonly deliveryId: string;
|
|
1247
|
+
readonly endpointId: string;
|
|
1248
|
+
readonly failureCode: "delivery_failed";
|
|
1249
|
+
readonly failureSummary: string;
|
|
1250
|
+
readonly failedAt: string;
|
|
1251
|
+
readonly revision: number;
|
|
1252
|
+
}
|
|
1253
|
+
interface DeadLetterRequeueResult {
|
|
1254
|
+
readonly acceptedAt: string;
|
|
1255
|
+
readonly attempts: 0;
|
|
1256
|
+
readonly availableAt: string;
|
|
1257
|
+
readonly deliveryId: string;
|
|
1258
|
+
readonly endpointId: string;
|
|
1259
|
+
readonly recoveredAt: string;
|
|
1260
|
+
readonly recoveredBy: string;
|
|
1261
|
+
readonly revision: number;
|
|
1262
|
+
readonly status: "pending";
|
|
1263
|
+
}
|
|
1264
|
+
interface RecoverySnapshot {
|
|
1265
|
+
readonly deadLetters: ReadonlyArray<DeadLetterRecoveryItem>;
|
|
1266
|
+
readonly toolOperations: ReadonlyArray<ToolOperationRecoveryItem>;
|
|
1267
|
+
}
|
|
1268
|
+
interface ToolOperationRecoveryItem {
|
|
1269
|
+
readonly agentId: string;
|
|
1270
|
+
readonly inputDigest: string;
|
|
1271
|
+
readonly instanceId: string;
|
|
1272
|
+
readonly operationId: string;
|
|
1273
|
+
readonly failureCode: "tool_outcome_unknown";
|
|
1274
|
+
readonly failureSummary: string;
|
|
1275
|
+
readonly revision: number;
|
|
1276
|
+
readonly status: "reconciliation-required";
|
|
1277
|
+
readonly toolId: string;
|
|
1278
|
+
readonly toolVersion: string;
|
|
1279
|
+
}
|
|
1280
|
+
interface ToolOperationResolutionResult {
|
|
1281
|
+
readonly agentId: string;
|
|
1282
|
+
readonly inputDigest: string;
|
|
1283
|
+
readonly instanceId: string;
|
|
1284
|
+
readonly operationId: string;
|
|
1285
|
+
readonly reconciledAt: string;
|
|
1286
|
+
readonly reconciledBy: string;
|
|
1287
|
+
readonly revision: number;
|
|
1288
|
+
readonly status: "aborted" | "completed";
|
|
1289
|
+
readonly toolId: string;
|
|
1290
|
+
readonly toolVersion: string;
|
|
1291
|
+
}
|
|
1292
|
+
interface RecoveryControl {
|
|
1293
|
+
inspect(): Effect.Effect<RecoverySnapshot, unknown>;
|
|
1294
|
+
requeueDeadLetter(input: {
|
|
1295
|
+
readonly actorId: string;
|
|
1296
|
+
readonly deliveryId: string;
|
|
1297
|
+
readonly endpointId: string;
|
|
1298
|
+
readonly expectedRevision: number;
|
|
1299
|
+
readonly note: string;
|
|
1300
|
+
}): Effect.Effect<DeadLetterRequeueResult, unknown>;
|
|
1301
|
+
resolveToolOperation(input: {
|
|
1302
|
+
readonly actorId: string;
|
|
1303
|
+
readonly expectedRevision: number;
|
|
1304
|
+
readonly instanceId: string;
|
|
1305
|
+
readonly note: string;
|
|
1306
|
+
readonly operationId: string;
|
|
1307
|
+
readonly outcome: ToolOperationReconciliationOutcome;
|
|
1308
|
+
}): Effect.Effect<ToolOperationResolutionResult, unknown>;
|
|
1309
|
+
}
|
|
1310
|
+
interface RecoveryControlOptions {
|
|
1311
|
+
readonly clock: {
|
|
1312
|
+
readonly now: () => string;
|
|
1313
|
+
};
|
|
1314
|
+
readonly inboxes: ReadonlyArray<{
|
|
1315
|
+
readonly endpointId: string;
|
|
1316
|
+
readonly repository: FeishuInboxRepository;
|
|
1317
|
+
}>;
|
|
1318
|
+
readonly toolOperations: ReadonlyArray<{
|
|
1319
|
+
readonly instanceId: string;
|
|
1320
|
+
readonly ledger: ToolOperationLedger;
|
|
1321
|
+
}>;
|
|
1322
|
+
}
|
|
1323
|
+
declare function createRecoveryControl(options: RecoveryControlOptions): RecoveryControl;
|
|
1324
|
+
//#endregion
|
|
1325
|
+
//#region src/infrastructure/persistence/jsonl-feishu-inbox-repository.d.ts
|
|
1326
|
+
interface JsonlFeishuInboxRepositoryOptions {
|
|
1327
|
+
readonly filePath: string;
|
|
1328
|
+
}
|
|
1329
|
+
declare function openJsonlFeishuInboxRepository(options: JsonlFeishuInboxRepositoryOptions): Promise<FeishuInboxRepository>;
|
|
1330
|
+
//#endregion
|
|
1331
|
+
//#region src/application/host/agent-instance-registry.d.ts
|
|
1332
|
+
interface AgentInstanceRecord {
|
|
1333
|
+
readonly agentId: string;
|
|
1334
|
+
readonly binding: AgentInstanceBinding;
|
|
1335
|
+
readonly bindingKey: string;
|
|
1336
|
+
readonly instanceId: string;
|
|
1337
|
+
readonly runtimeGenerationId: string;
|
|
1338
|
+
}
|
|
1339
|
+
type AgentInstanceBinding = {
|
|
1340
|
+
readonly kind: "endpoint";
|
|
1341
|
+
readonly endpointId: string;
|
|
1342
|
+
} | {
|
|
1343
|
+
readonly kind: "automation";
|
|
1344
|
+
readonly automationId: string;
|
|
1345
|
+
};
|
|
1346
|
+
interface AgentInstanceRegistryOptions {
|
|
1347
|
+
readonly initialRecords?: ReadonlyArray<AgentInstanceRecord>;
|
|
1348
|
+
}
|
|
1349
|
+
interface AgentInstanceRegistry {
|
|
1350
|
+
resolveAutomation(automationId: string, definition: ResolvedRivusAgentDefinition): AgentInstanceRecord;
|
|
1351
|
+
resolveEndpoint(endpointId: string, definition: ResolvedRivusAgentDefinition): AgentInstanceRecord;
|
|
1352
|
+
snapshot(): ReadonlyArray<AgentInstanceRecord>;
|
|
1353
|
+
}
|
|
1354
|
+
declare class AgentInstanceConflict extends Error {
|
|
1355
|
+
readonly name = "AgentInstanceConflict";
|
|
1356
|
+
}
|
|
1357
|
+
declare function createAgentInstanceRegistry(options?: AgentInstanceRegistryOptions): AgentInstanceRegistry;
|
|
1358
|
+
//#endregion
|
|
1359
|
+
//#region src/application/host/agent-runtime-pool.d.ts
|
|
1360
|
+
interface AgentRuntimeInput {
|
|
1361
|
+
readonly invocation?: AgentInvocationOrigin;
|
|
1362
|
+
readonly onUpdate?: (update: AgentRunUpdate) => void | Promise<void>;
|
|
1363
|
+
readonly payload?: unknown;
|
|
1364
|
+
readonly sessionKey: SessionKey;
|
|
1365
|
+
readonly text: string;
|
|
1366
|
+
}
|
|
1367
|
+
interface AgentRuntimeCancellation {
|
|
1368
|
+
readonly reason?: string;
|
|
1369
|
+
readonly runId: AgentRunId;
|
|
1370
|
+
readonly sessionKey: SessionKey;
|
|
1371
|
+
}
|
|
1372
|
+
interface PooledAgentRuntime {
|
|
1373
|
+
readonly concurrency?: "managed";
|
|
1374
|
+
cancel?(input: AgentRuntimeCancellation): Promise<boolean>;
|
|
1375
|
+
run(input: AgentRuntimeInput): Promise<unknown>;
|
|
1376
|
+
dispose?(): Promise<void> | void;
|
|
1377
|
+
}
|
|
1378
|
+
interface AgentRuntimePoolOptions {
|
|
1379
|
+
readonly disposeTimeoutMs?: number;
|
|
1380
|
+
readonly registry: AgentInstanceRegistry;
|
|
1381
|
+
readonly createRuntime: (instance: AgentInstanceRecord) => PooledAgentRuntime | Promise<PooledAgentRuntime>;
|
|
1382
|
+
}
|
|
1383
|
+
interface AgentRuntimePool {
|
|
1384
|
+
readonly registry: AgentInstanceRegistry;
|
|
1385
|
+
cancel(instance: AgentInstanceRecord, input: AgentRuntimeCancellation): Promise<boolean>;
|
|
1386
|
+
run(instance: AgentInstanceRecord, input: AgentRuntimeInput): Promise<unknown>;
|
|
1387
|
+
disposeAll(): Promise<void>;
|
|
1388
|
+
}
|
|
1389
|
+
declare class AgentInstanceBusy extends Error {
|
|
1390
|
+
readonly name = "AgentInstanceBusy";
|
|
1391
|
+
}
|
|
1392
|
+
declare class AgentRuntimeDisposed extends Error {
|
|
1393
|
+
readonly name = "AgentRuntimeDisposed";
|
|
1394
|
+
}
|
|
1395
|
+
declare function createAgentRuntimePool(options: AgentRuntimePoolOptions): AgentRuntimePool;
|
|
1396
|
+
//#endregion
|
|
1397
|
+
//#region src/application/host/session-scheduler.d.ts
|
|
1398
|
+
interface SessionSchedulerOptions {
|
|
1399
|
+
readonly createRuntime: (sessionKey: string) => PooledAgentRuntime | Promise<PooledAgentRuntime>;
|
|
1400
|
+
readonly maxConcurrentSessions: number;
|
|
1401
|
+
readonly maxQueuedRuns: number;
|
|
1402
|
+
}
|
|
1403
|
+
interface SessionSchedulerStatus {
|
|
1404
|
+
readonly activeSessions: number;
|
|
1405
|
+
readonly queuedRuns: number;
|
|
1406
|
+
readonly sessions: number;
|
|
1407
|
+
}
|
|
1408
|
+
interface SessionScheduler extends PooledAgentRuntime {
|
|
1409
|
+
readonly concurrency: "managed";
|
|
1410
|
+
status(): SessionSchedulerStatus;
|
|
1411
|
+
}
|
|
1412
|
+
declare class SessionSchedulerCapacityExceeded extends Error {
|
|
1413
|
+
readonly name = "SessionSchedulerCapacityExceeded";
|
|
1414
|
+
}
|
|
1415
|
+
declare class SessionSchedulerDisposed extends Error {
|
|
1416
|
+
readonly name = "SessionSchedulerDisposed";
|
|
1417
|
+
}
|
|
1418
|
+
declare function createSessionScheduler(options: SessionSchedulerOptions): SessionScheduler;
|
|
1419
|
+
//#endregion
|
|
1420
|
+
//#region src/infrastructure/http/json-fetch-request.d.ts
|
|
1421
|
+
interface JsonHttpRequest {
|
|
1422
|
+
readonly method: string;
|
|
1423
|
+
readonly url: string;
|
|
1424
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
1425
|
+
readonly body?: unknown;
|
|
1426
|
+
}
|
|
1427
|
+
interface JsonHttpResponse {
|
|
1428
|
+
readonly status: number;
|
|
1429
|
+
readonly body: unknown;
|
|
1430
|
+
}
|
|
1431
|
+
interface FetchLikeResponse {
|
|
1432
|
+
readonly status: number;
|
|
1433
|
+
json(): Promise<unknown>;
|
|
1434
|
+
}
|
|
1435
|
+
type FetchLike = (url: string, init: {
|
|
1436
|
+
readonly method: string;
|
|
1437
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
1438
|
+
readonly body?: string;
|
|
1439
|
+
readonly signal: AbortSignal;
|
|
1440
|
+
}) => Promise<FetchLikeResponse>;
|
|
1441
|
+
interface JsonFetchRequestOptions {
|
|
1442
|
+
readonly fetch?: FetchLike;
|
|
1443
|
+
}
|
|
1444
|
+
declare function createJsonFetchRequest(options?: JsonFetchRequestOptions): (request: JsonHttpRequest) => Effect.Effect<JsonHttpResponse, unknown>;
|
|
1445
|
+
//#endregion
|
|
1446
|
+
//#region src/application/agent/agent-harness-client.d.ts
|
|
1447
|
+
interface AgentHarnessClient {
|
|
1448
|
+
readonly harness: AgentHarness;
|
|
1449
|
+
cancelActiveRun(reason?: string): Promise<boolean>;
|
|
1450
|
+
cancelRun(runId: AgentRunId, reason?: string): Promise<boolean>;
|
|
1451
|
+
forSession(sessionKey: SessionKey): AgentSessionClient;
|
|
1452
|
+
getActiveRun(): ActiveAgentRun | undefined;
|
|
1453
|
+
getActiveRunId(): AgentRunId | undefined;
|
|
1454
|
+
getActiveRunState(): AgentRunState | undefined;
|
|
1455
|
+
getAvailability(): AgentHarnessAvailability;
|
|
1456
|
+
getHistory(): AgentHistory;
|
|
1457
|
+
getRunEvents(runId: AgentRunId): ReadonlyArray<AgentDomainEvent> | undefined;
|
|
1458
|
+
getRunSnapshot(runId: AgentRunId): AgentRunSnapshot | undefined;
|
|
1459
|
+
getRunSummary(runId: AgentRunId): AgentRunSummary | undefined;
|
|
1460
|
+
getRunState(runId: AgentRunId): AgentRunState | undefined;
|
|
1461
|
+
getRunUpdates(runId: AgentRunId): ReadonlyArray<AgentRunUpdate> | undefined;
|
|
1462
|
+
getSessionHistory(sessionKey: SessionKey): AgentHistory;
|
|
1463
|
+
getSessionLatestRunSnapshot(sessionKey: SessionKey): AgentRunSnapshot | undefined;
|
|
1464
|
+
getSessionLatestRunSummary(sessionKey: SessionKey): AgentRunSummary | undefined;
|
|
1465
|
+
getSessionRuns(sessionKey: SessionKey): ReadonlyArray<AgentRunSummary>;
|
|
1466
|
+
getSessionSnapshot(sessionKey: SessionKey): AgentSessionSnapshot;
|
|
1467
|
+
getSessionSummary(sessionKey: SessionKey): AgentSessionSummary | undefined;
|
|
1468
|
+
getSessionTranscript(sessionKey: SessionKey): AgentTranscript;
|
|
1469
|
+
getSessionState(sessionKey: SessionKey): AgentRunState | undefined;
|
|
1470
|
+
getState(): AgentRunState;
|
|
1471
|
+
prompt(command: PromptCommand): Promise<AgentPromptResult>;
|
|
1472
|
+
promptRunSnapshot(command: PromptCommand): Promise<AgentRunSnapshot>;
|
|
1473
|
+
promptSnapshot(command: PromptCommand): Promise<AgentSessionSnapshot>;
|
|
1474
|
+
promptText(command: PromptCommand): Promise<string>;
|
|
1475
|
+
promptTurn(command: PromptCommand): Promise<AgentTranscriptTurn>;
|
|
1476
|
+
promptWithEvents(command: PromptCommand, onEvent: AgentDomainEventCallback): Promise<AgentPromptResult>;
|
|
1477
|
+
promptWithText(command: PromptCommand, onTextDelta: AgentTextDeltaCallback): Promise<AgentPromptResult>;
|
|
1478
|
+
promptWithUpdates(command: PromptCommand, onUpdate: AgentRunUpdateCallback): Promise<AgentPromptResult>;
|
|
1479
|
+
stream(command: PromptCommand): AsyncIterable<AgentDomainEvent>;
|
|
1480
|
+
streamText(command: PromptCommand): AsyncIterable<string>;
|
|
1481
|
+
streamUpdates(command: PromptCommand): AsyncIterable<AgentRunUpdate>;
|
|
1482
|
+
subscribe(listener: AgentDomainEventListener): () => void;
|
|
1483
|
+
subscribeRun(runId: AgentRunId, listener: AgentDomainEventListener): () => void;
|
|
1484
|
+
subscribeRunUpdates(runId: AgentRunId, listener: AgentRunUpdateListener): () => void;
|
|
1485
|
+
subscribeUpdates(listener: AgentRunUpdateListener): () => void;
|
|
1486
|
+
tryPrompt(command: PromptCommand): Promise<AgentClientAttempt<AgentPromptResult, unknown>>;
|
|
1487
|
+
tryPromptText(command: PromptCommand): Promise<AgentClientAttempt<string, unknown>>;
|
|
1488
|
+
}
|
|
1489
|
+
interface AgentSessionClient {
|
|
1490
|
+
readonly handle: AgentSessionHandle;
|
|
1491
|
+
readonly sessionKey: SessionKey;
|
|
1492
|
+
cancelActiveRun(reason?: string): Promise<boolean>;
|
|
1493
|
+
cancelRun(runId: AgentRunId, reason?: string): Promise<boolean>;
|
|
1494
|
+
getActiveRun(): ActiveAgentRun | undefined;
|
|
1495
|
+
getActiveRunState(): AgentRunState | undefined;
|
|
1496
|
+
getAvailability(): AgentSessionAvailability;
|
|
1497
|
+
getHistory(): AgentHistory;
|
|
1498
|
+
getLatestRunSnapshot(): AgentRunSnapshot | undefined;
|
|
1499
|
+
getLatestRunSummary(): AgentRunSummary | undefined;
|
|
1500
|
+
getRunEvents(runId: AgentRunId): ReadonlyArray<AgentDomainEvent> | undefined;
|
|
1501
|
+
getRunSnapshot(runId: AgentRunId): AgentRunSnapshot | undefined;
|
|
1502
|
+
getRunSummary(runId: AgentRunId): AgentRunSummary | undefined;
|
|
1503
|
+
getRuns(): ReadonlyArray<AgentRunSummary>;
|
|
1504
|
+
getRunState(runId: AgentRunId): AgentRunState | undefined;
|
|
1505
|
+
getRunUpdates(runId: AgentRunId): ReadonlyArray<AgentRunUpdate> | undefined;
|
|
1506
|
+
getSnapshot(): AgentSessionSnapshot;
|
|
1507
|
+
getState(): AgentRunState | undefined;
|
|
1508
|
+
getSummary(): AgentSessionSummary | undefined;
|
|
1509
|
+
getTranscript(): AgentTranscript;
|
|
1510
|
+
prompt(text: string): Promise<AgentPromptResult>;
|
|
1511
|
+
promptRunSnapshot(text: string): Promise<AgentRunSnapshot>;
|
|
1512
|
+
promptSnapshot(text: string): Promise<AgentSessionSnapshot>;
|
|
1513
|
+
promptText(text: string): Promise<string>;
|
|
1514
|
+
promptTurn(text: string): Promise<AgentTranscriptTurn>;
|
|
1515
|
+
promptWithEvents(text: string, onEvent: AgentDomainEventCallback): Promise<AgentPromptResult>;
|
|
1516
|
+
promptWithText(text: string, onTextDelta: AgentTextDeltaCallback): Promise<AgentPromptResult>;
|
|
1517
|
+
promptWithUpdates(text: string, onUpdate: AgentRunUpdateCallback): Promise<AgentPromptResult>;
|
|
1518
|
+
stream(text: string): AsyncIterable<AgentDomainEvent>;
|
|
1519
|
+
streamText(text: string): AsyncIterable<string>;
|
|
1520
|
+
streamUpdates(text: string): AsyncIterable<AgentRunUpdate>;
|
|
1521
|
+
subscribe(listener: AgentDomainEventListener): () => void;
|
|
1522
|
+
subscribeRun(runId: AgentRunId, listener: AgentDomainEventListener): () => void;
|
|
1523
|
+
subscribeRunUpdates(runId: AgentRunId, listener: AgentRunUpdateListener): () => void;
|
|
1524
|
+
subscribeUpdates(listener: AgentRunUpdateListener): () => void;
|
|
1525
|
+
tryPrompt(text: string): Promise<AgentClientAttempt<AgentPromptResult, unknown>>;
|
|
1526
|
+
tryPromptText(text: string): Promise<AgentClientAttempt<string, unknown>>;
|
|
1527
|
+
}
|
|
1528
|
+
type AgentTextDeltaCallback = (delta: string) => void | Promise<void>;
|
|
1529
|
+
type AgentClientAttempt<T, E = unknown> = AgentClientSuccess<T> | AgentClientFailure<E>;
|
|
1530
|
+
interface AgentClientSuccess<T> {
|
|
1531
|
+
readonly ok: true;
|
|
1532
|
+
readonly value: T;
|
|
1533
|
+
}
|
|
1534
|
+
interface AgentClientFailure<E = unknown> {
|
|
1535
|
+
readonly ok: false;
|
|
1536
|
+
readonly error: E;
|
|
1537
|
+
}
|
|
1538
|
+
declare function createAgentHarnessClient(harness: AgentHarness): AgentHarnessClient;
|
|
1539
|
+
//#endregion
|
|
1540
|
+
//#region src/infrastructure/runtime/agent-runtime-primitives.d.ts
|
|
1541
|
+
type DefaultAgentHarnessOptions = Omit<AgentHarnessOptions, "clock" | "runIds"> & {
|
|
1542
|
+
readonly clock?: AgentClock;
|
|
1543
|
+
readonly runIds?: RunIdGenerator;
|
|
1544
|
+
};
|
|
1545
|
+
type DefaultAgentHarnessFromCallbackOptions = Omit<DefaultAgentHarnessOptions, "loop">;
|
|
1546
|
+
type DefaultAgentHarnessFromTextCallbackOptions = DefaultAgentHarnessFromCallbackOptions;
|
|
1547
|
+
type DefaultAgentHarnessClientOptions = DefaultAgentHarnessOptions;
|
|
1548
|
+
type DefaultAgentHarnessClientFromCallbackOptions = DefaultAgentHarnessFromCallbackOptions;
|
|
1549
|
+
type DefaultAgentHarnessClientFromTextCallbackOptions = DefaultAgentHarnessFromTextCallbackOptions;
|
|
1550
|
+
interface DefaultAgentRuntimeSessionOptions {
|
|
1551
|
+
readonly mainSessionKey?: SessionKey;
|
|
1552
|
+
}
|
|
1553
|
+
interface AgentRuntime {
|
|
1554
|
+
readonly client: AgentHarnessClient;
|
|
1555
|
+
readonly harness: AgentHarness;
|
|
1556
|
+
readonly mainClient: AgentSessionClient;
|
|
1557
|
+
readonly mainSession: AgentSessionHandle;
|
|
1558
|
+
readonly mainSessionKey: SessionKey;
|
|
1559
|
+
forSession(sessionKey: SessionKey): AgentSessionHandle;
|
|
1560
|
+
forSessionClient(sessionKey: SessionKey): AgentSessionClient;
|
|
1561
|
+
prompt(text: string): Promise<AgentPromptResult>;
|
|
1562
|
+
promptText(text: string): Promise<string>;
|
|
1563
|
+
promptTurn(text: string): Promise<AgentTranscriptTurn>;
|
|
1564
|
+
tryPrompt(text: string): Promise<AgentClientAttempt<AgentPromptResult, unknown>>;
|
|
1565
|
+
tryPromptText(text: string): Promise<AgentClientAttempt<string, unknown>>;
|
|
1566
|
+
}
|
|
1567
|
+
type DefaultAgentRuntimeOptions = DefaultAgentHarnessOptions;
|
|
1568
|
+
type DefaultAgentRuntimeFromCallbackOptions = DefaultAgentHarnessFromCallbackOptions;
|
|
1569
|
+
type DefaultAgentRuntimeFromTextCallbackOptions = DefaultAgentHarnessFromTextCallbackOptions;
|
|
1570
|
+
declare function createDefaultAgentHarness(options: DefaultAgentHarnessOptions): AgentHarness;
|
|
1571
|
+
declare function createDefaultAgentHarnessFromCallback(run: AgentLoopCallback, options?: DefaultAgentHarnessFromCallbackOptions): AgentHarness;
|
|
1572
|
+
declare function createDefaultAgentHarnessFromTextCallback(generate: TextAgentLoopCallback, options?: DefaultAgentHarnessFromTextCallbackOptions): AgentHarness;
|
|
1573
|
+
declare function createDefaultAgentHarnessClient(options: DefaultAgentHarnessClientOptions): AgentHarnessClient;
|
|
1574
|
+
declare function createDefaultAgentHarnessClientFromCallback(run: AgentLoopCallback, options?: DefaultAgentHarnessClientFromCallbackOptions): AgentHarnessClient;
|
|
1575
|
+
declare function createDefaultAgentHarnessClientFromTextCallback(generate: TextAgentLoopCallback, options?: DefaultAgentHarnessClientFromTextCallbackOptions): AgentHarnessClient;
|
|
1576
|
+
declare function createDefaultAgentRuntime(options: DefaultAgentRuntimeOptions, runtimeOptions?: DefaultAgentRuntimeSessionOptions): AgentRuntime;
|
|
1577
|
+
declare function createDefaultAgentRuntimeFromCallback(run: AgentLoopCallback, options?: DefaultAgentRuntimeFromCallbackOptions, runtimeOptions?: DefaultAgentRuntimeSessionOptions): AgentRuntime;
|
|
1578
|
+
declare function createDefaultAgentRuntimeFromTextCallback(generate: TextAgentLoopCallback, options?: DefaultAgentRuntimeFromTextCallbackOptions, runtimeOptions?: DefaultAgentRuntimeSessionOptions): AgentRuntime;
|
|
1579
|
+
declare function createSystemClock(): AgentClock;
|
|
1580
|
+
declare function createUuidRunIds(): RunIdGenerator;
|
|
1581
|
+
declare function createAgentRuntime(harness: AgentHarness, options?: DefaultAgentRuntimeSessionOptions): AgentRuntime;
|
|
1582
|
+
//#endregion
|
|
1583
|
+
//#region src/infrastructure/config/rivus-daemon-config.d.ts
|
|
1584
|
+
type RivusDaemonEnv = Readonly<Record<string, string | undefined>>;
|
|
1585
|
+
type RivusThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
1586
|
+
type RivusTextFileReader = (path: string) => Promise<string> | string;
|
|
1587
|
+
interface RivusDaemonConfigLoaderOptions {
|
|
1588
|
+
readonly readTextFile?: RivusTextFileReader;
|
|
1589
|
+
}
|
|
1590
|
+
interface RivusDaemonConfig {
|
|
1591
|
+
readonly agentId: string;
|
|
1592
|
+
readonly feishu: {
|
|
1593
|
+
readonly appId: string;
|
|
1594
|
+
readonly appSecret: string;
|
|
1595
|
+
readonly baseUrl: string;
|
|
1596
|
+
readonly streamMinIntervalMs: number;
|
|
1597
|
+
};
|
|
1598
|
+
readonly pi: {
|
|
1599
|
+
readonly apiKey?: string;
|
|
1600
|
+
readonly baseUrl?: string;
|
|
1601
|
+
readonly model?: string;
|
|
1602
|
+
readonly thinkingLevel?: RivusThinkingLevel;
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
declare class RivusDaemonConfigError {
|
|
1606
|
+
readonly variable: string;
|
|
1607
|
+
readonly message: string;
|
|
1608
|
+
readonly _tag = "RivusDaemonConfigError";
|
|
1609
|
+
constructor(variable: string, message: string);
|
|
1610
|
+
}
|
|
1611
|
+
declare function loadRivusDaemonConfig(env: RivusDaemonEnv, options?: RivusDaemonConfigLoaderOptions): Effect.Effect<RivusDaemonConfig, RivusDaemonConfigError>;
|
|
1612
|
+
//#endregion
|
|
1613
|
+
//#region src/infrastructure/config/feishu-endpoint-credentials.d.ts
|
|
1614
|
+
interface FeishuEndpointCredentials {
|
|
1615
|
+
readonly appId: string;
|
|
1616
|
+
readonly appSecret: string;
|
|
1617
|
+
}
|
|
1618
|
+
declare class FeishuEndpointCredentialError extends Error {
|
|
1619
|
+
readonly name = "FeishuEndpointCredentialError";
|
|
1620
|
+
}
|
|
1621
|
+
declare function resolveFeishuEndpointCredentials(credentialRef: string, env: RivusDaemonEnv): FeishuEndpointCredentials;
|
|
1622
|
+
//#endregion
|
|
1623
|
+
//#region src/infrastructure/config/openclaw-env-import.d.ts
|
|
1624
|
+
type RivusEnvFileVariables = Readonly<Record<string, string>>;
|
|
1625
|
+
interface OpenClawEnvImportOptions {
|
|
1626
|
+
readonly feishuBaseUrl?: string;
|
|
1627
|
+
readonly piApiKeyFile?: string;
|
|
1628
|
+
readonly streamMinIntervalMs?: number;
|
|
1629
|
+
}
|
|
1630
|
+
interface OpenClawEnvImportResult {
|
|
1631
|
+
readonly env: RivusEnvFileVariables;
|
|
1632
|
+
readonly warnings: ReadonlyArray<string>;
|
|
1633
|
+
}
|
|
1634
|
+
declare class OpenClawEnvImportError extends Error {
|
|
1635
|
+
constructor(message: string);
|
|
1636
|
+
}
|
|
1637
|
+
declare function createRivusEnvFromOpenClawConfig(openClawConfig: unknown, options?: OpenClawEnvImportOptions): OpenClawEnvImportResult;
|
|
1638
|
+
declare function formatRivusEnvFile(env: RivusEnvFileVariables): string;
|
|
1639
|
+
//#endregion
|
|
1640
|
+
//#region src/application/feishu/feishu-message-queue.d.ts
|
|
1641
|
+
interface FeishuMessageQueueOptions {
|
|
1642
|
+
readonly clock?: {
|
|
1643
|
+
readonly now: () => string;
|
|
1644
|
+
};
|
|
1645
|
+
readonly handleMessage: (payload: FeishuReceiveMessagePayload, options?: FeishuAgentDaemonHandleMessageOptions) => Effect.Effect<FeishuAgentDaemonHandleResult, unknown>;
|
|
1646
|
+
readonly shouldRetryError?: (error: unknown) => boolean;
|
|
1647
|
+
readonly leaseMs?: number;
|
|
1648
|
+
readonly maxAttempts?: number;
|
|
1649
|
+
readonly maxPending?: number;
|
|
1650
|
+
readonly repository?: FeishuInboxRepository;
|
|
1651
|
+
readonly retryDelayMs?: number;
|
|
1652
|
+
}
|
|
1653
|
+
type FeishuMessageAcceptResult = {
|
|
1654
|
+
readonly accepted: true;
|
|
1655
|
+
readonly messageId: string;
|
|
1656
|
+
readonly pending: number;
|
|
1657
|
+
} | {
|
|
1658
|
+
readonly accepted: false;
|
|
1659
|
+
readonly messageId: string;
|
|
1660
|
+
readonly pending: number;
|
|
1661
|
+
readonly reason: "capacity" | "duplicate" | "ignored";
|
|
1662
|
+
};
|
|
1663
|
+
type FeishuMessageDrainResult = {
|
|
1664
|
+
readonly handled: true;
|
|
1665
|
+
readonly messageId: string;
|
|
1666
|
+
readonly result: FeishuAgentDaemonHandleResult;
|
|
1667
|
+
} | {
|
|
1668
|
+
readonly handled: false;
|
|
1669
|
+
readonly reason: "empty";
|
|
1670
|
+
};
|
|
1671
|
+
interface FeishuMessageQueue {
|
|
1672
|
+
accept(payload: FeishuReceiveMessagePayload, options?: FeishuAgentDaemonHandleMessageOptions): Effect.Effect<FeishuMessageAcceptResult, unknown>;
|
|
1673
|
+
drainOne(): Effect.Effect<FeishuMessageDrainResult, unknown>;
|
|
1674
|
+
deadLetters(): ReadonlyArray<FeishuInboxDelivery>;
|
|
1675
|
+
pending(): number;
|
|
1676
|
+
}
|
|
1677
|
+
declare function createFeishuMessageQueue(options: FeishuMessageQueueOptions): FeishuMessageQueue;
|
|
1678
|
+
//#endregion
|
|
1679
|
+
//#region src/application/feishu/feishu-group-policy.d.ts
|
|
1680
|
+
type FeishuEndpointGroupPolicy = "mention-only" | "ignore-unmentioned" | "default-responder";
|
|
1681
|
+
declare function shouldAcceptFeishuEndpointMessage(payload: FeishuReceiveMessagePayload, policy: FeishuEndpointGroupPolicy, botOpenId: string): boolean;
|
|
1682
|
+
//#endregion
|
|
1683
|
+
//#region src/application/feishu/feishu-message-worker.d.ts
|
|
1684
|
+
interface FeishuMessageWorkerQueue {
|
|
1685
|
+
drainOne(): Effect.Effect<FeishuMessageDrainResult, unknown>;
|
|
1686
|
+
pending(): number;
|
|
1687
|
+
}
|
|
1688
|
+
interface FeishuMessageWorkerDrainAvailableResult {
|
|
1689
|
+
readonly drained: number;
|
|
1690
|
+
readonly results: ReadonlyArray<Extract<FeishuMessageDrainResult, {
|
|
1691
|
+
readonly handled: true;
|
|
1692
|
+
}>>;
|
|
1693
|
+
}
|
|
1694
|
+
interface FeishuMessageWorker {
|
|
1695
|
+
drainAvailable(): Effect.Effect<FeishuMessageWorkerDrainAvailableResult, unknown>;
|
|
1696
|
+
}
|
|
1697
|
+
interface FeishuMessageWorkerOptions {
|
|
1698
|
+
readonly concurrency?: number;
|
|
1699
|
+
readonly queue: FeishuMessageWorkerQueue;
|
|
1700
|
+
}
|
|
1701
|
+
declare function createFeishuMessageWorker(options: FeishuMessageWorkerOptions): FeishuMessageWorker;
|
|
1702
|
+
//#endregion
|
|
1703
|
+
//#region src/application/feishu/feishu-worker-loop.d.ts
|
|
1704
|
+
interface FeishuWorkerLoopOptions {
|
|
1705
|
+
readonly drainAvailable: () => Effect.Effect<unknown, unknown>;
|
|
1706
|
+
readonly intervalMs: number;
|
|
1707
|
+
readonly onError?: (error: unknown) => void | Promise<void>;
|
|
1708
|
+
readonly sleep: (ms: number) => Effect.Effect<void, unknown>;
|
|
1709
|
+
}
|
|
1710
|
+
interface FeishuWorkerLoop {
|
|
1711
|
+
running(): boolean;
|
|
1712
|
+
start(): void;
|
|
1713
|
+
stop(): Promise<void>;
|
|
1714
|
+
}
|
|
1715
|
+
declare function createFeishuWorkerLoop(options: FeishuWorkerLoopOptions): FeishuWorkerLoop;
|
|
1716
|
+
//#endregion
|
|
1717
|
+
//#region src/application/daemon/rivus-daemon-process.d.ts
|
|
1718
|
+
interface RivusDaemonTransport {
|
|
1719
|
+
running(): boolean;
|
|
1720
|
+
start(): Promise<void> | void;
|
|
1721
|
+
stop(): Promise<void> | void;
|
|
1722
|
+
}
|
|
1723
|
+
interface RivusDaemonWorkerLoop {
|
|
1724
|
+
running(): boolean;
|
|
1725
|
+
start(): void;
|
|
1726
|
+
stop(): Promise<void> | void;
|
|
1727
|
+
}
|
|
1728
|
+
interface RivusDaemonProcessOptions {
|
|
1729
|
+
readonly transport: RivusDaemonTransport;
|
|
1730
|
+
readonly workerLoop: RivusDaemonWorkerLoop;
|
|
1731
|
+
}
|
|
1732
|
+
interface RivusDaemonProcess {
|
|
1733
|
+
running(): boolean;
|
|
1734
|
+
start(): Effect.Effect<void, unknown>;
|
|
1735
|
+
stop(): Effect.Effect<void, unknown>;
|
|
1736
|
+
}
|
|
1737
|
+
declare function createRivusDaemonProcess(options: RivusDaemonProcessOptions): RivusDaemonProcess;
|
|
1738
|
+
//#endregion
|
|
1739
|
+
//#region src/application/daemon/rivus-daemon-transport.d.ts
|
|
1740
|
+
interface CompositeRivusDaemonTransportOptions {
|
|
1741
|
+
readonly transports: ReadonlyArray<RivusDaemonTransport>;
|
|
1742
|
+
}
|
|
1743
|
+
declare function createCompositeRivusDaemonTransport(options: CompositeRivusDaemonTransportOptions): RivusDaemonTransport;
|
|
1744
|
+
//#endregion
|
|
1745
|
+
//#region src/application/feishu/feishu-receive-status.d.ts
|
|
1746
|
+
type FeishuReceiveMessageReplayOptions = FeishuAgentDaemonHandleMessageOptions;
|
|
1747
|
+
interface FeishuReceiveMessageSummary {
|
|
1748
|
+
readonly chatId: string;
|
|
1749
|
+
readonly messageId: string;
|
|
1750
|
+
readonly tenantKey?: string;
|
|
1751
|
+
readonly threadId?: string;
|
|
1752
|
+
}
|
|
1753
|
+
interface FeishuReceiveAcceptedObservation {
|
|
1754
|
+
readonly accepted: FeishuMessageAcceptResult;
|
|
1755
|
+
readonly message: FeishuReceiveMessageSummary;
|
|
1756
|
+
readonly observedAt: Date;
|
|
1757
|
+
}
|
|
1758
|
+
interface FeishuReceiveHandledObservation {
|
|
1759
|
+
readonly intake: FeishuMessageIntakeSummary;
|
|
1760
|
+
readonly messageId: string;
|
|
1761
|
+
readonly observedAt: Date;
|
|
1762
|
+
readonly result: FeishuAgentDaemonHandleResult;
|
|
1763
|
+
}
|
|
1764
|
+
interface FeishuReceiveRuntimeStatus {
|
|
1765
|
+
readonly lastAccepted?: FeishuReceiveAcceptedObservation;
|
|
1766
|
+
readonly lastHandled?: FeishuReceiveHandledObservation;
|
|
1767
|
+
}
|
|
1768
|
+
interface FeishuReceiveMessageReplayResult {
|
|
1769
|
+
readonly accepted: FeishuMessageAcceptResult;
|
|
1770
|
+
readonly drained: FeishuMessageWorkerDrainAvailableResult;
|
|
1771
|
+
readonly intake: FeishuMessageIntakeSummary;
|
|
1772
|
+
}
|
|
1773
|
+
//#endregion
|
|
1774
|
+
//#region src/application/daemon/rivus-daemon-status.d.ts
|
|
1775
|
+
interface RivusDaemonStatus {
|
|
1776
|
+
readonly agentId: string;
|
|
1777
|
+
readonly harness: {
|
|
1778
|
+
readonly activeRunId?: AgentRunId;
|
|
1779
|
+
readonly activeRunState?: AgentRunState;
|
|
1780
|
+
readonly activeSessionKey?: SessionKey;
|
|
1781
|
+
readonly busy: boolean;
|
|
1782
|
+
};
|
|
1783
|
+
readonly history: AgentHistory;
|
|
1784
|
+
readonly process: {
|
|
1785
|
+
readonly running: boolean;
|
|
1786
|
+
};
|
|
1787
|
+
readonly queue: {
|
|
1788
|
+
readonly pending: number;
|
|
1789
|
+
};
|
|
1790
|
+
readonly receive?: FeishuReceiveRuntimeStatus;
|
|
1791
|
+
readonly transport: {
|
|
1792
|
+
readonly running: boolean;
|
|
1793
|
+
};
|
|
1794
|
+
readonly workerLoop: {
|
|
1795
|
+
readonly running: boolean;
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
interface RivusDaemonStatusReporter {
|
|
1799
|
+
status(): Effect.Effect<RivusDaemonStatus, unknown>;
|
|
1800
|
+
}
|
|
1801
|
+
interface RivusDaemonStatusReporterOptions {
|
|
1802
|
+
readonly activeRun?: () => ActiveAgentRun | undefined;
|
|
1803
|
+
readonly activeRunId?: () => AgentRunId | undefined;
|
|
1804
|
+
readonly activeRunState?: () => AgentRunState | undefined;
|
|
1805
|
+
readonly agentId: string;
|
|
1806
|
+
readonly availability?: () => AgentHarnessAvailability;
|
|
1807
|
+
readonly pending: () => number;
|
|
1808
|
+
readonly processRunning: () => boolean;
|
|
1809
|
+
readonly receiveStatus?: () => FeishuReceiveRuntimeStatus;
|
|
1810
|
+
readonly restoreHistory: () => Effect.Effect<AgentHistory, unknown>;
|
|
1811
|
+
readonly transportRunning: () => boolean;
|
|
1812
|
+
readonly workerLoopRunning: () => boolean;
|
|
1813
|
+
}
|
|
1814
|
+
declare function createRivusDaemonStatusReporter(options: RivusDaemonStatusReporterOptions): RivusDaemonStatusReporter;
|
|
1815
|
+
//#endregion
|
|
1816
|
+
//#region src/infrastructure/http/rivus-daemon-status-http-server.d.ts
|
|
1817
|
+
interface RivusDaemonStatusHttpServerOptions {
|
|
1818
|
+
readonly host?: string;
|
|
1819
|
+
readonly path?: string;
|
|
1820
|
+
readonly port: number;
|
|
1821
|
+
readonly statusReporter: RivusDaemonStatusReporter;
|
|
1822
|
+
}
|
|
1823
|
+
interface RivusDaemonStatusHttpServer extends RivusDaemonTransport {
|
|
1824
|
+
url(): string | undefined;
|
|
1825
|
+
}
|
|
1826
|
+
declare function createRivusDaemonStatusHttpServer(options: RivusDaemonStatusHttpServerOptions): RivusDaemonStatusHttpServer;
|
|
1827
|
+
//#endregion
|
|
1828
|
+
//#region src/application/daemon/rivus-daemon-shutdown-controller.d.ts
|
|
1829
|
+
type RivusDaemonShutdownSignal = "SIGINT" | "SIGTERM";
|
|
1830
|
+
interface RivusDaemonSignalSource {
|
|
1831
|
+
on(signal: RivusDaemonShutdownSignal, listener: () => void): void;
|
|
1832
|
+
}
|
|
1833
|
+
interface RivusDaemonShutdownControllerOptions {
|
|
1834
|
+
readonly daemon: Pick<RivusDaemonProcess, "stop">;
|
|
1835
|
+
readonly signalSource: RivusDaemonSignalSource;
|
|
1836
|
+
readonly signals?: ReadonlyArray<RivusDaemonShutdownSignal>;
|
|
1837
|
+
readonly onError?: (error: unknown, signal: RivusDaemonShutdownSignal) => void | Promise<void>;
|
|
1838
|
+
readonly onStopped?: (signal: RivusDaemonShutdownSignal) => void | Promise<void>;
|
|
1839
|
+
}
|
|
1840
|
+
interface RivusDaemonShutdownController {
|
|
1841
|
+
handle(signal: RivusDaemonShutdownSignal): Promise<void>;
|
|
1842
|
+
install(): void;
|
|
1843
|
+
stopping(): boolean;
|
|
1844
|
+
}
|
|
1845
|
+
declare function createRivusDaemonShutdownController(options: RivusDaemonShutdownControllerOptions): RivusDaemonShutdownController;
|
|
1846
|
+
//#endregion
|
|
1847
|
+
//#region src/application/host/rivus-agent-host.d.ts
|
|
1848
|
+
interface RivusEndpointDefinition {
|
|
1849
|
+
readonly id: string;
|
|
1850
|
+
readonly agentId: string;
|
|
1851
|
+
}
|
|
1852
|
+
interface RivusAgentHostOptions {
|
|
1853
|
+
readonly automations?: ReadonlyArray<RivusAutomationDefinition>;
|
|
1854
|
+
readonly definitions: ReadonlyArray<ResolvedRivusAgentDefinition>;
|
|
1855
|
+
readonly endpoints: ReadonlyArray<RivusEndpointDefinition>;
|
|
1856
|
+
readonly runtimePool: AgentRuntimePool;
|
|
1857
|
+
}
|
|
1858
|
+
interface RivusAutomationDefinition {
|
|
1859
|
+
readonly definition: ResolvedRivusAgentDefinition;
|
|
1860
|
+
readonly id: string;
|
|
1861
|
+
}
|
|
1862
|
+
interface RivusEndpointInput extends AgentRuntimeInput {}
|
|
1863
|
+
interface RivusAgentHost {
|
|
1864
|
+
cancelEndpoint(endpointId: string, input: AgentRuntimeCancellation): Promise<boolean>;
|
|
1865
|
+
handleAutomation(automationId: string, input: AgentRuntimeInput): Promise<unknown>;
|
|
1866
|
+
handleEndpoint(endpointId: string, input: RivusEndpointInput): Promise<unknown>;
|
|
1867
|
+
resolveAutomation(automationId: string): AgentInstanceRecord;
|
|
1868
|
+
resolveEndpoint(endpointId: string): AgentInstanceRecord;
|
|
1869
|
+
}
|
|
1870
|
+
declare class InvalidRivusEndpointBinding extends Error {
|
|
1871
|
+
readonly name = "InvalidRivusEndpointBinding";
|
|
1872
|
+
}
|
|
1873
|
+
declare function createRivusAgentHost(options: RivusAgentHostOptions): RivusAgentHost;
|
|
1874
|
+
//#endregion
|
|
1875
|
+
//#region src/application/plugin/rivus-plugin-loader.d.ts
|
|
1876
|
+
interface RivusPluginDeclaration {
|
|
1877
|
+
readonly id: string;
|
|
1878
|
+
readonly module: string;
|
|
1879
|
+
readonly required: boolean;
|
|
1880
|
+
}
|
|
1881
|
+
interface RivusDeploymentManifest {
|
|
1882
|
+
readonly plugins: ReadonlyArray<RivusPluginDeclaration>;
|
|
1883
|
+
readonly agents: ReadonlyArray<RivusAgentDeployment>;
|
|
1884
|
+
readonly automations?: ReadonlyArray<RivusAutomationDeployment>;
|
|
1885
|
+
readonly endpoints: ReadonlyArray<RivusEndpointDeployment>;
|
|
1886
|
+
readonly defaultAgentId: string;
|
|
1887
|
+
readonly defaultEndpointId: string;
|
|
1888
|
+
}
|
|
1889
|
+
type RivusAutomationDeliveryTargetType = "chat_id" | "open_id" | "user_id" | "union_id" | "email";
|
|
1890
|
+
interface RivusAutomationDelivery {
|
|
1891
|
+
readonly endpointId: string;
|
|
1892
|
+
readonly targetRef: string;
|
|
1893
|
+
readonly targetType: RivusAutomationDeliveryTargetType;
|
|
1894
|
+
}
|
|
1895
|
+
interface RivusAutomationDeployment {
|
|
1896
|
+
readonly id: string;
|
|
1897
|
+
readonly agentId: string;
|
|
1898
|
+
readonly templateId: string;
|
|
1899
|
+
readonly enabled: boolean;
|
|
1900
|
+
readonly required: boolean;
|
|
1901
|
+
readonly schedule: string;
|
|
1902
|
+
readonly timeZone: string;
|
|
1903
|
+
readonly delivery: RivusAutomationDelivery;
|
|
1904
|
+
}
|
|
1905
|
+
interface RivusEndpointDeployment {
|
|
1906
|
+
readonly id: string;
|
|
1907
|
+
readonly agentId: string;
|
|
1908
|
+
readonly sessionNamespace: string;
|
|
1909
|
+
readonly credentialRef: string;
|
|
1910
|
+
readonly enabled: boolean;
|
|
1911
|
+
readonly experimental?: RivusEndpointExperimentalFeatures;
|
|
1912
|
+
readonly required: boolean;
|
|
1913
|
+
readonly baseUrl: string;
|
|
1914
|
+
readonly streamMinIntervalMs: number;
|
|
1915
|
+
readonly groupPolicy: "mention-only" | "ignore-unmentioned" | "default-responder";
|
|
1916
|
+
}
|
|
1917
|
+
interface RivusEndpointExperimentalFeatures {
|
|
1918
|
+
readonly cotMessages: boolean;
|
|
1919
|
+
}
|
|
1920
|
+
interface RivusPluginModuleLoadRequest {
|
|
1921
|
+
readonly deploymentRoot: string;
|
|
1922
|
+
readonly module: string;
|
|
1923
|
+
readonly pluginId: string;
|
|
1924
|
+
}
|
|
1925
|
+
type RivusPluginModule = RivusPlugin | {
|
|
1926
|
+
readonly default: RivusPlugin | (() => RivusPlugin | Promise<RivusPlugin>);
|
|
1927
|
+
};
|
|
1928
|
+
interface RivusPluginLoadStatus {
|
|
1929
|
+
readonly id: string;
|
|
1930
|
+
readonly module: string;
|
|
1931
|
+
readonly required: boolean;
|
|
1932
|
+
readonly status: "loaded" | "failed";
|
|
1933
|
+
readonly version?: string;
|
|
1934
|
+
readonly error?: string;
|
|
1935
|
+
}
|
|
1936
|
+
interface RivusAgentDeploymentStatus {
|
|
1937
|
+
readonly agentId: string;
|
|
1938
|
+
readonly pluginId: string;
|
|
1939
|
+
readonly profileId: string;
|
|
1940
|
+
readonly status: "enabled" | "disabled";
|
|
1941
|
+
readonly reason?: string;
|
|
1942
|
+
readonly definition?: ResolvedRivusAgentDefinition;
|
|
1943
|
+
}
|
|
1944
|
+
interface LoadedRivusDeployment {
|
|
1945
|
+
readonly manifest: RivusDeploymentManifest;
|
|
1946
|
+
readonly catalog: RivusPluginCatalog;
|
|
1947
|
+
readonly plugins: ReadonlyArray<RivusPluginLoadStatus>;
|
|
1948
|
+
readonly agents: ReadonlyArray<RivusAgentDeploymentStatus>;
|
|
1949
|
+
readonly definitions: ReadonlyArray<ResolvedRivusAgentDefinition>;
|
|
1950
|
+
readonly automationDefinitions: ReadonlyArray<ResolvedRivusAutomationDefinition>;
|
|
1951
|
+
}
|
|
1952
|
+
interface ResolvedRivusAutomationDefinition extends RivusAutomationDeployment {
|
|
1953
|
+
readonly runtimeDefinition: ResolvedRivusAgentDefinition;
|
|
1954
|
+
readonly template: RegisteredRivusAutomation;
|
|
1955
|
+
}
|
|
1956
|
+
interface LoadRivusDeploymentOptions {
|
|
1957
|
+
readonly deploymentRoot: string;
|
|
1958
|
+
readonly manifest: RivusDeploymentManifest;
|
|
1959
|
+
readonly loadModule: (request: RivusPluginModuleLoadRequest) => Promise<RivusPluginModule> | RivusPluginModule;
|
|
1960
|
+
}
|
|
1961
|
+
declare class RivusPluginLoadError extends Error {
|
|
1962
|
+
readonly pluginId: string;
|
|
1963
|
+
readonly moduleSpecifier: string;
|
|
1964
|
+
readonly name = "RivusPluginLoadError";
|
|
1965
|
+
constructor(pluginId: string, moduleSpecifier: string, message: string, options?: ErrorOptions);
|
|
1966
|
+
}
|
|
1967
|
+
declare function loadRivusDeployment(options: LoadRivusDeploymentOptions): Promise<LoadedRivusDeployment>;
|
|
1968
|
+
declare function validateRivusDeploymentManifest(manifest: RivusDeploymentManifest): void;
|
|
1969
|
+
//#endregion
|
|
1970
|
+
//#region src/application/automation/automation-mandate.d.ts
|
|
1971
|
+
interface AutomationBinding {
|
|
1972
|
+
readonly agentId: string;
|
|
1973
|
+
readonly bindingId: string;
|
|
1974
|
+
readonly delivery: AutomationDeliveryBinding;
|
|
1975
|
+
readonly schedule: string;
|
|
1976
|
+
readonly servicePrincipalId: string;
|
|
1977
|
+
readonly skillGrantRevision: string;
|
|
1978
|
+
readonly skillIds: ReadonlyArray<string>;
|
|
1979
|
+
readonly templateId: string;
|
|
1980
|
+
readonly timeZone: string;
|
|
1981
|
+
readonly toolIds: ReadonlyArray<string>;
|
|
1982
|
+
}
|
|
1983
|
+
interface AutomationDeliveryBinding {
|
|
1984
|
+
readonly endpointId: string;
|
|
1985
|
+
readonly targetKey: string;
|
|
1986
|
+
readonly targetType: "chat_id" | "open_id" | "user_id" | "union_id" | "email";
|
|
1987
|
+
}
|
|
1988
|
+
interface AutomationMandate extends AutomationBinding {
|
|
1989
|
+
readonly id: string;
|
|
1990
|
+
readonly active: boolean;
|
|
1991
|
+
}
|
|
1992
|
+
interface AutomationTick {
|
|
1993
|
+
readonly tickId: string;
|
|
1994
|
+
readonly mandateId: string;
|
|
1995
|
+
readonly occurrence: string;
|
|
1996
|
+
readonly claimedBy: string;
|
|
1997
|
+
}
|
|
1998
|
+
interface AutomationMandateStore {
|
|
1999
|
+
activate(binding: AutomationBinding): AutomationMandate;
|
|
2000
|
+
revoke(id: string): void;
|
|
2001
|
+
claim(id: string, occurrence: string, workerId: string): AutomationTick;
|
|
2002
|
+
}
|
|
2003
|
+
declare class AutomationMandateError extends Error {
|
|
2004
|
+
readonly name = "AutomationMandateError";
|
|
2005
|
+
}
|
|
2006
|
+
declare function createAutomationMandateStore(): AutomationMandateStore;
|
|
2007
|
+
//#endregion
|
|
2008
|
+
//#region src/application/automation/scheduled-automation.d.ts
|
|
2009
|
+
type AutomationTickStatus = "running" | "failed" | "generated" | "delivered";
|
|
2010
|
+
interface AutomationTickRecord {
|
|
2011
|
+
readonly automationId: string;
|
|
2012
|
+
readonly body?: string;
|
|
2013
|
+
readonly error?: string;
|
|
2014
|
+
readonly occurrence: string;
|
|
2015
|
+
readonly mandateId: string;
|
|
2016
|
+
readonly providerMessageId?: string;
|
|
2017
|
+
readonly revision: number;
|
|
2018
|
+
readonly runId?: string;
|
|
2019
|
+
readonly status: AutomationTickStatus;
|
|
2020
|
+
readonly tickId: string;
|
|
2021
|
+
}
|
|
2022
|
+
interface AutomationTickRepository {
|
|
2023
|
+
get(mandateId: string, occurrence: string): Promise<AutomationTickRecord | undefined>;
|
|
2024
|
+
put(record: AutomationTickRecord): Promise<AutomationTickRecord>;
|
|
2025
|
+
}
|
|
2026
|
+
interface ScheduledAutomationRunInput {
|
|
2027
|
+
readonly occurrence: string;
|
|
2028
|
+
readonly sessionKey: string;
|
|
2029
|
+
readonly text: string;
|
|
2030
|
+
readonly tickId: string;
|
|
2031
|
+
}
|
|
2032
|
+
interface ScheduledAutomationRunResult {
|
|
2033
|
+
readonly body: string;
|
|
2034
|
+
readonly runId: string;
|
|
2035
|
+
}
|
|
2036
|
+
interface ScheduledAutomationDeliveryInput {
|
|
2037
|
+
readonly body: string;
|
|
2038
|
+
readonly idempotencyKey: string;
|
|
2039
|
+
}
|
|
2040
|
+
interface ScheduledAutomationOptions {
|
|
2041
|
+
readonly automationId: string;
|
|
2042
|
+
readonly binding: AutomationBinding;
|
|
2043
|
+
readonly clock?: ScheduledAutomationClock;
|
|
2044
|
+
readonly createInput: (tick: RivusAutomationTickContext) => RivusAutomationInput;
|
|
2045
|
+
readonly deliver: (input: ScheduledAutomationDeliveryInput) => Promise<{
|
|
2046
|
+
readonly providerMessageId: string;
|
|
2047
|
+
}>;
|
|
2048
|
+
readonly repository: AutomationTickRepository;
|
|
2049
|
+
readonly onError?: (error: unknown) => Promise<void> | void;
|
|
2050
|
+
readonly retryDelayMs?: number;
|
|
2051
|
+
readonly run: (input: ScheduledAutomationRunInput) => Promise<ScheduledAutomationRunResult>;
|
|
2052
|
+
}
|
|
2053
|
+
interface ScheduledAutomationClock {
|
|
2054
|
+
now(): Date;
|
|
2055
|
+
sleep(milliseconds: number, signal: AbortSignal): Promise<void>;
|
|
2056
|
+
}
|
|
2057
|
+
interface ScheduledAutomation {
|
|
2058
|
+
running(): boolean;
|
|
2059
|
+
runDue(at: Date): Promise<AutomationTickRecord | undefined>;
|
|
2060
|
+
start(): Promise<void>;
|
|
2061
|
+
stop(): Promise<void>;
|
|
2062
|
+
}
|
|
2063
|
+
declare function createScheduledAutomation(options: ScheduledAutomationOptions): ScheduledAutomation;
|
|
2064
|
+
//#endregion
|
|
2065
|
+
//#region src/application/deployment/rivus-deployment-daemon.d.ts
|
|
2066
|
+
interface RivusDeploymentEndpoint {
|
|
2067
|
+
running(): boolean;
|
|
2068
|
+
start(): Promise<void> | void;
|
|
2069
|
+
stop(): Promise<void> | void;
|
|
2070
|
+
}
|
|
2071
|
+
interface RivusDeploymentAutomation {
|
|
2072
|
+
running(): boolean;
|
|
2073
|
+
start(): Promise<void> | void;
|
|
2074
|
+
stop(): Promise<void> | void;
|
|
2075
|
+
}
|
|
2076
|
+
interface CreateRivusDeploymentAutomationInput {
|
|
2077
|
+
readonly automationId: string;
|
|
2078
|
+
readonly definition: ResolvedRivusAutomationDefinition;
|
|
2079
|
+
readonly deliveryEndpoint: RivusEndpointDeployment;
|
|
2080
|
+
readonly instanceId: string;
|
|
2081
|
+
readonly run: (input: ScheduledAutomationRunInput) => Promise<unknown>;
|
|
2082
|
+
}
|
|
2083
|
+
interface CreateRivusDeploymentEndpointInput {
|
|
2084
|
+
readonly agentId: string;
|
|
2085
|
+
readonly cancel: (input: AgentRuntimeCancellation) => Promise<boolean>;
|
|
2086
|
+
readonly endpointId: string;
|
|
2087
|
+
readonly definition: RivusEndpointDeployment;
|
|
2088
|
+
readonly handle: (input: RivusEndpointInput) => Promise<unknown>;
|
|
2089
|
+
readonly instanceId: string;
|
|
2090
|
+
}
|
|
2091
|
+
interface CreateRivusDeploymentRuntimeInput extends AgentInstanceRecord {
|
|
2092
|
+
readonly catalog: RivusPluginCatalog;
|
|
2093
|
+
readonly definition: ResolvedRivusAgentDefinition;
|
|
2094
|
+
}
|
|
2095
|
+
interface CreateRivusDeploymentDaemonOptions {
|
|
2096
|
+
readonly deploymentRoot: string;
|
|
2097
|
+
readonly manifest: RivusDeploymentManifest;
|
|
2098
|
+
readonly loadModule: (request: RivusPluginModuleLoadRequest) => Promise<RivusPluginModule> | RivusPluginModule;
|
|
2099
|
+
readonly initialInstanceRecords?: AgentInstanceRegistryOptions["initialRecords"];
|
|
2100
|
+
readonly createRuntime: (input: CreateRivusDeploymentRuntimeInput) => PooledAgentRuntime | Promise<PooledAgentRuntime>;
|
|
2101
|
+
readonly createEndpoint: (input: CreateRivusDeploymentEndpointInput) => RivusDeploymentEndpoint | Promise<RivusDeploymentEndpoint>;
|
|
2102
|
+
readonly createAutomation?: (input: CreateRivusDeploymentAutomationInput) => RivusDeploymentAutomation | Promise<RivusDeploymentAutomation>;
|
|
2103
|
+
}
|
|
2104
|
+
type RivusDeploymentComponentLifecycle = "disabled" | "stopped" | "starting" | "running" | "degraded" | "stopping" | "cleanup-required";
|
|
2105
|
+
type RivusDeploymentEndpointLifecycle = RivusDeploymentComponentLifecycle;
|
|
2106
|
+
type RivusDeploymentAutomationLifecycle = RivusDeploymentComponentLifecycle;
|
|
2107
|
+
interface RivusDeploymentEndpointStatus {
|
|
2108
|
+
readonly agentId: string;
|
|
2109
|
+
readonly endpointId: string;
|
|
2110
|
+
readonly enabled: boolean;
|
|
2111
|
+
readonly required: boolean;
|
|
2112
|
+
readonly running: boolean;
|
|
2113
|
+
readonly lifecycle: RivusDeploymentEndpointLifecycle;
|
|
2114
|
+
readonly error?: string;
|
|
2115
|
+
}
|
|
2116
|
+
type RivusDeploymentDaemonLifecycle = "stopped" | "starting" | "running" | "degraded" | "stopping" | "cleanup-required";
|
|
2117
|
+
interface RivusDeploymentDaemonStatus {
|
|
2118
|
+
readonly running: boolean;
|
|
2119
|
+
readonly ready: boolean;
|
|
2120
|
+
readonly lifecycle: RivusDeploymentDaemonLifecycle;
|
|
2121
|
+
readonly defaultAgentId: string;
|
|
2122
|
+
readonly defaultEndpointId: string;
|
|
2123
|
+
readonly plugins: LoadedRivusDeployment["plugins"];
|
|
2124
|
+
readonly agents: LoadedRivusDeployment["agents"];
|
|
2125
|
+
readonly endpoints: ReadonlyArray<RivusDeploymentEndpointStatus>;
|
|
2126
|
+
readonly automations: ReadonlyArray<RivusDeploymentAutomationStatus>;
|
|
2127
|
+
}
|
|
2128
|
+
interface RivusDeploymentAutomationStatus {
|
|
2129
|
+
readonly agentId: string;
|
|
2130
|
+
readonly automationId: string;
|
|
2131
|
+
readonly enabled: boolean;
|
|
2132
|
+
readonly required: boolean;
|
|
2133
|
+
readonly running: boolean;
|
|
2134
|
+
readonly lifecycle: RivusDeploymentAutomationLifecycle;
|
|
2135
|
+
readonly error?: string;
|
|
2136
|
+
}
|
|
2137
|
+
interface RivusDeploymentDaemon {
|
|
2138
|
+
readonly deployment: LoadedRivusDeployment;
|
|
2139
|
+
handleDefault(input: RivusEndpointInput): Promise<unknown>;
|
|
2140
|
+
handleEndpoint(endpointId: string, input: RivusEndpointInput): Promise<unknown>;
|
|
2141
|
+
runDefaultAgent(input: RivusEndpointInput): Promise<unknown>;
|
|
2142
|
+
running(): boolean;
|
|
2143
|
+
start(): Promise<void>;
|
|
2144
|
+
status(): RivusDeploymentDaemonStatus;
|
|
2145
|
+
stop(): Promise<void>;
|
|
2146
|
+
}
|
|
2147
|
+
declare class RivusDeploymentDaemonLifecycleError extends Error {
|
|
2148
|
+
readonly name = "RivusDeploymentDaemonLifecycleError";
|
|
2149
|
+
}
|
|
2150
|
+
declare class RivusDeploymentReadinessError extends Error {
|
|
2151
|
+
readonly endpointIds: ReadonlyArray<string>;
|
|
2152
|
+
readonly name = "RivusDeploymentReadinessError";
|
|
2153
|
+
constructor(endpointIds: ReadonlyArray<string>);
|
|
2154
|
+
}
|
|
2155
|
+
declare class RivusDeploymentAutomationReadinessError extends Error {
|
|
2156
|
+
readonly automationIds: ReadonlyArray<string>;
|
|
2157
|
+
readonly name = "RivusDeploymentAutomationReadinessError";
|
|
2158
|
+
constructor(automationIds: ReadonlyArray<string>);
|
|
2159
|
+
}
|
|
2160
|
+
declare function createRivusDeploymentDaemon(options: CreateRivusDeploymentDaemonOptions): Promise<RivusDeploymentDaemon>;
|
|
2161
|
+
//#endregion
|
|
2162
|
+
//#region src/composition/rivus-deployment-cli-process.d.ts
|
|
2163
|
+
interface RivusDeploymentBootstrapAdapters {
|
|
2164
|
+
readonly initialInstanceRecords?: AgentInstanceRegistryOptions["initialRecords"];
|
|
2165
|
+
readonly dispose?: () => Promise<void> | void;
|
|
2166
|
+
readonly createAutomation?: (input: CreateRivusDeploymentAutomationInput) => RivusDeploymentAutomation | Promise<RivusDeploymentAutomation>;
|
|
2167
|
+
readonly createRecoveryControl?: () => Promise<RecoveryControl> | RecoveryControl;
|
|
2168
|
+
readonly createRuntime: (input: CreateRivusDeploymentRuntimeInput) => PooledAgentRuntime | Promise<PooledAgentRuntime>;
|
|
2169
|
+
readonly createEndpoint: (input: CreateRivusDeploymentEndpointInput) => RivusDeploymentEndpoint | Promise<RivusDeploymentEndpoint>;
|
|
2170
|
+
readonly replayReceiveMessage?: (handleDefault: (input: RivusEndpointInput) => Promise<unknown>, payload: FeishuReceiveMessagePayload, options?: FeishuReceiveMessageReplayOptions) => Effect.Effect<FeishuReceiveMessageReplayResult, unknown>;
|
|
2171
|
+
}
|
|
2172
|
+
interface RivusDeploymentBootstrapContext {
|
|
2173
|
+
readonly argv: ReadonlyArray<string>;
|
|
2174
|
+
readonly env: RivusDaemonEnv;
|
|
2175
|
+
readonly manifestPath: string;
|
|
2176
|
+
}
|
|
2177
|
+
type RivusDeploymentBootstrapFactory = (context: RivusDeploymentBootstrapContext) => Promise<RivusDeploymentBootstrapAdapters> | RivusDeploymentBootstrapAdapters;
|
|
2178
|
+
interface RivusDeploymentCliProcess extends RivusDaemonProcess {
|
|
2179
|
+
readonly defaultSessionKey: string;
|
|
2180
|
+
openRecoveryControl(): Effect.Effect<RecoveryControl, unknown>;
|
|
2181
|
+
promptText(command: PromptCommand): Effect.Effect<string, unknown>;
|
|
2182
|
+
replayReceiveMessage?(payload: FeishuReceiveMessagePayload, options?: FeishuReceiveMessageReplayOptions): Effect.Effect<FeishuReceiveMessageReplayResult, unknown>;
|
|
2183
|
+
status(): Effect.Effect<RivusDeploymentDaemonStatus>;
|
|
2184
|
+
}
|
|
2185
|
+
declare function createRivusDeploymentCliProcess(factory: RivusDeploymentBootstrapFactory, context: RivusDeploymentBootstrapContext): Promise<RivusDeploymentCliProcess>;
|
|
2186
|
+
//#endregion
|
|
2187
|
+
//#region src/composition/rivus-daemon-cli.d.ts
|
|
2188
|
+
interface RivusDaemonBootstrapContext {
|
|
2189
|
+
readonly argv: ReadonlyArray<string>;
|
|
2190
|
+
readonly config: RivusDaemonConfig;
|
|
2191
|
+
readonly env: RivusDaemonEnv;
|
|
2192
|
+
}
|
|
2193
|
+
type RivusDaemonBootstrapFactory = (context: RivusDaemonBootstrapContext) => Promise<RivusDaemonProcess> | RivusDaemonProcess;
|
|
2194
|
+
interface RivusDaemonBootstrapModule {
|
|
2195
|
+
readonly createRivusDaemonProcess?: RivusDaemonBootstrapFactory;
|
|
2196
|
+
readonly createRivusDeploymentAdapters?: RivusDeploymentBootstrapFactory;
|
|
2197
|
+
readonly default?: RivusDaemonBootstrapFactory;
|
|
2198
|
+
}
|
|
2199
|
+
interface RivusDaemonCliWriter {
|
|
2200
|
+
write(text: string): unknown;
|
|
2201
|
+
}
|
|
2202
|
+
interface RivusDaemonPromptRunner {
|
|
2203
|
+
readonly defaultSessionKey?: string;
|
|
2204
|
+
promptText(command: PromptCommand): Effect.Effect<string, unknown>;
|
|
2205
|
+
}
|
|
2206
|
+
interface RivusDaemonFeishuReplayRunner {
|
|
2207
|
+
replayReceiveMessage(payload: FeishuReceiveMessagePayload, options?: FeishuReceiveMessageReplayOptions): Effect.Effect<FeishuReceiveMessageReplayResult, unknown>;
|
|
2208
|
+
}
|
|
2209
|
+
interface RivusDaemonRecoveryRunner {
|
|
2210
|
+
openRecoveryControl(): Effect.Effect<RecoveryControl, unknown>;
|
|
2211
|
+
}
|
|
2212
|
+
interface RivusDaemonCliOptions {
|
|
2213
|
+
readonly argv: ReadonlyArray<string>;
|
|
2214
|
+
readonly env: RivusDaemonEnv;
|
|
2215
|
+
readonly exitAfterSignal?: (exitCode: number) => void;
|
|
2216
|
+
readonly loadBootstrap?: (specifier: string) => Promise<RivusDaemonBootstrapModule>;
|
|
2217
|
+
readonly signalSource: RivusDaemonSignalSource;
|
|
2218
|
+
readonly stderr: RivusDaemonCliWriter;
|
|
2219
|
+
readonly stdout: RivusDaemonCliWriter;
|
|
2220
|
+
}
|
|
2221
|
+
declare function runRivusDaemonCli(options: RivusDaemonCliOptions): Effect.Effect<number>;
|
|
2222
|
+
//#endregion
|
|
2223
|
+
//#region src/infrastructure/feishu/feishu-human-interaction-card.d.ts
|
|
2224
|
+
interface FeishuRawCardJson {
|
|
2225
|
+
readonly body: {
|
|
2226
|
+
readonly elements: ReadonlyArray<unknown>;
|
|
2227
|
+
};
|
|
2228
|
+
readonly config: {
|
|
2229
|
+
readonly streaming_mode?: boolean;
|
|
2230
|
+
readonly update_multi: true;
|
|
2231
|
+
};
|
|
2232
|
+
readonly header: {
|
|
2233
|
+
readonly template: "blue" | "green" | "grey" | "orange" | "red";
|
|
2234
|
+
readonly title: {
|
|
2235
|
+
readonly content: string;
|
|
2236
|
+
readonly tag: "plain_text";
|
|
2237
|
+
};
|
|
2238
|
+
};
|
|
2239
|
+
readonly schema: "2.0";
|
|
2240
|
+
}
|
|
2241
|
+
declare function createFeishuHumanInteractionCard(interaction: HumanInteraction): FeishuRawCardJson;
|
|
2242
|
+
//#endregion
|
|
2243
|
+
//#region src/infrastructure/feishu/feishu-card-action-response.d.ts
|
|
2244
|
+
interface FeishuCardActionCallbackResponse {
|
|
2245
|
+
readonly card?: {
|
|
2246
|
+
readonly data: FeishuRawCardJson;
|
|
2247
|
+
readonly type: "raw";
|
|
2248
|
+
};
|
|
2249
|
+
readonly toast: FeishuCardActionToast;
|
|
2250
|
+
}
|
|
2251
|
+
interface FeishuCardActionToast {
|
|
2252
|
+
readonly type: "success" | "info" | "warning" | "error";
|
|
2253
|
+
readonly content: string;
|
|
2254
|
+
readonly i18n?: {
|
|
2255
|
+
readonly en_us?: string;
|
|
2256
|
+
readonly zh_cn?: string;
|
|
2257
|
+
};
|
|
2258
|
+
}
|
|
2259
|
+
declare function createFeishuCardActionCallbackResponse(result: FeishuAgentDaemonHandleResult): FeishuCardActionCallbackResponse;
|
|
2260
|
+
declare function createFeishuCardActionErrorResponse(): FeishuCardActionCallbackResponse;
|
|
2261
|
+
//#endregion
|
|
2262
|
+
//#region src/infrastructure/feishu/feishu-event-handlers.d.ts
|
|
2263
|
+
interface FeishuEventHandlerQueue {
|
|
2264
|
+
accept(payload: FeishuReceiveMessagePayload): Effect.Effect<FeishuMessageAcceptResult, unknown>;
|
|
2265
|
+
}
|
|
2266
|
+
interface FeishuEventHandlerCardActions {
|
|
2267
|
+
handleCardAction(payload: FeishuCardActionTriggerPayload): Effect.Effect<FeishuAgentDaemonHandleResult, unknown>;
|
|
2268
|
+
}
|
|
2269
|
+
interface FeishuEventHandlersOptions {
|
|
2270
|
+
readonly cardActions?: FeishuEventHandlerCardActions;
|
|
2271
|
+
readonly queue: FeishuEventHandlerQueue;
|
|
2272
|
+
}
|
|
2273
|
+
interface FeishuSdkReceiveMessagePayload {
|
|
2274
|
+
readonly message: FeishuReceiveMessagePayload["event"]["message"];
|
|
2275
|
+
readonly sender?: FeishuReceiveMessagePayload["event"]["sender"];
|
|
2276
|
+
readonly tenant_key?: string;
|
|
2277
|
+
}
|
|
2278
|
+
type FeishuReceiveMessageHandlerPayload = FeishuReceiveMessagePayload | FeishuSdkReceiveMessagePayload;
|
|
2279
|
+
interface FeishuEventHandlers {
|
|
2280
|
+
readonly "card.action.trigger"?: (payload: FeishuCardActionTriggerPayload) => Promise<FeishuCardActionCallbackResponse>;
|
|
2281
|
+
readonly "im.message.receive_v1": (payload: FeishuReceiveMessageHandlerPayload) => Promise<FeishuMessageAcceptResult>;
|
|
2282
|
+
}
|
|
2283
|
+
declare function createFeishuEventHandlers(options: FeishuEventHandlersOptions): FeishuEventHandlers;
|
|
2284
|
+
//#endregion
|
|
2285
|
+
//#region src/composition/feishu-agent-runtime.d.ts
|
|
2286
|
+
interface FeishuAgentRuntimeOptions {
|
|
2287
|
+
readonly agentId: string;
|
|
2288
|
+
readonly clock: AgentClock;
|
|
2289
|
+
readonly eventSinks?: ReadonlyArray<AgentDomainEventSink>;
|
|
2290
|
+
readonly initialEvents?: ReadonlyArray<AgentDomainEvent>;
|
|
2291
|
+
readonly initialRunStates?: ReadonlyArray<AgentRunState>;
|
|
2292
|
+
readonly loop: AgentLoop;
|
|
2293
|
+
readonly prepareRun?: (run: FeishuAgentRunPreparation) => Effect.Effect<void, unknown>;
|
|
2294
|
+
readonly periodicFlush?: FeishuPeriodicFlushSupervisor;
|
|
2295
|
+
readonly publish: (action: FeishuStreamAction) => Effect.Effect<void, unknown>;
|
|
2296
|
+
readonly runIds: RunIdGenerator;
|
|
2297
|
+
}
|
|
2298
|
+
interface FeishuPeriodicFlushSupervisor {
|
|
2299
|
+
withPeriodicFlush<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, unknown, R>;
|
|
2300
|
+
}
|
|
2301
|
+
interface FeishuAgentRuntime {
|
|
2302
|
+
readonly handlers: FeishuEventHandlers;
|
|
2303
|
+
readonly harness: AgentHarness;
|
|
2304
|
+
readonly queue: FeishuMessageQueue;
|
|
2305
|
+
readonly worker: FeishuMessageWorker;
|
|
2306
|
+
drainAvailable(): Effect.Effect<FeishuMessageWorkerDrainAvailableResult, unknown>;
|
|
2307
|
+
drainOne(): Effect.Effect<FeishuMessageDrainResult, unknown>;
|
|
2308
|
+
pending(): number;
|
|
2309
|
+
receiveStatus(): FeishuReceiveRuntimeStatus;
|
|
2310
|
+
replayReceiveMessage(payload: FeishuReceiveMessagePayload, options?: FeishuReceiveMessageReplayOptions): Effect.Effect<FeishuReceiveMessageReplayResult, unknown>;
|
|
2311
|
+
}
|
|
2312
|
+
declare function createFeishuAgentRuntime(options: FeishuAgentRuntimeOptions): FeishuAgentRuntime;
|
|
2313
|
+
//#endregion
|
|
2314
|
+
//#region src/application/agent/agent-history.d.ts
|
|
2315
|
+
interface AgentHistoryEventLog {
|
|
2316
|
+
readAll(): Effect.Effect<ReadonlyArray<AgentDomainEvent>, unknown>;
|
|
2317
|
+
}
|
|
2318
|
+
declare function restoreAgentHistory(eventLog: AgentHistoryEventLog): Effect.Effect<AgentHistory, unknown>;
|
|
2319
|
+
//#endregion
|
|
2320
|
+
//#region src/infrastructure/feishu/feishu-websocket-daemon.d.ts
|
|
2321
|
+
interface FeishuWebSocketClientStartOptions {
|
|
2322
|
+
readonly eventDispatcher: unknown;
|
|
2323
|
+
}
|
|
2324
|
+
interface FeishuWebSocketClient {
|
|
2325
|
+
connected?(): boolean;
|
|
2326
|
+
start(options: FeishuWebSocketClientStartOptions): void | Promise<void>;
|
|
2327
|
+
close?(): void | Promise<void>;
|
|
2328
|
+
disconnect?(): void | Promise<void>;
|
|
2329
|
+
stop?(): void | Promise<void>;
|
|
2330
|
+
}
|
|
2331
|
+
interface FeishuWebSocketEventDispatcher {
|
|
2332
|
+
register(handlers: FeishuEventHandlers): unknown;
|
|
2333
|
+
}
|
|
2334
|
+
declare function createLazyFeishuWebSocketEventDispatcher(create: () => FeishuWebSocketEventDispatcher): FeishuWebSocketEventDispatcher;
|
|
2335
|
+
interface FeishuWebSocketRuntime {
|
|
2336
|
+
readonly handlers: FeishuEventHandlers;
|
|
2337
|
+
drainAvailable?(): unknown;
|
|
2338
|
+
}
|
|
2339
|
+
type FeishuWebSocketDaemonOptions = {
|
|
2340
|
+
readonly client: FeishuWebSocketClient;
|
|
2341
|
+
readonly eventDispatcher: FeishuWebSocketEventDispatcher;
|
|
2342
|
+
readonly handlers: FeishuEventHandlers;
|
|
2343
|
+
readonly runtime?: never;
|
|
2344
|
+
} | {
|
|
2345
|
+
readonly client: FeishuWebSocketClient;
|
|
2346
|
+
readonly eventDispatcher: FeishuWebSocketEventDispatcher;
|
|
2347
|
+
readonly handlers?: never;
|
|
2348
|
+
readonly runtime: FeishuWebSocketRuntime;
|
|
2349
|
+
};
|
|
2350
|
+
interface FeishuWebSocketDaemon {
|
|
2351
|
+
running(): boolean;
|
|
2352
|
+
start(): Promise<void>;
|
|
2353
|
+
stop(): Promise<void>;
|
|
2354
|
+
}
|
|
2355
|
+
declare function createFeishuWebSocketDaemon(options: FeishuWebSocketDaemonOptions): FeishuWebSocketDaemon;
|
|
2356
|
+
//#endregion
|
|
2357
|
+
//#region src/infrastructure/feishu/feishu-cardkit-publisher.d.ts
|
|
2358
|
+
interface FeishuCardTarget {
|
|
2359
|
+
readonly cardId: string;
|
|
2360
|
+
readonly elementId: string;
|
|
2361
|
+
}
|
|
2362
|
+
interface FeishuCardKitTextUpdate {
|
|
2363
|
+
readonly cardId: string;
|
|
2364
|
+
readonly elementId: string;
|
|
2365
|
+
readonly content: string;
|
|
2366
|
+
readonly sequence: number;
|
|
2367
|
+
}
|
|
2368
|
+
interface FeishuCardKitFinish {
|
|
2369
|
+
readonly cardId: string;
|
|
2370
|
+
readonly text: string;
|
|
2371
|
+
readonly sequence: number;
|
|
2372
|
+
}
|
|
2373
|
+
interface FeishuCardKitFail {
|
|
2374
|
+
readonly cardId: string;
|
|
2375
|
+
readonly errorMessage: string;
|
|
2376
|
+
readonly sequence: number;
|
|
2377
|
+
}
|
|
2378
|
+
interface FeishuCardKitCancel {
|
|
2379
|
+
readonly cardId: string;
|
|
2380
|
+
readonly reason?: string;
|
|
2381
|
+
readonly sequence: number;
|
|
2382
|
+
}
|
|
2383
|
+
interface FeishuCardKitClient {
|
|
2384
|
+
cancel(request: FeishuCardKitCancel): Effect.Effect<void, unknown>;
|
|
2385
|
+
updateText(request: FeishuCardKitTextUpdate): Effect.Effect<void, unknown>;
|
|
2386
|
+
finish(request: FeishuCardKitFinish): Effect.Effect<void, unknown>;
|
|
2387
|
+
fail(request: FeishuCardKitFail): Effect.Effect<void, unknown>;
|
|
2388
|
+
}
|
|
2389
|
+
interface FeishuCardKitPublisherOptions {
|
|
2390
|
+
readonly client: FeishuCardKitClient;
|
|
2391
|
+
readonly ledger?: FeishuCardDeliveryLedger;
|
|
2392
|
+
readonly resolveTarget: (runId: AgentRunId) => Effect.Effect<FeishuCardTarget, unknown>;
|
|
2393
|
+
}
|
|
2394
|
+
interface FeishuCardKitPublisher {
|
|
2395
|
+
publish(action: FeishuStreamAction): Effect.Effect<void, unknown>;
|
|
2396
|
+
}
|
|
2397
|
+
declare function createFeishuCardKitPublisher(options: FeishuCardKitPublisherOptions): FeishuCardKitPublisher;
|
|
2398
|
+
//#endregion
|
|
2399
|
+
//#region src/infrastructure/feishu/feishu-card-target-registry.d.ts
|
|
2400
|
+
declare class FeishuCardTargetNotFound {
|
|
2401
|
+
readonly runId: AgentRunId;
|
|
2402
|
+
readonly _tag = "FeishuCardTargetNotFound";
|
|
2403
|
+
constructor(runId: AgentRunId);
|
|
2404
|
+
}
|
|
2405
|
+
type FeishuCardTargetRegistryOperation = "load" | "save";
|
|
2406
|
+
declare class FeishuCardTargetRegistryStoreError {
|
|
2407
|
+
readonly operation: FeishuCardTargetRegistryOperation;
|
|
2408
|
+
readonly cause: unknown;
|
|
2409
|
+
readonly _tag = "FeishuCardTargetRegistryStoreError";
|
|
2410
|
+
constructor(operation: FeishuCardTargetRegistryOperation, cause: unknown);
|
|
2411
|
+
}
|
|
2412
|
+
interface FeishuCardTargetRegistry {
|
|
2413
|
+
bind(runId: AgentRunId, target: FeishuCardTarget): Effect.Effect<void, FeishuCardTargetRegistryStoreError>;
|
|
2414
|
+
release(runId: AgentRunId): Effect.Effect<void, FeishuCardTargetRegistryStoreError>;
|
|
2415
|
+
resolveTarget(runId: AgentRunId): Effect.Effect<FeishuCardTarget, FeishuCardTargetNotFound | FeishuCardTargetRegistryStoreError>;
|
|
2416
|
+
size(): number;
|
|
2417
|
+
}
|
|
2418
|
+
interface JsonFileFeishuCardTargetRegistryOptions {
|
|
2419
|
+
readonly filePath: string;
|
|
2420
|
+
}
|
|
2421
|
+
declare function createInMemoryFeishuCardTargetRegistry(): FeishuCardTargetRegistry;
|
|
2422
|
+
declare function createJsonFileFeishuCardTargetRegistry(options: JsonFileFeishuCardTargetRegistryOptions): FeishuCardTargetRegistry;
|
|
2423
|
+
//#endregion
|
|
2424
|
+
//#region src/infrastructure/feishu/feishu-rate-limited-publisher.d.ts
|
|
2425
|
+
interface FeishuStreamActionPublisher {
|
|
2426
|
+
publish(action: FeishuStreamAction): Effect.Effect<void, unknown>;
|
|
2427
|
+
}
|
|
2428
|
+
interface RateLimitedFeishuPublisherOptions {
|
|
2429
|
+
readonly publisher: FeishuStreamActionPublisher;
|
|
2430
|
+
readonly minIntervalMs: number;
|
|
2431
|
+
readonly sleep: (ms: number) => Effect.Effect<void, unknown>;
|
|
2432
|
+
}
|
|
2433
|
+
declare function createRateLimitedFeishuPublisher(options: RateLimitedFeishuPublisherOptions): FeishuStreamActionPublisher;
|
|
2434
|
+
//#endregion
|
|
2435
|
+
//#region src/infrastructure/feishu/feishu-coalescing-publisher.d.ts
|
|
2436
|
+
interface FeishuCoalescingPublisher extends FeishuStreamActionPublisher {
|
|
2437
|
+
flush(runId?: AgentRunId): Effect.Effect<void, unknown>;
|
|
2438
|
+
}
|
|
2439
|
+
interface FeishuCoalescingPublisherOptions {
|
|
2440
|
+
readonly publisher: FeishuStreamActionPublisher;
|
|
2441
|
+
}
|
|
2442
|
+
declare function createCoalescingFeishuPublisher(options: FeishuCoalescingPublisherOptions): FeishuCoalescingPublisher;
|
|
2443
|
+
//#endregion
|
|
2444
|
+
//#region src/infrastructure/feishu/feishu-tenant-token-provider.d.ts
|
|
2445
|
+
interface FeishuTenantAccessTokenRequest {
|
|
2446
|
+
readonly method: "POST";
|
|
2447
|
+
readonly url: string;
|
|
2448
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
2449
|
+
readonly body: {
|
|
2450
|
+
readonly app_id: string;
|
|
2451
|
+
readonly app_secret: string;
|
|
2452
|
+
};
|
|
2453
|
+
}
|
|
2454
|
+
interface FeishuTenantAccessTokenResponse {
|
|
2455
|
+
readonly status: number;
|
|
2456
|
+
readonly body: {
|
|
2457
|
+
readonly code?: number;
|
|
2458
|
+
readonly msg?: string;
|
|
2459
|
+
readonly tenant_access_token?: string;
|
|
2460
|
+
readonly expire?: number;
|
|
2461
|
+
};
|
|
2462
|
+
}
|
|
2463
|
+
interface FeishuTenantAccessTokenProviderOptions {
|
|
2464
|
+
readonly appId: string;
|
|
2465
|
+
readonly appSecret: string;
|
|
2466
|
+
readonly baseUrl?: string;
|
|
2467
|
+
readonly refreshWindowMs?: number;
|
|
2468
|
+
readonly now?: () => number;
|
|
2469
|
+
readonly request: (request: FeishuTenantAccessTokenRequest) => Effect.Effect<FeishuTenantAccessTokenResponse, unknown>;
|
|
2470
|
+
}
|
|
2471
|
+
interface FeishuTenantAccessTokenProvider {
|
|
2472
|
+
getTenantAccessToken(): Effect.Effect<string, unknown>;
|
|
2473
|
+
}
|
|
2474
|
+
declare class FeishuTenantAccessTokenError {
|
|
2475
|
+
readonly status: number;
|
|
2476
|
+
readonly code: number | undefined;
|
|
2477
|
+
readonly message: string;
|
|
2478
|
+
readonly _tag = "FeishuTenantAccessTokenError";
|
|
2479
|
+
constructor(status: number, code: number | undefined, message: string);
|
|
2480
|
+
}
|
|
2481
|
+
declare function createFeishuTenantAccessTokenProvider(options: FeishuTenantAccessTokenProviderOptions): FeishuTenantAccessTokenProvider;
|
|
2482
|
+
//#endregion
|
|
2483
|
+
//#region src/infrastructure/feishu/feishu-openapi-client.d.ts
|
|
2484
|
+
interface FeishuOpenApiRequest {
|
|
2485
|
+
readonly method: "PATCH" | "POST" | "PUT";
|
|
2486
|
+
readonly url: string;
|
|
2487
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
2488
|
+
readonly body: unknown;
|
|
2489
|
+
}
|
|
2490
|
+
interface FeishuOpenApiResponse {
|
|
2491
|
+
readonly status: number;
|
|
2492
|
+
readonly body: {
|
|
2493
|
+
readonly code?: number;
|
|
2494
|
+
readonly msg?: string;
|
|
2495
|
+
readonly data?: unknown;
|
|
2496
|
+
};
|
|
2497
|
+
}
|
|
2498
|
+
interface FeishuOpenApiClient {
|
|
2499
|
+
request(request: Omit<FeishuOpenApiRequest, "headers">, errorMessage?: string): Effect.Effect<FeishuOpenApiResponse, unknown>;
|
|
2500
|
+
}
|
|
2501
|
+
type ConfiguredFeishuOpenApiRequest = FeishuOpenApiRequest | FeishuTenantAccessTokenRequest;
|
|
2502
|
+
type ConfiguredFeishuOpenApiResponse = FeishuOpenApiResponse | FeishuTenantAccessTokenResponse;
|
|
2503
|
+
declare class FeishuOpenApiError extends Error {
|
|
2504
|
+
readonly status: number;
|
|
2505
|
+
readonly code: number | undefined;
|
|
2506
|
+
readonly _tag = "FeishuOpenApiError";
|
|
2507
|
+
readonly name = "FeishuOpenApiError";
|
|
2508
|
+
constructor(status: number, code: number | undefined, message: string);
|
|
2509
|
+
}
|
|
2510
|
+
declare function createFeishuOpenApiClient(options: {
|
|
2511
|
+
readonly getTenantAccessToken: () => Effect.Effect<string, unknown>;
|
|
2512
|
+
readonly request: (request: FeishuOpenApiRequest) => Effect.Effect<FeishuOpenApiResponse, unknown>;
|
|
2513
|
+
}): FeishuOpenApiClient;
|
|
2514
|
+
declare function createConfiguredFeishuOpenApiClient(options: {
|
|
2515
|
+
readonly config: RivusDaemonConfig;
|
|
2516
|
+
readonly request: (request: ConfiguredFeishuOpenApiRequest) => Effect.Effect<ConfiguredFeishuOpenApiResponse, unknown>;
|
|
2517
|
+
}): FeishuOpenApiClient;
|
|
2518
|
+
//#endregion
|
|
2519
|
+
//#region src/infrastructure/persistence/jsonl-agent-event-log.d.ts
|
|
2520
|
+
type AgentEventLogOperation = "append" | "read";
|
|
2521
|
+
declare class AgentEventLogStoreError {
|
|
2522
|
+
readonly operation: AgentEventLogOperation;
|
|
2523
|
+
readonly cause: unknown;
|
|
2524
|
+
readonly _tag = "AgentEventLogStoreError";
|
|
2525
|
+
constructor(operation: AgentEventLogOperation, cause: unknown);
|
|
2526
|
+
}
|
|
2527
|
+
interface AgentEventLog extends AgentDomainEventSink {
|
|
2528
|
+
append(event: AgentDomainEvent): Effect.Effect<void, AgentEventLogStoreError>;
|
|
2529
|
+
readAll(): Effect.Effect<ReadonlyArray<AgentDomainEvent>, AgentEventLogStoreError>;
|
|
2530
|
+
readRun(runId: AgentRunId): Effect.Effect<ReadonlyArray<AgentDomainEvent>, AgentEventLogStoreError>;
|
|
2531
|
+
}
|
|
2532
|
+
interface JsonlAgentEventLogOptions {
|
|
2533
|
+
readonly filePath: string;
|
|
2534
|
+
}
|
|
2535
|
+
declare function createJsonlAgentEventLog(options: JsonlAgentEventLogOptions): AgentEventLog;
|
|
2536
|
+
//#endregion
|
|
2537
|
+
//#region src/composition/rivus-daemon-bootstrap.d.ts
|
|
2538
|
+
type ConfiguredRivusDaemonBootstrapRequest = ConfiguredFeishuOpenApiRequest;
|
|
2539
|
+
type ConfiguredRivusDaemonBootstrapResponse = ConfiguredFeishuOpenApiResponse;
|
|
2540
|
+
interface ConfiguredRivusDaemonBootstrapOptions {
|
|
2541
|
+
readonly cardTargets: FeishuCardTargetRegistry;
|
|
2542
|
+
readonly clock: AgentClock;
|
|
2543
|
+
readonly config: RivusDaemonConfig;
|
|
2544
|
+
readonly createStatusTransport?: (statusReporter: RivusDaemonStatusReporter) => RivusDaemonTransport;
|
|
2545
|
+
readonly eventDispatcher: FeishuWebSocketEventDispatcher;
|
|
2546
|
+
readonly eventLog: AgentEventLog;
|
|
2547
|
+
readonly flushIntervalMs?: number;
|
|
2548
|
+
readonly initialEvents?: ReadonlyArray<AgentDomainEvent>;
|
|
2549
|
+
readonly initialRunStates?: ReadonlyArray<AgentRunState>;
|
|
2550
|
+
readonly loop: AgentLoop;
|
|
2551
|
+
readonly onWorkerError?: (error: unknown) => void | Promise<void>;
|
|
2552
|
+
readonly request: (request: ConfiguredRivusDaemonBootstrapRequest) => Effect.Effect<ConfiguredRivusDaemonBootstrapResponse, unknown>;
|
|
2553
|
+
readonly runIds: RunIdGenerator;
|
|
2554
|
+
readonly sleep: (ms: number) => Effect.Effect<void, unknown>;
|
|
2555
|
+
readonly websocketClient: FeishuWebSocketClient;
|
|
2556
|
+
readonly workerIntervalMs?: number;
|
|
2557
|
+
}
|
|
2558
|
+
interface ConfiguredRivusDaemonBootstrap {
|
|
2559
|
+
readonly cardTargets: FeishuCardTargetRegistry;
|
|
2560
|
+
readonly eventLog: AgentEventLog;
|
|
2561
|
+
readonly process: RivusDaemonProcess;
|
|
2562
|
+
readonly publisher: FeishuCoalescingPublisher;
|
|
2563
|
+
readonly runtime: FeishuAgentRuntime;
|
|
2564
|
+
readonly statusReporter: RivusDaemonStatusReporter;
|
|
2565
|
+
readonly transport: RivusDaemonTransport;
|
|
2566
|
+
readonly websocketTransport: FeishuWebSocketDaemon;
|
|
2567
|
+
readonly workerLoop: FeishuWorkerLoop;
|
|
2568
|
+
promptText(command: PromptCommand): Effect.Effect<string, unknown>;
|
|
2569
|
+
restoreHistory(): Effect.Effect<AgentHistory, unknown>;
|
|
2570
|
+
status(): Effect.Effect<RivusDaemonStatus, unknown>;
|
|
2571
|
+
}
|
|
2572
|
+
declare function restoreConfiguredRivusDaemonBootstrap(options: ConfiguredRivusDaemonBootstrapOptions): Effect.Effect<ConfiguredRivusDaemonBootstrap, unknown>;
|
|
2573
|
+
declare function createConfiguredRivusDaemonBootstrap(options: ConfiguredRivusDaemonBootstrapOptions): ConfiguredRivusDaemonBootstrap;
|
|
2574
|
+
//#endregion
|
|
2575
|
+
//#region src/application/agent/agent-model-content-observer.d.ts
|
|
2576
|
+
interface AgentModelInputObservation {
|
|
2577
|
+
readonly input: unknown;
|
|
2578
|
+
readonly modelCallId: string;
|
|
2579
|
+
readonly runId: AgentRunId;
|
|
2580
|
+
}
|
|
2581
|
+
interface AgentModelOutputObservation {
|
|
2582
|
+
readonly modelCallId: string;
|
|
2583
|
+
readonly output: unknown;
|
|
2584
|
+
readonly runId: AgentRunId;
|
|
2585
|
+
}
|
|
2586
|
+
interface AgentModelContentObserver {
|
|
2587
|
+
observeInput(observation: AgentModelInputObservation): void;
|
|
2588
|
+
observeOutput(observation: AgentModelOutputObservation): void;
|
|
2589
|
+
}
|
|
2590
|
+
//#endregion
|
|
2591
|
+
//#region src/infrastructure/observability/langfuse-agent-telemetry.d.ts
|
|
2592
|
+
type LangfuseTelemetryEnv = Readonly<Record<string, string | undefined>>;
|
|
2593
|
+
type LangfuseTelemetryContentMode = "metadata-only" | "redacted";
|
|
2594
|
+
interface LangfuseTelemetryConfig {
|
|
2595
|
+
readonly contentMode?: LangfuseTelemetryContentMode;
|
|
2596
|
+
readonly endpoint: string;
|
|
2597
|
+
readonly environment: string;
|
|
2598
|
+
readonly publicKey: string;
|
|
2599
|
+
readonly secretKey: string;
|
|
2600
|
+
readonly serviceName: string;
|
|
2601
|
+
}
|
|
2602
|
+
interface LangfuseAgentTelemetry {
|
|
2603
|
+
readonly modelContentObserver: AgentModelContentObserver;
|
|
2604
|
+
readonly sink: AgentDomainEventSink;
|
|
2605
|
+
forceFlush(): Promise<void>;
|
|
2606
|
+
shutdown(): Promise<void>;
|
|
2607
|
+
}
|
|
2608
|
+
declare class LangfuseTelemetryConfigError extends Error {
|
|
2609
|
+
constructor(message: string);
|
|
2610
|
+
}
|
|
2611
|
+
declare function resolveLangfuseTelemetryConfig(env: LangfuseTelemetryEnv): LangfuseTelemetryConfig | undefined;
|
|
2612
|
+
declare function createLangfuseAgentTelemetry(config: LangfuseTelemetryConfig): LangfuseAgentTelemetry;
|
|
2613
|
+
//#endregion
|
|
2614
|
+
//#region src/infrastructure/observability/telemetry-content-redactor.d.ts
|
|
2615
|
+
interface TelemetryContentRedactorOptions {
|
|
2616
|
+
readonly maxArrayItems?: number;
|
|
2617
|
+
readonly maxDepth?: number;
|
|
2618
|
+
readonly maxObjectKeys?: number;
|
|
2619
|
+
readonly maxSerializedLength?: number;
|
|
2620
|
+
readonly maxStringLength?: number;
|
|
2621
|
+
}
|
|
2622
|
+
type TelemetryContentRedactor = (value: unknown) => string;
|
|
2623
|
+
declare function createTelemetryContentRedactor(options?: TelemetryContentRedactorOptions): TelemetryContentRedactor;
|
|
2624
|
+
//#endregion
|
|
2625
|
+
//#region src/infrastructure/observability/open-telemetry-agent-event-sink.d.ts
|
|
2626
|
+
interface OpenTelemetryAgentEventSinkOptions {
|
|
2627
|
+
readonly captureContent?: boolean;
|
|
2628
|
+
readonly onProjectionError?: (error: unknown, event: AgentDomainEvent) => Promise<void> | void;
|
|
2629
|
+
readonly redactContent?: TelemetryContentRedactor;
|
|
2630
|
+
readonly tracer: Tracer;
|
|
2631
|
+
}
|
|
2632
|
+
interface OpenTelemetryAgentTelemetry {
|
|
2633
|
+
readonly modelContentObserver: AgentModelContentObserver;
|
|
2634
|
+
readonly sink: AgentDomainEventSink;
|
|
2635
|
+
}
|
|
2636
|
+
declare function createOpenTelemetryAgentEventSink(options: OpenTelemetryAgentEventSinkOptions): AgentDomainEventSink;
|
|
2637
|
+
declare function createOpenTelemetryAgentTelemetry(options: OpenTelemetryAgentEventSinkOptions): OpenTelemetryAgentTelemetry;
|
|
2638
|
+
//#endregion
|
|
2639
|
+
//#region src/infrastructure/pi/pi-skill-tool.d.ts
|
|
2640
|
+
interface PiSkillRuntime {
|
|
2641
|
+
readonly prompt: string;
|
|
2642
|
+
readonly tool?: ToolDefinition;
|
|
2643
|
+
}
|
|
2644
|
+
declare function createPiSkillRuntime(skills: ReadonlyArray<RegisteredRivusSkill>): PiSkillRuntime;
|
|
2645
|
+
//#endregion
|
|
2646
|
+
//#region src/infrastructure/pi/pi-agent-loop.d.ts
|
|
2647
|
+
type PiAgentSessionEvent = PiMessageStartEvent | PiMessageUpdateEvent | PiMessageEndEvent | PiToolExecutionStartEvent | PiToolExecutionUpdateEvent | PiToolExecutionEndEvent | {
|
|
2648
|
+
readonly type: string;
|
|
2649
|
+
readonly [key: string]: unknown;
|
|
2650
|
+
};
|
|
2651
|
+
interface PiMessageUpdateEvent {
|
|
2652
|
+
readonly type: "message_update";
|
|
2653
|
+
readonly message: unknown;
|
|
2654
|
+
readonly assistantMessageEvent: {
|
|
2655
|
+
readonly type: "text_delta";
|
|
2656
|
+
readonly contentIndex: number;
|
|
2657
|
+
readonly delta: string;
|
|
2658
|
+
readonly partial: unknown;
|
|
2659
|
+
} | {
|
|
2660
|
+
readonly type: "thinking_delta";
|
|
2661
|
+
readonly contentIndex: number;
|
|
2662
|
+
readonly delta: string;
|
|
2663
|
+
readonly partial: unknown;
|
|
2664
|
+
} | {
|
|
2665
|
+
readonly type: string;
|
|
2666
|
+
readonly [key: string]: unknown;
|
|
2667
|
+
};
|
|
2668
|
+
}
|
|
2669
|
+
interface PiMessageStartEvent {
|
|
2670
|
+
readonly type: "message_start";
|
|
2671
|
+
readonly message: unknown;
|
|
2672
|
+
}
|
|
2673
|
+
interface PiMessageEndEvent {
|
|
2674
|
+
readonly type: "message_end";
|
|
2675
|
+
readonly message: unknown;
|
|
2676
|
+
}
|
|
2677
|
+
interface PiToolExecutionStartEvent {
|
|
2678
|
+
readonly type: "tool_execution_start";
|
|
2679
|
+
readonly toolCallId: string;
|
|
2680
|
+
readonly toolName: string;
|
|
2681
|
+
readonly args?: unknown;
|
|
2682
|
+
readonly input?: unknown;
|
|
2683
|
+
}
|
|
2684
|
+
interface PiToolExecutionUpdateEvent {
|
|
2685
|
+
readonly type: "tool_execution_update";
|
|
2686
|
+
readonly toolCallId: string;
|
|
2687
|
+
readonly toolName: string;
|
|
2688
|
+
readonly args?: unknown;
|
|
2689
|
+
readonly input?: unknown;
|
|
2690
|
+
readonly partialResult: unknown;
|
|
2691
|
+
}
|
|
2692
|
+
interface PiToolExecutionEndEvent {
|
|
2693
|
+
readonly type: "tool_execution_end";
|
|
2694
|
+
readonly toolCallId: string;
|
|
2695
|
+
readonly toolName: string;
|
|
2696
|
+
readonly result: unknown;
|
|
2697
|
+
readonly isError: boolean;
|
|
2698
|
+
}
|
|
2699
|
+
interface PiAgentSession {
|
|
2700
|
+
abort?: () => Promise<void> | void;
|
|
2701
|
+
prompt(text: string): Promise<void>;
|
|
2702
|
+
readonly state?: unknown;
|
|
2703
|
+
subscribe(listener: (event: PiAgentSessionEvent) => void): () => void;
|
|
2704
|
+
dispose?: () => Promise<void> | void;
|
|
2705
|
+
}
|
|
2706
|
+
interface PiAgentSessionHandle {
|
|
2707
|
+
readonly activate?: (input: AgentLoopInput) => Promise<void> | void;
|
|
2708
|
+
readonly dispose?: () => Promise<void> | void;
|
|
2709
|
+
readonly resolveToolName?: (toolName: string) => string;
|
|
2710
|
+
readonly session: PiAgentSession;
|
|
2711
|
+
}
|
|
2712
|
+
interface PiAgentLoopOptions {
|
|
2713
|
+
readonly disposeSessionAfterRun?: boolean;
|
|
2714
|
+
readonly modelContentObserver?: AgentModelContentObserver;
|
|
2715
|
+
readonly resolveSession: (input: AgentLoopInput) => Promise<PiAgentSessionHandle> | PiAgentSessionHandle;
|
|
2716
|
+
}
|
|
2717
|
+
interface PiCreateAgentSessionResult {
|
|
2718
|
+
readonly session: PiAgentSession;
|
|
2719
|
+
}
|
|
2720
|
+
interface PiSdkAgentLoopOptions<TSessionOptions = unknown> {
|
|
2721
|
+
readonly createAgentSession: (options: TSessionOptions | undefined) => Promise<PiCreateAgentSessionResult> | PiCreateAgentSessionResult;
|
|
2722
|
+
readonly sessionOptions?: TSessionOptions;
|
|
2723
|
+
}
|
|
2724
|
+
declare function createPiAgentLoop(options: PiAgentLoopOptions): AgentLoop;
|
|
2725
|
+
declare function createPiSdkAgentLoop<TSessionOptions = unknown>(options: PiSdkAgentLoopOptions<TSessionOptions>): AgentLoop;
|
|
2726
|
+
//#endregion
|
|
2727
|
+
//#region src/infrastructure/pi/pi-session-registry.d.ts
|
|
2728
|
+
interface PiSessionRegistryOptions {
|
|
2729
|
+
readonly createSession: (input: AgentLoopInput) => Promise<PiAgentSessionHandle> | PiAgentSessionHandle;
|
|
2730
|
+
}
|
|
2731
|
+
interface PiSessionRegistry {
|
|
2732
|
+
resolve(input: AgentLoopInput): Promise<PiAgentSessionHandle>;
|
|
2733
|
+
size(): number;
|
|
2734
|
+
dispose(sessionKey: SessionKey): Promise<void>;
|
|
2735
|
+
disposeAll(): Promise<void>;
|
|
2736
|
+
}
|
|
2737
|
+
declare function createPiSessionRegistry(options: PiSessionRegistryOptions): PiSessionRegistry;
|
|
2738
|
+
//#endregion
|
|
2739
|
+
//#region src/infrastructure/feishu/feishu-cardkit-openapi-client.d.ts
|
|
2740
|
+
interface FeishuCardKitOpenApiClientOptions {
|
|
2741
|
+
readonly agentName?: string;
|
|
2742
|
+
readonly baseUrl?: string;
|
|
2743
|
+
readonly client: FeishuOpenApiClient;
|
|
2744
|
+
}
|
|
2745
|
+
declare function createFeishuCardKitOpenApiClient(options: FeishuCardKitOpenApiClientOptions): FeishuCardKitClient;
|
|
2746
|
+
//#endregion
|
|
2747
|
+
//#region src/infrastructure/feishu/feishu-cot-publisher.d.ts
|
|
2748
|
+
type FeishuCotRunPreparation = FeishuAgentRunPreparation;
|
|
2749
|
+
interface FeishuCotPublisher {
|
|
2750
|
+
fail(runId: string): Effect.Effect<void, unknown>;
|
|
2751
|
+
prepare(run: FeishuCotRunPreparation): Effect.Effect<void, unknown>;
|
|
2752
|
+
publish(update: AgentRunUpdate): Effect.Effect<void, unknown>;
|
|
2753
|
+
}
|
|
2754
|
+
interface FeishuCotPublisherOptions {
|
|
2755
|
+
readonly baseUrl: string;
|
|
2756
|
+
readonly client: FeishuOpenApiClient;
|
|
2757
|
+
readonly minIntervalMs: number;
|
|
2758
|
+
readonly now?: () => number;
|
|
2759
|
+
}
|
|
2760
|
+
declare class FeishuCotProtocolError extends Error {
|
|
2761
|
+
readonly name = "FeishuCotProtocolError";
|
|
2762
|
+
}
|
|
2763
|
+
declare function createFeishuCotPublisher(options: FeishuCotPublisherOptions): FeishuCotPublisher;
|
|
2764
|
+
//#endregion
|
|
2765
|
+
//#region src/infrastructure/feishu/feishu-cardkit-target-preparation.d.ts
|
|
2766
|
+
interface FeishuCardTargetCreator {
|
|
2767
|
+
createTarget(run: FeishuAgentRunPreparation): Effect.Effect<FeishuCardTarget, unknown>;
|
|
2768
|
+
}
|
|
2769
|
+
interface FeishuCardTargetPreparationOptions {
|
|
2770
|
+
readonly createTarget: (run: FeishuAgentRunPreparation) => Effect.Effect<FeishuCardTarget, unknown>;
|
|
2771
|
+
readonly registry: FeishuCardTargetRegistry;
|
|
2772
|
+
}
|
|
2773
|
+
interface FeishuCardKitOpenApiTargetCreatorOptions {
|
|
2774
|
+
readonly baseUrl?: string;
|
|
2775
|
+
readonly client: FeishuOpenApiClient;
|
|
2776
|
+
readonly elementId: string;
|
|
2777
|
+
readonly initialContent?: string;
|
|
2778
|
+
readonly title?: string;
|
|
2779
|
+
}
|
|
2780
|
+
interface ConfiguredFeishuCardKitTargetPreparationOptions {
|
|
2781
|
+
readonly client: FeishuOpenApiClient;
|
|
2782
|
+
readonly config: RivusDaemonConfig;
|
|
2783
|
+
readonly elementId?: string;
|
|
2784
|
+
readonly initialContent?: string;
|
|
2785
|
+
readonly registry: FeishuCardTargetRegistry;
|
|
2786
|
+
readonly title?: string;
|
|
2787
|
+
}
|
|
2788
|
+
declare function createFeishuCardTargetPreparation(options: FeishuCardTargetPreparationOptions): (run: FeishuAgentRunPreparation) => Effect.Effect<void, unknown>;
|
|
2789
|
+
declare function createConfiguredFeishuCardKitTargetPreparation(options: ConfiguredFeishuCardKitTargetPreparationOptions): (run: FeishuAgentRunPreparation) => Effect.Effect<void, unknown>;
|
|
2790
|
+
declare function createFeishuCardKitOpenApiTargetCreator(options: FeishuCardKitOpenApiTargetCreatorOptions): FeishuCardTargetCreator;
|
|
2791
|
+
//#endregion
|
|
2792
|
+
//#region src/infrastructure/feishu/feishu-configured-cardkit-publisher.d.ts
|
|
2793
|
+
interface ConfiguredFeishuCardKitPublisherOptions {
|
|
2794
|
+
readonly agentName?: string;
|
|
2795
|
+
readonly client: FeishuOpenApiClient;
|
|
2796
|
+
readonly config: RivusDaemonConfig;
|
|
2797
|
+
readonly ledger?: FeishuCardDeliveryLedger;
|
|
2798
|
+
readonly resolveTarget: (runId: AgentRunId) => Effect.Effect<FeishuCardTarget, unknown>;
|
|
2799
|
+
readonly sleep: (ms: number) => Effect.Effect<void, unknown>;
|
|
2800
|
+
}
|
|
2801
|
+
declare function createConfiguredFeishuCardKitPublisher(options: ConfiguredFeishuCardKitPublisherOptions): FeishuCoalescingPublisher;
|
|
2802
|
+
//#endregion
|
|
2803
|
+
//#region src/infrastructure/feishu/feishu-periodic-flush.d.ts
|
|
2804
|
+
interface FeishuPeriodicFlushOptions {
|
|
2805
|
+
readonly flush: () => Effect.Effect<void, unknown>;
|
|
2806
|
+
readonly intervalMs: number;
|
|
2807
|
+
readonly sleep: (ms: number) => Effect.Effect<void, unknown>;
|
|
2808
|
+
}
|
|
2809
|
+
interface FeishuPeriodicFlush {
|
|
2810
|
+
withPeriodicFlush<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, unknown, R>;
|
|
2811
|
+
}
|
|
2812
|
+
declare function createFeishuPeriodicFlush(options: FeishuPeriodicFlushOptions): FeishuPeriodicFlush;
|
|
2813
|
+
//#endregion
|
|
2814
|
+
//#region src/testing/fakes.d.ts
|
|
2815
|
+
declare function createFixedClock(now: Date): AgentClock;
|
|
2816
|
+
declare function createSequenceRunIds(runIds: ReadonlyArray<AgentRunId>): RunIdGenerator;
|
|
2817
|
+
//#endregion
|
|
2818
|
+
//#region src/application/plugin/rivus-plugin-registry.d.ts
|
|
2819
|
+
declare function createRivusPluginCatalog(): RivusPluginCatalog;
|
|
2820
|
+
declare function resolveRivusAgentDefinition(catalog: RivusPluginCatalog, deployment: RivusAgentDeployment): ResolvedRivusAgentDefinition;
|
|
2821
|
+
//#endregion
|
|
2822
|
+
//#region src/application/workspace/workspace-instructions.d.ts
|
|
2823
|
+
interface WorkspaceRootHandle {
|
|
2824
|
+
readonly id: string;
|
|
2825
|
+
}
|
|
2826
|
+
interface WorkspaceInstructionSource {
|
|
2827
|
+
readonly relativePath: string;
|
|
2828
|
+
readonly digest: string;
|
|
2829
|
+
readonly bytes: number;
|
|
2830
|
+
readonly content: string;
|
|
2831
|
+
}
|
|
2832
|
+
type WorkspaceInstructionsDiagnosticCode = "workspace-instructions-refresh-required" | "workspace-instructions-source-omitted";
|
|
2833
|
+
interface WorkspaceInstructionsDiagnostic {
|
|
2834
|
+
readonly code: WorkspaceInstructionsDiagnosticCode;
|
|
2835
|
+
readonly relativePath?: string;
|
|
2836
|
+
readonly reason: string;
|
|
2837
|
+
}
|
|
2838
|
+
interface WorkspaceInstructionsRequest {
|
|
2839
|
+
readonly workspaceRoot: WorkspaceRootHandle;
|
|
2840
|
+
readonly workingDirectory: string;
|
|
2841
|
+
readonly targetPath?: string;
|
|
2842
|
+
readonly maxBytes: number;
|
|
2843
|
+
readonly operation?: "read" | "mutate";
|
|
2844
|
+
readonly presentedDigests?: ReadonlyArray<string>;
|
|
2845
|
+
}
|
|
2846
|
+
interface WorkspaceInstructionsView {
|
|
2847
|
+
readonly sources: ReadonlyArray<WorkspaceInstructionSource>;
|
|
2848
|
+
readonly content: string;
|
|
2849
|
+
readonly digest: string;
|
|
2850
|
+
readonly truncated: boolean;
|
|
2851
|
+
readonly refreshRequired: boolean;
|
|
2852
|
+
readonly diagnostics: ReadonlyArray<WorkspaceInstructionsDiagnostic>;
|
|
2853
|
+
}
|
|
2854
|
+
interface WorkspaceInstructionsProvider {
|
|
2855
|
+
resolve(request: WorkspaceInstructionsRequest): Promise<WorkspaceInstructionsView>;
|
|
2856
|
+
}
|
|
2857
|
+
declare class InvalidWorkspaceRoot extends Error {
|
|
2858
|
+
readonly name = "InvalidWorkspaceRoot";
|
|
2859
|
+
}
|
|
2860
|
+
declare function createWorkspaceRootHandle(rootPath: string): Promise<WorkspaceRootHandle>;
|
|
2861
|
+
//#endregion
|
|
2862
|
+
//#region src/infrastructure/workspace/agents-md-instructions-provider.d.ts
|
|
2863
|
+
declare class WorkspaceInstructionsSourceError extends Error {
|
|
2864
|
+
readonly relativePath: string;
|
|
2865
|
+
readonly reason: string;
|
|
2866
|
+
readonly name = "WorkspaceInstructionsSourceError";
|
|
2867
|
+
constructor(relativePath: string, reason: string);
|
|
2868
|
+
}
|
|
2869
|
+
declare function createAgentsMdInstructionsProvider(): WorkspaceInstructionsProvider;
|
|
2870
|
+
//#endregion
|
|
2871
|
+
//#region src/application/delegation/tool-authority.d.ts
|
|
2872
|
+
interface InvocationAuthorityRef {
|
|
2873
|
+
readonly id: string;
|
|
2874
|
+
}
|
|
2875
|
+
interface InvocationAuthority {
|
|
2876
|
+
readonly agentId: string;
|
|
2877
|
+
readonly instanceId: string;
|
|
2878
|
+
readonly memory?: AgentMemoryAuthority;
|
|
2879
|
+
readonly runId: string;
|
|
2880
|
+
readonly sessionKey: string;
|
|
2881
|
+
readonly sourceMessageId: string;
|
|
2882
|
+
readonly tenantKey: string;
|
|
2883
|
+
readonly toolGrantSet: RivusToolGrantSet;
|
|
2884
|
+
}
|
|
2885
|
+
declare class InvalidInvocationAuthority extends Error {
|
|
2886
|
+
readonly name = "InvalidInvocationAuthority";
|
|
2887
|
+
}
|
|
2888
|
+
declare function createInvocationAuthority(authority: InvocationAuthority): InvocationAuthorityRef;
|
|
2889
|
+
//#endregion
|
|
2890
|
+
//#region src/application/delegation/tool-broker.d.ts
|
|
2891
|
+
interface AuthorizationPolicyState {
|
|
2892
|
+
readonly epoch: number;
|
|
2893
|
+
readonly revokedToolIds: ReadonlyArray<string>;
|
|
2894
|
+
}
|
|
2895
|
+
interface AuthorizationPolicyProvider {
|
|
2896
|
+
current(): Promise<AuthorizationPolicyState>;
|
|
2897
|
+
}
|
|
2898
|
+
interface ToolApprovalRequest {
|
|
2899
|
+
readonly approvalId: string;
|
|
2900
|
+
readonly agentId: string;
|
|
2901
|
+
readonly instanceId: string;
|
|
2902
|
+
readonly inputDigest: string;
|
|
2903
|
+
readonly operationId: string;
|
|
2904
|
+
readonly runId: string;
|
|
2905
|
+
readonly sessionKey: string;
|
|
2906
|
+
readonly tenantKey: string;
|
|
2907
|
+
readonly callId: string;
|
|
2908
|
+
readonly toolId: string;
|
|
2909
|
+
readonly toolVersion: string;
|
|
2910
|
+
readonly risk: RivusToolRisk;
|
|
2911
|
+
}
|
|
2912
|
+
interface ToolApprovalService {
|
|
2913
|
+
consume(request: ToolApprovalRequest): Promise<boolean>;
|
|
2914
|
+
}
|
|
2915
|
+
interface ToolBrokerOptions {
|
|
2916
|
+
readonly approvals: ToolApprovalService;
|
|
2917
|
+
readonly catalog: RivusPluginCatalog;
|
|
2918
|
+
readonly hostTools?: ReadonlyArray<RivusHostToolDescriptor>;
|
|
2919
|
+
readonly policy: AuthorizationPolicyProvider;
|
|
2920
|
+
readonly operations?: ToolOperationLedger;
|
|
2921
|
+
}
|
|
2922
|
+
interface ToolExecutionRequest {
|
|
2923
|
+
readonly authority: InvocationAuthorityRef;
|
|
2924
|
+
readonly callId: string;
|
|
2925
|
+
readonly toolId: string;
|
|
2926
|
+
readonly version: string;
|
|
2927
|
+
readonly input: unknown;
|
|
2928
|
+
readonly operationId?: string;
|
|
2929
|
+
readonly approvalId?: string;
|
|
2930
|
+
}
|
|
2931
|
+
interface ToolBroker {
|
|
2932
|
+
execute(request: ToolExecutionRequest): Promise<unknown>;
|
|
2933
|
+
}
|
|
2934
|
+
declare class ToolInvocationDenied extends Error {
|
|
2935
|
+
readonly name = "ToolInvocationDenied";
|
|
2936
|
+
}
|
|
2937
|
+
declare function createToolBroker(options: ToolBrokerOptions): ToolBroker;
|
|
2938
|
+
//#endregion
|
|
2939
|
+
//#region src/infrastructure/persistence/jsonl-tool-operation-ledger.d.ts
|
|
2940
|
+
declare function openJsonlToolOperationLedger(options: {
|
|
2941
|
+
readonly filePath: string;
|
|
2942
|
+
}): Promise<ToolOperationLedger>;
|
|
2943
|
+
//#endregion
|
|
2944
|
+
//#region src/infrastructure/persistence/jsonl-recovery-control.d.ts
|
|
2945
|
+
interface JsonlRecoveryControlOptions {
|
|
2946
|
+
readonly clock?: {
|
|
2947
|
+
readonly now: () => string;
|
|
2948
|
+
};
|
|
2949
|
+
readonly endpointsDirectory: string;
|
|
2950
|
+
readonly instancesDirectory: string;
|
|
2951
|
+
}
|
|
2952
|
+
declare function openJsonlRecoveryControl(options: JsonlRecoveryControlOptions): Promise<RecoveryControl>;
|
|
2953
|
+
//#endregion
|
|
2954
|
+
//#region src/composition/agent-harness-pooled-runtime.d.ts
|
|
2955
|
+
declare function createAgentHarnessPooledRuntime(harness: AgentHarness): PooledAgentRuntime;
|
|
2956
|
+
//#endregion
|
|
2957
|
+
//#region src/composition/feishu-deployment-endpoint.d.ts
|
|
2958
|
+
interface FeishuDeploymentEndpointOptions extends Pick<CreateRivusDeploymentEndpointInput, "agentId" | "cancel" | "handle"> {
|
|
2959
|
+
readonly botOpenId: string;
|
|
2960
|
+
readonly endpointId?: string;
|
|
2961
|
+
readonly eventDispatcher: FeishuWebSocketEventDispatcher;
|
|
2962
|
+
readonly groupPolicy: FeishuEndpointGroupPolicy;
|
|
2963
|
+
readonly interactions?: FeishuHumanInteractionActions;
|
|
2964
|
+
readonly inboxRepository?: FeishuInboxRepository;
|
|
2965
|
+
readonly maxPendingMessages?: number;
|
|
2966
|
+
readonly memoryTenantId?: string;
|
|
2967
|
+
readonly onWorkerError?: (error: unknown) => void | Promise<void>;
|
|
2968
|
+
readonly onCapacityExceeded?: (payload: FeishuReceiveMessagePayload) => Effect.Effect<void, unknown>;
|
|
2969
|
+
readonly prepareRun?: (run: FeishuAgentRunPreparation) => Effect.Effect<void, unknown>;
|
|
2970
|
+
readonly publish: (action: FeishuStreamAction) => Effect.Effect<void, unknown>;
|
|
2971
|
+
readonly publishRunUpdate?: AgentRunUpdateHandler;
|
|
2972
|
+
readonly sessionNamespace: string;
|
|
2973
|
+
readonly shutdownTimeoutMs?: number;
|
|
2974
|
+
readonly sleep: (ms: number) => Effect.Effect<void, unknown>;
|
|
2975
|
+
readonly websocketClient: FeishuWebSocketClient;
|
|
2976
|
+
readonly workerIntervalMs?: number;
|
|
2977
|
+
readonly workerConcurrency?: number;
|
|
2978
|
+
}
|
|
2979
|
+
declare function createFeishuDeploymentEndpoint(options: FeishuDeploymentEndpointOptions): RivusDeploymentEndpoint;
|
|
2980
|
+
//#endregion
|
|
2981
|
+
//#region src/composition/feishu-presentation-preparation.d.ts
|
|
2982
|
+
interface FeishuPresentationPreparationOptions {
|
|
2983
|
+
readonly cotPublisher?: Pick<FeishuCotPublisher, "fail" | "prepare">;
|
|
2984
|
+
readonly prepareCardTarget: (run: FeishuAgentRunPreparation) => Effect.Effect<void, unknown>;
|
|
2985
|
+
readonly reportCotError: (operation: "abort" | "create", error: unknown) => Effect.Effect<void>;
|
|
2986
|
+
}
|
|
2987
|
+
declare function createFeishuPresentationPreparation(options: FeishuPresentationPreparationOptions): (run: FeishuAgentRunPreparation) => Effect.Effect<void, unknown>;
|
|
2988
|
+
//#endregion
|
|
2989
|
+
//#region src/application/memory/agent-memory.d.ts
|
|
2990
|
+
interface MemorySearchQuery {
|
|
2991
|
+
readonly query: string;
|
|
2992
|
+
}
|
|
2993
|
+
interface AgentMemoryHandle {
|
|
2994
|
+
readonly namespace: string;
|
|
2995
|
+
readonly scope: MemoryScope;
|
|
2996
|
+
confirm(input: {
|
|
2997
|
+
readonly id: string;
|
|
2998
|
+
readonly expectedRevision: number;
|
|
2999
|
+
readonly conversationSafe?: boolean;
|
|
3000
|
+
}): Promise<MemoryRecord>;
|
|
3001
|
+
forgetRequest(input: {
|
|
3002
|
+
readonly expectedRevision: number;
|
|
3003
|
+
readonly id: string;
|
|
3004
|
+
readonly reason?: string;
|
|
3005
|
+
}): Promise<MemoryRecord>;
|
|
3006
|
+
inspect(id: string): Promise<MemoryRecord | undefined>;
|
|
3007
|
+
propose(input: {
|
|
3008
|
+
readonly content: string;
|
|
3009
|
+
}): Promise<MemoryRecord>;
|
|
3010
|
+
read(id: string): Promise<MemoryRecord | undefined>;
|
|
3011
|
+
search(query: MemorySearchQuery): Promise<ReadonlyArray<MemoryRecord>>;
|
|
3012
|
+
}
|
|
3013
|
+
interface AgentMemoryService {
|
|
3014
|
+
bind(binding: MemoryBinding): AgentMemoryHandle;
|
|
3015
|
+
}
|
|
3016
|
+
interface AgentMemoryServiceOptions {
|
|
3017
|
+
readonly ids?: {
|
|
3018
|
+
readonly next: () => string;
|
|
3019
|
+
};
|
|
3020
|
+
readonly initial?: ReadonlyArray<AgentMemorySnapshot>;
|
|
3021
|
+
readonly persist?: (snapshot: AgentMemorySnapshot) => Promise<void>;
|
|
3022
|
+
}
|
|
3023
|
+
declare class AgentMemoryError extends Error {
|
|
3024
|
+
readonly name = "AgentMemoryError";
|
|
3025
|
+
}
|
|
3026
|
+
declare function createAgentMemoryService(options?: AgentMemoryServiceOptions): AgentMemoryService;
|
|
3027
|
+
//#endregion
|
|
3028
|
+
//#region src/application/memory/rivus-memory-tool.d.ts
|
|
3029
|
+
interface RivusMemoryTool {
|
|
3030
|
+
execute(command: {
|
|
3031
|
+
readonly command: "forget_request";
|
|
3032
|
+
readonly id: string;
|
|
3033
|
+
readonly reason?: string;
|
|
3034
|
+
}): Promise<MemoryTombstoneReceipt>;
|
|
3035
|
+
execute(command: {
|
|
3036
|
+
readonly command: "propose";
|
|
3037
|
+
readonly input: {
|
|
3038
|
+
readonly content: string;
|
|
3039
|
+
};
|
|
3040
|
+
readonly scope?: Exclude<MemoryScope, "shared-user-profile">;
|
|
3041
|
+
}): Promise<MemoryRecord>;
|
|
3042
|
+
execute(command: {
|
|
3043
|
+
readonly command: "read";
|
|
3044
|
+
readonly id: string;
|
|
3045
|
+
}): Promise<MemoryRecord | undefined>;
|
|
3046
|
+
execute(command: {
|
|
3047
|
+
readonly command: "search";
|
|
3048
|
+
readonly query: MemorySearchQuery;
|
|
3049
|
+
readonly scope?: MemoryScope;
|
|
3050
|
+
}): Promise<ReadonlyArray<MemoryRecord>>;
|
|
3051
|
+
replayCompleted(command: unknown, completedResult: unknown): Promise<unknown>;
|
|
3052
|
+
}
|
|
3053
|
+
interface MemoryTombstoneReceipt {
|
|
3054
|
+
readonly id: string;
|
|
3055
|
+
readonly revision: number;
|
|
3056
|
+
readonly scope: MemoryScope;
|
|
3057
|
+
readonly state: "tombstoned";
|
|
3058
|
+
}
|
|
3059
|
+
declare function createRivusMemoryTool(memory: AgentMemoryHandle | ReadonlyArray<AgentMemoryHandle>): RivusMemoryTool;
|
|
3060
|
+
declare function createRivusMemoryToolDescriptor(options: {
|
|
3061
|
+
readonly memory: AgentMemoryService;
|
|
3062
|
+
}): RivusHostToolDescriptor;
|
|
3063
|
+
//#endregion
|
|
3064
|
+
//#region src/infrastructure/persistence/jsonl-agent-memory-service.d.ts
|
|
3065
|
+
declare function openJsonlAgentMemoryService(options: {
|
|
3066
|
+
readonly filePath: string;
|
|
3067
|
+
}): Promise<AgentMemoryService>;
|
|
3068
|
+
//#endregion
|
|
3069
|
+
//#region src/application/memory/context-assembler.d.ts
|
|
3070
|
+
type AgentContextLayerKind = "host-safety" | "system-prompt" | "managed-instructions" | "workspace-instructions" | "tool-schema" | "skill" | "memory" | "compaction" | "transcript" | "current-input";
|
|
3071
|
+
interface AgentContextLayer {
|
|
3072
|
+
readonly kind: AgentContextLayerKind;
|
|
3073
|
+
readonly content: string;
|
|
3074
|
+
}
|
|
3075
|
+
interface AgentContextInput {
|
|
3076
|
+
readonly hostSafety: string;
|
|
3077
|
+
readonly systemPrompt: string;
|
|
3078
|
+
readonly managedInstructions?: string;
|
|
3079
|
+
readonly workspaceInstructions?: ReadonlyArray<string>;
|
|
3080
|
+
readonly toolSchemas: ReadonlyArray<string>;
|
|
3081
|
+
readonly skills?: ReadonlyArray<string>;
|
|
3082
|
+
readonly memory?: ReadonlyArray<string>;
|
|
3083
|
+
readonly compaction?: string;
|
|
3084
|
+
readonly transcript?: ReadonlyArray<string>;
|
|
3085
|
+
readonly currentInput: string;
|
|
3086
|
+
readonly maxBytes: number;
|
|
3087
|
+
}
|
|
3088
|
+
interface AssembledAgentContext {
|
|
3089
|
+
readonly layers: ReadonlyArray<AgentContextLayer>;
|
|
3090
|
+
readonly omittedKinds: ReadonlyArray<AgentContextLayerKind>;
|
|
3091
|
+
readonly bytes: number;
|
|
3092
|
+
}
|
|
3093
|
+
declare class AgentContextBudgetExceeded extends Error {
|
|
3094
|
+
readonly name = "AgentContextBudgetExceeded";
|
|
3095
|
+
}
|
|
3096
|
+
declare function assembleAgentContext(input: AgentContextInput): AssembledAgentContext;
|
|
3097
|
+
//#endregion
|
|
3098
|
+
//#region src/application/memory/compaction.d.ts
|
|
3099
|
+
interface CompactionInput {
|
|
3100
|
+
readonly tenantId: string;
|
|
3101
|
+
readonly agentId: string;
|
|
3102
|
+
readonly instanceId: string;
|
|
3103
|
+
readonly conversationId: string;
|
|
3104
|
+
readonly profileRevision: string;
|
|
3105
|
+
readonly watermark: number;
|
|
3106
|
+
readonly transcript: ReadonlyArray<string>;
|
|
3107
|
+
}
|
|
3108
|
+
interface CompactorPort {
|
|
3109
|
+
compact(input: CompactionInput): Promise<string>;
|
|
3110
|
+
}
|
|
3111
|
+
interface CompactionSnapshot extends Omit<CompactionInput, "transcript"> {
|
|
3112
|
+
readonly id: string;
|
|
3113
|
+
readonly summary: string;
|
|
3114
|
+
}
|
|
3115
|
+
interface CompactionService {
|
|
3116
|
+
createCandidate(input: CompactionInput): Promise<CompactionSnapshot>;
|
|
3117
|
+
commit(candidateId: string): CompactionSnapshot;
|
|
3118
|
+
current(instanceId: string, conversationId: string): CompactionSnapshot | undefined;
|
|
3119
|
+
}
|
|
3120
|
+
declare class CompactionError extends Error {
|
|
3121
|
+
readonly name = "CompactionError";
|
|
3122
|
+
}
|
|
3123
|
+
declare function createCompactionService(options: {
|
|
3124
|
+
readonly compactor: CompactorPort;
|
|
3125
|
+
}): CompactionService;
|
|
3126
|
+
//#endregion
|
|
3127
|
+
//#region src/application/automation/daily-automation-schedule.d.ts
|
|
3128
|
+
interface DailyAutomationSchedule {
|
|
3129
|
+
currentOccurrence(now: Date): string | undefined;
|
|
3130
|
+
nextOccurrence(now: Date): Date;
|
|
3131
|
+
}
|
|
3132
|
+
declare function createDailyAutomationSchedule(expression: string, timeZone: string, now?: Date): DailyAutomationSchedule;
|
|
3133
|
+
//#endregion
|
|
3134
|
+
//#region src/infrastructure/persistence/json-automation-tick-repository.d.ts
|
|
3135
|
+
interface OpenJsonAutomationTickRepositoryOptions {
|
|
3136
|
+
readonly filePath: string;
|
|
3137
|
+
}
|
|
3138
|
+
declare function openJsonAutomationTickRepository(options: OpenJsonAutomationTickRepositoryOptions): Promise<AutomationTickRepository>;
|
|
3139
|
+
//#endregion
|
|
3140
|
+
//#region src/application/automation/plugin-state.d.ts
|
|
3141
|
+
interface PluginStateRecord {
|
|
3142
|
+
readonly pluginId: string;
|
|
3143
|
+
readonly agentId: string;
|
|
3144
|
+
readonly key: string;
|
|
3145
|
+
readonly value: unknown;
|
|
3146
|
+
readonly revision: number;
|
|
3147
|
+
}
|
|
3148
|
+
interface PutPluginState {
|
|
3149
|
+
readonly pluginId: string;
|
|
3150
|
+
readonly agentId: string;
|
|
3151
|
+
readonly key: string;
|
|
3152
|
+
readonly value: unknown;
|
|
3153
|
+
readonly expectedRevision: number;
|
|
3154
|
+
}
|
|
3155
|
+
interface PluginStateStore {
|
|
3156
|
+
get(pluginId: string, agentId: string, key: string): PluginStateRecord | undefined;
|
|
3157
|
+
put(input: PutPluginState): PluginStateRecord;
|
|
3158
|
+
}
|
|
3159
|
+
declare class PluginStateConflict extends Error {
|
|
3160
|
+
readonly name = "PluginStateConflict";
|
|
3161
|
+
}
|
|
3162
|
+
declare function createPluginStateStore(): PluginStateStore;
|
|
3163
|
+
//#endregion
|
|
3164
|
+
//#region src/application/automation/delivery-outbox.d.ts
|
|
3165
|
+
type AutomationOutcome = {
|
|
3166
|
+
readonly kind: "suppressed";
|
|
3167
|
+
} | {
|
|
3168
|
+
readonly kind: "report" | "alert";
|
|
3169
|
+
readonly body: string;
|
|
3170
|
+
readonly target: string;
|
|
3171
|
+
};
|
|
3172
|
+
type DeliveryJobStatus = "pending" | "delivered" | "reconciliation-required";
|
|
3173
|
+
interface DeliveryJob {
|
|
3174
|
+
readonly id: string;
|
|
3175
|
+
readonly tickId: string;
|
|
3176
|
+
readonly kind: "report" | "alert";
|
|
3177
|
+
readonly body: string;
|
|
3178
|
+
readonly target: string;
|
|
3179
|
+
readonly status: DeliveryJobStatus;
|
|
3180
|
+
readonly receiptId?: string;
|
|
3181
|
+
}
|
|
3182
|
+
interface DeliveryOutbox {
|
|
3183
|
+
enqueue(job: Omit<DeliveryJob, "status">): DeliveryJob;
|
|
3184
|
+
recordAttempt(id: string, result: {
|
|
3185
|
+
readonly kind: "delivered";
|
|
3186
|
+
readonly providerMessageId: string;
|
|
3187
|
+
} | {
|
|
3188
|
+
readonly kind: "uncertain";
|
|
3189
|
+
}): DeliveryJob;
|
|
3190
|
+
snapshot(): ReadonlyArray<DeliveryJob>;
|
|
3191
|
+
}
|
|
3192
|
+
interface CommitAutomationOutcomeInput {
|
|
3193
|
+
readonly tickId: string;
|
|
3194
|
+
readonly outcome: AutomationOutcome;
|
|
3195
|
+
readonly state: PluginStateStore;
|
|
3196
|
+
readonly stateUpdate: PutPluginState;
|
|
3197
|
+
readonly outbox: DeliveryOutbox;
|
|
3198
|
+
}
|
|
3199
|
+
interface CommittedAutomationOutcome {
|
|
3200
|
+
readonly state: PluginStateRecord;
|
|
3201
|
+
readonly job?: DeliveryJob;
|
|
3202
|
+
}
|
|
3203
|
+
declare class DeliveryOutboxError extends Error {
|
|
3204
|
+
readonly name = "DeliveryOutboxError";
|
|
3205
|
+
}
|
|
3206
|
+
declare function createDeliveryOutbox(): DeliveryOutbox;
|
|
3207
|
+
declare function commitAutomationOutcome(input: CommitAutomationOutcomeInput): CommittedAutomationOutcome;
|
|
3208
|
+
//#endregion
|
|
3209
|
+
//#region src/application/delegation/delegation-service.d.ts
|
|
3210
|
+
interface DelegationEdge {
|
|
3211
|
+
readonly fromAgentId: string;
|
|
3212
|
+
readonly toAgentId: string;
|
|
3213
|
+
readonly toolIds: ReadonlyArray<string>;
|
|
3214
|
+
readonly maxHops: number;
|
|
3215
|
+
readonly maxBudget: number;
|
|
3216
|
+
}
|
|
3217
|
+
interface DelegationRequest {
|
|
3218
|
+
readonly callerAuthority: InvocationAuthorityRef;
|
|
3219
|
+
readonly targetAgentId: string;
|
|
3220
|
+
readonly targetInstanceId: string;
|
|
3221
|
+
readonly targetToolGrantSet: RivusToolGrantSet;
|
|
3222
|
+
readonly requestedToolIds: ReadonlyArray<string>;
|
|
3223
|
+
readonly hopCount: number;
|
|
3224
|
+
readonly budget: number;
|
|
3225
|
+
}
|
|
3226
|
+
interface DelegationGrant {
|
|
3227
|
+
readonly id: string;
|
|
3228
|
+
readonly request: DelegationRequest;
|
|
3229
|
+
readonly toolGrantSet: RivusToolGrantSet;
|
|
3230
|
+
readonly authority: InvocationAuthorityRef;
|
|
3231
|
+
}
|
|
3232
|
+
interface DelegationService {
|
|
3233
|
+
delegate(request: DelegationRequest): DelegationGrant;
|
|
3234
|
+
}
|
|
3235
|
+
declare class DelegationDenied extends Error {
|
|
3236
|
+
readonly name = "DelegationDenied";
|
|
3237
|
+
}
|
|
3238
|
+
declare function createDelegationService(options: {
|
|
3239
|
+
readonly edges: ReadonlyArray<DelegationEdge>;
|
|
3240
|
+
}): DelegationService;
|
|
3241
|
+
declare function intersectToolIds(sets: ReadonlyArray<ReadonlyArray<string>>): RivusToolGrantSet;
|
|
3242
|
+
//#endregion
|
|
3243
|
+
//#region src/application/delegation/subagent-coordinator.d.ts
|
|
3244
|
+
interface SpawnSubagentRequest {
|
|
3245
|
+
readonly parentAuthority: InvocationAuthorityRef;
|
|
3246
|
+
readonly childAgentId: string;
|
|
3247
|
+
readonly childProfileToolIds: ReadonlyArray<string>;
|
|
3248
|
+
readonly childDeploymentToolIds: ReadonlyArray<string>;
|
|
3249
|
+
readonly requestedToolIds: ReadonlyArray<string>;
|
|
3250
|
+
}
|
|
3251
|
+
interface SubagentRecord {
|
|
3252
|
+
readonly id: string;
|
|
3253
|
+
readonly parentRunId: string;
|
|
3254
|
+
readonly childAgentId: string;
|
|
3255
|
+
readonly toolGrantSet: RivusToolGrantSet;
|
|
3256
|
+
readonly authority: InvocationAuthorityRef;
|
|
3257
|
+
readonly capabilities: {
|
|
3258
|
+
readonly senderIdentity: false;
|
|
3259
|
+
readonly privateMemory: false;
|
|
3260
|
+
readonly shell: false;
|
|
3261
|
+
};
|
|
3262
|
+
readonly status: "active" | "cancelled";
|
|
3263
|
+
}
|
|
3264
|
+
interface SubagentCoordinator {
|
|
3265
|
+
spawn(request: SpawnSubagentRequest): SubagentRecord;
|
|
3266
|
+
cancelParent(parentRunId: string): void;
|
|
3267
|
+
get(id: string): SubagentRecord | undefined;
|
|
3268
|
+
}
|
|
3269
|
+
declare function createSubagentCoordinator(): SubagentCoordinator;
|
|
3270
|
+
//#endregion
|
|
3271
|
+
//#region src/infrastructure/plugin/node-rivus-plugin-module-loader.d.ts
|
|
3272
|
+
declare function loadNodeRivusPluginModule(request: RivusPluginModuleLoadRequest): Promise<RivusPluginModule>;
|
|
3273
|
+
//#endregion
|
|
3274
|
+
//#region src/infrastructure/config/rivus-deployment-manifest.d.ts
|
|
3275
|
+
interface LoadRivusDeploymentManifestOptions {
|
|
3276
|
+
readonly maxBytes?: number;
|
|
3277
|
+
}
|
|
3278
|
+
declare class RivusDeploymentManifestError extends Error {
|
|
3279
|
+
readonly manifestPath: string;
|
|
3280
|
+
readonly name = "RivusDeploymentManifestError";
|
|
3281
|
+
constructor(manifestPath: string, message: string, options?: ErrorOptions);
|
|
3282
|
+
}
|
|
3283
|
+
declare function loadRivusDeploymentManifest(manifestPath: string, options?: LoadRivusDeploymentManifestOptions): Promise<RivusDeploymentManifest>;
|
|
3284
|
+
//#endregion
|
|
3285
|
+
//#region src/infrastructure/runtime/configured-rivus-deployment-daemon.d.ts
|
|
3286
|
+
type CreateConfiguredRivusDeploymentDaemonOptions = Omit<CreateRivusDeploymentDaemonOptions, "deploymentRoot" | "loadModule" | "manifest"> & {
|
|
3287
|
+
readonly manifestPath: string;
|
|
3288
|
+
readonly manifestOptions?: LoadRivusDeploymentManifestOptions;
|
|
3289
|
+
};
|
|
3290
|
+
declare function createConfiguredRivusDeploymentDaemon(options: CreateConfiguredRivusDeploymentDaemonOptions): Promise<RivusDeploymentDaemon>;
|
|
3291
|
+
//#endregion
|
|
3292
|
+
//#region src/domain/human-interaction-transition.d.ts
|
|
3293
|
+
declare class HumanInteractionTransitionDenied extends Error {
|
|
3294
|
+
readonly name = "HumanInteractionTransitionDenied";
|
|
3295
|
+
}
|
|
3296
|
+
declare function transitionHumanInteraction(interaction: HumanInteraction, transition: HumanInteractionTransition): HumanInteraction;
|
|
3297
|
+
//#endregion
|
|
3298
|
+
//#region src/application/delegation/tool-input-digest.d.ts
|
|
3299
|
+
declare class InvalidStableJson extends Error {
|
|
3300
|
+
readonly name: string;
|
|
3301
|
+
}
|
|
3302
|
+
declare class InvalidToolInput extends InvalidStableJson {
|
|
3303
|
+
readonly name = "InvalidToolInput";
|
|
3304
|
+
}
|
|
3305
|
+
declare function createToolInputDigest(input: unknown): string;
|
|
3306
|
+
declare function normalizeStableJson(value: unknown): unknown;
|
|
3307
|
+
//#endregion
|
|
3308
|
+
//#region src/infrastructure/pi/pi-tool-proxy.d.ts
|
|
3309
|
+
interface PiToolApprovalRequest {
|
|
3310
|
+
readonly agentId: string;
|
|
3311
|
+
readonly allowedActorOpenIds: ReadonlyArray<string>;
|
|
3312
|
+
readonly approvalId: string;
|
|
3313
|
+
readonly callId: string;
|
|
3314
|
+
readonly endpointId: string;
|
|
3315
|
+
readonly inputDigest: string;
|
|
3316
|
+
readonly instanceId: string;
|
|
3317
|
+
readonly operationId: string;
|
|
3318
|
+
readonly risk: RivusToolRisk;
|
|
3319
|
+
readonly runId: string;
|
|
3320
|
+
readonly sessionKey: string;
|
|
3321
|
+
readonly signal?: AbortSignal;
|
|
3322
|
+
readonly sourceMessageId: string;
|
|
3323
|
+
readonly tenantKey: string;
|
|
3324
|
+
readonly toolId: string;
|
|
3325
|
+
readonly toolVersion: string;
|
|
3326
|
+
}
|
|
3327
|
+
interface PiToolApprovalGateway {
|
|
3328
|
+
requestApproval(request: PiToolApprovalRequest): Promise<void>;
|
|
3329
|
+
}
|
|
3330
|
+
interface PiToolProxyOptions {
|
|
3331
|
+
readonly agentId: string;
|
|
3332
|
+
readonly approvals: PiToolApprovalGateway;
|
|
3333
|
+
readonly broker: ToolBroker;
|
|
3334
|
+
readonly getActiveInput: () => AgentLoopInput | undefined;
|
|
3335
|
+
readonly instanceId: string;
|
|
3336
|
+
readonly memoryScopes?: ReadonlyArray<MemoryScope>;
|
|
3337
|
+
readonly toolGrantSet: RivusToolGrantSet;
|
|
3338
|
+
readonly tools: ReadonlyArray<RivusResolvedToolDescriptor>;
|
|
3339
|
+
}
|
|
3340
|
+
declare function createPiToolProxyDefinitions(options: PiToolProxyOptions): ToolDefinition[];
|
|
3341
|
+
declare function createPiToolNameResolver(tools: ReadonlyArray<Pick<RivusResolvedToolDescriptor, "id">>): (toolName: string) => string;
|
|
3342
|
+
//#endregion
|
|
3343
|
+
//#region src/composition/human-interaction-tool-approval-gateway.d.ts
|
|
3344
|
+
interface HumanInteractionEndpointRegistry {
|
|
3345
|
+
register(endpointId: string, service: HumanInteractionService): void;
|
|
3346
|
+
resolve(endpointId: string): HumanInteractionService | undefined;
|
|
3347
|
+
services(): ReadonlyArray<HumanInteractionService>;
|
|
3348
|
+
}
|
|
3349
|
+
declare function createHumanInteractionEndpointRegistry(): HumanInteractionEndpointRegistry;
|
|
3350
|
+
declare function createHumanInteractionToolApprovalGateway(options: {
|
|
3351
|
+
readonly clock?: {
|
|
3352
|
+
readonly now: () => string;
|
|
3353
|
+
};
|
|
3354
|
+
readonly expiresAfterMs?: number;
|
|
3355
|
+
readonly registry: HumanInteractionEndpointRegistry;
|
|
3356
|
+
}): PiToolApprovalGateway;
|
|
3357
|
+
declare function createRoutedHumanInteractionToolApprovalService(registry: HumanInteractionEndpointRegistry): ToolApprovalService;
|
|
3358
|
+
//#endregion
|
|
3359
|
+
//#region src/infrastructure/feishu/feishu-text-reply.d.ts
|
|
3360
|
+
interface FeishuTextReplySender {
|
|
3361
|
+
reply(messageId: string, text: string): Effect.Effect<void, unknown>;
|
|
3362
|
+
}
|
|
3363
|
+
declare function createConfiguredFeishuTextReplySender(options: {
|
|
3364
|
+
readonly client: FeishuOpenApiClient;
|
|
3365
|
+
readonly config: RivusDaemonConfig;
|
|
3366
|
+
}): FeishuTextReplySender;
|
|
3367
|
+
//#endregion
|
|
3368
|
+
//#region src/infrastructure/feishu/feishu-markdown-message-sender.d.ts
|
|
3369
|
+
interface FeishuMarkdownMessageInput {
|
|
3370
|
+
readonly idempotencyKey: string;
|
|
3371
|
+
readonly markdown: string;
|
|
3372
|
+
readonly receiveId: string;
|
|
3373
|
+
readonly receiveIdType: RivusAutomationDeliveryTargetType;
|
|
3374
|
+
}
|
|
3375
|
+
interface FeishuMarkdownMessageSender {
|
|
3376
|
+
send(input: FeishuMarkdownMessageInput): Effect.Effect<{
|
|
3377
|
+
readonly providerMessageId: string;
|
|
3378
|
+
}, unknown>;
|
|
3379
|
+
}
|
|
3380
|
+
declare function createConfiguredFeishuMarkdownMessageSender(options: {
|
|
3381
|
+
readonly client: FeishuOpenApiClient;
|
|
3382
|
+
readonly config: RivusDaemonConfig;
|
|
3383
|
+
}): FeishuMarkdownMessageSender;
|
|
3384
|
+
//#endregion
|
|
3385
|
+
//#region src/infrastructure/persistence/jsonl-human-interaction-repository.d.ts
|
|
3386
|
+
interface JsonlHumanInteractionRepositoryOptions {
|
|
3387
|
+
readonly filePath: string;
|
|
3388
|
+
}
|
|
3389
|
+
declare function createJsonlHumanInteractionRepository(options: JsonlHumanInteractionRepositoryOptions): HumanInteractionRepository;
|
|
3390
|
+
//#endregion
|
|
3391
|
+
//#region src/infrastructure/feishu/feishu-agent-run-card.d.ts
|
|
3392
|
+
type FeishuAgentRunCardInput = {
|
|
3393
|
+
readonly agentName: string;
|
|
3394
|
+
readonly elementId?: string;
|
|
3395
|
+
readonly runId: string;
|
|
3396
|
+
readonly sessionKey: string;
|
|
3397
|
+
readonly status: "running";
|
|
3398
|
+
readonly text?: string;
|
|
3399
|
+
} | {
|
|
3400
|
+
readonly agentName: string;
|
|
3401
|
+
readonly status: "completed";
|
|
3402
|
+
readonly text: string;
|
|
3403
|
+
} | {
|
|
3404
|
+
readonly agentName: string;
|
|
3405
|
+
readonly status: "cancelled" | "failed";
|
|
3406
|
+
};
|
|
3407
|
+
declare function createFeishuAgentRunCard(input: FeishuAgentRunCardInput): FeishuRawCardJson;
|
|
3408
|
+
//#endregion
|
|
3409
|
+
//#region src/infrastructure/feishu/feishu-human-interaction-presenter.d.ts
|
|
3410
|
+
interface FeishuHumanInteractionPresenterOptions {
|
|
3411
|
+
readonly baseUrl?: string;
|
|
3412
|
+
readonly client: FeishuOpenApiClient;
|
|
3413
|
+
}
|
|
3414
|
+
declare function createFeishuHumanInteractionPresenter(options: FeishuHumanInteractionPresenterOptions): HumanInteractionPresenter;
|
|
3415
|
+
//#endregion
|
|
3416
|
+
//#region src/infrastructure/feishu/feishu-configured-human-interaction-presenter.d.ts
|
|
3417
|
+
interface ConfiguredFeishuHumanInteractionPresenterOptions {
|
|
3418
|
+
readonly client: FeishuOpenApiClient;
|
|
3419
|
+
readonly config: RivusDaemonConfig;
|
|
3420
|
+
}
|
|
3421
|
+
declare function createConfiguredFeishuHumanInteractionPresenter(options: ConfiguredFeishuHumanInteractionPresenterOptions): HumanInteractionPresenter;
|
|
3422
|
+
//#endregion
|
|
3423
|
+
export { type ActiveAgentRun, type AgentClientAttempt, type AgentClientFailure, type AgentClientSuccess, type AgentClock, AgentContextBudgetExceeded, type AgentContextInput, type AgentContextLayer, type AgentContextLayerKind, type AgentConversationMessagesOptions, type AgentDomainEvent, type AgentDomainEventCallback, type AgentDomainEventHandler, type AgentDomainEventListener, type AgentDomainEventSink, type AgentDomainEventSinkCallback, AgentEventHandlerFailed, type AgentEventLog, type AgentEventLogOperation, AgentEventLogStoreError, AgentEventSinkFailed, type AgentHarness, type AgentHarnessAvailability, AgentHarnessBusy, type AgentHarnessBusyAvailability, type AgentHarnessClient, type AgentHarnessError, type AgentHarnessIdleAvailability, type AgentHarnessOptions, type AgentHistory, type AgentHistoryEventLog, AgentInstanceBusy, AgentInstanceConflict, type AgentInstanceRecord, type AgentInstanceRegistry, type AgentInstanceRegistryOptions, type AgentInvocationOrigin, type AgentLoop, type AgentLoopCallback, type AgentLoopCallbackOutput, type AgentLoopCallbackResult, type AgentLoopEvent, type AgentLoopEventLike, AgentLoopFailed, type AgentLoopInput, type AgentLoopModelExecutionEnd, type AgentLoopModelExecutionEndOptions, type AgentLoopModelExecutionStart, type AgentLoopModelExecutionStartOptions, type AgentLoopSkillExecutionEnd, type AgentLoopSkillExecutionEndOptions, type AgentLoopSkillExecutionStart, type AgentLoopSkillExecutionStartOptions, type AgentLoopTextDelta, type AgentLoopThinkingDelta, type AgentLoopToolExecutionEnd, type AgentLoopToolExecutionEndOptions, type AgentLoopToolExecutionStart, type AgentLoopToolExecutionStartOptions, type AgentLoopToolExecutionUpdate, type AgentLoopToolExecutionUpdateOptions, type AgentMemoryAuthority, AgentMemoryError, type AgentMemoryHandle, type AgentMemoryIdentity, type AgentMemoryService, type AgentMemoryServiceOptions, type AgentMemorySnapshot, type AgentModelContentObserver, type AgentModelExecutionEnded, type AgentModelExecutionEvent, type AgentModelExecutionStarted, type AgentModelInputObservation, type AgentModelOutputObservation, type AgentModelUsage, type AgentPromptResult, type AgentRunAccepted, AgentRunCancelled, type AgentRunCancelled$1 as AgentRunCancelledEvent, type AgentRunCompleted, type AgentRunFailed, type AgentRunId, type AgentRunPhase, type AgentRunSnapshot, type AgentRunState, type AgentRunSummary, type AgentRunUpdate, type AgentRunUpdateCallback, type AgentRunUpdateHandler, type AgentRunUpdateListener, type AgentRuntime, type AgentRuntimeCancellation, AgentRuntimeDisposed, type AgentRuntimeInput, type AgentRuntimePool, type AgentRuntimePoolOptions, type AgentSessionAvailability, type AgentSessionBusyAvailability, type AgentSessionClient, type AgentSessionHandle, type AgentSessionOtherBusyAvailability, type AgentSessionOwnedBusyAvailability, type AgentSessionSnapshot, type AgentSessionSummary, type AgentSkillExecutionEnded, type AgentSkillExecutionStarted, type AgentSkillExecutionState, type AgentTextDeltaCallback, type AgentToolExecutionEnded, type AgentToolExecutionEvent, type AgentToolExecutionStarted, type AgentToolExecutionUpdated, type AgentTranscript, type AgentTranscriptMessage, type AgentTranscriptMessageRole, type AgentTranscriptTurn, type AgentTurnCompleted, type AgentTurnStarted, type ApprovedHumanInteractionState, type AssembledAgentContext, type AssistantTextDelta, type AssistantThinkingDelta, type AsyncIterableAgentLoopOptions, type AuthorizationPolicyProvider, type AuthorizationPolicyState, type AutomationAgentInvocationOrigin, type AutomationBinding, type AutomationDeliveryBinding, type AutomationMandate, AutomationMandateError, type AutomationMandateStore, type AutomationOutcome, type AutomationTick, type AutomationTickRecord, type AutomationTickRepository, type AutomationTickStatus, type CancelledHumanInteractionState, type CommitAutomationOutcomeInput, type CommittedAutomationOutcome, CompactionError, type CompactionInput, type CompactionService, type CompactionSnapshot, type CompactorPort, type CompositeRivusDaemonTransportOptions, type ConfiguredFeishuCardKitPublisherOptions, type ConfiguredFeishuCardKitTargetPreparationOptions, type ConfiguredFeishuHumanInteractionPresenterOptions, type ConfiguredFeishuOpenApiRequest, type ConfiguredFeishuOpenApiResponse, type ConfiguredRivusDaemonBootstrap, type ConfiguredRivusDaemonBootstrapOptions, type ConfiguredRivusDaemonBootstrapRequest, type ConfiguredRivusDaemonBootstrapResponse, type ConsumeToolApprovalInput, type CreateConfiguredRivusDeploymentDaemonOptions, type CreateRivusDeploymentAutomationInput, type CreateRivusDeploymentDaemonOptions, type CreateRivusDeploymentEndpointInput, type CreateRivusDeploymentRuntimeInput, type DailyAutomationSchedule, type DeadLetterRecoveryItem, type DeadLetterRequeueResult, type DefaultAgentHarnessClientFromCallbackOptions, type DefaultAgentHarnessClientFromTextCallbackOptions, type DefaultAgentHarnessClientOptions, type DefaultAgentHarnessFromCallbackOptions, type DefaultAgentHarnessFromTextCallbackOptions, type DefaultAgentHarnessOptions, type DefaultAgentRuntimeFromCallbackOptions, type DefaultAgentRuntimeFromTextCallbackOptions, type DefaultAgentRuntimeOptions, type DefaultAgentRuntimeSessionOptions, DelegationDenied, type DelegationEdge, type DelegationGrant, type DelegationRequest, type DelegationService, type DeliveryJob, type DeliveryJobStatus, type DeliveryOutbox, DeliveryOutboxError, type EventAgentLoopOptions, type ExpiredHumanInteractionState, type FeishuAgentCommand, type FeishuAgentDaemon, type FeishuAgentDaemonCancelResult, type FeishuAgentDaemonHandleMessageOptions, type FeishuAgentDaemonHandleResult, type FeishuAgentDaemonInteractionResult, type FeishuAgentDaemonOptions, type FeishuAgentDaemonRunResult, type FeishuAgentDaemonSkippedResult, type FeishuAgentExecution, type FeishuAgentExecutionResult, type FeishuAgentInvocationOrigin, type FeishuAgentMessageSideEffects, type FeishuAgentRunCardInput, type FeishuAgentRunPreparation, type FeishuAgentRuntime, type FeishuAgentRuntimeOptions, type FeishuCancelMessageIntakeSummary, type FeishuCancelRunCommand, type FeishuCardActionCallbackResponse, type FeishuCardActionCommand, type FeishuCardActionIntakeError, type FeishuCardActionToast, type FeishuCardActionTriggerPayload, type FeishuCardDeliveryLedger, type FeishuCardDeliveryLedgerStateOptions, type FeishuCardDeliveryReconciler, type FeishuCardDeliveryReconcilerOptions, type FeishuCardDeliveryRecord, type FeishuCardKitCancel, type FeishuCardKitClient, type FeishuCardKitFail, type FeishuCardKitFinish, type FeishuCardKitOpenApiClientOptions, type FeishuCardKitOpenApiTargetCreatorOptions, type FeishuCardKitPublisher, type FeishuCardKitPublisherOptions, type FeishuCardKitTextUpdate, type FeishuCardTarget, type FeishuCardTargetCreator, FeishuCardTargetNotFound, type FeishuCardTargetPreparationOptions, type FeishuCardTargetRegistry, type FeishuCardTargetRegistryOperation, FeishuCardTargetRegistryStoreError, type FeishuCoalescingPublisher, type FeishuCoalescingPublisherOptions, type FeishuConversationReference, FeishuCotProtocolError, type FeishuCotPublisher, type FeishuCotPublisherOptions, type FeishuCotRunPreparation, type FeishuDeploymentEndpointOptions, FeishuEndpointCredentialError, type FeishuEndpointCredentials, type FeishuEndpointGroupPolicy, type FeishuEventHandlerCardActions, type FeishuEventHandlerQueue, type FeishuEventHandlers, type FeishuEventHandlersOptions, type FeishuHumanInteractionActions, type FeishuHumanInteractionPresenterOptions, type FeishuInboxCompletedState, type FeishuInboxDeadState, type FeishuInboxDelivery, type FeishuInboxDeliveryState, type FeishuInboxLeasedState, type FeishuInboxPendingState, type FeishuInboxRepository, type FeishuInboxRepositoryStateOptions, type FeishuMarkdownMessageInput, type FeishuMarkdownMessageSender, type FeishuMessageAcceptResult, type FeishuMessageDrainResult, type FeishuMessageIntakeBaseSummary, type FeishuMessageIntakeError, type FeishuMessageIntakeOptions, type FeishuMessageIntakeSummary, type FeishuMessageQueue, type FeishuMessageQueueOptions, type FeishuMessageWorker, type FeishuMessageWorkerDrainAvailableResult, type FeishuMessageWorkerOptions, type FeishuMessageWorkerQueue, type FeishuOpenApiClient, FeishuOpenApiError, type FeishuOpenApiRequest, type FeishuOpenApiResponse, type FeishuPeriodicFlush, type FeishuPeriodicFlushOptions, type FeishuPeriodicFlushSupervisor, type FeishuPresentationPreparationOptions, type FeishuPromptAgentCommand, type FeishuPromptMessageIntakeSummary, type FeishuRawCardJson, type FeishuReceiveAcceptedObservation, type FeishuReceiveHandledObservation, type FeishuReceiveMessageHandlerPayload, type FeishuReceiveMessagePayload, type FeishuReceiveMessageReplayOptions, type FeishuReceiveMessageReplayResult, type FeishuReceiveMessageSummary, type FeishuReceiveRuntimeStatus, type FeishuResolveInteractionCommand, type FeishuSdkReceiveMessagePayload, type FeishuSessionReference, type FeishuStreamAction, type FeishuStreamActionPublisher, type FeishuStreamProjector, FeishuTenantAccessTokenError, type FeishuTenantAccessTokenProvider, type FeishuTenantAccessTokenProviderOptions, type FeishuTenantAccessTokenRequest, type FeishuTenantAccessTokenResponse, type FeishuTextReplySender, type FeishuWebSocketClient, type FeishuWebSocketClientStartOptions, type FeishuWebSocketDaemon, type FeishuWebSocketDaemonOptions, type FeishuWebSocketEventDispatcher, type FeishuWebSocketRuntime, type FeishuWorkerLoop, type FeishuWorkerLoopOptions, type FetchLike, type FetchLikeResponse, type HumanInteraction, type HumanInteractionActor, type HumanInteractionBase, type HumanInteractionClock, type HumanInteractionEndpointRegistry, type HumanInteractionFact, type HumanInteractionId, type HumanInteractionPresenter, type HumanInteractionRepository, HumanInteractionRepositoryError, type HumanInteractionResolutionAction, type HumanInteractionService, type HumanInteractionServiceOptions, type HumanInteractionTransition, HumanInteractionTransitionDenied, InvalidFeishuCardAction, InvalidFeishuMessageContent, InvalidFeishuSessionReference, InvalidInvocationAuthority, InvalidRecoveryAction, InvalidRivusEndpointBinding, InvalidRivusPlugin, InvalidStableJson, InvalidToolInput, InvalidWorkspaceRoot, type InvocationAuthority, type InvocationAuthorityRef, type JsonFetchRequestOptions, type JsonFileFeishuCardTargetRegistryOptions, type JsonHttpRequest, type JsonHttpResponse, type JsonlAgentEventLogOptions, type JsonlFeishuCardDeliveryLedgerOptions, type JsonlFeishuInboxRepositoryOptions, type JsonlHumanInteractionRepositoryOptions, type JsonlRecoveryControlOptions, type LangfuseAgentTelemetry, type LangfuseTelemetryConfig, LangfuseTelemetryConfigError, type LangfuseTelemetryContentMode, type LangfuseTelemetryEnv, type LoadRivusDeploymentManifestOptions, type LoadRivusDeploymentOptions, type LoadedRivusDeployment, type LocalCliAgentInvocationOrigin, MEMORY_SCOPES, type MemoryBinding, type MemoryInvocationAudience, type MemoryRecord, type MemoryScope, type MemorySearchQuery, type MemoryState, type MemoryTombstoneReceipt, OpenClawEnvImportError, type OpenClawEnvImportOptions, type OpenClawEnvImportResult, type OpenJsonAutomationTickRepositoryOptions, type OpenTelemetryAgentEventSinkOptions, type OpenTelemetryAgentTelemetry, type PendingHumanInteractionState, type PiAgentLoopOptions, type PiAgentSession, type PiAgentSessionEvent, type PiAgentSessionHandle, type PiCreateAgentSessionResult, type PiSdkAgentLoopOptions, type PiSessionRegistry, type PiSessionRegistryOptions, type PiToolApprovalGateway, type PiToolApprovalRequest, type PiToolProxyOptions, PluginStateConflict, type PluginStateRecord, type PluginStateStore, type PooledAgentRuntime, type PromptCommand, type PutPluginState, RIVUS_MEMORY_TOOL_ID, RIVUS_MEMORY_TOOL_PLUGIN_ID, RIVUS_MEMORY_TOOL_VERSION, RIVUS_PLUGIN_API_VERSION, type RateLimitedFeishuPublisherOptions, type RecoveryAction, type RecoveryControl, type RecoveryControlOptions, type RecoverySnapshot, type RegisteredRivusAgentProfile, type RegisteredRivusAutomation, type RegisteredRivusPlugin, type RegisteredRivusSkill, type RegisteredRivusTool, type RejectedHumanInteractionState, type RequestToolApprovalInput, type RequestUserDecisionInput, type ResolveHumanInteractionInput, type ResolvedRivusAgentDefinition, type ResolvedRivusAutomationDefinition, type RivusAgentDeployment, type RivusAgentDeploymentStatus, type RivusAgentHost, type RivusAgentHostOptions, type RivusAgentProfile, type RivusAutomationDelivery, type RivusAutomationDeliveryTargetType, type RivusAutomationDeployment, type RivusAutomationInput, type RivusAutomationTemplate, type RivusAutomationTickContext, type RivusDaemonBootstrapContext, type RivusDaemonBootstrapFactory, type RivusDaemonBootstrapModule, type RivusDaemonCliOptions, type RivusDaemonCliWriter, type RivusDaemonConfig, RivusDaemonConfigError, type RivusDaemonConfigLoaderOptions, type RivusDaemonEnv, type RivusDaemonFeishuReplayRunner, type RivusDaemonProcess, type RivusDaemonProcessOptions, type RivusDaemonPromptRunner, type RivusDaemonRecoveryRunner, type RivusDaemonShutdownController, type RivusDaemonShutdownControllerOptions, type RivusDaemonShutdownSignal, type RivusDaemonSignalSource, type RivusDaemonStatus, type RivusDaemonStatusHttpServer, type RivusDaemonStatusHttpServerOptions, type RivusDaemonStatusReporter, type RivusDaemonStatusReporterOptions, type RivusDaemonTransport, type RivusDaemonWorkerLoop, type RivusDeploymentAutomation, type RivusDeploymentAutomationLifecycle, RivusDeploymentAutomationReadinessError, type RivusDeploymentAutomationStatus, type RivusDeploymentBootstrapAdapters, type RivusDeploymentBootstrapContext, type RivusDeploymentBootstrapFactory, type RivusDeploymentCliProcess, type RivusDeploymentComponentLifecycle, type RivusDeploymentDaemon, type RivusDeploymentDaemonLifecycle, RivusDeploymentDaemonLifecycleError, type RivusDeploymentDaemonStatus, type RivusDeploymentEndpoint, type RivusDeploymentEndpointLifecycle, type RivusDeploymentEndpointStatus, type RivusDeploymentManifest, RivusDeploymentManifestError, RivusDeploymentReadinessError, type RivusEndpointDefinition, type RivusEndpointDeployment, type RivusEndpointExperimentalFeatures, type RivusEndpointInput, type RivusEnvFileVariables, type RivusHostToolDescriptor, type RivusMemoryTool, type RivusPlugin, type RivusPluginCatalog, type RivusPluginCatalogSnapshot, RivusPluginConformanceError, type RivusPluginConformanceInput, type RivusPluginConformanceReport, type RivusPluginDeclaration, type RivusPluginLifecycleProbe, RivusPluginLoadError, type RivusPluginLoadStatus, type RivusPluginManifest, type RivusPluginModule, type RivusPluginModuleLoadRequest, type RivusPluginRegistry, type RivusResolvedToolDescriptor, type RivusSkillDescriptor, type RivusSkillGrantSet, type RivusTextFileReader, type RivusThinkingLevel, type RivusToolDescriptor, type RivusToolExecutionContext, type RivusToolExecutor, type RivusToolFactoryContext, type RivusToolGrantSet, type RivusToolIdempotency, RivusToolInputRejected, type RivusToolRisk, type RunIdGenerator, type ScheduledAutomation, type ScheduledAutomationClock, type ScheduledAutomationDeliveryInput, type ScheduledAutomationOptions, type ScheduledAutomationRunInput, type ScheduledAutomationRunResult, type SelectedHumanInteractionState, type SessionKey, type SessionScheduler, SessionSchedulerCapacityExceeded, SessionSchedulerDisposed, type SessionSchedulerOptions, type SessionSchedulerStatus, type SpawnSubagentRequest, type SubagentCoordinator, type SubagentRecord, type TelemetryContentRedactor, type TelemetryContentRedactorOptions, type TerminalAgentDomainEvent, type TextAgentLoopCallback, type TextAgentLoopOptions, type ToolApprovalBinding, type ToolApprovalInteraction, type ToolApprovalInteractionState, type ToolApprovalRequest, type ToolApprovalService, type ToolBroker, type ToolBrokerOptions, type ToolExecutionRequest, ToolInvocationDenied, type ToolOperationBeginResult, type ToolOperationBinding, type ToolOperationInspectResult, type ToolOperationLedger, type ToolOperationReconciliation, type ToolOperationReconciliationOutcome, type ToolOperationRecord, type ToolOperationRecoveryItem, type ToolOperationResolutionResult, type ToolOperationState, UnsupportedFeishuCardAction, UnsupportedFeishuMessage, type UserDecisionInteraction, type UserDecisionInteractionState, type UserDecisionOption, type WorkspaceInstructionSource, type WorkspaceInstructionsDiagnostic, type WorkspaceInstructionsDiagnosticCode, type WorkspaceInstructionsProvider, type WorkspaceInstructionsRequest, WorkspaceInstructionsSourceError, type WorkspaceInstructionsView, type WorkspaceRootHandle, assembleAgentContext, assertRivusPluginConforms, commitAutomationOutcome, createAgentCommandFromFeishuCardAction, createAgentCommandFromFeishuMessage, createAgentConversationMessages, createAgentDomainEventHandler, createAgentDomainEventSink, createAgentDomainEventSinkFromCallback, createAgentHarness, createAgentHarnessClient, createAgentHarnessPooledRuntime, createAgentInstanceRegistry, createAgentLoopFromCallback, createAgentLoopModelExecutionEnd, createAgentLoopModelExecutionStart, createAgentLoopSkillExecutionEnd, createAgentLoopSkillExecutionStart, createAgentLoopTextDelta, createAgentLoopThinkingDelta, createAgentLoopToolExecutionEnd, createAgentLoopToolExecutionStart, createAgentLoopToolExecutionUpdate, createAgentMemoryService, createAgentRunUpdateHandler, createAgentRuntime, createAgentRuntimePool, createAgentTranscriptMessages, createAgentTranscriptTurn, createAgentsMdInstructionsProvider, createAsyncIterableAgentLoop, createAutomationMandateStore, createCoalescingFeishuPublisher, createCompactionService, createCompositeRivusDaemonTransport, createConfiguredFeishuCardKitPublisher, createConfiguredFeishuCardKitTargetPreparation, createConfiguredFeishuHumanInteractionPresenter, createConfiguredFeishuMarkdownMessageSender, createConfiguredFeishuOpenApiClient, createConfiguredFeishuTextReplySender, createConfiguredRivusDaemonBootstrap, createConfiguredRivusDeploymentDaemon, createDailyAutomationSchedule, createDefaultAgentHarness, createDefaultAgentHarnessClient, createDefaultAgentHarnessClientFromCallback, createDefaultAgentHarnessClientFromTextCallback, createDefaultAgentHarnessFromCallback, createDefaultAgentHarnessFromTextCallback, createDefaultAgentRuntime, createDefaultAgentRuntimeFromCallback, createDefaultAgentRuntimeFromTextCallback, createDelegationService, createDeliveryOutbox, createEventAgentLoop, createFakeRivusPlugin, createFeishuAgentDaemon, createFeishuAgentRunCard, createFeishuAgentRuntime, createFeishuCardActionCallbackResponse, createFeishuCardActionErrorResponse, createFeishuCardDeliveryLedger, createFeishuCardDeliveryReconciler, createFeishuCardKitOpenApiClient, createFeishuCardKitOpenApiTargetCreator, createFeishuCardKitPublisher, createFeishuCardTargetPreparation, createFeishuConversationId, createFeishuCotPublisher, createFeishuDeploymentEndpoint, createFeishuEventHandlers, createFeishuHumanInteractionCard, createFeishuHumanInteractionPresenter, createFeishuInboxRepository, createFeishuMessageQueue, createFeishuMessageWorker, createFeishuOpenApiClient, createFeishuPeriodicFlush, createFeishuPresentationPreparation, createFeishuSessionKey, createFeishuStreamProjector, createFeishuTenantAccessTokenProvider, createFeishuWebSocketDaemon, createFeishuWorkerLoop, createFixedClock, createHumanInteractionEndpointRegistry, createHumanInteractionService, createHumanInteractionToolApprovalGateway, createInMemoryFeishuCardTargetRegistry, createInMemoryHumanInteractionRepository, createInvocationAuthority, createJsonFetchRequest, createJsonFileFeishuCardTargetRegistry, createJsonlAgentEventLog, createJsonlHumanInteractionRepository, createLangfuseAgentTelemetry, createLazyFeishuWebSocketEventDispatcher, createMemoryNamespace, createOpenTelemetryAgentEventSink, createOpenTelemetryAgentTelemetry, createPiAgentLoop, createPiSdkAgentLoop, createPiSessionRegistry, createPiSkillRuntime, createPiToolNameResolver, createPiToolProxyDefinitions, createPluginStateStore, createRateLimitedFeishuPublisher, createRecoveryAction, createRecoveryControl, createRivusAgentHost, createRivusDaemonProcess, createRivusDaemonShutdownController, createRivusDaemonStatusHttpServer, createRivusDaemonStatusReporter, createRivusDeploymentCliProcess, createRivusDeploymentDaemon, createRivusEnvFromOpenClawConfig, createRivusMemoryTool, createRivusMemoryToolContract, createRivusMemoryToolDescriptor, createRivusPluginCatalog, createRoutedHumanInteractionToolApprovalService, createScheduledAutomation, createSequenceRunIds, createSessionScheduler, createSubagentCoordinator, createSystemClock, createTelemetryContentRedactor, createTextAgentLoop, createTextAgentLoopFromCallback, createToolBroker, createToolInputDigest, createToolOperationLedger, createUuidRunIds, createWorkspaceRootHandle, describeFeishuMessageIntake, evolveAgentRun, formatRivusEnvFile, initialAgentRunState, intersectToolIds, isAgentToolExecutionEvent, isAssistantTextDeltaEvent, isAssistantThinkingDeltaEvent, isTerminalAgentDomainEvent, isTerminalAgentRunPhase, loadNodeRivusPluginModule, loadRivusDaemonConfig, loadRivusDeployment, loadRivusDeploymentManifest, normalizeStableJson, openJsonAutomationTickRepository, openJsonlAgentMemoryService, openJsonlFeishuCardDeliveryLedger, openJsonlFeishuInboxRepository, openJsonlRecoveryControl, openJsonlToolOperationLedger, replayAgentHistory, replayAgentTranscript, requiresToolApproval, resolveFeishuEndpointCredentials, resolveLangfuseTelemetryConfig, resolveRivusAgentDefinition, restoreAgentHistory, restoreConfiguredRivusDaemonBootstrap, restrictMemoryScopesForAudience, runRivusDaemonCli, shouldAcceptFeishuEndpointMessage, transitionHumanInteraction, validateRivusDeploymentManifest };
|