@loucompanion/forge-bridge 0.1.4-dev.fb770705136a → 0.2.1-dev.0f07274d438b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -4
- package/dist/bridge/bridge-chat-giphy-look.d.ts +48 -0
- package/dist/bridge/bridge-chat-giphy-look.js +55 -0
- package/dist/bridge/bridge-chat-provider-command.d.ts +40 -0
- package/dist/bridge/bridge-chat-provider-command.js +230 -0
- package/dist/bridge/bridge-chat.types.d.ts +20 -0
- package/dist/bridge/bridge-chat.types.js +28 -1
- package/dist/bridge/bridge-state-file.d.ts +161 -0
- package/dist/bridge/bridge-state-file.js +376 -0
- package/dist/bridge/bridge-state-io.d.ts +15 -0
- package/dist/bridge/bridge-state-io.js +68 -0
- package/dist/bridge/bridge-state-lock.d.ts +11 -0
- package/dist/bridge/bridge-state-lock.js +102 -0
- package/dist/bridge/bridge-state-unpublished.d.ts +17 -0
- package/dist/bridge/bridge-state-unpublished.js +111 -0
- package/dist/bridge/bridge.base.d.ts +9 -0
- package/dist/bridge/bridge.service.d.ts +102 -14
- package/dist/bridge/bridge.service.js +499 -471
- package/dist/bridge/bridge.types.d.ts +37 -0
- package/dist/bridge/bridge.types.js +2 -1
- package/dist/bridge/default-session-service.d.ts +13 -0
- package/dist/bridge/default-session-service.js +22 -0
- package/dist/bridge/dispatch-offer-policy.d.ts +22 -0
- package/dist/bridge/dispatch-offer-policy.js +58 -0
- package/dist/bridge/in-flight-registry.d.ts +62 -0
- package/dist/bridge/in-flight-registry.js +207 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/bridge/readiness-result-outbox.d.ts +5 -1
- package/dist/bridge/readiness-result-outbox.js +20 -0
- package/dist/bridge/runner-host-capabilities.d.ts +5 -0
- package/dist/bridge/runner-host-capabilities.js +31 -1
- package/dist/bridge/sandbox-resource-accounting.d.ts +16 -0
- package/dist/bridge/sandbox-resource-accounting.js +150 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -0
- package/dist/bridge/windows-bash-resolution.d.ts +31 -0
- package/dist/bridge/windows-bash-resolution.js +153 -0
- package/dist/cleanup/cleanup-wip.d.ts +12 -0
- package/dist/cleanup/cleanup-wip.js +66 -0
- package/dist/cleanup/cleanup.service.d.ts +20 -1
- package/dist/cleanup/cleanup.service.js +150 -169
- package/dist/cleanup/cleanup.types.d.ts +6 -0
- package/dist/cleanup/forge-owned-paths.d.ts +11 -0
- package/dist/cleanup/forge-owned-paths.js +62 -0
- package/dist/cleanup/host-runtime-ledger.d.ts +7 -0
- package/dist/cleanup/host-runtime-ledger.js +130 -0
- package/dist/cleanup/managed-branch-sweep.d.ts +27 -0
- package/dist/cleanup/managed-branch-sweep.js +111 -0
- package/dist/cli/cli.help.js +75 -13
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +161 -228
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +18 -1
- package/dist/cli/local-config.js +67 -5
- package/dist/cli/provider-cli-advertising.d.ts +24 -0
- package/dist/cli/provider-cli-advertising.js +88 -0
- package/dist/cli/provider-cli-detection.d.ts +10 -0
- package/dist/cli/provider-cli-detection.js +160 -0
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +20 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +184 -18
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +36 -0
- package/dist/runtime/attempt-node-runtime-launcher.js +169 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +2 -0
- package/dist/runtime/attempt-process-supervisor.js +12 -6
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -0
- package/dist/runtime/dotnet-build-outputs.d.ts +107 -0
- package/dist/runtime/dotnet-build-outputs.js +402 -0
- package/dist/runtime/ephemeral-test-postgres-grant.d.ts +37 -0
- package/dist/runtime/ephemeral-test-postgres-grant.js +85 -0
- package/dist/runtime/ephemeral-test-postgres.d.ts +57 -0
- package/dist/runtime/ephemeral-test-postgres.js +303 -0
- package/dist/runtime/host-facts.d.ts +2 -1
- package/dist/runtime/host-listener-inspector.d.ts +26 -0
- package/dist/runtime/host-listener-inspector.js +84 -3
- package/dist/runtime/host-load-admission.d.ts +72 -0
- package/dist/runtime/host-load-admission.js +99 -0
- package/dist/runtime/host-load-capacity.d.ts +198 -0
- package/dist/runtime/host-load-capacity.js +353 -0
- package/dist/runtime/host-load-child-environment.d.ts +40 -0
- package/dist/runtime/host-load-child-environment.js +110 -0
- package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
- package/dist/runtime/host-load-forge-cgroups.js +140 -0
- package/dist/runtime/host-load-governor-config.d.ts +82 -0
- package/dist/runtime/host-load-governor-config.js +104 -0
- package/dist/runtime/host-load-governor.d.ts +273 -0
- package/dist/runtime/host-load-governor.js +831 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +187 -0
- package/dist/runtime/host-load-live-test-slots.d.ts +61 -0
- package/dist/runtime/host-load-live-test-slots.js +193 -0
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +80 -0
- package/dist/runtime/host-load-sampler.d.ts +92 -2
- package/dist/runtime/host-load-sampler.js +166 -8
- package/dist/runtime/host-load-step-class.d.ts +70 -0
- package/dist/runtime/host-load-step-class.js +161 -0
- package/dist/runtime/host-load-step-reaper.d.ts +27 -0
- package/dist/runtime/host-load-step-reaper.js +95 -0
- package/dist/runtime/host-load-step-run.d.ts +107 -0
- package/dist/runtime/host-load-step-run.js +158 -0
- package/dist/runtime/host-load-test-slot.d.ts +46 -0
- package/dist/runtime/host-load-test-slot.js +100 -0
- package/dist/runtime/host-load-token-ledger.d.ts +200 -0
- package/dist/runtime/host-load-token-ledger.js +453 -0
- package/dist/runtime/host-load-windows-cpu.d.ts +34 -0
- package/dist/runtime/host-load-windows-cpu.js +85 -0
- package/dist/runtime/host-pressure-stall.d.ts +21 -1
- package/dist/runtime/host-pressure-stall.js +48 -1
- package/dist/runtime/host-runtime-contract.d.ts +15 -0
- package/dist/runtime/host-runtime-contract.js +39 -6
- package/dist/runtime/host-runtime-lease.d.ts +101 -6
- package/dist/runtime/host-runtime-lease.js +408 -294
- package/dist/runtime/host-runtime-ledger-recovery.d.ts +20 -0
- package/dist/runtime/host-runtime-ledger-recovery.js +134 -0
- package/dist/runtime/host-runtime-promotion.d.ts +101 -2
- package/dist/runtime/host-runtime-promotion.js +355 -14
- package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
- package/dist/runtime/host-runtime-requirements-check.js +29 -0
- package/dist/runtime/host-runtime-requirements.d.ts +36 -0
- package/dist/runtime/host-runtime-requirements.js +117 -0
- package/dist/runtime/managed-command-teardown.js +5 -16
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +7 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +13 -1
- package/dist/runtime/prepared-runtime-identity.d.ts +4 -0
- package/dist/runtime/prepared-runtime-identity.js +130 -9
- package/dist/runtime/prepared-runtime-readiness.d.ts +23 -1
- package/dist/runtime/prepared-runtime-readiness.js +89 -18
- package/dist/runtime/runner-settings.d.ts +104 -0
- package/dist/runtime/runner-settings.js +236 -0
- package/dist/runtime/supervised-runtime-build-guard.d.ts +45 -0
- package/dist/runtime/supervised-runtime-build-guard.js +112 -0
- package/dist/sandbox/host-capacity-broker.d.ts +115 -0
- package/dist/sandbox/host-capacity-broker.js +336 -0
- package/dist/sandbox/managed-branch.d.ts +13 -0
- package/dist/sandbox/managed-branch.js +90 -0
- package/dist/sandbox/provider-auth/codex.js +11 -11
- package/dist/sandbox/runtime.d.ts +11 -3
- package/dist/sandbox/runtime.js +53 -20
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/sandbox/sandbox-input.d.ts +22 -0
- package/dist/sandbox/sandbox-input.js +49 -0
- package/dist/sandbox/workspace.service.js +15 -2
- package/dist/session/architect-waits.d.ts +2 -0
- package/dist/session/architect-waits.js +138 -0
- package/dist/session/managed-attempt-tools.d.ts +2 -7
- package/dist/session/managed-attempt-tools.js +204 -141
- package/dist/session/managed-build-coordinator.d.ts +16 -0
- package/dist/session/managed-build-coordinator.js +10 -0
- package/dist/session/managed-build-receipt.d.ts +7 -0
- package/dist/session/managed-build-receipt.js +11 -3
- package/dist/session/managed-command-environment.d.ts +8 -0
- package/dist/session/managed-command-environment.js +28 -0
- package/dist/session/managed-command-host-load.d.ts +52 -0
- package/dist/session/managed-command-host-load.js +87 -0
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifact-bundle.d.ts +20 -0
- package/dist/session/phase-completion.artifact-bundle.js +167 -0
- package/dist/session/phase-completion.artifacts.d.ts +9 -17
- package/dist/session/phase-completion.artifacts.js +158 -190
- package/dist/session/phase-completion.command-validation.d.ts +7 -0
- package/dist/session/phase-completion.command-validation.js +77 -0
- package/dist/session/phase-completion.d.ts +31 -2
- package/dist/session/phase-completion.helpers.js +18 -65
- package/dist/session/phase-completion.js +19 -32
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +195 -0
- package/dist/session/phase-completion.phase-aliases.d.ts +5 -0
- package/dist/session/phase-completion.phase-aliases.js +43 -0
- package/dist/session/phase-completion.pr-review-schema.d.ts +1 -0
- package/dist/session/phase-completion.pr-review-schema.js +75 -0
- package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
- package/dist/session/phase-completion.pr-review-validation.js +212 -0
- package/dist/session/phase-completion.pr-review.d.ts +36 -0
- package/dist/session/phase-completion.pr-review.js +294 -0
- package/dist/session/phase-completion.prompts.d.ts +1 -1
- package/dist/session/phase-completion.prompts.js +20 -1
- package/dist/session/phase-completion.runtime.d.ts +13 -12
- package/dist/session/phase-completion.runtime.js +113 -214
- package/dist/session/phase-completion.schema-parts.d.ts +19 -0
- package/dist/session/phase-completion.schema-parts.js +188 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -3
- package/dist/session/phase-completion.schemas.js +219 -232
- package/dist/session/phase-completion.validation.d.ts +3 -3
- package/dist/session/phase-completion.validation.js +58 -94
- package/dist/session/pr-review-diff-base.d.ts +18 -0
- package/dist/session/pr-review-diff-base.js +44 -0
- package/dist/session/pr-review-placement.d.ts +50 -0
- package/dist/session/pr-review-placement.js +91 -0
- package/dist/session/pre-publication-change-set.d.ts +62 -0
- package/dist/session/pre-publication-change-set.js +166 -0
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +112 -0
- package/dist/session/pre-publication-native-postgres.d.ts +30 -0
- package/dist/session/pre-publication-native-postgres.js +111 -0
- package/dist/session/pre-publication-pass.d.ts +61 -0
- package/dist/session/pre-publication-pass.js +148 -0
- package/dist/session/pre-publication-process.d.ts +3 -0
- package/dist/session/pre-publication-process.js +32 -19
- package/dist/session/pre-publication-step-execution.d.ts +12 -0
- package/dist/session/pre-publication-step-execution.js +50 -0
- package/dist/session/pre-publication-validation.d.ts +39 -22
- package/dist/session/pre-publication-validation.js +241 -207
- package/dist/session/provider-cli/claude-background-work.d.ts +67 -0
- package/dist/session/provider-cli/claude-background-work.js +181 -0
- package/dist/session/provider-cli/dispatch-target-branch.d.ts +7 -0
- package/dist/session/provider-cli/dispatch-target-branch.js +8 -0
- package/dist/session/provider-cli/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pr-review-credential-isolation.d.ts +83 -0
- package/dist/session/provider-cli/pr-review-credential-isolation.js +144 -0
- package/dist/session/provider-cli/pr-review-guardrails.d.ts +70 -0
- package/dist/session/provider-cli/pr-review-guardrails.js +360 -0
- package/dist/session/provider-cli/pr-review-prompt.d.ts +2 -0
- package/dist/session/provider-cli/pr-review-prompt.js +119 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +281 -0
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +75 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.codex-models-cache.js +37 -0
- package/dist/session/provider-cli/provider-cli.deterministic.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +5 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
- package/dist/session/provider-cli/provider-cli.pr-review.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.pr-review.js +213 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +15 -36
- package/dist/session/provider-cli/provider-cli.process.js +41 -432
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +15 -3
- package/dist/session/provider-cli/provider-cli.prompts.js +183 -90
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.js +37 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +15 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +43 -1
- package/dist/session/provider-cli/provider-cli.service-support.d.ts +37 -0
- package/dist/session/provider-cli/provider-cli.service-support.js +146 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +18 -18
- package/dist/session/provider-cli/provider-cli.service.js +127 -317
- package/dist/session/provider-cli/provider-cli.types.d.ts +35 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.windows-environment.js +151 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.windows-launch.js +131 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +4 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +45 -0
- package/dist/session/provider-cli/provider-output-pipes.d.ts +30 -0
- package/dist/session/provider-cli/provider-output-pipes.js +67 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +2 -0
- package/dist/session/provider-cli/provider-output-state.js +6 -0
- package/dist/session/provider-cli/provider-user-config-isolation.d.ts +69 -0
- package/dist/session/provider-cli/provider-user-config-isolation.js +164 -0
- package/dist/session/qa-sidecar-validation.d.ts +6 -0
- package/dist/session/qa-sidecar-validation.js +28 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +51 -0
- package/dist/session/sandbox-host-capacity-gate.js +279 -0
- package/dist/session/session-host-project.d.ts +22 -0
- package/dist/session/session-host-project.js +98 -0
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +9 -1
- package/dist/session/session.parse-helpers.d.ts +10 -0
- package/dist/session/session.parse-helpers.js +84 -0
- package/dist/session/session.runtime-refresh.d.ts +46 -0
- package/dist/session/session.runtime-refresh.js +116 -0
- package/dist/session/session.service.d.ts +16 -2
- package/dist/session/session.service.js +208 -155
- package/dist/session/session.types.d.ts +8 -0
- package/dist/session/session.types.js +13 -83
- package/dist/session/session.types.pr-review.d.ts +48 -0
- package/dist/session/session.types.pr-review.js +51 -0
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- package/dist/session/workspace-runtime-fingerprint.d.ts +32 -0
- package/dist/session/workspace-runtime-fingerprint.js +138 -0
- package/dist/shared/fs/file-identity.d.ts +10 -0
- package/dist/shared/fs/file-identity.js +15 -0
- package/dist/shared/fs/replace-file.d.ts +7 -0
- package/dist/shared/fs/replace-file.js +33 -0
- package/dist/shared/process/host-process-recovery.d.ts +14 -3
- package/dist/shared/process/host-process-recovery.js +23 -3
- package/dist/shared/process/host-process-supervisor.d.ts +14 -1
- package/dist/shared/process/host-process-supervisor.js +67 -15
- package/dist/shared/process/process-tree.d.ts +52 -0
- package/dist/shared/process/process-tree.js +144 -0
- package/dist/shared/process/process.d.ts +67 -0
- package/dist/shared/process/process.js +213 -11
- package/dist/shared/process/windows-app-execution-alias.d.ts +19 -0
- package/dist/shared/process/windows-app-execution-alias.js +45 -0
- package/dist/shared/process/windows-launch.d.ts +18 -0
- package/dist/shared/process/windows-launch.js +68 -0
- package/dist/shared/provider-capabilities.d.ts +2 -0
- package/dist/shared/provider-capabilities.js +23 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.js +24 -0
- package/dist/worktree/dependency-warmer.d.ts +25 -0
- package/dist/worktree/dependency-warmer.js +46 -10
- package/dist/worktree/orphan-relink.d.ts +19 -0
- package/dist/worktree/orphan-relink.js +106 -0
- package/dist/worktree/wip-git.d.ts +58 -0
- package/dist/worktree/wip-git.js +182 -0
- package/dist/worktree/wip-refs.d.ts +85 -0
- package/dist/worktree/wip-refs.js +169 -0
- package/dist/worktree/wip-restore.d.ts +51 -0
- package/dist/worktree/wip-restore.js +324 -0
- package/dist/worktree/wip-snapshot.d.ts +53 -0
- package/dist/worktree/wip-snapshot.js +270 -0
- package/dist/worktree/worktree-inputs.d.ts +8 -0
- package/dist/worktree/worktree-inputs.js +134 -0
- package/dist/worktree/worktree-origin-sync.d.ts +35 -0
- package/dist/worktree/worktree-origin-sync.js +128 -0
- package/dist/worktree/worktree-wip-events.d.ts +20 -0
- package/dist/worktree/worktree-wip-events.js +148 -0
- package/dist/worktree/worktree-wip.d.ts +57 -0
- package/dist/worktree/worktree-wip.js +200 -0
- package/dist/worktree/worktree.base.d.ts +7 -1
- package/dist/worktree/worktree.service.d.ts +58 -5
- package/dist/worktree/worktree.service.js +237 -161
- package/dist/worktree/worktree.types.d.ts +54 -0
- package/package.json +2 -2
- package/runtime/windows-listener-owner.ps1 +12 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type WindowsProcessTable } from "./process-tree.js";
|
|
1
2
|
export interface ProcessRunRequest {
|
|
2
3
|
readonly command: string;
|
|
3
4
|
readonly args: readonly string[];
|
|
@@ -5,15 +6,81 @@ export interface ProcessRunRequest {
|
|
|
5
6
|
readonly env?: NodeJS.ProcessEnv;
|
|
6
7
|
readonly rawOutput?: boolean;
|
|
7
8
|
readonly windowsVerbatimArguments?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Stops the child (SIGTERM, then SIGKILL after a grace period) and rejects
|
|
11
|
+
* with an AbortError, but only once the child has exited, and with
|
|
12
|
+
* `processGroup` once its whole tree is proven gone: a caller that returns
|
|
13
|
+
* capacity on rejection never does so while the command still runs.
|
|
14
|
+
*/
|
|
15
|
+
readonly signal?: AbortSignal;
|
|
16
|
+
/**
|
|
17
|
+
* Treat the command's whole process tree as the step: it is stopped as a
|
|
18
|
+
* whole (on abort, and whatever outlives the command when it exits) and the
|
|
19
|
+
* run settles only once no member is left. Unix: the command leads its own
|
|
20
|
+
* process group. Windows (no process groups): the tree is tracked while the
|
|
21
|
+
* command runs and stopped with `taskkill /T /F`; see process-tree.ts. If the
|
|
22
|
+
* tree cannot be proven gone the run rejects with ProcessTreeTerminationError.
|
|
23
|
+
*/
|
|
24
|
+
readonly processGroup?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Keeps at most this many characters of each stream: the tail, after a
|
|
27
|
+
* truncation notice. Unbounded when omitted.
|
|
28
|
+
*/
|
|
29
|
+
readonly maxOutputChars?: number;
|
|
30
|
+
/** Called with the child's pid once it has spawned. */
|
|
31
|
+
readonly onSpawn?: (pid: number) => void;
|
|
8
32
|
}
|
|
9
33
|
export interface ProcessRunResult {
|
|
10
34
|
readonly exitCode: number;
|
|
11
35
|
readonly stdout: string;
|
|
12
36
|
readonly stderr: string;
|
|
37
|
+
/** True when maxOutputChars dropped the head of either stream. */
|
|
38
|
+
readonly outputTruncated?: boolean;
|
|
13
39
|
}
|
|
14
40
|
export interface ProcessRunner {
|
|
15
41
|
run(request: ProcessRunRequest): Promise<ProcessRunResult>;
|
|
16
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* A command's process tree could not be proven gone after it was stopped.
|
|
45
|
+
* Whatever reserved capacity for it must keep that reservation.
|
|
46
|
+
*/
|
|
47
|
+
export declare class ProcessTreeTerminationError extends Error {
|
|
48
|
+
readonly rootPid: number;
|
|
49
|
+
readonly command: string;
|
|
50
|
+
readonly stillGone: () => Promise<boolean>;
|
|
51
|
+
readonly code = "process_tree_termination_unconfirmed";
|
|
52
|
+
/**
|
|
53
|
+
* `stillGone` resolves true once the tree is proven gone (Unix: an existence
|
|
54
|
+
* check only, since its members were already SIGKILLed; Windows: another
|
|
55
|
+
* tracked stop), for callers that hold the reservation until then.
|
|
56
|
+
*/
|
|
57
|
+
constructor(rootPid: number, command: string, stillGone: () => Promise<boolean>);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* True when `error`, or anything it wraps (an AggregateError's errors, a cause
|
|
61
|
+
* chain, a sanitized copy that kept only the message), says a process tree
|
|
62
|
+
* could not be proven gone. Whoever holds capacity for that tree must keep it.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isProcessTreeTerminationUnproven(error: unknown, depth?: number): boolean;
|
|
65
|
+
export interface NodeProcessRunnerOptions {
|
|
66
|
+
/** How long a stopped command gets after SIGTERM before SIGKILL. */
|
|
67
|
+
readonly terminationGraceMs?: number;
|
|
68
|
+
/** How long to wait for a SIGKILLed tree to disappear before giving up. */
|
|
69
|
+
readonly killWaitMs?: number;
|
|
70
|
+
/** Test seams for the Windows tree path. */
|
|
71
|
+
readonly platform?: NodeJS.Platform;
|
|
72
|
+
readonly windowsProcesses?: WindowsProcessTable;
|
|
73
|
+
readonly windowsTrackIntervalMs?: number;
|
|
74
|
+
/** Test seam: whether a Unix process group still has members. */
|
|
75
|
+
readonly groupAlive?: (groupId: number) => boolean;
|
|
76
|
+
}
|
|
17
77
|
export declare class NodeProcessRunner implements ProcessRunner {
|
|
78
|
+
private readonly graceMs;
|
|
79
|
+
private readonly killWaitMs;
|
|
80
|
+
private readonly platform;
|
|
81
|
+
private readonly windowsProcesses;
|
|
82
|
+
private readonly windowsTrackIntervalMs;
|
|
83
|
+
private readonly groupAlive;
|
|
84
|
+
constructor(options?: NodeProcessRunnerOptions);
|
|
18
85
|
run(request: ProcessRunRequest): Promise<ProcessRunResult>;
|
|
19
86
|
}
|
|
@@ -1,38 +1,240 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import readline from "node:readline";
|
|
3
|
+
import { systemWindowsProcessTable, windowsTicksFromEpochMs, WindowsProcessTree } from "./process-tree.js";
|
|
4
|
+
/**
|
|
5
|
+
* A command's process tree could not be proven gone after it was stopped.
|
|
6
|
+
* Whatever reserved capacity for it must keep that reservation.
|
|
7
|
+
*/
|
|
8
|
+
export class ProcessTreeTerminationError extends Error {
|
|
9
|
+
rootPid;
|
|
10
|
+
command;
|
|
11
|
+
stillGone;
|
|
12
|
+
code = "process_tree_termination_unconfirmed";
|
|
13
|
+
/**
|
|
14
|
+
* `stillGone` resolves true once the tree is proven gone (Unix: an existence
|
|
15
|
+
* check only, since its members were already SIGKILLed; Windows: another
|
|
16
|
+
* tracked stop), for callers that hold the reservation until then.
|
|
17
|
+
*/
|
|
18
|
+
constructor(rootPid, command, stillGone) {
|
|
19
|
+
super(`process_tree_termination_unconfirmed: ${command} (pid ${rootPid}) left processes that did not stop after SIGKILL; its host capacity stays reserved until they are gone.`);
|
|
20
|
+
this.rootPid = rootPid;
|
|
21
|
+
this.command = command;
|
|
22
|
+
this.stillGone = stillGone;
|
|
23
|
+
this.name = "ProcessTreeTerminationError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Codes of every failure that means a process tree may still be running. */
|
|
27
|
+
const unprovenTerminationCodes = ["process_tree_termination_unconfirmed", "host_process_supervisor_termination_failed"];
|
|
28
|
+
/**
|
|
29
|
+
* True when `error`, or anything it wraps (an AggregateError's errors, a cause
|
|
30
|
+
* chain, a sanitized copy that kept only the message), says a process tree
|
|
31
|
+
* could not be proven gone. Whoever holds capacity for that tree must keep it.
|
|
32
|
+
*/
|
|
33
|
+
export function isProcessTreeTerminationUnproven(error, depth = 0) {
|
|
34
|
+
if (depth > 8 || error === null || error === undefined)
|
|
35
|
+
return false;
|
|
36
|
+
if (error instanceof ProcessTreeTerminationError)
|
|
37
|
+
return true;
|
|
38
|
+
const message = error instanceof Error ? error.message : typeof error === "string" ? error : "";
|
|
39
|
+
if (unprovenTerminationCodes.some(code => message.includes(code)))
|
|
40
|
+
return true;
|
|
41
|
+
if (error instanceof AggregateError && error.errors.some(inner => isProcessTreeTerminationUnproven(inner, depth + 1)))
|
|
42
|
+
return true;
|
|
43
|
+
return error instanceof Error && isProcessTreeTerminationUnproven(error.cause, depth + 1);
|
|
44
|
+
}
|
|
3
45
|
export class NodeProcessRunner {
|
|
46
|
+
graceMs;
|
|
47
|
+
killWaitMs;
|
|
48
|
+
platform;
|
|
49
|
+
windowsProcesses;
|
|
50
|
+
windowsTrackIntervalMs;
|
|
51
|
+
groupAlive;
|
|
52
|
+
constructor(options = {}) {
|
|
53
|
+
this.graceMs = options.terminationGraceMs ?? 5_000;
|
|
54
|
+
this.killWaitMs = options.killWaitMs ?? 10_000;
|
|
55
|
+
this.platform = options.platform ?? process.platform;
|
|
56
|
+
this.windowsProcesses = options.windowsProcesses ?? systemWindowsProcessTable;
|
|
57
|
+
this.windowsTrackIntervalMs = options.windowsTrackIntervalMs ?? 2_000;
|
|
58
|
+
this.groupAlive = options.groupAlive ?? groupExists;
|
|
59
|
+
}
|
|
4
60
|
async run(request) {
|
|
61
|
+
if (request.signal?.aborted)
|
|
62
|
+
throw abortError(request.signal);
|
|
63
|
+
const tree = request.processGroup === true ? (this.platform === "win32" ? "windows" : "unix") : null;
|
|
64
|
+
// Taken before the spawn: the root is created no earlier than this (less clock and
|
|
65
|
+
// precision slack), which anchors its Windows tree even if it exits before a snapshot.
|
|
66
|
+
const spawnedNotBefore = windowsTicksFromEpochMs(Date.now() - 2_000);
|
|
5
67
|
return await new Promise((resolve, reject) => {
|
|
6
68
|
const child = spawn(request.command, request.args, {
|
|
7
69
|
cwd: request.cwd,
|
|
8
70
|
env: request.env,
|
|
9
71
|
stdio: ["ignore", "pipe", "pipe"],
|
|
10
72
|
windowsVerbatimArguments: request.windowsVerbatimArguments,
|
|
73
|
+
detached: tree === "unix",
|
|
74
|
+
});
|
|
75
|
+
const stdout = new OutputTail(request.maxOutputChars);
|
|
76
|
+
const stderr = new OutputTail(request.maxOutputChars);
|
|
77
|
+
let aborted = false;
|
|
78
|
+
let escalation = null;
|
|
79
|
+
let tracking = null;
|
|
80
|
+
// Resolves true once the tree is proven gone (trivially true without a tree).
|
|
81
|
+
let treeGone = Promise.resolve(true);
|
|
82
|
+
const windowsTree = tree === "windows" && child.pid
|
|
83
|
+
? new WindowsProcessTree(child.pid, this.windowsProcesses, { notBefore: spawnedNotBefore })
|
|
84
|
+
: null;
|
|
85
|
+
const signalChild = (signal) => {
|
|
86
|
+
if (!child.pid)
|
|
87
|
+
return;
|
|
88
|
+
try {
|
|
89
|
+
process.kill(tree === "unix" ? -child.pid : child.pid, signal);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// ESRCH: already gone. Anything else surfaces as the child's own exit.
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const onAbort = () => {
|
|
96
|
+
aborted = true;
|
|
97
|
+
if (windowsTree) {
|
|
98
|
+
// No signals on Windows: the tracked tree is stopped once the root exits.
|
|
99
|
+
void this.windowsProcesses.killTree(child.pid);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
signalChild("SIGTERM");
|
|
103
|
+
escalation = setTimeout(() => signalChild("SIGKILL"), this.graceMs);
|
|
104
|
+
escalation.unref?.();
|
|
105
|
+
};
|
|
106
|
+
const cleanup = () => {
|
|
107
|
+
request.signal?.removeEventListener("abort", onAbort);
|
|
108
|
+
if (escalation)
|
|
109
|
+
clearTimeout(escalation);
|
|
110
|
+
if (tracking)
|
|
111
|
+
clearInterval(tracking);
|
|
112
|
+
};
|
|
113
|
+
if (request.onSpawn)
|
|
114
|
+
child.once("spawn", () => { if (child.pid)
|
|
115
|
+
request.onSpawn(child.pid); });
|
|
116
|
+
if (windowsTree) {
|
|
117
|
+
void windowsTree.track();
|
|
118
|
+
tracking = setInterval(() => void windowsTree.track(), this.windowsTrackIntervalMs);
|
|
119
|
+
tracking.unref?.();
|
|
120
|
+
}
|
|
121
|
+
request.signal?.addEventListener("abort", onAbort, { once: true });
|
|
122
|
+
child.on("error", error => {
|
|
123
|
+
// A launch failure (ENOENT and the like): nothing is running.
|
|
124
|
+
if (child.pid === undefined) {
|
|
125
|
+
cleanup();
|
|
126
|
+
reject(error);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
// The command itself ended. Members of its tree that outlive it (a daemon or an
|
|
130
|
+
// orphaned script holding the pipes open) are stopped, so "close" can follow.
|
|
131
|
+
child.once("exit", () => {
|
|
132
|
+
if (!child.pid)
|
|
133
|
+
return;
|
|
134
|
+
if (tree === "unix")
|
|
135
|
+
treeGone = stopUnixGroup(child.pid, this.graceMs, this.killWaitMs, this.groupAlive);
|
|
136
|
+
if (windowsTree) {
|
|
137
|
+
windowsTree.markRootExited();
|
|
138
|
+
treeGone = windowsTree.stop(Date.now() + this.graceMs + this.killWaitMs);
|
|
139
|
+
}
|
|
11
140
|
});
|
|
12
|
-
let stdout = "";
|
|
13
|
-
let stderr = "";
|
|
14
|
-
child.on("error", reject);
|
|
15
141
|
const stdoutReader = request.rawOutput ? undefined : readline.createInterface({ input: child.stdout });
|
|
16
142
|
const stderrReader = request.rawOutput ? undefined : readline.createInterface({ input: child.stderr });
|
|
17
143
|
if (request.rawOutput) {
|
|
18
|
-
child.stdout.setEncoding("utf8").on("data", chunk => { stdout
|
|
19
|
-
child.stderr.setEncoding("utf8").on("data", chunk => { stderr
|
|
144
|
+
child.stdout.setEncoding("utf8").on("data", chunk => { stdout.append(chunk); });
|
|
145
|
+
child.stderr.setEncoding("utf8").on("data", chunk => { stderr.append(chunk); });
|
|
20
146
|
}
|
|
21
147
|
stdoutReader?.on("line", (line) => {
|
|
22
|
-
stdout
|
|
148
|
+
stdout.append(`${line}\n`);
|
|
23
149
|
});
|
|
24
150
|
stderrReader?.on("line", (line) => {
|
|
25
|
-
stderr
|
|
151
|
+
stderr.append(`${line}\n`);
|
|
26
152
|
});
|
|
27
153
|
child.on("close", (code) => {
|
|
28
154
|
stdoutReader?.close();
|
|
29
155
|
stderrReader?.close();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
156
|
+
void treeGone.then(gone => {
|
|
157
|
+
cleanup();
|
|
158
|
+
// Never settle as finished while part of the tree may still run.
|
|
159
|
+
if (!gone) {
|
|
160
|
+
const pid = child.pid;
|
|
161
|
+
reject(new ProcessTreeTerminationError(pid, request.command, windowsTree
|
|
162
|
+
? async () => await windowsTree.stop(Date.now() + this.graceMs)
|
|
163
|
+
: async () => !this.groupAlive(pid)));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (aborted) {
|
|
167
|
+
reject(abortError(request.signal));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const truncated = stdout.truncated || stderr.truncated;
|
|
171
|
+
resolve({
|
|
172
|
+
exitCode: code ?? 1,
|
|
173
|
+
stdout: stdout.value(),
|
|
174
|
+
stderr: stderr.value(),
|
|
175
|
+
...truncated ? { outputTruncated: true } : {},
|
|
176
|
+
});
|
|
34
177
|
});
|
|
35
178
|
});
|
|
36
179
|
});
|
|
37
180
|
}
|
|
38
181
|
}
|
|
182
|
+
/** Keeps the last `limit` characters of a stream; unbounded without a limit. */
|
|
183
|
+
class OutputTail {
|
|
184
|
+
limit;
|
|
185
|
+
text = "";
|
|
186
|
+
truncated = false;
|
|
187
|
+
constructor(limit) {
|
|
188
|
+
this.limit = limit;
|
|
189
|
+
}
|
|
190
|
+
append(chunk) {
|
|
191
|
+
this.text += chunk;
|
|
192
|
+
// Trimmed in batches, so a noisy stream costs amortized linear time.
|
|
193
|
+
if (this.limit !== undefined && this.text.length > 2 * this.limit)
|
|
194
|
+
this.trim();
|
|
195
|
+
}
|
|
196
|
+
value() {
|
|
197
|
+
if (this.limit !== undefined && this.text.length > this.limit)
|
|
198
|
+
this.trim();
|
|
199
|
+
return this.truncated
|
|
200
|
+
? `[output truncated: only the last ${this.limit} characters are kept]\n${this.text}`
|
|
201
|
+
: this.text;
|
|
202
|
+
}
|
|
203
|
+
trim() {
|
|
204
|
+
this.text = this.text.slice(-this.limit);
|
|
205
|
+
this.truncated = true;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* SIGTERM, then SIGKILL, to what is left of a process group. True once the
|
|
210
|
+
* group is empty; false when members survive the SIGKILL wait.
|
|
211
|
+
*/
|
|
212
|
+
async function stopUnixGroup(groupId, graceMs, killWaitMs, alive) {
|
|
213
|
+
for (const [signal, waitMs] of [["SIGTERM", graceMs], ["SIGKILL", killWaitMs]]) {
|
|
214
|
+
if (!alive(groupId))
|
|
215
|
+
return true;
|
|
216
|
+
try {
|
|
217
|
+
process.kill(-groupId, signal);
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
// ESRCH: the group emptied meanwhile; checked below.
|
|
221
|
+
}
|
|
222
|
+
const deadline = Date.now() + waitMs;
|
|
223
|
+
while (alive(groupId) && Date.now() < deadline)
|
|
224
|
+
await new Promise(resolve => setTimeout(resolve, 20));
|
|
225
|
+
}
|
|
226
|
+
// The deadline is a failed proof, not a success: a member may still run.
|
|
227
|
+
return !alive(groupId);
|
|
228
|
+
}
|
|
229
|
+
function groupExists(groupId) {
|
|
230
|
+
try {
|
|
231
|
+
process.kill(-groupId, 0);
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
return error.code === "EPERM";
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function abortError(signal) {
|
|
239
|
+
return Object.assign(new Error("The operation was aborted", { cause: signal.reason }), { name: "AbortError", code: "ABORT_ERR" });
|
|
240
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tools an agent commonly starts by bare name. When one of them resolves to a Microsoft Store
|
|
3
|
+
* app-execution alias (`%LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe` and the like), Windows
|
|
4
|
+
* creates the process it starts outside the provider's Job Object: it survives the job, keeps the
|
|
5
|
+
* pipe handles it inherited, and holds the attempt's output open until it exits on its own.
|
|
6
|
+
*/
|
|
7
|
+
export declare const APP_EXECUTION_ALIAS_SENSITIVE_TOOLS: readonly ["pwsh", "node", "dotnet"];
|
|
8
|
+
export interface AppExecutionAliasFinding {
|
|
9
|
+
readonly tool: string;
|
|
10
|
+
/** The alias the tool's bare name resolves to. */
|
|
11
|
+
readonly aliasPath: string;
|
|
12
|
+
/** The first regular install later on PATH, or null when the alias is the only one. */
|
|
13
|
+
readonly nextInstallPath: string | null;
|
|
14
|
+
}
|
|
15
|
+
/** The sensitive tools whose bare name resolves, on this PATH, to an app-execution alias. */
|
|
16
|
+
export declare function findAppExecutionAliasTools(pathValue: string, pathExtValue?: string, tools?: readonly string[]): AppExecutionAliasFinding[];
|
|
17
|
+
export declare function describeAppExecutionAliasFindings(findings: readonly AppExecutionAliasFinding[]): string | null;
|
|
18
|
+
/** Reads PATH and PATHEXT from an environment whose key case is not normalized (Windows: "Path"). */
|
|
19
|
+
export declare function appExecutionAliasWarning(env: Readonly<Record<string, string | undefined>>, platform?: NodeJS.Platform): string | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { isWindowsAppExecutionAliasPath, resolveWindowsCommandFromPath } from "./windows-launch.js";
|
|
2
|
+
/**
|
|
3
|
+
* Tools an agent commonly starts by bare name. When one of them resolves to a Microsoft Store
|
|
4
|
+
* app-execution alias (`%LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe` and the like), Windows
|
|
5
|
+
* creates the process it starts outside the provider's Job Object: it survives the job, keeps the
|
|
6
|
+
* pipe handles it inherited, and holds the attempt's output open until it exits on its own.
|
|
7
|
+
*/
|
|
8
|
+
export const APP_EXECUTION_ALIAS_SENSITIVE_TOOLS = ["pwsh", "node", "dotnet"];
|
|
9
|
+
/** The sensitive tools whose bare name resolves, on this PATH, to an app-execution alias. */
|
|
10
|
+
export function findAppExecutionAliasTools(pathValue, pathExtValue, tools = APP_EXECUTION_ALIAS_SENSITIVE_TOOLS) {
|
|
11
|
+
const findings = [];
|
|
12
|
+
for (const tool of tools) {
|
|
13
|
+
const aliasPath = resolveWindowsCommandFromPath(tool, pathValue, pathExtValue);
|
|
14
|
+
if (!aliasPath || !isWindowsAppExecutionAliasPath(aliasPath))
|
|
15
|
+
continue;
|
|
16
|
+
const nextInstallPath = resolveWindowsCommandFromPath(tool, pathValue, pathExtValue, { skipAppExecutionAliases: true });
|
|
17
|
+
findings.push({ tool, aliasPath, nextInstallPath });
|
|
18
|
+
}
|
|
19
|
+
return findings;
|
|
20
|
+
}
|
|
21
|
+
export function describeAppExecutionAliasFindings(findings) {
|
|
22
|
+
if (findings.length === 0)
|
|
23
|
+
return null;
|
|
24
|
+
const tools = findings.map(finding => `${finding.tool} -> ${finding.aliasPath}${finding.nextInstallPath
|
|
25
|
+
? ` (a regular install later on PATH: ${finding.nextInstallPath})`
|
|
26
|
+
: " (no regular install on PATH)"}`);
|
|
27
|
+
return "Host readiness warning: on the provider PATH, "
|
|
28
|
+
+ `${tools.join("; ")} resolve${findings.length === 1 ? "s" : ""} to a Microsoft Store app-execution alias under WindowsApps. `
|
|
29
|
+
+ "A process started through an alias is created outside the provider's Windows Job Object, survives it, "
|
|
30
|
+
+ "and can hold the attempt's output pipes open until it exits. Install the tool normally "
|
|
31
|
+
+ "(for PowerShell, the MSI under C:\\Program Files\\PowerShell\\7) and put it ahead of WindowsApps on PATH.";
|
|
32
|
+
}
|
|
33
|
+
/** Reads PATH and PATHEXT from an environment whose key case is not normalized (Windows: "Path"). */
|
|
34
|
+
export function appExecutionAliasWarning(env, platform = process.platform) {
|
|
35
|
+
if (platform !== "win32")
|
|
36
|
+
return null;
|
|
37
|
+
const pathValue = environmentValue(env, "PATH");
|
|
38
|
+
if (!pathValue)
|
|
39
|
+
return null;
|
|
40
|
+
return describeAppExecutionAliasFindings(findAppExecutionAliasTools(pathValue, environmentValue(env, "PATHEXT")));
|
|
41
|
+
}
|
|
42
|
+
function environmentValue(env, name) {
|
|
43
|
+
const key = Object.keys(env).find(candidate => candidate.toUpperCase() === name);
|
|
44
|
+
return key === undefined ? undefined : env[key];
|
|
45
|
+
}
|
|
@@ -6,3 +6,21 @@ export declare function buildWindowsCmdLaunch(command: string, args: readonly st
|
|
|
6
6
|
export declare function buildWindowsLaunchCommand(commandPath: string, args: readonly string[]): LaunchCommand;
|
|
7
7
|
export declare function windowsCommandLine(command: string, args: readonly string[]): string;
|
|
8
8
|
export declare function quoteWindowsCommandLineArg(value: string): string;
|
|
9
|
+
export interface WindowsCommandPathOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Skip candidates under a `WindowsApps` directory. Those are Microsoft Store app-execution
|
|
12
|
+
* aliases: the process they start is created outside the caller's Job Object, so it survives the
|
|
13
|
+
* job and keeps any inherited pipe open. Resolve the next real install on PATH instead.
|
|
14
|
+
*/
|
|
15
|
+
readonly skipAppExecutionAliases?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolves Windows commands without spawning where.exe. Runtime launches can
|
|
19
|
+
* happen while the machine is under enough process pressure for where.exe to
|
|
20
|
+
* miss its timeout; returning the unresolved package-manager name in that case
|
|
21
|
+
* makes Node fall back to a shell shim that cannot survive Job Object wrapping.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveWindowsCommandFromPath(command: string, pathValue?: string, pathExtValue?: string, options?: WindowsCommandPathOptions): string | null;
|
|
24
|
+
export declare function chooseWindowsCommandCandidate(candidates: readonly string[]): string | null;
|
|
25
|
+
/** True for a path inside a `WindowsApps` directory, where Store app-execution aliases live. */
|
|
26
|
+
export declare function isWindowsAppExecutionAliasPath(candidate: string): boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
export function buildWindowsCmdLaunch(command, args, comSpec = process.env.ComSpec) {
|
|
3
4
|
const resolvedComSpec = comSpec?.trim();
|
|
@@ -39,3 +40,70 @@ function powershellExecutable() {
|
|
|
39
40
|
? path.join(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe")
|
|
40
41
|
: "powershell.exe";
|
|
41
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolves Windows commands without spawning where.exe. Runtime launches can
|
|
45
|
+
* happen while the machine is under enough process pressure for where.exe to
|
|
46
|
+
* miss its timeout; returning the unresolved package-manager name in that case
|
|
47
|
+
* makes Node fall back to a shell shim that cannot survive Job Object wrapping.
|
|
48
|
+
*/
|
|
49
|
+
export function resolveWindowsCommandFromPath(command, pathValue = process.env.PATH ?? "", pathExtValue = process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD", options = {}) {
|
|
50
|
+
if (!command || path.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const hasExtension = path.extname(command).length > 0;
|
|
54
|
+
const extensions = hasExtension
|
|
55
|
+
? [""]
|
|
56
|
+
: [...new Set([
|
|
57
|
+
"",
|
|
58
|
+
".exe",
|
|
59
|
+
".ps1",
|
|
60
|
+
".cmd",
|
|
61
|
+
".bat",
|
|
62
|
+
...pathExtValue.split(";").map(value => value.trim().toLowerCase()).filter(Boolean),
|
|
63
|
+
])];
|
|
64
|
+
for (const rawDirectory of pathValue.split(path.delimiter)) {
|
|
65
|
+
const directory = rawDirectory.trim().replace(/^"|"$/gu, "");
|
|
66
|
+
if (!directory)
|
|
67
|
+
continue;
|
|
68
|
+
const candidates = [];
|
|
69
|
+
for (const extension of extensions) {
|
|
70
|
+
const candidate = path.join(directory, `${command}${extension}`);
|
|
71
|
+
if (options.skipAppExecutionAliases && isWindowsAppExecutionAliasPath(candidate))
|
|
72
|
+
continue;
|
|
73
|
+
if (pathEntryExists(candidate))
|
|
74
|
+
candidates.push(candidate);
|
|
75
|
+
}
|
|
76
|
+
const resolved = chooseWindowsCommandCandidate(candidates);
|
|
77
|
+
if (resolved)
|
|
78
|
+
return resolved;
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
export function chooseWindowsCommandCandidate(candidates) {
|
|
83
|
+
const normalized = candidates
|
|
84
|
+
.map((candidate) => candidate.trim())
|
|
85
|
+
.filter((candidate) => candidate.length > 0);
|
|
86
|
+
if (normalized.length === 0) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const preferredExtensions = [".exe", ".ps1", ".cmd", ".bat", ""];
|
|
90
|
+
for (const extension of preferredExtensions) {
|
|
91
|
+
const candidate = normalized.find((entry) => path.extname(entry).toLowerCase() === extension);
|
|
92
|
+
if (candidate) {
|
|
93
|
+
return candidate;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return normalized[0];
|
|
97
|
+
}
|
|
98
|
+
/** True for a path inside a `WindowsApps` directory, where Store app-execution aliases live. */
|
|
99
|
+
export function isWindowsAppExecutionAliasPath(candidate) {
|
|
100
|
+
return candidate.split(/[\\/]+/u).some(segment => segment.toLowerCase() === "windowsapps");
|
|
101
|
+
}
|
|
102
|
+
// An app-execution alias is a reparse point that stat() may not open, so an
|
|
103
|
+
// alias is also accepted when only lstat() can see it.
|
|
104
|
+
function pathEntryExists(candidate) {
|
|
105
|
+
if (fs.existsSync(candidate))
|
|
106
|
+
return true;
|
|
107
|
+
return isWindowsAppExecutionAliasPath(candidate)
|
|
108
|
+
&& fs.lstatSync(candidate, { throwIfNoEntry: false }) !== undefined;
|
|
109
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type BridgeChatCapability } from "../bridge/bridge-chat.types.js";
|
|
2
2
|
import type { BridgeProviderStatus } from "../bridge/bridge.types.js";
|
|
3
3
|
export declare function supportsDraftImageAttachmentsFor(cliProviders: readonly string[]): boolean;
|
|
4
|
+
/** The sandbox profiles a bridge advertises when none are configured: Codex's sandbox, or none. */
|
|
5
|
+
export declare function defaultSandboxProfiles(providers: readonly string[], platform?: NodeJS.Platform): readonly string[];
|
|
4
6
|
export declare function bridgeChatCapabilityFor(cliProviders: readonly string[], providerStatuses: Readonly<Record<string, BridgeProviderStatus>>, baseCapability?: BridgeChatCapability | null): BridgeChatCapability;
|
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import { bridgeChatProtocolVersion, normalizeBridgeChatCapability, unavailableBridgeChatCapability, } from "../bridge/bridge-chat.types.js";
|
|
2
|
+
import { isProviderUserConfigIsolated, userConfigIsolatedProviders } from "../session/provider-cli/provider-user-config-isolation.js";
|
|
2
3
|
const defaultBridgeChatMaxMessageBytes = 128 * 1024;
|
|
3
4
|
const defaultBridgeChatMaxContextRefs = 8;
|
|
4
5
|
export function supportsDraftImageAttachmentsFor(cliProviders) {
|
|
5
6
|
return cliProviders.some((provider) => provider.trim().toLowerCase() === "codex");
|
|
6
7
|
}
|
|
8
|
+
/** The sandbox profiles a bridge advertises when none are configured: Codex's sandbox, or none. */
|
|
9
|
+
export function defaultSandboxProfiles(providers, platform = process.platform) {
|
|
10
|
+
if (!providers.some((provider) => provider.toLowerCase() === "codex")) {
|
|
11
|
+
return ["none"];
|
|
12
|
+
}
|
|
13
|
+
return platform === "win32"
|
|
14
|
+
? ["danger-full-access"]
|
|
15
|
+
: ["provider-workspace-write"];
|
|
16
|
+
}
|
|
7
17
|
export function bridgeChatCapabilityFor(cliProviders, providerStatuses, baseCapability) {
|
|
8
18
|
const base = normalizeBridgeChatCapability(baseCapability ?? unavailableBridgeChatCapability());
|
|
9
19
|
if (base.protocolVersion !== bridgeChatProtocolVersion) {
|
|
10
20
|
return base;
|
|
11
21
|
}
|
|
12
|
-
const
|
|
22
|
+
const configuredProviders = chatProviderEntries(cliProviders, providerStatuses);
|
|
23
|
+
// Bridge Chat refuses a provider whose user configuration Forge can't keep out of the turn
|
|
24
|
+
// (cursor-agent, unknown CLIs), so it is never offered. The remaining providers decide
|
|
25
|
+
// availability: the server dispatches a turn only to a capability that is fully available.
|
|
26
|
+
const providers = configuredProviders.filter((provider) => isProviderUserConfigIsolated(provider.providerKind));
|
|
27
|
+
if (configuredProviders.length > 0 && providers.length === 0) {
|
|
28
|
+
return unavailableBridgeChatCapability(bridgeChatProtocolVersion, "no_isolated_cli_providers", `Bridge Chat runs only ${userConfigIsolatedProviders.join(" and ")}; Forge can't keep the host user's own configuration out of ${configuredProviders.map((provider) => provider.providerKind).join(", ")}.`);
|
|
29
|
+
}
|
|
13
30
|
const usableProviders = providers.filter((provider) => provider.status?.signedIn !== false);
|
|
14
31
|
if (usableProviders.length === 0) {
|
|
15
32
|
return unavailableBridgeChatCapability(bridgeChatProtocolVersion, providers.length === 0 ? "no_cli_providers" : "no_signed_in_cli_providers", providers.length === 0
|
|
@@ -40,8 +57,12 @@ function chatProviderEntries(cliProviders, providerStatuses) {
|
|
|
40
57
|
const providerKind = provider.trim().toLowerCase();
|
|
41
58
|
if (providerKind.length === 0)
|
|
42
59
|
continue;
|
|
43
|
-
statuses.set(providerKind, {
|
|
60
|
+
statuses.set(providerKind, { status });
|
|
44
61
|
}
|
|
62
|
+
// Only configured CLI providers can run a Bridge Chat turn. A status entry for a
|
|
63
|
+
// provider that is not in cliProviders (for example a leftover entry in
|
|
64
|
+
// bridge.json for a CLI that is no longer installed) annotates nothing and must
|
|
65
|
+
// not be advertised as a chat provider.
|
|
45
66
|
const providers = new Map();
|
|
46
67
|
for (const provider of cliProviders) {
|
|
47
68
|
const providerKind = provider.trim().toLowerCase();
|
|
@@ -52,11 +73,6 @@ function chatProviderEntries(cliProviders, providerStatuses) {
|
|
|
52
73
|
status: statuses.get(providerKind)?.status,
|
|
53
74
|
});
|
|
54
75
|
}
|
|
55
|
-
for (const [providerKind, entry] of statuses) {
|
|
56
|
-
if (!providers.has(providerKind)) {
|
|
57
|
-
providers.set(providerKind, entry);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
76
|
return [...providers.values()].sort((left, right) => compareStable(left.providerKind, right.providerKind));
|
|
61
77
|
}
|
|
62
78
|
function sortedUniqueStrings(values, lower) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const forgeBridgeVersion = "0.1
|
|
1
|
+
export declare const forgeBridgeVersion = "0.2.1-dev.0f07274d438b";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const forgeBridgeVersion = "0.1
|
|
1
|
+
export const forgeBridgeVersion = "0.2.1-dev.0f07274d438b";
|
|
@@ -32,6 +32,7 @@ const ARCHITECT_OPERATIONAL_HOOKS = new Set([
|
|
|
32
32
|
"architect-complete",
|
|
33
33
|
"architect-revise"
|
|
34
34
|
]);
|
|
35
|
+
const PR_REVIEW_OPERATIONAL_SKILLS = new Set(["pr-review"]);
|
|
35
36
|
const DRAFT_OPERATIONAL_SKILLS = new Set([
|
|
36
37
|
"draft-intent",
|
|
37
38
|
"draft-repo-context",
|
|
@@ -74,6 +75,9 @@ export function filterArtifactsForLane(artifacts, lane, phase) {
|
|
|
74
75
|
if (normalizedLane === "architect") {
|
|
75
76
|
return artifacts.filter((artifact) => shouldInjectArchitectArtifact(artifact, commandSlug));
|
|
76
77
|
}
|
|
78
|
+
if (normalizedLane === "pr_review" || normalizedLane === "pr-review") {
|
|
79
|
+
return artifacts.filter((artifact) => shouldInjectPrReviewArtifact(artifact, commandSlug));
|
|
80
|
+
}
|
|
77
81
|
if (normalizedLane === "draft") {
|
|
78
82
|
return artifacts.filter((artifact) => shouldInjectDraftArtifact(artifact, commandSlug, phase));
|
|
79
83
|
}
|
|
@@ -112,6 +116,9 @@ export function resolveCommandSlug(lane, phase) {
|
|
|
112
116
|
return "debug-prompt";
|
|
113
117
|
}
|
|
114
118
|
const normalizedPhase = phase.trim().toLowerCase().replace(/-/g, "_");
|
|
119
|
+
if (normalizedLane === "pr_review" || normalizedLane === "pr-review") {
|
|
120
|
+
return "pr-review-prompt";
|
|
121
|
+
}
|
|
115
122
|
if (normalizedPhase === "rework") {
|
|
116
123
|
return "rework-prompt";
|
|
117
124
|
}
|
|
@@ -122,6 +129,9 @@ export function resolveCommandSlug(lane, phase) {
|
|
|
122
129
|
return "architect-prompt";
|
|
123
130
|
case "qa":
|
|
124
131
|
return "qa-prompt";
|
|
132
|
+
case "pr_review":
|
|
133
|
+
case "pr-review":
|
|
134
|
+
return "pr-review-prompt";
|
|
125
135
|
default:
|
|
126
136
|
return "dev-prompt";
|
|
127
137
|
}
|
|
@@ -191,6 +201,20 @@ function shouldInjectArchitectArtifact(artifact, commandSlug) {
|
|
|
191
201
|
return false;
|
|
192
202
|
}
|
|
193
203
|
}
|
|
204
|
+
function shouldInjectPrReviewArtifact(artifact, commandSlug) {
|
|
205
|
+
if (artifact.scope.trim().toLowerCase() !== "operational") {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
const slug = artifact.slug.trim().toLowerCase();
|
|
209
|
+
switch (normalizedArtifactKind(artifact.kind)) {
|
|
210
|
+
case "command":
|
|
211
|
+
return slug === commandSlug;
|
|
212
|
+
case "skill":
|
|
213
|
+
return PR_REVIEW_OPERATIONAL_SKILLS.has(slug);
|
|
214
|
+
default:
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
194
218
|
function shouldInjectDraftArtifact(artifact, commandSlug, phase) {
|
|
195
219
|
if (artifact.scope.trim().toLowerCase() !== "operational") {
|
|
196
220
|
return false;
|