@x1scroll/agent-sdk 1.0.1 → 1.0.3
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 +10 -7
- package/package.json +1 -1
- package/src/index.js +20 -19
package/README.md
CHANGED
|
@@ -122,35 +122,38 @@ const { txSig, memoryEntryPDA } = await client.storeMemory(
|
|
|
122
122
|
|
|
123
123
|
**Fee:** 0.001 XNT (same as `storeMemory`)
|
|
124
124
|
|
|
125
|
+
By default, content is pinned to the **x1scroll validator network** — no API key, no configuration needed. Pinata is available as an alternative for production workloads requiring independent pinning.
|
|
126
|
+
|
|
125
127
|
```js
|
|
126
|
-
//
|
|
128
|
+
// Default: pinned to x1scroll validator network (zero config)
|
|
127
129
|
const { txSig, cid } = await client.uploadMemory(
|
|
128
130
|
agentKeypair,
|
|
129
131
|
humanWallet.publicKey.toBase58(),
|
|
130
132
|
'session-2026-04-06',
|
|
131
|
-
{ summary: 'Discussed SDK launch', decisions: ['publish to npm', 'BSL license'] }
|
|
133
|
+
{ summary: 'Discussed SDK launch', decisions: ['publish to npm', 'BSL license'] },
|
|
134
|
+
{ tags: ['session', 'daily'] }
|
|
132
135
|
);
|
|
133
136
|
|
|
134
|
-
//
|
|
137
|
+
// Alternative: Pinata (bring your own key)
|
|
135
138
|
const { txSig, cid } = await client.uploadMemory(
|
|
136
139
|
agentKeypair,
|
|
137
140
|
humanWallet.publicKey.toBase58(),
|
|
138
141
|
'session-2026-04-06',
|
|
139
142
|
{ summary: 'Discussed SDK launch' },
|
|
140
|
-
{ provider: 'pinata', pinataJwt: process.env.PINATA_JWT
|
|
143
|
+
{ provider: 'pinata', pinataJwt: process.env.PINATA_JWT }
|
|
141
144
|
);
|
|
142
145
|
```
|
|
143
146
|
|
|
144
147
|
| Option | Type | Default | Description |
|
|
145
148
|
|--------|------|---------|-------------|
|
|
146
|
-
| `provider` | `string` | `'x1scroll'` | `'
|
|
147
|
-
| `pinataJwt` | `string` | — | Required if provider is `'pinata'` |
|
|
149
|
+
| `provider` | `string` | `'x1scroll'` | `'x1scroll'` (validator network) or `'pinata'` |
|
|
150
|
+
| `pinataJwt` | `string` | — | Required only if provider is `'pinata'` |
|
|
148
151
|
| `tags` | `string[]` | `[]` | Up to 5 tags |
|
|
149
152
|
| `encrypted` | `boolean` | `false` | Whether content is encrypted |
|
|
150
153
|
|
|
151
154
|
**Returns:** `Promise<{ txSig: string, memoryEntryPDA: string, cid: string }>`
|
|
152
155
|
|
|
153
|
-
> **Use `uploadMemory()`
|
|
156
|
+
> **Use `uploadMemory()` for zero-config IPFS pinning.** Content is pinned to x1scroll validator infrastructure — as long as X1 runs, your agent remembers. Use `storeMemory()` directly if you manage your own pinning.
|
|
154
157
|
|
|
155
158
|
---
|
|
156
159
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -562,14 +562,31 @@ class AgentClient {
|
|
|
562
562
|
|
|
563
563
|
let cid;
|
|
564
564
|
|
|
565
|
-
if (provider === '
|
|
565
|
+
if (provider === 'x1scroll' || !provider) {
|
|
566
|
+
// Upload to x1scroll validator network — pinned across X1 infrastructure
|
|
567
|
+
const res = await fetch('https://x1scroll.io/api/ipfs/upload', {
|
|
568
|
+
method: 'POST',
|
|
569
|
+
headers: { 'Content-Type': 'application/json' },
|
|
570
|
+
body: JSON.stringify({
|
|
571
|
+
content: body,
|
|
572
|
+
topic,
|
|
573
|
+
agentPubkey: agentKeypair.publicKey.toBase58(),
|
|
574
|
+
}),
|
|
575
|
+
});
|
|
576
|
+
if (!res.ok) {
|
|
577
|
+
const err = await res.text();
|
|
578
|
+
throw new AgentSDKError(`x1scroll IPFS upload failed (${res.status}): ${err}`, 'X1SCROLL_IPFS_ERROR');
|
|
579
|
+
}
|
|
580
|
+
const json = await res.json();
|
|
581
|
+
cid = json.cid;
|
|
582
|
+
|
|
583
|
+
} else if (provider === 'pinata') {
|
|
566
584
|
if (!pinataJwt) {
|
|
567
585
|
throw new AgentSDKError(
|
|
568
586
|
'pinataJwt is required when provider is "pinata". Get one at https://pinata.cloud',
|
|
569
587
|
'MISSING_PINATA_JWT'
|
|
570
588
|
);
|
|
571
589
|
}
|
|
572
|
-
// Upload to Pinata — returns IpfsHash
|
|
573
590
|
const res = await fetch('https://api.pinata.cloud/pinning/pinJSONToIPFS', {
|
|
574
591
|
method: 'POST',
|
|
575
592
|
headers: {
|
|
@@ -585,25 +602,9 @@ class AgentClient {
|
|
|
585
602
|
const json = await res.json();
|
|
586
603
|
cid = json.IpfsHash;
|
|
587
604
|
|
|
588
|
-
} else if (provider === 'x1scroll') {
|
|
589
|
-
// Upload to x1scroll.io IPFS node (free, rate-limited)
|
|
590
|
-
const res = await fetch('https://ipfs.x1scroll.io/upload', {
|
|
591
|
-
method: 'POST',
|
|
592
|
-
headers: { 'Content-Type': 'application/json' },
|
|
593
|
-
body: JSON.stringify({ content: body, topic, agentPubkey: agentKeypair.publicKey.toBase58() }),
|
|
594
|
-
});
|
|
595
|
-
if (!res.ok) {
|
|
596
|
-
throw new AgentSDKError(
|
|
597
|
-
`x1scroll IPFS upload failed (${res.status}). Use provider='pinata' for production workloads.`,
|
|
598
|
-
'X1SCROLL_IPFS_ERROR'
|
|
599
|
-
);
|
|
600
|
-
}
|
|
601
|
-
const json = await res.json();
|
|
602
|
-
cid = json.cid;
|
|
603
|
-
|
|
604
605
|
} else {
|
|
605
606
|
throw new AgentSDKError(
|
|
606
|
-
`Unknown provider "${provider}". Supported: '
|
|
607
|
+
`Unknown provider "${provider}". Supported: 'x1scroll' (default), 'pinata'`,
|
|
607
608
|
'INVALID_PROVIDER'
|
|
608
609
|
);
|
|
609
610
|
}
|