@resourcexjs/core 2.7.0 → 2.8.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/dist/index.d.ts +711 -418
- package/dist/index.js +14750 -14442
- package/dist/index.js.map +34 -26
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ResourceX
|
|
2
|
+
* RXA - ResourceX Archive
|
|
3
|
+
*
|
|
4
|
+
* Archive container (tar.gz format) for storage and transfer.
|
|
3
5
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
constructor(message: string, locator?: string);
|
|
10
|
-
}
|
|
11
|
-
declare class ManifestError extends ResourceXError {
|
|
12
|
-
constructor(message: string);
|
|
13
|
-
}
|
|
14
|
-
declare class ContentError extends ResourceXError {
|
|
15
|
-
constructor(message: string);
|
|
16
|
-
}
|
|
17
|
-
declare class DefinitionError extends ResourceXError {
|
|
18
|
-
constructor(message: string);
|
|
6
|
+
interface RXA {
|
|
7
|
+
/** Content as a readable stream (tar.gz format) */
|
|
8
|
+
readonly stream: ReadableStream<Uint8Array>;
|
|
9
|
+
/** Get raw archive buffer (tar.gz format) */
|
|
10
|
+
buffer(): Promise<Buffer>;
|
|
19
11
|
}
|
|
20
12
|
/**
|
|
13
|
+
* Create RXA from files.
|
|
14
|
+
*
|
|
15
|
+
* @param files - Record of file paths to Buffer contents
|
|
16
|
+
* @returns RXA archive object
|
|
17
|
+
*/
|
|
18
|
+
declare function archive(files: Record<string, Buffer>): Promise<RXA>;
|
|
19
|
+
/**
|
|
21
20
|
* RXD - ResourceX Definition
|
|
22
21
|
*
|
|
23
22
|
* The content of resource.json file.
|
|
@@ -37,6 +36,21 @@ interface RXD {
|
|
|
37
36
|
readonly [key: string]: unknown;
|
|
38
37
|
}
|
|
39
38
|
/**
|
|
39
|
+
* Parse and validate a resource definition (resource.json content).
|
|
40
|
+
*
|
|
41
|
+
* @param input - The raw JSON object to parse
|
|
42
|
+
* @returns A validated RXD object
|
|
43
|
+
* @throws DefinitionError if validation fails
|
|
44
|
+
*/
|
|
45
|
+
declare function define(input: unknown): RXD;
|
|
46
|
+
/**
|
|
47
|
+
* Extract files from RXA.
|
|
48
|
+
*
|
|
49
|
+
* @param rxa - Resource archive
|
|
50
|
+
* @returns Record of file paths to Buffer contents
|
|
51
|
+
*/
|
|
52
|
+
declare function extract(rxa: RXA): Promise<Record<string, Buffer>>;
|
|
53
|
+
/**
|
|
40
54
|
* RXL - ResourceX Locator
|
|
41
55
|
*
|
|
42
56
|
* Unique identifier for a resource (pure data object).
|
|
@@ -62,6 +76,20 @@ interface RXL {
|
|
|
62
76
|
readonly tag: string;
|
|
63
77
|
}
|
|
64
78
|
/**
|
|
79
|
+
* Format RXL to locator string.
|
|
80
|
+
*
|
|
81
|
+
* Docker-style format: [registry/][path/]name[:tag]
|
|
82
|
+
*
|
|
83
|
+
* Examples:
|
|
84
|
+
* - { name: "hello", tag: "latest" } → "hello" (omit :latest)
|
|
85
|
+
* - { name: "hello", tag: "1.0.0" } → "hello:1.0.0"
|
|
86
|
+
* - { registry: "localhost:3098", name: "hello", tag: "1.0.0" } → "localhost:3098/hello:1.0.0"
|
|
87
|
+
*
|
|
88
|
+
* @param rxl - Resource locator
|
|
89
|
+
* @returns Locator string
|
|
90
|
+
*/
|
|
91
|
+
declare function format(rxl: RXL): string;
|
|
92
|
+
/**
|
|
65
93
|
* RXM - ResourceX Manifest
|
|
66
94
|
*
|
|
67
95
|
* Resource metadata stored within the resource (pure data object).
|
|
@@ -75,34 +103,12 @@ interface RXM {
|
|
|
75
103
|
readonly files?: string[];
|
|
76
104
|
}
|
|
77
105
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* Archive container (tar.gz format) for storage and transfer.
|
|
81
|
-
*/
|
|
82
|
-
interface RXA {
|
|
83
|
-
/** Content as a readable stream (tar.gz format) */
|
|
84
|
-
readonly stream: ReadableStream<Uint8Array>;
|
|
85
|
-
/** Get raw archive buffer (tar.gz format) */
|
|
86
|
-
buffer(): Promise<Buffer>;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* RXR - ResourceX Resource
|
|
90
|
-
*
|
|
91
|
-
* Complete resource object combining locator, manifest, and archive.
|
|
92
|
-
*/
|
|
93
|
-
interface RXR {
|
|
94
|
-
readonly locator: RXL;
|
|
95
|
-
readonly manifest: RXM;
|
|
96
|
-
readonly archive: RXA;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Parse and validate a resource definition (resource.json content).
|
|
106
|
+
* Create RXL from RXM.
|
|
100
107
|
*
|
|
101
|
-
* @param
|
|
102
|
-
* @returns
|
|
103
|
-
* @throws DefinitionError if validation fails
|
|
108
|
+
* @param rxm - Resource manifest
|
|
109
|
+
* @returns RXL locator object (pure data)
|
|
104
110
|
*/
|
|
105
|
-
declare function
|
|
111
|
+
declare function locate(rxm: RXM): RXL;
|
|
106
112
|
/**
|
|
107
113
|
* Create RXM from RXD.
|
|
108
114
|
* Extracts only the core metadata fields (pure data object).
|
|
@@ -112,19 +118,31 @@ declare function define(input: unknown): RXD;
|
|
|
112
118
|
*/
|
|
113
119
|
declare function manifest(rxd: RXD): RXM;
|
|
114
120
|
/**
|
|
115
|
-
*
|
|
121
|
+
* Parse locator string to RXL.
|
|
116
122
|
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
123
|
+
* Docker-style format: [registry/][path/]name[:tag]
|
|
124
|
+
*
|
|
125
|
+
* Examples:
|
|
126
|
+
* - hello → name=hello, tag=latest
|
|
127
|
+
* - hello:1.0.0 → name=hello, tag=1.0.0
|
|
128
|
+
* - prompts/hello:stable → path=prompts, name=hello, tag=stable
|
|
129
|
+
* - localhost:3098/hello:1.0.0 → registry=localhost:3098, name=hello, tag=1.0.0
|
|
130
|
+
*
|
|
131
|
+
* @param locator - Locator string
|
|
132
|
+
* @returns RXL object
|
|
133
|
+
* @throws LocatorError if parsing fails
|
|
119
134
|
*/
|
|
120
|
-
declare function
|
|
135
|
+
declare function parse(locator: string): RXL;
|
|
121
136
|
/**
|
|
122
|
-
*
|
|
137
|
+
* RXR - ResourceX Resource
|
|
123
138
|
*
|
|
124
|
-
*
|
|
125
|
-
* @returns RXL locator object (pure data)
|
|
139
|
+
* Complete resource object combining locator, manifest, and archive.
|
|
126
140
|
*/
|
|
127
|
-
|
|
141
|
+
interface RXR {
|
|
142
|
+
readonly locator: RXL;
|
|
143
|
+
readonly manifest: RXM;
|
|
144
|
+
readonly archive: RXA;
|
|
145
|
+
}
|
|
128
146
|
/**
|
|
129
147
|
* Create RXR from RXM and RXA.
|
|
130
148
|
*
|
|
@@ -134,42 +152,20 @@ declare function locate(rxm: RXM): RXL;
|
|
|
134
152
|
*/
|
|
135
153
|
declare function resource(rxm: RXM, rxa: RXA): RXR;
|
|
136
154
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* @param rxa - Resource archive
|
|
140
|
-
* @returns Record of file paths to Buffer contents
|
|
141
|
-
*/
|
|
142
|
-
declare function extract(rxa: RXA): Promise<Record<string, Buffer>>;
|
|
143
|
-
/**
|
|
144
|
-
* Format RXL to locator string.
|
|
145
|
-
*
|
|
146
|
-
* Docker-style format: [registry/][path/]name[:tag]
|
|
147
|
-
*
|
|
148
|
-
* Examples:
|
|
149
|
-
* - { name: "hello", tag: "latest" } → "hello" (omit :latest)
|
|
150
|
-
* - { name: "hello", tag: "1.0.0" } → "hello:1.0.0"
|
|
151
|
-
* - { registry: "localhost:3098", name: "hello", tag: "1.0.0" } → "localhost:3098/hello:1.0.0"
|
|
152
|
-
*
|
|
153
|
-
* @param rxl - Resource locator
|
|
154
|
-
* @returns Locator string
|
|
155
|
-
*/
|
|
156
|
-
declare function format(rxl: RXL): string;
|
|
157
|
-
/**
|
|
158
|
-
* Parse locator string to RXL.
|
|
155
|
+
* RXS - ResourceX Source
|
|
159
156
|
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* Examples:
|
|
163
|
-
* - hello → name=hello, tag=latest
|
|
164
|
-
* - hello:1.0.0 → name=hello, tag=1.0.0
|
|
165
|
-
* - prompts/hello:stable → path=prompts, name=hello, tag=stable
|
|
166
|
-
* - localhost:3098/hello:1.0.0 → registry=localhost:3098, name=hello, tag=1.0.0
|
|
157
|
+
* Intermediate representation of raw files from any source.
|
|
158
|
+
* Produced by SourceLoader, consumed by TypeDetectorChain.
|
|
167
159
|
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* @throws LocatorError if parsing fails
|
|
160
|
+
* Unlike RXR (which is fully packaged), RXS is pre-detection:
|
|
161
|
+
* the files have been loaded but the type and metadata are unknown.
|
|
171
162
|
*/
|
|
172
|
-
|
|
163
|
+
interface RXS {
|
|
164
|
+
/** Original source identifier (path, URL, etc.) */
|
|
165
|
+
readonly source: string;
|
|
166
|
+
/** Raw files loaded from source: relative path -> content */
|
|
167
|
+
readonly files: Record<string, Buffer>;
|
|
168
|
+
}
|
|
173
169
|
/**
|
|
174
170
|
* Wrap existing tar.gz buffer as RXA.
|
|
175
171
|
*
|
|
@@ -178,243 +174,178 @@ declare function parse(locator: string): RXL;
|
|
|
178
174
|
*/
|
|
179
175
|
declare function wrap(buffer: Buffer): RXA;
|
|
180
176
|
/**
|
|
181
|
-
*
|
|
182
|
-
* Matches SandboX isolator types directly.
|
|
183
|
-
* Configured at Registry level, not per-type.
|
|
177
|
+
* TypeDetector - Strategy interface for detecting resource type from files.
|
|
184
178
|
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* - "cloudflare": Container isolation (~100ms), local Docker or edge
|
|
188
|
-
* - "e2b": MicroVM isolation (~150ms), production (planned)
|
|
179
|
+
* Detectors examine file contents and structure to determine
|
|
180
|
+
* the resource type and extract metadata.
|
|
189
181
|
*/
|
|
190
|
-
type IsolatorType = "none" | "srt" | "cloudflare" | "e2b";
|
|
191
182
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
* This is a serializable data structure that replaces RXR for sandbox execution.
|
|
195
|
-
* The executor pre-processes RXR (extracts files) before passing to resolver.
|
|
183
|
+
* Result of type detection.
|
|
184
|
+
* Fields map directly to RXD fields for generateDefinition().
|
|
196
185
|
*/
|
|
197
|
-
interface
|
|
198
|
-
/**
|
|
199
|
-
|
|
200
|
-
*/
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
186
|
+
interface TypeDetectionResult {
|
|
187
|
+
/** Detected resource type (e.g., "skill", "text") */
|
|
188
|
+
readonly type: string;
|
|
189
|
+
/** Detected resource name */
|
|
190
|
+
readonly name: string;
|
|
191
|
+
/** Tag/version (defaults to "latest" if not provided) */
|
|
192
|
+
readonly tag?: string;
|
|
193
|
+
/** Description extracted from content */
|
|
194
|
+
readonly description?: string;
|
|
195
|
+
/** Registry for the resource */
|
|
196
|
+
readonly registry?: string;
|
|
197
|
+
/** Path within registry */
|
|
198
|
+
readonly path?: string;
|
|
199
|
+
/** Author information */
|
|
200
|
+
readonly author?: string;
|
|
201
|
+
/** License information */
|
|
202
|
+
readonly license?: string;
|
|
203
|
+
/** Keywords for searchability */
|
|
204
|
+
readonly keywords?: string[];
|
|
205
|
+
/** Repository URL */
|
|
206
|
+
readonly repository?: string;
|
|
208
207
|
/**
|
|
209
|
-
*
|
|
210
|
-
*
|
|
208
|
+
* Files to exclude from the content archive.
|
|
209
|
+
* E.g., ["resource.json"] — metadata files, not content.
|
|
211
210
|
*/
|
|
212
|
-
|
|
211
|
+
readonly excludeFromContent?: string[];
|
|
213
212
|
}
|
|
214
213
|
/**
|
|
215
|
-
*
|
|
216
|
-
* Contains bundled code string instead of closure.
|
|
214
|
+
* TypeDetector - detects resource type from raw files.
|
|
217
215
|
*
|
|
218
|
-
*
|
|
216
|
+
* Follows the Chain of Responsibility pattern (like TypeHandlerChain).
|
|
219
217
|
*/
|
|
220
|
-
interface
|
|
221
|
-
/**
|
|
222
|
-
|
|
223
|
-
*/
|
|
224
|
-
name: string;
|
|
225
|
-
/**
|
|
226
|
-
* Alternative names for this type.
|
|
227
|
-
*/
|
|
228
|
-
aliases?: string[];
|
|
229
|
-
/**
|
|
230
|
-
* Human-readable description.
|
|
231
|
-
*/
|
|
232
|
-
description: string;
|
|
233
|
-
/**
|
|
234
|
-
* JSON Schema for resolver arguments.
|
|
235
|
-
*/
|
|
236
|
-
schema?: JSONSchema;
|
|
218
|
+
interface TypeDetector {
|
|
219
|
+
/** Detector name (for debugging and logging) */
|
|
220
|
+
readonly name: string;
|
|
237
221
|
/**
|
|
238
|
-
*
|
|
222
|
+
* Detect the resource type from the given files.
|
|
223
|
+
*
|
|
224
|
+
* @param files - Raw files from the source
|
|
225
|
+
* @param source - Original source identifier (for deriving name)
|
|
226
|
+
* @returns Detection result, or null if this detector cannot handle the files
|
|
239
227
|
*/
|
|
240
|
-
|
|
228
|
+
detect(files: Record<string, Buffer>, source: string): TypeDetectionResult | null;
|
|
241
229
|
}
|
|
242
230
|
/**
|
|
243
|
-
*
|
|
231
|
+
* Generate an RXD from a TypeDetectionResult.
|
|
232
|
+
*
|
|
233
|
+
* Maps detection result fields to the RXD schema and validates
|
|
234
|
+
* through the existing define() function.
|
|
235
|
+
*
|
|
236
|
+
* @param result - Detection result from TypeDetectorChain
|
|
237
|
+
* @returns Validated RXD
|
|
238
|
+
* @throws DefinitionError if the result produces invalid RXD
|
|
244
239
|
*/
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
240
|
+
declare function generateDefinition(result: TypeDetectionResult): RXD;
|
|
241
|
+
/**
|
|
242
|
+
* ResourceJsonDetector - Detects resources with an explicit resource.json.
|
|
243
|
+
*
|
|
244
|
+
* Highest-priority detector. When resource.json exists,
|
|
245
|
+
* it takes precedence over all other detectors.
|
|
246
|
+
*/
|
|
247
|
+
declare class ResourceJsonDetector implements TypeDetector {
|
|
248
|
+
readonly name = "resource-json";
|
|
249
|
+
detect(files: Record<string, Buffer>, _source: string): TypeDetectionResult | null;
|
|
253
250
|
}
|
|
254
251
|
/**
|
|
255
|
-
*
|
|
256
|
-
*
|
|
252
|
+
* SkillDetector - Detects Agent Skill resources from SKILL.md.
|
|
253
|
+
*
|
|
254
|
+
* Pattern:
|
|
255
|
+
* - Required: SKILL.md file
|
|
256
|
+
* - Optional: references/ directory
|
|
257
|
+
*
|
|
258
|
+
* SKILL.md is content (kept in archive), not metadata.
|
|
257
259
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
260
|
+
declare class SkillDetector implements TypeDetector {
|
|
261
|
+
readonly name = "skill";
|
|
262
|
+
detect(files: Record<string, Buffer>, source: string): TypeDetectionResult | null;
|
|
263
|
+
/**
|
|
264
|
+
* Extract description from the first markdown heading.
|
|
265
|
+
*/
|
|
266
|
+
private extractDescription;
|
|
261
267
|
}
|
|
262
268
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
269
|
+
* TypeDetectorChain - Chain of type detectors.
|
|
270
|
+
*
|
|
271
|
+
* Follows the same pattern as TypeHandlerChain:
|
|
272
|
+
* - Static create() factory with built-in detectors
|
|
273
|
+
* - Extensible via register()
|
|
274
|
+
* - First match wins
|
|
275
|
+
*
|
|
276
|
+
* Detection order:
|
|
277
|
+
* 1. ResourceJsonDetector (explicit resource.json always wins)
|
|
278
|
+
* 2. SkillDetector (SKILL.md pattern)
|
|
279
|
+
* 3. Custom detectors (registered in order)
|
|
265
280
|
*/
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
> {
|
|
281
|
+
declare class TypeDetectorChain {
|
|
282
|
+
private readonly detectors;
|
|
283
|
+
private constructor();
|
|
270
284
|
/**
|
|
271
|
-
*
|
|
285
|
+
* Create a new TypeDetectorChain with built-in detectors.
|
|
272
286
|
*/
|
|
273
|
-
|
|
287
|
+
static create(): TypeDetectorChain;
|
|
274
288
|
/**
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* - For dynamic resources (tool): call with arguments
|
|
289
|
+
* Register a custom detector.
|
|
290
|
+
* Custom detectors are appended after built-in detectors.
|
|
278
291
|
*/
|
|
279
|
-
|
|
292
|
+
register(detector: TypeDetector): void;
|
|
280
293
|
/**
|
|
281
|
-
*
|
|
282
|
-
*
|
|
294
|
+
* Detect type from files.
|
|
295
|
+
*
|
|
296
|
+
* @param files - Raw files from the source
|
|
297
|
+
* @param source - Original source identifier
|
|
298
|
+
* @returns Detection result
|
|
299
|
+
* @throws ResourceXError if no detector matches
|
|
283
300
|
*/
|
|
284
|
-
|
|
301
|
+
detect(files: Record<string, Buffer>, source: string): TypeDetectionResult;
|
|
285
302
|
}
|
|
286
303
|
/**
|
|
287
|
-
*
|
|
288
|
-
* The execute function is lazy-loaded: content is only read when called.
|
|
304
|
+
* ResourceX Error hierarchy
|
|
289
305
|
*/
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
TResult = unknown
|
|
293
|
-
> {
|
|
294
|
-
/**
|
|
295
|
-
* JSON Schema for arguments (required if TArgs is not void).
|
|
296
|
-
* This constraint ensures type safety at definition time.
|
|
297
|
-
*/
|
|
298
|
-
schema: TArgs extends void ? undefined : JSONSchema;
|
|
299
|
-
/**
|
|
300
|
-
* Resolve resource into a structured result object.
|
|
301
|
-
* @param rxr - RXR object from @resourcexjs/core
|
|
302
|
-
*/
|
|
303
|
-
resolve(rxr: unknown): Promise<ResolvedResource<TArgs, TResult>>;
|
|
306
|
+
declare class ResourceXError extends Error {
|
|
307
|
+
constructor(message: string, options?: ErrorOptions);
|
|
304
308
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
interface ResourceType<
|
|
309
|
-
TArgs = void,
|
|
310
|
-
TResult = unknown
|
|
311
|
-
> {
|
|
312
|
-
/**
|
|
313
|
-
* Type name (e.g., "text", "json", "binary").
|
|
314
|
-
*/
|
|
315
|
-
name: string;
|
|
316
|
-
/**
|
|
317
|
-
* Alternative names for this type (e.g., ["txt", "plaintext"]).
|
|
318
|
-
*/
|
|
319
|
-
aliases?: string[];
|
|
320
|
-
/**
|
|
321
|
-
* Human-readable description.
|
|
322
|
-
*/
|
|
323
|
-
description: string;
|
|
324
|
-
/**
|
|
325
|
-
* Resolver to transform RXR into structured result object.
|
|
326
|
-
*/
|
|
327
|
-
resolver: ResourceResolver<TArgs, TResult>;
|
|
309
|
+
declare class LocatorError extends ResourceXError {
|
|
310
|
+
readonly locator?: string;
|
|
311
|
+
constructor(message: string, locator?: string);
|
|
328
312
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
* @example
|
|
337
|
-
* ```typescript
|
|
338
|
-
* const promptType = await bundleResourceType("./prompt.type.ts");
|
|
339
|
-
* ```
|
|
340
|
-
*/
|
|
341
|
-
declare function bundleResourceType(sourcePath: string, basePath?: string): Promise<BundledType>;
|
|
342
|
-
/**
|
|
343
|
-
* Resource type related error.
|
|
344
|
-
*/
|
|
345
|
-
declare class ResourceTypeError extends ResourceXError {
|
|
313
|
+
declare class ManifestError extends ResourceXError {
|
|
314
|
+
constructor(message: string);
|
|
315
|
+
}
|
|
316
|
+
declare class ContentError extends ResourceXError {
|
|
317
|
+
constructor(message: string);
|
|
318
|
+
}
|
|
319
|
+
declare class DefinitionError extends ResourceXError {
|
|
346
320
|
constructor(message: string);
|
|
347
321
|
}
|
|
348
322
|
/**
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
* Responsibilities:
|
|
352
|
-
* - Register types (name + aliases)
|
|
353
|
-
* - Look up types by name
|
|
354
|
-
*
|
|
355
|
-
* Execution is delegated to ResolverExecutor (in registry package).
|
|
356
|
-
*
|
|
357
|
-
* Built-in types (text, json, binary) are registered by default.
|
|
323
|
+
* ResourceLoader - Strategy interface for loading resources from different sources.
|
|
358
324
|
*/
|
|
359
|
-
|
|
360
|
-
private handlers;
|
|
361
|
-
private constructor();
|
|
362
|
-
/**
|
|
363
|
-
* Create a new TypeHandlerChain instance.
|
|
364
|
-
* Built-in types (text, json, binary) are included by default.
|
|
365
|
-
*/
|
|
366
|
-
static create(): TypeHandlerChain;
|
|
367
|
-
/**
|
|
368
|
-
* Internal registration (no duplicate check).
|
|
369
|
-
*/
|
|
370
|
-
private registerInternal;
|
|
371
|
-
/**
|
|
372
|
-
* Register a type.
|
|
373
|
-
* @throws ResourceTypeError if type is already registered
|
|
374
|
-
*/
|
|
375
|
-
register(type: BundledType): void;
|
|
376
|
-
/**
|
|
377
|
-
* Check if a type is supported.
|
|
378
|
-
*/
|
|
379
|
-
canHandle(typeName: string): boolean;
|
|
380
|
-
/**
|
|
381
|
-
* Get handler for a type.
|
|
382
|
-
* @throws ResourceTypeError if type is not supported
|
|
383
|
-
*/
|
|
384
|
-
getHandler(typeName: string): BundledType;
|
|
385
|
-
/**
|
|
386
|
-
* Get handler for a type, or undefined if not found.
|
|
387
|
-
*/
|
|
388
|
-
getHandlerOrUndefined(typeName: string): BundledType | undefined;
|
|
325
|
+
interface ResourceLoader {
|
|
389
326
|
/**
|
|
390
|
-
*
|
|
327
|
+
* Check if this loader can handle the given source.
|
|
328
|
+
*
|
|
329
|
+
* @param source - Source path or identifier
|
|
330
|
+
* @returns true if this loader can handle the source
|
|
391
331
|
*/
|
|
392
|
-
|
|
332
|
+
canLoad(source: string): boolean | Promise<boolean>;
|
|
393
333
|
/**
|
|
394
|
-
*
|
|
334
|
+
* Load a resource from the given source.
|
|
335
|
+
*
|
|
336
|
+
* @param source - Source path or identifier
|
|
337
|
+
* @returns Complete RXR object
|
|
338
|
+
* @throws ResourceXError if loading fails
|
|
395
339
|
*/
|
|
396
|
-
|
|
340
|
+
load(source: string): Promise<RXR>;
|
|
397
341
|
}
|
|
398
342
|
/**
|
|
399
|
-
*
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
* JSON content
|
|
404
|
-
*/
|
|
405
|
-
declare const jsonType: BundledType;
|
|
406
|
-
/**
|
|
407
|
-
* Binary content
|
|
408
|
-
*/
|
|
409
|
-
declare const binaryType: BundledType;
|
|
410
|
-
/**
|
|
411
|
-
* All built-in types as an array.
|
|
412
|
-
*/
|
|
413
|
-
declare const builtinTypes: BundledType[];
|
|
414
|
-
/**
|
|
415
|
-
* ResourceLoader - Strategy interface for loading resources from different sources.
|
|
343
|
+
* SourceLoader - Strategy interface for loading raw files from a source.
|
|
344
|
+
*
|
|
345
|
+
* Unlike ResourceLoader (which produces a complete RXR),
|
|
346
|
+
* SourceLoader produces an RXS (raw files) for type detection.
|
|
416
347
|
*/
|
|
417
|
-
interface
|
|
348
|
+
interface SourceLoader {
|
|
418
349
|
/**
|
|
419
350
|
* Check if this loader can handle the given source.
|
|
420
351
|
*
|
|
@@ -423,13 +354,13 @@ interface ResourceLoader {
|
|
|
423
354
|
*/
|
|
424
355
|
canLoad(source: string): boolean | Promise<boolean>;
|
|
425
356
|
/**
|
|
426
|
-
* Load
|
|
357
|
+
* Load raw files from the given source.
|
|
427
358
|
*
|
|
428
359
|
* @param source - Source path or identifier
|
|
429
|
-
* @returns
|
|
360
|
+
* @returns RXS with raw files
|
|
430
361
|
* @throws ResourceXError if loading fails
|
|
431
362
|
*/
|
|
432
|
-
load(source: string): Promise<
|
|
363
|
+
load(source: string): Promise<RXS>;
|
|
433
364
|
}
|
|
434
365
|
/**
|
|
435
366
|
* Default ResourceLoader implementation for loading resources from folders.
|
|
@@ -463,6 +394,39 @@ declare class FolderLoader implements ResourceLoader {
|
|
|
463
394
|
private readFolderFiles;
|
|
464
395
|
}
|
|
465
396
|
/**
|
|
397
|
+
* FolderSourceLoader - Loads raw files from a folder into RXS.
|
|
398
|
+
*
|
|
399
|
+
* Unlike FolderLoader (which requires resource.json and produces RXR),
|
|
400
|
+
* FolderSourceLoader loads ALL files from a folder without interpreting them.
|
|
401
|
+
* Type detection happens downstream via TypeDetectorChain.
|
|
402
|
+
*/
|
|
403
|
+
declare class FolderSourceLoader implements SourceLoader {
|
|
404
|
+
canLoad(source: string): Promise<boolean>;
|
|
405
|
+
load(source: string): Promise<RXS>;
|
|
406
|
+
/**
|
|
407
|
+
* Recursively read all files in a folder.
|
|
408
|
+
*/
|
|
409
|
+
private readFolderFiles;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* GitHubSourceLoader - Loads raw files from a GitHub directory into RXS.
|
|
413
|
+
*
|
|
414
|
+
* Fetches files via the GitHub Contents API (no authentication required
|
|
415
|
+
* for public repositories).
|
|
416
|
+
*/
|
|
417
|
+
declare class GitHubSourceLoader implements SourceLoader {
|
|
418
|
+
canLoad(source: string): boolean;
|
|
419
|
+
load(source: string): Promise<RXS>;
|
|
420
|
+
/**
|
|
421
|
+
* Recursively fetch all files from a GitHub directory.
|
|
422
|
+
*/
|
|
423
|
+
private fetchDirectory;
|
|
424
|
+
/**
|
|
425
|
+
* Fetch a single file's content.
|
|
426
|
+
*/
|
|
427
|
+
private fetchFile;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
466
430
|
* Configuration options for loadResource.
|
|
467
431
|
*/
|
|
468
432
|
interface LoadResourceConfig {
|
|
@@ -503,53 +467,83 @@ interface LoadResourceConfig {
|
|
|
503
467
|
*/
|
|
504
468
|
declare function loadResource(source: string, config?: LoadResourceConfig): Promise<RXR>;
|
|
505
469
|
/**
|
|
506
|
-
*
|
|
507
|
-
*/
|
|
508
|
-
interface SearchOptions {
|
|
509
|
-
/**
|
|
510
|
-
* Search query string (matches against name, domain, path).
|
|
511
|
-
*/
|
|
512
|
-
query?: string;
|
|
513
|
-
/**
|
|
514
|
-
* Maximum number of results to return.
|
|
515
|
-
*/
|
|
516
|
-
limit?: number;
|
|
517
|
-
/**
|
|
518
|
-
* Number of results to skip (for pagination).
|
|
519
|
-
*/
|
|
520
|
-
offset?: number;
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
|
-
* Registry interface - business layer for RXR operations.
|
|
470
|
+
* SourceLoaderChain - Chain of source loaders.
|
|
524
471
|
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
472
|
+
* Follows the same pattern as TypeDetectorChain:
|
|
473
|
+
* - Static create() factory with built-in loaders
|
|
474
|
+
* - Extensible via register()
|
|
475
|
+
* - First match wins
|
|
476
|
+
*
|
|
477
|
+
* Loading order:
|
|
478
|
+
* 1. FolderSourceLoader (local directories)
|
|
479
|
+
* 2. GitHubSourceLoader (GitHub URLs)
|
|
480
|
+
* 3. Custom loaders (registered in order)
|
|
528
481
|
*/
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
* @throws RegistryError if not found
|
|
533
|
-
*/
|
|
534
|
-
get(rxl: RXL): Promise<RXR>;
|
|
482
|
+
declare class SourceLoaderChain {
|
|
483
|
+
private readonly loaders;
|
|
484
|
+
private constructor();
|
|
535
485
|
/**
|
|
536
|
-
*
|
|
486
|
+
* Create a new SourceLoaderChain with built-in loaders.
|
|
537
487
|
*/
|
|
538
|
-
|
|
488
|
+
static create(): SourceLoaderChain;
|
|
539
489
|
/**
|
|
540
|
-
*
|
|
490
|
+
* Register a custom loader.
|
|
491
|
+
* Custom loaders are appended after built-in loaders.
|
|
541
492
|
*/
|
|
542
|
-
|
|
493
|
+
register(loader: SourceLoader): void;
|
|
543
494
|
/**
|
|
544
|
-
*
|
|
495
|
+
* Check if any loader in the chain can handle the source.
|
|
496
|
+
*
|
|
497
|
+
* @param source - Source path or identifier
|
|
498
|
+
* @returns true if any loader can handle the source
|
|
545
499
|
*/
|
|
546
|
-
|
|
500
|
+
canLoad(source: string): Promise<boolean>;
|
|
547
501
|
/**
|
|
548
|
-
*
|
|
502
|
+
* Load raw files from a source.
|
|
503
|
+
*
|
|
504
|
+
* @param source - Source path or identifier
|
|
505
|
+
* @returns RXS with raw files
|
|
506
|
+
* @throws ResourceXError if no loader matches
|
|
549
507
|
*/
|
|
550
|
-
|
|
508
|
+
load(source: string): Promise<RXS>;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Configuration for resolveSource.
|
|
512
|
+
*/
|
|
513
|
+
interface ResolveSourceConfig {
|
|
514
|
+
/** Custom loader chain (overrides default chain) */
|
|
515
|
+
loaderChain?: SourceLoaderChain;
|
|
516
|
+
/** Additional loaders to register on the chain */
|
|
517
|
+
loaders?: SourceLoader[];
|
|
518
|
+
/** Custom detector chain (default: TypeDetectorChain.create()) */
|
|
519
|
+
detectorChain?: TypeDetectorChain;
|
|
520
|
+
/** Additional detectors to register on the default chain */
|
|
521
|
+
detectors?: TypeDetector[];
|
|
551
522
|
}
|
|
552
523
|
/**
|
|
524
|
+
* Resolve a source into a complete RXR.
|
|
525
|
+
*
|
|
526
|
+
* Pipeline: Load files -> Detect type -> Generate RXD -> Archive -> RXR
|
|
527
|
+
*
|
|
528
|
+
* Supports both explicit resource.json and auto-detection from file patterns.
|
|
529
|
+
*
|
|
530
|
+
* @param source - Source path or identifier
|
|
531
|
+
* @param config - Optional configuration
|
|
532
|
+
* @returns Complete RXR ready for registry
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
* ```typescript
|
|
536
|
+
* // Auto-detect from folder (with or without resource.json)
|
|
537
|
+
* const rxr = await resolveSource("./my-skill");
|
|
538
|
+
*
|
|
539
|
+
* // With custom loader
|
|
540
|
+
* const rxr = await resolveSource("./custom", {
|
|
541
|
+
* loaders: [new MyCustomLoader()]
|
|
542
|
+
* });
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
545
|
+
declare function resolveSource(source: string, config?: ResolveSourceConfig): Promise<RXR>;
|
|
546
|
+
/**
|
|
553
547
|
* RXAStore - Content-Addressable Storage for Resource Archives
|
|
554
548
|
*
|
|
555
549
|
* SPI interface for storing file content by digest (hash).
|
|
@@ -658,44 +652,186 @@ interface RXMStore {
|
|
|
658
652
|
* Delete all manifests from a registry (clear cache).
|
|
659
653
|
*/
|
|
660
654
|
deleteByRegistry(registry: string): Promise<void>;
|
|
661
|
-
}
|
|
662
|
-
declare class CASRegistry implements Registry {
|
|
663
|
-
private readonly rxaStore;
|
|
664
|
-
private readonly rxmStore;
|
|
665
|
-
constructor(rxaStore: RXAStore, rxmStore: RXMStore);
|
|
666
|
-
get(rxl: RXL): Promise<RXR>;
|
|
667
|
-
put(rxr: RXR): Promise<void>;
|
|
668
|
-
has(rxl: RXL): Promise<boolean>;
|
|
669
|
-
remove(rxl: RXL): Promise<void>;
|
|
670
|
-
list(options?: SearchOptions): Promise<RXL[]>;
|
|
671
|
-
/**
|
|
672
|
-
* Clear cached resources (resources with registry).
|
|
673
|
-
* @param registry - If provided, only clear resources from this registry
|
|
674
|
-
*/
|
|
675
|
-
clearCache(registry?: string): Promise<void>;
|
|
676
655
|
/**
|
|
677
|
-
*
|
|
656
|
+
* Set the "latest" pointer for a resource.
|
|
657
|
+
* Points to the tag of the most recently added version.
|
|
678
658
|
*/
|
|
679
|
-
|
|
659
|
+
setLatest(name: string, tag: string, registry?: string): Promise<void>;
|
|
680
660
|
/**
|
|
681
|
-
*
|
|
682
|
-
*
|
|
661
|
+
* Get the "latest" pointer for a resource.
|
|
662
|
+
* @returns The tag that "latest" points to, or null if no pointer exists.
|
|
683
663
|
*/
|
|
684
|
-
|
|
664
|
+
getLatest(name: string, registry?: string): Promise<string | null>;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Provider configuration passed to createStores/createLoader.
|
|
668
|
+
*/
|
|
669
|
+
interface ProviderConfig {
|
|
685
670
|
/**
|
|
686
|
-
*
|
|
671
|
+
* Base path for storage (filesystem) or connection info.
|
|
687
672
|
*/
|
|
688
|
-
|
|
673
|
+
path?: string;
|
|
689
674
|
/**
|
|
690
|
-
*
|
|
675
|
+
* Platform-specific configuration.
|
|
691
676
|
*/
|
|
692
|
-
|
|
677
|
+
[key: string]: unknown;
|
|
693
678
|
}
|
|
694
679
|
/**
|
|
695
|
-
*
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
680
|
+
* Stores created by the provider.
|
|
681
|
+
*/
|
|
682
|
+
interface ProviderStores {
|
|
683
|
+
rxaStore: RXAStore;
|
|
684
|
+
rxmStore: RXMStore;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Resource loader interface for loading from directories/archives.
|
|
688
|
+
*/
|
|
689
|
+
interface ResourceLoader2 {
|
|
690
|
+
/**
|
|
691
|
+
* Check if this loader can handle the given source.
|
|
692
|
+
*/
|
|
693
|
+
canLoad(source: string): boolean | Promise<boolean>;
|
|
694
|
+
/**
|
|
695
|
+
* Load resource from source.
|
|
696
|
+
*/
|
|
697
|
+
load(source: string): Promise<unknown>;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* ResourceX Provider - Platform implementation interface.
|
|
701
|
+
*
|
|
702
|
+
* Platforms implement this interface to provide storage and loading
|
|
703
|
+
* capabilities for their environment.
|
|
704
|
+
*/
|
|
705
|
+
interface ResourceXProvider {
|
|
706
|
+
/**
|
|
707
|
+
* Platform identifier.
|
|
708
|
+
*/
|
|
709
|
+
readonly platform: string;
|
|
710
|
+
/**
|
|
711
|
+
* Create storage instances for the platform.
|
|
712
|
+
*/
|
|
713
|
+
createStores(config: ProviderConfig): ProviderStores;
|
|
714
|
+
/**
|
|
715
|
+
* Create resource loader (optional).
|
|
716
|
+
* Not all platforms support loading from filesystem.
|
|
717
|
+
*/
|
|
718
|
+
createLoader?(config: ProviderConfig): ResourceLoader2;
|
|
719
|
+
/**
|
|
720
|
+
* Create source loader for auto-detection pipeline (optional).
|
|
721
|
+
*/
|
|
722
|
+
createSourceLoader?(config: ProviderConfig): SourceLoader;
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Well-known discovery response format.
|
|
726
|
+
*/
|
|
727
|
+
interface WellKnownResponse {
|
|
728
|
+
version?: string;
|
|
729
|
+
registries: string[];
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Result from discoverRegistry().
|
|
733
|
+
*/
|
|
734
|
+
interface DiscoveryResult {
|
|
735
|
+
domain: string;
|
|
736
|
+
registries: string[];
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Discover registry for a domain using well-known.
|
|
740
|
+
* @param domain - The domain to discover (e.g., "deepractice.ai")
|
|
741
|
+
* @returns Discovery result with domain and authorized registries
|
|
742
|
+
*/
|
|
743
|
+
declare function discoverRegistry(domain: string): Promise<DiscoveryResult>;
|
|
744
|
+
/**
|
|
745
|
+
* Registry-specific error.
|
|
746
|
+
*/
|
|
747
|
+
declare class RegistryError extends ResourceXError {
|
|
748
|
+
constructor(message: string, options?: ErrorOptions);
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Search options for querying resources.
|
|
752
|
+
*/
|
|
753
|
+
interface SearchOptions {
|
|
754
|
+
/**
|
|
755
|
+
* Search query string (matches against name, domain, path).
|
|
756
|
+
*/
|
|
757
|
+
query?: string;
|
|
758
|
+
/**
|
|
759
|
+
* Maximum number of results to return.
|
|
760
|
+
*/
|
|
761
|
+
limit?: number;
|
|
762
|
+
/**
|
|
763
|
+
* Number of results to skip (for pagination).
|
|
764
|
+
*/
|
|
765
|
+
offset?: number;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Registry interface - business layer for RXR operations.
|
|
769
|
+
*
|
|
770
|
+
* This interface defines CRUD operations on RXR objects.
|
|
771
|
+
* Different implementations (HostedRegistry, MirrorRegistry, LinkedRegistry)
|
|
772
|
+
* provide different semantics on top of the same Storage layer.
|
|
773
|
+
*/
|
|
774
|
+
interface Registry {
|
|
775
|
+
/**
|
|
776
|
+
* Get resource by locator.
|
|
777
|
+
* @throws RegistryError if not found
|
|
778
|
+
*/
|
|
779
|
+
get(rxl: RXL): Promise<RXR>;
|
|
780
|
+
/**
|
|
781
|
+
* Store resource.
|
|
782
|
+
*/
|
|
783
|
+
put(rxr: RXR): Promise<void>;
|
|
784
|
+
/**
|
|
785
|
+
* Check if resource exists.
|
|
786
|
+
*/
|
|
787
|
+
has(rxl: RXL): Promise<boolean>;
|
|
788
|
+
/**
|
|
789
|
+
* Delete resource.
|
|
790
|
+
*/
|
|
791
|
+
remove(rxl: RXL): Promise<void>;
|
|
792
|
+
/**
|
|
793
|
+
* List resources matching options.
|
|
794
|
+
*/
|
|
795
|
+
list(options?: SearchOptions): Promise<RXL[]>;
|
|
796
|
+
}
|
|
797
|
+
declare class CASRegistry implements Registry {
|
|
798
|
+
private readonly rxaStore;
|
|
799
|
+
private readonly rxmStore;
|
|
800
|
+
constructor(rxaStore: RXAStore, rxmStore: RXMStore);
|
|
801
|
+
private resolveTag;
|
|
802
|
+
get(rxl: RXL): Promise<RXR>;
|
|
803
|
+
put(rxr: RXR): Promise<void>;
|
|
804
|
+
has(rxl: RXL): Promise<boolean>;
|
|
805
|
+
remove(rxl: RXL): Promise<void>;
|
|
806
|
+
list(options?: SearchOptions): Promise<RXL[]>;
|
|
807
|
+
/**
|
|
808
|
+
* Clear cached resources (resources with registry).
|
|
809
|
+
* @param registry - If provided, only clear resources from this registry
|
|
810
|
+
*/
|
|
811
|
+
clearCache(registry?: string): Promise<void>;
|
|
812
|
+
/**
|
|
813
|
+
* Run garbage collection to remove orphaned blobs.
|
|
814
|
+
*/
|
|
815
|
+
gc(): Promise<number>;
|
|
816
|
+
/**
|
|
817
|
+
* Check if a digest exists in the blob store.
|
|
818
|
+
* Useful for "instant upload" - skip uploading if server already has it.
|
|
819
|
+
*/
|
|
820
|
+
hasBlob(digest: string): Promise<boolean>;
|
|
821
|
+
/**
|
|
822
|
+
* Get blob by digest.
|
|
823
|
+
*/
|
|
824
|
+
getBlob(digest: string): Promise<Buffer>;
|
|
825
|
+
/**
|
|
826
|
+
* Put blob directly (for pull optimization).
|
|
827
|
+
*/
|
|
828
|
+
putBlob(data: Buffer): Promise<string>;
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* LinkedRegistry - Registry for development symlinks.
|
|
832
|
+
*
|
|
833
|
+
* Creates symlinks to development directories so changes are reflected immediately.
|
|
834
|
+
* Unlike HostedRegistry/MirrorRegistry, it doesn't use Storage layer directly.
|
|
699
835
|
* Instead, it manages symlinks in a base directory.
|
|
700
836
|
*
|
|
701
837
|
* Storage structure:
|
|
@@ -745,6 +881,45 @@ declare class LinkedRegistry implements Registry {
|
|
|
745
881
|
private parsePathToRXL;
|
|
746
882
|
}
|
|
747
883
|
/**
|
|
884
|
+
* Base class for Registry middleware.
|
|
885
|
+
* Delegates all operations to the inner registry.
|
|
886
|
+
* Override specific methods to add custom behavior.
|
|
887
|
+
*/
|
|
888
|
+
declare abstract class RegistryMiddleware implements Registry {
|
|
889
|
+
protected readonly inner: Registry;
|
|
890
|
+
constructor(inner: Registry);
|
|
891
|
+
get(rxl: RXL): Promise<RXR>;
|
|
892
|
+
put(rxr: RXR): Promise<void>;
|
|
893
|
+
has(rxl: RXL): Promise<boolean>;
|
|
894
|
+
remove(rxl: RXL): Promise<void>;
|
|
895
|
+
list(options?: SearchOptions): Promise<RXL[]>;
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
898
|
+
* Registry validation middleware.
|
|
899
|
+
* Ensures all resources from this registry match the trusted registry.
|
|
900
|
+
*/
|
|
901
|
+
declare class RegistryValidation extends RegistryMiddleware {
|
|
902
|
+
private readonly trustedRegistry;
|
|
903
|
+
constructor(inner: Registry, trustedRegistry: string);
|
|
904
|
+
/**
|
|
905
|
+
* Validate that manifest registry matches trusted registry.
|
|
906
|
+
*/
|
|
907
|
+
private validateRegistry;
|
|
908
|
+
/**
|
|
909
|
+
* Get resource and validate registry.
|
|
910
|
+
*/
|
|
911
|
+
get(rxl: RXL): Promise<RXR>;
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Factory function to create registry validation middleware.
|
|
915
|
+
*
|
|
916
|
+
* @example
|
|
917
|
+
* const registry = withRegistryValidation(hostedRegistry, "deepractice.ai");
|
|
918
|
+
*/
|
|
919
|
+
declare function withRegistryValidation(registry: Registry, trustedRegistry: string): Registry;
|
|
920
|
+
declare const DomainValidation: typeof RegistryValidation;
|
|
921
|
+
declare const withDomainValidation: typeof withRegistryValidation;
|
|
922
|
+
/**
|
|
748
923
|
* Compute SHA-256 digest of data.
|
|
749
924
|
* Returns string in format "sha256:{hex}"
|
|
750
925
|
*/
|
|
@@ -767,6 +942,7 @@ declare class MemoryRXAStore implements RXAStore {
|
|
|
767
942
|
}
|
|
768
943
|
declare class MemoryRXMStore implements RXMStore {
|
|
769
944
|
private readonly manifests;
|
|
945
|
+
private readonly latestPointers;
|
|
770
946
|
/**
|
|
771
947
|
* Build key for manifest lookup.
|
|
772
948
|
*/
|
|
@@ -779,128 +955,245 @@ declare class MemoryRXMStore implements RXMStore {
|
|
|
779
955
|
listNames(registry?: string, query?: string): Promise<string[]>;
|
|
780
956
|
search(options?: RXMSearchOptions): Promise<StoredRXM[]>;
|
|
781
957
|
deleteByRegistry(registry: string): Promise<void>;
|
|
958
|
+
setLatest(name: string, tag: string, registry?: string): Promise<void>;
|
|
959
|
+
getLatest(name: string, registry?: string): Promise<string | null>;
|
|
782
960
|
/**
|
|
783
961
|
* Clear all manifests (for testing).
|
|
784
962
|
*/
|
|
785
963
|
clear(): void;
|
|
786
964
|
}
|
|
787
965
|
/**
|
|
788
|
-
*
|
|
966
|
+
* Isolator type for resolver execution.
|
|
967
|
+
* Matches SandboX isolator types directly.
|
|
968
|
+
* Configured at Registry level, not per-type.
|
|
969
|
+
*
|
|
970
|
+
* - "none": No isolation, fastest (~10ms), for development
|
|
971
|
+
* - "srt": OS-level isolation (~50ms), secure local dev
|
|
972
|
+
* - "cloudflare": Container isolation (~100ms), local Docker or edge
|
|
973
|
+
* - "e2b": MicroVM isolation (~150ms), production (planned)
|
|
789
974
|
*/
|
|
790
|
-
|
|
791
|
-
version?: string;
|
|
792
|
-
registries: string[];
|
|
793
|
-
}
|
|
975
|
+
type IsolatorType = "none" | "srt" | "cloudflare" | "e2b";
|
|
794
976
|
/**
|
|
795
|
-
*
|
|
977
|
+
* ResolveContext - Pure data context passed to resolver in sandbox.
|
|
978
|
+
*
|
|
979
|
+
* This is a serializable data structure that replaces RXR for sandbox execution.
|
|
980
|
+
* The executor pre-processes RXR (extracts files) before passing to resolver.
|
|
796
981
|
*/
|
|
797
|
-
interface
|
|
798
|
-
|
|
799
|
-
|
|
982
|
+
interface ResolveContext {
|
|
983
|
+
/**
|
|
984
|
+
* Resource manifest metadata.
|
|
985
|
+
*/
|
|
986
|
+
manifest: {
|
|
987
|
+
domain: string
|
|
988
|
+
path?: string
|
|
989
|
+
name: string
|
|
990
|
+
type: string
|
|
991
|
+
version: string
|
|
992
|
+
};
|
|
993
|
+
/**
|
|
994
|
+
* Extracted files from archive.
|
|
995
|
+
* Key is file path, value is file content as Uint8Array.
|
|
996
|
+
*/
|
|
997
|
+
files: Record<string, Uint8Array>;
|
|
800
998
|
}
|
|
801
999
|
/**
|
|
802
|
-
*
|
|
803
|
-
*
|
|
804
|
-
*
|
|
1000
|
+
* BundledType - Pre-bundled resource type ready for execution.
|
|
1001
|
+
* Contains bundled code string instead of closure.
|
|
1002
|
+
*
|
|
1003
|
+
* Note: Sandbox isolation is configured at Registry level via createRegistry({ sandbox: ... })
|
|
805
1004
|
*/
|
|
806
|
-
|
|
1005
|
+
interface BundledType {
|
|
1006
|
+
/**
|
|
1007
|
+
* Type name (e.g., "text", "json", "prompt").
|
|
1008
|
+
*/
|
|
1009
|
+
name: string;
|
|
1010
|
+
/**
|
|
1011
|
+
* Alternative names for this type.
|
|
1012
|
+
*/
|
|
1013
|
+
aliases?: string[];
|
|
1014
|
+
/**
|
|
1015
|
+
* Human-readable description.
|
|
1016
|
+
*/
|
|
1017
|
+
description: string;
|
|
1018
|
+
/**
|
|
1019
|
+
* JSON Schema for resolver arguments.
|
|
1020
|
+
*/
|
|
1021
|
+
schema?: JSONSchema;
|
|
1022
|
+
/**
|
|
1023
|
+
* Bundled resolver code (executable in sandbox).
|
|
1024
|
+
*/
|
|
1025
|
+
code: string;
|
|
1026
|
+
}
|
|
807
1027
|
/**
|
|
808
|
-
*
|
|
1028
|
+
* JSON Schema property definition.
|
|
809
1029
|
*/
|
|
810
|
-
|
|
811
|
-
|
|
1030
|
+
interface JSONSchemaProperty {
|
|
1031
|
+
type: "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
|
|
1032
|
+
description?: string;
|
|
1033
|
+
default?: unknown;
|
|
1034
|
+
enum?: unknown[];
|
|
1035
|
+
items?: JSONSchemaProperty;
|
|
1036
|
+
properties?: Record<string, JSONSchemaProperty>;
|
|
1037
|
+
required?: string[];
|
|
812
1038
|
}
|
|
813
1039
|
/**
|
|
814
|
-
*
|
|
815
|
-
*
|
|
816
|
-
* Override specific methods to add custom behavior.
|
|
1040
|
+
* JSON Schema definition for resolver arguments.
|
|
1041
|
+
* Used by UI to render parameter forms.
|
|
817
1042
|
*/
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
get(rxl: RXL): Promise<RXR>;
|
|
822
|
-
put(rxr: RXR): Promise<void>;
|
|
823
|
-
has(rxl: RXL): Promise<boolean>;
|
|
824
|
-
remove(rxl: RXL): Promise<void>;
|
|
825
|
-
list(options?: SearchOptions): Promise<RXL[]>;
|
|
1043
|
+
interface JSONSchema extends JSONSchemaProperty {
|
|
1044
|
+
$schema?: string;
|
|
1045
|
+
title?: string;
|
|
826
1046
|
}
|
|
827
1047
|
/**
|
|
828
|
-
*
|
|
829
|
-
*
|
|
1048
|
+
* ResolvedResource - Structured result object returned by resolver.
|
|
1049
|
+
* Contains execute function, original resource, and optional schema for UI rendering.
|
|
830
1050
|
*/
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
1051
|
+
interface ResolvedResource<
|
|
1052
|
+
TArgs = void,
|
|
1053
|
+
TResult = unknown
|
|
1054
|
+
> {
|
|
834
1055
|
/**
|
|
835
|
-
*
|
|
1056
|
+
* Original resource object (RXR from @resourcexjs/core).
|
|
836
1057
|
*/
|
|
837
|
-
|
|
1058
|
+
resource: unknown;
|
|
838
1059
|
/**
|
|
839
|
-
*
|
|
1060
|
+
* Execute function to get the resource content.
|
|
1061
|
+
* - For static resources (text/json/binary): call with no arguments
|
|
1062
|
+
* - For dynamic resources (tool): call with arguments
|
|
840
1063
|
*/
|
|
841
|
-
|
|
1064
|
+
execute: (args?: TArgs) => TResult | Promise<TResult>;
|
|
1065
|
+
/**
|
|
1066
|
+
* JSON Schema for the arguments (undefined if no arguments needed).
|
|
1067
|
+
* UI uses this to render parameter forms.
|
|
1068
|
+
*/
|
|
1069
|
+
schema: TArgs extends void ? undefined : JSONSchema;
|
|
842
1070
|
}
|
|
843
1071
|
/**
|
|
844
|
-
*
|
|
845
|
-
*
|
|
846
|
-
* @example
|
|
847
|
-
* const registry = withRegistryValidation(hostedRegistry, "deepractice.ai");
|
|
1072
|
+
* ResourceResolver - Transforms resource into a structured result object.
|
|
1073
|
+
* The execute function is lazy-loaded: content is only read when called.
|
|
848
1074
|
*/
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
1075
|
+
interface ResourceResolver<
|
|
1076
|
+
TArgs = void,
|
|
1077
|
+
TResult = unknown
|
|
1078
|
+
> {
|
|
1079
|
+
/**
|
|
1080
|
+
* JSON Schema for arguments (required if TArgs is not void).
|
|
1081
|
+
* This constraint ensures type safety at definition time.
|
|
1082
|
+
*/
|
|
1083
|
+
schema: TArgs extends void ? undefined : JSONSchema;
|
|
1084
|
+
/**
|
|
1085
|
+
* Resolve resource into a structured result object.
|
|
1086
|
+
* @param rxr - RXR object from @resourcexjs/core
|
|
1087
|
+
*/
|
|
1088
|
+
resolve(rxr: unknown): Promise<ResolvedResource<TArgs, TResult>>;
|
|
1089
|
+
}
|
|
852
1090
|
/**
|
|
853
|
-
*
|
|
1091
|
+
* ResourceType - Defines how a resource type is handled.
|
|
854
1092
|
*/
|
|
855
|
-
interface
|
|
1093
|
+
interface ResourceType<
|
|
1094
|
+
TArgs = void,
|
|
1095
|
+
TResult = unknown
|
|
1096
|
+
> {
|
|
856
1097
|
/**
|
|
857
|
-
*
|
|
1098
|
+
* Type name (e.g., "text", "json", "binary").
|
|
858
1099
|
*/
|
|
859
|
-
|
|
1100
|
+
name: string;
|
|
860
1101
|
/**
|
|
861
|
-
*
|
|
1102
|
+
* Alternative names for this type (e.g., ["txt", "plaintext"]).
|
|
862
1103
|
*/
|
|
863
|
-
|
|
1104
|
+
aliases?: string[];
|
|
1105
|
+
/**
|
|
1106
|
+
* Human-readable description.
|
|
1107
|
+
*/
|
|
1108
|
+
description: string;
|
|
1109
|
+
/**
|
|
1110
|
+
* Resolver to transform RXR into structured result object.
|
|
1111
|
+
*/
|
|
1112
|
+
resolver: ResourceResolver<TArgs, TResult>;
|
|
864
1113
|
}
|
|
865
1114
|
/**
|
|
866
|
-
*
|
|
1115
|
+
* Plain text content
|
|
867
1116
|
*/
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
1117
|
+
declare const textType: BundledType;
|
|
1118
|
+
/**
|
|
1119
|
+
* JSON content
|
|
1120
|
+
*/
|
|
1121
|
+
declare const jsonType: BundledType;
|
|
1122
|
+
/**
|
|
1123
|
+
* Binary content
|
|
1124
|
+
*/
|
|
1125
|
+
declare const binaryType: BundledType;
|
|
1126
|
+
/**
|
|
1127
|
+
* All built-in types as an array.
|
|
1128
|
+
*/
|
|
1129
|
+
declare const builtinTypes: BundledType[];
|
|
1130
|
+
/**
|
|
1131
|
+
* Bundle a resource type from a source file.
|
|
1132
|
+
*
|
|
1133
|
+
* @param sourcePath - Path to the .type.ts file
|
|
1134
|
+
* @param basePath - Base path for resolving relative paths (defaults to cwd)
|
|
1135
|
+
* @returns BundledType ready for registry
|
|
1136
|
+
*
|
|
1137
|
+
* @example
|
|
1138
|
+
* ```typescript
|
|
1139
|
+
* const promptType = await bundleResourceType("./prompt.type.ts");
|
|
1140
|
+
* ```
|
|
1141
|
+
*/
|
|
1142
|
+
declare function bundleResourceType(sourcePath: string, basePath?: string): Promise<BundledType>;
|
|
1143
|
+
/**
|
|
1144
|
+
* Resource type related error.
|
|
1145
|
+
*/
|
|
1146
|
+
declare class ResourceTypeError extends ResourceXError {
|
|
1147
|
+
constructor(message: string);
|
|
871
1148
|
}
|
|
872
1149
|
/**
|
|
873
|
-
*
|
|
1150
|
+
* TypeHandlerChain - Manages resource type registration.
|
|
1151
|
+
*
|
|
1152
|
+
* Responsibilities:
|
|
1153
|
+
* - Register types (name + aliases)
|
|
1154
|
+
* - Look up types by name
|
|
1155
|
+
*
|
|
1156
|
+
* Execution is delegated to ResolverExecutor (in registry package).
|
|
1157
|
+
*
|
|
1158
|
+
* Built-in types (text, json, binary) are registered by default.
|
|
874
1159
|
*/
|
|
875
|
-
|
|
1160
|
+
declare class TypeHandlerChain {
|
|
1161
|
+
private handlers;
|
|
1162
|
+
private constructor();
|
|
876
1163
|
/**
|
|
877
|
-
*
|
|
1164
|
+
* Create a new TypeHandlerChain instance.
|
|
1165
|
+
* Built-in types (text, json, binary) are included by default.
|
|
878
1166
|
*/
|
|
879
|
-
|
|
1167
|
+
static create(): TypeHandlerChain;
|
|
880
1168
|
/**
|
|
881
|
-
*
|
|
1169
|
+
* Internal registration (no duplicate check).
|
|
882
1170
|
*/
|
|
883
|
-
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* ResourceX Provider - Platform implementation interface.
|
|
887
|
-
*
|
|
888
|
-
* Platforms implement this interface to provide storage and loading
|
|
889
|
-
* capabilities for their environment.
|
|
890
|
-
*/
|
|
891
|
-
interface ResourceXProvider {
|
|
1171
|
+
private registerInternal;
|
|
892
1172
|
/**
|
|
893
|
-
*
|
|
1173
|
+
* Register a type.
|
|
1174
|
+
* @throws ResourceTypeError if type is already registered
|
|
894
1175
|
*/
|
|
895
|
-
|
|
1176
|
+
register(type: BundledType): void;
|
|
896
1177
|
/**
|
|
897
|
-
*
|
|
1178
|
+
* Check if a type is supported.
|
|
898
1179
|
*/
|
|
899
|
-
|
|
1180
|
+
canHandle(typeName: string): boolean;
|
|
900
1181
|
/**
|
|
901
|
-
*
|
|
902
|
-
*
|
|
1182
|
+
* Get handler for a type.
|
|
1183
|
+
* @throws ResourceTypeError if type is not supported
|
|
903
1184
|
*/
|
|
904
|
-
|
|
1185
|
+
getHandler(typeName: string): BundledType;
|
|
1186
|
+
/**
|
|
1187
|
+
* Get handler for a type, or undefined if not found.
|
|
1188
|
+
*/
|
|
1189
|
+
getHandlerOrUndefined(typeName: string): BundledType | undefined;
|
|
1190
|
+
/**
|
|
1191
|
+
* Get all supported type names (including aliases).
|
|
1192
|
+
*/
|
|
1193
|
+
getSupportedTypes(): string[];
|
|
1194
|
+
/**
|
|
1195
|
+
* Clear all registered types (for testing).
|
|
1196
|
+
*/
|
|
1197
|
+
clear(): void;
|
|
905
1198
|
}
|
|
906
|
-
export { wrap, withDomainValidation, textType, resource, parse, manifest, locate, loadResource, jsonType, isValidDigest, format, extract, discoverRegistry, define, computeDigest, bundleResourceType, builtinTypes, binaryType, archive, WellKnownResponse, TypeHandlerChain, StoredRXM, SearchOptions, ResourceXProvider, ResourceXError, ResourceTypeError, ResourceType, ResourceResolver, ResourceLoader, ResolvedResource, ResolveContext, RegistryMiddleware, RegistryError, Registry, RXR, RXMStore, RXMSearchOptions, RXM, RXL, RXD, RXAStore, RXA, ProviderStores, ProviderConfig, MemoryRXMStore, MemoryRXAStore, ManifestError, LocatorError, LoadResourceConfig, LinkedRegistry, JSONSchemaProperty, JSONSchema, IsolatorType, FolderLoader, DomainValidation, DiscoveryResult, DefinitionError, ContentError, CASRegistry, BundledType };
|
|
1199
|
+
export { wrap, withDomainValidation, textType, resource, resolveSource, parse, manifest, locate, loadResource, jsonType, isValidDigest, generateDefinition, format, extract, discoverRegistry, define, computeDigest, bundleResourceType, builtinTypes, binaryType, archive, WellKnownResponse, TypeHandlerChain, TypeDetectorChain, TypeDetector, TypeDetectionResult, StoredRXM, SourceLoaderChain, SourceLoader, SkillDetector, SearchOptions, ResourceXProvider, ResourceXError, ResourceTypeError, ResourceType, ResourceResolver, ResourceLoader, ResourceJsonDetector, ResolvedResource, ResolveSourceConfig, ResolveContext, RegistryMiddleware, RegistryError, Registry, RXS, RXR, RXMStore, RXMSearchOptions, RXM, RXL, RXD, RXAStore, RXA, ProviderStores, ProviderConfig, MemoryRXMStore, MemoryRXAStore, ManifestError, LocatorError, LoadResourceConfig, LinkedRegistry, JSONSchemaProperty, JSONSchema, IsolatorType, GitHubSourceLoader, FolderSourceLoader, FolderLoader, DomainValidation, DiscoveryResult, DefinitionError, ContentError, CASRegistry, BundledType };
|