@minionry/minion 0.7.36
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/LICENSE +14 -0
- package/PRIVACY.md +357 -0
- package/README.md +57 -0
- package/THIRD_PARTY_NOTICES.md +245 -0
- package/bin/branding.js +4 -0
- package/bin/commands/browser-install.js +483 -0
- package/bin/commands/create-sandbox.js +542 -0
- package/bin/commands/fingerprint.js +101 -0
- package/bin/commands/login.js +400 -0
- package/bin/commands/logout.js +93 -0
- package/bin/commands/minions.js +211 -0
- package/bin/commands/sandboxes.js +309 -0
- package/bin/commands/status.js +298 -0
- package/bin/commands/whoami.js +153 -0
- package/bin/launch-env.js +35 -0
- package/bin/machine-identity.js +221 -0
- package/bin/machine-layout.js +200 -0
- package/bin/minion.js +839 -0
- package/bin/platform-endpoints.js +8 -0
- package/bin/postinstall.js +52 -0
- package/bin/pty-doctor.js +326 -0
- package/bin/pty-locator.js +110 -0
- package/bin/pty-provision.js +186 -0
- package/bin/sandbox/Dockerfile +78 -0
- package/bin/sandbox/entrypoint.sh +14 -0
- package/bin/sandbox/install-repo.sh +53 -0
- package/bin/sandbox/seccomp-userns.json +883 -0
- package/bin/sandbox-config.js +306 -0
- package/dist/bin/machine-identity.js +221 -0
- package/dist/bin/machine-layout.js +200 -0
- package/dist/electron-host/agent-lease.js +141 -0
- package/dist/electron-host/dom-driver.js +642 -0
- package/dist/electron-host/ipc-protocol.js +89 -0
- package/dist/electron-host/js-driver.js +216 -0
- package/dist/electron-host/view-manager.js +254 -0
- package/dist/server/cli/engine-resume.js +49 -0
- package/dist/server/cli/eta-estimator.js +278 -0
- package/dist/server/cli/headless/background-activity.js +109 -0
- package/dist/server/cli/headless/claude-invoker-process.js +614 -0
- package/dist/server/cli/headless/claude-invoker-stall.js +150 -0
- package/dist/server/cli/headless/claude-invoker-stream.js +555 -0
- package/dist/server/cli/headless/claude-invoker-tools.js +148 -0
- package/dist/server/cli/headless/claude-invoker.js +151 -0
- package/dist/server/cli/headless/engine-availability.js +92 -0
- package/dist/server/cli/headless/engine-notice.js +185 -0
- package/dist/server/cli/headless/haiku-assessments.js +293 -0
- package/dist/server/cli/headless/headless-logger.js +75 -0
- package/dist/server/cli/headless/index.js +9 -0
- package/dist/server/cli/headless/mcp-config.js +314 -0
- package/dist/server/cli/headless/native-timeout-detector.js +72 -0
- package/dist/server/cli/headless/output-utils.js +71 -0
- package/dist/server/cli/headless/prompt-utils.js +82 -0
- package/dist/server/cli/headless/resilient-runner.js +326 -0
- package/dist/server/cli/headless/retry-strategies.js +292 -0
- package/dist/server/cli/headless/runner.js +245 -0
- package/dist/server/cli/headless/stall-assessor.js +295 -0
- package/dist/server/cli/headless/tool-watchdog.js +447 -0
- package/dist/server/cli/headless/types.js +18 -0
- package/dist/server/cli/history-portability.js +85 -0
- package/dist/server/cli/improvisation-attachments.js +99 -0
- package/dist/server/cli/improvisation-history-store.js +121 -0
- package/dist/server/cli/improvisation-movements.js +137 -0
- package/dist/server/cli/improvisation-output-queue.js +34 -0
- package/dist/server/cli/improvisation-retry.js +8 -0
- package/dist/server/cli/improvisation-session-manager.js +1016 -0
- package/dist/server/cli/improvisation-types.js +31 -0
- package/dist/server/cli/plan-lifecycle.js +72 -0
- package/dist/server/cli/prompt-builders.js +371 -0
- package/dist/server/cli/retry/retry-best-result.js +28 -0
- package/dist/server/cli/retry/retry-context-loss.js +75 -0
- package/dist/server/cli/retry/retry-recovery-strategies.js +213 -0
- package/dist/server/cli/retry/retry-resume-strategy.js +20 -0
- package/dist/server/cli/retry/retry-runner-factory.js +92 -0
- package/dist/server/cli/retry/retry-tool-results.js +22 -0
- package/dist/server/cli/retry/retry-types.js +3 -0
- package/dist/server/engines/EngineEvent.js +57 -0
- package/dist/server/engines/claude/ClaudeCodeEngine.js +316 -0
- package/dist/server/engines/claude/claude-command.js +32 -0
- package/dist/server/engines/codex/CodexEngine.js +469 -0
- package/dist/server/engines/codex/codex-auth.js +203 -0
- package/dist/server/engines/codex/codex-invoker.js +205 -0
- package/dist/server/engines/codex/codex-provision.js +215 -0
- package/dist/server/engines/credentials/credential-probe.js +88 -0
- package/dist/server/engines/credentials/model-profiles.js +249 -0
- package/dist/server/engines/credentials/provider-credentials.js +146 -0
- package/dist/server/engines/engine-event-stream.js +52 -0
- package/dist/server/engines/execution/engine-session.js +380 -0
- package/dist/server/engines/factory.js +42 -0
- package/dist/server/engines/hermes/HermesEngine.js +628 -0
- package/dist/server/engines/hermes/hermes-auth.js +159 -0
- package/dist/server/engines/hermes/hermes-gateway-home.js +271 -0
- package/dist/server/engines/hermes/hermes-invoker.js +350 -0
- package/dist/server/engines/hermes/hermes-provision.js +318 -0
- package/dist/server/engines/read-only.js +20 -0
- package/dist/server/engines/types.js +27 -0
- package/dist/server/handlers/company-execution-registry.js +67 -0
- package/dist/server/handlers/company-handlers.js +514 -0
- package/dist/server/handlers/company-triggers.js +189 -0
- package/dist/server/handlers/company-types.js +3 -0
- package/dist/server/index.js +244 -0
- package/dist/server/mcp/app-tools-bridge.js +110 -0
- package/dist/server/mcp/app-tools-mcp-server.js +99 -0
- package/dist/server/mcp/bouncer-integration.js +744 -0
- package/dist/server/mcp/browser-mcp-server.js +915 -0
- package/dist/server/mcp/browser-redaction.js +103 -0
- package/dist/server/mcp/classifier/BouncerClassifier.js +3 -0
- package/dist/server/mcp/classifier/ClaudeBouncerClassifier.js +212 -0
- package/dist/server/mcp/classifier/factory.js +124 -0
- package/dist/server/mcp/classifier/health.js +54 -0
- package/dist/server/mcp/classifier/telemetry.js +0 -0
- package/dist/server/mcp/company-patterns.js +104 -0
- package/dist/server/mcp/department-profiles.js +133 -0
- package/dist/server/mcp/quality-bridge.js +153 -0
- package/dist/server/mcp/quality-mcp-server.js +105 -0
- package/dist/server/mcp/security-analysis.js +384 -0
- package/dist/server/mcp/security-audit.js +152 -0
- package/dist/server/mcp/security-patterns.js +314 -0
- package/dist/server/mcp/server.js +194 -0
- package/dist/server/mcp/test-utils/agent-simulator.js +301 -0
- package/dist/server/mcp/test-utils/e2e-agent.js +103 -0
- package/dist/server/mcp/test-utils/e2e-capture.js +92 -0
- package/dist/server/mcp/test-utils/e2e-client.js +116 -0
- package/dist/server/mcp/test-utils/e2e-fixtures.js +87 -0
- package/dist/server/mcp/test-utils/e2e-gating.js +8 -0
- package/dist/server/mcp/test-utils/e2e-harness.js +8 -0
- package/dist/server/mcp/test-utils/e2e-scenarios.js +105 -0
- package/dist/server/routes/files.js +18 -0
- package/dist/server/routes/improvise.js +64 -0
- package/dist/server/routes/index.js +7 -0
- package/dist/server/routes/instances.js +41 -0
- package/dist/server/routes/internal.js +900 -0
- package/dist/server/routes/notifications.js +110 -0
- package/dist/server/server-setup.js +282 -0
- package/dist/server/services/agent-push.js +148 -0
- package/dist/server/services/analytics.js +197 -0
- package/dist/server/services/apps/build.js +249 -0
- package/dist/server/services/apps/greenlight.js +199 -0
- package/dist/server/services/apps/install.js +101 -0
- package/dist/server/services/apps/layout.js +35 -0
- package/dist/server/services/apps/serve.js +665 -0
- package/dist/server/services/apps/space-apps.js +248 -0
- package/dist/server/services/auth.js +48 -0
- package/dist/server/services/browser/chrome-sandbox.js +245 -0
- package/dist/server/services/browser/chromium-launch-spec.js +51 -0
- package/dist/server/services/browser/claude-reasoner.js +669 -0
- package/dist/server/services/browser/debug-log.js +3 -0
- package/dist/server/services/browser/driver-state.js +546 -0
- package/dist/server/services/browser/electron-provision.js +256 -0
- package/dist/server/services/browser/host-internal.js +245 -0
- package/dist/server/services/browser/host-mock.js +334 -0
- package/dist/server/services/browser/host-types.js +3 -0
- package/dist/server/services/browser/host.js +1067 -0
- package/dist/server/services/browser/index.js +4 -0
- package/dist/server/services/browser/ipc-client.js +354 -0
- package/dist/server/services/browser/pipewire-sink.js +199 -0
- package/dist/server/services/browser/preflight.js +590 -0
- package/dist/server/services/browser/reasoning-agent.js +659 -0
- package/dist/server/services/browser/sandbox-policy.js +169 -0
- package/dist/server/services/browser/stderr-noise-filter.js +26 -0
- package/dist/server/services/browser/telemetry.js +107 -0
- package/dist/server/services/browser/xvfb-supervisor.js +139 -0
- package/dist/server/services/browser-frame-policy.js +56 -0
- package/dist/server/services/client-id.js +32 -0
- package/dist/server/services/collab/registry.js +408 -0
- package/dist/server/services/collab/session.js +489 -0
- package/dist/server/services/collab/text-diff.js +28 -0
- package/dist/server/services/collab/types.js +19 -0
- package/dist/server/services/e2ee-group-key.js +197 -0
- package/dist/server/services/e2ee-identity.js +203 -0
- package/dist/server/services/file-explorer-ops.js +328 -0
- package/dist/server/services/file-transfer-zip.js +188 -0
- package/dist/server/services/files.js +111 -0
- package/dist/server/services/git/branch-ops.js +62 -0
- package/dist/server/services/git/command.js +68 -0
- package/dist/server/services/git/commit-message.js +74 -0
- package/dist/server/services/git/diff-ops.js +56 -0
- package/dist/server/services/git/haiku.js +76 -0
- package/dist/server/services/git/head-watcher.js +226 -0
- package/dist/server/services/git/index.js +17 -0
- package/dist/server/services/git/log-ops.js +98 -0
- package/dist/server/services/git/merge-ops.js +314 -0
- package/dist/server/services/git/parsers.js +401 -0
- package/dist/server/services/git/remote-ops.js +192 -0
- package/dist/server/services/git/status-ops.js +105 -0
- package/dist/server/services/git/suggestion-ops.js +80 -0
- package/dist/server/services/git/tag-ops.js +36 -0
- package/dist/server/services/git/types.js +4 -0
- package/dist/server/services/git/worktree-ops.js +114 -0
- package/dist/server/services/instances.js +337 -0
- package/dist/server/services/model-catalog.js +247 -0
- package/dist/server/services/observability/posthog.js +153 -0
- package/dist/server/services/pathUtils.js +114 -0
- package/dist/server/services/plan/agent-loader.js +97 -0
- package/dist/server/services/plan/agent-manager.js +363 -0
- package/dist/server/services/plan/agent-resolver.js +74 -0
- package/dist/server/services/plan/agents/assess-stall.md +33 -0
- package/dist/server/services/plan/agents/browser-planner.md +53 -0
- package/dist/server/services/plan/agents/browser-reasoner.md +114 -0
- package/dist/server/services/plan/agents/check-injection.md +95 -0
- package/dist/server/services/plan/agents/classify-error.md +30 -0
- package/dist/server/services/plan/agents/code-review.md +142 -0
- package/dist/server/services/plan/agents/commit-message.md +28 -0
- package/dist/server/services/plan/agents/detect-context-loss.md +30 -0
- package/dist/server/services/plan/agents/execute-issue.md +58 -0
- package/dist/server/services/plan/agents/fix-quality.md +25 -0
- package/dist/server/services/plan/agents/plan-coordinator.md +72 -0
- package/dist/server/services/plan/agents/pr-description.md +29 -0
- package/dist/server/services/plan/agents/retry-task.md +27 -0
- package/dist/server/services/plan/agents/review-code.md +38 -0
- package/dist/server/services/plan/agents/review-quality.md +45 -0
- package/dist/server/services/plan/agents/triage-findings.md +78 -0
- package/dist/server/services/plan/agents/verify-review.md +57 -0
- package/dist/server/services/plan/approval-evaluator.js +143 -0
- package/dist/server/services/plan/board-archive.js +102 -0
- package/dist/server/services/plan/board-config.js +108 -0
- package/dist/server/services/plan/board-export.js +214 -0
- package/dist/server/services/plan/composer-prompt.js +115 -0
- package/dist/server/services/plan/composer.js +664 -0
- package/dist/server/services/plan/config-installer.js +103 -0
- package/dist/server/services/plan/dependency-resolver.js +137 -0
- package/dist/server/services/plan/executor.js +696 -0
- package/dist/server/services/plan/front-matter.js +43 -0
- package/dist/server/services/plan/issue-classification.js +10 -0
- package/dist/server/services/plan/issue-effort.js +182 -0
- package/dist/server/services/plan/issue-loader.js +35 -0
- package/dist/server/services/plan/issue-prompt-builder.js +152 -0
- package/dist/server/services/plan/issue-retry.js +42 -0
- package/dist/server/services/plan/issue-writer.js +102 -0
- package/dist/server/services/plan/metrics-collector.js +272 -0
- package/dist/server/services/plan/output-manager.js +77 -0
- package/dist/server/services/plan/parser-core.js +435 -0
- package/dist/server/services/plan/parser-migration.js +108 -0
- package/dist/server/services/plan/parser.js +258 -0
- package/dist/server/services/plan/plan-runner-factory.js +68 -0
- package/dist/server/services/plan/pm-timeline.js +320 -0
- package/dist/server/services/plan/progress-log.js +101 -0
- package/dist/server/services/plan/prompt-builder.js +142 -0
- package/dist/server/services/plan/quality-delta.js +274 -0
- package/dist/server/services/plan/readiness-planner.js +34 -0
- package/dist/server/services/plan/review-gate.js +409 -0
- package/dist/server/services/plan/review-report.js +134 -0
- package/dist/server/services/plan/review-verdict-stream.js +161 -0
- package/dist/server/services/plan/state-reconciler.js +238 -0
- package/dist/server/services/plan/template-diff.js +175 -0
- package/dist/server/services/plan/template-instantiator.js +516 -0
- package/dist/server/services/plan/template-manifest.js +56 -0
- package/dist/server/services/plan/template-types.js +3 -0
- package/dist/server/services/plan/trigger-evaluator.js +211 -0
- package/dist/server/services/plan/types.js +3 -0
- package/dist/server/services/plan/watcher.js +73 -0
- package/dist/server/services/platform-credentials.js +56 -0
- package/dist/server/services/platform-e2ee.js +421 -0
- package/dist/server/services/platform-envelope.js +102 -0
- package/dist/server/services/platform-heartbeat.js +88 -0
- package/dist/server/services/platform-reconnect.js +60 -0
- package/dist/server/services/platform-token-lifecycle.js +95 -0
- package/dist/server/services/platform-url.js +17 -0
- package/dist/server/services/platform.js +656 -0
- package/dist/server/services/runtime-info.js +9 -0
- package/dist/server/services/schedule/agent-schedule-store.js +232 -0
- package/dist/server/services/schedule/agent-scheduler.js +323 -0
- package/dist/server/services/schedule/daily-timing.js +105 -0
- package/dist/server/services/schedule/quality-schedule-launch.js +11 -0
- package/dist/server/services/schedule/quality-schedule-store.js +211 -0
- package/dist/server/services/schedule/quality-scheduler.js +215 -0
- package/dist/server/services/schedule/run-bootstrap.js +329 -0
- package/dist/server/services/schedule/schedule-store.js +238 -0
- package/dist/server/services/schedule/schedule-wire.js +77 -0
- package/dist/server/services/schedule/scheduler.js +310 -0
- package/dist/server/services/schedule/template-source.js +97 -0
- package/dist/server/services/sdk/agent-sessions.js +264 -0
- package/dist/server/services/sdk/agents.js +557 -0
- package/dist/server/services/sdk/app-endpoints.js +48 -0
- package/dist/server/services/sdk/app-tools.js +303 -0
- package/dist/server/services/sdk/audit.js +48 -0
- package/dist/server/services/sdk/browser-transport.js +188 -0
- package/dist/server/services/sdk/browser.js +605 -0
- package/dist/server/services/sdk/composer.js +129 -0
- package/dist/server/services/sdk/connect.js +273 -0
- package/dist/server/services/sdk/consent-cooldown.js +31 -0
- package/dist/server/services/sdk/endpoint-url.js +141 -0
- package/dist/server/services/sdk/endpoints.js +314 -0
- package/dist/server/services/sdk/file-change-notify.js +36 -0
- package/dist/server/services/sdk/files-app.js +163 -0
- package/dist/server/services/sdk/files-search.js +131 -0
- package/dist/server/services/sdk/files-transfer.js +279 -0
- package/dist/server/services/sdk/files-workspace.js +233 -0
- package/dist/server/services/sdk/git.js +520 -0
- package/dist/server/services/sdk/grant-store.js +318 -0
- package/dist/server/services/sdk/host-ops.js +84 -0
- package/dist/server/services/sdk/inference-claude.js +214 -0
- package/dist/server/services/sdk/inference.js +247 -0
- package/dist/server/services/sdk/live-registry.js +42 -0
- package/dist/server/services/sdk/local-app-bindings.js +71 -0
- package/dist/server/services/sdk/pipeline.js +190 -0
- package/dist/server/services/sdk/pm-execute.js +228 -0
- package/dist/server/services/sdk/pm-planning-tap.js +29 -0
- package/dist/server/services/sdk/pm-schedule.js +165 -0
- package/dist/server/services/sdk/pm.js +634 -0
- package/dist/server/services/sdk/quality-change-notify.js +20 -0
- package/dist/server/services/sdk/quality-schedule.js +165 -0
- package/dist/server/services/sdk/quality.js +602 -0
- package/dist/server/services/sdk/rate-limits.js +198 -0
- package/dist/server/services/sdk/registry.js +597 -0
- package/dist/server/services/sdk/revoke.js +86 -0
- package/dist/server/services/sdk/run-profile.js +41 -0
- package/dist/server/services/sdk/sandbox.js +89 -0
- package/dist/server/services/sdk/storage.js +110 -0
- package/dist/server/services/sdk/streams.js +147 -0
- package/dist/server/services/sdk/terminal.js +201 -0
- package/dist/server/services/sdk/test-utils/workshop-browser-app.js +466 -0
- package/dist/server/services/sentry.js +99 -0
- package/dist/server/services/settings.js +374 -0
- package/dist/server/services/snippets/expander.js +87 -0
- package/dist/server/services/snippets/index.js +6 -0
- package/dist/server/services/snippets/loader.js +119 -0
- package/dist/server/services/snippets/parser.js +52 -0
- package/dist/server/services/snippets/types.js +3 -0
- package/dist/server/services/snippets/watcher.js +60 -0
- package/dist/server/services/space-layout.js +80 -0
- package/dist/server/services/system-prompts.js +219 -0
- package/dist/server/services/terminal/pty-manager.js +206 -0
- package/dist/server/services/terminal/pty-utils.js +150 -0
- package/dist/server/services/timeline/assembler.js +890 -0
- package/dist/server/services/timeline/contract.js +196 -0
- package/dist/server/services/timeline/index.js +4 -0
- package/dist/server/services/websocket/agent-schedule-handlers.js +217 -0
- package/dist/server/services/websocket/apps-handlers.js +399 -0
- package/dist/server/services/websocket/ask-user-question-bridge.js +112 -0
- package/dist/server/services/websocket/autocomplete-index.js +415 -0
- package/dist/server/services/websocket/autocomplete-match.js +243 -0
- package/dist/server/services/websocket/autocomplete.js +407 -0
- package/dist/server/services/websocket/browser-agent-runtime.js +208 -0
- package/dist/server/services/websocket/browser-device-profile.js +46 -0
- package/dist/server/services/websocket/browser-handlers.js +377 -0
- package/dist/server/services/websocket/browser-host-broadcast.js +179 -0
- package/dist/server/services/websocket/browser-ice-config.js +121 -0
- package/dist/server/services/websocket/browser-payloads.js +222 -0
- package/dist/server/services/websocket/browser-viewer-lifecycle.js +84 -0
- package/dist/server/services/websocket/browser-viewer-registry.js +118 -0
- package/dist/server/services/websocket/collab-broadcast.js +11 -0
- package/dist/server/services/websocket/collab-handlers.js +116 -0
- package/dist/server/services/websocket/commit-suggestion-service.js +132 -0
- package/dist/server/services/websocket/debug-log.js +38 -0
- package/dist/server/services/websocket/dispatch-util.js +10 -0
- package/dist/server/services/websocket/engine-auth-handlers.js +323 -0
- package/dist/server/services/websocket/engine-credential-watcher.js +83 -0
- package/dist/server/services/websocket/engine-profile-handlers.js +92 -0
- package/dist/server/services/websocket/file-definition-handlers.js +180 -0
- package/dist/server/services/websocket/file-download-handler.js +291 -0
- package/dist/server/services/websocket/file-explorer-handlers.js +291 -0
- package/dist/server/services/websocket/file-search-handlers.js +267 -0
- package/dist/server/services/websocket/file-share-handlers.js +328 -0
- package/dist/server/services/websocket/file-transfer-http.js +361 -0
- package/dist/server/services/websocket/file-upload-handler.js +267 -0
- package/dist/server/services/websocket/file-utils.js +346 -0
- package/dist/server/services/websocket/git-branch-handlers.js +90 -0
- package/dist/server/services/websocket/git-diff-handlers.js +59 -0
- package/dist/server/services/websocket/git-handlers.js +212 -0
- package/dist/server/services/websocket/git-head-watcher.js +85 -0
- package/dist/server/services/websocket/git-log-handlers.js +104 -0
- package/dist/server/services/websocket/git-pr-handlers.js +56 -0
- package/dist/server/services/websocket/git-tag-handlers.js +53 -0
- package/dist/server/services/websocket/git-utils.js +11 -0
- package/dist/server/services/websocket/git-worktree-handlers.js +521 -0
- package/dist/server/services/websocket/handler-context.js +113 -0
- package/dist/server/services/websocket/handler.js +1197 -0
- package/dist/server/services/websocket/index.js +5 -0
- package/dist/server/services/websocket/movement-written-files.js +26 -0
- package/dist/server/services/websocket/msg-id-tracker.js +48 -0
- package/dist/server/services/websocket/plan-board-handlers.js +410 -0
- package/dist/server/services/websocket/plan-execution-handlers.js +244 -0
- package/dist/server/services/websocket/plan-handlers.js +67 -0
- package/dist/server/services/websocket/plan-helpers.js +161 -0
- package/dist/server/services/websocket/plan-issue-handlers.js +168 -0
- package/dist/server/services/websocket/plan-sprint-handlers.js +190 -0
- package/dist/server/services/websocket/plan-transfer-handlers.js +310 -0
- package/dist/server/services/websocket/pm-timeline-broadcast.js +28 -0
- package/dist/server/services/websocket/post-session-scan.js +132 -0
- package/dist/server/services/websocket/prompt-queue-handlers.js +96 -0
- package/dist/server/services/websocket/quality-agent-cost.js +229 -0
- package/dist/server/services/websocket/quality-agent-notes.js +113 -0
- package/dist/server/services/websocket/quality-change-activity.js +187 -0
- package/dist/server/services/websocket/quality-complexity.js +345 -0
- package/dist/server/services/websocket/quality-dependencies.js +445 -0
- package/dist/server/services/websocket/quality-duplication.js +162 -0
- package/dist/server/services/websocket/quality-eta.js +65 -0
- package/dist/server/services/websocket/quality-fingerprint.js +104 -0
- package/dist/server/services/websocket/quality-grading.js +575 -0
- package/dist/server/services/websocket/quality-handlers.js +48 -0
- package/dist/server/services/websocket/quality-linting.js +270 -0
- package/dist/server/services/websocket/quality-operations.js +54 -0
- package/dist/server/services/websocket/quality-persistence.js +410 -0
- package/dist/server/services/websocket/quality-review-agent.js +526 -0
- package/dist/server/services/websocket/quality-run.js +220 -0
- package/dist/server/services/websocket/quality-secrets.js +0 -0
- package/dist/server/services/websocket/quality-service.js +775 -0
- package/dist/server/services/websocket/quality-tools.js +383 -0
- package/dist/server/services/websocket/quality-triage-agent.js +101 -0
- package/dist/server/services/websocket/quality-types.js +149 -0
- package/dist/server/services/websocket/recommended-answers.js +28 -0
- package/dist/server/services/websocket/schedule-handlers.js +197 -0
- package/dist/server/services/websocket/sdk-agent-host.js +569 -0
- package/dist/server/services/websocket/sdk-browser-host.js +459 -0
- package/dist/server/services/websocket/sdk-composer-host.js +10 -0
- package/dist/server/services/websocket/sdk-git-host.js +115 -0
- package/dist/server/services/websocket/sdk-handlers.js +242 -0
- package/dist/server/services/websocket/sdk-pm-execution-host.js +63 -0
- package/dist/server/services/websocket/sdk-pm-schedule-host.js +21 -0
- package/dist/server/services/websocket/sdk-quality-schedule-host.js +34 -0
- package/dist/server/services/websocket/sdk-terminal-host.js +140 -0
- package/dist/server/services/websocket/session-handlers.js +565 -0
- package/dist/server/services/websocket/session-history.js +335 -0
- package/dist/server/services/websocket/session-initialization.js +315 -0
- package/dist/server/services/websocket/session-registry.js +340 -0
- package/dist/server/services/websocket/session-role-directory.js +39 -0
- package/dist/server/services/websocket/settings-handlers.js +276 -0
- package/dist/server/services/websocket/skill-handlers.js +324 -0
- package/dist/server/services/websocket/skill-watcher.js +83 -0
- package/dist/server/services/websocket/snippet-handlers.js +261 -0
- package/dist/server/services/websocket/tab-broadcast.js +35 -0
- package/dist/server/services/websocket/tab-event-buffer.js +110 -0
- package/dist/server/services/websocket/tab-event-replay.js +47 -0
- package/dist/server/services/websocket/tab-handlers.js +211 -0
- package/dist/server/services/websocket/terminal-handlers.js +268 -0
- package/dist/server/services/websocket/types.js +96 -0
- package/dist/server/types/company-messages.js +102 -0
- package/dist/server/utils/agent-manager.js +202 -0
- package/dist/server/utils/console-timestamps.js +24 -0
- package/dist/server/utils/file-store.js +112 -0
- package/dist/server/utils/paths.js +28 -0
- package/dist/server/utils/port-manager.js +43 -0
- package/dist/server/utils/port.js +204 -0
- package/electron-host/dist/agent-lease.js +141 -0
- package/electron-host/dist/capture-recovery.js +77 -0
- package/electron-host/dist/codec-policy.js +37 -0
- package/electron-host/dist/controller-channel.js +60 -0
- package/electron-host/dist/controller-handlers.js +153 -0
- package/electron-host/dist/device-emulator.js +106 -0
- package/electron-host/dist/dom-driver.js +642 -0
- package/electron-host/dist/domain-registry.js +159 -0
- package/electron-host/dist/domain-validators.js +308 -0
- package/electron-host/dist/editable-focus-reporter.js +143 -0
- package/electron-host/dist/fake-peer.test-util.js +105 -0
- package/electron-host/dist/host-log.js +31 -0
- package/electron-host/dist/host-wire.js +11 -0
- package/electron-host/dist/input-router.js +421 -0
- package/electron-host/dist/ipc-protocol.js +89 -0
- package/electron-host/dist/ipc-server.js +193 -0
- package/electron-host/dist/js-driver.js +216 -0
- package/electron-host/dist/main-guards.js +70 -0
- package/electron-host/dist/main.js +716 -0
- package/electron-host/dist/roster-sync.js +87 -0
- package/electron-host/dist/rpc-context.js +1 -0
- package/electron-host/dist/rpc-tab-methods.js +138 -0
- package/electron-host/dist/rpc-webrtc-methods.js +121 -0
- package/electron-host/dist/screen-capture-cache.js +147 -0
- package/electron-host/dist/sdk-injector.js +166 -0
- package/electron-host/dist/sdp.js +102 -0
- package/electron-host/dist/session-surface.js +78 -0
- package/electron-host/dist/surface-sizing.js +59 -0
- package/electron-host/dist/view-manager.js +254 -0
- package/electron-host/dist/viewer-registry.js +46 -0
- package/electron-host/dist/viewer-session.js +288 -0
- package/electron-host/dist/webrtc-channels.js +14 -0
- package/electron-host/dist/webrtc-controller.js +57 -0
- package/electron-host/dist/webrtc-ice-filter.js +13 -0
- package/electron-host/dist/webrtc-peer.js +45 -0
- package/electron-host/package.json +12 -0
- package/electron-host/tsconfig.json +23 -0
- package/electron-host/webrtc-controller-preload.cjs +3 -0
- package/electron-host/webrtc-controller.html +14 -0
- package/package.json +85 -0
- package/vendor/e2ee/LICENSE +14 -0
- package/vendor/e2ee/package.json +14 -0
- package/vendor/e2ee/src/index.js +310 -0
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
// Copyright (c) 2025-present Minionry, Inc.
|
|
2
|
+
// SPDX-License-Identifier: LicenseRef-Minionry-Software
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { abortMerge, completeMerge, createWorktree, createWorktreePr, discardMergeBlockers, GIT_VIEW_TAB_ID, isInsideGitRepo, isSafeDiscardPath, isValidWorktreePath, listWorktrees, mergeWorktreeBranch, popMergeStashBySha, previewMerge, pushWorktree, readCurrentBranch, removeWorktree, resolveGitDirectory, resolveMainWorktreePath, } from '../git/index.js';
|
|
6
|
+
import { resolvePmDir } from '../plan/parser.js';
|
|
7
|
+
import { dispatchByType } from './dispatch-util.js';
|
|
8
|
+
import { FILES_VIEW_TAB_ID } from './file-explorer-handlers.js';
|
|
9
|
+
import { handleGitStatus } from './git-handlers.js';
|
|
10
|
+
import { handleGitLog } from './git-log-handlers.js';
|
|
11
|
+
import { sendGitError } from './git-utils.js';
|
|
12
|
+
import { clearScope, resolveScopeDir, scopeRepoPath, scopeRepoWorktrees, scopeWorktreePath, setScopeRepo, setScopeRepoWorktree, setScopeWorktree, } from './handler-context.js';
|
|
13
|
+
import { notifySdkGitWorktreesChanged } from './sdk-git-host.js';
|
|
14
|
+
export { deriveWorktreePath, findWorktreePathForBranch, parseWorktreePorcelain, parseWorktreeStatusSummary } from '../git/index.js';
|
|
15
|
+
function persistBoardWorktree(workingDir, boardId, worktreePath, branch, repoPath) {
|
|
16
|
+
const pmDir = resolvePmDir(workingDir);
|
|
17
|
+
if (!pmDir)
|
|
18
|
+
return;
|
|
19
|
+
const wsPath = join(pmDir, 'workspace.json');
|
|
20
|
+
if (!existsSync(wsPath))
|
|
21
|
+
return;
|
|
22
|
+
try {
|
|
23
|
+
const workspace = JSON.parse(readFileSync(wsPath, 'utf-8'));
|
|
24
|
+
if (!workspace.boardWorktrees)
|
|
25
|
+
workspace.boardWorktrees = {};
|
|
26
|
+
const entry = {
|
|
27
|
+
...(worktreePath && branch ? { path: worktreePath, branch } : {}),
|
|
28
|
+
...(repoPath ? { repoPath } : {}),
|
|
29
|
+
};
|
|
30
|
+
if (entry.path || entry.repoPath)
|
|
31
|
+
workspace.boardWorktrees[boardId] = entry;
|
|
32
|
+
else
|
|
33
|
+
delete workspace.boardWorktrees[boardId];
|
|
34
|
+
writeFileSync(wsPath, JSON.stringify(workspace, null, 2), 'utf-8');
|
|
35
|
+
}
|
|
36
|
+
catch { }
|
|
37
|
+
}
|
|
38
|
+
function isBoardId(id) {
|
|
39
|
+
return id.startsWith('BOARD-');
|
|
40
|
+
}
|
|
41
|
+
export function persistScopeBinding(ctx, workingDir, scopeId) {
|
|
42
|
+
const worktreePath = scopeWorktreePath(ctx, scopeId) ?? null;
|
|
43
|
+
const repoPath = scopeRepoPath(ctx, scopeId) ?? null;
|
|
44
|
+
const branch = ctx.gitBranches.get(scopeId) ?? null;
|
|
45
|
+
const registry = ctx.getRegistry(workingDir);
|
|
46
|
+
registry.updateTabWorktree(scopeId, worktreePath, branch);
|
|
47
|
+
registry.updateTabRepoPath(scopeId, repoPath);
|
|
48
|
+
registry.updateTabRepoWorktrees(scopeId, scopeRepoWorktrees(ctx, scopeId));
|
|
49
|
+
if (isBoardId(scopeId))
|
|
50
|
+
persistBoardWorktree(workingDir, scopeId, worktreePath, branch, repoPath);
|
|
51
|
+
}
|
|
52
|
+
export async function handleGitWorktreeMessage(ctx, ws, msg, tabId, gitDir, workingDir) {
|
|
53
|
+
const handlers = {
|
|
54
|
+
gitWorktreeList: () => handleGitWorktreeList(ctx, ws, msg, tabId, gitDir),
|
|
55
|
+
gitWorktreeCreate: () => handleGitWorktreeCreate(ctx, ws, msg, tabId, gitDir),
|
|
56
|
+
gitWorktreeCreateAndAssign: () => handleGitWorktreeCreateAndAssign(ctx, ws, msg, tabId, gitDir, workingDir),
|
|
57
|
+
gitWorktreeRemove: () => handleGitWorktreeRemove(ctx, ws, msg, tabId, gitDir, workingDir),
|
|
58
|
+
tabWorktreeSwitch: () => handleTabWorktreeSwitch(ctx, ws, msg, tabId, workingDir),
|
|
59
|
+
tabRepoWorktreeSwitch: () => handleTabRepoWorktreeSwitch(ctx, ws, msg, tabId, workingDir),
|
|
60
|
+
gitWorktreePush: () => handleGitWorktreePush(ctx, ws, msg, tabId, gitDir),
|
|
61
|
+
gitWorktreeCreatePR: () => handleGitWorktreeCreatePR(ctx, ws, msg, tabId, gitDir),
|
|
62
|
+
gitMergePreview: () => handleGitMergePreview(ctx, ws, msg, tabId, gitDir),
|
|
63
|
+
gitWorktreeMerge: () => handleGitWorktreeMerge(ctx, ws, msg, tabId, gitDir, workingDir),
|
|
64
|
+
gitMergeAbort: () => handleGitMergeAbort(ctx, ws, msg, tabId, gitDir),
|
|
65
|
+
gitMergeComplete: () => handleGitMergeComplete(ctx, ws, msg, tabId, gitDir),
|
|
66
|
+
gitMergeStashPop: () => handleGitMergeStashPop(ctx, ws, msg, tabId, gitDir),
|
|
67
|
+
gitMergeDiscardBlockers: () => handleGitMergeDiscardBlockers(ctx, ws, msg, tabId, gitDir),
|
|
68
|
+
};
|
|
69
|
+
await dispatchByType(handlers, 'git-worktree', msg.type, (type) => {
|
|
70
|
+
sendGitError(ctx, ws, tabId, `Unknown git worktree message type: ${type}`);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async function handleGitWorktreeList(ctx, ws, msg, tabId, workingDir) {
|
|
74
|
+
try {
|
|
75
|
+
const includeStatus = msg.data?.includeStatus === true;
|
|
76
|
+
const result = await listWorktrees({ cwd: workingDir, includeStatus });
|
|
77
|
+
if (!result.ok) {
|
|
78
|
+
sendGitError(ctx, ws, tabId, result.error);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
ctx.send(ws, {
|
|
82
|
+
type: 'gitWorktreeListResult',
|
|
83
|
+
tabId,
|
|
84
|
+
data: includeStatus ? { worktrees: result.value, withStatus: true } : { worktrees: result.value },
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
sendGitError(ctx, ws, tabId, error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function handleGitWorktreeCreate(ctx, ws, msg, tabId, workingDir) {
|
|
92
|
+
try {
|
|
93
|
+
const { branchName, baseBranch, path: worktreePath } = msg.data || {};
|
|
94
|
+
if (!branchName) {
|
|
95
|
+
sendGitError(ctx, ws, tabId, 'Branch name is required');
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const result = await createWorktree({ cwd: workingDir, branchName, baseBranch, path: worktreePath });
|
|
99
|
+
if (!result.ok) {
|
|
100
|
+
sendGitError(ctx, ws, tabId, result.error);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
ctx.send(ws, {
|
|
104
|
+
type: 'gitWorktreeCreated',
|
|
105
|
+
tabId,
|
|
106
|
+
data: { path: result.value.path, branch: result.value.branch, head: result.value.head },
|
|
107
|
+
});
|
|
108
|
+
notifySdkGitWorktreesChanged();
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
sendGitError(ctx, ws, tabId, error);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function handleGitWorktreeCreateAndAssign(ctx, ws, msg, tabId, gitDir, workingDir) {
|
|
115
|
+
try {
|
|
116
|
+
const { branchName, baseBranch, path: worktreePath } = msg.data || {};
|
|
117
|
+
if (!branchName) {
|
|
118
|
+
sendGitError(ctx, ws, tabId, 'Branch name is required');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const result = await createWorktree({ cwd: gitDir, branchName, baseBranch, path: worktreePath });
|
|
122
|
+
if (!result.ok) {
|
|
123
|
+
sendGitError(ctx, ws, tabId, result.error);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const { path: wtPath, head } = result.value;
|
|
127
|
+
setScopeWorktree(ctx, tabId, wtPath);
|
|
128
|
+
ctx.gitBranches.set(tabId, branchName);
|
|
129
|
+
persistScopeBinding(ctx, workingDir, tabId);
|
|
130
|
+
ctx.send(ws, {
|
|
131
|
+
type: 'gitWorktreeCreatedAndAssigned',
|
|
132
|
+
tabId,
|
|
133
|
+
data: { tabId, path: wtPath, branch: branchName, head },
|
|
134
|
+
});
|
|
135
|
+
notifySdkGitWorktreesChanged();
|
|
136
|
+
handleGitStatus(ctx, ws, tabId, wtPath);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
sendGitError(ctx, ws, tabId, error);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function cleanupWorktreeReferences(ctx, workingDir, wtPath) {
|
|
143
|
+
const resolvedWtPath = join(wtPath);
|
|
144
|
+
const matchesRemoved = (path) => path === resolvedWtPath || path === wtPath;
|
|
145
|
+
for (const [tid, scope] of [...ctx.gitScopes]) {
|
|
146
|
+
if (matchesRemoved(scope.worktreePath)) {
|
|
147
|
+
setScopeWorktree(ctx, tid, null);
|
|
148
|
+
ctx.gitBranches.delete(tid);
|
|
149
|
+
persistScopeBinding(ctx, workingDir, tid);
|
|
150
|
+
}
|
|
151
|
+
const removedRepoRoots = Object.entries(scope.repoWorktrees ?? {})
|
|
152
|
+
.filter(([, entry]) => matchesRemoved(entry.worktreePath))
|
|
153
|
+
.map(([repoRoot]) => repoRoot);
|
|
154
|
+
if (removedRepoRoots.length === 0)
|
|
155
|
+
continue;
|
|
156
|
+
for (const repoRoot of removedRepoRoots)
|
|
157
|
+
setScopeRepoWorktree(ctx, tid, repoRoot, null);
|
|
158
|
+
persistScopeBinding(ctx, workingDir, tid);
|
|
159
|
+
ctx.broadcastToAll({ type: 'tabRepoWorktreesSwitched', tabId: tid, data: { tabId: tid, ...repoWorktreeSnapshot(ctx, tid) } });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async function handleGitWorktreeRemove(ctx, ws, msg, tabId, gitDir, workingDir) {
|
|
163
|
+
try {
|
|
164
|
+
const { path: wtPath, force, deleteBranch } = msg.data || {};
|
|
165
|
+
if (!wtPath) {
|
|
166
|
+
sendGitError(ctx, ws, tabId, 'Worktree path is required');
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const cwd = await resolveMainWorktreePath(gitDir);
|
|
170
|
+
const result = await removeWorktree({ cwd, path: wtPath, force, deleteBranch });
|
|
171
|
+
if (!result.ok) {
|
|
172
|
+
sendGitError(ctx, ws, tabId, result.error);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
cleanupWorktreeReferences(ctx, workingDir, wtPath);
|
|
176
|
+
ctx.send(ws, { type: 'gitWorktreeRemoved', tabId, data: { path: wtPath } });
|
|
177
|
+
notifySdkGitWorktreesChanged();
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
sendGitError(ctx, ws, tabId, error);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
export async function handleTabWorktreeSwitch(ctx, ws, msg, tabId, workingDir) {
|
|
184
|
+
try {
|
|
185
|
+
const { tabId: targetTabId, worktreePath, allowCustom } = msg.data || {};
|
|
186
|
+
const resolvedTabId = targetTabId || tabId;
|
|
187
|
+
if (!worktreePath) {
|
|
188
|
+
setScopeWorktree(ctx, resolvedTabId, null);
|
|
189
|
+
ctx.gitBranches.delete(resolvedTabId);
|
|
190
|
+
persistScopeBinding(ctx, workingDir, resolvedTabId);
|
|
191
|
+
const repoPath = scopeRepoPath(ctx, resolvedTabId) ?? null;
|
|
192
|
+
ctx.send(ws, { type: 'tabWorktreeSwitched', tabId: resolvedTabId, data: { tabId: resolvedTabId, worktreePath: null, branch: null, repoPath } });
|
|
193
|
+
notifySdkGitWorktreesChanged();
|
|
194
|
+
refreshScopeAfterWorktreeSwitch(ctx, ws, resolvedTabId, repoPath ?? workingDir);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const repoDir = scopeRepoPath(ctx, resolvedTabId) ?? workingDir;
|
|
198
|
+
const isRegistered = await isValidWorktreePath(worktreePath, repoDir);
|
|
199
|
+
if (!isRegistered && !(allowCustom === true && (await isInsideGitRepo(worktreePath)))) {
|
|
200
|
+
sendGitError(ctx, ws, tabId, `'${worktreePath}' is not a registered worktree of this scope's repository`);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
setScopeWorktree(ctx, resolvedTabId, worktreePath);
|
|
204
|
+
const branch = await readCurrentBranch(worktreePath);
|
|
205
|
+
ctx.gitBranches.set(resolvedTabId, branch);
|
|
206
|
+
persistScopeBinding(ctx, workingDir, resolvedTabId);
|
|
207
|
+
ctx.send(ws, {
|
|
208
|
+
type: 'tabWorktreeSwitched',
|
|
209
|
+
tabId: resolvedTabId,
|
|
210
|
+
data: { tabId: resolvedTabId, worktreePath, branch, repoPath: scopeRepoPath(ctx, resolvedTabId) ?? null },
|
|
211
|
+
});
|
|
212
|
+
notifySdkGitWorktreesChanged();
|
|
213
|
+
refreshScopeAfterWorktreeSwitch(ctx, ws, resolvedTabId, worktreePath);
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
sendGitError(ctx, ws, tabId, error);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function refreshScopeAfterWorktreeSwitch(ctx, ws, tabId, gitDir) {
|
|
220
|
+
if (tabId === FILES_VIEW_TAB_ID)
|
|
221
|
+
return;
|
|
222
|
+
(async () => {
|
|
223
|
+
await handleGitStatus(ctx, ws, tabId, gitDir);
|
|
224
|
+
await handleGitLog(ctx, ws, { type: 'gitLog', tabId, data: { limit: 20 } }, tabId, gitDir);
|
|
225
|
+
})().catch((error) => {
|
|
226
|
+
console.error('[handleTabWorktreeSwitch] scope refresh failed:', error);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
const APP_HOST_SCOPE_ID = '__app_host__';
|
|
230
|
+
function isAgentTabScope(scopeId) {
|
|
231
|
+
return !isBoardId(scopeId) && scopeId !== GIT_VIEW_TAB_ID && scopeId !== FILES_VIEW_TAB_ID && scopeId !== APP_HOST_SCOPE_ID;
|
|
232
|
+
}
|
|
233
|
+
function repoWorktreeSnapshot(ctx, scopeId) {
|
|
234
|
+
return {
|
|
235
|
+
repoWorktrees: scopeRepoWorktrees(ctx, scopeId),
|
|
236
|
+
worktreePath: scopeWorktreePath(ctx, scopeId) ?? null,
|
|
237
|
+
repoPath: scopeRepoPath(ctx, scopeId) ?? null,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function sendTabRepoWorktreesSwitched(ctx, ws, scopeId, requestId, error) {
|
|
241
|
+
const data = {
|
|
242
|
+
tabId: scopeId,
|
|
243
|
+
...repoWorktreeSnapshot(ctx, scopeId),
|
|
244
|
+
...(requestId ? { requestId } : {}),
|
|
245
|
+
...(error ? { error } : {}),
|
|
246
|
+
};
|
|
247
|
+
ctx.send(ws, { type: 'tabRepoWorktreesSwitched', tabId: scopeId, data });
|
|
248
|
+
}
|
|
249
|
+
async function adoptLegacyAxes(ctx, scopeId) {
|
|
250
|
+
const legacyWorktree = scopeWorktreePath(ctx, scopeId);
|
|
251
|
+
const legacyRepo = scopeRepoPath(ctx, scopeId);
|
|
252
|
+
if (!legacyWorktree && !legacyRepo)
|
|
253
|
+
return;
|
|
254
|
+
if (legacyWorktree) {
|
|
255
|
+
const root = await resolveMainWorktreePath(legacyWorktree);
|
|
256
|
+
const alreadyMapped = scopeRepoWorktrees(ctx, scopeId).some((selection) => selection.repoRoot === root);
|
|
257
|
+
if (root !== legacyWorktree && !alreadyMapped) {
|
|
258
|
+
setScopeRepoWorktree(ctx, scopeId, root, { worktreePath: legacyWorktree, branch: ctx.gitBranches.get(scopeId) ?? null });
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
setScopeWorktree(ctx, scopeId, null);
|
|
262
|
+
setScopeRepo(ctx, scopeId, null);
|
|
263
|
+
ctx.gitBranches.delete(scopeId);
|
|
264
|
+
}
|
|
265
|
+
function normalizeBranch(branch) {
|
|
266
|
+
return branch === 'HEAD' || branch === '' ? null : branch;
|
|
267
|
+
}
|
|
268
|
+
async function validateRepoPath(workingDir, repoPath) {
|
|
269
|
+
const resolved = await resolveGitDirectory({ cwd: workingDir, directory: repoPath });
|
|
270
|
+
if (!resolved.ok)
|
|
271
|
+
return { error: resolved.error };
|
|
272
|
+
if (!(await isInsideGitRepo(resolved.value.directory)))
|
|
273
|
+
return { error: `'${repoPath}' is not a git repository` };
|
|
274
|
+
return { repoRoot: await resolveMainWorktreePath(resolved.value.directory) };
|
|
275
|
+
}
|
|
276
|
+
async function applySelectOp(ctx, scopeId, workingDir, data) {
|
|
277
|
+
const validated = await validateRepoPath(workingDir, data.repoPath);
|
|
278
|
+
if ('error' in validated)
|
|
279
|
+
return validated.error;
|
|
280
|
+
const { repoRoot } = validated;
|
|
281
|
+
if (data.worktreePath === null || data.worktreePath === repoRoot) {
|
|
282
|
+
await adoptLegacyAxes(ctx, scopeId);
|
|
283
|
+
setScopeRepoWorktree(ctx, scopeId, repoRoot, null);
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
if (!(await isValidWorktreePath(data.worktreePath, repoRoot))) {
|
|
287
|
+
return `'${data.worktreePath}' is not a registered worktree of ${repoRoot}`;
|
|
288
|
+
}
|
|
289
|
+
const branch = normalizeBranch(await readCurrentBranch(data.worktreePath));
|
|
290
|
+
await adoptLegacyAxes(ctx, scopeId);
|
|
291
|
+
setScopeRepoWorktree(ctx, scopeId, repoRoot, { worktreePath: data.worktreePath, branch });
|
|
292
|
+
return undefined;
|
|
293
|
+
}
|
|
294
|
+
async function applyCreateOp(ctx, scopeId, workingDir, data) {
|
|
295
|
+
const validated = await validateRepoPath(workingDir, data.repoPath);
|
|
296
|
+
if ('error' in validated)
|
|
297
|
+
return validated.error;
|
|
298
|
+
const { repoRoot } = validated;
|
|
299
|
+
const branchName = data.branchName.trim();
|
|
300
|
+
if (!branchName)
|
|
301
|
+
return 'Branch name is required';
|
|
302
|
+
const result = await createWorktree({ cwd: repoRoot, branchName, baseBranch: data.baseBranch });
|
|
303
|
+
if (!result.ok)
|
|
304
|
+
return result.error;
|
|
305
|
+
await adoptLegacyAxes(ctx, scopeId);
|
|
306
|
+
setScopeRepoWorktree(ctx, scopeId, repoRoot, { worktreePath: result.value.path, branch: branchName });
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
309
|
+
function refreshScopeAfterRepoWorktreeSwitch(ctx, ws, scopeId, gitDir) {
|
|
310
|
+
handleGitStatus(ctx, ws, scopeId, gitDir).catch((error) => {
|
|
311
|
+
console.error('[handleTabRepoWorktreeSwitch] scope refresh failed:', error);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
async function processTabRepoWorktreeSwitch(ctx, ws, scopeId, workingDir, data) {
|
|
315
|
+
const requestId = data.requestId;
|
|
316
|
+
if (!isAgentTabScope(scopeId)) {
|
|
317
|
+
sendTabRepoWorktreesSwitched(ctx, ws, scopeId, requestId, `'${scopeId}' is not an Agent tab — per-repo worktree selections are Agent-tab only`);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
try {
|
|
321
|
+
if (data.op === 'clear') {
|
|
322
|
+
clearScope(ctx, scopeId);
|
|
323
|
+
ctx.gitBranches.delete(scopeId);
|
|
324
|
+
persistScopeBinding(ctx, workingDir, scopeId);
|
|
325
|
+
sendTabRepoWorktreesSwitched(ctx, ws, scopeId, requestId);
|
|
326
|
+
notifySdkGitWorktreesChanged();
|
|
327
|
+
refreshScopeAfterRepoWorktreeSwitch(ctx, ws, scopeId, resolveScopeDir(ctx, scopeId, workingDir));
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (data.op !== 'select' && data.op !== 'create') {
|
|
331
|
+
sendTabRepoWorktreesSwitched(ctx, ws, scopeId, requestId, `Unknown tabRepoWorktreeSwitch op: ${String(data.op)}`);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const error = data.op === 'select'
|
|
335
|
+
? await applySelectOp(ctx, scopeId, workingDir, data)
|
|
336
|
+
: await applyCreateOp(ctx, scopeId, workingDir, data);
|
|
337
|
+
if (error) {
|
|
338
|
+
sendTabRepoWorktreesSwitched(ctx, ws, scopeId, requestId, error);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
persistScopeBinding(ctx, workingDir, scopeId);
|
|
342
|
+
sendTabRepoWorktreesSwitched(ctx, ws, scopeId, requestId);
|
|
343
|
+
notifySdkGitWorktreesChanged();
|
|
344
|
+
refreshScopeAfterRepoWorktreeSwitch(ctx, ws, scopeId, resolveScopeDir(ctx, scopeId, workingDir));
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
sendTabRepoWorktreesSwitched(ctx, ws, scopeId, requestId, error instanceof Error ? error.message : String(error));
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const repoWorktreeSwitchQueues = new Map();
|
|
351
|
+
function runSerializedForScope(scopeId, run) {
|
|
352
|
+
const prior = repoWorktreeSwitchQueues.get(scopeId) ?? Promise.resolve();
|
|
353
|
+
const current = prior
|
|
354
|
+
.catch(() => { })
|
|
355
|
+
.then(run)
|
|
356
|
+
.catch((error) => {
|
|
357
|
+
console.error(`[handleTabRepoWorktreeSwitch] command failed for scope ${scopeId}:`, error);
|
|
358
|
+
})
|
|
359
|
+
.finally(() => {
|
|
360
|
+
if (repoWorktreeSwitchQueues.get(scopeId) === current)
|
|
361
|
+
repoWorktreeSwitchQueues.delete(scopeId);
|
|
362
|
+
});
|
|
363
|
+
repoWorktreeSwitchQueues.set(scopeId, current);
|
|
364
|
+
return current;
|
|
365
|
+
}
|
|
366
|
+
export async function handleTabRepoWorktreeSwitch(ctx, ws, msg, tabId, workingDir) {
|
|
367
|
+
const data = (msg.data || {});
|
|
368
|
+
const scopeId = data.tabId || tabId;
|
|
369
|
+
await runSerializedForScope(scopeId, () => processTabRepoWorktreeSwitch(ctx, ws, scopeId, workingDir, data));
|
|
370
|
+
}
|
|
371
|
+
async function handleGitWorktreePush(ctx, ws, msg, tabId, _workingDir) {
|
|
372
|
+
try {
|
|
373
|
+
const { worktreePath, remote, branch, setUpstream } = msg.data || {};
|
|
374
|
+
if (!worktreePath) {
|
|
375
|
+
sendGitError(ctx, ws, tabId, 'Worktree path is required');
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const result = await pushWorktree({ cwd: worktreePath, remote, branch, setUpstream });
|
|
379
|
+
if (!result.ok) {
|
|
380
|
+
sendGitError(ctx, ws, tabId, result.error);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
ctx.send(ws, { type: 'gitWorktreePushed', tabId, data: { output: result.value.output, upstream: result.value.upstream } });
|
|
384
|
+
}
|
|
385
|
+
catch (error) {
|
|
386
|
+
sendGitError(ctx, ws, tabId, error);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
async function handleGitWorktreeCreatePR(ctx, ws, msg, tabId, _workingDir) {
|
|
390
|
+
try {
|
|
391
|
+
const { worktreePath, title, body, baseBranch, draft } = msg.data || {};
|
|
392
|
+
if (!worktreePath) {
|
|
393
|
+
sendGitError(ctx, ws, tabId, 'Worktree path is required');
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const result = await createWorktreePr({ cwd: worktreePath, title, body, baseBranch, draft });
|
|
397
|
+
if (!result.ok) {
|
|
398
|
+
sendGitError(ctx, ws, tabId, result.error);
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
ctx.send(ws, { type: 'gitWorktreePRCreated', tabId, data: { prUrl: result.value.prUrl, prNumber: result.value.prNumber } });
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
sendGitError(ctx, ws, tabId, error);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
async function handleGitMergePreview(ctx, ws, msg, tabId, workingDir) {
|
|
408
|
+
try {
|
|
409
|
+
const { sourceBranch, targetBranch } = msg.data || {};
|
|
410
|
+
if (!sourceBranch || !targetBranch) {
|
|
411
|
+
sendGitError(ctx, ws, tabId, 'Source and target branches are required');
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
const preview = await previewMerge({ cwd: workingDir, sourceBranch, targetBranch });
|
|
415
|
+
ctx.send(ws, { type: 'gitMergePreviewResult', tabId, data: preview });
|
|
416
|
+
}
|
|
417
|
+
catch (error) {
|
|
418
|
+
sendGitError(ctx, ws, tabId, error);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
async function handleGitWorktreeMerge(ctx, ws, msg, tabId, gitDir, workingDir) {
|
|
422
|
+
try {
|
|
423
|
+
const { sourceBranch, targetBranch, strategy, commitMessage, deleteWorktree, deleteBranch, stashFirst } = msg.data || {};
|
|
424
|
+
if (!sourceBranch || !targetBranch || !strategy) {
|
|
425
|
+
sendGitError(ctx, ws, tabId, 'Source branch, target branch, and strategy are required');
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const { data, removedWorktreePath } = await mergeWorktreeBranch({
|
|
429
|
+
cwd: gitDir, sourceBranch, targetBranch, strategy,
|
|
430
|
+
commitMessage, deleteWorktree, deleteBranch, stashFirst,
|
|
431
|
+
});
|
|
432
|
+
if (removedWorktreePath)
|
|
433
|
+
cleanupWorktreeReferences(ctx, workingDir, removedWorktreePath);
|
|
434
|
+
ctx.send(ws, {
|
|
435
|
+
type: 'gitWorktreeMergeResult',
|
|
436
|
+
tabId,
|
|
437
|
+
data: removedWorktreePath ? { ...data, removedWorktreePath } : data,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
catch (error) {
|
|
441
|
+
sendGitError(ctx, ws, tabId, error);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
async function handleGitMergeStashPop(ctx, ws, msg, tabId, workingDir) {
|
|
445
|
+
try {
|
|
446
|
+
const { stashSha, targetWorktreePath } = msg.data || {};
|
|
447
|
+
if (!stashSha) {
|
|
448
|
+
ctx.send(ws, { type: 'gitMergeStashPopped', tabId, data: { success: false, error: 'Missing stash reference' } });
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
const path = targetWorktreePath || (await resolveMainWorktreePath(workingDir));
|
|
452
|
+
const result = await popMergeStashBySha(path, stashSha);
|
|
453
|
+
if (result.exitCode !== 0) {
|
|
454
|
+
ctx.send(ws, { type: 'gitMergeStashPopped', tabId, data: { success: false, error: result.error || 'Failed to pop stash', targetWorktreePath: path } });
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
ctx.send(ws, { type: 'gitMergeStashPopped', tabId, data: { success: true, targetWorktreePath: path } });
|
|
458
|
+
handleGitStatus(ctx, ws, tabId, path);
|
|
459
|
+
}
|
|
460
|
+
catch (error) {
|
|
461
|
+
sendGitError(ctx, ws, tabId, error);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
async function handleGitMergeDiscardBlockers(ctx, ws, msg, tabId, workingDir) {
|
|
465
|
+
try {
|
|
466
|
+
const { paths, targetWorktreePath } = msg.data || {};
|
|
467
|
+
if (!Array.isArray(paths) || paths.length === 0) {
|
|
468
|
+
ctx.send(ws, { type: 'gitMergeBlockersDiscarded', tabId, data: { success: false, error: 'No paths to discard' } });
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
if (!paths.every(isSafeDiscardPath)) {
|
|
472
|
+
ctx.send(ws, { type: 'gitMergeBlockersDiscarded', tabId, data: { success: false, error: 'Invalid path in discard list' } });
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
const path = targetWorktreePath || (await resolveMainWorktreePath(workingDir));
|
|
476
|
+
const result = await discardMergeBlockers({ cwd: path, paths });
|
|
477
|
+
if (!result.ok) {
|
|
478
|
+
ctx.send(ws, {
|
|
479
|
+
type: 'gitMergeBlockersDiscarded',
|
|
480
|
+
tabId,
|
|
481
|
+
data: { success: false, error: result.error, targetWorktreePath: path },
|
|
482
|
+
});
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
ctx.send(ws, { type: 'gitMergeBlockersDiscarded', tabId, data: { success: true, targetWorktreePath: path, paths } });
|
|
486
|
+
handleGitStatus(ctx, ws, tabId, path);
|
|
487
|
+
}
|
|
488
|
+
catch (error) {
|
|
489
|
+
sendGitError(ctx, ws, tabId, error);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
function mergeResolutionTarget(msg) {
|
|
493
|
+
const { targetWorktreePath } = msg.data || {};
|
|
494
|
+
return typeof targetWorktreePath === 'string' && targetWorktreePath.length > 0 ? targetWorktreePath : undefined;
|
|
495
|
+
}
|
|
496
|
+
async function handleGitMergeAbort(ctx, ws, msg, tabId, workingDir) {
|
|
497
|
+
try {
|
|
498
|
+
const result = await abortMerge({ cwd: workingDir, targetWorktreePath: mergeResolutionTarget(msg) });
|
|
499
|
+
if (!result.ok) {
|
|
500
|
+
sendGitError(ctx, ws, tabId, result.error);
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
ctx.send(ws, { type: 'gitMergeAborted', tabId, data: { aborted: true } });
|
|
504
|
+
}
|
|
505
|
+
catch (error) {
|
|
506
|
+
sendGitError(ctx, ws, tabId, error);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
async function handleGitMergeComplete(ctx, ws, msg, tabId, workingDir) {
|
|
510
|
+
try {
|
|
511
|
+
const result = await completeMerge({ cwd: workingDir, targetWorktreePath: mergeResolutionTarget(msg) });
|
|
512
|
+
if (!result.ok) {
|
|
513
|
+
sendGitError(ctx, ws, tabId, result.error);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
ctx.send(ws, { type: 'gitMergeCompleted', tabId, data: { success: true, mergeCommit: result.value.mergeCommit } });
|
|
517
|
+
}
|
|
518
|
+
catch (error) {
|
|
519
|
+
sendGitError(ctx, ws, tabId, error);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Copyright (c) 2025-present Minionry, Inc.
|
|
2
|
+
// SPDX-License-Identifier: LicenseRef-Minionry-Software
|
|
3
|
+
function redirectThroughRepoWorktrees(map, base) {
|
|
4
|
+
if (!map)
|
|
5
|
+
return undefined;
|
|
6
|
+
let longestRoot;
|
|
7
|
+
for (const root of Object.keys(map)) {
|
|
8
|
+
if (base !== root && !base.startsWith(`${root}/`))
|
|
9
|
+
continue;
|
|
10
|
+
if (!longestRoot || root.length > longestRoot.length)
|
|
11
|
+
longestRoot = root;
|
|
12
|
+
}
|
|
13
|
+
return longestRoot === undefined ? undefined : map[longestRoot].worktreePath + base.slice(longestRoot.length);
|
|
14
|
+
}
|
|
15
|
+
export function resolveScopeDir(ctx, scopeId, workingDir) {
|
|
16
|
+
const scope = ctx.gitScopes.get(scopeId);
|
|
17
|
+
if (scope?.worktreePath)
|
|
18
|
+
return scope.worktreePath;
|
|
19
|
+
const base = scope?.repoPath ?? workingDir;
|
|
20
|
+
return redirectThroughRepoWorktrees(scope?.repoWorktrees, base) ?? base;
|
|
21
|
+
}
|
|
22
|
+
export function scopeExecutionDir(ctx, scopeId, workingDir) {
|
|
23
|
+
const scope = ctx.gitScopes.get(scopeId);
|
|
24
|
+
if (scope?.worktreePath)
|
|
25
|
+
return scope.worktreePath;
|
|
26
|
+
if (scope?.repoPath)
|
|
27
|
+
return redirectThroughRepoWorktrees(scope.repoWorktrees, scope.repoPath) ?? scope.repoPath;
|
|
28
|
+
if (workingDir === undefined)
|
|
29
|
+
return undefined;
|
|
30
|
+
return redirectThroughRepoWorktrees(scope?.repoWorktrees, workingDir);
|
|
31
|
+
}
|
|
32
|
+
export function scopeRepoWorktrees(ctx, scopeId) {
|
|
33
|
+
const map = ctx.gitScopes.get(scopeId)?.repoWorktrees;
|
|
34
|
+
if (!map)
|
|
35
|
+
return [];
|
|
36
|
+
return Object.entries(map)
|
|
37
|
+
.map(([repoRoot, entry]) => ({ repoRoot, worktreePath: entry.worktreePath, branch: entry.branch }))
|
|
38
|
+
.sort((a, b) => a.repoRoot.localeCompare(b.repoRoot));
|
|
39
|
+
}
|
|
40
|
+
export function setScopeRepoWorktree(ctx, scopeId, repoRoot, entry) {
|
|
41
|
+
const next = { ...ctx.gitScopes.get(scopeId)?.repoWorktrees };
|
|
42
|
+
if (entry)
|
|
43
|
+
next[repoRoot] = entry;
|
|
44
|
+
else
|
|
45
|
+
delete next[repoRoot];
|
|
46
|
+
mutateScope(ctx, scopeId, { repoWorktrees: next });
|
|
47
|
+
}
|
|
48
|
+
export function scopeWorktreePath(ctx, scopeId) {
|
|
49
|
+
return ctx.gitScopes.get(scopeId)?.worktreePath;
|
|
50
|
+
}
|
|
51
|
+
export function scopeRepoPath(ctx, scopeId) {
|
|
52
|
+
return ctx.gitScopes.get(scopeId)?.repoPath;
|
|
53
|
+
}
|
|
54
|
+
export function hasScopeBinding(ctx, scopeId) {
|
|
55
|
+
return ctx.gitScopes.has(scopeId);
|
|
56
|
+
}
|
|
57
|
+
function mutateScope(ctx, scopeId, patch) {
|
|
58
|
+
const next = { ...ctx.gitScopes.get(scopeId), ...patch };
|
|
59
|
+
if (!next.repoPath)
|
|
60
|
+
delete next.repoPath;
|
|
61
|
+
if (!next.worktreePath)
|
|
62
|
+
delete next.worktreePath;
|
|
63
|
+
if (next.repoWorktrees && Object.keys(next.repoWorktrees).length === 0)
|
|
64
|
+
delete next.repoWorktrees;
|
|
65
|
+
if (!next.repoPath && !next.worktreePath && !next.repoWorktrees)
|
|
66
|
+
ctx.gitScopes.delete(scopeId);
|
|
67
|
+
else
|
|
68
|
+
ctx.gitScopes.set(scopeId, next);
|
|
69
|
+
ctx.gitHeadWatcher?.retrack();
|
|
70
|
+
}
|
|
71
|
+
export function setScopeWorktree(ctx, scopeId, worktreePath) {
|
|
72
|
+
mutateScope(ctx, scopeId, { worktreePath: worktreePath ?? undefined });
|
|
73
|
+
}
|
|
74
|
+
export function setScopeRepo(ctx, scopeId, repoPath) {
|
|
75
|
+
mutateScope(ctx, scopeId, { repoPath: repoPath ?? undefined });
|
|
76
|
+
}
|
|
77
|
+
export function clearScope(ctx, scopeId) {
|
|
78
|
+
if (!ctx.gitScopes.delete(scopeId))
|
|
79
|
+
return;
|
|
80
|
+
ctx.gitHeadWatcher?.retrack();
|
|
81
|
+
}
|
|
82
|
+
export function trackedScopeDirs(ctx) {
|
|
83
|
+
const entries = [];
|
|
84
|
+
for (const [scopeId, scope] of ctx.gitScopes) {
|
|
85
|
+
const dir = scope.worktreePath ?? scope.repoPath;
|
|
86
|
+
if (dir)
|
|
87
|
+
entries.push([scopeId, dir]);
|
|
88
|
+
}
|
|
89
|
+
return entries;
|
|
90
|
+
}
|
|
91
|
+
export function trackedScopeRepoPaths(ctx) {
|
|
92
|
+
const roots = new Set();
|
|
93
|
+
for (const scope of ctx.gitScopes.values()) {
|
|
94
|
+
if (scope.repoPath)
|
|
95
|
+
roots.add(scope.repoPath);
|
|
96
|
+
if (scope.repoWorktrees) {
|
|
97
|
+
for (const repoRoot of Object.keys(scope.repoWorktrees))
|
|
98
|
+
roots.add(repoRoot);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return [...roots];
|
|
102
|
+
}
|
|
103
|
+
export function trackedRepoWorktreeEntries(ctx) {
|
|
104
|
+
const entries = [];
|
|
105
|
+
for (const [scopeId, scope] of ctx.gitScopes) {
|
|
106
|
+
if (!scope.repoWorktrees)
|
|
107
|
+
continue;
|
|
108
|
+
for (const [repoRoot, entry] of Object.entries(scope.repoWorktrees)) {
|
|
109
|
+
entries.push([scopeId, repoRoot, entry.worktreePath]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return entries;
|
|
113
|
+
}
|