@loucompanion/forge-bridge 0.1.4-dev.fb770705136a → 0.2.1-dev.15efe2d7309f
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 +146 -3
- 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 +11 -0
- package/dist/bridge/bridge-state-io.js +50 -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 +92 -14
- package/dist/bridge/bridge.service.js +446 -380
- package/dist/bridge/bridge.types.d.ts +21 -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 +9 -0
- package/dist/cleanup/forge-owned-paths.js +53 -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 +74 -12
- package/dist/cli/cli.service.d.ts +19 -10
- package/dist/cli/cli.service.js +152 -187
- package/dist/cli/idle-status.d.ts +84 -0
- package/dist/cli/idle-status.js +181 -0
- package/dist/cli/local-config.d.ts +6 -0
- package/dist/cli/local-config.js +32 -4
- 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-child-environment.d.ts +27 -0
- package/dist/runtime/host-load-child-environment.js +76 -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 +61 -0
- package/dist/runtime/host-load-governor-config.js +86 -0
- package/dist/runtime/host-load-governor.d.ts +193 -0
- package/dist/runtime/host-load-governor.js +662 -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-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +80 -0
- package/dist/runtime/host-load-sampler.d.ts +75 -2
- package/dist/runtime/host-load-sampler.js +142 -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 +73 -0
- package/dist/runtime/host-load-step-run.js +102 -0
- package/dist/runtime/host-load-test-slot.d.ts +43 -0
- package/dist/runtime/host-load-test-slot.js +88 -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 +10 -1
- package/dist/sandbox/runtime.js +47 -8
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- 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 +207 -121
- 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 +5 -0
- package/dist/session/managed-build-receipt.js +8 -3
- package/dist/session/managed-command-host-load.d.ts +47 -0
- package/dist/session/managed-command-host-load.js +83 -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.artifacts.d.ts +7 -0
- package/dist/session/phase-completion.artifacts.js +96 -26
- 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 +12 -0
- package/dist/session/phase-completion.helpers.js +13 -12
- package/dist/session/phase-completion.js +5 -0
- package/dist/session/phase-completion.mcp-args.d.ts +9 -0
- package/dist/session/phase-completion.mcp-args.js +156 -0
- package/dist/session/phase-completion.prompts.js +6 -1
- package/dist/session/phase-completion.runtime.d.ts +5 -11
- package/dist/session/phase-completion.runtime.js +91 -215
- 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 +208 -231
- package/dist/session/phase-completion.validation.d.ts +2 -3
- package/dist/session/phase-completion.validation.js +49 -93
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +111 -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 +31 -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 +37 -21
- package/dist/session/pre-publication-validation.js +221 -182
- 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/host-build-lock.d.ts +18 -0
- package/dist/session/provider-cli/host-build-lock.js +30 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +277 -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.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.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 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +109 -32
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +8 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +29 -1
- package/dist/session/provider-cli/provider-cli.service.d.ts +7 -1
- package/dist/session/provider-cli/provider-cli.service.js +106 -181
- 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 +257 -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.service.d.ts +15 -2
- package/dist/session/session.service.js +246 -138
- package/dist/session/session.types.d.ts +4 -0
- package/dist/session/session.types.js +7 -7
- 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.js +14 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- 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 +36 -5
- package/dist/worktree/worktree.service.js +127 -155
- package/dist/worktree/worktree.types.d.ts +47 -0
- package/package.json +2 -2
- package/runtime/windows-listener-owner.ps1 +12 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { readEnvironmentValue } from "./provider-cli.windows-environment.js";
|
|
6
|
+
const maximumRecoverableCodexModelsCacheBytes = 16 * 1024 * 1024;
|
|
7
|
+
export function isCodexModelsCacheSchemaFailure(result) {
|
|
8
|
+
const output = `${result.stderr}\n${result.stdout}`.toLowerCase();
|
|
9
|
+
return output.includes("base_instructions")
|
|
10
|
+
&& output.includes("missing field")
|
|
11
|
+
&& (output.includes("models_cache") || output.includes("models cache") || output.includes("model cache"));
|
|
12
|
+
}
|
|
13
|
+
export async function quarantineIncompatibleCodexModelsCache(requestEnv) {
|
|
14
|
+
const configuredHome = readEnvironmentValue(requestEnv ?? {}, "CODEX_HOME")
|
|
15
|
+
?? readEnvironmentValue(process.env, "CODEX_HOME")
|
|
16
|
+
?? readEnvironmentValue(process.env, "FORGE_CODEX_HOME");
|
|
17
|
+
const codexHome = path.resolve(configuredHome ?? path.join(os.homedir(), ".codex"));
|
|
18
|
+
if (!path.isAbsolute(codexHome) || codexHome === path.parse(codexHome).root)
|
|
19
|
+
return false;
|
|
20
|
+
const cachePath = path.join(codexHome, "models_cache.json");
|
|
21
|
+
const cacheStat = await fs.promises.lstat(cachePath).catch(error => {
|
|
22
|
+
if (error.code === "ENOENT")
|
|
23
|
+
return null;
|
|
24
|
+
throw error;
|
|
25
|
+
});
|
|
26
|
+
if (!cacheStat
|
|
27
|
+
|| !cacheStat.isFile()
|
|
28
|
+
|| cacheStat.isSymbolicLink()
|
|
29
|
+
|| cacheStat.nlink !== 1
|
|
30
|
+
|| cacheStat.size <= 0
|
|
31
|
+
|| cacheStat.size > maximumRecoverableCodexModelsCacheBytes) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const quarantinePath = path.join(codexHome, `models_cache.forge-incompatible-${Date.now()}-${randomUUID()}.json`);
|
|
35
|
+
await fs.promises.rename(cachePath, quarantinePath);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
@@ -57,17 +57,20 @@ export declare class MergeResolutionUnresolvedConflictError extends ForgeFailure
|
|
|
57
57
|
export declare function isMergeInProgress(git: GitRunner, worktreePath: string): Promise<boolean>;
|
|
58
58
|
export declare function readInProgressMerge(git: GitRunner, worktreePath: string): Promise<InProgressMerge | null>;
|
|
59
59
|
/**
|
|
60
|
-
* Fails before `git add -A` can silently resolve a conflict
|
|
60
|
+
* Fails before `git add -A` can silently resolve a conflict, during a merge or whenever the index
|
|
61
|
+
* holds unmerged paths without one (a WIP snapshot re-applied across a branch move that conflicted,
|
|
62
|
+
* see wip-restore.ts):
|
|
61
63
|
* - a modify/delete conflict, by keeping whatever is on disk;
|
|
62
64
|
* - a binary (or other marker-less) conflict, by staging whichever side is on disk;
|
|
63
65
|
* - a content conflict, by staging its conflict markers. This includes markers
|
|
64
66
|
* the provider already staged, which clears the unmerged stages, so every path
|
|
65
|
-
* both sides changed is checked too
|
|
67
|
+
* both sides of the merge changed is checked too, or without a merge every path
|
|
68
|
+
* the worktree's WIP re-apply conflict record lists.
|
|
66
69
|
* A text conflict the agent resolved in the working tree without `git add` is
|
|
67
70
|
* still unmerged here and is accepted once its markers are gone.
|
|
68
71
|
*/
|
|
69
72
|
export declare function assertNoUnresolvedMergeConflicts(git: GitRunner, worktreePath: string): Promise<void>;
|
|
70
|
-
export declare function readUnresolvedMergeConflicts(git: GitRunner, worktreePath: string, merge: InProgressMerge): Promise<readonly UnresolvedMergeConflict[]>;
|
|
73
|
+
export declare function readUnresolvedMergeConflicts(git: GitRunner, worktreePath: string, merge: InProgressMerge | null): Promise<readonly UnresolvedMergeConflict[]>;
|
|
71
74
|
/**
|
|
72
75
|
* Staging excludes some worktree changes (Forge runtime output) by unstaging them
|
|
73
76
|
* back to HEAD. During a merge HEAD is the story side, so an excluded path the merge
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { hasConflictMarkerLines, parseReapplyConflictRecord, wipReapplyConflictRecordName } from "../../worktree/wip-refs.js";
|
|
3
4
|
import { ForgeFailureError } from "../session.types.js";
|
|
4
5
|
const maxListedPaths = 20;
|
|
5
6
|
const pathArgumentChunkSize = 100;
|
|
@@ -61,19 +62,20 @@ export async function readInProgressMerge(git, worktreePath) {
|
|
|
61
62
|
return { headSha, mergeHeadSha, mergeBaseSha };
|
|
62
63
|
}
|
|
63
64
|
/**
|
|
64
|
-
* Fails before `git add -A` can silently resolve a conflict
|
|
65
|
+
* Fails before `git add -A` can silently resolve a conflict, during a merge or whenever the index
|
|
66
|
+
* holds unmerged paths without one (a WIP snapshot re-applied across a branch move that conflicted,
|
|
67
|
+
* see wip-restore.ts):
|
|
65
68
|
* - a modify/delete conflict, by keeping whatever is on disk;
|
|
66
69
|
* - a binary (or other marker-less) conflict, by staging whichever side is on disk;
|
|
67
70
|
* - a content conflict, by staging its conflict markers. This includes markers
|
|
68
71
|
* the provider already staged, which clears the unmerged stages, so every path
|
|
69
|
-
* both sides changed is checked too
|
|
72
|
+
* both sides of the merge changed is checked too, or without a merge every path
|
|
73
|
+
* the worktree's WIP re-apply conflict record lists.
|
|
70
74
|
* A text conflict the agent resolved in the working tree without `git add` is
|
|
71
75
|
* still unmerged here and is accepted once its markers are gone.
|
|
72
76
|
*/
|
|
73
77
|
export async function assertNoUnresolvedMergeConflicts(git, worktreePath) {
|
|
74
78
|
const merge = await readInProgressMerge(git, worktreePath);
|
|
75
|
-
if (!merge)
|
|
76
|
-
return;
|
|
77
79
|
const conflicts = await readUnresolvedMergeConflicts(git, worktreePath, merge);
|
|
78
80
|
if (conflicts.length > 0) {
|
|
79
81
|
throw new MergeResolutionUnresolvedConflictError(conflicts);
|
|
@@ -117,16 +119,34 @@ export async function readUnresolvedMergeConflicts(git, worktreePath, merge) {
|
|
|
117
119
|
else if (hasConflictMarkers(content))
|
|
118
120
|
conflicts.push({ path: filePath, kind: "conflict_markers" });
|
|
119
121
|
}
|
|
122
|
+
const unmergedPaths = new Set(stagesByPath.keys());
|
|
123
|
+
conflicts.push(...await markerConflicts(worktreePath, unmergedPaths, merge
|
|
124
|
+
? await bothChangedPaths(git, worktreePath, merge)
|
|
125
|
+
: await reapplyConflictPaths(git, worktreePath)));
|
|
126
|
+
return conflicts.sort((left, right) => left.path.localeCompare(right.path));
|
|
127
|
+
}
|
|
128
|
+
/** Paths both sides of the merge changed. */
|
|
129
|
+
async function bothChangedPaths(git, worktreePath, merge) {
|
|
120
130
|
const storyChanged = new Set(await diffNames(git, worktreePath, [merge.mergeBaseSha, merge.headSha]));
|
|
121
|
-
|
|
122
|
-
.filter(filePath => storyChanged.has(filePath)
|
|
123
|
-
|
|
131
|
+
return (await diffNames(git, worktreePath, [merge.mergeBaseSha, merge.mergeHeadSha]))
|
|
132
|
+
.filter(filePath => storyChanged.has(filePath));
|
|
133
|
+
}
|
|
134
|
+
/** Paths a WIP re-apply left conflicted, from the worktree's record (wip-refs.ts); [] without one. */
|
|
135
|
+
async function reapplyConflictPaths(git, worktreePath) {
|
|
136
|
+
const raw = (await git.run(worktreePath, ["rev-parse", "--git-path", wipReapplyConflictRecordName])).trim();
|
|
137
|
+
const record = path.isAbsolute(raw) ? raw : path.resolve(worktreePath, raw);
|
|
138
|
+
return parseReapplyConflictRecord(await fs.readFile(record, "utf8").catch(() => null));
|
|
139
|
+
}
|
|
140
|
+
/** Candidate conflict paths whose markers the provider already staged (no unmerged stages left). */
|
|
141
|
+
async function markerConflicts(worktreePath, unmergedPaths, candidates) {
|
|
142
|
+
const conflicts = [];
|
|
143
|
+
for (const filePath of candidates.filter(candidate => !unmergedPaths.has(candidate))) {
|
|
124
144
|
const content = await readWorkingFile(worktreePath, filePath);
|
|
125
145
|
if (content && !isBinary(content) && hasConflictMarkers(content)) {
|
|
126
146
|
conflicts.push({ path: filePath, kind: "conflict_markers" });
|
|
127
147
|
}
|
|
128
148
|
}
|
|
129
|
-
return conflicts
|
|
149
|
+
return conflicts;
|
|
130
150
|
}
|
|
131
151
|
/**
|
|
132
152
|
* Staging excludes some worktree changes (Forge runtime output) by unstaging them
|
|
@@ -265,9 +285,8 @@ function chunks(paths) {
|
|
|
265
285
|
}
|
|
266
286
|
return result;
|
|
267
287
|
}
|
|
268
|
-
const conflictMarkerPattern = /^<{7}(?: |$)[\s\S]*^>{7}(?: |$)/mu;
|
|
269
288
|
function hasConflictMarkers(content) {
|
|
270
|
-
return
|
|
289
|
+
return hasConflictMarkerLines(content.toString("utf8"));
|
|
271
290
|
}
|
|
272
291
|
/**
|
|
273
292
|
* Paths whose effective `merge` attribute selects Git's binary merge driver, which
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { LaunchCommand } from "../../shared/process/windows-launch.js";
|
|
2
2
|
import { ForgeFailureError } from "../session.types.js";
|
|
3
|
+
export { chooseWindowsCommandCandidate, resolveWindowsCommandFromPath } from "../../shared/process/windows-launch.js";
|
|
4
|
+
export { buildProviderChildEnvironment, type ProviderChildEnvironmentOptions } from "./provider-cli.child-environment.js";
|
|
3
5
|
export declare const PROVIDER_OUTPUT_CAPTURE_LIMIT_CHARS: number;
|
|
4
6
|
export type ProviderCliCommand = LaunchCommand;
|
|
7
|
+
export { resolveClaudeNpmDirectLaunch, resolveCodexNpmDirectLaunch, resolvePackageManagerDirectLaunch } from "./provider-cli.windows-launch.js";
|
|
5
8
|
export interface ProviderProcessRunRequest {
|
|
6
9
|
readonly command: string;
|
|
7
10
|
readonly args: readonly string[];
|
|
@@ -22,8 +25,8 @@ export interface ProviderProcessRunRequest {
|
|
|
22
25
|
*/
|
|
23
26
|
readonly resumesProviderThread?: boolean;
|
|
24
27
|
}
|
|
25
|
-
/** Why Forge stopped a provider
|
|
26
|
-
export type ProviderTerminalStopReason = "turn_exit_grace" | "success_ceiling";
|
|
28
|
+
/** Why Forge stopped a provider still resident after its turn (or its background work, for Claude). */
|
|
29
|
+
export type ProviderTerminalStopReason = "turn_exit_grace" | "success_ceiling" | "turn_ended_with_background_work";
|
|
27
30
|
export interface ProviderProcessRunResult {
|
|
28
31
|
readonly exitCode: number;
|
|
29
32
|
readonly stdout: string;
|
|
@@ -34,8 +37,10 @@ export interface ProviderProcessRunResult {
|
|
|
34
37
|
readonly memoryObservedAt?: string;
|
|
35
38
|
/** Present when the caller's cancellation stopped the process before it exited on its own. */
|
|
36
39
|
readonly cancelled?: true;
|
|
37
|
-
/** Present when Forge stopped a provider that stayed resident after
|
|
40
|
+
/** Present when Forge stopped a provider that stayed resident after its turn ended. */
|
|
38
41
|
readonly terminalStopReason?: ProviderTerminalStopReason;
|
|
42
|
+
/** Present when Forge closed output pipes a descendant still held after the provider exited. */
|
|
43
|
+
readonly outputPipesReleasedAfterExit?: true;
|
|
39
44
|
}
|
|
40
45
|
export interface ProviderProcessRunner {
|
|
41
46
|
run(request: ProviderProcessRunRequest, handlers?: ProviderProcessHandlers, signal?: AbortSignal): Promise<ProviderProcessRunResult>;
|
|
@@ -59,7 +64,8 @@ export interface ProviderProcessHandlers {
|
|
|
59
64
|
onGenerationStart?(): void;
|
|
60
65
|
}
|
|
61
66
|
/** Recovery must wrap the attempt coordinator, never its raw OS runner. Each
|
|
62
|
-
* relaunch needs a new fenced child generation and exclusive launch files.
|
|
67
|
+
* relaunch needs a new fenced child generation and exclusive launch files. The outer
|
|
68
|
+
* layer fails any run Forge stopped because its turn ended with background work live. */
|
|
63
69
|
export declare function recoveringProviderProcessRunner(inner: ProviderProcessRunner): ProviderProcessRunner;
|
|
64
70
|
/**
|
|
65
71
|
* Codex Desktop and an independently installed Codex CLI can briefly disagree
|
|
@@ -88,48 +94,21 @@ export declare class CodexResumeRecoveringProcessRunner implements ProviderProce
|
|
|
88
94
|
* arbitrary tool/command output and therefore cannot mint retry authority.
|
|
89
95
|
*/
|
|
90
96
|
export declare function isTransientCodexProviderNotFoundFailure(command: string, result: ProviderProcessRunResult): boolean;
|
|
91
|
-
interface ProviderChildEnvironmentOptions {
|
|
92
|
-
readonly parentEnv?: NodeJS.ProcessEnv;
|
|
93
|
-
readonly platform?: NodeJS.Platform;
|
|
94
|
-
readonly homeDir?: string;
|
|
95
|
-
}
|
|
96
|
-
export declare function buildProviderChildEnvironment(requestEnv?: Readonly<Record<string, string>>, options?: ProviderChildEnvironmentOptions): NodeJS.ProcessEnv;
|
|
97
97
|
export declare class StreamingProviderProcessRunner implements ProviderProcessRunner {
|
|
98
98
|
private readonly terminalExitGraceMs;
|
|
99
99
|
private readonly terminalSuccessCeilingMs;
|
|
100
100
|
private readonly terminalWorkPollMs;
|
|
101
|
-
|
|
101
|
+
private readonly outputPipeReleaseGraceMs;
|
|
102
|
+
constructor(terminalExitGraceMs?: number, terminalSuccessCeilingMs?: number, terminalWorkPollMs?: number, outputPipeReleaseGraceMs?: number);
|
|
102
103
|
run(request: ProviderProcessRunRequest, handlers?: ProviderProcessHandlers, signal?: AbortSignal): Promise<ProviderProcessRunResult>;
|
|
103
104
|
}
|
|
104
105
|
/**
|
|
105
106
|
* The typed failure for a provider run that ended without calling its required Forge
|
|
106
|
-
* completion tool. A run Forge stopped at the success ceiling
|
|
107
|
-
* is not mistaken for an agent that simply ended its turn.
|
|
107
|
+
* completion tool. A run Forge stopped at the success ceiling or for background work is
|
|
108
|
+
* reported as such, so it is not mistaken for an agent that simply ended its turn.
|
|
108
109
|
*/
|
|
109
110
|
export declare function providerCompletionToolMissingFailure(message: string, result?: Pick<ProviderProcessRunResult, "terminalStopReason"> | null): ForgeFailureError;
|
|
110
111
|
/** Returns aggregate resident bytes for the exact supervised Unix process group. */
|
|
111
112
|
export declare function processGroupResidentMemoryBytes(processGroupId: number, platform?: NodeJS.Platform, procRoot?: string): number | null;
|
|
112
113
|
export declare const UNIX_PROVIDER_START_GRANT_LINE = "forge-provider-start-granted\n";
|
|
113
114
|
export declare function buildUnixProviderStartGateLaunch(command: string, args: readonly string[]): LaunchCommand;
|
|
114
|
-
export declare function resolveCodexNpmDirectLaunch(commandPath: string, args: readonly string[]): LaunchCommand | null;
|
|
115
|
-
/**
|
|
116
|
-
* npm installs of Claude Code (`npm i -g @anthropic-ai/claude-code`) put a `claude.cmd` shim on
|
|
117
|
-
* PATH; launch its cli.js directly for the same Job Object reasons as Codex. The native installer
|
|
118
|
-
* ships `claude.exe`, which is preferred by PATH resolution and needs no rewrite.
|
|
119
|
-
*/
|
|
120
|
-
export declare function resolveClaudeNpmDirectLaunch(commandPath: string, args: readonly string[]): LaunchCommand | null;
|
|
121
|
-
/**
|
|
122
|
-
* Avoids cmd.exe's nested-quote handling for package-manager shims. That
|
|
123
|
-
* quoting loses executable paths containing spaces after the command is
|
|
124
|
-
* wrapped by the Windows Job Object supervisor.
|
|
125
|
-
*/
|
|
126
|
-
export declare function resolvePackageManagerDirectLaunch(commandPath: string, args: readonly string[]): LaunchCommand | null;
|
|
127
|
-
/**
|
|
128
|
-
* Resolves Windows commands without spawning where.exe. Runtime launches can
|
|
129
|
-
* happen while the machine is under enough process pressure for where.exe to
|
|
130
|
-
* miss its timeout; returning the unresolved package-manager name in that case
|
|
131
|
-
* makes Node fall back to a shell shim that cannot survive Job Object wrapping.
|
|
132
|
-
*/
|
|
133
|
-
export declare function resolveWindowsCommandFromPath(command: string, pathValue?: string, pathExtValue?: string): string | null;
|
|
134
|
-
export declare function chooseWindowsCommandCandidate(candidates: readonly string[]): string | null;
|
|
135
|
-
export {};
|