@everworker/oneringai 0.1.1 → 0.1.2

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,2 +1,2 @@
1
- export { y as ImageEditOptions, x as ImageGenerateOptions, j as ImageGeneration, k as ImageGenerationCreateOptions, B as ImageResponse, z as ImageVariationOptions, l as SimpleGenerateOptions } from '../../ImageModel-B-uH3JEz.cjs';
1
+ export { D as ImageEditOptions, B as ImageGenerateOptions, m as ImageGeneration, n as ImageGenerationCreateOptions, F as ImageResponse, E as ImageVariationOptions, o as SimpleGenerateOptions } from '../../ImageModel-DtN780fU.cjs';
2
2
  import '../../IProvider-BP49c93d.cjs';
@@ -1,2 +1,2 @@
1
- export { y as ImageEditOptions, x as ImageGenerateOptions, j as ImageGeneration, k as ImageGenerationCreateOptions, B as ImageResponse, z as ImageVariationOptions, l as SimpleGenerateOptions } from '../../ImageModel-C7EyUfU0.js';
1
+ export { D as ImageEditOptions, B as ImageGenerateOptions, m as ImageGeneration, n as ImageGenerationCreateOptions, F as ImageResponse, E as ImageVariationOptions, o as SimpleGenerateOptions } from '../../ImageModel-BkAX5Rr5.js';
2
2
  import '../../IProvider-BP49c93d.js';
@@ -1425,6 +1425,58 @@ var metrics = createMetricsCollector(
1425
1425
  process.env.METRICS_PREFIX || "oneringai"
1426
1426
  );
1427
1427
 
1428
+ // src/core/ScopedConnectorRegistry.ts
1429
+ var ScopedConnectorRegistry = class {
1430
+ constructor(policy, context) {
1431
+ this.policy = policy;
1432
+ this.context = context;
1433
+ }
1434
+ get(name) {
1435
+ if (!Connector.has(name)) {
1436
+ const available = this.list().join(", ") || "none";
1437
+ throw new Error(`Connector '${name}' not found. Available: ${available}`);
1438
+ }
1439
+ const connector = Connector.get(name);
1440
+ if (!this.policy.canAccess(connector, this.context)) {
1441
+ const available = this.list().join(", ") || "none";
1442
+ throw new Error(`Connector '${name}' not found. Available: ${available}`);
1443
+ }
1444
+ return connector;
1445
+ }
1446
+ has(name) {
1447
+ if (!Connector.has(name)) return false;
1448
+ const connector = Connector.get(name);
1449
+ return this.policy.canAccess(connector, this.context);
1450
+ }
1451
+ list() {
1452
+ return this.listAll().map((c) => c.name);
1453
+ }
1454
+ listAll() {
1455
+ return Connector.listAll().filter((c) => this.policy.canAccess(c, this.context));
1456
+ }
1457
+ size() {
1458
+ return this.listAll().length;
1459
+ }
1460
+ getDescriptionsForTools() {
1461
+ const connectors = this.listAll();
1462
+ if (connectors.length === 0) {
1463
+ return "No connectors registered yet.";
1464
+ }
1465
+ return connectors.map((c) => ` - "${c.name}": ${c.displayName} - ${c.config.description || "No description"}`).join("\n");
1466
+ }
1467
+ getInfo() {
1468
+ const info = {};
1469
+ for (const connector of this.listAll()) {
1470
+ info[connector.name] = {
1471
+ displayName: connector.displayName,
1472
+ description: connector.config.description || "",
1473
+ baseURL: connector.baseURL
1474
+ };
1475
+ }
1476
+ return info;
1477
+ }
1478
+ };
1479
+
1428
1480
  // src/core/Connector.ts
1429
1481
  var DEFAULT_CONNECTOR_TIMEOUT = 3e4;
1430
1482
  var DEFAULT_MAX_RETRIES = 3;
@@ -1510,6 +1562,50 @@ var Connector = class _Connector {
1510
1562
  static size() {
1511
1563
  return _Connector.registry.size;
1512
1564
  }
1565
+ // ============ Access Control ============
1566
+ static _accessPolicy = null;
1567
+ /**
1568
+ * Set a global access policy for connector scoping.
1569
+ * Pass null to clear the policy.
1570
+ */
1571
+ static setAccessPolicy(policy) {
1572
+ _Connector._accessPolicy = policy;
1573
+ }
1574
+ /**
1575
+ * Get the current global access policy (or null if none set).
1576
+ */
1577
+ static getAccessPolicy() {
1578
+ return _Connector._accessPolicy;
1579
+ }
1580
+ /**
1581
+ * Create a scoped (filtered) view of the connector registry.
1582
+ * Requires a global access policy to be set via setAccessPolicy().
1583
+ *
1584
+ * @param context - Opaque context passed to the policy (e.g., { userId, tenantId })
1585
+ * @returns IConnectorRegistry that only exposes accessible connectors
1586
+ * @throws Error if no access policy is set
1587
+ */
1588
+ static scoped(context) {
1589
+ if (!_Connector._accessPolicy) {
1590
+ throw new Error("No access policy set. Call Connector.setAccessPolicy() first.");
1591
+ }
1592
+ return new ScopedConnectorRegistry(_Connector._accessPolicy, context);
1593
+ }
1594
+ /**
1595
+ * Return the static Connector methods as an IConnectorRegistry object (unfiltered).
1596
+ * Useful when code accepts the interface but you want the full admin view.
1597
+ */
1598
+ static asRegistry() {
1599
+ return {
1600
+ get: (name) => _Connector.get(name),
1601
+ has: (name) => _Connector.has(name),
1602
+ list: () => _Connector.list(),
1603
+ listAll: () => _Connector.listAll(),
1604
+ size: () => _Connector.size(),
1605
+ getDescriptionsForTools: () => _Connector.getDescriptionsForTools(),
1606
+ getInfo: () => _Connector.getInfo()
1607
+ };
1608
+ }
1513
1609
  /**
1514
1610
  * Get connector descriptions formatted for tool parameters
1515
1611
  * Useful for generating dynamic tool descriptions