run402 4.93.1 → 4.94.0
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 +43 -41
- package/cli.mjs +34 -29
- package/core-dist/config.js +52 -18
- package/core-dist/control-plane-session.js +31 -6
- package/core-dist/keystore.js +7 -7
- package/core-dist/profiles.js +9 -7
- package/core-dist/{allowance-auth.js → wallet-auth.js} +15 -15
- package/{sdk/core-dist/allowance.js → core-dist/wallet.js} +20 -20
- package/{sdk/core-dist/write-auth-session.js → core-dist/write-approvals.js} +19 -19
- package/gitvault-surface.json +1 -1
- package/lib/admin.mjs +1 -1
- package/lib/agent.mjs +20 -18
- package/lib/approve.mjs +81 -0
- package/lib/apps.mjs +3 -3
- package/lib/assets.mjs +2 -2
- package/lib/billing.mjs +6 -6
- package/lib/buzz-doctor.mjs +1 -1
- package/lib/buzz-notifications.mjs +1 -1
- package/lib/buzz.mjs +1 -1
- package/lib/buzz.test.mjs +1 -1
- package/lib/ci.mjs +4 -4
- package/lib/cold-start.mjs +21 -21
- package/lib/command-manifest.mjs +20 -34
- package/lib/config.mjs +24 -24
- package/lib/contacts.mjs +13 -13
- package/lib/contracts.mjs +1 -1
- package/lib/credentials.mjs +2 -2
- package/lib/daemon-path.mjs +1 -1
- package/lib/delegates.mjs +1 -1
- package/lib/deliveries.mjs +4 -4
- package/lib/deploy-rehearse-discovery.test.mjs +7 -7
- package/lib/deploy-v2.mjs +232 -184
- package/lib/deploy.mjs +21 -53
- package/lib/doctor-source-scan.mjs +1 -1
- package/lib/doctor.mjs +57 -57
- package/lib/escalations.mjs +1 -1
- package/lib/feedback.mjs +10 -10
- package/lib/gitvault-daemon.mjs +1 -1
- package/lib/image.mjs +3 -3
- package/lib/init.mjs +66 -66
- package/lib/lightning-wallet.mjs +28 -28
- package/lib/login.mjs +207 -0
- package/lib/logout.mjs +53 -0
- package/lib/next-actions.mjs +15 -15
- package/lib/org.mjs +100 -13
- package/lib/pay.mjs +1 -1
- package/lib/projects.mjs +26 -29
- package/lib/redeem.mjs +7 -8
- package/lib/remote-helper-session.mjs +12 -12
- package/lib/repos.mjs +62 -62
- package/lib/rooms.mjs +103 -67
- package/lib/sdk-errors.mjs +9 -4
- package/lib/sdk.mjs +3 -3
- package/lib/service.mjs +5 -5
- package/lib/session-proofs.mjs +21 -0
- package/lib/sign-in.mjs +296 -0
- package/lib/sites.mjs +8 -8
- package/lib/stats.mjs +2 -2
- package/lib/status.mjs +25 -25
- package/lib/subdomains.mjs +19 -19
- package/lib/subscriptions.mjs +8 -8
- package/lib/tier.mjs +29 -22
- package/lib/transfer.mjs +58 -85
- package/lib/up.mjs +7 -7
- package/lib/wallet-context.mjs +3 -3
- package/lib/wallet-context.test.mjs +3 -3
- package/lib/wallets.mjs +196 -31
- package/lib/webhook-secret.mjs +6 -6
- package/lib/whoami.mjs +75 -0
- package/package.json +1 -1
- package/sdk/core-dist/config.js +52 -18
- package/sdk/core-dist/control-plane-session.js +31 -6
- package/sdk/core-dist/keystore.js +7 -7
- package/sdk/core-dist/profiles.js +9 -7
- package/sdk/core-dist/{allowance-auth.js → wallet-auth.js} +15 -15
- package/{core-dist/allowance.js → sdk/core-dist/wallet.js} +20 -20
- package/{core-dist/write-auth-session.js → sdk/core-dist/write-approvals.js} +19 -19
- package/sdk/dist/actions.d.ts +1 -1
- package/sdk/dist/actions.d.ts.map +1 -1
- package/sdk/dist/control-plane-credentials.d.ts +8 -8
- package/sdk/dist/control-plane-credentials.js +7 -7
- package/sdk/dist/credentials.d.ts +19 -19
- package/sdk/dist/credentials.d.ts.map +1 -1
- package/sdk/dist/credentials.js +1 -1
- package/sdk/dist/errors.d.ts +24 -26
- package/sdk/dist/errors.d.ts.map +1 -1
- package/sdk/dist/errors.js +34 -37
- package/sdk/dist/errors.js.map +1 -1
- package/sdk/dist/index.d.ts +29 -16
- package/sdk/dist/index.d.ts.map +1 -1
- package/sdk/dist/index.js +29 -16
- package/sdk/dist/index.js.map +1 -1
- package/sdk/dist/kernel.d.ts +1 -1
- package/sdk/dist/kernel.d.ts.map +1 -1
- package/sdk/dist/kernel.js +10 -9
- package/sdk/dist/kernel.js.map +1 -1
- package/sdk/dist/namespaces/admin.d.ts +51 -120
- package/sdk/dist/namespaces/admin.d.ts.map +1 -1
- package/sdk/dist/namespaces/admin.js +41 -45
- package/sdk/dist/namespaces/admin.js.map +1 -1
- package/sdk/dist/namespaces/agent.d.ts +2 -2
- package/sdk/dist/namespaces/agent.d.ts.map +1 -1
- package/sdk/dist/namespaces/agent.js +2 -2
- package/sdk/dist/namespaces/agent.js.map +1 -1
- package/sdk/dist/namespaces/ai.d.ts +1 -1
- package/sdk/dist/namespaces/ai.js +1 -1
- package/sdk/dist/namespaces/billing.d.ts +6 -3
- package/sdk/dist/namespaces/billing.d.ts.map +1 -1
- package/sdk/dist/namespaces/billing.js.map +1 -1
- package/sdk/dist/namespaces/buzz-notifications.types.d.ts +1 -1
- package/sdk/dist/namespaces/buzz.d.ts +2 -2
- package/sdk/dist/namespaces/buzz.d.ts.map +1 -1
- package/sdk/dist/namespaces/buzz.js +2 -2
- package/sdk/dist/namespaces/buzz.js.map +1 -1
- package/sdk/dist/namespaces/buzz.types.d.ts +2 -2
- package/sdk/dist/namespaces/buzz.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/credentials.types.d.ts +1 -1
- package/sdk/dist/namespaces/deploy.d.ts +1 -1
- package/sdk/dist/namespaces/deploy.js +5 -5
- package/sdk/dist/namespaces/deploy.js.map +1 -1
- package/sdk/dist/namespaces/deploy.types.d.ts +4 -4
- package/sdk/dist/namespaces/escalations.d.ts +1 -1
- package/sdk/dist/namespaces/escalations.js +1 -1
- package/sdk/dist/namespaces/escalations.types.d.ts +2 -2
- package/sdk/dist/namespaces/escalations.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/events.types.d.ts +1 -1
- package/sdk/dist/namespaces/functions.d.ts +1 -1
- package/sdk/dist/namespaces/functions.js +1 -1
- package/sdk/dist/namespaces/gitvault.crypto.d.ts +1 -1
- package/sdk/dist/namespaces/gitvault.d.ts +24 -24
- package/sdk/dist/namespaces/gitvault.d.ts.map +1 -1
- package/sdk/dist/namespaces/gitvault.js +109 -109
- package/sdk/dist/namespaces/gitvault.js.map +1 -1
- package/sdk/dist/namespaces/me.d.ts +120 -0
- package/sdk/dist/namespaces/me.d.ts.map +1 -0
- package/sdk/dist/namespaces/me.js +34 -0
- package/sdk/dist/namespaces/me.js.map +1 -0
- package/sdk/dist/namespaces/org.d.ts +108 -6
- package/sdk/dist/namespaces/org.d.ts.map +1 -1
- package/sdk/dist/namespaces/org.js +63 -7
- package/sdk/dist/namespaces/org.js.map +1 -1
- package/sdk/dist/namespaces/org.types.d.ts +29 -9
- package/sdk/dist/namespaces/org.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/pay.js +3 -3
- package/sdk/dist/namespaces/pay.js.map +1 -1
- package/sdk/dist/namespaces/projects.d.ts +9 -9
- package/sdk/dist/namespaces/projects.js +15 -15
- package/sdk/dist/namespaces/projects.js.map +1 -1
- package/sdk/dist/namespaces/projects.types.d.ts +28 -12
- package/sdk/dist/namespaces/projects.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/rooms.d.ts +7 -7
- package/sdk/dist/namespaces/rooms.js +17 -17
- package/sdk/dist/namespaces/rooms.js.map +1 -1
- package/sdk/dist/namespaces/rooms.types.d.ts +9 -9
- package/sdk/dist/namespaces/rooms.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/service.d.ts +1 -1
- package/sdk/dist/namespaces/service.js +1 -1
- package/sdk/dist/namespaces/{operator-session.d.ts → session.d.ts} +135 -51
- package/sdk/dist/namespaces/session.d.ts.map +1 -0
- package/sdk/dist/namespaces/{operator-session.js → session.js} +118 -30
- package/sdk/dist/namespaces/session.js.map +1 -0
- package/sdk/dist/namespaces/subdomains.d.ts +5 -5
- package/sdk/dist/namespaces/subdomains.d.ts.map +1 -1
- package/sdk/dist/namespaces/subdomains.js +6 -6
- package/sdk/dist/namespaces/subdomains.js.map +1 -1
- package/sdk/dist/namespaces/tier.d.ts +43 -20
- package/sdk/dist/namespaces/tier.d.ts.map +1 -1
- package/sdk/dist/namespaces/tier.js +7 -7
- package/sdk/dist/namespaces/tier.js.map +1 -1
- package/sdk/dist/namespaces/transfers.d.ts +74 -71
- package/sdk/dist/namespaces/transfers.d.ts.map +1 -1
- package/sdk/dist/namespaces/transfers.js +31 -38
- package/sdk/dist/namespaces/transfers.js.map +1 -1
- package/sdk/dist/namespaces/vouchers.d.ts +9 -10
- package/sdk/dist/namespaces/vouchers.d.ts.map +1 -1
- package/sdk/dist/namespaces/vouchers.js +4 -5
- package/sdk/dist/namespaces/vouchers.js.map +1 -1
- package/sdk/dist/namespaces/wallets.d.ts +72 -3
- package/sdk/dist/namespaces/wallets.d.ts.map +1 -1
- package/sdk/dist/namespaces/wallets.js +141 -3
- package/sdk/dist/namespaces/wallets.js.map +1 -1
- package/sdk/dist/namespaces/write-approval.d.ts +101 -0
- package/sdk/dist/namespaces/write-approval.d.ts.map +1 -0
- package/sdk/dist/namespaces/write-approval.js +62 -0
- package/sdk/dist/namespaces/write-approval.js.map +1 -0
- package/sdk/dist/node/actions-node.d.ts +3 -3
- package/sdk/dist/node/actions-node.d.ts.map +1 -1
- package/sdk/dist/node/actions-node.js +36 -36
- package/sdk/dist/node/actions-node.js.map +1 -1
- package/sdk/dist/node/{bearer-claim-key.d.ts → bearer-redeem-key.d.ts} +12 -12
- package/sdk/dist/node/bearer-redeem-key.d.ts.map +1 -0
- package/sdk/dist/node/{bearer-claim-key.js → bearer-redeem-key.js} +21 -21
- package/sdk/dist/node/bearer-redeem-key.js.map +1 -0
- package/sdk/dist/node/ci.d.ts +1 -1
- package/sdk/dist/node/ci.d.ts.map +1 -1
- package/sdk/dist/node/ci.js +6 -6
- package/sdk/dist/node/ci.js.map +1 -1
- package/sdk/dist/node/credentials.d.ts +17 -16
- package/sdk/dist/node/credentials.d.ts.map +1 -1
- package/sdk/dist/node/credentials.js +28 -27
- package/sdk/dist/node/credentials.js.map +1 -1
- package/sdk/dist/node/funding-recovery.d.ts +1 -1
- package/sdk/dist/node/funding-recovery.d.ts.map +1 -1
- package/sdk/dist/node/funding-recovery.js +1 -1
- package/sdk/dist/node/funding-recovery.js.map +1 -1
- package/sdk/dist/node/gitvault-apply.d.ts +1 -1
- package/sdk/dist/node/gitvault-apply.d.ts.map +1 -1
- package/sdk/dist/node/gitvault-handoff.d.ts +22 -22
- package/sdk/dist/node/gitvault-handoff.d.ts.map +1 -1
- package/sdk/dist/node/gitvault-handoff.js +45 -45
- package/sdk/dist/node/gitvault-handoff.js.map +1 -1
- package/sdk/dist/node/gitvault-prewarm.js +7 -7
- package/sdk/dist/node/gitvault-prewarm.js.map +1 -1
- package/sdk/dist/node/gitvault-restore.d.ts +1 -1
- package/sdk/dist/node/gitvault-restore.js +1 -1
- package/sdk/dist/node/index.d.ts +16 -16
- package/sdk/dist/node/index.d.ts.map +1 -1
- package/sdk/dist/node/index.js +15 -15
- package/sdk/dist/node/index.js.map +1 -1
- package/sdk/dist/node/org-adopt.d.ts +49 -0
- package/sdk/dist/node/org-adopt.d.ts.map +1 -0
- package/sdk/dist/node/org-adopt.js +77 -0
- package/sdk/dist/node/org-adopt.js.map +1 -0
- package/sdk/dist/node/paid-fetch.d.ts +7 -7
- package/sdk/dist/node/paid-fetch.d.ts.map +1 -1
- package/sdk/dist/node/paid-fetch.js +54 -54
- package/sdk/dist/node/paid-fetch.js.map +1 -1
- package/sdk/dist/node/preflight.d.ts +1 -1
- package/sdk/dist/node/preflight.d.ts.map +1 -1
- package/sdk/dist/node/preflight.js +1 -1
- package/sdk/dist/node/preflight.js.map +1 -1
- package/sdk/dist/node/source-scan.d.ts +1 -1
- package/sdk/dist/node/source-scan.js +2 -2
- package/sdk/dist/node/source-scan.js.map +1 -1
- package/sdk/dist/scoped.d.ts +3 -3
- package/sdk/dist/scoped.d.ts.map +1 -1
- package/sdk/dist/scoped.js +2 -2
- package/sdk/dist/scoped.js.map +1 -1
- package/core-dist/operator-session.js +0 -154
- package/lib/allowance.mjs +0 -355
- package/lib/operator-proofs.mjs +0 -22
- package/lib/operator.mjs +0 -771
- package/sdk/core-dist/operator-session.js +0 -154
- package/sdk/dist/namespaces/allowance.d.ts +0 -79
- package/sdk/dist/namespaces/allowance.d.ts.map +0 -1
- package/sdk/dist/namespaces/allowance.js +0 -149
- package/sdk/dist/namespaces/allowance.js.map +0 -1
- package/sdk/dist/namespaces/operator-session.d.ts.map +0 -1
- package/sdk/dist/namespaces/operator-session.js.map +0 -1
- package/sdk/dist/namespaces/operator.d.ts +0 -359
- package/sdk/dist/namespaces/operator.d.ts.map +0 -1
- package/sdk/dist/namespaces/operator.js +0 -272
- package/sdk/dist/namespaces/operator.js.map +0 -1
- package/sdk/dist/node/bearer-claim-key.d.ts.map +0 -1
- package/sdk/dist/node/bearer-claim-key.js.map +0 -1
- package/sdk/dist/node/operator-claim.d.ts +0 -49
- package/sdk/dist/node/operator-claim.d.ts.map +0 -1
- package/sdk/dist/node/operator-claim.js +0 -77
- package/sdk/dist/node/operator-claim.js.map +0 -1
package/lib/allowance.mjs
DELETED
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
import { readAllowance, saveAllowance, allowanceFile } from "./config.mjs";
|
|
2
|
-
import { getSdk } from "./sdk.mjs";
|
|
3
|
-
import { reportSdkError, fail } from "./sdk-errors.mjs";
|
|
4
|
-
import { assertKnownFlags, flagValue, normalizeArgv, parseIntegerFlag, positionalArgs, failUnknownSubcommand } from "./argparse.mjs";
|
|
5
|
-
|
|
6
|
-
const HELP = `run402 allowance — Manage your agent allowance
|
|
7
|
-
|
|
8
|
-
Usage:
|
|
9
|
-
run402 allowance <subcommand>
|
|
10
|
-
|
|
11
|
-
Subcommands:
|
|
12
|
-
status Show allowance address, network, rail, and funding status
|
|
13
|
-
create Generate a new allowance and save it locally
|
|
14
|
-
fund Request test funds from the faucet (Base Sepolia or Tempo)
|
|
15
|
-
balance Show on-chain balances and Run402 billing balance
|
|
16
|
-
export Print the allowance address as JSON (useful for scripting)
|
|
17
|
-
checkout Create an org balance checkout session (--amount <usd_micros>)
|
|
18
|
-
history View billing transaction history (--limit <n>)
|
|
19
|
-
|
|
20
|
-
Notes:
|
|
21
|
-
- Agent allowance is stored locally at ~/.config/run402/allowance.json
|
|
22
|
-
- The allowance works on any EVM chain (Base for x402, Tempo for MPP)
|
|
23
|
-
- Use 'run402 init' for x402 or 'run402 init mpp' for MPP rail
|
|
24
|
-
|
|
25
|
-
Examples:
|
|
26
|
-
run402 allowance create
|
|
27
|
-
run402 allowance status
|
|
28
|
-
run402 allowance fund
|
|
29
|
-
run402 allowance export
|
|
30
|
-
run402 allowance balance
|
|
31
|
-
run402 allowance checkout --amount 5000000
|
|
32
|
-
run402 allowance history --limit 10
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
const SUB_HELP = {
|
|
36
|
-
checkout: `run402 allowance checkout — Create an org balance checkout session
|
|
37
|
-
|
|
38
|
-
Usage:
|
|
39
|
-
run402 allowance checkout --amount <usd_micros>
|
|
40
|
-
|
|
41
|
-
Options:
|
|
42
|
-
--amount <n> Amount in USD micros (required; e.g. 5000000 for $5)
|
|
43
|
-
|
|
44
|
-
Examples:
|
|
45
|
-
run402 allowance checkout --amount 5000000
|
|
46
|
-
run402 allowance checkout --amount 10000000
|
|
47
|
-
`,
|
|
48
|
-
history: `run402 allowance history — View billing transaction history
|
|
49
|
-
|
|
50
|
-
Usage:
|
|
51
|
-
run402 allowance history [--limit <n>]
|
|
52
|
-
|
|
53
|
-
Options:
|
|
54
|
-
--limit <n> Max entries to return (default: 20)
|
|
55
|
-
|
|
56
|
-
Examples:
|
|
57
|
-
run402 allowance history
|
|
58
|
-
run402 allowance history --limit 10
|
|
59
|
-
`,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const USDC_ABI = [{ name: "balanceOf", type: "function", stateMutability: "view", inputs: [{ name: "account", type: "address" }], outputs: [{ name: "", type: "uint256" }] }];
|
|
63
|
-
const USDC_MAINNET = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
64
|
-
const USDC_SEPOLIA = "0x036CbD53842c5426634e7929541eC2318f3dCF7e";
|
|
65
|
-
const PATH_USD = "0x20c0000000000000000000000000000000000000";
|
|
66
|
-
const TEMPO_RPC = "https://rpc.moderato.tempo.xyz/";
|
|
67
|
-
|
|
68
|
-
async function loadDeps() {
|
|
69
|
-
const { generatePrivateKey, privateKeyToAccount } = await import("viem/accounts");
|
|
70
|
-
const { createPublicClient, http, defineChain } = await import("viem");
|
|
71
|
-
const { base, baseSepolia } = await import("viem/chains");
|
|
72
|
-
const tempoModerato = defineChain({
|
|
73
|
-
id: 42431,
|
|
74
|
-
name: "Tempo Moderato",
|
|
75
|
-
nativeCurrency: { name: "pathUSD", symbol: "pathUSD", decimals: 6 },
|
|
76
|
-
rpcUrls: { default: { http: [TEMPO_RPC] } },
|
|
77
|
-
});
|
|
78
|
-
return { generatePrivateKey, privateKeyToAccount, createPublicClient, http, base, baseSepolia, tempoModerato };
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function status() {
|
|
82
|
-
try {
|
|
83
|
-
const data = await getSdk().allowance.status();
|
|
84
|
-
if (!data.configured) {
|
|
85
|
-
console.log(JSON.stringify({ wallet: null, hint: "Run: run402 allowance create" }));
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const w = readAllowance();
|
|
89
|
-
// The Lightning allowance (mpp-lightning-over-nwc): public facts plus a
|
|
90
|
-
// best-effort balance read over NWC; the pairing secret never prints.
|
|
91
|
-
const { describeLightning, readLightningBalance } = await import("./lightning-wallet.mjs");
|
|
92
|
-
const lightning = w?.lightning ? describeLightning(w, null, await readLightningBalance(w)) : null;
|
|
93
|
-
console.log(JSON.stringify({
|
|
94
|
-
wallet: {
|
|
95
|
-
address: data.address,
|
|
96
|
-
created: data.created,
|
|
97
|
-
configured: data.configured,
|
|
98
|
-
// `faucet_used` is named for what it is: an on-disk marker that
|
|
99
|
-
// tracks faucet invocation, not pay-readiness. For a true "can this
|
|
100
|
-
// account pay right now" check, use `run402 allowance balance`.
|
|
101
|
-
faucet_used: !!data.faucet_used,
|
|
102
|
-
rail: data.rail ?? w?.rail ?? "x402",
|
|
103
|
-
path: data.path ?? allowanceFile(),
|
|
104
|
-
},
|
|
105
|
-
...(lightning ? { lightning } : {}),
|
|
106
|
-
}));
|
|
107
|
-
} catch (err) {
|
|
108
|
-
reportSdkError(err);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async function create() {
|
|
113
|
-
try {
|
|
114
|
-
const result = await getSdk().allowance.create();
|
|
115
|
-
console.log(JSON.stringify({
|
|
116
|
-
address: result.address,
|
|
117
|
-
path: result.path ?? allowanceFile(),
|
|
118
|
-
created: true,
|
|
119
|
-
}));
|
|
120
|
-
} catch (err) {
|
|
121
|
-
const msg = (err instanceof Error) ? err.message : String(err);
|
|
122
|
-
if (/already exists/i.test(msg)) {
|
|
123
|
-
fail({
|
|
124
|
-
code: "ALLOWANCE_EXISTS",
|
|
125
|
-
message: "Agent allowance already exists.",
|
|
126
|
-
hint: "Use 'status' to check it.",
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
reportSdkError(err);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async function fund() {
|
|
134
|
-
const w = readAllowance();
|
|
135
|
-
if (!w) {
|
|
136
|
-
fail({
|
|
137
|
-
code: "NO_ALLOWANCE",
|
|
138
|
-
message: "No agent allowance.",
|
|
139
|
-
hint: "Run: run402 allowance create",
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (w.rail === "mpp") {
|
|
144
|
-
// Tempo Moderato faucet — instant, no polling needed
|
|
145
|
-
const { createPublicClient, http, tempoModerato } = await loadDeps();
|
|
146
|
-
const client = createPublicClient({ chain: tempoModerato, transport: http() });
|
|
147
|
-
const before = await readUsdcBalance(client, PATH_USD, w.address).catch(() => 0);
|
|
148
|
-
|
|
149
|
-
const res = await fetch(TEMPO_RPC, {
|
|
150
|
-
method: "POST",
|
|
151
|
-
headers: { "Content-Type": "application/json" },
|
|
152
|
-
body: JSON.stringify({ jsonrpc: "2.0", method: "tempo_fundAddress", params: [w.address], id: 1 }),
|
|
153
|
-
});
|
|
154
|
-
const data = await res.json();
|
|
155
|
-
if (data.error) {
|
|
156
|
-
fail({
|
|
157
|
-
code: "FAUCET_FAILED",
|
|
158
|
-
message: data.error.message || "Tempo faucet failed",
|
|
159
|
-
details: { rail: "mpp" },
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Re-read balance once (instant confirmation)
|
|
164
|
-
const now = await readUsdcBalance(client, PATH_USD, w.address).catch(() => before);
|
|
165
|
-
saveAllowance({ ...w, funded: true, lastFaucet: new Date().toISOString() });
|
|
166
|
-
console.log(JSON.stringify({
|
|
167
|
-
address: w.address,
|
|
168
|
-
rail: "mpp",
|
|
169
|
-
onchain: {
|
|
170
|
-
"tempo-moderato_pathusd_micros": now,
|
|
171
|
-
},
|
|
172
|
-
}, null, 2));
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Default: Base Sepolia faucet (existing behavior)
|
|
177
|
-
const { createPublicClient, http, baseSepolia } = await loadDeps();
|
|
178
|
-
const client = createPublicClient({ chain: baseSepolia, transport: http() });
|
|
179
|
-
const before = await readUsdcBalance(client, USDC_SEPOLIA, w.address).catch(() => 0);
|
|
180
|
-
|
|
181
|
-
let data;
|
|
182
|
-
try {
|
|
183
|
-
data = await getSdk().allowance.faucet(w.address);
|
|
184
|
-
} catch (err) {
|
|
185
|
-
reportSdkError(err);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const MAX_WAIT = 30;
|
|
189
|
-
for (let i = 0; i < MAX_WAIT; i++) {
|
|
190
|
-
await new Promise(r => setTimeout(r, 1000));
|
|
191
|
-
const now = await readUsdcBalance(client, USDC_SEPOLIA, w.address).catch(() => before);
|
|
192
|
-
if (now > before) {
|
|
193
|
-
saveAllowance({ ...w, funded: true, lastFaucet: new Date().toISOString() });
|
|
194
|
-
console.log(JSON.stringify({
|
|
195
|
-
address: w.address,
|
|
196
|
-
rail: w.rail || "x402",
|
|
197
|
-
onchain: {
|
|
198
|
-
"base-sepolia_usd_micros": now,
|
|
199
|
-
},
|
|
200
|
-
}, null, 2));
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
saveAllowance({ ...w, funded: true, lastFaucet: new Date().toISOString() });
|
|
206
|
-
console.log(JSON.stringify({ ...data, balance_confirmed: false, hint: "Faucet request sent but on-chain balance not yet confirmed" }));
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
async function readUsdcBalance(client, usdc, address) {
|
|
210
|
-
const raw = await client.readContract({ address: usdc, abi: USDC_ABI, functionName: "balanceOf", args: [address] });
|
|
211
|
-
return Number(raw);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
async function balance() {
|
|
215
|
-
const w = readAllowance();
|
|
216
|
-
if (!w) {
|
|
217
|
-
fail({
|
|
218
|
-
code: "NO_ALLOWANCE",
|
|
219
|
-
message: "No agent allowance.",
|
|
220
|
-
hint: "Run: run402 allowance create",
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const { createPublicClient, http, base, baseSepolia, tempoModerato } = await loadDeps();
|
|
225
|
-
const mainnetClient = createPublicClient({ chain: base, transport: http() });
|
|
226
|
-
const sepoliaClient = createPublicClient({ chain: baseSepolia, transport: http() });
|
|
227
|
-
const tempoClient = createPublicClient({ chain: tempoModerato, transport: http() });
|
|
228
|
-
|
|
229
|
-
const [mainnetUsdc, sepoliaUsdc, tempoPathUsd, billingRes] = await Promise.all([
|
|
230
|
-
readUsdcBalance(mainnetClient, USDC_MAINNET, w.address).catch(() => null),
|
|
231
|
-
readUsdcBalance(sepoliaClient, USDC_SEPOLIA, w.address).catch(() => null),
|
|
232
|
-
readUsdcBalance(tempoClient, PATH_USD, w.address).catch(() => null),
|
|
233
|
-
getSdk().billing.checkBalance(w.address).catch(() => null),
|
|
234
|
-
]);
|
|
235
|
-
|
|
236
|
-
console.log(JSON.stringify({
|
|
237
|
-
address: w.address,
|
|
238
|
-
rail: w.rail || "x402",
|
|
239
|
-
onchain: {
|
|
240
|
-
"base-mainnet_usd_micros": mainnetUsdc,
|
|
241
|
-
"base-sepolia_usd_micros": sepoliaUsdc,
|
|
242
|
-
"tempo-moderato_pathusd_micros": tempoPathUsd,
|
|
243
|
-
},
|
|
244
|
-
run402: billingRes ? { balance_usd_micros: billingRes.available_usd_micros } : "no organization",
|
|
245
|
-
}, null, 2));
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
async function exportAddr(args = []) {
|
|
249
|
-
const parsedArgs = normalizeArgv(args);
|
|
250
|
-
assertKnownFlags(parsedArgs, [], []);
|
|
251
|
-
const bare = positionalArgs(parsedArgs, []);
|
|
252
|
-
if (bare.length > 0) {
|
|
253
|
-
fail({
|
|
254
|
-
code: "BAD_USAGE",
|
|
255
|
-
message: `Unexpected argument for allowance export: ${bare[0]}`,
|
|
256
|
-
details: { argument: bare[0] },
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
try {
|
|
260
|
-
const address = await getSdk().allowance.export();
|
|
261
|
-
console.log(JSON.stringify({ address }));
|
|
262
|
-
} catch {
|
|
263
|
-
fail({ code: "NO_ALLOWANCE", message: "No agent allowance." });
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
async function checkout(args) {
|
|
268
|
-
const w = readAllowance();
|
|
269
|
-
if (!w) {
|
|
270
|
-
fail({
|
|
271
|
-
code: "NO_ALLOWANCE",
|
|
272
|
-
message: "No agent allowance.",
|
|
273
|
-
hint: "Run: run402 allowance create",
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
const parsedArgs = normalizeArgv(args);
|
|
277
|
-
assertKnownFlags(parsedArgs, ["--amount", "--help", "-h"], ["--amount"]);
|
|
278
|
-
const bare = positionalArgs(parsedArgs, ["--amount"]);
|
|
279
|
-
if (bare.length > 0) {
|
|
280
|
-
fail({
|
|
281
|
-
code: "BAD_USAGE",
|
|
282
|
-
message: `Unexpected argument for allowance checkout: ${bare[0]}`,
|
|
283
|
-
details: { argument: bare[0] },
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
const amountRaw = flagValue(parsedArgs, "--amount");
|
|
287
|
-
if (amountRaw === null) {
|
|
288
|
-
fail({
|
|
289
|
-
code: "BAD_USAGE",
|
|
290
|
-
message: "Missing --amount <usd_micros>",
|
|
291
|
-
hint: "e.g. --amount 5000000 for $5",
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
const amount = parseIntegerFlag("--amount", amountRaw, { min: 1 });
|
|
295
|
-
try {
|
|
296
|
-
const org = await getSdk().billing.lookupOrganization(w.address);
|
|
297
|
-
const data = await getSdk().billing.createCheckout(org.org_id, {
|
|
298
|
-
product: "balance_topup",
|
|
299
|
-
amountUsdMicros: amount,
|
|
300
|
-
});
|
|
301
|
-
console.log(JSON.stringify(data, null, 2));
|
|
302
|
-
} catch (err) {
|
|
303
|
-
reportSdkError(err);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
async function history(args) {
|
|
308
|
-
const w = readAllowance();
|
|
309
|
-
if (!w) {
|
|
310
|
-
fail({
|
|
311
|
-
code: "NO_ALLOWANCE",
|
|
312
|
-
message: "No agent allowance.",
|
|
313
|
-
hint: "Run: run402 allowance create",
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
const parsedArgs = normalizeArgv(args);
|
|
317
|
-
assertKnownFlags(parsedArgs, ["--limit", "--help", "-h"], ["--limit"]);
|
|
318
|
-
const bare = positionalArgs(parsedArgs, ["--limit"]);
|
|
319
|
-
if (bare.length > 0) {
|
|
320
|
-
fail({
|
|
321
|
-
code: "BAD_USAGE",
|
|
322
|
-
message: `Unexpected argument for allowance history: ${bare[0]}`,
|
|
323
|
-
details: { argument: bare[0] },
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
const limit = parseIntegerFlag("--limit", flagValue(parsedArgs, "--limit"), { min: 1, def: 20 });
|
|
327
|
-
try {
|
|
328
|
-
const data = await getSdk().billing.history(w.address, limit);
|
|
329
|
-
console.log(JSON.stringify(data, null, 2));
|
|
330
|
-
} catch (err) {
|
|
331
|
-
reportSdkError(err);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
export async function run(sub, args) {
|
|
336
|
-
if (!sub || sub === '--help' || sub === '-h') {
|
|
337
|
-
console.log(HELP);
|
|
338
|
-
process.exit(0);
|
|
339
|
-
}
|
|
340
|
-
if (Array.isArray(args) && (args.includes("--help") || args.includes("-h"))) {
|
|
341
|
-
console.log(SUB_HELP[sub] || HELP);
|
|
342
|
-
process.exit(0);
|
|
343
|
-
}
|
|
344
|
-
switch (sub) {
|
|
345
|
-
case "status": await status(); break;
|
|
346
|
-
case "create": await create(); break;
|
|
347
|
-
case "fund": await fund(); break;
|
|
348
|
-
case "balance": await balance(); break;
|
|
349
|
-
case "export": await exportAddr(args); break;
|
|
350
|
-
case "checkout": await checkout(args); break;
|
|
351
|
-
case "history": await history(args); break;
|
|
352
|
-
default:
|
|
353
|
-
failUnknownSubcommand("allowance", sub);
|
|
354
|
-
}
|
|
355
|
-
}
|
package/lib/operator-proofs.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* one-passkey-per-person: the two proofs a wallet-authenticated notification
|
|
3
|
-
* mutation carries when the human behind this wallet is logged in.
|
|
4
|
-
*
|
|
5
|
-
* `run402 operator login --loopback` caches a passkey-fresh control-plane
|
|
6
|
-
* session. The gateway accepts that session — sent as `Authorization: Bearer`
|
|
7
|
-
* beside the wallet's `SIGN-IN-WITH-X` on the SAME request — as
|
|
8
|
-
* `operator_passkey` assurance for a wallet contact whose verified email the
|
|
9
|
-
* session's principal holds. So a person who logged in once is never asked to
|
|
10
|
-
* enroll a second passkey. With no live cached session this returns
|
|
11
|
-
* `undefined` and the verb behaves exactly as before (wallet auth alone).
|
|
12
|
-
*/
|
|
13
|
-
import { allowanceAuthHeaders } from "./config.mjs";
|
|
14
|
-
import { loadLiveControlPlaneSession } from "../core-dist/control-plane-session.js";
|
|
15
|
-
|
|
16
|
-
/** `{ siwx, token }` for `path`, or `undefined` when no live operator session is cached. */
|
|
17
|
-
export function operatorProofs(path) {
|
|
18
|
-
const siwx = allowanceAuthHeaders(path)["SIGN-IN-WITH-X"];
|
|
19
|
-
const live = loadLiveControlPlaneSession();
|
|
20
|
-
if (!live || !live.control_plane_session_token) return undefined;
|
|
21
|
-
return { siwx, token: live.control_plane_session_token };
|
|
22
|
-
}
|