@resourcexjs/arp 2.0.0 → 2.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 +16 -29
- package/dist/index.d.ts +53 -66
- package/dist/index.js +47 -2095
- package/dist/index.js.map +6 -8
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ arp:{semantic}:{transport}://{location}
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
- **semantic**: Content interpretation (text, binary)
|
|
22
|
-
- **transport**: Storage backend (file, http, https
|
|
22
|
+
- **transport**: Storage backend (file, http, https)
|
|
23
23
|
- **location**: Resource location (path, URL)
|
|
24
24
|
|
|
25
25
|
### Examples
|
|
@@ -27,18 +27,19 @@ arp:{semantic}:{transport}://{location}
|
|
|
27
27
|
```
|
|
28
28
|
arp:text:file://~/data.txt
|
|
29
29
|
arp:binary:https://example.com/image.png
|
|
30
|
-
arp:text:rxr://localhost/my-prompt.text@1.0.0/content
|
|
31
30
|
```
|
|
32
31
|
|
|
33
32
|
### Built-in Handlers
|
|
34
33
|
|
|
35
|
-
**createARP()** auto-registers
|
|
34
|
+
**createARP()** auto-registers standard protocol handlers:
|
|
36
35
|
|
|
37
36
|
**Transports:**
|
|
38
37
|
|
|
39
38
|
- `file` - Local filesystem (read-write)
|
|
40
39
|
- `http`, `https` - Network resources (read-only)
|
|
41
|
-
|
|
40
|
+
|
|
41
|
+
> **Note:** For `rxr` transport (ResourceX-specific), use `resourcexjs/arp` instead.
|
|
42
|
+
> The main package provides an enhanced `createARP()` that includes RxrTransport.
|
|
42
43
|
|
|
43
44
|
**Semantics:**
|
|
44
45
|
|
|
@@ -306,14 +307,21 @@ const result = await arl.resolve({ lang: "en" });
|
|
|
306
307
|
|
|
307
308
|
### RXR Transport (`rxr`)
|
|
308
309
|
|
|
309
|
-
|
|
310
|
+
> **Moved to main package:** RxrTransport is now available in `resourcexjs/arp`.
|
|
311
|
+
> Use the main package for ResourceX-specific functionality.
|
|
310
312
|
|
|
311
313
|
```typescript
|
|
312
|
-
//
|
|
313
|
-
|
|
314
|
-
|
|
314
|
+
// Use resourcexjs/arp for rxr transport
|
|
315
|
+
import { createARP, RxrTransport } from "resourcexjs/arp";
|
|
316
|
+
|
|
317
|
+
// createARP() from main package auto-registers RxrTransport
|
|
318
|
+
const arp = createARP();
|
|
319
|
+
const arl = arp.parse("arp:text:rxr://localhost/my-prompt.text@1.0.0/content");
|
|
320
|
+
const { content } = await arl.resolve();
|
|
315
321
|
```
|
|
316
322
|
|
|
323
|
+
**Format:** `arp:{semantic}:rxr://{rxl}/{internal-path}`
|
|
324
|
+
|
|
317
325
|
**Operations:**
|
|
318
326
|
|
|
319
327
|
- ✅ get (read file from resource)
|
|
@@ -326,27 +334,6 @@ arp.parse("arp:text:rxr://deepractice.ai/nuwa.text@1.0.0/thought/first-principle
|
|
|
326
334
|
- `localhost` domain → LocalRegistry (filesystem)
|
|
327
335
|
- Other domains → RemoteRegistry (via well-known discovery)
|
|
328
336
|
|
|
329
|
-
```typescript
|
|
330
|
-
// No manual setup needed - works out of the box!
|
|
331
|
-
const arp = createARP();
|
|
332
|
-
const arl = arp.parse("arp:text:rxr://localhost/hello.text@1.0.0/content");
|
|
333
|
-
const { content } = await arl.resolve();
|
|
334
|
-
// RxrTransport automatically creates LocalRegistry for localhost
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
**Manual Registry injection (optional):**
|
|
338
|
-
|
|
339
|
-
```typescript
|
|
340
|
-
import { createRegistry } from "@resourcexjs/registry";
|
|
341
|
-
import { createARP, RxrTransport } from "@resourcexjs/arp";
|
|
342
|
-
|
|
343
|
-
const registry = createRegistry({ path: "./custom-path" });
|
|
344
|
-
const rxrTransport = new RxrTransport(registry);
|
|
345
|
-
|
|
346
|
-
const arp = createARP();
|
|
347
|
-
arp.registerTransport(rxrTransport); // Override default rxr transport
|
|
348
|
-
```
|
|
349
|
-
|
|
350
337
|
## Error Handling
|
|
351
338
|
|
|
352
339
|
```typescript
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,19 @@
|
|
|
11
11
|
*/
|
|
12
12
|
type TransportParams = Record<string, string>;
|
|
13
13
|
/**
|
|
14
|
+
* Options for list operation
|
|
15
|
+
*/
|
|
16
|
+
interface ListOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Whether to list recursively
|
|
19
|
+
*/
|
|
20
|
+
recursive?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Glob pattern to filter results (e.g., "*.json")
|
|
23
|
+
*/
|
|
24
|
+
pattern?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
14
27
|
* Result from transport get operation
|
|
15
28
|
*/
|
|
16
29
|
interface TransportResult {
|
|
@@ -86,6 +99,20 @@ interface TransportHandler {
|
|
|
86
99
|
* @param location - The location string (format depends on transport)
|
|
87
100
|
*/
|
|
88
101
|
delete(location: string): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* List contents at location (optional - not all transports support this)
|
|
104
|
+
*
|
|
105
|
+
* @param location - The directory location
|
|
106
|
+
* @param options - List options (recursive, pattern filter)
|
|
107
|
+
* @returns Array of file/directory paths relative to location
|
|
108
|
+
*/
|
|
109
|
+
list?(location: string, options?: ListOptions): Promise<string[]>;
|
|
110
|
+
/**
|
|
111
|
+
* Create directory at location (optional - not all transports support this)
|
|
112
|
+
*
|
|
113
|
+
* @param location - The directory location to create
|
|
114
|
+
*/
|
|
115
|
+
mkdir?(location: string): Promise<void>;
|
|
89
116
|
}
|
|
90
117
|
/**
|
|
91
118
|
* Resource metadata
|
|
@@ -205,6 +232,15 @@ interface ARL extends ARI {
|
|
|
205
232
|
*/
|
|
206
233
|
delete(): Promise<void>;
|
|
207
234
|
/**
|
|
235
|
+
* List directory contents (only supported by some transports)
|
|
236
|
+
* @param options - List options (recursive, pattern filter)
|
|
237
|
+
*/
|
|
238
|
+
list(options?: ListOptions): Promise<string[]>;
|
|
239
|
+
/**
|
|
240
|
+
* Create directory (only supported by some transports)
|
|
241
|
+
*/
|
|
242
|
+
mkdir(): Promise<void>;
|
|
243
|
+
/**
|
|
208
244
|
* Convert to ARP URL string
|
|
209
245
|
*/
|
|
210
246
|
toString(): string;
|
|
@@ -246,6 +282,14 @@ declare class ARL2 implements ARL {
|
|
|
246
282
|
*/
|
|
247
283
|
delete(): Promise<void>;
|
|
248
284
|
/**
|
|
285
|
+
* List directory contents
|
|
286
|
+
*/
|
|
287
|
+
list(options?: ListOptions): Promise<string[]>;
|
|
288
|
+
/**
|
|
289
|
+
* Create directory
|
|
290
|
+
*/
|
|
291
|
+
mkdir(): Promise<void>;
|
|
292
|
+
/**
|
|
249
293
|
* Convert to ARP URL string
|
|
250
294
|
*/
|
|
251
295
|
toString(): string;
|
|
@@ -378,6 +422,14 @@ declare class FileTransportHandler implements TransportHandler {
|
|
|
378
422
|
* Delete file or directory
|
|
379
423
|
*/
|
|
380
424
|
delete(location: string): Promise<void>;
|
|
425
|
+
/**
|
|
426
|
+
* List directory contents
|
|
427
|
+
*/
|
|
428
|
+
list(location: string, options?: ListOptions): Promise<string[]>;
|
|
429
|
+
/**
|
|
430
|
+
* Create directory (recursively)
|
|
431
|
+
*/
|
|
432
|
+
mkdir(location: string): Promise<void>;
|
|
381
433
|
}
|
|
382
434
|
declare const fileTransport: FileTransportHandler;
|
|
383
435
|
declare class HttpTransportHandler implements TransportHandler {
|
|
@@ -408,71 +460,6 @@ declare class HttpTransportHandler implements TransportHandler {
|
|
|
408
460
|
}
|
|
409
461
|
declare const httpsTransport: HttpTransportHandler;
|
|
410
462
|
declare const httpTransport: HttpTransportHandler;
|
|
411
|
-
/**
|
|
412
|
-
* Minimal registry interface required by RxrTransport.
|
|
413
|
-
* This allows RxrTransport to work without depending on the full Registry type.
|
|
414
|
-
*/
|
|
415
|
-
interface RxrTransportRegistry {
|
|
416
|
-
get(locator: string): Promise<{
|
|
417
|
-
content: {
|
|
418
|
-
files(): Promise<Map<string, Buffer>>
|
|
419
|
-
}
|
|
420
|
-
}>;
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* RXR Transport - Access files inside a resource.
|
|
424
|
-
*
|
|
425
|
-
* Location format: {rxl}/{internal-path}
|
|
426
|
-
* Example: deepractice.ai/nuwa.role@1.0.0/thought/first-principles.md
|
|
427
|
-
*
|
|
428
|
-
* The RXL portion ends at @version, and the internal path follows.
|
|
429
|
-
*
|
|
430
|
-
* When no registry is provided, automatically creates one based on domain:
|
|
431
|
-
* - localhost: LocalRegistry
|
|
432
|
-
* - Other domains: RemoteRegistry with well-known discovery
|
|
433
|
-
*/
|
|
434
|
-
declare class RxrTransport implements TransportHandler {
|
|
435
|
-
private registry?;
|
|
436
|
-
readonly name = "rxr";
|
|
437
|
-
constructor(registry?: RxrTransportRegistry);
|
|
438
|
-
/**
|
|
439
|
-
* Get file content from inside a resource.
|
|
440
|
-
*/
|
|
441
|
-
get(location: string, _params?: TransportParams): Promise<TransportResult>;
|
|
442
|
-
/**
|
|
443
|
-
* Set is not supported - RXR transport is read-only.
|
|
444
|
-
*/
|
|
445
|
-
set(_location: string, _content: Buffer, _params?: TransportParams): Promise<void>;
|
|
446
|
-
/**
|
|
447
|
-
* Check if a file exists inside a resource.
|
|
448
|
-
*/
|
|
449
|
-
exists(location: string): Promise<boolean>;
|
|
450
|
-
/**
|
|
451
|
-
* Delete is not supported - RXR transport is read-only.
|
|
452
|
-
*/
|
|
453
|
-
delete(_location: string): Promise<void>;
|
|
454
|
-
/**
|
|
455
|
-
* Get or create a registry for the given domain.
|
|
456
|
-
* - If a registry was provided in constructor, use it
|
|
457
|
-
* - localhost: create LocalRegistry
|
|
458
|
-
* - Other domains: discover endpoint via well-known and create appropriate registry
|
|
459
|
-
*/
|
|
460
|
-
private getRegistry;
|
|
461
|
-
/**
|
|
462
|
-
* Check if URL is a git repository URL.
|
|
463
|
-
*/
|
|
464
|
-
private isGitUrl;
|
|
465
|
-
/**
|
|
466
|
-
* Parse location into domain, RXL and internal path.
|
|
467
|
-
* Format: {domain}/{path}/{name}.{type}@{version}/{internal-path}
|
|
468
|
-
* Example: deepractice.ai/nuwa.role@1.0.0/thought/first-principles.md
|
|
469
|
-
*/
|
|
470
|
-
private parseLocation;
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* Clear the registry cache. Useful for testing.
|
|
474
|
-
*/
|
|
475
|
-
declare function clearRegistryCache(): void;
|
|
476
463
|
interface TextResource extends Resource<string> {
|
|
477
464
|
type: "text";
|
|
478
465
|
content: string;
|
|
@@ -502,4 +489,4 @@ declare class BinarySemanticHandler implements SemanticHandler<Buffer> {
|
|
|
502
489
|
}
|
|
503
490
|
declare const binarySemantic: BinarySemanticHandler;
|
|
504
491
|
declare const VERSION: string;
|
|
505
|
-
export { textSemantic, httpsTransport, httpTransport, fileTransport, createARP,
|
|
492
|
+
export { textSemantic, httpsTransport, httpTransport, fileTransport, createARP, binarySemantic, VERSION, TransportResult, TransportParams, TransportHandler, TransportError, TextSemanticHandler, TextResource, SemanticHandler, SemanticError, SemanticContext, ResourceMeta, Resource, ParseError, ListOptions, HttpTransportHandler, FileTransportHandler, BinarySemanticHandler, BinaryResource, BinaryInput, ARPError, ARPConfig, ARP, ARL, ARI };
|