@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
|
@@ -1,20 +1,285 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { A as RivusDeploymentRuntimePort, C as FeishuReceiveMessagePayload, D as CreateRivusDeploymentRuntimePortInput, E as CreateRivusDeploymentEndpointPortInput, O as RivusDeploymentBackgroundSessionPort, S as FeishuCardActionTriggerPayload, T as CreateRivusDeploymentBackgroundSessionPortInput, U as AutomationScheduler, W as RecoveryControl, _ as DurableQueue, a as RivusDeploymentBootstrapContext, b as FeishuAgentRunPreparation, c as RivusDaemonProcess, d as FeishuReceiveMessageReplayResult, f as FeishuReceiveRuntimeStatus, g as DurableQueueWorkerDrainResult, h as DurableQueueWorker, i as RivusDaemonPromptRunner, k as RivusDeploymentEndpointPort, l as RivusDaemonTransport, m as FeishuMessageAcceptResult, p as FeishuInboundDeliveryMetadata, r as RivusDaemonFeishuReplayRunner, t as RivusDaemonBootstrapContext, u as FeishuReceiveMessageReplayOptions, v as DurableQueueDrainResult, w as CreateRivusDeploymentAutomationPortInput, x as FeishuStreamAction, y as FeishuAgentDaemonHandleResult } from "../chunks/rivus-daemon-cli.js";
|
|
2
|
+
import { AgentEventLog, AgentHarness, AgentHistory, AgentRunId, AgentRunState, PromptCommand } from "@rivus/runtime";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { PeriodicEffectLoop } from "@rivus/platform/concurrency";
|
|
5
|
+
//#region src/adapters/feishu/protocol/feishu-card-protocol.d.ts
|
|
6
|
+
/** Shared raw-card schema used by Feishu protocol adapters. */
|
|
7
|
+
interface FeishuRawCardJson {
|
|
8
|
+
readonly body: {
|
|
9
|
+
readonly direction?: "horizontal" | "vertical";
|
|
10
|
+
readonly elements: ReadonlyArray<unknown>;
|
|
11
|
+
readonly padding?: string;
|
|
12
|
+
readonly vertical_spacing?: string;
|
|
13
|
+
};
|
|
14
|
+
readonly config: {
|
|
15
|
+
readonly streaming_mode?: boolean;
|
|
16
|
+
readonly update_multi: true;
|
|
17
|
+
};
|
|
18
|
+
readonly header: {
|
|
19
|
+
readonly padding?: string;
|
|
20
|
+
readonly template: "blue" | "green" | "grey" | "orange" | "red";
|
|
21
|
+
readonly title: {
|
|
22
|
+
readonly content: string;
|
|
23
|
+
readonly tag: "plain_text";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
readonly schema: "2.0";
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/adapters/feishu/runtime/card-action-response.d.ts
|
|
30
|
+
interface FeishuCardActionCallbackResponse {
|
|
31
|
+
readonly card?: {
|
|
32
|
+
readonly data: FeishuRawCardJson;
|
|
33
|
+
readonly type: "raw";
|
|
34
|
+
};
|
|
35
|
+
readonly toast: FeishuCardActionToast;
|
|
36
|
+
}
|
|
37
|
+
interface FeishuCardActionToast {
|
|
38
|
+
readonly type: "success" | "info" | "warning" | "error";
|
|
39
|
+
readonly content: string;
|
|
40
|
+
readonly i18n?: {
|
|
41
|
+
readonly en_us?: string;
|
|
42
|
+
readonly zh_cn?: string;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/adapters/feishu/runtime/event-handlers.d.ts
|
|
47
|
+
interface FeishuSdkReceiveMessagePayload {
|
|
48
|
+
readonly message: FeishuReceiveMessagePayload["event"]["message"];
|
|
49
|
+
readonly sender?: FeishuReceiveMessagePayload["event"]["sender"];
|
|
50
|
+
readonly tenant_key?: string;
|
|
51
|
+
}
|
|
52
|
+
type FeishuReceiveMessageHandlerPayload = FeishuReceiveMessagePayload | FeishuSdkReceiveMessagePayload;
|
|
53
|
+
interface FeishuEventHandlers {
|
|
54
|
+
readonly "card.action.trigger"?: (payload: FeishuCardActionTriggerPayload) => Promise<FeishuCardActionCallbackResponse>;
|
|
55
|
+
readonly "im.message.receive_v1": (payload: FeishuReceiveMessageHandlerPayload) => Promise<FeishuMessageAcceptResult>;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/bootstrap/feishu/agent-runtime.d.ts
|
|
59
|
+
interface FeishuAgentRuntime {
|
|
60
|
+
readonly handlers: FeishuEventHandlers;
|
|
61
|
+
readonly harness: AgentHarness;
|
|
62
|
+
readonly queue: DurableQueue<FeishuReceiveMessagePayload, FeishuInboundDeliveryMetadata, FeishuAgentDaemonHandleResult>;
|
|
63
|
+
readonly worker: DurableQueueWorker<FeishuAgentDaemonHandleResult>;
|
|
64
|
+
drainAvailable(): Effect.Effect<DurableQueueWorkerDrainResult<FeishuAgentDaemonHandleResult>, unknown>;
|
|
65
|
+
drainOne(): Effect.Effect<DurableQueueDrainResult<FeishuAgentDaemonHandleResult>, unknown>;
|
|
66
|
+
pending(): number;
|
|
67
|
+
receiveStatus(): FeishuReceiveRuntimeStatus;
|
|
68
|
+
replayReceiveMessage(payload: FeishuReceiveMessagePayload, options?: FeishuReceiveMessageReplayOptions): Effect.Effect<FeishuReceiveMessageReplayResult, unknown>;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/platform/daemon/status/daemon-status-reporter.d.ts
|
|
72
|
+
interface DaemonStatusSnapshot<History, RunState, CardStatus, ReceiveStatus> {
|
|
73
|
+
readonly agentId: string;
|
|
74
|
+
readonly cards?: CardStatus;
|
|
75
|
+
readonly harness: {
|
|
76
|
+
readonly activeRunId?: string;
|
|
77
|
+
readonly activeRunState?: RunState;
|
|
78
|
+
readonly activeSessionKey?: string;
|
|
79
|
+
readonly busy: boolean;
|
|
80
|
+
};
|
|
81
|
+
readonly history: History;
|
|
82
|
+
readonly process: {
|
|
83
|
+
readonly running: boolean;
|
|
84
|
+
};
|
|
85
|
+
readonly queue: {
|
|
86
|
+
readonly pending: number;
|
|
87
|
+
};
|
|
88
|
+
readonly receive?: ReceiveStatus;
|
|
89
|
+
readonly transport: {
|
|
90
|
+
readonly running: boolean;
|
|
91
|
+
};
|
|
92
|
+
readonly workerLoop: {
|
|
93
|
+
readonly running: boolean;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
interface DaemonStatusReporter<History, RunState, CardStatus, ReceiveStatus> {
|
|
97
|
+
status(): Effect.Effect<DaemonStatusSnapshot<History, RunState, CardStatus, ReceiveStatus>, unknown>;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/adapters/feishu/runtime/websocket-daemon.d.ts
|
|
101
|
+
interface FeishuWebSocketDaemon {
|
|
102
|
+
running(): boolean;
|
|
103
|
+
start(): Promise<void>;
|
|
104
|
+
stop(): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/core/application/card-presentation/projection/card-presentation.d.ts
|
|
108
|
+
type CardPresentationStatus = "streaming" | "handoff-pending" | "active" | "closed" | "terminal";
|
|
109
|
+
interface CardPresentation {
|
|
110
|
+
readonly runId: string;
|
|
111
|
+
readonly presentationId: string;
|
|
112
|
+
readonly generation: number;
|
|
113
|
+
readonly cardId: string;
|
|
114
|
+
readonly elementId?: string;
|
|
115
|
+
readonly sourceMessageId: string;
|
|
116
|
+
readonly status: CardPresentationStatus;
|
|
117
|
+
readonly createdAt: string;
|
|
118
|
+
readonly leaseDeadlineAt: string;
|
|
119
|
+
readonly handoffAt?: string;
|
|
120
|
+
readonly handoffFailedAt?: string;
|
|
121
|
+
readonly predecessorPresentationId?: string;
|
|
122
|
+
readonly successorPresentationId?: string;
|
|
123
|
+
readonly terminalReceiptId?: string;
|
|
124
|
+
}
|
|
125
|
+
interface CardPresentationChain {
|
|
126
|
+
readonly runId: string;
|
|
127
|
+
readonly activeGeneration: number;
|
|
128
|
+
readonly activePresentationId: string;
|
|
129
|
+
readonly presentations: ReadonlyArray<CardPresentation>;
|
|
130
|
+
readonly revision: number;
|
|
131
|
+
}
|
|
132
|
+
interface CardPresentationBinding {
|
|
133
|
+
readonly cardId: string;
|
|
134
|
+
readonly createdAt: string;
|
|
135
|
+
readonly elementId?: string;
|
|
136
|
+
readonly leaseDeadlineAt: string;
|
|
137
|
+
readonly presentationId: string;
|
|
138
|
+
readonly runId: string;
|
|
139
|
+
readonly sourceMessageId: string;
|
|
140
|
+
}
|
|
141
|
+
interface CardPresentationSuccessor {
|
|
142
|
+
readonly cardId: string;
|
|
143
|
+
readonly createdAt: string;
|
|
144
|
+
readonly elementId?: string;
|
|
145
|
+
readonly leaseDeadlineAt: string;
|
|
146
|
+
readonly presentationId: string;
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/core/application/card-presentation/projection/card-presentation-service.d.ts
|
|
150
|
+
interface CardPresentationHandoffStart {
|
|
151
|
+
readonly presentation: CardPresentation;
|
|
152
|
+
readonly started: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface BeginCardPresentationHandoffInput {
|
|
155
|
+
readonly handoffAt: string;
|
|
156
|
+
readonly runId: string;
|
|
157
|
+
}
|
|
158
|
+
interface CompleteCardPresentationHandoffInput {
|
|
159
|
+
readonly runId: string;
|
|
160
|
+
readonly successor: CardPresentationSuccessor;
|
|
161
|
+
}
|
|
162
|
+
interface FailCardPresentationHandoffInput {
|
|
163
|
+
readonly failedAt: string;
|
|
164
|
+
readonly runId: string;
|
|
165
|
+
}
|
|
166
|
+
interface MarkCardPresentationTerminalInput {
|
|
167
|
+
readonly runId: string;
|
|
168
|
+
readonly terminalReceiptId: string;
|
|
169
|
+
}
|
|
170
|
+
interface CardPresentationService {
|
|
171
|
+
chain(runId: string): CardPresentationChain | undefined;
|
|
172
|
+
chains(): ReadonlyArray<CardPresentationChain>;
|
|
173
|
+
size(): number;
|
|
174
|
+
bind(binding: CardPresentationBinding): Effect.Effect<CardPresentation, unknown>;
|
|
175
|
+
beginHandoff(input: BeginCardPresentationHandoffInput): Effect.Effect<CardPresentationHandoffStart, unknown>;
|
|
176
|
+
compensateInterruptedHandoffs(compensatedAt: string): Effect.Effect<ReadonlyArray<CardPresentationChain>, unknown>;
|
|
177
|
+
completeHandoff(input: CompleteCardPresentationHandoffInput): Effect.Effect<CardPresentation, unknown>;
|
|
178
|
+
failHandoff(input: FailCardPresentationHandoffInput): Effect.Effect<void, unknown>;
|
|
179
|
+
markTerminal(input: MarkCardPresentationTerminalInput): Effect.Effect<void, unknown>;
|
|
180
|
+
release(runId: string): Effect.Effect<void, unknown>;
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/adapters/feishu/card-presentation/delivery/feishu-cardkit-publisher.d.ts
|
|
184
|
+
interface FeishuCardTarget {
|
|
185
|
+
readonly cardId: string;
|
|
186
|
+
readonly elementId: string;
|
|
187
|
+
readonly progressElementId?: string;
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/adapters/feishu/card-presentation/target/feishu-card-target-registry.d.ts
|
|
191
|
+
interface FeishuCardTargetRegistry extends CardPresentationService {
|
|
192
|
+
resolveTarget(runId: AgentRunId): Effect.Effect<FeishuCardTarget, unknown>;
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/adapters/feishu/card-presentation/rollover/feishu-card-rollover.d.ts
|
|
196
|
+
interface FeishuCardRolloverTarget {
|
|
197
|
+
readonly cardId: string;
|
|
198
|
+
readonly elementId?: string;
|
|
199
|
+
}
|
|
200
|
+
interface FeishuCardRolloverStreamPublisher {
|
|
201
|
+
flush(runId?: string): Effect.Effect<void, unknown>;
|
|
202
|
+
publish(action: FeishuStreamAction): Effect.Effect<void, unknown>;
|
|
203
|
+
}
|
|
204
|
+
type FeishuCardRolloverEventType = "handoff_started" | "handoff_succeeded" | "handoff_failed" | "handoff_notice_failed" | "presentation_write_failed" | "stale_update_dropped" | "stream_closed" | "terminal_delivery_failed";
|
|
205
|
+
type FeishuCardRolloverCounters = Readonly<Record<FeishuCardRolloverEventType, number>>;
|
|
206
|
+
interface FeishuCardRolloverStatus {
|
|
207
|
+
readonly counters: FeishuCardRolloverCounters;
|
|
208
|
+
readonly leaseMs: number;
|
|
209
|
+
readonly live: ReadonlyArray<CardPresentation>;
|
|
210
|
+
}
|
|
211
|
+
type FeishuCardRolloverHandoffResult = {
|
|
212
|
+
readonly presentation: CardPresentation;
|
|
213
|
+
readonly status: "rolled-over";
|
|
214
|
+
} | {
|
|
215
|
+
readonly reason: "already-pending" | "not-due" | "not-live" | "not-streaming";
|
|
216
|
+
readonly status: "skipped";
|
|
217
|
+
} | {
|
|
218
|
+
readonly error: unknown;
|
|
219
|
+
readonly status: "failed";
|
|
220
|
+
};
|
|
221
|
+
interface FeishuCardRollover extends FeishuCardRolloverStreamPublisher {
|
|
222
|
+
bindRun(run: FeishuAgentRunPreparation, target: FeishuCardRolloverTarget): Effect.Effect<CardPresentation, unknown>;
|
|
223
|
+
dueRunIds(now: Date): ReadonlyArray<string>;
|
|
224
|
+
handoff(runId: string): Effect.Effect<FeishuCardRolloverHandoffResult, unknown>;
|
|
225
|
+
observeStreamClosed(cardId: string): void;
|
|
226
|
+
recover(): Effect.Effect<{
|
|
227
|
+
readonly compensated: number;
|
|
228
|
+
}, unknown>;
|
|
229
|
+
releaseRun(runId: string): Effect.Effect<void>;
|
|
230
|
+
status(): FeishuCardRolloverStatus;
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/adapters/feishu/card-presentation/rollover/feishu-card-rollover-supervisor.d.ts
|
|
234
|
+
interface FeishuCardRolloverSupervisorTickResult {
|
|
235
|
+
readonly results: ReadonlyArray<FeishuCardRolloverHandoffResult>;
|
|
236
|
+
}
|
|
237
|
+
interface FeishuCardRolloverSupervisor {
|
|
238
|
+
recover(): Effect.Effect<void, unknown>;
|
|
239
|
+
running(): boolean;
|
|
240
|
+
start(): void;
|
|
241
|
+
stop(): Promise<void>;
|
|
242
|
+
tick(): Effect.Effect<FeishuCardRolloverSupervisorTickResult, unknown>;
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/bootstrap/feishu/card-rollover-runtime.d.ts
|
|
246
|
+
interface ConfiguredFeishuCardRolloverRuntime {
|
|
247
|
+
readonly rollover: FeishuCardRollover;
|
|
248
|
+
readonly supervisor: FeishuCardRolloverSupervisor;
|
|
249
|
+
readonly transport: RivusDaemonTransport;
|
|
250
|
+
prepareRun(run: FeishuAgentRunPreparation): Effect.Effect<void, unknown>;
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/bootstrap/feishu/rivus-daemon-bootstrap.d.ts
|
|
254
|
+
type ConfiguredRivusDaemonStatus = DaemonStatusSnapshot<AgentHistory, AgentRunState, FeishuCardRolloverStatus, FeishuReceiveRuntimeStatus>;
|
|
255
|
+
type ConfiguredRivusDaemonStatusReporter = DaemonStatusReporter<AgentHistory, AgentRunState, FeishuCardRolloverStatus, FeishuReceiveRuntimeStatus>;
|
|
256
|
+
interface ConfiguredRivusDaemonBootstrap {
|
|
257
|
+
readonly cardRollover: ConfiguredFeishuCardRolloverRuntime;
|
|
258
|
+
readonly cardTargets: FeishuCardTargetRegistry;
|
|
259
|
+
readonly eventLog: AgentEventLog;
|
|
260
|
+
readonly process: RivusDaemonProcess;
|
|
261
|
+
readonly publisher: FeishuCardRollover;
|
|
262
|
+
readonly runtime: FeishuAgentRuntime;
|
|
263
|
+
readonly statusReporter: ConfiguredRivusDaemonStatusReporter;
|
|
264
|
+
readonly transport: RivusDaemonTransport;
|
|
265
|
+
readonly websocketTransport: FeishuWebSocketDaemon;
|
|
266
|
+
readonly workerLoop: PeriodicEffectLoop;
|
|
267
|
+
promptText(command: PromptCommand): Effect.Effect<string, unknown>;
|
|
268
|
+
restoreHistory(): Effect.Effect<AgentHistory, unknown>;
|
|
269
|
+
status(): Effect.Effect<ConfiguredRivusDaemonStatus, unknown>;
|
|
270
|
+
}
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region src/bootstrap/feishu/pi-feishu-daemon-bootstrap.d.ts
|
|
273
|
+
export declare function createRivusDaemonProcess(context: RivusDaemonBootstrapContext): Promise<RivusDaemonProcess & RivusDaemonPromptRunner & RivusDaemonFeishuReplayRunner & Pick<ConfiguredRivusDaemonBootstrap, "status">>;
|
|
274
|
+
//#endregion
|
|
3
275
|
//#region src/bootstrap/pi-feishu.d.ts
|
|
4
|
-
declare function createRivusDeploymentAdapters(context: RivusDeploymentBootstrapContext): Promise<{
|
|
276
|
+
export declare function createRivusDeploymentAdapters(context: RivusDeploymentBootstrapContext): Promise<{
|
|
5
277
|
dispose: () => Promise<void>;
|
|
6
|
-
createRecoveryControl: () =>
|
|
7
|
-
createBackgroundSession: ((input:
|
|
8
|
-
createAutomation: (input:
|
|
9
|
-
createEndpoint: (input:
|
|
10
|
-
createRuntime: (input:
|
|
11
|
-
dispose: () => Promise<void>;
|
|
12
|
-
concurrency: "managed";
|
|
13
|
-
status(): SessionSchedulerStatus;
|
|
14
|
-
cancel?(input: AgentRuntimeCancellation): Promise<boolean>;
|
|
15
|
-
steer?(input: AgentRuntimeSteering): Promise<boolean>;
|
|
16
|
-
run(input: AgentRuntimeInput): Promise<unknown>;
|
|
17
|
-
}>;
|
|
278
|
+
createRecoveryControl: () => Effect.Effect<RecoveryControl, unknown, never>;
|
|
279
|
+
createBackgroundSession: ((input: CreateRivusDeploymentBackgroundSessionPortInput) => Effect.Effect<RivusDeploymentBackgroundSessionPort, unknown, never>) | undefined;
|
|
280
|
+
createAutomation: (input: CreateRivusDeploymentAutomationPortInput) => Effect.Effect<AutomationScheduler, unknown, never>;
|
|
281
|
+
createEndpoint: (input: CreateRivusDeploymentEndpointPortInput) => Effect.Effect<RivusDeploymentEndpointPort, unknown, never>;
|
|
282
|
+
createRuntime: (input: CreateRivusDeploymentRuntimePortInput) => Effect.Effect<RivusDeploymentRuntimePort, unknown>;
|
|
18
283
|
}>;
|
|
19
284
|
//#endregion
|
|
20
|
-
export {
|
|
285
|
+
export {};
|