@rivus/gateway 0.19.0 → 0.21.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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { B as ResolvedRivusAgentDefinition, F as RivusPluginManifest, H as RivusAgentProfile, I as RivusAutomationInput, L as RivusAutomationOutput, M as RivusPluginCatalog, N as RivusPluginRegistry, P as RIVUS_PLUGIN_API_VERSION, R as RivusAutomationTemplate, V as RivusAgentDeployment, j as RivusPlugin, n as RivusDaemonCliOptions, o as RivusHomeApi, s as RivusDaemonEnv, z as RivusAutomationTickContext } from "./chunks/rivus-daemon-cli.js";
2
- import { RivusMemoryScope, RivusResolvedToolDescriptor } from "@rivus/runtime";
1
+ import { A as AutomationPresentationKind, C as RivusAutomationInput, D as RivusAutomationTickContext, E as RivusAutomationTemplate, F as AutomationPresentationTableColumn, I as AutomationPresentationTrend, L as readAutomationPresentation, M as AutomationPresentationSource, N as AutomationPresentationTable, O as AutomationPresentation, P as AutomationPresentationTableCell, R as AutomationLineChart, S as RivusAutomationFailure, T as RivusAutomationRetryPolicy, _ as RivusPluginManifest, a as RivusDaemonEnv, b as RivusAgentProfile, g as RIVUS_PLUGIN_API_VERSION, h as RivusPluginRegistry, i as RivusHomeApi, j as AutomationPresentationSection, k as AutomationPresentationItem, m as RivusPluginCatalog, n as RivusDeploymentBootstrapFactory, p as RivusPlugin, r as RivusHome, v as ResolvedRivusAgentDefinition, w as RivusAutomationOutput, y as RivusAgentDeployment } 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,58 @@ 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
+ readonly checkPlugins?: boolean;
63
+ readonly lifecycle?: {
64
+ readonly started: () => Promise<void>;
65
+ readonly stopped: () => Promise<void>;
66
+ };
67
+ }
68
+ //#endregion
69
+ //#region src/bootstrap/upgrade/upgrade-home.d.ts
70
+ interface UpgradeResult {
71
+ readonly status: "upgraded" | "current";
72
+ readonly version: string;
73
+ readonly previousVersion: string;
74
+ readonly home: string;
75
+ readonly service: string;
76
+ readonly pid: number;
77
+ readonly executable: string;
78
+ readonly backup?: string;
79
+ readonly operationId?: string;
80
+ }
81
+ interface UpgradeHomeInvocation {
82
+ readonly home: RivusHome;
83
+ readonly userHome: string;
84
+ readonly platform: NodeJS.Platform;
85
+ readonly env: Readonly<Record<string, string | undefined>>;
86
+ readonly pid: number;
87
+ readonly isProcessAlive: (pid: number) => boolean;
88
+ readonly signal?: AbortSignal;
89
+ readonly progress: (phase: string, detail: string) => void;
90
+ }
91
+ //#endregion
40
92
  //#region src/bootstrap/cli/rivus-cli.d.ts
41
93
  interface RivusCliOptions extends RivusDaemonCliOptions {
42
94
  readonly changeWorkingDirectory: (directory: string) => void;
@@ -46,6 +98,12 @@ interface RivusCliOptions extends RivusDaemonCliOptions {
46
98
  readonly nodeExecutable: string;
47
99
  readonly nodeVersion: string;
48
100
  readonly modelManagementClient?: RivusModelManagementSocketClient;
101
+ readonly runtimeProcess?: {
102
+ readonly pid: number;
103
+ readonly executable: string;
104
+ };
105
+ readonly upgradeHost?: Pick<UpgradeHomeInvocation, "pid" | "platform" | "isProcessAlive">;
106
+ readonly upgradeRunner?: (input: UpgradeHomeInvocation) => Promise<UpgradeResult>;
49
107
  }
50
108
  //#endregion
51
109
  //#region src/bootstrap/cli/rivus-node-entrypoint.d.ts
@@ -61,5 +119,5 @@ interface RivusNodeEntrypointOptions {
61
119
  }
62
120
  export declare function runRivusNodeEntrypoint(options: RivusNodeEntrypointOptions): Effect.Effect<number>;
63
121
  //#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 };
122
+ 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
123
  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
- export { RIVUS_PLUGIN_API_VERSION, createRivusPluginCatalog, resolveRivusAgentDefinition, runRivusNodeEntrypoint };
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 RunBackgroundSessionMcpServerEnv {
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 runBackgroundSessionMcpServer(options?: RunBackgroundSessionMcpServerEnv): Promise<void>;
8
+ export declare function runRivusHostToolMcpServer(options?: RunRivusHostToolMcpServerEnv): Promise<void>;
9
9
  //#endregion
10
- //#region src/core/application/background-session/control/background-session-control.d.ts
11
- type BackgroundSessionControlCommand = "start" | "wait" | "list" | "status" | "send" | "stop";
12
- //#endregion
13
- //#region src/adapters/mcp/background-session/background-session-mcp-server.d.ts
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 BackgroundSessionMcpServer {
23
+ interface RivusHostToolMcpServer {
28
24
  run(): Promise<void>;
29
25
  }
30
- export declare class BackgroundSessionMcpError extends Error {
31
- readonly name = "BackgroundSessionMcpError";
26
+ export declare class RivusHostToolMcpError extends Error {
27
+ readonly name = "RivusHostToolMcpError";
32
28
  }
33
- export declare function createBackgroundSessionMcpServer(options: BackgroundSessionMcpServerOptions): BackgroundSessionMcpServer;
29
+ export declare function createRivusHostToolMcpServer(options: RivusHostToolMcpServerOptions): RivusHostToolMcpServer;
34
30
  //#endregion
35
- export type { BackgroundSessionMcpServer, BackgroundSessionMcpServerOptions };
31
+ export type { RivusHostToolMcpServer, RivusHostToolMcpServerOptions };
36
32
  export {};
package/dist/mcp.js CHANGED
@@ -1,30 +1,34 @@
1
- import { t as createBackgroundSessionToolContracts } from "./chunks/background-session-authority.js";
1
+ import { Schema } from "effect";
2
2
  import { pathToFileURL } from "node:url";
3
- //#region src/adapters/mcp/background-session/background-session-mcp-server.ts
4
- const BACKGROUND_SESSION_MCP_SERVER_NAME = "rivus-background-sessions";
5
- const BACKGROUND_SESSION_MCP_SERVER_VERSION = "1.0.0";
6
- var BackgroundSessionMcpError = class extends Error {
7
- name = "BackgroundSessionMcpError";
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 createBackgroundSessionMcpServer(options) {
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-background-sessions",
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 (!isRecord(message) || !isJsonRpcRequestId(message.id)) continue;
48
- const method = typeof message.method === "string" ? message.method : void 0;
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: options.tools }
95
+ result: { tools }
75
96
  });
76
97
  break;
98
+ }
77
99
  case "tools/call": {
78
- const params = isRecord(message.params) ? message.params : {};
79
- const name = typeof params.name === "string" ? params.name : "";
80
- const command = name.startsWith("background.") ? name.slice(11) : void 0;
81
- if (!command || !options.tools.some((tool) => tool.name === name)) {
82
- send({
83
- jsonrpc: "2.0",
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(envelope.result ?? null),
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 BackgroundSessionMcpError("invalid MCP JSON payload");
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 runBackgroundSessionMcpServer(options = {}) {
164
+ async function runRivusHostToolMcpServer(options = {}) {
181
165
  const controlUrl = requireEnv("RIVUS_MCP_CONTROL_URL");
182
166
  const controlToken = requireEnv("RIVUS_MCP_CONTROL_TOKEN");
183
- const capability = requireEnv("RIVUS_MCP_CAPABILITY");
184
- const enabledTools = optionalEnv("RIVUS_MCP_TOOLS")?.split(",").map((tool) => tool.trim()).filter(Boolean);
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 BackgroundSessionMcpError(`${name} is required`);
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 runBackgroundSessionMcpServer();
183
+ if (pathToFileURL(process.argv[1] ?? "").href === import.meta.url) await runRivusHostToolMcpServer();
206
184
  //#endregion
207
- export { BACKGROUND_SESSION_MCP_SERVER_NAME, BACKGROUND_SESSION_MCP_SERVER_VERSION, BackgroundSessionMcpError, createBackgroundSessionMcpServer, runBackgroundSessionMcpServer };
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.19.0",
3
+ "version": "0.21.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,20 +54,24 @@
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.19.0",
60
- "@rivus/runtime": "0.19.0",
60
+ "@rivus/platform": "0.21.0",
61
+ "@rivus/runtime": "0.21.0",
61
62
  "axios": "1.20.0",
62
63
  "effect": "^4.0.0",
63
64
  "get-east-asian-width": "1.6.0",
64
- "marked": "18.0.14"
65
+ "marked": "18.0.14",
66
+ "semver": "7.8.0",
67
+ "yaml": "2.9.1"
65
68
  },
66
69
  "publishConfig": {
67
70
  "access": "public"
68
71
  },
69
72
  "devDependencies": {
70
73
  "@types/node": "24.19.2",
74
+ "@types/semver": "7.7.1",
71
75
  "@typescript/native": "npm:typescript@7.0.2",
72
76
  "@vitest/coverage-v8": "5.0.1",
73
77
  "tar": "7.5.22",
@@ -1 +1 @@
1
- export { createRivusDeploymentAdapters } from "@rivus/gateway/bootstrap/pi-feishu";
1
+ export { createRivusDeploymentAdapters } from "@rivus/gateway/bootstrap/feishu";