@one-source/api-mcp 5.4.7 → 5.6.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/dist/mpp.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ export type MppMode = 'charge' | 'session';
2
+ export interface MppSessionHandle {
3
+ /** Payment-aware fetch that drives the voucher-channel lifecycle. */
4
+ fetch: typeof globalThis.fetch;
5
+ /** Whether the session manager initialised and can be selected. */
6
+ available: boolean;
7
+ }
8
+ export interface MppSetupResult {
9
+ enabled: boolean;
10
+ address?: string;
11
+ /** Per-call charge fetch, present whenever MPP is enabled. */
12
+ chargeFetch?: typeof globalThis.fetch;
13
+ /** Voucher-channel session handle. */
14
+ session?: MppSessionHandle;
15
+ }
16
+ export interface MppReclaimResult {
17
+ ok: boolean;
18
+ /** Human-readable outcome, safe to surface directly to the user. */
19
+ message: string;
20
+ }
21
+ export declare function setupMpp(): MppSetupResult;
22
+ /** Whether MPP payment is active (MPP_PRIVATE_KEY set). */
23
+ export declare function isMppEnabled(): boolean;
24
+ /** Payer wallet address, when enabled. */
25
+ export declare function getMppAddress(): string | undefined;
26
+ /** Whether the session channel scheme initialised and can be selected. */
27
+ export declare function isMppSessionAvailable(): boolean;
28
+ /** Whether an MPP voucher channel is currently open on-chain. */
29
+ export declare function isMppSessionOpen(): boolean;
30
+ /**
31
+ * Cooperatively close the active MPP voucher channel on shutdown. Safe to call
32
+ * when no channel was ever opened (no-op) and idempotent. Swallows errors so a
33
+ * stuck settle can't hang shutdown. Terminal — does not re-open the channel
34
+ * (use {@link reclaimMppSession} for the in-session reclaim that re-opens).
35
+ */
36
+ export declare function closeMppSession(): Promise<void>;
37
+ /**
38
+ * Reclaim the unspent deposit of the open MPP voucher channel back to the payer
39
+ * wallet, then re-arm the session so the next mpp-session call opens a fresh
40
+ * channel. This is the MPP analog of x402's `refundBatchChannel` and backs the
41
+ * `1s_refund` tool's MPP branch.
42
+ *
43
+ * Unlike {@link closeMppSession} (terminal, shutdown-only), this rebuilds the
44
+ * legacy session manager after settling so the rail stays usable in-session.
45
+ * Returns a structured result rather than throwing, so the calling tool can
46
+ * surface a clear message for the "nothing to reclaim" / failure cases.
47
+ */
48
+ export declare function reclaimMppSession(): Promise<MppReclaimResult>;
49
+ //# sourceMappingURL=mpp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mpp.d.ts","sourceRoot":"","sources":["../src/mpp.ts"],"names":[],"mappings":"AA4BA,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE3C,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAC/B,mEAAmE;IACnE,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACtC,sCAAsC;IACtC,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;CACjB;AAiCD,wBAAgB,QAAQ,IAAI,cAAc,CAiHzC;AAED,2DAA2D;AAC3D,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED,0CAA0C;AAC1C,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAElD;AAED,0EAA0E;AAC1E,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAED,iEAAiE;AACjE,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AA6CD;;;;;GAKG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAWrD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAiCnE"}
package/dist/mpp.js ADDED
@@ -0,0 +1,298 @@
1
+ /**
2
+ * MPP (Tempo Machine Payments Protocol) payment setup.
3
+ *
4
+ * When MPP_PRIVATE_KEY is set, builds payment-aware fetch wrappers that handle
5
+ * HTTP 402 `WWW-Authenticate: Payment` challenges from the gateway by signing
6
+ * Tempo payments (USDC.e / pathUSD) via the `mppx` SDK.
7
+ *
8
+ * Two sub-modes, both using the same MPP_PRIVATE_KEY wallet:
9
+ * - `charge` — one signed Tempo payment per call (the default). Local accounts
10
+ * sign in `pull` mode (server broadcasts), so no Tempo RPC is
11
+ * needed — the network/currency/recipient come from the gateway
12
+ * challenge, exactly like x402 `exact`.
13
+ * - `session` — a TIP-1034 voucher channel: the first call opens a channel
14
+ * on-chain (capped by MPP_MAX_DEPOSIT), subsequent calls are
15
+ * signed off-chain as cumulative vouchers, and the unspent
16
+ * deposit is reclaimed by `closeMppSession()` on shutdown.
17
+ *
18
+ * Like x402.ts, this returns the wrapped fetches instead of patching
19
+ * globalThis.fetch (Mppx.create polyfills global by default — we pass
20
+ * polyfill:false), so only the OneSourceClient pays; analytics and other HTTP
21
+ * consumers are unaffected. The unified `payment.ts` orchestrator selects
22
+ * between the charge fetch and the session fetch based on the active mode.
23
+ */
24
+ import { Mppx, tempo, sessionLegacyManager, sessionLegacy } from 'mppx/client';
25
+ import { privateKeyToAccount } from 'viem/accounts';
26
+ import { createPublicClient, http } from 'viem';
27
+ import { tempo as tempoChain } from 'viem/chains';
28
+ // Human-readable cap (in token units) on a session channel's on-chain deposit.
29
+ // Bounds the worst-case locked balance if the process dies before close.
30
+ const DEFAULT_MAX_DEPOSIT = '1';
31
+ let _applied = false;
32
+ let _cachedResult;
33
+ let _enabled = false;
34
+ let _address;
35
+ let _sessionAvailable = false;
36
+ // The mppx session manager, retained so `closeMppSession` can cooperatively
37
+ // settle and reclaim the unspent deposit on shutdown.
38
+ let _sessionManager;
39
+ // The legacy session method + the strip-x402 fetch + the last session request's
40
+ // URL and challenge — used by closeMppSession to sign and POST our own close
41
+ // credential at the locally-authorized cumulative (see closeMppSession).
42
+ let _sessionMethod;
43
+ let _sessionFetchImpl;
44
+ let _lastSessionUrl;
45
+ let _lastSessionChallenge;
46
+ let _sessionClosed = false;
47
+ // (Re)builds the legacy session manager + method under a fresh channel, so a
48
+ // reclaim (1s_refund) can settle the current channel and immediately make a new
49
+ // one openable on the next mpp-session call — mirrors x402's salt-rotation
50
+ // rebuild. Undefined when the session scheme failed to initialise.
51
+ let _rebuildSession;
52
+ function maxDeposit() {
53
+ return process.env.MPP_MAX_DEPOSIT?.trim() || DEFAULT_MAX_DEPOSIT;
54
+ }
55
+ export function setupMpp() {
56
+ const rawKey = process.env.MPP_PRIVATE_KEY;
57
+ if (!rawKey)
58
+ return { enabled: false };
59
+ if (_applied && _cachedResult)
60
+ return _cachedResult;
61
+ // Auto-prepend 0x — viem requires it but private keys are not typically stored with it
62
+ const privateKey = rawKey.startsWith('0x')
63
+ ? rawKey
64
+ : `0x${rawKey}`;
65
+ const account = privateKeyToAccount(privateKey);
66
+ // The gateway advertises BOTH x402 (Payment-Required header) and MPP
67
+ // (WWW-Authenticate: Payment) on every 402. mppx's HTTP transport eagerly
68
+ // parses the x402 header too, and its x402 decoder can't read the gateway's
69
+ // (coinbase-style) Payment-Required header — it throws before the MPP
70
+ // challenge is ever used. Strip Payment-Required from 402s so mppx only sees
71
+ // the MPP challenge; the x402 rail is handled separately by x402.ts.
72
+ const stripX402Fetch = async (input, init) => {
73
+ const res = await fetch(input, init);
74
+ if (res.status === 402 && res.headers.has('payment-required')) {
75
+ const headers = new Headers(res.headers);
76
+ headers.delete('payment-required');
77
+ return new Response(res.body, { status: res.status, statusText: res.statusText, headers });
78
+ }
79
+ return res;
80
+ };
81
+ // --- charge method (per-call payment) ---
82
+ // Register only the `charge` intent so this fetch always pays per-call (the
83
+ // bare `tempo()` factory would also register the session intent). polyfill:
84
+ // false keeps globalThis.fetch untouched.
85
+ const chargeClient = Mppx.create({
86
+ methods: [tempo.charge({ account })],
87
+ polyfill: false,
88
+ fetch: stripX402Fetch,
89
+ });
90
+ const chargeFetch = (input, init) => chargeClient.fetch(input, init);
91
+ // --- session method (voucher channel) ---
92
+ // Built eagerly but lazily funded: no on-chain channel opens until the first
93
+ // paid request is made while in session mode. The manager needs a viem client
94
+ // (Tempo chain + RPC) to open/settle the channel. If construction fails, fall
95
+ // back to charge-only rather than crashing the MCP.
96
+ //
97
+ // We use the LEGACY session manager: the gateway (tempoxyz/mpp-go) emits v1
98
+ // session challenges (no `sessionProtocol` marker), which mppx's current
99
+ // `tempo.session.manager` rejects (it requires sessionProtocol v2). The
100
+ // legacy manager accepts `sessionProtocol` undefined|v1. Switch to the v2
101
+ // manager once the gateway advertises sessionProtocol v2.
102
+ let session;
103
+ try {
104
+ const sessionClient = createPublicClient({
105
+ chain: tempoChain,
106
+ transport: http(process.env.MPP_RPC_URL?.trim() || undefined),
107
+ });
108
+ // (Re)construct the manager + standalone close method for a brand-new
109
+ // channel. Called once here and again by reclaimMppSession after a close,
110
+ // so the next mpp-session call opens a fresh channel rather than reusing the
111
+ // closed one (the legacy manager has no reset). maxDeposit() is read live so
112
+ // a cap changed via 1s_batch_config applies to the next channel.
113
+ _rebuildSession = () => {
114
+ _sessionManager = sessionLegacyManager({
115
+ account,
116
+ client: sessionClient,
117
+ maxDeposit: maxDeposit(),
118
+ fetch: stripX402Fetch,
119
+ });
120
+ // A standalone legacy session method (same account/client) used to sign
121
+ // our own close credential — see closeMppSession for why. The method
122
+ // factory takes `getClient` (the `client` shorthand is manager-only).
123
+ _sessionMethod = sessionLegacy({ account, getClient: () => sessionClient });
124
+ _sessionFetchImpl = stripX402Fetch;
125
+ // A rebuilt channel has no captured request yet.
126
+ _lastSessionUrl = undefined;
127
+ _lastSessionChallenge = undefined;
128
+ };
129
+ _rebuildSession();
130
+ // Reads `_sessionManager` live (not a captured const) so a post-reclaim
131
+ // rebuild routes through the new manager. Captures the last session
132
+ // request's URL + parsed challenge so a close can target the right endpoint
133
+ // and bind to a valid challenge.
134
+ const sessionFetch = async (input, init) => {
135
+ const mgr = _sessionManager;
136
+ if (!mgr)
137
+ throw new Error('MPP session manager not initialised');
138
+ const res = await mgr.fetch(input, init);
139
+ _lastSessionUrl = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
140
+ const challenge = res.challenge;
141
+ if (challenge)
142
+ _lastSessionChallenge = challenge;
143
+ return res;
144
+ };
145
+ _sessionAvailable = true;
146
+ session = { fetch: sessionFetch, available: true };
147
+ }
148
+ catch (err) {
149
+ _sessionAvailable = false;
150
+ _sessionManager = undefined;
151
+ _rebuildSession = undefined;
152
+ console.error(`[onesource-api] warning: MPP session channel unavailable (${err instanceof Error ? err.message : String(err)}); falling back to charge-only`);
153
+ }
154
+ _enabled = true;
155
+ _address = account.address;
156
+ _applied = true;
157
+ _cachedResult = {
158
+ enabled: true,
159
+ address: account.address,
160
+ chargeFetch,
161
+ ...(session ? { session } : {}),
162
+ };
163
+ return _cachedResult;
164
+ }
165
+ /** Whether MPP payment is active (MPP_PRIVATE_KEY set). */
166
+ export function isMppEnabled() {
167
+ return _enabled;
168
+ }
169
+ /** Payer wallet address, when enabled. */
170
+ export function getMppAddress() {
171
+ return _address;
172
+ }
173
+ /** Whether the session channel scheme initialised and can be selected. */
174
+ export function isMppSessionAvailable() {
175
+ return _sessionAvailable;
176
+ }
177
+ /** Whether an MPP voucher channel is currently open on-chain. */
178
+ export function isMppSessionOpen() {
179
+ return Boolean(_sessionManager?.opened);
180
+ }
181
+ /** Whether an open channel is ready to be settled (open + close machinery captured). */
182
+ function closeReady() {
183
+ return Boolean(_sessionManager?.opened && _sessionMethod && _sessionFetchImpl && _lastSessionUrl && _lastSessionChallenge);
184
+ }
185
+ /**
186
+ * Sign and POST our own close credential for the currently-open channel,
187
+ * settling the latest authorized spend on-chain and reclaiming the unspent
188
+ * deposit to the payer wallet. Caller must ensure {@link closeReady}; throws on
189
+ * gateway rejection.
190
+ *
191
+ * We do NOT use `manager.close()`: mppx's legacy manager signs the close at its
192
+ * locally-tracked `spent`, which it derives from the receipt `spent` field. The
193
+ * gateway (mpp-go) reports `spent` as the per-call delta and the running total
194
+ * in `acceptedCumulative`, so mppx's `spent` never advances past the first
195
+ * voucher and the close is rejected ("close cumulativeAmount … below the last
196
+ * accepted voucher"). Instead we sign our own close credential at the manager's
197
+ * `cumulative` (the total we authorized and the gateway accepted) and POST it —
198
+ * validated end-to-end against the live gateway. Track the upstream fix at
199
+ * wevm/mppx; switch back to `manager.close()` once it uses `acceptedCumulative`.
200
+ */
201
+ async function postCloseCredential() {
202
+ const mgr = _sessionManager;
203
+ const credential = await _sessionMethod.createCredential({
204
+ challenge: _lastSessionChallenge,
205
+ context: {
206
+ action: 'close',
207
+ channelId: mgr.channelId,
208
+ cumulativeAmountRaw: mgr.cumulative.toString(),
209
+ },
210
+ });
211
+ const res = await _sessionFetchImpl(_lastSessionUrl, {
212
+ method: 'POST',
213
+ headers: { Authorization: credential },
214
+ });
215
+ if (!res.ok) {
216
+ const body = await res.text().catch(() => '');
217
+ throw new Error(`gateway returned ${res.status}${body ? `: ${body.slice(0, 160)}` : ''}`);
218
+ }
219
+ }
220
+ /**
221
+ * Cooperatively close the active MPP voucher channel on shutdown. Safe to call
222
+ * when no channel was ever opened (no-op) and idempotent. Swallows errors so a
223
+ * stuck settle can't hang shutdown. Terminal — does not re-open the channel
224
+ * (use {@link reclaimMppSession} for the in-session reclaim that re-opens).
225
+ */
226
+ export async function closeMppSession() {
227
+ if (_sessionClosed)
228
+ return;
229
+ _sessionClosed = true;
230
+ if (!closeReady())
231
+ return;
232
+ try {
233
+ await postCloseCredential();
234
+ }
235
+ catch (err) {
236
+ console.error(`[onesource-api] warning: MPP session close failed (${err instanceof Error ? err.message : String(err)}); unspent deposit is reclaimable later on-chain`);
237
+ }
238
+ }
239
+ /**
240
+ * Reclaim the unspent deposit of the open MPP voucher channel back to the payer
241
+ * wallet, then re-arm the session so the next mpp-session call opens a fresh
242
+ * channel. This is the MPP analog of x402's `refundBatchChannel` and backs the
243
+ * `1s_refund` tool's MPP branch.
244
+ *
245
+ * Unlike {@link closeMppSession} (terminal, shutdown-only), this rebuilds the
246
+ * legacy session manager after settling so the rail stays usable in-session.
247
+ * Returns a structured result rather than throwing, so the calling tool can
248
+ * surface a clear message for the "nothing to reclaim" / failure cases.
249
+ */
250
+ export async function reclaimMppSession() {
251
+ if (!_enabled) {
252
+ return { ok: false, message: 'MPP payment is not active in this session (set MPP_PRIVATE_KEY to a funded Tempo wallet).' };
253
+ }
254
+ if (!_sessionAvailable) {
255
+ return { ok: false, message: 'MPP session channels are unavailable in this session, so there is nothing to reclaim.' };
256
+ }
257
+ if (!closeReady()) {
258
+ return {
259
+ ok: false,
260
+ message: 'No open MPP voucher channel — nothing to reclaim. A channel opens on your first call in mpp-session mode (1s_payment_mode → mpp-session).',
261
+ };
262
+ }
263
+ try {
264
+ await postCloseCredential();
265
+ }
266
+ catch (err) {
267
+ const raw = err instanceof Error ? err.message : String(err);
268
+ return {
269
+ ok: false,
270
+ message: `Reclaim failed: ${raw}. The unspent deposit remains reclaimable later on-chain.`,
271
+ };
272
+ }
273
+ // Re-arm: rebuild the manager so a later mpp-session call opens a new channel,
274
+ // and clear the shutdown latch so closeMppSession can still settle that one.
275
+ _rebuildSession?.();
276
+ _sessionClosed = false;
277
+ return {
278
+ ok: true,
279
+ message: `MPP voucher channel closed and settled. Unspent deposit is being returned to ${_address ?? 'your wallet'} on Tempo. ` +
280
+ 'A fresh channel will open on your next mpp-session call.',
281
+ };
282
+ }
283
+ /** @internal -- for test teardown only */
284
+ export function resetMpp() {
285
+ _applied = false;
286
+ _cachedResult = undefined;
287
+ _enabled = false;
288
+ _address = undefined;
289
+ _sessionAvailable = false;
290
+ _sessionManager = undefined;
291
+ _sessionMethod = undefined;
292
+ _sessionFetchImpl = undefined;
293
+ _lastSessionUrl = undefined;
294
+ _lastSessionChallenge = undefined;
295
+ _sessionClosed = false;
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AG,2DAA2D;SAC3F,CAAC;IACJ,CAAC;IACD,+EAA+E;IAC/E,6EAA6E;IAC7E,eAAe,EAAE,EAAE,CAAC;IACpB,cAAc,GAAG,KAAK,CAAC;IACvB,OAAO;QACL,EAAE,EAAE,IAAI;QACR,OAAO,EACL,gFAAgF,QAAQ,IAAI,aAAa,aAAa;YACtH,0DAA0D;KAC7D,CAAC;AACJ,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,QAAQ;IACtB,QAAQ,GAAG,KAAK,CAAC;IACjB,aAAa,GAAG,SAAS,CAAC;IAC1B,QAAQ,GAAG,KAAK,CAAC;IACjB,QAAQ,GAAG,SAAS,CAAC;IACrB,iBAAiB,GAAG,KAAK,CAAC;IAC1B,eAAe,GAAG,SAAS,CAAC;IAC5B,cAAc,GAAG,SAAS,CAAC;IAC3B,iBAAiB,GAAG,SAAS,CAAC;IAC9B,eAAe,GAAG,SAAS,CAAC;IAC5B,qBAAqB,GAAG,SAAS,CAAC;IAClC,cAAc,GAAG,KAAK,CAAC;IACvB,eAAe,GAAG,SAAS,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,48 @@
1
+ export type PaymentRailMode = 'x402-exact' | 'x402-batch' | 'mpp-charge' | 'mpp-session';
2
+ export type AuthMethod = 'x402' | 'mpp' | 'none';
3
+ export interface PaymentSetupResult {
4
+ /** Whether any payment rail is active (a wallet key is set). */
5
+ enabled: boolean;
6
+ /** Primary rail, for analytics / wallet-id reporting. */
7
+ authMethod: AuthMethod;
8
+ x402Address?: string;
9
+ mppAddress?: string;
10
+ /** Unified dispatch fetch, present when a rail is enabled. */
11
+ fetch?: typeof globalThis.fetch;
12
+ }
13
+ export interface PaymentModeInfo {
14
+ /** Whether any payment rail is active. */
15
+ enabled: boolean;
16
+ /** Current active rail+mode. */
17
+ mode: PaymentRailMode;
18
+ x402: {
19
+ enabled: boolean;
20
+ address?: string;
21
+ batchAvailable: boolean;
22
+ };
23
+ mpp: {
24
+ enabled: boolean;
25
+ address?: string;
26
+ sessionAvailable: boolean;
27
+ };
28
+ /** Modes that can be switched to right now (their rail is enabled/available). */
29
+ availableModes: PaymentRailMode[];
30
+ }
31
+ export declare function setupPayments(): PaymentSetupResult;
32
+ /** Current active rail+mode. */
33
+ export declare function getPaymentMode(): PaymentRailMode;
34
+ /**
35
+ * Switch the active rail+mode for subsequent calls. No-op (returns the unchanged
36
+ * mode) when the target rail's key isn't set or its sub-mode is unavailable
37
+ * (x402 batch scheme failed to init, or MPP session channel failed to init).
38
+ */
39
+ export declare function setPaymentMode(mode: PaymentRailMode): PaymentRailMode;
40
+ /** Snapshot of unified payment state for the 1s_payment_mode tool. */
41
+ export declare function getPaymentModeInfo(): PaymentModeInfo;
42
+ /**
43
+ * Settle and reclaim any open MPP voucher channel. Called on shutdown; no-op
44
+ * for the x402 rail (its batch residual is reclaimed via 1s_refund or the
45
+ * gateway's idle auto-refund). Idempotent.
46
+ */
47
+ export declare function closePaymentSession(): Promise<void>;
48
+ //# sourceMappingURL=payment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AA4BA,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,YAAY,GAAG,YAAY,GAAG,aAAa,CAAC;AAEzF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IACjC,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,gCAAgC;IAChC,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,OAAO,CAAA;KAAE,CAAC;IACtE,GAAG,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,OAAO,CAAA;KAAE,CAAC;IACvE,iFAAiF;IACjF,cAAc,EAAE,eAAe,EAAE,CAAC;CACnC;AA6BD,wBAAgB,aAAa,IAAI,kBAAkB,CA0ClD;AAED,gCAAgC;AAChC,wBAAgB,cAAc,IAAI,eAAe,CAEhD;AAgBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,eAAe,CAwBrE;AAED,sEAAsE;AACtE,wBAAgB,kBAAkB,IAAI,eAAe,CASpD;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEzD"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Unified payment orchestrator.
3
+ *
4
+ * The MCP can pay the gateway over two rails, each with two sub-modes:
5
+ * - x402 (USDC on Base): `x402-exact` | `x402-batch`
6
+ * - MPP (Tempo USDC.e /pathUSD): `mpp-charge` | `mpp-session`
7
+ *
8
+ * This module owns the single active mode and returns ONE dispatch fetch that
9
+ * routes each request to the matching rail's payment-aware fetch. The
10
+ * `1s_payment_mode` tool flips the mode in-session via {@link setPaymentMode}.
11
+ *
12
+ * The per-rail wiring lives in x402.ts and mpp.ts; this file only composes them
13
+ * and holds the unified selector, so the money-critical x402 path stays
14
+ * isolated and unchanged.
15
+ */
16
+ import { setupX402, setPaymentMode as setX402Mode, getPaymentModeInfo as getX402Info, } from './x402.js';
17
+ import { setupMpp, isMppEnabled, getMppAddress, isMppSessionAvailable, closeMppSession, } from './mpp.js';
18
+ let _applied = false;
19
+ let _cachedResult;
20
+ let _mode = 'x402-exact';
21
+ let _x402Fetch;
22
+ let _mppChargeFetch;
23
+ let _mppSessionFetch;
24
+ // Resolve the initial unified mode. Precedence: ONESOURCE_PAYMENT_MODE (if its
25
+ // rail is enabled) > x402 (key present, X402_PAYMENT_MODE picks the sub-mode) >
26
+ // mpp (MPP_PAYMENT_MODE picks the sub-mode). When both keys are set, x402 is the
27
+ // initial primary — both rails stay switchable via setPaymentMode.
28
+ function initialMode(x402Enabled, mppEnabled) {
29
+ const all = ['x402-exact', 'x402-batch', 'mpp-charge', 'mpp-session'];
30
+ const requested = process.env.ONESOURCE_PAYMENT_MODE?.trim().toLowerCase();
31
+ if (requested && all.includes(requested)) {
32
+ if (requested.startsWith('x402-') && x402Enabled)
33
+ return requested;
34
+ if (requested.startsWith('mpp-') && mppEnabled)
35
+ return requested;
36
+ }
37
+ if (x402Enabled) {
38
+ return process.env.X402_PAYMENT_MODE?.trim().toLowerCase() === 'batch' ? 'x402-batch' : 'x402-exact';
39
+ }
40
+ if (mppEnabled) {
41
+ return process.env.MPP_PAYMENT_MODE?.trim().toLowerCase() === 'session' ? 'mpp-session' : 'mpp-charge';
42
+ }
43
+ return 'x402-exact';
44
+ }
45
+ export function setupPayments() {
46
+ if (_applied && _cachedResult)
47
+ return _cachedResult;
48
+ const x402 = setupX402();
49
+ const mpp = setupMpp();
50
+ _x402Fetch = x402.enabled ? x402.fetch : undefined;
51
+ _mppChargeFetch = mpp.enabled ? mpp.chargeFetch : undefined;
52
+ _mppSessionFetch = mpp.enabled ? mpp.session?.fetch : undefined;
53
+ const enabled = Boolean(x402.enabled || mpp.enabled);
54
+ const authMethod = x402.enabled ? 'x402' : mpp.enabled ? 'mpp' : 'none';
55
+ _mode = initialMode(x402.enabled, mpp.enabled);
56
+ // Keep x402's internal scheme in sync with the unified mode at startup.
57
+ if (_mode === 'x402-batch')
58
+ setX402Mode('batch');
59
+ else if (_mode === 'x402-exact')
60
+ setX402Mode('exact');
61
+ // Dispatcher: route each request through the active rail's fetch. Reads
62
+ // `_mode` live so in-session switches take effect immediately. Falls back to
63
+ // any enabled fetch if the active one is somehow missing (defensive).
64
+ const dispatchFetch = (input, init) => {
65
+ const active = _mode === 'mpp-charge'
66
+ ? _mppChargeFetch
67
+ : _mode === 'mpp-session'
68
+ ? _mppSessionFetch
69
+ : _x402Fetch;
70
+ const f = active ?? _x402Fetch ?? _mppChargeFetch ?? _mppSessionFetch;
71
+ if (!f)
72
+ return fetch(input, init);
73
+ return f(input, init);
74
+ };
75
+ _applied = true;
76
+ _cachedResult = {
77
+ enabled,
78
+ authMethod,
79
+ ...(x402.address ? { x402Address: x402.address } : {}),
80
+ ...(mpp.address ? { mppAddress: mpp.address } : {}),
81
+ ...(enabled ? { fetch: dispatchFetch } : {}),
82
+ };
83
+ return _cachedResult;
84
+ }
85
+ /** Current active rail+mode. */
86
+ export function getPaymentMode() {
87
+ return _mode;
88
+ }
89
+ function availableModes() {
90
+ const modes = [];
91
+ const x = getX402Info();
92
+ if (x.enabled) {
93
+ modes.push('x402-exact');
94
+ if (x.batchAvailable)
95
+ modes.push('x402-batch');
96
+ }
97
+ if (isMppEnabled()) {
98
+ modes.push('mpp-charge');
99
+ if (isMppSessionAvailable())
100
+ modes.push('mpp-session');
101
+ }
102
+ return modes;
103
+ }
104
+ /**
105
+ * Switch the active rail+mode for subsequent calls. No-op (returns the unchanged
106
+ * mode) when the target rail's key isn't set or its sub-mode is unavailable
107
+ * (x402 batch scheme failed to init, or MPP session channel failed to init).
108
+ */
109
+ export function setPaymentMode(mode) {
110
+ const x = getX402Info();
111
+ switch (mode) {
112
+ case 'x402-exact':
113
+ if (!x.enabled)
114
+ return _mode;
115
+ setX402Mode('exact');
116
+ _mode = 'x402-exact';
117
+ return _mode;
118
+ case 'x402-batch':
119
+ if (!x.enabled || !x.batchAvailable)
120
+ return _mode;
121
+ setX402Mode('batch');
122
+ _mode = 'x402-batch';
123
+ return _mode;
124
+ case 'mpp-charge':
125
+ if (!isMppEnabled())
126
+ return _mode;
127
+ _mode = 'mpp-charge';
128
+ return _mode;
129
+ case 'mpp-session':
130
+ if (!isMppEnabled() || !isMppSessionAvailable())
131
+ return _mode;
132
+ _mode = 'mpp-session';
133
+ return _mode;
134
+ default:
135
+ return _mode;
136
+ }
137
+ }
138
+ /** Snapshot of unified payment state for the 1s_payment_mode tool. */
139
+ export function getPaymentModeInfo() {
140
+ const x = getX402Info();
141
+ return {
142
+ enabled: x.enabled || isMppEnabled(),
143
+ mode: _mode,
144
+ x402: { enabled: x.enabled, address: x.address, batchAvailable: x.batchAvailable },
145
+ mpp: { enabled: isMppEnabled(), address: getMppAddress(), sessionAvailable: isMppSessionAvailable() },
146
+ availableModes: availableModes(),
147
+ };
148
+ }
149
+ /**
150
+ * Settle and reclaim any open MPP voucher channel. Called on shutdown; no-op
151
+ * for the x402 rail (its batch residual is reclaimed via 1s_refund or the
152
+ * gateway's idle auto-refund). Idempotent.
153
+ */
154
+ export async function closePaymentSession() {
155
+ await closeMppSession();
156
+ }
157
+ /** @internal -- for test teardown only */
158
+ export function resetPayments() {
159
+ _applied = false;
160
+ _cachedResult = undefined;
161
+ _mode = 'x402-exact';
162
+ _x402Fetch = undefined;
163
+ _mppChargeFetch = undefined;
164
+ _mppSessionFetch = undefined;
165
+ }
166
+ //# sourceMappingURL=payment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment.js","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,SAAS,EACT,cAAc,IAAI,WAAW,EAC7B,kBAAkB,IAAI,WAAW,GAClC,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,eAAe,GAChB,MAAM,UAAU,CAAC;AA4BlB,IAAI,QAAQ,GAAG,KAAK,CAAC;AACrB,IAAI,aAA6C,CAAC;AAClD,IAAI,KAAK,GAAoB,YAAY,CAAC;AAC1C,IAAI,UAA+C,CAAC;AACpD,IAAI,eAAoD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KAAK,CAAC;IACjB,aAAa,GAAG,SAAS,CAAC;IAC1B,KAAK,GAAG,YAAY,CAAC;IACrB,UAAU,GAAG,SAAS,CAAC;IACvB,eAAe,GAAG,SAAS,CAAC;IAC5B,gBAAgB,GAAG,SAAS,CAAC;AAC/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"payment-mode.d.ts","sourceRoot":"","sources":["../../../src/tools/chain/payment-mode.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAoB9C,eAAO,MAAM,IAAI,EAAE,OA2ClB,CAAC"}
1
+ {"version":3,"file":"payment-mode.d.ts","sourceRoot":"","sources":["../../../src/tools/chain/payment-mode.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAoC9C,eAAO,MAAM,IAAI,EAAE,OAuElB,CAAC"}