@vtxmacro/cli 2026.9.7 → 2026.9.9
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/bin/vtx-service-bootstrap.js +1 -1
- package/bin/vtx.js +406 -128
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ import { fileURLToPath } from "node:url";
|
|
|
16
16
|
// agent-cli-release.json
|
|
17
17
|
var agent_cli_release_default = {
|
|
18
18
|
package_name: "@vtxmacro/cli",
|
|
19
|
-
package_version: "2026.9.
|
|
19
|
+
package_version: "2026.9.9",
|
|
20
20
|
codex_package_name: "@openai/codex",
|
|
21
21
|
codex_version: "0.147.0",
|
|
22
22
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
package/bin/vtx.js
CHANGED
|
@@ -47,7 +47,7 @@ var init_agent_cli_release = __esm({
|
|
|
47
47
|
"agent-cli-release.json"() {
|
|
48
48
|
agent_cli_release_default = {
|
|
49
49
|
package_name: "@vtxmacro/cli",
|
|
50
|
-
package_version: "2026.9.
|
|
50
|
+
package_version: "2026.9.9",
|
|
51
51
|
codex_package_name: "@openai/codex",
|
|
52
52
|
codex_version: "0.147.0",
|
|
53
53
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
|
@@ -14442,7 +14442,7 @@ var init_zod = __esm({
|
|
|
14442
14442
|
});
|
|
14443
14443
|
|
|
14444
14444
|
// lib/external-inference-contract.ts
|
|
14445
|
-
var EXTERNAL_INFERENCE_CONTRACT_VERSION, EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION, EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION_V2, EXTERNAL_INFERENCE_ADVERTISEMENT_SCHEMA_VERSION, EXTERNAL_INFERENCE_ENVELOPE_SCHEMA_VERSION, EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION, LEGACY_EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION, EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION, EXTERNAL_INFERENCE_INPUT_HASH_DOMAIN, MAX_EXTERNAL_INFERENCE_STATUS_HOSTS, MAX_PROFILE_EXTERNAL_INFERENCE_FALLBACKS_PER_LANE, MAX_GENERATION, MAX_SAFE_INTEGER, MAX_PROMPT_BYTES, MAX_IMMUTABLE_JOB_INPUT_BYTES, MAX_CANDIDATE_PLAINTEXT_BYTES, MAX_CIPHERTEXT_CHARS, SHA256_INITIAL_STATE, SHA256_ROUND_CONSTANTS, rotateRight, sha256BytesHex, sha256Utf8Hex, computeImmutableJobInputSha256, identifierSchema, operationIdentifierSchema, sha256HexSchema, generationSchema, zeroBasedGenerationSchema, nonNegativeSafeIntegerSchema, positiveSafeIntegerSchema, sqlIntegerTokenCountSchema, timestampSchema, safeCodeSchema, processExitCodeSchema, externalInferenceAdapterIdSchema, reasoningEffortSchema, modelNameSchema, displayNameSchema, authenticatedAccountEmailSchema, protocolVersionSchema, base64UrlAlphabet, isCanonicalBase64Url, base64Url32BytesSchema, base64UrlNonceSchema, base64UrlCiphertextSchema, claimHandleSchema, boundedJsonTextSchema, boundedPromptTextSchema, laneSchema, botModeSchema, executionModeSchema, responseModeSchema, controlModeSchema, dispatchOutcomeSchema, responseOutcomeSchema, nativeModelControllerSchema, legacyExternalAgentModelControllerSchema, externalAgentModelControllerSchema, boundExternalAgentModelControllerSchema, externalAgentUnboundControllerSchema, externalAgentUnboundControllerV2Schema, orderedFallbackHostIdsSchema, externalInferenceFallbackHostIdsSchema, liveModelControllerSchema, snapshotModelControllerSchema, modelIdentityMappingSchema, advertisedModelSchema, hostAdvertisementSchema, envelopeAadSchema, validateEnvelopeAad, commonEnvelopeShape, sealedKeyWrapEnvelopeSchema, sealedInputEnvelopeSchema, sealedCandidateEnvelopeSchema, sealedEnvelopeSchema, screenerCandidateRuntimeBindingSchema, screenerClientLeaseBindingSchema, screenerRuntimeBindingSchema, serverRuntimeBindingSchema, clientRuntimeBindingSchema, runtimeBindingSchema, immutableJobInputSchema, canonicalizeJsonValue, serializeImmutableJobInput, reportedTokenUsageSchema, unavailableTokenUsageSchema, tokenUsageSchema, agentConnectRequestSchema, agentNextRequestSchema, agentHeartbeatRequestSchema, emptyAgentNextResultSchema, claimedAgentNextResultSchema, agentNextResultSchema, agentCompleteRequestSchema, agentFailRequestSchema, requestedModelSelectionSchema, completedModelProvenanceSchema, attemptModelProvenanceSchema, providerWeeklyQuotaReadSchema, hostHeartbeatRequestSchema, jobClaimRequestBaseShape, jobClaimRequestSchema, emptyJobClaimSchema, claimedJobSchema, claimedDispatchIntentSchema, batchedJobClaimSchema, timedBatchedJobClaimSchema, jobClaimResultSchema, attemptStartRequestSchema, jobHeartbeatRequestSchema, continueHeartbeatDirectiveSchema, cancelHeartbeatDirectiveSchema, jobHeartbeatResultSchema, adapterOutcomeEvidenceSchema, completionBaseShape, validateCompletion, providerResponseCompletionSchema, decisionCandidateCompletionSchema, jobCompleteRequestSchema, codexProcessExitDiagnosticsSchema, jobFailRequestSchema, jobCancelRequestSchema, jobCancellationReceiptSchema, jobDeliveryRequestSchema, deliveryBaseShape, validateDeliveryCandidate, providerResponseDeliverySchema, decisionCandidateDeliverySchema, jobDeliveryResultSchema, jobConsumptionRequestSchema, jobConsumptionReceiptSchema, jobStateSchema, jobStatusReadSchema, hostStatusReadSchema, controllerBindingStatusReadSchema, queueStatusReadSchema, outcomeStatusReadSchema, externalInferenceVolumeWindowReadSchema, externalInferenceFailureCountReadSchema, externalInferenceHostDiagnosticsReadSchema, externalInferenceProfileActivityReadSchema, externalInferenceStatusReadSchema, nativeResearchEvidenceSourceSchema, externalAgentResearchEvidenceSourceSchema, researchEvidenceSourceSchema, reportedResearchTokenUsageSchema, unavailableResearchTokenUsageSchema, researchTokenUsageSchema, externalInferenceProductLineageBaseShape, traderExternalInferenceProductLineageSchema, decisionChatExternalInferenceProductLineageSchema, screenerExternalInferenceProductLineageSchema, externalInferenceProductLineageSchema, normalProductLinkageSchema, evidenceMaterializationMarkerSchema, deliveredExternalAgentSourceIdentitySchema, deliveredRequestEvidenceSchema, researchEvidenceBaseShape, researchEvidenceBaseSchema, validateExactUtf8, validateResearchEvidence, providerResponseResearchEvidenceSchema, decisionCandidateResearchEvidenceSchema, researchEvidenceSchema;
|
|
14445
|
+
var EXTERNAL_INFERENCE_CONTRACT_VERSION, EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION, EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION_V2, EXTERNAL_INFERENCE_ADVERTISEMENT_SCHEMA_VERSION, EXTERNAL_INFERENCE_ENVELOPE_SCHEMA_VERSION, EXTERNAL_INFERENCE_COMPRESSED_INPUT_ENVELOPE_SCHEMA_VERSION, EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION, LEGACY_EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION, EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION, EXTERNAL_INFERENCE_INPUT_HASH_DOMAIN, MAX_EXTERNAL_INFERENCE_STATUS_HOSTS, MAX_PROFILE_EXTERNAL_INFERENCE_FALLBACKS_PER_LANE, MAX_GENERATION, MAX_SAFE_INTEGER, MAX_PROMPT_BYTES, MAX_IMMUTABLE_JOB_INPUT_BYTES, MAX_CANDIDATE_PLAINTEXT_BYTES, MAX_CIPHERTEXT_CHARS, SHA256_INITIAL_STATE, SHA256_ROUND_CONSTANTS, rotateRight, sha256BytesHex, sha256Utf8Hex, computeImmutableJobInputSha256, identifierSchema, operationIdentifierSchema, sha256HexSchema, generationSchema, zeroBasedGenerationSchema, nonNegativeSafeIntegerSchema, positiveSafeIntegerSchema, sqlIntegerTokenCountSchema, timestampSchema, safeCodeSchema, processExitCodeSchema, externalInferenceAdapterIdSchema, reasoningEffortSchema, modelNameSchema, displayNameSchema, authenticatedAccountEmailSchema, protocolVersionSchema, base64UrlAlphabet, isCanonicalBase64Url, base64Url32BytesSchema, base64UrlNonceSchema, base64UrlCiphertextSchema, claimHandleSchema, boundedJsonTextSchema, boundedPromptTextSchema, laneSchema, botModeSchema, executionModeSchema, responseModeSchema, controlModeSchema, dispatchOutcomeSchema, responseOutcomeSchema, nativeModelControllerSchema, legacyExternalAgentModelControllerSchema, externalAgentModelControllerSchema, boundExternalAgentModelControllerSchema, externalAgentUnboundControllerSchema, externalAgentUnboundControllerV2Schema, orderedFallbackHostIdsSchema, externalInferenceFallbackHostIdsSchema, liveModelControllerSchema, snapshotModelControllerSchema, modelIdentityMappingSchema, advertisedModelSchema, hostAdvertisementSchema, envelopeAadSchema, validateEnvelopeAad, commonEnvelopeShape, sealedKeyWrapEnvelopeSchema, sealedInputEnvelopeSchema, sealedCandidateEnvelopeSchema, sealedEnvelopeSchema, screenerCandidateRuntimeBindingSchema, screenerClientLeaseBindingSchema, screenerRuntimeBindingSchema, serverRuntimeBindingSchema, clientRuntimeBindingSchema, runtimeBindingSchema, immutableJobInputSchema, canonicalizeJsonValue, serializeImmutableJobInput, reportedTokenUsageSchema, unavailableTokenUsageSchema, tokenUsageSchema, agentConnectRequestSchema, agentNextRequestSchema, agentHeartbeatRequestSchema, emptyAgentNextResultSchema, claimedAgentNextResultSchema, agentNextResultSchema, agentCompleteRequestSchema, agentFailRequestSchema, requestedModelSelectionSchema, completedModelProvenanceSchema, attemptModelProvenanceSchema, providerWeeklyQuotaReadSchema, hostHeartbeatRequestSchema, jobClaimRequestBaseShape, jobClaimRequestSchema, emptyJobClaimSchema, claimedJobSchema, claimedDispatchIntentSchema, batchedJobClaimSchema, timedBatchedJobClaimSchema, jobClaimResultSchema, attemptStartRequestSchema, jobHeartbeatRequestSchema, continueHeartbeatDirectiveSchema, cancelHeartbeatDirectiveSchema, jobHeartbeatResultSchema, adapterOutcomeEvidenceSchema, completionBaseShape, validateCompletion, providerResponseCompletionSchema, decisionCandidateCompletionSchema, jobCompleteRequestSchema, codexProcessExitDiagnosticsSchema, jobFailRequestSchema, jobCancelRequestSchema, jobCancellationReceiptSchema, jobDeliveryRequestSchema, deliveryBaseShape, validateDeliveryCandidate, providerResponseDeliverySchema, decisionCandidateDeliverySchema, jobDeliveryResultSchema, jobConsumptionRequestSchema, jobConsumptionReceiptSchema, jobStateSchema, jobStatusReadSchema, hostStatusReadSchema, controllerBindingStatusReadSchema, queueStatusReadSchema, outcomeStatusReadSchema, externalInferenceVolumeWindowReadSchema, externalInferenceFailureCountReadSchema, externalInferenceHostDiagnosticsReadSchema, externalInferenceProfileActivityReadSchema, externalInferenceStatusReadSchema, nativeResearchEvidenceSourceSchema, externalAgentResearchEvidenceSourceSchema, researchEvidenceSourceSchema, reportedResearchTokenUsageSchema, unavailableResearchTokenUsageSchema, researchTokenUsageSchema, externalInferenceProductLineageBaseShape, traderExternalInferenceProductLineageSchema, decisionChatExternalInferenceProductLineageSchema, screenerExternalInferenceProductLineageSchema, externalInferenceProductLineageSchema, normalProductLinkageSchema, evidenceMaterializationMarkerSchema, deliveredExternalAgentSourceIdentitySchema, deliveredRequestEvidenceSchema, researchEvidenceBaseShape, researchEvidenceBaseSchema, validateExactUtf8, validateResearchEvidence, providerResponseResearchEvidenceSchema, decisionCandidateResearchEvidenceSchema, researchEvidenceSchema;
|
|
14446
14446
|
var init_external_inference_contract = __esm({
|
|
14447
14447
|
"lib/external-inference-contract.ts"() {
|
|
14448
14448
|
"use strict";
|
|
@@ -14452,6 +14452,7 @@ var init_external_inference_contract = __esm({
|
|
|
14452
14452
|
EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION_V2 = "external_inference_controller_v2";
|
|
14453
14453
|
EXTERNAL_INFERENCE_ADVERTISEMENT_SCHEMA_VERSION = "external_inference_advertisement_v1";
|
|
14454
14454
|
EXTERNAL_INFERENCE_ENVELOPE_SCHEMA_VERSION = "external_inference_envelope_v1";
|
|
14455
|
+
EXTERNAL_INFERENCE_COMPRESSED_INPUT_ENVELOPE_SCHEMA_VERSION = "external_inference_input_envelope_v2";
|
|
14455
14456
|
EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION = "external_inference_job_input_v2";
|
|
14456
14457
|
LEGACY_EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION = "external_inference_job_input_v1";
|
|
14457
14458
|
EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION = "external_inference_usage_v1";
|
|
@@ -14858,7 +14859,10 @@ var init_external_inference_contract = __esm({
|
|
|
14858
14859
|
}
|
|
14859
14860
|
});
|
|
14860
14861
|
envelopeAadSchema = external_exports.strictObject({
|
|
14861
|
-
envelope_version: external_exports.
|
|
14862
|
+
envelope_version: external_exports.union([
|
|
14863
|
+
external_exports.literal(EXTERNAL_INFERENCE_ENVELOPE_SCHEMA_VERSION),
|
|
14864
|
+
external_exports.literal(EXTERNAL_INFERENCE_COMPRESSED_INPUT_ENVELOPE_SCHEMA_VERSION)
|
|
14865
|
+
]),
|
|
14862
14866
|
suite: external_exports.literal("X25519-HKDF-SHA256-AES256GCM"),
|
|
14863
14867
|
direction: external_exports.enum(["wrap", "input", "candidate"]),
|
|
14864
14868
|
job_id: identifierSchema,
|
|
@@ -14871,6 +14875,9 @@ var init_external_inference_contract = __esm({
|
|
|
14871
14875
|
plaintext_sha256: sha256HexSchema
|
|
14872
14876
|
});
|
|
14873
14877
|
validateEnvelopeAad = (value, context, attemptRequired) => {
|
|
14878
|
+
if (value.aad.envelope_version !== value.schema_version) {
|
|
14879
|
+
context.addIssue({ code: "custom", message: "envelope schema version must match AAD envelope version", path: ["aad", "envelope_version"] });
|
|
14880
|
+
}
|
|
14874
14881
|
if (value.aad.direction !== value.direction) {
|
|
14875
14882
|
context.addIssue({ code: "custom", message: "envelope direction must match AAD direction", path: ["aad", "direction"] });
|
|
14876
14883
|
}
|
|
@@ -14900,7 +14907,10 @@ var init_external_inference_contract = __esm({
|
|
|
14900
14907
|
}
|
|
14901
14908
|
};
|
|
14902
14909
|
commonEnvelopeShape = {
|
|
14903
|
-
schema_version: external_exports.
|
|
14910
|
+
schema_version: external_exports.union([
|
|
14911
|
+
external_exports.literal(EXTERNAL_INFERENCE_ENVELOPE_SCHEMA_VERSION),
|
|
14912
|
+
external_exports.literal(EXTERNAL_INFERENCE_COMPRESSED_INPUT_ENVELOPE_SCHEMA_VERSION)
|
|
14913
|
+
]),
|
|
14904
14914
|
suite: external_exports.literal("X25519-HKDF-SHA256-AES256GCM"),
|
|
14905
14915
|
key_generation: generationSchema,
|
|
14906
14916
|
nonce: base64UrlNonceSchema,
|
|
@@ -14911,6 +14921,7 @@ var init_external_inference_contract = __esm({
|
|
|
14911
14921
|
};
|
|
14912
14922
|
sealedKeyWrapEnvelopeSchema = external_exports.strictObject({
|
|
14913
14923
|
...commonEnvelopeShape,
|
|
14924
|
+
schema_version: external_exports.literal(EXTERNAL_INFERENCE_ENVELOPE_SCHEMA_VERSION),
|
|
14914
14925
|
direction: external_exports.literal("wrap"),
|
|
14915
14926
|
ephemeral_public_key: base64Url32BytesSchema
|
|
14916
14927
|
}).superRefine((value, context) => validateEnvelopeAad(value, context, false));
|
|
@@ -14920,6 +14931,7 @@ var init_external_inference_contract = __esm({
|
|
|
14920
14931
|
}).superRefine((value, context) => validateEnvelopeAad(value, context, false));
|
|
14921
14932
|
sealedCandidateEnvelopeSchema = external_exports.strictObject({
|
|
14922
14933
|
...commonEnvelopeShape,
|
|
14934
|
+
schema_version: external_exports.literal(EXTERNAL_INFERENCE_ENVELOPE_SCHEMA_VERSION),
|
|
14923
14935
|
direction: external_exports.literal("candidate")
|
|
14924
14936
|
}).superRefine((value, context) => validateEnvelopeAad(value, context, true));
|
|
14925
14937
|
sealedEnvelopeSchema = external_exports.discriminatedUnion("direction", [
|
|
@@ -23907,6 +23919,7 @@ var init_codex_adapter = __esm({
|
|
|
23907
23919
|
}
|
|
23908
23920
|
if (error48 instanceof CodexAppServerError) {
|
|
23909
23921
|
const dispatchOutcome = error48.code === "server_account_context_expired_before_provider_dispatch" ? "not_dispatched" : error48.dispatchOutcome === "not_dispatched" ? currentDispatchOutcome : error48.dispatchOutcome;
|
|
23922
|
+
input.onTerminalDispatchOutcome?.(dispatchOutcome);
|
|
23910
23923
|
if (baseCheckpoint && !completedResult) {
|
|
23911
23924
|
latestCheckpoint = {
|
|
23912
23925
|
...baseCheckpoint,
|
|
@@ -23950,6 +23963,7 @@ var init_codex_adapter = __esm({
|
|
|
23950
23963
|
dispatchOutcome: currentDispatchOutcome,
|
|
23951
23964
|
cause: error48
|
|
23952
23965
|
});
|
|
23966
|
+
input.onTerminalDispatchOutcome?.(classified.dispatchOutcome);
|
|
23953
23967
|
if (baseCheckpoint && !completedResult) {
|
|
23954
23968
|
latestCheckpoint = {
|
|
23955
23969
|
...baseCheckpoint,
|
|
@@ -24704,9 +24718,14 @@ ${input.outputSchemaJson}`
|
|
|
24704
24718
|
terminalStatus: "completed"
|
|
24705
24719
|
};
|
|
24706
24720
|
} catch (error48) {
|
|
24707
|
-
if (error48 instanceof CodexAppServerError)
|
|
24721
|
+
if (error48 instanceof CodexAppServerError) {
|
|
24722
|
+
input.onTerminalDispatchOutcome?.(error48.dispatchOutcome);
|
|
24723
|
+
throw error48;
|
|
24724
|
+
}
|
|
24708
24725
|
const cancelled = input.signal?.aborted === true;
|
|
24709
24726
|
const deadline = Date.now() >= input.deadlineAtMs;
|
|
24727
|
+
const dispatchOutcome = providerReceiptObserved ? "confirmed_dispatched" : dispatchEntered ? "outcome_unknown" : "not_dispatched";
|
|
24728
|
+
input.onTerminalDispatchOutcome?.(dispatchOutcome);
|
|
24710
24729
|
if (dispatchEntered && session) {
|
|
24711
24730
|
await session.abort().catch(() => void 0);
|
|
24712
24731
|
}
|
|
@@ -24715,7 +24734,7 @@ ${input.outputSchemaJson}`
|
|
|
24715
24734
|
category: cancelled ? "cancelled" : deadline ? "timeout" : "adapter",
|
|
24716
24735
|
code: cancelled ? "cancelled" : deadline ? "deadline_exceeded" : "copilot_adapter_failure",
|
|
24717
24736
|
retryable: false,
|
|
24718
|
-
dispatchOutcome
|
|
24737
|
+
dispatchOutcome,
|
|
24719
24738
|
cause: error48
|
|
24720
24739
|
});
|
|
24721
24740
|
} finally {
|
|
@@ -25488,12 +25507,14 @@ ${input.outputSchemaJson}`,
|
|
|
25488
25507
|
} catch (error48) {
|
|
25489
25508
|
const cancelled = input.signal?.aborted === true;
|
|
25490
25509
|
const deadline = !cancelled && boundary.signal.aborted;
|
|
25491
|
-
|
|
25510
|
+
const mapped = mapDeepSeekFailure({
|
|
25492
25511
|
error: error48,
|
|
25493
25512
|
cancelled,
|
|
25494
25513
|
deadline,
|
|
25495
25514
|
dispatchOutcome: proxyDispatchOutcome(proxy)
|
|
25496
25515
|
});
|
|
25516
|
+
input.onTerminalDispatchOutcome?.(mapped.dispatchOutcome);
|
|
25517
|
+
throw mapped;
|
|
25497
25518
|
} finally {
|
|
25498
25519
|
boundary.cleanup();
|
|
25499
25520
|
await proxy.close();
|
|
@@ -25980,6 +26001,7 @@ import {
|
|
|
25980
26001
|
hkdfSync,
|
|
25981
26002
|
randomBytes as randomBytes5
|
|
25982
26003
|
} from "node:crypto";
|
|
26004
|
+
import { gunzipSync } from "node:zlib";
|
|
25983
26005
|
var ENVELOPE_SUITE, JOB_KEY_PAYLOAD_SCHEMA_VERSION, WRAP_HKDF_INFO, PAYLOAD_HKDF_INFO, X25519_PKCS8_PREFIX, X25519_SPKI_PREFIX, ExternalInferenceEnvelopeError, canonicalize, canonicalEnvelopeAadBytes, externalInferenceSha256, decodeCanonicalBase64Url, rawPrivateKey, rawPublicKey, rawPublicBytes, aesGcmDecrypt, aesGcmEncrypt, assertIdentity, validatePlaintext, generateExternalInferenceEnvelopeKeyPair, externalInferenceEnvelopePublicKey, deriveKey, deriveExternalInferencePayloadKey, unwrapExternalInferenceJobKey, decryptExternalInferenceJobInput, decryptExternalInferenceClaim, sealExternalInferenceCandidate;
|
|
25984
26006
|
var init_crypto = __esm({
|
|
25985
26007
|
"lib/inference-host/crypto.ts"() {
|
|
@@ -26172,12 +26194,27 @@ var init_crypto = __esm({
|
|
|
26172
26194
|
);
|
|
26173
26195
|
}
|
|
26174
26196
|
const aadBytes = canonicalEnvelopeAadBytes(envelope.aad);
|
|
26175
|
-
const
|
|
26197
|
+
const encodedPlaintext = aesGcmDecrypt(
|
|
26176
26198
|
deriveExternalInferencePayloadKey(jobKey, envelope.aad),
|
|
26177
26199
|
decodeCanonicalBase64Url(envelope.nonce, "External inference envelope nonce", 12),
|
|
26178
26200
|
decodeCanonicalBase64Url(envelope.ciphertext, "External inference envelope ciphertext"),
|
|
26179
26201
|
aadBytes
|
|
26180
26202
|
);
|
|
26203
|
+
let plaintext;
|
|
26204
|
+
if (envelope.schema_version === EXTERNAL_INFERENCE_COMPRESSED_INPUT_ENVELOPE_SCHEMA_VERSION) {
|
|
26205
|
+
try {
|
|
26206
|
+
plaintext = gunzipSync(encodedPlaintext, {
|
|
26207
|
+
maxOutputLength: envelope.plaintext_bytes
|
|
26208
|
+
});
|
|
26209
|
+
} catch {
|
|
26210
|
+
throw new ExternalInferenceEnvelopeError(
|
|
26211
|
+
"invalid_job_input",
|
|
26212
|
+
"External inference compressed immutable input is invalid."
|
|
26213
|
+
);
|
|
26214
|
+
}
|
|
26215
|
+
} else {
|
|
26216
|
+
plaintext = encodedPlaintext;
|
|
26217
|
+
}
|
|
26181
26218
|
validatePlaintext(plaintext, envelope.plaintext_bytes, envelope.plaintext_sha256);
|
|
26182
26219
|
let rawJob;
|
|
26183
26220
|
try {
|
|
@@ -33308,6 +33345,7 @@ var init_runner = __esm({
|
|
|
33308
33345
|
let stopHostHeartbeatLoop = () => {
|
|
33309
33346
|
};
|
|
33310
33347
|
let hostHeartbeatLoop = Promise.resolve();
|
|
33348
|
+
let providerDispatchWatchdogDrainRequested = false;
|
|
33311
33349
|
const agentAbort = new AbortController();
|
|
33312
33350
|
let agentLoop = Promise.resolve();
|
|
33313
33351
|
let wakeDrain;
|
|
@@ -34107,6 +34145,24 @@ var init_runner = __esm({
|
|
|
34107
34145
|
active_attempts: active.size
|
|
34108
34146
|
});
|
|
34109
34147
|
},
|
|
34148
|
+
onAttemptStage: (stage) => {
|
|
34149
|
+
emitDiagnostic("attempt_stage_changed", {
|
|
34150
|
+
stage,
|
|
34151
|
+
job_id: claim.job_id,
|
|
34152
|
+
attempt_id: attemptId,
|
|
34153
|
+
active_attempts: active.size
|
|
34154
|
+
});
|
|
34155
|
+
},
|
|
34156
|
+
onProviderDispatchWatchdog: (observation) => {
|
|
34157
|
+
providerDispatchWatchdogDrainRequested = true;
|
|
34158
|
+
emitDiagnostic("provider_dispatch_watchdog_expired", {
|
|
34159
|
+
...observation,
|
|
34160
|
+
job_id: claim.job_id,
|
|
34161
|
+
attempt_id: attemptId,
|
|
34162
|
+
active_attempts: active.size
|
|
34163
|
+
});
|
|
34164
|
+
requestDrain("provider_dispatch_watchdog_expired");
|
|
34165
|
+
},
|
|
34110
34166
|
startRetryCount: nextStartRetryCount,
|
|
34111
34167
|
onAttemptStartRetry: (observation) => {
|
|
34112
34168
|
attemptStartRetryCounts.set(attemptId, observation.retry_count);
|
|
@@ -34473,7 +34529,8 @@ var init_runner = __esm({
|
|
|
34473
34529
|
});
|
|
34474
34530
|
});
|
|
34475
34531
|
const shouldRollover = !this.options.once && (settings.maxConcurrency === null || active.size + prepared.length < settings.maxConcurrency);
|
|
34476
|
-
|
|
34532
|
+
pendingClaimPromotions += 1;
|
|
34533
|
+
const batchReceiptDurability = mutateReceipt((current) => {
|
|
34477
34534
|
if (current.pending_claim_request?.claim_request_id !== request.claim_request_id) runnerIdentityMismatch("Batched claim receipt");
|
|
34478
34535
|
const attempts = { ...current.attempts };
|
|
34479
34536
|
for (const attempt of prepared) {
|
|
@@ -34489,6 +34546,8 @@ var init_runner = __esm({
|
|
|
34489
34546
|
updated_at: isoAt(now())
|
|
34490
34547
|
};
|
|
34491
34548
|
return shouldRollover ? preparePendingClaim(promoted) : promoted;
|
|
34549
|
+
}).then(() => void 0).finally(() => {
|
|
34550
|
+
pendingClaimPromotions = Math.max(0, pendingClaimPromotions - 1);
|
|
34492
34551
|
});
|
|
34493
34552
|
for (let index = 0; index < prepared.length; index += 1) {
|
|
34494
34553
|
const item = claim.claims[index];
|
|
@@ -34501,7 +34560,8 @@ var init_runner = __esm({
|
|
|
34501
34560
|
provider_dispatch_freshness_remaining_ms: item.provider_dispatch_freshness_remaining_ms
|
|
34502
34561
|
},
|
|
34503
34562
|
roundTripMs: claimTransportResidualMs,
|
|
34504
|
-
claimResponseReceivedAtMs
|
|
34563
|
+
claimResponseReceivedAtMs,
|
|
34564
|
+
receiptDurability: batchReceiptDurability
|
|
34505
34565
|
});
|
|
34506
34566
|
}
|
|
34507
34567
|
if (this.options.once) requestDrain("once_complete");
|
|
@@ -34545,13 +34605,17 @@ var init_runner = __esm({
|
|
|
34545
34605
|
]);
|
|
34546
34606
|
}
|
|
34547
34607
|
stopHostHeartbeatLoop();
|
|
34548
|
-
|
|
34549
|
-
|
|
34550
|
-
|
|
34551
|
-
|
|
34552
|
-
|
|
34553
|
-
|
|
34554
|
-
|
|
34608
|
+
if (providerDispatchWatchdogDrainRequested) {
|
|
34609
|
+
await settlesWithin(hostHeartbeatLoop, MIN_SLEEP_MS);
|
|
34610
|
+
} else {
|
|
34611
|
+
await hostHeartbeatLoop;
|
|
34612
|
+
await settlesWithin(
|
|
34613
|
+
hostHeartbeat("draining", {
|
|
34614
|
+
deadlineAtMs: now() + settings.drainTimeoutMs,
|
|
34615
|
+
timeoutMs: settings.drainTimeoutMs
|
|
34616
|
+
}),
|
|
34617
|
+
settings.drainTimeoutMs
|
|
34618
|
+
);
|
|
34555
34619
|
}
|
|
34556
34620
|
if (active.size > 0) {
|
|
34557
34621
|
let timedOut = false;
|
|
@@ -34589,7 +34653,11 @@ var init_runner = __esm({
|
|
|
34589
34653
|
]);
|
|
34590
34654
|
await settlesWithin(agentCleanup, settings.drainTimeoutMs);
|
|
34591
34655
|
stopHostHeartbeatLoop();
|
|
34592
|
-
|
|
34656
|
+
if (providerDispatchWatchdogDrainRequested) {
|
|
34657
|
+
await settlesWithin(hostHeartbeatLoop, MIN_SLEEP_MS);
|
|
34658
|
+
} else {
|
|
34659
|
+
await hostHeartbeatLoop;
|
|
34660
|
+
}
|
|
34593
34661
|
removeAbortListener();
|
|
34594
34662
|
unregisterSignals();
|
|
34595
34663
|
try {
|
|
@@ -34667,6 +34735,53 @@ var init_runner = __esm({
|
|
|
34667
34735
|
"The persisted same-attempt recovery scope is invalid."
|
|
34668
34736
|
);
|
|
34669
34737
|
}
|
|
34738
|
+
let lastPreProviderStage = "claimed";
|
|
34739
|
+
const reportPreProviderStage = (stage) => {
|
|
34740
|
+
if (lastPreProviderStage === stage && stage !== "claimed") return;
|
|
34741
|
+
lastPreProviderStage = stage;
|
|
34742
|
+
options.onAttemptStage?.(stage);
|
|
34743
|
+
};
|
|
34744
|
+
reportPreProviderStage("claimed");
|
|
34745
|
+
const attemptAbort = new AbortController();
|
|
34746
|
+
const relayAbort = () => attemptAbort.abort();
|
|
34747
|
+
signal.addEventListener("abort", relayAbort, { once: true });
|
|
34748
|
+
if (signal.aborted) attemptAbort.abort();
|
|
34749
|
+
let watchdogArmedAtMs = now();
|
|
34750
|
+
let providerDispatchWatchdog = null;
|
|
34751
|
+
let providerDispatchWatchdogExpired = false;
|
|
34752
|
+
let resolveProviderDispatchWatchdog;
|
|
34753
|
+
const providerDispatchWatchdogSignal = new Promise((resolve6) => {
|
|
34754
|
+
resolveProviderDispatchWatchdog = resolve6;
|
|
34755
|
+
});
|
|
34756
|
+
const clearProviderDispatchWatchdog = () => {
|
|
34757
|
+
if (providerDispatchWatchdog !== null) clearTimeout(providerDispatchWatchdog);
|
|
34758
|
+
providerDispatchWatchdog = null;
|
|
34759
|
+
};
|
|
34760
|
+
const armProviderDispatchWatchdog = (deadlineAtMs) => {
|
|
34761
|
+
clearProviderDispatchWatchdog();
|
|
34762
|
+
if (deadlineAtMs === void 0 || attemptReceipt.phase === "dispatched" || attemptAbort.signal.aborted) return;
|
|
34763
|
+
watchdogArmedAtMs = now();
|
|
34764
|
+
providerDispatchWatchdog = setTimeout(() => {
|
|
34765
|
+
providerDispatchWatchdog = null;
|
|
34766
|
+
if (providerDispatchedAt !== null || attemptAbort.signal.aborted) return;
|
|
34767
|
+
providerDispatchWatchdogExpired = true;
|
|
34768
|
+
options.onProviderDispatchWatchdog?.({
|
|
34769
|
+
last_stage: lastPreProviderStage,
|
|
34770
|
+
elapsed_ms: Math.max(0, now() - watchdogArmedAtMs),
|
|
34771
|
+
remaining_ms: Math.max(0, deadlineAtMs - now())
|
|
34772
|
+
});
|
|
34773
|
+
resolveProviderDispatchWatchdog();
|
|
34774
|
+
attemptAbort.abort();
|
|
34775
|
+
}, Math.max(MIN_SLEEP_MS, deadlineAtMs - now()));
|
|
34776
|
+
};
|
|
34777
|
+
const awaitPreProviderDurability = async (operation) => Promise.race([
|
|
34778
|
+
operation,
|
|
34779
|
+
providerDispatchWatchdogSignal.then(() => {
|
|
34780
|
+
throw new InferenceHostRecoveryRequiredError(
|
|
34781
|
+
"Provider dispatch stopped because its durable receipt missed the freshness deadline."
|
|
34782
|
+
);
|
|
34783
|
+
})
|
|
34784
|
+
]);
|
|
34670
34785
|
const persistAttempt = async (changes, clearPendingClaim = false) => {
|
|
34671
34786
|
const nextAttemptReceipt = validateAttemptReceipt({
|
|
34672
34787
|
...attemptReceipt,
|
|
@@ -34733,6 +34848,84 @@ var init_runner = __esm({
|
|
|
34733
34848
|
});
|
|
34734
34849
|
options.onClaimPersisted?.();
|
|
34735
34850
|
};
|
|
34851
|
+
const terminalizeProviderDispatchWatchdog = async () => {
|
|
34852
|
+
const failureCode = "server_account_context_expired_before_provider_dispatch";
|
|
34853
|
+
const failure = {
|
|
34854
|
+
category: "timeout",
|
|
34855
|
+
code: failureCode,
|
|
34856
|
+
retryable: false,
|
|
34857
|
+
dispatchOutcome: "not_dispatched",
|
|
34858
|
+
effectiveModel: null,
|
|
34859
|
+
effectiveEffort: null
|
|
34860
|
+
};
|
|
34861
|
+
const failureId = stableOperationId("failure", [
|
|
34862
|
+
claim.job_id,
|
|
34863
|
+
attemptId,
|
|
34864
|
+
failure.dispatchOutcome,
|
|
34865
|
+
failure.category,
|
|
34866
|
+
failure.code
|
|
34867
|
+
]);
|
|
34868
|
+
const failureRequest = jobFailRequestSchema.parse({
|
|
34869
|
+
schema_version: "external_inference_job_fail_v1",
|
|
34870
|
+
contract_version: EXTERNAL_INFERENCE_CONTRACT_VERSION,
|
|
34871
|
+
job_id: claim.job_id,
|
|
34872
|
+
host_id: claim.host_id,
|
|
34873
|
+
host_generation: claim.host_generation,
|
|
34874
|
+
advertisement_generation: claim.advertisement_generation,
|
|
34875
|
+
key_generation: claim.key_generation,
|
|
34876
|
+
claim_generation: claim.claim_generation,
|
|
34877
|
+
controller_generation: claim.controller_generation,
|
|
34878
|
+
claim_handle: claim.claim_handle,
|
|
34879
|
+
attempt_id: attemptId,
|
|
34880
|
+
failure_id: failureId,
|
|
34881
|
+
response_mode: claim.response_mode,
|
|
34882
|
+
output_schema_version: claim.output_schema_version,
|
|
34883
|
+
attempt_status: "failed_no_response",
|
|
34884
|
+
outcome: {
|
|
34885
|
+
dispatch_outcome: failure.dispatchOutcome,
|
|
34886
|
+
response_outcome: "none"
|
|
34887
|
+
},
|
|
34888
|
+
model: {
|
|
34889
|
+
requested_model: claim.requested_model,
|
|
34890
|
+
requested_reasoning_effort: claim.requested_reasoning_effort,
|
|
34891
|
+
effective_model: null,
|
|
34892
|
+
effective_reasoning_effort: null,
|
|
34893
|
+
adapter_request_id: null,
|
|
34894
|
+
adapter_response_id: null
|
|
34895
|
+
},
|
|
34896
|
+
usage: null,
|
|
34897
|
+
failure_category: failure.category,
|
|
34898
|
+
failure_code: failure.code,
|
|
34899
|
+
retryable: failure.retryable,
|
|
34900
|
+
provider_dispatch_freshness_remaining_ms: 0,
|
|
34901
|
+
membership_disposition: membershipFailureDisposition(failure),
|
|
34902
|
+
failed_at: isoAt(now())
|
|
34903
|
+
});
|
|
34904
|
+
void persistAttempt({
|
|
34905
|
+
phase: "terminal_pending",
|
|
34906
|
+
dispatch_outcome: "not_dispatched",
|
|
34907
|
+
terminal_operation_id: failureId,
|
|
34908
|
+
terminal_request: failureRequest
|
|
34909
|
+
}).catch(() => void 0);
|
|
34910
|
+
const evidenceDeadlineAtMs = Date.parse(jobInput.evidence_expires_at);
|
|
34911
|
+
const failureResult = await retryExact(() => mcp.callTool(
|
|
34912
|
+
"inference.job.fail",
|
|
34913
|
+
failureRequest,
|
|
34914
|
+
{ signal, deadlineAtMs: evidenceDeadlineAtMs }
|
|
34915
|
+
), { signal, deadlineAtMs: evidenceDeadlineAtMs });
|
|
34916
|
+
assertTerminalResult(failureRequest, failureResult);
|
|
34917
|
+
options.onAttemptOutcome?.({
|
|
34918
|
+
outcome: "failed",
|
|
34919
|
+
failure_category: failureRequest.failure_category,
|
|
34920
|
+
failure_code: failureRequest.failure_code,
|
|
34921
|
+
retryable: failureRequest.retryable,
|
|
34922
|
+
dispatch_outcome: failureRequest.outcome.dispatch_outcome,
|
|
34923
|
+
response_outcome: failureRequest.outcome.response_outcome,
|
|
34924
|
+
latency_ms: null,
|
|
34925
|
+
usage: null
|
|
34926
|
+
});
|
|
34927
|
+
return "failed";
|
|
34928
|
+
};
|
|
34736
34929
|
let outputContract = null;
|
|
34737
34930
|
let inputValidationError;
|
|
34738
34931
|
try {
|
|
@@ -34741,121 +34934,150 @@ var init_runner = __esm({
|
|
|
34741
34934
|
} catch (error48) {
|
|
34742
34935
|
inputValidationError = error48;
|
|
34743
34936
|
}
|
|
34744
|
-
|
|
34745
|
-
|
|
34746
|
-
|
|
34747
|
-
|
|
34748
|
-
|
|
34749
|
-
|
|
34750
|
-
|
|
34751
|
-
|
|
34752
|
-
|
|
34753
|
-
|
|
34754
|
-
|
|
34755
|
-
|
|
34756
|
-
|
|
34757
|
-
|
|
34758
|
-
|
|
34759
|
-
|
|
34760
|
-
|
|
34761
|
-
|
|
34762
|
-
|
|
34763
|
-
|
|
34764
|
-
|
|
34765
|
-
|
|
34766
|
-
|
|
34767
|
-
startCallCompletedAtMs = now();
|
|
34768
|
-
return result2;
|
|
34769
|
-
});
|
|
34770
|
-
const [startOutcome, claimPromotionOutcome] = await Promise.allSettled([
|
|
34771
|
-
startCallPromise,
|
|
34772
|
-
claimPromotionPromise
|
|
34773
|
-
]);
|
|
34774
|
-
if (claimPromotionOutcome.status === "rejected") {
|
|
34775
|
-
throw claimPromotionOutcome.reason;
|
|
34776
|
-
}
|
|
34777
|
-
if (startOutcome.status === "rejected") {
|
|
34778
|
-
const error48 = startOutcome.reason;
|
|
34779
|
-
if (error48 instanceof ExternalInferenceMcpError && error48.serverFailureCode === "server_account_context_expired_before_provider_dispatch") {
|
|
34780
|
-
await removeAttempt();
|
|
34781
|
-
options.onAttemptOutcome?.({
|
|
34782
|
-
outcome: "freshness_rejected_before_provider_dispatch",
|
|
34783
|
-
failure_category: "freshness",
|
|
34784
|
-
failure_code: error48.serverFailureCode,
|
|
34785
|
-
dispatch_outcome: "not_dispatched"
|
|
34786
|
-
});
|
|
34787
|
-
return "failed";
|
|
34788
|
-
}
|
|
34789
|
-
if (attemptDeadlineAtMs <= now() + MIN_CLAIM_START_WINDOW_MS) {
|
|
34790
|
-
await removeAttempt();
|
|
34791
|
-
return "failed";
|
|
34937
|
+
try {
|
|
34938
|
+
if (attemptReceipt.phase === "claimed") {
|
|
34939
|
+
const attemptDeadlineAtMs = Math.min(
|
|
34940
|
+
Date.parse(claim.deadline_at),
|
|
34941
|
+
Date.parse(claim.lease_expires_at)
|
|
34942
|
+
);
|
|
34943
|
+
if (attemptDeadlineAtMs <= now() + MIN_CLAIM_START_WINDOW_MS) {
|
|
34944
|
+
await removeAttempt();
|
|
34945
|
+
clearProviderDispatchWatchdog();
|
|
34946
|
+
signal.removeEventListener("abort", relayAbort);
|
|
34947
|
+
return "failed";
|
|
34948
|
+
}
|
|
34949
|
+
const startCallStartedAtMs = now();
|
|
34950
|
+
let startCallCompletedAtMs = startCallStartedAtMs;
|
|
34951
|
+
const acceptStartResult = (result2, freshnessAnchorAtMs, roundTripMs) => {
|
|
34952
|
+
assertStartResult(startRequest, result2);
|
|
34953
|
+
if (serverProviderDispatchDeadlineMs === void 0) return;
|
|
34954
|
+
const serverRemaining = result2.provider_dispatch_freshness_remaining_ms;
|
|
34955
|
+
if (!Number.isSafeInteger(serverRemaining) || Number(serverRemaining) < 0) {
|
|
34956
|
+
throw new InferenceHostRunnerError(
|
|
34957
|
+
"provider_dispatch_freshness_receipt_invalid",
|
|
34958
|
+
"The Server provider-dispatch freshness receipt is unavailable."
|
|
34959
|
+
);
|
|
34792
34960
|
}
|
|
34793
|
-
|
|
34794
|
-
|
|
34795
|
-
const
|
|
34796
|
-
|
|
34797
|
-
|
|
34961
|
+
startRoundTripMs = Math.max(0, roundTripMs);
|
|
34962
|
+
serverReportedFreshnessRemainingMs = Number(serverRemaining);
|
|
34963
|
+
const conservativeRemainingMs = Math.max(
|
|
34964
|
+
0,
|
|
34965
|
+
serverReportedFreshnessRemainingMs - startRoundTripMs
|
|
34798
34966
|
);
|
|
34799
|
-
|
|
34800
|
-
|
|
34801
|
-
|
|
34967
|
+
providerDispatchNotAfterMs = freshnessAnchorAtMs + conservativeRemainingMs;
|
|
34968
|
+
armProviderDispatchWatchdog(providerDispatchNotAfterMs);
|
|
34969
|
+
};
|
|
34970
|
+
if (options.prestarted) {
|
|
34971
|
+
startCallCompletedAtMs = now();
|
|
34972
|
+
acceptStartResult(
|
|
34973
|
+
options.prestarted.result,
|
|
34974
|
+
options.prestarted.claimResponseReceivedAtMs,
|
|
34975
|
+
options.prestarted.roundTripMs
|
|
34802
34976
|
);
|
|
34803
|
-
|
|
34804
|
-
|
|
34805
|
-
|
|
34977
|
+
if (options.prestarted.receiptDurability) {
|
|
34978
|
+
reportPreProviderStage("receipt_persistence");
|
|
34979
|
+
await awaitPreProviderDurability(options.prestarted.receiptDurability);
|
|
34980
|
+
}
|
|
34981
|
+
} else {
|
|
34982
|
+
reportPreProviderStage("receipt_persistence");
|
|
34983
|
+
const claimPromotionPromise = options.resumeReceipt ? Promise.resolve() : awaitPreProviderDurability(
|
|
34984
|
+
persistAttempt({ phase: "claimed" }, true)
|
|
34806
34985
|
);
|
|
34807
|
-
const
|
|
34808
|
-
|
|
34809
|
-
|
|
34810
|
-
|
|
34811
|
-
|
|
34812
|
-
|
|
34813
|
-
|
|
34814
|
-
|
|
34815
|
-
|
|
34816
|
-
|
|
34817
|
-
|
|
34818
|
-
|
|
34986
|
+
const startCallPromise = retryExact(() => mcp.callTool(
|
|
34987
|
+
"inference.job.start",
|
|
34988
|
+
startRequest,
|
|
34989
|
+
{ signal, deadlineAtMs: attemptDeadlineAtMs }
|
|
34990
|
+
), { signal, deadlineAtMs: attemptDeadlineAtMs }).then((result2) => {
|
|
34991
|
+
startCallCompletedAtMs = now();
|
|
34992
|
+
acceptStartResult(
|
|
34993
|
+
result2,
|
|
34994
|
+
startCallCompletedAtMs,
|
|
34995
|
+
startCallCompletedAtMs - startCallStartedAtMs
|
|
34996
|
+
);
|
|
34997
|
+
return result2;
|
|
34819
34998
|
});
|
|
34820
|
-
await
|
|
34821
|
-
|
|
34999
|
+
const [startOutcome, claimPromotionOutcome] = await Promise.allSettled([
|
|
35000
|
+
startCallPromise,
|
|
35001
|
+
claimPromotionPromise
|
|
35002
|
+
]);
|
|
35003
|
+
if (claimPromotionOutcome.status === "rejected") {
|
|
35004
|
+
throw claimPromotionOutcome.reason;
|
|
35005
|
+
}
|
|
35006
|
+
if (startOutcome.status === "rejected") {
|
|
35007
|
+
const error48 = startOutcome.reason;
|
|
35008
|
+
if (error48 instanceof ExternalInferenceMcpError && error48.serverFailureCode === "server_account_context_expired_before_provider_dispatch") {
|
|
35009
|
+
await removeAttempt();
|
|
35010
|
+
options.onAttemptOutcome?.({
|
|
35011
|
+
outcome: "freshness_rejected_before_provider_dispatch",
|
|
35012
|
+
failure_category: "freshness",
|
|
35013
|
+
failure_code: error48.serverFailureCode,
|
|
35014
|
+
dispatch_outcome: "not_dispatched"
|
|
35015
|
+
});
|
|
35016
|
+
clearProviderDispatchWatchdog();
|
|
35017
|
+
signal.removeEventListener("abort", relayAbort);
|
|
35018
|
+
return "failed";
|
|
35019
|
+
}
|
|
35020
|
+
if (attemptDeadlineAtMs <= now() + MIN_CLAIM_START_WINDOW_MS) {
|
|
35021
|
+
await removeAttempt();
|
|
35022
|
+
clearProviderDispatchWatchdog();
|
|
35023
|
+
signal.removeEventListener("abort", relayAbort);
|
|
35024
|
+
return "failed";
|
|
35025
|
+
}
|
|
35026
|
+
if (signal.aborted) throw error48;
|
|
35027
|
+
if (controlPlaneFatal(error48)) throw error48;
|
|
35028
|
+
const remainingMs = Math.max(
|
|
35029
|
+
MIN_SLEEP_MS,
|
|
35030
|
+
attemptDeadlineAtMs - now() - MIN_CLAIM_START_WINDOW_MS
|
|
35031
|
+
);
|
|
35032
|
+
const retryCount = Math.min(
|
|
35033
|
+
Math.max(1, options.startRetryCount),
|
|
35034
|
+
Number.MAX_SAFE_INTEGER
|
|
35035
|
+
);
|
|
35036
|
+
const retryDelayMs = Math.min(
|
|
35037
|
+
remoteRetryAfterMs(error48, attemptStartRetryFallbackMs(retryCount)),
|
|
35038
|
+
remainingMs
|
|
35039
|
+
);
|
|
35040
|
+
const rawErrorCode = error48 && typeof error48 === "object" && "code" in error48 ? String(error48.code) : "start_acknowledgement_failed";
|
|
35041
|
+
options.onAttemptStartRetry?.({
|
|
35042
|
+
failure_stage: "job_start_acknowledgement",
|
|
35043
|
+
error_code: safeFailureCode(rawErrorCode, "start_acknowledgement_failed"),
|
|
35044
|
+
http_status_code: error48 instanceof ExternalInferenceMcpError ? error48.httpStatusCode : null,
|
|
35045
|
+
retryable: retryableRemoteError(error48),
|
|
35046
|
+
definitively_not_applied: Boolean(
|
|
35047
|
+
error48 && typeof error48 === "object" && "definitivelyNotApplied" in error48 && error48.definitivelyNotApplied === true
|
|
35048
|
+
),
|
|
35049
|
+
retry_after_ms: error48 instanceof ExternalInferenceMcpError ? error48.retryAfterMs : null,
|
|
35050
|
+
retry_count: retryCount,
|
|
35051
|
+
next_delay_ms: retryDelayMs
|
|
35052
|
+
});
|
|
35053
|
+
await options.sleep(retryDelayMs, signal);
|
|
35054
|
+
clearProviderDispatchWatchdog();
|
|
35055
|
+
signal.removeEventListener("abort", relayAbort);
|
|
35056
|
+
return "retry_claimed";
|
|
35057
|
+
}
|
|
34822
35058
|
}
|
|
34823
|
-
startResult = startOutcome.value;
|
|
34824
35059
|
}
|
|
34825
|
-
|
|
34826
|
-
|
|
34827
|
-
|
|
34828
|
-
|
|
34829
|
-
|
|
34830
|
-
"
|
|
34831
|
-
|
|
34832
|
-
)
|
|
34833
|
-
}
|
|
34834
|
-
if (!options.prestarted) {
|
|
34835
|
-
startRoundTripMs = Math.max(0, startCallCompletedAtMs - startCallStartedAtMs);
|
|
34836
|
-
}
|
|
34837
|
-
serverReportedFreshnessRemainingMs = Number(serverRemaining);
|
|
34838
|
-
const conservativeRemainingMs = Math.max(
|
|
34839
|
-
0,
|
|
34840
|
-
serverReportedFreshnessRemainingMs - startRoundTripMs
|
|
35060
|
+
if (attemptReceipt.phase !== "dispatched") {
|
|
35061
|
+
const providerDispatchable = inputValidationError === void 0 && outputContract !== null;
|
|
35062
|
+
reportPreProviderStage("receipt_persistence");
|
|
35063
|
+
await awaitPreProviderDurability(
|
|
35064
|
+
persistAttempt({
|
|
35065
|
+
phase: providerDispatchable ? "dispatched" : "started",
|
|
35066
|
+
dispatch_outcome: providerDispatchable ? "outcome_unknown" : "not_dispatched"
|
|
35067
|
+
})
|
|
34841
35068
|
);
|
|
34842
|
-
const freshnessAnchorAtMs = options.prestarted ? options.prestarted.claimResponseReceivedAtMs : startCallCompletedAtMs;
|
|
34843
|
-
providerDispatchNotAfterMs = freshnessAnchorAtMs + conservativeRemainingMs;
|
|
34844
35069
|
}
|
|
34845
|
-
|
|
34846
|
-
|
|
34847
|
-
|
|
34848
|
-
|
|
34849
|
-
|
|
34850
|
-
|
|
34851
|
-
}
|
|
35070
|
+
reportPreProviderStage("thread_setup");
|
|
35071
|
+
} catch (error48) {
|
|
35072
|
+
clearProviderDispatchWatchdog();
|
|
35073
|
+
signal.removeEventListener("abort", relayAbort);
|
|
35074
|
+
if (providerDispatchWatchdogExpired) {
|
|
35075
|
+
return terminalizeProviderDispatchWatchdog();
|
|
35076
|
+
}
|
|
35077
|
+
throw error48;
|
|
34852
35078
|
}
|
|
34853
35079
|
let adapterResult;
|
|
34854
35080
|
let heartbeatFailure;
|
|
34855
|
-
const attemptAbort = new AbortController();
|
|
34856
|
-
const relayAbort = () => attemptAbort.abort();
|
|
34857
|
-
signal.addEventListener("abort", relayAbort, { once: true });
|
|
34858
|
-
if (signal.aborted) attemptAbort.abort();
|
|
34859
35081
|
let heartbeatStopped = false;
|
|
34860
35082
|
const heartbeatLoop = (async () => {
|
|
34861
35083
|
while (!heartbeatStopped && !attemptAbort.signal.aborted) {
|
|
@@ -34931,7 +35153,12 @@ var init_runner = __esm({
|
|
|
34931
35153
|
dispatchOutcome: "outcome_unknown"
|
|
34932
35154
|
});
|
|
34933
35155
|
}
|
|
34934
|
-
|
|
35156
|
+
let resolveTerminalDispatchOutcome;
|
|
35157
|
+
const terminalDispatchOutcomeSignal = new Promise((resolve6) => {
|
|
35158
|
+
resolveTerminalDispatchOutcome = resolve6;
|
|
35159
|
+
});
|
|
35160
|
+
let terminalDispatchOutcomeObserved = false;
|
|
35161
|
+
const adapterAttempt = this.dependencies.codexAdapter.runAttempt({
|
|
34935
35162
|
attemptId,
|
|
34936
35163
|
inputSha256: jobInput.input_sha256,
|
|
34937
35164
|
systemPrompt: jobInput.system_prompt,
|
|
@@ -34944,6 +35171,8 @@ var init_runner = __esm({
|
|
|
34944
35171
|
onProviderDispatch: () => {
|
|
34945
35172
|
const dispatchedAtMs = now();
|
|
34946
35173
|
providerDispatchedAt ??= isoAt(dispatchedAtMs);
|
|
35174
|
+
clearProviderDispatchWatchdog();
|
|
35175
|
+
options.onAttemptStage?.("provider_dispatched");
|
|
34947
35176
|
if (providerDispatchNotAfterMs === void 0) return;
|
|
34948
35177
|
providerDispatchFreshnessRemainingMs = Math.max(
|
|
34949
35178
|
0,
|
|
@@ -34956,8 +35185,49 @@ var init_runner = __esm({
|
|
|
34956
35185
|
start_round_trip_ms: startRoundTripMs
|
|
34957
35186
|
});
|
|
34958
35187
|
},
|
|
35188
|
+
onTerminalDispatchOutcome: (outcome) => {
|
|
35189
|
+
if (terminalDispatchOutcomeObserved) return;
|
|
35190
|
+
terminalDispatchOutcomeObserved = true;
|
|
35191
|
+
resolveTerminalDispatchOutcome(outcome);
|
|
35192
|
+
},
|
|
34959
35193
|
signal: attemptAbort.signal
|
|
34960
35194
|
});
|
|
35195
|
+
adapterResult = await Promise.race([
|
|
35196
|
+
adapterAttempt,
|
|
35197
|
+
providerDispatchWatchdogSignal.then(async () => {
|
|
35198
|
+
const classified = await Promise.race([
|
|
35199
|
+
adapterAttempt.then(
|
|
35200
|
+
(result2) => ({ kind: "result", result: result2 }),
|
|
35201
|
+
(error48) => ({ kind: "error", error: error48 })
|
|
35202
|
+
),
|
|
35203
|
+
terminalDispatchOutcomeSignal.then((outcome) => ({
|
|
35204
|
+
kind: "dispatch_outcome",
|
|
35205
|
+
outcome
|
|
35206
|
+
})),
|
|
35207
|
+
options.sleep(options.attemptHeartbeatMs).then(() => ({
|
|
35208
|
+
kind: "unsettled"
|
|
35209
|
+
}))
|
|
35210
|
+
]);
|
|
35211
|
+
if (classified.kind === "result") return classified.result;
|
|
35212
|
+
if (classified.kind === "error") throw classified.error;
|
|
35213
|
+
if (classified.kind === "dispatch_outcome" && classified.outcome === "not_dispatched") {
|
|
35214
|
+
throw new CodexAppServerError({
|
|
35215
|
+
message: "The Server account context expired before provider dispatch.",
|
|
35216
|
+
category: "timeout",
|
|
35217
|
+
code: "server_account_context_expired_before_provider_dispatch",
|
|
35218
|
+
retryable: false,
|
|
35219
|
+
dispatchOutcome: "not_dispatched"
|
|
35220
|
+
});
|
|
35221
|
+
}
|
|
35222
|
+
throw new CodexAppServerError({
|
|
35223
|
+
message: "Provider dispatch could not be excluded after the freshness watchdog expired.",
|
|
35224
|
+
category: "timeout",
|
|
35225
|
+
code: "provider_dispatch_outcome_unknown",
|
|
35226
|
+
retryable: false,
|
|
35227
|
+
dispatchOutcome: classified.kind === "dispatch_outcome" ? classified.outcome : "outcome_unknown"
|
|
35228
|
+
});
|
|
35229
|
+
})
|
|
35230
|
+
]);
|
|
34961
35231
|
adapterResultReadyAt = isoAt(now());
|
|
34962
35232
|
await persistAttempt({
|
|
34963
35233
|
phase: "dispatched",
|
|
@@ -35142,8 +35412,15 @@ var init_runner = __esm({
|
|
|
35142
35412
|
rateLimits: error48.rateLimits
|
|
35143
35413
|
});
|
|
35144
35414
|
}
|
|
35145
|
-
const
|
|
35146
|
-
|
|
35415
|
+
const effectiveError = providerDispatchWatchdogExpired && error48 instanceof CodexAppServerError && error48.dispatchOutcome === "not_dispatched" ? new CodexAppServerError({
|
|
35416
|
+
message: "The Server account context expired before provider dispatch.",
|
|
35417
|
+
category: "timeout",
|
|
35418
|
+
code: "server_account_context_expired_before_provider_dispatch",
|
|
35419
|
+
retryable: false,
|
|
35420
|
+
dispatchOutcome: "not_dispatched"
|
|
35421
|
+
}) : error48;
|
|
35422
|
+
const classified = classifyFailure(heartbeatFailure ?? effectiveError, adapterResult);
|
|
35423
|
+
const processExit = heartbeatFailure === void 0 && effectiveError instanceof CodexAppServerError && effectiveError.code === "codex_process_closed" && effectiveError.processExit?.expected_shutdown === false ? effectiveError.processExit : null;
|
|
35147
35424
|
const heartbeatAmbiguous = ambiguousHeartbeatTransport(heartbeatFailure);
|
|
35148
35425
|
const failure = heartbeatAmbiguous ? {
|
|
35149
35426
|
...classified,
|
|
@@ -35152,7 +35429,7 @@ var init_runner = __esm({
|
|
|
35152
35429
|
effectiveModel: adapterResult?.effectiveModel ?? classified.effectiveModel,
|
|
35153
35430
|
effectiveEffort: adapterResult?.effectiveReasoningEffort ?? classified.effectiveEffort
|
|
35154
35431
|
} : classified;
|
|
35155
|
-
const dispatchOutcome = heartbeatAmbiguous ? "outcome_unknown" :
|
|
35432
|
+
const dispatchOutcome = heartbeatAmbiguous ? "outcome_unknown" : effectiveError instanceof CodexAppServerError ? effectiveError.dispatchOutcome : failure.dispatchOutcome;
|
|
35156
35433
|
await persistAttempt({
|
|
35157
35434
|
phase: dispatchOutcome === "not_dispatched" ? "started" : "dispatched",
|
|
35158
35435
|
dispatch_outcome: dispatchOutcome
|
|
@@ -35193,7 +35470,7 @@ var init_runner = __esm({
|
|
|
35193
35470
|
adapter_request_id: canReportEffective ? adapterResult?.adapterRequestId ?? null : null,
|
|
35194
35471
|
adapter_response_id: canReportEffective ? adapterResult?.adapterResponseId ?? null : null
|
|
35195
35472
|
},
|
|
35196
|
-
usage: adapterResult ? reportedUsage(adapterResult, usageSource) :
|
|
35473
|
+
usage: adapterResult ? reportedUsage(adapterResult, usageSource) : effectiveError instanceof CodexAppServerError && effectiveError.usage ? reportedTokenUsage(effectiveError.usage, usageSource) : null,
|
|
35197
35474
|
failure_category: failure.category,
|
|
35198
35475
|
failure_code: failure.code,
|
|
35199
35476
|
retryable: failure.retryable,
|
|
@@ -35243,6 +35520,7 @@ var init_runner = __esm({
|
|
|
35243
35520
|
});
|
|
35244
35521
|
return "failed";
|
|
35245
35522
|
} finally {
|
|
35523
|
+
clearProviderDispatchWatchdog();
|
|
35246
35524
|
signal.removeEventListener("abort", relayAbort);
|
|
35247
35525
|
await stopHeartbeat();
|
|
35248
35526
|
}
|
|
@@ -43377,7 +43655,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
43377
43655
|
}
|
|
43378
43656
|
};
|
|
43379
43657
|
}
|
|
43380
|
-
if (cached2 && now - cached2.fetchedAtMs <= staleIf429MaxAgeMs && hasActiveInfoRateLimitCooldown(apiUrl, ["userFills"], now)) {
|
|
43658
|
+
if (!input.forceRefresh && cached2 && now - cached2.fetchedAtMs <= staleIf429MaxAgeMs && hasActiveInfoRateLimitCooldown(apiUrl, ["userFills"], now)) {
|
|
43381
43659
|
const scopedFills = filterFillsBySymbols(cached2.rawFills, input.symbols);
|
|
43382
43660
|
const tradeHistory2 = scopedFills.map(normalizeBrowserFillToTradeHistory).filter((fill) => fill !== null);
|
|
43383
43661
|
return {
|
|
@@ -43437,7 +43715,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
43437
43715
|
} catch (error48) {
|
|
43438
43716
|
recordInfoRateLimitCooldownFromError(apiUrl, error48, staleIf429MaxAgeMs);
|
|
43439
43717
|
const staleCache = readBrowserUserFillsCache(cacheKey);
|
|
43440
|
-
if (isRateLimitError(error48)) {
|
|
43718
|
+
if (isRateLimitError(error48) && !input.forceRefresh) {
|
|
43441
43719
|
evidenceSource = "stale_if_429";
|
|
43442
43720
|
rawWalletFills = staleCache && Date.now() - staleCache.fetchedAtMs <= staleIf429MaxAgeMs ? staleCache.rawFills : [];
|
|
43443
43721
|
providerRowCount = staleCache?.providerRowCount ?? 0;
|