@resourcexjs/registry 2.1.1 → 2.3.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 +10 -10
- package/dist/index.d.ts +93 -120
- package/dist/index.js +2166 -402
- package/dist/index.js.map +14 -12
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ const rxr = await loadResource("./my-prompt");
|
|
|
66
66
|
|
|
67
67
|
// Link to registry
|
|
68
68
|
const registry = createRegistry();
|
|
69
|
-
await registry.
|
|
69
|
+
await registry.add(rxr);
|
|
70
70
|
|
|
71
71
|
// Now available at: ~/.resourcex/localhost/my-prompt.text@1.0.0/
|
|
72
72
|
```
|
|
@@ -135,7 +135,7 @@ Link a resource to local registry.
|
|
|
135
135
|
- `resource: RXR` - Complete resource object
|
|
136
136
|
|
|
137
137
|
```typescript
|
|
138
|
-
await registry.
|
|
138
|
+
await registry.add(rxr);
|
|
139
139
|
```
|
|
140
140
|
|
|
141
141
|
#### `resolve(locator: string): Promise<RXR>`
|
|
@@ -358,7 +358,7 @@ const rxr = await loadResource("./my-prompts/assistant");
|
|
|
358
358
|
const registry = createRegistry();
|
|
359
359
|
|
|
360
360
|
// 3. Link to local registry
|
|
361
|
-
await registry.
|
|
361
|
+
await registry.add(rxr);
|
|
362
362
|
|
|
363
363
|
// 4. Resolve later
|
|
364
364
|
const resolved = await registry.resolve("localhost/assistant.prompt@1.0.0");
|
|
@@ -374,9 +374,9 @@ console.log(text);
|
|
|
374
374
|
const registry = createRegistry();
|
|
375
375
|
|
|
376
376
|
// Link multiple versions
|
|
377
|
-
await registry.
|
|
378
|
-
await registry.
|
|
379
|
-
await registry.
|
|
377
|
+
await registry.add(promptV1); // v1.0.0
|
|
378
|
+
await registry.add(promptV2); // v2.0.0
|
|
379
|
+
await registry.add(promptV3); // v3.0.0
|
|
380
380
|
|
|
381
381
|
// Resolve specific version
|
|
382
382
|
const v1 = await registry.resolve("localhost/prompt.text@1.0.0");
|
|
@@ -392,7 +392,7 @@ const registry = createRegistry({
|
|
|
392
392
|
path: "./project-registry",
|
|
393
393
|
});
|
|
394
394
|
|
|
395
|
-
await registry.
|
|
395
|
+
await registry.add(rxr);
|
|
396
396
|
// Stored at: ./project-registry/localhost/...
|
|
397
397
|
```
|
|
398
398
|
|
|
@@ -406,9 +406,9 @@ const registry = createRegistry({
|
|
|
406
406
|
});
|
|
407
407
|
|
|
408
408
|
// Now can handle these custom types
|
|
409
|
-
await registry.
|
|
410
|
-
await registry.
|
|
411
|
-
await registry.
|
|
409
|
+
await registry.add(promptResource);
|
|
410
|
+
await registry.add(toolResource);
|
|
411
|
+
await registry.add(agentResource);
|
|
412
412
|
```
|
|
413
413
|
|
|
414
414
|
## Resolution Strategy
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,44 @@ interface GitRegistryConfig {
|
|
|
46
46
|
domain?: string;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
+
* GitHub registry configuration (internal).
|
|
50
|
+
* Uses GitHub's archive API to download tarball (faster than git clone).
|
|
51
|
+
*/
|
|
52
|
+
interface GitHubRegistryConfig {
|
|
53
|
+
type: "github";
|
|
54
|
+
/** GitHub repository URL (format: https://github.com/owner/repo) */
|
|
55
|
+
url: string;
|
|
56
|
+
/** Git ref (branch, tag, or commit). Default: "main" */
|
|
57
|
+
ref?: string;
|
|
58
|
+
/** Base path in repo for resources. Default: ".resourcex" */
|
|
59
|
+
basePath?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Trusted domain for this registry.
|
|
62
|
+
* If set, only resources with this domain in manifest are allowed.
|
|
63
|
+
*/
|
|
64
|
+
domain?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* URL-based registry configuration.
|
|
68
|
+
* Auto-detects registry type based on URL format:
|
|
69
|
+
* - https://github.com/... → GitHubRegistry (tarball download)
|
|
70
|
+
* - git@... or *.git → GitRegistry (git clone)
|
|
71
|
+
* - https://... (other) → RemoteRegistry (HTTP API)
|
|
72
|
+
*/
|
|
73
|
+
interface UrlRegistryConfig {
|
|
74
|
+
/** Registry URL - type is auto-detected */
|
|
75
|
+
url: string;
|
|
76
|
+
/** Git ref (branch, tag, or commit). Default: "main" */
|
|
77
|
+
ref?: string;
|
|
78
|
+
/** Base path in repo for resources. Default: ".resourcex" */
|
|
79
|
+
basePath?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Trusted domain for this registry.
|
|
82
|
+
* Required for remote URLs (security).
|
|
83
|
+
*/
|
|
84
|
+
domain?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
49
87
|
* Well-known discovery response format.
|
|
50
88
|
* Used by discoverRegistry() to find registry for a domain.
|
|
51
89
|
*/
|
|
@@ -68,17 +106,9 @@ interface DiscoveryResult {
|
|
|
68
106
|
registries: string[];
|
|
69
107
|
}
|
|
70
108
|
/**
|
|
71
|
-
* Registry configuration - local, remote, or
|
|
109
|
+
* Registry configuration - local, remote, git, github, or URL-based.
|
|
72
110
|
*/
|
|
73
|
-
type RegistryConfig = LocalRegistryConfig | RemoteRegistryConfig | GitRegistryConfig;
|
|
74
|
-
/**
|
|
75
|
-
* Type guard to check if config is for remote registry.
|
|
76
|
-
*/
|
|
77
|
-
declare function isRemoteConfig(config?: RegistryConfig): config is RemoteRegistryConfig;
|
|
78
|
-
/**
|
|
79
|
-
* Type guard to check if config is for git registry.
|
|
80
|
-
*/
|
|
81
|
-
declare function isGitConfig(config?: RegistryConfig): config is GitRegistryConfig;
|
|
111
|
+
type RegistryConfig = LocalRegistryConfig | RemoteRegistryConfig | GitRegistryConfig | GitHubRegistryConfig | UrlRegistryConfig;
|
|
82
112
|
/**
|
|
83
113
|
* Search options for querying resources.
|
|
84
114
|
*/
|
|
@@ -136,6 +166,18 @@ interface Registry {
|
|
|
136
166
|
*/
|
|
137
167
|
supportType(type: ResourceType): void;
|
|
138
168
|
/**
|
|
169
|
+
* Link a development directory to local registry.
|
|
170
|
+
* Creates a symlink so changes are reflected immediately.
|
|
171
|
+
* @param path - Path to resource directory (must contain resource.json)
|
|
172
|
+
*/
|
|
173
|
+
link(path: string): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Add resource to local registry.
|
|
176
|
+
* Copies resource content to local storage.
|
|
177
|
+
* @param source - Resource directory path or RXR object
|
|
178
|
+
*/
|
|
179
|
+
add(source: string | RXR): Promise<void>;
|
|
180
|
+
/**
|
|
139
181
|
* Pull resource from remote registry to local cache.
|
|
140
182
|
* Discovers remote registry via well-known and caches locally.
|
|
141
183
|
* @param locator - Resource locator (must include domain)
|
|
@@ -144,15 +186,10 @@ interface Registry {
|
|
|
144
186
|
pull(locator: string, options?: PullOptions): Promise<void>;
|
|
145
187
|
/**
|
|
146
188
|
* Publish resource to remote registry.
|
|
147
|
-
* Resource
|
|
148
|
-
* @param
|
|
149
|
-
* @param options - Publish target configuration
|
|
189
|
+
* @param source - Resource directory path or RXR object
|
|
190
|
+
* @param options - Publish target configuration (required)
|
|
150
191
|
*/
|
|
151
|
-
publish(
|
|
152
|
-
/**
|
|
153
|
-
* Link resource to local registry (for development/caching).
|
|
154
|
-
*/
|
|
155
|
-
link(resource: RXR): Promise<void>;
|
|
192
|
+
publish(source: string | RXR, options: PublishOptions): Promise<void>;
|
|
156
193
|
/**
|
|
157
194
|
* Get raw resource by locator string.
|
|
158
195
|
* Returns the RXR (locator + manifest + content) without resolving.
|
|
@@ -231,12 +268,18 @@ declare class LocalRegistry implements Registry {
|
|
|
231
268
|
*/
|
|
232
269
|
private findArea;
|
|
233
270
|
/**
|
|
271
|
+
* Check if a path is a symlink.
|
|
272
|
+
*/
|
|
273
|
+
private isSymlink;
|
|
274
|
+
/**
|
|
234
275
|
* Load resource from a specific path.
|
|
276
|
+
* If path is a symlink, loads from the linked directory using FolderLoader.
|
|
235
277
|
*/
|
|
236
278
|
private loadFrom;
|
|
279
|
+
link(path: string): Promise<void>;
|
|
280
|
+
add(source: string | RXR2): Promise<void>;
|
|
237
281
|
pull(_locator: string, _options?: PullOptions): Promise<void>;
|
|
238
|
-
publish(
|
|
239
|
-
link(resource: RXR2): Promise<void>;
|
|
282
|
+
publish(_source: string | RXR2, _options: PublishOptions): Promise<void>;
|
|
240
283
|
get(locator: string): Promise<RXR2>;
|
|
241
284
|
resolve<
|
|
242
285
|
TArgs = void,
|
|
@@ -260,113 +303,42 @@ declare class LocalRegistry implements Registry {
|
|
|
260
303
|
*/
|
|
261
304
|
private parseNameType;
|
|
262
305
|
}
|
|
263
|
-
import { RXR as RXR3, RXL as RXL3 } from "@resourcexjs/core";
|
|
264
|
-
import { ResourceType as ResourceType3, ResolvedResource as ResolvedResource3 } from "@resourcexjs/type";
|
|
265
|
-
/**
|
|
266
|
-
* Remote registry implementation.
|
|
267
|
-
* Uses HTTP API for resource access.
|
|
268
|
-
*/
|
|
269
|
-
declare class RemoteRegistry implements Registry {
|
|
270
|
-
private readonly endpoint;
|
|
271
|
-
private readonly typeHandler;
|
|
272
|
-
constructor(config: RemoteRegistryConfig);
|
|
273
|
-
supportType(type: ResourceType3): void;
|
|
274
|
-
pull(_locator: string, _options?: PullOptions): Promise<void>;
|
|
275
|
-
publish(_resource: RXR3, _options: PublishOptions): Promise<void>;
|
|
276
|
-
link(_resource: RXR3): Promise<void>;
|
|
277
|
-
get(locator: string): Promise<RXR3>;
|
|
278
|
-
resolve<
|
|
279
|
-
TArgs = void,
|
|
280
|
-
TResult = unknown
|
|
281
|
-
>(locator: string): Promise<ResolvedResource3<TArgs, TResult>>;
|
|
282
|
-
exists(locator: string): Promise<boolean>;
|
|
283
|
-
delete(_locator: string): Promise<void>;
|
|
284
|
-
search(options?: SearchOptions): Promise<RXL3[]>;
|
|
285
|
-
}
|
|
286
306
|
/**
|
|
287
307
|
* Discover registry for a domain using well-known.
|
|
288
308
|
* @param domain - The domain to discover (e.g., "deepractice.ai")
|
|
289
309
|
* @returns Discovery result with domain and authorized registries
|
|
290
310
|
*/
|
|
291
311
|
declare function discoverRegistry(domain: string): Promise<DiscoveryResult>;
|
|
292
|
-
import { RXR as RXR4, RXL as RXL4 } from "@resourcexjs/core";
|
|
293
|
-
import { ResourceType as ResourceType4, ResolvedResource as ResolvedResource4 } from "@resourcexjs/type";
|
|
294
|
-
declare class GitRegistry implements Registry {
|
|
295
|
-
private readonly url;
|
|
296
|
-
private readonly ref;
|
|
297
|
-
private readonly basePath;
|
|
298
|
-
private readonly cacheDir;
|
|
299
|
-
private readonly typeHandler;
|
|
300
|
-
private readonly arp;
|
|
301
|
-
private readonly isLocal;
|
|
302
|
-
constructor(config: GitRegistryConfig);
|
|
303
|
-
/**
|
|
304
|
-
* Build cache directory name from git URL.
|
|
305
|
-
* git@github.com:Deepractice/Registry.git → github.com-Deepractice-Registry
|
|
306
|
-
*/
|
|
307
|
-
private buildCacheDir;
|
|
308
|
-
supportType(type: ResourceType4): void;
|
|
309
|
-
/**
|
|
310
|
-
* Create ARP URL for a file path.
|
|
311
|
-
*/
|
|
312
|
-
private toArpUrl;
|
|
313
|
-
/**
|
|
314
|
-
* Ensure the repository is cloned and up to date.
|
|
315
|
-
* For local paths, just verify the .git directory exists.
|
|
316
|
-
* For remote URLs, includes retry logic for transient network errors.
|
|
317
|
-
*/
|
|
318
|
-
private ensureCloned;
|
|
319
|
-
/**
|
|
320
|
-
* Get the default branch name (main or master).
|
|
321
|
-
*/
|
|
322
|
-
private getDefaultBranch;
|
|
323
|
-
/**
|
|
324
|
-
* Build filesystem path for a resource in the cloned repo.
|
|
325
|
-
* Path structure: {cacheDir}/{basePath}/{domain}/{path}/{name}.{type}/{version}
|
|
326
|
-
*/
|
|
327
|
-
private buildResourcePath;
|
|
328
|
-
get(locator: string): Promise<RXR4>;
|
|
329
|
-
resolve<
|
|
330
|
-
TArgs = void,
|
|
331
|
-
TResult = unknown
|
|
332
|
-
>(locator: string): Promise<ResolvedResource4<TArgs, TResult>>;
|
|
333
|
-
exists(locator: string): Promise<boolean>;
|
|
334
|
-
search(options?: SearchOptions): Promise<RXL4[]>;
|
|
335
|
-
private parseEntryToRXL;
|
|
336
|
-
pull(_locator: string, _options?: PullOptions): Promise<void>;
|
|
337
|
-
publish(_resource: RXR4, _options: PublishOptions): Promise<void>;
|
|
338
|
-
link(_resource: RXR4): Promise<void>;
|
|
339
|
-
delete(_locator: string): Promise<void>;
|
|
340
|
-
}
|
|
341
312
|
/**
|
|
342
313
|
* Create a registry instance.
|
|
343
314
|
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
* - GitRegistryConfig: Creates GitRegistry (git clone-based)
|
|
315
|
+
* Supports multiple configuration styles:
|
|
316
|
+
* - No config: LocalRegistry (filesystem-based)
|
|
317
|
+
* - `{ url, domain }`: Auto-detects type based on URL format
|
|
318
|
+
* - `{ endpoint }`: RemoteRegistry (HTTP API)
|
|
319
|
+
* - `{ type: "git", url }`: GitRegistry (git clone)
|
|
320
|
+
* - `{ type: "github", url }`: GitHubRegistry (tarball download)
|
|
351
321
|
*
|
|
352
322
|
* @example
|
|
353
323
|
* // Local registry (default)
|
|
354
324
|
* const registry = createRegistry();
|
|
355
|
-
* const registry2 = createRegistry({ path: "./custom-path" });
|
|
356
325
|
*
|
|
357
|
-
* //
|
|
358
|
-
* const
|
|
326
|
+
* // URL-based (auto-detect type)
|
|
327
|
+
* const registry2 = createRegistry({
|
|
328
|
+
* url: "https://github.com/Deepractice/Registry",
|
|
329
|
+
* domain: "deepractice.dev",
|
|
330
|
+
* });
|
|
359
331
|
*
|
|
360
|
-
* //
|
|
361
|
-
* const
|
|
362
|
-
*
|
|
363
|
-
* url:
|
|
364
|
-
* domain:
|
|
332
|
+
* // With discovery
|
|
333
|
+
* const discovery = await discoverRegistry("deepractice.dev");
|
|
334
|
+
* const registry3 = createRegistry({
|
|
335
|
+
* url: discovery.registries[0],
|
|
336
|
+
* domain: discovery.domain,
|
|
365
337
|
* });
|
|
366
338
|
*/
|
|
367
339
|
declare function createRegistry(config?: RegistryConfig): Registry;
|
|
368
|
-
import { RXR as
|
|
369
|
-
import { ResourceType as
|
|
340
|
+
import { RXR as RXR4, RXL as RXL4 } from "@resourcexjs/core";
|
|
341
|
+
import { ResourceType as ResourceType4, ResolvedResource as ResolvedResource4 } from "@resourcexjs/type";
|
|
370
342
|
/**
|
|
371
343
|
* Base class for Registry middleware.
|
|
372
344
|
* Delegates all operations to the inner registry.
|
|
@@ -375,21 +347,22 @@ import { ResourceType as ResourceType5, ResolvedResource as ResolvedResource5 }
|
|
|
375
347
|
declare abstract class RegistryMiddleware implements Registry {
|
|
376
348
|
protected readonly inner: Registry;
|
|
377
349
|
constructor(inner: Registry);
|
|
378
|
-
supportType(type:
|
|
350
|
+
supportType(type: ResourceType4): void;
|
|
351
|
+
link(path: string): Promise<void>;
|
|
352
|
+
add(source: string | RXR4): Promise<void>;
|
|
379
353
|
pull(locator: string, options?: PullOptions): Promise<void>;
|
|
380
|
-
publish(
|
|
381
|
-
|
|
382
|
-
get(locator: string): Promise<RXR5>;
|
|
354
|
+
publish(source: string | RXR4, options: PublishOptions): Promise<void>;
|
|
355
|
+
get(locator: string): Promise<RXR4>;
|
|
383
356
|
resolve<
|
|
384
357
|
TArgs = void,
|
|
385
358
|
TResult = unknown
|
|
386
|
-
>(locator: string): Promise<
|
|
359
|
+
>(locator: string): Promise<ResolvedResource4<TArgs, TResult>>;
|
|
387
360
|
exists(locator: string): Promise<boolean>;
|
|
388
361
|
delete(locator: string): Promise<void>;
|
|
389
|
-
search(options?: SearchOptions): Promise<
|
|
362
|
+
search(options?: SearchOptions): Promise<RXL4[]>;
|
|
390
363
|
}
|
|
391
|
-
import { RXR as
|
|
392
|
-
import { ResolvedResource as
|
|
364
|
+
import { RXR as RXR5 } from "@resourcexjs/core";
|
|
365
|
+
import { ResolvedResource as ResolvedResource5 } from "@resourcexjs/type";
|
|
393
366
|
/**
|
|
394
367
|
* Domain validation middleware.
|
|
395
368
|
* Ensures all resources from this registry match the trusted domain.
|
|
@@ -404,14 +377,14 @@ declare class DomainValidation extends RegistryMiddleware {
|
|
|
404
377
|
/**
|
|
405
378
|
* Get resource and validate domain.
|
|
406
379
|
*/
|
|
407
|
-
get(locator: string): Promise<
|
|
380
|
+
get(locator: string): Promise<RXR5>;
|
|
408
381
|
/**
|
|
409
382
|
* Resolve resource and validate domain.
|
|
410
383
|
*/
|
|
411
384
|
resolve<
|
|
412
385
|
TArgs = void,
|
|
413
386
|
TResult = unknown
|
|
414
|
-
>(locator: string): Promise<
|
|
387
|
+
>(locator: string): Promise<ResolvedResource5<TArgs, TResult>>;
|
|
415
388
|
}
|
|
416
389
|
/**
|
|
417
390
|
* Factory function to create domain validation middleware.
|
|
@@ -420,4 +393,4 @@ declare class DomainValidation extends RegistryMiddleware {
|
|
|
420
393
|
* const registry = withDomainValidation(gitRegistry, "deepractice.ai");
|
|
421
394
|
*/
|
|
422
395
|
declare function withDomainValidation(registry: Registry, trustedDomain: string): Registry;
|
|
423
|
-
export { withDomainValidation,
|
|
396
|
+
export { withDomainValidation, discoverRegistry, createRegistry, WellKnownResponse, UrlRegistryConfig, SearchOptions, RemoteRegistryConfig, RegistryMiddleware, RegistryError, RegistryConfig, Registry, PullOptions, PublishTarget, PublishOptions, LocalRegistryConfig, LocalRegistry, DomainValidation, DiscoveryResult };
|