@resourcexjs/core 2.18.0 → 2.20.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 CHANGED
@@ -434,52 +434,6 @@ interface SourceLoader {
434
434
  load(source: string): Promise<RXS>;
435
435
  }
436
436
  /**
437
- * Default ResourceLoader implementation for loading resources from folders.
438
- *
439
- * Expected folder structure:
440
- * ```
441
- * folder/
442
- * ├── resource.json # Resource metadata (required)
443
- * └── ... # Any other files/directories (content)
444
- * ```
445
- *
446
- * resource.json format:
447
- * ```json
448
- * {
449
- * "name": "resource-name", // required
450
- * "type": "text", // required
451
- * "tag": "1.0.0", // optional, defaults to "latest"
452
- * "registry": "localhost", // optional
453
- * "path": "optional/path" // optional
454
- * }
455
- * ```
456
- *
457
- * All files in the folder (except resource.json) will be packaged into the RXA.
458
- */
459
- declare class FolderLoader implements ResourceLoader {
460
- canLoad(source: string): Promise<boolean>;
461
- load(folderPath: string): Promise<RXR>;
462
- /**
463
- * Recursively read all files in a folder, returning a map of relative paths to buffers.
464
- */
465
- private readFolderFiles;
466
- }
467
- /**
468
- * FolderSourceLoader - Loads raw files from a folder into RXS.
469
- *
470
- * Unlike FolderLoader (which requires resource.json and produces RXR),
471
- * FolderSourceLoader loads ALL files from a folder without interpreting them.
472
- * Type detection happens downstream via TypeDetectorChain.
473
- */
474
- declare class FolderSourceLoader implements SourceLoader {
475
- canLoad(source: string): Promise<boolean>;
476
- load(source: string): Promise<RXS>;
477
- /**
478
- * Recursively read all files in a folder.
479
- */
480
- private readFolderFiles;
481
- }
482
- /**
483
437
  * GitHubSourceLoader - Loads raw files from a GitHub directory into RXS.
484
438
  *
485
439
  * Fetches files via the GitHub Contents API (no authentication required
@@ -502,60 +456,50 @@ declare class GitHubSourceLoader implements SourceLoader {
502
456
  */
503
457
  interface LoadResourceConfig {
504
458
  /**
505
- * Custom loader to use. If not provided, defaults to FolderLoader.
459
+ * Loader to use. Required environment-specific loaders are provided by the provider.
460
+ * For Node.js/Bun: use FolderLoader from @resourcexjs/node-provider.
506
461
  */
507
- loader?: ResourceLoader;
462
+ loader: ResourceLoader;
508
463
  }
509
464
  /**
510
465
  * Load a resource from a given source using a ResourceLoader.
511
466
  *
512
- * By default, uses FolderLoader which expects:
513
- * ```
514
- * folder/
515
- * ├── resource.json # Resource metadata
516
- * └── content # Resource content
517
- * ```
518
- *
519
- * You can provide a custom loader via config.loader to support other formats
520
- * (e.g., zip, tar.gz, URLs).
521
- *
522
467
  * @param source - Source path or identifier
523
- * @param config - Optional configuration
468
+ * @param config - Configuration with loader
524
469
  * @returns Complete RXR object ready for registry.link()
525
470
  * @throws ResourceXError if the source cannot be loaded
526
471
  *
527
472
  * @example
528
473
  * ```typescript
529
- * // Load from folder (default)
530
- * const rxr = await loadResource("./my-resource");
531
- * await registry.link(rxr);
474
+ * import { FolderLoader } from "@resourcexjs/node-provider";
532
475
  *
533
- * // Load with custom loader
534
- * const rxr = await loadResource("resource.zip", {
535
- * loader: new ZipLoader()
476
+ * const rxr = await loadResource("./my-resource", {
477
+ * loader: new FolderLoader()
536
478
  * });
537
479
  * ```
538
480
  */
539
- declare function loadResource(source: string, config?: LoadResourceConfig): Promise<RXR>;
481
+ declare function loadResource(source: string, config: LoadResourceConfig): Promise<RXR>;
540
482
  /**
541
483
  * SourceLoaderChain - Chain of source loaders.
542
484
  *
543
485
  * Follows the same pattern as TypeDetectorChain:
544
- * - Static create() factory with built-in loaders
486
+ * - Static create() factory with built-in environment-agnostic loaders
545
487
  * - Extensible via register()
546
488
  * - First match wins
547
489
  *
548
- * Loading order:
549
- * 1. FolderSourceLoader (local directories)
550
- * 2. GitHubSourceLoader (GitHub URLs)
551
- * 3. NpmSourceLoader (npm: prefixed packages)
552
- * 4. Custom loaders (registered in order)
490
+ * Built-in loaders (environment-agnostic):
491
+ * 1. GitHubSourceLoader (GitHub URLs via fetch)
492
+ *
493
+ * Provider-registered loaders (environment-specific):
494
+ * - FolderSourceLoader (local directories) — via node-provider
495
+ * - NpmSourceLoader (npm: prefixed packages) — via node-provider
553
496
  */
554
497
  declare class SourceLoaderChain {
555
498
  private readonly loaders;
556
499
  private constructor();
557
500
  /**
558
- * Create a new SourceLoaderChain with built-in loaders.
501
+ * Create a new SourceLoaderChain with built-in environment-agnostic loaders.
502
+ * Environment-specific loaders (folder, npm) are registered by the provider.
559
503
  */
560
504
  static create(): SourceLoaderChain;
561
505
  /**
@@ -794,9 +738,10 @@ interface ResourceXProvider {
794
738
  */
795
739
  createStores(config: ProviderConfig): ProviderStores;
796
740
  /**
797
- * Create source loader for auto-detection pipeline (optional).
741
+ * Create source loaders for auto-detection pipeline (optional).
742
+ * Returns environment-specific loaders to register on the chain.
798
743
  */
799
- createSourceLoader?(config: ProviderConfig): SourceLoader;
744
+ createSourceLoaders?(config: ProviderConfig): SourceLoader[];
800
745
  /**
801
746
  * Resolve platform-specific defaults (optional).
802
747
  *
@@ -936,59 +881,6 @@ declare class CASRegistry implements Registry {
936
881
  putBlob(data: Buffer): Promise<string>;
937
882
  }
938
883
  /**
939
- * LinkedRegistry - Registry for development symlinks.
940
- *
941
- * Creates symlinks to development directories so changes are reflected immediately.
942
- * Unlike HostedRegistry/MirrorRegistry, it doesn't use Storage layer directly.
943
- * Instead, it manages symlinks in a base directory.
944
- *
945
- * Storage structure:
946
- * {basePath}/{registry}/{path}/{name}/{tag} → /path/to/dev/folder
947
- */
948
- declare class LinkedRegistry implements Registry {
949
- private readonly basePath;
950
- constructor(basePath: string);
951
- /**
952
- * Build symlink path for a resource.
953
- */
954
- private buildLinkPath;
955
- /**
956
- * Check if a path is a symlink.
957
- */
958
- private isSymlink;
959
- get(rxi: RXI): Promise<RXR>;
960
- /**
961
- * Put is not typically used for LinkedRegistry.
962
- * Use link() instead to create symlinks.
963
- */
964
- put(_rxr: RXR): Promise<RXM>;
965
- has(rxi: RXI): Promise<boolean>;
966
- remove(rxi: RXI): Promise<void>;
967
- list(options?: SearchOptions): Promise<RXI[]>;
968
- /**
969
- * Link a development directory.
970
- * Creates a symlink so changes are reflected immediately.
971
- *
972
- * @param devPath - Path to development directory (must contain resource.json)
973
- * @returns The RXI of the linked resource
974
- */
975
- link(devPath: string): Promise<RXI>;
976
- /**
977
- * Unlink a development directory.
978
- * Alias for remove().
979
- */
980
- unlink(rxi: RXI): Promise<void>;
981
- /**
982
- * Recursively scan for symlinks.
983
- */
984
- private scanSymlinks;
985
- /**
986
- * Parse relative path to RXI.
987
- * Path format: {registry}/{path}/{name}/{tag}
988
- */
989
- private parsePathToRXI;
990
- }
991
- /**
992
884
  * Base class for Registry middleware.
993
885
  * Delegates all operations to the inner registry.
994
886
  * Override specific methods to add custom behavior.
@@ -1028,10 +920,14 @@ declare function withRegistryValidation(registry: Registry, trustedRegistry: str
1028
920
  declare const DomainValidation: typeof RegistryValidation;
1029
921
  declare const withDomainValidation: typeof withRegistryValidation;
1030
922
  /**
923
+ * Digest utilities for Content-Addressable Storage.
924
+ * Uses Web Crypto API for environment-agnostic SHA-256 hashing.
925
+ */
926
+ /**
1031
927
  * Compute SHA-256 digest of data.
1032
928
  * Returns string in format "sha256:{hex}"
1033
929
  */
1034
- declare function computeDigest(data: Buffer): string;
930
+ declare function computeDigest(data: Buffer): Promise<string>;
1035
931
  /**
1036
932
  * Validate digest format.
1037
933
  */
@@ -1072,16 +968,11 @@ declare class MemoryRXMStore implements RXMStore {
1072
968
  }
1073
969
  /**
1074
970
  * Isolator type for resolver execution.
1075
- * Matches SandboX isolator types directly.
1076
- * Configured at Registry level, not per-type.
1077
971
  *
1078
- * - "none": No isolation, fastest (~10ms), for development
1079
- * - "srt": OS-level isolation (~50ms), secure local dev
1080
- * - "cloudflare": Container isolation (~100ms), local Docker or edge
1081
- * - "e2b": MicroVM isolation (~150ms), production (planned)
1082
- * - "custom": User-provided executor function
972
+ * - "none": No isolation, direct eval execution (default)
973
+ * - "custom": User-provided executor function (e.g., QuickJS Wasm for Workers)
1083
974
  */
1084
- type IsolatorType = "none" | "srt" | "cloudflare" | "e2b" | "custom";
975
+ type IsolatorType = "none" | "custom";
1085
976
  /**
1086
977
  * Custom executor function for resolver execution.
1087
978
  * Used when isolator is set to "custom".
@@ -1255,19 +1146,6 @@ declare const prototypeType: BundledType;
1255
1146
  */
1256
1147
  declare const builtinTypes: BundledType[];
1257
1148
  /**
1258
- * Bundle a resource type from a source file.
1259
- *
1260
- * @param sourcePath - Path to the .type.ts file
1261
- * @param basePath - Base path for resolving relative paths (defaults to cwd)
1262
- * @returns BundledType ready for registry
1263
- *
1264
- * @example
1265
- * ```typescript
1266
- * const promptType = await bundleResourceType("./prompt.type.ts");
1267
- * ```
1268
- */
1269
- declare function bundleResourceType(sourcePath: string, basePath?: string): Promise<BundledType>;
1270
- /**
1271
1149
  * Resource type related error.
1272
1150
  */
1273
1151
  declare class ResourceTypeError extends ResourceXError {
@@ -1323,4 +1201,4 @@ declare class TypeHandlerChain {
1323
1201
  */
1324
1202
  clear(): void;
1325
1203
  }
1326
- export { wrap, withDomainValidation, textType, skillType, resource, resolveSource, prototypeType, 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, RegistryEntry, Registry, RXS, RXR, RXMStore, RXMSource, RXMSearchOptions, RXMDefinition, RXMArchive, RXM, RXL, RXI, RXD, RXAStore, RXA, ProviderStores, ProviderDefaults, ProviderConfig, PrototypeDetector, MemoryRXMStore, MemoryRXAStore, ManifestError, LocatorError, LoadResourceConfig, LinkedRegistry, JSONSchemaProperty, JSONSchema, IsolatorType, GitHubSourceLoader, FolderSourceLoader, FolderLoader, FileTree, FileEntry, DomainValidation, DiscoveryResult, DefinitionError, CustomExecutor, ContentError, CASRegistry, BundledType };
1204
+ export { wrap, withDomainValidation, textType, skillType, resource, resolveSource, prototypeType, parse, manifest, locate, loadResource, jsonType, isValidDigest, generateDefinition, format, extract, discoverRegistry, define, computeDigest, 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, RegistryEntry, Registry, RXS, RXR, RXMStore, RXMSource, RXMSearchOptions, RXMDefinition, RXMArchive, RXM, RXL, RXI, RXD, RXAStore, RXA, ProviderStores, ProviderDefaults, ProviderConfig, PrototypeDetector, MemoryRXMStore, MemoryRXAStore, ManifestError, LocatorError, LoadResourceConfig, JSONSchemaProperty, JSONSchema, IsolatorType, GitHubSourceLoader, FileTree, FileEntry, DomainValidation, DiscoveryResult, DefinitionError, CustomExecutor, ContentError, CASRegistry, BundledType };