@vtxmacro/cli 2026.10.24 → 2026.10.26
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-mcp.js +1 -1
- package/bin/vtx-service-bootstrap.js +20 -1
- package/bin/vtx.js +260 -14
- package/package.json +1 -1
package/bin/vtx-mcp.js
CHANGED
|
@@ -37,7 +37,7 @@ var init_define_VTX_PI_MODEL_POLICY = __esm({
|
|
|
37
37
|
var agent_cli_release_default;
|
|
38
38
|
var init_agent_cli_release = __esm({
|
|
39
39
|
"agent-cli-release.json"() {
|
|
40
|
-
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.
|
|
40
|
+
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.26", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
|
|
@@ -14,7 +14,7 @@ import { dirname as dirname4, relative as relative4, resolve as resolve4 } from
|
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
15
|
|
|
16
16
|
// agent-cli-release.json
|
|
17
|
-
var agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.
|
|
17
|
+
var agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.26", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
|
|
18
18
|
|
|
19
19
|
// lib/runtime-policy.generated.json
|
|
20
20
|
var runtime_policy_generated_default = {
|
|
@@ -1405,6 +1405,7 @@ var CANDLE_TIMEFRAME_SECONDS = {
|
|
|
1405
1405
|
};
|
|
1406
1406
|
var AI_COST_ESTIMATE_PERIOD_DAYS = 30;
|
|
1407
1407
|
var SECONDS_PER_AI_COST_ESTIMATE_PERIOD = SECONDS_PER_DAY * AI_COST_ESTIMATE_PERIOD_DAYS;
|
|
1408
|
+
var EXIT_CODE_TEMPFAIL = 75;
|
|
1408
1409
|
var INFERENCE_HOST_PROCESS_LOCK_RECORD_SCHEMA_VERSION = 2;
|
|
1409
1410
|
var INFERENCE_HOST_RECLAIM_GUARD_CREATE_PASSES = 2;
|
|
1410
1411
|
var LINUX_PROC_STAT_COMM_TERMINATOR_CHARS = 2;
|
|
@@ -3103,8 +3104,26 @@ var runInferenceHostServiceBootstrap = async (manifestPathValue, dependencies =
|
|
|
3103
3104
|
live.supervisor = runSupervisor(manifest.executable, supervisorArguments(script, manifestPath));
|
|
3104
3105
|
return live.supervisor;
|
|
3105
3106
|
};
|
|
3107
|
+
const launcherProtocol = dependencies.launcherProtocol ?? process.env.VTX_INFERENCE_HOST_LAUNCHER_PROTOCOL === "1";
|
|
3108
|
+
const handOffToLauncher = async (plan) => {
|
|
3109
|
+
const candidate = { ...plan.candidate, selected_at: now().toISOString() };
|
|
3110
|
+
await atomicWriteSelection(manifestPath, candidate);
|
|
3111
|
+
await rm4(rejectionPathFor(manifestPath), { force: true }).catch(() => void 0);
|
|
3112
|
+
await prunePrivateReleases(manifestPath, [candidate, plan.active]).catch(
|
|
3113
|
+
async () => await appendBootstrapLog(
|
|
3114
|
+
manifest.log_path,
|
|
3115
|
+
"service_release_cleanup_deferred",
|
|
3116
|
+
{ package_version: candidate.package_version }
|
|
3117
|
+
).catch(() => void 0)
|
|
3118
|
+
);
|
|
3119
|
+
await appendBootstrapLog(manifest.log_path, "service_release_handoff", {
|
|
3120
|
+
package_version: candidate.package_version
|
|
3121
|
+
}).catch(() => void 0);
|
|
3122
|
+
return EXIT_CODE_TEMPFAIL;
|
|
3123
|
+
};
|
|
3106
3124
|
let updatePlan = await checkUpdate();
|
|
3107
3125
|
while (await shouldRun()) {
|
|
3126
|
+
if (updatePlan.candidate && launcherProtocol) return await handOffToLauncher(updatePlan);
|
|
3108
3127
|
if (updatePlan.candidate) {
|
|
3109
3128
|
const candidate = { ...updatePlan.candidate, selected_at: now().toISOString() };
|
|
3110
3129
|
await rm4(runtimePathFor(manifestPath), { force: true });
|
package/bin/vtx.js
CHANGED
|
@@ -113,7 +113,7 @@ var init_routing = __esm({
|
|
|
113
113
|
var agent_cli_release_default;
|
|
114
114
|
var init_agent_cli_release = __esm({
|
|
115
115
|
"agent-cli-release.json"() {
|
|
116
|
-
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.
|
|
116
|
+
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.26", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
|
|
@@ -1598,6 +1598,9 @@ var init_constants = __esm({
|
|
|
1598
1598
|
// Tools a Grok tool-validation summary lists before truncating.
|
|
1599
1599
|
max_grok_tool_summaries: 8,
|
|
1600
1600
|
max_recent_failures: 32,
|
|
1601
|
+
// Resolved claim failures one host heartbeat reports; a host that collects
|
|
1602
|
+
// more reports the oldest it dropped as a count.
|
|
1603
|
+
max_heartbeat_claim_failures: 32,
|
|
1601
1604
|
max_status_bindings: 512,
|
|
1602
1605
|
max_validation_error_codes: 128,
|
|
1603
1606
|
max_discarded_fields: 128,
|
|
@@ -21293,7 +21296,7 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
21293
21296
|
});
|
|
21294
21297
|
|
|
21295
21298
|
// lib/external-inference-contract.ts
|
|
21296
|
-
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, PROVIDER_RESET_MAX_MS, MAX_GROK_TOOL_SUMMARIES, STDERR_OBSERVATION_CAP_BYTES, MAX_TURN_DECISION_OPERATION_IDS, SHA256_K, 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, grokToolValidationDiagnosticSchema, grokResponseIdentityDiagnosticSchema, agentTurnReceiptSchema, agentConnectRequestSchema, agentNextRequestSchema, agentHeartbeatRequestSchema, emptyAgentNextResultSchema, claimedAgentNextResultSchema, agentNextResultSchema, agentCompleteRequestSchema, agentFailRequestSchema, requestedModelSelectionSchema, completedModelProvenanceSchema, attemptModelProvenanceSchema, providerWeeklyQuotaReadSchema, hostRuntimeRecoverySchema, 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;
|
|
21299
|
+
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, PROVIDER_RESET_MAX_MS, MAX_GROK_TOOL_SUMMARIES, STDERR_OBSERVATION_CAP_BYTES, MAX_TURN_DECISION_OPERATION_IDS, SHA256_K, 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, grokToolValidationDiagnosticSchema, grokResponseIdentityDiagnosticSchema, agentTurnReceiptSchema, agentConnectRequestSchema, agentNextRequestSchema, agentHeartbeatRequestSchema, emptyAgentNextResultSchema, claimedAgentNextResultSchema, agentNextResultSchema, agentCompleteRequestSchema, agentFailRequestSchema, requestedModelSelectionSchema, completedModelProvenanceSchema, attemptModelProvenanceSchema, providerWeeklyQuotaReadSchema, hostRuntimeRecoverySchema, claimResolutionSchema, httpStatusCodeSchema, hostClaimTransportFailureSchema, hostClaimTransportFailureReportSchema, 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, externalInferenceClaimTransportFailureCountReadSchema, 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;
|
|
21297
21300
|
var init_external_inference_contract = __esm({
|
|
21298
21301
|
"lib/external-inference-contract.ts"() {
|
|
21299
21302
|
"use strict";
|
|
@@ -22270,6 +22273,24 @@ var init_external_inference_contract = __esm({
|
|
|
22270
22273
|
pending_attempts: nonNegativeSafeIntegerSchema,
|
|
22271
22274
|
pending_claim: external_exports.boolean()
|
|
22272
22275
|
});
|
|
22276
|
+
claimResolutionSchema = external_exports.enum(["replayed", "retired", "drained"]);
|
|
22277
|
+
httpStatusCodeSchema = external_exports.number().int().min(HTTP_STATUS_MIN).max(HTTP_STATUS_MAX);
|
|
22278
|
+
hostClaimTransportFailureSchema = external_exports.strictObject({
|
|
22279
|
+
claim_request_id: operationIdentifierSchema,
|
|
22280
|
+
failed_at: timestampSchema,
|
|
22281
|
+
failure_code: safeCodeSchema,
|
|
22282
|
+
http_status_code: httpStatusCodeSchema.nullable(),
|
|
22283
|
+
response_body_bytes: nonNegativeSafeIntegerSchema.nullable(),
|
|
22284
|
+
body_cut: external_exports.boolean(),
|
|
22285
|
+
attempts: positiveSafeIntegerSchema,
|
|
22286
|
+
resolution: claimResolutionSchema,
|
|
22287
|
+
resolved_at: timestampSchema
|
|
22288
|
+
});
|
|
22289
|
+
hostClaimTransportFailureReportSchema = external_exports.strictObject({
|
|
22290
|
+
entries: external_exports.array(hostClaimTransportFailureSchema).min(1).max(EXTERNAL_INFERENCE_LIMITS.max_heartbeat_claim_failures),
|
|
22291
|
+
// Failed requests dropped, oldest first, because the host's buffer was full.
|
|
22292
|
+
dropped: nonNegativeSafeIntegerSchema
|
|
22293
|
+
});
|
|
22273
22294
|
hostHeartbeatRequestSchema = external_exports.strictObject({
|
|
22274
22295
|
schema_version: external_exports.literal("external_inference_host_heartbeat_v1"),
|
|
22275
22296
|
contract_version: external_exports.literal(EXTERNAL_INFERENCE_CONTRACT_VERSION),
|
|
@@ -22283,6 +22304,7 @@ var init_external_inference_contract = __esm({
|
|
|
22283
22304
|
available_slots: nonNegativeSafeIntegerSchema,
|
|
22284
22305
|
provider_weekly_quota: providerWeeklyQuotaReadSchema.nullable().optional(),
|
|
22285
22306
|
runtime_recovery: hostRuntimeRecoverySchema.optional(),
|
|
22307
|
+
claim_transport_failures: hostClaimTransportFailureReportSchema.optional(),
|
|
22286
22308
|
provider_quota_recovery: external_exports.strictObject({
|
|
22287
22309
|
source: external_exports.literal("codex_app_server"),
|
|
22288
22310
|
observed_at: timestampSchema
|
|
@@ -22863,6 +22885,15 @@ var init_external_inference_contract = __esm({
|
|
|
22863
22885
|
count: positiveSafeIntegerSchema,
|
|
22864
22886
|
last_observed_at: timestampSchema
|
|
22865
22887
|
});
|
|
22888
|
+
externalInferenceClaimTransportFailureCountReadSchema = external_exports.strictObject({
|
|
22889
|
+
failure_code: safeCodeSchema,
|
|
22890
|
+
http_status_code: httpStatusCodeSchema.nullable(),
|
|
22891
|
+
body_cut: external_exports.boolean(),
|
|
22892
|
+
resolution: claimResolutionSchema,
|
|
22893
|
+
count: positiveSafeIntegerSchema,
|
|
22894
|
+
attempts: positiveSafeIntegerSchema,
|
|
22895
|
+
last_failed_at: timestampSchema
|
|
22896
|
+
});
|
|
22866
22897
|
externalInferenceHostDiagnosticsReadSchema = external_exports.strictObject({
|
|
22867
22898
|
host_id: identifierSchema,
|
|
22868
22899
|
active_attempts: nonNegativeSafeIntegerSchema,
|
|
@@ -22872,7 +22903,8 @@ var init_external_inference_contract = __esm({
|
|
|
22872
22903
|
last_hour: externalInferenceVolumeWindowReadSchema,
|
|
22873
22904
|
last_day: externalInferenceVolumeWindowReadSchema,
|
|
22874
22905
|
last_week: externalInferenceVolumeWindowReadSchema,
|
|
22875
|
-
recent_failures: external_exports.array(externalInferenceFailureCountReadSchema).max(EXTERNAL_INFERENCE_LIMITS.max_recent_failures)
|
|
22906
|
+
recent_failures: external_exports.array(externalInferenceFailureCountReadSchema).max(EXTERNAL_INFERENCE_LIMITS.max_recent_failures),
|
|
22907
|
+
claim_transport_failures: external_exports.array(externalInferenceClaimTransportFailureCountReadSchema).max(EXTERNAL_INFERENCE_LIMITS.max_recent_failures)
|
|
22876
22908
|
});
|
|
22877
22909
|
externalInferenceProfileActivityReadSchema = external_exports.strictObject({
|
|
22878
22910
|
last_hour: externalInferenceVolumeWindowReadSchema,
|
|
@@ -25758,6 +25790,7 @@ var init_mcp_client = __esm({
|
|
|
25758
25790
|
#providerCreditsSupported = false;
|
|
25759
25791
|
#agentAnalysisDurationSupported = false;
|
|
25760
25792
|
#runtimeRecoveryDiagnosticsSupported = false;
|
|
25793
|
+
#claimTransportFailureReportsSupported = false;
|
|
25761
25794
|
#providerHttpStatusTools = /* @__PURE__ */ new Set();
|
|
25762
25795
|
#grokToolValidationTools = /* @__PURE__ */ new Set();
|
|
25763
25796
|
#grokResponseIdentityTools = /* @__PURE__ */ new Set();
|
|
@@ -25803,6 +25836,9 @@ var init_mcp_client = __esm({
|
|
|
25803
25836
|
supportsRuntimeRecoveryDiagnostics() {
|
|
25804
25837
|
return this.#runtimeRecoveryDiagnosticsSupported;
|
|
25805
25838
|
}
|
|
25839
|
+
supportsClaimTransportFailureReports() {
|
|
25840
|
+
return this.#claimTransportFailureReportsSupported;
|
|
25841
|
+
}
|
|
25806
25842
|
supportsAgentAnalysisDuration() {
|
|
25807
25843
|
return this.#agentAnalysisDurationSupported;
|
|
25808
25844
|
}
|
|
@@ -25876,6 +25912,10 @@ var init_mcp_client = __esm({
|
|
|
25876
25912
|
"inference.host.heartbeat",
|
|
25877
25913
|
["runtime_recovery"]
|
|
25878
25914
|
);
|
|
25915
|
+
this.#claimTransportFailureReportsSupported = advertisesFields(
|
|
25916
|
+
"inference.host.heartbeat",
|
|
25917
|
+
["claim_transport_failures"]
|
|
25918
|
+
);
|
|
25879
25919
|
this.#providerQuotaRecoverySupported = advertisesFields(
|
|
25880
25920
|
"inference.host.heartbeat",
|
|
25881
25921
|
["provider_quota_recovery"]
|
|
@@ -36351,6 +36391,24 @@ var init_runner = __esm({
|
|
|
36351
36391
|
let drainReason = "stopped";
|
|
36352
36392
|
let terminalRecoveryFailureCode = null;
|
|
36353
36393
|
let acknowledgedRecoveryDiagnostic = null;
|
|
36394
|
+
const claimFailures = [];
|
|
36395
|
+
let claimFailuresDropped = 0;
|
|
36396
|
+
const boundClaimFailures = () => {
|
|
36397
|
+
while (claimFailures.length > EXTERNAL_INFERENCE_LIMITS.max_heartbeat_claim_failures) {
|
|
36398
|
+
const resolved = claimFailures.findIndex((record5) => record5.resolution !== void 0);
|
|
36399
|
+
claimFailures.splice(resolved >= 0 ? resolved : 0, 1);
|
|
36400
|
+
claimFailuresDropped += 1;
|
|
36401
|
+
}
|
|
36402
|
+
};
|
|
36403
|
+
const resolveClaimFailures = (resolution, unresolved) => {
|
|
36404
|
+
for (const record5 of claimFailures) {
|
|
36405
|
+
if (record5.resolution === void 0 && unresolved(record5)) {
|
|
36406
|
+
record5.resolution = resolution;
|
|
36407
|
+
record5.resolved_at = isoAt(now());
|
|
36408
|
+
}
|
|
36409
|
+
}
|
|
36410
|
+
boundClaimFailures();
|
|
36411
|
+
};
|
|
36354
36412
|
let receipt;
|
|
36355
36413
|
let mcp;
|
|
36356
36414
|
const active = /* @__PURE__ */ new Map();
|
|
@@ -36955,7 +37013,14 @@ var init_runner = __esm({
|
|
|
36955
37013
|
pending_claim: Boolean(current.pending_claim_request)
|
|
36956
37014
|
};
|
|
36957
37015
|
const parsedDiagnostic = hostRuntimeRecoverySchema.safeParse(diagnostic);
|
|
37016
|
+
resolveClaimFailures("retired", (record5) => record5.claim_request_id !== current.pending_claim_request?.claim_request_id);
|
|
37017
|
+
if (status === "draining") resolveClaimFailures("drained", () => true);
|
|
37018
|
+
const claimFailureReport = hostClaimTransportFailureReportSchema.safeParse({
|
|
37019
|
+
entries: claimFailures.filter((record5) => record5.resolution !== void 0).slice(0, EXTERNAL_INFERENCE_LIMITS.max_heartbeat_claim_failures),
|
|
37020
|
+
dropped: claimFailuresDropped
|
|
37021
|
+
});
|
|
36958
37022
|
request = {
|
|
37023
|
+
...mcp.supportsClaimTransportFailureReports?.() === true && claimFailureReport.success ? { claim_transport_failures: claimFailureReport.data } : {},
|
|
36959
37024
|
...mcp.supportsRuntimeRecoveryDiagnostics?.() === true && parsedDiagnostic.success && JSON.stringify(parsedDiagnostic.data) !== acknowledgedRecoveryDiagnostic ? { runtime_recovery: parsedDiagnostic.data } : {},
|
|
36960
37025
|
schema_version: "external_inference_host_heartbeat_v1",
|
|
36961
37026
|
contract_version: EXTERNAL_INFERENCE_CONTRACT_VERSION,
|
|
@@ -37012,6 +37077,15 @@ var init_runner = __esm({
|
|
|
37012
37077
|
if (request.runtime_recovery) {
|
|
37013
37078
|
acknowledgedRecoveryDiagnostic = JSON.stringify(request.runtime_recovery);
|
|
37014
37079
|
}
|
|
37080
|
+
if (request.claim_transport_failures) {
|
|
37081
|
+
const reported = request.claim_transport_failures;
|
|
37082
|
+
for (const entry of reported.entries) {
|
|
37083
|
+
const index = claimFailures.findIndex((record5) => record5.claim_request_id === entry.claim_request_id && record5.failed_at === entry.failed_at);
|
|
37084
|
+
if (index >= 0) claimFailures.splice(index, 1);
|
|
37085
|
+
else claimFailuresDropped = Math.max(0, claimFailuresDropped - 1);
|
|
37086
|
+
}
|
|
37087
|
+
claimFailuresDropped = Math.max(0, claimFailuresDropped - reported.dropped);
|
|
37088
|
+
}
|
|
37015
37089
|
if (result.host.status === "revoked" || result.host.status === "offline" && !allowOfflineProjection) {
|
|
37016
37090
|
const error48 = new InferenceHostRunnerError(
|
|
37017
37091
|
result.host.status === "revoked" ? "host_revoked" : "host_offline",
|
|
@@ -37699,16 +37773,45 @@ var init_runner = __esm({
|
|
|
37699
37773
|
}
|
|
37700
37774
|
);
|
|
37701
37775
|
assertClaimResult(request, claim);
|
|
37776
|
+
resolveClaimFailures(
|
|
37777
|
+
"replayed",
|
|
37778
|
+
(record5) => record5.claim_request_id === request.claim_request_id
|
|
37779
|
+
);
|
|
37702
37780
|
} catch (error48) {
|
|
37781
|
+
const failureCode = safeFailureCode(
|
|
37782
|
+
error48 instanceof ExternalInferenceMcpError ? error48.code : "",
|
|
37783
|
+
"claim_failed"
|
|
37784
|
+
);
|
|
37785
|
+
const httpStatusCode = error48 instanceof ExternalInferenceMcpError ? error48.httpStatusCode : null;
|
|
37703
37786
|
if (claimTiming) emitDiagnostic("claim_request_failed", {
|
|
37704
37787
|
claim_request_id: request.claim_request_id,
|
|
37705
|
-
failure_code:
|
|
37706
|
-
|
|
37707
|
-
"claim_failed"
|
|
37708
|
-
),
|
|
37709
|
-
http_status_code: error48 instanceof ExternalInferenceMcpError ? error48.httpStatusCode : null,
|
|
37788
|
+
failure_code: failureCode,
|
|
37789
|
+
http_status_code: httpStatusCode,
|
|
37710
37790
|
client_timing: claimTiming
|
|
37711
37791
|
});
|
|
37792
|
+
if (!this.options.signal?.aborted) {
|
|
37793
|
+
const open4 = claimFailures.find((record5) => record5.resolution === void 0 && record5.claim_request_id === request.claim_request_id);
|
|
37794
|
+
const responseBodyBytes = claimTiming?.response_body_bytes ?? null;
|
|
37795
|
+
const bodyCut = failureCode === "network_error" && (responseBodyBytes ?? 0) > 0;
|
|
37796
|
+
if (open4) {
|
|
37797
|
+
open4.attempts = Math.min(Number.MAX_SAFE_INTEGER, open4.attempts + 1);
|
|
37798
|
+
if (bodyCut) open4.body_cut = true;
|
|
37799
|
+
if (responseBodyBytes !== null) {
|
|
37800
|
+
open4.response_body_bytes = Math.max(open4.response_body_bytes ?? 0, responseBodyBytes);
|
|
37801
|
+
}
|
|
37802
|
+
} else {
|
|
37803
|
+
claimFailures.push({
|
|
37804
|
+
claim_request_id: request.claim_request_id,
|
|
37805
|
+
failed_at: isoAt(claimCallStartedAtMs),
|
|
37806
|
+
failure_code: failureCode,
|
|
37807
|
+
http_status_code: httpStatusCode,
|
|
37808
|
+
response_body_bytes: responseBodyBytes,
|
|
37809
|
+
body_cut: bodyCut,
|
|
37810
|
+
attempts: 1
|
|
37811
|
+
});
|
|
37812
|
+
boundClaimFailures();
|
|
37813
|
+
}
|
|
37814
|
+
}
|
|
37712
37815
|
if (!this.options.signal?.aborted && request.schema_version === "external_inference_job_claim_v3" && error48 instanceof ExternalInferenceMcpError && error48.serverFailureCode === "schema_validation") {
|
|
37713
37816
|
batchClaimVersion = INFERENCE_JOB_CLAIM_SCHEMA_VERSION.V2;
|
|
37714
37817
|
await mutateReceipt((current) => ({
|
|
@@ -99632,7 +99735,7 @@ var init_protective_entry_cover = __esm({
|
|
|
99632
99735
|
});
|
|
99633
99736
|
|
|
99634
99737
|
// lib/runtime/native-position-protection.ts
|
|
99635
|
-
var nativeProtectionSettings, memberSetting, KINDS, formatTriggerOrNull, nativePositionTriggerPrice, nativeEntryRequest, HALF_UP_DIGIT, roundDecimalHalfUp, nativeTrailingRetracement, nativeAfterFillActions, classifyNativeOrderEnd, isOpenInDirection, nativePlacementGate, nativeStrayOrderDecision, explainAbsentProtectiveOrder, readServerNativeProtectionState;
|
|
99738
|
+
var nativeProtectionSettings, memberSetting, KINDS, formatTriggerOrNull, nativePositionTriggerPrice, nativeEntryRequest, HALF_UP_DIGIT, roundDecimalHalfUp, nativeTrailingRetracement, nativeAfterFillActions, classifyNativeOrderEnd, isOpenInDirection, nativePlacementGate, nativeStrayOrderDecision, FIRED_TRIGGER_CONDITION, closingSide, DECIMAL_PATTERN, decimalUnits2, fractionDigits, nativePlaceCover, nativeRearmDecision, nativeLostStopCrossed, explainAbsentProtectiveOrder, readServerNativeProtectionState;
|
|
99636
99739
|
var init_native_position_protection = __esm({
|
|
99637
99740
|
"lib/runtime/native-position-protection.ts"() {
|
|
99638
99741
|
"use strict";
|
|
@@ -99641,6 +99744,7 @@ var init_native_position_protection = __esm({
|
|
|
99641
99744
|
init_define_VTX_PI_MODEL_POLICY();
|
|
99642
99745
|
init_constants();
|
|
99643
99746
|
init_hyperliquid_client();
|
|
99747
|
+
init_hyperliquid_market_symbol();
|
|
99644
99748
|
init_hyperliquid_order_status();
|
|
99645
99749
|
init_protective_stop_replacement();
|
|
99646
99750
|
nativeProtectionSettings = (resolved) => ({
|
|
@@ -99777,6 +99881,54 @@ var init_native_position_protection = __esm({
|
|
|
99777
99881
|
if (isOpenInDirection(input.position, input.isLong)) return "keep";
|
|
99778
99882
|
return input.positionStateMs > input.placedMs ? "cancel" : "need_reads";
|
|
99779
99883
|
};
|
|
99884
|
+
FIRED_TRIGGER_CONDITION = "Triggered";
|
|
99885
|
+
closingSide = (isLong) => isLong ? "a" : "b";
|
|
99886
|
+
DECIMAL_PATTERN = /^-?\d+(\.\d+)?$/;
|
|
99887
|
+
decimalUnits2 = (value, scale) => {
|
|
99888
|
+
if (!DECIMAL_PATTERN.test(value)) return null;
|
|
99889
|
+
const negative = value.startsWith("-");
|
|
99890
|
+
const [whole, fraction = ""] = (negative ? value.slice(1) : value).split(".");
|
|
99891
|
+
const units = BigInt(`${whole}${fraction.padEnd(scale, "0")}`);
|
|
99892
|
+
return negative ? -units : units;
|
|
99893
|
+
};
|
|
99894
|
+
fractionDigits = (value) => value.includes(".") ? value.split(".")[1].length : 0;
|
|
99895
|
+
nativePlaceCover = (input) => {
|
|
99896
|
+
const market = normalizeHyperliquidMarketSymbol(input.symbol);
|
|
99897
|
+
const own = new Set(input.ownClientOrderIds.map((value) => String(value).trim().toLowerCase()).filter(Boolean));
|
|
99898
|
+
const positionText = String(input.positionSize).replace(/^-/, "");
|
|
99899
|
+
const sized = [];
|
|
99900
|
+
for (const row of input.rows) {
|
|
99901
|
+
if (normalizeHyperliquidMarketSymbol(String(row.coin ?? "")) !== market) continue;
|
|
99902
|
+
if (row.reduceOnly !== true || row.isTrigger !== true) continue;
|
|
99903
|
+
if (String(row.triggerCondition ?? "").trim() === FIRED_TRIGGER_CONDITION) continue;
|
|
99904
|
+
if (String(row.side ?? "").trim().toLowerCase() !== closingSide(input.isLong)) continue;
|
|
99905
|
+
const orderType = String(row.orderType ?? "").toLowerCase();
|
|
99906
|
+
const rowKind = orderType.includes("take profit") ? "tp" : orderType.includes("stop") ? "sl" : null;
|
|
99907
|
+
if (rowKind !== input.kind) continue;
|
|
99908
|
+
if (own.has(String(row.cloid ?? "").trim().toLowerCase())) {
|
|
99909
|
+
return { decision: "adopt", order_id: Number(row.oid) };
|
|
99910
|
+
}
|
|
99911
|
+
const size = String(row.sz ?? "").trim();
|
|
99912
|
+
if (!DECIMAL_PATTERN.test(size)) return { decision: "need_reads" };
|
|
99913
|
+
const wholePosition = row.isPositionTpsl === true && Number(size) === 0;
|
|
99914
|
+
if (!wholePosition && !(Number(size) > 0)) return { decision: "need_reads" };
|
|
99915
|
+
sized.push(wholePosition ? positionText : size);
|
|
99916
|
+
}
|
|
99917
|
+
if (!DECIMAL_PATTERN.test(positionText)) return { decision: "place" };
|
|
99918
|
+
const scale = Math.max(fractionDigits(positionText), ...sized.map(fractionDigits));
|
|
99919
|
+
const position = decimalUnits2(positionText, scale);
|
|
99920
|
+
const covered = sized.reduce((total, size) => total + decimalUnits2(size, scale), BigInt(0));
|
|
99921
|
+
return position > BigInt(0) && covered >= position ? { decision: "covered" } : { decision: "place" };
|
|
99922
|
+
};
|
|
99923
|
+
nativeRearmDecision = (input) => {
|
|
99924
|
+
if (!isOpenInDirection(input.position, input.isLong)) return "retire";
|
|
99925
|
+
if (input.endedMs == null || !(input.positionStateMs > input.endedMs)) return "need_reads";
|
|
99926
|
+
return "rearm";
|
|
99927
|
+
};
|
|
99928
|
+
nativeLostStopCrossed = (input) => {
|
|
99929
|
+
if (input.mark == null || !Number.isFinite(input.mark)) return false;
|
|
99930
|
+
return input.isLong ? input.mark <= input.trigger : input.mark >= input.trigger;
|
|
99931
|
+
};
|
|
99780
99932
|
explainAbsentProtectiveOrder = (input) => {
|
|
99781
99933
|
if (isOpenInDirection(input.position, input.isLong)) return "status_read";
|
|
99782
99934
|
return input.positionStateMs > input.lastSeenRestingMs ? "ended_with_position" : "need_reads";
|
|
@@ -99795,7 +99947,7 @@ var init_native_position_protection = __esm({
|
|
|
99795
99947
|
});
|
|
99796
99948
|
|
|
99797
99949
|
// lib/runtime/native-protection-device.ts
|
|
99798
|
-
var NATIVE_PROTECTION_RECORD_VERSION, nativeProtectionStorage, resolveStorage, setNativeProtectionStorage, recordKey, isMember, readNativeProtectionRecord, writeNativeProtectionRecord, NativeOrderNotSentError, withDispatchBoundary, attempt, notSentRestores, errorText, actionOf, isOpenInDirection2, restingOrderIdAt, definitivelyRefused, planNativeOpen, recordEntryChildren, observeMembers, UNKNOWN_ORDER_RESPONSE, resolveUnknownOrderIds, settleNativeProtectionAfterFill, reconcileNativeProtection;
|
|
99950
|
+
var NATIVE_PROTECTION_RECORD_VERSION, nativeProtectionStorage, resolveStorage, setNativeProtectionStorage, recordKey, isMember, readNativeProtectionRecord, writeNativeProtectionRecord, NativeOrderNotSentError, withDispatchBoundary, attempt, notSentRestores, errorText, actionOf, isOpenInDirection2, coverRows, restingOrderIdAt, definitivelyRefused, planNativeOpen, recordEntryChildren, observeMembers, UNKNOWN_ORDER_RESPONSE, resolveUnknownOrderIds, settleNativeProtectionAfterFill, reconcileNativeProtection;
|
|
99799
99951
|
var init_native_protection_device = __esm({
|
|
99800
99952
|
"lib/runtime/native-protection-device.ts"() {
|
|
99801
99953
|
"use strict";
|
|
@@ -99883,6 +100035,20 @@ var init_native_protection_device = __esm({
|
|
|
99883
100035
|
errorText = (error48) => error48 instanceof Error ? error48.message : typeof error48 === "string" ? error48 : "Exchange call failed.";
|
|
99884
100036
|
actionOf = (kind) => kind === "sl" ? "AUTO_SL" : "AUTO_TP";
|
|
99885
100037
|
isOpenInDirection2 = (position, isLong) => isLong ? position > 0 : position < 0;
|
|
100038
|
+
coverRows = (page) => page.map((order) => ({
|
|
100039
|
+
coin: order.coin,
|
|
100040
|
+
side: order.side,
|
|
100041
|
+
sz: String(order.sz),
|
|
100042
|
+
oid: order.oid,
|
|
100043
|
+
orderType: order.order_type,
|
|
100044
|
+
triggerCondition: order.trigger_condition,
|
|
100045
|
+
isTrigger: order.is_trigger,
|
|
100046
|
+
reduceOnly: order.reduce_only,
|
|
100047
|
+
isPositionTpsl: order.is_position_tpsl,
|
|
100048
|
+
// The parsed page carries no client order id: a member's own unnamed order
|
|
100049
|
+
// counts as cover (nothing is placed) until its status read names it.
|
|
100050
|
+
cloid: null
|
|
100051
|
+
}));
|
|
99886
100052
|
restingOrderIdAt = (response, index) => {
|
|
99887
100053
|
const statuses = response?.response?.data?.statuses;
|
|
99888
100054
|
const status = Array.isArray(statuses) ? statuses[index] : void 0;
|
|
@@ -100130,6 +100296,17 @@ var init_native_protection_device = __esm({
|
|
|
100130
100296
|
});
|
|
100131
100297
|
continue;
|
|
100132
100298
|
}
|
|
100299
|
+
const cover = nativePlaceCover({
|
|
100300
|
+
kind: step.kind,
|
|
100301
|
+
isLong: record5.isLong,
|
|
100302
|
+
symbol: symbol2,
|
|
100303
|
+
positionSize: String(position.size),
|
|
100304
|
+
ownClientOrderIds: [],
|
|
100305
|
+
rows: coverRows(page)
|
|
100306
|
+
});
|
|
100307
|
+
if (cover.decision !== "place") {
|
|
100308
|
+
continue;
|
|
100309
|
+
}
|
|
100133
100310
|
const sentAtMs = io.nowMs();
|
|
100134
100311
|
const journaled = {
|
|
100135
100312
|
kind: step.kind,
|
|
@@ -100240,6 +100417,7 @@ var init_native_protection_device = __esm({
|
|
|
100240
100417
|
sizeDecimals: input.sizeDecimals
|
|
100241
100418
|
}) : null;
|
|
100242
100419
|
};
|
|
100420
|
+
const kindEnabled = (member) => (member.kind === "sl" ? input.settings.stopLoss : input.settings.takeProfit) != null;
|
|
100243
100421
|
const placeMember = async (args) => {
|
|
100244
100422
|
const gate = nativePlacementGate({
|
|
100245
100423
|
eventMs: args.eventMs,
|
|
@@ -100248,6 +100426,15 @@ var init_native_protection_device = __esm({
|
|
|
100248
100426
|
isLong: record5.isLong
|
|
100249
100427
|
});
|
|
100250
100428
|
if (gate !== "place") return args.member;
|
|
100429
|
+
const cover = nativePlaceCover({
|
|
100430
|
+
kind: args.member.kind,
|
|
100431
|
+
isLong: record5.isLong,
|
|
100432
|
+
symbol: symbol2,
|
|
100433
|
+
positionSize: String(position.size),
|
|
100434
|
+
ownClientOrderIds: [],
|
|
100435
|
+
rows: coverRows(page)
|
|
100436
|
+
});
|
|
100437
|
+
if (cover.decision !== "place") return args.member;
|
|
100251
100438
|
const clientOrderId = clientOrderIdForMutation(io.newMutationId());
|
|
100252
100439
|
const sentAtMs = io.nowMs();
|
|
100253
100440
|
const journaled = {
|
|
@@ -100386,10 +100573,16 @@ var init_native_protection_device = __esm({
|
|
|
100386
100573
|
members.push(member);
|
|
100387
100574
|
continue;
|
|
100388
100575
|
}
|
|
100389
|
-
if (!positionOpen) continue;
|
|
100576
|
+
if (!positionOpen || !kindEnabled(member)) continue;
|
|
100577
|
+
const neverLandedTrigger = currentTrigger(member);
|
|
100578
|
+
if (neverLandedTrigger == null) {
|
|
100579
|
+
anyResting = true;
|
|
100580
|
+
members.push(member);
|
|
100581
|
+
continue;
|
|
100582
|
+
}
|
|
100390
100583
|
const placed = await placeMember({
|
|
100391
100584
|
member,
|
|
100392
|
-
trigger:
|
|
100585
|
+
trigger: neverLandedTrigger,
|
|
100393
100586
|
replacedOnce: member.replacedOnce,
|
|
100394
100587
|
eventMs: Number.NEGATIVE_INFINITY,
|
|
100395
100588
|
reasonCode: "protective_order_never_landed_placed",
|
|
@@ -100434,6 +100627,27 @@ var init_native_protection_device = __esm({
|
|
|
100434
100627
|
continue;
|
|
100435
100628
|
}
|
|
100436
100629
|
if (end === "fired" || end === "ended_with_position") {
|
|
100630
|
+
const rearm = nativeRearmDecision({
|
|
100631
|
+
position: position.size,
|
|
100632
|
+
positionStateMs: stateMs,
|
|
100633
|
+
endedMs: evidence.statusTimestampMs ?? null,
|
|
100634
|
+
isLong: record5.isLong
|
|
100635
|
+
});
|
|
100636
|
+
if (rearm === "retire" || !kindEnabled(member)) continue;
|
|
100637
|
+
const rearmTrigger = currentTrigger(member);
|
|
100638
|
+
if (rearm === "need_reads" || rearmTrigger == null) {
|
|
100639
|
+
members.push(member);
|
|
100640
|
+
continue;
|
|
100641
|
+
}
|
|
100642
|
+
const rearmed = await placeMember({
|
|
100643
|
+
member,
|
|
100644
|
+
trigger: rearmTrigger,
|
|
100645
|
+
replacedOnce: false,
|
|
100646
|
+
eventMs: evidence.statusTimestampMs ?? Number.POSITIVE_INFINITY,
|
|
100647
|
+
reasonCode: "protective_native_rearmed",
|
|
100648
|
+
observationIndex
|
|
100649
|
+
});
|
|
100650
|
+
members.push(rearmed);
|
|
100437
100651
|
continue;
|
|
100438
100652
|
}
|
|
100439
100653
|
if (end === "lost_permanent" || member.replacedOnce) {
|
|
@@ -100455,7 +100669,34 @@ var init_native_protection_device = __esm({
|
|
|
100455
100669
|
members.push({ ...member, retiredReason: "protective_take_profit_lost" });
|
|
100456
100670
|
continue;
|
|
100457
100671
|
}
|
|
100458
|
-
|
|
100672
|
+
if (!kindEnabled(member)) continue;
|
|
100673
|
+
const trigger = currentTrigger(member);
|
|
100674
|
+
const lostGate = nativePlacementGate({
|
|
100675
|
+
eventMs: evidence.statusTimestampMs ?? Number.POSITIVE_INFINITY,
|
|
100676
|
+
position: position.size,
|
|
100677
|
+
positionStateMs: stateMs,
|
|
100678
|
+
isLong: record5.isLong
|
|
100679
|
+
});
|
|
100680
|
+
if (trigger == null || lostGate !== "place") {
|
|
100681
|
+
members.push(member);
|
|
100682
|
+
continue;
|
|
100683
|
+
}
|
|
100684
|
+
if (nativeLostStopCrossed({ isLong: record5.isLong, trigger: Number(trigger), mark: position.markPrice ?? null })) {
|
|
100685
|
+
members.push({ ...member, retiredReason: "protective_stop_trigger_crossed" });
|
|
100686
|
+
reports.push({
|
|
100687
|
+
order_id: String(member.orderId),
|
|
100688
|
+
symbol: symbol2,
|
|
100689
|
+
action: actionOf(member.kind),
|
|
100690
|
+
status: "failed",
|
|
100691
|
+
execution_metadata: {
|
|
100692
|
+
reason_code: "protective_stop_trigger_crossed",
|
|
100693
|
+
trigger_price: trigger,
|
|
100694
|
+
mark_price: position.markPrice,
|
|
100695
|
+
manual_intervention: true
|
|
100696
|
+
}
|
|
100697
|
+
});
|
|
100698
|
+
continue;
|
|
100699
|
+
}
|
|
100459
100700
|
const replacement = await placeMember({
|
|
100460
100701
|
member,
|
|
100461
100702
|
trigger,
|
|
@@ -104119,7 +104360,12 @@ var init_runtime_execution = __esm({
|
|
|
104119
104360
|
request.signal,
|
|
104120
104361
|
"trading_reduce"
|
|
104121
104362
|
);
|
|
104122
|
-
return {
|
|
104363
|
+
return {
|
|
104364
|
+
size: snapshot.size,
|
|
104365
|
+
entryPrice: snapshot.entryPrice,
|
|
104366
|
+
stateTimeMs: snapshot.stateTimeMs,
|
|
104367
|
+
markPrice: snapshot.markPrice
|
|
104368
|
+
};
|
|
104123
104369
|
},
|
|
104124
104370
|
readOpenOrders: () => fetchClientRuntimeOpenOrders(request, "trading_reduce"),
|
|
104125
104371
|
readOrderStatus: (orderId) => fetchBrowserOrderStatusEvidence({
|