@rivus/gateway 0.21.2 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +4 -1
  2. package/assets/audio-transcriber/fetch-model.mjs +63 -70
  3. package/assets/audio-transcriber/transcribe.mjs +38 -47
  4. package/assets/installation-policy.json +4 -3
  5. package/dist/bootstrap/feishu.d.ts +4 -2
  6. package/dist/bootstrap/feishu.js +19389 -17389
  7. package/dist/bootstrap/herdr-feishu.d.ts +1 -7
  8. package/dist/bootstrap/herdr-feishu.js +23 -12
  9. package/dist/chunks/automation-presentation.js +58 -60
  10. package/dist/chunks/feishu-receive-message.js +113 -0
  11. package/dist/chunks/herdr-feishu-runtime.js +1011 -626
  12. package/dist/chunks/public.d.ts +278 -0
  13. package/dist/chunks/public2.d.ts +10 -0
  14. package/dist/chunks/rivus-deployment-cli-process.d.ts +127 -455
  15. package/dist/chunks/rivus-home-deployment-env.js +1342 -1781
  16. package/dist/chunks/rivus-node-entrypoint.js +4574 -4199
  17. package/dist/index.d.ts +23 -11
  18. package/dist/mcp.d.ts +10 -9
  19. package/dist/mcp.js +43 -43
  20. package/package.json +18 -11
  21. package/templates/a-share-briefing-analysis.mjs +32 -34
  22. package/templates/a-share-briefing-renderer.mjs +175 -186
  23. package/templates/a-share-index-evidence.mjs +50 -54
  24. package/templates/a-share-market-briefing.mjs +37 -39
  25. package/templates/a-share-overseas-evidence.mjs +35 -39
  26. package/templates/a-share-policy-evidence.mjs +90 -96
  27. package/templates/a-share-sector-evidence.mjs +32 -35
  28. package/templates/acp-stdio-proxy.mjs +21 -22
  29. package/templates/current-weather.mjs +56 -58
  30. package/templates/html-drive-tools.mjs +130 -141
  31. package/templates/rivus-agents.plugin.mjs +55 -57
package/dist/index.d.ts CHANGED
@@ -1,13 +1,23 @@
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";
2
- import { Effect } from "effect";
3
- import { RivusMemoryScope, RivusResolvedToolDescriptor } from "@rivus/runtime";
1
+ import { a as RivusHome, i as RivusHomeApi, n as RivusDeploymentBootstrapFactory, r as RivusDaemonEnv } from "./chunks/rivus-deployment-cli-process.js";
2
+ import { A as AutomationLineChart, C as AutomationPresentationSection, D as AutomationPresentationTableColumn, E as AutomationPresentationTableCell, O as AutomationPresentationTrend, S as AutomationPresentationKind, T as AutomationPresentationTable, a as RivusAutomationInput, b as AutomationPresentation, c as RivusAutomationTickContext, d as RivusPluginRegistry, f as RIVUS_PLUGIN_API_VERSION, g as RivusAgentProfile, h as RivusAgentDeployment, k as readAutomationPresentation, l as RivusPlugin, m as ResolvedRivusAgentDefinition, o as RivusAutomationOutput, p as RivusPluginManifest, s as RivusAutomationTemplate, u as RivusPluginCatalog, v as RivusAutomationRetryPolicy, w as AutomationPresentationSource, x as AutomationPresentationItem } from "./chunks/public.js";
3
+ import { Context, Effect, Layer, Schema } from "effect";
4
+ import "@rivus/runtime";
5
+ import { createPiModelRuntime } from "@rivus/runtime/pi";
6
+ import { ProcessLockPlatform } from "@rivus/agent-kit-collab/process-lock";
7
+ //#region src/automation/domain/automation-occurrence/errors/rivus-automation-failure.d.ts
8
+ export declare class RivusAutomationFailure extends Error {
9
+ readonly name = "RivusAutomationFailure";
10
+ readonly code: string;
11
+ constructor(code: string, message?: string, options?: ErrorOptions);
12
+ }
13
+ //#endregion
4
14
  //#region src/bootstrap/catalog/rivus-agent-catalog.d.ts
5
15
  export declare function createRivusPluginCatalog(): RivusPluginCatalog;
6
16
  export declare function resolveRivusAgentDefinition(catalog: RivusPluginCatalog, deployment: RivusAgentDeployment, options?: {
7
17
  readonly backgroundSessions?: boolean;
8
18
  }): ResolvedRivusAgentDefinition;
9
19
  //#endregion
10
- //#region src/adapters/cli/model/rivus-model-cli-protocol.d.ts
20
+ //#region src/model-management/infra/adapters/cli/rivus-model-cli-protocol.d.ts
11
21
  type RivusModelCliCommand = RivusModelCliStatusCommand | RivusModelCliSetCommand | RivusModelCliRollbackCommand;
12
22
  interface RivusModelCliStatusCommand {
13
23
  readonly json: true;
@@ -32,12 +42,12 @@ interface RivusModelCliRollbackCommand {
32
42
  }
33
43
  type RivusModelCliResponse = Record<string, unknown>;
34
44
  //#endregion
35
- //#region src/adapters/cli/model/rivus-model-management-socket-client.d.ts
45
+ //#region src/model-management/infra/adapters/cli/rivus-model-management-socket-client.d.ts
36
46
  interface RivusModelManagementSocketClient {
37
47
  execute(command: RivusModelCliCommand): Promise<RivusModelCliResponse>;
38
48
  }
39
49
  //#endregion
40
- //#region src/platform/daemon/process/rivus-daemon-shutdown-controller.d.ts
50
+ //#region src/bootstrap/daemon/process/rivus-daemon-shutdown-controller.d.ts
41
51
  type RivusDaemonShutdownSignal = "SIGINT" | "SIGTERM";
42
52
  interface RivusDaemonSignalSource {
43
53
  on(signal: RivusDaemonShutdownSignal, listener: () => void): void;
@@ -66,7 +76,7 @@ interface RivusDaemonCliOptions {
66
76
  };
67
77
  }
68
78
  //#endregion
69
- //#region src/bootstrap/upgrade/upgrade-home.d.ts
79
+ //#region src/upgrade/application/use-cases/run-upgrade.d.ts
70
80
  interface UpgradeResult {
71
81
  readonly status: "upgraded" | "current";
72
82
  readonly version: string;
@@ -78,13 +88,15 @@ interface UpgradeResult {
78
88
  readonly backup?: string;
79
89
  readonly operationId?: string;
80
90
  }
91
+ //#endregion
92
+ //#region src/bootstrap/upgrade/upgrade-home.d.ts
81
93
  interface UpgradeHomeInvocation {
82
94
  readonly home: RivusHome;
83
95
  readonly userHome: string;
84
96
  readonly platform: NodeJS.Platform;
85
97
  readonly env: Readonly<Record<string, string | undefined>>;
86
- readonly pid: number;
87
- readonly isProcessAlive: (pid: number) => boolean;
98
+ /** Platform that holds the upgrade process lock; the Node entrypoint creates it. */
99
+ readonly lockPlatform: ProcessLockPlatform;
88
100
  readonly signal?: AbortSignal;
89
101
  readonly progress: (phase: string, detail: string) => void;
90
102
  }
@@ -102,7 +114,7 @@ interface RivusCliOptions extends RivusDaemonCliOptions {
102
114
  readonly pid: number;
103
115
  readonly executable: string;
104
116
  };
105
- readonly upgradeHost?: Pick<UpgradeHomeInvocation, "pid" | "platform" | "isProcessAlive">;
117
+ readonly upgradeHost?: Pick<UpgradeHomeInvocation, "lockPlatform" | "platform">;
106
118
  readonly upgradeRunner?: (input: UpgradeHomeInvocation) => Promise<UpgradeResult>;
107
119
  }
108
120
  //#endregion
@@ -119,5 +131,5 @@ interface RivusNodeEntrypointOptions {
119
131
  }
120
132
  export declare function runRivusNodeEntrypoint(options: RivusNodeEntrypointOptions): Effect.Effect<number>;
121
133
  //#endregion
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 };
134
+ 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, type RivusAutomationInput, type RivusAutomationOutput, type RivusAutomationRetryPolicy, type RivusAutomationTemplate, type RivusAutomationTickContext, type RivusPlugin, type RivusPluginManifest, type RivusPluginRegistry, readAutomationPresentation };
123
135
  export {};
package/dist/mcp.d.ts CHANGED
@@ -1,13 +1,6 @@
1
+ import "./chunks/public.js";
1
2
  import { Readable, Writable } from "node:stream";
2
- //#region src/bootstrap/mcp/rivus-mcp-entrypoint.d.ts
3
- interface RunRivusHostToolMcpServerEnv {
4
- readonly fetch?: typeof fetch;
5
- readonly input?: Readable;
6
- readonly output?: Writable;
7
- }
8
- export declare function runRivusHostToolMcpServer(options?: RunRivusHostToolMcpServerEnv): Promise<void>;
9
- //#endregion
10
- //#region src/adapters/mcp/host-tool/host-tool-mcp-server.d.ts
3
+ //#region src/agent-host/infra/adapters/host-tool-mcp-server.d.ts
11
4
  export declare const RIVUS_HOST_TOOL_MCP_SERVER_NAME = "rivus-host-tools";
12
5
  export declare const RIVUS_HOST_TOOL_MCP_SERVER_VERSION = "1.0.0";
13
6
  interface RivusHostToolMcpServerOptions {
@@ -28,5 +21,13 @@ export declare class RivusHostToolMcpError extends Error {
28
21
  }
29
22
  export declare function createRivusHostToolMcpServer(options: RivusHostToolMcpServerOptions): RivusHostToolMcpServer;
30
23
  //#endregion
24
+ //#region src/bootstrap/mcp/rivus-mcp-entrypoint.d.ts
25
+ interface RunRivusHostToolMcpServerEnv {
26
+ readonly fetch?: typeof fetch;
27
+ readonly input?: Readable;
28
+ readonly output?: Writable;
29
+ }
30
+ export declare function runRivusHostToolMcpServer(options?: RunRivusHostToolMcpServerEnv): Promise<void>;
31
+ //#endregion
31
32
  export type { RivusHostToolMcpServer, RivusHostToolMcpServerOptions };
32
33
  export {};
package/dist/mcp.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  import { pathToFileURL } from "node:url";
3
- //#region src/adapters/mcp/host-tool/host-tool-mcp-server.ts
3
+ //#region src/agent-host/infra/adapters/host-tool-mcp-server.ts
4
4
  const requestSchema = Schema.Struct({
5
5
  jsonrpc: Schema.Literal("2.0"),
6
6
  id: Schema.NullOr(Schema.Union([Schema.String, Schema.Number])),
@@ -23,23 +23,26 @@ const RIVUS_HOST_TOOL_MCP_SERVER_VERSION = "1.0.0";
23
23
  var RivusHostToolMcpError = class extends Error {
24
24
  name = "RivusHostToolMcpError";
25
25
  };
26
- function createRivusHostToolMcpServer(options) {
27
- const input = options.input ?? process.stdin;
28
- const output = options.output ?? process.stdout;
29
- const fetchImplementation = options.fetch ?? fetch;
30
- const serverInfo = {
31
- name: options.serverName ?? "rivus-host-tools",
32
- version: options.serverVersion ?? "1.0.0"
33
- };
34
- return { run: () => runMcpServer({
35
- capability: options.capability,
36
- controlToken: options.controlToken,
37
- controlUrl: options.controlUrl,
38
- fetchImplementation,
39
- input,
40
- output,
41
- serverInfo
42
- }) };
26
+ function parseMcpMessage(payload) {
27
+ try {
28
+ return JSON.parse(payload);
29
+ } catch {
30
+ throw new RivusHostToolMcpError("invalid MCP JSON payload");
31
+ }
32
+ }
33
+ async function* readMcpMessages(input) {
34
+ let buffer = "";
35
+ for await (const chunk of input) {
36
+ buffer += chunk.toString("utf8");
37
+ let newlineIndex = buffer.indexOf("\n");
38
+ while (newlineIndex >= 0) {
39
+ const line = buffer.slice(0, newlineIndex).replace(/\r$/, "");
40
+ buffer = buffer.slice(newlineIndex + 1);
41
+ if (line.trim() !== "") yield parseMcpMessage(line);
42
+ newlineIndex = buffer.indexOf("\n");
43
+ }
44
+ }
45
+ if (buffer.trim() !== "") yield parseMcpMessage(buffer.trim());
43
46
  }
44
47
  async function runMcpServer(options) {
45
48
  const send = (message) => {
@@ -138,29 +141,31 @@ async function runMcpServer(options) {
138
141
  }
139
142
  }
140
143
  }
141
- async function* readMcpMessages(input) {
142
- let buffer = "";
143
- for await (const chunk of input) {
144
- buffer += chunk.toString("utf8");
145
- let newlineIndex = buffer.indexOf("\n");
146
- while (newlineIndex >= 0) {
147
- const line = buffer.slice(0, newlineIndex).replace(/\r$/, "");
148
- buffer = buffer.slice(newlineIndex + 1);
149
- if (line.trim() !== "") yield parseMcpMessage(line);
150
- newlineIndex = buffer.indexOf("\n");
151
- }
152
- }
153
- if (buffer.trim() !== "") yield parseMcpMessage(buffer.trim());
154
- }
155
- function parseMcpMessage(payload) {
156
- try {
157
- return JSON.parse(payload);
158
- } catch {
159
- throw new RivusHostToolMcpError("invalid MCP JSON payload");
160
- }
144
+ function createRivusHostToolMcpServer(options) {
145
+ const input = options.input ?? process.stdin;
146
+ const output = options.output ?? process.stdout;
147
+ const fetchImplementation = options.fetch ?? fetch;
148
+ const serverInfo = {
149
+ name: options.serverName ?? "rivus-host-tools",
150
+ version: options.serverVersion ?? "1.0.0"
151
+ };
152
+ return { run: () => runMcpServer({
153
+ capability: options.capability,
154
+ controlToken: options.controlToken,
155
+ controlUrl: options.controlUrl,
156
+ fetchImplementation,
157
+ input,
158
+ output,
159
+ serverInfo
160
+ }) };
161
161
  }
162
162
  //#endregion
163
163
  //#region src/bootstrap/mcp/rivus-mcp-entrypoint.ts
164
+ function requireEnv(name) {
165
+ const value = process.env[name]?.trim();
166
+ if (!value) throw new RivusHostToolMcpError(`${name} is required`);
167
+ return value;
168
+ }
164
169
  async function runRivusHostToolMcpServer(options = {}) {
165
170
  const controlUrl = requireEnv("RIVUS_MCP_CONTROL_URL");
166
171
  const controlToken = requireEnv("RIVUS_MCP_CONTROL_TOKEN");
@@ -173,11 +178,6 @@ async function runRivusHostToolMcpServer(options = {}) {
173
178
  ...options.output ? { output: options.output } : {}
174
179
  }).run();
175
180
  }
176
- function requireEnv(name) {
177
- const value = process.env[name]?.trim();
178
- if (!value) throw new RivusHostToolMcpError(`${name} is required`);
179
- return value;
180
- }
181
181
  //#endregion
182
182
  //#region src/mcp.ts
183
183
  if (pathToFileURL(process.argv[1] ?? "").href === import.meta.url) await runRivusHostToolMcpServer();
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@rivus/gateway",
3
- "version": "0.21.2",
3
+ "version": "0.22.1",
4
4
  "description": "Message gateway, channels, host binding, automation, and daemon assembly for Rivus.",
5
5
  "type": "module",
6
+ "sideEffects": [
7
+ "./dist/cli.js",
8
+ "./dist/mcp.js"
9
+ ],
6
10
  "license": "GPL-3.0-only",
7
11
  "engines": {
8
12
  "node": "^24.11.0"
@@ -57,28 +61,31 @@
57
61
  "@agentclientprotocol/sdk": "1.5.1",
58
62
  "@larksuiteoapi/node-sdk": "1.74.0",
59
63
  "@resvg/resvg-js": "2.6.2",
60
- "@rivus/platform": "0.21.2",
61
- "@rivus/runtime": "0.21.2",
64
+ "@rivus/agent-kit": "0.24.0",
65
+ "@rivus/agent-kit-collab": "0.24.0",
66
+ "@rivus/platform": "0.22.1",
67
+ "@rivus/runtime": "0.22.1",
62
68
  "axios": "1.20.0",
63
- "effect": "^4.0.0",
64
- "get-east-asian-width": "1.6.0",
65
- "marked": "18.0.14",
66
- "semver": "7.8.0",
69
+ "effect": "4.1.1",
70
+ "get-east-asian-width": "1.7.0",
71
+ "marked": "18.1.3",
72
+ "semver": "7.8.5",
67
73
  "yaml": "2.9.1"
68
74
  },
69
75
  "publishConfig": {
70
76
  "access": "public"
71
77
  },
72
78
  "devDependencies": {
79
+ "@rivus/utils": "0.21.2",
73
80
  "@types/node": "24.19.2",
74
- "@types/semver": "7.7.1",
81
+ "@types/semver": "7.8.0",
75
82
  "@typescript/native": "npm:typescript@7.0.2",
76
- "@vitest/coverage-v8": "5.0.1",
83
+ "@vitest/coverage-v8": "5.0.5",
77
84
  "tar": "7.5.22",
78
85
  "typescript": "6.0.3",
79
86
  "unbzip2-stream": "1.4.3",
80
- "vite": "npm:@voidzero-dev/vite-plus-core@1.0.0",
81
- "vite-plus": "1.0.0"
87
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.3.0",
88
+ "vite-plus": "1.3.0"
82
89
  },
83
90
  "scripts": {
84
91
  "build": "node ../../scripts/generate-gateway-release-descriptor.mjs && vp pack",
@@ -1,14 +1,28 @@
1
- export function analyzeAShareBriefing({ overseasEvidence, quotes, sectorEvidence }) {
2
- return Object.freeze({
3
- index: Object.freeze(analyzeIndexStructure(quotes)),
4
- overseas: Object.freeze(analyzeOverseasStructure(overseasEvidence)),
5
- sector: analyzeSectorStructure(sectorEvidence),
6
- turnover: quotes
7
- .filter(({ symbol }) => symbol === "sh000001" || symbol === "sz399001")
8
- .reduce((sum, quote) => sum + quote.amount, 0)
9
- });
1
+ function analyzeSectorStructure(evidence) {
2
+ if (!evidence) {
3
+ return "行业数据不可用,不补写行业主线判断。";
4
+ }
5
+ const leaders = evidence.leaders
6
+ .slice(0, 2)
7
+ .map(({ name }) => name)
8
+ .join("、");
9
+ const laggards = evidence.laggards
10
+ .slice(0, 2)
11
+ .map(({ name }) => name)
12
+ .join("、");
13
+ return `领涨端集中在${leaders},领跌端集中在${laggards};这只描述行业横截面强弱,不构成市场涨跌的驱动归因。`;
14
+ }
15
+
16
+ function readDirection(quotes) {
17
+ const positive = quotes.filter(({ changePercent }) => changePercent > 0).length;
18
+ const negative = quotes.filter(({ changePercent }) => changePercent < 0).length;
19
+ const flat = quotes.length - positive - negative;
20
+ return `${positive} 涨 ${negative} 跌${flat > 0 ? ` ${flat} 平` : ""}`;
10
21
  }
11
22
 
23
+ function formatPercentagePoint(value) {
24
+ return `${value.toFixed(2)} 个百分点`;
25
+ }
12
26
  function analyzeIndexStructure(quotes) {
13
27
  const direction = readDirection(quotes);
14
28
  const ranked = [...quotes].sort((left, right) => right.changePercent - left.changePercent);
@@ -67,29 +81,13 @@ function analyzeOverseasStructure(evidence) {
67
81
  : "纳斯达克与标普 500 表现接近,海外科技风格未显示明显偏离。";
68
82
  return { conclusion, direction, inference: `${conclusion}。${relative}` };
69
83
  }
70
-
71
- function analyzeSectorStructure(evidence) {
72
- if (!evidence) {
73
- return "行业数据不可用,不补写行业主线判断。";
74
- }
75
- const leaders = evidence.leaders
76
- .slice(0, 2)
77
- .map(({ name }) => name)
78
- .join("、");
79
- const laggards = evidence.laggards
80
- .slice(0, 2)
81
- .map(({ name }) => name)
82
- .join("、");
83
- return `领涨端集中在${leaders},领跌端集中在${laggards};这只描述行业横截面强弱,不构成市场涨跌的驱动归因。`;
84
- }
85
-
86
- function readDirection(quotes) {
87
- const positive = quotes.filter(({ changePercent }) => changePercent > 0).length;
88
- const negative = quotes.filter(({ changePercent }) => changePercent < 0).length;
89
- const flat = quotes.length - positive - negative;
90
- return `${positive} 涨 ${negative} 跌${flat > 0 ? ` ${flat} 平` : ""}`;
91
- }
92
-
93
- function formatPercentagePoint(value) {
94
- return `${value.toFixed(2)} 个百分点`;
84
+ export function analyzeAShareBriefing({ overseasEvidence, quotes, sectorEvidence }) {
85
+ return Object.freeze({
86
+ index: Object.freeze(analyzeIndexStructure(quotes)),
87
+ overseas: Object.freeze(analyzeOverseasStructure(overseasEvidence)),
88
+ sector: analyzeSectorStructure(sectorEvidence),
89
+ turnover: quotes
90
+ .filter(({ symbol }) => symbol === "sh000001" || symbol === "sz399001")
91
+ .reduce((sum, quote) => sum + quote.amount, 0)
92
+ });
95
93
  }