@compose-market/sdk 0.1.0 → 0.1.1
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 +63 -0
- package/package.json +3 -72
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# `@compose-market/sdk`
|
|
2
|
+
|
|
3
|
+
Official Compose.Market SDK for wallet-tied Compose keys, x402 facilitator access, model discovery, and unified inference APIs.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @compose-market/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { ComposeSDK, ComposePaymentRequiredError } from "@compose-market/sdk";
|
|
15
|
+
|
|
16
|
+
const sdk = new ComposeSDK();
|
|
17
|
+
|
|
18
|
+
await sdk.wallets.attach({
|
|
19
|
+
address: "0x1234567890abcdef1234567890abcdef12345678",
|
|
20
|
+
chainId: 84532,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const session = await sdk.keys.create({
|
|
24
|
+
purpose: "session",
|
|
25
|
+
budgetUsd: 5,
|
|
26
|
+
durationHours: 2,
|
|
27
|
+
name: "demo-session",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
sdk.keys.use(session.token);
|
|
31
|
+
|
|
32
|
+
const models = await sdk.models.list();
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const response = await sdk.inference.responses.create({
|
|
36
|
+
model: "gpt-4.1-mini",
|
|
37
|
+
input: [{ type: "input_text", text: "Say hello." }],
|
|
38
|
+
modalities: ["text"],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
console.log(response);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (error instanceof ComposePaymentRequiredError) {
|
|
44
|
+
console.log(error.paymentRequired);
|
|
45
|
+
}
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Main capabilities
|
|
51
|
+
|
|
52
|
+
- Attach a wallet or smart-account context through the same header contract used by Compose.Market apps.
|
|
53
|
+
- Create, list, revoke, and activate Compose keys for both session and API usage.
|
|
54
|
+
- Discover the full model catalog, per-model parameter schemas, and pricing data.
|
|
55
|
+
- Call Compose inference endpoints through Responses, Chat Completions, Images, Audio, Embeddings, and Video APIs.
|
|
56
|
+
- Decode and work with x402 `PAYMENT-REQUIRED` negotiation details.
|
|
57
|
+
- Call Compose facilitator `supported`, `verify`, and `settle` endpoints directly.
|
|
58
|
+
|
|
59
|
+
## Notes
|
|
60
|
+
|
|
61
|
+
- The SDK is runtime-neutral and works in modern Node.js and browser environments with a standards-compliant `fetch`.
|
|
62
|
+
- The core package does not bundle a wallet SDK. External apps can attach any already-known wallet or smart-account address and chain context.
|
|
63
|
+
- Session key creation requires the tied wallet or smart account to already have enough USDC balance and allowance for the requested budget on the selected chain. If not, the SDK throws a `ComposeApiError` with status `402`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compose-market/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Official Compose.Market SDK for Compose keys, x402 facilitator access, model discovery, and inference APIs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"x402",
|
|
@@ -36,82 +36,13 @@
|
|
|
36
36
|
"index.js",
|
|
37
37
|
"index.d.ts"
|
|
38
38
|
],
|
|
39
|
+
"sideEffects": false,
|
|
39
40
|
"scripts": {
|
|
40
41
|
"clean": "rm -f index.js index.d.ts",
|
|
41
42
|
"build": "npm run clean && tsc -p tsconfig.json",
|
|
42
43
|
"test": "npm run build && node --import tsx --test tests/**/*.test.ts",
|
|
43
44
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
44
45
|
},
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"accepts": "^2.0.0",
|
|
47
|
-
"body-parser": "^2.2.2",
|
|
48
|
-
"bytes": "^3.1.2",
|
|
49
|
-
"call-bind-apply-helpers": "^1.0.2",
|
|
50
|
-
"call-bound": "^1.0.4",
|
|
51
|
-
"content-disposition": "^1.1.0",
|
|
52
|
-
"content-type": "^1.0.5",
|
|
53
|
-
"cookie": "^0.7.2",
|
|
54
|
-
"cookie-signature": "^1.2.2",
|
|
55
|
-
"debug": "^4.4.3",
|
|
56
|
-
"depd": "^2.0.0",
|
|
57
|
-
"dunder-proto": "^1.0.1",
|
|
58
|
-
"ee-first": "^1.1.1",
|
|
59
|
-
"encodeurl": "^2.0.0",
|
|
60
|
-
"es-define-property": "^1.0.1",
|
|
61
|
-
"es-errors": "^1.3.0",
|
|
62
|
-
"es-object-atoms": "^1.1.1",
|
|
63
|
-
"esbuild": "^0.27.7",
|
|
64
|
-
"escape-html": "^1.0.3",
|
|
65
|
-
"etag": "^1.8.1",
|
|
66
|
-
"finalhandler": "^2.1.1",
|
|
67
|
-
"forwarded": "^0.2.0",
|
|
68
|
-
"fresh": "^2.0.0",
|
|
69
|
-
"function-bind": "^1.1.2",
|
|
70
|
-
"get-intrinsic": "^1.3.0",
|
|
71
|
-
"get-proto": "^1.0.1",
|
|
72
|
-
"get-tsconfig": "^4.14.0",
|
|
73
|
-
"gopd": "^1.2.0",
|
|
74
|
-
"has-symbols": "^1.1.0",
|
|
75
|
-
"hasown": "^2.0.3",
|
|
76
|
-
"http-errors": "^2.0.1",
|
|
77
|
-
"iconv-lite": "^0.7.2",
|
|
78
|
-
"inherits": "^2.0.4",
|
|
79
|
-
"ipaddr.js": "^1.9.1",
|
|
80
|
-
"is-promise": "^4.0.0",
|
|
81
|
-
"math-intrinsics": "^1.1.0",
|
|
82
|
-
"media-typer": "^1.1.0",
|
|
83
|
-
"merge-descriptors": "^2.0.0",
|
|
84
|
-
"mime-db": "^1.54.0",
|
|
85
|
-
"mime-types": "^3.0.2",
|
|
86
|
-
"ms": "^2.1.3",
|
|
87
|
-
"negotiator": "^1.0.0",
|
|
88
|
-
"object-inspect": "^1.13.4",
|
|
89
|
-
"on-finished": "^2.4.1",
|
|
90
|
-
"once": "^1.4.0",
|
|
91
|
-
"parseurl": "^1.3.3",
|
|
92
|
-
"path-to-regexp": "^8.4.2",
|
|
93
|
-
"proxy-addr": "^2.0.7",
|
|
94
|
-
"qs": "^6.15.1",
|
|
95
|
-
"range-parser": "^1.2.1",
|
|
96
|
-
"raw-body": "^3.0.2",
|
|
97
|
-
"resolve-pkg-maps": "^1.0.0",
|
|
98
|
-
"router": "^2.2.0",
|
|
99
|
-
"safer-buffer": "^2.1.2",
|
|
100
|
-
"send": "^1.2.1",
|
|
101
|
-
"serve-static": "^2.2.1",
|
|
102
|
-
"setprototypeof": "^1.2.0",
|
|
103
|
-
"side-channel": "^1.1.0",
|
|
104
|
-
"side-channel-list": "^1.0.1",
|
|
105
|
-
"side-channel-map": "^1.0.1",
|
|
106
|
-
"side-channel-weakmap": "^1.0.2",
|
|
107
|
-
"statuses": "^2.0.2",
|
|
108
|
-
"toidentifier": "^1.0.1",
|
|
109
|
-
"type-is": "^2.0.1",
|
|
110
|
-
"undici-types": "^7.19.2",
|
|
111
|
-
"unpipe": "^1.0.0",
|
|
112
|
-
"vary": "^1.1.2",
|
|
113
|
-
"wrappy": "^1.0.2"
|
|
114
|
-
},
|
|
115
46
|
"devDependencies": {
|
|
116
47
|
"@types/express": "^5.0.6",
|
|
117
48
|
"@types/node": "^25.6.0",
|
|
@@ -123,4 +54,4 @@
|
|
|
123
54
|
"access": "public"
|
|
124
55
|
},
|
|
125
56
|
"module": "./index.js"
|
|
126
|
-
}
|
|
57
|
+
}
|