@rivus/agent 0.3.1 → 0.4.1
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/README.md +3 -3
- package/dist/acp.d.ts +98 -0
- package/dist/acp.js +436 -0
- package/dist/agent-loop.d.ts +420 -0
- package/dist/agent-loop.js +118 -0
- package/dist/agent-memory.d.ts +98 -0
- package/dist/cli.js +6 -2
- package/dist/index.d.ts +4 -418
- package/dist/index.js +63 -150
- package/dist/rivus-daemon-cli.js +11 -7
- package/dist/rivus-plugin-testkit.d.ts +3 -98
- package/examples/a-share-briefing-analysis.mjs +93 -0
- package/examples/a-share-briefing-renderer.mjs +257 -0
- package/examples/a-share-index-evidence.mjs +99 -0
- package/examples/a-share-market-briefing.mjs +83 -0
- package/examples/a-share-market-date.mjs +10 -0
- package/examples/a-share-overseas-evidence.mjs +86 -0
- package/examples/a-share-policy-evidence.mjs +145 -0
- package/examples/a-share-provider-response.mjs +21 -0
- package/examples/a-share-sector-evidence.mjs +70 -0
- package/examples/acp-stdio-proxy.mjs +55 -0
- package/examples/current-weather.mjs +6 -32
- package/examples/https-response-reader.mjs +36 -0
- package/examples/rivus-agents.plugin.mjs +55 -3
- package/examples/rivus.config.json +30 -1
- package/package.json +11 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,424 +1,10 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { $ as createAgentTranscriptTurn, A as createAgentLoopModelExecutionStart, At as AssistantThinkingDelta, B as createTextAgentLoop, C as AgentLoopToolExecutionUpdateOptions, Ct as AgentToolExecutionEnded, D as TextAgentLoopOptions, Dt as AgentTurnCompleted, E as TextAgentLoopCallback, Et as AgentToolExecutionUpdated, F as createAgentLoopToolExecutionEnd, Ft as isAssistantThinkingDeltaEvent, G as LocalCliAgentInvocationOrigin, H as AgentInvocationOrigin, I as createAgentLoopToolExecutionStart, It as isTerminalAgentDomainEvent, J as AgentTranscriptMessage, K as AgentConversationMessagesOptions, L as createAgentLoopToolExecutionUpdate, M as createAgentLoopSkillExecutionStart, Mt as TerminalAgentDomainEvent, N as createAgentLoopTextDelta, Nt as isAgentToolExecutionEvent, O as createAgentLoopFromCallback, Ot as AgentTurnStarted, P as createAgentLoopThinkingDelta, Pt as isAssistantTextDeltaEvent, Q as createAgentTranscriptMessages, R as createAsyncIterableAgentLoop, S as AgentLoopToolExecutionUpdate, St as AgentSkillExecutionStarted, T as EventAgentLoopOptions, Tt as AgentToolExecutionStarted, U as AutomationAgentInvocationOrigin, V as createTextAgentLoopFromCallback, W as FeishuAgentInvocationOrigin, X as AgentTranscriptTurn, Y as AgentTranscriptMessageRole, Z as createAgentConversationMessages, _ as AgentLoopThinkingDelta, _t as AgentRunCancelled$1, a as AgentLoopEvent, at as AgentRunPhase, b as AgentLoopToolExecutionStart, bt as AgentRunId, c as AgentLoopModelExecutionEnd, ct as evolveAgentRun, d as AgentLoopModelExecutionStartOptions, dt as AgentDomainEvent, et as replayAgentTranscript, f as AgentLoopSkillExecutionEnd, ft as AgentModelExecutionEnded, g as AgentLoopTextDelta, gt as AgentRunAccepted, h as AgentLoopSkillExecutionStartOptions, ht as AgentModelUsage, i as AgentLoopCallbackResult, it as replayAgentHistory, j as createAgentLoopSkillExecutionEnd, jt as SessionKey, k as createAgentLoopModelExecutionEnd, kt as AssistantTextDelta, l as AgentLoopModelExecutionEndOptions, lt as initialAgentRunState, m as AgentLoopSkillExecutionStart, mt as AgentModelExecutionStarted, n as AgentLoopCallback, nt as AgentRunSummary, o as AgentLoopEventLike, ot as AgentRunState, p as AgentLoopSkillExecutionEndOptions, pt as AgentModelExecutionEvent, q as AgentTranscript, r as AgentLoopCallbackOutput, rt as AgentSessionSummary, s as AgentLoopInput, st as AgentSkillExecutionState, t as AgentLoop, tt as AgentHistory, u as AgentLoopModelExecutionStart, ut as isTerminalAgentRunPhase, v as AgentLoopToolExecutionEnd, vt as AgentRunCompleted, w as AsyncIterableAgentLoopOptions, wt as AgentToolExecutionEvent, x as AgentLoopToolExecutionStartOptions, xt as AgentSkillExecutionEnded, y as AgentLoopToolExecutionEndOptions, yt as AgentRunFailed, z as createEventAgentLoop } from "./agent-loop.js";
|
|
2
|
+
import { a as MemoryBinding, c as MemoryScope, d as RIVUS_MEMORY_TOOL_PLUGIN_ID, f as RIVUS_MEMORY_TOOL_VERSION, h as restrictMemoryScopesForAudience, i as MEMORY_SCOPES, l as MemoryState, m as createRivusMemoryToolContract, n as AgentMemoryIdentity, o as MemoryInvocationAudience, p as createMemoryNamespace, r as AgentMemorySnapshot, s as MemoryRecord, t as AgentMemoryAuthority, u as RIVUS_MEMORY_TOOL_ID } from "./agent-memory.js";
|
|
3
|
+
import { A as RivusToolExecutionContext, C as RivusPluginCatalogSnapshot, D as RivusSkillDescriptor, E as RivusResolvedToolDescriptor, F as RivusToolInputRejected, I as RivusToolRisk, L as requiresToolApproval, M as RivusToolFactoryContext, N as RivusToolGrantSet, O as RivusSkillGrantSet, P as RivusToolIdempotency, S as RivusPluginCatalog, T as RivusPluginRegistry, _ 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, r as RivusPluginConformanceReport, s as InvalidRivusPlugin, t as RivusPluginConformanceError, u as RegisteredRivusAutomation, v as RivusAutomationTemplate, w as RivusPluginManifest, x as RivusPlugin, y as RivusAutomationTickContext } from "./rivus-plugin-testkit.js";
|
|
2
4
|
import { Effect, Stream } from "effect";
|
|
3
5
|
import { Tracer } from "@opentelemetry/api";
|
|
4
6
|
import { ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
5
7
|
|
|
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
8
|
//#region src/application/agent/agent-harness.d.ts
|
|
423
9
|
interface AgentClock {
|
|
424
10
|
readonly now: Effect.Effect<Date>;
|
|
@@ -2022,7 +1608,7 @@ interface AutomationTickRecord {
|
|
|
2022
1608
|
readonly tickId: string;
|
|
2023
1609
|
}
|
|
2024
1610
|
interface AutomationTickRepository {
|
|
2025
|
-
get(
|
|
1611
|
+
get(automationId: string, occurrence: string): Promise<AutomationTickRecord | undefined>;
|
|
2026
1612
|
put(record: AutomationTickRecord): Promise<AutomationTickRecord>;
|
|
2027
1613
|
}
|
|
2028
1614
|
interface ScheduledAutomationRunInput {
|