@rivus/gateway 0.16.2 → 0.17.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 +674 -21
- package/README.md +25 -0
- package/dist/bootstrap/herdr-feishu.d.ts +37 -0
- package/dist/bootstrap/herdr-feishu.js +856 -0
- package/dist/bootstrap/pi-feishu.d.ts +281 -16
- package/dist/bootstrap/pi-feishu.js +17314 -344
- package/dist/chunks/background-session-authority.js +2 -38
- package/dist/chunks/rivus-daemon-cli.d.ts +1115 -0
- package/dist/chunks/rivus-node-entrypoint.js +700 -819
- package/dist/chunks/{node-rivus-deployment-manifest.js → runtime-cache.js} +1116 -1475
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +1 -0
- package/dist/index.d.ts +65 -3
- package/dist/index.js +3 -1215
- package/dist/mcp.d.ts +7 -63
- package/dist/mcp.js +3 -250
- package/package.json +29 -14
- package/templates/a-share-briefing-analysis.mjs +3 -1
- package/templates/a-share-briefing-renderer.mjs +15 -5
- package/templates/a-share-index-evidence.mjs +9 -3
- package/templates/a-share-market-briefing.mjs +3 -1
- package/templates/a-share-overseas-evidence.mjs +12 -4
- package/templates/a-share-policy-evidence.mjs +30 -10
- package/templates/a-share-sector-evidence.mjs +3 -1
- package/templates/acp-stdio-proxy.mjs +10 -4
- package/templates/current-weather.mjs +36 -12
- package/templates/herdr-feishu.mjs +30 -0
- package/templates/html-drive-tools.mjs +36 -12
- package/templates/pi-feishu-deployment.bootstrap.ts +1 -3
- package/templates/pi-feishu.bootstrap.ts +1 -242
- package/templates/rivus-agents.plugin.mjs +3 -1
- package/dist/chunks/background-session-control-input.js +0 -45
- package/dist/chunks/background-session-service.d.ts +0 -390
- package/dist/chunks/index.d.ts +0 -4703
- package/dist/chunks/service.js +0 -12112
- package/templates/langfuse-drive-e2e.mjs +0 -175
|
@@ -0,0 +1,1115 @@
|
|
|
1
|
+
import { AgentHarness, AgentInvocationOrigin, AgentRunId, AgentRunUpdate, AttachmentAccess, PromptCommand, RegisteredRivusSkill, RegisteredRivusTool, RivusMemoryScope, RivusResolvedToolDescriptor, RivusRuntimeToolGrantSet, RivusRuntimeToolId, RivusSkillDescriptor, RivusSkillGrantSet, RivusToolDescriptor, RivusToolGrantSet, SessionKey, UserInput } from "@rivus/runtime";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
//#region src/core/application/recovery/contracts/recovery-control.d.ts
|
|
4
|
+
type RecoveryToolOperationOutcome = {
|
|
5
|
+
readonly result: unknown;
|
|
6
|
+
readonly status: "applied";
|
|
7
|
+
} | {
|
|
8
|
+
readonly status: "not-applied";
|
|
9
|
+
};
|
|
10
|
+
interface DeadLetterRecoveryItem {
|
|
11
|
+
readonly acceptedAt: string;
|
|
12
|
+
readonly attempts: number;
|
|
13
|
+
readonly deliveryId: string;
|
|
14
|
+
readonly endpointId: string;
|
|
15
|
+
readonly failureCode: "delivery_failed";
|
|
16
|
+
readonly failureSummary: string;
|
|
17
|
+
readonly failedAt: string;
|
|
18
|
+
readonly revision: number;
|
|
19
|
+
}
|
|
20
|
+
interface DeadLetterRequeueResult {
|
|
21
|
+
readonly acceptedAt: string;
|
|
22
|
+
readonly attempts: 0;
|
|
23
|
+
readonly availableAt: string;
|
|
24
|
+
readonly deliveryId: string;
|
|
25
|
+
readonly endpointId: string;
|
|
26
|
+
readonly recoveredAt: string;
|
|
27
|
+
readonly recoveredBy: string;
|
|
28
|
+
readonly revision: number;
|
|
29
|
+
readonly status: "pending";
|
|
30
|
+
}
|
|
31
|
+
interface RecoverySnapshot {
|
|
32
|
+
readonly deadLetters: ReadonlyArray<DeadLetterRecoveryItem>;
|
|
33
|
+
readonly toolOperations: ReadonlyArray<ToolOperationRecoveryItem>;
|
|
34
|
+
}
|
|
35
|
+
interface ToolOperationRecoveryItem {
|
|
36
|
+
readonly agentId: string;
|
|
37
|
+
readonly inputDigest: string;
|
|
38
|
+
readonly instanceId: string;
|
|
39
|
+
readonly operationId: string;
|
|
40
|
+
readonly failureCode: "tool_outcome_unknown";
|
|
41
|
+
readonly failureSummary: string;
|
|
42
|
+
readonly revision: number;
|
|
43
|
+
readonly status: "reconciliation-required";
|
|
44
|
+
readonly toolId: string;
|
|
45
|
+
readonly toolVersion: string;
|
|
46
|
+
}
|
|
47
|
+
interface ToolOperationResolutionResult {
|
|
48
|
+
readonly agentId: string;
|
|
49
|
+
readonly inputDigest: string;
|
|
50
|
+
readonly instanceId: string;
|
|
51
|
+
readonly operationId: string;
|
|
52
|
+
readonly reconciledAt: string;
|
|
53
|
+
readonly reconciledBy: string;
|
|
54
|
+
readonly revision: number;
|
|
55
|
+
readonly status: "aborted" | "completed";
|
|
56
|
+
readonly toolId: string;
|
|
57
|
+
readonly toolVersion: string;
|
|
58
|
+
}
|
|
59
|
+
interface RecoveryControl {
|
|
60
|
+
inspect(): Effect.Effect<RecoverySnapshot, unknown>;
|
|
61
|
+
requeueDeadLetter(input: {
|
|
62
|
+
readonly actorId: string;
|
|
63
|
+
readonly deliveryId: string;
|
|
64
|
+
readonly endpointId: string;
|
|
65
|
+
readonly expectedRevision: number;
|
|
66
|
+
readonly note: string;
|
|
67
|
+
}): Effect.Effect<DeadLetterRequeueResult, unknown>;
|
|
68
|
+
resolveToolOperation(input: {
|
|
69
|
+
readonly actorId: string;
|
|
70
|
+
readonly expectedRevision: number;
|
|
71
|
+
readonly instanceId: string;
|
|
72
|
+
readonly note: string;
|
|
73
|
+
readonly operationId: string;
|
|
74
|
+
readonly outcome: RecoveryToolOperationOutcome;
|
|
75
|
+
}): Effect.Effect<ToolOperationResolutionResult, unknown>;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/core/domain/automation-occurrence/aggregate/snapshot.d.ts
|
|
79
|
+
type AutomationOccurrenceStatus = "running" | "failed" | "generated" | "suppressed" | "delivered";
|
|
80
|
+
interface AutomationOccurrenceSnapshot {
|
|
81
|
+
readonly automationId: string;
|
|
82
|
+
readonly body?: string;
|
|
83
|
+
readonly error?: string;
|
|
84
|
+
readonly mandateId: string;
|
|
85
|
+
readonly occurrence: string;
|
|
86
|
+
readonly presentation?: unknown;
|
|
87
|
+
readonly providerMessageId?: string;
|
|
88
|
+
readonly revision: number;
|
|
89
|
+
readonly runId?: string;
|
|
90
|
+
readonly status: AutomationOccurrenceStatus;
|
|
91
|
+
readonly suppressionReason?: string;
|
|
92
|
+
readonly tickId: string;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/core/domain/automation-occurrence/aggregate/automation-occurrence.d.ts
|
|
96
|
+
interface CreateAutomationOccurrenceInput {
|
|
97
|
+
readonly automationId: string;
|
|
98
|
+
readonly mandateId: string;
|
|
99
|
+
readonly occurrence: string;
|
|
100
|
+
readonly tickId: string;
|
|
101
|
+
}
|
|
102
|
+
interface GenerateAutomationOccurrenceInput {
|
|
103
|
+
readonly body: string;
|
|
104
|
+
readonly presentation?: unknown;
|
|
105
|
+
readonly runId: string;
|
|
106
|
+
}
|
|
107
|
+
interface SuppressAutomationOccurrenceInput {
|
|
108
|
+
readonly reason: string;
|
|
109
|
+
readonly runId: string;
|
|
110
|
+
}
|
|
111
|
+
declare class AutomationOccurrence {
|
|
112
|
+
#private;
|
|
113
|
+
private constructor();
|
|
114
|
+
static create(input: CreateAutomationOccurrenceInput): AutomationOccurrence;
|
|
115
|
+
static restore(value: unknown): AutomationOccurrence;
|
|
116
|
+
get automationId(): string;
|
|
117
|
+
get mandateId(): string;
|
|
118
|
+
get occurrence(): string;
|
|
119
|
+
get revision(): number;
|
|
120
|
+
get status(): AutomationOccurrenceStatus;
|
|
121
|
+
get tickId(): string;
|
|
122
|
+
restart(): AutomationOccurrence;
|
|
123
|
+
fail(error: string): AutomationOccurrence;
|
|
124
|
+
generate(input: GenerateAutomationOccurrenceInput): AutomationOccurrence;
|
|
125
|
+
suppress(input: SuppressAutomationOccurrenceInput): AutomationOccurrence;
|
|
126
|
+
deliver(providerMessageId: string): AutomationOccurrence;
|
|
127
|
+
validateTransitionTo(next: AutomationOccurrence): boolean;
|
|
128
|
+
toSnapshot(): AutomationOccurrenceSnapshot;
|
|
129
|
+
private requireRunning;
|
|
130
|
+
private next;
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/core/application/automation/presentation/automation-line-chart.d.ts
|
|
134
|
+
interface AutomationLineChart {
|
|
135
|
+
readonly title: string;
|
|
136
|
+
readonly labels: ReadonlyArray<string>;
|
|
137
|
+
readonly unit: string;
|
|
138
|
+
readonly seriesLayout?: "overlay" | "separate";
|
|
139
|
+
readonly series: ReadonlyArray<{
|
|
140
|
+
readonly name: string;
|
|
141
|
+
readonly values: ReadonlyArray<number>;
|
|
142
|
+
}>;
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/core/application/automation/presentation/automation-presentation.d.ts
|
|
146
|
+
declare const AUTOMATION_PRESENTATION_SCHEMA_VERSION: 1;
|
|
147
|
+
type AutomationPresentationKind = "daily-ai" | "generic" | "industry" | "news" | "subscriptions";
|
|
148
|
+
interface AutomationPresentationSource {
|
|
149
|
+
readonly label: string;
|
|
150
|
+
readonly url: string;
|
|
151
|
+
}
|
|
152
|
+
interface AutomationPresentationItem {
|
|
153
|
+
readonly headline: string;
|
|
154
|
+
readonly note?: string;
|
|
155
|
+
readonly sources: ReadonlyArray<AutomationPresentationSource>;
|
|
156
|
+
}
|
|
157
|
+
interface AutomationPresentationSection {
|
|
158
|
+
readonly id: string;
|
|
159
|
+
readonly items: ReadonlyArray<AutomationPresentationItem>;
|
|
160
|
+
readonly title: string;
|
|
161
|
+
}
|
|
162
|
+
interface AutomationPresentation {
|
|
163
|
+
readonly lineChart?: AutomationLineChart;
|
|
164
|
+
readonly footnote?: string;
|
|
165
|
+
readonly kind?: AutomationPresentationKind;
|
|
166
|
+
readonly meta: ReadonlyArray<string>;
|
|
167
|
+
readonly schemaVersion: typeof AUTOMATION_PRESENTATION_SCHEMA_VERSION;
|
|
168
|
+
readonly sections: ReadonlyArray<AutomationPresentationSection>;
|
|
169
|
+
readonly summary?: string;
|
|
170
|
+
readonly title: string;
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/core/application/automation/scheduling/automation-scheduler.d.ts
|
|
174
|
+
interface ScheduledAutomationRunInput {
|
|
175
|
+
readonly occurrence: string;
|
|
176
|
+
readonly sessionKey: string;
|
|
177
|
+
readonly text: string;
|
|
178
|
+
readonly tickId: string;
|
|
179
|
+
}
|
|
180
|
+
interface AutomationScheduler {
|
|
181
|
+
running(): boolean;
|
|
182
|
+
runDue(at: Date): Effect.Effect<AutomationOccurrence | undefined, unknown>;
|
|
183
|
+
start(): Effect.Effect<void>;
|
|
184
|
+
stop(): Effect.Effect<void>;
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/core/application/agent-catalog/contracts/rivus-agent-definition.d.ts
|
|
188
|
+
interface RivusAgentProfile {
|
|
189
|
+
readonly id: string;
|
|
190
|
+
readonly displayName: string;
|
|
191
|
+
readonly systemPrompt: string;
|
|
192
|
+
readonly model: Readonly<Record<string, unknown>>;
|
|
193
|
+
readonly tools: {
|
|
194
|
+
readonly allow: ReadonlyArray<string>;
|
|
195
|
+
};
|
|
196
|
+
readonly skills: {
|
|
197
|
+
readonly allow: ReadonlyArray<string>;
|
|
198
|
+
};
|
|
199
|
+
readonly memory: {
|
|
200
|
+
readonly scopes: ReadonlyArray<RivusMemoryScope>;
|
|
201
|
+
};
|
|
202
|
+
readonly runtimeTools?: {
|
|
203
|
+
readonly allow: ReadonlyArray<RivusRuntimeToolId>;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
interface RegisteredRivusAgentProfile extends RivusAgentProfile {
|
|
207
|
+
readonly pluginId: string;
|
|
208
|
+
}
|
|
209
|
+
interface RivusAgentDeployment {
|
|
210
|
+
readonly agentId: string;
|
|
211
|
+
readonly pluginId: string;
|
|
212
|
+
readonly profileId: string;
|
|
213
|
+
readonly projectSpaceId?: string;
|
|
214
|
+
readonly endpointIds: ReadonlyArray<string>;
|
|
215
|
+
readonly memory?: {
|
|
216
|
+
readonly scopes: ReadonlyArray<RivusMemoryScope>;
|
|
217
|
+
readonly tool: boolean;
|
|
218
|
+
};
|
|
219
|
+
readonly runtimeTools?: {
|
|
220
|
+
readonly allow: ReadonlyArray<RivusRuntimeToolId>;
|
|
221
|
+
};
|
|
222
|
+
readonly skills: {
|
|
223
|
+
readonly allow: ReadonlyArray<string>;
|
|
224
|
+
};
|
|
225
|
+
readonly tools: {
|
|
226
|
+
readonly allow: ReadonlyArray<string>;
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
interface ResolvedRivusAgentDefinition {
|
|
230
|
+
readonly agentId: string;
|
|
231
|
+
readonly pluginId: string;
|
|
232
|
+
readonly profileId: string;
|
|
233
|
+
readonly projectSpaceId?: string;
|
|
234
|
+
readonly projectSpaceRevision?: string;
|
|
235
|
+
readonly endpointIds: ReadonlyArray<string>;
|
|
236
|
+
readonly profileRevision: string;
|
|
237
|
+
readonly systemPrompt: string;
|
|
238
|
+
readonly model: Readonly<Record<string, unknown>>;
|
|
239
|
+
readonly memory: {
|
|
240
|
+
readonly scopes: ReadonlyArray<RivusMemoryScope>;
|
|
241
|
+
readonly tool: boolean;
|
|
242
|
+
};
|
|
243
|
+
readonly runtimeToolGrantSet: RivusRuntimeToolGrantSet;
|
|
244
|
+
readonly skillGrantSet: RivusSkillGrantSet;
|
|
245
|
+
readonly skills: ReadonlyArray<RegisteredRivusSkill>;
|
|
246
|
+
readonly tools: ReadonlyArray<RivusResolvedToolDescriptor>;
|
|
247
|
+
readonly toolGrantSet: RivusToolGrantSet;
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/core/application/agent-catalog/contracts/rivus-automation-template.d.ts
|
|
251
|
+
interface RivusAutomationTemplate {
|
|
252
|
+
readonly id: string;
|
|
253
|
+
readonly profileId: string;
|
|
254
|
+
readonly requestedSkillIds: ReadonlyArray<string>;
|
|
255
|
+
readonly requestedToolIds: ReadonlyArray<string>;
|
|
256
|
+
readonly createInput: (tick: RivusAutomationTickContext) => RivusAutomationInput;
|
|
257
|
+
readonly createPresentation?: (output: RivusAutomationOutput) => AutomationPresentation;
|
|
258
|
+
}
|
|
259
|
+
interface RivusAutomationTickContext {
|
|
260
|
+
readonly occurrence: string;
|
|
261
|
+
}
|
|
262
|
+
interface RivusAutomationInput {
|
|
263
|
+
readonly text: string;
|
|
264
|
+
}
|
|
265
|
+
interface RivusAutomationOutput {
|
|
266
|
+
readonly occurrence: string;
|
|
267
|
+
readonly text: string;
|
|
268
|
+
}
|
|
269
|
+
interface RegisteredRivusAutomation extends RivusAutomationTemplate {
|
|
270
|
+
readonly pluginId: string;
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/core/application/agent-catalog/contracts/rivus-plugin.d.ts
|
|
274
|
+
declare const RIVUS_PLUGIN_API_VERSION = "1";
|
|
275
|
+
interface RivusPluginManifest {
|
|
276
|
+
readonly apiVersion: string;
|
|
277
|
+
readonly id: string;
|
|
278
|
+
readonly version: string;
|
|
279
|
+
}
|
|
280
|
+
interface RegisteredRivusPlugin extends RivusPluginManifest {}
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/core/application/agent-catalog/contracts/rivus-plugin-contracts.d.ts
|
|
283
|
+
interface RivusPluginRegistry {
|
|
284
|
+
registerAgentProfile(profile: RivusAgentProfile): void;
|
|
285
|
+
registerTool(tool: RivusToolDescriptor): void;
|
|
286
|
+
registerSkill(skill: RivusSkillDescriptor): void;
|
|
287
|
+
registerAutomation(template: RivusAutomationTemplate): void;
|
|
288
|
+
}
|
|
289
|
+
interface RivusPlugin {
|
|
290
|
+
readonly manifest: RivusPluginManifest;
|
|
291
|
+
register(registry: RivusPluginRegistry): void;
|
|
292
|
+
}
|
|
293
|
+
interface RivusPluginCatalogSnapshot {
|
|
294
|
+
readonly plugins: ReadonlyArray<RegisteredRivusPlugin>;
|
|
295
|
+
readonly profiles: ReadonlyArray<RegisteredRivusAgentProfile>;
|
|
296
|
+
readonly tools: ReadonlyArray<RegisteredRivusTool>;
|
|
297
|
+
readonly skills: ReadonlyArray<RegisteredRivusSkill>;
|
|
298
|
+
readonly automations: ReadonlyArray<RegisteredRivusAutomation>;
|
|
299
|
+
}
|
|
300
|
+
interface RivusPluginCatalog {
|
|
301
|
+
registerPlugin(plugin: RivusPlugin): void;
|
|
302
|
+
snapshot(): RivusPluginCatalogSnapshot;
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/core/application/agent-host/contracts/agent-instance.d.ts
|
|
306
|
+
type AgentInstanceBinding = {
|
|
307
|
+
readonly kind: "endpoint";
|
|
308
|
+
readonly endpointId: string;
|
|
309
|
+
} | {
|
|
310
|
+
readonly kind: "automation";
|
|
311
|
+
readonly automationId: string;
|
|
312
|
+
} | {
|
|
313
|
+
readonly kind: "background-session";
|
|
314
|
+
readonly agentId: string;
|
|
315
|
+
};
|
|
316
|
+
interface AgentInstanceRecord {
|
|
317
|
+
readonly agentId: string;
|
|
318
|
+
readonly binding: AgentInstanceBinding;
|
|
319
|
+
readonly bindingKey: string;
|
|
320
|
+
readonly instanceId: string;
|
|
321
|
+
readonly runtimeGenerationId: string;
|
|
322
|
+
}
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/core/application/agent-host/contracts/agent-host-runtime.d.ts
|
|
325
|
+
interface AgentRuntimeInput {
|
|
326
|
+
readonly attachmentAccess?: AttachmentAccess;
|
|
327
|
+
readonly invocation?: AgentInvocationOrigin;
|
|
328
|
+
readonly onUpdate?: (update: AgentRunUpdate) => Effect.Effect<void, unknown>;
|
|
329
|
+
readonly payload?: unknown;
|
|
330
|
+
readonly sessionKey: SessionKey;
|
|
331
|
+
readonly text: string;
|
|
332
|
+
readonly userInput?: UserInput;
|
|
333
|
+
}
|
|
334
|
+
interface AgentRuntimeCancellation {
|
|
335
|
+
readonly reason?: string;
|
|
336
|
+
readonly runId: AgentRunId;
|
|
337
|
+
readonly sessionKey: SessionKey;
|
|
338
|
+
}
|
|
339
|
+
interface AgentRuntimeSteering {
|
|
340
|
+
readonly attachmentAccess?: AttachmentAccess;
|
|
341
|
+
readonly runId: AgentRunId;
|
|
342
|
+
readonly sessionKey: SessionKey;
|
|
343
|
+
readonly text: string;
|
|
344
|
+
readonly userInput?: UserInput;
|
|
345
|
+
}
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/core/application/agent-host/registry/agent-instance-registry.d.ts
|
|
348
|
+
interface AgentInstanceRegistryOptions {
|
|
349
|
+
readonly initialRecords?: ReadonlyArray<AgentInstanceRecord>;
|
|
350
|
+
}
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/core/domain/background-session/value-objects/phase.d.ts
|
|
353
|
+
type BackgroundSessionPhase = "queued" | "running" | "waiting" | "input-required" | "stopping" | "stopped" | "completed" | "failed" | "reconciliation-required";
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region src/core/application/background-session/supervision/background-session-supervisor.d.ts
|
|
356
|
+
interface BackgroundSessionSupervisorStatus {
|
|
357
|
+
readonly capacity: number;
|
|
358
|
+
readonly counters: {
|
|
359
|
+
readonly completed: number;
|
|
360
|
+
readonly deliveriesDelivered: number;
|
|
361
|
+
readonly failed: number;
|
|
362
|
+
readonly started: number;
|
|
363
|
+
readonly staleLeaseEventsDropped: number;
|
|
364
|
+
readonly stopped: number;
|
|
365
|
+
};
|
|
366
|
+
readonly inFlightSteps: number;
|
|
367
|
+
readonly oldestDueAt?: string;
|
|
368
|
+
readonly owner: string;
|
|
369
|
+
readonly phaseCounts: Readonly<Record<BackgroundSessionPhase, number>>;
|
|
370
|
+
readonly reconciliationCount: number;
|
|
371
|
+
readonly repositoryHealthy: boolean;
|
|
372
|
+
readonly running: boolean;
|
|
373
|
+
}
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/core/application/deployment/contracts/manifest.d.ts
|
|
376
|
+
interface RivusBackgroundSessionsDeployment {
|
|
377
|
+
readonly enabled: boolean;
|
|
378
|
+
readonly leaseMs: number;
|
|
379
|
+
readonly leaseRenewalIntervalMs: number;
|
|
380
|
+
readonly maxConsecutiveFailures: number;
|
|
381
|
+
readonly maxConcurrentSessions: number;
|
|
382
|
+
readonly required: boolean;
|
|
383
|
+
readonly retryBackoffMs: number;
|
|
384
|
+
readonly sessionLifetimeMs: number;
|
|
385
|
+
readonly stepTimeoutMs: number;
|
|
386
|
+
}
|
|
387
|
+
type RivusAutomationDeliveryTargetType = "chat_id" | "open_id" | "user_id" | "union_id" | "email";
|
|
388
|
+
interface RivusAutomationDelivery {
|
|
389
|
+
readonly endpointId: string;
|
|
390
|
+
readonly targetRef: string;
|
|
391
|
+
readonly targetType: RivusAutomationDeliveryTargetType;
|
|
392
|
+
}
|
|
393
|
+
interface RivusAutomationDeployment {
|
|
394
|
+
readonly agentId: string;
|
|
395
|
+
readonly delivery: RivusAutomationDelivery;
|
|
396
|
+
readonly enabled: boolean;
|
|
397
|
+
readonly id: string;
|
|
398
|
+
readonly required: boolean;
|
|
399
|
+
readonly schedule: string;
|
|
400
|
+
readonly templateId: string;
|
|
401
|
+
readonly timeZone: string;
|
|
402
|
+
}
|
|
403
|
+
interface RivusEndpointDeployment {
|
|
404
|
+
readonly agentId: string;
|
|
405
|
+
readonly baseUrl: string;
|
|
406
|
+
readonly cardStreamLeaseMs: number;
|
|
407
|
+
readonly credentialRef: string;
|
|
408
|
+
readonly enabled: boolean;
|
|
409
|
+
readonly experimental?: RivusEndpointExperimentalFeatures;
|
|
410
|
+
readonly groupPolicy: "mention-only" | "ignore-unmentioned" | "default-responder";
|
|
411
|
+
readonly id: string;
|
|
412
|
+
readonly progressDisplay?: "hidden" | "collapsed" | "expanded";
|
|
413
|
+
readonly required: boolean;
|
|
414
|
+
readonly sessionNamespace: string;
|
|
415
|
+
readonly streamMinIntervalMs: number;
|
|
416
|
+
}
|
|
417
|
+
interface RivusEndpointExperimentalFeatures {
|
|
418
|
+
readonly cotMessages: boolean;
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/core/application/deployment/contracts/deployment.d.ts
|
|
422
|
+
interface ResolvedRivusAutomationDefinition extends RivusAutomationDeployment {
|
|
423
|
+
readonly runtimeDefinition: ResolvedRivusAgentDefinition;
|
|
424
|
+
readonly template: RegisteredRivusAutomation;
|
|
425
|
+
}
|
|
426
|
+
interface ResolvedRivusProjectSpace {
|
|
427
|
+
readonly id: string;
|
|
428
|
+
readonly root: string;
|
|
429
|
+
readonly workingDirectory: string;
|
|
430
|
+
readonly skillPaths: ReadonlyArray<string>;
|
|
431
|
+
readonly revision: string;
|
|
432
|
+
}
|
|
433
|
+
interface DeploymentLifecycleAdapterPort {
|
|
434
|
+
running(): boolean;
|
|
435
|
+
start(): Effect.Effect<void, unknown>;
|
|
436
|
+
stop(): Effect.Effect<void, unknown>;
|
|
437
|
+
}
|
|
438
|
+
interface RivusDeploymentEndpointPort extends DeploymentLifecycleAdapterPort {}
|
|
439
|
+
interface RivusDeploymentAutomationPort extends DeploymentLifecycleAdapterPort {}
|
|
440
|
+
interface RivusDeploymentBackgroundSessionPort extends DeploymentLifecycleAdapterPort {
|
|
441
|
+
status?(): BackgroundSessionSupervisorStatus;
|
|
442
|
+
}
|
|
443
|
+
interface CreateRivusDeploymentEndpointPortInput {
|
|
444
|
+
readonly agentId: string;
|
|
445
|
+
readonly cancel: (input: AgentRuntimeCancellation) => Effect.Effect<boolean, unknown>;
|
|
446
|
+
readonly definition: RivusEndpointDeployment;
|
|
447
|
+
readonly endpointId: string;
|
|
448
|
+
readonly handle: (input: AgentRuntimeInput) => Effect.Effect<unknown, unknown>;
|
|
449
|
+
readonly instanceId: string;
|
|
450
|
+
/** Resolved runtime grants are needed before the first attachment is prepared. */
|
|
451
|
+
readonly runtimeDefinition?: ResolvedRivusAgentDefinition;
|
|
452
|
+
readonly projectSpace?: ResolvedRivusProjectSpace;
|
|
453
|
+
readonly projectSpaceId?: string;
|
|
454
|
+
readonly steer: (input: AgentRuntimeSteering) => Effect.Effect<boolean, unknown>;
|
|
455
|
+
}
|
|
456
|
+
interface RivusDeploymentEndpointFactoryPort {
|
|
457
|
+
create(input: CreateRivusDeploymentEndpointPortInput): Effect.Effect<RivusDeploymentEndpointPort, unknown>;
|
|
458
|
+
}
|
|
459
|
+
interface CreateRivusDeploymentAutomationPortInput {
|
|
460
|
+
readonly automationId: string;
|
|
461
|
+
readonly definition: ResolvedRivusAutomationDefinition;
|
|
462
|
+
readonly deliveryEndpoint: RivusEndpointDeployment;
|
|
463
|
+
readonly instanceId: string;
|
|
464
|
+
readonly run: (input: ScheduledAutomationRunInput) => Effect.Effect<unknown, unknown>;
|
|
465
|
+
}
|
|
466
|
+
interface RivusDeploymentAutomationFactoryPort {
|
|
467
|
+
create(input: CreateRivusDeploymentAutomationPortInput): Effect.Effect<RivusDeploymentAutomationPort, unknown>;
|
|
468
|
+
}
|
|
469
|
+
interface RivusDeploymentBackgroundSessionCancellation {
|
|
470
|
+
readonly agentId: string;
|
|
471
|
+
readonly reason?: string;
|
|
472
|
+
readonly runId: string;
|
|
473
|
+
readonly sessionKey: string;
|
|
474
|
+
}
|
|
475
|
+
interface CreateRivusDeploymentBackgroundSessionPortInput {
|
|
476
|
+
readonly agentIds: ReadonlyArray<string>;
|
|
477
|
+
readonly cancel: (input: RivusDeploymentBackgroundSessionCancellation) => Effect.Effect<boolean, unknown>;
|
|
478
|
+
readonly config: RivusBackgroundSessionsDeployment;
|
|
479
|
+
readonly run: (input: {
|
|
480
|
+
readonly agentId: string;
|
|
481
|
+
readonly invocation: NonNullable<AgentRuntimeInput["invocation"]>;
|
|
482
|
+
readonly onUpdate?: AgentRuntimeInput["onUpdate"];
|
|
483
|
+
readonly sessionKey: string;
|
|
484
|
+
readonly text: string;
|
|
485
|
+
}) => Effect.Effect<unknown, unknown>;
|
|
486
|
+
}
|
|
487
|
+
interface RivusDeploymentBackgroundSessionFactoryPort {
|
|
488
|
+
create(input: CreateRivusDeploymentBackgroundSessionPortInput): Effect.Effect<RivusDeploymentBackgroundSessionPort, unknown>;
|
|
489
|
+
}
|
|
490
|
+
interface CreateRivusDeploymentRuntimePortInput extends AgentInstanceRecord {
|
|
491
|
+
readonly catalog: RivusPluginCatalog;
|
|
492
|
+
readonly definition: ResolvedRivusAgentDefinition;
|
|
493
|
+
readonly projectSpace?: ResolvedRivusProjectSpace;
|
|
494
|
+
}
|
|
495
|
+
interface RivusDeploymentRuntimeFactoryPort {
|
|
496
|
+
create(input: CreateRivusDeploymentRuntimePortInput): Effect.Effect<RivusDeploymentRuntimePort, unknown>;
|
|
497
|
+
}
|
|
498
|
+
interface RivusDeploymentRuntimePort {
|
|
499
|
+
readonly concurrency?: "managed";
|
|
500
|
+
readonly cancel?: (input: AgentRuntimeCancellation) => Effect.Effect<boolean, unknown>;
|
|
501
|
+
readonly dispose?: () => Effect.Effect<void, unknown>;
|
|
502
|
+
readonly run: (input: AgentRuntimeInput) => Effect.Effect<unknown, unknown>;
|
|
503
|
+
readonly steer?: (input: AgentRuntimeSteering) => Effect.Effect<boolean, unknown>;
|
|
504
|
+
}
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/core/domain/human-interaction/aggregate/snapshot.d.ts
|
|
507
|
+
type HumanInteractionId = string;
|
|
508
|
+
type HumanInteractionToolRisk = "observe" | "mutate" | "irreversible" | "host-control";
|
|
509
|
+
interface HumanInteractionActor {
|
|
510
|
+
readonly openId: string;
|
|
511
|
+
readonly tenantKey: string;
|
|
512
|
+
}
|
|
513
|
+
interface HumanInteractionFact {
|
|
514
|
+
readonly label: string;
|
|
515
|
+
readonly value: string;
|
|
516
|
+
}
|
|
517
|
+
interface ToolApprovalBinding {
|
|
518
|
+
readonly agentId: string;
|
|
519
|
+
readonly callId: string;
|
|
520
|
+
readonly inputDigest: string;
|
|
521
|
+
readonly instanceId: string;
|
|
522
|
+
readonly operationId: string;
|
|
523
|
+
readonly risk: HumanInteractionToolRisk;
|
|
524
|
+
readonly runId: string;
|
|
525
|
+
readonly sessionKey: string;
|
|
526
|
+
readonly tenantKey: string;
|
|
527
|
+
readonly toolId: string;
|
|
528
|
+
readonly toolVersion: string;
|
|
529
|
+
}
|
|
530
|
+
interface HumanInteractionBase {
|
|
531
|
+
readonly agentId: string;
|
|
532
|
+
readonly allowedActorOpenIds: ReadonlyArray<string>;
|
|
533
|
+
readonly createdAt: string;
|
|
534
|
+
readonly expiresAt: string;
|
|
535
|
+
readonly facts: ReadonlyArray<HumanInteractionFact>;
|
|
536
|
+
readonly id: HumanInteractionId;
|
|
537
|
+
readonly instanceId: string;
|
|
538
|
+
readonly revision: number;
|
|
539
|
+
readonly runId: string;
|
|
540
|
+
readonly sessionKey: string;
|
|
541
|
+
readonly sourceMessageId: string;
|
|
542
|
+
readonly summary: string;
|
|
543
|
+
readonly tenantKey: string;
|
|
544
|
+
readonly title: string;
|
|
545
|
+
}
|
|
546
|
+
interface PendingHumanInteractionState {
|
|
547
|
+
readonly status: "pending";
|
|
548
|
+
}
|
|
549
|
+
interface ApprovedHumanInteractionState {
|
|
550
|
+
readonly actor: HumanInteractionActor;
|
|
551
|
+
readonly consumedAt?: string;
|
|
552
|
+
readonly resolvedAt: string;
|
|
553
|
+
readonly status: "approved";
|
|
554
|
+
}
|
|
555
|
+
interface RejectedHumanInteractionState {
|
|
556
|
+
readonly actor: HumanInteractionActor;
|
|
557
|
+
readonly resolvedAt: string;
|
|
558
|
+
readonly status: "rejected";
|
|
559
|
+
}
|
|
560
|
+
interface SelectedHumanInteractionState {
|
|
561
|
+
readonly actor: HumanInteractionActor;
|
|
562
|
+
readonly optionId: string;
|
|
563
|
+
readonly resolvedAt: string;
|
|
564
|
+
readonly status: "selected";
|
|
565
|
+
}
|
|
566
|
+
interface ExpiredHumanInteractionState {
|
|
567
|
+
readonly expiredAt: string;
|
|
568
|
+
readonly status: "expired";
|
|
569
|
+
}
|
|
570
|
+
interface CancelledHumanInteractionState {
|
|
571
|
+
readonly cancelledAt: string;
|
|
572
|
+
readonly reason?: string;
|
|
573
|
+
readonly status: "cancelled";
|
|
574
|
+
}
|
|
575
|
+
type ToolApprovalInteractionState = PendingHumanInteractionState | ApprovedHumanInteractionState | RejectedHumanInteractionState | ExpiredHumanInteractionState | CancelledHumanInteractionState;
|
|
576
|
+
interface ToolApprovalInteraction extends HumanInteractionBase {
|
|
577
|
+
readonly kind: "tool-approval";
|
|
578
|
+
readonly request: Omit<ToolApprovalBinding, "agentId" | "instanceId" | "runId" | "sessionKey" | "tenantKey">;
|
|
579
|
+
readonly state: ToolApprovalInteractionState;
|
|
580
|
+
}
|
|
581
|
+
interface UserDecisionOption {
|
|
582
|
+
readonly description: string;
|
|
583
|
+
readonly id: string;
|
|
584
|
+
readonly label: string;
|
|
585
|
+
}
|
|
586
|
+
type UserDecisionInteractionState = PendingHumanInteractionState | SelectedHumanInteractionState | RejectedHumanInteractionState | ExpiredHumanInteractionState | CancelledHumanInteractionState;
|
|
587
|
+
interface UserDecisionInteraction extends HumanInteractionBase {
|
|
588
|
+
readonly kind: "user-decision";
|
|
589
|
+
readonly options: ReadonlyArray<UserDecisionOption>;
|
|
590
|
+
readonly recommendedOptionId?: string;
|
|
591
|
+
readonly state: UserDecisionInteractionState;
|
|
592
|
+
}
|
|
593
|
+
type HumanInteraction = ToolApprovalInteraction | UserDecisionInteraction;
|
|
594
|
+
type HumanInteractionSnapshot = HumanInteraction;
|
|
595
|
+
//#endregion
|
|
596
|
+
//#region src/adapters/feishu/protocol/feishu-receive-message.d.ts
|
|
597
|
+
interface FeishuReceiveMessagePayload {
|
|
598
|
+
readonly header?: {
|
|
599
|
+
readonly tenant_key?: string;
|
|
600
|
+
};
|
|
601
|
+
readonly event: {
|
|
602
|
+
readonly sender?: {
|
|
603
|
+
readonly sender_id?: {
|
|
604
|
+
readonly open_id?: string;
|
|
605
|
+
};
|
|
606
|
+
readonly sender_type?: string;
|
|
607
|
+
readonly tenant_key?: string;
|
|
608
|
+
};
|
|
609
|
+
readonly message: {
|
|
610
|
+
readonly create_time?: string;
|
|
611
|
+
readonly message_id: string;
|
|
612
|
+
readonly chat_id: string;
|
|
613
|
+
readonly chat_type?: string;
|
|
614
|
+
readonly thread_id?: string;
|
|
615
|
+
readonly parent_id?: string;
|
|
616
|
+
readonly root_id?: string;
|
|
617
|
+
readonly message_type: string;
|
|
618
|
+
readonly mentions?: ReadonlyArray<{
|
|
619
|
+
readonly id?: Readonly<Record<string, string>>;
|
|
620
|
+
readonly key?: string;
|
|
621
|
+
readonly name?: string;
|
|
622
|
+
}>;
|
|
623
|
+
readonly content: string;
|
|
624
|
+
};
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
//#endregion
|
|
628
|
+
//#region src/adapters/feishu/conversation-session/feishu-session-key.d.ts
|
|
629
|
+
interface FeishuSessionReference {
|
|
630
|
+
readonly tenantKey: string;
|
|
631
|
+
readonly chatId: string;
|
|
632
|
+
readonly threadId?: string;
|
|
633
|
+
readonly agentId: string;
|
|
634
|
+
}
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region src/adapters/feishu/intake/feishu-message-intake.d.ts
|
|
637
|
+
type FeishuMessageIntakeSummary = FeishuPromptMessageIntakeSummary | FeishuNewSessionMessageIntakeSummary | FeishuCancelMessageIntakeSummary;
|
|
638
|
+
interface FeishuMessageIntakeBaseSummary {
|
|
639
|
+
readonly messageId: string;
|
|
640
|
+
readonly sessionKey: SessionKey;
|
|
641
|
+
readonly sessionReference: FeishuSessionReference;
|
|
642
|
+
}
|
|
643
|
+
interface FeishuPromptMessageIntakeSummary extends FeishuMessageIntakeBaseSummary {
|
|
644
|
+
readonly commandType: "prompt";
|
|
645
|
+
readonly text: string;
|
|
646
|
+
}
|
|
647
|
+
interface FeishuNewSessionMessageIntakeSummary extends FeishuMessageIntakeBaseSummary {
|
|
648
|
+
readonly commandType: "new_session";
|
|
649
|
+
readonly previousSessionKey: SessionKey;
|
|
650
|
+
}
|
|
651
|
+
interface FeishuCancelMessageIntakeSummary extends FeishuMessageIntakeBaseSummary {
|
|
652
|
+
readonly commandType: "cancel_run";
|
|
653
|
+
readonly reason: string;
|
|
654
|
+
readonly runId?: AgentRunId;
|
|
655
|
+
}
|
|
656
|
+
//#endregion
|
|
657
|
+
//#region src/adapters/feishu/intake/feishu-card-action-intake.d.ts
|
|
658
|
+
interface FeishuCardActionTriggerPayload {
|
|
659
|
+
readonly action?: {
|
|
660
|
+
readonly tag?: string;
|
|
661
|
+
readonly value?: unknown;
|
|
662
|
+
};
|
|
663
|
+
readonly context?: {
|
|
664
|
+
readonly chat_id?: string;
|
|
665
|
+
readonly open_chat_id?: string;
|
|
666
|
+
readonly open_message_id?: string;
|
|
667
|
+
};
|
|
668
|
+
readonly event?: FeishuCardActionTriggerPayload;
|
|
669
|
+
readonly event_type?: string;
|
|
670
|
+
readonly operator?: {
|
|
671
|
+
readonly open_id?: string;
|
|
672
|
+
readonly tenant_key?: string;
|
|
673
|
+
readonly union_id?: string;
|
|
674
|
+
readonly user_id?: string;
|
|
675
|
+
};
|
|
676
|
+
readonly token?: string;
|
|
677
|
+
}
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region src/core/application/run-presentation/projection/presented-value.d.ts
|
|
680
|
+
type PresentedValue = {
|
|
681
|
+
readonly kind: "boolean";
|
|
682
|
+
readonly value: boolean;
|
|
683
|
+
} | {
|
|
684
|
+
readonly entries: ReadonlyArray<{
|
|
685
|
+
readonly key: string;
|
|
686
|
+
readonly value: PresentedValue;
|
|
687
|
+
}>;
|
|
688
|
+
readonly kind: "record";
|
|
689
|
+
readonly omittedEntries: number;
|
|
690
|
+
} | {
|
|
691
|
+
readonly items: ReadonlyArray<PresentedValue>;
|
|
692
|
+
readonly kind: "list";
|
|
693
|
+
readonly omittedItems: number;
|
|
694
|
+
} | {
|
|
695
|
+
readonly kind: "null";
|
|
696
|
+
} | {
|
|
697
|
+
readonly kind: "number";
|
|
698
|
+
readonly value: number;
|
|
699
|
+
} | {
|
|
700
|
+
readonly kind: "redacted";
|
|
701
|
+
readonly reason: "sensitive-key" | "sensitive-value";
|
|
702
|
+
} | {
|
|
703
|
+
readonly kind: "text";
|
|
704
|
+
readonly omittedCharacters: number;
|
|
705
|
+
readonly value: string;
|
|
706
|
+
} | {
|
|
707
|
+
readonly kind: "unsupported";
|
|
708
|
+
readonly valueType: string;
|
|
709
|
+
};
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region src/core/application/run-presentation/projection/run-presentation.d.ts
|
|
712
|
+
declare const RUN_PRESENTATION_SCHEMA_VERSION: 2;
|
|
713
|
+
type AgentRunId$1 = string;
|
|
714
|
+
type RunPresentationPhase = "cancelled" | "completed" | "failed" | "running";
|
|
715
|
+
type PresentationStepStatus = "completed" | "failed" | "running";
|
|
716
|
+
interface PresentationStepBase {
|
|
717
|
+
readonly durationMs?: number;
|
|
718
|
+
readonly endedAt?: string;
|
|
719
|
+
readonly id: string;
|
|
720
|
+
readonly label: string;
|
|
721
|
+
readonly startedAt: string;
|
|
722
|
+
readonly status: PresentationStepStatus;
|
|
723
|
+
}
|
|
724
|
+
interface AssistantPresentationStep extends PresentationStepBase {
|
|
725
|
+
readonly kind: "assistant";
|
|
726
|
+
readonly text: string;
|
|
727
|
+
}
|
|
728
|
+
interface ModelPresentationStep extends PresentationStepBase {
|
|
729
|
+
readonly kind: "model";
|
|
730
|
+
readonly model: string;
|
|
731
|
+
readonly provider: string;
|
|
732
|
+
}
|
|
733
|
+
interface SkillPresentationStep extends PresentationStepBase {
|
|
734
|
+
readonly kind: "skill";
|
|
735
|
+
readonly skillId: string;
|
|
736
|
+
}
|
|
737
|
+
interface ToolPresentationStep extends PresentationStepBase {
|
|
738
|
+
readonly error?: PresentedValue;
|
|
739
|
+
readonly input: PresentedValue;
|
|
740
|
+
readonly kind: "tool";
|
|
741
|
+
readonly output?: PresentedValue;
|
|
742
|
+
readonly skillId?: string;
|
|
743
|
+
readonly toolName: string;
|
|
744
|
+
}
|
|
745
|
+
interface ResponsePresentationStep extends PresentationStepBase {
|
|
746
|
+
readonly kind: "response";
|
|
747
|
+
}
|
|
748
|
+
type PresentationStep = AssistantPresentationStep | ModelPresentationStep | ResponsePresentationStep | SkillPresentationStep | ToolPresentationStep;
|
|
749
|
+
interface RunPresentation {
|
|
750
|
+
readonly answer: {
|
|
751
|
+
readonly format: "markdown";
|
|
752
|
+
readonly text: string;
|
|
753
|
+
};
|
|
754
|
+
readonly omittedStepCount: number;
|
|
755
|
+
readonly phase: RunPresentationPhase;
|
|
756
|
+
readonly revision: number;
|
|
757
|
+
readonly runId: AgentRunId$1;
|
|
758
|
+
readonly schemaVersion: typeof RUN_PRESENTATION_SCHEMA_VERSION;
|
|
759
|
+
readonly steps: ReadonlyArray<PresentationStep>;
|
|
760
|
+
readonly totalStepCount: number;
|
|
761
|
+
readonly totalToolCallCount: number;
|
|
762
|
+
}
|
|
763
|
+
//#endregion
|
|
764
|
+
//#region src/adapters/feishu/card-presentation/streaming/feishu-stream-projector.d.ts
|
|
765
|
+
type FeishuStreamAction = {
|
|
766
|
+
readonly type: "update_text";
|
|
767
|
+
readonly runId: AgentRunId;
|
|
768
|
+
readonly text: string;
|
|
769
|
+
} | {
|
|
770
|
+
readonly presentation: RunPresentation;
|
|
771
|
+
readonly runId: AgentRunId;
|
|
772
|
+
readonly type: "update_progress";
|
|
773
|
+
} | {
|
|
774
|
+
readonly presentation?: RunPresentation;
|
|
775
|
+
readonly runId: AgentRunId;
|
|
776
|
+
readonly sessionKey: string;
|
|
777
|
+
readonly text?: string;
|
|
778
|
+
readonly type: "update_presentation";
|
|
779
|
+
} | {
|
|
780
|
+
readonly presentation?: RunPresentation;
|
|
781
|
+
readonly type: "finish";
|
|
782
|
+
readonly runId: AgentRunId;
|
|
783
|
+
readonly text: string;
|
|
784
|
+
} | {
|
|
785
|
+
readonly presentation?: RunPresentation;
|
|
786
|
+
readonly type: "fail";
|
|
787
|
+
readonly runId: AgentRunId;
|
|
788
|
+
readonly errorMessage: string;
|
|
789
|
+
} | {
|
|
790
|
+
readonly presentation?: RunPresentation;
|
|
791
|
+
readonly type: "cancel";
|
|
792
|
+
readonly runId: AgentRunId;
|
|
793
|
+
readonly reason?: string;
|
|
794
|
+
readonly text?: string;
|
|
795
|
+
};
|
|
796
|
+
//#endregion
|
|
797
|
+
//#region src/adapters/feishu/protocol/feishu-agent-run-preparation.d.ts
|
|
798
|
+
interface FeishuAgentRunPreparation {
|
|
799
|
+
readonly messageId: string;
|
|
800
|
+
readonly prompt: string;
|
|
801
|
+
readonly receiveId: string;
|
|
802
|
+
readonly runId: AgentRunId;
|
|
803
|
+
readonly sessionKey: SessionKey;
|
|
804
|
+
}
|
|
805
|
+
//#endregion
|
|
806
|
+
//#region src/adapters/feishu/intake/feishu-agent-daemon.d.ts
|
|
807
|
+
interface FeishuAgentDaemonRunResult {
|
|
808
|
+
readonly messageId: string;
|
|
809
|
+
readonly runId: string;
|
|
810
|
+
readonly finalText: string;
|
|
811
|
+
}
|
|
812
|
+
interface FeishuAgentDaemonSkippedResult {
|
|
813
|
+
readonly messageId: string;
|
|
814
|
+
readonly skipped: true;
|
|
815
|
+
readonly reason: "duplicate";
|
|
816
|
+
}
|
|
817
|
+
interface FeishuAgentDaemonCancelResult {
|
|
818
|
+
readonly cancelled: boolean;
|
|
819
|
+
readonly messageId: string;
|
|
820
|
+
readonly runId?: AgentRunId;
|
|
821
|
+
readonly reason?: "not_active";
|
|
822
|
+
}
|
|
823
|
+
interface FeishuAgentDaemonSteeredResult {
|
|
824
|
+
readonly messageId: string;
|
|
825
|
+
readonly runId: AgentRunId;
|
|
826
|
+
readonly steered: true;
|
|
827
|
+
}
|
|
828
|
+
interface FeishuAgentDaemonInteractionResult {
|
|
829
|
+
readonly interaction: HumanInteractionSnapshot;
|
|
830
|
+
readonly interactionId: string;
|
|
831
|
+
readonly messageId: string;
|
|
832
|
+
readonly resolved: true;
|
|
833
|
+
}
|
|
834
|
+
interface FeishuAgentDaemonSessionResetResult {
|
|
835
|
+
readonly messageId: string;
|
|
836
|
+
readonly previousSessionKey: SessionKey;
|
|
837
|
+
readonly sessionKey: SessionKey;
|
|
838
|
+
readonly reset: true;
|
|
839
|
+
}
|
|
840
|
+
type FeishuAgentDaemonHandleResult = FeishuAgentDaemonRunResult | FeishuAgentDaemonSkippedResult | FeishuAgentDaemonCancelResult | FeishuAgentDaemonSteeredResult | FeishuAgentDaemonInteractionResult | FeishuAgentDaemonSessionResetResult;
|
|
841
|
+
type FeishuAgentMessageSideEffects = "enabled" | "disabled";
|
|
842
|
+
interface FeishuAgentDaemonHandleMessageOptions {
|
|
843
|
+
readonly sideEffects?: FeishuAgentMessageSideEffects;
|
|
844
|
+
}
|
|
845
|
+
//#endregion
|
|
846
|
+
//#region src/platform/durable-queue/records/inbound-delivery-record.d.ts
|
|
847
|
+
interface InboundDeliveryPendingState {
|
|
848
|
+
readonly availableAt: string;
|
|
849
|
+
readonly status: "pending";
|
|
850
|
+
}
|
|
851
|
+
interface InboundDeliveryLeasedState {
|
|
852
|
+
readonly leaseExpiresAt: string;
|
|
853
|
+
readonly leaseId: string;
|
|
854
|
+
readonly leasedAt: string;
|
|
855
|
+
readonly status: "leased";
|
|
856
|
+
}
|
|
857
|
+
interface InboundDeliveryCompletedState {
|
|
858
|
+
readonly completedAt: string;
|
|
859
|
+
readonly status: "completed";
|
|
860
|
+
}
|
|
861
|
+
interface InboundDeliveryDeadState {
|
|
862
|
+
readonly failedAt: string;
|
|
863
|
+
readonly reason: string;
|
|
864
|
+
readonly status: "dead";
|
|
865
|
+
}
|
|
866
|
+
type InboundDeliveryState = InboundDeliveryPendingState | InboundDeliveryLeasedState | InboundDeliveryCompletedState | InboundDeliveryDeadState;
|
|
867
|
+
interface InboundDeliveryRecoveryAudit {
|
|
868
|
+
readonly actorId: string;
|
|
869
|
+
readonly at: string;
|
|
870
|
+
readonly note: string;
|
|
871
|
+
}
|
|
872
|
+
type InboundDelivery<Payload = unknown, Metadata = unknown> = Readonly<{
|
|
873
|
+
readonly acceptedAt: string;
|
|
874
|
+
readonly attempts: number;
|
|
875
|
+
readonly id: string;
|
|
876
|
+
readonly laneKey: string;
|
|
877
|
+
readonly metadata?: Metadata;
|
|
878
|
+
readonly payload: Payload;
|
|
879
|
+
readonly recovery?: InboundDeliveryRecoveryAudit;
|
|
880
|
+
readonly revision: number;
|
|
881
|
+
readonly state: InboundDeliveryState;
|
|
882
|
+
}>;
|
|
883
|
+
//#endregion
|
|
884
|
+
//#region src/platform/durable-queue/processing/durable-queue.d.ts
|
|
885
|
+
interface DurableQueueAcceptInput<Payload, Metadata> {
|
|
886
|
+
readonly id: string;
|
|
887
|
+
readonly laneKey: string;
|
|
888
|
+
readonly metadata?: Metadata;
|
|
889
|
+
readonly payload: Payload;
|
|
890
|
+
}
|
|
891
|
+
type DurableQueueAcceptResult = {
|
|
892
|
+
readonly accepted: true;
|
|
893
|
+
readonly deliveryId: string;
|
|
894
|
+
readonly pending: number;
|
|
895
|
+
} | {
|
|
896
|
+
readonly accepted: false;
|
|
897
|
+
readonly deliveryId: string;
|
|
898
|
+
readonly pending: number;
|
|
899
|
+
readonly reason: "capacity" | "duplicate";
|
|
900
|
+
};
|
|
901
|
+
interface DurableQueueReplayResult {
|
|
902
|
+
readonly deliveryId: string;
|
|
903
|
+
readonly reason: "duplicate";
|
|
904
|
+
readonly skipped: true;
|
|
905
|
+
}
|
|
906
|
+
type DurableQueueDrainResult<Result> = {
|
|
907
|
+
readonly deliveryId: string;
|
|
908
|
+
readonly handled: true;
|
|
909
|
+
readonly result: Result | DurableQueueReplayResult;
|
|
910
|
+
} | {
|
|
911
|
+
readonly handled: false;
|
|
912
|
+
readonly reason: "empty";
|
|
913
|
+
};
|
|
914
|
+
interface DurableQueue<Payload, Metadata, Result> {
|
|
915
|
+
accept(input: DurableQueueAcceptInput<Payload, Metadata>): Effect.Effect<DurableQueueAcceptResult, unknown>;
|
|
916
|
+
deadLetters(): ReadonlyArray<InboundDelivery<Payload, Metadata>>;
|
|
917
|
+
drainOne(): Effect.Effect<DurableQueueDrainResult<Result>, unknown>;
|
|
918
|
+
pending(): number;
|
|
919
|
+
}
|
|
920
|
+
//#endregion
|
|
921
|
+
//#region src/platform/durable-queue/processing/worker.d.ts
|
|
922
|
+
interface DurableQueueWorkerDrainResult<Result> {
|
|
923
|
+
readonly drained: number;
|
|
924
|
+
readonly results: ReadonlyArray<Extract<DurableQueueDrainResult<Result>, {
|
|
925
|
+
readonly handled: true;
|
|
926
|
+
}>>;
|
|
927
|
+
}
|
|
928
|
+
interface DurableQueueWorker<Result> {
|
|
929
|
+
drainAvailable(): Effect.Effect<DurableQueueWorkerDrainResult<Result>, unknown>;
|
|
930
|
+
}
|
|
931
|
+
//#endregion
|
|
932
|
+
//#region src/adapters/feishu/inbound-delivery/feishu-inbound-delivery.d.ts
|
|
933
|
+
interface FeishuInboundDeliveryMetadata {
|
|
934
|
+
readonly sideEffects?: "disabled" | "enabled";
|
|
935
|
+
}
|
|
936
|
+
type FeishuMessageAcceptResult = {
|
|
937
|
+
readonly accepted: true;
|
|
938
|
+
readonly messageId: string;
|
|
939
|
+
readonly pending: number;
|
|
940
|
+
} | {
|
|
941
|
+
readonly accepted: false;
|
|
942
|
+
readonly messageId: string;
|
|
943
|
+
readonly pending: number;
|
|
944
|
+
readonly reason: "capacity" | "duplicate" | "ignored";
|
|
945
|
+
};
|
|
946
|
+
interface FeishuMessageDrainAvailableResult {
|
|
947
|
+
readonly drained: number;
|
|
948
|
+
readonly results: ReadonlyArray<{
|
|
949
|
+
readonly handled: true;
|
|
950
|
+
readonly messageId: string;
|
|
951
|
+
readonly result: FeishuAgentDaemonHandleResult;
|
|
952
|
+
}>;
|
|
953
|
+
}
|
|
954
|
+
//#endregion
|
|
955
|
+
//#region src/adapters/feishu/runtime/feishu-receive-status.d.ts
|
|
956
|
+
type FeishuReceiveMessageReplayOptions = FeishuAgentDaemonHandleMessageOptions;
|
|
957
|
+
interface FeishuReceiveMessageSummary {
|
|
958
|
+
readonly chatId: string;
|
|
959
|
+
readonly messageId: string;
|
|
960
|
+
readonly tenantKey?: string;
|
|
961
|
+
readonly threadId?: string;
|
|
962
|
+
}
|
|
963
|
+
interface FeishuReceiveAcceptedObservation {
|
|
964
|
+
readonly accepted: FeishuMessageAcceptResult;
|
|
965
|
+
readonly message: FeishuReceiveMessageSummary;
|
|
966
|
+
readonly observedAt: Date;
|
|
967
|
+
}
|
|
968
|
+
interface FeishuReceiveHandledObservation {
|
|
969
|
+
readonly intake: FeishuMessageIntakeSummary;
|
|
970
|
+
readonly messageId: string;
|
|
971
|
+
readonly observedAt: Date;
|
|
972
|
+
readonly result: FeishuAgentDaemonHandleResult;
|
|
973
|
+
}
|
|
974
|
+
interface FeishuReceiveRuntimeStatus {
|
|
975
|
+
readonly lastAccepted?: FeishuReceiveAcceptedObservation;
|
|
976
|
+
readonly lastHandled?: FeishuReceiveHandledObservation;
|
|
977
|
+
}
|
|
978
|
+
interface FeishuReceiveMessageReplayResult {
|
|
979
|
+
readonly accepted: FeishuMessageAcceptResult;
|
|
980
|
+
readonly drained: FeishuMessageDrainAvailableResult;
|
|
981
|
+
readonly intake: FeishuMessageIntakeSummary;
|
|
982
|
+
}
|
|
983
|
+
//#endregion
|
|
984
|
+
//#region src/platform/daemon/process/rivus-daemon-process.d.ts
|
|
985
|
+
interface RivusDaemonTransport {
|
|
986
|
+
running(): boolean;
|
|
987
|
+
start(): Promise<void> | void;
|
|
988
|
+
stop(): Promise<void> | void;
|
|
989
|
+
}
|
|
990
|
+
interface RivusDaemonProcess {
|
|
991
|
+
running(): boolean;
|
|
992
|
+
start(): Effect.Effect<void, unknown>;
|
|
993
|
+
stop(): Effect.Effect<void, unknown>;
|
|
994
|
+
}
|
|
995
|
+
//#endregion
|
|
996
|
+
//#region src/platform/home/config/runtime/rivus-daemon-config.d.ts
|
|
997
|
+
type RivusDaemonEnv = Readonly<Record<string, string | undefined>>;
|
|
998
|
+
type RivusThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
999
|
+
interface RivusDaemonConfig {
|
|
1000
|
+
readonly agentId: string;
|
|
1001
|
+
readonly feishu: {
|
|
1002
|
+
readonly appId: string;
|
|
1003
|
+
readonly appSecret: string;
|
|
1004
|
+
readonly baseUrl: string;
|
|
1005
|
+
readonly cardStreamLeaseMs: number;
|
|
1006
|
+
readonly streamMinIntervalMs: number;
|
|
1007
|
+
};
|
|
1008
|
+
readonly pi: {
|
|
1009
|
+
readonly apiKey?: string;
|
|
1010
|
+
readonly baseUrl?: string;
|
|
1011
|
+
readonly model?: string;
|
|
1012
|
+
readonly thinkingLevel?: RivusThinkingLevel;
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
//#endregion
|
|
1016
|
+
//#region src/platform/home/rivus-home.d.ts
|
|
1017
|
+
type RivusHomeEnvironment = Readonly<Record<string, string | undefined>>;
|
|
1018
|
+
interface RivusHome {
|
|
1019
|
+
readonly bootstrap: string;
|
|
1020
|
+
readonly directory: string;
|
|
1021
|
+
readonly envFilePath: string;
|
|
1022
|
+
readonly logsDirectory: string;
|
|
1023
|
+
readonly manifestPath: string;
|
|
1024
|
+
readonly stateDirectory: string;
|
|
1025
|
+
readonly workspaceDirectory: string;
|
|
1026
|
+
}
|
|
1027
|
+
interface InitializedRivusHome {
|
|
1028
|
+
readonly directory: string;
|
|
1029
|
+
readonly files: ReadonlyArray<string>;
|
|
1030
|
+
}
|
|
1031
|
+
interface RivusHomeDoctorCheck {
|
|
1032
|
+
readonly message: string;
|
|
1033
|
+
readonly name: "node" | "home" | "workspace" | "modules" | "manifest" | "credentials";
|
|
1034
|
+
readonly status: "pass" | "fail";
|
|
1035
|
+
}
|
|
1036
|
+
interface RivusHomeDoctorReport {
|
|
1037
|
+
readonly checks: ReadonlyArray<RivusHomeDoctorCheck>;
|
|
1038
|
+
readonly directory: string;
|
|
1039
|
+
readonly ready: boolean;
|
|
1040
|
+
}
|
|
1041
|
+
interface RivusHomeApi {
|
|
1042
|
+
diagnose(input: {
|
|
1043
|
+
readonly directory: string;
|
|
1044
|
+
readonly env: RivusHomeEnvironment;
|
|
1045
|
+
readonly envFilePath?: string;
|
|
1046
|
+
readonly nodeVersion: string;
|
|
1047
|
+
}): Effect.Effect<RivusHomeDoctorReport, Error>;
|
|
1048
|
+
load(directory: string): Effect.Effect<RivusHome, Error>;
|
|
1049
|
+
setup(directory: string): Effect.Effect<InitializedRivusHome, Error>;
|
|
1050
|
+
}
|
|
1051
|
+
//#endregion
|
|
1052
|
+
//#region src/bootstrap/deployment/rivus-deployment-cli-process.d.ts
|
|
1053
|
+
interface RivusDeploymentBootstrapAdapters {
|
|
1054
|
+
readonly initialInstanceRecords?: AgentInstanceRegistryOptions["initialRecords"];
|
|
1055
|
+
readonly dispose?: () => Promise<void> | void;
|
|
1056
|
+
readonly createAutomation?: RivusDeploymentAutomationFactoryPort["create"];
|
|
1057
|
+
readonly createBackgroundSession?: RivusDeploymentBackgroundSessionFactoryPort["create"];
|
|
1058
|
+
readonly createRecoveryControl?: () => Effect.Effect<RecoveryControl, unknown>;
|
|
1059
|
+
readonly createRuntime: RivusDeploymentRuntimeFactoryPort["create"];
|
|
1060
|
+
readonly createEndpoint: RivusDeploymentEndpointFactoryPort["create"];
|
|
1061
|
+
readonly replayReceiveMessage?: (handleDefault: (input: AgentRuntimeInput) => Effect.Effect<unknown, unknown>, payload: FeishuReceiveMessagePayload, options?: FeishuReceiveMessageReplayOptions) => Effect.Effect<FeishuReceiveMessageReplayResult, unknown>;
|
|
1062
|
+
}
|
|
1063
|
+
interface RivusDeploymentBootstrapContext {
|
|
1064
|
+
readonly argv: ReadonlyArray<string>;
|
|
1065
|
+
readonly env: RivusDaemonEnv;
|
|
1066
|
+
/** Explicit original configuration source, required for controlled export on disable. */
|
|
1067
|
+
readonly envFilePath?: string;
|
|
1068
|
+
/** Environment values before the explicit env file is merged. */
|
|
1069
|
+
readonly environmentOverrides?: RivusDaemonEnv;
|
|
1070
|
+
readonly manifestPath: string;
|
|
1071
|
+
readonly pluginPackageManifestPath?: string;
|
|
1072
|
+
}
|
|
1073
|
+
type RivusDeploymentBootstrapFactory = (context: RivusDeploymentBootstrapContext) => Promise<RivusDeploymentBootstrapAdapters> | RivusDeploymentBootstrapAdapters;
|
|
1074
|
+
//#endregion
|
|
1075
|
+
//#region src/platform/daemon/process/rivus-daemon-shutdown-controller.d.ts
|
|
1076
|
+
type RivusDaemonShutdownSignal = "SIGINT" | "SIGTERM";
|
|
1077
|
+
interface RivusDaemonSignalSource {
|
|
1078
|
+
on(signal: RivusDaemonShutdownSignal, listener: () => void): void;
|
|
1079
|
+
}
|
|
1080
|
+
//#endregion
|
|
1081
|
+
//#region src/bootstrap/daemon/rivus-daemon-cli.d.ts
|
|
1082
|
+
interface RivusDaemonBootstrapContext {
|
|
1083
|
+
readonly argv: ReadonlyArray<string>;
|
|
1084
|
+
readonly config: RivusDaemonConfig;
|
|
1085
|
+
readonly env: RivusDaemonEnv;
|
|
1086
|
+
}
|
|
1087
|
+
type RivusDaemonBootstrapFactory = (context: RivusDaemonBootstrapContext) => Promise<RivusDaemonProcess> | RivusDaemonProcess;
|
|
1088
|
+
interface RivusDaemonBootstrapModule {
|
|
1089
|
+
readonly createRivusDaemonProcess?: RivusDaemonBootstrapFactory;
|
|
1090
|
+
readonly createRivusDeploymentAdapters?: RivusDeploymentBootstrapFactory;
|
|
1091
|
+
readonly default?: RivusDaemonBootstrapFactory;
|
|
1092
|
+
}
|
|
1093
|
+
interface RivusDaemonCliWriter {
|
|
1094
|
+
write(text: string): unknown;
|
|
1095
|
+
}
|
|
1096
|
+
interface RivusDaemonPromptRunner {
|
|
1097
|
+
readonly defaultSessionKey?: string;
|
|
1098
|
+
promptText(command: PromptCommand): Effect.Effect<string, unknown>;
|
|
1099
|
+
}
|
|
1100
|
+
interface RivusDaemonFeishuReplayRunner {
|
|
1101
|
+
replayReceiveMessage(payload: FeishuReceiveMessagePayload, options?: FeishuReceiveMessageReplayOptions): Effect.Effect<FeishuReceiveMessageReplayResult, unknown>;
|
|
1102
|
+
}
|
|
1103
|
+
interface RivusDaemonCliOptions {
|
|
1104
|
+
readonly argv: ReadonlyArray<string>;
|
|
1105
|
+
readonly env: RivusDaemonEnv;
|
|
1106
|
+
readonly exitAfterSignal?: (exitCode: number) => void;
|
|
1107
|
+
readonly loadBootstrap?: (specifier: string) => Promise<RivusDaemonBootstrapModule>;
|
|
1108
|
+
readonly signalSource: RivusDaemonSignalSource;
|
|
1109
|
+
readonly stderr: RivusDaemonCliWriter;
|
|
1110
|
+
readonly stdout: RivusDaemonCliWriter;
|
|
1111
|
+
readonly pluginPackageManifestPath?: string;
|
|
1112
|
+
}
|
|
1113
|
+
//#endregion
|
|
1114
|
+
export { RivusDeploymentRuntimePort as A, ResolvedRivusAgentDefinition as B, FeishuReceiveMessagePayload as C, CreateRivusDeploymentRuntimePortInput as D, CreateRivusDeploymentEndpointPortInput as E, RivusPluginManifest as F, RivusAgentProfile as H, RivusAutomationInput as I, RivusAutomationOutput as L, RivusPluginCatalog as M, RivusPluginRegistry as N, RivusDeploymentBackgroundSessionPort as O, RIVUS_PLUGIN_API_VERSION as P, RivusAutomationTemplate as R, FeishuCardActionTriggerPayload as S, CreateRivusDeploymentBackgroundSessionPortInput as T, AutomationScheduler as U, RivusAgentDeployment as V, RecoveryControl as W, DurableQueue as _, RivusDeploymentBootstrapContext as a, FeishuAgentRunPreparation as b, RivusDaemonProcess as c, FeishuReceiveMessageReplayResult as d, FeishuReceiveRuntimeStatus as f, DurableQueueWorkerDrainResult as g, DurableQueueWorker as h, RivusDaemonPromptRunner as i, RivusPlugin as j, RivusDeploymentEndpointPort as k, RivusDaemonTransport as l, FeishuMessageAcceptResult as m, RivusDaemonCliOptions as n, RivusHomeApi as o, FeishuInboundDeliveryMetadata as p, RivusDaemonFeishuReplayRunner as r, RivusDaemonEnv as s, RivusDaemonBootstrapContext as t, FeishuReceiveMessageReplayOptions as u, DurableQueueDrainResult as v, CreateRivusDeploymentAutomationPortInput as w, FeishuStreamAction as x, FeishuAgentDaemonHandleResult as y, RivusAutomationTickContext as z };
|
|
1115
|
+
export {};
|