resourcexjs 2.4.1 → 2.5.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/dist/index.d.ts CHANGED
@@ -1,21 +1,160 @@
1
- import { ResourceXError, LocatorError, ManifestError, ContentError } from "@resourcexjs/core";
2
- import { ResourceTypeError } from "@resourcexjs/type";
1
+ import { BundledType, IsolatorType } from "@resourcexjs/type";
2
+ /**
3
+ * ResourceX configuration.
4
+ */
5
+ interface ResourceXConfig {
6
+ /**
7
+ * Base path for local storage.
8
+ * Default: ~/.resourcex
9
+ */
10
+ path?: string;
11
+ /**
12
+ * Central registry URL.
13
+ * Required for push/pull operations.
14
+ */
15
+ registry?: string;
16
+ /**
17
+ * Additional custom resource types.
18
+ * Built-in types (text, json, binary) are always included.
19
+ */
20
+ types?: BundledType[];
21
+ /**
22
+ * Isolator type for resolver execution.
23
+ * - "none": No isolation (default)
24
+ * - "srt": OS-level isolation
25
+ * - "cloudflare": Container isolation
26
+ * - "e2b": MicroVM isolation
27
+ */
28
+ isolator?: IsolatorType;
29
+ }
30
+ /**
31
+ * Resource - user-facing resource object.
32
+ *
33
+ * Three forms of resource reference:
34
+ * - path: local directory (e.g., "./my-prompt")
35
+ * - locator: identifier string (e.g., "hello.text@1.0.0")
36
+ * - resource: this object with full metadata
37
+ */
38
+ interface Resource {
39
+ /** Full locator string (e.g., "registry.example.com/hello.text@1.0.0") */
40
+ locator: string;
41
+ /** Resource registry (optional for local resources) */
42
+ registry?: string;
43
+ /** Resource path within registry (optional) */
44
+ path?: string;
45
+ /** Resource name */
46
+ name: string;
47
+ /** Resource type (e.g., "text", "json") */
48
+ type: string;
49
+ /** Tag (e.g., "1.0.0", "latest", "stable") */
50
+ tag: string;
51
+ /** File list in the resource archive */
52
+ files?: string[];
53
+ }
54
+ /**
55
+ * Executable resource - result of use().
56
+ */
57
+ interface Executable<T = unknown> {
58
+ /**
59
+ * Execute the resource resolver.
60
+ */
61
+ execute: (args?: unknown) => Promise<T>;
62
+ /**
63
+ * JSON schema for arguments (if any).
64
+ */
65
+ schema?: unknown;
66
+ }
67
+ /**
68
+ * ResourceX interface - unified API for resource management.
69
+ *
70
+ * Users interact only with:
71
+ * - path: local directory
72
+ * - locator: resource identifier string (e.g., "hello.text@1.0.0")
73
+ */
74
+ interface ResourceX {
75
+ /**
76
+ * Add resource from directory to local storage.
77
+ * @returns The added resource
78
+ */
79
+ add(path: string): Promise<Resource>;
80
+ /**
81
+ * Link development directory (symlink for live editing).
82
+ */
83
+ link(path: string): Promise<void>;
84
+ /**
85
+ * Unlink development directory.
86
+ */
87
+ unlink(locator: string): Promise<void>;
88
+ /**
89
+ * Check if resource exists locally.
90
+ */
91
+ has(locator: string): Promise<boolean>;
92
+ /**
93
+ * Get detailed resource information.
94
+ * @returns Resource with files list
95
+ */
96
+ info(locator: string): Promise<Resource>;
97
+ /**
98
+ * Remove resource from local storage.
99
+ */
100
+ remove(locator: string): Promise<void>;
101
+ /**
102
+ * Use resource and return executable.
103
+ * Checks: linked → local → cache → remote
104
+ */
105
+ use<T = unknown>(locator: string): Promise<Executable<T>>;
106
+ /**
107
+ * Search local resources.
108
+ * @returns Array of locator strings
109
+ */
110
+ search(query?: string): Promise<string[]>;
111
+ /**
112
+ * Push local resource to remote registry.
113
+ */
114
+ push(locator: string): Promise<void>;
115
+ /**
116
+ * Pull resource from remote to local cache.
117
+ */
118
+ pull(locator: string): Promise<void>;
119
+ /**
120
+ * Clear cached resources.
121
+ * @param registry - If provided, only clear resources from this registry
122
+ */
123
+ clearCache(registry?: string): Promise<void>;
124
+ /**
125
+ * Add support for custom resource type.
126
+ */
127
+ supportType(type: BundledType): void;
128
+ }
129
+ /**
130
+ * Create a ResourceX client instance.
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * const rx = createResourceX({
135
+ * registry: "https://registry.mycompany.com"
136
+ * });
137
+ *
138
+ * // Add from directory to local
139
+ * await rx.add("./my-prompt");
140
+ *
141
+ * // Use and execute
142
+ * const result = await rx.use("my-prompt.text@1.0.0");
143
+ * await result.execute();
144
+ *
145
+ * // Push to remote registry
146
+ * await rx.push("./my-prompt");
147
+ *
148
+ * // Pull from remote registry
149
+ * await rx.pull("my-prompt.text@1.0.0");
150
+ * ```
151
+ */
152
+ declare function createResourceX(config?: ResourceXConfig): ResourceX;
153
+ import { parse, format, manifest, archive, resource, extract, wrap } from "@resourcexjs/core";
154
+ import { RXL, RXM, RXA, RXR, RXD } from "@resourcexjs/core";
3
155
  import { RegistryError } from "@resourcexjs/registry";
4
- import { RXL } from "@resourcexjs/core";
5
- import { parseRXL } from "@resourcexjs/core";
6
- import { RXM, ManifestData } from "@resourcexjs/core";
7
- import { createRXM } from "@resourcexjs/core";
8
- import { RXA, RXP, RXAInput, PathNode } from "@resourcexjs/core";
9
- import { createRXA } from "@resourcexjs/core";
10
- import { RXR } from "@resourcexjs/core";
11
- import { ResourceType, ResourceResolver, ResolvedResource, JSONSchema, BundledType, IsolatorType } from "@resourcexjs/type";
12
- import { TypeHandlerChain, bundleResourceType } from "@resourcexjs/type";
13
- import { textType, jsonType, binaryType, builtinTypes } from "@resourcexjs/type";
14
- import { ResourceLoader } from "@resourcexjs/loader";
15
- import { loadResource, FolderLoader } from "@resourcexjs/loader";
16
- import { LoadResourceConfig } from "@resourcexjs/loader";
17
- import { Registry, RegistryConfig, ClientRegistryConfig, ServerRegistryConfig, CreateRegistryConfig, DiscoveryResult, WellKnownResponse, Storage, SearchOptions } from "@resourcexjs/registry";
18
- import { DefaultRegistry, createRegistry, discoverRegistry, LocalStorage } from "@resourcexjs/registry";
19
- import { RegistryMiddleware, DomainValidation, withDomainValidation } from "@resourcexjs/registry";
156
+ import { ResourceTypeError } from "@resourcexjs/type";
157
+ import { BundledType as BundledType2, IsolatorType as IsolatorType2 } from "@resourcexjs/type";
158
+ import { bundleResourceType } from "@resourcexjs/type";
20
159
  declare const VERSION: string;
21
- export { withDomainValidation, textType, parseRXL, loadResource, jsonType, discoverRegistry, createRegistry, createRXM, createRXA, bundleResourceType, builtinTypes, binaryType, WellKnownResponse, VERSION, TypeHandlerChain, Storage, ServerRegistryConfig, SearchOptions, ResourceXError, ResourceTypeError, ResourceType, ResourceResolver, ResourceLoader, ResolvedResource, RegistryMiddleware, RegistryError, RegistryConfig, Registry, RXR, RXP, RXM, RXL, RXAInput, RXA, PathNode, ManifestError, ManifestData, LocatorError, LocalStorage, LoadResourceConfig, JSONSchema, IsolatorType, FolderLoader, DomainValidation, DiscoveryResult, DefaultRegistry, CreateRegistryConfig, ContentError, ClientRegistryConfig, BundledType };
160
+ export { wrap, resource, parse, manifest, format, extract, createResourceX, bundleResourceType, archive, VERSION, ResourceXConfig, ResourceX, ResourceTypeError, Resource, RegistryError, RXR, RXM, RXL, RXD, RXA, IsolatorType2 as IsolatorType, Executable, BundledType2 as BundledType };