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