@ouro.bot/cli 0.1.0-alpha.324 → 0.1.0-alpha.325

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 CHANGED
@@ -1,6 +1,12 @@
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.325",
6
+ "changes": [
7
+ "fix(daemon): make `ouro up` run the same startup stability/status poll for already-running current daemons and successful stale-daemon restarts, so degraded workers are summarized with their repair hints instead of returning with only `daemon already running` or `restarted stale daemon`."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.324",
6
12
  "changes": [
@@ -83,45 +83,6 @@ const DEFAULT_DAEMON_STARTUP_STABILITY_WINDOW_MS = 1_500;
83
83
  const DEFAULT_DAEMON_STARTUP_RETRY_LIMIT = 1;
84
84
  const DEFAULT_DAEMON_STARTUP_LOG_LINES = 10;
85
85
  async function ensureDaemonRunning(deps) {
86
- const alive = await deps.checkSocketAlive(deps.socketPath);
87
- if (alive) {
88
- const localRuntime = (0, runtime_metadata_1.getRuntimeMetadata)();
89
- let runningRuntimePromise = null;
90
- const fetchRunningRuntimeMetadata = async () => {
91
- runningRuntimePromise ??= (async () => {
92
- const status = await deps.sendCommand(deps.socketPath, { kind: "daemon.status" });
93
- const payload = (0, cli_render_1.parseStatusPayload)(status.data);
94
- return {
95
- version: payload?.overview.version ?? "unknown",
96
- lastUpdated: payload?.overview.lastUpdated ?? "unknown",
97
- repoRoot: payload?.overview.repoRoot ?? "unknown",
98
- configFingerprint: payload?.overview.configFingerprint ?? "unknown",
99
- };
100
- })();
101
- return runningRuntimePromise;
102
- };
103
- return (0, daemon_runtime_sync_1.ensureCurrentDaemonRuntime)({
104
- socketPath: deps.socketPath,
105
- localVersion: localRuntime.version,
106
- localLastUpdated: localRuntime.lastUpdated,
107
- localRepoRoot: localRuntime.repoRoot,
108
- localConfigFingerprint: localRuntime.configFingerprint,
109
- fetchRunningVersion: async () => (await fetchRunningRuntimeMetadata()).version,
110
- fetchRunningRuntimeMetadata,
111
- stopDaemon: async () => {
112
- await deps.sendCommand(deps.socketPath, { kind: "daemon.stop" });
113
- },
114
- cleanupStaleSocket: deps.cleanupStaleSocket,
115
- startDaemonProcess: deps.startDaemonProcess,
116
- checkSocketAlive: deps.checkSocketAlive,
117
- });
118
- }
119
- const retryLimit = deps.startupRetryLimit ?? DEFAULT_DAEMON_STARTUP_RETRY_LIMIT;
120
- let lastFailure = {
121
- reason: "daemon failed before the startup monitor recorded a failure",
122
- retryable: false,
123
- };
124
- let lastPid = null;
125
86
  const readLatestDaemonStartupEvent = () => {
126
87
  try {
127
88
  // The daemon writes structured events to daemon.ndjson in the first
@@ -165,6 +126,67 @@ async function ensureDaemonRunning(deps) {
165
126
  }
166
127
  return null;
167
128
  };
129
+ const alive = await deps.checkSocketAlive(deps.socketPath);
130
+ if (alive) {
131
+ const localRuntime = (0, runtime_metadata_1.getRuntimeMetadata)();
132
+ let runningRuntimePromise = null;
133
+ const fetchRunningRuntimeMetadata = async () => {
134
+ runningRuntimePromise ??= (async () => {
135
+ const status = await deps.sendCommand(deps.socketPath, { kind: "daemon.status" });
136
+ const payload = (0, cli_render_1.parseStatusPayload)(status.data);
137
+ return {
138
+ version: payload?.overview.version ?? "unknown",
139
+ lastUpdated: payload?.overview.lastUpdated ?? "unknown",
140
+ repoRoot: payload?.overview.repoRoot ?? "unknown",
141
+ configFingerprint: payload?.overview.configFingerprint ?? "unknown",
142
+ };
143
+ })();
144
+ return runningRuntimePromise;
145
+ };
146
+ const runtimeResult = await (0, daemon_runtime_sync_1.ensureCurrentDaemonRuntime)({
147
+ socketPath: deps.socketPath,
148
+ localVersion: localRuntime.version,
149
+ localLastUpdated: localRuntime.lastUpdated,
150
+ localRepoRoot: localRuntime.repoRoot,
151
+ localConfigFingerprint: localRuntime.configFingerprint,
152
+ fetchRunningVersion: async () => (await fetchRunningRuntimeMetadata()).version,
153
+ fetchRunningRuntimeMetadata,
154
+ stopDaemon: async () => {
155
+ await deps.sendCommand(deps.socketPath, { kind: "daemon.stop" });
156
+ },
157
+ cleanupStaleSocket: deps.cleanupStaleSocket,
158
+ startDaemonProcess: deps.startDaemonProcess,
159
+ checkSocketAlive: deps.checkSocketAlive,
160
+ });
161
+ if (!runtimeResult.verifyStartupStatus) {
162
+ return runtimeResult;
163
+ }
164
+ const stability = await (0, startup_tui_1.pollDaemonStartup)({
165
+ sendCommand: deps.sendCommand,
166
+ socketPath: deps.socketPath,
167
+ daemonPid: runtimeResult.startedPid ?? null,
168
+ /* v8 ignore next -- thin wrapper: raw process.stdout.write for ANSI cursor control @preserve */
169
+ writeRaw: (text) => process.stdout.write(text),
170
+ /* v8 ignore next -- thin wrapper: real Date.now() injected for testability @preserve */
171
+ now: () => Date.now(),
172
+ /* v8 ignore next -- thin wrapper: real setTimeout injected for testability @preserve */
173
+ sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
174
+ /* v8 ignore start -- daemon log tail + pid check: reads real filesystem, tested via deployment @preserve */
175
+ readLatestDaemonEvent: readLatestDaemonStartupEvent,
176
+ /* v8 ignore stop */
177
+ });
178
+ return {
179
+ alreadyRunning: runtimeResult.alreadyRunning,
180
+ message: runtimeResult.message,
181
+ stability,
182
+ };
183
+ }
184
+ const retryLimit = deps.startupRetryLimit ?? DEFAULT_DAEMON_STARTUP_RETRY_LIMIT;
185
+ let lastFailure = {
186
+ reason: "daemon failed before the startup monitor recorded a failure",
187
+ retryable: false,
188
+ };
189
+ let lastPid = null;
168
190
  for (let attempt = 0; attempt <= retryLimit; attempt += 1) {
169
191
  deps.reportDaemonStartupPhase?.("starting daemon...");
170
192
  deps.reportDaemonStartupPhase?.("waiting for daemon socket...");
@@ -140,6 +140,8 @@ async function ensureCurrentDaemonRuntime(deps) {
140
140
  message: includesVersionDrift
141
141
  ? `restarted stale daemon from ${runningVersion} to ${deps.localVersion} (pid ${pid})${suffix}`
142
142
  : `restarted drifted daemon (${driftSummary}) (pid ${pid})${suffix}`,
143
+ verifyStartupStatus: verified,
144
+ startedPid: started.pid ?? null,
143
145
  };
144
146
  (0, runtime_1.emitNervesEvent)({
145
147
  component: "daemon",
@@ -213,6 +215,8 @@ async function ensureCurrentDaemonRuntime(deps) {
213
215
  const result = {
214
216
  alreadyRunning: true,
215
217
  message: `daemon already running (${deps.socketPath})`,
218
+ verifyStartupStatus: true,
219
+ startedPid: null,
216
220
  };
217
221
  (0, runtime_1.emitNervesEvent)({
218
222
  component: "daemon",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.324",
3
+ "version": "0.1.0-alpha.325",
4
4
  "main": "dist/heart/daemon/ouro-entry.js",
5
5
  "bin": {
6
6
  "cli": "dist/heart/daemon/ouro-bot-entry.js",