@resourcexjs/arp 1.7.0 → 2.1.0

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 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, agentvm)
22
+ - **transport**: Storage backend (file, http, https)
23
23
  - **location**: Resource location (path, URL)
24
24
 
25
25
  ### Examples
@@ -27,9 +27,25 @@ 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:agentvm://sandbox/config.json
31
30
  ```
32
31
 
32
+ ### Built-in Handlers
33
+
34
+ **createARP()** auto-registers standard protocol handlers:
35
+
36
+ **Transports:**
37
+
38
+ - `file` - Local filesystem (read-write)
39
+ - `http`, `https` - Network resources (read-only)
40
+
41
+ > **Note:** For `rxr` transport (ResourceX-specific), use `resourcexjs/arp` instead.
42
+ > The main package provides an enhanced `createARP()` that includes RxrTransport.
43
+
44
+ **Semantics:**
45
+
46
+ - `text` - UTF-8 text → string
47
+ - `binary` - Raw bytes → Buffer
48
+
33
49
  ## Usage
34
50
 
35
51
  ### Basic Operations
@@ -289,21 +305,34 @@ const result = await arl.resolve({ lang: "en" });
289
305
  // Fetches: https://api.example.com/data?format=json&lang=en
290
306
  ```
291
307
 
292
- ### AgentVM Transport (`agentvm`)
308
+ ### RXR Transport (`rxr`)
293
309
 
294
- AgentVM sandbox storage (`~/.agentvm/`).
310
+ > **Moved to main package:** RxrTransport is now available in `resourcexjs/arp`.
311
+ > Use the main package for ResourceX-specific functionality.
295
312
 
296
313
  ```typescript
297
- arp.parse("arp:text:agentvm://sandbox/config.json");
298
- // Maps to: ~/.agentvm/sandbox/config.json
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();
299
321
  ```
300
322
 
323
+ **Format:** `arp:{semantic}:rxr://{rxl}/{internal-path}`
324
+
301
325
  **Operations:**
302
326
 
303
- - ✅ get (read)
304
- - set (write)
305
- - ✅ exists
306
- - delete
327
+ - ✅ get (read file from resource)
328
+ - set (read-only, throws error)
329
+ - ✅ exists (check if file exists in resource)
330
+ - delete (read-only, throws error)
331
+
332
+ **Auto-creates Registry:**
333
+
334
+ - `localhost` domain → LocalRegistry (filesystem)
335
+ - Other domains → RemoteRegistry (via well-known discovery)
307
336
 
308
337
  ## Error Handling
309
338
 
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,67 +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 RemoteRegistry
459
- */
460
- private getRegistry;
461
- /**
462
- * Parse location into domain, RXL and internal path.
463
- * Format: {domain}/{path}/{name}.{type}@{version}/{internal-path}
464
- * Example: deepractice.ai/nuwa.role@1.0.0/thought/first-principles.md
465
- */
466
- private parseLocation;
467
- }
468
- /**
469
- * Clear the registry cache. Useful for testing.
470
- */
471
- declare function clearRegistryCache(): void;
472
463
  interface TextResource extends Resource<string> {
473
464
  type: "text";
474
465
  content: string;
@@ -498,4 +489,4 @@ declare class BinarySemanticHandler implements SemanticHandler<Buffer> {
498
489
  }
499
490
  declare const binarySemantic: BinarySemanticHandler;
500
491
  declare const VERSION: string;
501
- export { textSemantic, httpsTransport, httpTransport, fileTransport, createARP, clearRegistryCache, binarySemantic, VERSION, TransportResult, TransportParams, TransportHandler, TransportError, TextSemanticHandler, TextResource, SemanticHandler, SemanticError, SemanticContext, RxrTransportRegistry, RxrTransport, ResourceMeta, Resource, ParseError, HttpTransportHandler, FileTransportHandler, BinarySemanticHandler, BinaryResource, BinaryInput, ARPError, ARPConfig, ARP, ARL, ARI };
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 };