@vtxmacro/cli 2026.9.42 → 2026.9.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/vtx-service-bootstrap.js +1 -1
- package/bin/vtx.js +224 -8
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ import { fileURLToPath } from "node:url";
|
|
|
16
16
|
// agent-cli-release.json
|
|
17
17
|
var agent_cli_release_default = {
|
|
18
18
|
package_name: "@vtxmacro/cli",
|
|
19
|
-
package_version: "2026.9.
|
|
19
|
+
package_version: "2026.9.43",
|
|
20
20
|
codex_package_name: "@openai/codex",
|
|
21
21
|
codex_version: "0.153.3",
|
|
22
22
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
package/bin/vtx.js
CHANGED
|
@@ -77,7 +77,7 @@ var init_agent_cli_release = __esm({
|
|
|
77
77
|
"agent-cli-release.json"() {
|
|
78
78
|
agent_cli_release_default = {
|
|
79
79
|
package_name: "@vtxmacro/cli",
|
|
80
|
-
package_version: "2026.9.
|
|
80
|
+
package_version: "2026.9.43",
|
|
81
81
|
codex_package_name: "@openai/codex",
|
|
82
82
|
codex_version: "0.153.3",
|
|
83
83
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
|
@@ -47620,13 +47620,27 @@ async function runAndReportLocalWorkCycle(options, state, leaseToken, context) {
|
|
|
47620
47620
|
...buildRuntimePayload(state),
|
|
47621
47621
|
last_run_at: lastRunAt
|
|
47622
47622
|
};
|
|
47623
|
+
let decisionResponse = null;
|
|
47623
47624
|
if (result2.decision) {
|
|
47624
|
-
await options.client.reportRuntimeDecision(options.profileId, {
|
|
47625
|
+
decisionResponse = await options.client.reportRuntimeDecision(options.profileId, {
|
|
47625
47626
|
...basePayload,
|
|
47626
47627
|
...result2.decision
|
|
47627
47628
|
}, leaseToken);
|
|
47628
47629
|
}
|
|
47629
|
-
|
|
47630
|
+
let deferredTradeSync = null;
|
|
47631
|
+
if (result2.afterDecision) {
|
|
47632
|
+
const runtime = objectOrNull2(objectOrNull2(decisionResponse)?.runtime);
|
|
47633
|
+
const decision = runtime?.last_decision;
|
|
47634
|
+
const units = runtime?.last_units;
|
|
47635
|
+
const requestedUnits = Number(result2.decision?.units);
|
|
47636
|
+
if (!result2.decision || !["BUY", "SELL", "HOLD"].includes(String(decision)) || decision !== result2.decision.decision || typeof units !== "number" || !Number.isSafeInteger(units) || units < 0 || !Number.isSafeInteger(requestedUnits) || units > requestedUnits || (decision === "HOLD" ? units !== 0 : units <= 0)) {
|
|
47637
|
+
throw new Error("Runtime decision acceptance is unavailable or inconsistent; execution skipped.");
|
|
47638
|
+
}
|
|
47639
|
+
deferredTradeSync = await result2.afterDecision({
|
|
47640
|
+
decision,
|
|
47641
|
+
units
|
|
47642
|
+
});
|
|
47643
|
+
}
|
|
47630
47644
|
const tradeSync = deferredTradeSync ? { ...result2.tradeSync ?? {}, ...deferredTradeSync } : result2.tradeSync;
|
|
47631
47645
|
if (tradeSync) {
|
|
47632
47646
|
await options.client.reportRuntimeTradeSync(options.profileId, {
|
|
@@ -91386,6 +91400,167 @@ var init_runtime_execution = __esm({
|
|
|
91386
91400
|
}
|
|
91387
91401
|
});
|
|
91388
91402
|
|
|
91403
|
+
// lib/runtime/decision-contract.ts
|
|
91404
|
+
var VISIBLE_REASONING_KEYS, VISIBLE_REASONING_KEY_SET, VISIBLE_REASONING_ALIAS_KEY_SET, normalizeDecisionUnits, normalizeDecisionValue;
|
|
91405
|
+
var init_decision_contract = __esm({
|
|
91406
|
+
"lib/runtime/decision-contract.ts"() {
|
|
91407
|
+
"use strict";
|
|
91408
|
+
init_define_VTX_EXO_POLICY();
|
|
91409
|
+
init_define_VTX_GROK_POLICY();
|
|
91410
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
91411
|
+
VISIBLE_REASONING_KEYS = [
|
|
91412
|
+
"reasoning",
|
|
91413
|
+
"final_reasoning",
|
|
91414
|
+
"final_answer",
|
|
91415
|
+
"answer",
|
|
91416
|
+
"output_text",
|
|
91417
|
+
"text",
|
|
91418
|
+
"content"
|
|
91419
|
+
];
|
|
91420
|
+
VISIBLE_REASONING_KEY_SET = new Set(VISIBLE_REASONING_KEYS);
|
|
91421
|
+
VISIBLE_REASONING_ALIAS_KEY_SET = new Set([
|
|
91422
|
+
...VISIBLE_REASONING_KEYS,
|
|
91423
|
+
"reason"
|
|
91424
|
+
].map((key) => key.replace(/[^a-z0-9]+/gi, "").toLowerCase()));
|
|
91425
|
+
normalizeDecisionUnits = (rawUnits, decision) => {
|
|
91426
|
+
const parsedUnits = Number(rawUnits);
|
|
91427
|
+
if (Number.isFinite(parsedUnits) && parsedUnits >= 0) {
|
|
91428
|
+
return Math.trunc(parsedUnits);
|
|
91429
|
+
}
|
|
91430
|
+
return 0;
|
|
91431
|
+
};
|
|
91432
|
+
normalizeDecisionValue = (rawDecision) => {
|
|
91433
|
+
const decisionValue = String(rawDecision || "").trim().toUpperCase();
|
|
91434
|
+
return decisionValue === "BUY" || decisionValue === "SELL" ? decisionValue : "HOLD";
|
|
91435
|
+
};
|
|
91436
|
+
}
|
|
91437
|
+
});
|
|
91438
|
+
|
|
91439
|
+
// lib/runtime/constraint-contract.ts
|
|
91440
|
+
var normalizeOptionalInt, evaluateRuntimeDecisionAcceptance;
|
|
91441
|
+
var init_constraint_contract = __esm({
|
|
91442
|
+
"lib/runtime/constraint-contract.ts"() {
|
|
91443
|
+
"use strict";
|
|
91444
|
+
init_define_VTX_EXO_POLICY();
|
|
91445
|
+
init_define_VTX_GROK_POLICY();
|
|
91446
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
91447
|
+
init_execution_guard_contract();
|
|
91448
|
+
init_decision_contract();
|
|
91449
|
+
normalizeOptionalInt = (value) => {
|
|
91450
|
+
if (value === null || value === void 0) {
|
|
91451
|
+
return null;
|
|
91452
|
+
}
|
|
91453
|
+
const parsed = Number.parseInt(String(value), 10);
|
|
91454
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
91455
|
+
};
|
|
91456
|
+
evaluateRuntimeDecisionAcceptance = (input) => {
|
|
91457
|
+
const decision = normalizeDecisionValue(input.decision);
|
|
91458
|
+
const units = normalizeDecisionUnits(input.units, decision);
|
|
91459
|
+
if (decision === "HOLD") {
|
|
91460
|
+
return {
|
|
91461
|
+
accepted: true,
|
|
91462
|
+
decision,
|
|
91463
|
+
normalized_units: 0,
|
|
91464
|
+
reason_code: null
|
|
91465
|
+
};
|
|
91466
|
+
}
|
|
91467
|
+
if (input.constraints.runtime_disabled) {
|
|
91468
|
+
return {
|
|
91469
|
+
accepted: false,
|
|
91470
|
+
decision,
|
|
91471
|
+
normalized_units: 0,
|
|
91472
|
+
reason_code: "runtime_disabled"
|
|
91473
|
+
};
|
|
91474
|
+
}
|
|
91475
|
+
if (input.constraints.kill_switch_active) {
|
|
91476
|
+
return {
|
|
91477
|
+
accepted: false,
|
|
91478
|
+
decision,
|
|
91479
|
+
normalized_units: 0,
|
|
91480
|
+
reason_code: "kill_switch_active"
|
|
91481
|
+
};
|
|
91482
|
+
}
|
|
91483
|
+
if (!input.constraints.model_allowed) {
|
|
91484
|
+
return {
|
|
91485
|
+
accepted: false,
|
|
91486
|
+
decision,
|
|
91487
|
+
normalized_units: 0,
|
|
91488
|
+
reason_code: "model_ineligible"
|
|
91489
|
+
};
|
|
91490
|
+
}
|
|
91491
|
+
if (!input.constraints.provider_allowed) {
|
|
91492
|
+
return {
|
|
91493
|
+
accepted: false,
|
|
91494
|
+
decision,
|
|
91495
|
+
normalized_units: 0,
|
|
91496
|
+
reason_code: "provider_ineligible"
|
|
91497
|
+
};
|
|
91498
|
+
}
|
|
91499
|
+
if (units <= 0) {
|
|
91500
|
+
return {
|
|
91501
|
+
accepted: false,
|
|
91502
|
+
decision,
|
|
91503
|
+
normalized_units: 0,
|
|
91504
|
+
reason_code: "invalid_units"
|
|
91505
|
+
};
|
|
91506
|
+
}
|
|
91507
|
+
const maxPerPrompt = Math.max(Math.trunc(Number(input.constraints.max_trades_per_prompt) || 0), 0);
|
|
91508
|
+
if (maxPerPrompt === 0) {
|
|
91509
|
+
return {
|
|
91510
|
+
accepted: false,
|
|
91511
|
+
decision,
|
|
91512
|
+
normalized_units: 0,
|
|
91513
|
+
reason_code: "max_per_prompt_zero"
|
|
91514
|
+
};
|
|
91515
|
+
}
|
|
91516
|
+
const remainingGlobal = normalizeOptionalInt(input.constraints.remaining_global_units);
|
|
91517
|
+
const remainingExchange = normalizeOptionalInt(input.constraints.remaining_exchange_units);
|
|
91518
|
+
const remainingAsset = normalizeOptionalInt(input.constraints.remaining_asset_units);
|
|
91519
|
+
const currentSymbolSignedUnits = normalizeOptionalInt(input.constraints.current_symbol_signed_units) ?? 0;
|
|
91520
|
+
let cappedUnits = Math.min(units, maxPerPrompt);
|
|
91521
|
+
const exposureIncrease = (candidateUnits) => {
|
|
91522
|
+
const classified = classifyExecutionIntent(decision, candidateUnits, currentSymbolSignedUnits);
|
|
91523
|
+
return Math.max(
|
|
91524
|
+
0,
|
|
91525
|
+
Math.abs(classified.targetSignedUnits) - Math.abs(currentSymbolSignedUnits)
|
|
91526
|
+
);
|
|
91527
|
+
};
|
|
91528
|
+
const fitsCapacity = (candidateUnits) => {
|
|
91529
|
+
const increase = exposureIncrease(candidateUnits);
|
|
91530
|
+
if (remainingGlobal !== null && increase > Math.max(remainingGlobal, 0)) {
|
|
91531
|
+
return false;
|
|
91532
|
+
}
|
|
91533
|
+
if (remainingExchange !== null && increase > Math.max(remainingExchange, 0)) {
|
|
91534
|
+
return false;
|
|
91535
|
+
}
|
|
91536
|
+
if (remainingAsset !== null && increase > Math.max(remainingAsset, 0)) {
|
|
91537
|
+
return false;
|
|
91538
|
+
}
|
|
91539
|
+
return true;
|
|
91540
|
+
};
|
|
91541
|
+
while (cappedUnits > 0 && !fitsCapacity(cappedUnits)) {
|
|
91542
|
+
cappedUnits -= 1;
|
|
91543
|
+
}
|
|
91544
|
+
if (cappedUnits <= 0) {
|
|
91545
|
+
const requestedExposureIncrease = exposureIncrease(Math.min(units, maxPerPrompt));
|
|
91546
|
+
const reasonCode = requestedExposureIncrease > 0 && remainingGlobal !== null && remainingGlobal <= 0 ? "global_capacity_reached" : requestedExposureIncrease > 0 && remainingExchange !== null && remainingExchange <= 0 ? "exchange_capacity_reached" : requestedExposureIncrease > 0 && remainingAsset !== null && remainingAsset <= 0 ? "asset_capacity_reached" : "capacity_reached";
|
|
91547
|
+
return {
|
|
91548
|
+
accepted: false,
|
|
91549
|
+
decision,
|
|
91550
|
+
normalized_units: 0,
|
|
91551
|
+
reason_code: reasonCode
|
|
91552
|
+
};
|
|
91553
|
+
}
|
|
91554
|
+
return {
|
|
91555
|
+
accepted: true,
|
|
91556
|
+
decision,
|
|
91557
|
+
normalized_units: cappedUnits,
|
|
91558
|
+
reason_code: cappedUnits < units ? "units_capped" : null
|
|
91559
|
+
};
|
|
91560
|
+
};
|
|
91561
|
+
}
|
|
91562
|
+
});
|
|
91563
|
+
|
|
91389
91564
|
// lib/runtime/provider-observability.ts
|
|
91390
91565
|
var record4, identifier, count3, normalizeProviderDiagnostics;
|
|
91391
91566
|
var init_provider_observability = __esm({
|
|
@@ -92566,6 +92741,46 @@ function createHeadlessLocalWorker(options) {
|
|
|
92566
92741
|
message: `Tradability ${providerDecision.tradability ?? "missing"} is below the ${classifiedIntent === "open" ? "Open" : "Add"} minimum of ${applicableMinimum}. No order was placed.`
|
|
92567
92742
|
}
|
|
92568
92743
|
} : null;
|
|
92744
|
+
let executionDecision = { decision: providerDecision.decision, units: providerDecision.units };
|
|
92745
|
+
if (localHyperliquidContext && providerDecision.decision !== "HOLD") {
|
|
92746
|
+
const constraints = objectOrNull3(metadata.constraint_contract) ?? {};
|
|
92747
|
+
const limit = (key) => {
|
|
92748
|
+
const raw = key === "max_trades_per_exchange" && !Object.hasOwn(promptKnobs, key) ? promptKnobs.max_trades_global : promptKnobs[key];
|
|
92749
|
+
if (raw == null) throw new Error(`Missing headless runtime ${key}.`);
|
|
92750
|
+
const value = requireFiniteNumber(raw, key);
|
|
92751
|
+
if (!Number.isSafeInteger(value) || value < 0) throw new Error(`Invalid headless runtime ${key}.`);
|
|
92752
|
+
return value;
|
|
92753
|
+
};
|
|
92754
|
+
const unitSize = localHyperliquidContext.executionContext.unitSizeUsdc;
|
|
92755
|
+
const venue = getHyperliquidMarketDex(symbol2);
|
|
92756
|
+
let globalUsage = 0;
|
|
92757
|
+
let exchangeUsage = 0;
|
|
92758
|
+
let currentSignedUnits = 0;
|
|
92759
|
+
for (const position of localHyperliquidContext.accountState.positions) {
|
|
92760
|
+
if (Number(position.size) === 0) continue;
|
|
92761
|
+
const entryPrice = requirePositiveNumber2(position.entry_price, "position entry price");
|
|
92762
|
+
const signedUnits = signedUnitsFromPosition(Number(position.size), entryPrice, unitSize);
|
|
92763
|
+
globalUsage += Math.abs(signedUnits);
|
|
92764
|
+
if (getHyperliquidMarketDex(position.symbol) === venue) exchangeUsage += Math.abs(signedUnits);
|
|
92765
|
+
if (normalizeRuntimeSymbol(position.symbol) === normalizeRuntimeSymbol(symbol2)) currentSignedUnits = signedUnits;
|
|
92766
|
+
}
|
|
92767
|
+
const accepted = evaluateRuntimeDecisionAcceptance({
|
|
92768
|
+
...executionDecision,
|
|
92769
|
+
constraints: {
|
|
92770
|
+
runtime_disabled: constraints.runtime_disabled === true,
|
|
92771
|
+
kill_switch_active: constraints.kill_switch_active === true,
|
|
92772
|
+
max_trades_per_prompt: limit("max_trades_per_prompt"),
|
|
92773
|
+
remaining_global_units: limit("max_trades_global") - globalUsage,
|
|
92774
|
+
remaining_exchange_units: limit("max_trades_per_exchange") - exchangeUsage,
|
|
92775
|
+
remaining_asset_units: limit("max_trades_per_asset") - Math.abs(currentSignedUnits),
|
|
92776
|
+
current_symbol_signed_units: currentSignedUnits,
|
|
92777
|
+
model_allowed: constraints.model_allowed !== false,
|
|
92778
|
+
provider_allowed: constraints.provider_allowed !== false
|
|
92779
|
+
}
|
|
92780
|
+
});
|
|
92781
|
+
if (!accepted.accepted) throw new Error(`Headless runtime decision rejected: ${accepted.reason_code}`);
|
|
92782
|
+
executionDecision = { decision: accepted.decision, units: accepted.normalized_units };
|
|
92783
|
+
}
|
|
92569
92784
|
const envelope = metadata.envelope ?? {};
|
|
92570
92785
|
const baseTradeSync = {
|
|
92571
92786
|
analysis_run_id: analysisRunId,
|
|
@@ -92585,8 +92800,8 @@ function createHeadlessLocalWorker(options) {
|
|
|
92585
92800
|
contract_version: requireText(envelope.contract_version, "contract version"),
|
|
92586
92801
|
contract_hash: requireText(envelope.contract_hash, "contract hash"),
|
|
92587
92802
|
policy_generation_id: requireText(envelope.policy_generation_id, "policy generation id"),
|
|
92588
|
-
decision:
|
|
92589
|
-
units:
|
|
92803
|
+
decision: executionDecision.decision,
|
|
92804
|
+
units: executionDecision.units,
|
|
92590
92805
|
final_tradability: providerDecision.tradability,
|
|
92591
92806
|
reasoning: providerDecision.reasoning,
|
|
92592
92807
|
model: requireText(prompt.model ?? metadata.model, "model"),
|
|
@@ -92612,7 +92827,7 @@ function createHeadlessLocalWorker(options) {
|
|
|
92612
92827
|
execution_snapshot_id: tradabilityBlockExecution ? decisionSnapshotId : void 0,
|
|
92613
92828
|
executions: tradabilityBlockExecution ? [tradabilityBlockExecution] : []
|
|
92614
92829
|
},
|
|
92615
|
-
afterDecision: localHyperliquidContext ? async () => {
|
|
92830
|
+
afterDecision: localHyperliquidContext ? async (accepted) => {
|
|
92616
92831
|
const freshProfile = objectOrNull3(await options.client.getSecretStatus(input.profileId));
|
|
92617
92832
|
const freshWalletAddress = requireText(
|
|
92618
92833
|
freshProfile?.hyperliquid_wallet_address,
|
|
@@ -92631,8 +92846,8 @@ function createHeadlessLocalWorker(options) {
|
|
|
92631
92846
|
cycleId: analysisRunId,
|
|
92632
92847
|
signingKey: localHyperliquidContext.signingKey,
|
|
92633
92848
|
config: buildHeadlessExchangeConfig(llmConfig),
|
|
92634
|
-
decision:
|
|
92635
|
-
units:
|
|
92849
|
+
decision: accepted.decision,
|
|
92850
|
+
units: accepted.units,
|
|
92636
92851
|
executionContext: localHyperliquidContext.executionContext
|
|
92637
92852
|
});
|
|
92638
92853
|
return {
|
|
@@ -92655,6 +92870,7 @@ var init_headless_local_worker = __esm({
|
|
|
92655
92870
|
init_hyperliquid_account_state_adapter();
|
|
92656
92871
|
init_hyperliquid_market_symbol();
|
|
92657
92872
|
init_runtime_execution();
|
|
92873
|
+
init_constraint_contract();
|
|
92658
92874
|
init_protection_storage();
|
|
92659
92875
|
init_execution_guard_contract();
|
|
92660
92876
|
init_inference_observability();
|