@vtxmacro/cli 2026.10.16 → 2026.10.17
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/exo-harness.ts +1 -0
- package/bin/vtx-mcp.js +2 -1
- package/bin/vtx-service-bootstrap.js +2 -1
- package/bin/vtx-service-launcher.js +1 -0
- package/bin/vtx.js +301 -76
- package/package.json +1 -1
package/bin/exo-harness.ts
CHANGED
|
@@ -965,6 +965,7 @@ var runtime_policy_generated_default = {
|
|
|
965
965
|
update_failure_reason_max_chars: 160,
|
|
966
966
|
launcher_poll_interval_ms: 100,
|
|
967
967
|
log_tail_default_lines: 100,
|
|
968
|
+
log_rotate_bytes: 134217728,
|
|
968
969
|
worker_output_line_max_chars: 4096,
|
|
969
970
|
worker_stdout_tail_max_chars: 65536,
|
|
970
971
|
control_lock_wait_attempts: 400,
|
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.17", 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
|
|
|
@@ -2202,6 +2202,7 @@ var runtime_policy_generated_default = {
|
|
|
2202
2202
|
update_failure_reason_max_chars: 160,
|
|
2203
2203
|
launcher_poll_interval_ms: 100,
|
|
2204
2204
|
log_tail_default_lines: 100,
|
|
2205
|
+
log_rotate_bytes: 134217728,
|
|
2205
2206
|
worker_output_line_max_chars: 4096,
|
|
2206
2207
|
worker_stdout_tail_max_chars: 65536,
|
|
2207
2208
|
control_lock_wait_attempts: 400,
|
|
@@ -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.17", 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 = {
|
|
@@ -910,6 +910,7 @@ var runtime_policy_generated_default = {
|
|
|
910
910
|
update_failure_reason_max_chars: 160,
|
|
911
911
|
launcher_poll_interval_ms: 100,
|
|
912
912
|
log_tail_default_lines: 100,
|
|
913
|
+
log_rotate_bytes: 134217728,
|
|
913
914
|
worker_output_line_max_chars: 4096,
|
|
914
915
|
worker_stdout_tail_max_chars: 65536,
|
|
915
916
|
control_lock_wait_attempts: 400,
|
|
@@ -894,6 +894,7 @@ var runtime_policy_generated_default = {
|
|
|
894
894
|
update_failure_reason_max_chars: 160,
|
|
895
895
|
launcher_poll_interval_ms: 100,
|
|
896
896
|
log_tail_default_lines: 100,
|
|
897
|
+
log_rotate_bytes: 134217728,
|
|
897
898
|
worker_output_line_max_chars: 4096,
|
|
898
899
|
worker_stdout_tail_max_chars: 65536,
|
|
899
900
|
control_lock_wait_attempts: 400,
|
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.17", 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
|
|
|
@@ -1014,6 +1014,7 @@ var init_runtime_policy_generated = __esm({
|
|
|
1014
1014
|
update_failure_reason_max_chars: 160,
|
|
1015
1015
|
launcher_poll_interval_ms: 100,
|
|
1016
1016
|
log_tail_default_lines: 100,
|
|
1017
|
+
log_rotate_bytes: 134217728,
|
|
1017
1018
|
worker_output_line_max_chars: 4096,
|
|
1018
1019
|
worker_stdout_tail_max_chars: 65536,
|
|
1019
1020
|
control_lock_wait_attempts: 400,
|
|
@@ -4105,8 +4106,8 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
4105
4106
|
return { state: "busy" };
|
|
4106
4107
|
}
|
|
4107
4108
|
const raw = opened.size > PROCESS_LOCK_MAX_RECORD_BYTES ? "" : await handle.readFile("utf8");
|
|
4108
|
-
const
|
|
4109
|
-
if (!sameProcessLockFile(opened,
|
|
4109
|
+
const stat2 = await handle.stat();
|
|
4110
|
+
if (!sameProcessLockFile(opened, stat2)) return { state: "busy" };
|
|
4110
4111
|
let record5 = null;
|
|
4111
4112
|
try {
|
|
4112
4113
|
const parsed = JSON.parse(raw);
|
|
@@ -4115,22 +4116,22 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
4115
4116
|
record5 = null;
|
|
4116
4117
|
}
|
|
4117
4118
|
if (!record5 || record5.schema_version !== INFERENCE_HOST_PROCESS_LOCK_RECORD_SCHEMA_VERSION || !Number.isSafeInteger(record5.pid) || Number(record5.pid) < 1 || typeof record5.owner_token !== "string" || !record5.owner_token || typeof record5.process_identity !== "string" || !record5.process_identity || typeof record5.boot_identity !== "string" || !record5.boot_identity) {
|
|
4118
|
-
if (Date.now() -
|
|
4119
|
+
if (Date.now() - stat2.mtimeMs < PROCESS_LOCK_PUBLICATION_GRACE_MS) return { state: "busy" };
|
|
4119
4120
|
stale = true;
|
|
4120
|
-
return { state: "stale", handle, stat };
|
|
4121
|
+
return { state: "stale", handle, stat: stat2 };
|
|
4121
4122
|
}
|
|
4122
4123
|
const ownerPid = Number(record5.pid);
|
|
4123
4124
|
const storedIdentity = record5.process_identity;
|
|
4124
4125
|
const cacheKey = resolve(path);
|
|
4125
4126
|
if (await probes.currentBootIdentity() === record5.boot_identity && probes.isProcessAlive(ownerPid)) {
|
|
4126
4127
|
const cached2 = processLockObservationCache.get(cacheKey);
|
|
4127
|
-
const observedIdentity = cached2 && cached2.dev ===
|
|
4128
|
+
const observedIdentity = cached2 && cached2.dev === stat2.dev && cached2.ino === stat2.ino && cached2.pid === ownerPid && cached2.storedIdentity === storedIdentity && Date.now() - cached2.observedAtMs < HOST_CORE_POLICY.process_lock_identity_cache_ms ? cached2.observedIdentity : await probes.observeIdentity(ownerPid);
|
|
4128
4129
|
if (!observedIdentity) {
|
|
4129
4130
|
throw new Error("Inference host could not verify the existing lock owner identity.");
|
|
4130
4131
|
}
|
|
4131
4132
|
processLockObservationCache.set(cacheKey, {
|
|
4132
|
-
dev:
|
|
4133
|
-
ino:
|
|
4133
|
+
dev: stat2.dev,
|
|
4134
|
+
ino: stat2.ino,
|
|
4134
4135
|
pid: ownerPid,
|
|
4135
4136
|
storedIdentity,
|
|
4136
4137
|
observedIdentity,
|
|
@@ -4141,7 +4142,7 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
4141
4142
|
}
|
|
4142
4143
|
}
|
|
4143
4144
|
stale = true;
|
|
4144
|
-
return { state: "stale", handle, stat };
|
|
4145
|
+
return { state: "stale", handle, stat: stat2 };
|
|
4145
4146
|
} finally {
|
|
4146
4147
|
if (!stale) await handle.close().catch(() => void 0);
|
|
4147
4148
|
}
|
|
@@ -20808,6 +20809,7 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
20808
20809
|
update_failure_reason_max_chars: 160,
|
|
20809
20810
|
launcher_poll_interval_ms: 100,
|
|
20810
20811
|
log_tail_default_lines: 100,
|
|
20812
|
+
log_rotate_bytes: 134217728,
|
|
20811
20813
|
worker_output_line_max_chars: 4096,
|
|
20812
20814
|
worker_stdout_tail_max_chars: 65536,
|
|
20813
20815
|
control_lock_wait_attempts: 400,
|
|
@@ -26083,7 +26085,12 @@ var init_mcp_client = __esm({
|
|
|
26083
26085
|
} catch (error48) {
|
|
26084
26086
|
if (timing) timing.cancelBody();
|
|
26085
26087
|
else await response.body?.cancel().catch(() => void 0);
|
|
26086
|
-
throw error48;
|
|
26088
|
+
if (error48 instanceof ExternalInferenceMcpError) throw error48;
|
|
26089
|
+
throw new ExternalInferenceMcpError(
|
|
26090
|
+
options.signal?.aborted ? "request_aborted" : "network_error",
|
|
26091
|
+
options.signal?.aborted ? "Insights MCP request was aborted." : "Insights MCP response body could not be read.",
|
|
26092
|
+
{ cause: error48 }
|
|
26093
|
+
);
|
|
26087
26094
|
}
|
|
26088
26095
|
timing?.enter("response_validation_ms");
|
|
26089
26096
|
const document2 = documents.find((candidate) => candidate.id === requestId);
|
|
@@ -37653,6 +37660,11 @@ var init_runner = __esm({
|
|
|
37653
37660
|
} catch (error48) {
|
|
37654
37661
|
if (claimTiming) emitDiagnostic("claim_request_failed", {
|
|
37655
37662
|
claim_request_id: request.claim_request_id,
|
|
37663
|
+
failure_code: safeFailureCode(
|
|
37664
|
+
error48 instanceof ExternalInferenceMcpError ? error48.code : "",
|
|
37665
|
+
"claim_failed"
|
|
37666
|
+
),
|
|
37667
|
+
http_status_code: error48 instanceof ExternalInferenceMcpError ? error48.httpStatusCode : null,
|
|
37656
37668
|
client_timing: claimTiming
|
|
37657
37669
|
});
|
|
37658
37670
|
if (!this.options.signal?.aborted && request.schema_version === "external_inference_job_claim_v3" && error48 instanceof ExternalInferenceMcpError && error48.serverFailureCode === "schema_validation") {
|
|
@@ -47190,11 +47202,13 @@ var init_service_launcher_state = __esm({
|
|
|
47190
47202
|
// lib/inference-host/service.ts
|
|
47191
47203
|
import { spawn as spawn11 } from "node:child_process";
|
|
47192
47204
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
47193
|
-
import { createWriteStream, readFileSync as readFileSync2 } from "node:fs";
|
|
47194
|
-
import { access as access6, chmod as chmod4, mkdir as mkdir5, readFile as readFile12, rm as rm14, writeFile as writeFile5 } from "node:fs/promises";
|
|
47205
|
+
import { createReadStream, createWriteStream, readFileSync as readFileSync2 } from "node:fs";
|
|
47206
|
+
import { access as access6, appendFile as appendFile2, chmod as chmod4, mkdir as mkdir5, readFile as readFile12, rm as rm14, stat, truncate, writeFile as writeFile5 } from "node:fs/promises";
|
|
47195
47207
|
import { homedir as homedir4 } from "node:os";
|
|
47196
47208
|
import { dirname as dirname15, join as join16, resolve as resolve12 } from "node:path";
|
|
47197
|
-
|
|
47209
|
+
import { Transform } from "node:stream";
|
|
47210
|
+
import { pipeline } from "node:stream/promises";
|
|
47211
|
+
var SERVICE_NAME, SYSTEMD_UNIT, LAUNCHD_LABEL, SERVICE_POLICY, ATOMIC_REPLACEMENT_READ_ATTEMPTS, SERVICE_COOPERATIVE_STOP_SECONDS, pollAttemptsWithin, INFERENCE_HOST_SERVICE_DRAIN_COMMAND, INFERENCE_HOST_SERVICE_QUIESCE_COMMAND, InferenceHostBootstrapRestartRequiredError, inferenceHostServiceChildEnvironment, isWindowsSubsystemForLinux, inferenceHostServiceManifestPath, inferenceHostServiceDesiredPath, inferenceHostServiceLogPath, inferenceHostServiceRotatedLogPath, inferenceHostServiceRuntimePath, xmlEscape, plistEscape, systemdQuote, defaultRunCommand, probeInferenceHostLauncher, managerName, assertRuntimeEnvironment, withoutConcurrencyLimit, assertServicePath, manifestGeneration, assertWorker, assertManifest, assertServiceRuntimeState, assertDesiredState, readInferenceHostServiceManifest, readManifestAcrossAtomicReplacement, readInferenceHostServiceRuntime, readRuntimeAcrossAtomicReplacement, readInferenceHostServiceDesired, readDesiredAcrossAtomicReplacement, writeDesired, runtimeEnvironment, serviceBootstrapArguments, windowsOwnedCommandLine, vbScriptString, windowsServiceLauncher, windowsTaskXml, systemdUnit, launchAgentPlist, sameWorker, sameServiceDefinition, sameWorkerSet, InferenceHostServiceManager, serviceLogSinks, serviceLogSize, rotateServiceLog, writeServiceLog, appendServiceLog, spawnInferenceHostServiceChild, runInferenceHostServiceSupervisor;
|
|
47198
47212
|
var init_service = __esm({
|
|
47199
47213
|
"lib/inference-host/service.ts"() {
|
|
47200
47214
|
"use strict";
|
|
@@ -47246,6 +47260,7 @@ var init_service = __esm({
|
|
|
47246
47260
|
inferenceHostServiceManifestPath = (config2) => `${config2.supervisorStatePath}.service.json`;
|
|
47247
47261
|
inferenceHostServiceDesiredPath = (config2) => `${config2.supervisorStatePath}.service-desired.json`;
|
|
47248
47262
|
inferenceHostServiceLogPath = (config2) => `${config2.supervisorStatePath}.service.log`;
|
|
47263
|
+
inferenceHostServiceRotatedLogPath = (logPath) => `${logPath}.1`;
|
|
47249
47264
|
inferenceHostServiceRuntimePath = (config2) => `${config2.supervisorStatePath}.service-runtime.json`;
|
|
47250
47265
|
xmlEscape = (value) => value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
47251
47266
|
plistEscape = xmlEscape;
|
|
@@ -48285,10 +48300,16 @@ ${result.stderr}`)) {
|
|
|
48285
48300
|
async logs(lines = SERVICE_POLICY.log_tail_default_lines, instanceName) {
|
|
48286
48301
|
const manifest = await readInferenceHostServiceManifest(this.manifestPath());
|
|
48287
48302
|
const path = manifest?.log_path ?? this.logPath();
|
|
48288
|
-
|
|
48289
|
-
|
|
48290
|
-
|
|
48291
|
-
|
|
48303
|
+
const matching = async (file2) => {
|
|
48304
|
+
let contents;
|
|
48305
|
+
try {
|
|
48306
|
+
contents = await readFile12(file2, "utf8");
|
|
48307
|
+
} catch (error48) {
|
|
48308
|
+
if (error48.code === "ENOENT") return [];
|
|
48309
|
+
throw error48;
|
|
48310
|
+
}
|
|
48311
|
+
const logLines = contents.trimEnd() ? contents.trimEnd().split(/\r?\n/u) : [];
|
|
48312
|
+
return instanceName ? logLines.filter((line) => {
|
|
48292
48313
|
try {
|
|
48293
48314
|
const parsed = JSON.parse(line);
|
|
48294
48315
|
return parsed.instance_name === instanceName || Array.isArray(parsed.instances) && parsed.instances.includes(instanceName);
|
|
@@ -48296,12 +48317,11 @@ ${result.stderr}`)) {
|
|
|
48296
48317
|
return false;
|
|
48297
48318
|
}
|
|
48298
48319
|
}) : logLines;
|
|
48299
|
-
|
|
48320
|
+
};
|
|
48321
|
+
const current = await matching(path);
|
|
48322
|
+
const filtered = current.length >= lines ? current : [...await matching(inferenceHostServiceRotatedLogPath(path)), ...current];
|
|
48323
|
+
return filtered.length > 0 ? `${filtered.slice(-lines).join("\n")}
|
|
48300
48324
|
` : "";
|
|
48301
|
-
} catch (error48) {
|
|
48302
|
-
if (error48.code === "ENOENT") return "";
|
|
48303
|
-
throw error48;
|
|
48304
|
-
}
|
|
48305
48325
|
}
|
|
48306
48326
|
async uninstallInstance(instanceName) {
|
|
48307
48327
|
return await this.withControlLock(async () => {
|
|
@@ -48366,14 +48386,71 @@ ${result.stderr}`)) {
|
|
|
48366
48386
|
};
|
|
48367
48387
|
}
|
|
48368
48388
|
};
|
|
48369
|
-
|
|
48370
|
-
|
|
48371
|
-
|
|
48372
|
-
|
|
48373
|
-
|
|
48374
|
-
|
|
48375
|
-
|
|
48389
|
+
serviceLogSinks = /* @__PURE__ */ new Map();
|
|
48390
|
+
serviceLogSize = async (path) => await stat(path).then((entry) => entry.size, (error48) => {
|
|
48391
|
+
if (error48.code === "ENOENT") return 0;
|
|
48392
|
+
throw error48;
|
|
48393
|
+
});
|
|
48394
|
+
rotateServiceLog = async (path, size) => {
|
|
48395
|
+
const start = Math.max(0, size - SERVICE_POLICY.log_rotate_bytes);
|
|
48396
|
+
let aligned = start === 0;
|
|
48397
|
+
await pipeline(
|
|
48398
|
+
createReadStream(path, { start, end: size - 1 }),
|
|
48399
|
+
new Transform({
|
|
48400
|
+
transform(chunk, _encoding, callback) {
|
|
48401
|
+
if (aligned) {
|
|
48402
|
+
callback(null, chunk);
|
|
48403
|
+
return;
|
|
48404
|
+
}
|
|
48405
|
+
const newline = chunk.indexOf("\n");
|
|
48406
|
+
if (newline < 0) {
|
|
48407
|
+
callback();
|
|
48408
|
+
return;
|
|
48409
|
+
}
|
|
48410
|
+
aligned = true;
|
|
48411
|
+
callback(null, chunk.subarray(newline + 1));
|
|
48412
|
+
}
|
|
48413
|
+
}),
|
|
48414
|
+
createWriteStream(inferenceHostServiceRotatedLogPath(path), { flags: "w", mode: OWNER_ONLY_FILE_MODE })
|
|
48415
|
+
);
|
|
48416
|
+
await truncate(path, 0);
|
|
48417
|
+
};
|
|
48418
|
+
writeServiceLog = (path, text) => {
|
|
48419
|
+
let sink = serviceLogSinks.get(path);
|
|
48420
|
+
if (!sink) {
|
|
48421
|
+
sink = { tail: Promise.resolve(), bytes: null, rotateAtBytes: SERVICE_POLICY.log_rotate_bytes };
|
|
48422
|
+
serviceLogSinks.set(path, sink);
|
|
48423
|
+
}
|
|
48424
|
+
const state2 = sink;
|
|
48425
|
+
const write = state2.tail.then(async () => {
|
|
48426
|
+
if (state2.bytes === null) {
|
|
48427
|
+
await mkdir5(dirname15(path), { recursive: true, mode: OWNER_ONLY_DIRECTORY_MODE });
|
|
48428
|
+
state2.bytes = await serviceLogSize(path);
|
|
48429
|
+
}
|
|
48430
|
+
await appendFile2(path, text, { encoding: "utf8", mode: OWNER_ONLY_FILE_MODE });
|
|
48431
|
+
state2.bytes += Buffer.byteLength(text);
|
|
48432
|
+
if (state2.bytes < state2.rotateAtBytes) return;
|
|
48433
|
+
try {
|
|
48434
|
+
const size = await serviceLogSize(path);
|
|
48435
|
+
if (size >= SERVICE_POLICY.log_rotate_bytes) await rotateServiceLog(path, size);
|
|
48436
|
+
state2.bytes = size >= SERVICE_POLICY.log_rotate_bytes ? 0 : size;
|
|
48437
|
+
state2.rotateAtBytes = SERVICE_POLICY.log_rotate_bytes;
|
|
48438
|
+
} catch (error48) {
|
|
48439
|
+
state2.rotateAtBytes = state2.bytes + SERVICE_POLICY.log_rotate_bytes;
|
|
48440
|
+
await appendFile2(path, `${JSON.stringify({
|
|
48441
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
48442
|
+
event: "service_log_rotation_failed",
|
|
48443
|
+
error_code: String(error48.code ?? "unknown")
|
|
48444
|
+
})}
|
|
48445
|
+
`, { encoding: "utf8", mode: OWNER_ONLY_FILE_MODE }).catch(() => void 0);
|
|
48446
|
+
}
|
|
48376
48447
|
});
|
|
48448
|
+
state2.tail = write.catch(() => void 0);
|
|
48449
|
+
return write;
|
|
48450
|
+
};
|
|
48451
|
+
appendServiceLog = async (path, event, fields = {}) => {
|
|
48452
|
+
await writeServiceLog(path, `${JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), event, ...fields })}
|
|
48453
|
+
`);
|
|
48377
48454
|
};
|
|
48378
48455
|
spawnInferenceHostServiceChild = async (manifest, worker, signal, onReady = () => {
|
|
48379
48456
|
}, quiesceSignal) => {
|
|
@@ -48388,7 +48465,12 @@ ${result.stderr}`)) {
|
|
|
48388
48465
|
worker.display_name
|
|
48389
48466
|
];
|
|
48390
48467
|
const startedAt = Date.now();
|
|
48391
|
-
const log =
|
|
48468
|
+
const log = (line) => {
|
|
48469
|
+
void writeServiceLog(manifest.log_path, line).catch(() => void 0);
|
|
48470
|
+
};
|
|
48471
|
+
const logSettled = async () => {
|
|
48472
|
+
await serviceLogSinks.get(manifest.log_path)?.tail;
|
|
48473
|
+
};
|
|
48392
48474
|
return await new Promise((resolvePromise, reject) => {
|
|
48393
48475
|
let stdout = "";
|
|
48394
48476
|
let cooperativeStopTimedOut = false;
|
|
@@ -48406,7 +48488,7 @@ ${result.stderr}`)) {
|
|
|
48406
48488
|
const parsed = JSON.parse(line);
|
|
48407
48489
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
48408
48490
|
if (parsed.event === "runtime_started") onReady();
|
|
48409
|
-
log
|
|
48491
|
+
log(`${JSON.stringify({
|
|
48410
48492
|
...parsed,
|
|
48411
48493
|
instance_name: worker.instance_name
|
|
48412
48494
|
})}
|
|
@@ -48415,7 +48497,7 @@ ${result.stderr}`)) {
|
|
|
48415
48497
|
}
|
|
48416
48498
|
} catch {
|
|
48417
48499
|
}
|
|
48418
|
-
log
|
|
48500
|
+
log(`${JSON.stringify({
|
|
48419
48501
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
48420
48502
|
event: "worker_output",
|
|
48421
48503
|
instance_name: worker.instance_name,
|
|
@@ -48461,8 +48543,7 @@ ${result.stderr}`)) {
|
|
|
48461
48543
|
if (cooperativeStopTimer) clearTimeout(cooperativeStopTimer);
|
|
48462
48544
|
writeTaggedOutput("stdout", "", true);
|
|
48463
48545
|
writeTaggedOutput("stderr", "", true);
|
|
48464
|
-
|
|
48465
|
-
reject(error48);
|
|
48546
|
+
void logSettled().then(() => reject(error48));
|
|
48466
48547
|
});
|
|
48467
48548
|
child.once("exit", (code) => {
|
|
48468
48549
|
signal.removeEventListener("abort", onAbort);
|
|
@@ -48470,7 +48551,6 @@ ${result.stderr}`)) {
|
|
|
48470
48551
|
if (cooperativeStopTimer) clearTimeout(cooperativeStopTimer);
|
|
48471
48552
|
writeTaggedOutput("stdout", "", true);
|
|
48472
48553
|
writeTaggedOutput("stderr", "", true);
|
|
48473
|
-
log.end();
|
|
48474
48554
|
let drainReason = null;
|
|
48475
48555
|
for (const line of stdout.trim().split("\n").reverse()) {
|
|
48476
48556
|
try {
|
|
@@ -48484,12 +48564,13 @@ ${result.stderr}`)) {
|
|
|
48484
48564
|
} catch {
|
|
48485
48565
|
}
|
|
48486
48566
|
}
|
|
48487
|
-
|
|
48567
|
+
const uptimeMs = Date.now() - startedAt;
|
|
48568
|
+
void logSettled().then(() => resolvePromise({
|
|
48488
48569
|
exitCode: code ?? 1,
|
|
48489
|
-
uptimeMs
|
|
48570
|
+
uptimeMs,
|
|
48490
48571
|
drainReason,
|
|
48491
48572
|
cooperativeStopTimedOut
|
|
48492
|
-
});
|
|
48573
|
+
}));
|
|
48493
48574
|
});
|
|
48494
48575
|
});
|
|
48495
48576
|
};
|
|
@@ -91600,7 +91681,7 @@ var init_api2 = __esm({
|
|
|
91600
91681
|
if (!isRetryableClientRuntimeStatus(status)) {
|
|
91601
91682
|
return false;
|
|
91602
91683
|
}
|
|
91603
|
-
if (path === "/runtime/event") {
|
|
91684
|
+
if (path === "/runtime/event" || path === "/runtime/server-prompt-rescue") {
|
|
91604
91685
|
return false;
|
|
91605
91686
|
}
|
|
91606
91687
|
return true;
|
|
@@ -94741,7 +94822,9 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
94741
94822
|
);
|
|
94742
94823
|
const accountSummary = {
|
|
94743
94824
|
...normalizedSummary,
|
|
94744
|
-
|
|
94825
|
+
// Every read keeps its per-DEX pools, a chart-scoped Trade read too, so
|
|
94826
|
+
// the Trade page can measure the bot's venue equity (botVenueEquity).
|
|
94827
|
+
...{
|
|
94745
94828
|
perp_dex_accounts: perpsResult.dexPayloads.filter(({ payload }) => hasCompletePerpDexAccountMetrics(payload)).map(({ dex, payload }) => {
|
|
94746
94829
|
const summary = buildServerPromptRescueAccountSummary({
|
|
94747
94830
|
...payload,
|
|
@@ -107243,6 +107326,30 @@ var init_client_runtime_status_store = __esm({
|
|
|
107243
107326
|
}
|
|
107244
107327
|
});
|
|
107245
107328
|
|
|
107329
|
+
// lib/runtime/perp-dex-scope.ts
|
|
107330
|
+
var perpDexScopeForSymbols, profileEquityPerpDexScope;
|
|
107331
|
+
var init_perp_dex_scope = __esm({
|
|
107332
|
+
"lib/runtime/perp-dex-scope.ts"() {
|
|
107333
|
+
"use strict";
|
|
107334
|
+
init_define_VTX_EXO_POLICY();
|
|
107335
|
+
init_define_VTX_GROK_POLICY();
|
|
107336
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
107337
|
+
init_hyperliquid_market_symbol();
|
|
107338
|
+
perpDexScopeForSymbols = (symbols) => {
|
|
107339
|
+
const dexes = /* @__PURE__ */ new Set();
|
|
107340
|
+
for (const raw of symbols) {
|
|
107341
|
+
if (!String(raw ?? "").trim()) continue;
|
|
107342
|
+
if (!normalizeHyperliquidMarketSymbol(raw)) return void 0;
|
|
107343
|
+
dexes.add(getHyperliquidMarketDex(raw));
|
|
107344
|
+
}
|
|
107345
|
+
return dexes.size > 0 ? [...dexes].filter(Boolean) : void 0;
|
|
107346
|
+
};
|
|
107347
|
+
profileEquityPerpDexScope = (tradingSymbols, defaultTradingSymbols) => perpDexScopeForSymbols(
|
|
107348
|
+
(Array.isArray(tradingSymbols) && tradingSymbols.length > 0 ? tradingSymbols : defaultTradingSymbols ?? []).map((entry) => String(entry ?? "").trim()).filter(Boolean)
|
|
107349
|
+
);
|
|
107350
|
+
}
|
|
107351
|
+
});
|
|
107352
|
+
|
|
107246
107353
|
// lib/runtime/client-killswitch.ts
|
|
107247
107354
|
var toPositiveFinite2, toNonNegativeFinite, firstConfiguredSymbol, calculateClientKillswitchDrawdownPercent, evaluateClientKillswitch, closeClientKillswitchPositions;
|
|
107248
107355
|
var init_client_killswitch = __esm({
|
|
@@ -107254,6 +107361,7 @@ var init_client_killswitch = __esm({
|
|
|
107254
107361
|
init_api2();
|
|
107255
107362
|
init_constants();
|
|
107256
107363
|
init_browser_trading();
|
|
107364
|
+
init_perp_dex_scope();
|
|
107257
107365
|
init_hyperliquid_account_state_adapter();
|
|
107258
107366
|
toPositiveFinite2 = (value) => {
|
|
107259
107367
|
const parsed = Number(value);
|
|
@@ -107315,6 +107423,9 @@ var init_client_killswitch = __esm({
|
|
|
107315
107423
|
tickerPrice: 0,
|
|
107316
107424
|
leverage,
|
|
107317
107425
|
aggregatePerpDexs: true,
|
|
107426
|
+
// Only the DEXes the server measures the killswitch on; a trigger's close
|
|
107427
|
+
// re-reads every DEX before closing.
|
|
107428
|
+
perpDexScope: profileEquityPerpDexScope(settings.trading_symbols, input.config.default_trading_symbols),
|
|
107318
107429
|
forceRefresh: true,
|
|
107319
107430
|
sessionId: input.sessionId,
|
|
107320
107431
|
signal: input.signal
|
|
@@ -109013,6 +109124,87 @@ var init_client_account_report = __esm({
|
|
|
109013
109124
|
}
|
|
109014
109125
|
});
|
|
109015
109126
|
|
|
109127
|
+
// lib/api/server-host-prompt-rescue.ts
|
|
109128
|
+
async function requestServerHostPromptRescue(profileId, payload, options) {
|
|
109129
|
+
return postClientRuntime(
|
|
109130
|
+
"/runtime/server-prompt-rescue",
|
|
109131
|
+
profileId,
|
|
109132
|
+
buildClientRuntimeBody(payload, {
|
|
109133
|
+
analysis_run_id: payload.analysisRunId,
|
|
109134
|
+
cycle_id: payload.cycleId,
|
|
109135
|
+
symbol: payload.symbol,
|
|
109136
|
+
symbols: payload.symbols,
|
|
109137
|
+
request_sequence: payload.requestSequence,
|
|
109138
|
+
server_reason: payload.serverReason
|
|
109139
|
+
}, { includeForceTakeover: false }),
|
|
109140
|
+
options
|
|
109141
|
+
);
|
|
109142
|
+
}
|
|
109143
|
+
var init_server_host_prompt_rescue = __esm({
|
|
109144
|
+
"lib/api/server-host-prompt-rescue.ts"() {
|
|
109145
|
+
"use strict";
|
|
109146
|
+
init_define_VTX_EXO_POLICY();
|
|
109147
|
+
init_define_VTX_GROK_POLICY();
|
|
109148
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
109149
|
+
init_api2();
|
|
109150
|
+
}
|
|
109151
|
+
});
|
|
109152
|
+
|
|
109153
|
+
// lib/runtime/server-prompt-rescue-snapshot.ts
|
|
109154
|
+
var accountStateFromServerPromptRescueSnapshot;
|
|
109155
|
+
var init_server_prompt_rescue_snapshot = __esm({
|
|
109156
|
+
"lib/runtime/server-prompt-rescue-snapshot.ts"() {
|
|
109157
|
+
"use strict";
|
|
109158
|
+
init_define_VTX_EXO_POLICY();
|
|
109159
|
+
init_define_VTX_GROK_POLICY();
|
|
109160
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
109161
|
+
init_hyperliquid_market_symbol();
|
|
109162
|
+
accountStateFromServerPromptRescueSnapshot = (snapshot, symbol2) => {
|
|
109163
|
+
const capturedAtMs = Date.parse(snapshot.captured_at);
|
|
109164
|
+
if (!Number.isFinite(capturedAtMs)) {
|
|
109165
|
+
throw new Error("Server prompt rescue timestamp is invalid.");
|
|
109166
|
+
}
|
|
109167
|
+
const positions = snapshot.positions.map((position) => ({
|
|
109168
|
+
symbol: position.symbol,
|
|
109169
|
+
dex: position.dex,
|
|
109170
|
+
coin: position.coin ?? null,
|
|
109171
|
+
base_symbol: position.base_symbol ?? null,
|
|
109172
|
+
market_type: position.market_type,
|
|
109173
|
+
size: position.size,
|
|
109174
|
+
entry_price: position.entry_price ?? null,
|
|
109175
|
+
unrealized_pnl: position.unrealized_pnl ?? null,
|
|
109176
|
+
realized_pnl: position.realized_pnl ?? null,
|
|
109177
|
+
leverage: position.leverage ?? null,
|
|
109178
|
+
margin_used: position.margin_used ?? null,
|
|
109179
|
+
liquidation_price: position.liquidation_price ?? null,
|
|
109180
|
+
funding_usdc: position.funding_usdc ?? null
|
|
109181
|
+
}));
|
|
109182
|
+
return {
|
|
109183
|
+
evidence: {
|
|
109184
|
+
source: "live",
|
|
109185
|
+
fetchedAtMs: capturedAtMs,
|
|
109186
|
+
observedAtMs: Date.now(),
|
|
109187
|
+
cacheAgeMs: 0,
|
|
109188
|
+
freshnessLimitMs: null
|
|
109189
|
+
},
|
|
109190
|
+
accountSummary: snapshot.account_summary,
|
|
109191
|
+
availableToTrade: {
|
|
109192
|
+
symbol: normalizeHyperliquidMarketSymbol(symbol2),
|
|
109193
|
+
available_to_trade_buy: 0,
|
|
109194
|
+
available_to_trade_sell: 0,
|
|
109195
|
+
max_trade_size_buy: 0,
|
|
109196
|
+
max_trade_size_sell: 0,
|
|
109197
|
+
mark_price: 0,
|
|
109198
|
+
source: "fallback"
|
|
109199
|
+
},
|
|
109200
|
+
positions,
|
|
109201
|
+
...snapshot.taker_rate == null ? {} : { takerRate: snapshot.taker_rate },
|
|
109202
|
+
...snapshot.effective_taker_rates == null ? {} : { effectiveTakerRates: { ...snapshot.effective_taker_rates } }
|
|
109203
|
+
};
|
|
109204
|
+
};
|
|
109205
|
+
}
|
|
109206
|
+
});
|
|
109207
|
+
|
|
109016
109208
|
// lib/runtime/google-egress.ts
|
|
109017
109209
|
function googleEgressPolicyForModel(policy2, model) {
|
|
109018
109210
|
if (!policy2?.enabled) return void 0;
|
|
@@ -113416,16 +113608,17 @@ __export(local_analysis_exports, {
|
|
|
113416
113608
|
isClientRuntimeAiSchedulePaused: () => isClientRuntimeAiSchedulePaused,
|
|
113417
113609
|
isClientRuntimeAiScheduleStillActive: () => isClientRuntimeAiScheduleStillActive,
|
|
113418
113610
|
isServerDispatchAccountStateStale: () => isServerDispatchAccountStateStale,
|
|
113611
|
+
perpDexScopeForSymbols: () => perpDexScopeForSymbols,
|
|
113612
|
+
profileEquityPerpDexScope: () => profileEquityPerpDexScope,
|
|
113419
113613
|
resolveEffectivePromptRuntimeProvenance: () => resolveEffectivePromptRuntimeProvenance,
|
|
113420
113614
|
resolveExternalInferenceRuntimeTimeoutSeconds: () => resolveExternalInferenceRuntimeTimeoutSeconds,
|
|
113421
113615
|
resolveLocalRuntimeSecretProvider: () => resolveLocalRuntimeSecretProvider,
|
|
113422
113616
|
resolveLocalRuntimeSecretRequirements: () => resolveLocalRuntimeSecretRequirements,
|
|
113423
113617
|
resolveNativeValuesForModel: () => resolveNativeValuesForModel,
|
|
113424
113618
|
runLocalRuntimeCycle: () => runLocalRuntimeCycle,
|
|
113425
|
-
serverPerpDexScope: () => serverPerpDexScope,
|
|
113426
113619
|
summarizeReviewFailureExplanation: () => summarizeReviewFailureExplanation
|
|
113427
113620
|
});
|
|
113428
|
-
var CYCLE_TIMEOUT_FLOOR_MS, DECISION_SETTLEMENT_RESERVE_MAX_BUDGET_DIVISOR, MIN_AGENT_INSTRUCTION_RETRY_AFTER_MS, PROMPT_PARITY_ERROR_DETAIL_MAX_CHARS, EXTERNAL_INFERENCE_RUNTIME_POLL_INTERVAL_MS, REVIEW_PROVIDER_SERVER_ERROR_STATUSES, TRUNCATION_ELLIPSIS2, normalizeNativeValues, assertPromptModelController, resolveRuntimeReasoningControlsForModel, modelScopedKey, resolveNativeValuesForModel, observeRuntimeCycle, observeAccountState, aiOrderSlippageFraction,
|
|
113621
|
+
var CYCLE_TIMEOUT_FLOOR_MS, DECISION_SETTLEMENT_RESERVE_MAX_BUDGET_DIVISOR, MIN_AGENT_INSTRUCTION_RETRY_AFTER_MS, PROMPT_PARITY_ERROR_DETAIL_MAX_CHARS, EXTERNAL_INFERENCE_RUNTIME_POLL_INTERVAL_MS, REVIEW_PROVIDER_SERVER_ERROR_STATUSES, TRUNCATION_ELLIPSIS2, normalizeNativeValues, assertPromptModelController, resolveRuntimeReasoningControlsForModel, modelScopedKey, resolveNativeValuesForModel, observeRuntimeCycle, observeAccountState, aiOrderSlippageFraction, serverBehaviorStateArtifacts, ClientRuntimeAgentInstructionEmpty, isClientRuntimeAgentInstructionEmpty, ClientRuntimeAiSchedulePaused, ClientRuntimeAiScheduleStillActive, isClientRuntimeAiScheduleStillActive, ServerDispatchAccountStateStale, isServerDispatchAccountStateStale, isClientRuntimeAiSchedulePaused, buildClaimedAgentRuntimeCycleResult, resolveRuntimeMarginModePreference, resolveRuntimeLeveragePreference, resolveBooleanSetting2, CLIENT_RUNTIME_LIVE_CONTEXT_UNAVAILABLE_ERRORS, BEHAVIOR_STATE_UNAVAILABLE_ERROR, CriticalBehaviorStateError, clampNumber, resolveExternalInferenceRuntimeTimeoutSeconds, toPositiveFinite3, compactSnippet, hashRuntimeDebugText, EFFECTIVE_INPUT_MANIFEST_SCHEMA_VERSION, PROMPT_ASSEMBLY_DEFINITION_VERSION, RUNTIME_SOURCE_DEFINITION_VERSION, DECISION_INPUT_DEFINITION_VERSION, CONTEXT_ENVELOPE_DEFINITION_VERSION, CLIENT_RUNTIME_SOURCE_VERSION, CLIENT_MAIN_PROMPT_RENDERER, SERVER_MAIN_PROMPT_RENDERER, CLIENT_REVIEW_PROMPT_RENDERER, SERVER_REVIEW_PROMPT_RENDERER, resolveEffectivePromptRuntimeProvenance, canonicalManifestValue, canonicalManifestJson, sha256ManifestHex, effectiveInputComponent, buildEffectiveInputManifest, derivePromptVisibleSections, decodeDecisionTracePayload, extractDecisionSymbolTrace, formatDecisionSymbolTrace, formatActionableDecisionSymbols, normalizePromptSymbols, JSON_MODEL_OUTPUT_FENCE_PATTERN, STRICT_MODEL_OUTPUT_KEYS, currentModelOutputValidationErrors, currentModelOutputMatchesContract, projectCurrentModelDecisionContent, modelOutputValidationError, buildMissingDecisionHold, buildDecisionPlansFromResponse, buildReviewCandidatePlansFromResponse, forceUnavailableSymbolsToHold, extractTemplatePlaceholders, requireReviewPrimaryUserPromptTemplate, containsCompetingBehaviorStateMarkup, containsCompetingMainBehaviorStateMarkup, requireStrategyReviewTemplates, preflightStrategyReviewPromptContract, extractRuntimeReasoningSelection, isAbortError, isRuntimeTimeoutAbortReason, REVIEW_FAILURE_SENSITIVE_DB_TOKENS, REVIEW_FAILURE_SCHEMA_DISCLOSURE_TOKENS, REVIEW_FAILURE_SQL_STATEMENT_PATTERN, REVIEW_FAILURE_TRACEBACK_PATTERN, isSensitiveReviewFailureDetail, summarizeReviewFailureExplanation, buildReviewFailureHoldReason, createAbortError2, settleRuntimeCyclePromise, unwrapRuntimeCycleSettledResult, normalizeDecisionLabel, normalizeRuntimeSymbol, PromptContractFetchError, isLivePromptContextUnavailableError, buildFailClosedHoldResult, buildPromptConstructionFailureResult, buildLivePromptContextUnavailableFailureResult, pickFirstString, normalizeRuntimeStringList, requirePositiveRuntimeLimit, resolveRuntimeTradingScope, normalizeRuntimeProviderAlias, resolveCatalogModelEntry, createClientRuntimeProviderSetupError, createProviderSetupRejectionError, evaluateModelEligibility, extractReviewRuntimeReasoningSelection, isUsableRuntimeSettingsFallback, resolveRuntimeSettings, formatRuntimeDurationMs, normalizeRuntimeTimingNote, appendRuntimeTimingEvent, reportPromptParityTelemetry, resolveLocalRuntimeSecretRequirements, resolveLocalRuntimeSecretProvider, toEpochSeconds, REQUIRED_AI_INDICATOR_KEYS, sortTradingTimeframes, normalizePromptIdentityTimestamp, resolveCompletedCandleBoundary, normalizeAiIndicatorFlags, getPromptLookback, computeSma, computeEma, computeRsi, computeAtr, computeMacd, computeBollingerBands, getIndicatorValue, buildPromptCandlesComponent, buildPromptCandlesPayload, formatUtcTimestampWithWeekday, formatUtcNowWithWeekday, formatPromptPrice, capacityUnitSize, computePromptUnitsUsedForPosition, buildPromptAccountStatusValue, buildPromptPositionsValue, sanitizePromptSymbol, fillTimeMs, fillSize, normalizeFillSide, normalizeFillOrderId, normalizeFillRiskOrderIdentity, fillStartPosition, fillSortValue, sortFillsAscending, sortFillsDescending, inferEntryFromStartPositionChain, inferEntryFromCurrentPositionSize, calculateCurrentPositionState, calculatePositionEntryTimes, countPositionAdds, latestPositionRiskIncreaseTimeMs, latestPositionRiskIncreaseEvidence, compactPromptRiskIncrease, roundPositiveDecimalHalfUp, compactPromptLastTrade, ENTRY_TRADE_FIELDS, PREVIOUS_DECISION_FIELDS, PREVIOUS_CAMPAIGN_FIELDS, hasExactKeys2, isNonnegativeInteger, isFiniteNumber, isExactEnumString, isNonemptyPromptText, isCampaignReasoningText, projectBackendDecisionMemoryItem, requireRenderedStrategyBehaviorState, canonicalFillSideForRiskEvidence, isValidRiskEvidenceFill, isValidCampaignBoundaryFill, normalizeFillHistoryCoverage, resolveFillHistoryCoverageForSymbol, buildPromptBehaviorStateArtifacts, buildPromptBehaviorStateValue, shouldCompareServerPromptParity, buildLocalRuntimePromptArtifacts, createRuntimeId2, asRecord, buildRuntimeConstraintRejectionMessage, hasDeviceProviderSecret, requireNonEmptyStringField, requirePositiveIntegerField, compareContractVersion, parsePromptContractTimestamp, assertPromptContractCompatibility, assertPromptContractTemporalBounds, sleepWithAbort, requireAgentPollRetryAfterMs, materializeClaimedClientRuntimeAgentInstruction, attachClientRuntimeErrorProvenance, isExternalRuntimeProviderResult, invokeClientExternalInference, assertPromptContractBindingTupleEqual, assertPromptContractScopeMatch, fetchBoundPromptContracts, formatTemplateWithNamedVariables, carryReturnedModelCalls, runLocalRuntimeCycle;
|
|
113429
113622
|
var init_local_analysis = __esm({
|
|
113430
113623
|
"lib/runtime/local-analysis.ts"() {
|
|
113431
113624
|
"use strict";
|
|
@@ -113446,6 +113639,9 @@ var init_local_analysis = __esm({
|
|
|
113446
113639
|
init_execution_guard_contract();
|
|
113447
113640
|
init_hyperliquid_account_state_adapter();
|
|
113448
113641
|
init_client_account_report();
|
|
113642
|
+
init_hyperliquid_public_read();
|
|
113643
|
+
init_server_host_prompt_rescue();
|
|
113644
|
+
init_server_prompt_rescue_snapshot();
|
|
113449
113645
|
init_network_debug();
|
|
113450
113646
|
init_abort();
|
|
113451
113647
|
init_error_surface_contract();
|
|
@@ -113465,6 +113661,8 @@ var init_local_analysis = __esm({
|
|
|
113465
113661
|
init_native_request_parameters();
|
|
113466
113662
|
init_hyperliquid_market_symbol();
|
|
113467
113663
|
init_external_inference_contract();
|
|
113664
|
+
init_perp_dex_scope();
|
|
113665
|
+
init_perp_dex_scope();
|
|
113468
113666
|
init_model_controller_provenance();
|
|
113469
113667
|
init_ai_schedule();
|
|
113470
113668
|
init_runtime_policy_generated2();
|
|
@@ -113550,16 +113748,6 @@ var init_local_analysis = __esm({
|
|
|
113550
113748
|
});
|
|
113551
113749
|
};
|
|
113552
113750
|
aiOrderSlippageFraction = (config2, executionMode) => executionMode === "server" ? Number(config2.server_ai_max_slippage) / PERCENT_SCALE : clampNumber(void 0, config2.default_max_slippage) / PERCENT_SCALE;
|
|
113553
|
-
serverPerpDexScope = (symbols, executionMode) => {
|
|
113554
|
-
if (executionMode !== "server") return void 0;
|
|
113555
|
-
const dexes = /* @__PURE__ */ new Set();
|
|
113556
|
-
for (const raw of symbols) {
|
|
113557
|
-
if (!String(raw ?? "").trim()) continue;
|
|
113558
|
-
if (!normalizeHyperliquidMarketSymbol(raw)) return void 0;
|
|
113559
|
-
dexes.add(getHyperliquidMarketDex(raw));
|
|
113560
|
-
}
|
|
113561
|
-
return dexes.size > 0 ? [...dexes].filter(Boolean) : void 0;
|
|
113562
|
-
};
|
|
113563
113751
|
serverBehaviorStateArtifacts = (derived) => {
|
|
113564
113752
|
const rendered = derived.behavior_state;
|
|
113565
113753
|
if (derived.behavior_state_owner !== "server" || typeof rendered !== "string" || !rendered.trim()) {
|
|
@@ -113641,7 +113829,7 @@ var init_local_analysis = __esm({
|
|
|
113641
113829
|
tickerPrice: 0,
|
|
113642
113830
|
leverage,
|
|
113643
113831
|
aggregatePerpDexs: true,
|
|
113644
|
-
perpDexScope:
|
|
113832
|
+
perpDexScope: perpDexScopeForSymbols(symbols),
|
|
113645
113833
|
feeSymbols: symbols,
|
|
113646
113834
|
includeEffectiveTakerRate: true,
|
|
113647
113835
|
sessionId: String(runtimeInput.sessionId || "").trim(),
|
|
@@ -117563,6 +117751,7 @@ ${behaviorJson}
|
|
|
117563
117751
|
const getLatestTotalUnrealizedPnl = () => _latestTotalUnrealizedPnl;
|
|
117564
117752
|
const getAccountStateResolvedAtMs = () => _accountStateResolvedAtMs;
|
|
117565
117753
|
const accountStateStartedAtMs = Date.now();
|
|
117754
|
+
let promptRescueSequence = 0;
|
|
117566
117755
|
observeRuntimeCycle(input, { stage: "market_context" });
|
|
117567
117756
|
const browserAccountStateTask = fetchBrowserAccountState2({
|
|
117568
117757
|
publicRequestPriority: "trading_analysis",
|
|
@@ -117572,7 +117761,7 @@ ${behaviorJson}
|
|
|
117572
117761
|
tickerPrice: 0,
|
|
117573
117762
|
leverage: resolveRuntimeLeveragePreference(settings, config2),
|
|
117574
117763
|
aggregatePerpDexs: true,
|
|
117575
|
-
perpDexScope:
|
|
117764
|
+
perpDexScope: perpDexScopeForSymbols(symbols),
|
|
117576
117765
|
feeSymbols: symbols,
|
|
117577
117766
|
includeEffectiveTakerRate: true,
|
|
117578
117767
|
// A Server bot's cycle reads the account authoritatively, as the Python
|
|
@@ -117580,6 +117769,36 @@ ${behaviorJson}
|
|
|
117580
117769
|
forceRefresh: input.executionMode === "server",
|
|
117581
117770
|
sessionId,
|
|
117582
117771
|
signal: timeoutController.signal
|
|
117772
|
+
}).catch(async (error48) => {
|
|
117773
|
+
if (input.executionMode !== "server" || !(error48 instanceof HyperliquidPublicReadError)) throw error48;
|
|
117774
|
+
promptRescueSequence += 1;
|
|
117775
|
+
try {
|
|
117776
|
+
const rescued = await requestServerHostPromptRescue(profileId, {
|
|
117777
|
+
sessionId,
|
|
117778
|
+
deviceId,
|
|
117779
|
+
schedulerInstanceId: String(input.schedulerInstanceId || "").trim(),
|
|
117780
|
+
mode: input.mode,
|
|
117781
|
+
analysisRunId: String(input.analysisRunId || "").trim() || cycleId,
|
|
117782
|
+
cycleId,
|
|
117783
|
+
symbol: localFallbackSymbol,
|
|
117784
|
+
symbols,
|
|
117785
|
+
requestSequence: promptRescueSequence,
|
|
117786
|
+
serverReason: error48.code
|
|
117787
|
+
}, {
|
|
117788
|
+
schedulerInstanceId: String(input.schedulerInstanceId || "").trim(),
|
|
117789
|
+
signal: timeoutController.signal
|
|
117790
|
+
});
|
|
117791
|
+
appendRuntimeDebugEvent({ label: "account_state_prompt_rescued", note: `job=${rescued.job_id} reason=${error48.code}` });
|
|
117792
|
+
return accountStateFromServerPromptRescueSnapshot(rescued.snapshot, localFallbackSymbol);
|
|
117793
|
+
} catch (rescueError) {
|
|
117794
|
+
if (timeoutController.signal.aborted) throw rescueError;
|
|
117795
|
+
appendRuntimeDebugEvent({
|
|
117796
|
+
label: "account_state_prompt_rescue_unavailable",
|
|
117797
|
+
note: rescueError instanceof Error ? rescueError.message : String(rescueError),
|
|
117798
|
+
outcome: "error"
|
|
117799
|
+
});
|
|
117800
|
+
throw error48;
|
|
117801
|
+
}
|
|
117583
117802
|
}).then((state2) => {
|
|
117584
117803
|
observeAccountState(input, state2);
|
|
117585
117804
|
latestPositions = state2.positions;
|
|
@@ -120182,6 +120401,8 @@ var init_engine = __esm({
|
|
|
120182
120401
|
this._stopPromise = null;
|
|
120183
120402
|
this._scheduledSuspendPromise = null;
|
|
120184
120403
|
this._loopIntervalMs = null;
|
|
120404
|
+
// When this runtime last checked in for Copy Trading (_processClientCopyTrading).
|
|
120405
|
+
this._lastClientCopyCheckInAtMs = null;
|
|
120185
120406
|
this._heartbeatIntervalMs = null;
|
|
120186
120407
|
this._leaseStaleAfterMs = null;
|
|
120187
120408
|
this._heartbeatOfflineAfterMs = null;
|
|
@@ -122577,6 +122798,18 @@ var init_engine = __esm({
|
|
|
122577
122798
|
this._analysisAbortReason = null;
|
|
122578
122799
|
const analysisAbortController = new AbortController();
|
|
122579
122800
|
this._analysisAbortController = analysisAbortController;
|
|
122801
|
+
let copyTradingCheckedIn = false;
|
|
122802
|
+
const checkInCopyTrading = async (config2) => {
|
|
122803
|
+
copyTradingCheckedIn = true;
|
|
122804
|
+
this._lastClientCopyCheckInAtMs = Date.now();
|
|
122805
|
+
await this._processClientCopyTrading({
|
|
122806
|
+
profileId,
|
|
122807
|
+
runtimeSessionId: sessionId,
|
|
122808
|
+
runtimeDeviceId: deviceId,
|
|
122809
|
+
config: config2,
|
|
122810
|
+
signal: analysisAbortController.signal
|
|
122811
|
+
});
|
|
122812
|
+
};
|
|
122580
122813
|
let decisionSubmitted = false;
|
|
122581
122814
|
let cycleModelCalls = [];
|
|
122582
122815
|
let cycleModelCallsReported = false;
|
|
@@ -122850,13 +123083,7 @@ var init_engine = __esm({
|
|
|
122850
123083
|
}
|
|
122851
123084
|
if (runtimeMode === "trader" && !cancelled()) {
|
|
122852
123085
|
try {
|
|
122853
|
-
await this.
|
|
122854
|
-
profileId,
|
|
122855
|
-
runtimeSessionId: sessionId,
|
|
122856
|
-
runtimeDeviceId: deviceId,
|
|
122857
|
-
config: await this.getExecutionConfig(profileId),
|
|
122858
|
-
signal: analysisAbortController.signal
|
|
122859
|
-
});
|
|
123086
|
+
await checkInCopyTrading(await this.getExecutionConfig(profileId));
|
|
122860
123087
|
} catch (copyTradingError) {
|
|
122861
123088
|
appendRuntimeDebugEvent({
|
|
122862
123089
|
label: "ai_schedule_paused_copy_poll_failed",
|
|
@@ -123040,14 +123267,7 @@ var init_engine = __esm({
|
|
|
123040
123267
|
if (this._primaryAnalysisDisabled) {
|
|
123041
123268
|
this._nextRunAtMs = null;
|
|
123042
123269
|
}
|
|
123043
|
-
|
|
123044
|
-
await this._processClientCopyTrading({
|
|
123045
|
-
profileId,
|
|
123046
|
-
runtimeSessionId: sessionId,
|
|
123047
|
-
runtimeDeviceId: deviceId,
|
|
123048
|
-
config: config2,
|
|
123049
|
-
signal: analysisAbortController.signal
|
|
123050
|
-
});
|
|
123270
|
+
await checkInCopyTrading(await this.getExecutionConfig(profileId));
|
|
123051
123271
|
}
|
|
123052
123272
|
this._lastError = null;
|
|
123053
123273
|
this._notifyListeners();
|
|
@@ -123574,13 +123794,7 @@ var init_engine = __esm({
|
|
|
123574
123794
|
if (this._windowHandoffRequested) {
|
|
123575
123795
|
return;
|
|
123576
123796
|
}
|
|
123577
|
-
await
|
|
123578
|
-
profileId,
|
|
123579
|
-
runtimeSessionId: sessionId,
|
|
123580
|
-
runtimeDeviceId: deviceId,
|
|
123581
|
-
config: config2,
|
|
123582
|
-
signal: analysisAbortController.signal
|
|
123583
|
-
});
|
|
123797
|
+
await checkInCopyTrading(config2);
|
|
123584
123798
|
this._executionModeMismatchConsecutiveCount = 0;
|
|
123585
123799
|
if (executionFailures.length > 0) {
|
|
123586
123800
|
cycleOutcome = "failed";
|
|
@@ -123781,6 +123995,17 @@ var init_engine = __esm({
|
|
|
123781
123995
|
if (this._isExecuting) {
|
|
123782
123996
|
this._isExecuting = false;
|
|
123783
123997
|
}
|
|
123998
|
+
if (runtimeMode === "trader" && this._expectedExecutionMode !== "server" && !copyTradingCheckedIn && this._state === "running" && !this._isStopping && !this._windowHandoffRequested && !this._killswitchLatched && !this._executionFinalizationRequired && !this._scheduledSuspendPromise && !analysisAbortController.signal.aborted && this._profileId === profileId && this._sessionId === sessionId && this._deviceId === deviceId && (this._lastClientCopyCheckInAtMs === null || this._loopIntervalMs === null || Date.now() - this._lastClientCopyCheckInAtMs >= this._loopIntervalMs)) {
|
|
123999
|
+
try {
|
|
124000
|
+
await checkInCopyTrading(await this.getExecutionConfig(profileId));
|
|
124001
|
+
} catch (copyTradingError) {
|
|
124002
|
+
appendRuntimeDebugEvent({
|
|
124003
|
+
label: "copy_trading_cycle_end_check_in_failed",
|
|
124004
|
+
note: getSanitizedRuntimeErrorMessage(copyTradingError) || "Copy Trading check-in failed.",
|
|
124005
|
+
outcome: "error"
|
|
124006
|
+
});
|
|
124007
|
+
}
|
|
124008
|
+
}
|
|
123784
124009
|
if (this._analysisAbortController === analysisAbortController) {
|
|
123785
124010
|
this._analysisAbortController = null;
|
|
123786
124011
|
}
|