@ouro.bot/cli 0.1.0-alpha.63 → 0.1.0-alpha.637
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 +127 -23
- package/RepairGuide.ouro/agent.json +5 -0
- package/RepairGuide.ouro/psyche/IDENTITY.md +19 -0
- package/RepairGuide.ouro/psyche/SOUL.md +55 -0
- package/RepairGuide.ouro/skills/diagnose-broken-remote.md +63 -0
- package/RepairGuide.ouro/skills/diagnose-stacked-typed-issues.md +35 -0
- package/RepairGuide.ouro/skills/diagnose-sync-blocked.md +54 -0
- package/RepairGuide.ouro/skills/diagnose-vault-expired.md +60 -0
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +4 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +2 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +1 -1
- package/changelog.json +4081 -13
- package/dist/arc/attention-types.js +8 -0
- package/dist/arc/cares.js +144 -0
- package/dist/arc/episodes.js +118 -0
- package/dist/arc/evolution.js +487 -0
- package/dist/arc/intentions.js +134 -0
- package/dist/arc/json-store.js +117 -0
- package/dist/arc/obligations.js +270 -0
- package/dist/arc/packets.js +288 -0
- package/dist/arc/presence.js +185 -0
- package/dist/arc/task-lifecycle.js +57 -0
- package/dist/heart/active-work.js +860 -43
- package/dist/heart/agent-entry.js +69 -3
- package/dist/heart/attachments/image-normalize.js +194 -0
- package/dist/heart/attachments/materialize.js +97 -0
- package/dist/heart/attachments/originals.js +88 -0
- package/dist/heart/attachments/render.js +29 -0
- package/dist/heart/attachments/sources/bluebubbles.js +156 -0
- package/dist/heart/attachments/sources/cli-local-file.js +78 -0
- package/dist/heart/attachments/sources/index.js +16 -0
- package/dist/heart/attachments/store.js +103 -0
- package/dist/heart/attachments/types.js +93 -0
- package/dist/heart/auth/auth-flow.js +479 -0
- package/dist/heart/awaiting/await-alert.js +146 -0
- package/dist/heart/awaiting/await-expiry.js +108 -0
- package/dist/heart/awaiting/await-loader.js +91 -0
- package/dist/heart/awaiting/await-parser.js +141 -0
- package/dist/heart/awaiting/await-runtime-state.js +100 -0
- package/dist/heart/awaiting/await-scheduler.js +377 -0
- package/dist/heart/background-operations.js +281 -0
- package/dist/heart/bridges/manager.js +137 -17
- package/dist/heart/bridges/store.js +14 -2
- package/dist/heart/bundle-state.js +168 -0
- package/dist/heart/commitments.js +135 -0
- package/dist/heart/config-registry.js +322 -0
- package/dist/heart/config.js +114 -119
- package/dist/heart/core.js +1028 -248
- package/dist/heart/cross-chat-delivery.js +3 -18
- package/dist/heart/daemon/agent-config-check.js +419 -0
- package/dist/heart/daemon/agent-discovery.js +102 -3
- package/dist/heart/daemon/agent-service.js +522 -0
- package/dist/heart/daemon/agentic-repair.js +547 -0
- package/dist/heart/daemon/bluebubbles-health-diagnostics.js +122 -0
- package/dist/heart/daemon/boot-sync-probe.js +197 -0
- package/dist/heart/daemon/cadence.js +70 -0
- package/dist/heart/daemon/cli-defaults.js +776 -0
- package/dist/heart/daemon/cli-desk.js +322 -0
- package/dist/heart/daemon/cli-exec.js +7468 -0
- package/dist/heart/daemon/cli-help.js +505 -0
- package/dist/heart/daemon/cli-parse.js +1554 -0
- package/dist/heart/daemon/cli-render-doctor.js +57 -0
- package/dist/heart/daemon/cli-render.js +763 -0
- package/dist/heart/daemon/cli-types.js +8 -0
- package/dist/heart/daemon/connect-bay.js +323 -0
- package/dist/heart/daemon/daemon-cli.js +29 -1702
- package/dist/heart/daemon/daemon-entry.js +485 -2
- package/dist/heart/daemon/daemon-health.js +176 -0
- package/dist/heart/daemon/daemon-rollup.js +57 -0
- package/dist/heart/daemon/daemon-runtime-sync.js +88 -13
- package/dist/heart/daemon/daemon-tombstone.js +236 -0
- package/dist/heart/daemon/daemon.js +906 -71
- package/dist/heart/daemon/dns-workflow.js +394 -0
- package/dist/heart/daemon/doctor-types.js +8 -0
- package/dist/heart/daemon/doctor.js +873 -0
- package/dist/heart/daemon/health-monitor.js +122 -1
- package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
- package/dist/heart/daemon/hooks/bundle-meta.js +115 -1
- package/dist/heart/daemon/http-health-probe.js +80 -0
- package/dist/heart/daemon/human-command-screens.js +234 -0
- package/dist/heart/daemon/human-readiness.js +114 -0
- package/dist/heart/daemon/inner-status.js +89 -0
- package/dist/heart/daemon/interactive-repair.js +394 -0
- package/dist/heart/daemon/launchd.js +37 -8
- package/dist/heart/daemon/log-tailer.js +79 -10
- package/dist/heart/daemon/logs-prune.js +110 -0
- package/dist/heart/daemon/mcp-canary.js +297 -0
- package/dist/heart/daemon/migrate-to-desk.js +848 -0
- package/dist/heart/daemon/os-cron-deps.js +135 -0
- package/dist/heart/daemon/os-cron.js +14 -12
- package/dist/heart/daemon/ouro-bot-entry.js +4 -2
- package/dist/heart/daemon/ouro-entry.js +3 -1
- package/dist/heart/daemon/plugin-cli.js +432 -0
- package/dist/heart/daemon/process-manager.js +501 -35
- package/dist/heart/daemon/provider-discovery.js +137 -0
- package/dist/heart/daemon/provider-ping-progress.js +83 -0
- package/dist/heart/daemon/pulse.js +475 -0
- package/dist/heart/daemon/readiness-repair.js +365 -0
- package/dist/heart/daemon/run-hooks.js +2 -0
- package/dist/heart/daemon/runtime-logging.js +11 -3
- package/dist/heart/daemon/runtime-metadata.js +2 -30
- package/dist/heart/daemon/safe-mode.js +161 -0
- package/dist/heart/daemon/sense-manager.js +493 -38
- package/dist/heart/daemon/session-id-resolver.js +131 -0
- package/dist/heart/daemon/skill-management-installer.js +1 -1
- package/dist/heart/daemon/socket-client.js +158 -11
- package/dist/heart/daemon/stale-bundle-prune.js +96 -0
- package/dist/heart/daemon/startup-tui.js +330 -0
- package/dist/heart/daemon/task-scheduler.js +117 -39
- package/dist/heart/daemon/terminal-ui.js +499 -0
- package/dist/heart/daemon/thoughts.js +229 -17
- package/dist/heart/daemon/up-progress.js +366 -0
- package/dist/heart/daemon/vault-items.js +56 -0
- package/dist/heart/delegation.js +1 -4
- package/dist/heart/habits/habit-migration.js +189 -0
- package/dist/heart/habits/habit-parser.js +140 -0
- package/dist/heart/habits/habit-runtime-state.js +100 -0
- package/dist/heart/habits/habit-scheduler.js +372 -0
- package/dist/heart/{daemon → hatch}/hatch-flow.js +32 -56
- package/dist/heart/{daemon → hatch}/hatch-specialist.js +6 -8
- package/dist/heart/{daemon → hatch}/specialist-prompt.js +12 -9
- package/dist/heart/{daemon → hatch}/specialist-tools.js +37 -14
- package/dist/heart/identity.js +168 -57
- package/dist/heart/kept-notes.js +357 -0
- package/dist/heart/kicks.js +1 -1
- package/dist/heart/machine-identity.js +161 -0
- package/dist/heart/mail-import-discovery.js +353 -0
- package/dist/heart/mailbox/mailbox-http-hooks.js +66 -0
- package/dist/heart/mailbox/mailbox-http-response.js +7 -0
- package/dist/heart/mailbox/mailbox-http-routes.js +246 -0
- package/dist/heart/mailbox/mailbox-http-static.js +103 -0
- package/dist/heart/mailbox/mailbox-http-transport.js +116 -0
- package/dist/heart/mailbox/mailbox-http.js +99 -0
- package/dist/heart/mailbox/mailbox-read.js +31 -0
- package/dist/heart/mailbox/mailbox-types.js +27 -0
- package/dist/heart/mailbox/mailbox-view.js +197 -0
- package/dist/heart/mailbox/readers/agent-machine.js +418 -0
- package/dist/heart/mailbox/readers/continuity-readers.js +319 -0
- package/dist/heart/mailbox/readers/mail.js +375 -0
- package/dist/heart/mailbox/readers/runtime-readers.js +756 -0
- package/dist/heart/mailbox/readers/sessions.js +232 -0
- package/dist/heart/mailbox/readers/shared.js +111 -0
- package/dist/heart/mcp/mcp-server.js +692 -0
- package/dist/heart/migrate-config.js +100 -0
- package/dist/heart/model-capabilities.js +19 -0
- package/dist/heart/orientation-frame.js +217 -0
- package/dist/heart/platform.js +81 -0
- package/dist/heart/provider-attempt.js +134 -0
- package/dist/heart/provider-binding-resolver.js +272 -0
- package/dist/heart/provider-credentials.js +425 -0
- package/dist/heart/provider-failover.js +301 -0
- package/dist/heart/provider-models.js +81 -0
- package/dist/heart/provider-ping.js +262 -0
- package/dist/heart/provider-readiness-cache.js +40 -0
- package/dist/heart/provider-visibility.js +188 -0
- package/dist/heart/providers/anthropic-token.js +131 -0
- package/dist/heart/providers/anthropic.js +139 -52
- package/dist/heart/providers/azure.js +23 -11
- package/dist/heart/providers/error-classification.js +127 -0
- package/dist/heart/providers/github-copilot.js +145 -0
- package/dist/heart/providers/minimax-vlm.js +189 -0
- package/dist/heart/providers/minimax.js +26 -8
- package/dist/heart/providers/openai-codex.js +55 -40
- package/dist/heart/runtime-capability-check.js +170 -0
- package/dist/heart/runtime-credentials.js +367 -0
- package/dist/heart/runtime-cwd.js +87 -0
- package/dist/heart/sense-truth.js +13 -4
- package/dist/heart/session-activity.js +48 -24
- package/dist/heart/session-events.js +1163 -0
- package/dist/heart/session-playback-cli-main.js +5 -0
- package/dist/heart/session-playback-cli.js +36 -0
- package/dist/heart/session-playback.js +231 -0
- package/dist/heart/session-stats-cli-main.js +5 -0
- package/dist/heart/session-stats.js +182 -0
- package/dist/heart/session-transcript.js +133 -0
- package/dist/heart/start-of-turn-packet.js +345 -0
- package/dist/heart/streaming.js +44 -27
- package/dist/heart/structured-output.js +196 -0
- package/dist/heart/sync-classification.js +176 -0
- package/dist/heart/sync.js +449 -0
- package/dist/heart/target-resolution.js +9 -5
- package/dist/heart/tempo.js +93 -0
- package/dist/heart/temporal-view.js +41 -0
- package/dist/heart/timeouts.js +101 -0
- package/dist/heart/tool-activity-callbacks.js +59 -0
- package/dist/heart/tool-description.js +143 -0
- package/dist/heart/tool-friction.js +55 -0
- package/dist/heart/tool-loop.js +200 -0
- package/dist/heart/turn-context.js +389 -0
- package/dist/heart/{daemon → versioning}/ouro-bot-global-installer.js +6 -5
- package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +1 -1
- package/dist/heart/versioning/ouro-path-installer.js +426 -0
- package/dist/heart/versioning/ouro-version-manager.js +295 -0
- package/dist/heart/{daemon → versioning}/staged-restart.js +40 -8
- package/dist/heart/{daemon → versioning}/update-checker.js +6 -1
- package/dist/heart/{daemon → versioning}/update-hooks.js +63 -59
- package/dist/mailbox-ui/assets/index-9-AxCxuB.js +61 -0
- package/dist/mailbox-ui/assets/index-CWzt267f.css +1 -0
- package/dist/mailbox-ui/index.html +15 -0
- package/dist/mailroom/attention.js +167 -0
- package/dist/mailroom/autonomy.js +209 -0
- package/dist/mailroom/blob-store.js +715 -0
- package/dist/mailroom/body-cache.js +61 -0
- package/dist/mailroom/core.js +788 -0
- package/dist/mailroom/entry.js +160 -0
- package/dist/mailroom/file-store.js +568 -0
- package/dist/mailroom/mbox-import.js +393 -0
- package/dist/mailroom/migration.js +164 -0
- package/dist/mailroom/outbound.js +380 -0
- package/dist/mailroom/policy.js +263 -0
- package/dist/mailroom/reader.js +233 -0
- package/dist/mailroom/search-cache.js +334 -0
- package/dist/mailroom/search-relevance.js +319 -0
- package/dist/mailroom/smtp-ingress.js +176 -0
- package/dist/mailroom/source-state.js +176 -0
- package/dist/mailroom/thread.js +109 -0
- package/dist/mailroom/travel-extract.js +89 -0
- package/dist/mind/bundle-manifest.js +14 -1
- package/dist/mind/context.js +251 -101
- package/dist/mind/desk-section.js +310 -0
- package/dist/mind/diary-integrity.js +60 -0
- package/dist/mind/{memory.js → diary.js} +68 -76
- package/dist/mind/embedding-provider.js +60 -0
- package/dist/mind/file-state.js +179 -0
- package/dist/mind/friends/channel.js +39 -0
- package/dist/mind/friends/resolver.js +54 -2
- package/dist/mind/friends/store-file.js +48 -4
- package/dist/mind/friends/types.js +2 -2
- package/dist/mind/journal-index.js +162 -0
- package/dist/mind/note-search.js +268 -0
- package/dist/mind/obligation-steering.js +221 -0
- package/dist/mind/pending.js +6 -1
- package/dist/mind/prompt-refresh.js +3 -2
- package/dist/mind/prompt.js +1075 -146
- package/dist/mind/provenance-trust.js +26 -0
- package/dist/mind/scrutiny.js +173 -0
- package/dist/nerves/cli-logging.js +7 -1
- package/dist/nerves/coverage/audit-rules.js +15 -6
- package/dist/nerves/coverage/audit.js +28 -2
- package/dist/nerves/coverage/cli.js +1 -1
- package/dist/nerves/coverage/contract.js +5 -5
- package/dist/nerves/coverage/file-completeness.js +139 -5
- package/dist/nerves/event-buffer.js +111 -0
- package/dist/nerves/index.js +224 -4
- package/dist/nerves/observation.js +20 -0
- package/dist/nerves/redact.js +79 -0
- package/dist/nerves/review/cli-main.js +5 -0
- package/dist/nerves/review/cli.js +156 -0
- package/dist/nerves/review/core.js +152 -0
- package/dist/nerves/runtime.js +5 -1
- package/dist/repertoire/ado-client.js +15 -56
- package/dist/repertoire/ado-semantic.js +16 -10
- package/dist/repertoire/api-client.js +97 -0
- package/dist/repertoire/bitwarden-store.js +1040 -0
- package/dist/repertoire/bundle-templates.js +72 -0
- package/dist/repertoire/bw-installer.js +180 -0
- package/dist/repertoire/coding/codex-jsonl.js +64 -0
- package/dist/repertoire/coding/context-pack.js +331 -0
- package/dist/repertoire/coding/feedback.js +197 -30
- package/dist/repertoire/coding/manager.js +166 -10
- package/dist/repertoire/coding/spawner.js +55 -9
- package/dist/repertoire/coding/tools.js +219 -7
- package/dist/repertoire/commerce-errors.js +109 -0
- package/dist/repertoire/commerce-self-test.js +156 -0
- package/dist/repertoire/credential-access.js +178 -0
- package/dist/repertoire/desk/classifier.js +362 -0
- package/dist/repertoire/duffel-client.js +185 -0
- package/dist/repertoire/github-client.js +14 -55
- package/dist/repertoire/graph-client.js +11 -52
- package/dist/repertoire/guardrails.js +385 -0
- package/dist/repertoire/mcp-client.js +295 -0
- package/dist/repertoire/mcp-manager.js +403 -0
- package/dist/repertoire/mcp-tools.js +83 -0
- package/dist/repertoire/plugin-mcp.js +175 -0
- package/dist/repertoire/plugins.js +253 -0
- package/dist/repertoire/shell-sessions.js +133 -0
- package/dist/repertoire/skills.js +48 -4
- package/dist/repertoire/stripe-client.js +131 -0
- package/dist/repertoire/tool-results.js +29 -0
- package/dist/repertoire/tools-attachments.js +317 -0
- package/dist/repertoire/tools-awaiting.js +372 -0
- package/dist/repertoire/tools-base.js +59 -1082
- package/dist/repertoire/tools-bluebubbles.js +2 -0
- package/dist/repertoire/tools-bridge.js +144 -0
- package/dist/repertoire/tools-bundle.js +993 -0
- package/dist/repertoire/tools-config.js +186 -0
- package/dist/repertoire/tools-continuity.js +252 -0
- package/dist/repertoire/tools-credential.js +383 -0
- package/dist/repertoire/tools-evolution.js +527 -0
- package/dist/repertoire/tools-files.js +344 -0
- package/dist/repertoire/tools-flight.js +227 -0
- package/dist/repertoire/tools-flow.js +119 -0
- package/dist/repertoire/tools-github.js +3 -8
- package/dist/repertoire/tools-mail.js +1975 -0
- package/dist/repertoire/tools-notes.js +438 -0
- package/dist/repertoire/tools-obligations.js +143 -0
- package/dist/repertoire/tools-orientation.js +31 -0
- package/dist/repertoire/tools-record.js +464 -0
- package/dist/repertoire/tools-runtime.js +150 -0
- package/dist/repertoire/tools-session.js +766 -0
- package/dist/repertoire/tools-shell.js +120 -0
- package/dist/repertoire/tools-stripe.js +182 -0
- package/dist/repertoire/tools-surface.js +344 -0
- package/dist/repertoire/tools-teams.js +12 -39
- package/dist/repertoire/tools-travel.js +125 -0
- package/dist/repertoire/tools-trip.js +982 -0
- package/dist/repertoire/tools-user-profile.js +146 -0
- package/dist/repertoire/tools-vault.js +40 -0
- package/dist/repertoire/tools-voice.js +145 -0
- package/dist/repertoire/tools.js +215 -103
- package/dist/repertoire/travel-api-client.js +360 -0
- package/dist/repertoire/user-profile.js +131 -0
- package/dist/repertoire/vault-setup.js +246 -0
- package/dist/repertoire/vault-unlock.js +594 -0
- package/dist/scripts/claude-code-hook.js +41 -0
- package/dist/scripts/claude-code-stop-hook.js +47 -0
- package/dist/senses/attention-queue.js +186 -0
- package/dist/senses/await-turn-message.js +58 -0
- package/dist/senses/bluebubbles/active-turns.js +216 -0
- package/dist/senses/bluebubbles/attachment-cache.js +53 -0
- package/dist/senses/bluebubbles/attachment-download.js +137 -0
- package/dist/senses/{bluebubbles-client.js → bluebubbles/client.js} +219 -18
- package/dist/senses/bluebubbles/entry.js +77 -0
- package/dist/senses/{bluebubbles-inbound-log.js → bluebubbles/inbound-log.js} +20 -3
- package/dist/senses/bluebubbles/index.js +2737 -0
- package/dist/senses/{bluebubbles-media.js → bluebubbles/media.js} +121 -71
- package/dist/senses/{bluebubbles-model.js → bluebubbles/model.js} +33 -12
- package/dist/senses/{bluebubbles-mutation-log.js → bluebubbles/mutation-log.js} +3 -3
- package/dist/senses/bluebubbles/processed-log.js +133 -0
- package/dist/senses/bluebubbles/replay.js +137 -0
- package/dist/senses/{bluebubbles-runtime-state.js → bluebubbles/runtime-state.js} +30 -2
- package/dist/senses/{bluebubbles-session-cleanup.js → bluebubbles/session-cleanup.js} +1 -1
- package/dist/senses/bluebubbles-meta-guard.js +40 -0
- package/dist/senses/cli/bracketed-paste.js +82 -0
- package/dist/senses/cli/image-paste.js +287 -0
- package/dist/senses/cli/image-ref-navigation.js +75 -0
- package/dist/senses/cli/ink-app.js +156 -0
- package/dist/senses/cli/inline-diff.js +64 -0
- package/dist/senses/cli/input-keys.js +174 -0
- package/dist/senses/cli/kill-ring.js +86 -0
- package/dist/senses/cli/message-list.js +51 -0
- package/dist/senses/cli/ouro-tui.js +607 -0
- package/dist/senses/cli/spinner-imperative.js +135 -0
- package/dist/senses/cli/spinner.js +101 -0
- package/dist/senses/cli/status-line.js +60 -0
- package/dist/senses/cli/streaming-markdown.js +526 -0
- package/dist/senses/cli/tool-display.js +85 -0
- package/dist/senses/cli/tool-render.js +85 -0
- package/dist/senses/cli/tui-store.js +240 -0
- package/dist/senses/cli/virtual-list.js +35 -0
- package/dist/senses/cli-entry.js +60 -8
- package/dist/senses/cli-layout.js +100 -0
- package/dist/senses/cli.js +517 -204
- package/dist/senses/commands.js +66 -3
- package/dist/senses/habit-turn-message.js +108 -0
- package/dist/senses/inner-dialog-worker.js +254 -22
- package/dist/senses/inner-dialog.js +505 -40
- package/dist/senses/mail-entry.js +66 -0
- package/dist/senses/mail.js +379 -0
- package/dist/senses/pipeline.js +666 -181
- package/dist/senses/proactive-content-guard.js +51 -0
- package/dist/senses/shared-turn.js +393 -0
- package/dist/senses/surface-tool.js +108 -0
- package/dist/senses/teams-entry.js +60 -8
- package/dist/senses/teams.js +388 -98
- package/dist/senses/trust-gate.js +100 -5
- package/dist/senses/voice/audio-playback.js +237 -0
- package/dist/senses/voice/audio-routing.js +119 -0
- package/dist/senses/voice/elevenlabs.js +202 -0
- package/dist/senses/voice/floor-control.js +431 -0
- package/dist/senses/voice/floor-controller.js +115 -0
- package/dist/senses/voice/golden-path.js +116 -0
- package/dist/senses/voice/index.js +29 -0
- package/dist/senses/voice/meeting.js +113 -0
- package/dist/senses/voice/outbound.js +190 -0
- package/dist/senses/voice/phone.js +33 -0
- package/dist/senses/voice/playback.js +139 -0
- package/dist/senses/voice/realtime-eval.js +496 -0
- package/dist/senses/voice/realtime-trace.js +531 -0
- package/dist/senses/voice/transcript.js +70 -0
- package/dist/senses/voice/turn.js +191 -0
- package/dist/senses/voice/twilio-phone-runtime.js +807 -0
- package/dist/senses/voice/twilio-phone.js +5079 -0
- package/dist/senses/voice/types.js +2 -0
- package/dist/senses/voice/whisper.js +161 -0
- package/dist/senses/voice-entry.js +81 -0
- package/dist/senses/voice-realtime-eval-command.js +99 -0
- package/dist/senses/voice-realtime-eval-entry.js +21 -0
- package/dist/senses/voice-twilio-entry.js +87 -0
- package/dist/trips/core.js +138 -0
- package/dist/trips/store.js +265 -0
- package/dist/util/frontmatter.js +53 -0
- package/package.json +48 -8
- package/skills/agent-commerce.md +106 -0
- package/skills/browser-navigation.md +117 -0
- package/skills/commerce-setup-guide.md +116 -0
- package/skills/commerce-setup.md +84 -0
- package/skills/configure-dev-tools.md +99 -0
- package/skills/travel-planning.md +138 -0
- package/dist/heart/daemon/auth-flow.js +0 -351
- package/dist/heart/daemon/ouro-path-installer.js +0 -178
- package/dist/heart/safe-workspace.js +0 -228
- package/dist/heart/session-recall.js +0 -116
- package/dist/mind/associative-recall.js +0 -209
- package/dist/repertoire/tasks/board.js +0 -134
- package/dist/repertoire/tasks/index.js +0 -224
- package/dist/repertoire/tasks/lifecycle.js +0 -80
- package/dist/repertoire/tasks/middleware.js +0 -65
- package/dist/repertoire/tasks/parser.js +0 -173
- package/dist/repertoire/tasks/scanner.js +0 -132
- package/dist/repertoire/tasks/transitions.js +0 -144
- package/dist/senses/bluebubbles-entry.js +0 -13
- package/dist/senses/bluebubbles.js +0 -1177
- package/dist/senses/debug-activity.js +0 -148
- package/subagents/README.md +0 -7
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
- /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
- /package/dist/{repertoire/tasks/types.js → heart/attachments/sources/adapter.js} +0 -0
- /package/dist/heart/{daemon → hatch}/hatch-animation.js +0 -0
- /package/dist/heart/{daemon → hatch}/specialist-orchestrator.js +0 -0
- /package/dist/heart/{daemon → versioning}/ouro-uti.js +0 -0
- /package/dist/heart/{daemon → versioning}/wrapper-publish-guard.js +0 -0
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatOtherActiveSessionSummaries = formatOtherActiveSessionSummaries;
|
|
3
4
|
exports.suggestBridgeForActiveWork = suggestBridgeForActiveWork;
|
|
4
5
|
exports.buildActiveWorkFrame = buildActiveWorkFrame;
|
|
5
6
|
exports.formatActiveWorkFrame = formatActiveWorkFrame;
|
|
7
|
+
exports.formatLiveWorldStateCheckpoint = formatLiveWorldStateCheckpoint;
|
|
8
|
+
exports.snapshotActiveWork = snapshotActiveWork;
|
|
9
|
+
exports.detectActiveWorkChanges = detectActiveWorkChanges;
|
|
10
|
+
exports.formatActiveWorkChanges = formatActiveWorkChanges;
|
|
6
11
|
const runtime_1 = require("../nerves/runtime");
|
|
7
12
|
const state_machine_1 = require("./bridges/state-machine");
|
|
13
|
+
const obligations_1 = require("../arc/obligations");
|
|
8
14
|
const target_resolution_1 = require("./target-resolution");
|
|
15
|
+
const config_1 = require("./config");
|
|
16
|
+
const RECENT_ACTIVE_OBLIGATION_WINDOW_MS = 60 * 60 * 1000;
|
|
9
17
|
function activityPriority(source) {
|
|
10
18
|
return source === "friend-facing" ? 0 : 1;
|
|
11
19
|
}
|
|
@@ -15,21 +23,501 @@ function compareActivity(a, b) {
|
|
|
15
23
|
return sourceDiff;
|
|
16
24
|
return b.lastActivityMs - a.lastActivityMs;
|
|
17
25
|
}
|
|
18
|
-
function summarizeLiveTasks(taskBoard) {
|
|
19
|
-
const live = [
|
|
20
|
-
...taskBoard.byStatus.processing,
|
|
21
|
-
...taskBoard.byStatus.validating,
|
|
22
|
-
...taskBoard.byStatus.collaborating,
|
|
23
|
-
];
|
|
24
|
-
return [...new Set(live)];
|
|
25
|
-
}
|
|
26
26
|
function isActiveBridge(bridge) {
|
|
27
27
|
return bridge.lifecycle === "active";
|
|
28
28
|
}
|
|
29
29
|
function hasSharedObligationPressure(input) {
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
return input.mustResolveBeforeHandoff
|
|
31
|
+
|| activeObligationCount(input.pendingObligations) > 0;
|
|
32
|
+
}
|
|
33
|
+
function formatCodingLaneLabel(session) {
|
|
34
|
+
return `${session.runner} ${session.id}`;
|
|
35
|
+
}
|
|
36
|
+
function compactCodingCheckpoint(session) {
|
|
37
|
+
const checkpoint = session.checkpoint?.replace(/\s+/g, " ").trim();
|
|
38
|
+
if (!checkpoint)
|
|
39
|
+
return "";
|
|
40
|
+
return checkpoint.length <= 80 ? checkpoint : `${checkpoint.slice(0, 77)}...`;
|
|
41
|
+
}
|
|
42
|
+
function describeCodingSessionScope(session, currentSession) {
|
|
43
|
+
if (!session.originSession)
|
|
44
|
+
return "";
|
|
45
|
+
if (currentSession
|
|
46
|
+
&& session.originSession.friendId === currentSession.friendId
|
|
47
|
+
&& session.originSession.channel === currentSession.channel
|
|
48
|
+
&& session.originSession.key === currentSession.key) {
|
|
49
|
+
return " for this thread";
|
|
50
|
+
}
|
|
51
|
+
return ` for ${session.originSession.channel}/${session.originSession.key}`;
|
|
52
|
+
}
|
|
53
|
+
function activeObligationCount(obligations) {
|
|
54
|
+
return (obligations ?? []).filter((ob) => (0, obligations_1.isOpenObligationStatus)(ob.status)).length;
|
|
55
|
+
}
|
|
56
|
+
const TERMINAL_EVOLUTION_CASE_STATUSES = new Set(["closed", "blocked", "deferred"]);
|
|
57
|
+
function liveEvolutionCases(cases) {
|
|
58
|
+
return (cases ?? []).filter((evolutionCase) => !TERMINAL_EVOLUTION_CASE_STATUSES.has(evolutionCase.status));
|
|
59
|
+
}
|
|
60
|
+
function formatEvolutionCaseLine(evolutionCase) {
|
|
61
|
+
return `- [${evolutionCase.status}] ${evolutionCase.id}: ${evolutionCase.title}; next: ${evolutionCase.nextAction}; budget: ${evolutionCase.budgetProfile}`;
|
|
62
|
+
}
|
|
63
|
+
function formatEvolutionCheckpointLine(cases) {
|
|
64
|
+
const [currentCase, ...otherCases] = cases;
|
|
65
|
+
if (!currentCase)
|
|
66
|
+
return null;
|
|
67
|
+
const suffix = otherCases.length > 0 ? ` (${otherCases.length + 1} open cases)` : "";
|
|
68
|
+
return `- evolution case: [${currentCase.status}] ${currentCase.id} ${currentCase.title}; next ${currentCase.nextAction}${suffix}`;
|
|
69
|
+
}
|
|
70
|
+
function obligationOriginKey(obligation) {
|
|
71
|
+
return `${obligation.origin.friendId}/${obligation.origin.channel}/${(0, config_1.sanitizeKey)(obligation.origin.key)}`;
|
|
72
|
+
}
|
|
73
|
+
function buildLiveCodingLabelSet(codingSessions, otherCodingSessions) {
|
|
74
|
+
return new Set([
|
|
75
|
+
...codingSessions.map(formatCodingLaneLabel),
|
|
76
|
+
...otherCodingSessions.map(formatCodingLaneLabel),
|
|
77
|
+
]);
|
|
78
|
+
}
|
|
79
|
+
function isMaterialActiveObligation(obligation, liveCodingLabels, nowMs) {
|
|
80
|
+
if (obligation.currentArtifact?.trim())
|
|
81
|
+
return true;
|
|
82
|
+
if (obligation.status === "waiting_for_merge" || obligation.status === "updating_runtime")
|
|
83
|
+
return true;
|
|
84
|
+
const surface = obligation.currentSurface;
|
|
85
|
+
if (surface?.kind === "merge" || surface?.kind === "runtime")
|
|
86
|
+
return true;
|
|
87
|
+
const recentlyTouched = (nowMs - obligationTimestampMs(obligation)) <= RECENT_ACTIVE_OBLIGATION_WINDOW_MS;
|
|
88
|
+
if (surface?.kind === "coding") {
|
|
89
|
+
const liveLabel = surface.label.trim();
|
|
90
|
+
return (liveLabel.length > 0 && liveCodingLabels.has(liveLabel)) || recentlyTouched;
|
|
91
|
+
}
|
|
92
|
+
return recentlyTouched;
|
|
93
|
+
}
|
|
94
|
+
function normalizePendingObligations(obligations, codingSessions, otherCodingSessions) {
|
|
95
|
+
const openObligations = (obligations ?? []).filter((obligation) => (0, obligations_1.isOpenObligationStatus)(obligation.status));
|
|
96
|
+
if (openObligations.length === 0)
|
|
97
|
+
return [];
|
|
98
|
+
const liveCodingLabels = buildLiveCodingLabelSet(codingSessions, otherCodingSessions);
|
|
99
|
+
const nowMs = Date.now();
|
|
100
|
+
const normalized = [];
|
|
101
|
+
const seenOrigins = new Set();
|
|
102
|
+
for (const obligation of [...openObligations].sort(newestObligationFirst)) {
|
|
103
|
+
if (!isMaterialActiveObligation(obligation, liveCodingLabels, nowMs))
|
|
104
|
+
continue;
|
|
105
|
+
const originKey = obligationOriginKey(obligation);
|
|
106
|
+
if (seenOrigins.has(originKey))
|
|
107
|
+
continue;
|
|
108
|
+
seenOrigins.add(originKey);
|
|
109
|
+
normalized.push(obligation);
|
|
110
|
+
}
|
|
111
|
+
return normalized;
|
|
112
|
+
}
|
|
113
|
+
function formatObligationSurface(obligation) {
|
|
114
|
+
if (!obligation.currentSurface?.label)
|
|
115
|
+
return "";
|
|
116
|
+
switch (obligation.status) {
|
|
117
|
+
case "investigating":
|
|
118
|
+
return ` (working in ${obligation.currentSurface.label})`;
|
|
119
|
+
case "waiting_for_merge":
|
|
120
|
+
return ` (waiting at ${obligation.currentSurface.label})`;
|
|
121
|
+
case "updating_runtime":
|
|
122
|
+
return ` (updating via ${obligation.currentSurface.label})`;
|
|
123
|
+
default:
|
|
124
|
+
return ` (${obligation.currentSurface.label})`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function mergeArtifactFallback(obligation) {
|
|
128
|
+
const trimmed = obligation.content.trim();
|
|
129
|
+
if (!trimmed)
|
|
130
|
+
return "the fix";
|
|
131
|
+
const stripped = trimmed.replace(/^merge(?:\s+|$)/i, "").trim();
|
|
132
|
+
return stripped || "the fix";
|
|
133
|
+
}
|
|
134
|
+
function formatMergeArtifact(obligation) {
|
|
135
|
+
const currentArtifact = obligation.currentArtifact?.trim();
|
|
136
|
+
if (currentArtifact)
|
|
137
|
+
return currentArtifact;
|
|
138
|
+
if (obligation.currentSurface?.kind === "merge") {
|
|
139
|
+
const surfaceLabel = obligation.currentSurface.label.trim();
|
|
140
|
+
if (surfaceLabel)
|
|
141
|
+
return surfaceLabel;
|
|
142
|
+
}
|
|
143
|
+
return mergeArtifactFallback(obligation);
|
|
144
|
+
}
|
|
145
|
+
/* v8 ignore start -- Epic 1: obligation selection, resume handles, change detection @preserve */
|
|
146
|
+
function obligationStatusPriority(status) {
|
|
147
|
+
switch (status) {
|
|
148
|
+
case "investigating": return 0;
|
|
149
|
+
case "waiting_for_merge": return 1;
|
|
150
|
+
case "updating_runtime": return 2;
|
|
151
|
+
case "pending": return 3;
|
|
152
|
+
case "fulfilled": return 4;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function selectPrimaryObligation(obligations, currentSession) {
|
|
156
|
+
const open = obligations.filter(obligations_1.isOpenObligation);
|
|
157
|
+
if (open.length === 0)
|
|
158
|
+
return null;
|
|
159
|
+
// Prefer current-session match among advanced (non-pending) obligations
|
|
160
|
+
const sessionMatch = currentSession
|
|
161
|
+
? open.find((ob) => ob.status !== "pending"
|
|
162
|
+
&& ob.origin.friendId === currentSession.friendId
|
|
163
|
+
&& ob.origin.channel === currentSession.channel
|
|
164
|
+
&& (0, config_1.sanitizeKey)(ob.origin.key) === (0, config_1.sanitizeKey)(currentSession.key))
|
|
165
|
+
: null;
|
|
166
|
+
if (sessionMatch)
|
|
167
|
+
return sessionMatch;
|
|
168
|
+
// Then any advanced obligation, sorted by status priority then freshness
|
|
169
|
+
const sorted = [...open].sort((a, b) => {
|
|
170
|
+
const statusDiff = obligationStatusPriority(a.status) - obligationStatusPriority(b.status);
|
|
171
|
+
if (statusDiff !== 0)
|
|
172
|
+
return statusDiff;
|
|
173
|
+
return obligationTimestampMs(b) - obligationTimestampMs(a);
|
|
174
|
+
});
|
|
175
|
+
return sorted[0] ?? null;
|
|
176
|
+
}
|
|
177
|
+
function findPrimaryOpenObligation(frame) {
|
|
178
|
+
return frame.primaryObligation ?? selectPrimaryObligation(frame.pendingObligations ?? [], frame.currentSession);
|
|
179
|
+
}
|
|
180
|
+
function matchesCurrentSession(frame, obligation) {
|
|
181
|
+
return Boolean(frame.currentSession
|
|
182
|
+
&& obligation.origin.friendId === frame.currentSession.friendId
|
|
183
|
+
&& obligation.origin.channel === frame.currentSession.channel
|
|
184
|
+
&& (0, config_1.sanitizeKey)(obligation.origin.key) === (0, config_1.sanitizeKey)(frame.currentSession.key));
|
|
185
|
+
}
|
|
186
|
+
function findCurrentSessionOpenObligation(frame) {
|
|
187
|
+
return (frame.pendingObligations ?? []).find((obligation) => (0, obligations_1.isOpenObligationStatus)(obligation.status) && matchesCurrentSession(frame, obligation))
|
|
188
|
+
?? null;
|
|
189
|
+
}
|
|
190
|
+
function formatActiveLane(frame, obligation) {
|
|
191
|
+
const liveCodingSession = frame.codingSessions?.[0];
|
|
192
|
+
if (liveCodingSession) {
|
|
193
|
+
return `${formatCodingLaneLabel(liveCodingSession)}${describeCodingSessionScope(liveCodingSession, frame.currentSession)}`;
|
|
194
|
+
}
|
|
195
|
+
if (obligation?.currentSurface?.label) {
|
|
196
|
+
return obligation.currentSurface.label;
|
|
197
|
+
}
|
|
198
|
+
if (obligation && matchesCurrentSession(frame, obligation) && frame.currentSession) {
|
|
199
|
+
return "this same thread";
|
|
200
|
+
}
|
|
201
|
+
if (frame.inner?.job?.status === "running") {
|
|
202
|
+
return "inner dialog";
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
function formatCodingArtifact(session) {
|
|
207
|
+
const artifactPath = session?.artifactPath?.trim();
|
|
208
|
+
if (artifactPath)
|
|
209
|
+
return artifactPath;
|
|
210
|
+
return session ? "no PR or merge artifact yet" : null;
|
|
211
|
+
}
|
|
212
|
+
function formatCurrentArtifact(frame, obligation) {
|
|
213
|
+
// Live coding session artifact takes precedence (fresher evidence)
|
|
214
|
+
const liveCodingSession = frame.codingSessions?.[0];
|
|
215
|
+
if (liveCodingSession?.artifactPath?.trim()) {
|
|
216
|
+
return liveCodingSession.artifactPath.trim();
|
|
217
|
+
}
|
|
218
|
+
if (obligation?.currentArtifact?.trim()) {
|
|
219
|
+
return obligation.currentArtifact.trim();
|
|
220
|
+
}
|
|
221
|
+
if (obligation?.currentSurface?.kind === "merge" && obligation.currentSurface.label.trim()) {
|
|
222
|
+
return obligation.currentSurface.label.trim();
|
|
223
|
+
}
|
|
224
|
+
const liveCodingArtifact = formatCodingArtifact(liveCodingSession);
|
|
225
|
+
if (liveCodingArtifact) {
|
|
226
|
+
return liveCodingArtifact;
|
|
227
|
+
}
|
|
228
|
+
if (obligation) {
|
|
229
|
+
return "no artifact yet";
|
|
230
|
+
}
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
function formatObligationContentNextAction(obligation) {
|
|
234
|
+
const content = obligation?.content?.trim();
|
|
235
|
+
if (!content)
|
|
236
|
+
return null;
|
|
237
|
+
return `work on "${content}" and bring back a concrete artifact`;
|
|
238
|
+
}
|
|
239
|
+
function backgroundOperationPriority(operation) {
|
|
240
|
+
switch (operation.status) {
|
|
241
|
+
case "failed": return 0;
|
|
242
|
+
case "queued": return 1;
|
|
243
|
+
case "running": return 2;
|
|
244
|
+
case "succeeded": return 3;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function backgroundOperationSpecText(spec, key) {
|
|
248
|
+
const value = spec?.[key];
|
|
249
|
+
return typeof value === "string" ? value.trim() : "";
|
|
250
|
+
}
|
|
251
|
+
function selectPrimaryBackgroundOperation(frame) {
|
|
252
|
+
const operations = frame.backgroundOperations ?? [];
|
|
253
|
+
if (operations.length === 0)
|
|
254
|
+
return null;
|
|
255
|
+
return [...operations].sort((left, right) => {
|
|
256
|
+
const priorityDiff = backgroundOperationPriority(left) - backgroundOperationPriority(right);
|
|
257
|
+
if (priorityDiff !== 0)
|
|
258
|
+
return priorityDiff;
|
|
259
|
+
return Date.parse(right.updatedAt) - Date.parse(left.updatedAt);
|
|
260
|
+
})[0] ?? null;
|
|
261
|
+
}
|
|
262
|
+
function formatBackgroundOperationNextAction(operation) {
|
|
263
|
+
if (operation.kind === "mail.import-discovered") {
|
|
264
|
+
return "inspect the import-ready archive and start the matching mail import";
|
|
265
|
+
}
|
|
266
|
+
if (operation.kind === "mail.import-mbox") {
|
|
267
|
+
switch (operation.status) {
|
|
268
|
+
case "failed":
|
|
269
|
+
switch (operation.failure?.class?.trim()) {
|
|
270
|
+
case "transient-storage-read":
|
|
271
|
+
return "retry-safe once the transient storage/network issue clears";
|
|
272
|
+
case "mailroom-auth":
|
|
273
|
+
case "mailroom-config":
|
|
274
|
+
return "repair mail auth/config access, then retry";
|
|
275
|
+
case "source-grant-missing":
|
|
276
|
+
case "source-grant-ambiguous":
|
|
277
|
+
return "repair the delegated owner/source lane, then retry";
|
|
278
|
+
case "archive-discovery":
|
|
279
|
+
case "archive-ambiguity":
|
|
280
|
+
case "archive-missing":
|
|
281
|
+
case "archive-access":
|
|
282
|
+
return "materialize or point at the correct local archive, then retry";
|
|
283
|
+
}
|
|
284
|
+
if (operation.failure?.retryDisposition === "retry-safe") {
|
|
285
|
+
return "retry the failed mail import once the transient issue clears or the dependency answers again";
|
|
286
|
+
}
|
|
287
|
+
if (operation.failure?.retryDisposition === "investigate-first") {
|
|
288
|
+
return "inspect the failed mail import carefully, confirm the root cause, and then decide whether to retry";
|
|
289
|
+
}
|
|
290
|
+
return "inspect the failed mail import, fix the issue, and retry it";
|
|
291
|
+
case "queued":
|
|
292
|
+
return "queued — no action unless it stalls or i need live status";
|
|
293
|
+
case "running":
|
|
294
|
+
return "in flight — no action unless it stalls or i need live status";
|
|
295
|
+
case "succeeded":
|
|
296
|
+
return "caught up — no rerun needed unless a newer archive appears";
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
switch (operation.status) {
|
|
300
|
+
case "failed": return `repair the failed ${operation.title} operation and retry it`;
|
|
301
|
+
case "queued": return `let the queued ${operation.title} operation start, then re-check progress`;
|
|
302
|
+
case "running": return `monitor the ${operation.title} operation and react when it changes`;
|
|
303
|
+
case "succeeded": return `review the completed ${operation.title} operation and continue`;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function formatMailImportRecoveryUniverse(operation) {
|
|
307
|
+
const failureClass = operation.failure?.class?.trim();
|
|
308
|
+
if (!failureClass)
|
|
309
|
+
return null;
|
|
310
|
+
switch (failureClass) {
|
|
311
|
+
case "transient-storage-read":
|
|
312
|
+
return "transient dependency/read issue — safe to retry once storage/network answers again";
|
|
313
|
+
case "mailroom-auth":
|
|
314
|
+
case "mailroom-config":
|
|
315
|
+
return "mail auth/config issue — repair mail access or runtime config before retrying";
|
|
316
|
+
case "source-grant-missing":
|
|
317
|
+
case "source-grant-ambiguous":
|
|
318
|
+
return "delegated lane/registry issue — inspect owner/source linking before retrying";
|
|
319
|
+
case "archive-discovery":
|
|
320
|
+
case "archive-ambiguity":
|
|
321
|
+
case "archive-missing":
|
|
322
|
+
case "archive-access":
|
|
323
|
+
return "local archive/file issue — materialize or point at the right archive before retrying";
|
|
324
|
+
default:
|
|
325
|
+
return "unclassified import issue — inspect the recorded error before retrying";
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function formatBackgroundOperationMeta(operation) {
|
|
329
|
+
const lines = [`operation: ${operation.id}`];
|
|
330
|
+
const filePath = backgroundOperationSpecText(operation.spec, "filePath")
|
|
331
|
+
|| backgroundOperationSpecText(operation.spec, "newestCandidatePath");
|
|
332
|
+
if (filePath)
|
|
333
|
+
lines.push(`file: ${filePath}`);
|
|
334
|
+
const originLabel = backgroundOperationSpecText(operation.spec, "fileOriginLabel")
|
|
335
|
+
|| backgroundOperationSpecText(operation.spec, "newestCandidateOriginLabel");
|
|
336
|
+
if (originLabel)
|
|
337
|
+
lines.push(`origin: ${originLabel}`);
|
|
338
|
+
const ownerEmail = backgroundOperationSpecText(operation.spec, "ownerEmail");
|
|
339
|
+
const source = backgroundOperationSpecText(operation.spec, "source");
|
|
340
|
+
if (ownerEmail || source) {
|
|
341
|
+
lines.push(`owner/source: ${ownerEmail || "unknown"} / ${source || "unknown"}`);
|
|
342
|
+
}
|
|
343
|
+
if (operation.failure?.class?.trim())
|
|
344
|
+
lines.push(`failure class: ${operation.failure.class}`);
|
|
345
|
+
if (operation.failure?.retryDisposition?.trim())
|
|
346
|
+
lines.push(`retry: ${operation.failure.retryDisposition}`);
|
|
347
|
+
if (operation.failure?.hint?.trim())
|
|
348
|
+
lines.push(`recovery: ${operation.failure.hint}`);
|
|
349
|
+
const recoveryUniverse = operation.kind === "mail.import-mbox" ? formatMailImportRecoveryUniverse(operation) : null;
|
|
350
|
+
if (recoveryUniverse)
|
|
351
|
+
lines.push(`recovery universe: ${recoveryUniverse}`);
|
|
352
|
+
if (operation.startedAt?.trim())
|
|
353
|
+
lines.push(`started: ${operation.startedAt}`);
|
|
354
|
+
if (operation.finishedAt?.trim())
|
|
355
|
+
lines.push(`finished: ${operation.finishedAt}`);
|
|
356
|
+
else if (operation.updatedAt?.trim())
|
|
357
|
+
lines.push(`updated: ${operation.updatedAt}`);
|
|
358
|
+
const nextAction = formatBackgroundOperationNextAction(operation);
|
|
359
|
+
if (nextAction.trim().length > 0)
|
|
360
|
+
lines.push(`next: ${nextAction}`);
|
|
361
|
+
if (operation.remediation?.length) {
|
|
362
|
+
lines.push(...operation.remediation.map((step) => `remediation: ${step}`));
|
|
363
|
+
}
|
|
364
|
+
return lines;
|
|
365
|
+
}
|
|
366
|
+
function formatNextAction(frame, obligation) {
|
|
367
|
+
const obligationHasConcreteArtifact = Boolean(obligation?.currentArtifact?.trim())
|
|
368
|
+
|| obligation?.currentSurface?.kind === "merge";
|
|
369
|
+
if (obligation?.status === "waiting_for_merge") {
|
|
370
|
+
return obligation.nextAction?.trim() || `wait for checks, merge ${formatMergeArtifact(obligation)}, then update runtime`;
|
|
371
|
+
}
|
|
372
|
+
if (obligation?.status === "updating_runtime") {
|
|
373
|
+
return obligation.nextAction?.trim() || "update runtime, verify version/changelog, then re-observe";
|
|
374
|
+
}
|
|
375
|
+
if (obligationHasConcreteArtifact && obligation?.nextAction?.trim()) {
|
|
376
|
+
return obligation.nextAction.trim();
|
|
377
|
+
}
|
|
378
|
+
const liveCodingSession = frame.codingSessions?.[0];
|
|
379
|
+
if (liveCodingSession?.status === "waiting_input") {
|
|
380
|
+
return `answer ${formatCodingLaneLabel(liveCodingSession)} and continue`;
|
|
381
|
+
}
|
|
382
|
+
if (liveCodingSession?.status === "stalled") {
|
|
383
|
+
return `unstick ${formatCodingLaneLabel(liveCodingSession)} and continue`;
|
|
384
|
+
}
|
|
385
|
+
if (liveCodingSession) {
|
|
386
|
+
return "finish the coding pass and bring the result back here";
|
|
387
|
+
}
|
|
388
|
+
if (obligation?.nextAction?.trim())
|
|
389
|
+
return obligation.nextAction.trim();
|
|
390
|
+
if (obligation) {
|
|
391
|
+
return formatObligationContentNextAction(obligation) || "continue the active loop and bring the result back here";
|
|
392
|
+
}
|
|
393
|
+
const backgroundOperation = selectPrimaryBackgroundOperation(frame);
|
|
394
|
+
if (backgroundOperation) {
|
|
395
|
+
return formatBackgroundOperationNextAction(backgroundOperation);
|
|
396
|
+
}
|
|
397
|
+
if (frame.mustResolveBeforeHandoff) {
|
|
398
|
+
return "finish what i started here before moving on";
|
|
399
|
+
}
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
const RECENT_OTHER_LIVE_SESSION_WINDOW_MS = 60 * 60 * 1000;
|
|
403
|
+
function sessionOriginKey(origin) {
|
|
404
|
+
return `${origin.friendId}/${origin.channel}/${(0, config_1.sanitizeKey)(origin.key)}`;
|
|
405
|
+
}
|
|
406
|
+
function codingSessionTimestampMs(session) {
|
|
407
|
+
return Date.parse(session.lastActivityAt ?? session.startedAt);
|
|
408
|
+
}
|
|
409
|
+
function obligationTimestampMs(obligation) {
|
|
410
|
+
const value = Date.parse(obligation.updatedAt ?? obligation.createdAt);
|
|
411
|
+
return Number.isFinite(value) ? value : 0;
|
|
412
|
+
}
|
|
413
|
+
function newestObligationFirst(left, right) {
|
|
414
|
+
return obligationTimestampMs(right) - obligationTimestampMs(left);
|
|
415
|
+
}
|
|
416
|
+
function formatOtherSessionArtifact(obligation, codingSession) {
|
|
417
|
+
if (obligation?.currentArtifact?.trim())
|
|
418
|
+
return obligation.currentArtifact.trim();
|
|
419
|
+
if (obligation?.currentSurface?.kind === "merge" && obligation.currentSurface.label.trim()) {
|
|
420
|
+
return obligation.currentSurface.label.trim();
|
|
421
|
+
}
|
|
422
|
+
const codingArtifact = formatCodingArtifact(codingSession);
|
|
423
|
+
if (codingArtifact)
|
|
424
|
+
return codingArtifact;
|
|
425
|
+
return obligation ? "no artifact yet" : "no explicit artifact yet";
|
|
426
|
+
}
|
|
427
|
+
function formatOtherSessionNextAction(obligation, codingSession) {
|
|
428
|
+
if (obligation?.nextAction?.trim())
|
|
429
|
+
return obligation.nextAction.trim();
|
|
430
|
+
if (obligation?.status === "waiting_for_merge") {
|
|
431
|
+
return `wait for checks, merge ${formatMergeArtifact(obligation)}, then update runtime`;
|
|
432
|
+
}
|
|
433
|
+
if (obligation?.status === "updating_runtime") {
|
|
434
|
+
return "update runtime, verify version/changelog, then re-observe";
|
|
435
|
+
}
|
|
436
|
+
if (codingSession?.status === "waiting_input") {
|
|
437
|
+
return `answer ${formatCodingLaneLabel(codingSession)} and continue`;
|
|
438
|
+
}
|
|
439
|
+
if (codingSession?.status === "stalled") {
|
|
440
|
+
return `unstick ${formatCodingLaneLabel(codingSession)} and continue`;
|
|
441
|
+
}
|
|
442
|
+
if (codingSession) {
|
|
443
|
+
return "finish the coding pass and bring the result back there";
|
|
444
|
+
}
|
|
445
|
+
if (obligation) {
|
|
446
|
+
return formatObligationContentNextAction(obligation) || "continue the active loop and bring the result back there";
|
|
447
|
+
}
|
|
448
|
+
return "check this session and bring back the latest concrete state";
|
|
449
|
+
}
|
|
450
|
+
function formatOtherSessionLine(label, status, activeLane, artifact, nextAction) {
|
|
451
|
+
return `- ${label}: [${status}] ${activeLane}; artifact ${artifact}; next ${nextAction}`;
|
|
452
|
+
}
|
|
453
|
+
function formatOtherActiveSessionSummaries(frame, nowMs = Date.now()) {
|
|
454
|
+
const originMap = new Map();
|
|
455
|
+
for (const session of frame.friendActivity?.allOtherLiveSessions ?? []) {
|
|
456
|
+
if (session.friendId === "self" || session.channel === "inner")
|
|
457
|
+
continue;
|
|
458
|
+
originMap.set(sessionOriginKey(session), {
|
|
459
|
+
friendId: session.friendId,
|
|
460
|
+
channel: session.channel,
|
|
461
|
+
key: session.key,
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
const orphanCodingSummaries = (frame.otherCodingSessions ?? [])
|
|
465
|
+
.filter((session) => !session.originSession)
|
|
466
|
+
.sort((left, right) => codingSessionTimestampMs(right) - codingSessionTimestampMs(left))
|
|
467
|
+
.map((session) => ({
|
|
468
|
+
timestampMs: codingSessionTimestampMs(session),
|
|
469
|
+
line: formatOtherSessionLine("another session", session.status, formatCodingLaneLabel(session), formatCodingArtifact(session), formatOtherSessionNextAction(null, session)),
|
|
470
|
+
}));
|
|
471
|
+
for (const session of frame.otherCodingSessions ?? []) {
|
|
472
|
+
if (!session.originSession)
|
|
473
|
+
continue;
|
|
474
|
+
if (frame.currentSession
|
|
475
|
+
&& session.originSession.friendId === frame.currentSession.friendId
|
|
476
|
+
&& session.originSession.channel === frame.currentSession.channel
|
|
477
|
+
&& (0, config_1.sanitizeKey)(session.originSession.key) === (0, config_1.sanitizeKey)(frame.currentSession.key)) {
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
originMap.set(sessionOriginKey(session.originSession), session.originSession);
|
|
481
|
+
}
|
|
482
|
+
for (const obligation of frame.pendingObligations ?? []) {
|
|
483
|
+
if (obligation.status === "fulfilled" || matchesCurrentSession(frame, obligation))
|
|
484
|
+
continue;
|
|
485
|
+
originMap.set(sessionOriginKey(obligation.origin), obligation.origin);
|
|
486
|
+
}
|
|
487
|
+
const summaries = [...originMap.values()].map((origin) => {
|
|
488
|
+
const originKey = sessionOriginKey(origin);
|
|
489
|
+
const obligation = [...(frame.pendingObligations ?? [])]
|
|
490
|
+
.filter((candidate) => candidate.status !== "fulfilled" && sessionOriginKey(candidate.origin) === originKey)
|
|
491
|
+
.sort(newestObligationFirst)[0] ?? null;
|
|
492
|
+
const codingSession = [...(frame.otherCodingSessions ?? [])]
|
|
493
|
+
.filter((candidate) => candidate.originSession && sessionOriginKey(candidate.originSession) === originKey)
|
|
494
|
+
.sort((left, right) => codingSessionTimestampMs(right) - codingSessionTimestampMs(left))[0] ?? null;
|
|
495
|
+
const liveSession = (frame.friendActivity?.allOtherLiveSessions ?? []).find((candidate) => sessionOriginKey(candidate) === originKey) ?? null;
|
|
496
|
+
const hasMaterialLiveSession = liveSession
|
|
497
|
+
? ((nowMs - liveSession.lastActivityMs) <= RECENT_OTHER_LIVE_SESSION_WINDOW_MS
|
|
498
|
+
|| (frame.currentSession != null
|
|
499
|
+
&& liveSession.friendId === frame.currentSession.friendId
|
|
500
|
+
&& liveSession.channel !== frame.currentSession.channel))
|
|
501
|
+
: false;
|
|
502
|
+
if (!obligation && !codingSession && !hasMaterialLiveSession) {
|
|
503
|
+
return null;
|
|
504
|
+
}
|
|
505
|
+
const timestampMs = Math.max(liveSession?.lastActivityMs ?? 0, codingSession ? codingSessionTimestampMs(codingSession) : 0, obligation ? obligationTimestampMs(obligation) : 0);
|
|
506
|
+
const activeLane = codingSession
|
|
507
|
+
? formatCodingLaneLabel(codingSession)
|
|
508
|
+
: obligation?.currentSurface?.label?.trim() || "this live thread";
|
|
509
|
+
const artifact = formatOtherSessionArtifact(obligation, codingSession);
|
|
510
|
+
const nextAction = formatOtherSessionNextAction(obligation, codingSession);
|
|
511
|
+
const status = obligation?.status ?? codingSession?.status ?? "active";
|
|
512
|
+
const label = liveSession?.friendName ?? origin.friendId;
|
|
513
|
+
return {
|
|
514
|
+
timestampMs,
|
|
515
|
+
line: formatOtherSessionLine(`${label}/${origin.channel}/${origin.key}`, status, activeLane, artifact, nextAction),
|
|
516
|
+
};
|
|
517
|
+
}).filter((entry) => entry !== null)
|
|
518
|
+
.sort((left, right) => right.timestampMs - left.timestampMs);
|
|
519
|
+
const lines = summaries.map((entry) => entry.line);
|
|
520
|
+
return [...lines, ...orphanCodingSummaries.map((entry) => entry.line)];
|
|
33
521
|
}
|
|
34
522
|
function suggestBridgeForActiveWork(input) {
|
|
35
523
|
const targetCandidates = (input.targetCandidates ?? [])
|
|
@@ -50,10 +538,16 @@ function suggestBridgeForActiveWork(input) {
|
|
|
50
538
|
.sort((a, b) => {
|
|
51
539
|
return b.lastActivityMs - a.lastActivityMs;
|
|
52
540
|
});
|
|
53
|
-
if (!hasSharedObligationPressure(
|
|
541
|
+
if (!hasSharedObligationPressure({
|
|
542
|
+
mustResolveBeforeHandoff: input.mustResolveBeforeHandoff,
|
|
543
|
+
pendingObligations: input.pendingObligations,
|
|
544
|
+
}) || targetCandidates.length === 0) {
|
|
54
545
|
return null;
|
|
55
546
|
}
|
|
56
547
|
const targetSession = targetCandidates[0];
|
|
548
|
+
const objectiveHint = [...(input.pendingObligations ?? [])]
|
|
549
|
+
.find((obligation) => (0, obligations_1.isOpenObligationStatus)(obligation.status))
|
|
550
|
+
?.content?.trim() || "keep this shared work aligned";
|
|
57
551
|
const activeBridge = input.bridges.find(isActiveBridge) ?? null;
|
|
58
552
|
if (activeBridge) {
|
|
59
553
|
const alreadyAttached = activeBridge.attachedSessions.some((session) => session.friendId === targetSession.friendId
|
|
@@ -72,26 +566,70 @@ function suggestBridgeForActiveWork(input) {
|
|
|
72
566
|
return {
|
|
73
567
|
kind: "begin-new",
|
|
74
568
|
targetSession,
|
|
75
|
-
objectiveHint
|
|
569
|
+
objectiveHint,
|
|
76
570
|
reason: "shared-work-candidate",
|
|
77
571
|
};
|
|
78
572
|
}
|
|
79
573
|
function formatSessionLabel(session) {
|
|
80
574
|
return `${session.channel}/${session.key}`;
|
|
81
575
|
}
|
|
576
|
+
function deriveResumeHandleConfidence(primaryObligation, codingSession) {
|
|
577
|
+
if (primaryObligation?.currentArtifact?.trim() && primaryObligation.nextAction?.trim())
|
|
578
|
+
return "high";
|
|
579
|
+
if (codingSession?.checkpoint?.trim())
|
|
580
|
+
return "medium";
|
|
581
|
+
if (primaryObligation)
|
|
582
|
+
return "low";
|
|
583
|
+
return "low";
|
|
584
|
+
}
|
|
585
|
+
function buildResumeHandle(currentSession, primaryObligation, codingSessions) {
|
|
586
|
+
const sessionLabel = currentSession ? formatSessionLabel(currentSession) : null;
|
|
587
|
+
if (!sessionLabel)
|
|
588
|
+
return null;
|
|
589
|
+
const liveCoding = codingSessions[0] ?? null;
|
|
590
|
+
const lane = liveCoding
|
|
591
|
+
? `${formatCodingLaneLabel(liveCoding)}${describeCodingSessionScope(liveCoding, currentSession)}`
|
|
592
|
+
: (primaryObligation?.currentSurface?.label?.trim() || null);
|
|
593
|
+
const artifact = primaryObligation?.currentArtifact?.trim()
|
|
594
|
+
|| (liveCoding?.artifactPath?.trim() || null);
|
|
595
|
+
const blockerOrWaitingOn = primaryObligation?.meaning?.waitingOn?.detail?.trim() || null;
|
|
596
|
+
const nextAction = primaryObligation?.nextAction?.trim()
|
|
597
|
+
|| (primaryObligation?.content?.trim() ? `work on "${primaryObligation.content.trim()}" and bring back a concrete artifact` : null);
|
|
598
|
+
const lastVerifiedCheckpoint = liveCoding?.checkpoint?.trim() || null;
|
|
599
|
+
const codingIdentity = liveCoding
|
|
600
|
+
? { sessionId: liveCoding.id, runner: liveCoding.runner, status: liveCoding.status }
|
|
601
|
+
: null;
|
|
602
|
+
return {
|
|
603
|
+
sessionLabel,
|
|
604
|
+
lane,
|
|
605
|
+
artifact,
|
|
606
|
+
blockerOrWaitingOn,
|
|
607
|
+
nextAction,
|
|
608
|
+
lastVerifiedCheckpoint,
|
|
609
|
+
confidence: deriveResumeHandleConfidence(primaryObligation, liveCoding),
|
|
610
|
+
codingIdentity,
|
|
611
|
+
};
|
|
612
|
+
}
|
|
82
613
|
function buildActiveWorkFrame(input) {
|
|
83
614
|
const friendSessions = input.currentSession
|
|
84
615
|
? input.friendActivity
|
|
85
616
|
.filter((entry) => entry.friendId === input.currentSession?.friendId)
|
|
86
617
|
.sort(compareActivity)
|
|
87
618
|
: [];
|
|
88
|
-
const liveTaskNames = summarizeLiveTasks(input.taskBoard);
|
|
89
619
|
const activeBridgePresent = input.bridges.some(isActiveBridge);
|
|
620
|
+
const liveCodingSessions = input.codingSessions ?? [];
|
|
621
|
+
const openEvolutionCases = liveEvolutionCases(input.evolutionCases);
|
|
622
|
+
const allOtherLiveSessions = [...input.friendActivity].sort(compareActivity);
|
|
623
|
+
const otherCodingSessions = input.otherCodingSessions ?? [];
|
|
624
|
+
const pendingObligations = normalizePendingObligations(input.pendingObligations, liveCodingSessions, otherCodingSessions);
|
|
625
|
+
const openObligations = activeObligationCount(pendingObligations);
|
|
90
626
|
const centerOfGravity = activeBridgePresent
|
|
91
627
|
? "shared-work"
|
|
92
|
-
: (input.inner.status === "running" || input.inner.hasPending || input.mustResolveBeforeHandoff)
|
|
628
|
+
: (input.inner.status === "running" || input.inner.hasPending || input.mustResolveBeforeHandoff || openObligations > 0 || liveCodingSessions.length > 0)
|
|
93
629
|
? "inward-work"
|
|
94
630
|
: "local-turn";
|
|
631
|
+
const primaryObligation = selectPrimaryObligation(pendingObligations, input.currentSession ?? null);
|
|
632
|
+
const resumeHandle = buildResumeHandle(input.currentSession ?? null, primaryObligation, liveCodingSessions);
|
|
95
633
|
const frame = {
|
|
96
634
|
currentSession: input.currentSession ?? null,
|
|
97
635
|
currentObligation: input.currentObligation?.trim() || null,
|
|
@@ -99,24 +637,28 @@ function buildActiveWorkFrame(input) {
|
|
|
99
637
|
centerOfGravity,
|
|
100
638
|
inner: input.inner,
|
|
101
639
|
bridges: input.bridges,
|
|
102
|
-
taskPressure: {
|
|
103
|
-
compactBoard: input.taskBoard.compact,
|
|
104
|
-
liveTaskNames,
|
|
105
|
-
activeBridges: input.taskBoard.activeBridges,
|
|
106
|
-
},
|
|
107
640
|
friendActivity: {
|
|
108
641
|
freshestForCurrentFriend: friendSessions[0] ?? null,
|
|
109
642
|
otherLiveSessionsForCurrentFriend: friendSessions,
|
|
643
|
+
allOtherLiveSessions,
|
|
110
644
|
},
|
|
645
|
+
codingSessions: liveCodingSessions,
|
|
646
|
+
evolutionCases: openEvolutionCases,
|
|
647
|
+
backgroundOperations: input.backgroundOperations ?? [],
|
|
648
|
+
otherCodingSessions,
|
|
649
|
+
pendingObligations,
|
|
111
650
|
targetCandidates: input.targetCandidates ?? [],
|
|
651
|
+
innerReturnObligations: input.innerReturnObligations ?? [],
|
|
112
652
|
bridgeSuggestion: suggestBridgeForActiveWork({
|
|
113
653
|
currentSession: input.currentSession,
|
|
114
654
|
currentObligation: input.currentObligation,
|
|
115
655
|
mustResolveBeforeHandoff: input.mustResolveBeforeHandoff,
|
|
116
656
|
bridges: input.bridges,
|
|
117
|
-
|
|
657
|
+
pendingObligations,
|
|
118
658
|
targetCandidates: input.targetCandidates,
|
|
119
659
|
}),
|
|
660
|
+
primaryObligation,
|
|
661
|
+
resumeHandle,
|
|
120
662
|
};
|
|
121
663
|
(0, runtime_1.emitNervesEvent)({
|
|
122
664
|
component: "engine",
|
|
@@ -126,38 +668,154 @@ function buildActiveWorkFrame(input) {
|
|
|
126
668
|
centerOfGravity: frame.centerOfGravity,
|
|
127
669
|
friendId: frame.currentSession?.friendId ?? null,
|
|
128
670
|
bridges: frame.bridges.length,
|
|
129
|
-
liveTasks: frame.taskPressure.liveTaskNames.length,
|
|
130
671
|
liveSessions: frame.friendActivity.otherLiveSessionsForCurrentFriend.length,
|
|
672
|
+
codingSessions: frame.codingSessions.length,
|
|
673
|
+
otherLiveSessions: allOtherLiveSessions.length,
|
|
674
|
+
otherCodingSessions: otherCodingSessions.length,
|
|
675
|
+
pendingObligations: openObligations,
|
|
676
|
+
evolutionCases: openEvolutionCases.length,
|
|
131
677
|
hasBridgeSuggestion: frame.bridgeSuggestion !== null,
|
|
132
678
|
},
|
|
133
679
|
});
|
|
134
680
|
return frame;
|
|
135
681
|
}
|
|
136
|
-
function formatActiveWorkFrame(frame) {
|
|
137
|
-
const lines = ["##
|
|
682
|
+
function formatActiveWorkFrame(frame, options) {
|
|
683
|
+
const lines = ["## what i'm holding"];
|
|
684
|
+
lines.push("this is my top-level live world-state right now. inner work, coding lanes, other sessions, and return obligations all belong inside this picture.");
|
|
685
|
+
lines.push("if older checkpoints elsewhere in the transcript disagree with this picture, this picture wins.");
|
|
686
|
+
const primaryObligation = findPrimaryOpenObligation(frame);
|
|
687
|
+
const currentSessionObligation = findCurrentSessionOpenObligation(frame);
|
|
688
|
+
const activeLane = formatActiveLane(frame, primaryObligation);
|
|
689
|
+
const currentArtifact = formatCurrentArtifact(frame, primaryObligation);
|
|
690
|
+
const nextAction = formatNextAction(frame, primaryObligation);
|
|
691
|
+
const otherActiveSessions = formatOtherActiveSessionSummaries(frame);
|
|
692
|
+
// Session line
|
|
138
693
|
if (frame.currentSession) {
|
|
139
|
-
|
|
694
|
+
let sessionLine = `i'm in a conversation on ${formatSessionLabel(frame.currentSession)}.`;
|
|
695
|
+
if (currentSessionObligation?.content?.trim()) {
|
|
696
|
+
sessionLine += ` i still owe them: ${currentSessionObligation.content.trim()}.`;
|
|
697
|
+
}
|
|
698
|
+
else if (frame.mustResolveBeforeHandoff) {
|
|
699
|
+
sessionLine += " i need to finish what i started here before moving on.";
|
|
700
|
+
}
|
|
701
|
+
lines.push("");
|
|
702
|
+
lines.push(sessionLine);
|
|
140
703
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
lines.push(
|
|
704
|
+
else {
|
|
705
|
+
lines.push("");
|
|
706
|
+
lines.push("i'm not in a conversation right now.");
|
|
144
707
|
}
|
|
145
|
-
if (
|
|
146
|
-
lines.push("
|
|
708
|
+
if (activeLane || currentArtifact || nextAction) {
|
|
709
|
+
lines.push("");
|
|
710
|
+
lines.push("## current concrete state");
|
|
711
|
+
if (frame.currentSession) {
|
|
712
|
+
lines.push(`- live conversation: ${formatSessionLabel(frame.currentSession)}`);
|
|
713
|
+
}
|
|
714
|
+
if (activeLane) {
|
|
715
|
+
lines.push(`- active lane: ${activeLane}`);
|
|
716
|
+
}
|
|
717
|
+
if (currentArtifact) {
|
|
718
|
+
lines.push(`- current artifact: ${currentArtifact}`);
|
|
719
|
+
}
|
|
720
|
+
if (nextAction) {
|
|
721
|
+
lines.push(`- next action: ${nextAction}`);
|
|
722
|
+
}
|
|
723
|
+
if (frame.resumeHandle?.lastVerifiedCheckpoint) {
|
|
724
|
+
lines.push(`- last checkpoint: ${frame.resumeHandle.lastVerifiedCheckpoint}`);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
// Inner status block
|
|
728
|
+
const job = frame.inner?.job;
|
|
729
|
+
if (job) {
|
|
730
|
+
if (job.status === "queued") {
|
|
731
|
+
let queuedLine = "i have a thought queued up for private attention.";
|
|
732
|
+
if (frame.inner?.contentSnippet) {
|
|
733
|
+
queuedLine += `\nit's about: "${frame.inner.contentSnippet}"`;
|
|
734
|
+
}
|
|
735
|
+
lines.push("");
|
|
736
|
+
lines.push(queuedLine);
|
|
737
|
+
}
|
|
738
|
+
else if (job.status === "running") {
|
|
739
|
+
const originName = job.origin?.friendName ?? job.origin?.friendId;
|
|
740
|
+
let runningLine = originName
|
|
741
|
+
? `i'm thinking through something privately right now. ${originName} asked about something and i wanted to give it real thought.`
|
|
742
|
+
: "i'm thinking through something privately right now.";
|
|
743
|
+
if (frame.inner?.obligationPending) {
|
|
744
|
+
runningLine += "\ni still owe them an answer.";
|
|
745
|
+
}
|
|
746
|
+
lines.push("");
|
|
747
|
+
lines.push(runningLine);
|
|
748
|
+
}
|
|
749
|
+
else if (job.status === "surfaced") {
|
|
750
|
+
let surfacedLine = "i finished thinking about something privately. i should bring my answer back.";
|
|
751
|
+
if (job.surfacedResult) {
|
|
752
|
+
const truncated = job.surfacedResult.length > 120 ? job.surfacedResult.slice(0, 117) + "..." : job.surfacedResult;
|
|
753
|
+
surfacedLine += `\nwhat i came to: ${truncated}`;
|
|
754
|
+
}
|
|
755
|
+
lines.push("");
|
|
756
|
+
lines.push(surfacedLine);
|
|
757
|
+
}
|
|
758
|
+
// idle, returned, abandoned: omitted
|
|
759
|
+
}
|
|
760
|
+
if ((frame.codingSessions ?? []).length > 0) {
|
|
761
|
+
lines.push("");
|
|
762
|
+
lines.push("## live coding work");
|
|
763
|
+
for (const session of frame.codingSessions) {
|
|
764
|
+
const checkpoint = compactCodingCheckpoint(session);
|
|
765
|
+
lines.push(`- [${session.status}] ${formatCodingLaneLabel(session)}${describeCodingSessionScope(session, frame.currentSession)}${checkpoint ? `: ${checkpoint}` : ""}`);
|
|
766
|
+
/* v8 ignore start -- coding identity display: tested in identity-packet.test.ts @preserve */
|
|
767
|
+
if (session.codingIdentity) {
|
|
768
|
+
const id = session.codingIdentity;
|
|
769
|
+
lines.push(` branch: ${id.branch ?? "unknown"} commit: ${id.commit ?? "unknown"} ${id.dirty ? "dirty" : "clean"} verification: ${id.verificationStatus}`);
|
|
770
|
+
}
|
|
771
|
+
/* v8 ignore stop */
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
const evolutionCases = liveEvolutionCases(frame.evolutionCases);
|
|
775
|
+
if (evolutionCases.length > 0) {
|
|
776
|
+
lines.push("");
|
|
777
|
+
lines.push("## evolution cases");
|
|
778
|
+
for (const evolutionCase of evolutionCases) {
|
|
779
|
+
lines.push(formatEvolutionCaseLine(evolutionCase));
|
|
780
|
+
}
|
|
147
781
|
}
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
782
|
+
const backgroundOperations = frame.backgroundOperations ?? [];
|
|
783
|
+
if (backgroundOperations.length > 0) {
|
|
784
|
+
lines.push("");
|
|
785
|
+
lines.push("## background operations");
|
|
786
|
+
for (const operation of backgroundOperations) {
|
|
787
|
+
let line = `- [${operation.status}] ${operation.title}`;
|
|
788
|
+
if (operation.summary.trim().length > 0) {
|
|
789
|
+
line += `: ${operation.summary}`;
|
|
790
|
+
}
|
|
791
|
+
line += `\n ${formatBackgroundOperationMeta(operation).join("\n ")}`;
|
|
792
|
+
if (operation.detail?.trim()) {
|
|
793
|
+
line += `\n ${operation.detail.trim()}`;
|
|
794
|
+
}
|
|
795
|
+
if (operation.progress) {
|
|
796
|
+
const current = typeof operation.progress.current === "number" ? String(operation.progress.current) : "?";
|
|
797
|
+
const total = typeof operation.progress.total === "number" ? String(operation.progress.total) : null;
|
|
798
|
+
const unit = operation.progress.unit?.trim() ? ` ${operation.progress.unit.trim()}` : "";
|
|
799
|
+
line += `\n progress: ${total ? `${current}/${total}` : current}${unit}`;
|
|
800
|
+
}
|
|
801
|
+
if (operation.error?.message?.trim()) {
|
|
802
|
+
line += `\n error: ${operation.error.message.trim()}`;
|
|
803
|
+
}
|
|
804
|
+
lines.push(line);
|
|
805
|
+
}
|
|
153
806
|
}
|
|
807
|
+
if (otherActiveSessions.length > 0) {
|
|
808
|
+
lines.push("");
|
|
809
|
+
lines.push("## other active sessions");
|
|
810
|
+
lines.push(...otherActiveSessions);
|
|
811
|
+
}
|
|
812
|
+
// Bridges
|
|
154
813
|
if ((frame.bridges ?? []).length > 0) {
|
|
155
814
|
const bridgeLabels = frame.bridges.map((bridge) => `${bridge.id} [${(0, state_machine_1.bridgeStateLabel)(bridge)}]`);
|
|
156
|
-
lines.push(
|
|
157
|
-
|
|
158
|
-
if (frame.friendActivity?.freshestForCurrentFriend) {
|
|
159
|
-
lines.push(`freshest friend-facing session: ${formatSessionLabel(frame.friendActivity.freshestForCurrentFriend)}`);
|
|
815
|
+
lines.push("");
|
|
816
|
+
lines.push(`i have shared work spanning sessions: ${bridgeLabels.join(", ")}.`);
|
|
160
817
|
}
|
|
818
|
+
// Target candidates (keep factual format)
|
|
161
819
|
const targetCandidatesBlock = frame.targetCandidates && frame.targetCandidates.length > 0
|
|
162
820
|
? (0, target_resolution_1.formatTargetSessionCandidates)(frame.targetCandidates)
|
|
163
821
|
: "";
|
|
@@ -165,14 +823,173 @@ function formatActiveWorkFrame(frame) {
|
|
|
165
823
|
lines.push("");
|
|
166
824
|
lines.push(targetCandidatesBlock);
|
|
167
825
|
}
|
|
826
|
+
if ((frame.pendingObligations ?? []).length > 0) {
|
|
827
|
+
const openCount = frame.pendingObligations.filter((ob) => (0, obligations_1.isOpenObligationStatus)(ob.status)).length;
|
|
828
|
+
if (options?.obligationDetailsRenderedElsewhere && openCount > 0) {
|
|
829
|
+
// Enriched obligation data (with resumeHint, stalenessClass, waitingOn) is rendered elsewhere.
|
|
830
|
+
// Avoid duplicating the full list — just anchor the count here.
|
|
831
|
+
lines.push("");
|
|
832
|
+
lines.push(`return obligations: ${openCount} active (canonical details in **Owed** section of start-of-turn packet)`);
|
|
833
|
+
}
|
|
834
|
+
else if (openCount > 0) {
|
|
835
|
+
lines.push("");
|
|
836
|
+
lines.push("## return obligations");
|
|
837
|
+
for (const obligation of frame.pendingObligations) {
|
|
838
|
+
if (!(0, obligations_1.isOpenObligationStatus)(obligation.status))
|
|
839
|
+
continue;
|
|
840
|
+
let obligationLine = `- [${obligation.status}] ${obligation.origin.friendId}/${obligation.origin.channel}/${obligation.origin.key}: ${obligation.content}${formatObligationSurface(obligation)}`;
|
|
841
|
+
if (obligation.latestNote?.trim()) {
|
|
842
|
+
obligationLine += `\n latest: ${obligation.latestNote.trim()}`;
|
|
843
|
+
}
|
|
844
|
+
lines.push(obligationLine);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
if (frame.innerReturnObligations && frame.innerReturnObligations.length > 0) {
|
|
849
|
+
lines.push("");
|
|
850
|
+
lines.push("## inner return obligations");
|
|
851
|
+
for (const ob of frame.innerReturnObligations) {
|
|
852
|
+
const preview = ob.delegatedContent.length > 60
|
|
853
|
+
? `${ob.delegatedContent.slice(0, 57)}...`
|
|
854
|
+
: ob.delegatedContent;
|
|
855
|
+
lines.push(`- [${ob.status}] ${ob.origin.friendId}/${ob.origin.channel}/${ob.origin.key}: ${preview}`);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
// Bridge suggestion
|
|
168
859
|
if (frame.bridgeSuggestion) {
|
|
169
|
-
|
|
170
|
-
|
|
860
|
+
lines.push("");
|
|
861
|
+
if (frame.bridgeSuggestion.kind === "begin-new") {
|
|
862
|
+
lines.push(`this work touches my conversation on ${formatSessionLabel(frame.bridgeSuggestion.targetSession)} too -- i should connect these threads.`);
|
|
171
863
|
}
|
|
172
864
|
else {
|
|
173
|
-
lines.push(`
|
|
174
|
-
lines.push(`bridge objective hint: ${frame.bridgeSuggestion.objectiveHint}`);
|
|
865
|
+
lines.push(`this work relates to bridge ${frame.bridgeSuggestion.bridgeId} -- i should connect ${formatSessionLabel(frame.bridgeSuggestion.targetSession)} to it.`);
|
|
175
866
|
}
|
|
176
867
|
}
|
|
177
868
|
return lines.join("\n");
|
|
178
869
|
}
|
|
870
|
+
function formatLiveWorldStateCheckpoint(frame) {
|
|
871
|
+
const primaryObligation = findPrimaryOpenObligation(frame);
|
|
872
|
+
const activeLane = formatActiveLane(frame, primaryObligation) ?? "no explicit live lane";
|
|
873
|
+
const currentArtifact = formatCurrentArtifact(frame, primaryObligation) ?? "no artifact yet";
|
|
874
|
+
const nextAction = formatNextAction(frame, primaryObligation) ?? "continue from the live world-state";
|
|
875
|
+
const otherActiveSessions = formatOtherActiveSessionSummaries(frame);
|
|
876
|
+
const lines = [
|
|
877
|
+
"## live world-state",
|
|
878
|
+
"This is the freshest state for this turn. If older transcript history conflicts with it, this state wins.",
|
|
879
|
+
`- live conversation: ${frame.currentSession ? formatSessionLabel(frame.currentSession) : "not in a live conversation"}`,
|
|
880
|
+
`- active lane: ${activeLane}`,
|
|
881
|
+
`- current artifact: ${currentArtifact}`,
|
|
882
|
+
`- next action: ${nextAction}`,
|
|
883
|
+
];
|
|
884
|
+
if (frame.resumeHandle?.lastVerifiedCheckpoint) {
|
|
885
|
+
lines.push(`- last checkpoint: ${frame.resumeHandle.lastVerifiedCheckpoint}`);
|
|
886
|
+
}
|
|
887
|
+
const evolutionCheckpointLine = formatEvolutionCheckpointLine(liveEvolutionCases(frame.evolutionCases));
|
|
888
|
+
if (evolutionCheckpointLine) {
|
|
889
|
+
lines.push(evolutionCheckpointLine);
|
|
890
|
+
}
|
|
891
|
+
if (otherActiveSessions.length > 0) {
|
|
892
|
+
lines.push("other active sessions:");
|
|
893
|
+
lines.push(...otherActiveSessions);
|
|
894
|
+
}
|
|
895
|
+
return lines.join("\n");
|
|
896
|
+
}
|
|
897
|
+
function snapshotActiveWork(frame) {
|
|
898
|
+
return {
|
|
899
|
+
obligationSnapshots: (frame.pendingObligations ?? []).map((ob) => ({
|
|
900
|
+
id: ob.id,
|
|
901
|
+
status: ob.status,
|
|
902
|
+
artifact: ob.currentArtifact?.trim() || null,
|
|
903
|
+
nextAction: ob.nextAction?.trim() || null,
|
|
904
|
+
})),
|
|
905
|
+
codingSnapshots: (frame.codingSessions ?? []).map((cs) => ({
|
|
906
|
+
id: cs.id,
|
|
907
|
+
status: cs.status,
|
|
908
|
+
artifact: cs.artifactPath?.trim() || null,
|
|
909
|
+
checkpoint: cs.checkpoint?.trim() || null,
|
|
910
|
+
})),
|
|
911
|
+
timestamp: new Date().toISOString(),
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
function detectActiveWorkChanges(previous, current) {
|
|
915
|
+
const changes = [];
|
|
916
|
+
const prevObMap = new Map(previous.obligationSnapshots.map((ob) => [ob.id, ob]));
|
|
917
|
+
const currObMap = new Map(current.obligationSnapshots.map((ob) => [ob.id, ob]));
|
|
918
|
+
// Detect new and changed obligations
|
|
919
|
+
for (const [id, curr] of currObMap) {
|
|
920
|
+
const prev = prevObMap.get(id);
|
|
921
|
+
if (!prev) {
|
|
922
|
+
changes.push({
|
|
923
|
+
kind: "obligation_appeared",
|
|
924
|
+
id,
|
|
925
|
+
from: null,
|
|
926
|
+
to: curr.status,
|
|
927
|
+
summary: `new obligation: ${curr.status}`,
|
|
928
|
+
});
|
|
929
|
+
continue;
|
|
930
|
+
}
|
|
931
|
+
if (prev.status !== curr.status) {
|
|
932
|
+
changes.push({
|
|
933
|
+
kind: "obligation_status_changed",
|
|
934
|
+
id,
|
|
935
|
+
from: prev.status,
|
|
936
|
+
to: curr.status,
|
|
937
|
+
summary: `obligation ${prev.status} -> ${curr.status}`,
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
if (prev.artifact !== curr.artifact) {
|
|
941
|
+
changes.push({
|
|
942
|
+
kind: "obligation_artifact_changed",
|
|
943
|
+
id,
|
|
944
|
+
from: prev.artifact,
|
|
945
|
+
to: curr.artifact,
|
|
946
|
+
summary: curr.artifact ? `artifact updated: ${curr.artifact}` : "artifact cleared",
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
const prevCodingMap = new Map(previous.codingSnapshots.map((cs) => [cs.id, cs]));
|
|
951
|
+
const currCodingMap = new Map(current.codingSnapshots.map((cs) => [cs.id, cs]));
|
|
952
|
+
for (const [id, curr] of currCodingMap) {
|
|
953
|
+
const prev = prevCodingMap.get(id);
|
|
954
|
+
if (!prev)
|
|
955
|
+
continue;
|
|
956
|
+
if (prev.status !== curr.status) {
|
|
957
|
+
changes.push({
|
|
958
|
+
kind: "coding_status_changed",
|
|
959
|
+
id,
|
|
960
|
+
from: prev.status,
|
|
961
|
+
to: curr.status,
|
|
962
|
+
summary: `coding ${prev.status} -> ${curr.status}`,
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
if (prev.artifact !== curr.artifact) {
|
|
966
|
+
changes.push({
|
|
967
|
+
kind: "coding_artifact_changed",
|
|
968
|
+
id,
|
|
969
|
+
from: prev.artifact,
|
|
970
|
+
to: curr.artifact,
|
|
971
|
+
summary: curr.artifact ? `artifact updated: ${curr.artifact}` : "artifact cleared",
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
if (prev.checkpoint !== curr.checkpoint) {
|
|
975
|
+
changes.push({
|
|
976
|
+
kind: "coding_checkpoint_changed",
|
|
977
|
+
id,
|
|
978
|
+
from: prev.checkpoint,
|
|
979
|
+
to: curr.checkpoint,
|
|
980
|
+
summary: curr.checkpoint ? `checkpoint: ${curr.checkpoint}` : "checkpoint cleared",
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
return changes;
|
|
985
|
+
}
|
|
986
|
+
function formatActiveWorkChanges(changes) {
|
|
987
|
+
if (changes.length === 0)
|
|
988
|
+
return "";
|
|
989
|
+
const lines = ["## what changed since last looked"];
|
|
990
|
+
for (const change of changes) {
|
|
991
|
+
lines.push(`- ${change.summary}`);
|
|
992
|
+
}
|
|
993
|
+
return lines.join("\n");
|
|
994
|
+
}
|
|
995
|
+
/* v8 ignore stop */
|