@ouro.bot/cli 0.1.0-alpha.662 → 0.1.0-alpha.664

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.
@@ -43,6 +43,7 @@ const runtime_1 = require("../nerves/runtime");
43
43
  const bundle_state_1 = require("./bundle-state");
44
44
  const tempo_1 = require("./tempo");
45
45
  const flight_recorder_1 = require("../arc/flight-recorder");
46
+ const context_loss_sentinel_1 = require("./context-loss-sentinel");
46
47
  function estimateTokens(text) {
47
48
  return Math.ceil(text.length / 4);
48
49
  }
@@ -193,6 +194,7 @@ function buildStartOfTurnPacket(view, opts) {
193
194
  cares: buildCaresSection(view.activeCares),
194
195
  presence: buildPresenceSection(view.peerPresence),
195
196
  arcResume: opts?.flightRecorderResume ? (0, flight_recorder_1.formatFlightRecorderResume)(opts.flightRecorderResume) : undefined,
197
+ recoverySentinel: opts?.recoverySentinel,
196
198
  resumeHint: buildResumeHint(view, opts?.canonicalObligations ? effectiveObligations : undefined),
197
199
  currentSessionTiming: opts?.currentSessionTiming,
198
200
  tempo,
@@ -234,6 +236,7 @@ function renderStartOfTurnPacket(packet) {
234
236
  { label: "bundleState", content: (0, bundle_state_1.renderBundleStateHint)(packet.bundleState ?? []), priority: 7 },
235
237
  { label: "syncFailure", content: packet.syncFailure ?? "", priority: 7 },
236
238
  { label: "arc", content: packet.arcResume ?? "", priority: 7 },
239
+ { label: "recoverySentinel", content: packet.recoverySentinel ? (0, context_loss_sentinel_1.formatContextLossSentinelText)(packet.recoverySentinel) : "", priority: 7 },
237
240
  { label: "resume", content: packet.resumeHint, priority: 6 },
238
241
  { label: "sessionTiming", content: packet.currentSessionTiming ?? "", priority: 5 },
239
242
  { label: "obligations", content: packet.obligations, priority: 5 },
@@ -260,7 +263,7 @@ function renderStartOfTurnPacket(packet) {
260
263
  if (tokens <= budget.max)
261
264
  break;
262
265
  // Skip continuity sections — they are protected.
263
- if (section.label === "resume" || section.label === "arc")
266
+ if (section.label === "resume" || section.label === "arc" || section.label === "recoverySentinel")
264
267
  continue;
265
268
  // Remove this section entirely
266
269
  const idx = sections.findIndex((s) => s.label === section.label);
@@ -291,6 +294,9 @@ function formatSections(sections) {
291
294
  case "arc":
292
295
  parts.push(`**Arc:**\n${section.content}`);
293
296
  break;
297
+ case "recoverySentinel":
298
+ parts.push(`**Recovery Sentinel:**\n${section.content}`);
299
+ break;
294
300
  case "obligations":
295
301
  parts.push(`**Owed:**\n${section.content}`);
296
302
  break;
@@ -61,6 +61,7 @@ const daemon_health_1 = require("./daemon/daemon-health");
61
61
  const provider_visibility_1 = require("./provider-visibility");
62
62
  const mail_import_discovery_1 = require("./mail-import-discovery");
63
63
  const flight_recorder_1 = require("../arc/flight-recorder");
64
+ const context_loss_sentinel_1 = require("./context-loss-sentinel");
64
65
  // ── Helpers ─────────────────────────────────────────────────────────
65
66
  const DAEMON_SOCKET_PATH = "/tmp/ouroboros-daemon.sock";
66
67
  function isLiveCodingSessionStatus(status) {
@@ -257,6 +258,15 @@ function degradedFlightRecorderResume(issue) {
257
258
  recorderHealth: { status: "degraded", issues: [issue] },
258
259
  };
259
260
  }
261
+ function degradedRecoverySentinel(issue) {
262
+ return {
263
+ schemaVersion: 1,
264
+ latest: null,
265
+ latestReady: null,
266
+ history: [],
267
+ degraded: { issues: [issue] },
268
+ };
269
+ }
260
270
  // ── Builder ─────────────────────────────────────────────────────────
261
271
  async function buildTurnContext(input) {
262
272
  const agentRoot = (0, identity_1.getAgentRoot)();
@@ -392,6 +402,15 @@ async function buildTurnContext(input) {
392
402
  flightRecorderResume = degradedFlightRecorderResume(`flight recorder read failed: ${reason}`);
393
403
  /* v8 ignore stop */
394
404
  }
405
+ let recoverySentinel;
406
+ try {
407
+ recoverySentinel = (0, context_loss_sentinel_1.readContextLossSentinelView)(agentRoot, { limit: 5 });
408
+ }
409
+ catch (error) { /* v8 ignore start -- defensive: fallback on read failure @preserve */
410
+ const reason = error instanceof Error ? error.message : String(error);
411
+ recoverySentinel = degradedRecoverySentinel(`Recovery Sentinel read failed: ${reason}`);
412
+ /* v8 ignore stop */
413
+ }
395
414
  (0, runtime_1.emitNervesEvent)({
396
415
  component: "senses",
397
416
  event: "senses.turn_context_built",
@@ -426,5 +445,6 @@ async function buildTurnContext(input) {
426
445
  bundleMeta,
427
446
  daemonHealth,
428
447
  flightRecorderResume,
448
+ recoverySentinel,
429
449
  };
430
450
  }