@monoes/monomindcli 2.9.21 → 2.9.23
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/.claude/agents/consensus/quorum-manager.md +35 -54
- package/.claude/agents/core/coordinator.md +14 -18
- package/.claude/agents/core/researcher.md +1 -1
- package/.claude/agents/github/issue-tracker.md +3 -3
- package/.claude/agents/github/{code-review-swarm.md → monoswarm-code-review.md} +1 -1
- package/.claude/agents/github/{swarm-issue.md → monoswarm-issue.md} +1 -1
- package/.claude/agents/github/{multi-repo-swarm.md → monoswarm-multi-repo.md} +1 -1
- package/.claude/agents/github/{swarm-pr.md → monoswarm-pr.md} +1 -1
- package/.claude/agents/github/pr-manager.md +1 -1
- package/.claude/agents/github/release-manager.md +1 -1
- package/.claude/agents/github/repo-architect.md +1 -1
- package/.claude/agents/github/sync-coordinator.md +4 -4
- package/.claude/agents/{hive-mind → monoswarm}/collective-intelligence-coordinator.md +9 -16
- package/.claude/agents/{swarm → monoswarm}/mesh-coordinator.md +19 -24
- package/.claude/agents/{hive-mind/swarm-memory-manager.md → monoswarm/monoswarm-memory-manager.md} +1 -1
- package/.claude/agents/templates/{coordinator-swarm-init.md → coordinator-monoswarm-init.md} +1 -1
- package/.claude/agents/testing/{tdd-london-swarm.md → tdd-london-monoswarm.md} +2 -2
- package/.claude/commands/agents/agent-coordination.md +3 -3
- package/.claude/commands/agents/agent-types.md +1 -1
- package/.claude/commands/automation/self-healing.md +1 -1
- package/.claude/commands/automation/smart-spawn.md +1 -1
- package/.claude/commands/coordination/README.md +1 -1
- package/.claude/commands/coordination/{swarm-init.md → monoswarm-init.md} +2 -2
- package/.claude/commands/coordination/task-orchestrate.md +4 -4
- package/.claude/commands/github/README.md +1 -1
- package/.claude/commands/github/issue-tracker.md +2 -2
- package/.claude/commands/github/pr-manager.md +1 -1
- package/.claude/commands/github/release-manager.md +1 -1
- package/.claude/commands/github/repo-architect.md +1 -1
- package/.claude/commands/github/sync-coordinator.md +2 -2
- package/.claude/commands/hooks/README.md +1 -2
- package/.claude/commands/hooks/overview.md +1 -2
- package/.claude/commands/hooks/setup.md +0 -3
- package/.claude/commands/mastermind/createtask.md +2 -2
- package/.claude/commands/mastermind/do.md +3 -3
- package/.claude/commands/mastermind/help.md +2 -2
- package/.claude/commands/mastermind/ideate.md +1 -1
- package/.claude/commands/mastermind/improve.md +1 -1
- package/.claude/commands/mastermind/memory.md +2 -2
- package/.claude/commands/mastermind/{swarm.md → monoswarm.md} +13 -26
- package/.claude/commands/mastermind/topology.md +1 -1
- package/.claude/commands/memory/README.md +2 -2
- package/.claude/commands/memory/memory-search.md +1 -1
- package/.claude/commands/monoswarm/README.md +59 -0
- package/.claude/commands/monoswarm/consensus.md +61 -0
- package/.claude/commands/monoswarm/init.md +68 -0
- package/.claude/commands/monoswarm/memory.md +55 -0
- package/.claude/commands/monoswarm/monoswarm.md +139 -0
- package/.claude/commands/{swarm → monoswarm}/research.md +2 -2
- package/.claude/commands/monoswarm/spawn.md +49 -0
- package/.claude/commands/monoswarm/status.md +48 -0
- package/.claude/commands/monoswarm/stop.md +46 -0
- package/.claude/commands/optimization/auto-topology.md +9 -9
- package/.claude/commands/stream-chain/run.md +1 -1
- package/.claude/commands/workflows/development.md +1 -1
- package/.claude/commands/workflows/research.md +2 -2
- package/.claude/helpers/audit-log-writer.cjs +72 -0
- package/.claude/helpers/control-start.cjs +84 -26
- package/.claude/helpers/handlers/agent-start-handler.cjs +5 -5
- package/.claude/helpers/handlers/gates-handler.cjs +31 -10
- package/.claude/helpers/handlers/session-restore-handler.cjs +1 -1
- package/.claude/helpers/handlers/task-handler.cjs +4 -4
- package/.claude/helpers/skill-registry.json +4718 -3669
- package/.claude/helpers/statusline.cjs +21 -21
- package/.claude/helpers/token-tracker.cjs +0 -6
- package/.claude/settings.json +2 -3
- package/.claude/skills/hooks-automation/SKILL.md +5 -5
- package/.claude/skills/mastermind-createorg/SKILL.md +26 -3
- package/.claude/skills/mastermind-protocol/SKILL.md +3 -3
- package/.claude/skills/memory-toolkit/SKILL.md +2 -2
- package/.claude/skills/{swarm-orchestration → monoswarm}/SKILL.md +106 -42
- package/.claude/skills/specialagent/SKILL.md +1 -1
- package/README.md +31 -12
- package/dist/src/autopilot-state.d.ts +0 -16
- package/dist/src/autopilot-state.d.ts.map +1 -1
- package/dist/src/autopilot-state.js +0 -15
- package/dist/src/autopilot-state.js.map +1 -1
- package/dist/src/browser/dashboard/server.js +3 -3
- package/dist/src/browser/dashboard/server.js.map +1 -1
- package/dist/src/browser/dashboard/ui.html +2 -2
- package/dist/src/capabilities/cap-documents.d.ts.map +1 -1
- package/dist/src/capabilities/cap-documents.js +49 -38
- package/dist/src/capabilities/cap-documents.js.map +1 -1
- package/dist/src/commands/agent-lifecycle.d.ts.map +1 -1
- package/dist/src/commands/agent-lifecycle.js +4 -9
- package/dist/src/commands/agent-lifecycle.js.map +1 -1
- package/dist/src/commands/agent-ops.d.ts.map +1 -1
- package/dist/src/commands/agent-ops.js +37 -24
- package/dist/src/commands/agent-ops.js.map +1 -1
- package/dist/src/commands/analyze-ast.d.ts +1 -1
- package/dist/src/commands/analyze-ast.d.ts.map +1 -1
- package/dist/src/commands/analyze-ast.js +8 -27
- package/dist/src/commands/analyze-ast.js.map +1 -1
- package/dist/src/commands/analyze-imports.d.ts.map +1 -1
- package/dist/src/commands/analyze-imports.js +18 -17
- package/dist/src/commands/analyze-imports.js.map +1 -1
- package/dist/src/commands/analyze-symbols.d.ts.map +1 -1
- package/dist/src/commands/analyze-symbols.js +10 -24
- package/dist/src/commands/analyze-symbols.js.map +1 -1
- package/dist/src/commands/analyze.d.ts +19 -6
- package/dist/src/commands/analyze.d.ts.map +1 -1
- package/dist/src/commands/analyze.js +61 -15
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/autopilot.d.ts.map +1 -1
- package/dist/src/commands/autopilot.js +4 -89
- package/dist/src/commands/autopilot.js.map +1 -1
- package/dist/src/commands/browse.d.ts +1 -1
- package/dist/src/commands/cleanup.d.ts.map +1 -1
- package/dist/src/commands/cleanup.js +4 -2
- package/dist/src/commands/cleanup.js.map +1 -1
- package/dist/src/commands/completions.d.ts.map +1 -1
- package/dist/src/commands/completions.js +0 -1
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.js +7 -7
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/doctor-project-checks.d.ts +7 -0
- package/dist/src/commands/doctor-project-checks.d.ts.map +1 -1
- package/dist/src/commands/doctor-project-checks.js +37 -5
- package/dist/src/commands/doctor-project-checks.js.map +1 -1
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +9 -3
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/events.d.ts +9 -0
- package/dist/src/commands/events.d.ts.map +1 -0
- package/dist/src/commands/events.js +89 -0
- package/dist/src/commands/events.js.map +1 -0
- package/dist/src/commands/hooks-routing-commands.d.ts +1 -2
- package/dist/src/commands/hooks-routing-commands.d.ts.map +1 -1
- package/dist/src/commands/hooks-routing-commands.js +1 -101
- package/dist/src/commands/hooks-routing-commands.js.map +1 -1
- package/dist/src/commands/hooks-workers.d.ts.map +1 -1
- package/dist/src/commands/hooks-workers.js +19 -71
- package/dist/src/commands/hooks-workers.js.map +1 -1
- package/dist/src/commands/hooks.d.ts +1 -1
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +4 -7
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +2 -2
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +4 -3
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init-subcommands.d.ts.map +1 -1
- package/dist/src/commands/init-subcommands.js +4 -0
- package/dist/src/commands/init-subcommands.js.map +1 -1
- package/dist/src/commands/init-wizard.d.ts.map +1 -1
- package/dist/src/commands/init-wizard.js +0 -8
- package/dist/src/commands/init-wizard.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +53 -23
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/mcp.d.ts +1 -0
- package/dist/src/commands/mcp.d.ts.map +1 -1
- package/dist/src/commands/mcp.js +111 -60
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory-crud.d.ts.map +1 -1
- package/dist/src/commands/memory-crud.js +33 -20
- package/dist/src/commands/memory-crud.js.map +1 -1
- package/dist/src/commands/monoswarm.d.ts +8 -0
- package/dist/src/commands/monoswarm.d.ts.map +1 -0
- package/dist/src/commands/{swarm.js → monoswarm.js} +83 -297
- package/dist/src/commands/monoswarm.js.map +1 -0
- package/dist/src/commands/neural-core.d.ts.map +1 -1
- package/dist/src/commands/neural-core.js +9 -1
- package/dist/src/commands/neural-core.js.map +1 -1
- package/dist/src/commands/neural-optimize.d.ts.map +1 -1
- package/dist/src/commands/neural-optimize.js +30 -110
- package/dist/src/commands/neural-optimize.js.map +1 -1
- package/dist/src/commands/neural-registry.d.ts +1 -2
- package/dist/src/commands/neural-registry.d.ts.map +1 -1
- package/dist/src/commands/neural-registry.js +21 -168
- package/dist/src/commands/neural-registry.js.map +1 -1
- package/dist/src/commands/org-observe.d.ts +34 -3
- package/dist/src/commands/org-observe.d.ts.map +1 -1
- package/dist/src/commands/org-observe.js +213 -45
- package/dist/src/commands/org-observe.js.map +1 -1
- package/dist/src/commands/org.d.ts +14 -0
- package/dist/src/commands/org.d.ts.map +1 -1
- package/dist/src/commands/org.js +118 -20
- package/dist/src/commands/org.js.map +1 -1
- package/dist/src/commands/performance.d.ts.map +1 -1
- package/dist/src/commands/performance.js +38 -31
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/security-misc.d.ts.map +1 -1
- package/dist/src/commands/security-misc.js +220 -90
- package/dist/src/commands/security-misc.js.map +1 -1
- package/dist/src/commands/security-scan.d.ts +13 -0
- package/dist/src/commands/security-scan.d.ts.map +1 -1
- package/dist/src/commands/security-scan.js +96 -27
- package/dist/src/commands/security-scan.js.map +1 -1
- package/dist/src/commands/security.js +1 -1
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/start.d.ts.map +1 -1
- package/dist/src/commands/start.js +17 -96
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +72 -64
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/tokens.d.ts.map +1 -1
- package/dist/src/commands/tokens.js +4 -5
- package/dist/src/commands/tokens.js.map +1 -1
- package/dist/src/consensus/audit-writer.d.ts +2 -2
- package/dist/src/consensus/audit-writer.d.ts.map +1 -1
- package/dist/src/consensus/audit-writer.js +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +12 -10
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts.map +1 -1
- package/dist/src/init/claudemd-generator.js +32 -31
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/codex-generator.d.ts +10 -0
- package/dist/src/init/codex-generator.d.ts.map +1 -0
- package/dist/src/init/codex-generator.js +67 -0
- package/dist/src/init/codex-generator.js.map +1 -0
- package/dist/src/init/copy-assets.d.ts.map +1 -1
- package/dist/src/init/copy-assets.js +4 -8
- package/dist/src/init/copy-assets.js.map +1 -1
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +9 -2
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.js +1 -1
- package/dist/src/init/index.d.ts +1 -0
- package/dist/src/init/index.d.ts.map +1 -1
- package/dist/src/init/index.js +1 -0
- package/dist/src/init/index.js.map +1 -1
- package/dist/src/init/opencode-generator.js +2 -2
- package/dist/src/init/opencode-generator.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +1 -2
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/shared.d.ts.map +1 -1
- package/dist/src/init/shared.js +3 -7
- package/dist/src/init/shared.js.map +1 -1
- package/dist/src/init/statusline-generator.js +19 -19
- package/dist/src/init/types.d.ts +9 -10
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +8 -6
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/init/upgrade.js +5 -5
- package/dist/src/init/upgrade.js.map +1 -1
- package/dist/src/init/write-capabilities.d.ts.map +1 -1
- package/dist/src/init/write-capabilities.js +36 -49
- package/dist/src/init/write-capabilities.js.map +1 -1
- package/dist/src/init/write-claude.js +1 -1
- package/dist/src/init/write-claude.js.map +1 -1
- package/dist/src/init/write-codex.d.ts +4 -0
- package/dist/src/init/write-codex.d.ts.map +1 -0
- package/dist/src/init/write-codex.js +57 -0
- package/dist/src/init/write-codex.js.map +1 -0
- package/dist/src/init/write-runtime-config.d.ts.map +1 -1
- package/dist/src/init/write-runtime-config.js +4 -5
- package/dist/src/init/write-runtime-config.js.map +1 -1
- package/dist/src/knowledge/eval/golden-set.js +15 -15
- package/dist/src/knowledge/eval/golden-set.js.map +1 -1
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +1 -2
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.js +1 -1
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +3 -3
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/autopilot-tools.d.ts +1 -1
- package/dist/src/mcp-tools/autopilot-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/autopilot-tools.js +4 -62
- package/dist/src/mcp-tools/autopilot-tools.js.map +1 -1
- package/dist/src/mcp-tools/guidance-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/guidance-tools.js +21 -31
- package/dist/src/mcp-tools/guidance-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-intelligence.d.ts +0 -1
- package/dist/src/mcp-tools/hooks-intelligence.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-intelligence.js +56 -103
- package/dist/src/mcp-tools/hooks-intelligence.js.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.d.ts +1 -2
- package/dist/src/mcp-tools/hooks-routing.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.js +78 -152
- package/dist/src/mcp-tools/hooks-routing.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2 -4
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +1 -2
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +1 -2
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +10 -10
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/monograph/query-tools.js +9 -9
- package/dist/src/mcp-tools/monograph/query-tools.js.map +1 -1
- package/dist/src/mcp-tools/monoswarm-tools.d.ts +17 -0
- package/dist/src/mcp-tools/monoswarm-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monoswarm-tools.js +1153 -0
- package/dist/src/mcp-tools/monoswarm-tools.js.map +1 -0
- package/dist/src/mcp-tools/performance-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +32 -25
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +30 -13
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.d.ts +8 -12
- package/dist/src/mcp-tools/transfer-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +9 -13
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/memory/embedding-operations.d.ts.map +1 -1
- package/dist/src/memory/embedding-operations.js +0 -37
- package/dist/src/memory/embedding-operations.js.map +1 -1
- package/dist/src/memory/hnsw-operations.d.ts +14 -74
- package/dist/src/memory/hnsw-operations.d.ts.map +1 -1
- package/dist/src/memory/hnsw-operations.js +22 -262
- package/dist/src/memory/hnsw-operations.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts +2 -2
- package/dist/src/memory/intelligence.d.ts.map +1 -1
- package/dist/src/memory/intelligence.js +8 -7
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts +24 -24
- package/dist/src/memory/memory-bridge.d.ts.map +1 -1
- package/dist/src/memory/memory-bridge.js +33 -34
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-crud.d.ts.map +1 -1
- package/dist/src/memory/memory-crud.js +0 -20
- package/dist/src/memory/memory-crud.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +2 -3
- package/dist/src/memory/memory-initializer.d.ts.map +1 -1
- package/dist/src/memory/memory-initializer.js +2 -3
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/memory-read.d.ts.map +1 -1
- package/dist/src/memory/memory-read.js +5 -14
- package/dist/src/memory/memory-read.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts +1 -1
- package/dist/src/memory/sona-optimizer.js +1 -1
- package/dist/src/monovector/model-outcomes.d.ts +25 -0
- package/dist/src/monovector/model-outcomes.d.ts.map +1 -0
- package/dist/src/monovector/model-outcomes.js +113 -0
- package/dist/src/monovector/model-outcomes.js.map +1 -0
- package/dist/src/orgrt/agent-runner.d.ts +8 -2
- package/dist/src/orgrt/agent-runner.d.ts.map +1 -1
- package/dist/src/orgrt/agent-runner.js.map +1 -1
- package/dist/src/orgrt/antigravity-runner.d.ts +25 -2
- package/dist/src/orgrt/antigravity-runner.d.ts.map +1 -1
- package/dist/src/orgrt/antigravity-runner.js +265 -124
- package/dist/src/orgrt/antigravity-runner.js.map +1 -1
- package/dist/src/orgrt/approvals.d.ts +16 -1
- package/dist/src/orgrt/approvals.d.ts.map +1 -1
- package/dist/src/orgrt/approvals.js +47 -2
- package/dist/src/orgrt/approvals.js.map +1 -1
- package/dist/src/orgrt/checkpoint-ops.d.ts +10 -16
- package/dist/src/orgrt/checkpoint-ops.d.ts.map +1 -1
- package/dist/src/orgrt/checkpoint-ops.js +12 -18
- package/dist/src/orgrt/checkpoint-ops.js.map +1 -1
- package/dist/src/orgrt/checkpoint.d.ts +12 -1
- package/dist/src/orgrt/checkpoint.d.ts.map +1 -1
- package/dist/src/orgrt/checkpoint.js +19 -3
- package/dist/src/orgrt/checkpoint.js.map +1 -1
- package/dist/src/orgrt/codex-runner.d.ts +26 -2
- package/dist/src/orgrt/codex-runner.d.ts.map +1 -1
- package/dist/src/orgrt/codex-runner.js +359 -128
- package/dist/src/orgrt/codex-runner.js.map +1 -1
- package/dist/src/orgrt/copilot-runner.d.ts +14 -0
- package/dist/src/orgrt/copilot-runner.d.ts.map +1 -0
- package/dist/src/orgrt/copilot-runner.js +260 -0
- package/dist/src/orgrt/copilot-runner.js.map +1 -0
- package/dist/src/orgrt/cross-org.d.ts.map +1 -1
- package/dist/src/orgrt/cross-org.js +11 -0
- package/dist/src/orgrt/cross-org.js.map +1 -1
- package/dist/src/orgrt/crush-runner.d.ts +27 -0
- package/dist/src/orgrt/crush-runner.d.ts.map +1 -0
- package/dist/src/orgrt/crush-runner.js +263 -0
- package/dist/src/orgrt/crush-runner.js.map +1 -0
- package/dist/src/orgrt/daemon.d.ts +68 -16
- package/dist/src/orgrt/daemon.d.ts.map +1 -1
- package/dist/src/orgrt/daemon.js +212 -29
- package/dist/src/orgrt/daemon.js.map +1 -1
- package/dist/src/orgrt/decisions.d.ts +1 -0
- package/dist/src/orgrt/decisions.d.ts.map +1 -1
- package/dist/src/orgrt/decisions.js +20 -0
- package/dist/src/orgrt/decisions.js.map +1 -1
- package/dist/src/orgrt/grok-runner.d.ts +18 -0
- package/dist/src/orgrt/grok-runner.d.ts.map +1 -0
- package/dist/src/orgrt/grok-runner.js +348 -0
- package/dist/src/orgrt/grok-runner.js.map +1 -0
- package/dist/src/orgrt/kimicode-runner.d.ts +53 -7
- package/dist/src/orgrt/kimicode-runner.d.ts.map +1 -1
- package/dist/src/orgrt/kimicode-runner.js +246 -144
- package/dist/src/orgrt/kimicode-runner.js.map +1 -1
- package/dist/src/orgrt/mailbox.d.ts +26 -1
- package/dist/src/orgrt/mailbox.d.ts.map +1 -1
- package/dist/src/orgrt/mailbox.js +74 -2
- package/dist/src/orgrt/mailbox.js.map +1 -1
- package/dist/src/orgrt/pi-rpc-runner.d.ts +68 -0
- package/dist/src/orgrt/pi-rpc-runner.d.ts.map +1 -0
- package/dist/src/orgrt/pi-rpc-runner.js +385 -0
- package/dist/src/orgrt/pi-rpc-runner.js.map +1 -0
- package/dist/src/orgrt/pi-runner.d.ts +16 -0
- package/dist/src/orgrt/pi-runner.d.ts.map +1 -0
- package/dist/src/orgrt/pi-runner.js +264 -0
- package/dist/src/orgrt/pi-runner.js.map +1 -0
- package/dist/src/orgrt/policy.d.ts +11 -0
- package/dist/src/orgrt/policy.d.ts.map +1 -1
- package/dist/src/orgrt/policy.js +25 -2
- package/dist/src/orgrt/policy.js.map +1 -1
- package/dist/src/orgrt/provider.d.ts +29 -1
- package/dist/src/orgrt/provider.d.ts.map +1 -1
- package/dist/src/orgrt/provider.js +62 -2
- package/dist/src/orgrt/provider.js.map +1 -1
- package/dist/src/orgrt/qwen-rpc-runner.d.ts +56 -0
- package/dist/src/orgrt/qwen-rpc-runner.d.ts.map +1 -0
- package/dist/src/orgrt/qwen-rpc-runner.js +346 -0
- package/dist/src/orgrt/qwen-rpc-runner.js.map +1 -0
- package/dist/src/orgrt/qwen-runner.d.ts +18 -0
- package/dist/src/orgrt/qwen-runner.d.ts.map +1 -0
- package/dist/src/orgrt/qwen-runner.js +270 -0
- package/dist/src/orgrt/qwen-runner.js.map +1 -0
- package/dist/src/orgrt/scheduler-integration.d.ts.map +1 -1
- package/dist/src/orgrt/scheduler-integration.js +7 -0
- package/dist/src/orgrt/scheduler-integration.js.map +1 -1
- package/dist/src/orgrt/session.d.ts +29 -1
- package/dist/src/orgrt/session.d.ts.map +1 -1
- package/dist/src/orgrt/session.js +87 -18
- package/dist/src/orgrt/session.js.map +1 -1
- package/dist/src/orgrt/task-dag.d.ts +29 -1
- package/dist/src/orgrt/task-dag.d.ts.map +1 -1
- package/dist/src/orgrt/task-dag.js +54 -0
- package/dist/src/orgrt/task-dag.js.map +1 -1
- package/dist/src/orgrt/test-loop.d.ts.map +1 -1
- package/dist/src/orgrt/test-loop.js +86 -9
- package/dist/src/orgrt/test-loop.js.map +1 -1
- package/dist/src/orgrt/tool-fence.d.ts.map +1 -1
- package/dist/src/orgrt/tool-fence.js +15 -0
- package/dist/src/orgrt/tool-fence.js.map +1 -1
- package/dist/src/orgrt/types.d.ts +50 -1
- package/dist/src/orgrt/types.d.ts.map +1 -1
- package/dist/src/orgrt/types.js +47 -4
- package/dist/src/orgrt/types.js.map +1 -1
- package/dist/src/orgrt/usage-proxy.d.ts +32 -0
- package/dist/src/orgrt/usage-proxy.d.ts.map +1 -0
- package/dist/src/orgrt/usage-proxy.js +226 -0
- package/dist/src/orgrt/usage-proxy.js.map +1 -0
- package/dist/src/pricing/model-pricing.d.ts.map +1 -1
- package/dist/src/pricing/model-pricing.js +0 -4
- package/dist/src/pricing/model-pricing.js.map +1 -1
- package/dist/src/security/audit-log.d.ts +47 -0
- package/dist/src/security/audit-log.d.ts.map +1 -0
- package/dist/src/security/audit-log.js +84 -0
- package/dist/src/security/audit-log.js.map +1 -0
- package/dist/src/services/config-file-manager.d.ts +2 -2
- package/dist/src/services/config-file-manager.d.ts.map +1 -1
- package/dist/src/services/config-file-manager.js +6 -7
- package/dist/src/services/config-file-manager.js.map +1 -1
- package/dist/src/suggest.d.ts.map +1 -1
- package/dist/src/suggest.js +4 -5
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/anonymization/index.d.ts +1 -1
- package/dist/src/transfer/anonymization/index.js +1 -1
- package/dist/src/types.d.ts +3 -3
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/ui/collector.mjs +9 -13
- package/dist/src/ui/dashboard.html +93 -10
- package/dist/src/ui/data/agent-avatars.html +0 -12
- package/dist/src/ui/data/agent-avatars.json +10 -26
- package/dist/src/ui/orgs.html +8 -1
- package/dist/src/ui/routes-org.mjs +85 -16
- package/dist/src/ui/server.mjs +50 -23
- package/dist/src/utils/json-file.d.ts +12 -0
- package/dist/src/utils/json-file.d.ts.map +1 -1
- package/dist/src/utils/json-file.js +11 -0
- package/dist/src/utils/json-file.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/.claude/agents/consensus/crdt-synchronizer.md +0 -977
- package/.claude/commands/hive-mind/README.md +0 -42
- package/.claude/commands/hive-mind/hive-mind-consensus.md +0 -72
- package/.claude/commands/hive-mind/hive-mind-init.md +0 -68
- package/.claude/commands/hive-mind/hive-mind-memory.md +0 -73
- package/.claude/commands/hive-mind/hive-mind-spawn.md +0 -82
- package/.claude/commands/hive-mind/hive-mind-status.md +0 -56
- package/.claude/commands/hive-mind/hive-mind-stop.md +0 -55
- package/.claude/commands/hive-mind/hive-mind.md +0 -87
- package/.claude/commands/swarm/README.md +0 -40
- package/.claude/commands/swarm/swarm.md +0 -79
- package/.claude/skills/hive-mind-advanced/SKILL.md +0 -347
- package/.claude/skills/swarm-advanced/SKILL.md +0 -936
- package/dist/src/commands/swarm.d.ts +0 -8
- package/dist/src/commands/swarm.d.ts.map +0 -1
- package/dist/src/commands/swarm.js.map +0 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts +0 -17
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +0 -1239
- package/dist/src/mcp-tools/hive-mind-tools.js.map +0 -1
- package/dist/src/mcp-tools/swarm-tools.d.ts +0 -9
- package/dist/src/mcp-tools/swarm-tools.d.ts.map +0 -1
- package/dist/src/mcp-tools/swarm-tools.js +0 -411
- package/dist/src/mcp-tools/swarm-tools.js.map +0 -1
- package/dist/src/ui/data/avatars/crdt-synchronizer.svg +0 -53
- package/dist/src/ui/data/avatars/gossip-coordinator.svg +0 -54
- package/scripts/deploy-ipfs-node.sh +0 -153
- package/scripts/setup-ipfs-registry.md +0 -365
- /package/.claude/agents/{hive-mind → monoswarm}/scout-explorer.md +0 -0
- /package/.claude/agents/{hive-mind → monoswarm}/worker-specialist.md +0 -0
- /package/.claude/commands/{swarm → monoswarm}/analysis.md +0 -0
- /package/.claude/commands/{swarm → monoswarm}/development.md +0 -0
- /package/.claude/commands/{swarm → monoswarm}/examples.md +0 -0
- /package/.claude/commands/{swarm → monoswarm}/maintenance.md +0 -0
- /package/.claude/commands/{swarm → monoswarm}/optimization.md +0 -0
- /package/.claude/commands/{swarm → monoswarm}/testing.md +0 -0
- /package/dist/src/ui/data/avatars/{code-review-swarm.svg → monoswarm-code-review.svg} +0 -0
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/** close() reasons that mean "paused, not dead" — the underlying condition
|
|
2
|
+
* (a budget cap) can be raised by an operator, unlike a crash/terminal
|
|
3
|
+
* close. Checked before re-closing a checkpointed mailbox on resume: a
|
|
4
|
+
* mailbox checkpointed with one of these reasons is left open instead of
|
|
5
|
+
* being re-closed, or the idle watchdog's "raise the budget and resume
|
|
6
|
+
* from checkpoint" remedy would silently do nothing — nothing in this
|
|
7
|
+
* codebase ever reopens a closed mailbox otherwise. The only production
|
|
8
|
+
* resume path is daemon.ts's inline spawnRole logic (where `new Mailbox()`
|
|
9
|
+
* is constructed for a role with a roleCheckpoint); checkpoint.ts's
|
|
10
|
+
* mergeCheckpoint() applies the same check but isn't currently called
|
|
11
|
+
* outside tests — keep both in sync if either changes. */
|
|
12
|
+
const BUDGET_CLOSE_REASONS = new Set(['token-budget', 'usd-budget']);
|
|
13
|
+
export function isRecoverableCloseReason(reason) {
|
|
14
|
+
return reason !== undefined && BUDGET_CLOSE_REASONS.has(reason);
|
|
15
|
+
}
|
|
1
16
|
/**
|
|
2
17
|
* Async message queue feeding one persistent SDK session.
|
|
3
18
|
* push() from the daemon (deliveries from other agents / the user);
|
|
@@ -12,11 +27,21 @@ export class Mailbox {
|
|
|
12
27
|
queue = [];
|
|
13
28
|
wake = null;
|
|
14
29
|
closed = false;
|
|
30
|
+
/** Why close() was called — e.g. 'token-budget' / 'usd-budget' — distinct
|
|
31
|
+
* from a crash/terminal close (undefined). Lets callers like the idle
|
|
32
|
+
* watchdog tell a recoverable budget pause from genuine unreachability. */
|
|
33
|
+
closeReasonValue;
|
|
15
34
|
/** Bumped when a new stream() starts; stale generators see the mismatch and exit. */
|
|
16
35
|
generation = 0;
|
|
17
36
|
/** Monotonic count of REAL (non-continuation) messages consumed by stream().
|
|
18
37
|
* The restart loop snapshots this around a session to tell progress from spin. */
|
|
19
38
|
consumedReal = 0;
|
|
39
|
+
/** The most recently shift()ed-but-not-yet-confirmed-processed message: set
|
|
40
|
+
* right before stream() yields it, cleared once the generator is resumed
|
|
41
|
+
* for the next pull (proof the runner asked for more, i.e. the prior turn
|
|
42
|
+
* finished). If a session dies with this still set, the generator was
|
|
43
|
+
* abandoned mid-yield — see reclaimInFlight(). */
|
|
44
|
+
inFlight = null;
|
|
20
45
|
/** Number of real (non-continuation) messages consumed so far across all sessions. */
|
|
21
46
|
get consumedRealCount() { return this.consumedReal; }
|
|
22
47
|
push(text) {
|
|
@@ -29,12 +54,26 @@ export class Mailbox {
|
|
|
29
54
|
this.wake?.();
|
|
30
55
|
this.wake = null;
|
|
31
56
|
}
|
|
32
|
-
close() {
|
|
57
|
+
close(reason) {
|
|
58
|
+
// First write wins. session.ts's result-message handler can call
|
|
59
|
+
// close() up to three times for one message (circuit-breaker trip,
|
|
60
|
+
// token-budget, USD-budget are independent sibling `if`s, not
|
|
61
|
+
// mutually exclusive) — without this guard the LAST call's reason
|
|
62
|
+
// silently overwrites the first, so a genuinely terminal
|
|
63
|
+
// circuit-breaker close could get misclassified as a recoverable
|
|
64
|
+
// budget close and the resume path would reopen a role that's
|
|
65
|
+
// supposed to require manual intervention.
|
|
66
|
+
if (this.closed)
|
|
67
|
+
return;
|
|
33
68
|
this.closed = true;
|
|
69
|
+
this.closeReasonValue = reason;
|
|
34
70
|
this.wake?.();
|
|
35
71
|
this.wake = null;
|
|
36
72
|
}
|
|
37
73
|
get isClosed() { return this.closed; }
|
|
74
|
+
/** Why close() was called, if given a reason — undefined for a plain crash/
|
|
75
|
+
* terminal close. See the closeReasonValue field doc for intent. */
|
|
76
|
+
get closeReason() { return this.closeReasonValue; }
|
|
38
77
|
/**
|
|
39
78
|
* Detach the current waker WITHOUT resolving it. Called between sessions
|
|
40
79
|
* (maxTurns restart, crash backoff): the dead session's generator may still
|
|
@@ -60,6 +99,10 @@ export class Mailbox {
|
|
|
60
99
|
const gen = ++this.generation;
|
|
61
100
|
// Drop (never resolve) any stale waker — see detach().
|
|
62
101
|
this.wake = null;
|
|
102
|
+
// A fresh generator starts with nothing in flight — any prior value
|
|
103
|
+
// belonged to a now-dead generator and reclaimInFlight() (called from the
|
|
104
|
+
// crash-retry path, if at all) already had its chance to act on it.
|
|
105
|
+
this.inFlight = null;
|
|
63
106
|
while (true) {
|
|
64
107
|
while (this.queue.length > 0) {
|
|
65
108
|
if (gen !== this.generation)
|
|
@@ -67,6 +110,7 @@ export class Mailbox {
|
|
|
67
110
|
const content = this.queue.shift();
|
|
68
111
|
if (!content.startsWith(Mailbox.CONTINUE_PREFIX))
|
|
69
112
|
this.consumedReal++;
|
|
113
|
+
this.inFlight = content;
|
|
70
114
|
yield {
|
|
71
115
|
type: 'user',
|
|
72
116
|
message: { role: 'user', content },
|
|
@@ -75,6 +119,10 @@ export class Mailbox {
|
|
|
75
119
|
};
|
|
76
120
|
if (gen !== this.generation)
|
|
77
121
|
return;
|
|
122
|
+
// Resumed for another pull: the consumer asked for the next message,
|
|
123
|
+
// which only happens once it's done with this one — proof the prior
|
|
124
|
+
// turn completed rather than the session dying mid-processing.
|
|
125
|
+
this.inFlight = null;
|
|
78
126
|
}
|
|
79
127
|
if (this.closed || gen !== this.generation)
|
|
80
128
|
return;
|
|
@@ -83,12 +131,33 @@ export class Mailbox {
|
|
|
83
131
|
return;
|
|
84
132
|
}
|
|
85
133
|
}
|
|
134
|
+
/** Called by the crash-retry path right after a session dies abnormally. If
|
|
135
|
+
* a message was mid-flight — shifted for the crashed generator's yield but
|
|
136
|
+
* never confirmed processed, because the generator was abandoned at that
|
|
137
|
+
* yield rather than resumed for another pull — put it back at the front of
|
|
138
|
+
* the queue so the replacement session (built by the next stream() call)
|
|
139
|
+
* gets it first instead of the queue staying empty and the new session
|
|
140
|
+
* parking on the mailbox forever. A no-op when nothing was in flight
|
|
141
|
+
* (clean session end, or nothing was ever pulled). */
|
|
142
|
+
reclaimInFlight() {
|
|
143
|
+
if (this.inFlight === null)
|
|
144
|
+
return;
|
|
145
|
+
const content = this.inFlight;
|
|
146
|
+
this.inFlight = null;
|
|
147
|
+
this.queue.unshift(content);
|
|
148
|
+
// Undo the increment made when this message was shifted — it was never
|
|
149
|
+
// actually processed, so the restart loop's progress/spin detection
|
|
150
|
+
// should not count it as consumed.
|
|
151
|
+
if (!content.startsWith(Mailbox.CONTINUE_PREFIX))
|
|
152
|
+
this.consumedReal--;
|
|
153
|
+
}
|
|
86
154
|
/** Serialize mailbox state for checkpoint/resume - Pattern 3 */
|
|
87
155
|
serialize() {
|
|
88
156
|
return {
|
|
89
157
|
queue: [...this.queue], // Copy array - queue is public for checkpoint access
|
|
90
158
|
closed: this.closed,
|
|
91
159
|
consumedReal: this.consumedReal,
|
|
160
|
+
...(this.closeReasonValue ? { closeReason: this.closeReasonValue } : {}),
|
|
92
161
|
};
|
|
93
162
|
}
|
|
94
163
|
/** Deserialize mailbox state from checkpoint - Pattern 3 */
|
|
@@ -96,9 +165,12 @@ export class Mailbox {
|
|
|
96
165
|
this.queue = [...state.queue]; // Restore queue content
|
|
97
166
|
this.closed = state.closed;
|
|
98
167
|
this.consumedReal = state.consumedReal;
|
|
99
|
-
|
|
168
|
+
this.closeReasonValue = state.closeReason; // undefined for checkpoints predating this field
|
|
169
|
+
// Reset generation, wake, and in-flight tracking - a new stream() call
|
|
170
|
+
// will set fresh values; nothing from a checkpointed run is "in flight".
|
|
100
171
|
this.generation = 0;
|
|
101
172
|
this.wake = null;
|
|
173
|
+
this.inFlight = null;
|
|
102
174
|
}
|
|
103
175
|
}
|
|
104
176
|
//# sourceMappingURL=mailbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailbox.js","sourceRoot":"","sources":["../../../src/orgrt/mailbox.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,MAAM,OAAO,OAAO;IACV,MAAM,CAAU,SAAS,GAAG,GAAG,CAAC;IACxC;;6EAEyE;IACzE,MAAM,CAAU,eAAe,GAAG,wBAAwB,CAAC;IACnD,KAAK,GAAa,EAAE,CAAC;IACrB,IAAI,GAAwB,IAAI,CAAC;IACjC,MAAM,GAAG,KAAK,CAAC;IACvB,qFAAqF;IAC7E,UAAU,GAAG,CAAC,CAAC;IACvB;uFACmF;IAC3E,YAAY,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"mailbox.js","sourceRoot":"","sources":["../../../src/orgrt/mailbox.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;2DAU2D;AAC3D,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;AACrE,MAAM,UAAU,wBAAwB,CAAC,MAA0B;IACjE,OAAO,MAAM,KAAK,SAAS,IAAI,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAClE,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,OAAO;IACV,MAAM,CAAU,SAAS,GAAG,GA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uEAAuE;QACvE,yEAAyE;QACzE,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AgentRunner, AgentRunArgs, AgentMessage } from './agent-runner.js';
|
|
2
|
+
interface PiContentBlock {
|
|
3
|
+
type: string;
|
|
4
|
+
text?: string;
|
|
5
|
+
thinking?: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
arguments?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
interface PiRpcMessage {
|
|
11
|
+
content?: PiContentBlock[];
|
|
12
|
+
}
|
|
13
|
+
/** Pure, transport-independent JSONL line decoder — feed it raw string
|
|
14
|
+
* chunks, get back every complete parsed object found so far (silently
|
|
15
|
+
* skipping malformed lines rather than throwing, matching this repo's
|
|
16
|
+
* other subprocess parsers). Exported for unit testing without a real
|
|
17
|
+
* subprocess. */
|
|
18
|
+
export declare class JsonlDecoder {
|
|
19
|
+
private buf;
|
|
20
|
+
feed(chunk: string): Record<string, unknown>[];
|
|
21
|
+
}
|
|
22
|
+
/** Encode a client→server RPC command as one LF-terminated JSON line.
|
|
23
|
+
* Exported for unit testing the exact wire format. */
|
|
24
|
+
export declare function encodePiRpcCommand(cmd: {
|
|
25
|
+
type: string;
|
|
26
|
+
message?: string;
|
|
27
|
+
id?: string;
|
|
28
|
+
}): string;
|
|
29
|
+
/** Extract assistant-visible text and org tool_call fences from a
|
|
30
|
+
* message_end event's `message.content` array. `thinking` blocks are
|
|
31
|
+
* dropped (internal reasoning, not meant for the bus); `toolCall` blocks
|
|
32
|
+
* are pi's own native tool calls, executed autonomously by pi itself —
|
|
33
|
+
* this runner never sees their results and doesn't need to. Exported for
|
|
34
|
+
* unit testing against fixture content arrays. */
|
|
35
|
+
export declare function extractPiRpcText(message: PiRpcMessage): string;
|
|
36
|
+
/** The subset of a spawned child process this runner needs — narrower than
|
|
37
|
+
* node:child_process's real type, and deliberately duck-typed so tests can
|
|
38
|
+
* supply a fake implementation (an EventEmitter-backed fake process) to
|
|
39
|
+
* exercise the full turn-completion state machine without a real `pi`
|
|
40
|
+
* binary. Given the residual protocol-inference risk documented in this
|
|
41
|
+
* file's header, testing the orchestration logic itself — not just the
|
|
42
|
+
* pure JSONL/extraction helpers — is the point of this seam. */
|
|
43
|
+
export interface PiRpcProcess {
|
|
44
|
+
stdin: {
|
|
45
|
+
write(data: string): void;
|
|
46
|
+
} | null;
|
|
47
|
+
stdout: {
|
|
48
|
+
on(event: 'data', cb: (chunk: Buffer) => void): void;
|
|
49
|
+
} | null;
|
|
50
|
+
stderr: {
|
|
51
|
+
on(event: 'data', cb: (chunk: Buffer) => void): void;
|
|
52
|
+
} | null;
|
|
53
|
+
on(event: 'close', cb: (code: number | null) => void): void;
|
|
54
|
+
on(event: 'error', cb: (err: Error) => void): void;
|
|
55
|
+
kill(signal?: string): void;
|
|
56
|
+
}
|
|
57
|
+
export type SpawnPiRpc = (bin: string, args: string[], opts: {
|
|
58
|
+
cwd: string;
|
|
59
|
+
env: Record<string, string | undefined>;
|
|
60
|
+
}) => PiRpcProcess;
|
|
61
|
+
export declare class PiRpcAgentRunner implements AgentRunner {
|
|
62
|
+
private piBin?;
|
|
63
|
+
private spawnFn;
|
|
64
|
+
constructor(piBin?: string | undefined, spawnFn?: SpawnPiRpc);
|
|
65
|
+
run(args: AgentRunArgs): AsyncIterable<AgentMessage>;
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=pi-rpc-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-rpc-runner.d.ts","sourceRoot":"","sources":["../../../src/orgrt/pi-rpc-runner.ts"],"names":[],"mappings":"AAkEA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,E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IACxE,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,CAAC;IAC5D,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CAAE,KAAK,YAAY,CAAC;AAKvI,qBAAa,gBAAiB,YAAW,WAAW;IACtC,OAAO,CAAC,KAAK,CAAC;IAAU,OAAO,CAAC,OAAO;IAAnD,YAAoB,KAAK,CAAC,EAAE,MAAM,YAAA,EAAU,OAAO,GAAE,UAA8B,EAAI;IAEhF,GAAG,CAAC,IAAI,EAAE,YAAY,GAAG,aAAa,CAAC,YAAY,CAAC,CAgQ1D;CACF"}
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
// packages/@monomind/cli/src/orgrt/pi-rpc-runner.ts
|
|
2
|
+
/**
|
|
3
|
+
* PiRpcAgentRunner — AgentRunner impl backed by the Pi coding agent CLI's
|
|
4
|
+
* `--mode rpc` (session-lifetime, bidirectional JSON-over-stdio), instead of
|
|
5
|
+
* the default PiAgentRunner (pi-runner.ts), which spawns a fresh `pi --mode
|
|
6
|
+
* json` process per mailbox turn.
|
|
7
|
+
*
|
|
8
|
+
* OPT-IN, not the default. Select via role/org `runtime: 'pi-rpc'`. Prefer
|
|
9
|
+
* plain `runtime: 'pi'` (PiAgentRunner) unless you specifically want the
|
|
10
|
+
* benefit this buys: the subprocess stays alive for the WHOLE mailbox
|
|
11
|
+
* session, so conversational context carries naturally (no --session-dir
|
|
12
|
+
* resume guessing) and there's no per-turn spawn/bootstrap cost.
|
|
13
|
+
*
|
|
14
|
+
* Protocol — JSON objects, one per line (LF-delimited). RESOLVED against a
|
|
15
|
+
* live pi v0.73.1 install (issue #179): pi's docs (docs/rpc.md, bundled with
|
|
16
|
+
* the package) define `agent_end` — "Emitted when the agent completes.
|
|
17
|
+
* Contains all messages generated during this run." — as a distinct event
|
|
18
|
+
* from `message_end`/`turn_end`, and it's exactly the "prompt is fully done"
|
|
19
|
+
* signal this runner needs. Confirmed live with a prompt that made pi run 3
|
|
20
|
+
* of its own native tools in sequence (read → edit → bash): the run produced
|
|
21
|
+
* 4 separate turn_start/turn_end cycles and many message_end events, but
|
|
22
|
+
* EXACTLY ONE agent_end, firing only after the last turn closed. This
|
|
23
|
+
* replaces the old get_state-polling heuristic entirely — no more `isStreaming`
|
|
24
|
+
* ambiguity to worry about.
|
|
25
|
+
*
|
|
26
|
+
* Client → server (this runner sends), each with an optional "id" for
|
|
27
|
+
* response correlation:
|
|
28
|
+
* {"type":"prompt","message":"<text>"} — new/continuing turn
|
|
29
|
+
* {"type":"abort"} — not used by this runner
|
|
30
|
+
*
|
|
31
|
+
* Server → client (only agent_end is acted on; everything else — agent_start,
|
|
32
|
+
* turn_start/turn_end, message_start/message_update/message_end,
|
|
33
|
+
* tool_execution_* — is drained and ignored):
|
|
34
|
+
* {"type":"response","command":"prompt","success":true}
|
|
35
|
+
* {"type":"agent_end","messages":[
|
|
36
|
+
* {"role":"user","content":[{"type":"text","text":"..."}]},
|
|
37
|
+
* {"role":"assistant","content":[
|
|
38
|
+
* {"type":"thinking","thinking":"..."},
|
|
39
|
+
* {"type":"text","text":"..."},
|
|
40
|
+
* {"type":"toolCall","id":"call_1","name":"bash","arguments":{...}}
|
|
41
|
+
* ],"usage":{"input":N,"output":N,"totalTokens":N,"cost":{"total":N}}},
|
|
42
|
+
* {"role":"toolResult","content":[{"type":"text","text":"..."}]},
|
|
43
|
+
* ... (repeats per internal turn — one "assistant" entry per turn,
|
|
44
|
+
* each with ITS OWN per-turn `usage`, not cumulative)
|
|
45
|
+
* ]}
|
|
46
|
+
*
|
|
47
|
+
* Usage accounting: `agent_end.messages` includes one `assistant` entry per
|
|
48
|
+
* internal turn, each carrying that turn's OWN `usage` (confirmed live: a
|
|
49
|
+
* 4-turn run had usage.output of 65/109/13/22 across the 4 assistant
|
|
50
|
+
* entries — small, turn-scoped numbers, not a running cumulative total).
|
|
51
|
+
* This runner sums `usage.input`/`usage.output` across every assistant
|
|
52
|
+
* entry in `agent_end.messages` to get the correct total for the prompt.
|
|
53
|
+
* The PREVIOUS implementation (overwriting from `message_update`'s running
|
|
54
|
+
* total, which only tracks the CURRENT assistant message) silently
|
|
55
|
+
* undercounted any prompt that triggered more than one internal turn —
|
|
56
|
+
* confirmed via the same live test above.
|
|
57
|
+
*
|
|
58
|
+
* Org tools (org_send, knowledge_search, ask_human, …) — FENCE PROTOCOL:
|
|
59
|
+
* Pi's own native tools (bash, file edits) execute autonomously inside pi
|
|
60
|
+
* itself and never reach this runner — only org tools ride the shared
|
|
61
|
+
* tool-fence protocol (tool-fence.ts), extracted from the assistant text
|
|
62
|
+
* in `agent_end.messages` and fed back as a new `prompt` command in the
|
|
63
|
+
* SAME session.
|
|
64
|
+
*/
|
|
65
|
+
import { spawn } from 'node:child_process';
|
|
66
|
+
import { join } from 'node:path';
|
|
67
|
+
import { buildToolProtocol, parseToolCalls, executeToolCall, formatToolResults, MAX_TOOL_ROUNDS, TOOL_CALL_RE } from './tool-fence.js';
|
|
68
|
+
/** Upper bound on how long a single prompt's wait for `agent_end` may run
|
|
69
|
+
* before the mid-session silence watchdog (below) considers pi wedged.
|
|
70
|
+
* Distinct from a hard per-turn deadline — a long-running prompt that's
|
|
71
|
+
* still producing events well within this window is not a hang; only
|
|
72
|
+
* total SILENCE past this bound is. */
|
|
73
|
+
const SETTLE_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes
|
|
74
|
+
const STARTUP_GRACE_MS = 45_000;
|
|
75
|
+
/** Pure, transport-independent JSONL line decoder — feed it raw string
|
|
76
|
+
* chunks, get back every complete parsed object found so far (silently
|
|
77
|
+
* skipping malformed lines rather than throwing, matching this repo's
|
|
78
|
+
* other subprocess parsers). Exported for unit testing without a real
|
|
79
|
+
* subprocess. */
|
|
80
|
+
export class JsonlDecoder {
|
|
81
|
+
buf = '';
|
|
82
|
+
feed(chunk) {
|
|
83
|
+
this.buf += chunk;
|
|
84
|
+
const parts = this.buf.split('\n');
|
|
85
|
+
this.buf = parts.pop() ?? '';
|
|
86
|
+
const out = [];
|
|
87
|
+
for (const line of parts) {
|
|
88
|
+
const trimmed = line.trim();
|
|
89
|
+
if (!trimmed)
|
|
90
|
+
continue;
|
|
91
|
+
try {
|
|
92
|
+
out.push(JSON.parse(trimmed));
|
|
93
|
+
}
|
|
94
|
+
catch { /* skip malformed line */ }
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Encode a client→server RPC command as one LF-terminated JSON line.
|
|
100
|
+
* Exported for unit testing the exact wire format. */
|
|
101
|
+
export function encodePiRpcCommand(cmd) {
|
|
102
|
+
return JSON.stringify(cmd) + '\n';
|
|
103
|
+
}
|
|
104
|
+
/** Extract assistant-visible text and org tool_call fences from a
|
|
105
|
+
* message_end event's `message.content` array. `thinking` blocks are
|
|
106
|
+
* dropped (internal reasoning, not meant for the bus); `toolCall` blocks
|
|
107
|
+
* are pi's own native tool calls, executed autonomously by pi itself —
|
|
108
|
+
* this runner never sees their results and doesn't need to. Exported for
|
|
109
|
+
* unit testing against fixture content arrays. */
|
|
110
|
+
export function extractPiRpcText(message) {
|
|
111
|
+
return (message.content ?? [])
|
|
112
|
+
.filter((b) => b.type === 'text' && typeof b.text === 'string')
|
|
113
|
+
.map((b) => b.text)
|
|
114
|
+
.join('\n');
|
|
115
|
+
}
|
|
116
|
+
const defaultSpawnPiRpc = (bin, args, opts) => spawn(bin, args, { cwd: opts.cwd, env: opts.env, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
117
|
+
export class PiRpcAgentRunner {
|
|
118
|
+
piBin;
|
|
119
|
+
spawnFn;
|
|
120
|
+
constructor(piBin, spawnFn = defaultSpawnPiRpc) {
|
|
121
|
+
this.piBin = piBin;
|
|
122
|
+
this.spawnFn = spawnFn;
|
|
123
|
+
}
|
|
124
|
+
async *run(args) {
|
|
125
|
+
const bin = this.piBin || process.env.PI_CLI_BIN || 'pi';
|
|
126
|
+
const sessionDir = join(args.cwd, '.monomind-pi-session');
|
|
127
|
+
// No --approve: confirmed against a live v0.73.1 install that pi rejects
|
|
128
|
+
// it outright ("Unknown option: --approve") — no such flag exists.
|
|
129
|
+
// Confirmed unnecessary too: built-in tools (read/edit/bash) execute
|
|
130
|
+
// autonomously in --mode rpc with zero confirmation gating (a live
|
|
131
|
+
// multi-tool prompt — read, edit, bash — ran end-to-end with no prompt
|
|
132
|
+
// or block). See #179.
|
|
133
|
+
const cliArgs = ['--mode', 'rpc', '--session-dir', sessionDir];
|
|
134
|
+
if (args.model)
|
|
135
|
+
cliArgs.push('--model', args.model);
|
|
136
|
+
const child = this.spawnFn(bin, cliArgs, {
|
|
137
|
+
cwd: args.cwd,
|
|
138
|
+
env: { ...process.env, PI_TELEMETRY: '0', PI_SKIP_VERSION_CHECK: '1', ...args.env },
|
|
139
|
+
});
|
|
140
|
+
let stderrTail = '';
|
|
141
|
+
child.stderr?.on('data', (c) => { stderrTail = (stderrTail + c.toString()).slice(-4000); });
|
|
142
|
+
const decoder = new JsonlDecoder();
|
|
143
|
+
const eventQueue = [];
|
|
144
|
+
const waiters = [];
|
|
145
|
+
let closed = false;
|
|
146
|
+
let closeCode = null;
|
|
147
|
+
// Bumped only by REAL stdout activity (not the synthetic __closed__/
|
|
148
|
+
// __error__/__hang__ events pushed below) — see silenceWatchdog further
|
|
149
|
+
// down, which uses this to detect a mid-session hang.
|
|
150
|
+
let lastEventAt = Date.now();
|
|
151
|
+
const pushEvents = (evs) => {
|
|
152
|
+
for (const ev of evs) {
|
|
153
|
+
const waiter = waiters.shift();
|
|
154
|
+
if (waiter)
|
|
155
|
+
waiter(ev);
|
|
156
|
+
else
|
|
157
|
+
eventQueue.push(ev);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
child.stdout?.on('data', (c) => { lastEventAt = Date.now(); pushEvents(decoder.feed(c.toString())); });
|
|
161
|
+
// Distinct from `closed` (which WE set to stop routing new commands, e.g.
|
|
162
|
+
// as soon as a hang is suspected) — this is only true once the OS
|
|
163
|
+
// confirms the process actually exited. The finally block below uses it
|
|
164
|
+
// to decide whether a pending SIGKILL escalation is still needed.
|
|
165
|
+
let processExited = false;
|
|
166
|
+
child.on('close', (code) => { closed = true; processExited = true; closeCode = code; pushEvents([{ type: '__closed__', code }]); });
|
|
167
|
+
child.on('error', (err) => { closed = true; pushEvents([{ type: '__error__', error: err }]); });
|
|
168
|
+
const nextEvent = () => {
|
|
169
|
+
const queued = eventQueue.shift();
|
|
170
|
+
if (queued)
|
|
171
|
+
return Promise.resolve(queued);
|
|
172
|
+
if (closed)
|
|
173
|
+
return Promise.resolve({ type: '__closed__', code: closeCode });
|
|
174
|
+
return new Promise((resolve) => waiters.push(resolve));
|
|
175
|
+
};
|
|
176
|
+
const send = (cmd) => {
|
|
177
|
+
child.stdin?.write(encodePiRpcCommand(cmd));
|
|
178
|
+
};
|
|
179
|
+
// SIGTERM→SIGKILL escalation, matching the other subprocess runners'
|
|
180
|
+
// pattern — a hang detection that only ever sends SIGTERM would leave a
|
|
181
|
+
// zombie process behind if pi ignores it.
|
|
182
|
+
const KILL_GRACE_MS = 5000;
|
|
183
|
+
let killTimer;
|
|
184
|
+
const killChild = () => {
|
|
185
|
+
try {
|
|
186
|
+
child.kill('SIGTERM');
|
|
187
|
+
}
|
|
188
|
+
catch { /* already gone */ }
|
|
189
|
+
killTimer = setTimeout(() => { try {
|
|
190
|
+
child.kill('SIGKILL');
|
|
191
|
+
}
|
|
192
|
+
catch { /* already gone */ } }, KILL_GRACE_MS);
|
|
193
|
+
killTimer.unref?.();
|
|
194
|
+
};
|
|
195
|
+
// Startup-hang detection — same rationale as the other subprocess
|
|
196
|
+
// runners' STARTUP_GRACE_MS, applied once at process start rather than
|
|
197
|
+
// per turn since the process is long-lived here.
|
|
198
|
+
let sawAnyEvent = false;
|
|
199
|
+
let hangTimer = setTimeout(() => {
|
|
200
|
+
if (!sawAnyEvent) {
|
|
201
|
+
closed = true;
|
|
202
|
+
killChild();
|
|
203
|
+
pushEvents([{ type: '__hang__' }]);
|
|
204
|
+
}
|
|
205
|
+
}, STARTUP_GRACE_MS);
|
|
206
|
+
const disarmHang = () => { if (!sawAnyEvent) {
|
|
207
|
+
sawAnyEvent = true;
|
|
208
|
+
if (hangTimer) {
|
|
209
|
+
clearTimeout(hangTimer);
|
|
210
|
+
hangTimer = undefined;
|
|
211
|
+
}
|
|
212
|
+
} };
|
|
213
|
+
// Rolling watchdog — catches a hang AFTER the startup check has already
|
|
214
|
+
// passed (e.g. pi wedges mid-session on turn 5), which the one-shot
|
|
215
|
+
// startup timer above can't see since it disarms itself on the first
|
|
216
|
+
// event. Checked periodically rather than a single per-turn timer,
|
|
217
|
+
// since a turn's own wait can legitimately take a long time (real model
|
|
218
|
+
// latency) — what matters is total SILENCE from the process, not how
|
|
219
|
+
// long any one turn takes.
|
|
220
|
+
//
|
|
221
|
+
// PAUSED (not just clock-bumped) whenever this runner isn't actually
|
|
222
|
+
// waiting on pi — either an org tool call is in flight (executeToolCall
|
|
223
|
+
// can run ask_human, which waits on a real person and can legitimately
|
|
224
|
+
// take far longer than MID_SESSION_SILENCE_MS), or there's no turn in
|
|
225
|
+
// flight at all: `for await (const p of args.prompt)` blocks on the
|
|
226
|
+
// ROLE'S OWN MAILBOX (session.ts), which idles for as long as the role
|
|
227
|
+
// has nothing new to do — completely normal, and NOT "pi is wedged".
|
|
228
|
+
// A pure "bump lastEventAt" approach would still let the watchdog fire
|
|
229
|
+
// mid-wait for anything slower than the silence window itself; pausing
|
|
230
|
+
// the check entirely for the duration is the correct fix in both cases.
|
|
231
|
+
let toolCallInFlight = false;
|
|
232
|
+
let turnInFlight = false;
|
|
233
|
+
const MID_SESSION_SILENCE_MS = SETTLE_TIMEOUT_MS; // reuse the same bound as the ceiling for total event silence
|
|
234
|
+
const silenceWatchdog = setInterval(() => {
|
|
235
|
+
if (closed || toolCallInFlight || !turnInFlight)
|
|
236
|
+
return;
|
|
237
|
+
if (Date.now() - lastEventAt > MID_SESSION_SILENCE_MS) {
|
|
238
|
+
closed = true;
|
|
239
|
+
killChild();
|
|
240
|
+
pushEvents([{ type: '__hang__' }]);
|
|
241
|
+
}
|
|
242
|
+
}, 30_000);
|
|
243
|
+
silenceWatchdog.unref?.();
|
|
244
|
+
try {
|
|
245
|
+
let first = true;
|
|
246
|
+
for await (const p of args.prompt) {
|
|
247
|
+
const text = typeof p === 'string' ? p : (p?.message?.content ?? String(p ?? ''));
|
|
248
|
+
let nextMessage = first ? `${args.systemPrompt}${buildToolProtocol(args.tools)}\n\n---\n\n${text}` : text;
|
|
249
|
+
first = false;
|
|
250
|
+
let turnInputTokens = 0;
|
|
251
|
+
let turnOutputTokens = 0;
|
|
252
|
+
let round = 0;
|
|
253
|
+
// The silence watchdog only applies from here to the end of this
|
|
254
|
+
// turn's work — see its declaration above. Always cleared in
|
|
255
|
+
// `finally` so a thrown error (which exits the loop) can't leave it
|
|
256
|
+
// stuck true and permanently disable the watchdog for the rest of
|
|
257
|
+
// the session.
|
|
258
|
+
turnInFlight = true;
|
|
259
|
+
try {
|
|
260
|
+
turnLoop: for (;;) {
|
|
261
|
+
send({ type: 'prompt', message: nextMessage });
|
|
262
|
+
let agentEndMessages;
|
|
263
|
+
for (;;) {
|
|
264
|
+
const ev = await nextEvent();
|
|
265
|
+
disarmHang();
|
|
266
|
+
const kind = ev.type;
|
|
267
|
+
if (kind === '__closed__' || kind === '__error__' || kind === '__hang__') {
|
|
268
|
+
if (kind === '__error__') {
|
|
269
|
+
// Rethrow the ORIGINAL spawn error (not a fresh generic one)
|
|
270
|
+
// so the outer catch's `err.code === 'ENOENT'` check below
|
|
271
|
+
// can actually match it — a wrapped/re-created Error loses
|
|
272
|
+
// the .code property, which silently broke the "missing pi
|
|
273
|
+
// binary" install-instructions message.
|
|
274
|
+
throw ev.error;
|
|
275
|
+
}
|
|
276
|
+
const hangSuspected = kind === '__hang__';
|
|
277
|
+
throw new Error(hangSuspected
|
|
278
|
+
? `PiRpcAgentRunner: pi produced no output within ${STARTUP_GRACE_MS / 1000}s and was killed. ` +
|
|
279
|
+
'This usually means it is stuck on a prompt headless mode has no way to answer. Run `pi` ' +
|
|
280
|
+
`once manually in a real terminal in this project to check, then retry.${stderrTail ? `\nstderr: ${stderrTail.slice(-500)}` : ''}`
|
|
281
|
+
: `PiRpcAgentRunner: pi rpc process ended unexpectedly (${kind})` +
|
|
282
|
+
(stderrTail ? `\nstderr: ${stderrTail.slice(-500)}` : ''));
|
|
283
|
+
}
|
|
284
|
+
if (kind === 'agent_end') {
|
|
285
|
+
// See file header: agent_end is pi's own, confirmed-live,
|
|
286
|
+
// single unambiguous "this prompt is fully done" signal —
|
|
287
|
+
// fires exactly once even across multiple internal
|
|
288
|
+
// turn_start/turn_end cycles from pi's own native tool use.
|
|
289
|
+
agentEndMessages = ev.messages;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
// agent_start, turn_start/turn_end, message_start/message_update/
|
|
293
|
+
// message_end, tool_execution_* (pi's own native tools), other
|
|
294
|
+
// response acks — all drained and ignored; agent_end alone
|
|
295
|
+
// carries everything this runner needs (final text + usage).
|
|
296
|
+
}
|
|
297
|
+
if (!agentEndMessages)
|
|
298
|
+
break turnLoop; // process closed before agent_end — nothing to extract this round
|
|
299
|
+
const assistantMessages = agentEndMessages.filter((m) => m.role === 'assistant');
|
|
300
|
+
for (const m of assistantMessages) {
|
|
301
|
+
// Summed, not overwritten: each assistant entry carries ITS OWN
|
|
302
|
+
// per-turn usage (confirmed live — see file header), so summing
|
|
303
|
+
// across every internal turn in this agent_end is the correct
|
|
304
|
+
// total for the prompt just sent.
|
|
305
|
+
if (m.usage) {
|
|
306
|
+
turnInputTokens += m.usage.input ?? 0;
|
|
307
|
+
turnOutputTokens += m.usage.output ?? 0;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const rawText = assistantMessages.map((m) => extractPiRpcText(m)).filter(Boolean).join('\n');
|
|
311
|
+
const visibleText = rawText.replace(TOOL_CALL_RE, '').trim();
|
|
312
|
+
if (visibleText)
|
|
313
|
+
yield { type: 'assistant', text: visibleText };
|
|
314
|
+
const malformed = [];
|
|
315
|
+
const calls = parseToolCalls([rawText], (raw, err) => malformed.push(`[monomind] ignored malformed tool_call fence (${err}): ${raw.slice(0, 200)}`));
|
|
316
|
+
for (const note of malformed)
|
|
317
|
+
yield { type: 'assistant', text: note };
|
|
318
|
+
if (calls.length === 0)
|
|
319
|
+
break turnLoop;
|
|
320
|
+
round += 1;
|
|
321
|
+
if (round > MAX_TOOL_ROUNDS) {
|
|
322
|
+
yield { type: 'assistant', text: `[monomind] tool-call round cap (${MAX_TOOL_ROUNDS}) reached — dropping ${calls.length} pending tool call(s)` };
|
|
323
|
+
break turnLoop;
|
|
324
|
+
}
|
|
325
|
+
// Pause the silence watchdog for the duration — see its
|
|
326
|
+
// declaration above for why a call like ask_human blocking on a
|
|
327
|
+
// human isn't "pi is wedged". Always un-paused in `finally` so an
|
|
328
|
+
// exception out of executeToolCall can't leave it stuck off.
|
|
329
|
+
toolCallInFlight = true;
|
|
330
|
+
const results = [];
|
|
331
|
+
try {
|
|
332
|
+
for (const call of calls)
|
|
333
|
+
results.push(await executeToolCall(args.tools, call, args.canUseTool));
|
|
334
|
+
}
|
|
335
|
+
finally {
|
|
336
|
+
toolCallInFlight = false;
|
|
337
|
+
lastEventAt = Date.now(); // the post-tool-call silence window starts fresh, not already partway elapsed
|
|
338
|
+
}
|
|
339
|
+
nextMessage = formatToolResults(calls, results);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
finally {
|
|
343
|
+
turnInFlight = false;
|
|
344
|
+
}
|
|
345
|
+
yield {
|
|
346
|
+
type: 'result',
|
|
347
|
+
subtype: 'success',
|
|
348
|
+
input_tokens: turnInputTokens,
|
|
349
|
+
output_tokens: turnOutputTokens,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
catch (err) {
|
|
354
|
+
if (err.code === 'ENOENT') {
|
|
355
|
+
throw new Error('PiRpcAgentRunner requires the Pi coding agent CLI (pi) on PATH. ' +
|
|
356
|
+
'Install it: npm install -g @mariozechner/pi-coding-agent, then configure a ' +
|
|
357
|
+
'provider. Or unset the runtime to use Claude.');
|
|
358
|
+
}
|
|
359
|
+
throw err;
|
|
360
|
+
}
|
|
361
|
+
finally {
|
|
362
|
+
if (hangTimer)
|
|
363
|
+
clearTimeout(hangTimer);
|
|
364
|
+
clearInterval(silenceWatchdog);
|
|
365
|
+
if (processExited) {
|
|
366
|
+
// Process is confirmed dead — any pending SIGKILL escalation from
|
|
367
|
+
// killChild() is no longer needed.
|
|
368
|
+
if (killTimer)
|
|
369
|
+
clearTimeout(killTimer);
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
// NOT confirmed dead (e.g. the hang/silence watchdog fired and
|
|
373
|
+
// sent SIGTERM, but the process hasn't closed yet). Clearing
|
|
374
|
+
// killTimer here would cancel the SIGKILL escalation mid-grace-
|
|
375
|
+
// period and orphan a process that's ignoring SIGTERM — exactly
|
|
376
|
+
// the wedged case these watchdogs exist to handle. Leave the
|
|
377
|
+
// existing (unref'd) escalation timer running, or arm a fresh one
|
|
378
|
+
// if we're exiting via a path that never called killChild() at all.
|
|
379
|
+
if (!killTimer)
|
|
380
|
+
killChild();
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
//# sourceMappingUR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