@compose-market/sdk 0.1.1 → 0.2.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/LICENSE +21 -0
  3. package/README.md +158 -35
  4. package/dist/errors.d.ts +145 -0
  5. package/dist/errors.d.ts.map +1 -0
  6. package/dist/errors.js +152 -0
  7. package/dist/errors.js.map +1 -0
  8. package/dist/http.d.ts +98 -0
  9. package/dist/http.d.ts.map +1 -0
  10. package/dist/http.js +350 -0
  11. package/dist/http.js.map +1 -0
  12. package/dist/index.d.ts +104 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +137 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/resources/inference.d.ts +161 -0
  17. package/dist/resources/inference.d.ts.map +1 -0
  18. package/dist/resources/inference.js +710 -0
  19. package/dist/resources/inference.js.map +1 -0
  20. package/dist/resources/keys.d.ts +50 -0
  21. package/dist/resources/keys.d.ts.map +1 -0
  22. package/dist/resources/keys.js +154 -0
  23. package/dist/resources/keys.js.map +1 -0
  24. package/dist/resources/models.d.ts +26 -0
  25. package/dist/resources/models.d.ts.map +1 -0
  26. package/dist/resources/models.js +52 -0
  27. package/dist/resources/models.js.map +1 -0
  28. package/dist/resources/webhooks.d.ts +27 -0
  29. package/dist/resources/webhooks.d.ts.map +1 -0
  30. package/dist/resources/webhooks.js +78 -0
  31. package/dist/resources/webhooks.js.map +1 -0
  32. package/dist/resources/x402.d.ts +37 -0
  33. package/dist/resources/x402.d.ts.map +1 -0
  34. package/dist/resources/x402.js +72 -0
  35. package/dist/resources/x402.js.map +1 -0
  36. package/dist/streaming/receipt.d.ts +25 -0
  37. package/dist/streaming/receipt.d.ts.map +1 -0
  38. package/dist/streaming/receipt.js +92 -0
  39. package/dist/streaming/receipt.js.map +1 -0
  40. package/dist/streaming/sse.d.ts +29 -0
  41. package/dist/streaming/sse.d.ts.map +1 -0
  42. package/dist/streaming/sse.js +125 -0
  43. package/dist/streaming/sse.js.map +1 -0
  44. package/dist/types/index.d.ts +497 -0
  45. package/dist/types/index.d.ts.map +1 -0
  46. package/dist/types/index.js +10 -0
  47. package/dist/types/index.js.map +1 -0
  48. package/package.json +30 -20
  49. package/index.d.ts +0 -244
  50. package/index.js +0 -397
package/dist/index.js ADDED
@@ -0,0 +1,137 @@
1
+ /**
2
+ * `@compose-market/sdk` — Official SDK for Compose Market.
3
+ *
4
+ * Exposes the canonical header contract (`Authorization: Bearer compose-<jwt>`,
5
+ * `x-session-user-address`, `x-chain-id`) that powers Compose's first-party
6
+ * apps (web/, mesh/) and lets any third-party integrator embed:
7
+ *
8
+ * - Compose Key lifecycle (create / list / get / revoke, session metadata)
9
+ * - 45k+ model catalog (list / listAll / search / get / getParams)
10
+ * - OpenAI-shaped inference (chat.completions, responses, embeddings, images,
11
+ * audio.speech, audio.transcriptions, videos) with full SSE streaming and
12
+ * typed tool-call deltas + reasoning deltas.
13
+ * - x402 facilitator access (supported / chains / verify / settle) and typed
14
+ * decoders for PAYMENT-REQUIRED, PAYMENT-RESPONSE, X-Compose-Receipt.
15
+ * - Webhook signature verification (HMAC-SHA256, Stripe-style header).
16
+ *
17
+ * Design:
18
+ * - Zero runtime dependencies. Uses platform `fetch`, WebCrypto, TextDecoder,
19
+ * ReadableStream. Works in Node 20+, Bun, Deno, Cloudflare Workers, browsers.
20
+ * - Identity is whatever the integrator already has. The SDK does NOT call a
21
+ * wallet, does NOT request signatures, does NOT run KYC. The end-user's
22
+ * wallet address — produced by whatever auth stack the integrator already
23
+ * uses — is trusted in the same exact way our first-party apps trust it —
24
+ * via the `x-session-user-address` header. The Compose Key JWT returned by
25
+ * `keys.create(...)` is the real cryptographic identity from that point on.
26
+ * - Every billable call returns a `ComposeCompletion<T>` carrying the parsed
27
+ * body, the settlement receipt (if any), the request id, and the raw
28
+ * Response so integrators can read non-standard headers without parsing.
29
+ */
30
+ import { HttpClient } from "./http.js";
31
+ import { KeysResource } from "./resources/keys.js";
32
+ import { ModelsResource } from "./resources/models.js";
33
+ import { InferenceResource } from "./resources/inference.js";
34
+ import { X402Resource } from "./resources/x402.js";
35
+ import { WebhooksResource } from "./resources/webhooks.js";
36
+ import { BadRequestError } from "./errors.js";
37
+ export * from "./types/index.js";
38
+ export * from "./errors.js";
39
+ export { decodeReceiptHeader, extractReceiptFromResponse, parseReceiptEvent } from "./streaming/receipt.js";
40
+ export { parseSSEStream } from "./streaming/sse.js";
41
+ export const SDK_VERSION = "1.0.0";
42
+ const DEFAULT_RETRY = {
43
+ maxRetries: 2,
44
+ initialDelayMs: 500,
45
+ maxDelayMs: 8_000,
46
+ jitter: true,
47
+ };
48
+ function normalizeBaseUrl(value) {
49
+ return (value || "https://api.compose.market").replace(/\/+$/, "");
50
+ }
51
+ function normalizeWalletAddress(value) {
52
+ const trimmed = value.trim().toLowerCase();
53
+ if (!/^0x[a-f0-9]{40}$/.test(trimmed)) {
54
+ throw new BadRequestError({ message: "userAddress must be a valid 0x-prefixed EVM address" });
55
+ }
56
+ return trimmed;
57
+ }
58
+ function normalizeChainId(value) {
59
+ if (value === undefined || value === null)
60
+ return null;
61
+ if (!Number.isInteger(value) || value <= 0) {
62
+ throw new BadRequestError({ message: "chainId must be a positive integer" });
63
+ }
64
+ return value;
65
+ }
66
+ export class ComposeSDK {
67
+ keys;
68
+ models;
69
+ inference;
70
+ x402;
71
+ webhooks;
72
+ wallets;
73
+ http;
74
+ walletAddress;
75
+ chainId;
76
+ composeKey;
77
+ constructor(options = {}) {
78
+ this.walletAddress = options.userAddress ? normalizeWalletAddress(options.userAddress) : null;
79
+ this.chainId = normalizeChainId(options.chainId);
80
+ this.composeKey = options.composeKey ?? null;
81
+ const userAgent = options.userAgent
82
+ ? `@compose-market/sdk/${SDK_VERSION} ${options.userAgent}`
83
+ : `@compose-market/sdk/${SDK_VERSION}`;
84
+ this.http = new HttpClient({
85
+ baseUrl: normalizeBaseUrl(options.baseUrl),
86
+ fetch: options.fetch ?? globalThis.fetch.bind(globalThis),
87
+ timeoutMs: options.timeoutMs ?? 60_000,
88
+ defaultHeaders: { ...(options.defaultHeaders ?? {}) },
89
+ retry: { ...DEFAULT_RETRY, ...(options.retry ?? {}) },
90
+ userAgent,
91
+ logger: options.logger,
92
+ });
93
+ this.wallets = {
94
+ attach: (input) => {
95
+ this.walletAddress = normalizeWalletAddress(input.address);
96
+ this.chainId = normalizeChainId(input.chainId);
97
+ },
98
+ current: () => ({ address: this.walletAddress, chainId: this.chainId }),
99
+ clear: () => {
100
+ this.walletAddress = null;
101
+ this.chainId = null;
102
+ },
103
+ };
104
+ const getWallet = () => {
105
+ if (!this.walletAddress) {
106
+ throw new BadRequestError({
107
+ message: "Wallet context is required. Call sdk.wallets.attach({ address, chainId }) first, or pass userAddress + chainId to the constructor.",
108
+ });
109
+ }
110
+ if (this.chainId === null) {
111
+ throw new BadRequestError({
112
+ message: "chainId is required. Call sdk.wallets.attach(...) or pass chainId to the constructor.",
113
+ });
114
+ }
115
+ return { address: this.walletAddress, chainId: this.chainId };
116
+ };
117
+ const getWalletMaybe = () => ({
118
+ address: this.walletAddress,
119
+ chainId: this.chainId,
120
+ });
121
+ this.keys = new KeysResource(this.http, {
122
+ getWallet,
123
+ setToken: (token) => { this.composeKey = token; },
124
+ getToken: () => this.composeKey,
125
+ clearToken: () => { this.composeKey = null; },
126
+ });
127
+ this.models = new ModelsResource(this.http);
128
+ this.inference = new InferenceResource(this.http, {
129
+ getWalletMaybe,
130
+ getTokenMaybe: () => this.composeKey,
131
+ });
132
+ this.x402 = new X402Resource(this.http);
133
+ this.webhooks = new WebhooksResource();
134
+ }
135
+ }
136
+ export default ComposeSDK;
137
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAA4D,MAAM,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I,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE;YACpC,SAAS;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC;YACjD,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU;YAC/B,UAAU,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC;SAChD,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE;YAC9C,cAAc;YACd,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU;SACvC,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC;IAC3C,CAAC;CACJ;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,161 @@
1
+ import type { HttpClient } from "../http.js";
2
+ import type { AudioSpeechCreateParams, AudioTranscriptionCreateParams, AudioTranscriptionResponse, ChatCompletion, ChatCompletionChunk, ChatCompletionsCreateParams, ComposeReceipt, EmbeddingsCreateParams, EmbeddingsResponse, ImagesGenerateParams, ImagesResponse, ResponseObject, ResponseStreamEvent, ResponsesCreateParams, VideoGenerateParams, VideoJobStatus, VideoStatusStreamEvent } from "../types/index.js";
3
+ export interface ComposeCallOptions {
4
+ signal?: AbortSignal;
5
+ timeoutMs?: number;
6
+ idempotencyKey?: string;
7
+ composeRunId?: string;
8
+ x402MaxAmountWei?: string;
9
+ paymentSignature?: string;
10
+ /** Override the Compose Key for this call. Passing `null` forces the raw x402 path. */
11
+ composeKey?: string | null;
12
+ /** Override the end-user wallet address for this call. */
13
+ walletAddress?: string;
14
+ /** Override the chain id for this call. */
15
+ chainId?: number;
16
+ }
17
+ export interface ComposeCompletion<T> {
18
+ /** The parsed JSON body for the completed call. */
19
+ data: T;
20
+ /** Settlement receipt, if the call was billable and settled successfully. */
21
+ receipt: ComposeReceipt | null;
22
+ /** The request id the server assigned (or echoed) for this call. */
23
+ requestId: string | null;
24
+ /** The raw Response — useful to inspect non-standard headers. */
25
+ response: Response;
26
+ }
27
+ export interface ChatCompletionFinalResult {
28
+ chatCompletion: ChatCompletion;
29
+ receipt: ComposeReceipt | null;
30
+ requestId: string | null;
31
+ }
32
+ export interface ResponsesStreamFinalResult {
33
+ response: ResponseObject | null;
34
+ receipt: ComposeReceipt | null;
35
+ requestId: string | null;
36
+ }
37
+ interface InferenceContext {
38
+ getWalletMaybe(): {
39
+ address: string | null;
40
+ chainId: number | null;
41
+ };
42
+ getTokenMaybe(): string | null;
43
+ }
44
+ /**
45
+ * Async iterable returned by `inference.chat.completions.stream(...)` and
46
+ * `inference.responses.stream(...)`. Exposes `.final()` for consumers that
47
+ * want the reassembled final object + receipt without iterating manually.
48
+ *
49
+ * `for await (const chunk of stream) { ... }` consumes chunks; the generator's
50
+ * return value is captured internally so a subsequent `await stream.final()`
51
+ * resolves to the typed final object even when the caller drove iteration.
52
+ */
53
+ export declare class ComposeStreamIterator<Chunk, Final> implements AsyncIterable<Chunk> {
54
+ private readonly iterator;
55
+ private finalResult;
56
+ private finalSettled;
57
+ private finalPromise;
58
+ constructor(iterator: AsyncGenerator<Chunk, Final, void>);
59
+ [Symbol.asyncIterator](): AsyncIterator<Chunk, void, void>;
60
+ final(): Promise<Final>;
61
+ }
62
+ declare class ChatCompletionsNamespace {
63
+ private readonly client;
64
+ private readonly ctx;
65
+ constructor(client: HttpClient, ctx: InferenceContext);
66
+ create(params: ChatCompletionsCreateParams, options?: ComposeCallOptions): Promise<ComposeCompletion<ChatCompletion>>;
67
+ stream(params: ChatCompletionsCreateParams, options?: ComposeCallOptions): ComposeStreamIterator<ChatCompletionChunk, ChatCompletionFinalResult>;
68
+ }
69
+ declare class ResponsesNamespace {
70
+ private readonly client;
71
+ private readonly ctx;
72
+ constructor(client: HttpClient, ctx: InferenceContext);
73
+ create(params: ResponsesCreateParams, options?: ComposeCallOptions): Promise<ComposeCompletion<ResponseObject>>;
74
+ stream(params: ResponsesCreateParams, options?: ComposeCallOptions): ComposeStreamIterator<ResponseStreamEvent, ResponsesStreamFinalResult>;
75
+ get(responseId: string, options?: ComposeCallOptions): Promise<ResponseObject>;
76
+ inputItems(responseId: string, options?: ComposeCallOptions): Promise<{
77
+ object: "list";
78
+ data: Record<string, unknown>[];
79
+ }>;
80
+ cancel(responseId: string, options?: ComposeCallOptions): Promise<ResponseObject>;
81
+ }
82
+ declare class EmbeddingsNamespace {
83
+ private readonly client;
84
+ private readonly ctx;
85
+ constructor(client: HttpClient, ctx: InferenceContext);
86
+ create(params: EmbeddingsCreateParams, options?: ComposeCallOptions): Promise<ComposeCompletion<EmbeddingsResponse>>;
87
+ }
88
+ declare class ImagesNamespace {
89
+ private readonly client;
90
+ private readonly ctx;
91
+ constructor(client: HttpClient, ctx: InferenceContext);
92
+ generate(params: ImagesGenerateParams, options?: ComposeCallOptions): Promise<ComposeCompletion<ImagesResponse>>;
93
+ edit(params: ImagesGenerateParams & {
94
+ image?: string;
95
+ }, options?: ComposeCallOptions): Promise<ComposeCompletion<ImagesResponse>>;
96
+ }
97
+ declare class AudioNamespace {
98
+ private readonly client;
99
+ private readonly ctx;
100
+ constructor(client: HttpClient, ctx: InferenceContext);
101
+ /**
102
+ * Text-to-speech. Returns the raw audio `Response` (stream the body via
103
+ * `response.body` or `await response.arrayBuffer()`), plus any receipt
104
+ * extracted from response headers.
105
+ */
106
+ speech(params: AudioSpeechCreateParams, options?: ComposeCallOptions): Promise<{
107
+ response: Response;
108
+ receipt: ComposeReceipt | null;
109
+ requestId: string | null;
110
+ }>;
111
+ /**
112
+ * Speech-to-text. Supports both multipart/form-data (preferred, OpenAI-
113
+ * compatible) when `file` is a `Blob`/`File`/`Uint8Array`, and base64-in-
114
+ * JSON (Compose legacy) when `file` is a string.
115
+ */
116
+ transcriptions(params: AudioTranscriptionCreateParams, options?: ComposeCallOptions): Promise<ComposeCompletion<AudioTranscriptionResponse>>;
117
+ }
118
+ declare class VideosNamespace {
119
+ private readonly client;
120
+ private readonly ctx;
121
+ constructor(client: HttpClient, ctx: InferenceContext);
122
+ generate(params: VideoGenerateParams, options?: ComposeCallOptions): Promise<ComposeCompletion<{
123
+ job_id?: string;
124
+ id?: string;
125
+ } & Record<string, unknown>>>;
126
+ get(videoId: string, options?: ComposeCallOptions): Promise<VideoJobStatus>;
127
+ /**
128
+ * Server-driven polling via SSE. Subscribes to `/v1/videos/:id/stream`
129
+ * and yields each status update as it arrives, terminating on the
130
+ * `completed` or `failed` state.
131
+ */
132
+ stream(videoId: string, opts?: ComposeCallOptions & {
133
+ pollIntervalMs?: number;
134
+ timeoutMs?: number;
135
+ }): ComposeStreamIterator<VideoStatusStreamEvent, {
136
+ final: VideoJobStatus | null;
137
+ requestId: string | null;
138
+ }>;
139
+ /**
140
+ * Convenience helper: resolves once the video job hits a terminal state,
141
+ * driven by the server-side SSE poller. Aborts after `timeoutMs` elapses.
142
+ */
143
+ waitUntilDone(videoId: string, opts?: ComposeCallOptions & {
144
+ pollIntervalMs?: number;
145
+ timeoutMs?: number;
146
+ onStatus?: (status: VideoStatusStreamEvent) => void;
147
+ }): Promise<VideoJobStatus | null>;
148
+ }
149
+ export declare class InferenceResource {
150
+ readonly chat: {
151
+ completions: ChatCompletionsNamespace;
152
+ };
153
+ readonly responses: ResponsesNamespace;
154
+ readonly embeddings: EmbeddingsNamespace;
155
+ readonly images: ImagesNamespace;
156
+ readonly audio: AudioNamespace;
157
+ readonly videos: VideosNamespace;
158
+ constructor(client: HttpClient, ctx: InferenceContext);
159
+ }
160
+ export {};
161
+ //# sourceMappingURL=inference.d.ts.map
@@ -0,0 +1 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