@ouro.bot/cli 0.1.0-alpha.5 → 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 +226 -183
- package/SerpentGuide.ouro/agent.json +82 -0
- package/SerpentGuide.ouro/psyche/SOUL.md +25 -0
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +2 -2
- package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +1 -1
- package/assets/ouroboros.png +0 -0
- package/changelog.json +3418 -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 +989 -0
- 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/bridges/manager.js +358 -0
- package/dist/heart/bridges/state-machine.js +135 -0
- package/dist/heart/bridges/store.js +123 -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 +193 -130
- package/dist/heart/core.js +1010 -261
- 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 +157 -0
- 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 +30 -697
- package/dist/heart/daemon/daemon-entry.js +359 -8
- package/dist/heart/daemon/daemon-health.js +141 -0
- package/dist/heart/daemon/daemon-runtime-sync.js +268 -0
- package/dist/heart/daemon/daemon-tombstone.js +236 -0
- package/dist/heart/daemon/daemon.js +813 -19
- 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 +206 -0
- 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 +171 -0
- 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 +17 -8
- 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 +215 -1
- 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 +39 -0
- package/dist/heart/daemon/runtime-logging.js +67 -16
- package/dist/heart/daemon/runtime-metadata.js +191 -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 +431 -0
- 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 +307 -0
- 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 +524 -0
- package/dist/heart/daemon/up-progress.js +366 -0
- package/dist/heart/daemon/vault-items.js +56 -0
- package/dist/heart/delegation.js +62 -0
- 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-animation.js +10 -3
- package/dist/heart/{daemon → hatch}/hatch-flow.js +54 -136
- package/dist/heart/{daemon → hatch}/hatch-specialist.js +3 -3
- package/dist/heart/hatch/specialist-orchestrator.js +129 -0
- package/dist/heart/hatch/specialist-prompt.js +102 -0
- package/dist/heart/hatch/specialist-tools.js +306 -0
- package/dist/heart/identity.js +274 -61
- package/dist/heart/kept-notes.js +357 -0
- package/dist/heart/kicks.js +2 -20
- 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/progress-story.js +42 -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 +202 -50
- 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 +68 -0
- package/dist/heart/session-activity.js +190 -0
- 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 +129 -34
- 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/turn-coordinator.js +28 -0
- package/dist/heart/versioning/ouro-bot-global-installer.js +128 -0
- package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +1 -1
- package/dist/heart/versioning/ouro-path-installer.js +425 -0
- package/dist/heart/{daemon → versioning}/ouro-uti.js +11 -2
- package/dist/heart/versioning/ouro-version-manager.js +295 -0
- package/dist/heart/versioning/staged-restart.js +146 -0
- package/dist/heart/versioning/update-checker.js +115 -0
- package/dist/heart/versioning/update-hooks.js +142 -0
- package/dist/heart/versioning/wrapper-publish-guard.js +86 -0
- 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 +77 -1
- package/dist/mind/context.js +173 -94
- package/dist/mind/diary-integrity.js +60 -0
- package/dist/mind/{memory.js → diary.js} +84 -96
- package/dist/mind/embedding-provider.js +60 -0
- package/dist/mind/file-state.js +179 -0
- package/dist/mind/first-impressions.js +16 -2
- package/dist/mind/friends/channel.js +73 -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 +58 -3
- package/dist/mind/friends/trust-explanation.js +74 -0
- package/dist/mind/friends/types.js +10 -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 +76 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt-refresh.js +3 -2
- package/dist/mind/prompt.js +1144 -117
- package/dist/mind/provenance-trust.js +26 -0
- package/dist/mind/scrutiny.js +173 -0
- package/dist/mind/token-estimate.js +8 -12
- package/dist/nerves/cli-logging.js +22 -3
- 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 +17 -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 +301 -0
- package/dist/repertoire/coding/index.js +4 -1
- package/dist/repertoire/coding/manager.js +220 -13
- package/dist/repertoire/coding/spawner.js +58 -12
- package/dist/repertoire/coding/tools.js +209 -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/data/ado-endpoints.json +188 -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 +43 -5
- package/dist/repertoire/tasks/fix.js +182 -0
- package/dist/repertoire/tasks/index.js +39 -13
- 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 -79
- package/dist/repertoire/tool-results.js +29 -0
- package/dist/repertoire/tools-attachments.js +317 -0
- package/dist/repertoire/tools-base.js +49 -707
- package/dist/repertoire/tools-bluebubbles.js +94 -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 +64 -61
- 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 +149 -98
- 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 +685 -0
- package/dist/senses/bluebubbles/entry.js +73 -0
- package/dist/senses/bluebubbles/inbound-log.js +126 -0
- package/dist/senses/bluebubbles/index.js +1881 -0
- package/dist/senses/bluebubbles/media.js +389 -0
- package/dist/senses/bluebubbles/model.js +282 -0
- package/dist/senses/bluebubbles/mutation-log.js +116 -0
- package/dist/senses/bluebubbles/processed-log.js +111 -0
- package/dist/senses/bluebubbles/replay.js +129 -0
- package/dist/senses/bluebubbles/runtime-state.js +109 -0
- package/dist/senses/bluebubbles/session-cleanup.js +72 -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 +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 +768 -264
- package/dist/senses/commands.js +66 -3
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/habit-turn-message.js +108 -0
- package/dist/senses/inner-dialog-worker.js +199 -16
- package/dist/senses/inner-dialog.js +640 -91
- package/dist/senses/mail-entry.js +66 -0
- package/dist/senses/mail.js +379 -0
- package/dist/senses/pipeline.js +665 -0
- 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 +844 -197
- package/dist/senses/trust-gate.js +207 -2
- package/dist/trips/core.js +138 -0
- package/dist/trips/store.js +146 -0
- package/package.json +47 -6
- 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/AdoptionSpecialist.ouro/agent.json +0 -20
- package/AdoptionSpecialist.ouro/psyche/SOUL.md +0 -22
- package/dist/heart/daemon/specialist-orchestrator.js +0 -160
- package/dist/heart/daemon/specialist-prompt.js +0 -40
- package/dist/heart/daemon/specialist-session.js +0 -142
- package/dist/heart/daemon/specialist-tools.js +0 -128
- package/dist/heart/daemon/subagent-installer.js +0 -125
- package/dist/inner-worker-entry.js +0 -4
- package/dist/mind/associative-recall.js +0 -197
- package/subagents/README.md +0 -73
- package/subagents/work-doer.md +0 -233
- package/subagents/work-merger.md +0 -624
- package/subagents/work-planner.md +0 -373
- /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/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
|
@@ -35,21 +35,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.CodingSessionManager = void 0;
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
|
-
const os = __importStar(require("os"));
|
|
39
38
|
const path = __importStar(require("path"));
|
|
40
39
|
const identity_1 = require("../../heart/identity");
|
|
41
40
|
const runtime_1 = require("../../nerves/runtime");
|
|
42
41
|
const spawner_1 = require("./spawner");
|
|
43
|
-
function safeAgentName() {
|
|
44
|
-
try {
|
|
45
|
-
return (0, identity_1.getAgentName)();
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
return "default";
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
42
|
function defaultStateFilePath(agentName) {
|
|
52
|
-
return path.join(
|
|
43
|
+
return path.join((0, identity_1.getAgentRoot)(agentName), "state", "coding", "sessions.json");
|
|
44
|
+
}
|
|
45
|
+
function defaultArtifactDirPath(agentName) {
|
|
46
|
+
return path.join((0, identity_1.getAgentRoot)(agentName), "state", "coding", "sessions");
|
|
53
47
|
}
|
|
54
48
|
function isPidAlive(pid) {
|
|
55
49
|
try {
|
|
@@ -63,6 +57,11 @@ function isPidAlive(pid) {
|
|
|
63
57
|
function cloneSession(session) {
|
|
64
58
|
return {
|
|
65
59
|
...session,
|
|
60
|
+
originSession: session.originSession ? { ...session.originSession } : undefined,
|
|
61
|
+
checkpoint: session.checkpoint ?? null,
|
|
62
|
+
artifactPath: session.artifactPath,
|
|
63
|
+
stdoutTail: session.stdoutTail,
|
|
64
|
+
stderrTail: session.stderrTail,
|
|
66
65
|
failure: session.failure
|
|
67
66
|
? {
|
|
68
67
|
...session.failure,
|
|
@@ -84,6 +83,46 @@ function appendTail(existing, nextChunk, maxLength = 2000) {
|
|
|
84
83
|
const combined = `${existing}${nextChunk}`;
|
|
85
84
|
return combined.length <= maxLength ? combined : combined.slice(combined.length - maxLength);
|
|
86
85
|
}
|
|
86
|
+
function compactText(text) {
|
|
87
|
+
return text.replace(/\s+/g, " ").trim();
|
|
88
|
+
}
|
|
89
|
+
function clipText(text, maxLength = 240) {
|
|
90
|
+
return text.length <= maxLength ? text : `${text.slice(0, maxLength - 3)}...`;
|
|
91
|
+
}
|
|
92
|
+
function latestMeaningfulLine(text) {
|
|
93
|
+
const lines = text
|
|
94
|
+
.split(/\r?\n/)
|
|
95
|
+
.map((line) => compactText(line))
|
|
96
|
+
.filter(Boolean);
|
|
97
|
+
if (lines.length === 0)
|
|
98
|
+
return null;
|
|
99
|
+
return clipText(lines.at(-1));
|
|
100
|
+
}
|
|
101
|
+
function fallbackCheckpoint(status, code, signal) {
|
|
102
|
+
switch (status) {
|
|
103
|
+
case "waiting_input":
|
|
104
|
+
return "needs input";
|
|
105
|
+
case "stalled":
|
|
106
|
+
return "no recent output";
|
|
107
|
+
case "completed":
|
|
108
|
+
return "completed";
|
|
109
|
+
case "failed":
|
|
110
|
+
if (code !== null)
|
|
111
|
+
return `exit code ${code}`;
|
|
112
|
+
if (signal)
|
|
113
|
+
return `terminated by ${signal}`;
|
|
114
|
+
return "failed";
|
|
115
|
+
case "killed":
|
|
116
|
+
return "terminated by parent agent";
|
|
117
|
+
default:
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function deriveCheckpoint(session) {
|
|
122
|
+
return (latestMeaningfulLine(session.stderrTail)
|
|
123
|
+
?? latestMeaningfulLine(session.stdoutTail)
|
|
124
|
+
?? fallbackCheckpoint(session.status, session.lastExitCode, session.lastSignal));
|
|
125
|
+
}
|
|
87
126
|
function isSpawnCodingResult(value) {
|
|
88
127
|
return typeof value === "object" && value !== null && "process" in value;
|
|
89
128
|
}
|
|
@@ -115,11 +154,13 @@ function defaultFailureDiagnostics(code, signal, command, args, stdoutTail, stde
|
|
|
115
154
|
}
|
|
116
155
|
class CodingSessionManager {
|
|
117
156
|
records = new Map();
|
|
157
|
+
listeners = new Map();
|
|
118
158
|
spawnProcess;
|
|
119
159
|
nowIso;
|
|
120
160
|
maxRestarts;
|
|
121
161
|
defaultStallThresholdMs;
|
|
122
162
|
stateFilePath;
|
|
163
|
+
artifactDirPath;
|
|
123
164
|
existsSync;
|
|
124
165
|
readFileSync;
|
|
125
166
|
writeFileSync;
|
|
@@ -137,8 +178,19 @@ class CodingSessionManager {
|
|
|
137
178
|
this.writeFileSync = options.writeFileSync ?? fs.writeFileSync;
|
|
138
179
|
this.mkdirSync = options.mkdirSync ?? fs.mkdirSync;
|
|
139
180
|
this.pidAlive = options.pidAlive ?? isPidAlive;
|
|
140
|
-
|
|
181
|
+
// No silent fallback to "default" — if there's no agentName and no
|
|
182
|
+
// explicit option, getAgentName() throws. The previous `safeAgentName`
|
|
183
|
+
// helper fell back to "default" and ended up writing coding session
|
|
184
|
+
// state to `~/AgentBundles/default.ouro/state/coding/sessions.json` on
|
|
185
|
+
// every vitest run because the coding manager singleton constructs with
|
|
186
|
+
// `{}`. That leaked real-fs state into the developer's home directory
|
|
187
|
+
// on every coverage run. Production callers always pass via argv (see
|
|
188
|
+
// getAgentName); test callers must either pass `agentName` explicitly
|
|
189
|
+
// or mock `../../heart/identity`.
|
|
190
|
+
this.agentName = options.agentName ?? (0, identity_1.getAgentName)();
|
|
141
191
|
this.stateFilePath = options.stateFilePath ?? defaultStateFilePath(this.agentName);
|
|
192
|
+
this.artifactDirPath = options.artifactDirPath
|
|
193
|
+
?? (options.stateFilePath ? path.dirname(options.stateFilePath) : defaultArtifactDirPath(this.agentName));
|
|
142
194
|
this.loadPersistedState();
|
|
143
195
|
}
|
|
144
196
|
async spawnSession(request) {
|
|
@@ -155,9 +207,15 @@ class CodingSessionManager {
|
|
|
155
207
|
runner: normalizedRequest.runner,
|
|
156
208
|
workdir: normalizedRequest.workdir,
|
|
157
209
|
taskRef: normalizedRequest.taskRef,
|
|
210
|
+
originSession: normalizedRequest.originSession ? { ...normalizedRequest.originSession } : undefined,
|
|
211
|
+
obligationId: normalizedRequest.obligationId,
|
|
158
212
|
scopeFile: normalizedRequest.scopeFile,
|
|
159
213
|
stateFile: normalizedRequest.stateFile,
|
|
214
|
+
checkpoint: null,
|
|
215
|
+
artifactPath: this.artifactPathFor(id),
|
|
160
216
|
status: "spawning",
|
|
217
|
+
stdoutTail: "",
|
|
218
|
+
stderrTail: "",
|
|
161
219
|
pid: null,
|
|
162
220
|
startedAt: now,
|
|
163
221
|
lastActivityAt: now,
|
|
@@ -188,6 +246,7 @@ class CodingSessionManager {
|
|
|
188
246
|
meta: { id, runner: normalizedRequest.runner, pid: session.pid },
|
|
189
247
|
});
|
|
190
248
|
this.persistState();
|
|
249
|
+
this.notifyListeners(id, { kind: "spawned", session: cloneSession(session) });
|
|
191
250
|
return cloneSession(session);
|
|
192
251
|
}
|
|
193
252
|
listSessions() {
|
|
@@ -199,6 +258,20 @@ class CodingSessionManager {
|
|
|
199
258
|
const record = this.records.get(sessionId);
|
|
200
259
|
return record ? cloneSession(record.session) : null;
|
|
201
260
|
}
|
|
261
|
+
subscribe(sessionId, listener) {
|
|
262
|
+
const listeners = this.listeners.get(sessionId) ?? new Set();
|
|
263
|
+
listeners.add(listener);
|
|
264
|
+
this.listeners.set(sessionId, listeners);
|
|
265
|
+
return () => {
|
|
266
|
+
const current = this.listeners.get(sessionId);
|
|
267
|
+
if (!current)
|
|
268
|
+
return;
|
|
269
|
+
current.delete(listener);
|
|
270
|
+
if (current.size === 0) {
|
|
271
|
+
this.listeners.delete(sessionId);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
}
|
|
202
275
|
sendInput(sessionId, input) {
|
|
203
276
|
const record = this.records.get(sessionId);
|
|
204
277
|
if (!record || !record.process) {
|
|
@@ -226,6 +299,7 @@ class CodingSessionManager {
|
|
|
226
299
|
record.process.kill("SIGTERM");
|
|
227
300
|
record.process = null;
|
|
228
301
|
record.session.status = "killed";
|
|
302
|
+
record.session.checkpoint = "terminated by parent agent";
|
|
229
303
|
record.session.endedAt = this.nowIso();
|
|
230
304
|
(0, runtime_1.emitNervesEvent)({
|
|
231
305
|
component: "repertoire",
|
|
@@ -234,6 +308,7 @@ class CodingSessionManager {
|
|
|
234
308
|
meta: { id: sessionId },
|
|
235
309
|
});
|
|
236
310
|
this.persistState();
|
|
311
|
+
this.notifyListeners(sessionId, { kind: "killed", session: cloneSession(record.session) });
|
|
237
312
|
return { ok: true, message: `killed ${sessionId}` };
|
|
238
313
|
}
|
|
239
314
|
checkStalls(nowMs = Date.now()) {
|
|
@@ -247,6 +322,7 @@ class CodingSessionManager {
|
|
|
247
322
|
continue;
|
|
248
323
|
stalled += 1;
|
|
249
324
|
record.session.status = "stalled";
|
|
325
|
+
record.session.checkpoint = deriveCheckpoint(record.session);
|
|
250
326
|
(0, runtime_1.emitNervesEvent)({
|
|
251
327
|
level: "warn",
|
|
252
328
|
component: "repertoire",
|
|
@@ -254,6 +330,7 @@ class CodingSessionManager {
|
|
|
254
330
|
message: "coding session stalled",
|
|
255
331
|
meta: { id: record.session.id, elapsedMs: elapsed },
|
|
256
332
|
});
|
|
333
|
+
this.notifyListeners(record.session.id, { kind: "stalled", session: cloneSession(record.session) });
|
|
257
334
|
if (record.request.autoRestartOnStall !== false && record.session.restartCount < this.maxRestarts) {
|
|
258
335
|
this.restartSession(record, "stalled");
|
|
259
336
|
}
|
|
@@ -271,6 +348,7 @@ class CodingSessionManager {
|
|
|
271
348
|
record.process = null;
|
|
272
349
|
if (record.session.status === "running" || record.session.status === "spawning") {
|
|
273
350
|
record.session.status = "killed";
|
|
351
|
+
record.session.checkpoint = "terminated during manager shutdown";
|
|
274
352
|
record.session.endedAt = this.nowIso();
|
|
275
353
|
}
|
|
276
354
|
}
|
|
@@ -297,18 +375,30 @@ class CodingSessionManager {
|
|
|
297
375
|
}
|
|
298
376
|
onOutput(record, text, stream) {
|
|
299
377
|
record.session.lastActivityAt = this.nowIso();
|
|
378
|
+
let updateKind = "progress";
|
|
300
379
|
if (stream === "stdout") {
|
|
301
380
|
record.stdoutTail = appendTail(record.stdoutTail, text);
|
|
381
|
+
record.session.stdoutTail = record.stdoutTail;
|
|
302
382
|
}
|
|
303
383
|
else {
|
|
304
384
|
record.stderrTail = appendTail(record.stderrTail, text);
|
|
385
|
+
record.session.stderrTail = record.stderrTail;
|
|
305
386
|
}
|
|
306
387
|
if (text.includes("status: NEEDS_REVIEW") || text.includes("❌ blocked")) {
|
|
307
388
|
record.session.status = "waiting_input";
|
|
389
|
+
updateKind = "waiting_input";
|
|
308
390
|
}
|
|
309
391
|
if (text.includes("✅ all units complete")) {
|
|
310
392
|
record.session.status = "completed";
|
|
311
393
|
record.session.endedAt = this.nowIso();
|
|
394
|
+
updateKind = "completed";
|
|
395
|
+
}
|
|
396
|
+
const checkpoint = latestMeaningfulLine(text);
|
|
397
|
+
if (checkpoint) {
|
|
398
|
+
record.session.checkpoint = checkpoint;
|
|
399
|
+
}
|
|
400
|
+
else if (!record.session.checkpoint) {
|
|
401
|
+
record.session.checkpoint = deriveCheckpoint(record.session);
|
|
312
402
|
}
|
|
313
403
|
(0, runtime_1.emitNervesEvent)({
|
|
314
404
|
component: "repertoire",
|
|
@@ -317,6 +407,12 @@ class CodingSessionManager {
|
|
|
317
407
|
meta: { id: record.session.id, status: record.session.status },
|
|
318
408
|
});
|
|
319
409
|
this.persistState();
|
|
410
|
+
this.notifyListeners(record.session.id, {
|
|
411
|
+
kind: updateKind,
|
|
412
|
+
session: cloneSession(record.session),
|
|
413
|
+
stream,
|
|
414
|
+
text,
|
|
415
|
+
});
|
|
320
416
|
}
|
|
321
417
|
onExit(record, code, signal) {
|
|
322
418
|
if (!record.process)
|
|
@@ -327,13 +423,16 @@ class CodingSessionManager {
|
|
|
327
423
|
record.session.lastSignal = signal;
|
|
328
424
|
if (record.session.status === "killed" || record.session.status === "completed") {
|
|
329
425
|
record.session.endedAt = this.nowIso();
|
|
426
|
+
record.session.checkpoint = deriveCheckpoint(record.session);
|
|
330
427
|
this.persistState();
|
|
331
428
|
return;
|
|
332
429
|
}
|
|
333
430
|
if (code === 0) {
|
|
334
431
|
record.session.status = "completed";
|
|
335
432
|
record.session.endedAt = this.nowIso();
|
|
433
|
+
record.session.checkpoint = deriveCheckpoint(record.session);
|
|
336
434
|
this.persistState();
|
|
435
|
+
this.notifyListeners(record.session.id, { kind: "completed", session: cloneSession(record.session) });
|
|
337
436
|
return;
|
|
338
437
|
}
|
|
339
438
|
if (record.request.autoRestartOnCrash !== false && record.session.restartCount < this.maxRestarts) {
|
|
@@ -343,6 +442,7 @@ class CodingSessionManager {
|
|
|
343
442
|
record.session.status = "failed";
|
|
344
443
|
record.session.endedAt = this.nowIso();
|
|
345
444
|
record.session.failure = defaultFailureDiagnostics(code, signal, record.command, record.args, record.stdoutTail, record.stderrTail);
|
|
445
|
+
record.session.checkpoint = deriveCheckpoint(record.session);
|
|
346
446
|
(0, runtime_1.emitNervesEvent)({
|
|
347
447
|
level: "error",
|
|
348
448
|
component: "repertoire",
|
|
@@ -351,6 +451,7 @@ class CodingSessionManager {
|
|
|
351
451
|
meta: { id: record.session.id, code, signal, command: record.command },
|
|
352
452
|
});
|
|
353
453
|
this.persistState();
|
|
454
|
+
this.notifyListeners(record.session.id, { kind: "failed", session: cloneSession(record.session) });
|
|
354
455
|
}
|
|
355
456
|
restartSession(record, reason) {
|
|
356
457
|
const replacement = normalizeSpawnResult(this.spawnProcess(record.request));
|
|
@@ -359,12 +460,15 @@ class CodingSessionManager {
|
|
|
359
460
|
record.args = [...replacement.args];
|
|
360
461
|
record.stdoutTail = "";
|
|
361
462
|
record.stderrTail = "";
|
|
463
|
+
record.session.stdoutTail = "";
|
|
464
|
+
record.session.stderrTail = "";
|
|
362
465
|
record.session.pid = replacement.process.pid ?? null;
|
|
363
466
|
record.session.restartCount += 1;
|
|
364
467
|
record.session.status = "running";
|
|
365
468
|
record.session.lastActivityAt = this.nowIso();
|
|
366
469
|
record.session.endedAt = null;
|
|
367
470
|
record.session.failure = null;
|
|
471
|
+
record.session.checkpoint = `restarted after ${reason}`;
|
|
368
472
|
this.attachProcessListeners(record);
|
|
369
473
|
(0, runtime_1.emitNervesEvent)({
|
|
370
474
|
level: "warn",
|
|
@@ -375,6 +479,26 @@ class CodingSessionManager {
|
|
|
375
479
|
});
|
|
376
480
|
this.persistState();
|
|
377
481
|
}
|
|
482
|
+
notifyListeners(sessionId, update) {
|
|
483
|
+
const listeners = this.listeners.get(sessionId);
|
|
484
|
+
if (!listeners || listeners.size === 0)
|
|
485
|
+
return;
|
|
486
|
+
for (const listener of listeners) {
|
|
487
|
+
void Promise.resolve(listener(update)).catch((error) => {
|
|
488
|
+
(0, runtime_1.emitNervesEvent)({
|
|
489
|
+
level: "warn",
|
|
490
|
+
component: "repertoire",
|
|
491
|
+
event: "repertoire.coding_feedback_listener_error",
|
|
492
|
+
message: "coding session listener failed",
|
|
493
|
+
meta: {
|
|
494
|
+
sessionId,
|
|
495
|
+
kind: update.kind,
|
|
496
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
497
|
+
},
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
}
|
|
378
502
|
loadPersistedState() {
|
|
379
503
|
if (!this.existsSync(this.stateFilePath)) {
|
|
380
504
|
return;
|
|
@@ -426,13 +550,21 @@ class CodingSessionManager {
|
|
|
426
550
|
}
|
|
427
551
|
const normalizedRequest = {
|
|
428
552
|
...request,
|
|
553
|
+
originSession: request.originSession ? { ...request.originSession } : undefined,
|
|
429
554
|
sessionId: request.sessionId ?? session.id,
|
|
555
|
+
obligationId: request.obligationId,
|
|
430
556
|
parentAgent: request.parentAgent ?? this.agentName,
|
|
431
557
|
};
|
|
432
558
|
const normalizedSession = {
|
|
433
559
|
...session,
|
|
434
560
|
taskRef: session.taskRef ?? normalizedRequest.taskRef,
|
|
561
|
+
originSession: session.originSession ?? normalizedRequest.originSession,
|
|
562
|
+
obligationId: session.obligationId ?? normalizedRequest.obligationId,
|
|
435
563
|
failure: session.failure ?? null,
|
|
564
|
+
stdoutTail: session.stdoutTail ?? session.failure?.stdoutTail ?? "",
|
|
565
|
+
stderrTail: session.stderrTail ?? session.failure?.stderrTail ?? "",
|
|
566
|
+
checkpoint: typeof session.checkpoint === "string" ? session.checkpoint : null,
|
|
567
|
+
artifactPath: typeof session.artifactPath === "string" ? session.artifactPath : this.artifactPathFor(session.id),
|
|
436
568
|
};
|
|
437
569
|
if (typeof normalizedSession.pid === "number") {
|
|
438
570
|
const alive = this.pidAlive(normalizedSession.pid);
|
|
@@ -445,14 +577,15 @@ class CodingSessionManager {
|
|
|
445
577
|
normalizedSession.pid = null;
|
|
446
578
|
}
|
|
447
579
|
}
|
|
580
|
+
normalizedSession.checkpoint = normalizedSession.checkpoint ?? deriveCheckpoint(normalizedSession);
|
|
448
581
|
this.records.set(normalizedSession.id, {
|
|
449
582
|
request: normalizedRequest,
|
|
450
583
|
session: normalizedSession,
|
|
451
584
|
process: null,
|
|
452
585
|
command: normalizedSession.failure?.command ?? "restored",
|
|
453
586
|
args: normalizedSession.failure ? [...normalizedSession.failure.args] : [],
|
|
454
|
-
stdoutTail: normalizedSession.
|
|
455
|
-
stderrTail: normalizedSession.
|
|
587
|
+
stdoutTail: normalizedSession.stdoutTail,
|
|
588
|
+
stderrTail: normalizedSession.stderrTail,
|
|
456
589
|
});
|
|
457
590
|
this.sequence = Math.max(this.sequence, extractSequence(normalizedSession.id));
|
|
458
591
|
}
|
|
@@ -484,6 +617,80 @@ class CodingSessionManager {
|
|
|
484
617
|
meta: { path: this.stateFilePath, reason: error instanceof Error ? error.message : String(error) },
|
|
485
618
|
});
|
|
486
619
|
}
|
|
620
|
+
this.persistArtifacts();
|
|
621
|
+
}
|
|
622
|
+
artifactPathFor(sessionId) {
|
|
623
|
+
return path.join(this.artifactDirPath, `${sessionId}.md`);
|
|
624
|
+
}
|
|
625
|
+
renderArtifact(record) {
|
|
626
|
+
const { request, session } = record;
|
|
627
|
+
const stdout = session.stdoutTail.trim() || "(empty)";
|
|
628
|
+
const stderr = session.stderrTail.trim() || "(empty)";
|
|
629
|
+
const lines = [
|
|
630
|
+
"# Coding Session Artifact",
|
|
631
|
+
"",
|
|
632
|
+
"## Session",
|
|
633
|
+
`id: ${session.id}`,
|
|
634
|
+
`runner: ${session.runner}`,
|
|
635
|
+
`status: ${session.status}`,
|
|
636
|
+
`taskRef: ${session.taskRef ?? "unassigned"}`,
|
|
637
|
+
`workdir: ${session.workdir}`,
|
|
638
|
+
`startedAt: ${session.startedAt}`,
|
|
639
|
+
`lastActivityAt: ${session.lastActivityAt}`,
|
|
640
|
+
`endedAt: ${session.endedAt ?? "active"}`,
|
|
641
|
+
`pid: ${session.pid ?? "none"}`,
|
|
642
|
+
`restarts: ${session.restartCount}`,
|
|
643
|
+
`checkpoint: ${session.checkpoint ?? "none"}`,
|
|
644
|
+
`scopeFile: ${session.scopeFile ?? "none"}`,
|
|
645
|
+
`stateFile: ${session.stateFile ?? "none"}`,
|
|
646
|
+
"",
|
|
647
|
+
"## Request",
|
|
648
|
+
request.prompt,
|
|
649
|
+
"",
|
|
650
|
+
"## Stdout Tail",
|
|
651
|
+
stdout,
|
|
652
|
+
"",
|
|
653
|
+
"## Stderr Tail",
|
|
654
|
+
stderr,
|
|
655
|
+
];
|
|
656
|
+
if (session.failure) {
|
|
657
|
+
lines.push("", "## Failure", `command: ${session.failure.command}`, `args: ${session.failure.args.join(" ") || "(none)"}`, `code: ${session.failure.code ?? "null"}`, `signal: ${session.failure.signal ?? "null"}`);
|
|
658
|
+
}
|
|
659
|
+
return `${lines.join("\n")}\n`;
|
|
660
|
+
}
|
|
661
|
+
persistArtifacts() {
|
|
662
|
+
try {
|
|
663
|
+
this.mkdirSync(this.artifactDirPath, { recursive: true });
|
|
664
|
+
}
|
|
665
|
+
catch (error) {
|
|
666
|
+
(0, runtime_1.emitNervesEvent)({
|
|
667
|
+
level: "warn",
|
|
668
|
+
component: "repertoire",
|
|
669
|
+
event: "repertoire.coding_artifact_persist_error",
|
|
670
|
+
message: "failed preparing coding artifact directory",
|
|
671
|
+
meta: { path: this.artifactDirPath, reason: error instanceof Error ? error.message : String(error) },
|
|
672
|
+
});
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
for (const record of this.records.values()) {
|
|
676
|
+
try {
|
|
677
|
+
record.session.artifactPath = record.session.artifactPath ?? this.artifactPathFor(record.session.id);
|
|
678
|
+
this.writeFileSync(record.session.artifactPath, this.renderArtifact(record), "utf-8");
|
|
679
|
+
}
|
|
680
|
+
catch (error) {
|
|
681
|
+
(0, runtime_1.emitNervesEvent)({
|
|
682
|
+
level: "warn",
|
|
683
|
+
component: "repertoire",
|
|
684
|
+
event: "repertoire.coding_artifact_persist_error",
|
|
685
|
+
message: "failed writing coding session artifact",
|
|
686
|
+
meta: {
|
|
687
|
+
id: record.session.id,
|
|
688
|
+
path: record.session.artifactPath ?? this.artifactPathFor(record.session.id),
|
|
689
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
690
|
+
},
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
}
|
|
487
694
|
}
|
|
488
695
|
}
|
|
489
696
|
exports.CodingSessionManager = CodingSessionManager;
|
|
@@ -36,42 +36,84 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.spawnCodingProcess = spawnCodingProcess;
|
|
37
37
|
const child_process_1 = require("child_process");
|
|
38
38
|
const fs = __importStar(require("fs"));
|
|
39
|
+
const os = __importStar(require("os"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
39
41
|
const runtime_1 = require("../../nerves/runtime");
|
|
40
|
-
function buildCommandArgs(runner, workdir) {
|
|
42
|
+
function buildCommandArgs(runner, workdir, parentAgent) {
|
|
41
43
|
if (runner === "claude") {
|
|
42
44
|
return {
|
|
43
45
|
command: "claude",
|
|
44
46
|
args: [
|
|
45
47
|
"-p",
|
|
48
|
+
"--verbose",
|
|
49
|
+
"--no-session-persistence",
|
|
46
50
|
"--dangerously-skip-permissions",
|
|
47
51
|
"--add-dir",
|
|
48
52
|
workdir,
|
|
49
|
-
"--input-format",
|
|
50
|
-
"stream-json",
|
|
51
53
|
"--output-format",
|
|
52
54
|
"stream-json",
|
|
53
55
|
],
|
|
54
56
|
};
|
|
55
57
|
}
|
|
58
|
+
const agent = parentAgent ?? "unknown";
|
|
59
|
+
// Use absolute path to ouro-entry.js so MCP works in both dev and installed mode
|
|
60
|
+
// __dirname at runtime is dist/repertoire/coding/ — go up 2 levels to dist/
|
|
61
|
+
const distRoot = path.resolve(__dirname, "..", "..");
|
|
62
|
+
const ouroEntryPath = path.join(distRoot, "heart", "daemon", "ouro-entry.js");
|
|
56
63
|
return {
|
|
57
64
|
command: "codex",
|
|
58
|
-
args: [
|
|
65
|
+
args: [
|
|
66
|
+
"exec",
|
|
67
|
+
"--skip-git-repo-check",
|
|
68
|
+
"--cd",
|
|
69
|
+
workdir,
|
|
70
|
+
"--ephemeral",
|
|
71
|
+
"--json",
|
|
72
|
+
"-c",
|
|
73
|
+
`mcp_servers.ouro.command=node`,
|
|
74
|
+
"-c",
|
|
75
|
+
`mcp_servers.ouro.args=["${ouroEntryPath}","mcp-serve","--agent","${agent}"]`,
|
|
76
|
+
],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function buildSpawnEnv(baseEnv, homeDir) {
|
|
80
|
+
const binDir = path.join(homeDir, ".ouro-cli", "bin");
|
|
81
|
+
const existingPath = baseEnv.PATH ?? "";
|
|
82
|
+
const pathEntries = existingPath.split(path.delimiter).filter((entry) => entry.length > 0);
|
|
83
|
+
if (!pathEntries.includes(binDir)) {
|
|
84
|
+
pathEntries.unshift(binDir);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
...baseEnv,
|
|
88
|
+
PATH: pathEntries.join(path.delimiter),
|
|
59
89
|
};
|
|
60
90
|
}
|
|
91
|
+
function appendFileSection(sections, label, filePath, deps) {
|
|
92
|
+
if (!filePath || !deps.existsSync(filePath))
|
|
93
|
+
return;
|
|
94
|
+
const content = deps.readFileSync(filePath, "utf-8").trim();
|
|
95
|
+
if (content.length === 0)
|
|
96
|
+
return;
|
|
97
|
+
sections.push(`${label} (${filePath}):\n${content}`);
|
|
98
|
+
}
|
|
61
99
|
function buildPrompt(request, deps) {
|
|
62
100
|
const sections = [];
|
|
101
|
+
sections.push([
|
|
102
|
+
"Execution contract:",
|
|
103
|
+
"- You are a subordinate coding session launched by a parent Ouro agent.",
|
|
104
|
+
"- Execute the concrete request in the supplied workdir directly.",
|
|
105
|
+
"- Do not switch into planning/doing workflows, approval gates, or repo-management rituals unless the request explicitly asks for them.",
|
|
106
|
+
"- Treat the request, scope file, and state file as the authoritative briefing for this session.",
|
|
107
|
+
"- Prefer direct execution and verification over narration.",
|
|
108
|
+
].join("\n"));
|
|
63
109
|
sections.push([
|
|
64
110
|
"Coding session metadata:",
|
|
65
111
|
`sessionId: ${request.sessionId ?? "pending"}`,
|
|
66
112
|
`parentAgent: ${request.parentAgent ?? "unknown"}`,
|
|
67
113
|
`taskRef: ${request.taskRef ?? "unassigned"}`,
|
|
68
114
|
].join("\n"));
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (stateContent.length > 0) {
|
|
72
|
-
sections.push(`State file (${request.stateFile}):\n${stateContent}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
115
|
+
appendFileSection(sections, "Scope file", request.scopeFile, deps);
|
|
116
|
+
appendFileSection(sections, "State file", request.stateFile, deps);
|
|
75
117
|
sections.push(request.prompt);
|
|
76
118
|
return sections.join("\n\n---\n\n");
|
|
77
119
|
}
|
|
@@ -79,8 +121,11 @@ function spawnCodingProcess(request, deps = {}) {
|
|
|
79
121
|
const spawnFn = deps.spawnFn ?? ((command, args, options) => (0, child_process_1.spawn)(command, args, options));
|
|
80
122
|
const existsSync = deps.existsSync ?? fs.existsSync;
|
|
81
123
|
const readFileSync = deps.readFileSync ?? fs.readFileSync;
|
|
124
|
+
const homeDir = deps.homeDir ?? os.homedir();
|
|
125
|
+
const baseEnv = deps.baseEnv ?? process.env;
|
|
82
126
|
const prompt = buildPrompt(request, { existsSync, readFileSync });
|
|
83
|
-
const { command, args } = buildCommandArgs(request.runner, request.workdir);
|
|
127
|
+
const { command, args } = buildCommandArgs(request.runner, request.workdir, request.parentAgent);
|
|
128
|
+
const env = buildSpawnEnv(baseEnv, homeDir);
|
|
84
129
|
(0, runtime_1.emitNervesEvent)({
|
|
85
130
|
component: "repertoire",
|
|
86
131
|
event: "repertoire.coding_spawn_start",
|
|
@@ -89,9 +134,10 @@ function spawnCodingProcess(request, deps = {}) {
|
|
|
89
134
|
});
|
|
90
135
|
const proc = spawnFn(command, args, {
|
|
91
136
|
cwd: request.workdir,
|
|
137
|
+
env,
|
|
92
138
|
stdio: ["pipe", "pipe", "pipe"],
|
|
93
139
|
});
|
|
94
|
-
proc.stdin.
|
|
140
|
+
proc.stdin.end(`${prompt}\n`);
|
|
95
141
|
(0, runtime_1.emitNervesEvent)({
|
|
96
142
|
component: "repertoire",
|
|
97
143
|
event: "repertoire.coding_spawn_end",
|