@x1scroll/agent-sdk 1.0.1 → 1.0.2

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 (3) hide show
  1. package/README.md +6 -13
  2. package/package.json +1 -1
  3. package/src/index.js +21 -45
package/README.md CHANGED
@@ -122,29 +122,22 @@ const { txSig, memoryEntryPDA } = await client.storeMemory(
122
122
 
123
123
  **Fee:** 0.001 XNT (same as `storeMemory`)
124
124
 
125
- ```js
126
- // Using x1scroll.io IPFS (free, rate-limited — good for dev/testing)
127
- const { txSig, cid } = await client.uploadMemory(
128
- agentKeypair,
129
- humanWallet.publicKey.toBase58(),
130
- 'session-2026-04-06',
131
- { summary: 'Discussed SDK launch', decisions: ['publish to npm', 'BSL license'] }
132
- );
125
+ Requires a free [Pinata](https://pinata.cloud) API key (free tier: 100 pins, 1GB — enough for development and testing).
133
126
 
134
- // Using Pinata (production — persistent pinning guaranteed)
127
+ ```js
135
128
  const { txSig, cid } = await client.uploadMemory(
136
129
  agentKeypair,
137
130
  humanWallet.publicKey.toBase58(),
138
131
  'session-2026-04-06',
139
- { summary: 'Discussed SDK launch' },
140
- { provider: 'pinata', pinataJwt: process.env.PINATA_JWT, tags: ['session', 'daily'] }
132
+ { summary: 'Discussed SDK launch', decisions: ['publish to npm', 'BSL license'] },
133
+ { pinataJwt: process.env.PINATA_JWT, tags: ['session', 'daily'] }
141
134
  );
135
+ // Content is pinned on IPFS, CID stored on X1. Done.
142
136
  ```
143
137
 
144
138
  | Option | Type | Default | Description |
145
139
  |--------|------|---------|-------------|
146
- | `provider` | `string` | `'x1scroll'` | `'pinata'` or `'x1scroll'` |
147
- | `pinataJwt` | `string` | — | Required if provider is `'pinata'` |
140
+ | `pinataJwt` | `string` | | **Required.** Get free at pinata.cloud |
148
141
  | `tags` | `string[]` | `[]` | Up to 5 tags |
149
142
  | `encrypted` | `boolean` | `false` | Whether content is encrypted |
150
143
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x1scroll/agent-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Agent identity and on-chain memory protocol for X1 blockchain",
5
5
  "license": "BSL-1.1",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -551,62 +551,38 @@ class AgentClient {
551
551
  */
552
552
  async uploadMemory(agentKeypair, agentRecordHuman, topic, content, options = {}) {
553
553
  const {
554
- provider = 'x1scroll',
555
554
  pinataJwt = null,
556
555
  tags = [],
557
556
  encrypted = false,
558
557
  } = options;
559
558
 
559
+ if (!pinataJwt) {
560
+ throw new AgentSDKError(
561
+ 'pinataJwt is required for uploadMemory(). Get a free API key at https://pinata.cloud (free tier: 100 pins, 1GB). Pass it as options.pinataJwt.',
562
+ 'MISSING_PINATA_JWT'
563
+ );
564
+ }
565
+
560
566
  // Serialize content
561
567
  const body = (typeof content === 'string') ? content : JSON.stringify(content);
562
568
 
563
569
  let cid;
564
570
 
565
- if (provider === 'pinata') {
566
- if (!pinataJwt) {
567
- throw new AgentSDKError(
568
- 'pinataJwt is required when provider is "pinata". Get one at https://pinata.cloud',
569
- 'MISSING_PINATA_JWT'
570
- );
571
- }
572
- // Upload to Pinata returns IpfsHash
573
- const res = await fetch('https://api.pinata.cloud/pinning/pinJSONToIPFS', {
574
- method: 'POST',
575
- headers: {
576
- 'Content-Type': 'application/json',
577
- 'Authorization': `Bearer ${pinataJwt}`,
578
- },
579
- body: JSON.stringify({ pinataContent: body, pinataMetadata: { name: topic } }),
580
- });
581
- if (!res.ok) {
582
- const err = await res.text();
583
- throw new AgentSDKError(`Pinata upload failed: ${err}`, 'PINATA_ERROR');
584
- }
585
- const json = await res.json();
586
- cid = json.IpfsHash;
587
-
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
- } else {
605
- throw new AgentSDKError(
606
- `Unknown provider "${provider}". Supported: 'pinata', 'x1scroll'`,
607
- 'INVALID_PROVIDER'
608
- );
571
+ // Upload to Pinata — auto-pinned, persistent
572
+ const res = await fetch('https://api.pinata.cloud/pinning/pinJSONToIPFS', {
573
+ method: 'POST',
574
+ headers: {
575
+ 'Content-Type': 'application/json',
576
+ 'Authorization': `Bearer ${pinataJwt}`,
577
+ },
578
+ body: JSON.stringify({ pinataContent: body, pinataMetadata: { name: topic } }),
579
+ });
580
+ if (!res.ok) {
581
+ const err = await res.text();
582
+ throw new AgentSDKError(`Pinata upload failed: ${err}`, 'PINATA_ERROR');
609
583
  }
584
+ const json = await res.json();
585
+ cid = json.IpfsHash;
610
586
 
611
587
  if (!cid) {
612
588
  throw new AgentSDKError('IPFS upload returned no CID', 'NO_CID');