@ouro.bot/cli 0.1.0-alpha.437 → 0.1.0-alpha.439

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,22 @@
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.439",
6
+ "changes": [
7
+ "When an older Ouro-owned launcher is shadowing the managed `~/.ouro-cli/bin/ouro` path, system setup now repairs it in place instead of dumping a PATH lecture onto the human. Old global Homebrew/npm launchers that clearly belong to Ouro get rewritten to the current managed wrapper automatically.",
8
+ "That repair is intentionally narrow and truthful: Ouro only rewrites a shadowed launcher when its realpath or readable content proves it is one of our old launchers. Unknown launchers still keep the explicit PATH warning instead of being touched.",
9
+ "New path-installer and startup output coverage lock in the self-heal path, including readable non-Ouro launchers, disappearing files, write failures, and the happy-path repair of a stale `/opt/homebrew/bin/ouro`, with full coverage, integration, and packaged-install validation on top."
10
+ ]
11
+ },
12
+ {
13
+ "version": "0.1.0-alpha.438",
14
+ "changes": [
15
+ "Live provider failures now keep their real diagnosis all the way through startup, repair, and the connect bay: expired credentials still prompt re-auth, but busy providers, provider outages, rate limits, quota failures, and network trouble now point humans toward retrying later, checking usage, or switching lanes instead of being mislabeled as an auth problem.",
16
+ "The readiness board and connect bay now share one classification-aware repair model, so a lane only says `needs credentials` when the live ping actually came back as an auth failure; other live-check failures stay in the broader `needs attention` bucket with matching next actions.",
17
+ "New daemon, connect-bay, human-readiness, hermetic-runtime, and full-suite coverage lock in the truthful failure guidance, and packaged-install verification confirms the fix survives beyond the repo checkout into the shipped CLI."
18
+ ]
19
+ },
4
20
  {
5
21
  "version": "0.1.0-alpha.437",
6
22
  "changes": [
@@ -298,12 +298,18 @@ function failedPingResult(agentName, lane, provider, model, result) {
298
298
  return {
299
299
  ok: false,
300
300
  error: `${lane} provider ${provider} model ${model} failed live check: ${result.message}`,
301
- fix: `Run 'ouro auth --agent ${agentName} --provider ${provider}' to refresh credentials.`,
301
+ fix: (0, readiness_repair_1.providerLiveCheckFix)({
302
+ agentName,
303
+ lane,
304
+ provider,
305
+ classification: result.classification,
306
+ }),
302
307
  issue: (0, readiness_repair_1.providerLiveCheckFailedIssue)({
303
308
  agentName,
304
309
  lane,
305
310
  provider,
306
311
  model,
312
+ classification: result.classification,
307
313
  message: result.message,
308
314
  }),
309
315
  };
@@ -3262,6 +3262,9 @@ async function performSystemSetup(deps) {
3262
3262
  if (installResult.repairedOldLauncher) {
3263
3263
  deps.writeStdout("repaired stale ouro launcher at ~/.local/bin/ouro");
3264
3264
  }
3265
+ if (installResult.repairedShadowedLauncherPath) {
3266
+ deps.writeStdout(`updated stale ouro launcher at ${installResult.repairedShadowedLauncherPath}`);
3267
+ }
3265
3268
  if (installResult.pathResolution?.status === "shadowed") {
3266
3269
  deps.writeStdout(`fix ouro PATH: ${installResult.pathResolution.detail}; ` +
3267
3270
  `fix: ${installResult.pathResolution.remediation}`);
@@ -6,6 +6,7 @@ exports.connectEntryNeedsAttention = connectEntryNeedsAttention;
6
6
  exports.renderConnectBay = renderConnectBay;
7
7
  const runtime_1 = require("../../nerves/runtime");
8
8
  const terminal_ui_1 = require("./terminal-ui");
9
+ const readiness_repair_1 = require("./readiness-repair");
9
10
  const CONNECT_STATUS_PRIORITY = {
10
11
  "needs attention": 0,
11
12
  locked: 1,
@@ -79,6 +80,16 @@ function extractCommand(fixHint, commandPrefix) {
79
80
  function resolveProviderHealthStatus(providerHealth) {
80
81
  if (!providerHealth || providerHealth.ok)
81
82
  return undefined;
83
+ const issue = providerHealth.issue;
84
+ if (issue?.kind === "vault-locked")
85
+ return "locked";
86
+ if (issue?.kind === "vault-unconfigured")
87
+ return "needs setup";
88
+ if (issue?.kind === "provider-credentials-missing")
89
+ return "needs credentials";
90
+ if (issue?.kind === "provider-live-check-failed") {
91
+ return issue.actions[0]?.kind === "provider-auth" ? "needs credentials" : "needs attention";
92
+ }
82
93
  const error = String(providerHealth.error).toLowerCase();
83
94
  const fix = String(providerHealth.fix).toLowerCase();
84
95
  if (error.includes("failed live check"))
@@ -99,7 +110,11 @@ function resolveProviderHealthStatus(providerHealth) {
99
110
  return "locked";
100
111
  return "needs attention";
101
112
  }
102
- function resolveProviderHealthCommand(fixHint, status) {
113
+ function resolveProviderHealthCommand(providerHealth, status) {
114
+ const issueCommand = (0, readiness_repair_1.preferredConnectRepairAction)(providerHealth?.issue)?.command;
115
+ if (issueCommand)
116
+ return issueCommand;
117
+ const fixHint = providerHealth?.fix;
103
118
  if (!fixHint)
104
119
  return undefined;
105
120
  const prefixes = status === "locked"
@@ -329,7 +344,7 @@ function renderNonTtyBay(entries, options) {
329
344
  }
330
345
  function summarizeProviderLane(agent, lane, providerHealth) {
331
346
  const providerHealthStatus = resolveProviderHealthStatus(providerHealth);
332
- const providerHealthCommand = resolveProviderHealthCommand(providerHealth?.fix, providerHealthStatus);
347
+ const providerHealthCommand = resolveProviderHealthCommand(providerHealth, providerHealthStatus);
333
348
  if (lane.status === "unconfigured") {
334
349
  return {
335
350
  lane: lane.lane,
@@ -372,7 +387,7 @@ function summarizeProviderLane(agent, lane, providerHealth) {
372
387
  status: "needs attention",
373
388
  title: `${lane.provider} / ${lane.model}`,
374
389
  detail: `failed live check: ${lane.readiness.error ?? "unknown error"}`,
375
- action: providerHealth?.fix ?? `ouro auth --agent ${agent} --provider ${lane.provider}`,
390
+ action: providerHealthCommand ?? providerHealth?.fix ?? `ouro auth --agent ${agent} --provider ${lane.provider}`,
376
391
  };
377
392
  }
378
393
  if (lane.readiness.status === "stale") {
@@ -404,7 +419,7 @@ function summarizeProvidersForConnect(agent, visibility, providerHealth) {
404
419
  const laneSummaries = visibility.lanes.map((lane) => summarizeProviderLane(agent, lane, providerHealth));
405
420
  const worstLaneStatus = laneSummaries.reduce((worst, lane) => CONNECT_STATUS_PRIORITY[lane.status] < CONNECT_STATUS_PRIORITY[worst] ? lane.status : worst, "ready");
406
421
  const providerHealthStatus = resolveProviderHealthStatus(providerHealth);
407
- const providerHealthCommand = resolveProviderHealthCommand(providerHealth?.fix, providerHealthStatus);
422
+ const providerHealthCommand = resolveProviderHealthCommand(providerHealth, providerHealthStatus);
408
423
  const nextLane = laneSummaries.find((lane) => isProblemStatus(lane.status));
409
424
  return {
410
425
  status: providerHealthStatus ?? worstLaneStatus,
@@ -22,7 +22,7 @@ function statusFromIssue(issue) {
22
22
  case "provider-credentials-missing":
23
23
  return "needs credentials";
24
24
  case "provider-live-check-failed":
25
- return "needs attention";
25
+ return issue.actions[0]?.kind === "provider-auth" ? "needs credentials" : "needs attention";
26
26
  case "generic":
27
27
  return "needs attention";
28
28
  }
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.vaultLockedIssue = vaultLockedIssue;
4
4
  exports.vaultUnconfiguredIssue = vaultUnconfiguredIssue;
5
5
  exports.providerCredentialMissingIssue = providerCredentialMissingIssue;
6
+ exports.providerLiveCheckFix = providerLiveCheckFix;
7
+ exports.preferredConnectRepairAction = preferredConnectRepairAction;
6
8
  exports.providerLiveCheckFailedIssue = providerLiveCheckFailedIssue;
7
9
  exports.genericReadinessIssue = genericReadinessIssue;
8
10
  exports.isKnownReadinessIssue = isKnownReadinessIssue;
@@ -92,6 +94,110 @@ function providerCredentialMissingIssue(input) {
92
94
  ],
93
95
  };
94
96
  }
97
+ function normalizeProviderLiveCheckClassification(classification) {
98
+ switch (classification) {
99
+ case "auth-failure":
100
+ case "usage-limit":
101
+ case "rate-limit":
102
+ case "server-error":
103
+ case "network-error":
104
+ case "unknown":
105
+ return classification;
106
+ default:
107
+ return "unknown";
108
+ }
109
+ }
110
+ function providerUseAction(input) {
111
+ return {
112
+ kind: "provider-use",
113
+ label: "Choose a different working provider/model",
114
+ command: `ouro use --agent ${input.agentName} --lane ${input.lane} --provider <provider> --model <model>`,
115
+ actor: "human-choice",
116
+ executable: false,
117
+ lane: input.lane,
118
+ };
119
+ }
120
+ function providerAuthAction(input) {
121
+ return {
122
+ kind: "provider-auth",
123
+ label: `Refresh ${input.provider} credentials`,
124
+ command: `ouro auth --agent ${input.agentName} --provider ${input.provider}`,
125
+ actor: "human-required",
126
+ provider: input.provider,
127
+ };
128
+ }
129
+ function providerRetryAction(input) {
130
+ return {
131
+ kind: "provider-retry",
132
+ label: input.label,
133
+ command: `ouro repair --agent ${input.agentName}`,
134
+ actor: "human-choice",
135
+ executable: false,
136
+ };
137
+ }
138
+ function providerLiveCheckFix(input) {
139
+ const classification = normalizeProviderLiveCheckClassification(input.classification);
140
+ const authCommand = `ouro auth --agent ${input.agentName} --provider ${input.provider}`;
141
+ const useCommand = `ouro use --agent ${input.agentName} --lane ${input.lane} --provider <provider> --model <model>`;
142
+ switch (classification) {
143
+ case "auth-failure":
144
+ return `Run '${authCommand}' to refresh credentials, or run '${useCommand}' to choose another provider/model for this lane.`;
145
+ case "usage-limit":
146
+ return `This usually means ${input.provider} hit a usage limit. Restore quota, then run 'ouro up' again. Or run '${useCommand}' to choose another provider/model for this lane.`;
147
+ case "rate-limit":
148
+ return `Run 'ouro up' again after a short wait. Or run '${useCommand}' to choose another provider/model for this lane.`;
149
+ case "server-error":
150
+ return `Run 'ouro up' again in a moment. If ${input.provider} keeps failing, run '${useCommand}' to choose another provider/model for this lane.`;
151
+ case "network-error":
152
+ return `Check the network or provider availability, then run 'ouro up' again. Or run '${useCommand}' to choose another provider/model for this lane.`;
153
+ case "unknown":
154
+ return `Run 'ouro up' again. If it keeps failing, run '${authCommand}' to refresh credentials or '${useCommand}' to choose another provider/model for this lane.`;
155
+ }
156
+ }
157
+ function providerLiveCheckActions(input) {
158
+ const classification = normalizeProviderLiveCheckClassification(input.classification);
159
+ const useAction = providerUseAction(input);
160
+ const authAction = providerAuthAction(input);
161
+ switch (classification) {
162
+ case "auth-failure":
163
+ return [authAction, useAction];
164
+ case "usage-limit":
165
+ return [
166
+ providerRetryAction({ agentName: input.agentName, label: "After restoring quota, check again" }),
167
+ useAction,
168
+ ];
169
+ case "rate-limit":
170
+ return [
171
+ providerRetryAction({ agentName: input.agentName, label: "Give it a minute, then check again" }),
172
+ useAction,
173
+ ];
174
+ case "server-error":
175
+ return [
176
+ providerRetryAction({ agentName: input.agentName, label: "Check again in a moment" }),
177
+ useAction,
178
+ ];
179
+ case "network-error":
180
+ return [
181
+ providerRetryAction({ agentName: input.agentName, label: "Check again after the network settles" }),
182
+ useAction,
183
+ authAction,
184
+ ];
185
+ case "unknown":
186
+ return [
187
+ providerRetryAction({ agentName: input.agentName, label: "Check again" }),
188
+ authAction,
189
+ useAction,
190
+ ];
191
+ }
192
+ }
193
+ function preferredConnectRepairAction(issue) {
194
+ if (!issue)
195
+ return undefined;
196
+ if (issue.kind === "provider-live-check-failed" && issue.actions[0]?.kind === "provider-retry") {
197
+ return issue.actions.find((action) => action.kind !== "provider-retry") ?? issue.actions[0];
198
+ }
199
+ return issue.actions[0];
200
+ }
95
201
  function providerLiveCheckFailedIssue(input) {
96
202
  return {
97
203
  kind: "provider-live-check-failed",
@@ -99,23 +205,7 @@ function providerLiveCheckFailedIssue(input) {
99
205
  actor: "human-choice",
100
206
  summary: `${input.agentName}: ${input.lane} provider ${input.provider} / ${input.model} failed live check`,
101
207
  detail: input.message,
102
- actions: [
103
- {
104
- kind: "provider-auth",
105
- label: `Refresh ${input.provider} credentials`,
106
- command: `ouro auth --agent ${input.agentName} --provider ${input.provider}`,
107
- actor: "human-required",
108
- provider: input.provider,
109
- },
110
- {
111
- kind: "provider-use",
112
- label: "Choose a different working provider/model for this lane",
113
- command: `ouro use --agent ${input.agentName} --lane ${input.lane} --provider <provider> --model <model>`,
114
- actor: "human-choice",
115
- executable: false,
116
- lane: input.lane,
117
- },
118
- ],
208
+ actions: providerLiveCheckActions(input),
119
209
  };
120
210
  }
121
211
  function genericReadinessIssue(input) {
@@ -106,6 +106,72 @@ function isWrapperCurrent(scriptPath, existsSync, readFileSync) {
106
106
  return false;
107
107
  }
108
108
  }
109
+ function isOwnedOuroLauncherPath(resolvedPath) {
110
+ const normalized = path.normalize(resolvedPath);
111
+ return (normalized.includes(`${path.sep}node_modules${path.sep}@ouro.bot${path.sep}cli${path.sep}`) ||
112
+ normalized.includes(`${path.sep}node_modules${path.sep}ouro.bot${path.sep}`));
113
+ }
114
+ function isOwnedOuroLauncherContent(content) {
115
+ return (content.includes("@ouro.bot/cli") ||
116
+ content.includes("ouro.bot@latest") ||
117
+ content.includes('exec npx --yes ouro.bot "$@"') ||
118
+ content.includes("CurrentVersion/node_modules/@ouro.bot/cli"));
119
+ }
120
+ function canRepairShadowedLauncher(shadowPath, existsSync, readFileSync, realpathSync) {
121
+ if (!existsSync(shadowPath))
122
+ return false;
123
+ try {
124
+ if (isOwnedOuroLauncherPath(realpathSync(shadowPath)))
125
+ return true;
126
+ }
127
+ catch {
128
+ // Fall through to content detection below.
129
+ }
130
+ try {
131
+ return isOwnedOuroLauncherContent(readFileSync(shadowPath, "utf-8"));
132
+ }
133
+ catch {
134
+ return false;
135
+ }
136
+ }
137
+ function repairShadowedLauncher(input) {
138
+ if (!canRepairShadowedLauncher(input.shadowPath, input.existsSync, input.readFileSync, input.realpathSync)) {
139
+ return null;
140
+ }
141
+ (0, runtime_1.emitNervesEvent)({
142
+ component: "daemon",
143
+ event: "daemon.ouro_path_shadow_repair_start",
144
+ message: "repairing stale shadowed ouro launcher",
145
+ meta: { shadowPath: input.shadowPath },
146
+ });
147
+ try {
148
+ if (input.lstatSync(input.shadowPath).isSymbolicLink()) {
149
+ input.unlinkSync(input.shadowPath);
150
+ }
151
+ input.writeFileSync(input.shadowPath, WRAPPER_SCRIPT, { mode: 0o755 });
152
+ input.chmodSync(input.shadowPath, 0o755);
153
+ (0, runtime_1.emitNervesEvent)({
154
+ component: "daemon",
155
+ event: "daemon.ouro_path_shadow_repair_end",
156
+ message: "repaired stale shadowed ouro launcher",
157
+ meta: { shadowPath: input.shadowPath },
158
+ });
159
+ return input.shadowPath;
160
+ }
161
+ catch (error) {
162
+ (0, runtime_1.emitNervesEvent)({
163
+ level: "warn",
164
+ component: "daemon",
165
+ event: "daemon.ouro_path_shadow_repair_error",
166
+ message: "failed to repair stale shadowed ouro launcher",
167
+ meta: {
168
+ shadowPath: input.shadowPath,
169
+ error: error instanceof Error ? error.message : String(error),
170
+ },
171
+ });
172
+ return null;
173
+ }
174
+ }
109
175
  function firstOuroOnPath(envPath, existsSync) {
110
176
  for (const dir of envPath.split(path.delimiter)) {
111
177
  if (!dir)
@@ -166,6 +232,9 @@ function installOuroCommand(deps = {}) {
166
232
  const readFileSync = deps.readFileSync ?? ((p, enc) => fs.readFileSync(p, enc));
167
233
  const appendFileSync = deps.appendFileSync ?? fs.appendFileSync;
168
234
  const chmodSync = deps.chmodSync ?? fs.chmodSync;
235
+ const realpathSync = deps.realpathSync ?? fs.realpathSync;
236
+ const lstatSync = deps.lstatSync ?? fs.lstatSync;
237
+ const unlinkSync = deps.unlinkSync ?? fs.unlinkSync;
169
238
  const envPath = deps.envPath ?? process.env.PATH ?? "";
170
239
  const shell = deps.shell ?? process.env.SHELL;
171
240
  /* v8 ignore stop */
@@ -212,7 +281,22 @@ function installOuroCommand(deps = {}) {
212
281
  }
213
282
  // ── Fast-path: modern wrapper already current ──
214
283
  if (modernCurrent) {
215
- const pathResolution = resolvePath();
284
+ let pathResolution = resolvePath();
285
+ const repairedShadowedLauncherPath = pathResolution.status === "shadowed" && pathResolution.resolvedPath
286
+ ? repairShadowedLauncher({
287
+ shadowPath: pathResolution.resolvedPath,
288
+ existsSync,
289
+ readFileSync,
290
+ writeFileSync,
291
+ chmodSync,
292
+ realpathSync,
293
+ lstatSync,
294
+ unlinkSync,
295
+ })
296
+ : null;
297
+ if (repairedShadowedLauncherPath) {
298
+ pathResolution = resolvePath();
299
+ }
216
300
  if (pathResolution.status === "shadowed") {
217
301
  (0, runtime_1.emitNervesEvent)({
218
302
  level: "warn",
@@ -228,7 +312,16 @@ function installOuroCommand(deps = {}) {
228
312
  message: "ouro command already installed",
229
313
  meta: { scriptPath, pathStatus: pathResolution.status, resolvedPath: pathResolution.resolvedPath },
230
314
  });
231
- return { installed: false, scriptPath, pathReady: isBinDirInPath(binDir, envPath), shellProfileUpdated: null, skippedReason: "already-installed", repairedOldLauncher, pathResolution };
315
+ return {
316
+ installed: false,
317
+ scriptPath,
318
+ pathReady: isBinDirInPath(binDir, envPath),
319
+ shellProfileUpdated: null,
320
+ skippedReason: "already-installed",
321
+ repairedOldLauncher,
322
+ repairedShadowedLauncherPath,
323
+ pathResolution,
324
+ };
232
325
  }
233
326
  (0, runtime_1.emitNervesEvent)({
234
327
  component: "daemon",
@@ -281,7 +374,22 @@ function installOuroCommand(deps = {}) {
281
374
  }
282
375
  }
283
376
  }
284
- const pathResolution = resolvePath();
377
+ let pathResolution = resolvePath();
378
+ const repairedShadowedLauncherPath = pathResolution.status === "shadowed" && pathResolution.resolvedPath
379
+ ? repairShadowedLauncher({
380
+ shadowPath: pathResolution.resolvedPath,
381
+ existsSync,
382
+ readFileSync,
383
+ writeFileSync,
384
+ chmodSync,
385
+ realpathSync,
386
+ lstatSync,
387
+ unlinkSync,
388
+ })
389
+ : null;
390
+ if (repairedShadowedLauncherPath) {
391
+ pathResolution = resolvePath();
392
+ }
285
393
  if (pathResolution.status === "shadowed") {
286
394
  (0, runtime_1.emitNervesEvent)({
287
395
  level: "warn",
@@ -295,7 +403,23 @@ function installOuroCommand(deps = {}) {
295
403
  component: "daemon",
296
404
  event: "daemon.ouro_path_install_end",
297
405
  message: "ouro command installed",
298
- meta: { scriptPath, pathReady, shellProfileUpdated, oldScriptPath: oldExists ? oldScriptPath : null, pathStatus: pathResolution.status, resolvedPath: pathResolution.resolvedPath },
406
+ meta: {
407
+ scriptPath,
408
+ pathReady,
409
+ shellProfileUpdated,
410
+ oldScriptPath: oldExists ? oldScriptPath : null,
411
+ repairedShadowedLauncherPath,
412
+ pathStatus: pathResolution.status,
413
+ resolvedPath: pathResolution.resolvedPath,
414
+ },
299
415
  });
300
- return { installed: true, scriptPath, pathReady, shellProfileUpdated, repairedOldLauncher, pathResolution };
416
+ return {
417
+ installed: true,
418
+ scriptPath,
419
+ pathReady,
420
+ shellProfileUpdated,
421
+ repairedOldLauncher,
422
+ repairedShadowedLauncherPath,
423
+ pathResolution,
424
+ };
301
425
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.437",
3
+ "version": "0.1.0-alpha.439",
4
4
  "main": "dist/heart/daemon/ouro-entry.js",
5
5
  "bin": {
6
6
  "cli": "dist/heart/daemon/ouro-bot-entry.js",