qlogicagent 2.13.4 → 2.13.5
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/dist/agent/agent.d.ts +48 -0
- package/dist/agent/agent.js +197 -0
- package/dist/agent/memory-recall-context.d.ts +18 -0
- package/dist/agent/memory-recall-context.js +139 -0
- package/dist/agent/memory-recall-context.test.d.ts +1 -0
- package/dist/agent/memory-recall-context.test.js +58 -0
- package/dist/agent/memory-recall-injection.d.ts +34 -0
- package/dist/agent/memory-recall-injection.js +66 -0
- package/dist/agent/runtime-vars.d.ts +48 -0
- package/dist/agent/runtime-vars.js +54 -0
- package/dist/agent/tool-access.d.ts +1 -0
- package/dist/agent/tool-access.js +1 -0
- package/dist/agent/tool-loop/artifact-events.d.ts +17 -0
- package/dist/agent/tool-loop/artifact-events.js +75 -0
- package/dist/agent/tool-loop/budget-continuation-policy.d.ts +22 -0
- package/dist/agent/tool-loop/budget-continuation-policy.js +44 -0
- package/dist/agent/tool-loop/completion-action-policy.d.ts +19 -0
- package/dist/agent/tool-loop/completion-action-policy.js +68 -0
- package/dist/agent/tool-loop/completion-action-policy.test.d.ts +1 -0
- package/dist/agent/tool-loop/completion-action-policy.test.js +77 -0
- package/dist/agent/tool-loop/completion-stop-policy.d.ts +19 -0
- package/dist/agent/tool-loop/completion-stop-policy.js +31 -0
- package/dist/agent/tool-loop/compression-pipeline.d.ts +44 -0
- package/dist/agent/tool-loop/compression-pipeline.js +68 -0
- package/dist/agent/tool-loop/loop-helpers.d.ts +15 -0
- package/dist/agent/tool-loop/loop-helpers.js +86 -0
- package/dist/agent/tool-loop/recovery-helpers.d.ts +18 -0
- package/dist/agent/tool-loop/recovery-helpers.js +42 -0
- package/dist/agent/tool-loop/single-round.d.ts +2 -0
- package/dist/agent/tool-loop/single-round.js +43 -0
- package/dist/agent/tool-loop/skill-instruction-policy.d.ts +7 -0
- package/dist/agent/tool-loop/skill-instruction-policy.js +18 -0
- package/dist/agent/tool-loop/stream-error-recovery.d.ts +59 -0
- package/dist/agent/tool-loop/stream-error-recovery.js +93 -0
- package/dist/agent/tool-loop/tool-failure-policy.d.ts +22 -0
- package/dist/agent/tool-loop/tool-failure-policy.js +46 -0
- package/dist/agent/tool-loop/tool-result-events.d.ts +11 -0
- package/dist/agent/tool-loop/tool-result-events.js +59 -0
- package/dist/agent/tool-loop/tool-result-events.test.d.ts +1 -0
- package/dist/agent/tool-loop/tool-result-events.test.js +30 -0
- package/dist/agent/tool-loop.contract.test.d.ts +1 -0
- package/dist/agent/tool-loop.contract.test.js +254 -0
- package/dist/agent/tool-loop.d.ts +121 -0
- package/dist/agent/tool-loop.js +1017 -0
- package/dist/agent/tool-loop.policy-architecture.test.d.ts +1 -0
- package/dist/agent/tool-loop.policy-architecture.test.js +21 -0
- package/dist/agent/tool-loop.states.test.d.ts +1 -0
- package/dist/agent/tool-loop.states.test.js +211 -0
- package/dist/agent/tunable-defaults.d.ts +1 -0
- package/dist/agent/tunable-defaults.js +1 -0
- package/dist/agent/types.d.ts +311 -0
- package/dist/agent/types.js +8 -0
- package/dist/cli/acp-commands.d.ts +32 -0
- package/dist/cli/acp-commands.js +145 -0
- package/dist/cli/acp-commands.test.d.ts +1 -0
- package/dist/cli/acp-commands.test.js +89 -0
- package/dist/cli/acp-extended-handlers.d.ts +69 -0
- package/dist/cli/acp-extended-handlers.js +484 -0
- package/dist/cli/acp-extended-handlers.product-confirm.test.d.ts +1 -0
- package/dist/cli/acp-extended-handlers.product-confirm.test.js +56 -0
- package/dist/cli/acp-extended-handlers.product-project.test.d.ts +1 -0
- package/dist/cli/acp-extended-handlers.product-project.test.js +66 -0
- package/dist/cli/acp-extended-handlers.solo-project.test.d.ts +1 -0
- package/dist/cli/acp-extended-handlers.solo-project.test.js +51 -0
- package/dist/cli/acp-extended-handlers.specchat.test.d.ts +1 -0
- package/dist/cli/acp-extended-handlers.specchat.test.js +62 -0
- package/dist/cli/acp-extended-handlers.workflowchat.test.d.ts +1 -0
- package/dist/cli/acp-extended-handlers.workflowchat.test.js +49 -0
- package/dist/cli/acp-extended-host-adapter.d.ts +29 -0
- package/dist/cli/acp-extended-host-adapter.js +40 -0
- package/dist/cli/acp-extended-host-adapter.test.d.ts +1 -0
- package/dist/cli/acp-extended-host-adapter.test.js +63 -0
- package/dist/cli/acp-message-router.d.ts +8 -0
- package/dist/cli/acp-message-router.js +40 -0
- package/dist/cli/acp-message-router.test.d.ts +1 -0
- package/dist/cli/acp-message-router.test.js +30 -0
- package/dist/cli/acp-session-handlers.d.ts +41 -0
- package/dist/cli/acp-session-handlers.js +304 -0
- package/dist/cli/acp-session-handlers.test.d.ts +1 -0
- package/dist/cli/acp-session-handlers.test.js +346 -0
- package/dist/cli/acp-session-host.d.ts +48 -0
- package/dist/cli/acp-session-host.js +1 -0
- package/dist/cli/agent-config-coordinator.d.ts +16 -0
- package/dist/cli/agent-config-coordinator.js +56 -0
- package/dist/cli/agent-config-coordinator.test.d.ts +1 -0
- package/dist/cli/agent-config-coordinator.test.js +51 -0
- package/dist/cli/agent-config-runtime.d.ts +11 -0
- package/dist/cli/agent-config-runtime.js +4 -0
- package/dist/cli/agent-runner-factory.d.ts +2 -0
- package/dist/cli/agent-runner-factory.js +11 -0
- package/dist/cli/agent-runtime-bootstrap.d.ts +67 -0
- package/dist/cli/agent-runtime-bootstrap.js +104 -0
- package/dist/cli/agent-runtime-ports-adapter.d.ts +2 -0
- package/dist/cli/agent-runtime-ports-adapter.js +22 -0
- package/dist/cli/agent-runtime-session-state.d.ts +24 -0
- package/dist/cli/agent-runtime-session-state.js +51 -0
- package/dist/cli/agent-status-notifier.d.ts +11 -0
- package/dist/cli/agent-status-notifier.js +26 -0
- package/dist/cli/agent-status-notifier.test.d.ts +1 -0
- package/dist/cli/agent-status-notifier.test.js +33 -0
- package/dist/cli/base-tool-bootstrap.d.ts +16 -0
- package/dist/cli/base-tool-bootstrap.js +20 -0
- package/dist/cli/cli-acp-request-handler.d.ts +11 -0
- package/dist/cli/cli-acp-request-handler.js +61 -0
- package/dist/cli/cli-acp-request-handler.test.d.ts +1 -0
- package/dist/cli/cli-acp-request-handler.test.js +58 -0
- package/dist/cli/cli-agent-builder.d.ts +35 -0
- package/dist/cli/cli-agent-builder.js +33 -0
- package/dist/cli/community-resource-installer.d.ts +30 -0
- package/dist/cli/community-resource-installer.js +66 -0
- package/dist/cli/community-resource-installer.test.d.ts +1 -0
- package/dist/cli/community-resource-installer.test.js +175 -0
- package/dist/cli/community-skill-installer.d.ts +12 -0
- package/dist/cli/community-skill-installer.js +220 -0
- package/dist/cli/community-skill-installer.test.d.ts +1 -0
- package/dist/cli/community-skill-installer.test.js +179 -0
- package/dist/cli/community-workflow-installer.d.ts +29 -0
- package/dist/cli/community-workflow-installer.js +69 -0
- package/dist/cli/conversation-context.d.ts +30 -0
- package/dist/cli/conversation-context.js +69 -0
- package/dist/cli/conversation-context.test.d.ts +1 -0
- package/dist/cli/conversation-context.test.js +61 -0
- package/dist/cli/core-tool-coordinator.d.ts +41 -0
- package/dist/cli/core-tool-coordinator.js +55 -0
- package/dist/cli/core-tools/agent-tool-bootstrap.d.ts +12 -0
- package/dist/cli/core-tools/agent-tool-bootstrap.js +5 -0
- package/dist/cli/core-tools/agent-tool-service.background.test.d.ts +1 -0
- package/dist/cli/core-tools/agent-tool-service.background.test.js +212 -0
- package/dist/cli/core-tools/agent-tool-service.d.ts +36 -0
- package/dist/cli/core-tools/agent-tool-service.js +152 -0
- package/dist/cli/core-tools/checkpoint-tool-bootstrap.d.ts +9 -0
- package/dist/cli/core-tools/checkpoint-tool-bootstrap.js +8 -0
- package/dist/cli/core-tools/checkpoint-tool-service.d.ts +7 -0
- package/dist/cli/core-tools/checkpoint-tool-service.js +5 -0
- package/dist/cli/core-tools/config-tool-bootstrap.d.ts +5 -0
- package/dist/cli/core-tools/config-tool-bootstrap.js +5 -0
- package/dist/cli/core-tools/config-tool-service.d.ts +11 -0
- package/dist/cli/core-tools/config-tool-service.js +86 -0
- package/dist/cli/core-tools/config-tool-service.test.d.ts +1 -0
- package/dist/cli/core-tools/config-tool-service.test.js +69 -0
- package/dist/cli/core-tools/cron-tool-bootstrap.d.ts +8 -0
- package/dist/cli/core-tools/cron-tool-bootstrap.js +8 -0
- package/dist/cli/core-tools/cron-workflow-service.d.ts +7 -0
- package/dist/cli/core-tools/cron-workflow-service.js +206 -0
- package/dist/cli/core-tools/cron-workflow-service.test.d.ts +1 -0
- package/dist/cli/core-tools/cron-workflow-service.test.js +78 -0
- package/dist/cli/core-tools/fork-system-prompt.d.ts +45 -0
- package/dist/cli/core-tools/fork-system-prompt.js +66 -0
- package/dist/cli/core-tools/fork-system-prompt.test.d.ts +1 -0
- package/dist/cli/core-tools/fork-system-prompt.test.js +77 -0
- package/dist/cli/core-tools/monitor-tool-bootstrap.d.ts +7 -0
- package/dist/cli/core-tools/monitor-tool-bootstrap.js +8 -0
- package/dist/cli/core-tools/monitor-tool-service.d.ts +6 -0
- package/dist/cli/core-tools/monitor-tool-service.js +74 -0
- package/dist/cli/core-tools/registry.d.ts +8 -0
- package/dist/cli/core-tools/registry.js +60 -0
- package/dist/cli/core-tools/session-tool-manifest.d.ts +12 -0
- package/dist/cli/core-tools/session-tool-manifest.js +19 -0
- package/dist/cli/core-tools/team-registry.d.ts +62 -0
- package/dist/cli/core-tools/team-registry.js +85 -0
- package/dist/cli/core-tools/team-registry.test.d.ts +1 -0
- package/dist/cli/core-tools/team-registry.test.js +79 -0
- package/dist/cli/core-tools/team-tool-bootstrap.d.ts +11 -0
- package/dist/cli/core-tools/team-tool-bootstrap.js +8 -0
- package/dist/cli/core-tools/team-tool-service.d.ts +43 -0
- package/dist/cli/core-tools/team-tool-service.js +326 -0
- package/dist/cli/core-tools/team-tool-service.test.d.ts +1 -0
- package/dist/cli/core-tools/team-tool-service.test.js +48 -0
- package/dist/cli/credential-vault.d.ts +62 -0
- package/dist/cli/credential-vault.js +190 -0
- package/dist/cli/credential-vault.test.d.ts +6 -0
- package/dist/cli/credential-vault.test.js +130 -0
- package/dist/cli/default-project-bootstrap.d.ts +8 -0
- package/dist/cli/default-project-bootstrap.js +39 -0
- package/dist/cli/dev-tool-bootstrap.d.ts +8 -0
- package/dist/cli/dev-tool-bootstrap.js +19 -0
- package/dist/cli/dev-tools/dev-tool-bootstrap-service.d.ts +6 -0
- package/dist/cli/dev-tools/dev-tool-bootstrap-service.js +6 -0
- package/dist/cli/dev-tools/dev-tool-registry.d.ts +6 -0
- package/dist/cli/dev-tools/dev-tool-registry.js +7 -0
- package/dist/cli/dev-tools/lsp-tool-service.d.ts +5 -0
- package/dist/cli/dev-tools/lsp-tool-service.js +30 -0
- package/dist/cli/dev-tools/lsp-tool-service.test.d.ts +1 -0
- package/dist/cli/dev-tools/lsp-tool-service.test.js +14 -0
- package/dist/cli/dream-host-adapter.d.ts +23 -0
- package/dist/cli/dream-host-adapter.js +33 -0
- package/dist/cli/gateway-rpc-connection.d.ts +50 -0
- package/dist/cli/gateway-rpc-connection.js +133 -0
- package/dist/cli/handlers/agents-handler.d.ts +51 -0
- package/dist/cli/handlers/agents-handler.js +769 -0
- package/dist/cli/handlers/community-handler.d.ts +39 -0
- package/dist/cli/handlers/community-handler.js +671 -0
- package/dist/cli/handlers/community-handler.test.d.ts +1 -0
- package/dist/cli/handlers/community-handler.test.js +1602 -0
- package/dist/cli/handlers/config-handler.d.ts +28 -0
- package/dist/cli/handlers/config-handler.js +438 -0
- package/dist/cli/handlers/config-handler.test.d.ts +1 -0
- package/dist/cli/handlers/config-handler.test.js +140 -0
- package/dist/cli/handlers/config-handler.tools-list.test.d.ts +1 -0
- package/dist/cli/handlers/config-handler.tools-list.test.js +93 -0
- package/dist/cli/handlers/control-handler.d.ts +23 -0
- package/dist/cli/handlers/control-handler.js +88 -0
- package/dist/cli/handlers/dream-handler.d.ts +31 -0
- package/dist/cli/handlers/dream-handler.js +235 -0
- package/dist/cli/handlers/files-handler.d.ts +22 -0
- package/dist/cli/handlers/files-handler.instructions.test.d.ts +1 -0
- package/dist/cli/handlers/files-handler.instructions.test.js +127 -0
- package/dist/cli/handlers/files-handler.js +593 -0
- package/dist/cli/handlers/media-handler.d.ts +19 -0
- package/dist/cli/handlers/media-handler.js +212 -0
- package/dist/cli/handlers/media-handler.test.d.ts +1 -0
- package/dist/cli/handlers/media-handler.test.js +107 -0
- package/dist/cli/handlers/memory-handler.d.ts +61 -0
- package/dist/cli/handlers/memory-handler.js +792 -0
- package/dist/cli/handlers/pet-confirm-handler.d.ts +7 -0
- package/dist/cli/handlers/pet-confirm-handler.js +6 -0
- package/dist/cli/handlers/pet-handler.d.ts +47 -0
- package/dist/cli/handlers/pet-handler.js +455 -0
- package/dist/cli/handlers/pet-handler.test.d.ts +1 -0
- package/dist/cli/handlers/pet-handler.test.js +620 -0
- package/dist/cli/handlers/product-handler.d.ts +37 -0
- package/dist/cli/handlers/product-handler.js +393 -0
- package/dist/cli/handlers/project-handler.d.ts +28 -0
- package/dist/cli/handlers/project-handler.js +421 -0
- package/dist/cli/handlers/session-handler.channel.test.d.ts +1 -0
- package/dist/cli/handlers/session-handler.channel.test.js +157 -0
- package/dist/cli/handlers/session-handler.d.ts +58 -0
- package/dist/cli/handlers/session-handler.delete.test.d.ts +1 -0
- package/dist/cli/handlers/session-handler.delete.test.js +38 -0
- package/dist/cli/handlers/session-handler.js +833 -0
- package/dist/cli/handlers/session-handler.resume.test.d.ts +1 -0
- package/dist/cli/handlers/session-handler.resume.test.js +66 -0
- package/dist/cli/handlers/settings-handler.d.ts +19 -0
- package/dist/cli/handlers/settings-handler.js +710 -0
- package/dist/cli/handlers/settings-handler.remote-catalog.test.d.ts +1 -0
- package/dist/cli/handlers/settings-handler.remote-catalog.test.js +1247 -0
- package/dist/cli/handlers/skills-handler.d.ts +29 -0
- package/dist/cli/handlers/skills-handler.js +368 -0
- package/dist/cli/handlers/skills-handler.profile.test.d.ts +1 -0
- package/dist/cli/handlers/skills-handler.profile.test.js +70 -0
- package/dist/cli/handlers/solo-handler.d.ts +38 -0
- package/dist/cli/handlers/solo-handler.js +351 -0
- package/dist/cli/handlers/turn-handler.d.ts +52 -0
- package/dist/cli/handlers/turn-handler.js +574 -0
- package/dist/cli/handlers/turn-handler.test.d.ts +1 -0
- package/dist/cli/handlers/turn-handler.test.js +22 -0
- package/dist/cli/handlers/workflow-handler.d.ts +181 -0
- package/dist/cli/handlers/workflow-handler.events.test.d.ts +1 -0
- package/dist/cli/handlers/workflow-handler.events.test.js +113 -0
- package/dist/cli/handlers/workflow-handler.js +1449 -0
- package/dist/cli/handlers/workflow-handler.multiroot.test.d.ts +12 -0
- package/dist/cli/handlers/workflow-handler.multiroot.test.js +745 -0
- package/dist/cli/idle-dream-coordinator.d.ts +47 -0
- package/dist/cli/idle-dream-coordinator.js +126 -0
- package/dist/cli/idle-dream-coordinator.test.d.ts +1 -0
- package/dist/cli/idle-dream-coordinator.test.js +125 -0
- package/dist/cli/main.d.ts +15 -0
- package/dist/cli/main.js +112 -0
- package/dist/cli/mcp-bootstrap.d.ts +20 -0
- package/dist/cli/mcp-bootstrap.js +66 -0
- package/dist/cli/mcp-plugin-bootstrap.d.ts +2 -0
- package/dist/cli/mcp-plugin-bootstrap.js +2 -0
- package/dist/cli/mcp-plugin-bootstrap.test.d.ts +1 -0
- package/dist/cli/mcp-plugin-bootstrap.test.js +38 -0
- package/dist/cli/mcp-tool-proxy.d.ts +7 -0
- package/dist/cli/mcp-tool-proxy.js +15 -0
- package/dist/cli/media-capability-schema.d.ts +49 -0
- package/dist/cli/media-capability-schema.js +384 -0
- package/dist/cli/media-capability-schema.test.d.ts +1 -0
- package/dist/cli/media-capability-schema.test.js +103 -0
- package/dist/cli/media-file-api-service.d.ts +73 -0
- package/dist/cli/media-file-api-service.js +143 -0
- package/dist/cli/media-file-api-service.test.d.ts +1 -0
- package/dist/cli/media-file-api-service.test.js +119 -0
- package/dist/cli/media-file-tool-service.d.ts +13 -0
- package/dist/cli/media-file-tool-service.js +63 -0
- package/dist/cli/media-runtime-capability.test.d.ts +1 -0
- package/dist/cli/media-runtime-capability.test.js +106 -0
- package/dist/cli/media-runtime-facade.d.ts +51 -0
- package/dist/cli/media-runtime-facade.js +389 -0
- package/dist/cli/media-runtime-facade.test.d.ts +1 -0
- package/dist/cli/media-runtime-facade.test.js +42 -0
- package/dist/cli/memory-candidate-service.d.ts +83 -0
- package/dist/cli/memory-candidate-service.js +341 -0
- package/dist/cli/memory-coordinator.d.ts +37 -0
- package/dist/cli/memory-coordinator.js +85 -0
- package/dist/cli/memory-coordinator.test.d.ts +1 -0
- package/dist/cli/memory-coordinator.test.js +78 -0
- package/dist/cli/memory-multimodal.test.d.ts +1 -0
- package/dist/cli/memory-multimodal.test.js +137 -0
- package/dist/cli/model-client-resolver.d.ts +31 -0
- package/dist/cli/model-client-resolver.js +173 -0
- package/dist/cli/model-client-resolver.test.d.ts +1 -0
- package/dist/cli/model-client-resolver.test.js +105 -0
- package/dist/cli/multi-agent-handler-host.d.ts +27 -0
- package/dist/cli/multi-agent-handler-host.js +55 -0
- package/dist/cli/multi-agent-handler-host.test.d.ts +1 -0
- package/dist/cli/multi-agent-handler-host.test.js +63 -0
- package/dist/cli/multi-agent-state-coordinator.d.ts +11 -0
- package/dist/cli/multi-agent-state-coordinator.js +7 -0
- package/dist/cli/permission-approval-bridge.d.ts +15 -0
- package/dist/cli/permission-approval-bridge.js +66 -0
- package/dist/cli/permission-approval-bridge.test.d.ts +1 -0
- package/dist/cli/permission-approval-bridge.test.js +100 -0
- package/dist/cli/permission-bootstrap.d.ts +40 -0
- package/dist/cli/permission-bootstrap.js +58 -0
- package/dist/cli/permission-bootstrap.test.d.ts +1 -0
- package/dist/cli/permission-bootstrap.test.js +129 -0
- package/dist/cli/permission-runtime-service.d.ts +9 -0
- package/dist/cli/permission-runtime-service.js +11 -0
- package/dist/cli/permission-settings-store.d.ts +1 -0
- package/dist/cli/permission-settings-store.js +3 -0
- package/dist/cli/permission-settings-store.test.d.ts +1 -0
- package/dist/cli/permission-settings-store.test.js +65 -0
- package/dist/cli/pet-confirm-coordinator.d.ts +20 -0
- package/dist/cli/pet-confirm-coordinator.js +32 -0
- package/dist/cli/pet-confirm-coordinator.test.d.ts +1 -0
- package/dist/cli/pet-confirm-coordinator.test.js +34 -0
- package/dist/cli/pet-runtime.d.ts +55 -0
- package/dist/cli/pet-runtime.js +220 -0
- package/dist/cli/pet-runtime.test.d.ts +1 -0
- package/dist/cli/pet-runtime.test.js +46 -0
- package/dist/cli/plugin-bootstrap.d.ts +15 -0
- package/dist/cli/plugin-bootstrap.js +63 -0
- package/dist/cli/product-coordinator.d.ts +34 -0
- package/dist/cli/product-coordinator.js +124 -0
- package/dist/cli/product-coordinator.test.d.ts +1 -0
- package/dist/cli/product-coordinator.test.js +51 -0
- package/dist/cli/project-command-service.d.ts +28 -0
- package/dist/cli/project-command-service.js +99 -0
- package/dist/cli/project-context.d.ts +1 -0
- package/dist/cli/project-context.js +4 -0
- package/dist/cli/project-memory-store-factory.d.ts +2 -0
- package/dist/cli/project-memory-store-factory.js +11 -0
- package/dist/cli/project-template-seeder.d.ts +5 -0
- package/dist/cli/project-template-seeder.js +43 -0
- package/dist/cli/provider-core-facade.d.ts +31 -0
- package/dist/cli/provider-core-facade.js +51 -0
- package/dist/cli/provider-core-facade.test.d.ts +1 -0
- package/dist/cli/provider-core-facade.test.js +9 -0
- package/dist/cli/resolved-agent-cache.d.ts +47 -0
- package/dist/cli/resolved-agent-cache.js +38 -0
- package/dist/cli/rpc-registry.community.test.d.ts +1 -0
- package/dist/cli/rpc-registry.community.test.js +45 -0
- package/dist/cli/rpc-registry.d.ts +62 -0
- package/dist/cli/rpc-registry.js +243 -0
- package/dist/cli/runtime-dependency-catalog.d.ts +56 -0
- package/dist/cli/runtime-dependency-catalog.js +110 -0
- package/dist/cli/runtime-hook-bootstrap.d.ts +38 -0
- package/dist/cli/runtime-hook-bootstrap.js +71 -0
- package/dist/cli/runtime-watcher-bootstrap.d.ts +15 -0
- package/dist/cli/runtime-watcher-bootstrap.js +30 -0
- package/dist/cli/session-context.d.ts +32 -0
- package/dist/cli/session-context.js +15 -0
- package/dist/cli/session-coordinator.d.ts +22 -0
- package/dist/cli/session-coordinator.js +47 -0
- package/dist/cli/session-coordinator.test.d.ts +1 -0
- package/dist/cli/session-coordinator.test.js +61 -0
- package/dist/cli/session-history-coordinator.d.ts +8 -0
- package/dist/cli/session-history-coordinator.js +57 -0
- package/dist/cli/session-history-coordinator.test.d.ts +1 -0
- package/dist/cli/session-history-coordinator.test.js +39 -0
- package/dist/cli/session-query-service.d.ts +24 -0
- package/dist/cli/session-query-service.js +57 -0
- package/dist/cli/skill-meta-subturn-service.d.ts +26 -0
- package/dist/cli/skill-meta-subturn-service.js +93 -0
- package/dist/cli/skill-meta-tool-bootstrap.d.ts +34 -0
- package/dist/cli/skill-meta-tool-bootstrap.js +295 -0
- package/dist/cli/skill-meta-tool-bootstrap.test.d.ts +1 -0
- package/dist/cli/skill-meta-tool-bootstrap.test.js +42 -0
- package/dist/cli/skill-supporting-file.test.d.ts +1 -0
- package/dist/cli/skill-supporting-file.test.js +97 -0
- package/dist/cli/skills-query-service.d.ts +29 -0
- package/dist/cli/skills-query-service.js +38 -0
- package/dist/cli/stdio-acp-protocol-coordinator.d.ts +18 -0
- package/dist/cli/stdio-acp-protocol-coordinator.js +33 -0
- package/dist/cli/stdio-acp-request-host.d.ts +28 -0
- package/dist/cli/stdio-acp-request-host.js +82 -0
- package/dist/cli/stdio-acp-request-host.test.d.ts +1 -0
- package/dist/cli/stdio-acp-request-host.test.js +61 -0
- package/dist/cli/stdio-agent-session-bootstrap.d.ts +80 -0
- package/dist/cli/stdio-agent-session-bootstrap.js +74 -0
- package/dist/cli/stdio-rpc-handler-hosts.d.ts +50 -0
- package/dist/cli/stdio-rpc-handler-hosts.js +135 -0
- package/dist/cli/stdio-rpc-handler-hosts.test.d.ts +1 -0
- package/dist/cli/stdio-rpc-handler-hosts.test.js +10 -0
- package/dist/cli/stdio-runtime-bootstrap.d.ts +16 -0
- package/dist/cli/stdio-runtime-bootstrap.js +17 -0
- package/dist/cli/stdio-runtime-services.d.ts +36 -0
- package/dist/cli/stdio-runtime-services.js +53 -0
- package/dist/cli/stdio-server.architecture.test.d.ts +1 -0
- package/dist/cli/stdio-server.architecture.test.js +18 -0
- package/dist/cli/stdio-server.contract.test.d.ts +1 -0
- package/dist/cli/stdio-server.contract.test.js +96 -0
- package/dist/cli/stdio-server.d.ts +211 -0
- package/dist/cli/stdio-server.js +731 -0
- package/dist/cli/stdio-session-runtime-coordinator.d.ts +19 -0
- package/dist/cli/stdio-session-runtime-coordinator.js +21 -0
- package/dist/cli/test-support/tool-catalog-fixture.d.ts +3 -0
- package/dist/cli/test-support/tool-catalog-fixture.js +98 -0
- package/dist/cli/tool-bootstrap-core-registration.d.ts +30 -0
- package/dist/cli/tool-bootstrap-core-registration.js +555 -0
- package/dist/cli/tool-bootstrap-media-registration.d.ts +8 -0
- package/dist/cli/tool-bootstrap-media-registration.js +348 -0
- package/dist/cli/tool-bootstrap-paths.d.ts +7 -0
- package/dist/cli/tool-bootstrap-paths.js +17 -0
- package/dist/cli/tool-bootstrap-providers.d.ts +3 -0
- package/dist/cli/tool-bootstrap-providers.js +10 -0
- package/dist/cli/tool-bootstrap-web-registration.d.ts +13 -0
- package/dist/cli/tool-bootstrap-web-registration.js +144 -0
- package/dist/cli/tool-bootstrap-workflow-registration.d.ts +7 -0
- package/dist/cli/tool-bootstrap-workflow-registration.js +65 -0
- package/dist/cli/tool-bootstrap.background-exec.test.d.ts +1 -0
- package/dist/cli/tool-bootstrap.background-exec.test.js +83 -0
- package/dist/cli/tool-bootstrap.cwd.test.d.ts +1 -0
- package/dist/cli/tool-bootstrap.cwd.test.js +37 -0
- package/dist/cli/tool-bootstrap.d.ts +63 -0
- package/dist/cli/tool-bootstrap.instructions.test.d.ts +1 -0
- package/dist/cli/tool-bootstrap.instructions.test.js +37 -0
- package/dist/cli/tool-bootstrap.js +255 -0
- package/dist/cli/tool-bootstrap.media-provider-alias.test.d.ts +1 -0
- package/dist/cli/tool-bootstrap.media-provider-alias.test.js +90 -0
- package/dist/cli/tool-bootstrap.test.d.ts +1 -0
- package/dist/cli/tool-bootstrap.test.js +94 -0
- package/dist/cli/tool-catalog.d.ts +4 -0
- package/dist/cli/tool-catalog.js +14 -0
- package/dist/cli/tool-invoker-factory.d.ts +12 -0
- package/dist/cli/tool-invoker-factory.js +45 -0
- package/dist/cli/tool-registration-modules.contract.test.d.ts +1 -0
- package/dist/cli/tool-registration-modules.contract.test.js +75 -0
- package/dist/cli/tool-registry-adapter.d.ts +5 -0
- package/dist/cli/tool-registry-adapter.js +27 -0
- package/dist/cli/tool-result-processor.d.ts +14 -0
- package/dist/cli/tool-result-processor.js +83 -0
- package/dist/cli/tool-result-processor.test.d.ts +1 -0
- package/dist/cli/tool-result-processor.test.js +69 -0
- package/dist/cli/transport.d.ts +30 -0
- package/dist/cli/transport.js +68 -0
- package/dist/cli/tunable-store.d.ts +26 -0
- package/dist/cli/tunable-store.js +105 -0
- package/dist/cli/turn-ask-user-setup.d.ts +24 -0
- package/dist/cli/turn-ask-user-setup.js +46 -0
- package/dist/cli/turn-ask-user-setup.test.d.ts +1 -0
- package/dist/cli/turn-ask-user-setup.test.js +39 -0
- package/dist/cli/turn-core.d.ts +57 -0
- package/dist/cli/turn-core.js +58 -0
- package/dist/cli/turn-event-forwarder.d.ts +10 -0
- package/dist/cli/turn-event-forwarder.js +136 -0
- package/dist/cli/turn-lifecycle.d.ts +19 -0
- package/dist/cli/turn-lifecycle.js +53 -0
- package/dist/cli/turn-lifecycle.test.d.ts +1 -0
- package/dist/cli/turn-lifecycle.test.js +32 -0
- package/dist/cli/turn-media-setup.d.ts +19 -0
- package/dist/cli/turn-media-setup.js +71 -0
- package/dist/cli/turn-media-setup.test.d.ts +1 -0
- package/dist/cli/turn-media-setup.test.js +280 -0
- package/dist/cli/turn-permission-sync.d.ts +6 -0
- package/dist/cli/turn-permission-sync.js +7 -0
- package/dist/cli/turn-permission-sync.test.d.ts +1 -0
- package/dist/cli/turn-permission-sync.test.js +20 -0
- package/dist/cli/turn-project-router.d.ts +22 -0
- package/dist/cli/turn-project-router.js +141 -0
- package/dist/cli/turn-project-router.test.d.ts +1 -0
- package/dist/cli/turn-project-router.test.js +79 -0
- package/dist/cli/turn-skill-autopersist.d.ts +47 -0
- package/dist/cli/turn-skill-autopersist.js +262 -0
- package/dist/cli/turn-skill-autopersist.test.d.ts +1 -0
- package/dist/cli/turn-skill-autopersist.test.js +222 -0
- package/dist/cli/turn-suggestion-generator.d.ts +15 -0
- package/dist/cli/turn-suggestion-generator.js +34 -0
- package/dist/cli/workflow-host-adapter.d.ts +29 -0
- package/dist/cli/workflow-host-adapter.js +15 -0
- package/dist/cli/workflow-host-adapter.test.d.ts +1 -0
- package/dist/cli/workflow-host-adapter.test.js +35 -0
- package/dist/config/config.d.ts +17 -0
- package/dist/config/config.js +21 -0
- package/dist/contracts/fire-hook.d.ts +14 -0
- package/dist/contracts/fire-hook.js +14 -0
- package/dist/contracts/fire-hook.test.d.ts +1 -0
- package/dist/contracts/fire-hook.test.js +34 -0
- package/dist/contracts/hooks.d.ts +186 -0
- package/dist/contracts/hooks.js +7 -0
- package/dist/contracts/index.d.ts +4 -0
- package/dist/contracts/index.js +4 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +15 -1269
- package/dist/orchestration/agent-instance.d.ts +84 -0
- package/dist/orchestration/agent-instance.js +535 -0
- package/dist/orchestration/context/context-collapse.d.ts +58 -0
- package/dist/orchestration/context/context-collapse.js +134 -0
- package/dist/orchestration/context/reactive-compact.d.ts +73 -0
- package/dist/orchestration/context/reactive-compact.js +78 -0
- package/dist/orchestration/context/turn-loop-guard.d.ts +86 -0
- package/dist/orchestration/context/turn-loop-guard.js +100 -0
- package/dist/orchestration/dag-scheduler.d.ts +167 -0
- package/dist/orchestration/dag-scheduler.js +546 -0
- package/dist/orchestration/error-handling/error-classification.d.ts +3 -0
- package/dist/orchestration/error-handling/error-classification.js +35 -0
- package/dist/orchestration/error-handling/failover-classification.d.ts +8 -0
- package/dist/orchestration/error-handling/failover-classification.js +381 -0
- package/dist/orchestration/error-handling/retry-loop.d.ts +69 -0
- package/dist/orchestration/error-handling/retry-loop.js +96 -0
- package/dist/orchestration/index.d.ts +15 -0
- package/dist/orchestration/index.js +18 -0
- package/dist/orchestration/product-budget.d.ts +56 -0
- package/dist/orchestration/product-budget.js +112 -0
- package/dist/orchestration/product-checkpoint.d.ts +46 -0
- package/dist/orchestration/product-checkpoint.js +74 -0
- package/dist/orchestration/product-dag-mutation-applier.d.ts +10 -0
- package/dist/orchestration/product-dag-mutation-applier.js +91 -0
- package/dist/orchestration/product-persistence.d.ts +35 -0
- package/dist/orchestration/product-persistence.js +55 -0
- package/dist/orchestration/product-planner.d.ts +146 -0
- package/dist/orchestration/product-planner.js +379 -0
- package/dist/orchestration/product-run-coordinator.d.ts +31 -0
- package/dist/orchestration/product-run-coordinator.js +31 -0
- package/dist/orchestration/product-worktree.d.ts +12 -0
- package/dist/orchestration/product-worktree.js +69 -0
- package/dist/orchestration/skill-improvement.d.ts +129 -0
- package/dist/orchestration/skill-improvement.js +243 -0
- package/dist/orchestration/solo-evaluator.d.ts +124 -0
- package/dist/orchestration/solo-evaluator.js +611 -0
- package/dist/orchestration/solo-persistence.d.ts +48 -0
- package/dist/orchestration/solo-persistence.js +67 -0
- package/dist/orchestration/solo-spec-builder.d.ts +48 -0
- package/dist/orchestration/solo-spec-builder.js +139 -0
- package/dist/orchestration/subagent/agent-registry.d.ts +46 -0
- package/dist/orchestration/subagent/agent-registry.js +129 -0
- package/dist/orchestration/subagent/fork-subagent.d.ts +100 -0
- package/dist/orchestration/subagent/fork-subagent.js +101 -0
- package/dist/orchestration/subagent/task-types.d.ts +1 -0
- package/dist/orchestration/subagent/task-types.js +1 -0
- package/dist/orchestration/tool-cascade.d.ts +49 -0
- package/dist/orchestration/tool-cascade.js +86 -0
- package/dist/orchestration/tool-loop/conversation-repair.d.ts +61 -0
- package/dist/orchestration/tool-loop/conversation-repair.js +429 -0
- package/dist/orchestration/tool-loop/tool-choice-policy.d.ts +54 -0
- package/dist/orchestration/tool-loop/tool-choice-policy.js +164 -0
- package/dist/orchestration/tool-loop/tool-loop-state.d.ts +50 -0
- package/dist/orchestration/tool-loop/tool-loop-state.js +133 -0
- package/dist/orchestration/tool-loop/tool-schema.d.ts +46 -0
- package/dist/orchestration/tool-loop/tool-schema.js +208 -0
- package/dist/orchestration/workflow/budget-permission-gate.d.ts +85 -0
- package/dist/orchestration/workflow/budget-permission-gate.js +134 -0
- package/dist/orchestration/workflow/builtin-executors.d.ts +18 -0
- package/dist/orchestration/workflow/builtin-executors.js +191 -0
- package/dist/orchestration/workflow/capability-catalog.d.ts +64 -0
- package/dist/orchestration/workflow/capability-catalog.js +166 -0
- package/dist/orchestration/workflow/cron-schedule.d.ts +37 -0
- package/dist/orchestration/workflow/cron-schedule.js +199 -0
- package/dist/orchestration/workflow/data-item.d.ts +39 -0
- package/dist/orchestration/workflow/data-item.js +52 -0
- package/dist/orchestration/workflow/expression.d.ts +60 -0
- package/dist/orchestration/workflow/expression.js +474 -0
- package/dist/orchestration/workflow/host-executors.d.ts +15 -0
- package/dist/orchestration/workflow/host-executors.js +207 -0
- package/dist/orchestration/workflow/n8n-expression.d.ts +48 -0
- package/dist/orchestration/workflow/n8n-expression.js +95 -0
- package/dist/orchestration/workflow/n8n-import.d.ts +68 -0
- package/dist/orchestration/workflow/n8n-import.js +319 -0
- package/dist/orchestration/workflow/node-registry.d.ts +19 -0
- package/dist/orchestration/workflow/node-registry.js +45 -0
- package/dist/orchestration/workflow/node-schema.d.ts +232 -0
- package/dist/orchestration/workflow/node-schema.js +29 -0
- package/dist/orchestration/workflow/qla-executor-host.d.ts +77 -0
- package/dist/orchestration/workflow/qla-executor-host.js +124 -0
- package/dist/orchestration/workflow/run-checkpoint-store.d.ts +53 -0
- package/dist/orchestration/workflow/run-checkpoint-store.js +59 -0
- package/dist/orchestration/workflow/run-history-store.d.ts +65 -0
- package/dist/orchestration/workflow/run-history-store.js +104 -0
- package/dist/orchestration/workflow/trigger-validation.d.ts +22 -0
- package/dist/orchestration/workflow/trigger-validation.js +241 -0
- package/dist/orchestration/workflow/workflow-audit-store.d.ts +31 -0
- package/dist/orchestration/workflow/workflow-audit-store.js +55 -0
- package/dist/orchestration/workflow/workflow-bundle.d.ts +65 -0
- package/dist/orchestration/workflow/workflow-bundle.js +168 -0
- package/dist/orchestration/workflow/workflow-controller.d.ts +219 -0
- package/dist/orchestration/workflow/workflow-controller.js +522 -0
- package/dist/orchestration/workflow/workflow-patch.d.ts +116 -0
- package/dist/orchestration/workflow/workflow-patch.js +369 -0
- package/dist/orchestration/workflow/workflow-render.d.ts +41 -0
- package/dist/orchestration/workflow/workflow-render.js +108 -0
- package/dist/orchestration/workflow/workflow-runtime.d.ts +171 -0
- package/dist/orchestration/workflow/workflow-runtime.js +474 -0
- package/dist/orchestration/workflow/workflow-scheduler.d.ts +111 -0
- package/dist/orchestration/workflow/workflow-scheduler.js +230 -0
- package/dist/orchestration/workflow/workflow-service.d.ts +14 -0
- package/dist/orchestration/workflow/workflow-service.js +18 -0
- package/dist/orchestration/workflow/workflow-store.d.ts +81 -0
- package/dist/orchestration/workflow/workflow-store.js +123 -0
- package/dist/orchestration/workflow/workflow-trigger.d.ts +35 -0
- package/dist/orchestration/workflow/workflow-trigger.js +1 -0
- package/dist/orchestration/workflow-chat-builder.d.ts +57 -0
- package/dist/orchestration/workflow-chat-builder.js +202 -0
- package/dist/permissions.d.ts +2 -0
- package/dist/permissions.js +1 -1
- package/dist/permissions.public-api.test.d.ts +1 -0
- package/dist/permissions.public-api.test.js +32 -0
- package/dist/pet-contracts.d.ts +1 -0
- package/dist/pet-contracts.js +1 -1
- package/dist/protocol/index.d.ts +7 -0
- package/dist/protocol/index.js +7 -0
- package/dist/protocol/methods.d.ts +1190 -0
- package/dist/protocol/methods.js +110 -0
- package/dist/protocol/notifications.d.ts +9 -0
- package/dist/protocol/notifications.js +9 -0
- package/dist/protocol/wire/acp-agent-management.d.ts +456 -0
- package/dist/protocol/wire/acp-agent-management.js +7 -0
- package/dist/protocol/wire/acp-protocol.d.ts +369 -0
- package/dist/protocol/wire/acp-protocol.js +120 -0
- package/dist/protocol/wire/agent-events.d.ts +32 -0
- package/dist/protocol/wire/agent-events.js +113 -0
- package/dist/protocol/wire/agent-methods.d.ts +564 -0
- package/dist/protocol/wire/agent-methods.js +11 -0
- package/dist/protocol/wire/agent-rpc.d.ts +100 -0
- package/dist/protocol/wire/agent-rpc.js +72 -0
- package/dist/protocol/wire/capability-manifest.d.ts +112 -0
- package/dist/protocol/wire/capability-manifest.js +149 -0
- package/dist/protocol/wire/capability-transport.d.ts +207 -0
- package/dist/protocol/wire/capability-transport.js +1 -0
- package/dist/protocol/wire/channel-ingress.d.ts +29 -0
- package/dist/protocol/wire/channel-ingress.js +1 -0
- package/dist/protocol/wire/channel.d.ts +89 -0
- package/dist/protocol/wire/channel.js +1 -0
- package/dist/protocol/wire/chat-types.d.ts +106 -0
- package/dist/protocol/wire/chat-types.js +7 -0
- package/dist/protocol/wire/checkpoint-runtime.d.ts +61 -0
- package/dist/protocol/wire/checkpoint-runtime.js +499 -0
- package/dist/protocol/wire/checkpoint.d.ts +72 -0
- package/dist/protocol/wire/checkpoint.js +12 -0
- package/dist/protocol/wire/execution.d.ts +391 -0
- package/dist/protocol/wire/execution.js +1 -0
- package/dist/protocol/wire/gateway-contract.d.ts +61 -0
- package/dist/protocol/wire/gateway-contract.js +236 -0
- package/dist/protocol/wire/gateway-contract.test.d.ts +1 -0
- package/dist/protocol/wire/gateway-contract.test.js +123 -0
- package/dist/protocol/wire/gateway-rpc.d.ts +652 -0
- package/dist/protocol/wire/gateway-rpc.js +58 -0
- package/dist/protocol/wire/gateway.d.ts +62 -0
- package/dist/protocol/wire/gateway.js +1 -0
- package/dist/protocol/wire/hook-protocol.d.ts +37 -0
- package/dist/protocol/wire/hook-protocol.js +2 -0
- package/dist/protocol/wire/index.d.ts +28 -0
- package/dist/protocol/wire/index.js +27 -0
- package/dist/protocol/wire/memory-provider-lifecycle.d.ts +82 -0
- package/dist/protocol/wire/memory-provider-lifecycle.js +24 -0
- package/dist/protocol/wire/notification-payloads.d.ts +918 -0
- package/dist/protocol/wire/notification-payloads.js +13 -0
- package/dist/protocol/wire/pet-contracts.d.ts +76 -0
- package/dist/protocol/wire/pet-contracts.js +23 -0
- package/dist/protocol/wire/provider-runtime-contract.d.ts +66 -0
- package/dist/protocol/wire/provider-runtime-contract.js +23 -0
- package/dist/protocol/wire/provider-runtime-core.d.ts +147 -0
- package/dist/protocol/wire/provider-runtime-core.js +488 -0
- package/dist/protocol/wire/provider-runtime-io.d.ts +20 -0
- package/dist/protocol/wire/provider-runtime-io.js +57 -0
- package/dist/protocol/wire/resource-manifest.d.ts +68 -0
- package/dist/protocol/wire/resource-manifest.js +174 -0
- package/dist/protocol/wire/session.d.ts +32 -0
- package/dist/protocol/wire/session.js +1 -0
- package/dist/protocol/wire/thread-protocol.d.ts +145 -0
- package/dist/protocol/wire/thread-protocol.js +13 -0
- package/dist/protocol/wire/transport.d.ts +57 -0
- package/dist/protocol/wire/transport.js +1 -0
- package/dist/protocol/wire/turn.d.ts +208 -0
- package/dist/protocol/wire/turn.js +1 -0
- package/dist/protocol/wire/web-capability.d.ts +54 -0
- package/dist/protocol/wire/web-capability.js +52 -0
- package/dist/runtime/community/community-consent-client.d.ts +142 -0
- package/dist/runtime/community/community-consent-client.js +381 -0
- package/dist/runtime/community/community-consent-client.test.d.ts +1 -0
- package/dist/runtime/community/community-consent-client.test.js +491 -0
- package/dist/runtime/community/community-desensitization-red-team-cli.d.ts +7 -0
- package/dist/runtime/community/community-desensitization-red-team-cli.js +43 -0
- package/dist/runtime/community/community-desensitization-red-team-cli.test.d.ts +1 -0
- package/dist/runtime/community/community-desensitization-red-team-cli.test.js +23 -0
- package/dist/runtime/community/community-desensitization.d.ts +29 -0
- package/dist/runtime/community/community-desensitization.js +81 -0
- package/dist/runtime/community/community-desensitization.test.d.ts +1 -0
- package/dist/runtime/community/community-desensitization.test.js +43 -0
- package/dist/runtime/community/community-discovery-cache.d.ts +24 -0
- package/dist/runtime/community/community-discovery-cache.js +52 -0
- package/dist/runtime/community/community-discovery-coordinator.d.ts +33 -0
- package/dist/runtime/community/community-discovery-coordinator.js +84 -0
- package/dist/runtime/community/community-discovery-coordinator.test.d.ts +1 -0
- package/dist/runtime/community/community-discovery-coordinator.test.js +97 -0
- package/dist/runtime/community/community-pet-publisher.d.ts +30 -0
- package/dist/runtime/community/community-pet-publisher.js +53 -0
- package/dist/runtime/community/community-pet-publisher.test.d.ts +1 -0
- package/dist/runtime/community/community-pet-publisher.test.js +53 -0
- package/dist/runtime/community/community-signal-reporter.d.ts +33 -0
- package/dist/runtime/community/community-signal-reporter.js +85 -0
- package/dist/runtime/community/community-signal-reporter.test.d.ts +1 -0
- package/dist/runtime/community/community-signal-reporter.test.js +100 -0
- package/dist/runtime/community/community-telemetry-metadata.d.ts +4 -0
- package/dist/runtime/community/community-telemetry-metadata.js +42 -0
- package/dist/runtime/community/community-telemetry-recorder.d.ts +6 -0
- package/dist/runtime/community/community-telemetry-recorder.js +31 -0
- package/dist/runtime/community/community-telemetry-types.d.ts +1 -0
- package/dist/runtime/community/community-telemetry-types.js +1 -0
- package/dist/runtime/config/tunable-defaults.d.ts +255 -0
- package/dist/runtime/config/tunable-defaults.js +293 -0
- package/dist/runtime/context/context-compression-strategies.d.ts +301 -0
- package/dist/runtime/context/context-compression-strategies.js +860 -0
- package/dist/runtime/execution/dream-agent.d.ts +260 -0
- package/dist/runtime/execution/dream-agent.js +974 -0
- package/dist/runtime/execution/dream-category-context.d.ts +47 -0
- package/dist/runtime/execution/dream-category-context.js +226 -0
- package/dist/runtime/execution/dream-lock.test.d.ts +1 -0
- package/dist/runtime/execution/dream-lock.test.js +54 -0
- package/dist/runtime/execution/fork-context.d.ts +14 -0
- package/dist/runtime/execution/fork-context.js +20 -0
- package/dist/runtime/execution/fork-context.test.d.ts +1 -0
- package/dist/runtime/execution/fork-context.test.js +101 -0
- package/dist/runtime/execution/forked-agent.d.ts +111 -0
- package/dist/runtime/execution/forked-agent.js +172 -0
- package/dist/runtime/execution/index.d.ts +7 -0
- package/dist/runtime/execution/index.js +8 -0
- package/dist/runtime/execution/memory-decay.d.ts +69 -0
- package/dist/runtime/execution/memory-decay.js +80 -0
- package/dist/runtime/execution/progress-tracker.d.ts +78 -0
- package/dist/runtime/execution/progress-tracker.js +107 -0
- package/dist/runtime/execution/streaming-tool-executor.d.ts +102 -0
- package/dist/runtime/execution/streaming-tool-executor.js +345 -0
- package/dist/runtime/execution/streaming-tool-executor.test.d.ts +1 -0
- package/dist/runtime/execution/streaming-tool-executor.test.js +49 -0
- package/dist/runtime/execution/tool-eligibility.d.ts +36 -0
- package/dist/runtime/execution/tool-eligibility.js +94 -0
- package/dist/runtime/execution/tool-eligibility.test.d.ts +1 -0
- package/dist/runtime/execution/tool-eligibility.test.js +96 -0
- package/dist/runtime/execution/tool-result-storage.d.ts +87 -0
- package/dist/runtime/execution/tool-result-storage.js +274 -0
- package/dist/runtime/hooks/context-compression.d.ts +61 -0
- package/dist/runtime/hooks/context-compression.js +334 -0
- package/dist/runtime/hooks/hook-registry.d.ts +12 -0
- package/dist/runtime/hooks/hook-registry.js +61 -0
- package/dist/runtime/hooks/hook-registry.test.d.ts +1 -0
- package/dist/runtime/hooks/hook-registry.test.js +51 -0
- package/dist/runtime/hooks/index.d.ts +4 -0
- package/dist/runtime/hooks/index.js +5 -0
- package/dist/runtime/hooks/memory-hooks.d.ts +75 -0
- package/dist/runtime/hooks/memory-hooks.js +356 -0
- package/dist/runtime/hooks/skill-recall-hooks.d.ts +37 -0
- package/dist/runtime/hooks/skill-recall-hooks.js +263 -0
- package/dist/runtime/hooks/skill-recall-hooks.test.d.ts +1 -0
- package/dist/runtime/hooks/skill-recall-hooks.test.js +52 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.js +13 -0
- package/dist/runtime/infra/acp-detector.d.ts +133 -0
- package/dist/runtime/infra/acp-detector.js +862 -0
- package/dist/runtime/infra/acp-detector.test.d.ts +1 -0
- package/dist/runtime/infra/acp-detector.test.js +164 -0
- package/dist/runtime/infra/acp-host-handler.d.ts +31 -0
- package/dist/runtime/infra/acp-host-handler.js +123 -0
- package/dist/runtime/infra/acp-host-handler.test.d.ts +1 -0
- package/dist/runtime/infra/acp-host-handler.test.js +64 -0
- package/dist/runtime/infra/acp-protocol-adapter.d.ts +146 -0
- package/dist/runtime/infra/acp-protocol-adapter.js +382 -0
- package/dist/runtime/infra/acp-protocol-adapter.test.d.ts +1 -0
- package/dist/runtime/infra/acp-protocol-adapter.test.js +180 -0
- package/dist/runtime/infra/acp-usage-tracker.d.ts +46 -0
- package/dist/runtime/infra/acp-usage-tracker.js +92 -0
- package/dist/runtime/infra/agent-catalog.test.d.ts +1 -0
- package/dist/runtime/infra/agent-catalog.test.js +174 -0
- package/dist/runtime/infra/agent-config-store.d.ts +30 -0
- package/dist/runtime/infra/agent-config-store.js +115 -0
- package/dist/runtime/infra/agent-install-runner.d.ts +57 -0
- package/dist/runtime/infra/agent-install-runner.js +123 -0
- package/dist/runtime/infra/agent-install-runner.test.d.ts +1 -0
- package/dist/runtime/infra/agent-install-runner.test.js +103 -0
- package/dist/runtime/infra/agent-paths.d.ts +67 -0
- package/dist/runtime/infra/agent-paths.js +167 -0
- package/dist/runtime/infra/agent-paths.test.d.ts +1 -0
- package/dist/runtime/infra/agent-paths.test.js +49 -0
- package/dist/runtime/infra/agent-process.d.ts +299 -0
- package/dist/runtime/infra/agent-process.js +1318 -0
- package/dist/runtime/infra/background-tasks.d.ts +115 -0
- package/dist/runtime/infra/background-tasks.js +249 -0
- package/dist/runtime/infra/background-tasks.test.d.ts +1 -0
- package/dist/runtime/infra/background-tasks.test.js +242 -0
- package/dist/runtime/infra/checkpoint-backend.d.ts +8 -0
- package/dist/runtime/infra/checkpoint-backend.js +110 -0
- package/dist/runtime/infra/cleanup-registry.d.ts +23 -0
- package/dist/runtime/infra/cleanup-registry.js +34 -0
- package/dist/runtime/infra/default-path-service.d.ts +33 -0
- package/dist/runtime/infra/default-path-service.js +76 -0
- package/dist/runtime/infra/default-path-service.test.d.ts +1 -0
- package/dist/runtime/infra/default-path-service.test.js +31 -0
- package/dist/runtime/infra/disk-storage.d.ts +20 -0
- package/dist/runtime/infra/disk-storage.js +64 -0
- package/dist/runtime/infra/external-agent-approvals.d.ts +41 -0
- package/dist/runtime/infra/external-agent-approvals.js +101 -0
- package/dist/runtime/infra/external-agent-approvals.test.d.ts +1 -0
- package/dist/runtime/infra/external-agent-approvals.test.js +99 -0
- package/dist/runtime/infra/external-agent-pool.d.ts +54 -0
- package/dist/runtime/infra/external-agent-pool.js +0 -0
- package/dist/runtime/infra/external-agent-pool.test.d.ts +1 -0
- package/dist/runtime/infra/external-agent-pool.test.js +102 -0
- package/dist/runtime/infra/file-watcher.d.ts +72 -0
- package/dist/runtime/infra/file-watcher.js +154 -0
- package/dist/runtime/infra/index.d.ts +19 -0
- package/dist/runtime/infra/index.js +19 -0
- package/dist/runtime/infra/key-injection.test.d.ts +1 -0
- package/dist/runtime/infra/key-injection.test.js +88 -0
- package/dist/runtime/infra/key-pool.d.ts +122 -0
- package/dist/runtime/infra/key-pool.js +378 -0
- package/dist/runtime/infra/key-pool.test.d.ts +1 -0
- package/dist/runtime/infra/key-pool.test.js +36 -0
- package/dist/runtime/infra/llmrouter-catalog.d.ts +84 -0
- package/dist/runtime/infra/llmrouter-catalog.js +287 -0
- package/dist/runtime/infra/llmrouter-catalog.test.d.ts +1 -0
- package/dist/runtime/infra/llmrouter-catalog.test.js +80 -0
- package/dist/runtime/infra/llmrouter-zero-config.test.d.ts +1 -0
- package/dist/runtime/infra/llmrouter-zero-config.test.js +64 -0
- package/dist/runtime/infra/mcp-bridge.d.ts +166 -0
- package/dist/runtime/infra/mcp-bridge.js +161 -0
- package/dist/runtime/infra/media-persistence.d.ts +87 -0
- package/dist/runtime/infra/media-persistence.js +278 -0
- package/dist/runtime/infra/migrate-project-skills.d.ts +21 -0
- package/dist/runtime/infra/migrate-project-skills.js +131 -0
- package/dist/runtime/infra/migrate-project-skills.test.d.ts +1 -0
- package/dist/runtime/infra/migrate-project-skills.test.js +69 -0
- package/dist/runtime/infra/model-id-translator.d.ts +22 -0
- package/dist/runtime/infra/model-id-translator.js +74 -0
- package/dist/runtime/infra/model-registry.d.ts +148 -0
- package/dist/runtime/infra/model-registry.js +529 -0
- package/dist/runtime/infra/model-registry.test.d.ts +1 -0
- package/dist/runtime/infra/model-registry.test.js +253 -0
- package/dist/runtime/infra/process-config-port.d.ts +2 -0
- package/dist/runtime/infra/process-config-port.js +5 -0
- package/dist/runtime/infra/profile-storage.test.d.ts +1 -0
- package/dist/runtime/infra/profile-storage.test.js +41 -0
- package/dist/runtime/infra/project-instructions-store.d.ts +30 -0
- package/dist/runtime/infra/project-instructions-store.js +124 -0
- package/dist/runtime/infra/project-skill-manifest.d.ts +32 -0
- package/dist/runtime/infra/project-skill-manifest.js +160 -0
- package/dist/runtime/infra/project-skill-manifest.test.d.ts +1 -0
- package/dist/runtime/infra/project-skill-manifest.test.js +42 -0
- package/dist/runtime/infra/project-store.d.ts +48 -0
- package/dist/runtime/infra/project-store.js +284 -0
- package/dist/runtime/infra/secure-storage.d.ts +81 -0
- package/dist/runtime/infra/secure-storage.js +117 -0
- package/dist/runtime/infra/skill-injector.d.ts +59 -0
- package/dist/runtime/infra/skill-injector.js +155 -0
- package/dist/runtime/infra/skill-injector.test.d.ts +1 -0
- package/dist/runtime/infra/skill-injector.test.js +9 -0
- package/dist/runtime/infra/skill-resolver.d.ts +51 -0
- package/dist/runtime/infra/skill-resolver.js +109 -0
- package/dist/runtime/infra/skill-resolver.test.d.ts +1 -0
- package/dist/runtime/infra/skill-resolver.test.js +72 -0
- package/dist/runtime/infra/task-runtime.d.ts +71 -0
- package/dist/runtime/infra/task-runtime.js +181 -0
- package/dist/runtime/infra/token-budget.d.ts +92 -0
- package/dist/runtime/infra/token-budget.js +170 -0
- package/dist/runtime/infra/worktree-backend.d.ts +86 -0
- package/dist/runtime/infra/worktree-backend.js +522 -0
- package/dist/runtime/memory/categories.d.ts +5 -0
- package/dist/runtime/memory/categories.js +4 -0
- package/dist/runtime/memory/find-relevant-memories.d.ts +70 -0
- package/dist/runtime/memory/find-relevant-memories.js +270 -0
- package/dist/runtime/memory/implicit-extraction.d.ts +58 -0
- package/dist/runtime/memory/implicit-extraction.js +187 -0
- package/dist/runtime/memory/recall-category-filter.d.ts +54 -0
- package/dist/runtime/memory/recall-category-filter.js +215 -0
- package/dist/runtime/permission-model.d.ts +19 -0
- package/dist/runtime/permission-model.js +24 -0
- package/dist/runtime/permission-model.test.d.ts +1 -0
- package/dist/runtime/permission-model.test.js +32 -0
- package/dist/runtime/pet/hatch-pet-runner.d.ts +18 -0
- package/dist/runtime/pet/hatch-pet-runner.js +120 -0
- package/dist/runtime/pet/hatch-pet-runner.test.d.ts +1 -0
- package/dist/runtime/pet/hatch-pet-runner.test.js +28 -0
- package/dist/runtime/pet/index.d.ts +18 -0
- package/dist/runtime/pet/index.js +9 -0
- package/dist/runtime/pet/pet-community-assets.d.ts +13 -0
- package/dist/runtime/pet/pet-community-assets.js +106 -0
- package/dist/runtime/pet/pet-file-loader.d.ts +5 -0
- package/dist/runtime/pet/pet-file-loader.js +11 -0
- package/dist/runtime/pet/pet-growth-engine.d.ts +2 -0
- package/dist/runtime/pet/pet-growth-engine.js +1 -0
- package/dist/runtime/pet/pet-profile-service.d.ts +91 -0
- package/dist/runtime/pet/pet-profile-service.js +296 -0
- package/dist/runtime/pet/pet-profile-service.test.d.ts +1 -0
- package/dist/runtime/pet/pet-profile-service.test.js +171 -0
- package/dist/runtime/pet/pet-reaction-engine.d.ts +11 -0
- package/dist/runtime/pet/pet-reaction-engine.js +11 -0
- package/dist/runtime/pet/pet-reaction-engine.test.d.ts +1 -0
- package/dist/runtime/pet/pet-reaction-engine.test.js +12 -0
- package/dist/runtime/pet/pet-soul-service.d.ts +21 -0
- package/dist/runtime/pet/pet-soul-service.js +63 -0
- package/dist/runtime/pet/pet-soul-service.test.d.ts +1 -0
- package/dist/runtime/pet/pet-soul-service.test.js +115 -0
- package/dist/runtime/pet/pet-types.d.ts +1 -0
- package/dist/runtime/pet/pet-types.js +1 -0
- package/dist/runtime/pet/petdex-asset.d.ts +32 -0
- package/dist/runtime/pet/petdex-asset.js +242 -0
- package/dist/runtime/pet/petdex-asset.test.d.ts +1 -0
- package/dist/runtime/pet/petdex-asset.test.js +257 -0
- package/dist/runtime/pet/petdex-forge-service.d.ts +19 -0
- package/dist/runtime/pet/petdex-forge-service.js +820 -0
- package/dist/runtime/pet/petdex-forge-service.test.d.ts +1 -0
- package/dist/runtime/pet/petdex-forge-service.test.js +142 -0
- package/dist/runtime/ports/agent-execution-contracts.d.ts +182 -0
- package/dist/runtime/ports/agent-execution-contracts.js +1 -0
- package/dist/runtime/ports/agent-runtime-ports.d.ts +76 -0
- package/dist/runtime/ports/agent-runtime-ports.js +1 -0
- package/dist/runtime/ports/checkpoint-contracts.d.ts +19 -0
- package/dist/runtime/ports/checkpoint-contracts.js +1 -0
- package/dist/runtime/ports/config-port.d.ts +4 -0
- package/dist/runtime/ports/config-port.js +5 -0
- package/dist/runtime/ports/index.d.ts +19 -0
- package/dist/runtime/ports/index.js +5 -0
- package/dist/runtime/ports/memory-provider.d.ts +181 -0
- package/dist/runtime/ports/memory-provider.js +1 -0
- package/dist/runtime/ports/memory-recall-source.d.ts +3 -0
- package/dist/runtime/ports/memory-recall-source.js +1 -0
- package/dist/runtime/ports/memory-writer.d.ts +21 -0
- package/dist/runtime/ports/memory-writer.js +1 -0
- package/dist/runtime/ports/model-transport-contracts.d.ts +125 -0
- package/dist/runtime/ports/model-transport-contracts.js +9 -0
- package/dist/runtime/ports/path-service.d.ts +31 -0
- package/dist/runtime/ports/path-service.js +1 -0
- package/dist/runtime/ports/permission-contracts.d.ts +128 -0
- package/dist/runtime/ports/permission-contracts.js +5 -0
- package/dist/runtime/ports/project-memory-store.d.ts +44 -0
- package/dist/runtime/ports/project-memory-store.js +1 -0
- package/dist/runtime/ports/source-provider.d.ts +39 -0
- package/dist/runtime/ports/source-provider.js +4 -0
- package/dist/runtime/ports/tool-call-contracts.d.ts +16 -0
- package/dist/runtime/ports/tool-call-contracts.js +13 -0
- package/dist/runtime/ports/tool-contracts.d.ts +87 -0
- package/dist/runtime/ports/tool-contracts.js +3 -0
- package/dist/runtime/ports/tool-risk.d.ts +7 -0
- package/dist/runtime/ports/tool-risk.js +16 -0
- package/dist/runtime/ports/web-search-contracts.d.ts +21 -0
- package/dist/runtime/ports/web-search-contracts.js +1 -0
- package/dist/runtime/ports/worktree-contracts.d.ts +22 -0
- package/dist/runtime/ports/worktree-contracts.js +1 -0
- package/dist/runtime/prompt/environment-context.d.ts +60 -0
- package/dist/runtime/prompt/environment-context.js +410 -0
- package/dist/runtime/prompt/environment-context.test.d.ts +1 -0
- package/dist/runtime/prompt/environment-context.test.js +75 -0
- package/dist/runtime/prompt/fresh-workspace-evidence.d.ts +21 -0
- package/dist/runtime/prompt/fresh-workspace-evidence.js +224 -0
- package/dist/runtime/prompt/fresh-workspace-evidence.test.d.ts +1 -0
- package/dist/runtime/prompt/fresh-workspace-evidence.test.js +163 -0
- package/dist/runtime/prompt/index.d.ts +5 -0
- package/dist/runtime/prompt/index.js +6 -0
- package/dist/runtime/prompt/instruction-loader.d.ts +70 -0
- package/dist/runtime/prompt/instruction-loader.js +515 -0
- package/dist/runtime/prompt/instruction-loader.test.d.ts +1 -0
- package/dist/runtime/prompt/instruction-loader.test.js +64 -0
- package/dist/runtime/prompt/prompt-policy.d.ts +12 -0
- package/dist/runtime/prompt/prompt-policy.js +40 -0
- package/dist/runtime/prompt/system-prompt-sections.d.ts +65 -0
- package/dist/runtime/prompt/system-prompt-sections.js +93 -0
- package/dist/runtime/prompt/task-domain.d.ts +82 -0
- package/dist/runtime/prompt/task-domain.js +248 -0
- package/dist/runtime/sandbox/index.d.ts +2 -0
- package/dist/runtime/sandbox/index.js +2 -0
- package/dist/runtime/sandbox/skill-sandbox.d.ts +53 -0
- package/dist/runtime/sandbox/skill-sandbox.js +93 -0
- package/dist/runtime/sandbox/skill-sandbox.test.d.ts +1 -0
- package/dist/runtime/sandbox/skill-sandbox.test.js +172 -0
- package/dist/runtime/sandbox/windows-skill-sandbox.d.ts +78 -0
- package/dist/runtime/sandbox/windows-skill-sandbox.js +128 -0
- package/dist/runtime/session/group-session-split.d.ts +38 -0
- package/dist/runtime/session/group-session-split.js +99 -0
- package/dist/runtime/session/index.d.ts +4 -0
- package/dist/runtime/session/index.js +5 -0
- package/dist/runtime/session/session-catalog.d.ts +4 -0
- package/dist/runtime/session/session-catalog.js +59 -0
- package/dist/runtime/session/session-locator.d.ts +26 -0
- package/dist/runtime/session/session-locator.js +91 -0
- package/dist/runtime/session/session-locator.test.d.ts +1 -0
- package/dist/runtime/session/session-locator.test.js +59 -0
- package/dist/runtime/session/session-metadata-store.d.ts +8 -0
- package/dist/runtime/session/session-metadata-store.js +167 -0
- package/dist/runtime/session/session-paths.d.ts +9 -0
- package/dist/runtime/session/session-paths.js +27 -0
- package/dist/runtime/session/session-persistence.d.ts +16 -0
- package/dist/runtime/session/session-persistence.js +16 -0
- package/dist/runtime/session/session-persistence.test.d.ts +1 -0
- package/dist/runtime/session/session-persistence.test.js +237 -0
- package/dist/runtime/session/session-resume.d.ts +4 -0
- package/dist/runtime/session/session-resume.js +60 -0
- package/dist/runtime/session/session-schema.d.ts +10 -0
- package/dist/runtime/session/session-schema.js +35 -0
- package/dist/runtime/session/session-state.d.ts +96 -0
- package/dist/runtime/session/session-state.js +180 -0
- package/dist/runtime/session/session-summary.d.ts +5 -0
- package/dist/runtime/session/session-summary.js +67 -0
- package/dist/runtime/session/session-transcript-store.d.ts +13 -0
- package/dist/runtime/session/session-transcript-store.js +109 -0
- package/dist/runtime/session/session-types.d.ts +77 -0
- package/dist/runtime/session/session-types.js +1 -0
- package/dist/runtime/session/session-write-queue.d.ts +2 -0
- package/dist/runtime/session/session-write-queue.js +48 -0
- package/dist/runtime/tasks/task-types.d.ts +166 -0
- package/dist/runtime/tasks/task-types.js +64 -0
- package/dist/server/search-svc.d.ts +1 -0
- package/dist/server/search-svc.js +113 -0
- package/dist/skills/index.d.ts +6 -0
- package/dist/skills/index.js +5 -0
- package/dist/skills/mcp/index.d.ts +1 -0
- package/dist/skills/mcp/index.js +3 -0
- package/dist/skills/mcp/mcp-manager.d.ts +75 -0
- package/dist/skills/mcp/mcp-manager.js +358 -0
- package/dist/skills/mcp/mcp-tool-metadata.d.ts +18 -0
- package/dist/skills/mcp/mcp-tool-metadata.js +48 -0
- package/dist/skills/memory/categories.d.ts +1 -0
- package/dist/skills/memory/categories.js +1 -0
- package/dist/skills/memory/find-relevant-memories.d.ts +1 -0
- package/dist/skills/memory/find-relevant-memories.js +1 -0
- package/dist/skills/memory/implicit-extraction.d.ts +1 -0
- package/dist/skills/memory/implicit-extraction.js +1 -0
- package/dist/skills/memory/local-embedding.d.ts +80 -0
- package/dist/skills/memory/local-embedding.js +210 -0
- package/dist/skills/memory/local-memory-provider.d.ts +257 -0
- package/dist/skills/memory/local-memory-provider.js +486 -0
- package/dist/skills/memory/local-store-records.d.ts +184 -0
- package/dist/skills/memory/local-store-records.js +1 -0
- package/dist/skills/memory/local-store.d.ts +479 -0
- package/dist/skills/memory/local-store.js +1022 -0
- package/dist/skills/memory/memdir.d.ts +93 -0
- package/dist/skills/memory/memdir.js +530 -0
- package/dist/skills/memory/memory-attachment-store.d.ts +62 -0
- package/dist/skills/memory/memory-attachment-store.js +0 -0
- package/dist/skills/memory/memory-consolidation.d.ts +43 -0
- package/dist/skills/memory/memory-consolidation.js +462 -0
- package/dist/skills/memory/memory-db-path.d.ts +13 -0
- package/dist/skills/memory/memory-db-path.js +27 -0
- package/dist/skills/memory/memory-embedding-config.d.ts +31 -0
- package/dist/skills/memory/memory-embedding-config.js +66 -0
- package/dist/skills/memory/memory-provider-factory.d.ts +33 -0
- package/dist/skills/memory/memory-provider-factory.js +79 -0
- package/dist/skills/memory/memory-tool.d.ts +85 -0
- package/dist/skills/memory/memory-tool.js +326 -0
- package/dist/skills/memory/memory-vector-utils.d.ts +2 -0
- package/dist/skills/memory/memory-vector-utils.js +19 -0
- package/dist/skills/memory/recall-category-filter.d.ts +1 -0
- package/dist/skills/memory/recall-category-filter.js +1 -0
- package/dist/skills/memory/sqlite-memory-mappers.d.ts +6 -0
- package/dist/skills/memory/sqlite-memory-mappers.js +104 -0
- package/dist/skills/memory/sqlite-memory-schema.d.ts +3 -0
- package/dist/skills/memory/sqlite-memory-schema.js +152 -0
- package/dist/skills/permissions/bash-classifier.d.ts +30 -0
- package/dist/skills/permissions/bash-classifier.js +174 -0
- package/dist/skills/permissions/classifier-cache.d.ts +51 -0
- package/dist/skills/permissions/classifier-cache.js +103 -0
- package/dist/skills/permissions/community-sandbox-policy.d.ts +3 -0
- package/dist/skills/permissions/community-sandbox-policy.js +233 -0
- package/dist/skills/permissions/community-sandbox-red-team-cli.d.ts +7 -0
- package/dist/skills/permissions/community-sandbox-red-team-cli.js +43 -0
- package/dist/skills/permissions/community-sandbox-red-team.d.ts +32 -0
- package/dist/skills/permissions/community-sandbox-red-team.js +221 -0
- package/dist/skills/permissions/denial-audit-log.d.ts +52 -0
- package/dist/skills/permissions/denial-audit-log.js +80 -0
- package/dist/skills/permissions/denial-tracking.d.ts +42 -0
- package/dist/skills/permissions/denial-tracking.js +60 -0
- package/dist/skills/permissions/group-security-policy.d.ts +15 -0
- package/dist/skills/permissions/group-security-policy.js +60 -0
- package/dist/skills/permissions/hook-runner.d.ts +120 -0
- package/dist/skills/permissions/hook-runner.js +545 -0
- package/dist/skills/permissions/index.d.ts +13 -0
- package/dist/skills/permissions/index.js +8 -0
- package/dist/skills/permissions/operation-classifier.d.ts +43 -0
- package/dist/skills/permissions/operation-classifier.js +251 -0
- package/dist/skills/permissions/permission-classifier.d.ts +41 -0
- package/dist/skills/permissions/permission-classifier.js +186 -0
- package/dist/skills/permissions/rule-engine.d.ts +49 -0
- package/dist/skills/permissions/rule-engine.js +285 -0
- package/dist/skills/permissions/settings-watcher.d.ts +19 -0
- package/dist/skills/permissions/settings-watcher.js +121 -0
- package/dist/skills/permissions/types.d.ts +2 -0
- package/dist/skills/permissions/types.js +1 -0
- package/dist/skills/plugins/index.d.ts +2 -0
- package/dist/skills/plugins/index.js +3 -0
- package/dist/skills/plugins/plugin-api.d.ts +38 -0
- package/dist/skills/plugins/plugin-api.js +18 -0
- package/dist/skills/plugins/plugin-loader.d.ts +57 -0
- package/dist/skills/plugins/plugin-loader.js +254 -0
- package/dist/skills/plugins/plugin-marketplace.d.ts +61 -0
- package/dist/skills/plugins/plugin-marketplace.js +229 -0
- package/dist/skills/portable-tool.d.ts +165 -0
- package/dist/skills/portable-tool.js +34 -0
- package/dist/skills/skill-system/skill-frontmatter.d.ts +19 -0
- package/dist/skills/skill-system/skill-frontmatter.js +344 -0
- package/dist/skills/skill-system/skill-guard.d.ts +23 -0
- package/dist/skills/skill-system/skill-guard.js +229 -0
- package/dist/skills/skill-system/skill-lifecycle.d.ts +93 -0
- package/dist/skills/skill-system/skill-lifecycle.js +236 -0
- package/dist/skills/skill-system/skill-source.d.ts +38 -0
- package/dist/skills/skill-system/skill-source.js +75 -0
- package/dist/skills/skill-system/skill-types.d.ts +140 -0
- package/dist/skills/skill-system/skill-types.js +6 -0
- package/dist/skills/skill-system/skill-validation.d.ts +29 -0
- package/dist/skills/skill-system/skill-validation.js +154 -0
- package/dist/skills/tool-access.d.ts +30 -0
- package/dist/skills/tool-access.js +58 -0
- package/dist/skills/tools/agent-tool.d.ts +102 -0
- package/dist/skills/tools/agent-tool.js +159 -0
- package/dist/skills/tools/ask-user-tool.d.ts +80 -0
- package/dist/skills/tools/ask-user-tool.js +121 -0
- package/dist/skills/tools/brief-tool.d.ts +74 -0
- package/dist/skills/tools/brief-tool.js +95 -0
- package/dist/skills/tools/browser-tool.d.ts +114 -0
- package/dist/skills/tools/browser-tool.js +160 -0
- package/dist/skills/tools/checkpoint-tool.d.ts +66 -0
- package/dist/skills/tools/checkpoint-tool.js +102 -0
- package/dist/skills/tools/config-tool.d.ts +61 -0
- package/dist/skills/tools/config-tool.js +123 -0
- package/dist/skills/tools/cron-tool.d.ts +96 -0
- package/dist/skills/tools/cron-tool.js +165 -0
- package/dist/skills/tools/edit-tool.d.ts +43 -0
- package/dist/skills/tools/edit-tool.js +72 -0
- package/dist/skills/tools/exec-tool.d.ts +117 -0
- package/dist/skills/tools/exec-tool.js +354 -0
- package/dist/skills/tools/file-management-tool.d.ts +90 -0
- package/dist/skills/tools/file-management-tool.js +166 -0
- package/dist/skills/tools/image-generate-tool.d.ts +74 -0
- package/dist/skills/tools/image-generate-tool.js +91 -0
- package/dist/skills/tools/instructions-tool.d.ts +65 -0
- package/dist/skills/tools/instructions-tool.js +209 -0
- package/dist/skills/tools/lsp-tool.d.ts +153 -0
- package/dist/skills/tools/lsp-tool.js +230 -0
- package/dist/skills/tools/media-cancel-tool.d.ts +30 -0
- package/dist/skills/tools/media-cancel-tool.js +46 -0
- package/dist/skills/tools/monitor-tool.d.ts +113 -0
- package/dist/skills/tools/monitor-tool.js +129 -0
- package/dist/skills/tools/music-generate-tool.d.ts +80 -0
- package/dist/skills/tools/music-generate-tool.js +98 -0
- package/dist/skills/tools/notebook-edit-tool.d.ts +15 -0
- package/dist/skills/tools/notebook-edit-tool.js +206 -0
- package/dist/skills/tools/patch-tool.d.ts +52 -0
- package/dist/skills/tools/patch-tool.js +556 -0
- package/dist/skills/tools/petdex-create-tool.d.ts +47 -0
- package/dist/skills/tools/petdex-create-tool.js +95 -0
- package/dist/skills/tools/plan-mode-tool.d.ts +98 -0
- package/dist/skills/tools/plan-mode-tool.js +164 -0
- package/dist/skills/tools/read-tool.d.ts +51 -0
- package/dist/skills/tools/read-tool.js +88 -0
- package/dist/skills/tools/search-tool.d.ts +112 -0
- package/dist/skills/tools/search-tool.js +226 -0
- package/dist/skills/tools/shell/bash-provider.d.ts +26 -0
- package/dist/skills/tools/shell/bash-provider.js +125 -0
- package/dist/skills/tools/shell/command-classification.d.ts +44 -0
- package/dist/skills/tools/shell/command-classification.js +119 -0
- package/dist/skills/tools/shell/command-semantics.d.ts +14 -0
- package/dist/skills/tools/shell/command-semantics.js +87 -0
- package/dist/skills/tools/shell/destructive-command-warning.d.ts +10 -0
- package/dist/skills/tools/shell/destructive-command-warning.js +80 -0
- package/dist/skills/tools/shell/exec-permissions.d.ts +52 -0
- package/dist/skills/tools/shell/exec-permissions.js +277 -0
- package/dist/skills/tools/shell/index.d.ts +18 -0
- package/dist/skills/tools/shell/index.js +18 -0
- package/dist/skills/tools/shell/powershell-provider.d.ts +15 -0
- package/dist/skills/tools/shell/powershell-provider.js +80 -0
- package/dist/skills/tools/shell/sandbox/helper-resolver.d.ts +7 -0
- package/dist/skills/tools/shell/sandbox/helper-resolver.js +20 -0
- package/dist/skills/tools/shell/sandbox/landlock-argv.d.ts +6 -0
- package/dist/skills/tools/shell/sandbox/landlock-argv.js +13 -0
- package/dist/skills/tools/shell/sandbox/platform.d.ts +3 -0
- package/dist/skills/tools/shell/sandbox/platform.js +13 -0
- package/dist/skills/tools/shell/sandbox/sandbox-launcher.d.ts +15 -0
- package/dist/skills/tools/shell/sandbox/sandbox-launcher.js +59 -0
- package/dist/skills/tools/shell/sandbox/sandbox-scope.d.ts +6 -0
- package/dist/skills/tools/shell/sandbox/sandbox-scope.js +17 -0
- package/dist/skills/tools/shell/sandbox/sandbox-types.d.ts +47 -0
- package/dist/skills/tools/shell/sandbox/sandbox-types.js +1 -0
- package/dist/skills/tools/shell/sandbox/seatbelt-profile.d.ts +6 -0
- package/dist/skills/tools/shell/sandbox/seatbelt-profile.js +28 -0
- package/dist/skills/tools/shell/shell-command.d.ts +54 -0
- package/dist/skills/tools/shell/shell-command.js +347 -0
- package/dist/skills/tools/shell/shell-exec.d.ts +38 -0
- package/dist/skills/tools/shell/shell-exec.js +202 -0
- package/dist/skills/tools/shell/shell-provider.d.ts +85 -0
- package/dist/skills/tools/shell/shell-provider.js +38 -0
- package/dist/skills/tools/shell/subprocess-env.d.ts +6 -0
- package/dist/skills/tools/shell/subprocess-env.js +87 -0
- package/dist/skills/tools/shell/task-output.d.ts +44 -0
- package/dist/skills/tools/shell/task-output.js +137 -0
- package/dist/skills/tools/skill-tool.d.ts +106 -0
- package/dist/skills/tools/skill-tool.js +265 -0
- package/dist/skills/tools/sleep-tool.d.ts +49 -0
- package/dist/skills/tools/sleep-tool.js +81 -0
- package/dist/skills/tools/structured-output-tool.d.ts +116 -0
- package/dist/skills/tools/structured-output-tool.js +176 -0
- package/dist/skills/tools/stt-tool.d.ts +33 -0
- package/dist/skills/tools/stt-tool.js +58 -0
- package/dist/skills/tools/task-tool.d.ts +125 -0
- package/dist/skills/tools/task-tool.js +390 -0
- package/dist/skills/tools/team-tool.d.ts +156 -0
- package/dist/skills/tools/team-tool.js +173 -0
- package/dist/skills/tools/three-d-generate-tool.d.ts +46 -0
- package/dist/skills/tools/three-d-generate-tool.js +66 -0
- package/dist/skills/tools/tool-search-tool.d.ts +62 -0
- package/dist/skills/tools/tool-search-tool.js +187 -0
- package/dist/skills/tools/tts-tool.d.ts +50 -0
- package/dist/skills/tools/tts-tool.js +58 -0
- package/dist/skills/tools/video-edit-tool.d.ts +72 -0
- package/dist/skills/tools/video-edit-tool.js +84 -0
- package/dist/skills/tools/video-generate-tool.d.ts +162 -0
- package/dist/skills/tools/video-generate-tool.js +178 -0
- package/dist/skills/tools/video-merge-tool.d.ts +105 -0
- package/dist/skills/tools/video-merge-tool.js +95 -0
- package/dist/skills/tools/video-upscale-tool.d.ts +45 -0
- package/dist/skills/tools/video-upscale-tool.js +57 -0
- package/dist/skills/tools/voice-clone-tool.d.ts +40 -0
- package/dist/skills/tools/voice-clone-tool.js +58 -0
- package/dist/skills/tools/web-answer-tool.d.ts +27 -0
- package/dist/skills/tools/web-answer-tool.js +124 -0
- package/dist/skills/tools/web-fetch-tool.d.ts +80 -0
- package/dist/skills/tools/web-fetch-tool.js +95 -0
- package/dist/skills/tools/web-research-tool.d.ts +48 -0
- package/dist/skills/tools/web-research-tool.js +254 -0
- package/dist/skills/tools/web-search-tool.d.ts +46 -0
- package/dist/skills/tools/web-search-tool.js +95 -0
- package/dist/skills/tools/workflow-tool.d.ts +45 -0
- package/dist/skills/tools/workflow-tool.js +113 -0
- package/dist/skills/tools/worktree-tool.d.ts +69 -0
- package/dist/skills/tools/worktree-tool.js +147 -0
- package/dist/skills/tools/write-tool.d.ts +45 -0
- package/dist/skills/tools/write-tool.js +83 -0
- package/dist/skills/tools.d.ts +45 -0
- package/dist/skills/tools.js +165 -0
- package/dist/skills/web-search/brave-source.d.ts +2 -0
- package/dist/skills/web-search/brave-source.js +36 -0
- package/dist/skills/web-search/crawl4ai-extractor.d.ts +15 -0
- package/dist/skills/web-search/crawl4ai-extractor.js +92 -0
- package/dist/skills/web-search/embedding-rerank.d.ts +13 -0
- package/dist/skills/web-search/embedding-rerank.js +44 -0
- package/dist/skills/web-search/exa-source.d.ts +2 -0
- package/dist/skills/web-search/exa-source.js +43 -0
- package/dist/skills/web-search/multi-source-backend.d.ts +23 -0
- package/dist/skills/web-search/multi-source-backend.js +99 -0
- package/dist/skills/web-search/redis-source-cache.d.ts +6 -0
- package/dist/skills/web-search/redis-source-cache.js +44 -0
- package/dist/skills/web-search/search-svc-source.d.ts +4 -0
- package/dist/skills/web-search/search-svc-source.js +64 -0
- package/dist/skills/web-search/searxng-source.d.ts +2 -0
- package/dist/skills/web-search/searxng-source.js +91 -0
- package/dist/skills/web-search/serper-source.d.ts +2 -0
- package/dist/skills/web-search/serper-source.js +33 -0
- package/dist/skills/web-search/source-factory.d.ts +5 -0
- package/dist/skills/web-search/source-factory.js +15 -0
- package/dist/skills/web-search/stability.d.ts +26 -0
- package/dist/skills/web-search/stability.js +57 -0
- package/dist/transport/acp-event-emitter.d.ts +21 -0
- package/dist/transport/acp-event-emitter.js +142 -0
- package/dist/transport/acp-event-emitter.test.d.ts +1 -0
- package/dist/transport/acp-event-emitter.test.js +87 -0
- package/dist/transport/acp-server.d.ts +169 -0
- package/dist/transport/acp-server.js +480 -0
- package/dist/transport/acp-server.test.d.ts +1 -0
- package/dist/transport/acp-server.test.js +230 -0
- package/dist/transport/index.d.ts +7 -0
- package/dist/transport/index.js +5 -0
- package/dist/transport/io-transport.d.ts +19 -0
- package/dist/transport/io-transport.js +8 -0
- package/package.json +2 -2
|
@@ -0,0 +1,1318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Process Manager — CC tmux-aligned subprocess isolation.
|
|
3
|
+
*
|
|
4
|
+
* Spawns team member agents as independent child processes, each with:
|
|
5
|
+
* - Own cwd (set to worktree path for git isolation)
|
|
6
|
+
* - Own stdin/stdout JSON-RPC transport
|
|
7
|
+
* - Own memory + tool context (no shared process.cwd)
|
|
8
|
+
* - Lifecycle tracking (PID, health, abort)
|
|
9
|
+
*
|
|
10
|
+
* CC does this via tmux split-pane + `claudeagent-id ...` commands.
|
|
11
|
+
* We spawn `node dist/cli.js` as child processes with JSON-RPC stdio.
|
|
12
|
+
*
|
|
13
|
+
* Reference: claude-code-haha/src/utils/swarm/spawnMultiAgent.ts
|
|
14
|
+
* Reference: claude-code-haha/src/utils/swarm/spawnUtils.ts
|
|
15
|
+
*/
|
|
16
|
+
import { spawn, execFile } from "node:child_process";
|
|
17
|
+
import { createInterface } from "node:readline";
|
|
18
|
+
import { resolve, join } from "node:path";
|
|
19
|
+
import { randomUUID } from "node:crypto";
|
|
20
|
+
import { createServer } from "node:net";
|
|
21
|
+
import { createWriteStream, mkdirSync } from "node:fs";
|
|
22
|
+
import { tmpdir } from "node:os";
|
|
23
|
+
import { ACP_MAX_SPAWN_RETRIES, ACP_RETRY_BACKOFF_BASE, ACP_RUNTIME_RESTART_MAX, ACP_RUNTIME_RESTART_BACKOFF_BASE, } from "../config/tunable-defaults.js";
|
|
24
|
+
import { AcpProtocolAdapter, asAuthRequiredError } from "./acp-protocol-adapter.js";
|
|
25
|
+
import { createAcpHostHandler } from "./acp-host-handler.js";
|
|
26
|
+
import { AcpUsageTracker } from "./acp-usage-tracker.js";
|
|
27
|
+
import { ACP_BACKENDS } from "./acp-detector.js";
|
|
28
|
+
import { buildAgentRpcMeta } from "../../protocol/wire/index.js";
|
|
29
|
+
let rpcIdCounter = 1;
|
|
30
|
+
function buildRpcRequest(method, params) {
|
|
31
|
+
return { jsonrpc: "2.0", id: rpcIdCounter++, method, params, meta: buildAgentRpcMeta(method) };
|
|
32
|
+
}
|
|
33
|
+
// ── Env Var Forwarding (CC spawnUtils parity) ───────────────
|
|
34
|
+
/** Environment variables forwarded to child agents (CC getEnvVarInheritanceList parity). */
|
|
35
|
+
const FORWARDED_ENV_KEYS = [
|
|
36
|
+
"NODE_ENV",
|
|
37
|
+
"HOME",
|
|
38
|
+
"PATH",
|
|
39
|
+
"TERM",
|
|
40
|
+
// LLM config
|
|
41
|
+
"OPENAI_API_KEY",
|
|
42
|
+
"OPENAI_BASE_URL",
|
|
43
|
+
"ANTHROPIC_API_KEY",
|
|
44
|
+
"ANTHROPIC_BASE_URL",
|
|
45
|
+
// llmrouter model catalog — without these a member subprocess cannot reach the
|
|
46
|
+
// catalog ("无法连接 llmrouter 模型目录") and fails its first turn. Forward the
|
|
47
|
+
// parent's catalog config so the member resolves models with the same access.
|
|
48
|
+
"QLOGIC_LLMROUTER_BASE_URL",
|
|
49
|
+
"QLOGIC_LLMROUTER_ACCESS_TOKEN",
|
|
50
|
+
"QLOGIC_LLMROUTER_USER_ID",
|
|
51
|
+
"QLOGIC_LLMROUTER_INFERENCE_KEY",
|
|
52
|
+
"QLOGIC_LLMROUTER_EMBEDDING_MODEL",
|
|
53
|
+
"QLOGIC_LLMROUTER_EMBEDDING_DIMENSIONS",
|
|
54
|
+
// Proxy
|
|
55
|
+
"HTTP_PROXY",
|
|
56
|
+
"HTTPS_PROXY",
|
|
57
|
+
"NO_PROXY",
|
|
58
|
+
"http_proxy",
|
|
59
|
+
"https_proxy",
|
|
60
|
+
"no_proxy",
|
|
61
|
+
];
|
|
62
|
+
function buildChildEnv(config) {
|
|
63
|
+
const env = {};
|
|
64
|
+
// Forward selected env vars from parent
|
|
65
|
+
for (const key of FORWARDED_ENV_KEYS) {
|
|
66
|
+
if (process.env[key]) {
|
|
67
|
+
env[key] = process.env[key];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// NOTE: config.provider/model/apiKey/baseUrl are intentionally NOT mirrored into
|
|
71
|
+
// env. Internal children consume them as standing session config (pushed via
|
|
72
|
+
// session/set_config_option after session/new) — the env mirror was a dead
|
|
73
|
+
// channel nothing read, masquerading as provider pass-through.
|
|
74
|
+
// Agent identity
|
|
75
|
+
env.QLOGICAGENT_MEMBER_ID = config.memberId;
|
|
76
|
+
env.QLOGICAGENT_MEMBER_NAME = config.name;
|
|
77
|
+
if (config.agentType)
|
|
78
|
+
env.QLOGICAGENT_AGENT_TYPE = config.agentType;
|
|
79
|
+
// Merge user-provided env
|
|
80
|
+
if (config.env)
|
|
81
|
+
Object.assign(env, config.env);
|
|
82
|
+
return env;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Build LLM-related environment variables for an external ACP teammate.
|
|
86
|
+
*
|
|
87
|
+
* Priority chain:
|
|
88
|
+
* 1. Per-agent override (AgentConfig.apiKey / baseUrl)
|
|
89
|
+
* 2. Gateway proxy mode (all requests through shared gateway)
|
|
90
|
+
* 3. Inherit from qlogicagent's own env
|
|
91
|
+
*
|
|
92
|
+
* Handles the asymmetry between agents that support base URL override
|
|
93
|
+
* (can redirect to gateway) vs those that don't (only API key forwarding).
|
|
94
|
+
*/
|
|
95
|
+
export function buildLlmEnvForTeammate(agentId, agentConfig, gatewayUrl) {
|
|
96
|
+
const env = {};
|
|
97
|
+
const backend = ACP_BACKENDS[agentId];
|
|
98
|
+
const apiKeyEnvVar = backend?.apiKeyEnvVar;
|
|
99
|
+
const baseUrlEnvVar = backend?.baseUrlEnvVar;
|
|
100
|
+
const supportsBaseUrl = backend?.supportsBaseUrlOverride ?? false;
|
|
101
|
+
// 1. Per-agent override (highest priority)
|
|
102
|
+
if (agentConfig?.apiKey && apiKeyEnvVar) {
|
|
103
|
+
env[apiKeyEnvVar] = agentConfig.apiKey;
|
|
104
|
+
}
|
|
105
|
+
if (agentConfig?.baseUrl && baseUrlEnvVar && supportsBaseUrl) {
|
|
106
|
+
env[baseUrlEnvVar] = agentConfig.baseUrl;
|
|
107
|
+
}
|
|
108
|
+
// 2. Gateway proxy mode — inject if agent supports base URL and no per-agent baseUrl override
|
|
109
|
+
if (gatewayUrl && supportsBaseUrl && baseUrlEnvVar && !agentConfig?.baseUrl) {
|
|
110
|
+
env[baseUrlEnvVar] = gatewayUrl;
|
|
111
|
+
}
|
|
112
|
+
// 3. Inherit — already handled by buildChildEnv() forwarding FORWARDED_ENV_KEYS
|
|
113
|
+
// No additional work needed here.
|
|
114
|
+
// Merge per-agent custom env vars
|
|
115
|
+
if (agentConfig?.env) {
|
|
116
|
+
Object.assign(env, agentConfig.env);
|
|
117
|
+
}
|
|
118
|
+
return env;
|
|
119
|
+
}
|
|
120
|
+
// ── Error Classification & Retry ────────────────────────────
|
|
121
|
+
/** Fault severity levels for ACP agent errors. */
|
|
122
|
+
export const ACP_FAULT_LEVEL = {
|
|
123
|
+
/** Unrecoverable — agent binary missing, permission denied, etc. */
|
|
124
|
+
FATAL: "fatal",
|
|
125
|
+
/** Retriable — spawn timeout, handshake timeout, transient crash. */
|
|
126
|
+
RETRIABLE: "retriable",
|
|
127
|
+
/** Warning — non-critical issue (e.g. degraded capabilities). */
|
|
128
|
+
WARN: "warn",
|
|
129
|
+
};
|
|
130
|
+
const MAX_SPAWN_RETRIES = ACP_MAX_SPAWN_RETRIES;
|
|
131
|
+
const RETRY_BACKOFF_BASE = ACP_RETRY_BACKOFF_BASE;
|
|
132
|
+
const RUNTIME_RESTART_MAX = ACP_RUNTIME_RESTART_MAX;
|
|
133
|
+
const RUNTIME_RESTART_BACKOFF_BASE = ACP_RUNTIME_RESTART_BACKOFF_BASE;
|
|
134
|
+
function sleep(ms) {
|
|
135
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Terminate a process AND all its descendants. On Windows, child.kill() ends only the direct
|
|
139
|
+
* process, orphaning grandchildren — e.g. kimi-cli (a Python launcher) leaves its interpreter
|
|
140
|
+
* subprocesses running, which pile up across spawns and bog the machine (slow cold starts →
|
|
141
|
+
* ACP handshake timeouts). `taskkill /T` reaps the whole tree; POSIX falls back to SIGTERM→SIGKILL.
|
|
142
|
+
*/
|
|
143
|
+
function killProcessTree(child, pid) {
|
|
144
|
+
if (process.platform === "win32" && typeof pid === "number" && pid > 0) {
|
|
145
|
+
try {
|
|
146
|
+
execFile("taskkill", ["/PID", String(pid), "/T", "/F"], () => { });
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
catch { /* fall through to signal kill */ }
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
child.kill("SIGTERM");
|
|
153
|
+
setTimeout(() => { try {
|
|
154
|
+
child.kill("SIGKILL");
|
|
155
|
+
}
|
|
156
|
+
catch { /* already gone */ } }, 10_000);
|
|
157
|
+
}
|
|
158
|
+
catch { /* already gone */ }
|
|
159
|
+
}
|
|
160
|
+
// ── Agent Process Manager ───────────────────────────────────
|
|
161
|
+
/**
|
|
162
|
+
* Manages a pool of child agent processes.
|
|
163
|
+
* Each child is a `qlogicagent` subprocess using JSON-RPC over stdio.
|
|
164
|
+
*/
|
|
165
|
+
export class AgentProcessManager {
|
|
166
|
+
processes = new Map();
|
|
167
|
+
callbacks;
|
|
168
|
+
cliBinaryPath;
|
|
169
|
+
mcpBridgeScriptPath;
|
|
170
|
+
constructor(callbacks = {}) {
|
|
171
|
+
this.callbacks = callbacks;
|
|
172
|
+
// Resolve binary path: use the same dist/cli.js from our own package
|
|
173
|
+
const packageRoot = resolve(join(import.meta.url.startsWith("file://")
|
|
174
|
+
? new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/, "$1")
|
|
175
|
+
: process.cwd(), "..", // from dist/ or src/ go up
|
|
176
|
+
".."));
|
|
177
|
+
this.cliBinaryPath = join(packageRoot, "dist", "cli.js");
|
|
178
|
+
this.mcpBridgeScriptPath = join(packageRoot, "dist", "runtime", "infra", "mcp-bridge-server.js");
|
|
179
|
+
}
|
|
180
|
+
// ── Q-1 Structured Logging ──────────────────────────────
|
|
181
|
+
/** Format: [ISO] [level] [agent:id] [phase] message */
|
|
182
|
+
slog(level, agentId, phase, message) {
|
|
183
|
+
const ts = new Date().toISOString();
|
|
184
|
+
const line = `[${ts}] [${level}] [agent:${agentId}] [${phase}] ${message}`;
|
|
185
|
+
if (level === "warn") {
|
|
186
|
+
this.callbacks.log?.warn(line);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
this.callbacks.log?.info(line);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/** Spawn a child agent process in the given cwd. */
|
|
193
|
+
async spawn(config) {
|
|
194
|
+
if (this.processes.has(config.memberId)) {
|
|
195
|
+
throw new Error(`Agent process "${config.memberId}" already spawned`);
|
|
196
|
+
}
|
|
197
|
+
const log = this.callbacks.log;
|
|
198
|
+
const env = buildChildEnv(config);
|
|
199
|
+
const handle = {
|
|
200
|
+
memberId: config.memberId,
|
|
201
|
+
name: config.name,
|
|
202
|
+
pid: -1,
|
|
203
|
+
cwd: config.cwd,
|
|
204
|
+
state: "starting",
|
|
205
|
+
startedAt: Date.now(),
|
|
206
|
+
};
|
|
207
|
+
// ── ACP External Agent Path ─────────────────────────────
|
|
208
|
+
if (config.external) {
|
|
209
|
+
return this.spawnAcpAgentWithRetry(config, handle, env);
|
|
210
|
+
}
|
|
211
|
+
// ── Internal Agent Path (original) ──────────────────────
|
|
212
|
+
const args = [this.cliBinaryPath];
|
|
213
|
+
if (config.verbose)
|
|
214
|
+
args.push("--verbose");
|
|
215
|
+
this.slog("info", config.memberId, "spawn", `spawning ${config.name} in ${config.cwd}`);
|
|
216
|
+
const child = spawn(process.execPath, args, {
|
|
217
|
+
cwd: config.cwd,
|
|
218
|
+
env,
|
|
219
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
220
|
+
// Prevent child from keeping parent alive
|
|
221
|
+
detached: false,
|
|
222
|
+
});
|
|
223
|
+
handle.pid = child.pid ?? -1;
|
|
224
|
+
const pendingRpc = new Map();
|
|
225
|
+
this.processes.set(config.memberId, { handle, child, pendingRpc });
|
|
226
|
+
// Parse child stdout as line-delimited JSON-RPC
|
|
227
|
+
const rl = createInterface({ input: child.stdout, crlfDelay: Number.POSITIVE_INFINITY });
|
|
228
|
+
rl.on("line", (line) => {
|
|
229
|
+
const trimmed = line.trim();
|
|
230
|
+
if (!trimmed)
|
|
231
|
+
return;
|
|
232
|
+
try {
|
|
233
|
+
const msg = JSON.parse(trimmed);
|
|
234
|
+
const hasId = "id" in msg;
|
|
235
|
+
const hasMethod = "method" in msg && typeof msg.method === "string";
|
|
236
|
+
// Request FROM child TO parent (host) — e.g. session/request_permission.
|
|
237
|
+
if (hasId && hasMethod) {
|
|
238
|
+
this.handleChildHostRequest(config.memberId, msg);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
// Response to a pending request we sent.
|
|
242
|
+
if (hasId) {
|
|
243
|
+
const pending = pendingRpc.get(msg.id);
|
|
244
|
+
if (pending) {
|
|
245
|
+
clearTimeout(pending.timer);
|
|
246
|
+
pendingRpc.delete(msg.id);
|
|
247
|
+
const resp = msg;
|
|
248
|
+
if (resp.error) {
|
|
249
|
+
pending.reject(new Error(resp.error.message));
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
pending.resolve(resp.result);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
// Notification from child — translate ACP session/update to internal turn.* form
|
|
258
|
+
// so captureChildProgress + onNotification see the same shape as the legacy path.
|
|
259
|
+
if (hasMethod) {
|
|
260
|
+
const translated = AcpProtocolAdapter.translateNotification(msg.method, msg.params);
|
|
261
|
+
const method = translated?.method ?? msg.method;
|
|
262
|
+
const params = translated?.params ?? msg.params;
|
|
263
|
+
this.captureChildProgress(config.memberId, method, params);
|
|
264
|
+
this.callbacks.onNotification?.(config.memberId, method, params);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
this.slog("warn", config.memberId, "parse", `invalid JSON: ${trimmed.slice(0, 200)}`);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
// Capture stderr for diagnostics
|
|
272
|
+
if (child.stderr) {
|
|
273
|
+
const errRl = createInterface({ input: child.stderr, crlfDelay: Number.POSITIVE_INFINITY });
|
|
274
|
+
errRl.on("line", (line) => {
|
|
275
|
+
this.callbacks.log?.debug?.(`[${new Date().toISOString()}] [debug] [agent:${config.memberId}] [stderr] ${line}`);
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
// Handle process exit
|
|
279
|
+
child.on("exit", (code, signal) => {
|
|
280
|
+
const prev = handle.state;
|
|
281
|
+
if (prev !== "killed") {
|
|
282
|
+
handle.state = code === 0 ? "completed" : "failed";
|
|
283
|
+
}
|
|
284
|
+
handle.endedAt = Date.now();
|
|
285
|
+
if (code !== 0 && !handle.error) {
|
|
286
|
+
handle.error = `Process exited with code ${code} (signal: ${signal})`;
|
|
287
|
+
}
|
|
288
|
+
// Reject all pending RPCs
|
|
289
|
+
for (const [id, pending] of pendingRpc) {
|
|
290
|
+
clearTimeout(pending.timer);
|
|
291
|
+
pending.reject(new Error(`Agent process exited (code=${code})`));
|
|
292
|
+
pendingRpc.delete(id);
|
|
293
|
+
}
|
|
294
|
+
this.callbacks.onStateChange?.(config.memberId, handle.state);
|
|
295
|
+
this.callbacks.onExit?.(config.memberId, code, signal);
|
|
296
|
+
this.slog("info", config.memberId, "exit", `exited (code=${code}, signal=${signal})`);
|
|
297
|
+
});
|
|
298
|
+
child.on("error", (err) => {
|
|
299
|
+
handle.state = "failed";
|
|
300
|
+
handle.error = err.message;
|
|
301
|
+
handle.endedAt = Date.now();
|
|
302
|
+
this.callbacks.onStateChange?.(config.memberId, "failed");
|
|
303
|
+
this.slog("warn", config.memberId, "error", err.message);
|
|
304
|
+
});
|
|
305
|
+
this.callbacks.onStateChange?.(config.memberId, "starting");
|
|
306
|
+
// ACP handshake: initialize (declare the qlogicagent extension capability) + register a
|
|
307
|
+
// session, so the child runs the standard session/prompt path and emits session/update.
|
|
308
|
+
// thread.turn is retired for the parent→child wire.
|
|
309
|
+
try {
|
|
310
|
+
await this.sendRpc(config.memberId, "initialize", {
|
|
311
|
+
protocolVersion: 1,
|
|
312
|
+
clientInfo: { name: "qlogicagent-team-leader", version: "1.0.0" },
|
|
313
|
+
clientCapabilities: { qlogicagent: { version: 1, events: true, methods: true, orchestration: true } },
|
|
314
|
+
}, 15_000);
|
|
315
|
+
const childSessionId = randomUUID();
|
|
316
|
+
// Carry the member's standing context (persona + parent memory) as a
|
|
317
|
+
// session-level appendSystemPrompt so every turn inherits it. The child's
|
|
318
|
+
// assembleSystemPrompt already appends config.appendSystemPrompt — no
|
|
319
|
+
// child-side change needed.
|
|
320
|
+
const sessionNewParams = { sessionId: childSessionId, cwd: config.cwd };
|
|
321
|
+
if (config.systemPrompt)
|
|
322
|
+
sessionNewParams._meta = { appendSystemPrompt: config.systemPrompt };
|
|
323
|
+
await this.sendRpc(config.memberId, "session/new", sessionNewParams, 15_000);
|
|
324
|
+
handle.sessionId = childSessionId;
|
|
325
|
+
// Standing LLM config: same wire any ACP host uses to provision a session.
|
|
326
|
+
// A standalone child cannot self-provision (no llmrouter directory, empty
|
|
327
|
+
// registry) — its turns resolve from this explicit session config. Failures
|
|
328
|
+
// here are config-gate failures and fail the spawn like the handshake.
|
|
329
|
+
const llmOptions = [
|
|
330
|
+
["provider", config.provider],
|
|
331
|
+
["model", config.model],
|
|
332
|
+
["apiKey", config.apiKey],
|
|
333
|
+
["baseUrl", config.baseUrl],
|
|
334
|
+
];
|
|
335
|
+
for (const [option, value] of llmOptions) {
|
|
336
|
+
if (!value)
|
|
337
|
+
continue;
|
|
338
|
+
await this.sendRpc(config.memberId, "session/set_config_option", { sessionId: childSessionId, option, value }, 15_000);
|
|
339
|
+
}
|
|
340
|
+
handle.state = "ready";
|
|
341
|
+
this.callbacks.onStateChange?.(config.memberId, "ready");
|
|
342
|
+
this.slog("info", config.memberId, "handshake", `initialized (pid=${handle.pid}, session=${childSessionId})`);
|
|
343
|
+
}
|
|
344
|
+
catch (err) {
|
|
345
|
+
handle.state = "failed";
|
|
346
|
+
handle.error = `Initialize handshake failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
347
|
+
handle.endedAt = Date.now();
|
|
348
|
+
this.callbacks.onStateChange?.(config.memberId, "failed");
|
|
349
|
+
this.kill(config.memberId);
|
|
350
|
+
throw new Error(handle.error);
|
|
351
|
+
}
|
|
352
|
+
return handle;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Send a task to a child agent via ACP session/prompt.
|
|
356
|
+
* Returns the JSON-RPC result (content/usage carried on the response).
|
|
357
|
+
*/
|
|
358
|
+
async sendTask(memberId, prompt, options) {
|
|
359
|
+
const entry = this.processes.get(memberId);
|
|
360
|
+
if (!entry)
|
|
361
|
+
throw new Error(`No agent process: ${memberId}`);
|
|
362
|
+
// Members are reused across turns by the external-agent pool, so the accumulated result text
|
|
363
|
+
// from the previous turn must be cleared — otherwise turn N returns turns 1..N concatenated.
|
|
364
|
+
entry.handle.resultText = "";
|
|
365
|
+
entry.handle.state = "running";
|
|
366
|
+
this.callbacks.onStateChange?.(memberId, "running");
|
|
367
|
+
try {
|
|
368
|
+
let result;
|
|
369
|
+
// Route through ACP adapter for external agents
|
|
370
|
+
if (entry.acpAdapter) {
|
|
371
|
+
const sessionId = entry.handle.sessionId ?? "default";
|
|
372
|
+
const response = await entry.acpAdapter.sendPrompt(entry.child, sessionId, prompt, options?.timeout ?? 300_000);
|
|
373
|
+
// In standard ACP, content is delivered via session/update notifications
|
|
374
|
+
// during prompt execution. The response only has stopReason + usage.
|
|
375
|
+
// The resultText is accumulated by the notification handler (turn.delta).
|
|
376
|
+
const text = entry.handle.resultText ?? "";
|
|
377
|
+
// Track usage from prompt response
|
|
378
|
+
if (response.usage && entry.usageTracker) {
|
|
379
|
+
entry.usageTracker.onPromptResponseUsage(response.usage);
|
|
380
|
+
}
|
|
381
|
+
result = { content: text, stopReason: response.stopReason };
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
// Internal agent: standard ACP session/prompt. Content streams via session/update
|
|
385
|
+
// (turn.delta) and is accumulated into handle.resultText by captureChildProgress;
|
|
386
|
+
// the response carries only { stopReason, usage? }. Mirror the external-agent shape
|
|
387
|
+
// so callers see a uniform { content, stopReason } regardless of transport.
|
|
388
|
+
const sessionId = options?.sessionId ?? entry.handle.sessionId ?? "default";
|
|
389
|
+
const r = await this.sendRpc(memberId, "session/prompt", {
|
|
390
|
+
sessionId,
|
|
391
|
+
prompt: [{ type: "text", text: prompt }],
|
|
392
|
+
}, options?.timeout ?? 300_000);
|
|
393
|
+
const text = entry.handle.resultText ?? "";
|
|
394
|
+
const stopReason = r && typeof r.stopReason === "string" ? r.stopReason : undefined;
|
|
395
|
+
result = { content: text, stopReason };
|
|
396
|
+
}
|
|
397
|
+
entry.handle.state = "completed";
|
|
398
|
+
entry.handle.endedAt = Date.now();
|
|
399
|
+
this.callbacks.onStateChange?.(memberId, "completed");
|
|
400
|
+
return result;
|
|
401
|
+
}
|
|
402
|
+
catch (err) {
|
|
403
|
+
entry.handle.state = "failed";
|
|
404
|
+
entry.handle.error = err instanceof Error ? err.message : String(err);
|
|
405
|
+
entry.handle.endedAt = Date.now();
|
|
406
|
+
this.callbacks.onStateChange?.(memberId, "failed");
|
|
407
|
+
throw err;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/** Send a raw JSON-RPC request to a child. */
|
|
411
|
+
async sendRpc(memberId, method, params, timeoutMs = 30_000) {
|
|
412
|
+
const entry = this.processes.get(memberId);
|
|
413
|
+
if (!entry)
|
|
414
|
+
throw new Error(`No agent process: ${memberId}`);
|
|
415
|
+
const req = buildRpcRequest(method, params);
|
|
416
|
+
return new Promise((resolve, reject) => {
|
|
417
|
+
const timer = setTimeout(() => {
|
|
418
|
+
entry.pendingRpc.delete(req.id);
|
|
419
|
+
reject(new Error(`RPC timeout: ${method} (${timeoutMs}ms)`));
|
|
420
|
+
}, timeoutMs);
|
|
421
|
+
entry.pendingRpc.set(req.id, { resolve, reject, timer });
|
|
422
|
+
try {
|
|
423
|
+
entry.child.stdin.write(`${JSON.stringify(req)}\n`);
|
|
424
|
+
}
|
|
425
|
+
catch (err) {
|
|
426
|
+
clearTimeout(timer);
|
|
427
|
+
entry.pendingRpc.delete(req.id);
|
|
428
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Send a long-running task to a child agent with heartbeat keepalive.
|
|
434
|
+
*
|
|
435
|
+
* Unlike `sendTask()` (which blocks for up to 5 minutes), this method:
|
|
436
|
+
* 1. Dispatches the task via ACP `session/prompt`
|
|
437
|
+
* 2. Periodically sends `ping` RPCs to detect child liveness
|
|
438
|
+
* 3. Supports very long execution times (hours/days) for async work
|
|
439
|
+
* like video generation, batch processing, etc.
|
|
440
|
+
*
|
|
441
|
+
* The child is expected to emit `turn.delta` / `turn.progress`
|
|
442
|
+
* notifications during long work. If no response to ping within
|
|
443
|
+
* `pingTimeout`, the task is considered failed.
|
|
444
|
+
*/
|
|
445
|
+
async sendTaskAsync(memberId, prompt, options) {
|
|
446
|
+
const entry = this.processes.get(memberId);
|
|
447
|
+
if (!entry)
|
|
448
|
+
throw new Error(`No agent process: ${memberId}`);
|
|
449
|
+
entry.handle.state = "running";
|
|
450
|
+
this.callbacks.onStateChange?.(memberId, "running");
|
|
451
|
+
const sessionId = options?.sessionId ?? entry.handle.sessionId ?? "default";
|
|
452
|
+
const promptParams = {
|
|
453
|
+
sessionId,
|
|
454
|
+
prompt: [{ type: "text", text: prompt }],
|
|
455
|
+
};
|
|
456
|
+
const pingInterval = options?.pingInterval ?? 60_000;
|
|
457
|
+
const pingTimeout = options?.pingTimeout ?? 10_000;
|
|
458
|
+
const totalTimeout = options?.timeout ?? 0;
|
|
459
|
+
const startedAt = Date.now();
|
|
460
|
+
// Send the task (no timeout on the RPC itself — we'll manage liveness via ping)
|
|
461
|
+
const taskRpcTimeout = totalTimeout > 0 ? totalTimeout : 24 * 60 * 60 * 1000; // 24h max
|
|
462
|
+
const taskPromise = this.sendRpc(memberId, "session/prompt", promptParams, taskRpcTimeout);
|
|
463
|
+
// Start heartbeat ping loop
|
|
464
|
+
const pingTimer = setInterval(async () => {
|
|
465
|
+
// Check total timeout
|
|
466
|
+
if (totalTimeout > 0 && Date.now() - startedAt > totalTimeout) {
|
|
467
|
+
clearInterval(pingTimer);
|
|
468
|
+
entry.handle.state = "failed";
|
|
469
|
+
entry.handle.error = "Task timed out";
|
|
470
|
+
entry.handle.endedAt = Date.now();
|
|
471
|
+
this.callbacks.onStateChange?.(memberId, "failed");
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
try {
|
|
475
|
+
await this.sendRpc(memberId, "ping", undefined, pingTimeout);
|
|
476
|
+
}
|
|
477
|
+
catch {
|
|
478
|
+
// Ping failed — child may be dead or unresponsive.
|
|
479
|
+
// Don't immediately kill; the task RPC promise will resolve/reject
|
|
480
|
+
// when the child process exits.
|
|
481
|
+
this.slog("warn", entry.handle.memberId, "heartbeat", "ping failed");
|
|
482
|
+
}
|
|
483
|
+
}, pingInterval);
|
|
484
|
+
try {
|
|
485
|
+
const result = await taskPromise;
|
|
486
|
+
clearInterval(pingTimer);
|
|
487
|
+
entry.handle.state = "completed";
|
|
488
|
+
entry.handle.endedAt = Date.now();
|
|
489
|
+
// Content was accumulated into handle.resultText from session/update (turn.delta);
|
|
490
|
+
// the standard ACP response carries only { stopReason, usage? }.
|
|
491
|
+
this.callbacks.onStateChange?.(memberId, "completed");
|
|
492
|
+
return result;
|
|
493
|
+
}
|
|
494
|
+
catch (err) {
|
|
495
|
+
clearInterval(pingTimer);
|
|
496
|
+
entry.handle.state = "failed";
|
|
497
|
+
entry.handle.error = err instanceof Error ? err.message : String(err);
|
|
498
|
+
entry.handle.endedAt = Date.now();
|
|
499
|
+
this.callbacks.onStateChange?.(memberId, "failed");
|
|
500
|
+
throw err;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Ping a child agent to check liveness.
|
|
505
|
+
*
|
|
506
|
+
* Q-2 protocol alignment:
|
|
507
|
+
* - Internal agents: JSON-RPC `ping` request (guaranteed to respond).
|
|
508
|
+
* - ACP agents: Send `notifications/ping` notification, then wait for
|
|
509
|
+
* `$/alive` notification back. Falls back to `sendRpc("ping")` if
|
|
510
|
+
* `$/alive` is not received (some ACP agents may support RPC ping).
|
|
511
|
+
*/
|
|
512
|
+
async ping(memberId, timeoutMs = 5_000) {
|
|
513
|
+
const entry = this.processes.get(memberId);
|
|
514
|
+
if (!entry)
|
|
515
|
+
return false;
|
|
516
|
+
if (entry.acpAdapter) {
|
|
517
|
+
// ACP path: notification-based liveness check
|
|
518
|
+
// Send a ping notification (no response expected)
|
|
519
|
+
try {
|
|
520
|
+
const msg = JSON.stringify({
|
|
521
|
+
jsonrpc: "2.0",
|
|
522
|
+
method: "notifications/ping",
|
|
523
|
+
params: { timestamp: Date.now() },
|
|
524
|
+
}) + "\n";
|
|
525
|
+
entry.child.stdin?.write(msg);
|
|
526
|
+
}
|
|
527
|
+
catch {
|
|
528
|
+
return false;
|
|
529
|
+
}
|
|
530
|
+
// Wait for $/alive notification or any activity within timeout
|
|
531
|
+
const before = entry.handle.lastActivityAt ?? 0;
|
|
532
|
+
const deadline = Date.now() + timeoutMs;
|
|
533
|
+
while (Date.now() < deadline) {
|
|
534
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
535
|
+
if ((entry.handle.lastActivityAt ?? 0) > before)
|
|
536
|
+
return true;
|
|
537
|
+
}
|
|
538
|
+
// Fallback: try RPC ping (some agents may respond)
|
|
539
|
+
try {
|
|
540
|
+
await this.sendRpc(memberId, "ping", undefined, Math.min(timeoutMs, 3_000));
|
|
541
|
+
return true;
|
|
542
|
+
}
|
|
543
|
+
catch {
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
// Internal agent: standard RPC ping
|
|
548
|
+
try {
|
|
549
|
+
await this.sendRpc(memberId, "ping", undefined, timeoutMs);
|
|
550
|
+
return true;
|
|
551
|
+
}
|
|
552
|
+
catch {
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Get the runtime status of a child agent process.
|
|
558
|
+
* Includes real-time media generation progress if available.
|
|
559
|
+
*/
|
|
560
|
+
getStatus(memberId) {
|
|
561
|
+
const entry = this.processes.get(memberId);
|
|
562
|
+
if (!entry)
|
|
563
|
+
return null;
|
|
564
|
+
const { handle } = entry;
|
|
565
|
+
const alive = handle.state === "starting" || handle.state === "ready" || handle.state === "running";
|
|
566
|
+
const runningFor = alive ? Date.now() - handle.startedAt : undefined;
|
|
567
|
+
const idleFor = handle.lastActivityAt && alive
|
|
568
|
+
? Math.round((Date.now() - handle.lastActivityAt) / 1000)
|
|
569
|
+
: undefined;
|
|
570
|
+
return {
|
|
571
|
+
alive,
|
|
572
|
+
state: handle.state,
|
|
573
|
+
runningFor,
|
|
574
|
+
resultText: handle.resultText,
|
|
575
|
+
error: handle.error,
|
|
576
|
+
mediaProgress: handle.mediaProgress,
|
|
577
|
+
lastToolCall: handle.lastToolCall,
|
|
578
|
+
idleFor,
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Auto-capture structured progress from child notifications.
|
|
583
|
+
* This is the key mechanism that allows the parent to know:
|
|
584
|
+
* - Which provider task ID the child is polling (for video/3D/TTS)
|
|
585
|
+
* - Real progress percentage
|
|
586
|
+
* - What the child is currently doing (which tool, what delta text)
|
|
587
|
+
*/
|
|
588
|
+
/**
|
|
589
|
+
* Respond to a request the child agent makes to the parent (host) over ACP —
|
|
590
|
+
* e.g. session/request_permission. Sub-agents run autonomously under the parent,
|
|
591
|
+
* so tool-permission requests are auto-approved.
|
|
592
|
+
*/
|
|
593
|
+
handleChildHostRequest(memberId, msg) {
|
|
594
|
+
const entry = this.processes.get(memberId);
|
|
595
|
+
const stdin = entry?.child.stdin;
|
|
596
|
+
if (!stdin?.writable)
|
|
597
|
+
return;
|
|
598
|
+
const reply = (body) => {
|
|
599
|
+
try {
|
|
600
|
+
stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id: msg.id, ...body })}\n`);
|
|
601
|
+
}
|
|
602
|
+
catch { /* child gone */ }
|
|
603
|
+
};
|
|
604
|
+
if (msg.method === "session/request_permission") {
|
|
605
|
+
reply({ result: { optionId: "allow" } });
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
reply({ error: { code: -32601, message: `Method not found: ${msg.method}` } });
|
|
609
|
+
}
|
|
610
|
+
captureChildProgress(memberId, method, params) {
|
|
611
|
+
const entry = this.processes.get(memberId);
|
|
612
|
+
if (!entry)
|
|
613
|
+
return;
|
|
614
|
+
const { handle } = entry;
|
|
615
|
+
handle.lastActivityAt = Date.now();
|
|
616
|
+
switch (method) {
|
|
617
|
+
case "turn.media_progress": {
|
|
618
|
+
const p = params;
|
|
619
|
+
if (p && typeof p.taskId === "string") {
|
|
620
|
+
handle.mediaProgress = {
|
|
621
|
+
taskId: p.taskId,
|
|
622
|
+
mediaType: p.mediaType ?? "unknown",
|
|
623
|
+
percent: typeof p.percent === "number" ? p.percent : 0,
|
|
624
|
+
status: p.status ?? "unknown",
|
|
625
|
+
provider: p.provider,
|
|
626
|
+
updatedAt: Date.now(),
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
case "turn.tool_call": {
|
|
632
|
+
const p = params;
|
|
633
|
+
if (p && typeof p.name === "string") {
|
|
634
|
+
handle.lastToolCall = p.name;
|
|
635
|
+
}
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
case "turn.delta": {
|
|
639
|
+
const p = params;
|
|
640
|
+
if (p && typeof p.text === "string") {
|
|
641
|
+
// Keep only last 200 chars for status display
|
|
642
|
+
const text = p.text;
|
|
643
|
+
handle.resultText = `${handle.resultText ?? ""}${text}`;
|
|
644
|
+
handle.lastDelta = text.slice(-200);
|
|
645
|
+
}
|
|
646
|
+
break;
|
|
647
|
+
}
|
|
648
|
+
case "turn.tool_result": {
|
|
649
|
+
// Tool completed — clear media progress if it was from a media tool
|
|
650
|
+
const p = params;
|
|
651
|
+
if (p && handle.mediaProgress && handle.mediaProgress.percent >= 100) {
|
|
652
|
+
handle.mediaProgress = undefined;
|
|
653
|
+
}
|
|
654
|
+
break;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Spawn an external ACP agent with retry logic.
|
|
660
|
+
* Retries up to MAX_SPAWN_RETRIES times with exponential backoff.
|
|
661
|
+
*/
|
|
662
|
+
async spawnAcpAgentWithRetry(config, handle, env) {
|
|
663
|
+
let lastError = null;
|
|
664
|
+
for (let attempt = 0; attempt <= MAX_SPAWN_RETRIES; attempt++) {
|
|
665
|
+
try {
|
|
666
|
+
// On retry, clean up previous failed attempt
|
|
667
|
+
if (attempt > 0) {
|
|
668
|
+
this.processes.delete(config.memberId);
|
|
669
|
+
handle.state = "starting";
|
|
670
|
+
handle.error = undefined;
|
|
671
|
+
handle.endedAt = undefined;
|
|
672
|
+
const backoff = RETRY_BACKOFF_BASE * attempt; // 3s, 6s
|
|
673
|
+
this.slog("info", config.memberId, "spawn", `retry ${attempt}/${MAX_SPAWN_RETRIES} after ${backoff}ms`);
|
|
674
|
+
await sleep(backoff);
|
|
675
|
+
}
|
|
676
|
+
return await this.spawnAcpAgent(config, handle, env);
|
|
677
|
+
}
|
|
678
|
+
catch (err) {
|
|
679
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
680
|
+
// Non-retryable failures (e.g. the agent needs login) won't heal by retrying — surface
|
|
681
|
+
// the actionable message immediately instead of spending 3 attempts on it.
|
|
682
|
+
if (lastError.retryable === false) {
|
|
683
|
+
handle.state = "failed";
|
|
684
|
+
handle.error = lastError.message;
|
|
685
|
+
handle.endedAt = Date.now();
|
|
686
|
+
this.callbacks.onStateChange?.(config.memberId, "failed");
|
|
687
|
+
throw lastError;
|
|
688
|
+
}
|
|
689
|
+
this.slog("warn", config.memberId, "spawn", `attempt ${attempt + 1} failed: ${lastError.message}`);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
// All retries exhausted
|
|
693
|
+
handle.state = "failed";
|
|
694
|
+
handle.error = `ACP spawn failed after ${MAX_SPAWN_RETRIES + 1} attempts: ${lastError?.message}`;
|
|
695
|
+
handle.endedAt = Date.now();
|
|
696
|
+
this.callbacks.onStateChange?.(config.memberId, "failed");
|
|
697
|
+
throw new Error(handle.error);
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Spawn an external ACP agent process.
|
|
701
|
+
* Uses the ACP protocol adapter for lifecycle management.
|
|
702
|
+
*/
|
|
703
|
+
async spawnAcpAgent(config, handle, env) {
|
|
704
|
+
const log = this.callbacks.log;
|
|
705
|
+
const ext = config.external;
|
|
706
|
+
// Merge ACP-specific env
|
|
707
|
+
if (ext.env)
|
|
708
|
+
Object.assign(env, ext.env);
|
|
709
|
+
const acpArgs = [...ext.acpArgs];
|
|
710
|
+
this.slog("info", config.memberId, "spawn", `spawning ACP ${config.name} via ${ext.cliPath} ${acpArgs.join(" ")}`);
|
|
711
|
+
const child = spawn(ext.cliPath, acpArgs, {
|
|
712
|
+
cwd: config.cwd,
|
|
713
|
+
env,
|
|
714
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
715
|
+
detached: false,
|
|
716
|
+
});
|
|
717
|
+
handle.pid = child.pid ?? -1;
|
|
718
|
+
const pendingRpc = new Map();
|
|
719
|
+
const acpAdapter = new AcpProtocolAdapter();
|
|
720
|
+
const usageTracker = new AcpUsageTracker();
|
|
721
|
+
// ── IPC server for MCP bridge tool calls ──────────────────
|
|
722
|
+
const { server: ipcServer, pipePath: ipcPath } = this.createMcpIpcServer(config.memberId);
|
|
723
|
+
env.QLOGICAGENT_PARENT_RPC = ipcPath;
|
|
724
|
+
// ── Stderr log file ──────────────────────────────────────
|
|
725
|
+
let stderrStream;
|
|
726
|
+
if (this.callbacks.sessionDir) {
|
|
727
|
+
try {
|
|
728
|
+
mkdirSync(this.callbacks.sessionDir, { recursive: true });
|
|
729
|
+
stderrStream = createWriteStream(join(this.callbacks.sessionDir, `${config.memberId}.stderr.log`), { flags: "a" });
|
|
730
|
+
}
|
|
731
|
+
catch { /* best-effort */ }
|
|
732
|
+
}
|
|
733
|
+
// External-agent host handler: serves reverse-RPC (permission auto-allow + fs + terminal),
|
|
734
|
+
// confined to the agent cwd. Terminals are reaped on detach/kill via disposeAll().
|
|
735
|
+
const hostHandler = createAcpHostHandler({
|
|
736
|
+
cwd: config.cwd,
|
|
737
|
+
requestPermission: this.callbacks.onPermissionRequest
|
|
738
|
+
? (params) => this.callbacks.onPermissionRequest(config.memberId, params)
|
|
739
|
+
: undefined,
|
|
740
|
+
});
|
|
741
|
+
this.processes.set(config.memberId, { handle, child, pendingRpc, acpAdapter, usageTracker, ipcServer, ipcPath, stderrStream, hostHandler });
|
|
742
|
+
// Attach ACP protocol adapter to child stdio
|
|
743
|
+
acpAdapter.attach(child, (method, params) => {
|
|
744
|
+
// Track usage from ACP notifications
|
|
745
|
+
if (method === "usage_update") {
|
|
746
|
+
usageTracker.onUsageUpdate(params);
|
|
747
|
+
}
|
|
748
|
+
// Translate ACP notifications to internal format
|
|
749
|
+
const translated = AcpProtocolAdapter.translateNotification(method, params);
|
|
750
|
+
if (translated) {
|
|
751
|
+
this.captureChildProgress(config.memberId, translated.method, translated.params);
|
|
752
|
+
this.callbacks.onNotification?.(config.memberId, translated.method, translated.params);
|
|
753
|
+
}
|
|
754
|
+
else {
|
|
755
|
+
// Forward raw for unrecognized notifications
|
|
756
|
+
this.captureChildProgress(config.memberId, method, params);
|
|
757
|
+
this.callbacks.onNotification?.(config.memberId, method, params);
|
|
758
|
+
}
|
|
759
|
+
}, hostHandler);
|
|
760
|
+
// Capture stderr for diagnostics + file
|
|
761
|
+
if (child.stderr) {
|
|
762
|
+
const errRl = createInterface({ input: child.stderr, crlfDelay: Number.POSITIVE_INFINITY });
|
|
763
|
+
errRl.on("line", (line) => {
|
|
764
|
+
this.callbacks.log?.debug?.(`[${new Date().toISOString()}] [debug] [agent:${config.memberId}] [stderr] ${line}`);
|
|
765
|
+
stderrStream?.write(`${new Date().toISOString()} ${line}\n`);
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
// Handle process exit (with runtime restart for RETRIABLE crashes)
|
|
769
|
+
child.on("exit", (code, signal) => {
|
|
770
|
+
acpAdapter.detach();
|
|
771
|
+
hostHandler.disposeAll();
|
|
772
|
+
const prev = handle.state;
|
|
773
|
+
// ── Runtime crash auto-restart ────────────────────────
|
|
774
|
+
if (prev !== "killed" && prev !== "completed" && code !== 0) {
|
|
775
|
+
const entry = this.processes.get(config.memberId);
|
|
776
|
+
const restartCount = entry?.runtimeRestartCount ?? 0;
|
|
777
|
+
if (restartCount < RUNTIME_RESTART_MAX) {
|
|
778
|
+
const backoff = RUNTIME_RESTART_BACKOFF_BASE * (2 ** restartCount); // 5s, 10s, 20s
|
|
779
|
+
this.slog("warn", config.memberId, "crash", `crashed (code=${code}), restarting ${restartCount + 1}/${RUNTIME_RESTART_MAX} after ${backoff}ms`);
|
|
780
|
+
this.callbacks.onNotification?.(config.memberId, "agents.error", {
|
|
781
|
+
agentId: config.memberId,
|
|
782
|
+
phase: "runtime",
|
|
783
|
+
error: `Process crashed (code=${code}, signal=${signal}), restarting`,
|
|
784
|
+
retriesLeft: RUNTIME_RESTART_MAX - restartCount - 1,
|
|
785
|
+
});
|
|
786
|
+
setTimeout(() => {
|
|
787
|
+
this.attemptRuntimeRestart(config, env, restartCount + 1).catch((err) => {
|
|
788
|
+
this.slog("warn", config.memberId, "restart", `failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
789
|
+
});
|
|
790
|
+
}, backoff);
|
|
791
|
+
return; // Don't mark as failed yet — restart in progress
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
if (prev !== "killed") {
|
|
795
|
+
handle.state = code === 0 ? "completed" : "failed";
|
|
796
|
+
}
|
|
797
|
+
handle.endedAt = Date.now();
|
|
798
|
+
if (code !== 0 && !handle.error) {
|
|
799
|
+
handle.error = `ACP process exited with code ${code} (signal: ${signal})`;
|
|
800
|
+
}
|
|
801
|
+
this.callbacks.onStateChange?.(config.memberId, handle.state);
|
|
802
|
+
this.callbacks.onExit?.(config.memberId, code, signal);
|
|
803
|
+
this.slog("info", config.memberId, "exit", `ACP exited (code=${code}, signal=${signal})`);
|
|
804
|
+
});
|
|
805
|
+
child.on("error", (err) => {
|
|
806
|
+
acpAdapter.detach();
|
|
807
|
+
hostHandler.disposeAll();
|
|
808
|
+
handle.state = "failed";
|
|
809
|
+
handle.error = err.message;
|
|
810
|
+
handle.endedAt = Date.now();
|
|
811
|
+
this.callbacks.onStateChange?.(config.memberId, "failed");
|
|
812
|
+
this.callbacks.onNotification?.(config.memberId, "agents.error", {
|
|
813
|
+
agentId: config.memberId,
|
|
814
|
+
phase: "spawn",
|
|
815
|
+
error: err.message,
|
|
816
|
+
retriesLeft: 0,
|
|
817
|
+
});
|
|
818
|
+
this.slog("warn", config.memberId, "error", err.message);
|
|
819
|
+
});
|
|
820
|
+
this.callbacks.onStateChange?.(config.memberId, "starting");
|
|
821
|
+
// Perform ACP initialize handshake
|
|
822
|
+
try {
|
|
823
|
+
const initResult = await acpAdapter.initialize(child);
|
|
824
|
+
handle.state = "ready";
|
|
825
|
+
handle.supportsResume = initResult.agentCapabilities.loadSession === true;
|
|
826
|
+
this.callbacks.onStateChange?.(config.memberId, "ready");
|
|
827
|
+
this.slog("info", config.memberId, "handshake", `ACP initialized (protocol=${initResult.protocolVersion}, loadSession=${handle.supportsResume}, pid=${handle.pid})`);
|
|
828
|
+
// Create ACP session with MCP servers and system prompt
|
|
829
|
+
try {
|
|
830
|
+
const sessionOpts = {
|
|
831
|
+
cwd: config.cwd,
|
|
832
|
+
};
|
|
833
|
+
// Auto-inject MCP bridge server if we have an IPC path
|
|
834
|
+
const mcpServers = [...(config.mcpServers ?? [])];
|
|
835
|
+
const entry = this.processes.get(config.memberId);
|
|
836
|
+
const mcpCapabilities = initResult.agentCapabilities.mcpCapabilities;
|
|
837
|
+
const supportsStdioMcp = mcpCapabilities?.stdio === true;
|
|
838
|
+
if (entry?.ipcPath && supportsStdioMcp) {
|
|
839
|
+
mcpServers.push({
|
|
840
|
+
name: "qlogicagent-tools",
|
|
841
|
+
command: process.execPath,
|
|
842
|
+
args: [this.mcpBridgeScriptPath],
|
|
843
|
+
env: {
|
|
844
|
+
QLOGICAGENT_PARENT_RPC: entry.ipcPath,
|
|
845
|
+
QLOGICAGENT_SESSION_ID: config.memberId,
|
|
846
|
+
},
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
if (mcpServers.length > 0)
|
|
850
|
+
sessionOpts.mcpServers = mcpServers;
|
|
851
|
+
if (config.systemPrompt)
|
|
852
|
+
sessionOpts.systemPrompt = config.systemPrompt;
|
|
853
|
+
const sessionResult = await acpAdapter.createSession(child, sessionOpts);
|
|
854
|
+
handle.sessionId = sessionResult.sessionId;
|
|
855
|
+
this.slog("info", config.memberId, "session", `session created (id=${sessionResult.sessionId})`);
|
|
856
|
+
}
|
|
857
|
+
catch (err) {
|
|
858
|
+
// Session creation is FATAL: ACP requires a session before any prompt. Swallowing it let
|
|
859
|
+
// the turn run with a bogus "default" sessionId, so the agent rejected the prompt with a
|
|
860
|
+
// misleading "Invalid params" — hiding the real cause, commonly an auth/config gate. Two
|
|
861
|
+
// patterns: (1) the agent rejects session/new with an auth error directly (kimi: -32000 +
|
|
862
|
+
// authMethods); (2) it advertises authMethods at *initialize* then fails session/new
|
|
863
|
+
// generically (hermes: "hermes-setup" + -32603 "No LLM provider configured"). Both are
|
|
864
|
+
// non-retryable — asAuthRequiredError(err, initAuthMethods) surfaces the actionable
|
|
865
|
+
// message + authMethods (retryable=false) so the spawn layer stops, instead of burning
|
|
866
|
+
// 3 retries / hiding the cause.
|
|
867
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
868
|
+
const initAuthMethods = (initResult.authMethods ?? []);
|
|
869
|
+
const authErr = asAuthRequiredError(e, initAuthMethods);
|
|
870
|
+
this.slog("warn", config.memberId, "session", `session creation failed: ${(authErr ?? e).message}`);
|
|
871
|
+
throw authErr ?? e;
|
|
872
|
+
}
|
|
873
|
+
// Start heartbeat monitoring for external ACP agents
|
|
874
|
+
this.startHeartbeat(config.memberId, (hungId) => {
|
|
875
|
+
this.slog("warn", hungId, "heartbeat", "hang detected — force-killing");
|
|
876
|
+
this.callbacks.onNotification?.(hungId, "agents.error", {
|
|
877
|
+
agentId: hungId,
|
|
878
|
+
phase: "heartbeat",
|
|
879
|
+
error: `Agent ${config.name} stopped responding (${AgentProcessManager.MAX_MISSED_BEATS} missed heartbeats)`,
|
|
880
|
+
retriesLeft: 0,
|
|
881
|
+
});
|
|
882
|
+
this.kill(hungId);
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
catch (err) {
|
|
886
|
+
const e = err instanceof Error ? err : new Error(String(err));
|
|
887
|
+
// Auth-required (and other non-retryable) failures carry retryable=false + a ready-to-show
|
|
888
|
+
// message ("Authentication required. Run `kimi login` …"); don't bury those under the
|
|
889
|
+
// generic "ACP handshake failed" prefix, and forward the agent's authMethods to the UI.
|
|
890
|
+
const nonRetryable = e.retryable === false;
|
|
891
|
+
const authMethods = e.authMethods;
|
|
892
|
+
handle.state = "failed";
|
|
893
|
+
handle.error = nonRetryable ? e.message : `ACP handshake failed: ${e.message}`;
|
|
894
|
+
handle.endedAt = Date.now();
|
|
895
|
+
acpAdapter.detach();
|
|
896
|
+
hostHandler.disposeAll();
|
|
897
|
+
this.callbacks.onStateChange?.(config.memberId, "failed");
|
|
898
|
+
this.callbacks.onNotification?.(config.memberId, "agents.error", {
|
|
899
|
+
agentId: config.memberId,
|
|
900
|
+
phase: "handshake",
|
|
901
|
+
error: handle.error,
|
|
902
|
+
retriesLeft: 0,
|
|
903
|
+
...(authMethods ? { authMethods } : {}),
|
|
904
|
+
});
|
|
905
|
+
this.kill(config.memberId);
|
|
906
|
+
throw e;
|
|
907
|
+
}
|
|
908
|
+
return handle;
|
|
909
|
+
}
|
|
910
|
+
/** Kill a specific child agent process. */
|
|
911
|
+
kill(memberId) {
|
|
912
|
+
const entry = this.processes.get(memberId);
|
|
913
|
+
if (!entry)
|
|
914
|
+
return;
|
|
915
|
+
this.stopHeartbeat(memberId);
|
|
916
|
+
entry.handle.state = "killed";
|
|
917
|
+
entry.handle.endedAt = Date.now();
|
|
918
|
+
entry.acpAdapter?.detach();
|
|
919
|
+
entry.hostHandler?.disposeAll();
|
|
920
|
+
// Close IPC server & stderr stream
|
|
921
|
+
try {
|
|
922
|
+
entry.ipcServer?.close();
|
|
923
|
+
}
|
|
924
|
+
catch { /* ignore */ }
|
|
925
|
+
try {
|
|
926
|
+
entry.stderrStream?.end();
|
|
927
|
+
}
|
|
928
|
+
catch { /* ignore */ }
|
|
929
|
+
// Reap the WHOLE process tree, not just the direct child — external CLIs like kimi-cli
|
|
930
|
+
// (a Python launcher) spawn grandchildren that child.kill() would orphan on Windows.
|
|
931
|
+
killProcessTree(entry.child, entry.handle.pid);
|
|
932
|
+
this.callbacks.onStateChange?.(memberId, "killed");
|
|
933
|
+
this.slog("info", memberId, "kill", `killed (pid=${entry.handle.pid})`);
|
|
934
|
+
}
|
|
935
|
+
/** Kill all child processes and clean up. */
|
|
936
|
+
killAll() {
|
|
937
|
+
for (const memberId of this.processes.keys()) {
|
|
938
|
+
this.kill(memberId);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
/** Get the handle for a specific member. */
|
|
942
|
+
getHandle(memberId) {
|
|
943
|
+
return this.processes.get(memberId)?.handle;
|
|
944
|
+
}
|
|
945
|
+
/** Get all handles. */
|
|
946
|
+
getAllHandles() {
|
|
947
|
+
return [...this.processes.values()].map(p => p.handle);
|
|
948
|
+
}
|
|
949
|
+
/** Whether a member's process is still spawned and usable (for pool reuse across turns). */
|
|
950
|
+
isAlive(memberId) {
|
|
951
|
+
const entry = this.processes.get(memberId);
|
|
952
|
+
if (!entry)
|
|
953
|
+
return false;
|
|
954
|
+
if (entry.child.killed || entry.child.exitCode !== null)
|
|
955
|
+
return false;
|
|
956
|
+
return entry.handle.state !== "killed" && entry.handle.state !== "failed";
|
|
957
|
+
}
|
|
958
|
+
/** Get usage tracker for an ACP agent (returns null for internal agents). */
|
|
959
|
+
getUsageTracker(memberId) {
|
|
960
|
+
return this.processes.get(memberId)?.usageTracker ?? null;
|
|
961
|
+
}
|
|
962
|
+
// ── MCP IPC Server ────────────────────────────────────────
|
|
963
|
+
/**
|
|
964
|
+
* Create a named-pipe IPC server for MCP bridge tool-call proxying.
|
|
965
|
+
* External agents' MCP bridge servers connect here to proxy tool calls
|
|
966
|
+
* back to qlogicagent.
|
|
967
|
+
*/
|
|
968
|
+
createMcpIpcServer(memberId) {
|
|
969
|
+
const slug = memberId.replace(/[^a-zA-Z0-9-]/g, "-");
|
|
970
|
+
const pipePath = process.platform === "win32"
|
|
971
|
+
? `\\\\.\\pipe\\qlogicagent-mcp-${slug}-${Date.now()}`
|
|
972
|
+
: join(tmpdir(), `qlogicagent-mcp-${slug}-${Date.now()}.sock`);
|
|
973
|
+
const server = createServer((socket) => {
|
|
974
|
+
let buffer = "";
|
|
975
|
+
socket.on("data", (chunk) => {
|
|
976
|
+
buffer += chunk.toString();
|
|
977
|
+
let nl;
|
|
978
|
+
while ((nl = buffer.indexOf("\n")) !== -1) {
|
|
979
|
+
const line = buffer.slice(0, nl).trim();
|
|
980
|
+
buffer = buffer.slice(nl + 1);
|
|
981
|
+
if (!line)
|
|
982
|
+
continue;
|
|
983
|
+
this.handleMcpIpcMessage(memberId, line, socket);
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
server.listen(pipePath);
|
|
988
|
+
server.on("error", (err) => {
|
|
989
|
+
this.slog("warn", memberId, "mcp-ipc", `server error: ${err.message}`);
|
|
990
|
+
});
|
|
991
|
+
return { server, pipePath };
|
|
992
|
+
}
|
|
993
|
+
/** Handle a single JSON-RPC message from the MCP bridge IPC connection. */
|
|
994
|
+
handleMcpIpcMessage(memberId, line, socket) {
|
|
995
|
+
let msg;
|
|
996
|
+
try {
|
|
997
|
+
msg = JSON.parse(line);
|
|
998
|
+
}
|
|
999
|
+
catch {
|
|
1000
|
+
return; // ignore malformed
|
|
1001
|
+
}
|
|
1002
|
+
if (msg.method === "mcp.toolCall" && msg.id !== undefined) {
|
|
1003
|
+
const tool = typeof msg.params?.tool === "string" ? msg.params.tool : "";
|
|
1004
|
+
const args = msg.params?.arguments ?? {};
|
|
1005
|
+
if (!this.callbacks.onMcpToolCall) {
|
|
1006
|
+
const resp = JSON.stringify({ jsonrpc: "2.0", id: msg.id, error: { code: -32601, message: "No onMcpToolCall handler" } }) + "\n";
|
|
1007
|
+
try {
|
|
1008
|
+
socket.write(resp);
|
|
1009
|
+
}
|
|
1010
|
+
catch { /* socket gone */ }
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
this.callbacks.onMcpToolCall(memberId, tool, args)
|
|
1014
|
+
.then((result) => {
|
|
1015
|
+
const resp = JSON.stringify({ jsonrpc: "2.0", id: msg.id, result }) + "\n";
|
|
1016
|
+
try {
|
|
1017
|
+
socket.write(resp);
|
|
1018
|
+
}
|
|
1019
|
+
catch { /* socket gone */ }
|
|
1020
|
+
})
|
|
1021
|
+
.catch((err) => {
|
|
1022
|
+
const resp = JSON.stringify({
|
|
1023
|
+
jsonrpc: "2.0",
|
|
1024
|
+
id: msg.id,
|
|
1025
|
+
error: { code: -32603, message: err instanceof Error ? err.message : String(err) },
|
|
1026
|
+
}) + "\n";
|
|
1027
|
+
try {
|
|
1028
|
+
socket.write(resp);
|
|
1029
|
+
}
|
|
1030
|
+
catch { /* socket gone */ }
|
|
1031
|
+
});
|
|
1032
|
+
}
|
|
1033
|
+
else if (msg.id !== undefined) {
|
|
1034
|
+
// Unknown method
|
|
1035
|
+
const resp = JSON.stringify({ jsonrpc: "2.0", id: msg.id, error: { code: -32601, message: `Unknown IPC method: ${msg.method}` } }) + "\n";
|
|
1036
|
+
try {
|
|
1037
|
+
socket.write(resp);
|
|
1038
|
+
}
|
|
1039
|
+
catch { /* socket gone */ }
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
// ── Runtime Crash Restart ─────────────────────────────────
|
|
1043
|
+
/**
|
|
1044
|
+
* Attempt to restart a crashed ACP agent.
|
|
1045
|
+
* Re-spawns the child process prepping the same config and env,
|
|
1046
|
+
* then re-runs ACP handshake.
|
|
1047
|
+
*/
|
|
1048
|
+
async attemptRuntimeRestart(config, env, restartCount) {
|
|
1049
|
+
const log = this.callbacks.log;
|
|
1050
|
+
const existing = this.processes.get(config.memberId);
|
|
1051
|
+
// Clean up old entry but preserve IPC server & stderr stream
|
|
1052
|
+
const ipcServer = existing?.ipcServer;
|
|
1053
|
+
const ipcPath = existing?.ipcPath;
|
|
1054
|
+
const stderrStream = existing?.stderrStream;
|
|
1055
|
+
this.processes.delete(config.memberId);
|
|
1056
|
+
try {
|
|
1057
|
+
const handle = {
|
|
1058
|
+
memberId: config.memberId,
|
|
1059
|
+
name: config.name,
|
|
1060
|
+
pid: -1,
|
|
1061
|
+
cwd: config.cwd,
|
|
1062
|
+
state: "starting",
|
|
1063
|
+
startedAt: Date.now(),
|
|
1064
|
+
};
|
|
1065
|
+
const ext = config.external;
|
|
1066
|
+
const acpArgs = [...ext.acpArgs];
|
|
1067
|
+
// Ensure IPC path is set for MCP bridge
|
|
1068
|
+
if (ipcPath)
|
|
1069
|
+
env.QLOGICAGENT_PARENT_RPC = ipcPath;
|
|
1070
|
+
const child = spawn(ext.cliPath, acpArgs, {
|
|
1071
|
+
cwd: config.cwd,
|
|
1072
|
+
env,
|
|
1073
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1074
|
+
detached: false,
|
|
1075
|
+
});
|
|
1076
|
+
handle.pid = child.pid ?? -1;
|
|
1077
|
+
const pendingRpc = new Map();
|
|
1078
|
+
const acpAdapter = new AcpProtocolAdapter();
|
|
1079
|
+
const usageTracker = new AcpUsageTracker();
|
|
1080
|
+
const hostHandler = createAcpHostHandler({
|
|
1081
|
+
cwd: config.cwd,
|
|
1082
|
+
requestPermission: this.callbacks.onPermissionRequest
|
|
1083
|
+
? (params) => this.callbacks.onPermissionRequest(config.memberId, params)
|
|
1084
|
+
: undefined,
|
|
1085
|
+
});
|
|
1086
|
+
this.processes.set(config.memberId, {
|
|
1087
|
+
handle, child, pendingRpc, acpAdapter, usageTracker,
|
|
1088
|
+
ipcServer, ipcPath, stderrStream, hostHandler,
|
|
1089
|
+
runtimeRestartCount: restartCount,
|
|
1090
|
+
});
|
|
1091
|
+
// Re-attach ACP adapter
|
|
1092
|
+
acpAdapter.attach(child, (method, params) => {
|
|
1093
|
+
if (method === "usage_update") {
|
|
1094
|
+
usageTracker.onUsageUpdate(params);
|
|
1095
|
+
}
|
|
1096
|
+
const translated = AcpProtocolAdapter.translateNotification(method, params);
|
|
1097
|
+
if (translated) {
|
|
1098
|
+
this.captureChildProgress(config.memberId, translated.method, translated.params);
|
|
1099
|
+
this.callbacks.onNotification?.(config.memberId, translated.method, translated.params);
|
|
1100
|
+
}
|
|
1101
|
+
else {
|
|
1102
|
+
this.captureChildProgress(config.memberId, method, params);
|
|
1103
|
+
this.callbacks.onNotification?.(config.memberId, method, params);
|
|
1104
|
+
}
|
|
1105
|
+
}, hostHandler);
|
|
1106
|
+
if (child.stderr) {
|
|
1107
|
+
const errRl = createInterface({ input: child.stderr, crlfDelay: Number.POSITIVE_INFINITY });
|
|
1108
|
+
errRl.on("line", (line) => {
|
|
1109
|
+
this.callbacks.log?.debug?.(`[${new Date().toISOString()}] [debug] [agent:${config.memberId}] [stderr] ${line}`);
|
|
1110
|
+
stderrStream?.write(`${new Date().toISOString()} ${line}\n`);
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
// Re-wire exit handler (recursive for further restarts)
|
|
1114
|
+
child.on("exit", (code, signal) => {
|
|
1115
|
+
acpAdapter.detach();
|
|
1116
|
+
hostHandler.disposeAll();
|
|
1117
|
+
const prev = handle.state;
|
|
1118
|
+
if (prev !== "killed" && prev !== "completed" && code !== 0) {
|
|
1119
|
+
const entry = this.processes.get(config.memberId);
|
|
1120
|
+
const rc = entry?.runtimeRestartCount ?? restartCount;
|
|
1121
|
+
if (rc < RUNTIME_RESTART_MAX) {
|
|
1122
|
+
const backoff = RUNTIME_RESTART_BACKOFF_BASE * (2 ** rc);
|
|
1123
|
+
this.slog("warn", config.memberId, "crash", `crashed again (code=${code}), restart ${rc + 1}/${RUNTIME_RESTART_MAX}`);
|
|
1124
|
+
this.callbacks.onNotification?.(config.memberId, "agents.error", {
|
|
1125
|
+
agentId: config.memberId,
|
|
1126
|
+
phase: "runtime",
|
|
1127
|
+
error: `Process crashed (code=${code}), restarting`,
|
|
1128
|
+
retriesLeft: RUNTIME_RESTART_MAX - rc - 1,
|
|
1129
|
+
});
|
|
1130
|
+
setTimeout(() => {
|
|
1131
|
+
this.attemptRuntimeRestart(config, env, rc + 1).catch((err) => {
|
|
1132
|
+
this.slog("warn", config.memberId, "restart", `failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
1133
|
+
});
|
|
1134
|
+
}, backoff);
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
if (prev !== "killed") {
|
|
1139
|
+
handle.state = code === 0 ? "completed" : "failed";
|
|
1140
|
+
}
|
|
1141
|
+
handle.endedAt = Date.now();
|
|
1142
|
+
if (code !== 0 && !handle.error) {
|
|
1143
|
+
handle.error = `ACP process exited with code ${code} (signal: ${signal})`;
|
|
1144
|
+
}
|
|
1145
|
+
this.callbacks.onStateChange?.(config.memberId, handle.state);
|
|
1146
|
+
this.callbacks.onExit?.(config.memberId, code, signal);
|
|
1147
|
+
});
|
|
1148
|
+
child.on("error", (err) => {
|
|
1149
|
+
acpAdapter.detach();
|
|
1150
|
+
hostHandler.disposeAll();
|
|
1151
|
+
handle.state = "failed";
|
|
1152
|
+
handle.error = err.message;
|
|
1153
|
+
handle.endedAt = Date.now();
|
|
1154
|
+
this.callbacks.onStateChange?.(config.memberId, "failed");
|
|
1155
|
+
});
|
|
1156
|
+
this.callbacks.onStateChange?.(config.memberId, "starting");
|
|
1157
|
+
// Re-handshake
|
|
1158
|
+
const initResult = await acpAdapter.initialize(child);
|
|
1159
|
+
handle.state = "ready";
|
|
1160
|
+
handle.supportsResume = initResult.agentCapabilities.loadSession === true;
|
|
1161
|
+
this.callbacks.onStateChange?.(config.memberId, "ready");
|
|
1162
|
+
this.slog("info", config.memberId, "restart", `ACP restarted (attempt=${restartCount}, protocol=${initResult.protocolVersion}, loadSession=${handle.supportsResume}, pid=${handle.pid})`);
|
|
1163
|
+
// Build MCP server list for session creation
|
|
1164
|
+
const mcpServers = [...(config.mcpServers ?? [])];
|
|
1165
|
+
if (ipcPath) {
|
|
1166
|
+
mcpServers.push({
|
|
1167
|
+
name: "qlogicagent-tools",
|
|
1168
|
+
command: process.execPath,
|
|
1169
|
+
args: [this.mcpBridgeScriptPath],
|
|
1170
|
+
env: { QLOGICAGENT_PARENT_RPC: ipcPath, QLOGICAGENT_SESSION_ID: config.memberId },
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
// D-1: Try session/resume if the agent supports it and we have a previous session
|
|
1174
|
+
try {
|
|
1175
|
+
if (handle.supportsResume && handle.sessionId) {
|
|
1176
|
+
const resumeResult = await acpAdapter.resumeSession(child, handle.sessionId, {
|
|
1177
|
+
cwd: config.cwd,
|
|
1178
|
+
mcpServers: mcpServers.length > 0 ? mcpServers : undefined,
|
|
1179
|
+
});
|
|
1180
|
+
handle.sessionId = resumeResult.sessionId;
|
|
1181
|
+
this.slog("info", config.memberId, "session", `session resumed (id=${handle.sessionId})`);
|
|
1182
|
+
}
|
|
1183
|
+
else {
|
|
1184
|
+
// Fallback: create new session (optionally with summary)
|
|
1185
|
+
const sessionOpts = {
|
|
1186
|
+
cwd: config.cwd,
|
|
1187
|
+
};
|
|
1188
|
+
if (mcpServers.length > 0)
|
|
1189
|
+
sessionOpts.mcpServers = mcpServers;
|
|
1190
|
+
if (config.systemPrompt)
|
|
1191
|
+
sessionOpts.systemPrompt = config.systemPrompt;
|
|
1192
|
+
const sessionResult = await acpAdapter.createSession(child, sessionOpts);
|
|
1193
|
+
handle.sessionId = sessionResult.sessionId;
|
|
1194
|
+
this.slog("info", config.memberId, "session", `new session on restart (id=${handle.sessionId})`);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
catch {
|
|
1198
|
+
this.slog("warn", config.memberId, "session", "session re-creation failed on restart");
|
|
1199
|
+
}
|
|
1200
|
+
this.startHeartbeat(config.memberId, (hungId) => {
|
|
1201
|
+
this.slog("warn", hungId, "heartbeat", "hang detected — force-killing");
|
|
1202
|
+
this.callbacks.onNotification?.(hungId, "agents.error", {
|
|
1203
|
+
agentId: hungId,
|
|
1204
|
+
phase: "heartbeat",
|
|
1205
|
+
error: `Agent ${config.name} stopped responding`,
|
|
1206
|
+
retriesLeft: 0,
|
|
1207
|
+
});
|
|
1208
|
+
this.kill(hungId);
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
catch (err) {
|
|
1212
|
+
// Restart failed — mark as terminal failure
|
|
1213
|
+
const entry = this.processes.get(config.memberId);
|
|
1214
|
+
if (entry) {
|
|
1215
|
+
entry.handle.state = "failed";
|
|
1216
|
+
entry.handle.error = `Runtime restart failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
1217
|
+
entry.handle.endedAt = Date.now();
|
|
1218
|
+
}
|
|
1219
|
+
this.callbacks.onStateChange?.(config.memberId, "failed");
|
|
1220
|
+
this.callbacks.onNotification?.(config.memberId, "agents.error", {
|
|
1221
|
+
agentId: config.memberId,
|
|
1222
|
+
phase: "runtime",
|
|
1223
|
+
error: `Restart failed after ${restartCount} attempts: ${err instanceof Error ? err.message : String(err)}`,
|
|
1224
|
+
retriesLeft: 0,
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
/** Get IPC pipe path for a member's MCP bridge. */
|
|
1229
|
+
getMcpIpcPath(memberId) {
|
|
1230
|
+
return this.processes.get(memberId)?.ipcPath;
|
|
1231
|
+
}
|
|
1232
|
+
// ── Heartbeat & Hang Detection ────────────────────────────
|
|
1233
|
+
heartbeatTimers = new Map();
|
|
1234
|
+
missedBeats = new Map();
|
|
1235
|
+
/** Heartbeat interval (ms). */
|
|
1236
|
+
static HEARTBEAT_INTERVAL = 30_000;
|
|
1237
|
+
/** Number of missed heartbeats before force-kill. */
|
|
1238
|
+
static MAX_MISSED_BEATS = 3;
|
|
1239
|
+
/**
|
|
1240
|
+
* Start heartbeat monitoring for a running agent.
|
|
1241
|
+
* Sends periodic ping RPCs; after MAX_MISSED_BEATS consecutive failures,
|
|
1242
|
+
* the agent is force-killed and marked as "hang".
|
|
1243
|
+
*/
|
|
1244
|
+
startHeartbeat(memberId, onHang) {
|
|
1245
|
+
this.stopHeartbeat(memberId);
|
|
1246
|
+
this.missedBeats.set(memberId, 0);
|
|
1247
|
+
const timer = setInterval(async () => {
|
|
1248
|
+
const entry = this.processes.get(memberId);
|
|
1249
|
+
if (!entry || entry.handle.state === "completed" || entry.handle.state === "failed" || entry.handle.state === "killed") {
|
|
1250
|
+
this.stopHeartbeat(memberId);
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
const alive = await this.ping(memberId, 10_000);
|
|
1254
|
+
if (alive) {
|
|
1255
|
+
this.missedBeats.set(memberId, 0);
|
|
1256
|
+
return;
|
|
1257
|
+
}
|
|
1258
|
+
const missed = (this.missedBeats.get(memberId) ?? 0) + 1;
|
|
1259
|
+
this.missedBeats.set(memberId, missed);
|
|
1260
|
+
this.slog("warn", memberId, "heartbeat", `missed (${missed}/${AgentProcessManager.MAX_MISSED_BEATS})`);
|
|
1261
|
+
if (missed >= AgentProcessManager.MAX_MISSED_BEATS) {
|
|
1262
|
+
this.slog("warn", memberId, "heartbeat", "hang detected, force-killing");
|
|
1263
|
+
this.stopHeartbeat(memberId);
|
|
1264
|
+
entry.handle.error = `Hang detected: ${missed} consecutive heartbeat failures`;
|
|
1265
|
+
this.kill(memberId);
|
|
1266
|
+
onHang?.(memberId);
|
|
1267
|
+
}
|
|
1268
|
+
}, AgentProcessManager.HEARTBEAT_INTERVAL);
|
|
1269
|
+
this.heartbeatTimers.set(memberId, timer);
|
|
1270
|
+
}
|
|
1271
|
+
/** Stop heartbeat monitoring for an agent. */
|
|
1272
|
+
stopHeartbeat(memberId) {
|
|
1273
|
+
const timer = this.heartbeatTimers.get(memberId);
|
|
1274
|
+
if (timer) {
|
|
1275
|
+
clearInterval(timer);
|
|
1276
|
+
this.heartbeatTimers.delete(memberId);
|
|
1277
|
+
}
|
|
1278
|
+
this.missedBeats.delete(memberId);
|
|
1279
|
+
}
|
|
1280
|
+
/** Get missed heartbeat count for an agent. */
|
|
1281
|
+
getMissedBeats(memberId) {
|
|
1282
|
+
return this.missedBeats.get(memberId) ?? 0;
|
|
1283
|
+
}
|
|
1284
|
+
/** Get count of active (non-terminal) processes. */
|
|
1285
|
+
activeCount() {
|
|
1286
|
+
return [...this.processes.values()].filter(p => p.handle.state === "starting" || p.handle.state === "ready" || p.handle.state === "running").length;
|
|
1287
|
+
}
|
|
1288
|
+
/** Remove a terminated process from tracking. */
|
|
1289
|
+
remove(memberId) {
|
|
1290
|
+
const entry = this.processes.get(memberId);
|
|
1291
|
+
if (!entry)
|
|
1292
|
+
return;
|
|
1293
|
+
this.stopHeartbeat(memberId);
|
|
1294
|
+
if (entry.handle.state === "running" || entry.handle.state === "starting" || entry.handle.state === "ready") {
|
|
1295
|
+
this.kill(memberId);
|
|
1296
|
+
}
|
|
1297
|
+
this.processes.delete(memberId);
|
|
1298
|
+
}
|
|
1299
|
+
/** Clean up all processes. */
|
|
1300
|
+
dispose() {
|
|
1301
|
+
for (const memberId of this.heartbeatTimers.keys()) {
|
|
1302
|
+
this.stopHeartbeat(memberId);
|
|
1303
|
+
}
|
|
1304
|
+
// Close all IPC servers and stderr streams before killing
|
|
1305
|
+
for (const entry of this.processes.values()) {
|
|
1306
|
+
try {
|
|
1307
|
+
entry.ipcServer?.close();
|
|
1308
|
+
}
|
|
1309
|
+
catch { /* ignore */ }
|
|
1310
|
+
try {
|
|
1311
|
+
entry.stderrStream?.end();
|
|
1312
|
+
}
|
|
1313
|
+
catch { /* ignore */ }
|
|
1314
|
+
}
|
|
1315
|
+
this.killAll();
|
|
1316
|
+
this.processes.clear();
|
|
1317
|
+
}
|
|
1318
|
+
}
|