@paperclipai/server 2026.817.0 → 2026.818.0-beta.1
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/adapters/hermes-gateway-doc.d.ts +1 -1
- package/dist/adapters/hermes-gateway-doc.d.ts.map +1 -1
- package/dist/adapters/hermes-gateway-doc.js +1 -1
- package/dist/adapters/plugin-loader.d.ts.map +1 -1
- package/dist/adapters/plugin-loader.js +3 -2
- package/dist/adapters/plugin-loader.js.map +1 -1
- package/dist/agent-auth-jwt.d.ts.map +1 -1
- package/dist/agent-auth-jwt.js +8 -2
- package/dist/agent-auth-jwt.js.map +1 -1
- package/dist/app.d.ts +5 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +202 -15
- package/dist/app.js.map +1 -1
- package/dist/built-ins/agents/summarizer/AGENTS.md +2 -2
- package/dist/built-ins/agents/summarizer/routines/refresh-stale-summaries.md +1 -0
- package/dist/db-errors.d.ts +9 -0
- package/dist/db-errors.d.ts.map +1 -1
- package/dist/db-errors.js +19 -0
- package/dist/db-errors.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -2
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +162 -38
- package/dist/index.js.map +1 -1
- package/dist/lib/request-promise-memo.d.ts +6 -0
- package/dist/lib/request-promise-memo.d.ts.map +1 -0
- package/dist/lib/request-promise-memo.js +25 -0
- package/dist/lib/request-promise-memo.js.map +1 -0
- package/dist/lib/request-promise-memo.test.d.ts +2 -0
- package/dist/lib/request-promise-memo.test.d.ts.map +1 -0
- package/dist/lib/request-promise-memo.test.js +74 -0
- package/dist/lib/request-promise-memo.test.js.map +1 -0
- package/dist/middleware/auth.d.ts +13 -1
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +92 -41
- package/dist/middleware/auth.js.map +1 -1
- package/dist/middleware/cloud-tenant-actor.test.js +26 -1
- package/dist/middleware/cloud-tenant-actor.test.js.map +1 -1
- package/dist/middleware/error-handler.d.ts.map +1 -1
- package/dist/middleware/error-handler.js +11 -2
- package/dist/middleware/error-handler.js.map +1 -1
- package/dist/middleware/logger.d.ts.map +1 -1
- package/dist/middleware/logger.js +7 -33
- package/dist/middleware/logger.js.map +1 -1
- package/dist/middleware/private-hostname-guard.d.ts.map +1 -1
- package/dist/middleware/private-hostname-guard.js +11 -6
- package/dist/middleware/private-hostname-guard.js.map +1 -1
- package/dist/middleware/private-json-etag.d.ts +3 -0
- package/dist/middleware/private-json-etag.d.ts.map +1 -0
- package/dist/middleware/private-json-etag.js +37 -0
- package/dist/middleware/private-json-etag.js.map +1 -0
- package/dist/middleware/redact-sensitive.d.ts.map +1 -1
- package/dist/middleware/redact-sensitive.js +11 -0
- package/dist/middleware/redact-sensitive.js.map +1 -1
- package/dist/realtime/live-events-ws.d.ts +12 -0
- package/dist/realtime/live-events-ws.d.ts.map +1 -1
- package/dist/realtime/live-events-ws.js +20 -0
- package/dist/realtime/live-events-ws.js.map +1 -1
- package/dist/redaction.js +1 -1
- package/dist/redaction.js.map +1 -1
- package/dist/routes/access.d.ts +2 -0
- package/dist/routes/access.d.ts.map +1 -1
- package/dist/routes/access.js +21 -10
- package/dist/routes/access.js.map +1 -1
- package/dist/routes/agents.d.ts +42 -0
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/agents.js +875 -8
- package/dist/routes/agents.js.map +1 -1
- package/dist/routes/companies.d.ts +5 -1
- package/dist/routes/companies.d.ts.map +1 -1
- package/dist/routes/companies.js +467 -30
- package/dist/routes/companies.js.map +1 -1
- package/dist/routes/environments.d.ts +12 -3
- package/dist/routes/environments.d.ts.map +1 -1
- package/dist/routes/environments.js +139 -23
- package/dist/routes/environments.js.map +1 -1
- package/dist/routes/execution-workspaces.d.ts.map +1 -1
- package/dist/routes/execution-workspaces.js +240 -70
- package/dist/routes/execution-workspaces.js.map +1 -1
- package/dist/routes/file-resources.d.ts +14 -1
- package/dist/routes/file-resources.d.ts.map +1 -1
- package/dist/routes/file-resources.js +182 -3
- package/dist/routes/file-resources.js.map +1 -1
- package/dist/routes/index.d.ts +2 -1
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +2 -1
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/instance-settings.d.ts.map +1 -1
- package/dist/routes/instance-settings.js +20 -1
- package/dist/routes/instance-settings.js.map +1 -1
- package/dist/routes/issues.d.ts.map +1 -1
- package/dist/routes/issues.js +750 -235
- package/dist/routes/issues.js.map +1 -1
- package/dist/routes/onboarding-seed.d.ts +27 -0
- package/dist/routes/onboarding-seed.d.ts.map +1 -0
- package/dist/routes/onboarding-seed.js +56 -0
- package/dist/routes/onboarding-seed.js.map +1 -0
- package/dist/routes/openapi.d.ts.map +1 -1
- package/dist/routes/openapi.js +316 -2
- package/dist/routes/openapi.js.map +1 -1
- package/dist/routes/secrets.d.ts.map +1 -1
- package/dist/routes/secrets.js +11 -1
- package/dist/routes/secrets.js.map +1 -1
- package/dist/routes/setup-token-route.test.d.ts +2 -0
- package/dist/routes/setup-token-route.test.d.ts.map +1 -0
- package/dist/routes/setup-token-route.test.js +896 -0
- package/dist/routes/setup-token-route.test.js.map +1 -0
- package/dist/routes/tool-access.d.ts.map +1 -1
- package/dist/routes/tool-access.js +87 -52
- package/dist/routes/tool-access.js.map +1 -1
- package/dist/routes/workspace-runtime-service-authz.d.ts +11 -1
- package/dist/routes/workspace-runtime-service-authz.d.ts.map +1 -1
- package/dist/routes/workspace-runtime-service-authz.js +18 -16
- package/dist/routes/workspace-runtime-service-authz.js.map +1 -1
- package/dist/services/access.d.ts.map +1 -1
- package/dist/services/activity.d.ts +1 -1
- package/dist/services/agents.d.ts +21 -0
- package/dist/services/agents.d.ts.map +1 -1
- package/dist/services/agents.js +121 -1
- package/dist/services/agents.js.map +1 -1
- package/dist/services/attention-resolver-audience.test.d.ts +2 -0
- package/dist/services/attention-resolver-audience.test.d.ts.map +1 -0
- package/dist/services/attention-resolver-audience.test.js +81 -0
- package/dist/services/attention-resolver-audience.test.js.map +1 -0
- package/dist/services/attention.d.ts +20 -1
- package/dist/services/attention.d.ts.map +1 -1
- package/dist/services/attention.js +45 -1
- package/dist/services/attention.js.map +1 -1
- package/dist/services/authorization.d.ts +2 -2
- package/dist/services/authorization.d.ts.map +1 -1
- package/dist/services/authorization.js +89 -46
- package/dist/services/authorization.js.map +1 -1
- package/dist/services/board-auth.d.ts.map +1 -1
- package/dist/services/board-auth.js +40 -1
- package/dist/services/board-auth.js.map +1 -1
- package/dist/services/board-auth.test.d.ts +2 -0
- package/dist/services/board-auth.test.d.ts.map +1 -0
- package/dist/services/board-auth.test.js +34 -0
- package/dist/services/board-auth.test.js.map +1 -0
- package/dist/services/built-in-agents.d.ts.map +1 -1
- package/dist/services/built-in-agents.js +20 -4
- package/dist/services/built-in-agents.js.map +1 -1
- package/dist/services/bundled-plugins.d.ts +11 -1
- package/dist/services/bundled-plugins.d.ts.map +1 -1
- package/dist/services/bundled-plugins.js +46 -1
- package/dist/services/bundled-plugins.js.map +1 -1
- package/dist/services/codex-device-login-reaper.d.ts +61 -0
- package/dist/services/codex-device-login-reaper.d.ts.map +1 -0
- package/dist/services/codex-device-login-reaper.js +219 -0
- package/dist/services/codex-device-login-reaper.js.map +1 -0
- package/dist/services/codex-device-login-service.d.ts +355 -0
- package/dist/services/codex-device-login-service.d.ts.map +1 -0
- package/dist/services/codex-device-login-service.js +775 -0
- package/dist/services/codex-device-login-service.js.map +1 -0
- package/dist/services/companies.d.ts.map +1 -1
- package/dist/services/companies.js +7 -0
- package/dist/services/companies.js.map +1 -1
- package/dist/services/company-export-readme.js +1 -1
- package/dist/services/company-export-readme.js.map +1 -1
- package/dist/services/company-import-transfers.d.ts +55 -0
- package/dist/services/company-import-transfers.d.ts.map +1 -0
- package/dist/services/company-import-transfers.js +151 -0
- package/dist/services/company-import-transfers.js.map +1 -0
- package/dist/services/company-portability.d.ts.map +1 -1
- package/dist/services/company-portability.js +128 -3
- package/dist/services/company-portability.js.map +1 -1
- package/dist/services/company-transfer-runs.d.ts +136 -0
- package/dist/services/company-transfer-runs.d.ts.map +1 -0
- package/dist/services/company-transfer-runs.js +243 -0
- package/dist/services/company-transfer-runs.js.map +1 -0
- package/dist/services/cross-issue-influence-limit.d.ts +7 -1
- package/dist/services/cross-issue-influence-limit.d.ts.map +1 -1
- package/dist/services/cross-issue-influence-limit.js.map +1 -1
- package/dist/services/environment-config.d.ts +15 -0
- package/dist/services/environment-config.d.ts.map +1 -1
- package/dist/services/environment-config.js +56 -10
- package/dist/services/environment-config.js.map +1 -1
- package/dist/services/environment-execution-target.d.ts.map +1 -1
- package/dist/services/environment-execution-target.js +61 -11
- package/dist/services/environment-execution-target.js.map +1 -1
- package/dist/services/environment-run-orchestrator.d.ts +16 -1
- package/dist/services/environment-run-orchestrator.d.ts.map +1 -1
- package/dist/services/environment-run-orchestrator.js +1 -1
- package/dist/services/environment-run-orchestrator.js.map +1 -1
- package/dist/services/environment-runtime.d.ts +178 -2
- package/dist/services/environment-runtime.d.ts.map +1 -1
- package/dist/services/environment-runtime.js +1035 -96
- package/dist/services/environment-runtime.js.map +1 -1
- package/dist/services/environments.d.ts +75 -0
- package/dist/services/environments.d.ts.map +1 -1
- package/dist/services/environments.js +199 -8
- package/dist/services/environments.js.map +1 -1
- package/dist/services/execution-allowlist.d.ts +16 -4
- package/dist/services/execution-allowlist.d.ts.map +1 -1
- package/dist/services/execution-allowlist.js +35 -16
- package/dist/services/execution-allowlist.js.map +1 -1
- package/dist/services/execution-allowlist.test.js +33 -0
- package/dist/services/execution-allowlist.test.js.map +1 -1
- package/dist/services/execution-workspace-policy.d.ts +14 -1
- package/dist/services/execution-workspace-policy.d.ts.map +1 -1
- package/dist/services/execution-workspace-policy.js +29 -12
- package/dist/services/execution-workspace-policy.js.map +1 -1
- package/dist/services/execution-workspaces.d.ts +89 -0
- package/dist/services/execution-workspaces.d.ts.map +1 -1
- package/dist/services/execution-workspaces.js +997 -125
- package/dist/services/execution-workspaces.js.map +1 -1
- package/dist/services/heartbeat-run-summary.d.ts +1 -0
- package/dist/services/heartbeat-run-summary.d.ts.map +1 -1
- package/dist/services/heartbeat-run-summary.js +19 -3
- package/dist/services/heartbeat-run-summary.js.map +1 -1
- package/dist/services/heartbeat.d.ts +18 -2
- package/dist/services/heartbeat.d.ts.map +1 -1
- package/dist/services/heartbeat.js +369 -16
- package/dist/services/heartbeat.js.map +1 -1
- package/dist/services/import-write-types.d.ts +12 -0
- package/dist/services/import-write-types.d.ts.map +1 -1
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +2 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/instance-settings.d.ts +10 -1
- package/dist/services/instance-settings.d.ts.map +1 -1
- package/dist/services/instance-settings.js +16 -9
- package/dist/services/instance-settings.js.map +1 -1
- package/dist/services/issue-review-policy.d.ts +4 -0
- package/dist/services/issue-review-policy.d.ts.map +1 -1
- package/dist/services/issue-review-policy.js +18 -7
- package/dist/services/issue-review-policy.js.map +1 -1
- package/dist/services/issue-thread-interaction-resolution.d.ts +92 -0
- package/dist/services/issue-thread-interaction-resolution.d.ts.map +1 -0
- package/dist/services/issue-thread-interaction-resolution.js +198 -0
- package/dist/services/issue-thread-interaction-resolution.js.map +1 -0
- package/dist/services/issue-thread-interaction-resolution.test.d.ts +2 -0
- package/dist/services/issue-thread-interaction-resolution.test.d.ts.map +1 -0
- package/dist/services/issue-thread-interaction-resolution.test.js +152 -0
- package/dist/services/issue-thread-interaction-resolution.test.js.map +1 -0
- package/dist/services/issue-thread-interactions.d.ts +24 -4
- package/dist/services/issue-thread-interactions.d.ts.map +1 -1
- package/dist/services/issue-thread-interactions.js +360 -145
- package/dist/services/issue-thread-interactions.js.map +1 -1
- package/dist/services/issue-thread-interactions.test.js +18 -11
- package/dist/services/issue-thread-interactions.test.js.map +1 -1
- package/dist/services/issues.d.ts +3 -0
- package/dist/services/issues.d.ts.map +1 -1
- package/dist/services/issues.js +157 -33
- package/dist/services/issues.js.map +1 -1
- package/dist/services/local-service-supervisor.d.ts +2 -0
- package/dist/services/local-service-supervisor.d.ts.map +1 -1
- package/dist/services/local-service-supervisor.js +53 -3
- package/dist/services/local-service-supervisor.js.map +1 -1
- package/dist/services/managed-environments.d.ts +4 -1
- package/dist/services/managed-environments.d.ts.map +1 -1
- package/dist/services/managed-environments.js +86 -2
- package/dist/services/managed-environments.js.map +1 -1
- package/dist/services/managed-environments.test.js +164 -0
- package/dist/services/managed-environments.test.js.map +1 -1
- package/dist/services/onboarding-greeting.d.ts +7 -0
- package/dist/services/onboarding-greeting.d.ts.map +1 -0
- package/dist/services/onboarding-greeting.js +27 -0
- package/dist/services/onboarding-greeting.js.map +1 -0
- package/dist/services/onboarding-greeting.test.d.ts +2 -0
- package/dist/services/onboarding-greeting.test.d.ts.map +1 -0
- package/dist/services/onboarding-greeting.test.js +32 -0
- package/dist/services/onboarding-greeting.test.js.map +1 -0
- package/dist/services/onboarding-seed.d.ts +57 -0
- package/dist/services/onboarding-seed.d.ts.map +1 -0
- package/dist/services/onboarding-seed.js +344 -0
- package/dist/services/onboarding-seed.js.map +1 -0
- package/dist/services/plan-review-context.d.ts +9 -1
- package/dist/services/plan-review-context.d.ts.map +1 -1
- package/dist/services/plan-review-context.js +192 -0
- package/dist/services/plan-review-context.js.map +1 -1
- package/dist/services/plugin-environment-driver.d.ts +46 -0
- package/dist/services/plugin-environment-driver.d.ts.map +1 -1
- package/dist/services/plugin-environment-driver.js +50 -0
- package/dist/services/plugin-environment-driver.js.map +1 -1
- package/dist/services/plugin-host-services.d.ts +1 -0
- package/dist/services/plugin-host-services.d.ts.map +1 -1
- package/dist/services/plugin-host-services.js +51 -28
- package/dist/services/plugin-host-services.js.map +1 -1
- package/dist/services/plugin-loader.d.ts +10 -1
- package/dist/services/plugin-loader.d.ts.map +1 -1
- package/dist/services/plugin-loader.js +43 -2
- package/dist/services/plugin-loader.js.map +1 -1
- package/dist/services/plugin-worker-manager.d.ts +61 -0
- package/dist/services/plugin-worker-manager.d.ts.map +1 -1
- package/dist/services/plugin-worker-manager.js +248 -1
- package/dist/services/plugin-worker-manager.js.map +1 -1
- package/dist/services/productivity-review.d.ts.map +1 -1
- package/dist/services/productivity-review.js +5 -0
- package/dist/services/productivity-review.js.map +1 -1
- package/dist/services/recovery/service.d.ts.map +1 -1
- package/dist/services/recovery/service.js +5 -1
- package/dist/services/recovery/service.js.map +1 -1
- package/dist/services/recovery/successful-run-handoff.d.ts +16 -1
- package/dist/services/recovery/successful-run-handoff.d.ts.map +1 -1
- package/dist/services/recovery/successful-run-handoff.js +32 -0
- package/dist/services/recovery/successful-run-handoff.js.map +1 -1
- package/dist/services/recovery/successful-run-handoff.test.js +51 -1
- package/dist/services/recovery/successful-run-handoff.test.js.map +1 -1
- package/dist/services/routines.d.ts.map +1 -1
- package/dist/services/routines.js +48 -4
- package/dist/services/routines.js.map +1 -1
- package/dist/services/runtime-exposure/broker-client.d.ts +88 -0
- package/dist/services/runtime-exposure/broker-client.d.ts.map +1 -0
- package/dist/services/runtime-exposure/broker-client.js +217 -0
- package/dist/services/runtime-exposure/broker-client.js.map +1 -0
- package/dist/services/runtime-exposure/broker-client.test.d.ts +2 -0
- package/dist/services/runtime-exposure/broker-client.test.d.ts.map +1 -0
- package/dist/services/runtime-exposure/broker-client.test.js +185 -0
- package/dist/services/runtime-exposure/broker-client.test.js.map +1 -0
- package/dist/services/runtime-exposure/exposure-manager.d.ts +135 -0
- package/dist/services/runtime-exposure/exposure-manager.d.ts.map +1 -0
- package/dist/services/runtime-exposure/exposure-manager.js +247 -0
- package/dist/services/runtime-exposure/exposure-manager.js.map +1 -0
- package/dist/services/runtime-exposure/exposure-manager.test.d.ts +2 -0
- package/dist/services/runtime-exposure/exposure-manager.test.d.ts.map +1 -0
- package/dist/services/runtime-exposure/exposure-manager.test.js +384 -0
- package/dist/services/runtime-exposure/exposure-manager.test.js.map +1 -0
- package/dist/services/runtime-exposure/loopback-listener.d.ts +33 -0
- package/dist/services/runtime-exposure/loopback-listener.d.ts.map +1 -0
- package/dist/services/runtime-exposure/loopback-listener.js +146 -0
- package/dist/services/runtime-exposure/loopback-listener.js.map +1 -0
- package/dist/services/runtime-exposure/loopback-listener.test.d.ts +2 -0
- package/dist/services/runtime-exposure/loopback-listener.test.d.ts.map +1 -0
- package/dist/services/runtime-exposure/loopback-listener.test.js +116 -0
- package/dist/services/runtime-exposure/loopback-listener.test.js.map +1 -0
- package/dist/services/runtime-exposure/port-pair.d.ts +47 -0
- package/dist/services/runtime-exposure/port-pair.d.ts.map +1 -0
- package/dist/services/runtime-exposure/port-pair.js +57 -0
- package/dist/services/runtime-exposure/port-pair.js.map +1 -0
- package/dist/services/runtime-exposure/port-pair.test.d.ts +2 -0
- package/dist/services/runtime-exposure/port-pair.test.d.ts.map +1 -0
- package/dist/services/runtime-exposure/port-pair.test.js +92 -0
- package/dist/services/runtime-exposure/port-pair.test.js.map +1 -0
- package/dist/services/runtime-exposure/port-reservation.d.ts +211 -0
- package/dist/services/runtime-exposure/port-reservation.d.ts.map +1 -0
- package/dist/services/runtime-exposure/port-reservation.js +380 -0
- package/dist/services/runtime-exposure/port-reservation.js.map +1 -0
- package/dist/services/runtime-exposure/port-reservation.test.d.ts +2 -0
- package/dist/services/runtime-exposure/port-reservation.test.d.ts.map +1 -0
- package/dist/services/runtime-exposure/port-reservation.test.js +456 -0
- package/dist/services/runtime-exposure/port-reservation.test.js.map +1 -0
- package/dist/services/runtime-exposure/tailscale-hostname.d.ts +11 -0
- package/dist/services/runtime-exposure/tailscale-hostname.d.ts.map +1 -0
- package/dist/services/runtime-exposure/tailscale-hostname.js +36 -0
- package/dist/services/runtime-exposure/tailscale-hostname.js.map +1 -0
- package/dist/services/runtime-exposure/tailscale-hostname.test.d.ts +2 -0
- package/dist/services/runtime-exposure/tailscale-hostname.test.d.ts.map +1 -0
- package/dist/services/runtime-exposure/tailscale-hostname.test.js +14 -0
- package/dist/services/runtime-exposure/tailscale-hostname.test.js.map +1 -0
- package/dist/services/sandbox-orphan-cleanup-spool.d.ts +64 -0
- package/dist/services/sandbox-orphan-cleanup-spool.d.ts.map +1 -0
- package/dist/services/sandbox-orphan-cleanup-spool.js +134 -0
- package/dist/services/sandbox-orphan-cleanup-spool.js.map +1 -0
- package/dist/services/sandbox-provider-runtime.d.ts +15 -0
- package/dist/services/sandbox-provider-runtime.d.ts.map +1 -1
- package/dist/services/sandbox-provider-runtime.js +1 -0
- package/dist/services/sandbox-provider-runtime.js.map +1 -1
- package/dist/services/secrets.d.ts +103 -0
- package/dist/services/secrets.d.ts.map +1 -1
- package/dist/services/secrets.js +432 -10
- package/dist/services/secrets.js.map +1 -1
- package/dist/services/setup-token-session.d.ts +630 -0
- package/dist/services/setup-token-session.d.ts.map +1 -0
- package/dist/services/setup-token-session.js +1005 -0
- package/dist/services/setup-token-session.js.map +1 -0
- package/dist/services/setup-token-session.test.d.ts +2 -0
- package/dist/services/setup-token-session.test.d.ts.map +1 -0
- package/dist/services/setup-token-session.test.js +1143 -0
- package/dist/services/setup-token-session.test.js.map +1 -0
- package/dist/services/setup-token-transport-binding.d.ts +202 -0
- package/dist/services/setup-token-transport-binding.d.ts.map +1 -0
- package/dist/services/setup-token-transport-binding.js +386 -0
- package/dist/services/setup-token-transport-binding.js.map +1 -0
- package/dist/services/setup-token-transport-binding.test.d.ts +2 -0
- package/dist/services/setup-token-transport-binding.test.d.ts.map +1 -0
- package/dist/services/setup-token-transport-binding.test.js +761 -0
- package/dist/services/setup-token-transport-binding.test.js.map +1 -0
- package/dist/services/summary-slots.d.ts.map +1 -1
- package/dist/services/summary-slots.js +40 -6
- package/dist/services/summary-slots.js.map +1 -1
- package/dist/services/task-watchdogs.js +2 -2
- package/dist/services/task-watchdogs.js.map +1 -1
- package/dist/services/tool-access-policy.d.ts +1 -1
- package/dist/services/tool-access.d.ts.map +1 -1
- package/dist/services/tool-access.js +29 -11
- package/dist/services/tool-access.js.map +1 -1
- package/dist/services/tool-gateway.d.ts +1 -1
- package/dist/services/tool-gateway.d.ts.map +1 -1
- package/dist/services/tool-gateway.js +56 -5
- package/dist/services/tool-gateway.js.map +1 -1
- package/dist/services/workspace-file-resources.d.ts +10 -1
- package/dist/services/workspace-file-resources.d.ts.map +1 -1
- package/dist/services/workspace-file-resources.js +258 -6
- package/dist/services/workspace-file-resources.js.map +1 -1
- package/dist/services/workspace-git-operation-scheduler.d.ts +135 -0
- package/dist/services/workspace-git-operation-scheduler.d.ts.map +1 -0
- package/dist/services/workspace-git-operation-scheduler.js +655 -0
- package/dist/services/workspace-git-operation-scheduler.js.map +1 -0
- package/dist/services/workspace-git-operation-scheduler.test.d.ts +2 -0
- package/dist/services/workspace-git-operation-scheduler.test.d.ts.map +1 -0
- package/dist/services/workspace-git-operation-scheduler.test.js +367 -0
- package/dist/services/workspace-git-operation-scheduler.test.js.map +1 -0
- package/dist/services/workspace-operations.d.ts +60 -0
- package/dist/services/workspace-operations.d.ts.map +1 -1
- package/dist/services/workspace-operations.js +384 -19
- package/dist/services/workspace-operations.js.map +1 -1
- package/dist/services/workspace-runtime-exposure-backfill.test.d.ts +2 -0
- package/dist/services/workspace-runtime-exposure-backfill.test.d.ts.map +1 -0
- package/dist/services/workspace-runtime-exposure-backfill.test.js +149 -0
- package/dist/services/workspace-runtime-exposure-backfill.test.js.map +1 -0
- package/dist/services/workspace-runtime-exposure.test.d.ts +2 -0
- package/dist/services/workspace-runtime-exposure.test.d.ts.map +1 -0
- package/dist/services/workspace-runtime-exposure.test.js +517 -0
- package/dist/services/workspace-runtime-exposure.test.js.map +1 -0
- package/dist/services/workspace-runtime-leases.d.ts +90 -0
- package/dist/services/workspace-runtime-leases.d.ts.map +1 -0
- package/dist/services/workspace-runtime-leases.js +252 -0
- package/dist/services/workspace-runtime-leases.js.map +1 -0
- package/dist/services/workspace-runtime-read-model.d.ts +12 -0
- package/dist/services/workspace-runtime-read-model.d.ts.map +1 -1
- package/dist/services/workspace-runtime-read-model.test.js +3 -0
- package/dist/services/workspace-runtime-read-model.test.js.map +1 -1
- package/dist/services/workspace-runtime-ready-comment.test.js +1 -0
- package/dist/services/workspace-runtime-ready-comment.test.js.map +1 -1
- package/dist/services/workspace-runtime.d.ts +160 -2
- package/dist/services/workspace-runtime.d.ts.map +1 -1
- package/dist/services/workspace-runtime.js +1693 -141
- package/dist/services/workspace-runtime.js.map +1 -1
- package/dist/shutdown.d.ts +24 -0
- package/dist/shutdown.d.ts.map +1 -1
- package/dist/shutdown.js +37 -0
- package/dist/shutdown.js.map +1 -1
- package/dist/shutdown.test.js +113 -1
- package/dist/shutdown.test.js.map +1 -1
- package/dist/startup-banner.js +1 -1
- package/dist/startup-banner.js.map +1 -1
- package/dist/url-utils.d.ts +26 -0
- package/dist/url-utils.d.ts.map +1 -0
- package/dist/url-utils.js +59 -0
- package/dist/url-utils.js.map +1 -0
- package/dist/url-utils.test.d.ts +2 -0
- package/dist/url-utils.test.d.ts.map +1 -0
- package/dist/url-utils.test.js +55 -0
- package/dist/url-utils.test.js.map +1 -0
- package/dist/worktree-config.d.ts.map +1 -1
- package/dist/worktree-config.js +3 -17
- package/dist/worktree-config.js.map +1 -1
- package/package.json +20 -20
- package/skills/paperclip/SKILL.md +16 -11
- package/skills/paperclip/references/api-reference.md +8 -5
- package/skills/paperclip-board/SKILL.md +1 -1
- package/ui-dist/assets/{abnfDiagram-VRR7QNED-wvSnvD6-.js → abnfDiagram-N423BO3Z-BvgoV-u5.js} +1 -1
- package/ui-dist/assets/{arc-Bx0V1JsN.js → arc-BInnUBUU.js} +1 -1
- package/ui-dist/assets/architectureDiagram-T3A2C74G-Dg4MziOm.js +36 -0
- package/ui-dist/assets/{blockDiagram-677ZJIJ3-BROcLaUk.js → blockDiagram-VBNYF7ZC-D9kzAkLN.js} +1 -1
- package/ui-dist/assets/{c4Diagram-LMCZKHZV-D-V3kgju.js → c4Diagram-5PPSVZJV-BwzsgV_0.js} +1 -1
- package/ui-dist/assets/channel-qoSYbCn0.js +1 -0
- package/ui-dist/assets/{chunk-32BRIVSS-qillH3H6.js → chunk-2GRJ4B5K-D2EQ9vrl.js} +1 -1
- package/ui-dist/assets/{chunk-2Q5K7J3B-D19cVnii.js → chunk-2Q5K7J3B-DOA_8fSd.js} +1 -1
- package/ui-dist/assets/{chunk-EX3LRPZG-CLUswrZg.js → chunk-5RXB4S5H-CT5ukRiT.js} +1 -1
- package/ui-dist/assets/{chunk-5VM5RSS4-Cwlp02Lx.js → chunk-5VM5RSS4-D2gOlkyB.js} +1 -1
- package/ui-dist/assets/{chunk-MOJQB5TN-yKciyq6E.js → chunk-6Q2QTUOP-DUb6aG8c.js} +1 -1
- package/ui-dist/assets/{chunk-V7JOEXUC-DjJ75g0_.js → chunk-GF5L2VYU-BPabG3Cx.js} +1 -1
- package/ui-dist/assets/{chunk-JWPE2WC7-BjepyzEb.js → chunk-JWPE2WC7-scNfhlZz.js} +1 -1
- package/ui-dist/assets/{chunk-VR4S4FIN-CiEmy8-R.js → chunk-KBJHAD2P-BcRAzRpq.js} +1 -1
- package/ui-dist/assets/{chunk-RYQCIY6F-ed7mQM9j.js → chunk-RYQCIY6F-BiZ0-EGh.js} +1 -1
- package/ui-dist/assets/{chunk-XXDRQBXY-BiI83zoO.js → chunk-XXDRQBXY-lJULxFIE.js} +1 -1
- package/ui-dist/assets/classDiagram-JCYQIIEL-B24u1REs.js +1 -0
- package/ui-dist/assets/classDiagram-v2-OCEON4UE-B24u1REs.js +1 -0
- package/ui-dist/assets/{cose-bilkent-JH36ORCC-DIdQf5ta.js → cose-bilkent-JH36ORCC-Do8pe8JB.js} +1 -1
- package/ui-dist/assets/{cynefin-VYW2F7L2-B2m9xxh8.js → cynefin-VYW2F7L2-B34jJY1x.js} +1 -1
- package/ui-dist/assets/{cynefinDiagram-TSTJHNR4-CGVdB0kX.js → cynefinDiagram-MW4NZA55-DQ8QK8JK.js} +1 -1
- package/ui-dist/assets/cytoscape.esm-DShqj__B.js +321 -0
- package/ui-dist/assets/{dagre-VKFMJZFB-CskKiZwJ.js → dagre-VZM6K2ZE-B7lSKgxH.js} +1 -1
- package/ui-dist/assets/{diagram-OA4YK3LP-D2cn5eIN.js → diagram-7IWD3JNH-B3hLAFGE.js} +1 -1
- package/ui-dist/assets/{diagram-FQU43EPY-oa5Zu0XG.js → diagram-B4RE2ZJO-CH9Ro9e0.js} +1 -1
- package/ui-dist/assets/{diagram-NH7WQ7WH-fymti5Js.js → diagram-LBJQPF4R-DdPVMii7.js} +1 -1
- package/ui-dist/assets/{diagram-G47NLZAW-BWF2ZCsw.js → diagram-Q27KOJAE-f5VXswjc.js} +1 -1
- package/ui-dist/assets/diagram-UB23O5K3-DGqxixsR.js +41 -0
- package/ui-dist/assets/{ebnfDiagram-CCIWWBDH-CJ1d3D5q.js → ebnfDiagram-BXEA7PRR-C-1klg_w.js} +1 -1
- package/ui-dist/assets/{erDiagram-Q63AITRT-BJCPa7kK.js → erDiagram-JOGREHBK-Dt4qK4gv.js} +1 -1
- package/ui-dist/assets/{flowDiagram-23GEKE2U-BWjWuz6r.js → flowDiagram-UKHOOZJN-9ZlrTuET.js} +5 -5
- package/ui-dist/assets/{ganttDiagram-NO4QXBWP-Dv1KKjoM.js → ganttDiagram-PKOTCBZU-CE3lyvFq.js} +1 -1
- package/ui-dist/assets/{gitGraphDiagram-IHSO6WYX-9X7vgL0A.js → gitGraphDiagram-DS77QQ5N-HH2fSgad.js} +1 -1
- package/ui-dist/assets/{index-CpaK48ok.js → index-B61ORkIb.js} +1 -1
- package/ui-dist/assets/index-BHiUiToL.css +1 -0
- package/ui-dist/assets/{index-D2YCrA-D.js → index-BY5ITKmG.js} +1 -1
- package/ui-dist/assets/{index-9JMDmXc5.js → index-BbAhzCq8.js} +1 -1
- package/ui-dist/assets/{index-C5qHatpp.js → index-Bc9g6q63.js} +1 -1
- package/ui-dist/assets/{index-DuI6e5mP.js → index-Bf7tyGxE.js} +1 -1
- package/ui-dist/assets/{index-BahRsj0s.js → index-BvFx-4KW.js} +1 -1
- package/ui-dist/assets/{index-DKlsEDV7.js → index-C1mpWCcn.js} +1 -1
- package/ui-dist/assets/{index-DIXaXZrW.js → index-CHXG4GPL.js} +1 -1
- package/ui-dist/assets/{index-DcfO6NoY.js → index-CLu3Tfpv.js} +1 -1
- package/ui-dist/assets/{index-Cfz6P0Qq.js → index-CQhaM6qd.js} +1 -1
- package/ui-dist/assets/{index-D9d3sl6K.js → index-CVTL3aAL.js} +1 -1
- package/ui-dist/assets/{index-BexA3NAl.js → index-CcRTJ93J.js} +1 -1
- package/ui-dist/assets/{index-CnBrDwGT.js → index-Cm6iEYPt.js} +247 -223
- package/ui-dist/assets/{index-ByGcu-MB.js → index-DQIrrn2L.js} +1 -1
- package/ui-dist/assets/{index-DKEzHO7c.js → index-DU4U1fuv.js} +1 -1
- package/ui-dist/assets/{index-pqJO8FsV.js → index-DV2FOgyD.js} +1 -1
- package/ui-dist/assets/{index-tDuieU3u.js → index-DceuCrr8.js} +1 -1
- package/ui-dist/assets/{index-CjN2lm_w.js → index-DlVBBF8o.js} +1 -1
- package/ui-dist/assets/{index-0yJtUsFh.js → index-DsdVneqe.js} +1 -1
- package/ui-dist/assets/{index-C2a4_IKU.js → index-DvFUXI-Q.js} +1 -1
- package/ui-dist/assets/{index-BTMiDMYv.js → index-FHzrJ7iQ.js} +1 -1
- package/ui-dist/assets/{index-cUQXJtLK.js → index-diFs0CNC.js} +1 -1
- package/ui-dist/assets/{index-C96LHV1A.js → index-hkanj4t6.js} +1 -1
- package/ui-dist/assets/{index-rDI1Q4r9.js → index-yRJnh4vx.js} +1 -1
- package/ui-dist/assets/{infoDiagram-FWYZ7A6U-CHIhutSb.js → infoDiagram-6WML65LV-2jai2fw-.js} +1 -1
- package/ui-dist/assets/{ishikawaDiagram-FXEZZL3T-ChaD7-5_.js → ishikawaDiagram-WSZJBQD7-CUmGhmEb.js} +1 -1
- package/ui-dist/assets/{journeyDiagram-5HDEW3XC-M5T2sMgn.js → journeyDiagram-NVQOT4AX-CGQuPDO1.js} +1 -1
- package/ui-dist/assets/{kanban-definition-HUTT4EX6-B8H6R_Wc.js → kanban-definition-27J2QSJJ-zgEPcbHl.js} +1 -1
- package/ui-dist/assets/{linear-cpPKlVCq.js → linear-BVf5VtLS.js} +1 -1
- package/ui-dist/assets/mermaid.core-D2TFkGfI.js +308 -0
- package/ui-dist/assets/{mindmap-definition-LN4V7U3C-Bf6POzvm.js → mindmap-definition-FAOFIHXS-xoAQ0Lb_.js} +1 -1
- package/ui-dist/assets/{pegDiagram-2B236MQR-BJbGktAV.js → pegDiagram-VL7TDLO6-CBR1PWLr.js} +1 -1
- package/ui-dist/assets/{pieDiagram-ENE6RG2P-BmSN9Bio.js → pieDiagram-7S7Q4E2Y-BMPnzK_e.js} +1 -1
- package/ui-dist/assets/{quadrantDiagram-ABIIQ3AL-JUpqQCx_.js → quadrantDiagram-CIZ2JOQS-CPtVUPkR.js} +1 -1
- package/ui-dist/assets/{railroadDiagram-RFXS5EU6-B8k8T4-2.js → railroadDiagram-AXF67PYL-DC0lsZV1.js} +1 -1
- package/ui-dist/assets/{requirementDiagram-TGXJPOKE-b32heq7Q.js → requirementDiagram-LRYGKXZP-BF6k05SB.js} +1 -1
- package/ui-dist/assets/{sankeyDiagram-HTMAVEWB-DC3s-xgf.js → sankeyDiagram-W5VNT64P-CRN0ibiP.js} +1 -1
- package/ui-dist/assets/{sequenceDiagram-DBY2YBRQ-BsCFyv_E.js → sequenceDiagram-SI44F4Z6-CQtTiPWm.js} +1 -1
- package/ui-dist/assets/{sizeCapture-X5ZJPWSS-S7xeCud3.js → sizeCapture-X5ZJPWSS-BdjuGZd1.js} +1 -1
- package/ui-dist/assets/{stateDiagram-2N3HPSRC-58O3ofoS.js → stateDiagram-OKZ733FA-B99onxyh.js} +1 -1
- package/ui-dist/assets/stateDiagram-v2-UEYNNEHI-bzFlYBZ1.js +1 -0
- package/ui-dist/assets/{swimlanes-5IMT3BWC-DFCVG0iF.js → swimlanes-SLNWSIFB-BIByPbrL.js} +2 -2
- package/ui-dist/assets/swimlanesDiagram-ULZ7WXOC-DgdkBnuK.js +8 -0
- package/ui-dist/assets/{timeline-definition-FHXFAJF6-C0c0SkQu.js → timeline-definition-Z64GVDOM-I1NgOcn9.js} +1 -1
- package/ui-dist/assets/{vennDiagram-L72KCM5P-B1cEx8GQ.js → vennDiagram-T6HMQDX7-D6t2Njcl.js} +1 -1
- package/ui-dist/assets/{wardleyDiagram-EHGQE667-BQhDkOx9.js → wardleyDiagram-T6FBY63Y-BiYKm9gh.js} +1 -1
- package/ui-dist/assets/{xychartDiagram-FW5EYKEG-YSQp1N0i.js → xychartDiagram-ELKLHX3M-BhwXKWIa.js} +4 -4
- package/ui-dist/index.html +3 -3
- package/ui-dist/sw.js +8 -3
- package/ui-dist/assets/architectureDiagram-ZJ3FMSHR-BcJt8Ia1.js +0 -36
- package/ui-dist/assets/channel-ZRpjyNiZ.js +0 -1
- package/ui-dist/assets/classDiagram-OUVF2IWQ-CCzzzCgk.js +0 -1
- package/ui-dist/assets/classDiagram-v2-EOCWNBFH-CCzzzCgk.js +0 -1
- package/ui-dist/assets/cytoscape.esm-D8joxN9f.js +0 -321
- package/ui-dist/assets/diagram-WEI45ONY-M3WOC2tK.js +0 -41
- package/ui-dist/assets/index-BqfqfoQX.css +0 -1
- package/ui-dist/assets/mermaid.core-MCazc_od.js +0 -308
- package/ui-dist/assets/stateDiagram-v2-6OUMAXLB-_VY5dpDG.js +0 -1
- package/ui-dist/assets/swimlanesDiagram-G3AALYLV-BJhUjfns.js +0 -8
|
@@ -0,0 +1,655 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
|
+
import { setExpensiveWorkspaceGitExecutor } from "@paperclipai/adapter-utils/git-workspace-sync";
|
|
5
|
+
import { HttpError } from "../errors.js";
|
|
6
|
+
import { logger } from "../middleware/logger.js";
|
|
7
|
+
export const WORKSPACE_GIT_SCAN_ERROR_CODES = {
|
|
8
|
+
saturated: "workspace_git_scan_saturated",
|
|
9
|
+
timeout: "workspace_git_scan_timeout",
|
|
10
|
+
cancelled: "workspace_git_scan_cancelled",
|
|
11
|
+
outputLimit: "workspace_git_scan_output_limit",
|
|
12
|
+
failed: "workspace_git_scan_failed",
|
|
13
|
+
};
|
|
14
|
+
export class WorkspaceGitScanError extends HttpError {
|
|
15
|
+
code;
|
|
16
|
+
constructor(code, message, details = {}) {
|
|
17
|
+
const status = code === WORKSPACE_GIT_SCAN_ERROR_CODES.timeout
|
|
18
|
+
? 504
|
|
19
|
+
: code === WORKSPACE_GIT_SCAN_ERROR_CODES.cancelled
|
|
20
|
+
? 499
|
|
21
|
+
: 503;
|
|
22
|
+
super(status, message, {
|
|
23
|
+
code,
|
|
24
|
+
retryable: code !== WORKSPACE_GIT_SCAN_ERROR_CODES.cancelled,
|
|
25
|
+
...details,
|
|
26
|
+
});
|
|
27
|
+
this.name = "WorkspaceGitScanError";
|
|
28
|
+
this.code = code;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function isWorkspaceGitScanError(error) {
|
|
32
|
+
return error instanceof WorkspaceGitScanError;
|
|
33
|
+
}
|
|
34
|
+
const DEFAULT_CONCURRENCY = 2;
|
|
35
|
+
const DEFAULT_QUEUE_CAPACITY = 32;
|
|
36
|
+
const DEFAULT_TIMEOUT_MS = 8_000;
|
|
37
|
+
const DEFAULT_KILL_GRACE_MS = 250;
|
|
38
|
+
const DEFAULT_CACHE_TTL_MS = 10_000;
|
|
39
|
+
const DEFAULT_CACHE_ENTRIES = 64;
|
|
40
|
+
const DEFAULT_CACHE_BYTES = 8 * 1024 * 1024;
|
|
41
|
+
const DEFAULT_OUTPUT_BYTES = 1024 * 1024;
|
|
42
|
+
const DEFAULT_WARNING_INTERVAL_MS = 10_000;
|
|
43
|
+
function clampInteger(value, fallback, min, max) {
|
|
44
|
+
if (!Number.isFinite(value))
|
|
45
|
+
return fallback;
|
|
46
|
+
return Math.min(max, Math.max(min, Math.floor(value)));
|
|
47
|
+
}
|
|
48
|
+
function envInteger(env, key, fallback, min, max) {
|
|
49
|
+
const raw = env[key]?.trim();
|
|
50
|
+
if (!raw)
|
|
51
|
+
return fallback;
|
|
52
|
+
const parsed = Number(raw);
|
|
53
|
+
return clampInteger(parsed, fallback, min, max);
|
|
54
|
+
}
|
|
55
|
+
export function workspaceGitSchedulerOptionsFromEnv(env = process.env) {
|
|
56
|
+
return {
|
|
57
|
+
concurrency: envInteger(env, "PAPERCLIP_WORKSPACE_GIT_SCAN_CONCURRENCY", DEFAULT_CONCURRENCY, 1, 16),
|
|
58
|
+
queueCapacity: envInteger(env, "PAPERCLIP_WORKSPACE_GIT_SCAN_QUEUE_CAPACITY", DEFAULT_QUEUE_CAPACITY, 0, 1_024),
|
|
59
|
+
timeoutMs: envInteger(env, "PAPERCLIP_WORKSPACE_GIT_SCAN_TIMEOUT_MS", DEFAULT_TIMEOUT_MS, 100, 120_000),
|
|
60
|
+
defaultCacheTtlMs: envInteger(env, "PAPERCLIP_WORKSPACE_GIT_SCAN_CACHE_TTL_MS", DEFAULT_CACHE_TTL_MS, 0, 60_000),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function workspaceIdentity(canonicalWorkspacePath) {
|
|
64
|
+
return createHash("sha256").update(canonicalWorkspacePath).digest("hex").slice(0, 16);
|
|
65
|
+
}
|
|
66
|
+
function scanKey(input) {
|
|
67
|
+
// These variables can change status semantics. Hash values so neither keys nor
|
|
68
|
+
// telemetry expose credentials or private config contents.
|
|
69
|
+
const effectiveEnv = input.env ?? process.env;
|
|
70
|
+
const semanticEnv = [
|
|
71
|
+
"GIT_CONFIG_COUNT",
|
|
72
|
+
"GIT_CONFIG_PARAMETERS",
|
|
73
|
+
"GIT_DIR",
|
|
74
|
+
"GIT_INDEX_FILE",
|
|
75
|
+
"GIT_OPTIONAL_LOCKS",
|
|
76
|
+
"GIT_WORK_TREE",
|
|
77
|
+
].map((key) => [key, effectiveEnv[key] ?? null]);
|
|
78
|
+
return createHash("sha256")
|
|
79
|
+
.update(JSON.stringify({
|
|
80
|
+
workspacePath: input.canonicalWorkspacePath,
|
|
81
|
+
args: input.args,
|
|
82
|
+
semanticEnv,
|
|
83
|
+
timeoutMs: input.timeoutMs,
|
|
84
|
+
maxStdoutBytes: input.maxStdoutBytes,
|
|
85
|
+
maxStderrBytes: input.maxStderrBytes,
|
|
86
|
+
}))
|
|
87
|
+
.digest("hex");
|
|
88
|
+
}
|
|
89
|
+
function abortError(workspaceHash) {
|
|
90
|
+
return new WorkspaceGitScanError(WORKSPACE_GIT_SCAN_ERROR_CODES.cancelled, "Workspace Git scan was cancelled", { workspaceHash });
|
|
91
|
+
}
|
|
92
|
+
function signalChild(child, signal) {
|
|
93
|
+
if (child.exitCode !== null || child.signalCode !== null)
|
|
94
|
+
return;
|
|
95
|
+
if (process.platform !== "win32" && child.pid) {
|
|
96
|
+
try {
|
|
97
|
+
process.kill(-child.pid, signal);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Fall back to the direct child if the process group already disappeared.
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
child.kill(signal);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// The close/error handler owns settlement; an already-dead child is benign.
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function createSpawnRunner(input) {
|
|
112
|
+
return (runInput) => new Promise((resolve, reject) => {
|
|
113
|
+
if (runInput.signal.aborted) {
|
|
114
|
+
reject(abortError(workspaceIdentity(runInput.canonicalWorkspacePath)));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const child = spawn(input.gitBinary, [...input.gitArgsPrefix, "-C", runInput.canonicalWorkspacePath, ...runInput.args], {
|
|
118
|
+
cwd: runInput.canonicalWorkspacePath,
|
|
119
|
+
env: runInput.env ?? process.env,
|
|
120
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
121
|
+
detached: process.platform !== "win32",
|
|
122
|
+
windowsHide: true,
|
|
123
|
+
});
|
|
124
|
+
const stdoutChunks = [];
|
|
125
|
+
const stderrChunks = [];
|
|
126
|
+
let stdoutBytes = 0;
|
|
127
|
+
let stderrBytes = 0;
|
|
128
|
+
let termination = null;
|
|
129
|
+
let spawnError = null;
|
|
130
|
+
let settled = false;
|
|
131
|
+
const terminate = (reason) => {
|
|
132
|
+
if (termination)
|
|
133
|
+
return;
|
|
134
|
+
termination = reason;
|
|
135
|
+
signalChild(child, "SIGTERM");
|
|
136
|
+
killTimer = setTimeout(() => signalChild(child, "SIGKILL"), runInput.killGraceMs);
|
|
137
|
+
killTimer.unref?.();
|
|
138
|
+
};
|
|
139
|
+
const append = (chunk, chunks, currentBytes, maxBytes) => {
|
|
140
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
141
|
+
const remaining = Math.max(0, maxBytes - currentBytes);
|
|
142
|
+
if (remaining > 0)
|
|
143
|
+
chunks.push(buffer.subarray(0, remaining));
|
|
144
|
+
const nextBytes = currentBytes + buffer.length;
|
|
145
|
+
if (nextBytes > maxBytes)
|
|
146
|
+
terminate("output_limit");
|
|
147
|
+
return nextBytes;
|
|
148
|
+
};
|
|
149
|
+
const onAbort = () => terminate("cancelled");
|
|
150
|
+
runInput.signal.addEventListener("abort", onAbort, { once: true });
|
|
151
|
+
child.stdout?.on("data", (chunk) => {
|
|
152
|
+
stdoutBytes = append(chunk, stdoutChunks, stdoutBytes, runInput.maxStdoutBytes);
|
|
153
|
+
});
|
|
154
|
+
child.stderr?.on("data", (chunk) => {
|
|
155
|
+
stderrBytes = append(chunk, stderrChunks, stderrBytes, runInput.maxStderrBytes);
|
|
156
|
+
});
|
|
157
|
+
child.once("error", (error) => {
|
|
158
|
+
spawnError = error;
|
|
159
|
+
});
|
|
160
|
+
const timeoutTimer = setTimeout(() => terminate("timeout"), runInput.timeoutMs);
|
|
161
|
+
timeoutTimer.unref?.();
|
|
162
|
+
let killTimer = null;
|
|
163
|
+
child.once("close", (code, childSignal) => {
|
|
164
|
+
if (settled)
|
|
165
|
+
return;
|
|
166
|
+
settled = true;
|
|
167
|
+
clearTimeout(timeoutTimer);
|
|
168
|
+
if (killTimer)
|
|
169
|
+
clearTimeout(killTimer);
|
|
170
|
+
runInput.signal.removeEventListener("abort", onAbort);
|
|
171
|
+
const stdout = Buffer.concat(stdoutChunks).toString("utf8");
|
|
172
|
+
const stderr = Buffer.concat(stderrChunks).toString("utf8");
|
|
173
|
+
const workspaceHash = workspaceIdentity(runInput.canonicalWorkspacePath);
|
|
174
|
+
if (termination === "timeout") {
|
|
175
|
+
reject(new WorkspaceGitScanError(WORKSPACE_GIT_SCAN_ERROR_CODES.timeout, `Workspace Git scan timed out after ${runInput.timeoutMs}ms`, { workspaceHash, timeoutMs: runInput.timeoutMs }));
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (termination === "cancelled") {
|
|
179
|
+
reject(abortError(workspaceHash));
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (termination === "output_limit") {
|
|
183
|
+
reject(new WorkspaceGitScanError(WORKSPACE_GIT_SCAN_ERROR_CODES.outputLimit, "Workspace Git scan exceeded its output limit", {
|
|
184
|
+
workspaceHash,
|
|
185
|
+
stdoutBytes,
|
|
186
|
+
stderrBytes,
|
|
187
|
+
maxStdoutBytes: runInput.maxStdoutBytes,
|
|
188
|
+
maxStderrBytes: runInput.maxStderrBytes,
|
|
189
|
+
}));
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (spawnError) {
|
|
193
|
+
reject(new WorkspaceGitScanError(WORKSPACE_GIT_SCAN_ERROR_CODES.failed, "Workspace Git scan could not start", { workspaceHash, cause: spawnError.message }));
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (code !== 0) {
|
|
197
|
+
reject(new WorkspaceGitScanError(WORKSPACE_GIT_SCAN_ERROR_CODES.failed, "Workspace Git scan failed", {
|
|
198
|
+
workspaceHash,
|
|
199
|
+
exitCode: code,
|
|
200
|
+
signal: childSignal,
|
|
201
|
+
// Keep the diagnostic bounded; callers never receive raw paths in telemetry.
|
|
202
|
+
stderr: stderr.trim().slice(0, 1_000),
|
|
203
|
+
}));
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
resolve({ stdout, stderr });
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
export class WorkspaceGitOperationScheduler {
|
|
211
|
+
concurrency;
|
|
212
|
+
queueCapacity;
|
|
213
|
+
timeoutMs;
|
|
214
|
+
killGraceMs;
|
|
215
|
+
defaultCacheTtlMs;
|
|
216
|
+
maxCacheEntries;
|
|
217
|
+
maxCacheBytes;
|
|
218
|
+
maxStdoutBytes;
|
|
219
|
+
maxStderrBytes;
|
|
220
|
+
warningIntervalMs;
|
|
221
|
+
runner;
|
|
222
|
+
now;
|
|
223
|
+
inFlight = new Map();
|
|
224
|
+
queue = [];
|
|
225
|
+
cache = new Map();
|
|
226
|
+
lastServedByFairnessKey = new Map();
|
|
227
|
+
warningBuckets = new Map();
|
|
228
|
+
cacheBytes = 0;
|
|
229
|
+
activeCount = 0;
|
|
230
|
+
serviceSequence = 0;
|
|
231
|
+
totals = {
|
|
232
|
+
started: 0,
|
|
233
|
+
succeeded: 0,
|
|
234
|
+
failed: 0,
|
|
235
|
+
timedOut: 0,
|
|
236
|
+
cancelled: 0,
|
|
237
|
+
saturated: 0,
|
|
238
|
+
cacheHits: 0,
|
|
239
|
+
singleFlightJoins: 0,
|
|
240
|
+
};
|
|
241
|
+
constructor(options = {}) {
|
|
242
|
+
this.concurrency = clampInteger(options.concurrency, DEFAULT_CONCURRENCY, 1, 16);
|
|
243
|
+
this.queueCapacity = clampInteger(options.queueCapacity, DEFAULT_QUEUE_CAPACITY, 0, 1_024);
|
|
244
|
+
this.timeoutMs = clampInteger(options.timeoutMs, DEFAULT_TIMEOUT_MS, 1, 120_000);
|
|
245
|
+
this.killGraceMs = clampInteger(options.killGraceMs, DEFAULT_KILL_GRACE_MS, 1, 10_000);
|
|
246
|
+
this.defaultCacheTtlMs = clampInteger(options.defaultCacheTtlMs, DEFAULT_CACHE_TTL_MS, 0, 60_000);
|
|
247
|
+
this.maxCacheEntries = clampInteger(options.maxCacheEntries, DEFAULT_CACHE_ENTRIES, 0, 10_000);
|
|
248
|
+
this.maxCacheBytes = clampInteger(options.maxCacheBytes, DEFAULT_CACHE_BYTES, 0, 1024 * 1024 * 1024);
|
|
249
|
+
this.maxStdoutBytes = clampInteger(options.maxStdoutBytes, DEFAULT_OUTPUT_BYTES, 1, 128 * 1024 * 1024);
|
|
250
|
+
this.maxStderrBytes = clampInteger(options.maxStderrBytes, DEFAULT_OUTPUT_BYTES, 1, 128 * 1024 * 1024);
|
|
251
|
+
this.warningIntervalMs = clampInteger(options.warningIntervalMs, DEFAULT_WARNING_INTERVAL_MS, 1, 60 * 60_000);
|
|
252
|
+
this.now = options.now ?? Date.now;
|
|
253
|
+
this.runner = options.runner ?? createSpawnRunner({
|
|
254
|
+
gitBinary: options.gitBinary ?? "git",
|
|
255
|
+
gitArgsPrefix: options.gitArgsPrefix ?? [],
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
snapshot() {
|
|
259
|
+
this.pruneExpiredCache();
|
|
260
|
+
return {
|
|
261
|
+
activeCount: this.activeCount,
|
|
262
|
+
queuedCount: this.queue.length,
|
|
263
|
+
inFlightCount: this.inFlight.size,
|
|
264
|
+
cacheEntryCount: this.cache.size,
|
|
265
|
+
cacheBytes: this.cacheBytes,
|
|
266
|
+
totals: { ...this.totals },
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
async run(input) {
|
|
270
|
+
if (input.signal?.aborted)
|
|
271
|
+
throw abortError("unresolved");
|
|
272
|
+
let canonicalWorkspacePath;
|
|
273
|
+
try {
|
|
274
|
+
canonicalWorkspacePath = await fs.realpath(input.workspacePath);
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
throw new WorkspaceGitScanError(WORKSPACE_GIT_SCAN_ERROR_CODES.failed, "Workspace Git scan path is unavailable", { cause: error instanceof Error ? error.message : String(error) });
|
|
278
|
+
}
|
|
279
|
+
if (input.signal?.aborted)
|
|
280
|
+
throw abortError(workspaceIdentity(canonicalWorkspacePath));
|
|
281
|
+
const workspaceHash = workspaceIdentity(canonicalWorkspacePath);
|
|
282
|
+
const timeoutMs = clampInteger(input.timeoutMs, this.timeoutMs, 1, 120_000);
|
|
283
|
+
const maxStdoutBytes = clampInteger(input.maxStdoutBytes, this.maxStdoutBytes, 1, 128 * 1024 * 1024);
|
|
284
|
+
const maxStderrBytes = clampInteger(input.maxStderrBytes, this.maxStderrBytes, 1, 128 * 1024 * 1024);
|
|
285
|
+
const key = scanKey({
|
|
286
|
+
canonicalWorkspacePath,
|
|
287
|
+
args: input.args,
|
|
288
|
+
env: input.env,
|
|
289
|
+
timeoutMs,
|
|
290
|
+
maxStdoutBytes,
|
|
291
|
+
maxStderrBytes,
|
|
292
|
+
});
|
|
293
|
+
const cacheTtlMs = clampInteger(input.cacheTtlMs, this.defaultCacheTtlMs, 0, 60_000);
|
|
294
|
+
// A correctness-sensitive caller that explicitly disables caching must not
|
|
295
|
+
// consume a result populated earlier by the file browser.
|
|
296
|
+
const cached = cacheTtlMs > 0 ? this.readCache(key) : null;
|
|
297
|
+
if (cached) {
|
|
298
|
+
this.totals.cacheHits += 1;
|
|
299
|
+
logger.debug({
|
|
300
|
+
event: "workspace_git_scan",
|
|
301
|
+
operation: input.operation,
|
|
302
|
+
workspaceHash,
|
|
303
|
+
cacheHit: true,
|
|
304
|
+
singleFlightJoined: false,
|
|
305
|
+
activeCount: this.activeCount,
|
|
306
|
+
queuedCount: this.queue.length,
|
|
307
|
+
cacheHitCount: this.totals.cacheHits,
|
|
308
|
+
}, "workspace Git scan cache hit");
|
|
309
|
+
return {
|
|
310
|
+
stdout: cached.stdout,
|
|
311
|
+
stderr: cached.stderr,
|
|
312
|
+
canonicalWorkspacePath,
|
|
313
|
+
workspaceHash,
|
|
314
|
+
cacheHit: true,
|
|
315
|
+
singleFlightJoined: false,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
const existing = this.inFlight.get(key);
|
|
319
|
+
if (existing) {
|
|
320
|
+
existing.joinCount += 1;
|
|
321
|
+
this.totals.singleFlightJoins += 1;
|
|
322
|
+
return this.addWaiter(existing, input.signal, true);
|
|
323
|
+
}
|
|
324
|
+
if (this.activeCount >= this.concurrency && this.queue.length >= this.queueCapacity) {
|
|
325
|
+
this.totals.saturated += 1;
|
|
326
|
+
this.warnRateLimited("saturated", {
|
|
327
|
+
event: "workspace_git_scan",
|
|
328
|
+
operation: input.operation,
|
|
329
|
+
workspaceHash,
|
|
330
|
+
outcome: "saturated",
|
|
331
|
+
activeCount: this.activeCount,
|
|
332
|
+
queuedCount: this.queue.length,
|
|
333
|
+
saturationCount: this.totals.saturated,
|
|
334
|
+
}, "workspace Git scan queue saturated");
|
|
335
|
+
throw new WorkspaceGitScanError(WORKSPACE_GIT_SCAN_ERROR_CODES.saturated, "Changed files are temporarily unavailable because the Git scan queue is full", {
|
|
336
|
+
workspaceHash,
|
|
337
|
+
activeCount: this.activeCount,
|
|
338
|
+
queuedCount: this.queue.length,
|
|
339
|
+
retryAfterSeconds: 1,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
const fairnessKeys = Array.from(new Set([
|
|
343
|
+
`repository:${workspaceHash}`,
|
|
344
|
+
...(input.fairnessKeys ?? []).filter(Boolean),
|
|
345
|
+
])).sort();
|
|
346
|
+
const scan = {
|
|
347
|
+
key,
|
|
348
|
+
operation: input.operation,
|
|
349
|
+
canonicalWorkspacePath,
|
|
350
|
+
workspaceHash,
|
|
351
|
+
args: [...input.args],
|
|
352
|
+
fairnessKeys,
|
|
353
|
+
env: input.env,
|
|
354
|
+
timeoutMs,
|
|
355
|
+
maxStdoutBytes,
|
|
356
|
+
maxStderrBytes,
|
|
357
|
+
cacheTtlMs,
|
|
358
|
+
enqueuedAt: this.now(),
|
|
359
|
+
state: "queued",
|
|
360
|
+
controller: new AbortController(),
|
|
361
|
+
waiters: new Map(),
|
|
362
|
+
joinCount: 0,
|
|
363
|
+
};
|
|
364
|
+
this.inFlight.set(key, scan);
|
|
365
|
+
this.queue.push(scan);
|
|
366
|
+
const promise = this.addWaiter(scan, input.signal, false);
|
|
367
|
+
this.drain();
|
|
368
|
+
return promise;
|
|
369
|
+
}
|
|
370
|
+
addWaiter(scan, signal, joined) {
|
|
371
|
+
if (signal?.aborted)
|
|
372
|
+
return Promise.reject(abortError(scan.workspaceHash));
|
|
373
|
+
return new Promise((resolve, reject) => {
|
|
374
|
+
const waiter = {
|
|
375
|
+
id: Symbol("workspace-git-waiter"),
|
|
376
|
+
signal,
|
|
377
|
+
resolve,
|
|
378
|
+
reject,
|
|
379
|
+
joined,
|
|
380
|
+
};
|
|
381
|
+
if (signal) {
|
|
382
|
+
waiter.onAbort = () => {
|
|
383
|
+
this.removeWaiter(scan, waiter);
|
|
384
|
+
reject(abortError(scan.workspaceHash));
|
|
385
|
+
};
|
|
386
|
+
signal.addEventListener("abort", waiter.onAbort, { once: true });
|
|
387
|
+
}
|
|
388
|
+
scan.waiters.set(waiter.id, waiter);
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
removeWaiter(scan, waiter) {
|
|
392
|
+
if (!scan.waiters.delete(waiter.id))
|
|
393
|
+
return;
|
|
394
|
+
if (waiter.signal && waiter.onAbort) {
|
|
395
|
+
waiter.signal.removeEventListener("abort", waiter.onAbort);
|
|
396
|
+
}
|
|
397
|
+
if (scan.waiters.size > 0)
|
|
398
|
+
return;
|
|
399
|
+
if (scan.state === "queued") {
|
|
400
|
+
const index = this.queue.indexOf(scan);
|
|
401
|
+
if (index >= 0)
|
|
402
|
+
this.queue.splice(index, 1);
|
|
403
|
+
this.inFlight.delete(scan.key);
|
|
404
|
+
this.totals.cancelled += 1;
|
|
405
|
+
logger.debug({
|
|
406
|
+
event: "workspace_git_scan",
|
|
407
|
+
operation: scan.operation,
|
|
408
|
+
workspaceHash: scan.workspaceHash,
|
|
409
|
+
outcome: "cancelled_before_start",
|
|
410
|
+
activeCount: this.activeCount,
|
|
411
|
+
queuedCount: this.queue.length,
|
|
412
|
+
}, "queued workspace Git scan cancelled");
|
|
413
|
+
this.drain();
|
|
414
|
+
this.pruneFairnessState();
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
// Detach the doomed single-flight entry immediately. A new caller arriving
|
|
418
|
+
// while the child is terminating may enqueue a fresh scan instead of
|
|
419
|
+
// joining an already-aborted promise; the active slot remains occupied
|
|
420
|
+
// until the child actually closes.
|
|
421
|
+
if (this.inFlight.get(scan.key) === scan)
|
|
422
|
+
this.inFlight.delete(scan.key);
|
|
423
|
+
scan.controller.abort();
|
|
424
|
+
}
|
|
425
|
+
drain() {
|
|
426
|
+
while (this.activeCount < this.concurrency && this.queue.length > 0) {
|
|
427
|
+
const index = this.nextFairQueueIndex();
|
|
428
|
+
const scan = this.queue.splice(index, 1)[0];
|
|
429
|
+
if (scan.waiters.size === 0) {
|
|
430
|
+
this.inFlight.delete(scan.key);
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
this.start(scan);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
nextFairQueueIndex() {
|
|
437
|
+
let selectedIndex = 0;
|
|
438
|
+
let selectedScore = Number.POSITIVE_INFINITY;
|
|
439
|
+
let selectedEnqueuedAt = Number.POSITIVE_INFINITY;
|
|
440
|
+
for (let index = 0; index < this.queue.length; index += 1) {
|
|
441
|
+
const scan = this.queue[index];
|
|
442
|
+
// Average recency across every dimension so a common repository/company
|
|
443
|
+
// key cannot mask a fresh actor or issue. Repeatedly changing only one
|
|
444
|
+
// dimension therefore cannot jump ahead of a wholly unserved group.
|
|
445
|
+
const score = scan.fairnessKeys.reduce((total, key) => total + (this.lastServedByFairnessKey.get(key) ?? 0), 0) / scan.fairnessKeys.length;
|
|
446
|
+
if (score < selectedScore || (score === selectedScore && scan.enqueuedAt < selectedEnqueuedAt)) {
|
|
447
|
+
selectedIndex = index;
|
|
448
|
+
selectedScore = score;
|
|
449
|
+
selectedEnqueuedAt = scan.enqueuedAt;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return selectedIndex;
|
|
453
|
+
}
|
|
454
|
+
start(scan) {
|
|
455
|
+
scan.state = "running";
|
|
456
|
+
this.activeCount += 1;
|
|
457
|
+
this.totals.started += 1;
|
|
458
|
+
this.serviceSequence += 1;
|
|
459
|
+
for (const key of scan.fairnessKeys)
|
|
460
|
+
this.lastServedByFairnessKey.set(key, this.serviceSequence);
|
|
461
|
+
const startedAt = this.now();
|
|
462
|
+
const queueWaitMs = Math.max(0, startedAt - scan.enqueuedAt);
|
|
463
|
+
void this.runner({
|
|
464
|
+
canonicalWorkspacePath: scan.canonicalWorkspacePath,
|
|
465
|
+
args: scan.args,
|
|
466
|
+
env: scan.env,
|
|
467
|
+
signal: scan.controller.signal,
|
|
468
|
+
timeoutMs: scan.timeoutMs,
|
|
469
|
+
killGraceMs: this.killGraceMs,
|
|
470
|
+
maxStdoutBytes: scan.maxStdoutBytes,
|
|
471
|
+
maxStderrBytes: scan.maxStderrBytes,
|
|
472
|
+
}).then((result) => this.finishSuccess(scan, result, queueWaitMs, startedAt), (error) => this.finishFailure(scan, error, queueWaitMs, startedAt));
|
|
473
|
+
}
|
|
474
|
+
finishSuccess(scan, result, queueWaitMs, startedAt) {
|
|
475
|
+
this.totals.succeeded += 1;
|
|
476
|
+
if (scan.cacheTtlMs > 0)
|
|
477
|
+
this.writeCache(scan.key, scan, result);
|
|
478
|
+
const responseBase = {
|
|
479
|
+
stdout: result.stdout,
|
|
480
|
+
stderr: result.stderr,
|
|
481
|
+
canonicalWorkspacePath: scan.canonicalWorkspacePath,
|
|
482
|
+
workspaceHash: scan.workspaceHash,
|
|
483
|
+
cacheHit: false,
|
|
484
|
+
};
|
|
485
|
+
for (const waiter of scan.waiters.values()) {
|
|
486
|
+
this.detachWaiter(waiter);
|
|
487
|
+
waiter.resolve({ ...responseBase, singleFlightJoined: waiter.joined });
|
|
488
|
+
}
|
|
489
|
+
logger.info({
|
|
490
|
+
event: "workspace_git_scan",
|
|
491
|
+
operation: scan.operation,
|
|
492
|
+
workspaceHash: scan.workspaceHash,
|
|
493
|
+
outcome: "success",
|
|
494
|
+
queueWaitMs,
|
|
495
|
+
executionMs: Math.max(0, this.now() - startedAt),
|
|
496
|
+
activeCount: this.activeCount,
|
|
497
|
+
queuedCount: this.queue.length,
|
|
498
|
+
cacheHit: false,
|
|
499
|
+
singleFlightJoinCount: scan.joinCount,
|
|
500
|
+
exitOutcome: "zero",
|
|
501
|
+
}, "workspace Git scan completed");
|
|
502
|
+
this.release(scan);
|
|
503
|
+
}
|
|
504
|
+
finishFailure(scan, error, queueWaitMs, startedAt) {
|
|
505
|
+
const normalized = isWorkspaceGitScanError(error)
|
|
506
|
+
? error
|
|
507
|
+
: new WorkspaceGitScanError(WORKSPACE_GIT_SCAN_ERROR_CODES.failed, "Workspace Git scan failed", { cause: error instanceof Error ? error.message : String(error), workspaceHash: scan.workspaceHash });
|
|
508
|
+
if (normalized.code === WORKSPACE_GIT_SCAN_ERROR_CODES.timeout) {
|
|
509
|
+
this.totals.timedOut += 1;
|
|
510
|
+
this.warnRateLimited("timeout", {
|
|
511
|
+
event: "workspace_git_scan",
|
|
512
|
+
operation: scan.operation,
|
|
513
|
+
workspaceHash: scan.workspaceHash,
|
|
514
|
+
outcome: "timeout",
|
|
515
|
+
queueWaitMs,
|
|
516
|
+
executionMs: Math.max(0, this.now() - startedAt),
|
|
517
|
+
activeCount: this.activeCount,
|
|
518
|
+
queuedCount: this.queue.length,
|
|
519
|
+
timeoutCount: this.totals.timedOut,
|
|
520
|
+
}, "workspace Git scan timed out");
|
|
521
|
+
}
|
|
522
|
+
else if (normalized.code === WORKSPACE_GIT_SCAN_ERROR_CODES.cancelled) {
|
|
523
|
+
this.totals.cancelled += 1;
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
this.totals.failed += 1;
|
|
527
|
+
}
|
|
528
|
+
for (const waiter of scan.waiters.values()) {
|
|
529
|
+
this.detachWaiter(waiter);
|
|
530
|
+
waiter.reject(normalized);
|
|
531
|
+
}
|
|
532
|
+
logger.info({
|
|
533
|
+
event: "workspace_git_scan",
|
|
534
|
+
operation: scan.operation,
|
|
535
|
+
workspaceHash: scan.workspaceHash,
|
|
536
|
+
outcome: normalized.code,
|
|
537
|
+
queueWaitMs,
|
|
538
|
+
executionMs: Math.max(0, this.now() - startedAt),
|
|
539
|
+
activeCount: this.activeCount,
|
|
540
|
+
queuedCount: this.queue.length,
|
|
541
|
+
cacheHit: false,
|
|
542
|
+
singleFlightJoinCount: scan.joinCount,
|
|
543
|
+
exitOutcome: normalized.code,
|
|
544
|
+
}, "workspace Git scan finished without a result");
|
|
545
|
+
this.release(scan);
|
|
546
|
+
}
|
|
547
|
+
detachWaiter(waiter) {
|
|
548
|
+
if (waiter.signal && waiter.onAbort) {
|
|
549
|
+
waiter.signal.removeEventListener("abort", waiter.onAbort);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
release(scan) {
|
|
553
|
+
scan.waiters.clear();
|
|
554
|
+
if (this.inFlight.get(scan.key) === scan)
|
|
555
|
+
this.inFlight.delete(scan.key);
|
|
556
|
+
this.activeCount = Math.max(0, this.activeCount - 1);
|
|
557
|
+
this.drain();
|
|
558
|
+
this.pruneFairnessState();
|
|
559
|
+
}
|
|
560
|
+
pruneFairnessState() {
|
|
561
|
+
if (this.lastServedByFairnessKey.size === 0)
|
|
562
|
+
return;
|
|
563
|
+
const liveKeys = new Set();
|
|
564
|
+
for (const scan of this.inFlight.values()) {
|
|
565
|
+
for (const key of scan.fairnessKeys)
|
|
566
|
+
liveKeys.add(key);
|
|
567
|
+
}
|
|
568
|
+
for (const key of this.lastServedByFairnessKey.keys()) {
|
|
569
|
+
if (!liveKeys.has(key))
|
|
570
|
+
this.lastServedByFairnessKey.delete(key);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
readCache(key) {
|
|
574
|
+
const entry = this.cache.get(key);
|
|
575
|
+
if (!entry)
|
|
576
|
+
return null;
|
|
577
|
+
if (entry.expiresAt <= this.now()) {
|
|
578
|
+
this.deleteCacheEntry(key, entry);
|
|
579
|
+
return null;
|
|
580
|
+
}
|
|
581
|
+
// LRU touch.
|
|
582
|
+
this.cache.delete(key);
|
|
583
|
+
this.cache.set(key, entry);
|
|
584
|
+
return entry;
|
|
585
|
+
}
|
|
586
|
+
writeCache(key, scan, result) {
|
|
587
|
+
if (this.maxCacheEntries === 0 || this.maxCacheBytes === 0)
|
|
588
|
+
return;
|
|
589
|
+
const bytes = Buffer.byteLength(result.stdout) + Buffer.byteLength(result.stderr);
|
|
590
|
+
if (bytes > this.maxCacheBytes)
|
|
591
|
+
return;
|
|
592
|
+
const existing = this.cache.get(key);
|
|
593
|
+
if (existing)
|
|
594
|
+
this.deleteCacheEntry(key, existing);
|
|
595
|
+
const entry = {
|
|
596
|
+
...result,
|
|
597
|
+
canonicalWorkspacePath: scan.canonicalWorkspacePath,
|
|
598
|
+
workspaceHash: scan.workspaceHash,
|
|
599
|
+
expiresAt: this.now() + scan.cacheTtlMs,
|
|
600
|
+
bytes,
|
|
601
|
+
};
|
|
602
|
+
this.cache.set(key, entry);
|
|
603
|
+
this.cacheBytes += bytes;
|
|
604
|
+
while (this.cache.size > this.maxCacheEntries || this.cacheBytes > this.maxCacheBytes) {
|
|
605
|
+
const oldest = this.cache.entries().next().value;
|
|
606
|
+
if (!oldest)
|
|
607
|
+
break;
|
|
608
|
+
this.deleteCacheEntry(oldest[0], oldest[1]);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
deleteCacheEntry(key, entry) {
|
|
612
|
+
if (!this.cache.delete(key))
|
|
613
|
+
return;
|
|
614
|
+
this.cacheBytes = Math.max(0, this.cacheBytes - entry.bytes);
|
|
615
|
+
}
|
|
616
|
+
pruneExpiredCache() {
|
|
617
|
+
const now = this.now();
|
|
618
|
+
for (const [key, entry] of this.cache) {
|
|
619
|
+
if (entry.expiresAt <= now)
|
|
620
|
+
this.deleteCacheEntry(key, entry);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
warnRateLimited(key, fields, message) {
|
|
624
|
+
const now = this.now();
|
|
625
|
+
const bucket = this.warningBuckets.get(key);
|
|
626
|
+
if (bucket && now - bucket.lastLoggedAt < this.warningIntervalMs) {
|
|
627
|
+
bucket.suppressed += 1;
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
const suppressedSinceLastWarning = bucket?.suppressed ?? 0;
|
|
631
|
+
this.warningBuckets.set(key, { lastLoggedAt: now, suppressed: 0 });
|
|
632
|
+
logger.warn({ ...fields, suppressedSinceLastWarning }, message);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
export function createWorkspaceGitOperationScheduler(options = {}) {
|
|
636
|
+
return new WorkspaceGitOperationScheduler(options);
|
|
637
|
+
}
|
|
638
|
+
const envOptions = workspaceGitSchedulerOptionsFromEnv();
|
|
639
|
+
export const workspaceGitOperationScheduler = createWorkspaceGitOperationScheduler(envOptions);
|
|
640
|
+
setExpensiveWorkspaceGitExecutor(async (input) => {
|
|
641
|
+
const result = await workspaceGitOperationScheduler.run({
|
|
642
|
+
workspacePath: input.localDir,
|
|
643
|
+
args: input.args,
|
|
644
|
+
operation: input.operation,
|
|
645
|
+
cacheTtlMs: 0,
|
|
646
|
+
timeoutMs: input.timeout,
|
|
647
|
+
maxStdoutBytes: input.maxBuffer,
|
|
648
|
+
maxStderrBytes: input.maxBuffer,
|
|
649
|
+
});
|
|
650
|
+
return { stdout: result.stdout, stderr: result.stderr };
|
|
651
|
+
});
|
|
652
|
+
export function getWorkspaceGitOperationSchedulerSnapshot() {
|
|
653
|
+
return workspaceGitOperationScheduler.snapshot();
|
|
654
|
+
}
|
|
655
|
+
//# sourceMappingURL=workspace-git-operation-scheduler.js.map
|