@loucompanion/forge-bridge 0.1.3-dev.f66395c3ac21 → 0.1.4-dev.04a1e5b9e484
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 +165 -1
- package/dist/bridge/bridge-chat.types.d.ts +111 -0
- package/dist/bridge/bridge-chat.types.js +401 -0
- package/dist/bridge/bridge.base.d.ts +9 -1
- package/dist/bridge/bridge.service.d.ts +129 -3
- package/dist/bridge/bridge.service.js +2427 -70
- package/dist/bridge/bridge.types.d.ts +218 -2
- package/dist/bridge/dispatch-result-outbox.d.ts +25 -0
- package/dist/bridge/dispatch-result-outbox.js +62 -0
- package/dist/bridge/dispatch-result-worker.d.ts +2 -0
- package/dist/bridge/dispatch-result-worker.js +122 -0
- package/dist/bridge/internals.d.ts +2 -0
- package/dist/bridge/internals.js +1 -0
- package/dist/bridge/readiness-result-outbox.d.ts +21 -0
- package/dist/bridge/readiness-result-outbox.js +54 -0
- package/dist/bridge/readiness-result-worker.d.ts +2 -0
- package/dist/bridge/readiness-result-worker.js +121 -0
- package/dist/bridge/runner-host-capabilities.d.ts +15 -0
- package/dist/bridge/runner-host-capabilities.js +93 -0
- package/dist/cleanup/cleanup.service.d.ts +14 -2
- package/dist/cleanup/cleanup.service.js +496 -3
- package/dist/cleanup/cleanup.types.d.ts +10 -0
- package/dist/cleanup/index.d.ts +1 -1
- package/dist/cleanup/index.js +1 -1
- package/dist/cleanup/internals.d.ts +2 -2
- package/dist/cleanup/internals.js +1 -1
- package/dist/cli/cli.help.d.ts +2 -0
- package/dist/cli/cli.help.js +217 -0
- package/dist/cli/cli.service.d.ts +55 -7
- package/dist/cli/cli.service.js +429 -219
- package/dist/cli/local-config.d.ts +7 -0
- package/dist/cli/local-config.js +51 -3
- package/dist/runtime/aspnet-runtime-prebuild.d.ts +36 -0
- package/dist/runtime/aspnet-runtime-prebuild.js +341 -0
- package/dist/runtime/attempt-database-broker.d.ts +89 -0
- package/dist/runtime/attempt-database-broker.js +390 -0
- package/dist/runtime/attempt-node-runtime-launcher.d.ts +18 -0
- package/dist/runtime/attempt-node-runtime-launcher.js +140 -0
- package/dist/runtime/attempt-path-operation.d.ts +21 -0
- package/dist/runtime/attempt-path-operation.js +94 -0
- package/dist/runtime/attempt-private-directory.d.ts +6 -0
- package/dist/runtime/attempt-private-directory.js +54 -0
- package/dist/runtime/attempt-process-supervisor-registry.d.ts +20 -0
- package/dist/runtime/attempt-process-supervisor-registry.js +64 -0
- package/dist/runtime/attempt-process-supervisor.d.ts +102 -0
- package/dist/runtime/attempt-process-supervisor.js +421 -0
- package/dist/runtime/canonical-source-file.d.ts +3 -0
- package/dist/runtime/canonical-source-file.js +54 -0
- package/dist/runtime/docker-engine-probe.d.ts +90 -0
- package/dist/runtime/docker-engine-probe.js +333 -0
- package/dist/runtime/generated-output-reset.d.ts +20 -0
- package/dist/runtime/generated-output-reset.js +157 -0
- package/dist/runtime/host-database-capability-boundary.d.ts +16 -0
- package/dist/runtime/host-database-capability-boundary.js +62 -0
- package/dist/runtime/host-diagnostics.d.ts +11 -0
- package/dist/runtime/host-diagnostics.js +192 -0
- package/dist/runtime/host-execution-root.d.ts +4 -0
- package/dist/runtime/host-execution-root.js +39 -0
- package/dist/runtime/host-listener-inspector.d.ts +51 -0
- package/dist/runtime/host-listener-inspector.js +385 -0
- package/dist/runtime/host-port-broker.d.ts +76 -0
- package/dist/runtime/host-port-broker.js +333 -0
- package/dist/runtime/host-runtime-contract.d.ts +58 -0
- package/dist/runtime/host-runtime-contract.js +813 -0
- package/dist/runtime/host-runtime-lease.d.ts +217 -0
- package/dist/runtime/host-runtime-lease.js +2487 -0
- package/dist/runtime/host-runtime-promotion.d.ts +32 -0
- package/dist/runtime/host-runtime-promotion.js +206 -0
- package/dist/runtime/memory-capacity.d.ts +70 -0
- package/dist/runtime/memory-capacity.js +123 -0
- package/dist/runtime/native-test-postgres-fallback.d.ts +25 -0
- package/dist/runtime/native-test-postgres-fallback.js +91 -0
- package/dist/runtime/node-host-runtime-adapter.d.ts +54 -0
- package/dist/runtime/node-host-runtime-adapter.js +286 -0
- package/dist/runtime/pinned-directory-process.d.ts +9 -0
- package/dist/runtime/pinned-directory-process.js +61 -0
- package/dist/runtime/pinned-source-directory.d.ts +17 -0
- package/dist/runtime/pinned-source-directory.js +94 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +21 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +268 -0
- package/dist/runtime/prepared-runtime-identity.d.ts +6 -0
- package/dist/runtime/prepared-runtime-identity.js +218 -0
- package/dist/runtime/prepared-runtime-readiness.d.ts +30 -0
- package/dist/runtime/prepared-runtime-readiness.js +285 -0
- package/dist/runtime/runtime-isolation-lease.d.ts +67 -0
- package/dist/runtime/runtime-isolation-lease.js +161 -0
- package/dist/runtime/workspace-resource-estimator.d.ts +17 -0
- package/dist/runtime/workspace-resource-estimator.js +174 -0
- package/dist/sandbox/command-runner.d.ts +4 -0
- package/dist/sandbox/command-runner.js +47 -0
- package/dist/sandbox/contract.d.ts +5 -0
- package/dist/sandbox/contract.js +276 -0
- package/dist/sandbox/event-budget.d.ts +11 -0
- package/dist/sandbox/event-budget.js +27 -0
- package/dist/sandbox/image-policy.d.ts +35 -0
- package/dist/sandbox/image-policy.js +247 -0
- package/dist/sandbox/index.d.ts +5 -0
- package/dist/sandbox/index.js +5 -0
- package/dist/sandbox/lease-watchdog.d.ts +18 -0
- package/dist/sandbox/lease-watchdog.js +67 -0
- package/dist/sandbox/preflight.d.ts +84 -0
- package/dist/sandbox/preflight.js +521 -0
- package/dist/sandbox/process.d.ts +20 -0
- package/dist/sandbox/process.js +209 -0
- package/dist/sandbox/provider-auth/codex.d.ts +26 -0
- package/dist/sandbox/provider-auth/codex.js +212 -0
- package/dist/sandbox/repository-lock.d.ts +6 -0
- package/dist/sandbox/repository-lock.js +129 -0
- package/dist/sandbox/runtime.d.ts +302 -0
- package/dist/sandbox/runtime.js +2368 -0
- package/dist/sandbox/sandbox.types.d.ts +93 -0
- package/dist/sandbox/sandbox.types.js +1 -0
- package/dist/sandbox/smoke.d.ts +76 -0
- package/dist/sandbox/smoke.js +380 -0
- package/dist/sandbox/worker-supervisor.d.ts +13 -0
- package/dist/sandbox/worker-supervisor.js +36 -0
- package/dist/sandbox/worker.d.ts +1 -0
- package/dist/sandbox/worker.js +225 -0
- package/dist/sandbox/workspace.service.d.ts +13 -0
- package/dist/sandbox/workspace.service.js +74 -0
- package/dist/session/managed-attempt-tools.d.ts +28 -0
- package/dist/session/managed-attempt-tools.js +1016 -0
- package/dist/session/managed-build-coordinator.d.ts +5 -0
- package/dist/session/managed-build-coordinator.js +106 -0
- package/dist/session/managed-build-receipt.d.ts +21 -0
- package/dist/session/managed-build-receipt.js +337 -0
- package/dist/session/managed-verification-timeouts.d.ts +8 -0
- package/dist/session/managed-verification-timeouts.js +17 -0
- package/dist/session/phase-completion.artifacts.d.ts +27 -0
- package/dist/session/phase-completion.artifacts.js +829 -0
- package/dist/session/phase-completion.d.ts +53 -42
- package/dist/session/phase-completion.helpers.d.ts +117 -0
- package/dist/session/phase-completion.helpers.js +707 -0
- package/dist/session/phase-completion.js +125 -3007
- package/dist/session/phase-completion.prompts.d.ts +14 -0
- package/dist/session/phase-completion.prompts.js +233 -0
- package/dist/session/phase-completion.runtime.d.ts +49 -0
- package/dist/session/phase-completion.runtime.js +840 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -0
- package/dist/session/phase-completion.schemas.js +859 -0
- package/dist/session/phase-completion.validation.d.ts +38 -0
- package/dist/session/phase-completion.validation.js +918 -0
- package/dist/session/pre-publication-validation.d.ts +75 -0
- package/dist/session/pre-publication-validation.js +661 -0
- package/dist/session/provider-cli/bridge-cli.conformance-fixtures.d.ts +72 -0
- package/dist/session/provider-cli/bridge-cli.conformance-fixtures.js +462 -0
- package/dist/session/provider-cli/ci-repair-readiness.d.ts +16 -0
- package/dist/session/provider-cli/ci-repair-readiness.js +110 -0
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +95 -0
- package/dist/session/provider-cli/provider-cli.artifacts.js +812 -0
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.deterministic-payloads.d.ts +12 -0
- package/dist/session/provider-cli/provider-cli.deterministic-payloads.js +279 -0
- package/dist/session/provider-cli/provider-cli.deterministic.d.ts +14 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +407 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +99 -0
- package/dist/session/provider-cli/provider-cli.process.js +874 -0
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +52 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +715 -0
- package/dist/session/provider-cli/provider-cli.qa-sidecars.d.ts +11 -0
- package/dist/session/provider-cli/provider-cli.qa-sidecars.js +66 -0
- package/dist/session/provider-cli/provider-cli.repair-epoch.d.ts +6 -0
- package/dist/session/provider-cli/provider-cli.repair-epoch.js +11 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +22 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +92 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +47 -53
- package/dist/session/provider-cli/provider-cli.service.js +1258 -2497
- package/dist/session/provider-cli/provider-cli.types.d.ts +8 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +32 -0
- package/dist/session/provider-cli/provider-output-state.js +817 -0
- package/dist/session/provider-cli/provider-usage.d.ts +7 -0
- package/dist/session/provider-cli/provider-usage.js +28 -5
- package/dist/session/session-redaction.d.ts +3 -0
- package/dist/session/session-redaction.js +448 -0
- package/dist/session/session.base.d.ts +6 -1
- package/dist/session/session.service.d.ts +8 -2
- package/dist/session/session.service.js +586 -59
- package/dist/session/session.types.d.ts +324 -3
- package/dist/session/session.types.js +939 -10
- package/dist/session/unreferenced-exports.d.ts +12 -0
- package/dist/session/unreferenced-exports.js +59 -0
- package/dist/shared/format/format-bytes.d.ts +1 -0
- package/dist/shared/format/format-bytes.js +9 -0
- package/dist/shared/git/git.js +2 -1
- package/dist/shared/path/path.d.ts +1 -0
- package/dist/shared/path/path.js +21 -1
- package/dist/shared/process/dotnet-toolchain.d.ts +17 -0
- package/dist/shared/process/dotnet-toolchain.js +307 -0
- package/dist/shared/process/host-process-recovery.d.ts +12 -0
- package/dist/shared/process/host-process-recovery.js +79 -0
- package/dist/shared/process/host-process-supervisor.d.ts +59 -0
- package/dist/shared/process/host-process-supervisor.js +331 -0
- package/dist/shared/process/process.d.ts +3 -0
- package/dist/shared/process/process.js +13 -7
- package/dist/shared/process/windows-launch.d.ts +8 -0
- package/dist/shared/process/windows-launch.js +41 -0
- package/dist/shared/provider-capabilities.d.ts +4 -0
- package/dist/shared/provider-capabilities.js +88 -0
- package/dist/shared/redaction/redaction.d.ts +1 -0
- package/dist/shared/redaction/redaction.js +47 -4
- package/dist/shared/time/monotonic.d.ts +1 -0
- package/dist/shared/time/monotonic.js +8 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.d.ts +3 -2
- package/dist/worktree/artifact-injector.js +82 -10
- package/dist/worktree/dependency-warmer.d.ts +53 -1
- package/dist/worktree/dependency-warmer.js +619 -11
- package/dist/worktree/index.d.ts +2 -1
- package/dist/worktree/index.js +1 -0
- package/dist/worktree/prior-phase-artifact-hydrator.d.ts +2 -0
- package/dist/worktree/prior-phase-artifact-hydrator.js +136 -0
- package/dist/worktree/story-qa-reference-hydrator.d.ts +4 -0
- package/dist/worktree/story-qa-reference-hydrator.js +253 -0
- package/dist/worktree/worktree-paths.d.ts +4 -0
- package/dist/worktree/worktree-paths.js +30 -0
- package/dist/worktree/worktree.base.d.ts +3 -0
- package/dist/worktree/worktree.service.d.ts +16 -3
- package/dist/worktree/worktree.service.js +334 -54
- package/dist/worktree/worktree.types.d.ts +9 -1
- package/package.json +12 -7
- package/runtime/windows-job-supervisor.ps1 +722 -0
- package/runtime/windows-listener-owner.ps1 +33 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
export const bridgeChatProtocolVersion = "chat_interactive_v1";
|
|
2
|
+
export const bridgeChatUpdateRequiredCode = "update_required";
|
|
3
|
+
export const bridgeChatMaxCallbackPayloadBytes = 256 * 1024;
|
|
4
|
+
export const bridgeChatMaxProviderThreadIdChars = 256;
|
|
5
|
+
const supportedAvailability = new Set(["available", "degraded", "unavailable"]);
|
|
6
|
+
const supportedRequestedCapabilities = new Set([
|
|
7
|
+
"text",
|
|
8
|
+
"cancel",
|
|
9
|
+
"resume",
|
|
10
|
+
"thread_continuity",
|
|
11
|
+
"attachment_handoffs",
|
|
12
|
+
"action_broker_grants",
|
|
13
|
+
]);
|
|
14
|
+
const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
15
|
+
const unixEpochMs = Date.parse("1970-01-01T00:00:00.000Z");
|
|
16
|
+
const maxOpaqueHandleChars = 4096;
|
|
17
|
+
const maxGrantNonceChars = 4096;
|
|
18
|
+
const maxMetadataStringChars = 4096;
|
|
19
|
+
export function unavailableBridgeChatCapability(protocolVersion = bridgeChatProtocolVersion, unavailableCode, unavailableReason) {
|
|
20
|
+
return {
|
|
21
|
+
availability: "unavailable",
|
|
22
|
+
protocolVersion: nonEmptyStringOr(protocolVersion, bridgeChatProtocolVersion),
|
|
23
|
+
supportedProviders: [],
|
|
24
|
+
supportedModels: [],
|
|
25
|
+
supportsTextStreaming: false,
|
|
26
|
+
supportsCancel: false,
|
|
27
|
+
supportsResume: false,
|
|
28
|
+
supportsProviderThreadContinuity: false,
|
|
29
|
+
supportsAttachments: false,
|
|
30
|
+
supportsActionBrokerGrants: false,
|
|
31
|
+
maxMessageBytes: 0,
|
|
32
|
+
maxContextRefs: 0,
|
|
33
|
+
unavailableCode: cleanOptionalString(unavailableCode),
|
|
34
|
+
unavailableReason: cleanOptionalString(unavailableReason),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function normalizeBridgeChatCapability(value) {
|
|
38
|
+
if (!value) {
|
|
39
|
+
return unavailableBridgeChatCapability();
|
|
40
|
+
}
|
|
41
|
+
const protocolVersion = nonEmptyStringOr(value.protocolVersion, bridgeChatProtocolVersion);
|
|
42
|
+
if (protocolVersion !== bridgeChatProtocolVersion) {
|
|
43
|
+
return unavailableBridgeChatCapability(protocolVersion, bridgeChatUpdateRequiredCode, `Bridge Chat protocol '${protocolVersion}' is not supported by this bridge.`);
|
|
44
|
+
}
|
|
45
|
+
const availability = supportedAvailability.has(value.availability) ? value.availability : "unavailable";
|
|
46
|
+
return {
|
|
47
|
+
availability,
|
|
48
|
+
protocolVersion: bridgeChatProtocolVersion,
|
|
49
|
+
supportedProviders: cleanStringArray(value.supportedProviders, true),
|
|
50
|
+
supportedModels: cleanStringArray(value.supportedModels, false),
|
|
51
|
+
supportsTextStreaming: value.supportsTextStreaming === true,
|
|
52
|
+
supportsCancel: value.supportsCancel === true,
|
|
53
|
+
supportsResume: value.supportsResume === true,
|
|
54
|
+
supportsProviderThreadContinuity: value.supportsProviderThreadContinuity === true,
|
|
55
|
+
supportsAttachments: value.supportsAttachments === true,
|
|
56
|
+
supportsActionBrokerGrants: value.supportsActionBrokerGrants === true,
|
|
57
|
+
maxMessageBytes: nonNegativeInteger(value.maxMessageBytes),
|
|
58
|
+
maxContextRefs: nonNegativeInteger(value.maxContextRefs),
|
|
59
|
+
unavailableCode: availability === "unavailable" ? cleanOptionalString(value.unavailableCode) : null,
|
|
60
|
+
unavailableReason: availability === "unavailable" ? cleanOptionalString(value.unavailableReason) : null,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function parseChatTurnDispatchPacket(value, capability = unavailableBridgeChatCapability()) {
|
|
64
|
+
const packet = asObject(value, "chat turn dispatch packet");
|
|
65
|
+
const protocolVersion = requiredString(packet, "protocolVersion");
|
|
66
|
+
if (protocolVersion !== bridgeChatProtocolVersion) {
|
|
67
|
+
throw new Error(`Unsupported chat protocolVersion: ${protocolVersion}`);
|
|
68
|
+
}
|
|
69
|
+
assertReservedFieldsAbsent(packet, "chat turn dispatch packet");
|
|
70
|
+
const normalizedCapability = normalizeBridgeChatCapability(capability);
|
|
71
|
+
const messages = parseMessages(packet.messages, normalizedCapability.maxMessageBytes);
|
|
72
|
+
const contextRefs = parseContextRefs(packet.contextRefs);
|
|
73
|
+
if (normalizedCapability.maxContextRefs > 0 && contextRefs.length > normalizedCapability.maxContextRefs) {
|
|
74
|
+
throw new Error("contextRefs exceeds maxContextRefs.");
|
|
75
|
+
}
|
|
76
|
+
const turnId = requiredUuid(packet, "turnId");
|
|
77
|
+
const leaseId = requiredUuid(packet, "leaseId");
|
|
78
|
+
const fencingToken = requiredUuid(packet, "fencingToken");
|
|
79
|
+
const requestedCapabilities = parseRequestedCapabilities(packet.requestedCapabilities, normalizedCapability);
|
|
80
|
+
const attachmentHandoffs = parseAttachmentHandoffs(packet.attachmentHandoffs, normalizedCapability, requestedCapabilities);
|
|
81
|
+
const actionBrokerGrants = parseActionBrokerGrants(packet.actionBrokerGrants, normalizedCapability, requestedCapabilities);
|
|
82
|
+
assertBoundedEnvelopesMatchFence(attachmentHandoffs, actionBrokerGrants, turnId, leaseId, fencingToken);
|
|
83
|
+
return {
|
|
84
|
+
chatRunId: requiredUuid(packet, "chatRunId"),
|
|
85
|
+
conversationId: requiredUuid(packet, "conversationId"),
|
|
86
|
+
turnId,
|
|
87
|
+
leaseId,
|
|
88
|
+
fencingToken,
|
|
89
|
+
runnerInstanceId: requiredUuid(packet, "runnerInstanceId"),
|
|
90
|
+
providerKind: requiredString(packet, "providerKind").trim().toLowerCase(),
|
|
91
|
+
model: requiredString(packet, "model").trim(),
|
|
92
|
+
messages,
|
|
93
|
+
contextRefs,
|
|
94
|
+
idempotencyKey: requiredString(packet, "idempotencyKey").trim(),
|
|
95
|
+
providerThreadId: optionalString(packet, "providerThreadId", bridgeChatMaxProviderThreadIdChars),
|
|
96
|
+
protocolVersion: bridgeChatProtocolVersion,
|
|
97
|
+
requestedCapabilities,
|
|
98
|
+
attachmentHandoffs,
|
|
99
|
+
actionBrokerGrants,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export function isTerminalChatTurnCallbackKind(kind) {
|
|
103
|
+
return kind === "output_completed" || kind === "failed" || kind === "cancelled" || kind === "expired";
|
|
104
|
+
}
|
|
105
|
+
export function assertBridgeChatCallbackPayload(value, label = "payload") {
|
|
106
|
+
if (value === undefined || value === null) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
110
|
+
throw new Error(`${label} must be an object when provided.`);
|
|
111
|
+
}
|
|
112
|
+
if (new TextEncoder().encode(JSON.stringify(value)).byteLength > bridgeChatMaxCallbackPayloadBytes) {
|
|
113
|
+
throw new Error(`${label} exceeds maxCallbackPayloadBytes.`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function parseMessages(value, maxMessageBytes) {
|
|
117
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
118
|
+
throw new Error("messages must be a non-empty array.");
|
|
119
|
+
}
|
|
120
|
+
return value.map((entry, index) => {
|
|
121
|
+
const message = asObject(entry, `messages[${index}]`);
|
|
122
|
+
assertReservedFieldsAbsent(message, `messages[${index}]`);
|
|
123
|
+
const content = requiredString(message, "content");
|
|
124
|
+
if (maxMessageBytes > 0 && new TextEncoder().encode(content).byteLength > maxMessageBytes) {
|
|
125
|
+
throw new Error(`messages[${index}].content exceeds maxMessageBytes.`);
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
role: requiredString(message, "role").trim(),
|
|
129
|
+
content,
|
|
130
|
+
metadata: optionalObject(message.metadata, `messages[${index}].metadata`),
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function parseContextRefs(value) {
|
|
135
|
+
if (value === undefined || value === null) {
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
if (!Array.isArray(value)) {
|
|
139
|
+
throw new Error("contextRefs must be an array when provided.");
|
|
140
|
+
}
|
|
141
|
+
return value.map((entry, index) => {
|
|
142
|
+
const ref = asObject(entry, `contextRefs[${index}]`);
|
|
143
|
+
assertReservedFieldsAbsent(ref, `contextRefs[${index}]`);
|
|
144
|
+
return {
|
|
145
|
+
kind: requiredString(ref, "kind").trim(),
|
|
146
|
+
refId: requiredString(ref, "refId").trim(),
|
|
147
|
+
title: optionalString(ref, "title"),
|
|
148
|
+
summary: optionalString(ref, "summary"),
|
|
149
|
+
metadata: optionalObject(ref.metadata, `contextRefs[${index}].metadata`),
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function parseAttachmentHandoffs(value, capability, requestedCapabilities) {
|
|
154
|
+
if (value === undefined || value === null) {
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
if (!Array.isArray(value)) {
|
|
158
|
+
throw new Error("attachmentHandoffs must be an array when provided.");
|
|
159
|
+
}
|
|
160
|
+
if (value.length > 0 && !capability.supportsAttachments) {
|
|
161
|
+
throw new Error("Bridge Chat attachmentHandoffs require supportsAttachments.");
|
|
162
|
+
}
|
|
163
|
+
if (value.length > 0 && !requestedCapabilities.includes("attachment_handoffs")) {
|
|
164
|
+
throw new Error("Bridge Chat attachmentHandoffs require requestedCapabilities to include attachment_handoffs.");
|
|
165
|
+
}
|
|
166
|
+
return value.map((entry, index) => {
|
|
167
|
+
const handoff = asObject(entry, `attachmentHandoffs[${index}]`);
|
|
168
|
+
assertOnlyKeys(handoff, `attachmentHandoffs[${index}]`, [
|
|
169
|
+
"turnId",
|
|
170
|
+
"attachmentId",
|
|
171
|
+
"tempFileToken",
|
|
172
|
+
"mimeType",
|
|
173
|
+
"sizeBytes",
|
|
174
|
+
"sha256",
|
|
175
|
+
"fileNameDisplay",
|
|
176
|
+
"expiresAt",
|
|
177
|
+
"status",
|
|
178
|
+
]);
|
|
179
|
+
const status = requiredString(handoff, "status").trim();
|
|
180
|
+
if (status !== "available") {
|
|
181
|
+
throw new Error(`attachmentHandoffs[${index}].status must be available.`);
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
turnId: requiredUuid(handoff, "turnId"),
|
|
185
|
+
attachmentId: requiredUuid(handoff, "attachmentId"),
|
|
186
|
+
tempFileToken: boundedRequiredString(handoff, "tempFileToken", maxOpaqueHandleChars),
|
|
187
|
+
mimeType: boundedRequiredString(handoff, "mimeType", maxMetadataStringChars),
|
|
188
|
+
sizeBytes: requiredNonNegativeInteger(handoff, "sizeBytes"),
|
|
189
|
+
sha256: boundedRequiredString(handoff, "sha256", maxMetadataStringChars),
|
|
190
|
+
fileNameDisplay: boundedRequiredString(handoff, "fileNameDisplay", maxMetadataStringChars),
|
|
191
|
+
expiresAt: requiredFutureContractTimestamp(handoff, "expiresAt"),
|
|
192
|
+
status,
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function parseActionBrokerGrants(value, capability, requestedCapabilities) {
|
|
197
|
+
if (value === undefined || value === null) {
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
if (!Array.isArray(value)) {
|
|
201
|
+
throw new Error("actionBrokerGrants must be an array when provided.");
|
|
202
|
+
}
|
|
203
|
+
if (value.length > 0 && !capability.supportsActionBrokerGrants) {
|
|
204
|
+
throw new Error("Bridge Chat actionBrokerGrants require supportsActionBrokerGrants.");
|
|
205
|
+
}
|
|
206
|
+
if (value.length > 0 && !requestedCapabilities.includes("action_broker_grants")) {
|
|
207
|
+
throw new Error("Bridge Chat actionBrokerGrants require requestedCapabilities to include action_broker_grants.");
|
|
208
|
+
}
|
|
209
|
+
return value.map((entry, index) => {
|
|
210
|
+
const grant = asObject(entry, `actionBrokerGrants[${index}]`);
|
|
211
|
+
assertOnlyKeys(grant, `actionBrokerGrants[${index}]`, [
|
|
212
|
+
"grantId",
|
|
213
|
+
"turnId",
|
|
214
|
+
"leaseId",
|
|
215
|
+
"fencingToken",
|
|
216
|
+
"allowedScopes",
|
|
217
|
+
"nonce",
|
|
218
|
+
"expiresAt",
|
|
219
|
+
"redactionStatus",
|
|
220
|
+
]);
|
|
221
|
+
const redactionStatus = requiredString(grant, "redactionStatus").trim();
|
|
222
|
+
if (redactionStatus !== "redacted" && redactionStatus !== "not_applicable") {
|
|
223
|
+
throw new Error(`actionBrokerGrants[${index}].redactionStatus is unsupported.`);
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
grantId: requiredUuid(grant, "grantId"),
|
|
227
|
+
turnId: requiredUuid(grant, "turnId"),
|
|
228
|
+
leaseId: requiredUuid(grant, "leaseId"),
|
|
229
|
+
fencingToken: requiredUuid(grant, "fencingToken"),
|
|
230
|
+
allowedScopes: requiredSortedStringArray(grant, "allowedScopes"),
|
|
231
|
+
nonce: boundedRequiredString(grant, "nonce", maxGrantNonceChars),
|
|
232
|
+
expiresAt: requiredFutureContractTimestamp(grant, "expiresAt"),
|
|
233
|
+
redactionStatus,
|
|
234
|
+
};
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function parseRequestedCapabilities(value, capability) {
|
|
238
|
+
if (value === undefined || value === null) {
|
|
239
|
+
return [];
|
|
240
|
+
}
|
|
241
|
+
if (!Array.isArray(value)) {
|
|
242
|
+
throw new Error("requestedCapabilities must be an array when provided.");
|
|
243
|
+
}
|
|
244
|
+
return value.map((entry, index) => {
|
|
245
|
+
if (typeof entry !== "string" || entry.trim().length === 0) {
|
|
246
|
+
throw new Error(`requestedCapabilities[${index}] must be a non-empty string.`);
|
|
247
|
+
}
|
|
248
|
+
const requestedCapability = entry.trim().toLowerCase();
|
|
249
|
+
if (!supportedRequestedCapabilities.has(requestedCapability)) {
|
|
250
|
+
throw new Error(`Bridge Chat v1 does not support requestedCapabilities ${requestedCapability}.`);
|
|
251
|
+
}
|
|
252
|
+
if (requestedCapability === "attachment_handoffs" && !capability.supportsAttachments) {
|
|
253
|
+
throw new Error("Bridge Chat v1 does not support requestedCapabilities attachment_handoffs for this runner.");
|
|
254
|
+
}
|
|
255
|
+
if (requestedCapability === "action_broker_grants" && !capability.supportsActionBrokerGrants) {
|
|
256
|
+
throw new Error("Bridge Chat v1 does not support requestedCapabilities action_broker_grants for this runner.");
|
|
257
|
+
}
|
|
258
|
+
return requestedCapability;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function assertBoundedEnvelopesMatchFence(attachmentHandoffs, actionBrokerGrants, turnId, leaseId, fencingToken) {
|
|
262
|
+
attachmentHandoffs.forEach((handoff, index) => {
|
|
263
|
+
if (handoff.turnId !== turnId) {
|
|
264
|
+
throw new Error(`attachmentHandoffs[${index}].turnId must match turnId.`);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
actionBrokerGrants.forEach((grant, index) => {
|
|
268
|
+
if (grant.turnId !== turnId || grant.leaseId !== leaseId || grant.fencingToken !== fencingToken) {
|
|
269
|
+
throw new Error(`actionBrokerGrants[${index}] must match the active dispatch fence.`);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
function assertReservedFieldsAbsent(source, label) {
|
|
274
|
+
for (const key of ["attachments", "attachmentHandles", "actionGrants"]) {
|
|
275
|
+
if (source[key] !== undefined && source[key] !== null) {
|
|
276
|
+
throw new Error(`${label}.${key} is reserved for a later Bridge Chat protocol.`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function assertOnlyKeys(source, label, allowedKeys) {
|
|
281
|
+
const allowed = new Set(allowedKeys);
|
|
282
|
+
for (const key of Object.keys(source)) {
|
|
283
|
+
if (!allowed.has(key)) {
|
|
284
|
+
throw new Error(`${label}.${key} is not supported by Bridge Chat v1.`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function asObject(value, label) {
|
|
289
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
290
|
+
throw new Error(`${label} must be an object.`);
|
|
291
|
+
}
|
|
292
|
+
return value;
|
|
293
|
+
}
|
|
294
|
+
function optionalObject(value, label) {
|
|
295
|
+
if (value === undefined || value === null) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
return asObject(value, label);
|
|
299
|
+
}
|
|
300
|
+
function requiredUuid(source, key) {
|
|
301
|
+
const value = requiredString(source, key).trim();
|
|
302
|
+
if (!uuidPattern.test(value)) {
|
|
303
|
+
throw new Error(`${key} must be a UUID.`);
|
|
304
|
+
}
|
|
305
|
+
return value;
|
|
306
|
+
}
|
|
307
|
+
function requiredString(source, key) {
|
|
308
|
+
const value = source[key];
|
|
309
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
310
|
+
throw new Error(`${key} must be a non-empty string.`);
|
|
311
|
+
}
|
|
312
|
+
return value;
|
|
313
|
+
}
|
|
314
|
+
function boundedRequiredString(source, key, maxLength) {
|
|
315
|
+
const clean = requiredString(source, key).trim();
|
|
316
|
+
if (clean.length > maxLength) {
|
|
317
|
+
throw new Error(`${key} exceeds ${maxLength} characters.`);
|
|
318
|
+
}
|
|
319
|
+
return clean;
|
|
320
|
+
}
|
|
321
|
+
function requiredNonNegativeInteger(source, key) {
|
|
322
|
+
const value = source[key];
|
|
323
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
|
|
324
|
+
throw new Error(`${key} must be a non-negative integer.`);
|
|
325
|
+
}
|
|
326
|
+
return value;
|
|
327
|
+
}
|
|
328
|
+
function requiredSortedStringArray(source, key) {
|
|
329
|
+
const value = source[key];
|
|
330
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
331
|
+
throw new Error(`${key} must be a non-empty string array.`);
|
|
332
|
+
}
|
|
333
|
+
const cleaned = value.map((entry, index) => {
|
|
334
|
+
if (typeof entry !== "string" || entry.trim().length === 0) {
|
|
335
|
+
throw new Error(`${key}[${index}] must be a non-empty string.`);
|
|
336
|
+
}
|
|
337
|
+
return entry.trim();
|
|
338
|
+
});
|
|
339
|
+
if (new Set(cleaned).size !== cleaned.length) {
|
|
340
|
+
throw new Error(`${key} must not contain duplicate values.`);
|
|
341
|
+
}
|
|
342
|
+
const sorted = [...cleaned].sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
|
|
343
|
+
if (cleaned.some((scope, index) => scope !== sorted[index])) {
|
|
344
|
+
throw new Error(`${key} must be sorted.`);
|
|
345
|
+
}
|
|
346
|
+
return cleaned;
|
|
347
|
+
}
|
|
348
|
+
function requiredFutureContractTimestamp(source, key) {
|
|
349
|
+
const value = requiredString(source, key).trim();
|
|
350
|
+
const parsed = Date.parse(value);
|
|
351
|
+
if (!Number.isFinite(parsed) || parsed <= unixEpochMs) {
|
|
352
|
+
throw new Error(`${key} is required.`);
|
|
353
|
+
}
|
|
354
|
+
return value;
|
|
355
|
+
}
|
|
356
|
+
function optionalString(source, key, maxLength) {
|
|
357
|
+
const value = source[key];
|
|
358
|
+
if (value === undefined || value === null) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
if (typeof value !== "string") {
|
|
362
|
+
throw new Error(`${key} must be a string when provided.`);
|
|
363
|
+
}
|
|
364
|
+
const clean = value.trim();
|
|
365
|
+
if (clean.length === 0) {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
if (maxLength !== undefined && clean.length > maxLength) {
|
|
369
|
+
throw new Error(`${key} exceeds maxProviderThreadIdChars.`);
|
|
370
|
+
}
|
|
371
|
+
return clean;
|
|
372
|
+
}
|
|
373
|
+
function cleanOptionalString(value) {
|
|
374
|
+
if (typeof value !== "string") {
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
const clean = value.trim();
|
|
378
|
+
return clean.length === 0 ? null : clean;
|
|
379
|
+
}
|
|
380
|
+
function nonEmptyStringOr(value, fallback) {
|
|
381
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : fallback;
|
|
382
|
+
}
|
|
383
|
+
function cleanStringArray(values, lower) {
|
|
384
|
+
const seen = new Set();
|
|
385
|
+
const cleaned = [];
|
|
386
|
+
for (const value of values) {
|
|
387
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
const clean = lower ? value.trim().toLowerCase() : value.trim();
|
|
391
|
+
const key = clean.toLowerCase();
|
|
392
|
+
if (!seen.has(key)) {
|
|
393
|
+
seen.add(key);
|
|
394
|
+
cleaned.push(clean);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return cleaned;
|
|
398
|
+
}
|
|
399
|
+
function nonNegativeInteger(value) {
|
|
400
|
+
return Number.isSafeInteger(value) && value > 0 ? value : 0;
|
|
401
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BridgeCancelHandler, BridgeDispatchHandler, BridgeServiceConfig } from "./bridge.types.js";
|
|
1
|
+
import type { BridgeCancelHandler, BridgeChatTurnHandler, BridgeDispatchHandler, BridgeLeaseUpdateHandler, BridgeOfferHandler, BridgeReadinessProbeHandler, BridgeReapHandler, BridgeServiceConfig, BridgeStartHandler } from "./bridge.types.js";
|
|
2
2
|
export interface BridgeService {
|
|
3
3
|
connectOnce(): Promise<void>;
|
|
4
4
|
run(signal?: AbortSignal): Promise<void>;
|
|
@@ -8,8 +8,16 @@ export interface BridgeConnection {
|
|
|
8
8
|
start(): Promise<void>;
|
|
9
9
|
stop(): Promise<void>;
|
|
10
10
|
onClose(handler: (error?: Error) => void): void;
|
|
11
|
+
onReconnecting?(handler: (error?: Error) => void): void;
|
|
12
|
+
onReconnected?(handler: (connectionId?: string) => void | Promise<void>): void;
|
|
11
13
|
onDispatch(handler: BridgeDispatchHandler): void;
|
|
14
|
+
onChatTurn?(handler: BridgeChatTurnHandler): void;
|
|
15
|
+
onOffer?(handler: BridgeOfferHandler): void;
|
|
16
|
+
onStart?(handler: BridgeStartHandler): void;
|
|
17
|
+
onLeaseUpdate?(handler: BridgeLeaseUpdateHandler): void;
|
|
12
18
|
onCancel(handler: BridgeCancelHandler): void;
|
|
19
|
+
onReap?(handler: BridgeReapHandler): void;
|
|
20
|
+
onReadinessProbe?(handler: BridgeReadinessProbeHandler): void;
|
|
13
21
|
invoke<TResponse>(methodName: string, payload: unknown): Promise<TResponse>;
|
|
14
22
|
}
|
|
15
23
|
export interface BridgeConnectionFactory {
|
|
@@ -1,30 +1,135 @@
|
|
|
1
1
|
import type { SessionService } from "../session/session.base.js";
|
|
2
|
+
import type { ProviderProcessRunner } from "../session/provider-cli/provider-cli.process.js";
|
|
3
|
+
import { DockerEngineProbe, type DockerEngineCapabilitySnapshot } from "../runtime/docker-engine-probe.js";
|
|
4
|
+
import { type DispatchSandboxResourceRequest, type RunOnceDispatchPacket, type RunOnceResultPacket } from "../session/session.types.js";
|
|
5
|
+
import { DockerPreflight } from "../sandbox/preflight.js";
|
|
6
|
+
import type { SandboxPreflightResult } from "../sandbox/sandbox.types.js";
|
|
7
|
+
import { type SandboxRuntime } from "../sandbox/runtime.js";
|
|
2
8
|
import type { BridgeConnection, BridgeConnectionFactory, BridgeService } from "./bridge.base.js";
|
|
3
|
-
import
|
|
9
|
+
import { type RunnerHostCapabilityProbe } from "./runner-host-capabilities.js";
|
|
10
|
+
import type { BridgeCancelHandler, BridgeChatTurnHandler, BridgeDispatchHandler, BridgeLeaseUpdateRequest, BridgeReapRequest, BridgeServiceConfig } from "./bridge.types.js";
|
|
11
|
+
import { type ReadinessResultOutbox } from "./readiness-result-outbox.js";
|
|
12
|
+
import { type DispatchResultOutbox } from "./dispatch-result-outbox.js";
|
|
13
|
+
export type SandboxResourceResolver = (dispatch: RunOnceDispatchPacket) => Promise<ResolvedSandboxResourceProfile>;
|
|
14
|
+
export interface ResolvedSandboxResourceProfile {
|
|
15
|
+
readonly resources: DispatchSandboxResourceRequest;
|
|
16
|
+
readonly sandboxConfigCommitSha: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Protocol-v2 events are acknowledged one at a time before runOnce returns.
|
|
20
|
+
* Sending the complete transcript again in DispatchResult made long QA and CI
|
|
21
|
+
* sessions exceed SignalR's receive limit, disconnecting the bridge after the
|
|
22
|
+
* provider had already completed. The API combines its acknowledged streamed
|
|
23
|
+
* events with the terminal result, so the callback only needs the outcome and
|
|
24
|
+
* artifacts. Protocol v1 retains the transcript for legacy servers.
|
|
25
|
+
*/
|
|
26
|
+
export declare function compactTerminalResult(dispatch: RunOnceDispatchPacket, result: RunOnceResultPacket): RunOnceResultPacket;
|
|
4
27
|
export declare class ForgeBridgeService implements BridgeService {
|
|
5
28
|
private readonly config;
|
|
6
|
-
private readonly sessions;
|
|
7
29
|
private readonly connections;
|
|
30
|
+
private readonly hostCapabilityProbe;
|
|
31
|
+
private readonly chatProcessRunner;
|
|
8
32
|
private connection;
|
|
9
33
|
private heartbeatTimer;
|
|
34
|
+
private heartbeatInFlight;
|
|
35
|
+
private consecutiveHeartbeatFailures;
|
|
36
|
+
private reconnectingFromHeartbeatFailure;
|
|
37
|
+
private leaseWatchdogTimer;
|
|
38
|
+
private sandboxMaintenanceTimer;
|
|
39
|
+
private sandboxMaintenanceRunning;
|
|
10
40
|
private closed;
|
|
41
|
+
private transportRecovery;
|
|
42
|
+
private transportRecoveryGeneration;
|
|
11
43
|
private stopped;
|
|
12
44
|
private readonly activeSessions;
|
|
13
|
-
|
|
45
|
+
private readonly reservations;
|
|
46
|
+
private readonly activeReadinessProbes;
|
|
47
|
+
private readonly readinessResultOutbox;
|
|
48
|
+
private readinessResultFlush;
|
|
49
|
+
private readonly dispatchResultOutbox;
|
|
50
|
+
private dispatchResultFlush;
|
|
51
|
+
private dispatchResultGeneration;
|
|
52
|
+
private dispatchResultFlushedGeneration;
|
|
53
|
+
private readonly dispatchResultHandoffs;
|
|
54
|
+
private readonly preflight;
|
|
55
|
+
private readonly dockerEngineProbe;
|
|
56
|
+
private readonly sandboxRuntime;
|
|
57
|
+
private readonly sandboxResourceResolver;
|
|
58
|
+
private readonly sessions;
|
|
59
|
+
private readonly enforceHostDatabaseCapabilityBoundary;
|
|
60
|
+
private hostCapabilities;
|
|
61
|
+
private readonly recoveredHostAttempts;
|
|
62
|
+
private hostCapabilitiesDetected;
|
|
63
|
+
constructor(config: BridgeServiceConfig, sessions?: SessionService | undefined, connections?: BridgeConnectionFactory, preflight?: DockerPreflight, sandboxRuntime?: SandboxRuntime, sandboxResourceResolver?: SandboxResourceResolver, dockerEngineProbe?: DockerEngineProbe, hostCapabilityProbe?: RunnerHostCapabilityProbe, readinessResultOutbox?: ReadinessResultOutbox, chatProcessRunner?: ProviderProcessRunner, dispatchResultOutbox?: DispatchResultOutbox);
|
|
14
64
|
connectOnce(): Promise<void>;
|
|
65
|
+
private rememberRecoveredHostAttempts;
|
|
66
|
+
private recoveredHostAttemptsForHello;
|
|
67
|
+
private registerConnection;
|
|
15
68
|
run(signal?: AbortSignal): Promise<void>;
|
|
16
69
|
stop(): Promise<void>;
|
|
70
|
+
private handleChatTurn;
|
|
71
|
+
private createChatTurnWorkspace;
|
|
72
|
+
private runChatProviderProcess;
|
|
73
|
+
private sendChatProviderEvent;
|
|
74
|
+
private sendChatAbortTerminal;
|
|
75
|
+
private sendStandaloneChatTerminal;
|
|
76
|
+
private sendChatCallback;
|
|
77
|
+
private invokeChatCallbackWithRetry;
|
|
78
|
+
private requiredChatCapabilityFailure;
|
|
79
|
+
private bridgeChatCapability;
|
|
17
80
|
private handleDispatch;
|
|
81
|
+
private reservedDispatchHandoffIsCurrent;
|
|
82
|
+
private releaseReservedDispatchHandoff;
|
|
83
|
+
private releaseActiveSessionAndRefreshCapacity;
|
|
84
|
+
private handleOffer;
|
|
85
|
+
private commitOfferReservation;
|
|
86
|
+
private handleStart;
|
|
87
|
+
private redeemSecretGrant;
|
|
88
|
+
private redeemPublishGrant;
|
|
89
|
+
private handleLeaseUpdate;
|
|
90
|
+
private sendOfferDecision;
|
|
18
91
|
private parseDispatchOrReport;
|
|
92
|
+
private parseChatTurnOrReport;
|
|
19
93
|
private handleCancel;
|
|
94
|
+
private chatCancelMatchesActiveTurn;
|
|
95
|
+
private handleReap;
|
|
96
|
+
private handleReadinessProbe;
|
|
97
|
+
private deferActiveReadinessProbes;
|
|
98
|
+
private flushReadinessResults;
|
|
99
|
+
private flushReadinessResultsCore;
|
|
20
100
|
private abortActiveSessions;
|
|
101
|
+
private abortActiveReadinessProbes;
|
|
102
|
+
private normalizeReadinessProbe;
|
|
21
103
|
private normalizeDispatch;
|
|
22
104
|
private sendResult;
|
|
105
|
+
private sendLegacyResult;
|
|
106
|
+
private sendResultPayload;
|
|
107
|
+
private sendResultPayloadDirect;
|
|
108
|
+
private flushDispatchResults;
|
|
109
|
+
private flushDispatchResultsCore;
|
|
23
110
|
private startHeartbeat;
|
|
111
|
+
private heartbeatTick;
|
|
112
|
+
private startLeaseWatchdog;
|
|
113
|
+
private stopLeaseWatchdog;
|
|
114
|
+
private expireLeases;
|
|
115
|
+
private expireReservations;
|
|
24
116
|
private stopHeartbeat;
|
|
117
|
+
private startSandboxMaintenance;
|
|
118
|
+
private stopSandboxMaintenance;
|
|
119
|
+
private runSandboxMaintenance;
|
|
120
|
+
private readAttemptSnapshot;
|
|
121
|
+
private flushCleanupReports;
|
|
25
122
|
private sendHeartbeat;
|
|
123
|
+
private sendHeartbeatSnapshot;
|
|
26
124
|
private capabilities;
|
|
125
|
+
private requiredCapabilityFailure;
|
|
126
|
+
private usedSandboxResources;
|
|
127
|
+
private activeSandboxResources;
|
|
128
|
+
private sandboxResourceCapacity;
|
|
27
129
|
private invokeAck;
|
|
130
|
+
private beginTransportRecovery;
|
|
131
|
+
private completeTransportRecovery;
|
|
132
|
+
private waitForTransportRecovery;
|
|
28
133
|
private waitForClose;
|
|
29
134
|
private stopConnection;
|
|
30
135
|
}
|
|
@@ -38,9 +143,30 @@ export declare class SignalRBridgeConnection implements BridgeConnection {
|
|
|
38
143
|
start(): Promise<void>;
|
|
39
144
|
stop(): Promise<void>;
|
|
40
145
|
onClose(handler: (error?: Error) => void): void;
|
|
146
|
+
onReconnecting(handler: (error?: Error) => void): void;
|
|
147
|
+
onReconnected(handler: (connectionId?: string) => void | Promise<void>): void;
|
|
41
148
|
onDispatch(handler: BridgeDispatchHandler): void;
|
|
149
|
+
onChatTurn(handler: BridgeChatTurnHandler): void;
|
|
150
|
+
onOffer(handler: BridgeDispatchHandler): void;
|
|
151
|
+
onStart(handler: BridgeDispatchHandler): void;
|
|
152
|
+
onLeaseUpdate(handler: (request: BridgeLeaseUpdateRequest) => Promise<void>): void;
|
|
42
153
|
onCancel(handler: BridgeCancelHandler): void;
|
|
154
|
+
onReap(handler: (request: BridgeReapRequest) => Promise<void>): void;
|
|
155
|
+
onReadinessProbe(handler: (request: unknown) => Promise<void>): void;
|
|
43
156
|
invoke<TResponse>(methodName: string, payload: unknown): Promise<TResponse>;
|
|
44
157
|
}
|
|
45
158
|
export declare function defaultBridgeServiceConfig(overrides?: Partial<BridgeServiceConfig>): BridgeServiceConfig;
|
|
46
159
|
export declare function resolveBridgeRunnerHubUrl(serverUrl: string): URL;
|
|
160
|
+
export declare function delay(ms: number, signal?: AbortSignal): Promise<void>;
|
|
161
|
+
export declare function waitForPromiseOrAbort(promise: Promise<unknown>, signal?: AbortSignal): Promise<void>;
|
|
162
|
+
export declare function canReapManagedSandboxes(preflight: {
|
|
163
|
+
readonly healthy: boolean;
|
|
164
|
+
readonly unavailableCode?: string | null;
|
|
165
|
+
}): boolean;
|
|
166
|
+
export declare function dockerEngineRequirementFailure(requiredCapabilities: readonly string[], executionMode: string | undefined, capability: DockerEngineCapabilitySnapshot | null): string | null;
|
|
167
|
+
export type SandboxResourceVector = DispatchSandboxResourceRequest;
|
|
168
|
+
export declare function canReserveSandboxResources(used: SandboxResourceVector, requested: SandboxResourceVector, capacity: SandboxResourceVector): boolean;
|
|
169
|
+
export declare function sandboxMemoryCommitmentCapacity(preflight: Pick<SandboxPreflightResult, "totalMemoryBytes" | "availableMemoryBytes" | "hostReserveBytes">, activeMemoryBytes: number): number;
|
|
170
|
+
export declare function sandboxCapacityFailureMessage(used: SandboxResourceVector, requested: SandboxResourceVector, capacity: SandboxResourceVector, preflight: SandboxPreflightResult | null, config: BridgeServiceConfig): string;
|
|
171
|
+
export declare function resolveDynamicSandboxResources(requested: DispatchSandboxResourceRequest, serviceCount: number, networkMode: "offline" | "public_allowlist" | "open_public", baseRuntimeOverheadBytes?: number): DispatchSandboxResourceRequest;
|
|
172
|
+
export declare function resolveSandboxResourcesFromRepo(dispatch: RunOnceDispatchPacket, baseRuntimeOverheadBytes?: number): Promise<ResolvedSandboxResourceProfile>;
|