@everworker/oneringai 0.2.3 → 0.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.
@@ -1,3 +1,3 @@
1
- export { o as ImageEditOptions, n as ImageGenerateOptions, b as ImageGeneration, c as ImageGenerationCreateOptions, q as ImageResponse, p as ImageVariationOptions, S as SimpleGenerateOptions } from '../../ImageModel-BWN6VVS6.cjs';
2
- import '../../IProvider-c4QCbPjn.cjs';
1
+ export { g as ImageEditOptions, h as ImageGenerateOptions, i as ImageGeneration, j as ImageGenerationCreateOptions, m as ImageResponse, n as ImageVariationOptions, S as SimpleGenerateOptions } from '../../ImageModel-zh19LiVM.cjs';
2
+ import '../../IProvider-Br817mKc.cjs';
3
3
  import '../../Vendor-DYh_bzwo.cjs';
@@ -1,3 +1,3 @@
1
- export { o as ImageEditOptions, n as ImageGenerateOptions, b as ImageGeneration, c as ImageGenerationCreateOptions, q as ImageResponse, p as ImageVariationOptions, S as SimpleGenerateOptions } from '../../ImageModel-BJ2mVPGV.js';
2
- import '../../IProvider-DcYJ3YE-.js';
1
+ export { g as ImageEditOptions, h as ImageGenerateOptions, i as ImageGeneration, j as ImageGenerationCreateOptions, m as ImageResponse, n as ImageVariationOptions, S as SimpleGenerateOptions } from '../../ImageModel-B2KUs-ps.js';
2
+ import '../../IProvider-BUbU5UwV.js';
3
3
  import '../../Vendor-DYh_bzwo.js';
@@ -789,6 +789,109 @@ var OAuthManager = class {
789
789
  }
790
790
  }
791
791
  };
792
+
793
+ // src/core/StorageRegistry.ts
794
+ var StorageRegistry = class _StorageRegistry {
795
+ /** Internal storage map */
796
+ static entries = /* @__PURE__ */ new Map();
797
+ /** Default context passed to all factory calls (set via setContext) */
798
+ static _context;
799
+ /**
800
+ * Configure multiple storage backends at once.
801
+ *
802
+ * @example
803
+ * ```typescript
804
+ * // Single-tenant
805
+ * StorageRegistry.configure({
806
+ * customTools: new MongoCustomToolStorage(),
807
+ * sessions: (agentId) => new RedisContextStorage(agentId),
808
+ * });
809
+ *
810
+ * // Multi-tenant
811
+ * StorageRegistry.configure({
812
+ * sessions: (agentId, ctx) => new TenantContextStorage(agentId, ctx?.tenantId),
813
+ * persistentInstructions: (agentId, ctx) => new TenantInstructionsStorage(agentId, ctx?.userId),
814
+ * });
815
+ * ```
816
+ */
817
+ static configure(config) {
818
+ for (const [key, value] of Object.entries(config)) {
819
+ if (value !== void 0) {
820
+ _StorageRegistry.entries.set(key, value);
821
+ }
822
+ }
823
+ }
824
+ /**
825
+ * Set the default StorageContext.
826
+ *
827
+ * This context is automatically passed to all per-agent factory calls
828
+ * (sessions, persistentInstructions, workingMemory) when no explicit
829
+ * context is provided. Typically set once at app startup with global
830
+ * tenant/environment info, or per-request in multi-tenant servers.
831
+ *
832
+ * @example
833
+ * ```typescript
834
+ * // Single-tenant app — set once at init
835
+ * StorageRegistry.setContext({ tenantId: 'acme', environment: 'production' });
836
+ *
837
+ * // Multi-tenant server — set per-request
838
+ * app.use((req, res, next) => {
839
+ * StorageRegistry.setContext({ userId: req.user.id, tenantId: req.tenant.id });
840
+ * next();
841
+ * });
842
+ * ```
843
+ */
844
+ static setContext(context) {
845
+ _StorageRegistry._context = context;
846
+ }
847
+ /**
848
+ * Get the current default StorageContext.
849
+ */
850
+ static getContext() {
851
+ return _StorageRegistry._context;
852
+ }
853
+ /**
854
+ * Set a single storage backend.
855
+ */
856
+ static set(key, value) {
857
+ _StorageRegistry.entries.set(key, value);
858
+ }
859
+ /**
860
+ * Get a storage backend (or undefined if not configured).
861
+ */
862
+ static get(key) {
863
+ return _StorageRegistry.entries.get(key);
864
+ }
865
+ /**
866
+ * Resolve a storage backend, lazily creating and caching a default if needed.
867
+ *
868
+ * If a value has been configured via `set()` or `configure()`, returns that.
869
+ * Otherwise, calls `defaultFactory()`, caches the result, and returns it.
870
+ */
871
+ static resolve(key, defaultFactory) {
872
+ const existing = _StorageRegistry.entries.get(key);
873
+ if (existing !== void 0) {
874
+ return existing;
875
+ }
876
+ const value = defaultFactory();
877
+ _StorageRegistry.entries.set(key, value);
878
+ return value;
879
+ }
880
+ /**
881
+ * Check if a storage backend has been configured.
882
+ */
883
+ static has(key) {
884
+ return _StorageRegistry.entries.has(key);
885
+ }
886
+ /**
887
+ * Clear all configured storage backends and context.
888
+ * Useful for testing.
889
+ */
890
+ static reset() {
891
+ _StorageRegistry.entries.clear();
892
+ _StorageRegistry._context = void 0;
893
+ }
894
+ };
792
895
  var DEFAULT_CIRCUIT_BREAKER_CONFIG = {
793
896
  failureThreshold: 5,
794
897
  successThreshold: 2,
@@ -1526,7 +1629,6 @@ var DEFAULT_MAX_DELAY_MS = 3e4;
1526
1629
  var Connector = class _Connector {
1527
1630
  // ============ Static Registry ============
1528
1631
  static registry = /* @__PURE__ */ new Map();
1529
- static defaultStorage = new MemoryStorage();
1530
1632
  /**
1531
1633
  * Create and register a new connector
1532
1634
  * @param config - Must include `name` field
@@ -1584,11 +1686,18 @@ var Connector = class _Connector {
1584
1686
  }
1585
1687
  _Connector.registry.clear();
1586
1688
  }
1689
+ /**
1690
+ * Get the default token storage for OAuth connectors.
1691
+ * Resolves from StorageRegistry, falling back to MemoryStorage.
1692
+ */
1693
+ static get defaultStorage() {
1694
+ return StorageRegistry.resolve("oauthTokens", () => new MemoryStorage());
1695
+ }
1587
1696
  /**
1588
1697
  * Set default token storage for OAuth connectors
1589
1698
  */
1590
1699
  static setDefaultStorage(storage) {
1591
- _Connector.defaultStorage = storage;
1700
+ StorageRegistry.set("oauthTokens", storage);
1592
1701
  }
1593
1702
  /**
1594
1703
  * Get all registered connectors