@rivus/gateway 0.22.0 → 0.22.2
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/bootstrap/feishu.d.ts +3 -6
- package/dist/bootstrap/feishu.js +1889 -1931
- package/dist/chunks/feishu-receive-message.js +1 -1
- package/dist/chunks/herdr-feishu-runtime.js +65 -65
- package/dist/chunks/rivus-deployment-cli-process.d.ts +4 -1
- package/dist/chunks/rivus-home-deployment-env.js +2 -2
- package/dist/chunks/rivus-node-entrypoint.js +117 -44
- package/dist/index.d.ts +1 -1
- package/package.json +8 -5
|
@@ -34,7 +34,7 @@ const messageFields = {
|
|
|
34
34
|
chat_type: Schema.optional(Schema.String),
|
|
35
35
|
create_time: Schema.optional(Schema.String),
|
|
36
36
|
mentions: Schema.optional(Schema.Array(Schema.Struct({
|
|
37
|
-
id: Schema.optional(Schema.
|
|
37
|
+
id: Schema.optional(Schema.Struct({ open_id: Schema.optional(Schema.String) })),
|
|
38
38
|
key: Schema.optional(Schema.String),
|
|
39
39
|
name: Schema.optional(Schema.String)
|
|
40
40
|
}))),
|
|
@@ -5,8 +5,8 @@ import { isAbsolute, join, resolve } from "node:path";
|
|
|
5
5
|
import { chmod, lstat, mkdir, open, readFile, readdir } from "node:fs/promises";
|
|
6
6
|
import { isNodeErrorWithCode } from "@rivus/platform/filesystem";
|
|
7
7
|
import { createConnection } from "node:net";
|
|
8
|
-
import { acquireProcessLock } from "@rivus/agent-kit-collab/process-lock";
|
|
9
8
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
9
|
+
import { acquireProcessLock } from "@rivus/agent-kit-collab/process-lock";
|
|
10
10
|
import { stripVTControlCharacters } from "node:util";
|
|
11
11
|
import { Worker } from "node:worker_threads";
|
|
12
12
|
import { eastAsianWidth } from "get-east-asian-width";
|
|
@@ -70,70 +70,6 @@ var ConversationStateStore = class extends Context.Service()("@rivus/gateway/ter
|
|
|
70
70
|
var TerminalMessageClaims = class extends Context.Service()("@rivus/gateway/terminal-session/TerminalMessageClaims") {};
|
|
71
71
|
var TerminalMessageClaimLookup = class extends Context.Service()("@rivus/gateway/terminal-session/TerminalMessageClaimLookup") {};
|
|
72
72
|
//#endregion
|
|
73
|
-
//#region src/terminal-session/application/services/terminal-session-bindings.ts
|
|
74
|
-
var TerminalBindingPersistenceError = class extends Error {
|
|
75
|
-
constructor(cause) {
|
|
76
|
-
super("Terminal binding snapshot could not be saved", { cause });
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
function createTerminalSessionBindings(options) {
|
|
80
|
-
let bindings = new Map((options.store?.initial ?? []).map((entry) => [entry.handle, entry]));
|
|
81
|
-
const serial = Semaphore.makeUnsafe(1);
|
|
82
|
-
const commit = (candidate) => Effect.gen(function* () {
|
|
83
|
-
if (options.store) yield* options.store.save([...candidate.values()]).pipe(Effect.mapError((cause) => new TerminalBindingPersistenceError(cause)));
|
|
84
|
-
bindings = candidate;
|
|
85
|
-
});
|
|
86
|
-
const insert = (candidate, entry) => {
|
|
87
|
-
candidate.delete(entry.handle);
|
|
88
|
-
candidate.set(entry.handle, entry);
|
|
89
|
-
if (candidate.size > 1e3) candidate.delete(candidate.keys().next().value);
|
|
90
|
-
return entry;
|
|
91
|
-
};
|
|
92
|
-
const fresh = (candidate, message, agent, expires) => {
|
|
93
|
-
let handle = options.newHandle();
|
|
94
|
-
while (candidate.has(handle)) handle = options.newHandle();
|
|
95
|
-
return insert(candidate, {
|
|
96
|
-
handle,
|
|
97
|
-
actorId: message.actorId,
|
|
98
|
-
chatId: message.chatId,
|
|
99
|
-
agent,
|
|
100
|
-
...expires === void 0 ? {} : { expires }
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
return {
|
|
104
|
-
lookup: (handle, message) => serial.withPermits(1)(Effect.uninterruptible(Effect.gen(function* () {
|
|
105
|
-
const binding = bindings.get(handle);
|
|
106
|
-
if (!binding) return { kind: "missing" };
|
|
107
|
-
if (binding.actorId !== message.actorId || binding.chatId !== message.chatId) return { kind: "unauthorized" };
|
|
108
|
-
const candidate = new Map(bindings);
|
|
109
|
-
insert(candidate, binding);
|
|
110
|
-
yield* commit(candidate);
|
|
111
|
-
return {
|
|
112
|
-
kind: "found",
|
|
113
|
-
binding
|
|
114
|
-
};
|
|
115
|
-
}))),
|
|
116
|
-
selections: (message, agents) => serial.withPermits(1)(Effect.uninterruptible(Effect.gen(function* () {
|
|
117
|
-
const candidate = new Map(bindings);
|
|
118
|
-
const selected = agents.map((agent) => {
|
|
119
|
-
const existing = [...candidate.values()].find((entry) => entry.expires === void 0 && entry.actorId === message.actorId && entry.chatId === message.chatId && entry.agent.session === agent.session && entry.agent.pane === agent.pane && entry.agent.identity === agent.identity);
|
|
120
|
-
return existing ? insert(candidate, {
|
|
121
|
-
...existing,
|
|
122
|
-
agent
|
|
123
|
-
}) : fresh(candidate, message, agent);
|
|
124
|
-
});
|
|
125
|
-
if (agents.length) yield* commit(candidate);
|
|
126
|
-
return selected;
|
|
127
|
-
}))),
|
|
128
|
-
form: (message, agent, expires) => serial.withPermits(1)(Effect.uninterruptible(Effect.gen(function* () {
|
|
129
|
-
const candidate = new Map(bindings);
|
|
130
|
-
const binding = fresh(candidate, message, agent, expires);
|
|
131
|
-
yield* commit(candidate);
|
|
132
|
-
return binding;
|
|
133
|
-
})))
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
//#endregion
|
|
137
73
|
//#region src/terminal-session/application/services/conversation-mode.ts
|
|
138
74
|
const stateKey = (actorId, chatId) => `${actorId}\u0000${chatId}`;
|
|
139
75
|
/**
|
|
@@ -313,6 +249,70 @@ function createConversationMode(options) {
|
|
|
313
249
|
};
|
|
314
250
|
}
|
|
315
251
|
//#endregion
|
|
252
|
+
//#region src/terminal-session/application/services/terminal-session-bindings.ts
|
|
253
|
+
var TerminalBindingPersistenceError = class extends Error {
|
|
254
|
+
constructor(cause) {
|
|
255
|
+
super("Terminal binding snapshot could not be saved", { cause });
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
function createTerminalSessionBindings(options) {
|
|
259
|
+
let bindings = new Map((options.store?.initial ?? []).map((entry) => [entry.handle, entry]));
|
|
260
|
+
const serial = Semaphore.makeUnsafe(1);
|
|
261
|
+
const commit = (candidate) => Effect.gen(function* () {
|
|
262
|
+
if (options.store) yield* options.store.save([...candidate.values()]).pipe(Effect.mapError((cause) => new TerminalBindingPersistenceError(cause)));
|
|
263
|
+
bindings = candidate;
|
|
264
|
+
});
|
|
265
|
+
const insert = (candidate, entry) => {
|
|
266
|
+
candidate.delete(entry.handle);
|
|
267
|
+
candidate.set(entry.handle, entry);
|
|
268
|
+
if (candidate.size > 1e3) candidate.delete(candidate.keys().next().value);
|
|
269
|
+
return entry;
|
|
270
|
+
};
|
|
271
|
+
const fresh = (candidate, message, agent, expires) => {
|
|
272
|
+
let handle = options.newHandle();
|
|
273
|
+
while (candidate.has(handle)) handle = options.newHandle();
|
|
274
|
+
return insert(candidate, {
|
|
275
|
+
handle,
|
|
276
|
+
actorId: message.actorId,
|
|
277
|
+
chatId: message.chatId,
|
|
278
|
+
agent,
|
|
279
|
+
...expires === void 0 ? {} : { expires }
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
return {
|
|
283
|
+
lookup: (handle, message) => serial.withPermits(1)(Effect.uninterruptible(Effect.gen(function* () {
|
|
284
|
+
const binding = bindings.get(handle);
|
|
285
|
+
if (!binding) return { kind: "missing" };
|
|
286
|
+
if (binding.actorId !== message.actorId || binding.chatId !== message.chatId) return { kind: "unauthorized" };
|
|
287
|
+
const candidate = new Map(bindings);
|
|
288
|
+
insert(candidate, binding);
|
|
289
|
+
yield* commit(candidate);
|
|
290
|
+
return {
|
|
291
|
+
kind: "found",
|
|
292
|
+
binding
|
|
293
|
+
};
|
|
294
|
+
}))),
|
|
295
|
+
selections: (message, agents) => serial.withPermits(1)(Effect.uninterruptible(Effect.gen(function* () {
|
|
296
|
+
const candidate = new Map(bindings);
|
|
297
|
+
const selected = agents.map((agent) => {
|
|
298
|
+
const existing = [...candidate.values()].find((entry) => entry.expires === void 0 && entry.actorId === message.actorId && entry.chatId === message.chatId && entry.agent.session === agent.session && entry.agent.pane === agent.pane && entry.agent.identity === agent.identity);
|
|
299
|
+
return existing ? insert(candidate, {
|
|
300
|
+
...existing,
|
|
301
|
+
agent
|
|
302
|
+
}) : fresh(candidate, message, agent);
|
|
303
|
+
});
|
|
304
|
+
if (agents.length) yield* commit(candidate);
|
|
305
|
+
return selected;
|
|
306
|
+
}))),
|
|
307
|
+
form: (message, agent, expires) => serial.withPermits(1)(Effect.uninterruptible(Effect.gen(function* () {
|
|
308
|
+
const candidate = new Map(bindings);
|
|
309
|
+
const binding = fresh(candidate, message, agent, expires);
|
|
310
|
+
yield* commit(candidate);
|
|
311
|
+
return binding;
|
|
312
|
+
})))
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
//#endregion
|
|
316
316
|
//#region src/terminal-session/domain/bridge/value-objects/terminal-bridge-model.ts
|
|
317
317
|
var TerminalTargetChangedError = class extends Error {
|
|
318
318
|
constructor() {
|
|
@@ -435,7 +435,10 @@ interface FeishuReceiveMessagePayload {
|
|
|
435
435
|
readonly root_id?: string;
|
|
436
436
|
readonly message_type: string;
|
|
437
437
|
readonly mentions?: ReadonlyArray<{
|
|
438
|
-
readonly id?:
|
|
438
|
+
readonly id?: {
|
|
439
|
+
readonly open_id?: string;
|
|
440
|
+
readonly [key: string]: unknown;
|
|
441
|
+
};
|
|
439
442
|
readonly key?: string;
|
|
440
443
|
readonly name?: string;
|
|
441
444
|
}>;
|
|
@@ -5,8 +5,8 @@ import { basename, delimiter, dirname, isAbsolute, join, relative, resolve } fro
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { access, constants, cp, mkdir, readFile, readdir, rename, rm, stat } from "node:fs/promises";
|
|
7
7
|
import { isNodeErrorWithCode, isPathWithin } from "@rivus/platform/filesystem";
|
|
8
|
-
import { acquireProcessLock } from "@rivus/agent-kit-collab/process-lock";
|
|
9
8
|
import { createHash, randomUUID } from "node:crypto";
|
|
9
|
+
import { acquireProcessLock } from "@rivus/agent-kit-collab/process-lock";
|
|
10
10
|
import { spawn } from "node:child_process";
|
|
11
11
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
12
12
|
//#region src/lib/deep-freeze.ts
|
|
@@ -741,7 +741,7 @@ const gatewayAudioTranscriberAssetDirectory = fileURLToPath(new URL("assets/audi
|
|
|
741
741
|
//#endregion
|
|
742
742
|
//#region src/home/infra/adapters/project/release-descriptor.ts
|
|
743
743
|
const RIVUS_RELEASE_DESCRIPTOR = Object.freeze({
|
|
744
|
-
version: "0.22.
|
|
744
|
+
version: "0.22.2",
|
|
745
745
|
dependencies: Object.freeze({
|
|
746
746
|
"@earendil-works/pi-coding-agent": "0.84.4",
|
|
747
747
|
"@larksuiteoapi/node-sdk": "1.74.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as loadMergedLocalEnvFile, C as loadRivusDeploymentManifest, D as gatewayPackageManifestPath, E as gatewayPackageDirectory, F as validateRivusDeploymentManifest, I as validateRivusProjectSpaceDeployment, L as createBackgroundSessionToolContracts, M as resolveFeishuEndpointCredentials, N as InvalidRivusProjectSpace, P as parseRivusDeploymentManifest, R as narrowBackgroundSessionDefinition, S as renderRivusModelCliHelp, T as gatewayAudioTranscriberAssetDirectory, b as parseRivusModelCliArguments, c as readRivusAudioStatus, d as invokeRuntimeControl, g as createRivusModelManagementWireRequest, i as runRivusAudioProcess, j as resolveAcpRuntimeEnvironment, k as gatewayTemplateDirectory, l as createRuntimeCache, n as withoutRivusHomeDeployment, o as installRivusAudioTranscriber, p as parseRivusModelManagementEnabled, r as runRivusAudioPassthroughProcess, s as readRivusAudioInstalledRelease, t as RIVUS_HOME_DEPLOYMENT_ENV, u as disposeRuntimeCacheEntries, w as RIVUS_RELEASE_DESCRIPTOR, x as renderRivusModelCliArgumentError, z as deepFreeze } from "./rivus-home-deployment-env.js";
|
|
2
2
|
import { t as decodeFeishuReceiveMessage } from "./feishu-receive-message.js";
|
|
3
|
-
import { createRequire, findPackageJSON } from "node:module";
|
|
3
|
+
import { createRequire, findPackageJSON, registerHooks } from "node:module";
|
|
4
4
|
import { createSha256Digest, createStableId } from "@rivus/platform/identity";
|
|
5
5
|
import { Cause, Context, Deferred, Effect, Exit, Layer, Option, Result, Schema, SchemaIssue, Semaphore } from "effect";
|
|
6
6
|
import { RIVUS_MEMORY_TOOL_PLUGIN_ID, RIVUS_RUNTIME_TOOL_IDS, createRivusMemoryToolContract, isRivusRuntimeToolId } from "@rivus/runtime";
|
|
@@ -11,16 +11,16 @@ import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep
|
|
|
11
11
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
12
12
|
import { createNodePlatform } from "@rivus/agent-kit/node";
|
|
13
13
|
import { access, chmod, constants, copyFile, link, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, rmdir, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
14
|
+
import { compare, minVersion, parse, satisfies, valid } from "semver";
|
|
14
15
|
import { assertPathWithin, isNodeErrorWithCode, isPathWithin } from "@rivus/platform/filesystem";
|
|
15
16
|
import { createConnection } from "node:net";
|
|
16
|
-
import { acquireProcessLock } from "@rivus/agent-kit-collab/process-lock";
|
|
17
17
|
import { randomUUID } from "node:crypto";
|
|
18
|
-
import {
|
|
18
|
+
import { acquireProcessLock } from "@rivus/agent-kit-collab/process-lock";
|
|
19
|
+
import { constants as constants$1, realpathSync } from "node:fs";
|
|
19
20
|
import { spawn } from "node:child_process";
|
|
20
21
|
import { isDeepStrictEqual } from "node:util";
|
|
21
22
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
22
|
-
import { parse, stringify } from "yaml";
|
|
23
|
-
import { compare, minVersion, parse as parse$1, satisfies, valid } from "semver";
|
|
23
|
+
import { parse as parse$1, stringify } from "yaml";
|
|
24
24
|
//#region src/agent-catalog/domain/plugin/value-objects/rivus-plugin.ts
|
|
25
25
|
const RIVUS_PLUGIN_API_VERSION = "1";
|
|
26
26
|
var InvalidRivusPlugin = class extends Error {
|
|
@@ -1200,16 +1200,13 @@ function loadRivusHome(directoryPath) {
|
|
|
1200
1200
|
}
|
|
1201
1201
|
//#endregion
|
|
1202
1202
|
//#region src/home/infra/adapters/doctor/rivus-home-doctor.ts
|
|
1203
|
-
function
|
|
1204
|
-
const
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
name: "node",
|
|
1208
|
-
status: "pass"
|
|
1209
|
-
} : {
|
|
1210
|
-
message: `Node.js 24.11 or newer on major 24 is required; current version is ${version}`,
|
|
1203
|
+
function checkNodeRuntime(version) {
|
|
1204
|
+
const range = "^24.11.0 || ^26.13.1";
|
|
1205
|
+
const supported = satisfies(version, range);
|
|
1206
|
+
return {
|
|
1211
1207
|
name: "node",
|
|
1212
|
-
status: "fail"
|
|
1208
|
+
status: supported ? "pass" : "fail",
|
|
1209
|
+
message: supported ? `Node.js ${version} satisfies ${range}` : `Node.js ${range} is required; current version is ${version}`
|
|
1213
1210
|
};
|
|
1214
1211
|
}
|
|
1215
1212
|
function checkWorkspace(home, findMissingWorkspacePaths) {
|
|
@@ -1239,7 +1236,7 @@ function report(directory, checks) {
|
|
|
1239
1236
|
}
|
|
1240
1237
|
function diagnoseRivusHome(input, options) {
|
|
1241
1238
|
return Effect.gen(function* () {
|
|
1242
|
-
const checks = [
|
|
1239
|
+
const checks = [checkNodeRuntime(input.nodeVersion)];
|
|
1243
1240
|
const loaded = yield* options.load(input.directory).pipe(Effect.result);
|
|
1244
1241
|
if (Result.isFailure(loaded)) {
|
|
1245
1242
|
checks.push({
|
|
@@ -1946,11 +1943,11 @@ function checkModules(home, manifest, resolveModule, resolvePluginModule) {
|
|
|
1946
1943
|
if (result._tag === "Failure") missing.push(`${plugin.module} (${formatError(result.failure)})`);
|
|
1947
1944
|
}
|
|
1948
1945
|
return missing.length === 0 ? {
|
|
1949
|
-
message: "Bootstrap, Plugin, runtime, and Feishu modules resolve
|
|
1946
|
+
message: "Bootstrap, Plugin, runtime, and Feishu modules resolve; run check-config --load-plugins to import them",
|
|
1950
1947
|
name: "modules",
|
|
1951
1948
|
status: "pass"
|
|
1952
1949
|
} : {
|
|
1953
|
-
message: `
|
|
1950
|
+
message: `modules are unavailable: ${missing.join(", ")}`,
|
|
1954
1951
|
name: "modules",
|
|
1955
1952
|
status: "fail"
|
|
1956
1953
|
};
|
|
@@ -2007,19 +2004,6 @@ const REQUIRED_DEPENDENCIES = Object.freeze([
|
|
|
2007
2004
|
"@larksuiteoapi/node-sdk",
|
|
2008
2005
|
"effect"
|
|
2009
2006
|
]);
|
|
2010
|
-
function checkNode(version) {
|
|
2011
|
-
const [major, minor] = version.split(".").map(Number);
|
|
2012
|
-
if (major === 24 && Number.isInteger(minor) && minor >= 11) return {
|
|
2013
|
-
message: `Node.js ${version} satisfies the supported ^24.11 runtime`,
|
|
2014
|
-
name: "node",
|
|
2015
|
-
status: "pass"
|
|
2016
|
-
};
|
|
2017
|
-
return {
|
|
2018
|
-
message: `Node.js 24.11 or newer on major 24 is required; current version is ${version}`,
|
|
2019
|
-
name: "node",
|
|
2020
|
-
status: "fail"
|
|
2021
|
-
};
|
|
2022
|
-
}
|
|
2023
2007
|
function checkManifest(directory) {
|
|
2024
2008
|
return loadRivusDeploymentManifest(join(directory, "rivus.config.json")).pipe(Effect.flatMap((manifest) => Effect.gen(function* () {
|
|
2025
2009
|
validateRivusDeploymentManifest(manifest);
|
|
@@ -2124,7 +2108,7 @@ function toError(error) {
|
|
|
2124
2108
|
function diagnoseRivusProject(options) {
|
|
2125
2109
|
return Effect.gen(function* () {
|
|
2126
2110
|
const directory = resolve(options.directory);
|
|
2127
|
-
const checks = [
|
|
2111
|
+
const checks = [checkNodeRuntime(options.nodeVersion)];
|
|
2128
2112
|
checks.push(yield* Effect.tryPromise({
|
|
2129
2113
|
try: () => checkFiles(directory),
|
|
2130
2114
|
catch: toError
|
|
@@ -2322,6 +2306,95 @@ function isRivusModelManagementEnabled(env) {
|
|
|
2322
2306
|
return value === "1" || value === "true";
|
|
2323
2307
|
}
|
|
2324
2308
|
//#endregion
|
|
2309
|
+
//#region src/bootstrap/cli/release-package-resolution.ts
|
|
2310
|
+
/**
|
|
2311
|
+
* Packages the running release provides to every module in the process. Rivus classes, services and Effect values
|
|
2312
|
+
* are compared by identity (`instanceof`, Context keys, fiber internals), so a process may hold only one copy of each.
|
|
2313
|
+
*/
|
|
2314
|
+
const RELEASE_PACKAGES = [
|
|
2315
|
+
"@rivus/agent",
|
|
2316
|
+
"@rivus/gateway",
|
|
2317
|
+
"@rivus/runtime",
|
|
2318
|
+
"@rivus/platform",
|
|
2319
|
+
"effect"
|
|
2320
|
+
];
|
|
2321
|
+
let installed = false;
|
|
2322
|
+
let resolvingReleasePackage = false;
|
|
2323
|
+
/** Returns the release package a bare specifier names, such as `effect` for `effect/Schema`. */
|
|
2324
|
+
function releasePackageOf(specifier) {
|
|
2325
|
+
return RELEASE_PACKAGES.find((name) => specifier === name || specifier.startsWith(`${name}/`));
|
|
2326
|
+
}
|
|
2327
|
+
function copyOutsideRoots(path, releaseRoots) {
|
|
2328
|
+
const segments = path.split(sep);
|
|
2329
|
+
return RELEASE_PACKAGES.find((name) => {
|
|
2330
|
+
const nameSegments = name.split("/");
|
|
2331
|
+
const found = segments.some((segment, index) => segment === "node_modules" && nameSegments.every((part, offset) => segments[index + 1 + offset] === part) && index + nameSegments.length + 1 < segments.length);
|
|
2332
|
+
const root = releaseRoots.get(name);
|
|
2333
|
+
return found && (root === void 0 || !isPathWithin(root, path));
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2336
|
+
/**
|
|
2337
|
+
* Returns the release package whose installed copy contains `path` when that copy is not the running one. A copy is
|
|
2338
|
+
* recognized by its `node_modules/<name>/` directory, which also matches pnpm's `.pnpm/.../node_modules/<name>/`.
|
|
2339
|
+
* A match is rechecked by real path, because `--preserve-symlinks` reports files of the running copy by link paths
|
|
2340
|
+
* while the running roots are real paths.
|
|
2341
|
+
*/
|
|
2342
|
+
function foreignReleasePackageOf(path, releaseRoots) {
|
|
2343
|
+
if (!copyOutsideRoots(path, releaseRoots)) return;
|
|
2344
|
+
try {
|
|
2345
|
+
return copyOutsideRoots(realpathSync(path), releaseRoots);
|
|
2346
|
+
} catch {
|
|
2347
|
+
return copyOutsideRoots(path, releaseRoots);
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
function releaseRoots() {
|
|
2351
|
+
const roots = /* @__PURE__ */ new Map();
|
|
2352
|
+
for (const name of RELEASE_PACKAGES) try {
|
|
2353
|
+
const manifest = findPackageJSON(name, import.meta.url);
|
|
2354
|
+
if (manifest) roots.set(name, realpathSync(dirname(manifest)));
|
|
2355
|
+
} catch {}
|
|
2356
|
+
return roots;
|
|
2357
|
+
}
|
|
2358
|
+
function describeParent(parentURL) {
|
|
2359
|
+
return parentURL?.startsWith("file:") ? fileURLToPath(parentURL) : parentURL ?? "the process entry";
|
|
2360
|
+
}
|
|
2361
|
+
/**
|
|
2362
|
+
* Makes every module the process loads, including Home Bootstrap modules, Home Plugins and their own dependencies,
|
|
2363
|
+
* use the running release's copy of the release packages, as if they were peer dependencies. A bare import resolves
|
|
2364
|
+
* from this Gateway; a file path into another installed copy fails and names the importing module. `require` callers
|
|
2365
|
+
* receive the same ESM entry as importers, so CommonJS and ESM share one instance.
|
|
2366
|
+
*/
|
|
2367
|
+
function installReleasePackageResolution() {
|
|
2368
|
+
if (installed) return;
|
|
2369
|
+
installed = true;
|
|
2370
|
+
const roots = releaseRoots();
|
|
2371
|
+
const resolve = (specifier, context, nextResolve) => {
|
|
2372
|
+
if (resolvingReleasePackage) return nextResolve(specifier, context);
|
|
2373
|
+
if (releasePackageOf(specifier)) {
|
|
2374
|
+
resolvingReleasePackage = true;
|
|
2375
|
+
try {
|
|
2376
|
+
return {
|
|
2377
|
+
shortCircuit: true,
|
|
2378
|
+
url: import.meta.resolve(specifier)
|
|
2379
|
+
};
|
|
2380
|
+
} catch (error) {
|
|
2381
|
+
throw new Error(`${describeParent(context.parentURL)} imports ${specifier}, which the running Rivus installation does not provide`, { cause: error });
|
|
2382
|
+
} finally {
|
|
2383
|
+
resolvingReleasePackage = false;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
const resolved = nextResolve(specifier, context);
|
|
2387
|
+
const path = resolved.url.startsWith("file:") ? fileURLToPath(resolved.url) : void 0;
|
|
2388
|
+
const foreign = path === void 0 ? void 0 : foreignReleasePackageOf(path, roots);
|
|
2389
|
+
if (foreign) {
|
|
2390
|
+
const root = roots.get(foreign);
|
|
2391
|
+
throw new Error(`${describeParent(context.parentURL)} loads ${foreign} from ${path}, outside the running Rivus installation${root ? ` (${root})` : ""}; import ${foreign} by package name so the running release provides it`);
|
|
2392
|
+
}
|
|
2393
|
+
return resolved;
|
|
2394
|
+
};
|
|
2395
|
+
registerHooks({ resolve });
|
|
2396
|
+
}
|
|
2397
|
+
//#endregion
|
|
2325
2398
|
//#region src/cli/domain/cli/value-objects/rivus-cli-protocol.ts
|
|
2326
2399
|
const RIVUS_CLI_USAGE = `Usage:
|
|
2327
2400
|
rivus setup [directory]
|
|
@@ -3893,9 +3966,12 @@ function checkDeploymentPlugins(input) {
|
|
|
3893
3966
|
}
|
|
3894
3967
|
//#endregion
|
|
3895
3968
|
//#region src/bootstrap/daemon/rivus-daemon-cli.ts
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
return
|
|
3969
|
+
function loadDeploymentFactory(options, specifier) {
|
|
3970
|
+
const loadBootstrap = options.loadBootstrap ?? ((module) => import(module));
|
|
3971
|
+
return Effect.tryPromise({
|
|
3972
|
+
try: () => loadBootstrap(specifier),
|
|
3973
|
+
catch: (error) => error
|
|
3974
|
+
}).pipe(Effect.flatMap(({ createRivusDeploymentAdapters }) => createRivusDeploymentAdapters ? Effect.succeed(createRivusDeploymentAdapters) : Effect.fail(/* @__PURE__ */ new Error("Manifest bootstrap module must export createRivusDeploymentAdapters(context)"))));
|
|
3899
3975
|
}
|
|
3900
3976
|
function runOneShotDaemon(daemon, action) {
|
|
3901
3977
|
return Effect.exit(Effect.suspend(action)).pipe(Effect.flatMap((exit) => daemon.stop().pipe(Effect.flatMap(() => exit._tag === "Success" ? Effect.succeed(exit.value) : Effect.failCause(exit.cause)))));
|
|
@@ -3992,6 +4068,7 @@ function runRivusDaemonCli(options) {
|
|
|
3992
4068
|
try: () => validateRivusDeploymentManifest(manifest),
|
|
3993
4069
|
catch: (error) => error
|
|
3994
4070
|
});
|
|
4071
|
+
if (options.checkPlugins && bootstrapSpecifier) yield* loadDeploymentFactory(options, bootstrapSpecifier);
|
|
3995
4072
|
options.stdout.write(formatRivusDaemonJson(toRedactedDeploymentManifest(manifest)));
|
|
3996
4073
|
return 0;
|
|
3997
4074
|
}
|
|
@@ -3999,13 +4076,9 @@ function runRivusDaemonCli(options) {
|
|
|
3999
4076
|
options.stderr.write(formatRivusDaemonUsageError("Missing --bootstrap <module> or RIVUS_BOOTSTRAP_MODULE"));
|
|
4000
4077
|
return 1;
|
|
4001
4078
|
}
|
|
4002
|
-
const
|
|
4003
|
-
const module = yield* Effect.tryPromise({
|
|
4004
|
-
try: () => loadBootstrap(bootstrapSpecifier),
|
|
4005
|
-
catch: (error) => error
|
|
4006
|
-
});
|
|
4079
|
+
const factory = yield* loadDeploymentFactory(options, bootstrapSpecifier);
|
|
4007
4080
|
const daemon = yield* Effect.tryPromise({
|
|
4008
|
-
try: () =>
|
|
4081
|
+
try: () => createRivusDeploymentCliProcess(factory, {
|
|
4009
4082
|
argv: options.argv,
|
|
4010
4083
|
env,
|
|
4011
4084
|
...parsed.envFilePath ? { envFilePath: parsed.envFilePath } : {},
|
|
@@ -4443,7 +4516,7 @@ async function optionalRecord(path, yaml = false) {
|
|
|
4443
4516
|
throw new Error("The installed consumer configuration cannot be read");
|
|
4444
4517
|
}
|
|
4445
4518
|
try {
|
|
4446
|
-
return record(yaml ? parse(text) : JSON.parse(text));
|
|
4519
|
+
return record(yaml ? parse$1(text) : JSON.parse(text));
|
|
4447
4520
|
} catch {
|
|
4448
4521
|
throw new Error("The installed consumer configuration is invalid");
|
|
4449
4522
|
}
|
|
@@ -4537,7 +4610,7 @@ try { if (image.get_width() !== 1 || image.get_height() !== 1 || !image.get_byte
|
|
|
4537
4610
|
finally { image.free(); }
|
|
4538
4611
|
`;
|
|
4539
4612
|
function stableVersion(value) {
|
|
4540
|
-
const parsed = parse
|
|
4613
|
+
const parsed = parse(value);
|
|
4541
4614
|
return parsed !== null && parsed.version === value && parsed.prerelease.length === 0 && parsed.build.length === 0;
|
|
4542
4615
|
}
|
|
4543
4616
|
async function inspectInstalledRelease(command, cwd, env) {
|
|
@@ -6075,7 +6148,7 @@ function toImportSpecifier(specifier) {
|
|
|
6075
6148
|
return specifier;
|
|
6076
6149
|
}
|
|
6077
6150
|
function runRivusNodeEntrypoint(options) {
|
|
6078
|
-
return runRivusCli({
|
|
6151
|
+
return Effect.sync(installReleasePackageResolution).pipe(Effect.andThen(() => runRivusCli({
|
|
6079
6152
|
argv: options.argv,
|
|
6080
6153
|
changeWorkingDirectory: options.changeWorkingDirectory,
|
|
6081
6154
|
cwd: options.cwd,
|
|
@@ -6100,7 +6173,7 @@ function runRivusNodeEntrypoint(options) {
|
|
|
6100
6173
|
signalSource: options.signalSource,
|
|
6101
6174
|
stderr: options.stderr,
|
|
6102
6175
|
stdout: options.stdout
|
|
6103
|
-
});
|
|
6176
|
+
})));
|
|
6104
6177
|
}
|
|
6105
6178
|
//#endregion
|
|
6106
6179
|
export { RIVUS_PLUGIN_API_VERSION as i, createRivusPluginCatalog as n, resolveRivusAgentDefinition as r, runRivusNodeEntrypoint as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { a as RivusHome, i as RivusHomeApi, n as RivusDeploymentBootstrapFactory
|
|
|
2
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
3
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
4
4
|
import "@rivus/runtime";
|
|
5
|
-
import { ProcessLockPlatform } from "@rivus/agent-kit-collab/process-lock";
|
|
6
5
|
import { createPiModelRuntime } from "@rivus/runtime/pi";
|
|
6
|
+
import { ProcessLockPlatform } from "@rivus/agent-kit-collab/process-lock";
|
|
7
7
|
//#region src/automation/domain/automation-occurrence/errors/rivus-automation-failure.d.ts
|
|
8
8
|
export declare class RivusAutomationFailure extends Error {
|
|
9
9
|
readonly name = "RivusAutomationFailure";
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivus/gateway",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.2",
|
|
4
4
|
"description": "Message gateway, channels, host binding, automation, and daemon assembly for Rivus.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"sideEffects":
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"./dist/cli.js",
|
|
8
|
+
"./dist/mcp.js"
|
|
9
|
+
],
|
|
7
10
|
"license": "GPL-3.0-only",
|
|
8
11
|
"engines": {
|
|
9
|
-
"node": "^24.11.0"
|
|
12
|
+
"node": "^24.11.0 || ^26.13.1"
|
|
10
13
|
},
|
|
11
14
|
"repository": {
|
|
12
15
|
"type": "git",
|
|
@@ -60,8 +63,8 @@
|
|
|
60
63
|
"@resvg/resvg-js": "2.6.2",
|
|
61
64
|
"@rivus/agent-kit": "0.24.0",
|
|
62
65
|
"@rivus/agent-kit-collab": "0.24.0",
|
|
63
|
-
"@rivus/platform": "0.22.
|
|
64
|
-
"@rivus/runtime": "0.22.
|
|
66
|
+
"@rivus/platform": "0.22.2",
|
|
67
|
+
"@rivus/runtime": "0.22.2",
|
|
65
68
|
"axios": "1.20.0",
|
|
66
69
|
"effect": "4.1.1",
|
|
67
70
|
"get-east-asian-width": "1.7.0",
|