@rivus/gateway 0.19.0 → 0.20.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/README.md +12 -7
- package/dist/bootstrap/feishu.d.ts +13 -0
- package/dist/bootstrap/{pi-feishu.js → feishu.js} +16038 -15746
- package/dist/chunks/automation-presentation.js +265 -0
- package/dist/chunks/herdr-feishu-runtime.js +1 -1
- package/dist/chunks/{rivus-daemon-cli.d.ts → rivus-deployment-cli-process.d.ts} +136 -355
- package/dist/chunks/rivus-home-deployment-env.js +958 -91
- package/dist/chunks/rivus-node-entrypoint.js +377 -1148
- package/dist/index.d.ts +27 -3
- package/dist/index.js +2 -1
- package/dist/mcp.d.ts +11 -15
- package/dist/mcp.js +64 -86
- package/package.json +9 -8
- package/templates/{pi-feishu-deployment.bootstrap.ts → feishu-deployment.bootstrap.ts} +1 -1
- package/dist/bootstrap/pi-feishu.d.ts +0 -285
- package/dist/chunks/background-session-authority.js +0 -194
- package/templates/pi-feishu.bootstrap.ts +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { RivusMemoryScope, RivusResolvedToolDescriptor } from "@rivus/runtime";
|
|
1
|
+
import { A as AutomationPresentationSection, C as RivusAutomationOutput, D as AutomationPresentation, E as RivusAutomationTickContext, F as AutomationPresentationTrend, I as readAutomationPresentation, L as AutomationLineChart, M as AutomationPresentationTable, N as AutomationPresentationTableCell, O as AutomationPresentationItem, P as AutomationPresentationTableColumn, S as RivusAutomationInput, T as RivusAutomationTemplate, _ as ResolvedRivusAgentDefinition, f as RivusPlugin, g as RivusPluginManifest, h as RIVUS_PLUGIN_API_VERSION, i as RivusDaemonEnv, j as AutomationPresentationSource, k as AutomationPresentationKind, m as RivusPluginRegistry, n as RivusDeploymentBootstrapFactory, p as RivusPluginCatalog, r as RivusHomeApi, v as RivusAgentDeployment, w as RivusAutomationRetryPolicy, x as RivusAutomationFailure, y as RivusAgentProfile } from "./chunks/rivus-deployment-cli-process.js";
|
|
3
2
|
import { Effect } from "effect";
|
|
3
|
+
import { RivusMemoryScope, RivusResolvedToolDescriptor } from "@rivus/runtime";
|
|
4
4
|
//#region src/bootstrap/catalog/rivus-agent-catalog.d.ts
|
|
5
5
|
export declare function createRivusPluginCatalog(): RivusPluginCatalog;
|
|
6
6
|
export declare function resolveRivusAgentDefinition(catalog: RivusPluginCatalog, deployment: RivusAgentDeployment, options?: {
|
|
@@ -37,6 +37,30 @@ interface RivusModelManagementSocketClient {
|
|
|
37
37
|
execute(command: RivusModelCliCommand): Promise<RivusModelCliResponse>;
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
|
+
//#region src/platform/daemon/process/rivus-daemon-shutdown-controller.d.ts
|
|
41
|
+
type RivusDaemonShutdownSignal = "SIGINT" | "SIGTERM";
|
|
42
|
+
interface RivusDaemonSignalSource {
|
|
43
|
+
on(signal: RivusDaemonShutdownSignal, listener: () => void): void;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/bootstrap/daemon/rivus-daemon-cli.d.ts
|
|
47
|
+
interface RivusDaemonBootstrapModule {
|
|
48
|
+
readonly createRivusDeploymentAdapters?: RivusDeploymentBootstrapFactory;
|
|
49
|
+
}
|
|
50
|
+
interface RivusDaemonCliWriter {
|
|
51
|
+
write(text: string): unknown;
|
|
52
|
+
}
|
|
53
|
+
interface RivusDaemonCliOptions {
|
|
54
|
+
readonly argv: ReadonlyArray<string>;
|
|
55
|
+
readonly env: RivusDaemonEnv;
|
|
56
|
+
readonly exitAfterSignal?: (exitCode: number) => void;
|
|
57
|
+
readonly loadBootstrap?: (specifier: string) => Promise<RivusDaemonBootstrapModule>;
|
|
58
|
+
readonly signalSource: RivusDaemonSignalSource;
|
|
59
|
+
readonly stderr: RivusDaemonCliWriter;
|
|
60
|
+
readonly stdout: RivusDaemonCliWriter;
|
|
61
|
+
readonly pluginPackageManifestPath?: string;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
40
64
|
//#region src/bootstrap/cli/rivus-cli.d.ts
|
|
41
65
|
interface RivusCliOptions extends RivusDaemonCliOptions {
|
|
42
66
|
readonly changeWorkingDirectory: (directory: string) => void;
|
|
@@ -61,5 +85,5 @@ interface RivusNodeEntrypointOptions {
|
|
|
61
85
|
}
|
|
62
86
|
export declare function runRivusNodeEntrypoint(options: RivusNodeEntrypointOptions): Effect.Effect<number>;
|
|
63
87
|
//#endregion
|
|
64
|
-
export { RIVUS_PLUGIN_API_VERSION, type RivusAgentDeployment, type RivusAgentProfile, type RivusAutomationInput, type RivusAutomationOutput, type RivusAutomationTemplate, type RivusAutomationTickContext, type RivusPlugin, type RivusPluginManifest, type RivusPluginRegistry };
|
|
88
|
+
export { type AutomationLineChart, type AutomationPresentation, type AutomationPresentationItem, type AutomationPresentationKind, type AutomationPresentationSection, type AutomationPresentationSource, type AutomationPresentationTable, type AutomationPresentationTableCell, type AutomationPresentationTableColumn, type AutomationPresentationTrend, RIVUS_PLUGIN_API_VERSION, type RivusAgentDeployment, type RivusAgentProfile, RivusAutomationFailure, type RivusAutomationInput, type RivusAutomationOutput, type RivusAutomationRetryPolicy, type RivusAutomationTemplate, type RivusAutomationTickContext, type RivusPlugin, type RivusPluginManifest, type RivusPluginRegistry, readAutomationPresentation };
|
|
65
89
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { i as RIVUS_PLUGIN_API_VERSION, n as createRivusPluginCatalog, r as resolveRivusAgentDefinition, t as runRivusNodeEntrypoint } from "./chunks/rivus-node-entrypoint.js";
|
|
2
|
-
|
|
2
|
+
import { n as RivusAutomationFailure, t as readAutomationPresentation } from "./chunks/automation-presentation.js";
|
|
3
|
+
export { RIVUS_PLUGIN_API_VERSION, RivusAutomationFailure, createRivusPluginCatalog, readAutomationPresentation, resolveRivusAgentDefinition, runRivusNodeEntrypoint };
|
|
3
4
|
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,36 +1,32 @@
|
|
|
1
1
|
import { Readable, Writable } from "node:stream";
|
|
2
2
|
//#region src/bootstrap/mcp/rivus-mcp-entrypoint.d.ts
|
|
3
|
-
interface
|
|
3
|
+
interface RunRivusHostToolMcpServerEnv {
|
|
4
4
|
readonly fetch?: typeof fetch;
|
|
5
5
|
readonly input?: Readable;
|
|
6
6
|
readonly output?: Writable;
|
|
7
7
|
}
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function runRivusHostToolMcpServer(options?: RunRivusHostToolMcpServerEnv): Promise<void>;
|
|
9
9
|
//#endregion
|
|
10
|
-
//#region src/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare const BACKGROUND_SESSION_MCP_SERVER_NAME = "rivus-background-sessions";
|
|
15
|
-
export declare const BACKGROUND_SESSION_MCP_SERVER_VERSION = "1.0.0";
|
|
16
|
-
interface BackgroundSessionMcpServerOptions {
|
|
10
|
+
//#region src/adapters/mcp/host-tool/host-tool-mcp-server.d.ts
|
|
11
|
+
export declare const RIVUS_HOST_TOOL_MCP_SERVER_NAME = "rivus-host-tools";
|
|
12
|
+
export declare const RIVUS_HOST_TOOL_MCP_SERVER_VERSION = "1.0.0";
|
|
13
|
+
interface RivusHostToolMcpServerOptions {
|
|
17
14
|
readonly capability: string;
|
|
18
15
|
readonly controlUrl: string;
|
|
19
16
|
readonly controlToken: string;
|
|
20
|
-
readonly enabledTools?: ReadonlyArray<BackgroundSessionControlCommand>;
|
|
21
17
|
readonly fetch?: typeof fetch;
|
|
22
18
|
readonly input?: Readable;
|
|
23
19
|
readonly output?: Writable;
|
|
24
20
|
readonly serverName?: string;
|
|
25
21
|
readonly serverVersion?: string;
|
|
26
22
|
}
|
|
27
|
-
interface
|
|
23
|
+
interface RivusHostToolMcpServer {
|
|
28
24
|
run(): Promise<void>;
|
|
29
25
|
}
|
|
30
|
-
export declare class
|
|
31
|
-
readonly name = "
|
|
26
|
+
export declare class RivusHostToolMcpError extends Error {
|
|
27
|
+
readonly name = "RivusHostToolMcpError";
|
|
32
28
|
}
|
|
33
|
-
export declare function
|
|
29
|
+
export declare function createRivusHostToolMcpServer(options: RivusHostToolMcpServerOptions): RivusHostToolMcpServer;
|
|
34
30
|
//#endregion
|
|
35
|
-
export type {
|
|
31
|
+
export type { RivusHostToolMcpServer, RivusHostToolMcpServerOptions };
|
|
36
32
|
export {};
|
package/dist/mcp.js
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Schema } from "effect";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
|
-
//#region src/adapters/mcp/
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
//#region src/adapters/mcp/host-tool/host-tool-mcp-server.ts
|
|
4
|
+
const requestSchema = Schema.Struct({
|
|
5
|
+
jsonrpc: Schema.Literal("2.0"),
|
|
6
|
+
id: Schema.NullOr(Schema.Union([Schema.String, Schema.Number])),
|
|
7
|
+
method: Schema.String,
|
|
8
|
+
params: Schema.optional(Schema.Unknown)
|
|
9
|
+
});
|
|
10
|
+
const callParamsSchema = Schema.Struct({
|
|
11
|
+
name: Schema.String,
|
|
12
|
+
arguments: Schema.optional(Schema.Unknown)
|
|
13
|
+
});
|
|
14
|
+
const controlResponseSchema = Schema.Union([Schema.Struct({
|
|
15
|
+
ok: Schema.Literal(true),
|
|
16
|
+
result: Schema.Unknown
|
|
17
|
+
}), Schema.Struct({
|
|
18
|
+
ok: Schema.Literal(false),
|
|
19
|
+
error: Schema.Struct({ message: Schema.String })
|
|
20
|
+
})]);
|
|
21
|
+
const RIVUS_HOST_TOOL_MCP_SERVER_NAME = "rivus-host-tools";
|
|
22
|
+
const RIVUS_HOST_TOOL_MCP_SERVER_VERSION = "1.0.0";
|
|
23
|
+
var RivusHostToolMcpError = class extends Error {
|
|
24
|
+
name = "RivusHostToolMcpError";
|
|
8
25
|
};
|
|
9
|
-
function
|
|
26
|
+
function createRivusHostToolMcpServer(options) {
|
|
10
27
|
const input = options.input ?? process.stdin;
|
|
11
28
|
const output = options.output ?? process.stdout;
|
|
12
29
|
const fetchImplementation = options.fetch ?? fetch;
|
|
13
|
-
const enabledTools = new Set(options.enabledTools ?? [
|
|
14
|
-
"start",
|
|
15
|
-
"wait",
|
|
16
|
-
"list",
|
|
17
|
-
"status",
|
|
18
|
-
"send",
|
|
19
|
-
"stop"
|
|
20
|
-
]);
|
|
21
|
-
const tools = createBackgroundSessionToolContracts().filter(({ id }) => enabledTools.has(id.slice(11))).map((contract) => ({
|
|
22
|
-
description: contract.description,
|
|
23
|
-
inputSchema: contract.inputSchema,
|
|
24
|
-
name: contract.id
|
|
25
|
-
}));
|
|
26
30
|
const serverInfo = {
|
|
27
|
-
name: options.serverName ?? "rivus-
|
|
31
|
+
name: options.serverName ?? "rivus-host-tools",
|
|
28
32
|
version: options.serverVersion ?? "1.0.0"
|
|
29
33
|
};
|
|
30
34
|
return { run: () => runMcpServer({
|
|
@@ -34,8 +38,7 @@ function createBackgroundSessionMcpServer(options) {
|
|
|
34
38
|
fetchImplementation,
|
|
35
39
|
input,
|
|
36
40
|
output,
|
|
37
|
-
serverInfo
|
|
38
|
-
tools
|
|
41
|
+
serverInfo
|
|
39
42
|
}) };
|
|
40
43
|
}
|
|
41
44
|
async function runMcpServer(options) {
|
|
@@ -43,10 +46,27 @@ async function runMcpServer(options) {
|
|
|
43
46
|
const body = JSON.stringify(message);
|
|
44
47
|
options.output.write(`${body}\n`);
|
|
45
48
|
};
|
|
49
|
+
const forward = async (operation, body) => {
|
|
50
|
+
const response = await options.fetchImplementation(new URL(`/v1/tools/${operation}`, options.controlUrl), {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: {
|
|
53
|
+
authorization: `Bearer ${options.controlToken}`,
|
|
54
|
+
"content-type": "application/json"
|
|
55
|
+
},
|
|
56
|
+
body: JSON.stringify({
|
|
57
|
+
...body,
|
|
58
|
+
capability: options.capability
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
const envelope = await response.json();
|
|
62
|
+
if (!Schema.is(controlResponseSchema)(envelope)) throw new RivusHostToolMcpError("invalid host-tool control response");
|
|
63
|
+
if (!envelope.ok) throw new RivusHostToolMcpError(envelope.error.message);
|
|
64
|
+
if (!response.ok) throw new RivusHostToolMcpError(`host-tool control failed with ${response.status}`);
|
|
65
|
+
return envelope.result;
|
|
66
|
+
};
|
|
46
67
|
for await (const message of readMcpMessages(options.input)) {
|
|
47
|
-
if (!
|
|
48
|
-
const
|
|
49
|
-
if (!method) continue;
|
|
68
|
+
if (!Schema.is(requestSchema)(message)) continue;
|
|
69
|
+
const { method } = message;
|
|
50
70
|
try {
|
|
51
71
|
switch (method) {
|
|
52
72
|
case "initialize":
|
|
@@ -67,59 +87,29 @@ async function runMcpServer(options) {
|
|
|
67
87
|
result: {}
|
|
68
88
|
});
|
|
69
89
|
break;
|
|
70
|
-
case "tools/list":
|
|
90
|
+
case "tools/list": {
|
|
91
|
+
const tools = await forward("list", {});
|
|
71
92
|
send({
|
|
72
93
|
jsonrpc: "2.0",
|
|
73
94
|
id: message.id,
|
|
74
|
-
result: { tools
|
|
95
|
+
result: { tools }
|
|
75
96
|
});
|
|
76
97
|
break;
|
|
98
|
+
}
|
|
77
99
|
case "tools/call": {
|
|
78
|
-
const params =
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
id: message.id,
|
|
85
|
-
error: {
|
|
86
|
-
code: -32602,
|
|
87
|
-
message: `unknown tool: ${name}`
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
const response = await options.fetchImplementation(options.controlUrl, {
|
|
93
|
-
body: JSON.stringify({
|
|
94
|
-
capability: options.capability,
|
|
95
|
-
command,
|
|
96
|
-
input: params.arguments ?? {}
|
|
97
|
-
}),
|
|
98
|
-
headers: {
|
|
99
|
-
authorization: `Bearer ${options.controlToken}`,
|
|
100
|
-
"content-type": "application/json"
|
|
101
|
-
},
|
|
102
|
-
method: "POST"
|
|
100
|
+
const params = message.params;
|
|
101
|
+
if (!Schema.is(callParamsSchema)(params)) throw new RivusHostToolMcpError("invalid tools/call parameters");
|
|
102
|
+
const result = await forward("call", {
|
|
103
|
+
callId: `${Date.now()}:${String(message.id)}`,
|
|
104
|
+
toolName: params.name,
|
|
105
|
+
input: params.arguments ?? {}
|
|
103
106
|
});
|
|
104
|
-
const envelope = await response.json();
|
|
105
|
-
if (!response.ok || envelope.error) {
|
|
106
|
-
const messageText = envelope.error?.message ?? `background session control failed with ${response.status}`;
|
|
107
|
-
send({
|
|
108
|
-
jsonrpc: "2.0",
|
|
109
|
-
id: message.id,
|
|
110
|
-
error: {
|
|
111
|
-
code: -32e3,
|
|
112
|
-
message: messageText
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
107
|
send({
|
|
118
108
|
jsonrpc: "2.0",
|
|
119
109
|
id: message.id,
|
|
120
110
|
result: {
|
|
121
111
|
content: [{
|
|
122
|
-
text: JSON.stringify(
|
|
112
|
+
text: typeof result === "string" ? result : JSON.stringify(result ?? null),
|
|
123
113
|
type: "text"
|
|
124
114
|
}],
|
|
125
115
|
isError: false
|
|
@@ -166,27 +156,18 @@ function parseMcpMessage(payload) {
|
|
|
166
156
|
try {
|
|
167
157
|
return JSON.parse(payload);
|
|
168
158
|
} catch {
|
|
169
|
-
throw new
|
|
159
|
+
throw new RivusHostToolMcpError("invalid MCP JSON payload");
|
|
170
160
|
}
|
|
171
161
|
}
|
|
172
|
-
function isJsonRpcRequestId(value) {
|
|
173
|
-
return value === null || typeof value === "string" || typeof value === "number";
|
|
174
|
-
}
|
|
175
|
-
function isRecord(value) {
|
|
176
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
177
|
-
}
|
|
178
162
|
//#endregion
|
|
179
163
|
//#region src/bootstrap/mcp/rivus-mcp-entrypoint.ts
|
|
180
|
-
async function
|
|
164
|
+
async function runRivusHostToolMcpServer(options = {}) {
|
|
181
165
|
const controlUrl = requireEnv("RIVUS_MCP_CONTROL_URL");
|
|
182
166
|
const controlToken = requireEnv("RIVUS_MCP_CONTROL_TOKEN");
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
await createBackgroundSessionMcpServer({
|
|
186
|
-
capability,
|
|
167
|
+
await createRivusHostToolMcpServer({
|
|
168
|
+
capability: requireEnv("RIVUS_MCP_CAPABILITY"),
|
|
187
169
|
controlToken,
|
|
188
170
|
controlUrl,
|
|
189
|
-
...enabledTools ? { enabledTools } : {},
|
|
190
171
|
...options.fetch ? { fetch: options.fetch } : {},
|
|
191
172
|
...options.input ? { input: options.input } : {},
|
|
192
173
|
...options.output ? { output: options.output } : {}
|
|
@@ -194,15 +175,12 @@ async function runBackgroundSessionMcpServer(options = {}) {
|
|
|
194
175
|
}
|
|
195
176
|
function requireEnv(name) {
|
|
196
177
|
const value = process.env[name]?.trim();
|
|
197
|
-
if (!value) throw new
|
|
178
|
+
if (!value) throw new RivusHostToolMcpError(`${name} is required`);
|
|
198
179
|
return value;
|
|
199
180
|
}
|
|
200
|
-
function optionalEnv(name) {
|
|
201
|
-
return process.env[name]?.trim() || void 0;
|
|
202
|
-
}
|
|
203
181
|
//#endregion
|
|
204
182
|
//#region src/mcp.ts
|
|
205
|
-
if (pathToFileURL(process.argv[1] ?? "").href === import.meta.url) await
|
|
183
|
+
if (pathToFileURL(process.argv[1] ?? "").href === import.meta.url) await runRivusHostToolMcpServer();
|
|
206
184
|
//#endregion
|
|
207
|
-
export {
|
|
185
|
+
export { RIVUS_HOST_TOOL_MCP_SERVER_NAME, RIVUS_HOST_TOOL_MCP_SERVER_VERSION, RivusHostToolMcpError, createRivusHostToolMcpServer, runRivusHostToolMcpServer };
|
|
208
186
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivus/gateway",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Message gateway, channels, host binding, automation, and daemon assembly for Rivus.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "GPL-3.0-only",
|
|
@@ -27,11 +27,6 @@
|
|
|
27
27
|
"import": "./dist/mcp.js",
|
|
28
28
|
"default": "./dist/mcp.js"
|
|
29
29
|
},
|
|
30
|
-
"./bootstrap/pi-feishu": {
|
|
31
|
-
"types": "./dist/bootstrap/pi-feishu.d.ts",
|
|
32
|
-
"import": "./dist/bootstrap/pi-feishu.js",
|
|
33
|
-
"default": "./dist/bootstrap/pi-feishu.js"
|
|
34
|
-
},
|
|
35
30
|
"./cli": "./dist/cli.js",
|
|
36
31
|
"./plugin/starter": "./templates/rivus-starter.plugin.mjs",
|
|
37
32
|
"./skills/runtime-management/SKILL.md": "./skills/runtime-management/SKILL.md",
|
|
@@ -40,6 +35,11 @@
|
|
|
40
35
|
"types": "./dist/bootstrap/herdr-feishu.d.ts",
|
|
41
36
|
"import": "./dist/bootstrap/herdr-feishu.js",
|
|
42
37
|
"default": "./dist/bootstrap/herdr-feishu.js"
|
|
38
|
+
},
|
|
39
|
+
"./bootstrap/feishu": {
|
|
40
|
+
"types": "./dist/bootstrap/feishu.d.ts",
|
|
41
|
+
"import": "./dist/bootstrap/feishu.js",
|
|
42
|
+
"default": "./dist/bootstrap/feishu.js"
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"files": [
|
|
@@ -54,10 +54,11 @@
|
|
|
54
54
|
"LICENSE"
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
|
+
"@agentclientprotocol/sdk": "1.5.1",
|
|
57
58
|
"@larksuiteoapi/node-sdk": "1.74.0",
|
|
58
59
|
"@resvg/resvg-js": "2.6.2",
|
|
59
|
-
"@rivus/platform": "0.
|
|
60
|
-
"@rivus/runtime": "0.
|
|
60
|
+
"@rivus/platform": "0.20.0",
|
|
61
|
+
"@rivus/runtime": "0.20.0",
|
|
61
62
|
"axios": "1.20.0",
|
|
62
63
|
"effect": "^4.0.0",
|
|
63
64
|
"get-east-asian-width": "1.6.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createRivusDeploymentAdapters } from "@rivus/gateway/bootstrap/
|
|
1
|
+
export { createRivusDeploymentAdapters } from "@rivus/gateway/bootstrap/feishu";
|
|
@@ -1,285 +0,0 @@
|
|
|
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
|
|
275
|
-
//#region src/bootstrap/pi-feishu.d.ts
|
|
276
|
-
export declare function createRivusDeploymentAdapters(context: RivusDeploymentBootstrapContext): Promise<{
|
|
277
|
-
dispose: () => Promise<void>;
|
|
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>;
|
|
283
|
-
}>;
|
|
284
|
-
//#endregion
|
|
285
|
-
export {};
|