Files
agents-marketplace/packages/shared/src/tx/server.ts
david 6de62b8cf0 feat(gateway): OpenAI-compatible custodial gateway
New multi-tenant gateway package: external developers point any OpenAI SDK at
the marketplace. Each API key is its own custodial buyer wallet (AES-256-GCM
sealed under GATEWAY_MASTER_KEY); every request posts an on-chain escrow from
that user's wallet.

- POST /openai/v1/chat/completions (one escrow/call, llm.text.generate.v1,
  buffered + pseudo-stream), chat sessions (one escrow/session, llm.chat.v1,
  real SSE), GET /openai/v1/models, /signup, /account, /account/withdraw.
- Settles by resolving the Submitted ref via the indexer + awaited Accept;
  state-aware reclaim sweeper + per-wallet auto-consolidation for collateral.
- Reuses the buyer Marketplace SDK via new buyer exports ./sdk; new shared
  buildWithdrawTx (custodial exit). Runs via tsx; Dockerfile + mainnet compose.

Design in docs/gateway.md. Typecheck passes for all packages; 20 vitest tests
pass. Not yet exercised against a live chain.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 10:22:58 +02:00

48 lines
1.7 KiB
TypeScript

/**
* tx/server.ts — server-only re-exports.
*
* These bind the lucid-evolution + CML WASM dep graph at import time, so
* they MUST NOT be imported from anything that gets bundled by Vite (i.e.
* the buyer UI). The buyer SDK uses /* @vite-ignore *\/ dynamic imports
* to reach the live-CBOR builders for the same reason.
*
* Consumers: supplier CLIs and Node-only tx tooling.
*/
export { loadEscrowScript, loadAdvertScript } from "./internal/liveCbor.js";
export { pkhToEnterpriseAddress } from "./internal/pkhAddress.js";
export type {
LivePublishRefScriptsParams,
PublishRefScriptsBuildResult,
} from "./internal/publishReferenceScripts.js";
export { buildLiveTxForPublishReferenceScripts } from "./internal/publishReferenceScripts.js";
// ── Wallet consolidate (one-shot operational tx; live-only) ─────────────
export type {
ConsolidateWalletParams,
ConsolidateWalletBuildResult,
} from "./wallet/consolidateWallet.js";
export { buildConsolidateWalletTx } from "./wallet/consolidateWallet.js";
export type {
ConsolidateReason,
PlannedConsolidate,
UtxoLike,
} from "./wallet/planConsolidate.js";
export {
DEFAULT_COLLATERAL_LOVELACE,
DEFAULT_FEE_RESERVE,
planConsolidate,
} from "./wallet/planConsolidate.js";
export type {
ConsolidateWalletFlowParams,
ConsolidateWalletFlowResult,
} from "./wallet/runConsolidateWallet.js";
export { runConsolidateWallet } from "./wallet/runConsolidateWallet.js";
// ── Wallet withdraw (custodial exit; live-only) ─────────────────────────
export type {
WithdrawWalletParams,
WithdrawWalletBuildResult,
} from "./wallet/withdrawWallet.js";
export { buildWithdrawTx } from "./wallet/withdrawWallet.js";