@rivus/gateway 0.20.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/README.md +9 -0
- package/assets/installation-policy.json +13 -0
- package/dist/bootstrap/feishu.d.ts +1 -1
- package/dist/bootstrap/feishu.js +2 -2
- package/dist/chunks/rivus-deployment-cli-process.d.ts +1 -1
- package/dist/chunks/rivus-home-deployment-env.js +187 -4
- package/dist/chunks/rivus-node-entrypoint.js +1598 -23
- package/dist/index.d.ts +35 -1
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -5,6 +5,15 @@ Feishu adapters, management, project initialization, and the Gateway CLI resourc
|
|
|
5
5
|
|
|
6
6
|
The package has no npm bin. Applications choose the public entrypoint or an explicit template resource.
|
|
7
7
|
|
|
8
|
+
Gateway assembles the product CLI's `rivus upgrade [--json]` workflow for existing macOS LaunchAgents and Linux user
|
|
9
|
+
systemd services. It validates a separate installation of the latest stable four-package release against the actual Home before
|
|
10
|
+
stop, then backs up, switches and requires the service PID to match fresh readiness evidence. Home and application
|
|
11
|
+
state stay in place; retries retain the original target and failures do not restore older state automatically.
|
|
12
|
+
The package ships the reviewed consumer dependency policy at `assets/installation-policy.json`.
|
|
13
|
+
`rivus check-config --load-plugins` imports, validates and registers Plugins and resolves Agent/Automation definitions
|
|
14
|
+
without constructing runtime stores, Endpoints or schedulers; ordinary config checks remain offline.
|
|
15
|
+
See [managed Home upgrades](../../docs/en/operations/local-deployment.md#managed-home-upgrades).
|
|
16
|
+
|
|
8
17
|
The root exposes `createRivusPluginCatalog`, `resolveRivusAgentDefinition`, `RIVUS_PLUGIN_API_VERSION` and
|
|
9
18
|
`runRivusNodeEntrypoint`, plus nine plugin contracts. Catalog construction and resolution are implemented in Bootstrap.
|
|
10
19
|
Host, Deployment, Automation, Human, Inbox, Recovery, Delegation and presentation helpers remain internal; use the
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"stateCompatibility": "rivus-home-0.20",
|
|
4
|
+
"minimumSourceVersion": "0.20.0",
|
|
5
|
+
"pnpmVersion": "12.8.1",
|
|
6
|
+
"overrides": {
|
|
7
|
+
"brace-expansion@>=5.0.0 <5.0.12": "5.0.12",
|
|
8
|
+
"undici@>=8.0.0 <8.12.3": "8.12.3",
|
|
9
|
+
"@opentelemetry/api": "1.9.1",
|
|
10
|
+
"zod@>=4.0.0 <4.6.6": "4.6.6"
|
|
11
|
+
},
|
|
12
|
+
"allowBuilds": { "@google/genai": false, "protobufjs": false }
|
|
13
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as CreateRivusDeploymentEndpointPortInput, d as RivusDeploymentEndpointPort, f as RivusDeploymentRuntimePort, l as CreateRivusDeploymentRuntimePortInput, o as CreateRivusDeploymentAutomationPortInput, s as CreateRivusDeploymentBackgroundSessionPortInput, t as RivusDeploymentBootstrapContext, u as RivusDeploymentBackgroundSessionPort, x as AutomationScheduler, z as RecoveryControl } from "../chunks/rivus-deployment-cli-process.js";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
//#region src/bootstrap/feishu.d.ts
|
|
4
4
|
export declare function createRivusDeploymentAdapters(context: RivusDeploymentBootstrapContext): Promise<{
|
package/dist/bootstrap/feishu.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as parseRivusModelManagementEnabled, E as migrateRivusModelManagementConfig, H as createBackgroundSessionToolContracts, L as resolveFeishuEndpointCredentials, O as parseRivusModelManagementHomeConfig, S as gatewaySkillsDirectory, T as resolveAcpRuntimeEnvironment, W as deepFreeze$1, _ as readRivusAudioInstalledRelease, a as invokeRuntimeControl, b as gatewayPackageDirectory, c as createRivusModelManagementFailure, g as installRivusAudioTranscriber, h as RivusAudioInstallStepError, i as disposeRuntimeCacheEntries, k as loadMergedLocalEnvFile, m as runRivusAudioProcess, o as RIVUS_RELEASE_DESCRIPTOR, r as createRuntimeCache, s as createRivusModelManagementSocketServer, t as RIVUS_HOME_DEPLOYMENT_ENV, w as loadRivusDeploymentManifest, y as gatewayAudioTranscriberAssetDirectory } from "../chunks/rivus-home-deployment-env.js";
|
|
2
2
|
import { n as RivusAutomationFailure, t as readAutomationPresentation } from "../chunks/automation-presentation.js";
|
|
3
3
|
import { a as openTerminalBindingsStore, c as classifyFeishuCardOwnership, d as parseFeishuTerminalMessage, i as openTerminalMessageClaims, l as createFeishuTerminalDelivery, n as embeddedHerdrRouteSchema, o as terminalAgentSchema, s as createHerdrSocketClient, t as createHerdrFeishuBridgeRuntime, u as parseFeishuTerminalAction } from "../chunks/herdr-feishu-runtime.js";
|
|
4
4
|
import { createRandomId, createSha256Digest, createStableId } from "@rivus/platform/identity";
|
|
@@ -8,8 +8,8 @@ import { homedir, tmpdir } from "node:os";
|
|
|
8
8
|
import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
9
9
|
import { access, appendFile, chmod, constants, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
10
10
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
11
|
-
import { mkdtempSync, rmSync, statSync } from "node:fs";
|
|
12
11
|
import { appendJsonlRecord, isRecord, loadJsonlSnapshotStore, readPersistenceFile, writeAtomicTextFile, writePersistenceFile } from "@rivus/platform/persistence";
|
|
12
|
+
import { mkdtempSync, rmSync, statSync } from "node:fs";
|
|
13
13
|
import { spawn, spawnSync } from "node:child_process";
|
|
14
14
|
import { unwrapExit } from "@rivus/platform/effect";
|
|
15
15
|
import { createAcpStdioAgentLoop, createJsonAcpSessionStore } from "@rivus/runtime/acp";
|
|
@@ -892,5 +892,5 @@ interface RivusDeploymentBootstrapContext {
|
|
|
892
892
|
}
|
|
893
893
|
type RivusDeploymentBootstrapFactory = (context: RivusDeploymentBootstrapContext) => Promise<RivusDeploymentBootstrapAdapters> | RivusDeploymentBootstrapAdapters;
|
|
894
894
|
//#endregion
|
|
895
|
-
export {
|
|
895
|
+
export { AutomationPresentationKind as A, RivusAutomationInput as C, RivusAutomationTickContext as D, RivusAutomationTemplate as E, AutomationPresentationTableColumn as F, AutomationPresentationTrend as I, readAutomationPresentation as L, AutomationPresentationSource as M, AutomationPresentationTable as N, AutomationPresentation as O, AutomationPresentationTableCell as P, AutomationLineChart as R, RivusAutomationFailure as S, RivusAutomationRetryPolicy as T, RivusPluginManifest as _, RivusDaemonEnv as a, RivusAgentProfile as b, CreateRivusDeploymentEndpointPortInput as c, RivusDeploymentEndpointPort as d, RivusDeploymentRuntimePort as f, RIVUS_PLUGIN_API_VERSION as g, RivusPluginRegistry as h, RivusHomeApi as i, AutomationPresentationSection as j, AutomationPresentationItem as k, CreateRivusDeploymentRuntimePortInput as l, RivusPluginCatalog as m, RivusDeploymentBootstrapFactory as n, CreateRivusDeploymentAutomationPortInput as o, RivusPlugin as p, RivusHome as r, CreateRivusDeploymentBackgroundSessionPortInput as s, RivusDeploymentBootstrapContext as t, RivusDeploymentBackgroundSessionPort as u, ResolvedRivusAgentDefinition as v, RivusAutomationOutput as w, AutomationScheduler as x, RivusAgentDeployment as y, RecoveryControl as z };
|
|
896
896
|
export {};
|
|
@@ -2,11 +2,11 @@ import { Cause, Deferred, Effect, Exit, Option, Result, Schema, SchemaIssue, Sem
|
|
|
2
2
|
import { isRivusRuntimeToolId } from "@rivus/runtime";
|
|
3
3
|
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { access, chmod, constants, cp, mkdir, open, readFile, readdir, rename, rm, rmdir, stat, unlink, writeFile } from "node:fs/promises";
|
|
5
|
+
import { access, chmod, constants, cp, mkdir, open, readFile, readdir, realpath, rename, rm, rmdir, stat, unlink, writeFile } from "node:fs/promises";
|
|
6
6
|
import { createHash, randomUUID } from "node:crypto";
|
|
7
|
+
import { readPersistenceFile, writeAtomicTextFile } from "@rivus/platform/persistence";
|
|
7
8
|
import { isPathWithin } from "@rivus/platform/filesystem";
|
|
8
9
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
9
|
-
import { readPersistenceFile, writeAtomicTextFile } from "@rivus/platform/persistence";
|
|
10
10
|
import { spawn } from "node:child_process";
|
|
11
11
|
import { createConnection, createServer } from "node:net";
|
|
12
12
|
//#region src/platform/values/deep-freeze.ts
|
|
@@ -644,6 +644,189 @@ function required(env, variable) {
|
|
|
644
644
|
return value;
|
|
645
645
|
}
|
|
646
646
|
//#endregion
|
|
647
|
+
//#region src/platform/home/upgrade/upgrade-journal.ts
|
|
648
|
+
const recordSchema = Schema.fromJsonString(Schema.Struct({
|
|
649
|
+
schemaVersion: Schema.Literal(1),
|
|
650
|
+
id: Schema.NonEmptyString,
|
|
651
|
+
home: Schema.NonEmptyString,
|
|
652
|
+
sourceVersion: Schema.NonEmptyString,
|
|
653
|
+
targetVersion: Schema.NonEmptyString,
|
|
654
|
+
sourceCommand: Schema.Array(Schema.NonEmptyString),
|
|
655
|
+
service: Schema.Struct({
|
|
656
|
+
kind: Schema.Literals(["launchd", "systemd"]),
|
|
657
|
+
id: Schema.NonEmptyString,
|
|
658
|
+
definitionPath: Schema.NonEmptyString
|
|
659
|
+
}),
|
|
660
|
+
phase: Schema.Literals([
|
|
661
|
+
"preparing",
|
|
662
|
+
"prepared",
|
|
663
|
+
"stopping",
|
|
664
|
+
"stopped",
|
|
665
|
+
"backed-up",
|
|
666
|
+
"switching",
|
|
667
|
+
"starting",
|
|
668
|
+
"complete"
|
|
669
|
+
]),
|
|
670
|
+
createdAt: Schema.NonEmptyString,
|
|
671
|
+
startedAfter: Schema.optional(Schema.NonEmptyString)
|
|
672
|
+
}));
|
|
673
|
+
function upgradePaths(home, id) {
|
|
674
|
+
const directory = join(home, ".rivus-upgrade");
|
|
675
|
+
return {
|
|
676
|
+
directory,
|
|
677
|
+
journal: join(directory, "operation.json"),
|
|
678
|
+
release: join(directory, "releases", id ?? ""),
|
|
679
|
+
backup: join(directory, "backups", id ?? "")
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
async function readUpgradeRecord(home) {
|
|
683
|
+
const text = await readPersistenceFile(upgradePaths(home).journal);
|
|
684
|
+
if (text === void 0) return;
|
|
685
|
+
const record = Schema.decodeUnknownSync(recordSchema)(text);
|
|
686
|
+
if (record.home !== home || !/^[a-f\d-]{36}$/.test(record.id)) throw new Error("upgrade journal belongs to another Home or has an invalid operation id");
|
|
687
|
+
return record;
|
|
688
|
+
}
|
|
689
|
+
async function writeUpgradeRecord(record) {
|
|
690
|
+
const paths = upgradePaths(record.home);
|
|
691
|
+
await mkdir(paths.directory, {
|
|
692
|
+
recursive: true,
|
|
693
|
+
mode: 448
|
|
694
|
+
});
|
|
695
|
+
await writeAtomicTextFile(paths.journal, `${JSON.stringify(record)}\n`, {
|
|
696
|
+
durable: true,
|
|
697
|
+
mode: 384
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
const ownerSchema = Schema.fromJsonString(Schema.Struct({
|
|
701
|
+
pid: Schema.Int,
|
|
702
|
+
token: Schema.NonEmptyString
|
|
703
|
+
}));
|
|
704
|
+
/** Publishes a complete owner atomically; stale reclamation removes only the owner token actually observed. */
|
|
705
|
+
async function acquireUpgradeLock(home, options) {
|
|
706
|
+
const root = upgradePaths(home).directory;
|
|
707
|
+
await mkdir(root, {
|
|
708
|
+
recursive: true,
|
|
709
|
+
mode: 448
|
|
710
|
+
});
|
|
711
|
+
const token = randomUUID();
|
|
712
|
+
const lock = join(root, "lock");
|
|
713
|
+
const draft = join(root, `.lock-${token}`);
|
|
714
|
+
await mkdir(draft, { mode: 448 });
|
|
715
|
+
try {
|
|
716
|
+
await writeFile(join(draft, token), JSON.stringify({
|
|
717
|
+
pid: options.pid,
|
|
718
|
+
token
|
|
719
|
+
}), {
|
|
720
|
+
flag: "wx",
|
|
721
|
+
mode: 384
|
|
722
|
+
});
|
|
723
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
724
|
+
try {
|
|
725
|
+
await rename(draft, lock);
|
|
726
|
+
return async () => {
|
|
727
|
+
await unlink(join(lock, token));
|
|
728
|
+
await rmdir(lock).catch((error) => {
|
|
729
|
+
if (!hasCode(error, "ENOTEMPTY")) throw error;
|
|
730
|
+
});
|
|
731
|
+
};
|
|
732
|
+
} catch (error) {
|
|
733
|
+
if (!hasCode(error, "ENOTEMPTY") && !hasCode(error, "EEXIST")) throw error;
|
|
734
|
+
}
|
|
735
|
+
let names;
|
|
736
|
+
try {
|
|
737
|
+
names = await readdir(lock);
|
|
738
|
+
} catch (error) {
|
|
739
|
+
if (hasCode(error, "ENOENT")) continue;
|
|
740
|
+
throw error;
|
|
741
|
+
}
|
|
742
|
+
if (names.length !== 1) throw new Error("upgrade lock owner is uninspectable; preserve it for recovery");
|
|
743
|
+
const name = names[0];
|
|
744
|
+
let owner;
|
|
745
|
+
try {
|
|
746
|
+
owner = Schema.decodeUnknownSync(ownerSchema)(await readFile(join(lock, name), "utf8"));
|
|
747
|
+
} catch (error) {
|
|
748
|
+
if (hasCode(error, "ENOENT")) continue;
|
|
749
|
+
throw new Error("upgrade lock owner is uninspectable", { cause: error });
|
|
750
|
+
}
|
|
751
|
+
if (owner.token !== name || owner.pid <= 0 || options.isProcessAlive(owner.pid)) throw new Error("another upgrade owns this Home; wait for that invocation to finish");
|
|
752
|
+
await unlink(join(lock, name)).catch((error) => {
|
|
753
|
+
if (!hasCode(error, "ENOENT")) throw error;
|
|
754
|
+
});
|
|
755
|
+
await rmdir(lock).catch((error) => {
|
|
756
|
+
if (!hasCode(error, "ENOENT") && !hasCode(error, "ENOTEMPTY")) throw error;
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
throw new Error("upgrade lock changed concurrently; retry after the current invocation finishes");
|
|
760
|
+
} finally {
|
|
761
|
+
await rm(draft, {
|
|
762
|
+
recursive: true,
|
|
763
|
+
force: true
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
function hasCode(error, code) {
|
|
768
|
+
return Schema.is(Schema.Struct({ code: Schema.Literal(code) }))(error);
|
|
769
|
+
}
|
|
770
|
+
//#endregion
|
|
771
|
+
//#region src/platform/home/upgrade/runtime-receipt.ts
|
|
772
|
+
const absolutePath = Schema.String.check(Schema.makeFilter(isAbsolute));
|
|
773
|
+
const runtimeReceiptSchema = Schema.Struct({
|
|
774
|
+
schemaVersion: Schema.Literal(1),
|
|
775
|
+
home: absolutePath,
|
|
776
|
+
pid: Schema.Number.check(Schema.isInt(), Schema.isGreaterThan(0)),
|
|
777
|
+
version: Schema.Trimmed.check(Schema.isNonEmpty()),
|
|
778
|
+
executable: absolutePath,
|
|
779
|
+
startedAt: Schema.String.check(Schema.makeFilter((value) => Number.isFinite(Date.parse(value))))
|
|
780
|
+
});
|
|
781
|
+
async function writeRuntimeReceipt(input) {
|
|
782
|
+
const receipt = Schema.decodeUnknownSync(runtimeReceiptSchema)({
|
|
783
|
+
...input,
|
|
784
|
+
home: await realpath(input.home),
|
|
785
|
+
executable: await realpath(input.executable),
|
|
786
|
+
schemaVersion: 1
|
|
787
|
+
});
|
|
788
|
+
const directory = join(receipt.home, ".rivus-upgrade");
|
|
789
|
+
await mkdir(directory, {
|
|
790
|
+
mode: 448,
|
|
791
|
+
recursive: true
|
|
792
|
+
});
|
|
793
|
+
await chmod(directory, 448);
|
|
794
|
+
const path = join(directory, "runtime.json");
|
|
795
|
+
await chmod(path, 384).catch((error) => {
|
|
796
|
+
if (!isMissing$1(error)) throw error;
|
|
797
|
+
});
|
|
798
|
+
await writeAtomicTextFile(path, `${JSON.stringify(receipt)}\n`, {
|
|
799
|
+
durable: true,
|
|
800
|
+
mode: 384
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
async function readRuntimeReceipt(home) {
|
|
804
|
+
let canonicalHome;
|
|
805
|
+
let raw;
|
|
806
|
+
try {
|
|
807
|
+
canonicalHome = await realpath(home);
|
|
808
|
+
raw = await readFile(join(canonicalHome, ".rivus-upgrade", "runtime.json"), "utf8");
|
|
809
|
+
} catch (error) {
|
|
810
|
+
if (isMissing$1(error)) return;
|
|
811
|
+
throw error;
|
|
812
|
+
}
|
|
813
|
+
try {
|
|
814
|
+
const receipt = Schema.decodeUnknownSync(runtimeReceiptSchema)(JSON.parse(raw));
|
|
815
|
+
return receipt.home === canonicalHome ? receipt : void 0;
|
|
816
|
+
} catch {
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
async function clearRuntimeReceipt(home, pid) {
|
|
821
|
+
const receipt = await readRuntimeReceipt(home);
|
|
822
|
+
if (receipt?.pid === pid) await unlink(join(receipt.home, ".rivus-upgrade", "runtime.json")).catch((error) => {
|
|
823
|
+
if (!isMissing$1(error)) throw error;
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
function isMissing$1(error) {
|
|
827
|
+
return Schema.is(Schema.Struct({ code: Schema.Literal("ENOENT") }))(error);
|
|
828
|
+
}
|
|
829
|
+
//#endregion
|
|
647
830
|
//#region src/platform/home/config/runtime/local-env-file.ts
|
|
648
831
|
var LocalEnvFileError = class extends Error {
|
|
649
832
|
constructor(message) {
|
|
@@ -2067,7 +2250,7 @@ function parseLockOwner(value) {
|
|
|
2067
2250
|
//#endregion
|
|
2068
2251
|
//#region src/platform/project/setup/release-descriptor.ts
|
|
2069
2252
|
const RIVUS_RELEASE_DESCRIPTOR = Object.freeze({
|
|
2070
|
-
version: "0.
|
|
2253
|
+
version: "0.21.0",
|
|
2071
2254
|
dependencies: Object.freeze({
|
|
2072
2255
|
"@earendil-works/pi-coding-agent": "0.84.4",
|
|
2073
2256
|
"@larksuiteoapi/node-sdk": "1.74.0",
|
|
@@ -2168,5 +2351,5 @@ function withoutRivusHomeDeployment(env) {
|
|
|
2168
2351
|
return rest;
|
|
2169
2352
|
}
|
|
2170
2353
|
//#endregion
|
|
2171
|
-
export {
|
|
2354
|
+
export { clearRuntimeReceipt as A, validateRivusDeploymentManifest as B, gatewayTemplateDirectory as C, parseRivusModelManagementEnabled as D, migrateRivusModelManagementConfig as E, upgradePaths as F, createBackgroundSessionToolContracts as H, writeUpgradeRecord as I, resolveFeishuEndpointCredentials as L, writeRuntimeReceipt as M, acquireUpgradeLock as N, parseRivusModelManagementHomeConfig as O, readUpgradeRecord as P, InvalidRivusProjectSpace as R, gatewaySkillsDirectory as S, resolveAcpRuntimeEnvironment as T, narrowBackgroundSessionDefinition as U, validateRivusProjectSpaceDeployment as V, deepFreeze as W, readRivusAudioInstalledRelease as _, invokeRuntimeControl as a, gatewayPackageDirectory as b, createRivusModelManagementFailure as c, renderRivusModelCliArgumentError as d, renderRivusModelCliHelp as f, installRivusAudioTranscriber as g, RivusAudioInstallStepError as h, disposeRuntimeCacheEntries as i, readRuntimeReceipt as j, loadMergedLocalEnvFile as k, createRivusModelManagementWireRequest as l, runRivusAudioProcess as m, withoutRivusHomeDeployment as n, RIVUS_RELEASE_DESCRIPTOR as o, runRivusAudioPassthroughProcess as p, createRuntimeCache as r, createRivusModelManagementSocketServer as s, RIVUS_HOME_DEPLOYMENT_ENV as t, parseRivusModelCliArguments as u, readRivusAudioStatus as v, loadRivusDeploymentManifest as w, gatewayPackageManifestPath as x, gatewayAudioTranscriberAssetDirectory as y, parseRivusDeploymentManifest as z };
|
|
2172
2355
|
|