@resourcexjs/arp 1.6.0 → 2.0.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 +52 -10
- package/dist/index.d.ts +66 -1
- package/dist/index.js +2095 -2
- package/dist/index.js.map +6 -4
- package/package.json +4 -1
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, rxr)
|
|
23
23
|
- **location**: Resource location (path, URL)
|
|
24
24
|
|
|
25
25
|
### Examples
|
|
@@ -27,9 +27,24 @@ 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:
|
|
30
|
+
arp:text:rxr://localhost/my-prompt.text@1.0.0/content
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
### Built-in Handlers
|
|
34
|
+
|
|
35
|
+
**createARP()** auto-registers all built-in handlers:
|
|
36
|
+
|
|
37
|
+
**Transports:**
|
|
38
|
+
|
|
39
|
+
- `file` - Local filesystem (read-write)
|
|
40
|
+
- `http`, `https` - Network resources (read-only)
|
|
41
|
+
- `rxr` - Files inside resources (read-only, auto-creates Registry)
|
|
42
|
+
|
|
43
|
+
**Semantics:**
|
|
44
|
+
|
|
45
|
+
- `text` - UTF-8 text → string
|
|
46
|
+
- `binary` - Raw bytes → Buffer
|
|
47
|
+
|
|
33
48
|
## Usage
|
|
34
49
|
|
|
35
50
|
### Basic Operations
|
|
@@ -289,21 +304,48 @@ const result = await arl.resolve({ lang: "en" });
|
|
|
289
304
|
// Fetches: https://api.example.com/data?format=json&lang=en
|
|
290
305
|
```
|
|
291
306
|
|
|
292
|
-
###
|
|
307
|
+
### RXR Transport (`rxr`)
|
|
293
308
|
|
|
294
|
-
|
|
309
|
+
Access files inside ResourceX resources (read-only).
|
|
295
310
|
|
|
296
311
|
```typescript
|
|
297
|
-
arp
|
|
298
|
-
|
|
312
|
+
// Format: arp:{semantic}:rxr://{rxl}/{internal-path}
|
|
313
|
+
arp.parse("arp:text:rxr://localhost/my-prompt.text@1.0.0/content");
|
|
314
|
+
arp.parse("arp:text:rxr://deepractice.ai/nuwa.text@1.0.0/thought/first-principles.md");
|
|
299
315
|
```
|
|
300
316
|
|
|
301
317
|
**Operations:**
|
|
302
318
|
|
|
303
|
-
- ✅ get (read)
|
|
304
|
-
-
|
|
305
|
-
- ✅ exists
|
|
306
|
-
-
|
|
319
|
+
- ✅ get (read file from resource)
|
|
320
|
+
- ❌ set (read-only, throws error)
|
|
321
|
+
- ✅ exists (check if file exists in resource)
|
|
322
|
+
- ❌ delete (read-only, throws error)
|
|
323
|
+
|
|
324
|
+
**Auto-creates Registry:**
|
|
325
|
+
|
|
326
|
+
- `localhost` domain → LocalRegistry (filesystem)
|
|
327
|
+
- Other domains → RemoteRegistry (via well-known discovery)
|
|
328
|
+
|
|
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
|
+
```
|
|
307
349
|
|
|
308
350
|
## Error Handling
|
|
309
351
|
|
package/dist/index.d.ts
CHANGED
|
@@ -408,6 +408,71 @@ declare class HttpTransportHandler implements TransportHandler {
|
|
|
408
408
|
}
|
|
409
409
|
declare const httpsTransport: HttpTransportHandler;
|
|
410
410
|
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;
|
|
411
476
|
interface TextResource extends Resource<string> {
|
|
412
477
|
type: "text";
|
|
413
478
|
content: string;
|
|
@@ -437,4 +502,4 @@ declare class BinarySemanticHandler implements SemanticHandler<Buffer> {
|
|
|
437
502
|
}
|
|
438
503
|
declare const binarySemantic: BinarySemanticHandler;
|
|
439
504
|
declare const VERSION: string;
|
|
440
|
-
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 };
|
|
505
|
+
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 };
|