@blockrun/clawrouter 0.12.265 → 0.12.266
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/dist/cli.js +1383 -417
- package/dist/index.d.ts +52 -23
- package/dist/index.js +1101 -388
- package/docs/clawrouter-cuts-llm-api-costs-500x.md +1 -1
- package/docs/configuration.md +26 -24
- package/docs/troubleshooting.md +6 -2
- package/openclaw.plugin.json +2 -1
- package/package.json +3 -2
- package/scripts/reinstall.sh +181 -77
- package/scripts/uninstall.sh +53 -8
- package/scripts/update.ps1 +215 -33
- package/scripts/update.sh +223 -86
package/dist/index.js
CHANGED
|
@@ -8006,15 +8006,15 @@ function wNAF(c, bits) {
|
|
|
8006
8006
|
const { windows, windowSize } = calcWOpts(W, bits);
|
|
8007
8007
|
const points = [];
|
|
8008
8008
|
let p = elm;
|
|
8009
|
-
let
|
|
8009
|
+
let base4 = p;
|
|
8010
8010
|
for (let window2 = 0; window2 < windows; window2++) {
|
|
8011
|
-
|
|
8012
|
-
points.push(
|
|
8011
|
+
base4 = p;
|
|
8012
|
+
points.push(base4);
|
|
8013
8013
|
for (let i = 1; i < windowSize; i++) {
|
|
8014
|
-
|
|
8015
|
-
points.push(
|
|
8014
|
+
base4 = base4.add(p);
|
|
8015
|
+
points.push(base4);
|
|
8016
8016
|
}
|
|
8017
|
-
p =
|
|
8017
|
+
p = base4.double();
|
|
8018
8018
|
}
|
|
8019
8019
|
return points;
|
|
8020
8020
|
},
|
|
@@ -10652,7 +10652,7 @@ async function internal_estimateFeesPerGas(client, args) {
|
|
|
10652
10652
|
throw new BaseFeeScalarError();
|
|
10653
10653
|
const decimals = baseFeeMultiplier.toString().split(".")[1]?.length ?? 0;
|
|
10654
10654
|
const denominator = 10 ** decimals;
|
|
10655
|
-
const multiply = (
|
|
10655
|
+
const multiply = (base4) => base4 * BigInt(Math.round(baseFeeMultiplier * denominator)) / BigInt(denominator);
|
|
10656
10656
|
const block = block_ ? block_ : await getAction(client, getBlock, "getBlock")({});
|
|
10657
10657
|
if (typeof chain3?.fees?.estimateFeesPerGas === "function") {
|
|
10658
10658
|
const fees = await chain3.fees.estimateFeesPerGas({
|
|
@@ -11123,7 +11123,7 @@ async function fillTransaction(client, parameters) {
|
|
|
11123
11123
|
throw new BaseFeeScalarError();
|
|
11124
11124
|
const decimals = feeMultiplier.toString().split(".")[1]?.length ?? 0;
|
|
11125
11125
|
const denominator = 10 ** decimals;
|
|
11126
|
-
const multiplyFee = (
|
|
11126
|
+
const multiplyFee = (base4) => base4 * BigInt(Math.round(feeMultiplier * denominator)) / BigInt(denominator);
|
|
11127
11127
|
if (!transaction.feePayerSignature) {
|
|
11128
11128
|
if (transaction.maxFeePerGas && !parameters.maxFeePerGas)
|
|
11129
11129
|
transaction.maxFeePerGas = multiplyFee(transaction.maxFeePerGas);
|
|
@@ -14081,17 +14081,17 @@ async function call(client, args) {
|
|
|
14081
14081
|
}
|
|
14082
14082
|
}
|
|
14083
14083
|
const params = (() => {
|
|
14084
|
-
const
|
|
14084
|
+
const base4 = [
|
|
14085
14085
|
request2,
|
|
14086
14086
|
block
|
|
14087
14087
|
];
|
|
14088
14088
|
if (rpcStateOverride && rpcBlockOverrides)
|
|
14089
|
-
return [...
|
|
14089
|
+
return [...base4, rpcStateOverride, rpcBlockOverrides];
|
|
14090
14090
|
if (rpcStateOverride)
|
|
14091
|
-
return [...
|
|
14091
|
+
return [...base4, rpcStateOverride];
|
|
14092
14092
|
if (rpcBlockOverrides)
|
|
14093
|
-
return [...
|
|
14094
|
-
return
|
|
14093
|
+
return [...base4, {}, rpcBlockOverrides];
|
|
14094
|
+
return base4;
|
|
14095
14095
|
})();
|
|
14096
14096
|
const response = await client.request({
|
|
14097
14097
|
method: "eth_call",
|
|
@@ -15497,14 +15497,14 @@ function createClient(parameters) {
|
|
|
15497
15497
|
uid: uid(),
|
|
15498
15498
|
...experimental_blockTag ? { experimental_blockTag } : {}
|
|
15499
15499
|
};
|
|
15500
|
-
function extend2(
|
|
15500
|
+
function extend2(base4) {
|
|
15501
15501
|
return (extendFn) => {
|
|
15502
|
-
const extended = extendFn(
|
|
15502
|
+
const extended = extendFn(base4);
|
|
15503
15503
|
for (const key3 in client)
|
|
15504
15504
|
delete extended[key3];
|
|
15505
|
-
const combined = { ...
|
|
15505
|
+
const combined = { ...base4, ...extended };
|
|
15506
15506
|
for (const key3 in extended) {
|
|
15507
|
-
const a =
|
|
15507
|
+
const a = base4[key3];
|
|
15508
15508
|
const b = extended[key3];
|
|
15509
15509
|
if (isPlainObject(a) && isPlainObject(b))
|
|
15510
15510
|
combined[key3] = { ...a, ...b };
|
|
@@ -17257,10 +17257,10 @@ function defineChain(chain3) {
|
|
|
17257
17257
|
serializers: void 0,
|
|
17258
17258
|
...chain3
|
|
17259
17259
|
};
|
|
17260
|
-
function extend2(
|
|
17260
|
+
function extend2(base4) {
|
|
17261
17261
|
return (fnOrExtended) => {
|
|
17262
|
-
const properties = typeof fnOrExtended === "function" ? fnOrExtended(
|
|
17263
|
-
const combined = { ...
|
|
17262
|
+
const properties = typeof fnOrExtended === "function" ? fnOrExtended(base4) : fnOrExtended;
|
|
17263
|
+
const combined = { ...base4, ...properties };
|
|
17264
17264
|
return Object.assign(combined, { extend: extend2(combined) });
|
|
17265
17265
|
};
|
|
17266
17266
|
}
|
|
@@ -17624,9 +17624,9 @@ function validateTypedData(parameters) {
|
|
|
17624
17624
|
throw new InvalidTypedDataTypeError({ type });
|
|
17625
17625
|
const integerMatch = type.match(integerRegex2);
|
|
17626
17626
|
if (integerMatch && (typeof value === "number" || typeof value === "bigint")) {
|
|
17627
|
-
const [_type,
|
|
17627
|
+
const [_type, base4, size_] = integerMatch;
|
|
17628
17628
|
numberToHex(value, {
|
|
17629
|
-
signed:
|
|
17629
|
+
signed: base4 === "int",
|
|
17630
17630
|
size: Number.parseInt(size_, 10) / 8
|
|
17631
17631
|
});
|
|
17632
17632
|
}
|
|
@@ -20255,15 +20255,15 @@ function wNAF2(c, bits) {
|
|
|
20255
20255
|
const { windows, windowSize } = calcWOpts2(W, bits);
|
|
20256
20256
|
const points = [];
|
|
20257
20257
|
let p = elm;
|
|
20258
|
-
let
|
|
20258
|
+
let base4 = p;
|
|
20259
20259
|
for (let window2 = 0; window2 < windows; window2++) {
|
|
20260
|
-
|
|
20261
|
-
points.push(
|
|
20260
|
+
base4 = p;
|
|
20261
|
+
points.push(base4);
|
|
20262
20262
|
for (let i = 1; i < windowSize; i++) {
|
|
20263
|
-
|
|
20264
|
-
points.push(
|
|
20263
|
+
base4 = base4.add(p);
|
|
20264
|
+
points.push(base4);
|
|
20265
20265
|
}
|
|
20266
|
-
p =
|
|
20266
|
+
p = base4.double();
|
|
20267
20267
|
}
|
|
20268
20268
|
return points;
|
|
20269
20269
|
},
|
|
@@ -32847,23 +32847,23 @@ var init_types = __esm({
|
|
|
32847
32847
|
}
|
|
32848
32848
|
if (effect.type === "transform") {
|
|
32849
32849
|
if (ctx.common.async === false) {
|
|
32850
|
-
const
|
|
32850
|
+
const base4 = this._def.schema._parseSync({
|
|
32851
32851
|
data: ctx.data,
|
|
32852
32852
|
path: ctx.path,
|
|
32853
32853
|
parent: ctx
|
|
32854
32854
|
});
|
|
32855
|
-
if (!isValid(
|
|
32855
|
+
if (!isValid(base4))
|
|
32856
32856
|
return INVALID;
|
|
32857
|
-
const result = effect.transform(
|
|
32857
|
+
const result = effect.transform(base4.value, checkCtx);
|
|
32858
32858
|
if (result instanceof Promise) {
|
|
32859
32859
|
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
32860
32860
|
}
|
|
32861
32861
|
return { status: status.value, value: result };
|
|
32862
32862
|
} else {
|
|
32863
|
-
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((
|
|
32864
|
-
if (!isValid(
|
|
32863
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base4) => {
|
|
32864
|
+
if (!isValid(base4))
|
|
32865
32865
|
return INVALID;
|
|
32866
|
-
return Promise.resolve(effect.transform(
|
|
32866
|
+
return Promise.resolve(effect.transform(base4.value, checkCtx)).then((result) => ({
|
|
32867
32867
|
status: status.value,
|
|
32868
32868
|
value: result
|
|
32869
32869
|
}));
|
|
@@ -34441,6 +34441,11 @@ function cloneLimits(limits) {
|
|
|
34441
34441
|
}
|
|
34442
34442
|
return clone;
|
|
34443
34443
|
}
|
|
34444
|
+
function canonicalLimits(limits) {
|
|
34445
|
+
return JSON.stringify(
|
|
34446
|
+
Object.fromEntries(Object.entries(limits).sort(([a], [b]) => a < b ? -1 : 1))
|
|
34447
|
+
);
|
|
34448
|
+
}
|
|
34444
34449
|
function parseQuotedAmountUsd(selected) {
|
|
34445
34450
|
const raw = selected.amount ?? selected.maxAmountRequired;
|
|
34446
34451
|
if (typeof raw !== "string" || !CANONICAL_AMOUNT.test(raw)) {
|
|
@@ -34516,7 +34521,7 @@ function formatDuration(seconds) {
|
|
|
34516
34521
|
return mins > 0 ? `${hours}h ${mins}m` : `${hours}h`;
|
|
34517
34522
|
}
|
|
34518
34523
|
}
|
|
34519
|
-
var WALLET_DIR, HOUR_MS, DAY_MS, CAIP2_BASE, CAIP2_SOLANA_MAINNET, POLICY_LISTS, ADDRESS_LISTS, EVM_ADDRESS, MalformedSpendPolicyError, FileSpendControlStorage, InMemorySpendControlStorage, RESERVATION_TTL_MS, SpendControl, SpendPolicyError, CANONICAL_AMOUNT;
|
|
34524
|
+
var WALLET_DIR, HOUR_MS, DAY_MS, CAIP2_BASE, CAIP2_SOLANA_MAINNET, PAYABLE_NETWORKS, POLICY_LISTS, ADDRESS_LISTS, EVM_ADDRESS, MalformedSpendPolicyError, SpendPolicyConflictError, FileSpendControlStorage, InMemorySpendControlStorage, RESERVATION_TTL_MS, SpendControl, SpendPolicyError, CANONICAL_AMOUNT;
|
|
34520
34525
|
var init_spend_control = __esm({
|
|
34521
34526
|
"src/spend-control.ts"() {
|
|
34522
34527
|
"use strict";
|
|
@@ -34526,6 +34531,7 @@ var init_spend_control = __esm({
|
|
|
34526
34531
|
DAY_MS = 24 * HOUR_MS;
|
|
34527
34532
|
CAIP2_BASE = "eip155:8453";
|
|
34528
34533
|
CAIP2_SOLANA_MAINNET = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
|
|
34534
|
+
PAYABLE_NETWORKS = [CAIP2_BASE, CAIP2_SOLANA_MAINNET];
|
|
34529
34535
|
POLICY_LISTS = [
|
|
34530
34536
|
"allowedPayees",
|
|
34531
34537
|
"blockedPayees",
|
|
@@ -34542,6 +34548,12 @@ var init_spend_control = __esm({
|
|
|
34542
34548
|
this.name = "MalformedSpendPolicyError";
|
|
34543
34549
|
}
|
|
34544
34550
|
};
|
|
34551
|
+
SpendPolicyConflictError = class extends Error {
|
|
34552
|
+
constructor() {
|
|
34553
|
+
super("spending.json limits changed underneath this write; nothing was written");
|
|
34554
|
+
this.name = "SpendPolicyConflictError";
|
|
34555
|
+
}
|
|
34556
|
+
};
|
|
34545
34557
|
FileSpendControlStorage = class {
|
|
34546
34558
|
spendingFile;
|
|
34547
34559
|
constructor() {
|
|
@@ -34622,6 +34634,25 @@ var init_spend_control = __esm({
|
|
|
34622
34634
|
}
|
|
34623
34635
|
this.save({ limits: storedLimits, history });
|
|
34624
34636
|
}
|
|
34637
|
+
/**
|
|
34638
|
+
* Persist limits while leaving the stored history exactly as it is on disk.
|
|
34639
|
+
* With `expect`, refuse when the stored limits are no longer the ones the
|
|
34640
|
+
* writer read — a stale instance must not replace another writer's edit.
|
|
34641
|
+
* The re-read happens immediately before the atomic rename, so the race
|
|
34642
|
+
* window is the write itself, not the whole command.
|
|
34643
|
+
*/
|
|
34644
|
+
saveLimits(limits, expect) {
|
|
34645
|
+
let current;
|
|
34646
|
+
try {
|
|
34647
|
+
current = this.load();
|
|
34648
|
+
} catch {
|
|
34649
|
+
return;
|
|
34650
|
+
}
|
|
34651
|
+
if (expect !== void 0 && canonicalLimits(current?.limits ?? {}) !== canonicalLimits(expect)) {
|
|
34652
|
+
throw new SpendPolicyConflictError();
|
|
34653
|
+
}
|
|
34654
|
+
this.save({ limits, history: current?.history ?? [] });
|
|
34655
|
+
}
|
|
34625
34656
|
};
|
|
34626
34657
|
InMemorySpendControlStorage = class {
|
|
34627
34658
|
data = null;
|
|
@@ -34637,6 +34668,15 @@ var init_spend_control = __esm({
|
|
|
34637
34668
|
history: data.history.map((r2) => ({ ...r2 }))
|
|
34638
34669
|
};
|
|
34639
34670
|
}
|
|
34671
|
+
saveLimits(limits, expect) {
|
|
34672
|
+
if (expect !== void 0 && canonicalLimits(this.data?.limits ?? {}) !== canonicalLimits(expect)) {
|
|
34673
|
+
throw new SpendPolicyConflictError();
|
|
34674
|
+
}
|
|
34675
|
+
this.data = {
|
|
34676
|
+
limits: cloneLimits(limits),
|
|
34677
|
+
history: this.data?.history.map((r2) => ({ ...r2 })) ?? []
|
|
34678
|
+
};
|
|
34679
|
+
}
|
|
34640
34680
|
};
|
|
34641
34681
|
RESERVATION_TTL_MS = 2 * 60 * 1e3;
|
|
34642
34682
|
SpendControl = class {
|
|
@@ -34648,6 +34688,8 @@ var init_spend_control = __esm({
|
|
|
34648
34688
|
reservationSeq = 0;
|
|
34649
34689
|
/** Limits we loaded and have not changed; history-only saves must not clobber operator edits. */
|
|
34650
34690
|
limitsDirty = false;
|
|
34691
|
+
/** The limits this instance last read from or wrote to storage — the compare-and-swap baseline. */
|
|
34692
|
+
diskLimits = {};
|
|
34651
34693
|
/** Set when spending.json held an unusable policy list: refuse every payment. */
|
|
34652
34694
|
policyFileBroken;
|
|
34653
34695
|
storage;
|
|
@@ -34692,6 +34734,15 @@ var init_spend_control = __esm({
|
|
|
34692
34734
|
getLimits() {
|
|
34693
34735
|
return cloneLimits(this.limits);
|
|
34694
34736
|
}
|
|
34737
|
+
/**
|
|
34738
|
+
* Why spending.json could not be loaded, or undefined when it is usable.
|
|
34739
|
+
* While set, every setter mutates memory only: save() refuses to rewrite a
|
|
34740
|
+
* file it could not fully parse, so callers must check this before
|
|
34741
|
+
* reporting a change as applied.
|
|
34742
|
+
*/
|
|
34743
|
+
getPolicyFileError() {
|
|
34744
|
+
return this.policyFileBroken;
|
|
34745
|
+
}
|
|
34695
34746
|
check(estimatedCost2, counterparty) {
|
|
34696
34747
|
if (this.policyFileBroken !== void 0) {
|
|
34697
34748
|
return {
|
|
@@ -34952,6 +35003,22 @@ var init_spend_control = __esm({
|
|
|
34952
35003
|
this.storage.saveHistory([...this.history]);
|
|
34953
35004
|
return;
|
|
34954
35005
|
}
|
|
35006
|
+
if (this.limitsDirty && this.storage.saveLimits) {
|
|
35007
|
+
try {
|
|
35008
|
+
this.storage.saveLimits(cloneLimits(this.limits), cloneLimits(this.diskLimits));
|
|
35009
|
+
} catch (err) {
|
|
35010
|
+
if (err instanceof SpendPolicyConflictError) {
|
|
35011
|
+
const current = this.storage.load();
|
|
35012
|
+
this.limits = cloneLimits(current?.limits ?? {});
|
|
35013
|
+
this.diskLimits = cloneLimits(this.limits);
|
|
35014
|
+
this.limitsDirty = false;
|
|
35015
|
+
}
|
|
35016
|
+
throw err;
|
|
35017
|
+
}
|
|
35018
|
+
this.diskLimits = cloneLimits(this.limits);
|
|
35019
|
+
this.limitsDirty = false;
|
|
35020
|
+
return;
|
|
35021
|
+
}
|
|
34955
35022
|
this.storage.save({
|
|
34956
35023
|
limits: cloneLimits(this.limits),
|
|
34957
35024
|
history: [...this.history]
|
|
@@ -34972,6 +35039,7 @@ var init_spend_control = __esm({
|
|
|
34972
35039
|
}
|
|
34973
35040
|
if (data) {
|
|
34974
35041
|
this.limits = cloneLimits(data.limits);
|
|
35042
|
+
this.diskLimits = cloneLimits(data.limits);
|
|
34975
35043
|
this.history = data.history;
|
|
34976
35044
|
this.cleanup();
|
|
34977
35045
|
}
|
|
@@ -36624,12 +36692,12 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36624
36692
|
const id2 = modelId.toLowerCase();
|
|
36625
36693
|
const modelName = id2.slice(id2.indexOf("/") + 1);
|
|
36626
36694
|
const match = (values, score) => values.some((value) => modelName === value) ? score : 0;
|
|
36627
|
-
const
|
|
36695
|
+
const base4 = 0.68;
|
|
36628
36696
|
switch (task) {
|
|
36629
36697
|
case "code_agent":
|
|
36630
36698
|
if (terminalToolSignal && agentRisk === "complex_high") {
|
|
36631
36699
|
return Math.max(
|
|
36632
|
-
|
|
36700
|
+
base4,
|
|
36633
36701
|
match(["claude-sonnet-5"], 1),
|
|
36634
36702
|
match(["gpt-5.3-codex"], 0.87),
|
|
36635
36703
|
match(["gpt-5-mini"], 0.78),
|
|
@@ -36637,7 +36705,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36637
36705
|
);
|
|
36638
36706
|
}
|
|
36639
36707
|
return Math.max(
|
|
36640
|
-
|
|
36708
|
+
base4,
|
|
36641
36709
|
match(["gpt-5.3-codex"], 1),
|
|
36642
36710
|
match(["claude-sonnet-5"], 0.98),
|
|
36643
36711
|
match(["gpt-5-mini"], 0.96),
|
|
@@ -36648,7 +36716,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36648
36716
|
case "tool_agent":
|
|
36649
36717
|
if (terminalToolSignal && agentRisk === "complex_high") {
|
|
36650
36718
|
return Math.max(
|
|
36651
|
-
|
|
36719
|
+
base4,
|
|
36652
36720
|
match(["claude-sonnet-5"], 1),
|
|
36653
36721
|
match(["gpt-5.3-codex"], 0.87),
|
|
36654
36722
|
match(["gpt-5-mini"], 0.78),
|
|
@@ -36657,7 +36725,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36657
36725
|
}
|
|
36658
36726
|
if (terminalToolSignal && !terminalSafetySensitive) {
|
|
36659
36727
|
return Math.max(
|
|
36660
|
-
|
|
36728
|
+
base4,
|
|
36661
36729
|
match(["gpt-5-mini"], 1),
|
|
36662
36730
|
match(["gpt-5.3-codex"], 0.98),
|
|
36663
36731
|
match(["claude-sonnet-5"], 0.9),
|
|
@@ -36666,7 +36734,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36666
36734
|
}
|
|
36667
36735
|
if (terminalToolSignal && terminalSafetySensitive) {
|
|
36668
36736
|
return Math.max(
|
|
36669
|
-
|
|
36737
|
+
base4,
|
|
36670
36738
|
match(["claude-sonnet-5"], 1),
|
|
36671
36739
|
match(["claude-opus-4.8"], 0.9),
|
|
36672
36740
|
match(["gpt-5.3-codex"], 0.84)
|
|
@@ -36674,14 +36742,14 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36674
36742
|
}
|
|
36675
36743
|
if (agentDomain === "web_research") {
|
|
36676
36744
|
return deepWebResearch ? Math.max(
|
|
36677
|
-
|
|
36745
|
+
base4,
|
|
36678
36746
|
match(["claude-sonnet-5"], 1),
|
|
36679
36747
|
match(["gpt-5-mini"], 0.88),
|
|
36680
36748
|
match(["gemini-3.5-flash"], 0.84),
|
|
36681
36749
|
match(["claude-opus-5"], 0.8),
|
|
36682
36750
|
match(["claude-opus-4.8"], 0.78)
|
|
36683
36751
|
) : Math.max(
|
|
36684
|
-
|
|
36752
|
+
base4,
|
|
36685
36753
|
match(["claude-sonnet-5"], 1),
|
|
36686
36754
|
match(["gpt-5-mini"], 0.88),
|
|
36687
36755
|
match(["gemini-3.5-flash"], 0.86),
|
|
@@ -36692,7 +36760,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36692
36760
|
if (agentDomain === "retail") {
|
|
36693
36761
|
if (agentRisk === "standard") {
|
|
36694
36762
|
return Math.max(
|
|
36695
|
-
|
|
36763
|
+
base4,
|
|
36696
36764
|
match(["gpt-5-mini"], 1),
|
|
36697
36765
|
match(["claude-sonnet-5"], 0.88),
|
|
36698
36766
|
match(["gemini-3.5-flash"], 0.82),
|
|
@@ -36703,7 +36771,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36703
36771
|
}
|
|
36704
36772
|
if (agentRisk === "policy_exception") {
|
|
36705
36773
|
return Math.max(
|
|
36706
|
-
|
|
36774
|
+
base4,
|
|
36707
36775
|
match(["gpt-4.1"], 1),
|
|
36708
36776
|
match(["claude-sonnet-5"], 0.9),
|
|
36709
36777
|
match(["deepseek-v4-pro"], 0.82),
|
|
@@ -36713,7 +36781,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36713
36781
|
}
|
|
36714
36782
|
if (agentRisk === "policy_exception_simple") {
|
|
36715
36783
|
return Math.max(
|
|
36716
|
-
|
|
36784
|
+
base4,
|
|
36717
36785
|
match(["gpt-5-mini"], 1),
|
|
36718
36786
|
match(["gpt-4.1"], 0.86),
|
|
36719
36787
|
match(["deepseek-v4-pro"], 0.82),
|
|
@@ -36721,7 +36789,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36721
36789
|
);
|
|
36722
36790
|
}
|
|
36723
36791
|
return Math.max(
|
|
36724
|
-
|
|
36792
|
+
base4,
|
|
36725
36793
|
match(["deepseek-v4-pro"], 1),
|
|
36726
36794
|
match(["claude-sonnet-5"], 0.88),
|
|
36727
36795
|
match(["gemini-3.5-flash"], 0.82),
|
|
@@ -36733,7 +36801,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36733
36801
|
if (agentDomain === "airline") {
|
|
36734
36802
|
if (agentRisk === "complex_high") {
|
|
36735
36803
|
return Math.max(
|
|
36736
|
-
|
|
36804
|
+
base4,
|
|
36737
36805
|
match(["claude-sonnet-5"], 1),
|
|
36738
36806
|
match(["gpt-5-mini"], 0.78),
|
|
36739
36807
|
match(["gemini-3.5-flash"], 0.76),
|
|
@@ -36741,7 +36809,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36741
36809
|
);
|
|
36742
36810
|
}
|
|
36743
36811
|
return Math.max(
|
|
36744
|
-
|
|
36812
|
+
base4,
|
|
36745
36813
|
match(["gpt-5-mini"], 1),
|
|
36746
36814
|
match(["claude-sonnet-5"], 0.9),
|
|
36747
36815
|
match(["gemini-3.5-flash"], 0.8),
|
|
@@ -36749,7 +36817,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36749
36817
|
);
|
|
36750
36818
|
}
|
|
36751
36819
|
return Math.max(
|
|
36752
|
-
|
|
36820
|
+
base4,
|
|
36753
36821
|
match(["claude-sonnet-5"], 1),
|
|
36754
36822
|
match(["gemini-3.5-flash"], 0.88),
|
|
36755
36823
|
match(["gpt-5.3-codex"], 0.87),
|
|
@@ -36760,12 +36828,12 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36760
36828
|
case "tool_agent_parallel":
|
|
36761
36829
|
if (terminalToolSignal) {
|
|
36762
36830
|
return terminalSafetySensitive ? Math.max(
|
|
36763
|
-
|
|
36831
|
+
base4,
|
|
36764
36832
|
match(["claude-sonnet-5"], 1),
|
|
36765
36833
|
match(["claude-opus-4.8"], 0.9),
|
|
36766
36834
|
match(["gpt-5.3-codex"], 0.86)
|
|
36767
36835
|
) : Math.max(
|
|
36768
|
-
|
|
36836
|
+
base4,
|
|
36769
36837
|
match(["gpt-5-mini"], 1),
|
|
36770
36838
|
match(["gpt-5.3-codex"], 0.98),
|
|
36771
36839
|
match(["claude-sonnet-5"], 0.92),
|
|
@@ -36774,14 +36842,14 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36774
36842
|
}
|
|
36775
36843
|
if (agentDomain === "web_research") {
|
|
36776
36844
|
return deepWebResearch ? Math.max(
|
|
36777
|
-
|
|
36845
|
+
base4,
|
|
36778
36846
|
match(["claude-sonnet-5"], 1),
|
|
36779
36847
|
match(["gpt-5-mini"], 0.88),
|
|
36780
36848
|
match(["gemini-3.5-flash"], 0.84),
|
|
36781
36849
|
match(["claude-opus-5"], 0.8),
|
|
36782
36850
|
match(["claude-opus-4.8"], 0.78)
|
|
36783
36851
|
) : Math.max(
|
|
36784
|
-
|
|
36852
|
+
base4,
|
|
36785
36853
|
match(["claude-sonnet-5"], 1),
|
|
36786
36854
|
match(["gpt-5-mini"], 0.88),
|
|
36787
36855
|
match(["gemini-3.5-flash"], 0.86),
|
|
@@ -36792,7 +36860,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36792
36860
|
if (agentDomain === "retail") {
|
|
36793
36861
|
if (agentRisk === "policy_exception") {
|
|
36794
36862
|
return Math.max(
|
|
36795
|
-
|
|
36863
|
+
base4,
|
|
36796
36864
|
match(["gpt-4.1"], 1),
|
|
36797
36865
|
match(["claude-sonnet-5"], 0.9),
|
|
36798
36866
|
match(["deepseek-v4-pro"], 0.82),
|
|
@@ -36802,7 +36870,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36802
36870
|
}
|
|
36803
36871
|
if (agentRisk === "policy_exception_simple") {
|
|
36804
36872
|
return Math.max(
|
|
36805
|
-
|
|
36873
|
+
base4,
|
|
36806
36874
|
match(["gpt-5-mini"], 1),
|
|
36807
36875
|
match(["gpt-4.1"], 0.86),
|
|
36808
36876
|
match(["deepseek-v4-pro"], 0.82),
|
|
@@ -36810,7 +36878,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36810
36878
|
);
|
|
36811
36879
|
}
|
|
36812
36880
|
return Math.max(
|
|
36813
|
-
|
|
36881
|
+
base4,
|
|
36814
36882
|
match(["deepseek-v4-pro"], 1),
|
|
36815
36883
|
match(["claude-sonnet-5"], 0.88),
|
|
36816
36884
|
match(["claude-opus-4.8"], 0.84),
|
|
@@ -36820,20 +36888,20 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36820
36888
|
}
|
|
36821
36889
|
if (agentDomain === "airline") {
|
|
36822
36890
|
return agentRisk === "complex_high" ? Math.max(
|
|
36823
|
-
|
|
36891
|
+
base4,
|
|
36824
36892
|
match(["claude-sonnet-5"], 1),
|
|
36825
36893
|
match(["gpt-5-mini"], 0.78),
|
|
36826
36894
|
match(["claude-opus-4.8"], 0.76),
|
|
36827
36895
|
match(["gemini-3.5-flash"], 0.74)
|
|
36828
36896
|
) : Math.max(
|
|
36829
|
-
|
|
36897
|
+
base4,
|
|
36830
36898
|
match(["gpt-5-mini"], 1),
|
|
36831
36899
|
match(["claude-sonnet-5"], 0.9),
|
|
36832
36900
|
match(["gemini-3.5-flash"], 0.8)
|
|
36833
36901
|
);
|
|
36834
36902
|
}
|
|
36835
36903
|
return Math.max(
|
|
36836
|
-
|
|
36904
|
+
base4,
|
|
36837
36905
|
match(["claude-opus-4.8"], 1),
|
|
36838
36906
|
match(["claude-sonnet-5"], 0.84),
|
|
36839
36907
|
match(["grok-4.5"], 0.82),
|
|
@@ -36843,7 +36911,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36843
36911
|
case "code_edit":
|
|
36844
36912
|
case "debug":
|
|
36845
36913
|
return Math.max(
|
|
36846
|
-
|
|
36914
|
+
base4,
|
|
36847
36915
|
match(["gpt-5.3-codex"], 1),
|
|
36848
36916
|
match(["claude-sonnet-4.6"], 0.94),
|
|
36849
36917
|
match(["glm-5.2"], 0.9),
|
|
@@ -36851,7 +36919,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36851
36919
|
);
|
|
36852
36920
|
case "reasoning":
|
|
36853
36921
|
return Math.max(
|
|
36854
|
-
|
|
36922
|
+
base4,
|
|
36855
36923
|
match(["claude-sonnet-5", "claude-sonnet-4.6"], 0.98),
|
|
36856
36924
|
match(["deepseek-v4-pro"], 0.95),
|
|
36857
36925
|
match(["grok-4.5"], 0.94),
|
|
@@ -36859,7 +36927,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36859
36927
|
);
|
|
36860
36928
|
case "reasoning_mcq":
|
|
36861
36929
|
return Math.max(
|
|
36862
|
-
|
|
36930
|
+
base4,
|
|
36863
36931
|
match(["gemini-3-flash-preview"], 1),
|
|
36864
36932
|
match(["gemini-3.5-flash"], 0.91),
|
|
36865
36933
|
match(["grok-4.5"], 0.9),
|
|
@@ -36868,20 +36936,20 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36868
36936
|
);
|
|
36869
36937
|
case "reasoning_math":
|
|
36870
36938
|
return Math.max(
|
|
36871
|
-
|
|
36939
|
+
base4,
|
|
36872
36940
|
match(["gemini-3.5-flash"], 1),
|
|
36873
36941
|
match(["grok-4.5"], 0.93),
|
|
36874
36942
|
match(["claude-sonnet-5", "deepseek-v4-pro", "kimi-k3"], 0.9)
|
|
36875
36943
|
);
|
|
36876
36944
|
case "vision":
|
|
36877
36945
|
return Math.max(
|
|
36878
|
-
|
|
36946
|
+
base4,
|
|
36879
36947
|
match(["gemini-3.1-pro"], 0.96),
|
|
36880
36948
|
match(["qwen3.7-max", "claude-sonnet-4.6", "kimi-k3", "grok-4.3"], 0.9)
|
|
36881
36949
|
);
|
|
36882
36950
|
case "long_context":
|
|
36883
36951
|
return Math.max(
|
|
36884
|
-
|
|
36952
|
+
base4,
|
|
36885
36953
|
match(["gemini-3.1-pro"], 1),
|
|
36886
36954
|
match(["qwen3.7-max", "glm-5.2"], 0.89),
|
|
36887
36955
|
match(["gemini-3.5-flash"], 0.88),
|
|
@@ -36891,7 +36959,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36891
36959
|
const kimiExtractionAffinity = language === "zh" ? 1 : 0.9;
|
|
36892
36960
|
const otherExtractionAffinity = language === "zh" ? 0.88 : 0.9;
|
|
36893
36961
|
return Math.max(
|
|
36894
|
-
|
|
36962
|
+
base4,
|
|
36895
36963
|
match(["gemini-3.5-flash", "gemini-2.5-flash", "gpt-4o-mini"], otherExtractionAffinity),
|
|
36896
36964
|
match(["claude-sonnet-5", "claude-sonnet-4.6"], otherExtractionAffinity),
|
|
36897
36965
|
match(["kimi-k3"], kimiExtractionAffinity)
|
|
@@ -36899,7 +36967,7 @@ function affinity(modelId, task, language = "other", agentDomain = "other", deep
|
|
|
36899
36967
|
}
|
|
36900
36968
|
default:
|
|
36901
36969
|
return Math.max(
|
|
36902
|
-
|
|
36970
|
+
base4,
|
|
36903
36971
|
match(["gemini-3.5-flash", "gemini-2.5-flash", "kimi-k3"], 0.86)
|
|
36904
36972
|
);
|
|
36905
36973
|
}
|
|
@@ -38174,13 +38242,13 @@ ${value.slice(-(scanLimit - prefixLength))}`;
|
|
|
38174
38242
|
name = "portfolio";
|
|
38175
38243
|
route(prompt, systemPrompt, maxOutputTokens, options) {
|
|
38176
38244
|
const features = classifyTask(prompt, systemPrompt, options);
|
|
38177
|
-
const
|
|
38245
|
+
const base4 = new RulesStrategy().route(prompt, systemPrompt, maxOutputTokens, {
|
|
38178
38246
|
...options,
|
|
38179
38247
|
requiresTools: features.needsTools
|
|
38180
38248
|
});
|
|
38181
|
-
const tierConfigs =
|
|
38182
|
-
if (!tierConfigs) return
|
|
38183
|
-
const targetTier = (features.taskType === "reasoning_mcq" || features.taskType === "reasoning_math") && (
|
|
38249
|
+
const tierConfigs = base4.tierConfigs;
|
|
38250
|
+
if (!tierConfigs) return base4;
|
|
38251
|
+
const targetTier = (features.taskType === "reasoning_mcq" || features.taskType === "reasoning_math") && (base4.tier === "SIMPLE" || base4.tier === "MEDIUM") ? "REASONING" : base4.tier;
|
|
38184
38252
|
const tierConfig = tierConfigs[targetTier];
|
|
38185
38253
|
const configuredCandidates = tierConfig ? getFallbackChain(targetTier, tierConfigs) : [];
|
|
38186
38254
|
const unavailable = new Set(options.unavailableModels ?? []);
|
|
@@ -38193,7 +38261,7 @@ ${value.slice(-(scanLimit - prefixLength))}`;
|
|
|
38193
38261
|
(model2) => isEligible(model2, features, maxOutputTokens, options)
|
|
38194
38262
|
);
|
|
38195
38263
|
const eligibleCandidates = eligible.length > 0 ? eligible : chain3;
|
|
38196
|
-
if (eligibleCandidates.length === 0) return
|
|
38264
|
+
if (eligibleCandidates.length === 0) return base4;
|
|
38197
38265
|
const profileName = options.routingProfile === "eco" ? "eco" : options.routingProfile === "premium" ? "premium" : "auto";
|
|
38198
38266
|
const portfolio = options.config.portfolio ?? DEFAULT_PORTFOLIO_WEIGHTS;
|
|
38199
38267
|
const getAffinity = (model2) => affinity(
|
|
@@ -38266,27 +38334,27 @@ ${value.slice(-(scanLimit - prefixLength))}`;
|
|
|
38266
38334
|
(model2) => !scoredModels.includes(model2) && !webResearchFallbackOrder.includes(model2)
|
|
38267
38335
|
)
|
|
38268
38336
|
] : [...scoredModels, ...eligibleCandidates.filter((model2) => !scoredModels.includes(model2))];
|
|
38269
|
-
const model = ranked[0] ??
|
|
38337
|
+
const model = ranked[0] ?? base4.model;
|
|
38270
38338
|
const selectedTierConfigs = {
|
|
38271
38339
|
...tierConfigs,
|
|
38272
38340
|
[targetTier]: { primary: model, fallback: ranked.slice(1) }
|
|
38273
38341
|
};
|
|
38274
38342
|
const decision = selectModel(
|
|
38275
38343
|
targetTier,
|
|
38276
|
-
|
|
38344
|
+
base4.confidence,
|
|
38277
38345
|
"portfolio",
|
|
38278
|
-
`${
|
|
38346
|
+
`${base4.reasoning} | v3 task=${features.taskType} agentRisk=${features.agentRisk} deepWebResearch=${features.deepWebResearch} terminalCode=${features.implicitTerminalCode} terminalSafety=${features.terminalSafetySensitive} candidates=${ranked.length}`,
|
|
38279
38347
|
selectedTierConfigs,
|
|
38280
38348
|
options.modelPricing,
|
|
38281
38349
|
features.estimatedInputTokens,
|
|
38282
38350
|
maxOutputTokens,
|
|
38283
38351
|
options.routingProfile,
|
|
38284
|
-
|
|
38352
|
+
base4.agenticScore
|
|
38285
38353
|
);
|
|
38286
38354
|
return {
|
|
38287
38355
|
...decision,
|
|
38288
38356
|
tierConfigs: selectedTierConfigs,
|
|
38289
|
-
profile:
|
|
38357
|
+
profile: base4.profile,
|
|
38290
38358
|
candidates: ranked,
|
|
38291
38359
|
candidateScores: rankedEntries.map(({ model: model2, score, quality, cost, speed, reliability }) => ({
|
|
38292
38360
|
model: model2,
|
|
@@ -40465,7 +40533,7 @@ var init_errors5 = __esm({
|
|
|
40465
40533
|
`Options:`,
|
|
40466
40534
|
` 1. Fund wallet: ${walletAddress}`,
|
|
40467
40535
|
` 2. Use free model: /model free`,
|
|
40468
|
-
` 3. Uninstall: bash ~/.openclaw/extensions/clawrouter/scripts/uninstall.sh`
|
|
40536
|
+
` 3. Uninstall: bash ~/.openclaw/extensions/blockrun-clawrouter/scripts/uninstall.sh`
|
|
40469
40537
|
].join("\n");
|
|
40470
40538
|
super(msg);
|
|
40471
40539
|
this.name = "EmptyWalletError";
|
|
@@ -40617,6 +40685,154 @@ var init_balance = __esm({
|
|
|
40617
40685
|
}
|
|
40618
40686
|
});
|
|
40619
40687
|
|
|
40688
|
+
// node_modules/base-x/src/esm/index.js
|
|
40689
|
+
function base2(ALPHABET3) {
|
|
40690
|
+
if (ALPHABET3.length >= 255) {
|
|
40691
|
+
throw new TypeError("Alphabet too long");
|
|
40692
|
+
}
|
|
40693
|
+
const BASE_MAP = new Uint8Array(256);
|
|
40694
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
40695
|
+
BASE_MAP[j] = 255;
|
|
40696
|
+
}
|
|
40697
|
+
for (let i = 0; i < ALPHABET3.length; i++) {
|
|
40698
|
+
const x = ALPHABET3.charAt(i);
|
|
40699
|
+
const xc = x.charCodeAt(0);
|
|
40700
|
+
if (BASE_MAP[xc] !== 255) {
|
|
40701
|
+
throw new TypeError(x + " is ambiguous");
|
|
40702
|
+
}
|
|
40703
|
+
BASE_MAP[xc] = i;
|
|
40704
|
+
}
|
|
40705
|
+
const BASE = ALPHABET3.length;
|
|
40706
|
+
const LEADER = ALPHABET3.charAt(0);
|
|
40707
|
+
const FACTOR = Math.log(BASE) / Math.log(256);
|
|
40708
|
+
const iFACTOR = Math.log(256) / Math.log(BASE);
|
|
40709
|
+
function encode9(source) {
|
|
40710
|
+
if (source instanceof Uint8Array) {
|
|
40711
|
+
} else if (ArrayBuffer.isView(source)) {
|
|
40712
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
40713
|
+
} else if (Array.isArray(source)) {
|
|
40714
|
+
source = Uint8Array.from(source);
|
|
40715
|
+
}
|
|
40716
|
+
if (!(source instanceof Uint8Array)) {
|
|
40717
|
+
throw new TypeError("Expected Uint8Array");
|
|
40718
|
+
}
|
|
40719
|
+
if (source.length === 0) {
|
|
40720
|
+
return "";
|
|
40721
|
+
}
|
|
40722
|
+
let zeroes = 0;
|
|
40723
|
+
let length = 0;
|
|
40724
|
+
let pbegin = 0;
|
|
40725
|
+
const pend = source.length;
|
|
40726
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
40727
|
+
pbegin++;
|
|
40728
|
+
zeroes++;
|
|
40729
|
+
}
|
|
40730
|
+
const size5 = (pend - pbegin) * iFACTOR + 1 >>> 0;
|
|
40731
|
+
const b58 = new Uint8Array(size5);
|
|
40732
|
+
while (pbegin !== pend) {
|
|
40733
|
+
let carry2 = source[pbegin];
|
|
40734
|
+
let i = 0;
|
|
40735
|
+
for (let it1 = size5 - 1; (carry2 !== 0 || i < length) && it1 !== -1; it1--, i++) {
|
|
40736
|
+
carry2 += 256 * b58[it1] >>> 0;
|
|
40737
|
+
b58[it1] = carry2 % BASE >>> 0;
|
|
40738
|
+
carry2 = carry2 / BASE >>> 0;
|
|
40739
|
+
}
|
|
40740
|
+
if (carry2 !== 0) {
|
|
40741
|
+
throw new Error("Non-zero carry");
|
|
40742
|
+
}
|
|
40743
|
+
length = i;
|
|
40744
|
+
pbegin++;
|
|
40745
|
+
}
|
|
40746
|
+
let it2 = size5 - length;
|
|
40747
|
+
while (it2 !== size5 && b58[it2] === 0) {
|
|
40748
|
+
it2++;
|
|
40749
|
+
}
|
|
40750
|
+
let str = LEADER.repeat(zeroes);
|
|
40751
|
+
for (; it2 < size5; ++it2) {
|
|
40752
|
+
str += ALPHABET3.charAt(b58[it2]);
|
|
40753
|
+
}
|
|
40754
|
+
return str;
|
|
40755
|
+
}
|
|
40756
|
+
function decodeUnsafe(source) {
|
|
40757
|
+
if (typeof source !== "string") {
|
|
40758
|
+
throw new TypeError("Expected String");
|
|
40759
|
+
}
|
|
40760
|
+
if (source.length === 0) {
|
|
40761
|
+
return new Uint8Array();
|
|
40762
|
+
}
|
|
40763
|
+
let psz = 0;
|
|
40764
|
+
let zeroes = 0;
|
|
40765
|
+
let length = 0;
|
|
40766
|
+
while (source[psz] === LEADER) {
|
|
40767
|
+
zeroes++;
|
|
40768
|
+
psz++;
|
|
40769
|
+
}
|
|
40770
|
+
const size5 = (source.length - psz) * FACTOR + 1 >>> 0;
|
|
40771
|
+
const b256 = new Uint8Array(size5);
|
|
40772
|
+
while (psz < source.length) {
|
|
40773
|
+
const charCode = source.charCodeAt(psz);
|
|
40774
|
+
if (charCode > 255) {
|
|
40775
|
+
return;
|
|
40776
|
+
}
|
|
40777
|
+
let carry2 = BASE_MAP[charCode];
|
|
40778
|
+
if (carry2 === 255) {
|
|
40779
|
+
return;
|
|
40780
|
+
}
|
|
40781
|
+
let i = 0;
|
|
40782
|
+
for (let it3 = size5 - 1; (carry2 !== 0 || i < length) && it3 !== -1; it3--, i++) {
|
|
40783
|
+
carry2 += BASE * b256[it3] >>> 0;
|
|
40784
|
+
b256[it3] = carry2 % 256 >>> 0;
|
|
40785
|
+
carry2 = carry2 / 256 >>> 0;
|
|
40786
|
+
}
|
|
40787
|
+
if (carry2 !== 0) {
|
|
40788
|
+
throw new Error("Non-zero carry");
|
|
40789
|
+
}
|
|
40790
|
+
length = i;
|
|
40791
|
+
psz++;
|
|
40792
|
+
}
|
|
40793
|
+
let it4 = size5 - length;
|
|
40794
|
+
while (it4 !== size5 && b256[it4] === 0) {
|
|
40795
|
+
it4++;
|
|
40796
|
+
}
|
|
40797
|
+
const vch = new Uint8Array(zeroes + (size5 - it4));
|
|
40798
|
+
let j = zeroes;
|
|
40799
|
+
while (it4 !== size5) {
|
|
40800
|
+
vch[j++] = b256[it4++];
|
|
40801
|
+
}
|
|
40802
|
+
return vch;
|
|
40803
|
+
}
|
|
40804
|
+
function decode4(string) {
|
|
40805
|
+
const buffer2 = decodeUnsafe(string);
|
|
40806
|
+
if (buffer2) {
|
|
40807
|
+
return buffer2;
|
|
40808
|
+
}
|
|
40809
|
+
throw new Error("Non-base" + BASE + " character");
|
|
40810
|
+
}
|
|
40811
|
+
return {
|
|
40812
|
+
encode: encode9,
|
|
40813
|
+
decodeUnsafe,
|
|
40814
|
+
decode: decode4
|
|
40815
|
+
};
|
|
40816
|
+
}
|
|
40817
|
+
var esm_default;
|
|
40818
|
+
var init_esm6 = __esm({
|
|
40819
|
+
"node_modules/base-x/src/esm/index.js"() {
|
|
40820
|
+
"use strict";
|
|
40821
|
+
esm_default = base2;
|
|
40822
|
+
}
|
|
40823
|
+
});
|
|
40824
|
+
|
|
40825
|
+
// node_modules/bs58/src/esm/index.js
|
|
40826
|
+
var ALPHABET, esm_default2;
|
|
40827
|
+
var init_esm7 = __esm({
|
|
40828
|
+
"node_modules/bs58/src/esm/index.js"() {
|
|
40829
|
+
"use strict";
|
|
40830
|
+
init_esm6();
|
|
40831
|
+
ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
40832
|
+
esm_default2 = esm_default(ALPHABET);
|
|
40833
|
+
}
|
|
40834
|
+
});
|
|
40835
|
+
|
|
40620
40836
|
// node_modules/@noble/curves/node_modules/@noble/hashes/utils.js
|
|
40621
40837
|
function isBytes7(a) {
|
|
40622
40838
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
@@ -41785,15 +42001,15 @@ var init_curve3 = __esm({
|
|
|
41785
42001
|
const { windows, windowSize } = calcWOpts3(W, this.bits);
|
|
41786
42002
|
const points = [];
|
|
41787
42003
|
let p = point3;
|
|
41788
|
-
let
|
|
42004
|
+
let base4 = p;
|
|
41789
42005
|
for (let window2 = 0; window2 < windows; window2++) {
|
|
41790
|
-
|
|
41791
|
-
points.push(
|
|
42006
|
+
base4 = p;
|
|
42007
|
+
points.push(base4);
|
|
41792
42008
|
for (let i = 1; i < windowSize; i++) {
|
|
41793
|
-
|
|
41794
|
-
points.push(
|
|
42009
|
+
base4 = base4.add(p);
|
|
42010
|
+
points.push(base4);
|
|
41795
42011
|
}
|
|
41796
|
-
p =
|
|
42012
|
+
p = base4.double();
|
|
41797
42013
|
}
|
|
41798
42014
|
return points;
|
|
41799
42015
|
}
|
|
@@ -44841,6 +45057,37 @@ var init_sha26 = __esm({
|
|
|
44841
45057
|
}
|
|
44842
45058
|
});
|
|
44843
45059
|
|
|
45060
|
+
// src/solana-key.ts
|
|
45061
|
+
function deriveSolanaKeyBytes(mnemonic) {
|
|
45062
|
+
const seed = mnemonicToSeedSync(mnemonic);
|
|
45063
|
+
let digest = hmac6(sha5123, new TextEncoder().encode("ed25519 seed"), seed);
|
|
45064
|
+
let key2 = digest.slice(0, 32);
|
|
45065
|
+
let chainCode = digest.slice(32);
|
|
45066
|
+
for (const index2 of SOLANA_HARDENED_INDICES) {
|
|
45067
|
+
const data = new Uint8Array(37);
|
|
45068
|
+
data[0] = 0;
|
|
45069
|
+
data.set(key2, 1);
|
|
45070
|
+
data[33] = index2 >>> 24 & 255;
|
|
45071
|
+
data[34] = index2 >>> 16 & 255;
|
|
45072
|
+
data[35] = index2 >>> 8 & 255;
|
|
45073
|
+
data[36] = index2 & 255;
|
|
45074
|
+
digest = hmac6(sha5123, chainCode, data);
|
|
45075
|
+
key2 = digest.slice(0, 32);
|
|
45076
|
+
chainCode = digest.slice(32);
|
|
45077
|
+
}
|
|
45078
|
+
return new Uint8Array(key2);
|
|
45079
|
+
}
|
|
45080
|
+
var SOLANA_HARDENED_INDICES;
|
|
45081
|
+
var init_solana_key = __esm({
|
|
45082
|
+
"src/solana-key.ts"() {
|
|
45083
|
+
"use strict";
|
|
45084
|
+
init_hmac6();
|
|
45085
|
+
init_sha26();
|
|
45086
|
+
init_esm3();
|
|
45087
|
+
SOLANA_HARDENED_INDICES = [44 + 2147483648, 501 + 2147483648, 0 + 2147483648, 0 + 2147483648];
|
|
45088
|
+
}
|
|
45089
|
+
});
|
|
45090
|
+
|
|
44844
45091
|
// node_modules/@solana/errors/dist/index.node.mjs
|
|
44845
45092
|
function encodeValue(value) {
|
|
44846
45093
|
if (Array.isArray(value)) {
|
|
@@ -46282,20 +46529,20 @@ function partitionLeadingZeroes(value, zeroCharacter) {
|
|
|
46282
46529
|
return [leadingZeros, tailChars];
|
|
46283
46530
|
}
|
|
46284
46531
|
function getBigIntFromBaseX(value, alphabet4) {
|
|
46285
|
-
const
|
|
46532
|
+
const base4 = BigInt(alphabet4.length);
|
|
46286
46533
|
let sum = 0n;
|
|
46287
46534
|
for (const char of value) {
|
|
46288
|
-
sum *=
|
|
46535
|
+
sum *= base4;
|
|
46289
46536
|
sum += BigInt(alphabet4.indexOf(char));
|
|
46290
46537
|
}
|
|
46291
46538
|
return sum;
|
|
46292
46539
|
}
|
|
46293
46540
|
function getBaseXFromBigInt(value, alphabet4) {
|
|
46294
|
-
const
|
|
46541
|
+
const base4 = BigInt(alphabet4.length);
|
|
46295
46542
|
const tailChars = [];
|
|
46296
46543
|
while (value > 0n) {
|
|
46297
|
-
tailChars.unshift(alphabet4[Number(value %
|
|
46298
|
-
value /=
|
|
46544
|
+
tailChars.unshift(alphabet4[Number(value % base4)]);
|
|
46545
|
+
value /= base4;
|
|
46299
46546
|
}
|
|
46300
46547
|
return tailChars.join("");
|
|
46301
46548
|
}
|
|
@@ -48342,20 +48589,20 @@ function partitionLeadingZeroes2(value, zeroCharacter) {
|
|
|
48342
48589
|
return [leadingZeros, tailChars];
|
|
48343
48590
|
}
|
|
48344
48591
|
function getBigIntFromBaseX2(value, alphabet4) {
|
|
48345
|
-
const
|
|
48592
|
+
const base4 = BigInt(alphabet4.length);
|
|
48346
48593
|
let sum = 0n;
|
|
48347
48594
|
for (const char of value) {
|
|
48348
|
-
sum *=
|
|
48595
|
+
sum *= base4;
|
|
48349
48596
|
sum += BigInt(alphabet4.indexOf(char));
|
|
48350
48597
|
}
|
|
48351
48598
|
return sum;
|
|
48352
48599
|
}
|
|
48353
48600
|
function getBaseXFromBigInt2(value, alphabet4) {
|
|
48354
|
-
const
|
|
48601
|
+
const base4 = BigInt(alphabet4.length);
|
|
48355
48602
|
const tailChars = [];
|
|
48356
48603
|
while (value > 0n) {
|
|
48357
|
-
tailChars.unshift(alphabet4[Number(value %
|
|
48358
|
-
value /=
|
|
48604
|
+
tailChars.unshift(alphabet4[Number(value % base4)]);
|
|
48605
|
+
value /= base4;
|
|
48359
48606
|
}
|
|
48360
48607
|
return tailChars.join("");
|
|
48361
48608
|
}
|
|
@@ -59133,25 +59380,6 @@ function deriveEvmKey(mnemonic) {
|
|
|
59133
59380
|
const account = privateKeyToAccount(hex);
|
|
59134
59381
|
return { privateKey: hex, address: account.address };
|
|
59135
59382
|
}
|
|
59136
|
-
function deriveSolanaKeyBytes(mnemonic) {
|
|
59137
|
-
const seed = mnemonicToSeedSync(mnemonic);
|
|
59138
|
-
let I = hmac6(sha5123, new TextEncoder().encode("ed25519 seed"), seed);
|
|
59139
|
-
let key2 = I.slice(0, 32);
|
|
59140
|
-
let chainCode = I.slice(32);
|
|
59141
|
-
for (const index2 of SOLANA_HARDENED_INDICES) {
|
|
59142
|
-
const data = new Uint8Array(37);
|
|
59143
|
-
data[0] = 0;
|
|
59144
|
-
data.set(key2, 1);
|
|
59145
|
-
data[33] = index2 >>> 24 & 255;
|
|
59146
|
-
data[34] = index2 >>> 16 & 255;
|
|
59147
|
-
data[35] = index2 >>> 8 & 255;
|
|
59148
|
-
data[36] = index2 & 255;
|
|
59149
|
-
I = hmac6(sha5123, chainCode, data);
|
|
59150
|
-
key2 = I.slice(0, 32);
|
|
59151
|
-
chainCode = I.slice(32);
|
|
59152
|
-
}
|
|
59153
|
-
return new Uint8Array(key2);
|
|
59154
|
-
}
|
|
59155
59383
|
function deriveAllKeys(mnemonic) {
|
|
59156
59384
|
const { privateKey: evmPrivateKey, address: evmAddress } = deriveEvmKey(mnemonic);
|
|
59157
59385
|
const solanaPrivateKeyBytes = deriveSolanaKeyBytes(mnemonic);
|
|
@@ -59162,22 +59390,22 @@ async function getSolanaAddress(privateKeyBytes) {
|
|
|
59162
59390
|
const signer = await createKeyPairSignerFromPrivateKeyBytes2(privateKeyBytes);
|
|
59163
59391
|
return signer.address;
|
|
59164
59392
|
}
|
|
59165
|
-
var ETH_DERIVATION_PATH
|
|
59393
|
+
var ETH_DERIVATION_PATH;
|
|
59166
59394
|
var init_wallet2 = __esm({
|
|
59167
59395
|
"src/wallet.ts"() {
|
|
59168
59396
|
"use strict";
|
|
59169
59397
|
init_bip32();
|
|
59170
59398
|
init_esm3();
|
|
59171
59399
|
init_english();
|
|
59172
|
-
init_hmac6();
|
|
59173
|
-
init_sha26();
|
|
59174
59400
|
init_accounts();
|
|
59401
|
+
init_solana_key();
|
|
59402
|
+
init_solana_key();
|
|
59175
59403
|
ETH_DERIVATION_PATH = "m/44'/60'/0'/0/0";
|
|
59176
|
-
SOLANA_HARDENED_INDICES = [44 + 2147483648, 501 + 2147483648, 0 + 2147483648, 0 + 2147483648];
|
|
59177
59404
|
}
|
|
59178
59405
|
});
|
|
59179
59406
|
|
|
59180
59407
|
// src/auth.ts
|
|
59408
|
+
import { createPrivateKey, createPublicKey } from "crypto";
|
|
59181
59409
|
import { writeFile, mkdir as mkdir2 } from "fs/promises";
|
|
59182
59410
|
import { join as join7 } from "path";
|
|
59183
59411
|
import { homedir as homedir4 } from "os";
|
|
@@ -59232,7 +59460,67 @@ async function saveMnemonic(mnemonic) {
|
|
|
59232
59460
|
await mkdir2(WALLET_DIR2, { recursive: true });
|
|
59233
59461
|
await writeFile(MNEMONIC_FILE, mnemonic + "\n", { mode: 384 });
|
|
59234
59462
|
}
|
|
59235
|
-
async function
|
|
59463
|
+
async function migrateLegacyWalletToCore() {
|
|
59464
|
+
const migrated = { base: false, solana: false, chain: false };
|
|
59465
|
+
const [coreBase, coreSolana, coreChain] = await Promise.all([
|
|
59466
|
+
readExisting(CORE_WALLET_FILE),
|
|
59467
|
+
readExisting(CORE_SOLANA_WALLET_FILE),
|
|
59468
|
+
readExisting(CORE_CHAIN_FILE)
|
|
59469
|
+
]);
|
|
59470
|
+
if (coreBase === void 0) {
|
|
59471
|
+
const legacyBase = await loadSavedWallet();
|
|
59472
|
+
if (legacyBase) {
|
|
59473
|
+
migrated.base = await writeCoreFileIfMissing(CORE_WALLET_FILE, legacyBase + "\n");
|
|
59474
|
+
}
|
|
59475
|
+
}
|
|
59476
|
+
if (coreSolana === void 0) {
|
|
59477
|
+
const mnemonic = await loadMnemonic();
|
|
59478
|
+
if (mnemonic) {
|
|
59479
|
+
const secret = solanaSecretKeyFromSeed(deriveSolanaKeyBytes(mnemonic));
|
|
59480
|
+
migrated.solana = await writeCoreFileIfMissing(
|
|
59481
|
+
CORE_SOLANA_WALLET_FILE,
|
|
59482
|
+
JSON.stringify([...secret]) + "\n"
|
|
59483
|
+
);
|
|
59484
|
+
}
|
|
59485
|
+
}
|
|
59486
|
+
if (coreChain === void 0) {
|
|
59487
|
+
const legacyChain = await readOptional(CHAIN_FILE);
|
|
59488
|
+
if (legacyChain === "base" || legacyChain === "solana") {
|
|
59489
|
+
migrated.chain = await writeCoreFileIfMissing(CORE_CHAIN_FILE, legacyChain + "\n");
|
|
59490
|
+
}
|
|
59491
|
+
}
|
|
59492
|
+
if (migrated.base || migrated.solana || migrated.chain) {
|
|
59493
|
+
const parts = Object.entries(migrated).filter(([, changed]) => changed).map(([name]) => name).join(", ");
|
|
59494
|
+
console.log(`[ClawRouter] Migrated legacy ${parts} data to ${CORE_WALLET_DIR}`);
|
|
59495
|
+
}
|
|
59496
|
+
return migrated;
|
|
59497
|
+
}
|
|
59498
|
+
async function writeCoreFileIfMissing(path5, value) {
|
|
59499
|
+
await mkdir2(CORE_WALLET_DIR, { recursive: true });
|
|
59500
|
+
try {
|
|
59501
|
+
await writeFile(path5, value, { mode: 384, flag: "wx" });
|
|
59502
|
+
return true;
|
|
59503
|
+
} catch (error) {
|
|
59504
|
+
if (error.code === "EEXIST") return false;
|
|
59505
|
+
throw error;
|
|
59506
|
+
}
|
|
59507
|
+
}
|
|
59508
|
+
async function readExisting(path5) {
|
|
59509
|
+
try {
|
|
59510
|
+
return await readTextFile(path5);
|
|
59511
|
+
} catch (error) {
|
|
59512
|
+
if (error.code === "ENOENT") return void 0;
|
|
59513
|
+
throw error;
|
|
59514
|
+
}
|
|
59515
|
+
}
|
|
59516
|
+
function solanaSecretKeyFromSeed(seed) {
|
|
59517
|
+
const privateDer = Buffer.concat([Buffer.from("302e020100300506032b657004220420", "hex"), seed]);
|
|
59518
|
+
const publicDer = createPublicKey(
|
|
59519
|
+
createPrivateKey({ key: privateDer, format: "der", type: "pkcs8" })
|
|
59520
|
+
).export({ format: "der", type: "spki" });
|
|
59521
|
+
return Uint8Array.from([...seed, ...Buffer.from(publicDer).subarray(-32)]);
|
|
59522
|
+
}
|
|
59523
|
+
async function generateAndSaveWallet(existingCoreSolanaKey) {
|
|
59236
59524
|
const existingMnemonic = await loadMnemonic();
|
|
59237
59525
|
if (existingMnemonic) {
|
|
59238
59526
|
throw new Error(
|
|
@@ -59250,7 +59538,17 @@ Then run: npx @blockrun/clawrouter`
|
|
|
59250
59538
|
const derived = deriveAllKeys(mnemonic);
|
|
59251
59539
|
await mkdir2(WALLET_DIR2, { recursive: true });
|
|
59252
59540
|
await writeFile(WALLET_FILE, derived.evmPrivateKey + "\n", { mode: 384 });
|
|
59253
|
-
|
|
59541
|
+
if (!existingCoreSolanaKey) {
|
|
59542
|
+
await writeFile(MNEMONIC_FILE, mnemonic + "\n", { mode: 384 });
|
|
59543
|
+
}
|
|
59544
|
+
await writeCoreFileIfMissing(CORE_WALLET_FILE, derived.evmPrivateKey + "\n");
|
|
59545
|
+
if (!existingCoreSolanaKey) {
|
|
59546
|
+
await writeCoreFileIfMissing(
|
|
59547
|
+
CORE_SOLANA_WALLET_FILE,
|
|
59548
|
+
JSON.stringify([...solanaSecretKeyFromSeed(derived.solanaPrivateKeyBytes)]) + "\n"
|
|
59549
|
+
);
|
|
59550
|
+
}
|
|
59551
|
+
const solanaPrivateKeyBytes = existingCoreSolanaKey ?? derived.solanaPrivateKeyBytes;
|
|
59254
59552
|
try {
|
|
59255
59553
|
const verification = (await readTextFile(WALLET_FILE)).trim();
|
|
59256
59554
|
if (verification !== derived.evmPrivateKey) {
|
|
@@ -59265,7 +59563,7 @@ Then run: npx @blockrun/clawrouter`
|
|
|
59265
59563
|
}
|
|
59266
59564
|
let solanaAddress;
|
|
59267
59565
|
try {
|
|
59268
|
-
solanaAddress = await getSolanaAddress(
|
|
59566
|
+
solanaAddress = await getSolanaAddress(solanaPrivateKeyBytes);
|
|
59269
59567
|
} catch {
|
|
59270
59568
|
}
|
|
59271
59569
|
let solanaDefaultSaved = false;
|
|
@@ -59284,8 +59582,11 @@ Then run: npx @blockrun/clawrouter`
|
|
|
59284
59582
|
if (solanaAddress) {
|
|
59285
59583
|
console.log(`[ClawRouter] Solana Address : ${solanaAddress}`);
|
|
59286
59584
|
}
|
|
59287
|
-
console.log(`[ClawRouter]
|
|
59288
|
-
console.log(`[ClawRouter]
|
|
59585
|
+
console.log(`[ClawRouter] Base key : ${CORE_WALLET_FILE}`);
|
|
59586
|
+
console.log(`[ClawRouter] Solana key : ${CORE_SOLANA_WALLET_FILE}`);
|
|
59587
|
+
if (!existingCoreSolanaKey) {
|
|
59588
|
+
console.log(`[ClawRouter] Recovery words : ${MNEMONIC_FILE}`);
|
|
59589
|
+
}
|
|
59289
59590
|
console.log(`[ClawRouter]`);
|
|
59290
59591
|
console.log(`[ClawRouter] Both EVM (Base) and Solana wallets are ready.`);
|
|
59291
59592
|
if (solanaDefaultSaved) {
|
|
@@ -59304,44 +59605,50 @@ Then run: npx @blockrun/clawrouter`
|
|
|
59304
59605
|
return {
|
|
59305
59606
|
key: derived.evmPrivateKey,
|
|
59306
59607
|
address: derived.evmAddress,
|
|
59307
|
-
mnemonic,
|
|
59308
|
-
solanaPrivateKeyBytes
|
|
59608
|
+
...existingCoreSolanaKey ? {} : { mnemonic },
|
|
59609
|
+
solanaPrivateKeyBytes
|
|
59309
59610
|
};
|
|
59310
59611
|
}
|
|
59311
|
-
async function
|
|
59612
|
+
async function resolveExistingWalletKey() {
|
|
59613
|
+
const coreSolanaKey = await loadCoreSolanaKeyForSelectedChain();
|
|
59614
|
+
const envKey = process["env"].BLOCKRUN_WALLET_KEY;
|
|
59615
|
+
if (typeof envKey === "string" && /^0x[0-9a-f]{64}$/i.test(envKey)) {
|
|
59616
|
+
const account = privateKeyToAccount(envKey);
|
|
59617
|
+
return {
|
|
59618
|
+
key: envKey,
|
|
59619
|
+
address: account.address,
|
|
59620
|
+
source: "env",
|
|
59621
|
+
...await resolvedSolanaMaterial(coreSolanaKey)
|
|
59622
|
+
};
|
|
59623
|
+
}
|
|
59624
|
+
const core = await loadCoreWallet();
|
|
59625
|
+
if (core) {
|
|
59626
|
+
const account = privateKeyToAccount(core);
|
|
59627
|
+
return {
|
|
59628
|
+
key: core,
|
|
59629
|
+
address: account.address,
|
|
59630
|
+
source: "core",
|
|
59631
|
+
...await resolvedSolanaMaterial(coreSolanaKey)
|
|
59632
|
+
};
|
|
59633
|
+
}
|
|
59312
59634
|
const saved = await loadSavedWallet();
|
|
59313
59635
|
if (saved) {
|
|
59314
59636
|
const account = privateKeyToAccount(saved);
|
|
59315
|
-
|
|
59316
|
-
|
|
59317
|
-
|
|
59318
|
-
|
|
59319
|
-
|
|
59320
|
-
|
|
59321
|
-
source: "saved",
|
|
59322
|
-
mnemonic,
|
|
59323
|
-
solanaPrivateKeyBytes: solanaKeyBytes
|
|
59324
|
-
};
|
|
59325
|
-
}
|
|
59326
|
-
return { key: saved, address: account.address, source: "saved" };
|
|
59327
|
-
}
|
|
59328
|
-
const envKey = process["env"].BLOCKRUN_WALLET_KEY;
|
|
59329
|
-
if (typeof envKey === "string" && envKey.startsWith("0x") && envKey.length === 66) {
|
|
59330
|
-
const account = privateKeyToAccount(envKey);
|
|
59331
|
-
const mnemonic = await loadMnemonic();
|
|
59332
|
-
if (mnemonic) {
|
|
59333
|
-
const solanaKeyBytes = deriveSolanaKeyBytes(mnemonic);
|
|
59334
|
-
return {
|
|
59335
|
-
key: envKey,
|
|
59336
|
-
address: account.address,
|
|
59337
|
-
source: "env",
|
|
59338
|
-
mnemonic,
|
|
59339
|
-
solanaPrivateKeyBytes: solanaKeyBytes
|
|
59340
|
-
};
|
|
59341
|
-
}
|
|
59342
|
-
return { key: envKey, address: account.address, source: "env" };
|
|
59637
|
+
return {
|
|
59638
|
+
key: saved,
|
|
59639
|
+
address: account.address,
|
|
59640
|
+
source: "saved",
|
|
59641
|
+
...await resolvedSolanaMaterial(coreSolanaKey)
|
|
59642
|
+
};
|
|
59343
59643
|
}
|
|
59344
|
-
|
|
59644
|
+
return void 0;
|
|
59645
|
+
}
|
|
59646
|
+
async function resolveOrGenerateWalletKey() {
|
|
59647
|
+
await migrateLegacyWalletToCore();
|
|
59648
|
+
const existing = await resolveExistingWalletKey();
|
|
59649
|
+
if (existing) return existing;
|
|
59650
|
+
const existingCoreSolanaKey = await loadCoreSolanaKey();
|
|
59651
|
+
const result = await generateAndSaveWallet(existingCoreSolanaKey);
|
|
59345
59652
|
return {
|
|
59346
59653
|
key: result.key,
|
|
59347
59654
|
address: result.address,
|
|
@@ -59350,13 +59657,69 @@ async function resolveOrGenerateWalletKey() {
|
|
|
59350
59657
|
solanaPrivateKeyBytes: result.solanaPrivateKeyBytes
|
|
59351
59658
|
};
|
|
59352
59659
|
}
|
|
59660
|
+
async function loadCoreSolanaKeyForSelectedChain() {
|
|
59661
|
+
try {
|
|
59662
|
+
return await loadCoreSolanaKey();
|
|
59663
|
+
} catch (error) {
|
|
59664
|
+
if (await resolvePaymentChain() === "solana") throw error;
|
|
59665
|
+
return void 0;
|
|
59666
|
+
}
|
|
59667
|
+
}
|
|
59668
|
+
async function loadCoreWallet() {
|
|
59669
|
+
const key2 = (await readExisting(CORE_WALLET_FILE))?.trim();
|
|
59670
|
+
if (key2 === void 0) return void 0;
|
|
59671
|
+
if (/^0x[0-9a-f]{64}$/i.test(key2)) return key2;
|
|
59672
|
+
throw new Error(
|
|
59673
|
+
`BlockRun Core wallet at ${CORE_WALLET_FILE} has an invalid format. Refusing to use another wallet implicitly.`
|
|
59674
|
+
);
|
|
59675
|
+
}
|
|
59676
|
+
async function loadCoreSolanaKey() {
|
|
59677
|
+
const environmentKey = process["env"].SOLANA_WALLET_KEY?.trim();
|
|
59678
|
+
const raw = environmentKey || (await readExisting(CORE_SOLANA_WALLET_FILE))?.trim();
|
|
59679
|
+
if (!raw) return void 0;
|
|
59680
|
+
try {
|
|
59681
|
+
let bytes;
|
|
59682
|
+
if (raw.startsWith("[")) {
|
|
59683
|
+
const parsed = JSON.parse(raw);
|
|
59684
|
+
if (!Array.isArray(parsed) || !parsed.every((item) => Number.isInteger(item) && item >= 0 && item <= 255))
|
|
59685
|
+
throw new Error("expected an array of byte values");
|
|
59686
|
+
bytes = Uint8Array.from(parsed);
|
|
59687
|
+
} else {
|
|
59688
|
+
const hex = raw.replace(/^0x/i, "");
|
|
59689
|
+
bytes = /^[0-9a-f]{128}$/i.test(hex) ? Buffer.from(hex, "hex") : esm_default2.decode(raw);
|
|
59690
|
+
}
|
|
59691
|
+
if (bytes.length !== 64) throw new Error(`expected 64 bytes, received ${bytes.length}`);
|
|
59692
|
+
const expected = solanaSecretKeyFromSeed(bytes.slice(0, 32));
|
|
59693
|
+
if (!Buffer.from(expected).equals(Buffer.from(bytes))) {
|
|
59694
|
+
throw new Error("public key does not match the private seed");
|
|
59695
|
+
}
|
|
59696
|
+
return bytes.slice(0, 32);
|
|
59697
|
+
} catch (error) {
|
|
59698
|
+
throw new Error(
|
|
59699
|
+
`BlockRun Core Solana wallet has an invalid format: ${error instanceof Error ? error.message : String(error)}`,
|
|
59700
|
+
{ cause: error }
|
|
59701
|
+
);
|
|
59702
|
+
}
|
|
59703
|
+
}
|
|
59704
|
+
async function readOptional(path5) {
|
|
59705
|
+
try {
|
|
59706
|
+
return (await readTextFile(path5)).trim() || void 0;
|
|
59707
|
+
} catch {
|
|
59708
|
+
return void 0;
|
|
59709
|
+
}
|
|
59710
|
+
}
|
|
59711
|
+
async function resolvedSolanaMaterial(coreSolanaKey) {
|
|
59712
|
+
if (coreSolanaKey) return { solanaPrivateKeyBytes: coreSolanaKey };
|
|
59713
|
+
const mnemonic = await loadMnemonic();
|
|
59714
|
+
return mnemonic ? { mnemonic, solanaPrivateKeyBytes: deriveSolanaKeyBytes(mnemonic) } : {};
|
|
59715
|
+
}
|
|
59353
59716
|
async function setupSolana() {
|
|
59354
59717
|
const existing = await loadMnemonic();
|
|
59355
59718
|
if (existing) {
|
|
59356
59719
|
throw new Error("Solana wallet already set up. Mnemonic file exists at " + MNEMONIC_FILE);
|
|
59357
59720
|
}
|
|
59358
|
-
const
|
|
59359
|
-
if (!
|
|
59721
|
+
const evmKey = await loadCoreWallet() ?? await loadSavedWallet();
|
|
59722
|
+
if (!evmKey) {
|
|
59360
59723
|
throw new Error(
|
|
59361
59724
|
"No EVM wallet found. Run ClawRouter first to generate a wallet before setting up Solana."
|
|
59362
59725
|
);
|
|
@@ -59364,16 +59727,28 @@ async function setupSolana() {
|
|
|
59364
59727
|
const mnemonic = generateWalletMnemonic();
|
|
59365
59728
|
const solanaKeyBytes = deriveSolanaKeyBytes(mnemonic);
|
|
59366
59729
|
await saveMnemonic(mnemonic);
|
|
59730
|
+
await writeCoreFileIfMissing(
|
|
59731
|
+
CORE_SOLANA_WALLET_FILE,
|
|
59732
|
+
JSON.stringify([...solanaSecretKeyFromSeed(solanaKeyBytes)]) + "\n"
|
|
59733
|
+
);
|
|
59367
59734
|
console.log(`[ClawRouter] Solana wallet set up successfully.`);
|
|
59368
|
-
console.log(`[ClawRouter]
|
|
59735
|
+
console.log(`[ClawRouter] Solana key saved to ${CORE_SOLANA_WALLET_FILE}`);
|
|
59736
|
+
console.log(`[ClawRouter] Recovery mnemonic saved to ${MNEMONIC_FILE}`);
|
|
59369
59737
|
console.log(`[ClawRouter] Existing EVM wallet unchanged.`);
|
|
59370
59738
|
return { mnemonic, solanaPrivateKeyBytes: solanaKeyBytes };
|
|
59371
59739
|
}
|
|
59372
59740
|
async function savePaymentChain(chain3) {
|
|
59373
59741
|
await mkdir2(WALLET_DIR2, { recursive: true });
|
|
59374
|
-
await
|
|
59742
|
+
await mkdir2(CORE_WALLET_DIR, { recursive: true });
|
|
59743
|
+
await Promise.all([
|
|
59744
|
+
writeFile(CHAIN_FILE, chain3 + "\n", { mode: 384 }),
|
|
59745
|
+
writeFile(CORE_CHAIN_FILE, chain3 + "\n", { mode: 384 })
|
|
59746
|
+
]);
|
|
59375
59747
|
}
|
|
59376
59748
|
async function loadPaymentChain() {
|
|
59749
|
+
const core = await readOptional(CORE_CHAIN_FILE);
|
|
59750
|
+
if (core === "solana") return "solana";
|
|
59751
|
+
if (core === "base") return "base";
|
|
59377
59752
|
try {
|
|
59378
59753
|
const content = (await readTextFile(CHAIN_FILE)).trim();
|
|
59379
59754
|
if (content === "solana") return "solana";
|
|
@@ -59387,17 +59762,22 @@ async function resolvePaymentChain() {
|
|
|
59387
59762
|
if (process["env"].CLAWROUTER_PAYMENT_CHAIN === "base") return "base";
|
|
59388
59763
|
return loadPaymentChain();
|
|
59389
59764
|
}
|
|
59390
|
-
var WALLET_DIR2, WALLET_FILE, MNEMONIC_FILE, CHAIN_FILE;
|
|
59765
|
+
var WALLET_DIR2, WALLET_FILE, MNEMONIC_FILE, CHAIN_FILE, CORE_WALLET_DIR, CORE_WALLET_FILE, CORE_SOLANA_WALLET_FILE, CORE_CHAIN_FILE;
|
|
59391
59766
|
var init_auth = __esm({
|
|
59392
59767
|
"src/auth.ts"() {
|
|
59393
59768
|
"use strict";
|
|
59394
59769
|
init_fs_read();
|
|
59770
|
+
init_esm7();
|
|
59395
59771
|
init_accounts();
|
|
59396
59772
|
init_wallet2();
|
|
59397
59773
|
WALLET_DIR2 = join7(homedir4(), ".openclaw", "blockrun");
|
|
59398
59774
|
WALLET_FILE = join7(WALLET_DIR2, "wallet.key");
|
|
59399
59775
|
MNEMONIC_FILE = join7(WALLET_DIR2, "mnemonic");
|
|
59400
59776
|
CHAIN_FILE = join7(WALLET_DIR2, "payment-chain");
|
|
59777
|
+
CORE_WALLET_DIR = join7(homedir4(), ".blockrun");
|
|
59778
|
+
CORE_WALLET_FILE = join7(CORE_WALLET_DIR, ".session");
|
|
59779
|
+
CORE_SOLANA_WALLET_FILE = join7(CORE_WALLET_DIR, ".solana-session");
|
|
59780
|
+
CORE_CHAIN_FILE = join7(CORE_WALLET_DIR, ".chain");
|
|
59401
59781
|
}
|
|
59402
59782
|
});
|
|
59403
59783
|
|
|
@@ -75550,7 +75930,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
75550
75930
|
"node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
75551
75931
|
"use strict";
|
|
75552
75932
|
var { writeFile: writeFile3, readFile: readFile3, mkdir: mkdir5 } = __require("fs/promises");
|
|
75553
|
-
var { dirname:
|
|
75933
|
+
var { dirname: dirname4, resolve } = __require("path");
|
|
75554
75934
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("timers");
|
|
75555
75935
|
var { InvalidArgumentError, UndiciError } = require_errors();
|
|
75556
75936
|
var { hashId, isUrlExcludedFactory, normalizeHeaders: normalizeHeaders3, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -75796,7 +76176,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
75796
76176
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
75797
76177
|
}
|
|
75798
76178
|
const resolvedPath = resolve(path5);
|
|
75799
|
-
await mkdir5(
|
|
76179
|
+
await mkdir5(dirname4(resolvedPath), { recursive: true });
|
|
75800
76180
|
const data = Array.from(this.#snapshots.entries()).map(([hash5, snapshot]) => ({
|
|
75801
76181
|
hash: hash5,
|
|
75802
76182
|
snapshot
|
|
@@ -89872,6 +90252,7 @@ var init_client3 = __esm({
|
|
|
89872
90252
|
|
|
89873
90253
|
// src/proxy.ts
|
|
89874
90254
|
import { AsyncLocalStorage } from "async_hooks";
|
|
90255
|
+
import { createHmac } from "crypto";
|
|
89875
90256
|
import { createServer } from "http";
|
|
89876
90257
|
import { finished } from "stream";
|
|
89877
90258
|
import { homedir as homedir7 } from "os";
|
|
@@ -90497,12 +90878,25 @@ function buildProxyModelList(createdAt = Math.floor(Date.now() / 1e3)) {
|
|
|
90497
90878
|
if (seen.has(model.id)) return false;
|
|
90498
90879
|
seen.add(model.id);
|
|
90499
90880
|
return true;
|
|
90500
|
-
}).map((model) =>
|
|
90501
|
-
id
|
|
90502
|
-
|
|
90503
|
-
|
|
90504
|
-
|
|
90505
|
-
|
|
90881
|
+
}).map((model) => {
|
|
90882
|
+
const targetId = MODEL_ALIASES[model.id] ?? model.id;
|
|
90883
|
+
const canonical = BLOCKRUN_MODELS.find((entry) => entry.id === targetId);
|
|
90884
|
+
return {
|
|
90885
|
+
id: model.id,
|
|
90886
|
+
object: "model",
|
|
90887
|
+
created: createdAt,
|
|
90888
|
+
owned_by: targetId.includes("/") ? targetId.split("/")[0] ?? "blockrun" : "blockrun",
|
|
90889
|
+
name: model.name,
|
|
90890
|
+
context_window: model.contextWindow,
|
|
90891
|
+
max_output: model.maxTokens,
|
|
90892
|
+
input_price: model.cost.input,
|
|
90893
|
+
output_price: model.cost.output,
|
|
90894
|
+
reasoning: model.reasoning,
|
|
90895
|
+
vision: model.input.includes("image"),
|
|
90896
|
+
agentic: canonical?.agentic ?? false,
|
|
90897
|
+
tool_calling: canonical?.toolCalling ?? false
|
|
90898
|
+
};
|
|
90899
|
+
});
|
|
90506
90900
|
}
|
|
90507
90901
|
function mergeRoutingConfig(overrides) {
|
|
90508
90902
|
if (!overrides) return DEFAULT_ROUTING_CONFIG;
|
|
@@ -90742,7 +91136,7 @@ async function startProxy(options) {
|
|
|
90742
91136
|
}
|
|
90743
91137
|
void loadGatewayCatalog(apiBase);
|
|
90744
91138
|
const listenPort = options.port ?? getProxyPort();
|
|
90745
|
-
const existingProxy = await checkExistingProxy(listenPort);
|
|
91139
|
+
const existingProxy = options.allowExistingProxy === false ? void 0 : await checkExistingProxy(listenPort);
|
|
90746
91140
|
if (existingProxy) {
|
|
90747
91141
|
const account2 = privateKeyToAccount(walletKey);
|
|
90748
91142
|
const baseUrl2 = `http://127.0.0.1:${listenPort}`;
|
|
@@ -90897,7 +91291,22 @@ async function startProxy(options) {
|
|
|
90897
91291
|
response.balanceError = "Could not fetch balance";
|
|
90898
91292
|
}
|
|
90899
91293
|
}
|
|
90900
|
-
|
|
91294
|
+
const headers = {
|
|
91295
|
+
"Content-Type": "application/json",
|
|
91296
|
+
"Cache-Control": "no-store"
|
|
91297
|
+
};
|
|
91298
|
+
const challengeValue = req.headers["x-clawrouter-challenge"];
|
|
91299
|
+
const challenge2 = Array.isArray(challengeValue) ? challengeValue[0] : challengeValue;
|
|
91300
|
+
if (challenge2 && /^[a-f0-9]{64}$/i.test(challenge2)) {
|
|
91301
|
+
try {
|
|
91302
|
+
const token = readFileSync2(DESKTOP_SERVICE_TOKEN_FILE, "utf8").trim();
|
|
91303
|
+
if (/^[a-f0-9]{64}$/i.test(token)) {
|
|
91304
|
+
headers["X-ClawRouter-Proof"] = createHmac("sha256", token).update(challenge2).digest("hex");
|
|
91305
|
+
}
|
|
91306
|
+
} catch {
|
|
91307
|
+
}
|
|
91308
|
+
}
|
|
91309
|
+
res.writeHead(200, headers);
|
|
90901
91310
|
res.end(JSON.stringify(response));
|
|
90902
91311
|
return;
|
|
90903
91312
|
}
|
|
@@ -91766,6 +92175,10 @@ async function startProxy(options) {
|
|
|
91766
92175
|
const onError = async (err) => {
|
|
91767
92176
|
server.removeListener("error", onError);
|
|
91768
92177
|
if (err.code === "EADDRINUSE") {
|
|
92178
|
+
if (options.allowExistingProxy === false) {
|
|
92179
|
+
rejectAttempt(err);
|
|
92180
|
+
return;
|
|
92181
|
+
}
|
|
91769
92182
|
const existingProxy2 = await checkExistingProxy(listenPort);
|
|
91770
92183
|
if (existingProxy2) {
|
|
91771
92184
|
console.log(`[ClawRouter] Existing proxy detected on port ${listenPort}, reusing`);
|
|
@@ -94170,7 +94583,7 @@ data: [DONE]
|
|
|
94170
94583
|
});
|
|
94171
94584
|
}
|
|
94172
94585
|
}
|
|
94173
|
-
var paymentStore, BLOCKRUN_API, BLOCKRUN_SOLANA_API, IMAGE_DIR, AUDIO_DIR, VIDEO_DIR, AUTO_MODEL, ROUTING_PROFILES, FREE_MODELS, gatewayModelIds, FREE_MODEL, FREE_UPSTREAM_OVERRIDES, MAX_MESSAGES, CONTEXT_LIMIT_KB, HEARTBEAT_INTERVAL_MS, BALANCE_CHECK_TIMEOUT_MS, GATEWAY_CATALOG_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, PER_MODEL_TIMEOUT_MS, REASONING_MODEL_TIMEOUT_MS, REASONING_MODEL_IDS, MAX_FALLBACK_ATTEMPTS, HEALTH_CHECK_TIMEOUT_MS, RATE_LIMIT_COOLDOWN_MS, OVERLOAD_COOLDOWN_MS, PORT_RETRY_ATTEMPTS, PORT_RETRY_DELAY_MS, MODEL_BODY_READ_TIMEOUT_MS, ERROR_BODY_READ_TIMEOUT_MS, ClientDisconnectedError, rateLimitedModels, overloadedModels, perProviderErrors, BALANCE_CHECK_BUFFER, BALANCE_PREFLIGHT_OUTPUT_TOKEN_CAP, PROVIDER_ERROR_PATTERNS, DEGRADED_RESPONSE_PATTERNS, DEGRADED_LOOP_PATTERNS, VALID_ROLES, ROLE_MAPPINGS, VALID_TOOL_ID_PATTERN, KIMI_BLOCK_RE, KIMI_TOKEN_RE, THINKING_TAG_RE, THINKING_BLOCK_RE, BLOCKRUN_MODEL_BY_ID, IMAGE_PRICING, IMAGE_MODEL_IDS, IMAGE_MODEL_SIZES, IMAGE_MODEL_ALIASES, VIDEO_PRICING, PHONE_PRICING;
|
|
94586
|
+
var paymentStore, BLOCKRUN_API, BLOCKRUN_SOLANA_API, DESKTOP_SERVICE_TOKEN_FILE, IMAGE_DIR, AUDIO_DIR, VIDEO_DIR, AUTO_MODEL, ROUTING_PROFILES, FREE_MODELS, gatewayModelIds, FREE_MODEL, FREE_UPSTREAM_OVERRIDES, MAX_MESSAGES, CONTEXT_LIMIT_KB, HEARTBEAT_INTERVAL_MS, BALANCE_CHECK_TIMEOUT_MS, GATEWAY_CATALOG_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, PER_MODEL_TIMEOUT_MS, REASONING_MODEL_TIMEOUT_MS, REASONING_MODEL_IDS, MAX_FALLBACK_ATTEMPTS, HEALTH_CHECK_TIMEOUT_MS, RATE_LIMIT_COOLDOWN_MS, OVERLOAD_COOLDOWN_MS, PORT_RETRY_ATTEMPTS, PORT_RETRY_DELAY_MS, MODEL_BODY_READ_TIMEOUT_MS, ERROR_BODY_READ_TIMEOUT_MS, ClientDisconnectedError, rateLimitedModels, overloadedModels, perProviderErrors, BALANCE_CHECK_BUFFER, BALANCE_PREFLIGHT_OUTPUT_TOKEN_CAP, PROVIDER_ERROR_PATTERNS, DEGRADED_RESPONSE_PATTERNS, DEGRADED_LOOP_PATTERNS, VALID_ROLES, ROLE_MAPPINGS, VALID_TOOL_ID_PATTERN, KIMI_BLOCK_RE, KIMI_TOKEN_RE, THINKING_TAG_RE, THINKING_BLOCK_RE, BLOCKRUN_MODEL_BY_ID, IMAGE_PRICING, IMAGE_MODEL_IDS, IMAGE_MODEL_SIZES, IMAGE_MODEL_ALIASES, VIDEO_PRICING, PHONE_PRICING;
|
|
94174
94587
|
var init_proxy = __esm({
|
|
94175
94588
|
"src/proxy.ts"() {
|
|
94176
94589
|
"use strict";
|
|
@@ -94208,6 +94621,7 @@ var init_proxy = __esm({
|
|
|
94208
94621
|
paymentStore = new AsyncLocalStorage();
|
|
94209
94622
|
BLOCKRUN_API = "https://blockrun.ai/api";
|
|
94210
94623
|
BLOCKRUN_SOLANA_API = "https://sol.blockrun.ai/api";
|
|
94624
|
+
DESKTOP_SERVICE_TOKEN_FILE = process.env.CLAWROUTER_DESKTOP_TOKEN_FILE ?? join10(homedir7(), ".clawrouter-desktop", "service-token");
|
|
94211
94625
|
IMAGE_DIR = join10(homedir7(), ".openclaw", "blockrun", "images");
|
|
94212
94626
|
AUDIO_DIR = join10(homedir7(), ".openclaw", "blockrun", "audio");
|
|
94213
94627
|
VIDEO_DIR = join10(homedir7(), ".openclaw", "blockrun", "videos");
|
|
@@ -94463,8 +94877,8 @@ var init_provider = __esm({
|
|
|
94463
94877
|
return buildProviderModels(`http://127.0.0.1:${port}/v1`);
|
|
94464
94878
|
},
|
|
94465
94879
|
// No auth required — the x402 proxy handles wallet-based payments internally.
|
|
94466
|
-
// The proxy
|
|
94467
|
-
//
|
|
94880
|
+
// The proxy uses the shared BlockRun Core wallet under ~/.blockrun, with
|
|
94881
|
+
// automatic non-destructive migration from older ClawRouter wallet files.
|
|
94468
94882
|
auth: []
|
|
94469
94883
|
};
|
|
94470
94884
|
}
|
|
@@ -108833,7 +109247,7 @@ var init_URLSearchParams = __esm({
|
|
|
108833
109247
|
|
|
108834
109248
|
// node_modules/axios/lib/platform/node/index.js
|
|
108835
109249
|
import crypto6 from "crypto";
|
|
108836
|
-
var ALPHA, DIGIT,
|
|
109250
|
+
var ALPHA, DIGIT, ALPHABET2, generateString, node_default;
|
|
108837
109251
|
var init_node2 = __esm({
|
|
108838
109252
|
"node_modules/axios/lib/platform/node/index.js"() {
|
|
108839
109253
|
"use strict";
|
|
@@ -108841,12 +109255,12 @@ var init_node2 = __esm({
|
|
|
108841
109255
|
init_FormData();
|
|
108842
109256
|
ALPHA = "abcdefghijklmnopqrstuvwxyz";
|
|
108843
109257
|
DIGIT = "0123456789";
|
|
108844
|
-
|
|
109258
|
+
ALPHABET2 = {
|
|
108845
109259
|
DIGIT,
|
|
108846
109260
|
ALPHA,
|
|
108847
109261
|
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
|
108848
109262
|
};
|
|
108849
|
-
generateString = (size5 = 16, alphabet4 =
|
|
109263
|
+
generateString = (size5 = 16, alphabet4 = ALPHABET2.ALPHA_DIGIT) => {
|
|
108850
109264
|
let str = "";
|
|
108851
109265
|
const { length } = alphabet4;
|
|
108852
109266
|
const randomValues = new Uint32Array(size5);
|
|
@@ -108863,7 +109277,7 @@ var init_node2 = __esm({
|
|
|
108863
109277
|
FormData: FormData_default,
|
|
108864
109278
|
Blob: typeof Blob !== "undefined" && Blob || null
|
|
108865
109279
|
},
|
|
108866
|
-
ALPHABET,
|
|
109280
|
+
ALPHABET: ALPHABET2,
|
|
108867
109281
|
generateString,
|
|
108868
109282
|
protocols: ["http", "https", "file", "data"]
|
|
108869
109283
|
};
|
|
@@ -110927,8 +111341,8 @@ var require_follow_redirects = __commonJS({
|
|
|
110927
111341
|
}
|
|
110928
111342
|
return parsed;
|
|
110929
111343
|
}
|
|
110930
|
-
function resolveUrl(relative,
|
|
110931
|
-
return useNativeURL ? new URL3(relative,
|
|
111344
|
+
function resolveUrl(relative, base4) {
|
|
111345
|
+
return useNativeURL ? new URL3(relative, base4) : parseUrl3(url2.resolve(base4, relative));
|
|
110932
111346
|
}
|
|
110933
111347
|
function validateUrl(input) {
|
|
110934
111348
|
if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
|
|
@@ -117739,7 +118153,7 @@ function __addDisposableResource(env, value, async) {
|
|
|
117739
118153
|
return value;
|
|
117740
118154
|
}
|
|
117741
118155
|
function __disposeResources(env) {
|
|
117742
|
-
function
|
|
118156
|
+
function fail2(e7) {
|
|
117743
118157
|
env.error = env.hasError ? new _SuppressedError(e7, env.error, "An error was suppressed during disposal.") : e7;
|
|
117744
118158
|
env.hasError = true;
|
|
117745
118159
|
}
|
|
@@ -117751,12 +118165,12 @@ function __disposeResources(env) {
|
|
|
117751
118165
|
if (r2.dispose) {
|
|
117752
118166
|
var result = r2.dispose.call(r2.value);
|
|
117753
118167
|
if (r2.async) return s3 |= 2, Promise.resolve(result).then(next, function(e7) {
|
|
117754
|
-
|
|
118168
|
+
fail2(e7);
|
|
117755
118169
|
return next();
|
|
117756
118170
|
});
|
|
117757
118171
|
} else s3 |= 1;
|
|
117758
118172
|
} catch (e7) {
|
|
117759
|
-
|
|
118173
|
+
fail2(e7);
|
|
117760
118174
|
}
|
|
117761
118175
|
}
|
|
117762
118176
|
if (s3 === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
@@ -124926,15 +125340,15 @@ var require_curve = __commonJS({
|
|
|
124926
125340
|
const { windows, windowSize } = calcWOpts4(W, bits);
|
|
124927
125341
|
const points = [];
|
|
124928
125342
|
let p = elm;
|
|
124929
|
-
let
|
|
125343
|
+
let base4 = p;
|
|
124930
125344
|
for (let window2 = 0; window2 < windows; window2++) {
|
|
124931
|
-
|
|
124932
|
-
points.push(
|
|
125345
|
+
base4 = p;
|
|
125346
|
+
points.push(base4);
|
|
124933
125347
|
for (let i = 1; i < windowSize; i++) {
|
|
124934
|
-
|
|
124935
|
-
points.push(
|
|
125348
|
+
base4 = base4.add(p);
|
|
125349
|
+
points.push(base4);
|
|
124936
125350
|
}
|
|
124937
|
-
p =
|
|
125351
|
+
p = base4.double();
|
|
124938
125352
|
}
|
|
124939
125353
|
return points;
|
|
124940
125354
|
},
|
|
@@ -127692,7 +128106,7 @@ var require_estimateFeesPerGas = __commonJS({
|
|
|
127692
128106
|
throw new fee_js_1.BaseFeeScalarError();
|
|
127693
128107
|
const decimals = baseFeeMultiplier.toString().split(".")[1]?.length ?? 0;
|
|
127694
128108
|
const denominator = 10 ** decimals;
|
|
127695
|
-
const multiply = (
|
|
128109
|
+
const multiply = (base4) => base4 * BigInt(Math.round(baseFeeMultiplier * denominator)) / BigInt(denominator);
|
|
127696
128110
|
const block = block_ ? block_ : await (0, getAction_js_1.getAction)(client, getBlock_js_1.getBlock, "getBlock")({});
|
|
127697
128111
|
if (typeof chain3?.fees?.estimateFeesPerGas === "function") {
|
|
127698
128112
|
const fees = await chain3.fees.estimateFeesPerGas({
|
|
@@ -128202,7 +128616,7 @@ var require_fillTransaction = __commonJS({
|
|
|
128202
128616
|
throw new fee_js_1.BaseFeeScalarError();
|
|
128203
128617
|
const decimals = feeMultiplier.toString().split(".")[1]?.length ?? 0;
|
|
128204
128618
|
const denominator = 10 ** decimals;
|
|
128205
|
-
const multiplyFee = (
|
|
128619
|
+
const multiplyFee = (base4) => base4 * BigInt(Math.round(feeMultiplier * denominator)) / BigInt(denominator);
|
|
128206
128620
|
if (!transaction.feePayerSignature) {
|
|
128207
128621
|
if (transaction.maxFeePerGas && !parameters.maxFeePerGas)
|
|
128208
128622
|
transaction.maxFeePerGas = multiplyFee(transaction.maxFeePerGas);
|
|
@@ -132960,17 +133374,17 @@ var require_call = __commonJS({
|
|
|
132960
133374
|
}
|
|
132961
133375
|
}
|
|
132962
133376
|
const params = (() => {
|
|
132963
|
-
const
|
|
133377
|
+
const base4 = [
|
|
132964
133378
|
request2,
|
|
132965
133379
|
block
|
|
132966
133380
|
];
|
|
132967
133381
|
if (rpcStateOverride && rpcBlockOverrides)
|
|
132968
|
-
return [...
|
|
133382
|
+
return [...base4, rpcStateOverride, rpcBlockOverrides];
|
|
132969
133383
|
if (rpcStateOverride)
|
|
132970
|
-
return [...
|
|
133384
|
+
return [...base4, rpcStateOverride];
|
|
132971
133385
|
if (rpcBlockOverrides)
|
|
132972
|
-
return [...
|
|
132973
|
-
return
|
|
133386
|
+
return [...base4, {}, rpcBlockOverrides];
|
|
133387
|
+
return base4;
|
|
132974
133388
|
})();
|
|
132975
133389
|
const response = await client.request({
|
|
132976
133390
|
method: "eth_call",
|
|
@@ -134582,14 +134996,14 @@ var require_createClient = __commonJS({
|
|
|
134582
134996
|
uid: (0, uid_js_1.uid)(),
|
|
134583
134997
|
...experimental_blockTag ? { experimental_blockTag } : {}
|
|
134584
134998
|
};
|
|
134585
|
-
function extend2(
|
|
134999
|
+
function extend2(base4) {
|
|
134586
135000
|
return (extendFn) => {
|
|
134587
|
-
const extended = extendFn(
|
|
135001
|
+
const extended = extendFn(base4);
|
|
134588
135002
|
for (const key3 in client)
|
|
134589
135003
|
delete extended[key3];
|
|
134590
|
-
const combined = { ...
|
|
135004
|
+
const combined = { ...base4, ...extended };
|
|
134591
135005
|
for (const key3 in extended) {
|
|
134592
|
-
const a =
|
|
135006
|
+
const a = base4[key3];
|
|
134593
135007
|
const b = extended[key3];
|
|
134594
135008
|
if (isPlainObject4(a) && isPlainObject4(b))
|
|
134595
135009
|
combined[key3] = { ...a, ...b };
|
|
@@ -136607,10 +137021,10 @@ var require_defineChain = __commonJS({
|
|
|
136607
137021
|
serializers: void 0,
|
|
136608
137022
|
...chain3
|
|
136609
137023
|
};
|
|
136610
|
-
function extend2(
|
|
137024
|
+
function extend2(base4) {
|
|
136611
137025
|
return (fnOrExtended) => {
|
|
136612
|
-
const properties = typeof fnOrExtended === "function" ? fnOrExtended(
|
|
136613
|
-
const combined = { ...
|
|
137026
|
+
const properties = typeof fnOrExtended === "function" ? fnOrExtended(base4) : fnOrExtended;
|
|
137027
|
+
const combined = { ...base4, ...properties };
|
|
136614
137028
|
return Object.assign(combined, { extend: extend2(combined) });
|
|
136615
137029
|
};
|
|
136616
137030
|
}
|
|
@@ -137945,9 +138359,9 @@ var require_typedData2 = __commonJS({
|
|
|
137945
138359
|
throw new typedData_js_1.InvalidTypedDataTypeError({ type });
|
|
137946
138360
|
const integerMatch = type.match(regex_js_1.integerRegex);
|
|
137947
138361
|
if (integerMatch && (typeof value === "number" || typeof value === "bigint")) {
|
|
137948
|
-
const [_type,
|
|
138362
|
+
const [_type, base4, size_] = integerMatch;
|
|
137949
138363
|
(0, toHex_js_1.numberToHex)(value, {
|
|
137950
|
-
signed:
|
|
138364
|
+
signed: base4 === "int",
|
|
137951
138365
|
size: Number.parseInt(size_, 10) / 8
|
|
137952
138366
|
});
|
|
137953
138367
|
}
|
|
@@ -141739,15 +142153,15 @@ var require_curve2 = __commonJS({
|
|
|
141739
142153
|
const { windows, windowSize } = calcWOpts4(W, bits);
|
|
141740
142154
|
const points = [];
|
|
141741
142155
|
let p = elm;
|
|
141742
|
-
let
|
|
142156
|
+
let base4 = p;
|
|
141743
142157
|
for (let window2 = 0; window2 < windows; window2++) {
|
|
141744
|
-
|
|
141745
|
-
points.push(
|
|
142158
|
+
base4 = p;
|
|
142159
|
+
points.push(base4);
|
|
141746
142160
|
for (let i = 1; i < windowSize; i++) {
|
|
141747
|
-
|
|
141748
|
-
points.push(
|
|
142161
|
+
base4 = base4.add(p);
|
|
142162
|
+
points.push(base4);
|
|
141749
142163
|
}
|
|
141750
|
-
p =
|
|
142164
|
+
p = base4.double();
|
|
141751
142165
|
}
|
|
141752
142166
|
return points;
|
|
141753
142167
|
},
|
|
@@ -175260,14 +175674,14 @@ var require_Authenticator = __commonJS({
|
|
|
175260
175674
|
const rpIdHash = Hash4.sha256(Hex.fromString(rpId));
|
|
175261
175675
|
const flag_bytes = Hex.fromNumber(flag, { size: 1 });
|
|
175262
175676
|
const signCount_bytes = Hex.fromNumber(signCount, { size: 4 });
|
|
175263
|
-
const
|
|
175677
|
+
const base4 = Hex.concat(rpIdHash, flag_bytes, signCount_bytes);
|
|
175264
175678
|
if (!credential)
|
|
175265
|
-
return
|
|
175679
|
+
return base4;
|
|
175266
175680
|
const aaguid = Hex.fromBytes(new Uint8Array(16));
|
|
175267
175681
|
const credentialId = Hex.fromBytes(credential.id);
|
|
175268
175682
|
const credIdLen = Hex.fromNumber(credential.id.length, { size: 2 });
|
|
175269
175683
|
const coseKey = CoseKey.fromPublicKey(credential.publicKey);
|
|
175270
|
-
return Hex.concat(
|
|
175684
|
+
return Hex.concat(base4, aaguid, credIdLen, credentialId, coseKey);
|
|
175271
175685
|
}
|
|
175272
175686
|
function getSignCount(authenticatorData) {
|
|
175273
175687
|
const bytes = Bytes.fromHex(authenticatorData);
|
|
@@ -179175,7 +179589,7 @@ var require_VirtualMaster = __commonJS({
|
|
|
179175
179589
|
terminateAll();
|
|
179176
179590
|
resolve(result);
|
|
179177
179591
|
};
|
|
179178
|
-
const
|
|
179592
|
+
const fail2 = (error) => {
|
|
179179
179593
|
if (settled)
|
|
179180
179594
|
return;
|
|
179181
179595
|
settled = true;
|
|
@@ -179200,14 +179614,14 @@ var require_VirtualMaster = __commonJS({
|
|
|
179200
179614
|
succeed(void 0);
|
|
179201
179615
|
return;
|
|
179202
179616
|
case "error":
|
|
179203
|
-
|
|
179617
|
+
fail2(new Errors.BaseError(msg.message));
|
|
179204
179618
|
return;
|
|
179205
179619
|
}
|
|
179206
179620
|
};
|
|
179207
|
-
const onAbort = () =>
|
|
179621
|
+
const onAbort = () => fail2(getAbortError2(value.signal));
|
|
179208
179622
|
value.signal?.addEventListener("abort", onAbort, { once: true });
|
|
179209
179623
|
for (let i = 0; i < value.workerCount; i++) {
|
|
179210
|
-
const handle = value.pool.spawn(i, onMessage,
|
|
179624
|
+
const handle = value.pool.spawn(i, onMessage, fail2);
|
|
179211
179625
|
handles.push(handle);
|
|
179212
179626
|
handle.postMessage({
|
|
179213
179627
|
type: "start",
|
|
@@ -179351,8 +179765,8 @@ var require_ZoneId = __commonJS({
|
|
|
179351
179765
|
return chainId - getChainIdConfig(sourceId2).base;
|
|
179352
179766
|
}
|
|
179353
179767
|
function toChainId(zoneId, sourceId2 = defaultSourceId) {
|
|
179354
|
-
const { base:
|
|
179355
|
-
return
|
|
179768
|
+
const { base: base4, range } = getChainIdConfig(sourceId2);
|
|
179769
|
+
return base4 + zoneId % range;
|
|
179356
179770
|
}
|
|
179357
179771
|
var UnsupportedSourceIdError = class extends Errors.BaseError {
|
|
179358
179772
|
constructor({ sourceId: sourceId2 }) {
|
|
@@ -192958,7 +193372,7 @@ var require_bn = __commonJS({
|
|
|
192958
193372
|
ctor.prototype = new TempCtor();
|
|
192959
193373
|
ctor.prototype.constructor = ctor;
|
|
192960
193374
|
}
|
|
192961
|
-
function BN3(number,
|
|
193375
|
+
function BN3(number, base4, endian) {
|
|
192962
193376
|
if (BN3.isBN(number)) {
|
|
192963
193377
|
return number;
|
|
192964
193378
|
}
|
|
@@ -192967,11 +193381,11 @@ var require_bn = __commonJS({
|
|
|
192967
193381
|
this.length = 0;
|
|
192968
193382
|
this.red = null;
|
|
192969
193383
|
if (number !== null) {
|
|
192970
|
-
if (
|
|
192971
|
-
endian =
|
|
192972
|
-
|
|
193384
|
+
if (base4 === "le" || base4 === "be") {
|
|
193385
|
+
endian = base4;
|
|
193386
|
+
base4 = 10;
|
|
192973
193387
|
}
|
|
192974
|
-
this._init(number || 0,
|
|
193388
|
+
this._init(number || 0, base4 || 10, endian || "be");
|
|
192975
193389
|
}
|
|
192976
193390
|
}
|
|
192977
193391
|
if (typeof module2 === "object") {
|
|
@@ -193004,17 +193418,17 @@ var require_bn = __commonJS({
|
|
|
193004
193418
|
if (left.cmp(right) < 0) return left;
|
|
193005
193419
|
return right;
|
|
193006
193420
|
};
|
|
193007
|
-
BN3.prototype._init = function init2(number,
|
|
193421
|
+
BN3.prototype._init = function init2(number, base4, endian) {
|
|
193008
193422
|
if (typeof number === "number") {
|
|
193009
|
-
return this._initNumber(number,
|
|
193423
|
+
return this._initNumber(number, base4, endian);
|
|
193010
193424
|
}
|
|
193011
193425
|
if (typeof number === "object") {
|
|
193012
|
-
return this._initArray(number,
|
|
193426
|
+
return this._initArray(number, base4, endian);
|
|
193013
193427
|
}
|
|
193014
|
-
if (
|
|
193015
|
-
|
|
193428
|
+
if (base4 === "hex") {
|
|
193429
|
+
base4 = 16;
|
|
193016
193430
|
}
|
|
193017
|
-
assert10(
|
|
193431
|
+
assert10(base4 === (base4 | 0) && base4 >= 2 && base4 <= 36);
|
|
193018
193432
|
number = number.toString().replace(/\s+/g, "");
|
|
193019
193433
|
var start = 0;
|
|
193020
193434
|
if (number[0] === "-") {
|
|
@@ -193022,17 +193436,17 @@ var require_bn = __commonJS({
|
|
|
193022
193436
|
this.negative = 1;
|
|
193023
193437
|
}
|
|
193024
193438
|
if (start < number.length) {
|
|
193025
|
-
if (
|
|
193439
|
+
if (base4 === 16) {
|
|
193026
193440
|
this._parseHex(number, start, endian);
|
|
193027
193441
|
} else {
|
|
193028
|
-
this._parseBase(number,
|
|
193442
|
+
this._parseBase(number, base4, start);
|
|
193029
193443
|
if (endian === "le") {
|
|
193030
|
-
this._initArray(this.toArray(),
|
|
193444
|
+
this._initArray(this.toArray(), base4, endian);
|
|
193031
193445
|
}
|
|
193032
193446
|
}
|
|
193033
193447
|
}
|
|
193034
193448
|
};
|
|
193035
|
-
BN3.prototype._initNumber = function _initNumber(number,
|
|
193449
|
+
BN3.prototype._initNumber = function _initNumber(number, base4, endian) {
|
|
193036
193450
|
if (number < 0) {
|
|
193037
193451
|
this.negative = 1;
|
|
193038
193452
|
number = -number;
|
|
@@ -193056,9 +193470,9 @@ var require_bn = __commonJS({
|
|
|
193056
193470
|
this.length = 3;
|
|
193057
193471
|
}
|
|
193058
193472
|
if (endian !== "le") return;
|
|
193059
|
-
this._initArray(this.toArray(),
|
|
193473
|
+
this._initArray(this.toArray(), base4, endian);
|
|
193060
193474
|
};
|
|
193061
|
-
BN3.prototype._initArray = function _initArray(number,
|
|
193475
|
+
BN3.prototype._initArray = function _initArray(number, base4, endian) {
|
|
193062
193476
|
assert10(typeof number.length === "number");
|
|
193063
193477
|
if (number.length <= 0) {
|
|
193064
193478
|
this.words = [0];
|
|
@@ -193172,20 +193586,20 @@ var require_bn = __commonJS({
|
|
|
193172
193586
|
}
|
|
193173
193587
|
return r2;
|
|
193174
193588
|
}
|
|
193175
|
-
BN3.prototype._parseBase = function _parseBase(number,
|
|
193589
|
+
BN3.prototype._parseBase = function _parseBase(number, base4, start) {
|
|
193176
193590
|
this.words = [0];
|
|
193177
193591
|
this.length = 1;
|
|
193178
|
-
for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *=
|
|
193592
|
+
for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base4) {
|
|
193179
193593
|
limbLen++;
|
|
193180
193594
|
}
|
|
193181
193595
|
limbLen--;
|
|
193182
|
-
limbPow = limbPow /
|
|
193596
|
+
limbPow = limbPow / base4 | 0;
|
|
193183
193597
|
var total = number.length - start;
|
|
193184
193598
|
var mod5 = total % limbLen;
|
|
193185
193599
|
var end = Math.min(total, total - mod5) + start;
|
|
193186
193600
|
var word = 0;
|
|
193187
193601
|
for (var i = start; i < end; i += limbLen) {
|
|
193188
|
-
word = parseBase(number, i, i + limbLen,
|
|
193602
|
+
word = parseBase(number, i, i + limbLen, base4);
|
|
193189
193603
|
this.imuln(limbPow);
|
|
193190
193604
|
if (this.words[0] + word < 67108864) {
|
|
193191
193605
|
this.words[0] += word;
|
|
@@ -193195,9 +193609,9 @@ var require_bn = __commonJS({
|
|
|
193195
193609
|
}
|
|
193196
193610
|
if (mod5 !== 0) {
|
|
193197
193611
|
var pow = 1;
|
|
193198
|
-
word = parseBase(number, i, number.length,
|
|
193612
|
+
word = parseBase(number, i, number.length, base4);
|
|
193199
193613
|
for (i = 0; i < mod5; i++) {
|
|
193200
|
-
pow *=
|
|
193614
|
+
pow *= base4;
|
|
193201
193615
|
}
|
|
193202
193616
|
this.imuln(pow);
|
|
193203
193617
|
if (this.words[0] + word < 67108864) {
|
|
@@ -193367,11 +193781,11 @@ var require_bn = __commonJS({
|
|
|
193367
193781
|
52521875,
|
|
193368
193782
|
60466176
|
|
193369
193783
|
];
|
|
193370
|
-
BN3.prototype.toString = function toString4(
|
|
193371
|
-
|
|
193784
|
+
BN3.prototype.toString = function toString4(base4, padding3) {
|
|
193785
|
+
base4 = base4 || 10;
|
|
193372
193786
|
padding3 = padding3 | 0 || 1;
|
|
193373
193787
|
var out;
|
|
193374
|
-
if (
|
|
193788
|
+
if (base4 === 16 || base4 === "hex") {
|
|
193375
193789
|
out = "";
|
|
193376
193790
|
var off = 0;
|
|
193377
193791
|
var carry2 = 0;
|
|
@@ -193401,14 +193815,14 @@ var require_bn = __commonJS({
|
|
|
193401
193815
|
}
|
|
193402
193816
|
return out;
|
|
193403
193817
|
}
|
|
193404
|
-
if (
|
|
193405
|
-
var groupSize = groupSizes[
|
|
193406
|
-
var groupBase = groupBases[
|
|
193818
|
+
if (base4 === (base4 | 0) && base4 >= 2 && base4 <= 36) {
|
|
193819
|
+
var groupSize = groupSizes[base4];
|
|
193820
|
+
var groupBase = groupBases[base4];
|
|
193407
193821
|
out = "";
|
|
193408
193822
|
var c = this.clone();
|
|
193409
193823
|
c.negative = 0;
|
|
193410
193824
|
while (!c.isZero()) {
|
|
193411
|
-
var r2 = c.modrn(groupBase).toString(
|
|
193825
|
+
var r2 = c.modrn(groupBase).toString(base4);
|
|
193412
193826
|
c = c.idivn(groupBase);
|
|
193413
193827
|
if (!c.isZero()) {
|
|
193414
193828
|
out = zeros2[groupSize - r2.length] + r2 + out;
|
|
@@ -203977,8 +204391,8 @@ function createCommonjsModule(fn, basedir, module) {
|
|
|
203977
204391
|
return module = {
|
|
203978
204392
|
path: basedir,
|
|
203979
204393
|
exports: {},
|
|
203980
|
-
require: function(path5,
|
|
203981
|
-
return commonjsRequire(path5,
|
|
204394
|
+
require: function(path5, base4) {
|
|
204395
|
+
return commonjsRequire(path5, base4 === void 0 || base4 === null ? module.path : base4);
|
|
203982
204396
|
}
|
|
203983
204397
|
}, fn(module, module.exports), module.exports;
|
|
203984
204398
|
}
|
|
@@ -204017,7 +204431,7 @@ function BasePoint(curve, type) {
|
|
|
204017
204431
|
this.precomputed = null;
|
|
204018
204432
|
}
|
|
204019
204433
|
function ShortCurve(conf) {
|
|
204020
|
-
|
|
204434
|
+
base3.call(this, "short", conf);
|
|
204021
204435
|
this.a = new import_bn2.default(conf.a, 16).toRed(this.red);
|
|
204022
204436
|
this.b = new import_bn2.default(conf.b, 16).toRed(this.red);
|
|
204023
204437
|
this.tinv = this.two.redInvm();
|
|
@@ -204028,7 +204442,7 @@ function ShortCurve(conf) {
|
|
|
204028
204442
|
this._endoWnafT2 = new Array(4);
|
|
204029
204443
|
}
|
|
204030
204444
|
function Point3(curve, x, y, isRed) {
|
|
204031
|
-
|
|
204445
|
+
base3.BasePoint.call(this, curve, "affine");
|
|
204032
204446
|
if (x === null && y === null) {
|
|
204033
204447
|
this.x = null;
|
|
204034
204448
|
this.y = null;
|
|
@@ -204048,7 +204462,7 @@ function Point3(curve, x, y, isRed) {
|
|
|
204048
204462
|
}
|
|
204049
204463
|
}
|
|
204050
204464
|
function JPoint(curve, x, y, z) {
|
|
204051
|
-
|
|
204465
|
+
base3.BasePoint.call(this, curve, "jacobian");
|
|
204052
204466
|
if (x === null && y === null && z === null) {
|
|
204053
204467
|
this.x = this.curve.one;
|
|
204054
204468
|
this.y = this.curve.one;
|
|
@@ -204178,7 +204592,7 @@ function EC(options) {
|
|
|
204178
204592
|
this.g.precompute(options.curve.n.bitLength() + 1);
|
|
204179
204593
|
this.hash = options.hash || options.curve.hash;
|
|
204180
204594
|
}
|
|
204181
|
-
var import_bn2, import_hash2, minimalisticAssert, utils_1, utils_1$1, getNAF, getJSF, assert$1,
|
|
204595
|
+
var import_bn2, import_hash2, minimalisticAssert, utils_1, utils_1$1, getNAF, getJSF, assert$1, base3, inherits_browser, assert$2, short_1, curve_1, curves_1, hmacDrbg, assert$3, key, assert$4, signature2, rand, assert$5, ec, elliptic_1, EC$1;
|
|
204182
204596
|
var init_elliptic = __esm({
|
|
204183
204597
|
"node_modules/@ethersproject/signing-key/lib.esm/elliptic.js"() {
|
|
204184
204598
|
"use strict";
|
|
@@ -204346,7 +204760,7 @@ var init_elliptic = __esm({
|
|
|
204346
204760
|
getNAF = utils_1$1.getNAF;
|
|
204347
204761
|
getJSF = utils_1$1.getJSF;
|
|
204348
204762
|
assert$1 = utils_1$1.assert;
|
|
204349
|
-
|
|
204763
|
+
base3 = BaseCurve;
|
|
204350
204764
|
BaseCurve.prototype.point = function point() {
|
|
204351
204765
|
throw new Error("Not implemented");
|
|
204352
204766
|
};
|
|
@@ -204658,7 +205072,7 @@ var init_elliptic = __esm({
|
|
|
204658
205072
|
}
|
|
204659
205073
|
});
|
|
204660
205074
|
assert$2 = utils_1$1.assert;
|
|
204661
|
-
inherits_browser(ShortCurve,
|
|
205075
|
+
inherits_browser(ShortCurve, base3);
|
|
204662
205076
|
short_1 = ShortCurve;
|
|
204663
205077
|
ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
|
|
204664
205078
|
if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)
|
|
@@ -204832,7 +205246,7 @@ var init_elliptic = __esm({
|
|
|
204832
205246
|
}
|
|
204833
205247
|
return res;
|
|
204834
205248
|
};
|
|
204835
|
-
inherits_browser(Point3,
|
|
205249
|
+
inherits_browser(Point3, base3.BasePoint);
|
|
204836
205250
|
ShortCurve.prototype.point = function point2(x, y, isRed) {
|
|
204837
205251
|
return new Point3(this, x, y, isRed);
|
|
204838
205252
|
};
|
|
@@ -205007,7 +205421,7 @@ var init_elliptic = __esm({
|
|
|
205007
205421
|
var res = this.curve.jpoint(this.x, this.y, this.curve.one);
|
|
205008
205422
|
return res;
|
|
205009
205423
|
};
|
|
205010
|
-
inherits_browser(JPoint,
|
|
205424
|
+
inherits_browser(JPoint, base3.BasePoint);
|
|
205011
205425
|
ShortCurve.prototype.jpoint = function jpoint(x, y, z) {
|
|
205012
205426
|
return new JPoint(this, x, y, z);
|
|
205013
205427
|
};
|
|
@@ -205297,7 +205711,7 @@ var init_elliptic = __esm({
|
|
|
205297
205711
|
curve_1 = createCommonjsModule(function(module, exports) {
|
|
205298
205712
|
"use strict";
|
|
205299
205713
|
var curve = exports;
|
|
205300
|
-
curve.base =
|
|
205714
|
+
curve.base = base3;
|
|
205301
205715
|
curve.short = short_1;
|
|
205302
205716
|
curve.mont = /*RicMoo:ethers:require(./mont)*/
|
|
205303
205717
|
null;
|
|
@@ -210518,10 +210932,10 @@ var init_lib28 = __esm({
|
|
|
210518
210932
|
var require_bech32 = __commonJS({
|
|
210519
210933
|
"node_modules/bech32/index.js"(exports, module) {
|
|
210520
210934
|
"use strict";
|
|
210521
|
-
var
|
|
210935
|
+
var ALPHABET3 = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
|
|
210522
210936
|
var ALPHABET_MAP = {};
|
|
210523
|
-
for (z = 0; z <
|
|
210524
|
-
x =
|
|
210937
|
+
for (z = 0; z < ALPHABET3.length; z++) {
|
|
210938
|
+
x = ALPHABET3.charAt(z);
|
|
210525
210939
|
if (ALPHABET_MAP[x] !== void 0) throw new TypeError(x + " is ambiguous");
|
|
210526
210940
|
ALPHABET_MAP[x] = z;
|
|
210527
210941
|
}
|
|
@@ -210556,7 +210970,7 @@ var require_bech32 = __commonJS({
|
|
|
210556
210970
|
var x2 = words2[i];
|
|
210557
210971
|
if (x2 >> 5 !== 0) throw new Error("Non 5-bit word");
|
|
210558
210972
|
chk = polymodStep(chk) ^ x2;
|
|
210559
|
-
result +=
|
|
210973
|
+
result += ALPHABET3.charAt(x2);
|
|
210560
210974
|
}
|
|
210561
210975
|
for (i = 0; i < 6; ++i) {
|
|
210562
210976
|
chk = polymodStep(chk);
|
|
@@ -210564,7 +210978,7 @@ var require_bech32 = __commonJS({
|
|
|
210564
210978
|
chk ^= 1;
|
|
210565
210979
|
for (i = 0; i < 6; ++i) {
|
|
210566
210980
|
var v = chk >> (5 - i) * 5 & 31;
|
|
210567
|
-
result +=
|
|
210981
|
+
result += ALPHABET3.charAt(v);
|
|
210568
210982
|
}
|
|
210569
210983
|
return result;
|
|
210570
210984
|
}
|
|
@@ -217944,12 +218358,12 @@ var require_axios = __commonJS({
|
|
|
217944
218358
|
var URLSearchParams2 = url2.URLSearchParams;
|
|
217945
218359
|
var ALPHA2 = "abcdefghijklmnopqrstuvwxyz";
|
|
217946
218360
|
var DIGIT2 = "0123456789";
|
|
217947
|
-
var
|
|
218361
|
+
var ALPHABET3 = {
|
|
217948
218362
|
DIGIT: DIGIT2,
|
|
217949
218363
|
ALPHA: ALPHA2,
|
|
217950
218364
|
ALPHA_DIGIT: ALPHA2 + ALPHA2.toUpperCase() + DIGIT2
|
|
217951
218365
|
};
|
|
217952
|
-
var generateString2 = (size5 = 16, alphabet4 =
|
|
218366
|
+
var generateString2 = (size5 = 16, alphabet4 = ALPHABET3.ALPHA_DIGIT) => {
|
|
217953
218367
|
let str = "";
|
|
217954
218368
|
const {
|
|
217955
218369
|
length
|
|
@@ -217968,7 +218382,7 @@ var require_axios = __commonJS({
|
|
|
217968
218382
|
FormData: FormData$1,
|
|
217969
218383
|
Blob: typeof Blob !== "undefined" && Blob || null
|
|
217970
218384
|
},
|
|
217971
|
-
ALPHABET:
|
|
218385
|
+
ALPHABET: ALPHABET3,
|
|
217972
218386
|
generateString: generateString2,
|
|
217973
218387
|
protocols: ["http", "https", "file", "data"]
|
|
217974
218388
|
};
|
|
@@ -225294,10 +225708,10 @@ async function redeemPosition(input, deps) {
|
|
|
225294
225708
|
structured: { conditionId, negRisk, transactionHash: txHash, pusdBalance: balanceAfter }
|
|
225295
225709
|
};
|
|
225296
225710
|
} catch (err) {
|
|
225297
|
-
const
|
|
225711
|
+
const base4 = await mapClobError(err);
|
|
225298
225712
|
const legacyHint = ` If this market predates the 2026-04-28 V2 cutover it may settle in legacy USDC.e collateral, which this tool does not auto-detect yet \u2014 redeem it once via the Polymarket UI.`;
|
|
225299
225713
|
return {
|
|
225300
|
-
text: `${
|
|
225714
|
+
text: `${base4}${/revert|execution reverted|failed/i.test(base4) ? legacyHint : ""}`,
|
|
225301
225715
|
isError: true
|
|
225302
225716
|
};
|
|
225303
225717
|
}
|
|
@@ -225943,8 +226357,8 @@ var init_dist7 = __esm({
|
|
|
225943
226357
|
if (normalized.startsWith("/api/")) {
|
|
225944
226358
|
normalized = normalized.slice(4);
|
|
225945
226359
|
}
|
|
225946
|
-
const
|
|
225947
|
-
if (!params) return
|
|
226360
|
+
const base4 = `${this.apiUrl}${normalized}`;
|
|
226361
|
+
if (!params) return base4;
|
|
225948
226362
|
const qs = new URLSearchParams();
|
|
225949
226363
|
for (const [key2, value] of Object.entries(params)) {
|
|
225950
226364
|
if (value === void 0 || value === null) continue;
|
|
@@ -225958,12 +226372,12 @@ var init_dist7 = __esm({
|
|
|
225958
226372
|
}
|
|
225959
226373
|
}
|
|
225960
226374
|
const query = qs.toString();
|
|
225961
|
-
return query ? `${
|
|
226375
|
+
return query ? `${base4}?${query}` : base4;
|
|
225962
226376
|
}
|
|
225963
226377
|
absolute(url2) {
|
|
225964
226378
|
if (url2.startsWith("http://") || url2.startsWith("https://")) return url2;
|
|
225965
|
-
const
|
|
225966
|
-
return `${
|
|
226379
|
+
const base4 = this.apiUrl.endsWith("/api") ? this.apiUrl.slice(0, -"/api".length) : this.apiUrl;
|
|
226380
|
+
return `${base4}${url2}`;
|
|
225967
226381
|
}
|
|
225968
226382
|
async requestWithPayment(url2, method, body) {
|
|
225969
226383
|
const init2 = { method };
|
|
@@ -226537,6 +226951,210 @@ var init_exclude = __esm({
|
|
|
226537
226951
|
}
|
|
226538
226952
|
});
|
|
226539
226953
|
|
|
226954
|
+
// src/commands/policy.ts
|
|
226955
|
+
function unsetMeaning(key2) {
|
|
226956
|
+
switch (key2) {
|
|
226957
|
+
case "allowedPayees":
|
|
226958
|
+
return "every payee is permitted";
|
|
226959
|
+
case "allowedNetworks":
|
|
226960
|
+
return "every network is permitted";
|
|
226961
|
+
case "allowedAssets":
|
|
226962
|
+
return "every asset is permitted";
|
|
226963
|
+
case "blockedPayees":
|
|
226964
|
+
return "no payee is blocked";
|
|
226965
|
+
default:
|
|
226966
|
+
return `spend in the ${key2} window is uncapped`;
|
|
226967
|
+
}
|
|
226968
|
+
}
|
|
226969
|
+
function fail(text) {
|
|
226970
|
+
return { text, isError: true };
|
|
226971
|
+
}
|
|
226972
|
+
function isPolicyList2(v) {
|
|
226973
|
+
return POLICY_LISTS.includes(v);
|
|
226974
|
+
}
|
|
226975
|
+
function isSpendWindow(v) {
|
|
226976
|
+
return SPEND_WINDOWS.includes(v);
|
|
226977
|
+
}
|
|
226978
|
+
function isListAction(v) {
|
|
226979
|
+
return LIST_ACTIONS.includes(v);
|
|
226980
|
+
}
|
|
226981
|
+
function rejectValue(list, value) {
|
|
226982
|
+
if (list === "allowedNetworks") {
|
|
226983
|
+
return PAYABLE_NETWORKS.includes(value) ? void 0 : `"${value}" is not a network the proxy can pay on \u2014 allowedNetworks accepts only ${CAIP2_BASE} (Base) or ${CAIP2_SOLANA_MAINNET} (Solana mainnet), not a nickname. Other CAIP-2 ids are well formed but cannot appear in a payment quote, so allowlisting one would only block payments`;
|
|
226984
|
+
}
|
|
226985
|
+
if (/^0x/i.test(value)) {
|
|
226986
|
+
return EVM_ADDRESS2.test(value) ? void 0 : `"${value}" starts with 0x but is not 0x followed by exactly 40 hex characters`;
|
|
226987
|
+
}
|
|
226988
|
+
return BASE58_ADDRESS.test(value) ? void 0 : `"${value}" is not an address \u2014 expected 0x plus 40 hex characters (Base) or a 32\u201344 character base58 id (Solana)`;
|
|
226989
|
+
}
|
|
226990
|
+
function parsePolicyArgs(argv) {
|
|
226991
|
+
const [sub = "", target = "", ...values] = argv;
|
|
226992
|
+
const action = sub.toLowerCase();
|
|
226993
|
+
if (action === "") return { kind: "show" };
|
|
226994
|
+
if (action === "limit") {
|
|
226995
|
+
if (!isSpendWindow(target)) {
|
|
226996
|
+
return fail(
|
|
226997
|
+
`Unknown window "${target}"; expected one of: ${SPEND_WINDOWS.join(", ")}
|
|
226998
|
+
${USAGE}`
|
|
226999
|
+
);
|
|
227000
|
+
}
|
|
227001
|
+
const raw = values[0];
|
|
227002
|
+
if (raw === void 0 || values.length !== 1) {
|
|
227003
|
+
return fail(`policy limit takes exactly one amount (or "clear")
|
|
227004
|
+
${USAGE}`);
|
|
227005
|
+
}
|
|
227006
|
+
if (raw === "clear") return { kind: "limit", window: target, usd: void 0 };
|
|
227007
|
+
const usd = Number(raw);
|
|
227008
|
+
if (!USD.test(raw) || !Number.isFinite(usd) || usd <= 0) {
|
|
227009
|
+
return fail(
|
|
227010
|
+
`Rejected amount "${raw}": must be a positive decimal USD value such as 0.10 or 5`
|
|
227011
|
+
);
|
|
227012
|
+
}
|
|
227013
|
+
return { kind: "limit", window: target, usd };
|
|
227014
|
+
}
|
|
227015
|
+
if (!isListAction(action)) return fail(`Unknown subcommand "${sub}"
|
|
227016
|
+
${USAGE}`);
|
|
227017
|
+
if (!isPolicyList2(target)) {
|
|
227018
|
+
return fail(`Unknown list "${target}"; expected one of: ${POLICY_LISTS.join(", ")}
|
|
227019
|
+
${USAGE}`);
|
|
227020
|
+
}
|
|
227021
|
+
if (action === "clear" ? values.length !== 0 : values.length === 0) {
|
|
227022
|
+
return fail(
|
|
227023
|
+
`policy ${action} <list> ${action === "clear" ? "takes no values" : "needs at least one value"}
|
|
227024
|
+
${USAGE}`
|
|
227025
|
+
);
|
|
227026
|
+
}
|
|
227027
|
+
for (const v of values) {
|
|
227028
|
+
const why = rejectValue(target, v);
|
|
227029
|
+
if (why !== void 0) return fail(`Rejected ${target} entry: ${why}`);
|
|
227030
|
+
}
|
|
227031
|
+
return { kind: "list", action, list: target, values };
|
|
227032
|
+
}
|
|
227033
|
+
function nextListValue(current, plan) {
|
|
227034
|
+
const have = current ?? [];
|
|
227035
|
+
const wanted = [...new Set(plan.values.map(normalizePayee))];
|
|
227036
|
+
switch (plan.action) {
|
|
227037
|
+
case "set":
|
|
227038
|
+
return { next: wanted };
|
|
227039
|
+
case "clear":
|
|
227040
|
+
return { next: void 0 };
|
|
227041
|
+
case "add":
|
|
227042
|
+
return { next: [.../* @__PURE__ */ new Set([...have, ...wanted])] };
|
|
227043
|
+
case "remove": {
|
|
227044
|
+
if (have.length === 0) return { reject: `${plan.list} is not configured; nothing to remove` };
|
|
227045
|
+
const missing = wanted.filter((v) => !have.includes(v));
|
|
227046
|
+
if (missing.length > 0) return { reject: `not in ${plan.list}: ${missing.join(", ")}` };
|
|
227047
|
+
const next = have.filter((v) => !wanted.includes(v));
|
|
227048
|
+
if (next.length === 0 && ALLOW_LISTS.includes(plan.list)) {
|
|
227049
|
+
return {
|
|
227050
|
+
reject: `removing the last ${plan.list} entry would unset the list, and then ${unsetMeaning(plan.list)}. Use "policy clear ${plan.list}" if that is what you want`
|
|
227051
|
+
};
|
|
227052
|
+
}
|
|
227053
|
+
return { next: next.length > 0 ? next : void 0 };
|
|
227054
|
+
}
|
|
227055
|
+
}
|
|
227056
|
+
}
|
|
227057
|
+
function formatPolicy(limits) {
|
|
227058
|
+
const lines = ["Spend limits (USD):"];
|
|
227059
|
+
for (const w of SPEND_WINDOWS) {
|
|
227060
|
+
const v = limits[w];
|
|
227061
|
+
lines.push(` ${w}: ${v === void 0 ? `(unset \u2014 ${unsetMeaning(w)})` : `$${v}`}`);
|
|
227062
|
+
}
|
|
227063
|
+
lines.push("Policy lists:");
|
|
227064
|
+
for (const l2 of POLICY_LISTS) {
|
|
227065
|
+
const v = limits[l2];
|
|
227066
|
+
lines.push(` ${l2}: ${v && v.length > 0 ? v.join(", ") : `(unset \u2014 ${unsetMeaning(l2)})`}`);
|
|
227067
|
+
}
|
|
227068
|
+
return lines.join("\n");
|
|
227069
|
+
}
|
|
227070
|
+
function runPolicyCommand(argv, options) {
|
|
227071
|
+
const plan = parsePolicyArgs(argv);
|
|
227072
|
+
if (!("kind" in plan)) return plan;
|
|
227073
|
+
const openControl = options?.openControl ?? (() => new SpendControl());
|
|
227074
|
+
const live = options?.liveControl?.();
|
|
227075
|
+
const control = live ?? openControl();
|
|
227076
|
+
const broken = control.getPolicyFileError();
|
|
227077
|
+
if (broken !== void 0) {
|
|
227078
|
+
return fail(`${broken}
|
|
227079
|
+
Nothing was written; repair or delete spending.json, then retry.`);
|
|
227080
|
+
}
|
|
227081
|
+
if (plan.kind === "show") return { text: formatPolicy(control.getLimits()) };
|
|
227082
|
+
const before = openControl().getLimits();
|
|
227083
|
+
const key2 = plan.kind === "limit" ? plan.window : plan.list;
|
|
227084
|
+
let expected;
|
|
227085
|
+
try {
|
|
227086
|
+
if (plan.kind === "limit") {
|
|
227087
|
+
expected = plan.usd;
|
|
227088
|
+
if (plan.usd === void 0) control.clearLimit(plan.window);
|
|
227089
|
+
else control.setLimit(plan.window, plan.usd);
|
|
227090
|
+
} else {
|
|
227091
|
+
const outcome = nextListValue(control.getLimits()[plan.list], plan);
|
|
227092
|
+
if ("reject" in outcome) return fail(`${outcome.reject}; nothing written`);
|
|
227093
|
+
expected = outcome.next;
|
|
227094
|
+
if (outcome.next === void 0) control.clearPolicy(plan.list);
|
|
227095
|
+
else control.setPolicy(plan.list, outcome.next);
|
|
227096
|
+
}
|
|
227097
|
+
} catch (err) {
|
|
227098
|
+
if (err instanceof SpendPolicyConflictError) {
|
|
227099
|
+
return fail(
|
|
227100
|
+
`${key2} was not written: another writer changed spending.json while this command ran, and replacing it would have dropped their change. Run "policy" to see what disk holds now, then retry`
|
|
227101
|
+
);
|
|
227102
|
+
}
|
|
227103
|
+
return fail(`Nothing was written: ${err instanceof Error ? err.message : String(err)}`);
|
|
227104
|
+
}
|
|
227105
|
+
const expectedAll = { ...before };
|
|
227106
|
+
if (expected === void 0) delete expectedAll[key2];
|
|
227107
|
+
else expectedAll[key2] = expected;
|
|
227108
|
+
const after = openControl().getLimits();
|
|
227109
|
+
const keys = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after), key2])];
|
|
227110
|
+
const drift = keys.filter((k) => JSON.stringify(after[k]) !== JSON.stringify(expectedAll[k]));
|
|
227111
|
+
if (drift.length > 0) {
|
|
227112
|
+
const show = (v) => v === void 0 ? "(unset)" : JSON.stringify(v);
|
|
227113
|
+
const detail = drift.map((k) => `${k} ${show(after[k])} vs ${show(expectedAll[k])}`).join("; ");
|
|
227114
|
+
return fail(
|
|
227115
|
+
`Write did not land cleanly \u2014 on disk vs expected: ${detail}. Another write may have raced this one; run "policy" to see what disk holds now`
|
|
227116
|
+
);
|
|
227117
|
+
}
|
|
227118
|
+
const headline = expected === void 0 ? `${key2} is now unset \u2014 ${unsetMeaning(key2)}.` : `${key2}: ${JSON.stringify(expected)}`;
|
|
227119
|
+
return {
|
|
227120
|
+
text: live ? `${headline}
|
|
227121
|
+
${APPLIED_LIVE}` : `${RESTART_REQUIRED}
|
|
227122
|
+
${headline}`
|
|
227123
|
+
};
|
|
227124
|
+
}
|
|
227125
|
+
function createPolicyCommand(options) {
|
|
227126
|
+
return {
|
|
227127
|
+
name: "policy",
|
|
227128
|
+
description: "Spend limits and counterparty policy \u2014 /policy [set|add|remove|clear <list> ...] [limit <window> <usd>|clear]",
|
|
227129
|
+
acceptsArgs: true,
|
|
227130
|
+
requireAuth: true,
|
|
227131
|
+
handler: async (ctx) => runPolicyCommand((ctx.args ?? "").trim().split(/\s+/).filter(Boolean), options)
|
|
227132
|
+
};
|
|
227133
|
+
}
|
|
227134
|
+
var SPEND_WINDOWS, USD, EVM_ADDRESS2, BASE58_ADDRESS, LIST_ACTIONS, ALLOW_LISTS, USAGE, RESTART_REQUIRED, APPLIED_LIVE;
|
|
227135
|
+
var init_policy = __esm({
|
|
227136
|
+
"src/commands/policy.ts"() {
|
|
227137
|
+
"use strict";
|
|
227138
|
+
init_spend_control();
|
|
227139
|
+
SPEND_WINDOWS = ["perRequest", "hourly", "daily", "session"];
|
|
227140
|
+
USD = /^\d+(\.\d+)?$/;
|
|
227141
|
+
EVM_ADDRESS2 = /^0x[0-9a-fA-F]{40}$/;
|
|
227142
|
+
BASE58_ADDRESS = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
227143
|
+
LIST_ACTIONS = ["set", "add", "remove", "clear"];
|
|
227144
|
+
ALLOW_LISTS = ["allowedPayees", "allowedNetworks", "allowedAssets"];
|
|
227145
|
+
USAGE = [
|
|
227146
|
+
"Usage:",
|
|
227147
|
+
" policy show limits and lists on disk",
|
|
227148
|
+
` policy set|add|remove <list> <v>... <list>: ${POLICY_LISTS.join(" | ")}`,
|
|
227149
|
+
" policy clear <list>",
|
|
227150
|
+
` policy limit <window> <usd>|clear <window>: ${SPEND_WINDOWS.join(" | ")}`,
|
|
227151
|
+
`Networks are CAIP-2 ids: ${CAIP2_BASE} (Base) or ${CAIP2_SOLANA_MAINNET} (Solana mainnet).`
|
|
227152
|
+
].join("\n");
|
|
227153
|
+
RESTART_REQUIRED = "NOT applied to a running proxy \u2014 it reads spending.json once at startup. Restart the proxy (or the OpenClaw gateway) for this to take effect.";
|
|
227154
|
+
APPLIED_LIVE = "Applied to the running proxy and saved to spending.json.";
|
|
227155
|
+
}
|
|
227156
|
+
});
|
|
227157
|
+
|
|
226540
227158
|
// src/mcp-config.ts
|
|
226541
227159
|
function isRecord(value) {
|
|
226542
227160
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -226587,6 +227205,108 @@ var init_mcp_config = __esm({
|
|
|
226587
227205
|
}
|
|
226588
227206
|
});
|
|
226589
227207
|
|
|
227208
|
+
// src/openclaw-plugin-config.ts
|
|
227209
|
+
function asObject2(value) {
|
|
227210
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
227211
|
+
}
|
|
227212
|
+
function prepareBlockRunPluginConfig(config, options = {}) {
|
|
227213
|
+
if (!options.explicitSetup && !options.legacyBlockRunInstall && !options.stripUnsupportedInstalls) {
|
|
227214
|
+
return false;
|
|
227215
|
+
}
|
|
227216
|
+
let changed = false;
|
|
227217
|
+
let plugins = asObject2(config.plugins);
|
|
227218
|
+
if (!plugins) {
|
|
227219
|
+
plugins = {};
|
|
227220
|
+
config.plugins = plugins;
|
|
227221
|
+
changed = true;
|
|
227222
|
+
}
|
|
227223
|
+
let entries = asObject2(plugins.entries);
|
|
227224
|
+
if (!entries) {
|
|
227225
|
+
entries = {};
|
|
227226
|
+
plugins.entries = entries;
|
|
227227
|
+
changed = true;
|
|
227228
|
+
}
|
|
227229
|
+
const legacyEntry = asObject2(entries.clawrouter);
|
|
227230
|
+
const currentEntry = asObject2(entries[BLOCKRUN_PLUGIN_ID]);
|
|
227231
|
+
if (options.legacyBlockRunInstall && legacyEntry) {
|
|
227232
|
+
const migratedEntry = currentEntry ?? {};
|
|
227233
|
+
if (!currentEntry && typeof legacyEntry.enabled === "boolean") {
|
|
227234
|
+
migratedEntry.enabled = legacyEntry.enabled;
|
|
227235
|
+
}
|
|
227236
|
+
for (const key2 of ["walletKey", "routing"]) {
|
|
227237
|
+
if (!(key2 in migratedEntry) && key2 in legacyEntry) {
|
|
227238
|
+
migratedEntry[key2] = legacyEntry[key2];
|
|
227239
|
+
}
|
|
227240
|
+
if (key2 in legacyEntry) {
|
|
227241
|
+
delete legacyEntry[key2];
|
|
227242
|
+
changed = true;
|
|
227243
|
+
}
|
|
227244
|
+
}
|
|
227245
|
+
const legacyConfig = asObject2(legacyEntry.config);
|
|
227246
|
+
if (legacyConfig) {
|
|
227247
|
+
const currentConfig = asObject2(migratedEntry.config) ?? {};
|
|
227248
|
+
for (const key2 of ["walletKey", "routing"]) {
|
|
227249
|
+
if (!(key2 in currentConfig) && key2 in legacyConfig) {
|
|
227250
|
+
currentConfig[key2] = legacyConfig[key2];
|
|
227251
|
+
}
|
|
227252
|
+
if (key2 in legacyConfig) {
|
|
227253
|
+
delete legacyConfig[key2];
|
|
227254
|
+
changed = true;
|
|
227255
|
+
}
|
|
227256
|
+
}
|
|
227257
|
+
if (Object.keys(currentConfig).length > 0) migratedEntry.config = currentConfig;
|
|
227258
|
+
if (Object.keys(legacyConfig).length === 0) {
|
|
227259
|
+
delete legacyEntry.config;
|
|
227260
|
+
changed = true;
|
|
227261
|
+
}
|
|
227262
|
+
}
|
|
227263
|
+
if (!currentEntry || entries[BLOCKRUN_PLUGIN_ID] !== migratedEntry) {
|
|
227264
|
+
entries[BLOCKRUN_PLUGIN_ID] = migratedEntry;
|
|
227265
|
+
changed = true;
|
|
227266
|
+
}
|
|
227267
|
+
}
|
|
227268
|
+
if (options.explicitSetup) {
|
|
227269
|
+
const next = asObject2(entries[BLOCKRUN_PLUGIN_ID]) ?? {};
|
|
227270
|
+
if (next.enabled !== true) {
|
|
227271
|
+
entries[BLOCKRUN_PLUGIN_ID] = { ...next, enabled: true };
|
|
227272
|
+
changed = true;
|
|
227273
|
+
}
|
|
227274
|
+
}
|
|
227275
|
+
const allow = plugins.allow;
|
|
227276
|
+
if (Array.isArray(allow)) {
|
|
227277
|
+
const shouldAllow = options.explicitSetup || options.legacyBlockRunInstall && allow.includes("clawrouter");
|
|
227278
|
+
if (shouldAllow && !allow.includes(BLOCKRUN_PLUGIN_ID)) {
|
|
227279
|
+
allow.push(BLOCKRUN_PLUGIN_ID);
|
|
227280
|
+
changed = true;
|
|
227281
|
+
}
|
|
227282
|
+
}
|
|
227283
|
+
const deny = plugins.deny;
|
|
227284
|
+
if (Array.isArray(deny)) {
|
|
227285
|
+
if (options.explicitSetup) {
|
|
227286
|
+
const next = deny.filter((id2) => id2 !== BLOCKRUN_PLUGIN_ID);
|
|
227287
|
+
if (next.length !== deny.length) {
|
|
227288
|
+
plugins.deny = next;
|
|
227289
|
+
changed = true;
|
|
227290
|
+
}
|
|
227291
|
+
} else if (options.legacyBlockRunInstall && deny.includes("clawrouter") && !deny.includes(BLOCKRUN_PLUGIN_ID)) {
|
|
227292
|
+
deny.push(BLOCKRUN_PLUGIN_ID);
|
|
227293
|
+
changed = true;
|
|
227294
|
+
}
|
|
227295
|
+
}
|
|
227296
|
+
if (options.stripUnsupportedInstalls && "installs" in plugins) {
|
|
227297
|
+
delete plugins.installs;
|
|
227298
|
+
changed = true;
|
|
227299
|
+
}
|
|
227300
|
+
return changed;
|
|
227301
|
+
}
|
|
227302
|
+
var BLOCKRUN_PLUGIN_ID;
|
|
227303
|
+
var init_openclaw_plugin_config = __esm({
|
|
227304
|
+
"src/openclaw-plugin-config.ts"() {
|
|
227305
|
+
"use strict";
|
|
227306
|
+
BLOCKRUN_PLUGIN_ID = "blockrun-clawrouter";
|
|
227307
|
+
}
|
|
227308
|
+
});
|
|
227309
|
+
|
|
226590
227310
|
// src/retry.ts
|
|
226591
227311
|
function sleep3(ms) {
|
|
226592
227312
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -226656,13 +227376,14 @@ import {
|
|
|
226656
227376
|
readdirSync,
|
|
226657
227377
|
mkdirSync as mkdirSync3,
|
|
226658
227378
|
copyFileSync,
|
|
227379
|
+
chmodSync,
|
|
226659
227380
|
renameSync as renameSync2,
|
|
226660
227381
|
unlinkSync
|
|
226661
227382
|
} from "fs";
|
|
226662
227383
|
import { readFile as readFileAsync } from "fs/promises";
|
|
226663
227384
|
import { homedir as homedir13 } from "os";
|
|
226664
|
-
import {
|
|
226665
|
-
import {
|
|
227385
|
+
import { randomUUID } from "crypto";
|
|
227386
|
+
import { join as join16 } from "path";
|
|
226666
227387
|
async function waitForProxyHealth(port, timeoutMs = 3e3) {
|
|
226667
227388
|
const start = Date.now();
|
|
226668
227389
|
while (Date.now() - start < timeoutMs) {
|
|
@@ -226675,53 +227396,21 @@ async function waitForProxyHealth(port, timeoutMs = 3e3) {
|
|
|
226675
227396
|
}
|
|
226676
227397
|
return false;
|
|
226677
227398
|
}
|
|
226678
|
-
function
|
|
226679
|
-
|
|
226680
|
-
}
|
|
226681
|
-
function installSkillsToWorkspace(logger48) {
|
|
227399
|
+
function writePrivateJsonSync(path5, value) {
|
|
227400
|
+
const temporary = `${path5}.tmp.${randomUUID()}`;
|
|
226682
227401
|
try {
|
|
226683
|
-
|
|
226684
|
-
|
|
226685
|
-
|
|
226686
|
-
|
|
226687
|
-
|
|
226688
|
-
const profile = (process["env"].OPENCLAW_PROFILE ?? "").trim().toLowerCase();
|
|
226689
|
-
const workspaceDirName = profile && profile !== "default" ? `workspace-${profile}` : "workspace";
|
|
226690
|
-
const workspaceSkillsDir = join16(homedir13(), ".openclaw", workspaceDirName, "skills");
|
|
226691
|
-
mkdirSync3(workspaceSkillsDir, { recursive: true });
|
|
226692
|
-
const INTERNAL_SKILLS = /* @__PURE__ */ new Set(["release"]);
|
|
226693
|
-
const entries = readdirSync(bundledSkillsDir, { withFileTypes: true });
|
|
226694
|
-
let installed = 0;
|
|
226695
|
-
for (const entry of entries) {
|
|
226696
|
-
if (!entry.isDirectory()) continue;
|
|
226697
|
-
const skillName = entry.name;
|
|
226698
|
-
if (INTERNAL_SKILLS.has(skillName)) continue;
|
|
226699
|
-
const srcSkillFile = join16(bundledSkillsDir, skillName, "SKILL.md");
|
|
226700
|
-
if (!existsSync3(srcSkillFile)) continue;
|
|
226701
|
-
const destDir = join16(workspaceSkillsDir, skillName);
|
|
226702
|
-
const destSkillFile = join16(destDir, "SKILL.md");
|
|
226703
|
-
let needsUpdate = true;
|
|
226704
|
-
if (existsSync3(destSkillFile)) {
|
|
226705
|
-
try {
|
|
226706
|
-
const srcContent = readTextFileSync(srcSkillFile);
|
|
226707
|
-
const destContent = readTextFileSync(destSkillFile);
|
|
226708
|
-
if (srcContent === destContent) needsUpdate = false;
|
|
226709
|
-
} catch {
|
|
226710
|
-
}
|
|
226711
|
-
}
|
|
226712
|
-
if (needsUpdate) {
|
|
226713
|
-
mkdirSync3(destDir, { recursive: true });
|
|
226714
|
-
copyFileSync(srcSkillFile, destSkillFile);
|
|
226715
|
-
installed++;
|
|
226716
|
-
}
|
|
226717
|
-
}
|
|
226718
|
-
if (installed > 0) {
|
|
226719
|
-
logger48.info(`Installed ${installed} skill(s) to ${workspaceSkillsDir}`);
|
|
226720
|
-
}
|
|
226721
|
-
} catch (err) {
|
|
226722
|
-
logger48.warn(`Failed to install skills: ${err instanceof Error ? err.message : String(err)}`);
|
|
227402
|
+
writeFileSync3(temporary, JSON.stringify(value, null, 2), { mode: 384 });
|
|
227403
|
+
renameSync2(temporary, path5);
|
|
227404
|
+
chmodSync(path5, 384);
|
|
227405
|
+
} finally {
|
|
227406
|
+
if (existsSync3(temporary)) unlinkSync(temporary);
|
|
226723
227407
|
}
|
|
226724
227408
|
}
|
|
227409
|
+
function hasConfiguredWallet() {
|
|
227410
|
+
return Boolean(
|
|
227411
|
+
process["env"].BLOCKRUN_WALLET_KEY || existsSync3(CORE_WALLET_FILE) || existsSync3(WALLET_FILE)
|
|
227412
|
+
);
|
|
227413
|
+
}
|
|
226725
227414
|
function isCompletionMode() {
|
|
226726
227415
|
const args = process.argv;
|
|
226727
227416
|
return args.some((arg, i) => arg === "completion" && i >= 1 && i <= 3);
|
|
@@ -226895,35 +227584,19 @@ function injectModelsConfig(logger48, options = {}) {
|
|
|
226895
227584
|
logger48.info(`Added ${addedCount} models to allowlist (${TOP_MODELS.length} total)`);
|
|
226896
227585
|
}
|
|
226897
227586
|
}
|
|
226898
|
-
const
|
|
226899
|
-
|
|
226900
|
-
|
|
226901
|
-
|
|
227587
|
+
const legacyEntry = config.plugins?.entries?.clawrouter;
|
|
227588
|
+
const legacyEntryConfig = legacyEntry?.config;
|
|
227589
|
+
const legacyBlockRunInstall = Boolean(
|
|
227590
|
+
legacyEntry && ["walletKey", "routing"].some(
|
|
227591
|
+
(key2) => key2 in legacyEntry || (legacyEntryConfig ? key2 in legacyEntryConfig : false)
|
|
227592
|
+
)
|
|
227593
|
+
);
|
|
227594
|
+
if (legacyBlockRunInstall && prepareBlockRunPluginConfig(config, { legacyBlockRunInstall })) {
|
|
226902
227595
|
needsWrite = true;
|
|
226903
227596
|
logger48.info(
|
|
226904
|
-
|
|
227597
|
+
`Migrated legacy BlockRun plugin config to ${BLOCKRUN_PLUGIN_ID} (renamed from clawrouter; see #305)`
|
|
226905
227598
|
);
|
|
226906
227599
|
}
|
|
226907
|
-
const pluginsCfg = config.plugins;
|
|
226908
|
-
const allow = pluginsCfg?.allow;
|
|
226909
|
-
if (Array.isArray(allow) && allow.includes("clawrouter") && !allow.includes(BLOCKRUN_PLUGIN_ID)) {
|
|
226910
|
-
allow.push(BLOCKRUN_PLUGIN_ID);
|
|
226911
|
-
needsWrite = true;
|
|
226912
|
-
logger48.info(`Added ${BLOCKRUN_PLUGIN_ID} to plugins.allow (renamed from clawrouter; see #305)`);
|
|
226913
|
-
}
|
|
226914
|
-
const deny = pluginsCfg?.deny;
|
|
226915
|
-
if (Array.isArray(deny) && deny.includes("clawrouter") && !deny.includes(BLOCKRUN_PLUGIN_ID)) {
|
|
226916
|
-
deny.push(BLOCKRUN_PLUGIN_ID);
|
|
226917
|
-
needsWrite = true;
|
|
226918
|
-
logger48.info(`Added ${BLOCKRUN_PLUGIN_ID} to plugins.deny (renamed from clawrouter; see #305)`);
|
|
226919
|
-
}
|
|
226920
|
-
const installs = pluginsCfg?.installs;
|
|
226921
|
-
if (installs && installs.clawrouter && !installs[BLOCKRUN_PLUGIN_ID]) {
|
|
226922
|
-
installs[BLOCKRUN_PLUGIN_ID] = installs.clawrouter;
|
|
226923
|
-
delete installs.clawrouter;
|
|
226924
|
-
needsWrite = true;
|
|
226925
|
-
logger48.info(`Migrated plugins.installs.clawrouter -> ${BLOCKRUN_PLUGIN_ID} (see #305)`);
|
|
226926
|
-
}
|
|
226927
227600
|
if (!config.tools || typeof config.tools !== "object" || Array.isArray(config.tools)) {
|
|
226928
227601
|
config.tools = {};
|
|
226929
227602
|
needsWrite = true;
|
|
@@ -226963,8 +227636,9 @@ function injectModelsConfig(logger48, options = {}) {
|
|
|
226963
227636
|
}
|
|
226964
227637
|
try {
|
|
226965
227638
|
const tmpPath = `${configPath}.tmp.${process.pid}`;
|
|
226966
|
-
writeFileSync3(tmpPath, JSON.stringify(config, null, 2));
|
|
227639
|
+
writeFileSync3(tmpPath, JSON.stringify(config, null, 2), { mode: 384 });
|
|
226967
227640
|
renameSync2(tmpPath, configPath);
|
|
227641
|
+
chmodSync(configPath, 384);
|
|
226968
227642
|
logger48.info("Smart routing enabled (blockrun/auto)");
|
|
226969
227643
|
} catch (err) {
|
|
226970
227644
|
logger48.info(`Failed to write config: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -226999,7 +227673,7 @@ function syncAgentModelCache(logger48, options = {}) {
|
|
|
226999
227673
|
const staleCount = Array.isArray(current) ? current.length : 0;
|
|
227000
227674
|
entry.models = VISIBLE_OPENCLAW_MODELS;
|
|
227001
227675
|
const tmpPath = `${cachePath}.tmp.${process.pid}`;
|
|
227002
|
-
writeFileSync3(tmpPath, JSON.stringify(cache2, null, 2));
|
|
227676
|
+
writeFileSync3(tmpPath, JSON.stringify(cache2, null, 2), { mode: 384 });
|
|
227003
227677
|
renameSync2(tmpPath, cachePath);
|
|
227004
227678
|
logger48.info(
|
|
227005
227679
|
`Repaired ${agent} model cache: ${staleCount} \u2192 ${expectedIds.length} BlockRun models`
|
|
@@ -227070,7 +227744,7 @@ function injectAuthProfile(logger48) {
|
|
|
227070
227744
|
key: "x402-proxy-handles-auth"
|
|
227071
227745
|
};
|
|
227072
227746
|
try {
|
|
227073
|
-
|
|
227747
|
+
writePrivateJsonSync(authPath, store);
|
|
227074
227748
|
logger48.info(`Injected BlockRun auth profile for agent: ${agentId}`);
|
|
227075
227749
|
} catch (err) {
|
|
227076
227750
|
logger48.info(
|
|
@@ -227186,7 +227860,7 @@ async function startProxyInBackground(api, startupGeneration) {
|
|
|
227186
227860
|
} else {
|
|
227187
227861
|
if (configKey !== void 0) {
|
|
227188
227862
|
api.logger.warn(
|
|
227189
|
-
`pluginConfig.walletKey is set but invalid (expected 0x + 64 hex chars) \u2014 falling back to
|
|
227863
|
+
`pluginConfig.walletKey is set but invalid (expected 0x + 64 hex chars) \u2014 falling back to the BlockRun wallet`
|
|
227190
227864
|
);
|
|
227191
227865
|
}
|
|
227192
227866
|
wallet = await resolveOrGenerateWalletKey();
|
|
@@ -227198,6 +227872,8 @@ async function startProxyInBackground(api, startupGeneration) {
|
|
|
227198
227872
|
api.logger.warn(` Run /wallet export to get your private key`);
|
|
227199
227873
|
api.logger.warn(` Losing this key = losing your USDC funds`);
|
|
227200
227874
|
api.logger.warn(`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);
|
|
227875
|
+
} else if (wallet.source === "core") {
|
|
227876
|
+
api.logger.info(`Using BlockRun Core wallet: ${wallet.address}`);
|
|
227201
227877
|
} else if (wallet.source === "saved") {
|
|
227202
227878
|
api.logger.info(`Using saved wallet: ${wallet.address}`);
|
|
227203
227879
|
} else if (wallet.source === "config") {
|
|
@@ -227218,6 +227894,7 @@ async function startProxyInBackground(api, startupGeneration) {
|
|
|
227218
227894
|
routingConfig,
|
|
227219
227895
|
maxCostPerRunUsd,
|
|
227220
227896
|
maxCostPerRunMode,
|
|
227897
|
+
spendControl: liveSpendControl = new SpendControl(),
|
|
227221
227898
|
onReady: (port) => {
|
|
227222
227899
|
api.logger.info(`BlockRun x402 proxy listening on port ${port}`);
|
|
227223
227900
|
},
|
|
@@ -227484,7 +228161,7 @@ function buildImageGenerationProvider() {
|
|
|
227484
228161
|
]
|
|
227485
228162
|
}
|
|
227486
228163
|
},
|
|
227487
|
-
isConfigured:
|
|
228164
|
+
isConfigured: hasConfiguredWallet,
|
|
227488
228165
|
generateImage: async (req) => {
|
|
227489
228166
|
const port = getProxyPort();
|
|
227490
228167
|
const body = JSON.stringify({
|
|
@@ -227534,7 +228211,7 @@ function buildMusicGenerationProvider() {
|
|
|
227534
228211
|
supportsFormat: true,
|
|
227535
228212
|
supportedFormats: ["mp3"]
|
|
227536
228213
|
},
|
|
227537
|
-
isConfigured:
|
|
228214
|
+
isConfigured: hasConfiguredWallet,
|
|
227538
228215
|
generateMusic: async (req) => {
|
|
227539
228216
|
const port = getProxyPort();
|
|
227540
228217
|
const body = JSON.stringify({
|
|
@@ -227610,7 +228287,7 @@ function buildVideoGenerationProvider() {
|
|
|
227610
228287
|
supportedDurationSeconds: [5, 8, 10]
|
|
227611
228288
|
}
|
|
227612
228289
|
},
|
|
227613
|
-
isConfigured:
|
|
228290
|
+
isConfigured: hasConfiguredWallet,
|
|
227614
228291
|
generateVideo: async (req) => {
|
|
227615
228292
|
const port = getProxyPort();
|
|
227616
228293
|
const imageUrl = req.inputImages?.[0]?.url;
|
|
@@ -227689,26 +228366,25 @@ function createWalletCommand(api) {
|
|
|
227689
228366
|
requireAuth: true,
|
|
227690
228367
|
handler: async (ctx) => {
|
|
227691
228368
|
const subcommand = ctx.args?.trim().toLowerCase() || "status";
|
|
227692
|
-
let
|
|
227693
|
-
let address2;
|
|
228369
|
+
let wallet;
|
|
227694
228370
|
try {
|
|
227695
|
-
|
|
227696
|
-
|
|
227697
|
-
|
|
227698
|
-
|
|
227699
|
-
|
|
227700
|
-
|
|
227701
|
-
}
|
|
227702
|
-
} catch {
|
|
228371
|
+
wallet = subcommand === "status" || subcommand === "export" ? await resolveExistingWalletKey() : await resolveOrGenerateWalletKey();
|
|
228372
|
+
} catch (error) {
|
|
228373
|
+
return {
|
|
228374
|
+
text: `Could not load the BlockRun wallet: ${error instanceof Error ? error.message : String(error)}`,
|
|
228375
|
+
isError: true
|
|
228376
|
+
};
|
|
227703
228377
|
}
|
|
227704
|
-
if (!
|
|
228378
|
+
if (!wallet) {
|
|
227705
228379
|
return {
|
|
227706
|
-
text:
|
|
227707
|
-
|
|
227708
|
-
Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
228380
|
+
text: "No BlockRun wallet found. Run `clawrouter setup` or connect an agent in ClawRouter Desktop to create one.",
|
|
227709
228381
|
isError: true
|
|
227710
228382
|
};
|
|
227711
228383
|
}
|
|
228384
|
+
const walletKey = wallet.key;
|
|
228385
|
+
const address2 = wallet.address;
|
|
228386
|
+
const resolvedSolanaKey = wallet.solanaPrivateKeyBytes;
|
|
228387
|
+
const walletPath = wallet.source === "core" ? CORE_WALLET_FILE : WALLET_FILE;
|
|
227712
228388
|
if (subcommand === "export") {
|
|
227713
228389
|
const lines = [
|
|
227714
228390
|
"**ClawRouter Wallet Export**",
|
|
@@ -227745,13 +228421,26 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
227745
228421
|
}
|
|
227746
228422
|
} catch {
|
|
227747
228423
|
}
|
|
228424
|
+
if (!hasMnemonic3 && resolvedSolanaKey) {
|
|
228425
|
+
try {
|
|
228426
|
+
const { createKeyPairSignerFromPrivateKeyBytes: createKeyPairSignerFromPrivateKeyBytes2 } = await Promise.resolve().then(() => (init_index_node37(), index_node_exports));
|
|
228427
|
+
const signer = await createKeyPairSignerFromPrivateKeyBytes2(resolvedSolanaKey);
|
|
228428
|
+
lines.push(
|
|
228429
|
+
"",
|
|
228430
|
+
"**Solana:**",
|
|
228431
|
+
` Address: \`${signer.address}\``,
|
|
228432
|
+
wallet.source === "core" ? ` Private key managed by BlockRun Core: \`${CORE_SOLANA_WALLET_FILE}\`` : " Private key is managed by the configured wallet source."
|
|
228433
|
+
);
|
|
228434
|
+
} catch {
|
|
228435
|
+
}
|
|
228436
|
+
}
|
|
227748
228437
|
lines.push(
|
|
227749
228438
|
"",
|
|
227750
228439
|
"**To restore on a new machine:**",
|
|
227751
228440
|
"1. Set the environment variable before running OpenClaw:",
|
|
227752
228441
|
` \`export BLOCKRUN_WALLET_KEY=${walletKey}\``,
|
|
227753
228442
|
"2. Or save to file:",
|
|
227754
|
-
` \`mkdir -p ~/.
|
|
228443
|
+
` \`mkdir -p ~/.blockrun && echo "${walletKey}" > ~/.blockrun/.session && chmod 600 ~/.blockrun/.session\``
|
|
227755
228444
|
);
|
|
227756
228445
|
if (hasMnemonic3) {
|
|
227757
228446
|
lines.push(
|
|
@@ -227764,6 +228453,22 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
227764
228453
|
if (subcommand === "solana") {
|
|
227765
228454
|
try {
|
|
227766
228455
|
let solanaAddr;
|
|
228456
|
+
if (resolvedSolanaKey) {
|
|
228457
|
+
await savePaymentChain("solana");
|
|
228458
|
+
const { createKeyPairSignerFromPrivateKeyBytes: createKeyPairSignerFromPrivateKeyBytes3 } = await Promise.resolve().then(() => (init_index_node37(), index_node_exports));
|
|
228459
|
+
const signer2 = await createKeyPairSignerFromPrivateKeyBytes3(resolvedSolanaKey);
|
|
228460
|
+
solanaAddr = signer2.address;
|
|
228461
|
+
if (api) restartProxyForChainSwitch(api);
|
|
228462
|
+
return {
|
|
228463
|
+
text: [
|
|
228464
|
+
"\u2713 Payment chain switched to **Solana**.",
|
|
228465
|
+
api ? "Proxy restarting in background (~2s)." : "Restart the gateway to apply.",
|
|
228466
|
+
"",
|
|
228467
|
+
`**Solana Address:** \`${solanaAddr}\``,
|
|
228468
|
+
`**Fund with USDC on Solana:** https://solscan.io/account/${solanaAddr}`
|
|
228469
|
+
].join("\n")
|
|
228470
|
+
};
|
|
228471
|
+
}
|
|
227767
228472
|
if (existsSync3(MNEMONIC_FILE)) {
|
|
227768
228473
|
const existingMnemonic = readTextFileSync(MNEMONIC_FILE).trim();
|
|
227769
228474
|
if (existingMnemonic) {
|
|
@@ -227835,13 +228540,9 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
227835
228540
|
})();
|
|
227836
228541
|
const solanaPromise = (async () => {
|
|
227837
228542
|
try {
|
|
227838
|
-
if (!
|
|
227839
|
-
const { deriveSolanaKeyBytes: deriveSolanaKeyBytes2 } = await Promise.resolve().then(() => (init_wallet2(), wallet_exports));
|
|
227840
|
-
const mnemonic = readTextFileSync(MNEMONIC_FILE).trim();
|
|
227841
|
-
if (!mnemonic) return "";
|
|
227842
|
-
const solKeyBytes = deriveSolanaKeyBytes2(mnemonic);
|
|
228543
|
+
if (!resolvedSolanaKey) return "";
|
|
227843
228544
|
const { createKeyPairSignerFromPrivateKeyBytes: createKeyPairSignerFromPrivateKeyBytes2 } = await Promise.resolve().then(() => (init_index_node37(), index_node_exports));
|
|
227844
|
-
const signer = await createKeyPairSignerFromPrivateKeyBytes2(
|
|
228545
|
+
const signer = await createKeyPairSignerFromPrivateKeyBytes2(resolvedSolanaKey);
|
|
227845
228546
|
const solAddr = signer.address;
|
|
227846
228547
|
let solBalanceText = "Balance: (could not check)";
|
|
227847
228548
|
try {
|
|
@@ -227902,7 +228603,7 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
227902
228603
|
solanaSection,
|
|
227903
228604
|
usageSection,
|
|
227904
228605
|
"",
|
|
227905
|
-
`**Key File:** \`${
|
|
228606
|
+
`**Key File:** \`${walletPath}\``,
|
|
227906
228607
|
"",
|
|
227907
228608
|
"**Commands:**",
|
|
227908
228609
|
"\u2022 `/wallet` - Show this status",
|
|
@@ -227916,7 +228617,7 @@ Run \`openclaw plugins install @blockrun/clawrouter\` to generate a wallet.`,
|
|
|
227916
228617
|
}
|
|
227917
228618
|
};
|
|
227918
228619
|
}
|
|
227919
|
-
var activeProxyHandle, pendingConfiguredStartupApi, IMAGE_DIR2, AUDIO_DIR2, VIDEO_DIR2,
|
|
228620
|
+
var activeProxyHandle, liveSpendControl, pendingConfiguredStartupApi, IMAGE_DIR2, AUDIO_DIR2, VIDEO_DIR2, plugin, index_default2;
|
|
227920
228621
|
var init_index = __esm({
|
|
227921
228622
|
"src/index.ts"() {
|
|
227922
228623
|
init_provider();
|
|
@@ -227935,7 +228636,11 @@ var init_index = __esm({
|
|
|
227935
228636
|
init_tool();
|
|
227936
228637
|
init_stats2();
|
|
227937
228638
|
init_exclude();
|
|
228639
|
+
init_policy();
|
|
228640
|
+
init_spend_control();
|
|
227938
228641
|
init_mcp_config();
|
|
228642
|
+
init_openclaw_plugin_config();
|
|
228643
|
+
init_openclaw_plugin_config();
|
|
227939
228644
|
init_proxy();
|
|
227940
228645
|
init_provider();
|
|
227941
228646
|
init_models();
|
|
@@ -227954,11 +228659,11 @@ var init_index = __esm({
|
|
|
227954
228659
|
init_response_cache();
|
|
227955
228660
|
init_partners();
|
|
227956
228661
|
activeProxyHandle = null;
|
|
228662
|
+
liveSpendControl = null;
|
|
227957
228663
|
pendingConfiguredStartupApi = null;
|
|
227958
228664
|
IMAGE_DIR2 = join16(homedir13(), ".openclaw", "blockrun", "images");
|
|
227959
228665
|
AUDIO_DIR2 = join16(homedir13(), ".openclaw", "blockrun", "audio");
|
|
227960
228666
|
VIDEO_DIR2 = join16(homedir13(), ".openclaw", "blockrun", "videos");
|
|
227961
|
-
BLOCKRUN_PLUGIN_ID = "blockrun-clawrouter";
|
|
227962
228667
|
plugin = {
|
|
227963
228668
|
// NOT "clawrouter". OpenClaw bundles its own plugin under that id since the
|
|
227964
228669
|
// 2026.7.1 line (vendored at dist/extensions/clawrouter, provider `clawrouter/*`,
|
|
@@ -227976,7 +228681,6 @@ var init_index = __esm({
|
|
|
227976
228681
|
api.logger.info("ClawRouter disabled (CLAWROUTER_DISABLED=true). Using default routing.");
|
|
227977
228682
|
return;
|
|
227978
228683
|
}
|
|
227979
|
-
installSkillsToWorkspace(api.logger);
|
|
227980
228684
|
const proc = process;
|
|
227981
228685
|
const proxyAlreadyStarted = !!proc.__clawrouterProxyStarted;
|
|
227982
228686
|
if (isCompletionMode()) {
|
|
@@ -228269,9 +228973,14 @@ ${errText}`
|
|
|
228269
228973
|
}
|
|
228270
228974
|
api.registerCommand(createStatsCommand());
|
|
228271
228975
|
api.registerCommand(createExcludeCommand());
|
|
228976
|
+
api.registerCommand(
|
|
228977
|
+
createPolicyCommand({
|
|
228978
|
+
liveControl: () => activeProxyHandle ? liveSpendControl ?? void 0 : void 0
|
|
228979
|
+
})
|
|
228980
|
+
);
|
|
228272
228981
|
if (shouldLogRegistration) {
|
|
228273
228982
|
api.logger.info(
|
|
228274
|
-
"Commands registered: /wallet, /blockrun, /stats, /exclude, /partners, /cr-imagegen, /videogen, /cr-call"
|
|
228983
|
+
"Commands registered: /wallet, /blockrun, /stats, /exclude, /policy, /partners, /cr-imagegen, /videogen, /cr-call"
|
|
228275
228984
|
);
|
|
228276
228985
|
}
|
|
228277
228986
|
api.registerService({
|
|
@@ -228303,6 +229012,8 @@ ${errText}`
|
|
|
228303
229012
|
api.logger.warn(` Run /wallet export to get your private key`);
|
|
228304
229013
|
api.logger.warn(` Losing this key = losing your USDC funds`);
|
|
228305
229014
|
api.logger.warn(`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`);
|
|
229015
|
+
} else if (source === "core") {
|
|
229016
|
+
api.logger.info(`Using BlockRun Core wallet: ${address2}`);
|
|
228306
229017
|
} else if (source === "saved") {
|
|
228307
229018
|
api.logger.info(`Using saved wallet: ${address2}`);
|
|
228308
229019
|
} else if (source === "config") {
|
|
@@ -228376,18 +229087,18 @@ ${errText}`
|
|
|
228376
229087
|
delete config.models.providers.blockrun;
|
|
228377
229088
|
}
|
|
228378
229089
|
removeManagedBlockrunMcpServerConfig(config);
|
|
228379
|
-
for (const key2 of [
|
|
228380
|
-
BLOCKRUN_PLUGIN_ID,
|
|
228381
|
-
"clawrouter",
|
|
228382
|
-
"ClawRouter",
|
|
228383
|
-
"@blockrun/clawrouter"
|
|
228384
|
-
]) {
|
|
229090
|
+
for (const key2 of [BLOCKRUN_PLUGIN_ID, "ClawRouter", "@blockrun/clawrouter"]) {
|
|
228385
229091
|
if (config.plugins?.entries?.[key2]) delete config.plugins.entries[key2];
|
|
228386
229092
|
if (config.plugins?.installs?.[key2]) delete config.plugins.installs[key2];
|
|
228387
229093
|
}
|
|
228388
229094
|
if (Array.isArray(config.plugins?.allow)) {
|
|
228389
229095
|
config.plugins.allow = config.plugins.allow.filter(
|
|
228390
|
-
(p) => p !== BLOCKRUN_PLUGIN_ID && p !== "
|
|
229096
|
+
(p) => p !== BLOCKRUN_PLUGIN_ID && p !== "ClawRouter" && p !== "@blockrun/clawrouter"
|
|
229097
|
+
);
|
|
229098
|
+
}
|
|
229099
|
+
if (Array.isArray(config.plugins?.deny)) {
|
|
229100
|
+
config.plugins.deny = config.plugins.deny.filter(
|
|
229101
|
+
(p) => p !== BLOCKRUN_PLUGIN_ID && p !== "ClawRouter" && p !== "@blockrun/clawrouter"
|
|
228391
229102
|
);
|
|
228392
229103
|
}
|
|
228393
229104
|
if (config.agents?.defaults?.models) {
|
|
@@ -228402,8 +229113,9 @@ ${errText}`
|
|
|
228402
229113
|
delete config.tools.web.search.provider;
|
|
228403
229114
|
}
|
|
228404
229115
|
const tmpPath = `${configPath}.tmp.${process.pid}`;
|
|
228405
|
-
writeFileSync3(tmpPath, JSON.stringify(config, null, 2));
|
|
229116
|
+
writeFileSync3(tmpPath, JSON.stringify(config, null, 2), { mode: 384 });
|
|
228406
229117
|
renameSync2(tmpPath, configPath);
|
|
229118
|
+
chmodSync(configPath, 384);
|
|
228407
229119
|
api.logger.info("ClawRouter config cleaned up");
|
|
228408
229120
|
}
|
|
228409
229121
|
} catch (err) {
|
|
@@ -228420,7 +229132,7 @@ ${errText}`
|
|
|
228420
229132
|
const store = JSON.parse(readTextFileSync(authPath));
|
|
228421
229133
|
if (store.profiles?.["blockrun:default"]) {
|
|
228422
229134
|
delete store.profiles["blockrun:default"];
|
|
228423
|
-
|
|
229135
|
+
writePrivateJsonSync(authPath, store);
|
|
228424
229136
|
}
|
|
228425
229137
|
} catch {
|
|
228426
229138
|
}
|
|
@@ -228453,6 +229165,7 @@ export {
|
|
|
228453
229165
|
MalformedSpendPolicyError,
|
|
228454
229166
|
OPENCLAW_MODELS,
|
|
228455
229167
|
PARTNER_SERVICES,
|
|
229168
|
+
PAYABLE_NETWORKS,
|
|
228456
229169
|
RequestDeduplicator,
|
|
228457
229170
|
ResponseCache,
|
|
228458
229171
|
RpcError2 as RpcError,
|