@ouro.bot/cli 0.1.0-alpha.1000 → 0.1.0-alpha.1002
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/changelog.json +12 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/daemon/cli-defaults.js +2 -0
- package/dist/heart/daemon/cli-exec.js +8 -0
- package/dist/heart/daemon/daemon-entry.js +9 -0
- package/dist/heart/daemon/daemon.js +15 -0
- package/dist/heart/daemon/home-filesystem.js +93 -0
- package/dist/repertoire/bitwarden-store.js +20 -0
- package/dist/repertoire/bw-installer.js +39 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1002",
|
|
6
|
+
"changes": [
|
|
7
|
+
"When the bundled Bitwarden CLI is missing one of its own modules (for example after an endpoint security product quarantines a file in it), ouro logs it once and uses the bw on PATH instead of failing to start."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1001",
|
|
12
|
+
"changes": [
|
|
13
|
+
"A starting daemon refuses to start, before it updates or signals anything, while another daemon still answers on its socket, so a second daemon can no longer kill a live one. On Linux, ouro up and the daemon refuse a FAT or exFAT ouro home with a clear message."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1000",
|
|
6
18
|
"changes": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1002</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -73,6 +73,7 @@ const update_state_1 = require("../versioning/update-state");
|
|
|
73
73
|
const logs_prune_1 = require("./logs-prune");
|
|
74
74
|
const daemon_health_1 = require("./daemon-health");
|
|
75
75
|
const log_tailer_1 = require("./log-tailer");
|
|
76
|
+
const home_filesystem_1 = require("./home-filesystem");
|
|
76
77
|
const launchd_1 = require("./launchd");
|
|
77
78
|
const linux_service_1 = require("./linux-service");
|
|
78
79
|
const socket_client_1 = require("./socket-client");
|
|
@@ -797,6 +798,7 @@ function createDefaultOuroCliDeps(socketPath = socket_client_1.DEFAULT_DAEMON_SO
|
|
|
797
798
|
isTTY: process.stdout.isTTY === true,
|
|
798
799
|
checkSocketAlive: socket_client_1.checkDaemonSocketAlive,
|
|
799
800
|
cleanupStaleSocket: defaultCleanupStaleSocket,
|
|
801
|
+
checkHomeFilesystem: () => (0, home_filesystem_1.unsupportedHomeFilesystem)((0, ouro_version_manager_1.getOuroCliHome)()),
|
|
800
802
|
fallbackPendingMessage: defaultFallbackPendingMessage,
|
|
801
803
|
tailLogs: (options) => (0, log_tailer_1.tailLogs)(options),
|
|
802
804
|
healthFilePath: (0, daemon_health_1.getDefaultHealthPath)(),
|
|
@@ -7048,6 +7048,14 @@ async function runOuroCli(args, deps = (0, cli_defaults_1.createDefaultOuroCliDe
|
|
|
7048
7048
|
autoRender: true,
|
|
7049
7049
|
});
|
|
7050
7050
|
const daemonAliveAtBootStart = await deps.checkSocketAlive(deps.socketPath);
|
|
7051
|
+
if (!daemonAliveAtBootStart) {
|
|
7052
|
+
const homeFilesystemProblem = deps.checkHomeFilesystem?.() ?? null;
|
|
7053
|
+
if (homeFilesystemProblem) {
|
|
7054
|
+
deps.writeStdout(homeFilesystemProblem);
|
|
7055
|
+
return homeFilesystemProblem;
|
|
7056
|
+
}
|
|
7057
|
+
}
|
|
7058
|
+
;
|
|
7051
7059
|
progress.setPhasePlan?.(bootPhasePlan(daemonAliveAtBootStart));
|
|
7052
7060
|
// ── versioned CLI update check ──
|
|
7053
7061
|
const versionIntent = deps.readVersionIntent?.() ?? null;
|
|
@@ -66,6 +66,8 @@ const daemon_tombstone_1 = require("./daemon-tombstone");
|
|
|
66
66
|
const agent_config_check_1 = require("./agent-config-check");
|
|
67
67
|
const pulse_1 = require("./pulse");
|
|
68
68
|
const socket_client_1 = require("./socket-client");
|
|
69
|
+
const home_filesystem_1 = require("./home-filesystem");
|
|
70
|
+
const ouro_version_manager_1 = require("../versioning/ouro-version-manager");
|
|
69
71
|
const await_private_wake_1 = require("./await-private-wake");
|
|
70
72
|
const habit_private_wake_1 = require("./habit-private-wake");
|
|
71
73
|
const habit_policy_1 = require("../../rsvp/habit-policy");
|
|
@@ -97,6 +99,13 @@ function parseSocketPath(argv) {
|
|
|
97
99
|
}
|
|
98
100
|
const socketPath = parseSocketPath(process.argv);
|
|
99
101
|
(0, runtime_logging_1.configureDaemonRuntimeLogger)("daemon");
|
|
102
|
+
/* v8 ignore start -- refuses to start on a FAT or exFAT home; the check is unit-tested in home-filesystem.test.ts @preserve */
|
|
103
|
+
const homeFilesystemProblem = (0, home_filesystem_1.unsupportedHomeFilesystem)((0, ouro_version_manager_1.getOuroCliHome)());
|
|
104
|
+
if (homeFilesystemProblem) {
|
|
105
|
+
process.stderr.write(`${homeFilesystemProblem}\n`);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
/* v8 ignore stop */
|
|
100
109
|
const entryPath = path.resolve(__dirname, "daemon-entry.js");
|
|
101
110
|
const mode = (0, runtime_mode_1.detectRuntimeMode)((0, identity_1.getRepoRoot)());
|
|
102
111
|
// Each agent runs on exactly one machine: manage only agents homed here
|
|
@@ -646,6 +646,7 @@ class OuroDaemon {
|
|
|
646
646
|
schedulerFireVerifier;
|
|
647
647
|
schedulerFireConsumer;
|
|
648
648
|
orphanStartupDrain;
|
|
649
|
+
socketAnswering;
|
|
649
650
|
externalEventSourceReadiness;
|
|
650
651
|
constructor(options) {
|
|
651
652
|
this.socketPath = options.socketPath;
|
|
@@ -679,6 +680,7 @@ class OuroDaemon {
|
|
|
679
680
|
this.schedulerFireVerifier = options.schedulerFireVerifier;
|
|
680
681
|
this.schedulerFireConsumer = options.schedulerFireConsumer;
|
|
681
682
|
this.orphanStartupDrain = options.orphanStartupDrain ?? drainOrphanProcessesBeforeStartup;
|
|
683
|
+
this.socketAnswering = options.socketAnswering ?? socket_client_1.checkDaemonSocketAlive;
|
|
682
684
|
this.externalEventSourceReadiness = options.externalEventSourceReadiness ?? (async (agent, source) => {
|
|
683
685
|
const { ensureSanctuarySourceRuntimeReady } = await Promise.resolve().then(() => __importStar(require("../../senses/sanctuary-runtime")));
|
|
684
686
|
await ensureSanctuarySourceRuntimeReady(agent, source);
|
|
@@ -805,6 +807,19 @@ class OuroDaemon {
|
|
|
805
807
|
}
|
|
806
808
|
}
|
|
807
809
|
async startInner() {
|
|
810
|
+
// A replacement always stops the old daemon first (ouro up, launchd bootout,
|
|
811
|
+
// staged restart). A daemon that still answers is live, not orphaned: never
|
|
812
|
+
// kill its processes or unlink its socket, whatever HOME this one runs under.
|
|
813
|
+
if (await this.socketAnswering(this.socketPath)) {
|
|
814
|
+
(0, runtime_1.emitNervesEvent)({
|
|
815
|
+
level: "error",
|
|
816
|
+
component: "daemon",
|
|
817
|
+
event: "daemon.socket_already_served",
|
|
818
|
+
message: "another daemon already answers on this socket; refusing to start",
|
|
819
|
+
meta: { socketPath: this.socketPath },
|
|
820
|
+
});
|
|
821
|
+
throw new Error(`another daemon already answers on ${this.socketPath}; stop it with ouro stop, or start this one with its own --socket`);
|
|
822
|
+
}
|
|
808
823
|
const containerPolicy = (0, container_runtime_1.readContainerRuntimePolicy)();
|
|
809
824
|
// Register update hooks and apply pending updates before starting agents
|
|
810
825
|
(0, update_hooks_1.registerUpdateHook)(bundle_meta_1.bundleMetaHook);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.unsupportedHomeFilesystem = unsupportedHomeFilesystem;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const runtime_1 = require("../../nerves/runtime");
|
|
40
|
+
/**
|
|
41
|
+
* Linux `statfs` magic numbers for filesystems that cannot hold `~/.ouro-cli`:
|
|
42
|
+
* no Unix sockets (the daemon's `listen` fails with EPERM), no symlinks (the
|
|
43
|
+
* `CurrentVersion` switch needs them) and no POSIX modes (a 0600 secret file
|
|
44
|
+
* is world-readable). Removable media and appliance data partitions often use them.
|
|
45
|
+
*/
|
|
46
|
+
const UNSUPPORTED_LINUX_FILESYSTEMS = new Map([
|
|
47
|
+
[0x4d44, "FAT"],
|
|
48
|
+
[0x2011bab0, "exFAT"],
|
|
49
|
+
]);
|
|
50
|
+
const defaultDeps = {
|
|
51
|
+
platform: process.platform,
|
|
52
|
+
statfsType: (dir) => fs.statfsSync(dir).type,
|
|
53
|
+
exists: (dir) => fs.existsSync(dir),
|
|
54
|
+
};
|
|
55
|
+
function nearestExistingDir(dir, exists) {
|
|
56
|
+
let current = path.resolve(dir);
|
|
57
|
+
while (!exists(current)) {
|
|
58
|
+
const parent = path.dirname(current);
|
|
59
|
+
if (parent === current)
|
|
60
|
+
break;
|
|
61
|
+
current = parent;
|
|
62
|
+
}
|
|
63
|
+
return current;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns a message when `ouroCliHome` (or, before it exists, its nearest
|
|
67
|
+
* existing parent) sits on a filesystem the runtime cannot use, and null
|
|
68
|
+
* otherwise. Read-only: it never writes to the directory it checks.
|
|
69
|
+
*/
|
|
70
|
+
function unsupportedHomeFilesystem(ouroCliHome, deps = defaultDeps) {
|
|
71
|
+
if (deps.platform !== "linux")
|
|
72
|
+
return null;
|
|
73
|
+
const checkedDir = nearestExistingDir(ouroCliHome, deps.exists);
|
|
74
|
+
let type;
|
|
75
|
+
try {
|
|
76
|
+
type = deps.statfsType(checkedDir);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const filesystem = UNSUPPORTED_LINUX_FILESYSTEMS.get(type);
|
|
82
|
+
if (!filesystem)
|
|
83
|
+
return null;
|
|
84
|
+
const message = `${ouroCliHome} is on ${filesystem}, which has no Unix sockets, symlinks or file permissions. Set HOME to a directory on ext4 or another POSIX filesystem, then run ouro up again.`;
|
|
85
|
+
(0, runtime_1.emitNervesEvent)({
|
|
86
|
+
level: "error",
|
|
87
|
+
component: "daemon",
|
|
88
|
+
event: "daemon.home_filesystem_unsupported",
|
|
89
|
+
message: "the ouro home is on a filesystem the runtime cannot use",
|
|
90
|
+
meta: { ouroCliHome, checkedDir, filesystem },
|
|
91
|
+
});
|
|
92
|
+
return message;
|
|
93
|
+
}
|
|
@@ -645,6 +645,8 @@ class BitwardenCredentialStore {
|
|
|
645
645
|
catch (err) {
|
|
646
646
|
/* v8 ignore next -- defensive: loginAttempt always throws Error instances @preserve */
|
|
647
647
|
lastError = err instanceof Error ? err : new Error(String(err));
|
|
648
|
+
if (this.switchFromBrokenBundledBw(lastError))
|
|
649
|
+
return this.login();
|
|
648
650
|
// Don't retry non-transient errors (auth failures, bw not installed)
|
|
649
651
|
if (!isTransientError(lastError)) {
|
|
650
652
|
this.setTerminalLoginError(lastError);
|
|
@@ -932,6 +934,10 @@ class BitwardenCredentialStore {
|
|
|
932
934
|
}
|
|
933
935
|
catch (error) {
|
|
934
936
|
const err = error;
|
|
937
|
+
if (!attemptedFreshSession && this.switchFromBrokenBundledBw(err)) {
|
|
938
|
+
attemptedFreshSession = true;
|
|
939
|
+
continue;
|
|
940
|
+
}
|
|
935
941
|
if (attemptedFreshSession || !isBwSessionAuthError(err)) {
|
|
936
942
|
throw err;
|
|
937
943
|
}
|
|
@@ -941,6 +947,20 @@ class BitwardenCredentialStore {
|
|
|
941
947
|
}
|
|
942
948
|
}
|
|
943
949
|
}
|
|
950
|
+
/**
|
|
951
|
+
* When the bundled bw fails to load one of its own modules, stop using it and
|
|
952
|
+
* drop this session, so the next login resolves the bw on PATH with its own
|
|
953
|
+
* profile directory. Returns whether it switched.
|
|
954
|
+
*/
|
|
955
|
+
switchFromBrokenBundledBw(error) {
|
|
956
|
+
if (!(0, bw_installer_1.isBwMissingModuleError)(error) || !(0, bw_installer_1.isBundledBw)(this.bwBinaryPath))
|
|
957
|
+
return false;
|
|
958
|
+
(0, bw_installer_1.markBundledBwBroken)(error.message);
|
|
959
|
+
this.onProgress?.("the bundled Bitwarden CLI is damaged; switching to the bw on PATH");
|
|
960
|
+
this.sessionToken = null;
|
|
961
|
+
this.structuredItemCache = null;
|
|
962
|
+
return true;
|
|
963
|
+
}
|
|
944
964
|
async withTransientRetry(operation) {
|
|
945
965
|
let lastError;
|
|
946
966
|
for (let attempt = 0; attempt < TRANSIENT_MAX_RETRIES; attempt++) {
|
|
@@ -45,6 +45,10 @@ exports.PINNED_BW_CLI_VERSION = void 0;
|
|
|
45
45
|
exports.findExecutableOnPath = findExecutableOnPath;
|
|
46
46
|
exports.findExecutableViaNpmPrefix = findExecutableViaNpmPrefix;
|
|
47
47
|
exports.findBundledBwCli = findBundledBwCli;
|
|
48
|
+
exports.isBundledBw = isBundledBw;
|
|
49
|
+
exports.isBwMissingModuleError = isBwMissingModuleError;
|
|
50
|
+
exports.markBundledBwBroken = markBundledBwBroken;
|
|
51
|
+
exports.resetBundledBwStateForTests = resetBundledBwStateForTests;
|
|
48
52
|
exports.bwCommand = bwCommand;
|
|
49
53
|
exports.ensureBwCli = ensureBwCli;
|
|
50
54
|
const node_child_process_1 = require("node:child_process");
|
|
@@ -168,6 +172,38 @@ function findBundledBwCli(resolvePackageJson = (id) => require.resolve(id)) {
|
|
|
168
172
|
return null;
|
|
169
173
|
}
|
|
170
174
|
}
|
|
175
|
+
let bundledBwPath = null;
|
|
176
|
+
let bundledBwBroken = false;
|
|
177
|
+
/** Whether `bwBinaryPath` is the bundled bw that ensureBwCli last returned. */
|
|
178
|
+
function isBundledBw(bwBinaryPath) {
|
|
179
|
+
return bundledBwPath !== null && bwBinaryPath === bundledBwPath;
|
|
180
|
+
}
|
|
181
|
+
/** True when bw output shows a damaged install: a module of its own is missing. */
|
|
182
|
+
function isBwMissingModuleError(error) {
|
|
183
|
+
return /\bCannot find module\b/.test(error.message);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Stop using the bundled bw for the rest of this process, after it failed to
|
|
187
|
+
* load one of its own modules (an endpoint security product can quarantine a
|
|
188
|
+
* file inside it). ensureBwCli then falls back to the bw on PATH. Logged once.
|
|
189
|
+
*/
|
|
190
|
+
function markBundledBwBroken(reason) {
|
|
191
|
+
if (bundledBwBroken)
|
|
192
|
+
return;
|
|
193
|
+
bundledBwBroken = true;
|
|
194
|
+
(0, runtime_1.emitNervesEvent)({
|
|
195
|
+
level: "warn",
|
|
196
|
+
event: "repertoire.bw_cli_bundled_broken",
|
|
197
|
+
component: "repertoire",
|
|
198
|
+
message: "the bw that ships with ouro is missing a module; using bw on PATH instead",
|
|
199
|
+
meta: { bundledPath: bundledBwPath, reason: reason.split("\n")[0].slice(0, 300) },
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/** Test seam: forget the bundled-bw state between tests. */
|
|
203
|
+
function resetBundledBwStateForTests() {
|
|
204
|
+
bundledBwPath = null;
|
|
205
|
+
bundledBwBroken = false;
|
|
206
|
+
}
|
|
171
207
|
/** How to spawn a resolved `bw`: a `.js` entry point runs under this Node, anything else directly. */
|
|
172
208
|
function bwCommand(bwBinaryPath, args, nodePath = process.execPath) {
|
|
173
209
|
return bwBinaryPath.endsWith(".js") ? { file: nodePath, args: [bwBinaryPath, ...args] } : { file: bwBinaryPath, args };
|
|
@@ -184,9 +220,10 @@ async function ensureBwCli(findBundled = findBundledBwCli) {
|
|
|
184
220
|
return override;
|
|
185
221
|
throw new Error(`OURO_BW_BINARY is set to ${override}, which is not an executable file`);
|
|
186
222
|
}
|
|
187
|
-
// 1. The bw that ships with ouro
|
|
188
|
-
const bundled = findBundled();
|
|
223
|
+
// 1. The bw that ships with ouro, unless it was found broken in this process
|
|
224
|
+
const bundled = bundledBwBroken ? null : findBundled();
|
|
189
225
|
if (bundled) {
|
|
226
|
+
bundledBwPath = bundled;
|
|
190
227
|
return bundled;
|
|
191
228
|
}
|
|
192
229
|
// 2. A bw already on PATH
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1002",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1002",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@azure/identity": "^4.13.0",
|