@loucompanion/forge-bridge 0.1.4-dev.25308ca4a63d → 0.1.4-dev.297b5afcac9e
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 +55 -0
- package/dist/bridge/bridge-chat-provider-command.d.ts +16 -0
- package/dist/bridge/bridge-chat-provider-command.js +137 -0
- package/dist/bridge/bridge-chat.types.d.ts +10 -0
- package/dist/bridge/bridge-chat.types.js +16 -1
- package/dist/bridge/bridge.base.d.ts +2 -0
- package/dist/bridge/bridge.service.d.ts +53 -1
- package/dist/bridge/bridge.service.js +234 -113
- package/dist/bridge/bridge.types.d.ts +11 -0
- package/dist/bridge/local-yield-flag.d.ts +6 -0
- package/dist/bridge/local-yield-flag.js +34 -0
- package/dist/bridge/runner-host-capabilities.d.ts +3 -0
- package/dist/bridge/runner-host-capabilities.js +13 -0
- package/dist/cli/cli.help.js +18 -0
- package/dist/cli/cli.service.d.ts +16 -0
- package/dist/cli/cli.service.js +122 -13
- package/dist/cli/local-config.d.ts +4 -0
- package/dist/cli/local-config.js +26 -4
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +5 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +44 -0
- package/dist/runtime/attempt-database-broker.d.ts +1 -1
- package/dist/runtime/docker-engine-probe.d.ts +5 -0
- package/dist/runtime/docker-engine-probe.js +7 -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-load-admission.d.ts +18 -3
- package/dist/runtime/host-load-admission.js +19 -4
- package/dist/runtime/host-load-child-environment.d.ts +11 -6
- package/dist/runtime/host-load-child-environment.js +22 -11
- package/dist/runtime/host-load-governor-config.d.ts +19 -1
- package/dist/runtime/host-load-governor-config.js +37 -0
- package/dist/runtime/host-load-governor.d.ts +12 -0
- package/dist/runtime/host-load-governor.js +139 -26
- package/dist/runtime/host-load-runtime-settings.d.ts +25 -0
- package/dist/runtime/host-load-runtime-settings.js +78 -0
- package/dist/runtime/host-load-sampler.d.ts +34 -4
- package/dist/runtime/host-load-sampler.js +73 -7
- package/dist/runtime/host-load-step-class.d.ts +3 -1
- package/dist/runtime/host-load-step-class.js +60 -5
- package/dist/runtime/host-load-test-slot.d.ts +43 -0
- package/dist/runtime/host-load-test-slot.js +81 -0
- package/dist/runtime/host-load-token-ledger.d.ts +26 -0
- package/dist/runtime/host-load-token-ledger.js +93 -61
- 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-runtime-contract.d.ts +12 -0
- package/dist/runtime/host-runtime-contract.js +29 -1
- package/dist/runtime/host-runtime-lease.d.ts +29 -3
- package/dist/runtime/host-runtime-lease.js +83 -63
- package/dist/runtime/host-runtime-promotion.d.ts +23 -0
- package/dist/runtime/host-runtime-promotion.js +36 -0
- package/dist/runtime/native-test-postgres-fallback.d.ts +51 -7
- package/dist/runtime/native-test-postgres-fallback.js +60 -8
- package/dist/runtime/runner-settings.d.ts +100 -0
- package/dist/runtime/runner-settings.js +214 -0
- package/dist/sandbox/host-capacity-broker.d.ts +7 -1
- package/dist/sandbox/host-capacity-broker.js +23 -4
- 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 +0 -7
- package/dist/session/managed-attempt-tools.js +51 -62
- package/dist/session/managed-command-host-load.d.ts +2 -0
- package/dist/session/managed-command-host-load.js +2 -1
- package/dist/session/phase-completion.artifacts.js +2 -1
- package/dist/session/phase-completion.d.ts +8 -0
- package/dist/session/phase-completion.js +1 -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.runtime.d.ts +0 -8
- package/dist/session/phase-completion.runtime.js +38 -168
- package/dist/session/phase-completion.schemas.js +25 -23
- package/dist/session/phase-completion.validation.js +3 -1
- 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-step-execution.d.ts +2 -1
- package/dist/session/pre-publication-step-execution.js +6 -5
- package/dist/session/pre-publication-validation.d.ts +30 -14
- package/dist/session/pre-publication-validation.js +207 -134
- package/dist/session/provider-cli/claude-background-work.d.ts +66 -0
- package/dist/session/provider-cli/claude-background-work.js +180 -0
- package/dist/session/provider-cli/pre-publication-repair.d.ts +56 -0
- package/dist/session/provider-cli/pre-publication-repair.js +276 -0
- package/dist/session/provider-cli/provider-cli.child-environment.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.child-environment.js +73 -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.process.d.ts +15 -36
- package/dist/session/provider-cli/provider-cli.process.js +39 -430
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +5 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +58 -8
- package/dist/session/provider-cli/provider-cli.runtime.js +7 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +5 -5
- package/dist/session/provider-cli/provider-cli.service.js +65 -257
- 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/qa-sidecar-validation.d.ts +6 -0
- package/dist/session/qa-sidecar-validation.js +28 -0
- package/dist/session/sandbox-host-capacity-gate.js +12 -3
- package/dist/session/session-redaction.js +31 -181
- package/dist/session/session.base.d.ts +6 -1
- package/dist/session/session.service.d.ts +4 -1
- package/dist/session/session.service.js +6 -0
- package/dist/session/session.types.js +3 -3
- package/dist/session/sidecar-json-shape.d.ts +31 -0
- package/dist/session/sidecar-json-shape.js +217 -0
- 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 +5 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -8,13 +8,16 @@ import { defaultForgeBridgeConfig } from "../config.js";
|
|
|
8
8
|
import { bridgeChatCapabilityFor, supportsDraftImageAttachmentsFor } from "../shared/provider-capabilities.js";
|
|
9
9
|
import { redactText } from "../shared/redaction/redaction.js";
|
|
10
10
|
import { BridgeSessionService } from "../session/session.service.js";
|
|
11
|
-
import { ProcessBackedProviderCliService, RoutingProviderCliService, StreamingProviderProcessRunner, } from "../session/provider-cli/provider-cli.service.js";
|
|
12
|
-
import {
|
|
11
|
+
import { formatProviderCliCommandForCheckpoint, ProcessBackedProviderCliService, RoutingProviderCliService, StreamingProviderProcessRunner, } from "../session/provider-cli/provider-cli.service.js";
|
|
12
|
+
import { assertChatTurnFinished, buildChatProviderCommand, chatTurnMetadataFileName } from "./bridge-chat-provider-command.js";
|
|
13
13
|
import { clip, createProviderOutputState } from "../session/provider-cli/provider-output-state.js";
|
|
14
14
|
import { redactRunnerDispatchEvent, redactRunOnceResultPacket } from "../session/session-redaction.js";
|
|
15
15
|
import { PrePublicationValidator } from "../session/pre-publication-validation.js";
|
|
16
16
|
import { FileForgeCgroupRegistry } from "../runtime/host-load-forge-cgroups.js";
|
|
17
|
-
import { HostRuntimeLeaseManager, } from "../runtime/host-runtime-lease.js";
|
|
17
|
+
import { hostCapacityLimitDefaults, HostRuntimeLeaseManager, } from "../runtime/host-runtime-lease.js";
|
|
18
|
+
import { computeEffectiveRunnerSettings, parseRunnerSettingsDocument, runnerSettingsInForce, sameRunnerSettingsReport, } from "../runtime/runner-settings.js";
|
|
19
|
+
import { resetHostLoadRuntimeSettings, writeHostLoadRuntimeSettings } from "../runtime/host-load-runtime-settings.js";
|
|
20
|
+
import { readLocalYieldFlag } from "./local-yield-flag.js";
|
|
18
21
|
import { assertHostDatabaseCapabilityBoundary, establishHostDatabaseCapabilityBoundary, } from "../runtime/host-database-capability-boundary.js";
|
|
19
22
|
import { defaultHostExecutionRoot } from "../runtime/host-execution-root.js";
|
|
20
23
|
import { buildMemoryAdmissionDiagnostics } from "../runtime/memory-capacity.js";
|
|
@@ -88,6 +91,19 @@ export class ForgeBridgeService {
|
|
|
88
91
|
enforceHostDatabaseCapabilityBoundary;
|
|
89
92
|
hostCapabilities = emptyRunnerHostCapabilitySnapshot();
|
|
90
93
|
dockerAvailable = false;
|
|
94
|
+
// Decision 0014 settings push. The last applied server document (null until one
|
|
95
|
+
// arrives: an old server never sends one), the local `forge-bridge yield` flag,
|
|
96
|
+
// and the effective settings computed from both and the host's env bounds.
|
|
97
|
+
appliedSettingsDocument = null;
|
|
98
|
+
localYield = false;
|
|
99
|
+
effectiveSettings;
|
|
100
|
+
settingsReport;
|
|
101
|
+
/** Applies run one at a time; offers wait for every apply queued before them. */
|
|
102
|
+
settingsTail = Promise.resolve();
|
|
103
|
+
// Server documents that turn yield on and are queued but not applied yet. The
|
|
104
|
+
// reservation commit is synchronous and can't wait for the apply, so it counts these.
|
|
105
|
+
pendingYieldOn = 0;
|
|
106
|
+
settingsStarted = null;
|
|
91
107
|
hostRequirementFacts() {
|
|
92
108
|
const facts = this.hostLoad.facts();
|
|
93
109
|
return {
|
|
@@ -153,6 +169,9 @@ export class ForgeBridgeService {
|
|
|
153
169
|
?? (dispatch => resolveSandboxResourcesFromRepo(dispatch, this.config.sandboxRuntimeOverheadBytes));
|
|
154
170
|
this.readinessResultOutbox = readinessResultOutbox ?? new FileReadinessResultOutbox(config.sandboxStateRoot);
|
|
155
171
|
this.dispatchResultOutbox = dispatchResultOutbox ?? new FileDispatchResultOutbox(config.sandboxStateRoot);
|
|
172
|
+
// With no server document and no local flag these equal today's env/default behaviour.
|
|
173
|
+
this.effectiveSettings = computeEffectiveRunnerSettings(null, process.env, this.runnerHostDefaults(), false);
|
|
174
|
+
this.settingsReport = this.effectiveSettings.report;
|
|
156
175
|
}
|
|
157
176
|
async connectOnce() {
|
|
158
177
|
if (this.revokedReason !== null) {
|
|
@@ -187,6 +206,7 @@ export class ForgeBridgeService {
|
|
|
187
206
|
// keeps refreshing its cached snapshot for later heartbeats.
|
|
188
207
|
await this.hostLoad.start().catch(() => undefined);
|
|
189
208
|
this.sessions.setHostRequirementsCheck?.(requires => unmetHostRuntimeRequirements(requires, this.hostRequirementFacts()));
|
|
209
|
+
await this.startSettings();
|
|
190
210
|
const connection = this.connections.create(this.config);
|
|
191
211
|
this.connection = connection;
|
|
192
212
|
this.transportRecovery = null;
|
|
@@ -237,6 +257,7 @@ export class ForgeBridgeService {
|
|
|
237
257
|
connection.onReap?.((request) => this.handleReap(request));
|
|
238
258
|
connection.onReadinessProbe?.((request) => this.handleReadinessProbe(request));
|
|
239
259
|
connection.onRevoked?.((notice) => this.handleRevoked(notice));
|
|
260
|
+
connection.onApplySettings?.((document) => this.handleApplySettings(document));
|
|
240
261
|
await connection.start();
|
|
241
262
|
await this.registerConnection(connection);
|
|
242
263
|
await this.flushDispatchResults(true).catch(error => {
|
|
@@ -358,6 +379,169 @@ export class ForgeBridgeService {
|
|
|
358
379
|
this.abortActiveReadinessProbes("runner removed from Forge");
|
|
359
380
|
void this.stopConnection().catch(() => undefined);
|
|
360
381
|
}
|
|
382
|
+
/** The effective settings and how they were derived, as last reported (decision 0014). */
|
|
383
|
+
get runnerSettings() {
|
|
384
|
+
return this.settingsReport;
|
|
385
|
+
}
|
|
386
|
+
runnerHostDefaults() {
|
|
387
|
+
return this.sessions.runnerLimitDefaults?.() ?? hostCapacityLimitDefaults();
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Once per bridge process: drop governor overrides an earlier process left on
|
|
391
|
+
* the state root, then put today's effective settings (env bounds and the local
|
|
392
|
+
* yield flag, no server document yet) in force.
|
|
393
|
+
*/
|
|
394
|
+
async startSettings() {
|
|
395
|
+
this.settingsStarted ??= (async () => {
|
|
396
|
+
await resetHostLoadRuntimeSettings(this.config.sandboxStateRoot).catch(error => {
|
|
397
|
+
logBridgeStatus(`Could not reset the host load settings file: ${errorMessage(error)}.`);
|
|
398
|
+
});
|
|
399
|
+
this.localYield = await this.readLocalYield();
|
|
400
|
+
await this.enqueueSettings({ kind: "local" });
|
|
401
|
+
})();
|
|
402
|
+
await this.settingsStarted;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Decision 0014 `ApplySettings`. Applies only a document newer than the one
|
|
406
|
+
* applied, one at a time, then acknowledges it with `SettingsApplied`. A replay of
|
|
407
|
+
* the applied version is acknowledged again without applying it; an older one is
|
|
408
|
+
* ignored.
|
|
409
|
+
*/
|
|
410
|
+
async handleApplySettings(raw) {
|
|
411
|
+
const document = parseRunnerSettingsDocument(raw);
|
|
412
|
+
if (!document) {
|
|
413
|
+
logBridgeStatus("Ignored an ApplySettings message without a valid settings version.");
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (document.runnerId && document.runnerId !== this.config.runnerId) {
|
|
417
|
+
logBridgeStatus(`Ignored settings v${document.version} addressed to runner ${document.runnerId}.`);
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
await this.enqueueSettings({ kind: "server", document });
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Polls the local `forge-bridge yield` flag (every heartbeat and before each
|
|
424
|
+
* offer decision). A change is applied at once and reported again under the
|
|
425
|
+
* same settings version.
|
|
426
|
+
*/
|
|
427
|
+
/** Yielding now, or about to: a received yield-on that is still being applied counts. */
|
|
428
|
+
yieldingOrQueued() {
|
|
429
|
+
return this.effectiveSettings.yielding || this.localYield || this.pendingYieldOn > 0;
|
|
430
|
+
}
|
|
431
|
+
async refreshLocalYield() {
|
|
432
|
+
if (!this.config.localYieldFlagPath)
|
|
433
|
+
return;
|
|
434
|
+
const localYield = await this.readLocalYield();
|
|
435
|
+
if (localYield === this.localYield)
|
|
436
|
+
return;
|
|
437
|
+
this.localYield = localYield;
|
|
438
|
+
logBridgeStatus(`Local yield to foreground turned ${localYield ? "on" : "off"} (forge-bridge yield).`);
|
|
439
|
+
await this.enqueueSettings({ kind: "local" });
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* A setting the host couldn't put in force holds placement on the server, so
|
|
443
|
+
* every heartbeat tries the applied document again until it takes.
|
|
444
|
+
*/
|
|
445
|
+
async retryFailedSettings() {
|
|
446
|
+
if (!this.settingsReport.rejected.some(entry => entry.kind === "apply_failed"))
|
|
447
|
+
return;
|
|
448
|
+
await this.enqueueSettings({ kind: "local" });
|
|
449
|
+
}
|
|
450
|
+
async readLocalYield() {
|
|
451
|
+
const flagPath = this.config.localYieldFlagPath;
|
|
452
|
+
return flagPath ? await readLocalYieldFlag(flagPath) : false;
|
|
453
|
+
}
|
|
454
|
+
enqueueSettings(change) {
|
|
455
|
+
const turnsYieldOn = change.kind === "server" && change.document.yieldToForeground;
|
|
456
|
+
if (turnsYieldOn)
|
|
457
|
+
this.pendingYieldOn += 1;
|
|
458
|
+
const applied = this.settingsTail
|
|
459
|
+
.then(() => this.applySettings(change))
|
|
460
|
+
.finally(() => {
|
|
461
|
+
if (turnsYieldOn)
|
|
462
|
+
this.pendingYieldOn -= 1;
|
|
463
|
+
});
|
|
464
|
+
// A failed apply must not wedge later applies or the offers waiting on them.
|
|
465
|
+
this.settingsTail = applied.catch(error => {
|
|
466
|
+
logBridgeStatus(`Applying runner settings failed: ${errorMessage(error)}.`);
|
|
467
|
+
});
|
|
468
|
+
return this.settingsTail;
|
|
469
|
+
}
|
|
470
|
+
async applySettings(change) {
|
|
471
|
+
const applied = this.appliedSettingsDocument;
|
|
472
|
+
if (change.kind === "server" && applied !== null && change.document.version <= applied.version) {
|
|
473
|
+
if (change.document.version === applied.version) {
|
|
474
|
+
// The server sends the current version again at each Hello. After a reconnect it may never
|
|
475
|
+
// have seen this version's ack (the old connection dropped first), and its offer gate waits
|
|
476
|
+
// for one from this connection, so acknowledge what is in force again rather than nothing.
|
|
477
|
+
void this.sendSettingsApplied(this.settingsReport);
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
logBridgeStatus(`Ignored runner settings v${change.document.version}; v${applied.version} is already applied.`);
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
const document = change.kind === "server" ? change.document : applied;
|
|
484
|
+
const effective = computeEffectiveRunnerSettings(document, process.env, this.runnerHostDefaults(), this.localYield);
|
|
485
|
+
const failures = await this.putSettingsInForce(effective);
|
|
486
|
+
// Report what is in force: a key the host couldn't take keeps its previous value.
|
|
487
|
+
const report = {
|
|
488
|
+
...runnerSettingsInForce(effective.report, this.settingsReport, failures),
|
|
489
|
+
version: document?.version ?? null,
|
|
490
|
+
};
|
|
491
|
+
const changed = !sameRunnerSettingsReport(report, this.settingsReport);
|
|
492
|
+
this.appliedSettingsDocument = document;
|
|
493
|
+
this.effectiveSettings = effective;
|
|
494
|
+
this.settingsReport = report;
|
|
495
|
+
if (change.kind === "server") {
|
|
496
|
+
logBridgeStatus(`Applied runner settings v${change.document.version}: ${describeRunnerSettings(report)}.`);
|
|
497
|
+
}
|
|
498
|
+
// Only a server that has sent ApplySettings knows SettingsApplied; an old one learns nothing new.
|
|
499
|
+
if (this.appliedSettingsDocument !== null && (change.kind === "server" || changed)) {
|
|
500
|
+
void this.sendSettingsApplied(report);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Max attempts and the memory reserve go to host attempt admission; the governor
|
|
505
|
+
* budget (the yield budget while yielding) and the heavy-step limit go to the
|
|
506
|
+
* shared settings file every governor on the state root reads at admission.
|
|
507
|
+
* Neither touches admitted work. Returns the keys the host could not put in
|
|
508
|
+
* force (`apply_failed`); their previous values stay in force.
|
|
509
|
+
*/
|
|
510
|
+
async putSettingsInForce(effective) {
|
|
511
|
+
const { values } = effective.report;
|
|
512
|
+
const rejected = [];
|
|
513
|
+
try {
|
|
514
|
+
await this.sessions.applyRunnerLimits?.({
|
|
515
|
+
maxConcurrentAttempts: values.maxConcurrentAttempts,
|
|
516
|
+
memoryReserveBytes: values.memoryReserveBytes,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
catch (error) {
|
|
520
|
+
const reason = `host attempt admission did not take the limit: ${errorMessage(error)}`;
|
|
521
|
+
rejected.push({ key: "maxConcurrentAttempts", reason, kind: "apply_failed" }, { key: "memoryReserveBytes", reason, kind: "apply_failed" });
|
|
522
|
+
}
|
|
523
|
+
try {
|
|
524
|
+
await writeHostLoadRuntimeSettings(this.config.sandboxStateRoot, {
|
|
525
|
+
cpuBudgetFraction: effective.governorCpuBudgetFraction,
|
|
526
|
+
maxHeavySteps: values.maxHeavySteps,
|
|
527
|
+
yielding: effective.yielding,
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
catch (error) {
|
|
531
|
+
const reason = `the host load governor settings could not be written: ${errorMessage(error)}`;
|
|
532
|
+
rejected.push({ key: "cpuBudgetPercent", reason, kind: "apply_failed" }, { key: "yieldCpuBudgetPercent", reason, kind: "apply_failed" }, { key: "maxHeavySteps", reason, kind: "apply_failed" });
|
|
533
|
+
}
|
|
534
|
+
return rejected;
|
|
535
|
+
}
|
|
536
|
+
/** A failed acknowledgement is not retried here: the next heartbeat carries the same report. */
|
|
537
|
+
async sendSettingsApplied(report) {
|
|
538
|
+
try {
|
|
539
|
+
await this.invokeAck("SettingsApplied", report);
|
|
540
|
+
}
|
|
541
|
+
catch (error) {
|
|
542
|
+
logBridgeStatus(`SettingsApplied for v${report.version ?? "none"} was not acknowledged: ${errorMessage(error)}. The next heartbeat reports it.`);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
361
545
|
async stop() {
|
|
362
546
|
this.stopped = true;
|
|
363
547
|
this.abortActiveSessions("bridge stopping");
|
|
@@ -497,6 +681,7 @@ export class ForgeBridgeService {
|
|
|
497
681
|
env: {
|
|
498
682
|
FORGE_BRIDGE_CHAT_RUN_ID: packet.chatRunId,
|
|
499
683
|
FORGE_BRIDGE_CHAT_TURN_ID: packet.turnId,
|
|
684
|
+
...plan.env,
|
|
500
685
|
},
|
|
501
686
|
stdin: plan.stdin,
|
|
502
687
|
}, {
|
|
@@ -523,6 +708,7 @@ export class ForgeBridgeService {
|
|
|
523
708
|
content: "Bridge Chat provider process exited.",
|
|
524
709
|
}).catch(() => undefined);
|
|
525
710
|
}
|
|
711
|
+
assertChatTurnFinished(result);
|
|
526
712
|
return { command: plan.command, output, result };
|
|
527
713
|
}
|
|
528
714
|
async sendChatProviderEvent(packet, active, event, providerThreadId) {
|
|
@@ -891,6 +1077,16 @@ export class ForgeBridgeService {
|
|
|
891
1077
|
await this.sendOfferDecision(dispatch, false, "lease_expired", "Offer lease is already expired.");
|
|
892
1078
|
return;
|
|
893
1079
|
}
|
|
1080
|
+
// Decision 0014: decide under the settings Forge sent (an offer never races an
|
|
1081
|
+
// apply), and refuse new work while yielding to the foreground. The local flag
|
|
1082
|
+
// is read here too, before Forge has heard about it.
|
|
1083
|
+
await this.refreshLocalYield().catch(() => undefined);
|
|
1084
|
+
// Every apply queued so far, including one a concurrent offer or heartbeat started.
|
|
1085
|
+
await this.settingsTail;
|
|
1086
|
+
if (this.effectiveSettings.yielding) {
|
|
1087
|
+
await this.sendOfferDecision(dispatch, false, "runner_yielding", runnerYieldingMessage(this.settingsReport));
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
894
1090
|
const preflight = sandbox.executionMode === "docker" && this.config.dockerEnabled
|
|
895
1091
|
? await this.preflight.run()
|
|
896
1092
|
: this.preflight.current();
|
|
@@ -975,6 +1171,11 @@ export class ForgeBridgeService {
|
|
|
975
1171
|
if (Date.parse(dispatch.lease.expiresAt) <= now) {
|
|
976
1172
|
return rejectedOfferReservation("lease_expired", "Offer lease is already expired.");
|
|
977
1173
|
}
|
|
1174
|
+
// Yield may have turned on while the offer was being profiled, including a
|
|
1175
|
+
// yield Forge sent or the local flag set that hasn't finished applying yet.
|
|
1176
|
+
if (this.yieldingOrQueued()) {
|
|
1177
|
+
return rejectedOfferReservation("runner_yielding", runnerYieldingMessage(this.settingsReport));
|
|
1178
|
+
}
|
|
978
1179
|
if (sandbox.executionMode === "docker") {
|
|
979
1180
|
// A concurrent heartbeat/preflight refresh may have produced a newer
|
|
980
1181
|
// conservative dual-domain sample while this offer was being profiled.
|
|
@@ -1586,6 +1787,9 @@ export class ForgeBridgeService {
|
|
|
1586
1787
|
// force reconnects. Transport failures still do.
|
|
1587
1788
|
await this.flushDispatchResults().catch(deferRejectedReplay("Dispatch"));
|
|
1588
1789
|
await this.flushReadinessResults().catch(deferRejectedReplay("Readiness"));
|
|
1790
|
+
// The heartbeat carries the effective settings, so pick up `forge-bridge yield` first.
|
|
1791
|
+
await this.refreshLocalYield().catch(() => undefined);
|
|
1792
|
+
await this.retryFailedSettings().catch(() => undefined);
|
|
1589
1793
|
await this.sendHeartbeat();
|
|
1590
1794
|
this.consecutiveHeartbeatFailures = 0;
|
|
1591
1795
|
}
|
|
@@ -1745,7 +1949,7 @@ export class ForgeBridgeService {
|
|
|
1745
1949
|
pendingCommitmentMemoryBytes: Math.max(0, used.memoryBytes - activeResources.memoryBytes),
|
|
1746
1950
|
}) : null;
|
|
1747
1951
|
return {
|
|
1748
|
-
schemaVersion:
|
|
1952
|
+
schemaVersion: 8,
|
|
1749
1953
|
activeSessionCount: this.activeSessions.size,
|
|
1750
1954
|
cliProviders: this.config.cliProviders,
|
|
1751
1955
|
providerStatuses: this.config.providerStatuses,
|
|
@@ -1810,7 +2014,8 @@ export class ForgeBridgeService {
|
|
|
1810
2014
|
supportsDraftRunOnce: this.config.supportsDraftRunOnce,
|
|
1811
2015
|
supportsDraftAttachments: this.config.supportsDraftAttachments,
|
|
1812
2016
|
supportsDraftImageAttachments: this.config.supportsDraftImageAttachments,
|
|
1813
|
-
bridgeChat: bridgeChatCapabilityFor(this.config.cliProviders, this.config.providerStatuses, this.config.bridgeChat)
|
|
2017
|
+
bridgeChat: bridgeChatCapabilityFor(this.config.cliProviders, this.config.providerStatuses, this.config.bridgeChat),
|
|
2018
|
+
settings: { supportsServerSettings: true, ...this.settingsReport },
|
|
1814
2019
|
};
|
|
1815
2020
|
}
|
|
1816
2021
|
async requiredCapabilityFailure(dispatch) {
|
|
@@ -1964,6 +2169,25 @@ export class ForgeBridgeService {
|
|
|
1964
2169
|
}
|
|
1965
2170
|
}
|
|
1966
2171
|
}
|
|
2172
|
+
function runnerYieldingMessage(report) {
|
|
2173
|
+
const where = report.sources.yieldToForeground === "host_local" ? "on this host (forge-bridge yield on)" : "in Forge";
|
|
2174
|
+
return `runner_yielding: this runner is yielding to foreground work (turned on ${where}); it takes no new attempts until yield is off. Running attempts continue.`;
|
|
2175
|
+
}
|
|
2176
|
+
function describeRunnerSettings(report) {
|
|
2177
|
+
const { values } = report;
|
|
2178
|
+
const parts = [
|
|
2179
|
+
`max attempts ${values.maxConcurrentAttempts}`,
|
|
2180
|
+
`CPU budget ${values.cpuBudgetPercent}%`,
|
|
2181
|
+
`yield budget ${values.yieldCpuBudgetPercent}%`,
|
|
2182
|
+
`memory reserve ${formatBytes(values.memoryReserveBytes)}`,
|
|
2183
|
+
`heavy steps ${values.maxHeavySteps ?? "budget only"}`,
|
|
2184
|
+
`yield ${values.yieldToForeground ? "on" : "off"}`,
|
|
2185
|
+
];
|
|
2186
|
+
const capped = report.bounds
|
|
2187
|
+
.filter(bound => report.sources[bound.key] === "host_env")
|
|
2188
|
+
.map(bound => `${bound.envVar}=${bound.value}`);
|
|
2189
|
+
return `${parts.join(", ")}${capped.length > 0 ? `; host bounds in force: ${[...new Set(capped)].join(", ")}` : ""}`;
|
|
2190
|
+
}
|
|
1967
2191
|
/** The `run` command's exit code after Forge removed the runner. */
|
|
1968
2192
|
export const bridgeRevokedExitCode = 3;
|
|
1969
2193
|
export const bridgeRevokedMessage = "This bridge was removed from Forge. Pair it again with forge-bridge pair.";
|
|
@@ -2044,6 +2268,11 @@ export class SignalRBridgeConnection {
|
|
|
2044
2268
|
void this.connection.stop().catch(() => undefined);
|
|
2045
2269
|
});
|
|
2046
2270
|
}
|
|
2271
|
+
onApplySettings(handler) {
|
|
2272
|
+
this.connection.on("ApplySettings", (raw) => {
|
|
2273
|
+
void Promise.resolve(handler(raw)).catch(() => undefined);
|
|
2274
|
+
});
|
|
2275
|
+
}
|
|
2047
2276
|
onRevoked(handler) {
|
|
2048
2277
|
this.connection.on("Revoked", (raw) => {
|
|
2049
2278
|
const notice = raw && typeof raw === "object" ? raw : {};
|
|
@@ -2463,7 +2692,6 @@ const defaultChatTurnLeaseMs = 60 * 60 * 1000;
|
|
|
2463
2692
|
const maxChatEventContentChars = 4000;
|
|
2464
2693
|
const maxChatTerminalTextChars = 120_000;
|
|
2465
2694
|
const maxChatExactSecretChars = 8 * 1024;
|
|
2466
|
-
const chatTurnMetadataFileName = "forge-chat-metadata.json";
|
|
2467
2695
|
async function materializeChatTurnMetadata(packet, workspacePath) {
|
|
2468
2696
|
if (packet.attachmentHandoffs.length === 0 && packet.actionBrokerGrants.length === 0) {
|
|
2469
2697
|
return;
|
|
@@ -2523,113 +2751,6 @@ async function cleanupChatTurnWorkspace(workspacePath, redactionSecrets) {
|
|
|
2523
2751
|
};
|
|
2524
2752
|
}
|
|
2525
2753
|
}
|
|
2526
|
-
function buildChatProviderCommand(packet, cwd) {
|
|
2527
|
-
const provider = packet.providerKind.trim().toLowerCase();
|
|
2528
|
-
const model = packet.model.trim();
|
|
2529
|
-
const prompt = buildChatPrompt(packet);
|
|
2530
|
-
const resumeThreadId = packet.providerThreadId?.trim() || null;
|
|
2531
|
-
if (provider === "codex") {
|
|
2532
|
-
const args = ["-s", codexSandboxModeForPlatform(process.platform, "host"), "-a", "never", "exec"];
|
|
2533
|
-
if (resumeThreadId) {
|
|
2534
|
-
args.push("--cd", cwd, "resume");
|
|
2535
|
-
}
|
|
2536
|
-
args.push("--model", model, "--json");
|
|
2537
|
-
if (!resumeThreadId) {
|
|
2538
|
-
args.push("--cd", cwd);
|
|
2539
|
-
}
|
|
2540
|
-
args.push("--skip-git-repo-check");
|
|
2541
|
-
if (resumeThreadId) {
|
|
2542
|
-
args.push(resumeThreadId);
|
|
2543
|
-
}
|
|
2544
|
-
args.push("-");
|
|
2545
|
-
return { command: { command: "codex", args }, stdin: prompt };
|
|
2546
|
-
}
|
|
2547
|
-
if (provider === "cursor") {
|
|
2548
|
-
const args = ["--print", "--output-format", "stream-json", "--model", model, "--workspace", cwd];
|
|
2549
|
-
if (resumeThreadId) {
|
|
2550
|
-
args.push("--resume", resumeThreadId);
|
|
2551
|
-
}
|
|
2552
|
-
args.push("--yolo", "--approve-mcps", "--trust", prompt);
|
|
2553
|
-
return { command: { command: "cursor-agent", args } };
|
|
2554
|
-
}
|
|
2555
|
-
if (provider === "claude") {
|
|
2556
|
-
const args = ["-p", "--output-format", "stream-json", "--verbose", "--model", model, "--permission-mode", "bypassPermissions"];
|
|
2557
|
-
if (resumeThreadId) {
|
|
2558
|
-
args.push("--resume", resumeThreadId);
|
|
2559
|
-
}
|
|
2560
|
-
return { command: { command: "claude", args }, stdin: prompt };
|
|
2561
|
-
}
|
|
2562
|
-
return {
|
|
2563
|
-
command: {
|
|
2564
|
-
command: provider,
|
|
2565
|
-
args: ["--model", model, prompt],
|
|
2566
|
-
},
|
|
2567
|
-
};
|
|
2568
|
-
}
|
|
2569
|
-
function buildChatPrompt(packet) {
|
|
2570
|
-
const messages = packet.messages
|
|
2571
|
-
.map((message, index) => {
|
|
2572
|
-
const role = message.role.trim() || `message-${index + 1}`;
|
|
2573
|
-
return `[${role}]\n${message.content}`;
|
|
2574
|
-
})
|
|
2575
|
-
.join("\n\n");
|
|
2576
|
-
const contextRefs = packet.contextRefs.length === 0
|
|
2577
|
-
? ""
|
|
2578
|
-
: `\n\n# Context References\n\n${packet.contextRefs.map((ref, index) => {
|
|
2579
|
-
const title = ref.title?.trim() ? `\nTitle: ${ref.title.trim()}` : "";
|
|
2580
|
-
const summary = ref.summary?.trim() ? `\nSummary: ${ref.summary.trim()}` : "";
|
|
2581
|
-
return `${index + 1}. ${ref.kind}:${ref.refId}${title}${summary}`;
|
|
2582
|
-
}).join("\n\n")}`;
|
|
2583
|
-
const continuation = packet.providerThreadId
|
|
2584
|
-
? "\n\nContinue the existing provider thread identified by the bridge; do not restart the conversation context."
|
|
2585
|
-
: "";
|
|
2586
|
-
const boundedMetadata = buildChatBoundedMetadataPrompt(packet);
|
|
2587
|
-
return `You are handling a Forge Bridge Chat turn.
|
|
2588
|
-
|
|
2589
|
-
Conversation ID: ${packet.conversationId}
|
|
2590
|
-
Turn ID: ${packet.turnId}
|
|
2591
|
-
Provider: ${packet.providerKind}
|
|
2592
|
-
Model: ${packet.model}${continuation}${boundedMetadata}
|
|
2593
|
-
|
|
2594
|
-
# Conversation
|
|
2595
|
-
|
|
2596
|
-
${messages}${contextRefs}
|
|
2597
|
-
`;
|
|
2598
|
-
}
|
|
2599
|
-
function buildChatBoundedMetadataPrompt(packet) {
|
|
2600
|
-
if (packet.attachmentHandoffs.length === 0 && packet.actionBrokerGrants.length === 0) {
|
|
2601
|
-
return "";
|
|
2602
|
-
}
|
|
2603
|
-
const sections = [
|
|
2604
|
-
`\n\n# Bounded Handoff Metadata\n\nMetadata file: ${chatTurnMetadataFileName}\n\nThe metadata file is turn-scoped and cleaned up by the bridge when the turn ends. It contains opaque handles only; attachment content, raw paths, and grant nonces are not included.`,
|
|
2605
|
-
];
|
|
2606
|
-
if (packet.attachmentHandoffs.length > 0) {
|
|
2607
|
-
sections.push(`Attachment handoffs:\n${packet.attachmentHandoffs.map((handoff, index) => [
|
|
2608
|
-
`${index + 1}. turnId: ${handoff.turnId}`,
|
|
2609
|
-
` attachmentId: ${handoff.attachmentId}`,
|
|
2610
|
-
` tempFileToken: ${handoff.tempFileToken}`,
|
|
2611
|
-
` mimeType: ${handoff.mimeType}`,
|
|
2612
|
-
` sizeBytes: ${handoff.sizeBytes}`,
|
|
2613
|
-
` sha256: ${handoff.sha256}`,
|
|
2614
|
-
` fileNameDisplay: ${handoff.fileNameDisplay}`,
|
|
2615
|
-
` expiresAt: ${handoff.expiresAt}`,
|
|
2616
|
-
` status: ${handoff.status}`,
|
|
2617
|
-
].join("\n")).join("\n\n")}`);
|
|
2618
|
-
}
|
|
2619
|
-
if (packet.actionBrokerGrants.length > 0) {
|
|
2620
|
-
sections.push(`Action-broker grants:\n${packet.actionBrokerGrants.map((grant, index) => [
|
|
2621
|
-
`${index + 1}. grantId: ${grant.grantId}`,
|
|
2622
|
-
` turnId: ${grant.turnId}`,
|
|
2623
|
-
` leaseId: ${grant.leaseId}`,
|
|
2624
|
-
` fencingToken: ${grant.fencingToken}`,
|
|
2625
|
-
` allowedScopes: ${grant.allowedScopes.join(", ")}`,
|
|
2626
|
-
` expiresAt: ${grant.expiresAt}`,
|
|
2627
|
-
` redactionStatus: ${grant.redactionStatus}`,
|
|
2628
|
-
" nonce: held by bridge",
|
|
2629
|
-
].join("\n")).join("\n\n")}`);
|
|
2630
|
-
}
|
|
2631
|
-
return sections.join("\n\n");
|
|
2632
|
-
}
|
|
2633
2754
|
function chatProviderExitFailure(command, result, redactionSecrets) {
|
|
2634
2755
|
const commandText = redactText(formatProviderCliCommandForCheckpoint(command), redactionSecrets);
|
|
2635
2756
|
const stderr = clip(redactText(result.stderr.trim(), redactionSecrets), 1000);
|
|
@@ -7,6 +7,7 @@ import type { MemoryAdmissionDiagnostics } from "../runtime/memory-capacity.js";
|
|
|
7
7
|
import type { DockerEngineCapabilitySnapshot } from "../runtime/docker-engine-probe.js";
|
|
8
8
|
import type { HostFacts } from "../runtime/host-facts.js";
|
|
9
9
|
import type { HostLoadSnapshot } from "../runtime/host-load-sampler.js";
|
|
10
|
+
import type { RunnerSettingsReport } from "../runtime/runner-settings.js";
|
|
10
11
|
import type { BridgeChatCapability, ChatTurnCancelPacket } from "./bridge-chat.types.js";
|
|
11
12
|
export interface BridgeServiceConfig {
|
|
12
13
|
readonly serverUrl: string;
|
|
@@ -65,6 +66,11 @@ export interface BridgeServiceConfig {
|
|
|
65
66
|
readonly callbackAckTimeoutMs?: number;
|
|
66
67
|
readonly heartbeatDockerProbeWaitMs?: number;
|
|
67
68
|
readonly reconnectBackoffMs: readonly number[];
|
|
69
|
+
/**
|
|
70
|
+
* Decision 0014: the `forge-bridge yield` flag file next to the bridge config,
|
|
71
|
+
* polled while running. Null or absent: no local yield flag.
|
|
72
|
+
*/
|
|
73
|
+
readonly localYieldFlagPath?: string | null;
|
|
68
74
|
}
|
|
69
75
|
export interface BridgeRepoMapping {
|
|
70
76
|
readonly repoId?: string | null;
|
|
@@ -152,6 +158,11 @@ export interface BridgeCapabilities {
|
|
|
152
158
|
readonly host?: HostFacts | null;
|
|
153
159
|
/** Live host load sample (schema 7). Never material: heartbeats with only load changes are not persisted. */
|
|
154
160
|
readonly load?: HostLoadSnapshot | null;
|
|
161
|
+
/** Decision 0014 (schema 8): server settings support and the last `SettingsApplied` report. Material. */
|
|
162
|
+
readonly settings?: BridgeSettingsCapability | null;
|
|
163
|
+
}
|
|
164
|
+
export interface BridgeSettingsCapability extends RunnerSettingsReport {
|
|
165
|
+
readonly supportsServerSettings: true;
|
|
155
166
|
}
|
|
156
167
|
export interface SandboxMemoryCapacityDiagnostics {
|
|
157
168
|
readonly defaultWorkerMemoryLimitBytes: number;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** `<config dir>/<config name>.yield.json`, e.g. `~/.config/forge/bridge.yield.json` beside `bridge.json`. */
|
|
2
|
+
export declare function localYieldFlagPathFor(configPath: string): string;
|
|
3
|
+
/** The local flag; a missing or unreadable file means off. */
|
|
4
|
+
export declare function readLocalYieldFlag(flagPath: string): Promise<boolean>;
|
|
5
|
+
/** Writes the flag atomically with mode 0600. */
|
|
6
|
+
export declare function writeLocalYieldFlag(flagPath: string, yieldToForeground: boolean): Promise<void>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
/** `<config dir>/<config name>.yield.json`, e.g. `~/.config/forge/bridge.yield.json` beside `bridge.json`. */
|
|
5
|
+
export function localYieldFlagPathFor(configPath) {
|
|
6
|
+
const parsed = path.parse(path.resolve(configPath));
|
|
7
|
+
return path.join(parsed.dir, `${parsed.name}.yield.json`);
|
|
8
|
+
}
|
|
9
|
+
/** The local flag; a missing or unreadable file means off. */
|
|
10
|
+
export async function readLocalYieldFlag(flagPath) {
|
|
11
|
+
try {
|
|
12
|
+
const parsed = JSON.parse(await fs.readFile(flagPath, "utf8"));
|
|
13
|
+
return parsed?.schemaVersion === 1 && parsed.yieldToForeground === true;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Writes the flag atomically with mode 0600. */
|
|
20
|
+
export async function writeLocalYieldFlag(flagPath, yieldToForeground) {
|
|
21
|
+
const content = { schemaVersion: 1, yieldToForeground, updatedAt: new Date().toISOString() };
|
|
22
|
+
await fs.mkdir(path.dirname(flagPath), { recursive: true, mode: 0o700 });
|
|
23
|
+
const temporary = `${flagPath}.${process.pid}.${randomUUID()}.tmp`;
|
|
24
|
+
try {
|
|
25
|
+
await fs.writeFile(temporary, `${JSON.stringify(content, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
26
|
+
// The umask can narrow the create mode but never widen it; set it exactly.
|
|
27
|
+
await fs.chmod(temporary, 0o600);
|
|
28
|
+
await fs.rename(temporary, flagPath);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
await fs.rm(temporary, { force: true }).catch(() => undefined);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -11,6 +11,9 @@ export interface RunnerHostCapabilityProbe {
|
|
|
11
11
|
detect(config: BridgeServiceConfig): Promise<RunnerHostCapabilitySnapshot>;
|
|
12
12
|
}
|
|
13
13
|
export declare class ProcessRunnerHostCapabilityProbe implements RunnerHostCapabilityProbe {
|
|
14
|
+
private readonly warn;
|
|
15
|
+
private readonly providerEnvironment;
|
|
16
|
+
constructor(warn?: (message: string) => void, providerEnvironment?: () => NodeJS.ProcessEnv);
|
|
14
17
|
detect(config: BridgeServiceConfig): Promise<RunnerHostCapabilitySnapshot>;
|
|
15
18
|
}
|
|
16
19
|
export declare function isUnavailablePlaywrightConfigError(error: unknown): boolean;
|
|
@@ -3,9 +3,22 @@ import fs from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
import { probeTestPostgresCapability } from "./test-postgres-capability.js";
|
|
6
|
+
import { appExecutionAliasWarning } from "../shared/process/windows-app-execution-alias.js";
|
|
7
|
+
import { buildProviderChildEnvironment } from "../session/provider-cli/provider-cli.process.js";
|
|
6
8
|
const execFileAsync = promisify(execFile);
|
|
7
9
|
export class ProcessRunnerHostCapabilityProbe {
|
|
10
|
+
warn;
|
|
11
|
+
providerEnvironment;
|
|
12
|
+
constructor(warn = message => process.stderr.write(`[${new Date().toISOString()}] ${message}\n`), providerEnvironment = () => buildProviderChildEnvironment()) {
|
|
13
|
+
this.warn = warn;
|
|
14
|
+
this.providerEnvironment = providerEnvironment;
|
|
15
|
+
}
|
|
8
16
|
async detect(config) {
|
|
17
|
+
// Readiness, not a capability: the bridge still settles an attempt whose descendant escaped
|
|
18
|
+
// the Job Object (see OutputPipeRelease), but the host should not hand out aliases.
|
|
19
|
+
const aliasWarning = appExecutionAliasWarning(this.providerEnvironment());
|
|
20
|
+
if (aliasWarning)
|
|
21
|
+
this.warn(aliasWarning);
|
|
9
22
|
const [pnpm, dotnet, git, bash, pwsh, windowsPowerShell] = await Promise.all([
|
|
10
23
|
probe("pnpm", ["--version"]),
|
|
11
24
|
probe("dotnet", ["--version"]),
|
package/dist/cli/cli.help.js
CHANGED
|
@@ -21,6 +21,7 @@ export function helpText() {
|
|
|
21
21
|
" remove-repo * Remove a saved repo mapping",
|
|
22
22
|
" cleanup * Prune managed bridge worktrees",
|
|
23
23
|
" sandbox * Initialize, diagnose, smoke-test, or reap Docker sandboxes",
|
|
24
|
+
" yield * Yield this machine to foreground work: no new attempts",
|
|
24
25
|
" version * Print the installed bridge package version",
|
|
25
26
|
" help * Display help for command",
|
|
26
27
|
" run-once * Internal: run one dispatch packet from JSON",
|
|
@@ -179,6 +180,23 @@ export function commandHelpText(command) {
|
|
|
179
180
|
"Stop the connected bridge first so the Docker ownership lock can be acquired.",
|
|
180
181
|
"",
|
|
181
182
|
].join("\n");
|
|
183
|
+
case "yield":
|
|
184
|
+
return [
|
|
185
|
+
"Forge Bridge — yield",
|
|
186
|
+
"Yield this machine to foreground work (for example while you are gaming).",
|
|
187
|
+
"",
|
|
188
|
+
"Usage:",
|
|
189
|
+
" forge-bridge yield on",
|
|
190
|
+
" forge-bridge yield off",
|
|
191
|
+
" forge-bridge yield status",
|
|
192
|
+
"",
|
|
193
|
+
"While yielding, the bridge takes no new attempts; running attempts finish, and",
|
|
194
|
+
"their heavy steps run under the yield CPU budget. A running bridge notices the",
|
|
195
|
+
"change within one heartbeat, without a restart, and reports it to Forge.",
|
|
196
|
+
"The flag is saved in its own file next to bridge.json. Yield is also on when the",
|
|
197
|
+
"runner's Yield toggle in Forge is on: either side turns it on.",
|
|
198
|
+
"",
|
|
199
|
+
].join("\n");
|
|
182
200
|
case "run-once":
|
|
183
201
|
return [
|
|
184
202
|
"Forge Bridge — run-once",
|
|
@@ -17,6 +17,7 @@ export declare class ForgeBridgeCliService implements CliService {
|
|
|
17
17
|
constructor(sessions?: SessionService, bridgeFactory?: (config: BridgeServiceConfig) => BridgeService, pairRunner?: PairRunnerClient, cleanupFactory?: CleanupServiceFactory, dotNetToolchainConfigurator?: DotNetToolchainConfigurator);
|
|
18
18
|
run(argv: readonly string[], io?: CliIo): Promise<number>;
|
|
19
19
|
}
|
|
20
|
+
type YieldAction = "on" | "off" | "status";
|
|
20
21
|
export declare function parseArgs(argv: readonly string[]): {
|
|
21
22
|
readonly ok: true;
|
|
22
23
|
readonly command: "run-once";
|
|
@@ -86,6 +87,10 @@ export declare function parseArgs(argv: readonly string[]): {
|
|
|
86
87
|
} | {
|
|
87
88
|
readonly ok: true;
|
|
88
89
|
readonly command: "sandbox-status";
|
|
90
|
+
} | {
|
|
91
|
+
readonly ok: true;
|
|
92
|
+
readonly command: "yield";
|
|
93
|
+
readonly action: YieldAction;
|
|
89
94
|
} | {
|
|
90
95
|
readonly ok: false;
|
|
91
96
|
readonly error: string;
|
|
@@ -104,13 +109,24 @@ interface PairArgs {
|
|
|
104
109
|
readonly repoRoot?: string;
|
|
105
110
|
readonly cleanupWorktrees: boolean;
|
|
106
111
|
readonly cliProviders: readonly string[];
|
|
112
|
+
/** True when `--cli-provider` named the providers, which then win over the Connect dialog's choice. */
|
|
113
|
+
readonly cliProvidersFromFlag?: boolean;
|
|
107
114
|
readonly projectLabels: readonly string[];
|
|
108
115
|
}
|
|
116
|
+
/** Decision 0014 §5: what the Connect dialog's pairing intent set for this host, echoed by the claim. */
|
|
117
|
+
export interface PairRunnerHost {
|
|
118
|
+
readonly name?: string;
|
|
119
|
+
readonly repoRoot?: string;
|
|
120
|
+
readonly cliProviders?: readonly string[];
|
|
121
|
+
}
|
|
109
122
|
interface PairRunnerClaim {
|
|
110
123
|
readonly runnerId: string;
|
|
111
124
|
readonly deviceToken: string;
|
|
125
|
+
readonly host?: PairRunnerHost;
|
|
112
126
|
}
|
|
113
127
|
type PairRunnerClient = (args: PairArgs) => Promise<PairRunnerClaim>;
|
|
128
|
+
/** Expands `~` in a repo folder chosen in Forge and rejects one shaped for another OS. */
|
|
129
|
+
export declare function resolveHostRepoRoot(value: string, platform?: NodeJS.Platform, home?: string): string | undefined;
|
|
114
130
|
export declare const claudeDefaultModels: readonly string[];
|
|
115
131
|
export declare function parseCodexModelCatalog(raw: string): string[];
|
|
116
132
|
export declare function parseCursorModelList(raw: string): string[];
|