@basedchef/contextkit 0.1.5 → 0.1.6
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 +82 -85
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -45,60 +45,11 @@ function
|
|
|
45
45
|
import { ContextKit } from "@basedchef/contextkit";
|
|
46
46
|
|
|
47
47
|
const client = new ContextKit({
|
|
48
|
-
apiKey: "
|
|
49
|
-
baseUrl: "https://
|
|
48
|
+
apiKey: "<CONTEXTKIT_API_KEY>",
|
|
49
|
+
baseUrl: "https://your-domain.com"
|
|
50
50
|
});
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
## API Key Credits
|
|
54
|
-
|
|
55
|
-
Paid direct endpoints use the API key owner's ContextKit credit balance first. If credits are available, no Bankr payment is needed per request.
|
|
56
|
-
|
|
57
|
-
```ts
|
|
58
|
-
const credits = await client.credits();
|
|
59
|
-
console.log(credits.balanceUsd);
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Equivalent terminal test:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
cat > credits.mjs <<'EOF'
|
|
66
|
-
import { ContextKit } from "@basedchef/contextkit";
|
|
67
|
-
|
|
68
|
-
const client = new ContextKit({
|
|
69
|
-
apiKey: "ck_live_replace_me",
|
|
70
|
-
baseUrl: "https://91.107.248.223.sslip.io"
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const result = await client.credits();
|
|
74
|
-
console.log(JSON.stringify(result, null, 2));
|
|
75
|
-
EOF
|
|
76
|
-
|
|
77
|
-
node credits.mjs
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
If the balance is too low, direct paid routes return a normal HTTP 402 x402 challenge.
|
|
81
|
-
|
|
82
|
-
## Buy Credits
|
|
83
|
-
|
|
84
|
-
Users can top up credits from the ContextKit dashboard:
|
|
85
|
-
|
|
86
|
-
1. Sign in to the dashboard.
|
|
87
|
-
2. Open `/dashboard/credits`.
|
|
88
|
-
3. Create a USDC invoice.
|
|
89
|
-
4. Send the exact USDC amount on Base to the shown wallet.
|
|
90
|
-
5. Paste the transaction hash.
|
|
91
|
-
6. ContextKit verifies the transaction and credits the account automatically.
|
|
92
|
-
|
|
93
|
-
The backend verifies:
|
|
94
|
-
|
|
95
|
-
- the transaction exists on Base,
|
|
96
|
-
- the transaction succeeded,
|
|
97
|
-
- the Base USDC contract emitted a `Transfer`,
|
|
98
|
-
- the recipient is the ContextKit wallet,
|
|
99
|
-
- the amount is at least the invoice amount,
|
|
100
|
-
- the tx hash was not already used.
|
|
101
|
-
|
|
102
53
|
## Summarize
|
|
103
54
|
|
|
104
55
|
```bash
|
|
@@ -106,8 +57,8 @@ cat > summarize.mjs <<'EOF'
|
|
|
106
57
|
import { ContextKit } from "@basedchef/contextkit";
|
|
107
58
|
|
|
108
59
|
const client = new ContextKit({
|
|
109
|
-
apiKey: "
|
|
110
|
-
baseUrl: "https://
|
|
60
|
+
apiKey: "<CONTEXTKIT_API_KEY>",
|
|
61
|
+
baseUrl: "https://your-domain.com"
|
|
111
62
|
});
|
|
112
63
|
|
|
113
64
|
const result = await client.summarize({
|
|
@@ -140,8 +91,8 @@ cat > compress.mjs <<'EOF'
|
|
|
140
91
|
import { ContextKit } from "@basedchef/contextkit";
|
|
141
92
|
|
|
142
93
|
const client = new ContextKit({
|
|
143
|
-
apiKey: "
|
|
144
|
-
baseUrl: "https://
|
|
94
|
+
apiKey: "<CONTEXTKIT_API_KEY>",
|
|
95
|
+
baseUrl: "https://your-domain.com"
|
|
145
96
|
});
|
|
146
97
|
|
|
147
98
|
const result = await client.compressContext({
|
|
@@ -166,8 +117,8 @@ cat > handoff.mjs <<'EOF'
|
|
|
166
117
|
import { ContextKit } from "@basedchef/contextkit";
|
|
167
118
|
|
|
168
119
|
const client = new ContextKit({
|
|
169
|
-
apiKey: "
|
|
170
|
-
baseUrl: "https://
|
|
120
|
+
apiKey: "<CONTEXTKIT_API_KEY>",
|
|
121
|
+
baseUrl: "https://your-domain.com"
|
|
171
122
|
});
|
|
172
123
|
|
|
173
124
|
const result = await client.handoff({
|
|
@@ -192,8 +143,8 @@ cat > profile.mjs <<'EOF'
|
|
|
192
143
|
import { ContextKit } from "@basedchef/contextkit";
|
|
193
144
|
|
|
194
145
|
const client = new ContextKit({
|
|
195
|
-
apiKey: "
|
|
196
|
-
baseUrl: "https://
|
|
146
|
+
apiKey: "<CONTEXTKIT_API_KEY>",
|
|
147
|
+
baseUrl: "https://your-domain.com"
|
|
197
148
|
});
|
|
198
149
|
|
|
199
150
|
const result = await client.extractProfile({
|
|
@@ -220,8 +171,8 @@ cat > memory.mjs <<'EOF'
|
|
|
220
171
|
import { ContextKit } from "@basedchef/contextkit";
|
|
221
172
|
|
|
222
173
|
const client = new ContextKit({
|
|
223
|
-
apiKey: "
|
|
224
|
-
baseUrl: "https://
|
|
174
|
+
apiKey: "<CONTEXTKIT_API_KEY>",
|
|
175
|
+
baseUrl: "https://your-domain.com"
|
|
225
176
|
});
|
|
226
177
|
|
|
227
178
|
const result = await client.memoryEnrichment({
|
|
@@ -246,8 +197,8 @@ cat > estimate.mjs <<'EOF'
|
|
|
246
197
|
import { ContextKit } from "@basedchef/contextkit";
|
|
247
198
|
|
|
248
199
|
const client = new ContextKit({
|
|
249
|
-
apiKey: "
|
|
250
|
-
baseUrl: "https://
|
|
200
|
+
apiKey: "<CONTEXTKIT_API_KEY>",
|
|
201
|
+
baseUrl: "https://your-domain.com"
|
|
251
202
|
});
|
|
252
203
|
|
|
253
204
|
const result = await client.estimateTokens({
|
|
@@ -273,8 +224,8 @@ If an API key has no credits, ContextKit direct paid routes return HTTP 402. Adv
|
|
|
273
224
|
|
|
274
225
|
```ts
|
|
275
226
|
const client = new ContextKit({
|
|
276
|
-
apiKey: "
|
|
277
|
-
baseUrl: "https://
|
|
227
|
+
apiKey: "<CONTEXTKIT_API_KEY>",
|
|
228
|
+
baseUrl: "https://your-domain.com",
|
|
278
229
|
x402: async (challenge, request) => {
|
|
279
230
|
return wallet.pay(challenge, request);
|
|
280
231
|
}
|
|
@@ -287,12 +238,38 @@ Most SDK integrations should instead top up credits from the dashboard and avoid
|
|
|
287
238
|
|
|
288
239
|
For simple users and autonomous agents, this is the main path:
|
|
289
240
|
|
|
241
|
+
Summarize:
|
|
242
|
+
|
|
290
243
|
```bash
|
|
291
244
|
bankr x402 call https://x402.bankr.bot/0xdace98cd605dd56b2edc66f0f4df3687f64fd824/contextkit-summarize \
|
|
292
245
|
-X POST \
|
|
293
246
|
-d '{"messages":[{"role":"user","content":"Summarize this context."}]}'
|
|
294
247
|
```
|
|
295
248
|
|
|
249
|
+
Compress context:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
bankr x402 call https://x402.bankr.bot/0xdace98cd605dd56b2edc66f0f4df3687f64fd824/contextkit-compress \
|
|
253
|
+
-X POST \
|
|
254
|
+
-d '{"messages":[{"role":"user","content":"Compress this project context into compact memory."}]}'
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Handoff:
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
bankr x402 call https://x402.bankr.bot/0xdace98cd605dd56b2edc66f0f4df3687f64fd824/contextkit-handoff \
|
|
261
|
+
-X POST \
|
|
262
|
+
-d '{"messages":[{"role":"user","content":"Create a project handoff for the next AI agent."}]}'
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Extract profile:
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
bankr x402 call https://x402.bankr.bot/0xdace98cd605dd56b2edc66f0f4df3687f64fd824/contextkit-profile \
|
|
269
|
+
-X POST \
|
|
270
|
+
-d '{"messages":[{"role":"user","content":"Extract durable user preferences and profile memory."}]}'
|
|
271
|
+
```
|
|
272
|
+
|
|
296
273
|
This path requires:
|
|
297
274
|
|
|
298
275
|
- Bankr login
|
|
@@ -316,26 +293,54 @@ const valid = await verifyContextKitWebhook({
|
|
|
316
293
|
});
|
|
317
294
|
```
|
|
318
295
|
|
|
319
|
-
##
|
|
296
|
+
## API Key Credits
|
|
320
297
|
|
|
321
|
-
|
|
298
|
+
Paid direct endpoints use the API key owner's ContextKit credit balance first. If credits are available, no Bankr payment is needed per request.
|
|
322
299
|
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
npm --workspace @basedchef/contextkit run build
|
|
300
|
+
```ts
|
|
301
|
+
const credits = await client.credits();
|
|
302
|
+
console.log(credits.balanceUsd);
|
|
327
303
|
```
|
|
328
304
|
|
|
329
|
-
|
|
305
|
+
Equivalent terminal test:
|
|
330
306
|
|
|
331
307
|
```bash
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
308
|
+
cat > credits.mjs <<'EOF'
|
|
309
|
+
import { ContextKit } from "@basedchef/contextkit";
|
|
310
|
+
|
|
311
|
+
const client = new ContextKit({
|
|
312
|
+
apiKey: "<CONTEXTKIT_API_KEY>",
|
|
313
|
+
baseUrl: "https://your-domain.com"
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
const result = await client.credits();
|
|
317
|
+
console.log(JSON.stringify(result, null, 2));
|
|
318
|
+
EOF
|
|
319
|
+
|
|
320
|
+
node credits.mjs
|
|
336
321
|
```
|
|
337
322
|
|
|
338
|
-
If
|
|
323
|
+
If the balance is too low, direct paid routes return a normal HTTP 402 x402 challenge.
|
|
324
|
+
|
|
325
|
+
## Buy Credits
|
|
326
|
+
|
|
327
|
+
Users can top up credits from the ContextKit dashboard:
|
|
328
|
+
|
|
329
|
+
1. Sign in to the dashboard.
|
|
330
|
+
2. Open `/dashboard/credits`.
|
|
331
|
+
3. Create a USDC invoice.
|
|
332
|
+
4. Send the exact USDC amount on Base to the shown wallet.
|
|
333
|
+
5. Paste the transaction hash.
|
|
334
|
+
6. ContextKit verifies the transaction and credits the account automatically.
|
|
335
|
+
|
|
336
|
+
The backend verifies:
|
|
337
|
+
|
|
338
|
+
- the transaction exists on Base,
|
|
339
|
+
- the transaction succeeded,
|
|
340
|
+
- the Base USDC contract emitted a `Transfer`,
|
|
341
|
+
- the recipient is the ContextKit wallet,
|
|
342
|
+
- the amount is at least the invoice amount,
|
|
343
|
+
- the tx hash was not already used.
|
|
339
344
|
|
|
340
345
|
## Troubleshooting
|
|
341
346
|
|
|
@@ -347,14 +352,6 @@ Your API key has insufficient credits. Top up credits in `/dashboard/credits` or
|
|
|
347
352
|
|
|
348
353
|
The API key is invalid, revoked, or missing required scopes.
|
|
349
354
|
|
|
350
|
-
`npm publish` says version already exists
|
|
351
|
-
|
|
352
|
-
Increase `packages/sdk/package.json` version before publishing.
|
|
353
|
-
|
|
354
|
-
`npm publish` says OTP failed
|
|
355
|
-
|
|
356
|
-
Use the current six-digit authenticator code and make sure server time is synchronized.
|
|
357
|
-
|
|
358
355
|
## License
|
|
359
356
|
|
|
360
357
|
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basedchef/contextkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "TypeScript SDK for ContextKit, a Bankr-hosted x402 context API for AI agents, memory compression, handoffs, profiles, and webhooks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"author": "basedchef",
|
|
16
|
-
"homepage": "https://
|
|
16
|
+
"homepage": "https://your-domain.com",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "git+https://github.com/arsalang75523/contextkit.git",
|