resourcexjs 2.5.4 → 2.5.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 +57 -50
- package/dist/arp.d.ts +2 -71
- package/dist/arp.js +3 -2628
- package/dist/arp.js.map +4 -9
- package/dist/index.d.ts +35 -91
- package/dist/index.js +14894 -16312
- package/dist/index.js.map +7 -10
- package/package.json +3 -7
package/README.md
CHANGED
|
@@ -5,9 +5,9 @@ Resource management protocol for AI Agents. Like npm for AI resources (prompts,
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install resourcexjs
|
|
8
|
+
npm install resourcexjs @resourcexjs/node-provider
|
|
9
9
|
# or
|
|
10
|
-
bun add resourcexjs
|
|
10
|
+
bun add resourcexjs @resourcexjs/node-provider
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
**Requirements:** Node.js 22+ or Bun
|
|
@@ -15,7 +15,11 @@ bun add resourcexjs
|
|
|
15
15
|
## Quick Start
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
import { createResourceX } from "resourcexjs";
|
|
18
|
+
import { createResourceX, setProvider } from "resourcexjs";
|
|
19
|
+
import { NodeProvider } from "@resourcexjs/node-provider";
|
|
20
|
+
|
|
21
|
+
// Configure provider before creating client
|
|
22
|
+
setProvider(new NodeProvider());
|
|
19
23
|
|
|
20
24
|
const rx = createResourceX();
|
|
21
25
|
|
|
@@ -84,32 +88,53 @@ Example `resource.json`:
|
|
|
84
88
|
|
|
85
89
|
### Storage Layout
|
|
86
90
|
|
|
87
|
-
Resources are stored in `~/.resourcex/`:
|
|
91
|
+
Resources are stored using content-addressable storage (CAS) in `~/.resourcex/`:
|
|
88
92
|
|
|
89
93
|
```
|
|
90
94
|
~/.resourcex/
|
|
91
|
-
├──
|
|
92
|
-
│ └──
|
|
93
|
-
│ └──
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
│
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
└──
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
├── blobs/ # Content-addressable blob storage
|
|
96
|
+
│ └── ab/
|
|
97
|
+
│ └── sha256:abcd1234... # Archive data (tar.gz)
|
|
98
|
+
└── manifests/
|
|
99
|
+
├── _local/ # Local resources (no registry)
|
|
100
|
+
│ └── my-prompt/
|
|
101
|
+
│ └── 1.0.0.json # Manifest with digest reference
|
|
102
|
+
└── registry.example.com/ # Cached remote resources
|
|
103
|
+
└── hello/
|
|
104
|
+
└── 1.0.0.json
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Provider Configuration
|
|
108
|
+
|
|
109
|
+
ResourceX requires a platform provider to be configured before use. The provider handles platform-specific storage operations.
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { setProvider, hasProvider, clearProvider } from "resourcexjs";
|
|
113
|
+
import { NodeProvider } from "@resourcexjs/node-provider";
|
|
114
|
+
|
|
115
|
+
// Set provider (required before createResourceX)
|
|
116
|
+
setProvider(new NodeProvider());
|
|
117
|
+
|
|
118
|
+
// Check if provider is configured
|
|
119
|
+
if (hasProvider()) {
|
|
120
|
+
const rx = createResourceX();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Clear provider (useful for testing)
|
|
124
|
+
clearProvider();
|
|
103
125
|
```
|
|
104
126
|
|
|
105
127
|
## API Reference
|
|
106
128
|
|
|
107
129
|
### createResourceX(config?)
|
|
108
130
|
|
|
109
|
-
Create a ResourceX client instance.
|
|
131
|
+
Create a ResourceX client instance. Requires a provider to be set first.
|
|
110
132
|
|
|
111
133
|
```typescript
|
|
112
|
-
import { createResourceX } from "resourcexjs";
|
|
134
|
+
import { createResourceX, setProvider } from "resourcexjs";
|
|
135
|
+
import { NodeProvider } from "@resourcexjs/node-provider";
|
|
136
|
+
|
|
137
|
+
setProvider(new NodeProvider());
|
|
113
138
|
|
|
114
139
|
const rx = createResourceX({
|
|
115
140
|
path: "~/.resourcex", // Storage path (default: ~/.resourcex)
|
|
@@ -130,22 +155,6 @@ const resource = await rx.add("./my-prompt");
|
|
|
130
155
|
console.log(resource.locator); // "my-prompt:1.0.0"
|
|
131
156
|
```
|
|
132
157
|
|
|
133
|
-
#### rx.link(path)
|
|
134
|
-
|
|
135
|
-
Link a directory for live development (symlink). Changes to the directory are immediately available.
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
await rx.link("./dev-prompt");
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
#### rx.unlink(locator)
|
|
142
|
-
|
|
143
|
-
Remove a development link.
|
|
144
|
-
|
|
145
|
-
```typescript
|
|
146
|
-
await rx.unlink("dev-prompt:1.0.0");
|
|
147
|
-
```
|
|
148
|
-
|
|
149
158
|
#### rx.has(locator)
|
|
150
159
|
|
|
151
160
|
Check if a resource exists locally.
|
|
@@ -194,10 +203,9 @@ console.log(executable.schema);
|
|
|
194
203
|
|
|
195
204
|
Resolution order:
|
|
196
205
|
|
|
197
|
-
1.
|
|
198
|
-
2.
|
|
199
|
-
3.
|
|
200
|
-
4. Remote registry (auto-pull if configured)
|
|
206
|
+
1. Local storage
|
|
207
|
+
2. Cache (previously pulled)
|
|
208
|
+
3. Remote registry (auto-pull if configured)
|
|
201
209
|
|
|
202
210
|
#### rx.search(query?)
|
|
203
211
|
|
|
@@ -219,6 +227,11 @@ const results = await rx.search("prompt");
|
|
|
219
227
|
Push a local resource to the remote registry.
|
|
220
228
|
|
|
221
229
|
```typescript
|
|
230
|
+
import { createResourceX, setProvider } from "resourcexjs";
|
|
231
|
+
import { NodeProvider } from "@resourcexjs/node-provider";
|
|
232
|
+
|
|
233
|
+
setProvider(new NodeProvider());
|
|
234
|
+
|
|
222
235
|
const rx = createResourceX({
|
|
223
236
|
registry: "https://registry.example.com",
|
|
224
237
|
});
|
|
@@ -340,10 +353,6 @@ await fileArl.exists();
|
|
|
340
353
|
// HTTP operations
|
|
341
354
|
const httpArl = arp.parse("arp:json:https://api.example.com/data");
|
|
342
355
|
const { content: data } = await httpArl.resolve();
|
|
343
|
-
|
|
344
|
-
// Access files inside resources (RXR transport)
|
|
345
|
-
const rxrArl = arp.parse("arp:text:rxr://hello:1.0.0/content");
|
|
346
|
-
const { content: fileContent } = await rxrArl.resolve();
|
|
347
356
|
```
|
|
348
357
|
|
|
349
358
|
## Configuration Options
|
|
@@ -454,14 +463,12 @@ ARPError (base)
|
|
|
454
463
|
|
|
455
464
|
## Related Packages
|
|
456
465
|
|
|
457
|
-
| Package
|
|
458
|
-
|
|
|
459
|
-
| `@resourcexjs/core`
|
|
460
|
-
| `@resourcexjs/
|
|
461
|
-
| `@resourcexjs/
|
|
462
|
-
| `@resourcexjs/
|
|
463
|
-
| `@resourcexjs/loader` | Resource loading utilities |
|
|
464
|
-
| `@resourcexjs/arp` | Low-level I/O protocol |
|
|
466
|
+
| Package | Description |
|
|
467
|
+
| ---------------------------- | ------------------------------- |
|
|
468
|
+
| `@resourcexjs/core` | Core primitives and CASRegistry |
|
|
469
|
+
| `@resourcexjs/node-provider` | Node.js/Bun platform provider |
|
|
470
|
+
| `@resourcexjs/server` | Registry server |
|
|
471
|
+
| `@resourcexjs/arp` | Low-level I/O protocol |
|
|
465
472
|
|
|
466
473
|
## License
|
|
467
474
|
|
package/dist/arp.d.ts
CHANGED
|
@@ -1,71 +1,2 @@
|
|
|
1
|
-
import { ARP, ARPConfig } from "@resourcexjs/arp";
|
|
2
|
-
|
|
3
|
-
import { VERSION } from "@resourcexjs/arp";
|
|
4
|
-
import { ARPError, ParseError, TransportError, SemanticError } from "@resourcexjs/arp";
|
|
5
|
-
import { TransportHandler as TransportHandler2, TransportResult as TransportResult2, TransportParams as TransportParams2, FileTransportHandler, fileTransport, HttpTransportHandler, httpsTransport, httpTransport } from "@resourcexjs/arp";
|
|
6
|
-
import { Resource, SemanticHandler, ResourceMeta, SemanticContext, TextResource, BinaryResource, BinaryInput, TextSemanticHandler, textSemantic, BinarySemanticHandler, binarySemantic } from "@resourcexjs/arp";
|
|
7
|
-
import { ARI, ARL } from "@resourcexjs/arp";
|
|
8
|
-
import { TransportHandler, TransportResult, TransportParams } from "@resourcexjs/arp";
|
|
9
|
-
/**
|
|
10
|
-
* RXR Transport - Access files inside a resource.
|
|
11
|
-
*
|
|
12
|
-
* Location format: {rxl}/{internal-path}
|
|
13
|
-
* Example: deepractice.ai/nuwa.role@1.0.0/thought/first-principles.md
|
|
14
|
-
*
|
|
15
|
-
* The RXL portion ends at @version, and the internal path follows.
|
|
16
|
-
*/
|
|
17
|
-
declare class RxrTransport implements TransportHandler {
|
|
18
|
-
private basePath?;
|
|
19
|
-
readonly name = "rxr";
|
|
20
|
-
constructor(basePath?: string);
|
|
21
|
-
/**
|
|
22
|
-
* Get file content from inside a resource.
|
|
23
|
-
*/
|
|
24
|
-
get(location: string, _params?: TransportParams): Promise<TransportResult>;
|
|
25
|
-
/**
|
|
26
|
-
* Set is not supported - RXR transport is read-only.
|
|
27
|
-
*/
|
|
28
|
-
set(_location: string, _content: Buffer, _params?: TransportParams): Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* Check if a file exists inside a resource.
|
|
31
|
-
*/
|
|
32
|
-
exists(location: string): Promise<boolean>;
|
|
33
|
-
/**
|
|
34
|
-
* Delete is not supported - RXR transport is read-only.
|
|
35
|
-
*/
|
|
36
|
-
delete(_location: string): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Get the registry instance.
|
|
39
|
-
*/
|
|
40
|
-
private getRegistry;
|
|
41
|
-
/**
|
|
42
|
-
* Parse location into RXL and internal path.
|
|
43
|
-
* Format: {registry}/{path}/{name}.{type}@{version}/{internal-path}
|
|
44
|
-
* Example: deepractice.ai/nuwa.role@1.0.0/thought/first-principles.md
|
|
45
|
-
*/
|
|
46
|
-
private parseLocation;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Clear the default registry. Useful for testing.
|
|
50
|
-
*/
|
|
51
|
-
declare function clearRegistryCache(): void;
|
|
52
|
-
/**
|
|
53
|
-
* Create an ARP instance with ResourceX integration.
|
|
54
|
-
*
|
|
55
|
-
* This enhanced version automatically registers the RXR transport,
|
|
56
|
-
* which allows accessing files inside ResourceX resources.
|
|
57
|
-
*
|
|
58
|
-
* Default transports: file, http, https, rxr
|
|
59
|
-
* Default semantics: text, binary
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* const arp = createARP();
|
|
64
|
-
*
|
|
65
|
-
* // Use rxr transport to access resource internals
|
|
66
|
-
* const arl = arp.parse("arp:text:rxr://localhost/my-prompt.text@1.0.0/content");
|
|
67
|
-
* const resource = await arl.resolve();
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
declare function createARP(config?: ARPConfig): ARP;
|
|
71
|
-
export { textSemantic, httpsTransport, httpTransport, fileTransport, createARP, clearRegistryCache, binarySemantic, VERSION, TransportResult2 as TransportResult, TransportParams2 as TransportParams, TransportHandler2 as TransportHandler, TransportError, TextSemanticHandler, TextResource, SemanticHandler, SemanticError, SemanticContext, RxrTransport, ResourceMeta, Resource, ParseError, HttpTransportHandler, FileTransportHandler, BinarySemanticHandler, BinaryResource, BinaryInput, ARPError, ARPConfig2 as ARPConfig, ARP2 as ARP, ARL, ARI };
|
|
1
|
+
import { ARP, createARP, ARPConfig, VERSION, ARPError, ParseError, TransportError, SemanticError, TransportHandler, TransportResult, TransportParams, FileTransportHandler, fileTransport, HttpTransportHandler, httpsTransport, httpTransport, Resource, SemanticHandler, ResourceMeta, SemanticContext, TextResource, BinaryResource, BinaryInput, TextSemanticHandler, textSemantic, BinarySemanticHandler, binarySemantic, ARI, ARL } from "@resourcexjs/arp";
|
|
2
|
+
export { textSemantic, httpsTransport, httpTransport, fileTransport, createARP, binarySemantic, VERSION, TransportResult, TransportParams, TransportHandler, TransportError, TextSemanticHandler, TextResource, SemanticHandler, SemanticError, SemanticContext, ResourceMeta, Resource, ParseError, HttpTransportHandler, FileTransportHandler, BinarySemanticHandler, BinaryResource, BinaryInput, ARPError, ARPConfig, ARP, ARL, ARI };
|