@naylence/agent-sdk 0.3.13 → 0.3.15

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.
Files changed (93) hide show
  1. package/dist/browser/index.js +3344 -60377
  2. package/dist/browser/index.js.map +1 -1
  3. package/dist/cjs/agent-isomorphic.d.ts +11 -0
  4. package/dist/cjs/agent-isomorphic.js +30 -0
  5. package/dist/cjs/agent-isomorphic.js.map +1 -0
  6. package/dist/cjs/browser.d.ts +3 -1
  7. package/dist/cjs/browser.js +17 -1
  8. package/dist/cjs/browser.js.map +1 -1
  9. package/dist/cjs/index.d.ts +1 -3
  10. package/dist/cjs/index.js +1 -32
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/naylence/agent/factory-manifest.browser.d.ts +5 -0
  13. package/dist/cjs/naylence/agent/factory-manifest.browser.js +7 -0
  14. package/dist/cjs/naylence/agent/factory-manifest.browser.js.map +1 -0
  15. package/dist/cjs/naylence/agent/factory-manifest.d.ts +5 -0
  16. package/dist/cjs/naylence/agent/factory-manifest.js +46 -0
  17. package/dist/cjs/naylence/agent/factory-manifest.js.map +1 -0
  18. package/dist/cjs/naylence/agent/gateway/agent-http-gateway-listener-factory.d.ts +23 -0
  19. package/dist/cjs/naylence/agent/gateway/agent-http-gateway-listener-factory.js +144 -0
  20. package/dist/cjs/naylence/agent/gateway/agent-http-gateway-listener-factory.js.map +1 -0
  21. package/dist/cjs/naylence/agent/gateway/agent-http-gateway-listener.d.ts +40 -0
  22. package/dist/cjs/naylence/agent/gateway/agent-http-gateway-listener.js +347 -0
  23. package/dist/cjs/naylence/agent/gateway/agent-http-gateway-listener.js.map +1 -0
  24. package/dist/cjs/naylence/agent/index.d.ts +1 -0
  25. package/dist/cjs/naylence/agent/index.js +1 -0
  26. package/dist/cjs/naylence/agent/index.js.map +1 -1
  27. package/dist/cjs/naylence/agent/util/register-agent-factories.d.ts +4 -0
  28. package/dist/cjs/naylence/agent/util/register-agent-factories.js +132 -0
  29. package/dist/cjs/naylence/agent/util/register-agent-factories.js.map +1 -0
  30. package/dist/cjs/node.d.ts +5 -0
  31. package/dist/cjs/node.js +46 -0
  32. package/dist/cjs/node.js.map +1 -0
  33. package/dist/cjs/plugin.js +2 -0
  34. package/dist/cjs/plugin.js.map +1 -1
  35. package/dist/cjs/version.d.ts +1 -1
  36. package/dist/cjs/version.js +1 -1
  37. package/dist/esm/agent-isomorphic.d.ts +18 -0
  38. package/dist/esm/agent-isomorphic.js +21 -0
  39. package/dist/esm/agent-isomorphic.js.map +1 -0
  40. package/dist/esm/browser.d.ts +9 -1
  41. package/dist/esm/browser.js +21 -3
  42. package/dist/esm/browser.js.map +1 -1
  43. package/dist/esm/index.d.ts +7 -3
  44. package/dist/esm/index.js +7 -34
  45. package/dist/esm/index.js.map +1 -1
  46. package/dist/esm/naylence/agent/factory-manifest.browser.d.ts +11 -0
  47. package/dist/esm/naylence/agent/factory-manifest.browser.js +11 -0
  48. package/dist/esm/naylence/agent/factory-manifest.browser.js.map +1 -0
  49. package/dist/esm/naylence/agent/factory-manifest.d.ts +11 -0
  50. package/dist/esm/naylence/agent/factory-manifest.js +17 -0
  51. package/dist/esm/naylence/agent/factory-manifest.js.map +1 -0
  52. package/dist/esm/naylence/agent/gateway/agent-http-gateway-listener-factory.d.ts +37 -0
  53. package/dist/esm/naylence/agent/gateway/agent-http-gateway-listener-factory.js +128 -0
  54. package/dist/esm/naylence/agent/gateway/agent-http-gateway-listener-factory.js.map +1 -0
  55. package/dist/esm/naylence/agent/gateway/agent-http-gateway-listener.d.ts +50 -0
  56. package/dist/esm/naylence/agent/gateway/agent-http-gateway-listener.js +350 -0
  57. package/dist/esm/naylence/agent/gateway/agent-http-gateway-listener.js.map +1 -0
  58. package/dist/esm/naylence/agent/index.d.ts +5 -0
  59. package/dist/esm/naylence/agent/index.js +5 -0
  60. package/dist/esm/naylence/agent/index.js.map +1 -1
  61. package/dist/esm/naylence/agent/util/register-agent-factories.d.ts +4 -0
  62. package/dist/esm/naylence/agent/util/register-agent-factories.js +103 -0
  63. package/dist/esm/naylence/agent/util/register-agent-factories.js.map +1 -0
  64. package/dist/esm/node.d.ts +11 -0
  65. package/dist/esm/node.js +37 -0
  66. package/dist/esm/node.js.map +1 -0
  67. package/dist/esm/plugin.js +2 -4
  68. package/dist/esm/plugin.js.map +1 -1
  69. package/dist/esm/version.d.ts +1 -1
  70. package/dist/esm/version.js +2 -2
  71. package/dist/types/agent-isomorphic.d.ts +19 -0
  72. package/dist/types/agent-isomorphic.d.ts.map +1 -0
  73. package/dist/types/browser.d.ts +9 -1
  74. package/dist/types/browser.d.ts.map +1 -1
  75. package/dist/types/index.d.ts +7 -3
  76. package/dist/types/index.d.ts.map +1 -1
  77. package/dist/types/naylence/agent/factory-manifest.browser.d.ts +12 -0
  78. package/dist/types/naylence/agent/factory-manifest.browser.d.ts.map +1 -0
  79. package/dist/types/naylence/agent/factory-manifest.d.ts +12 -0
  80. package/dist/types/naylence/agent/factory-manifest.d.ts.map +1 -0
  81. package/dist/types/naylence/agent/gateway/agent-http-gateway-listener-factory.d.ts +38 -0
  82. package/dist/types/naylence/agent/gateway/agent-http-gateway-listener-factory.d.ts.map +1 -0
  83. package/dist/types/naylence/agent/gateway/agent-http-gateway-listener.d.ts +51 -0
  84. package/dist/types/naylence/agent/gateway/agent-http-gateway-listener.d.ts.map +1 -0
  85. package/dist/types/naylence/agent/index.d.ts +5 -0
  86. package/dist/types/naylence/agent/index.d.ts.map +1 -1
  87. package/dist/types/naylence/agent/util/register-agent-factories.d.ts +5 -0
  88. package/dist/types/naylence/agent/util/register-agent-factories.d.ts.map +1 -0
  89. package/dist/types/node.d.ts +12 -0
  90. package/dist/types/node.d.ts.map +1 -0
  91. package/dist/types/plugin.d.ts.map +1 -1
  92. package/dist/types/version.d.ts +1 -1
  93. package/package.json +26 -15
@@ -0,0 +1,11 @@
1
+ export * from './naylence/agent/a2a-types.js';
2
+ export * from './naylence/agent/agent.js';
3
+ export * from './naylence/agent/base-agent.js';
4
+ export * from './naylence/agent/background-task-agent.js';
5
+ export { AgentProxy } from './naylence/agent/agent-proxy.js';
6
+ export * from './naylence/agent/errors.js';
7
+ export * from './naylence/agent/rpc-adapter.js';
8
+ export * from './naylence/agent/util.js';
9
+ export * from './naylence/agent/configs.js';
10
+ export * from './naylence/agent/util/register-agent-factories.js';
11
+ import './naylence/agent/agent-proxy-default.js';
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.AgentProxy = void 0;
18
+ __exportStar(require("./naylence/agent/a2a-types.js"), exports);
19
+ __exportStar(require("./naylence/agent/agent.js"), exports);
20
+ __exportStar(require("./naylence/agent/base-agent.js"), exports);
21
+ __exportStar(require("./naylence/agent/background-task-agent.js"), exports);
22
+ var agent_proxy_js_1 = require("./naylence/agent/agent-proxy.js");
23
+ Object.defineProperty(exports, "AgentProxy", { enumerable: true, get: function () { return agent_proxy_js_1.AgentProxy; } });
24
+ __exportStar(require("./naylence/agent/errors.js"), exports);
25
+ __exportStar(require("./naylence/agent/rpc-adapter.js"), exports);
26
+ __exportStar(require("./naylence/agent/util.js"), exports);
27
+ __exportStar(require("./naylence/agent/configs.js"), exports);
28
+ __exportStar(require("./naylence/agent/util/register-agent-factories.js"), exports);
29
+ require("./naylence/agent/agent-proxy-default.js");
30
+ //# sourceMappingURL=agent-isomorphic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-isomorphic.js","sourceRoot":"","sources":["../../src/agent-isomorphic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AASA,gEAA8C;AAC9C,4DAA0C;AAC1C,iEAA+C;AAC/C,4EAA0D;AAC1D,kEAA6D;AAApD,4GAAA,UAAU,OAAA;AACnB,6DAA2C;AAC3C,kEAAgD;AAChD,2DAAyC;AACzC,8DAA4C;AAC5C,oFAAkE;AAGlE,mDAAiD"}
@@ -1 +1,3 @@
1
- export * from './index.js';
1
+ import '@naylence/runtime';
2
+ export * from './agent-isomorphic.js';
3
+ export { default } from './plugin.js';
@@ -13,6 +13,22 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
16
19
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.js"), exports);
20
+ exports.default = void 0;
21
+ require("@naylence/runtime");
22
+ const plugin_js_1 = __importDefault(require("./plugin.js"));
23
+ (async () => {
24
+ try {
25
+ await plugin_js_1.default.register();
26
+ }
27
+ catch (err) {
28
+ console.error('[naylence-agent-sdk] Failed to auto-register plugin:', err);
29
+ }
30
+ })();
31
+ __exportStar(require("./agent-isomorphic.js"), exports);
32
+ var plugin_js_2 = require("./plugin.js");
33
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(plugin_js_2).default; } });
18
34
  //# sourceMappingURL=browser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAGA,6CAA2B"}
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAMA,6BAA2B;AAC3B,4DAAiC;AAGjC,CAAC,KAAK,IAAI,EAAE;IACV,IAAI,CAAC;QACH,MAAM,mBAAM,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,sDAAsD,EAAE,GAAG,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC,CAAC,EAAE,CAAC;AAGL,wDAAsC;AAGtC,yCAAsC;AAA7B,qHAAA,OAAO,OAAA"}
@@ -1,3 +1 @@
1
- import '@naylence/runtime';
2
- export * from './naylence/agent/index.js';
3
- export { default } from './plugin.js';
1
+ export * from './agent-isomorphic.js';
package/dist/cjs/index.js CHANGED
@@ -13,37 +13,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
16
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.default = void 0;
21
- require("@naylence/runtime");
22
- const plugin_js_1 = __importDefault(require("./plugin.js"));
23
- (async () => {
24
- try {
25
- await plugin_js_1.default.register();
26
- }
27
- catch (err) {
28
- console.error('[naylence-agent-sdk] Failed to auto-register plugin:', err);
29
- }
30
- })();
31
- const g = (typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {});
32
- const proc = g.process || (typeof process !== 'undefined' ? process : undefined);
33
- const isNode = typeof process !== 'undefined' &&
34
- process.versions != null &&
35
- process.versions.node != null;
36
- if (isNode && proc && proc.env) {
37
- const pluginName = '@naylence/agent-sdk';
38
- const current = proc.env.FAME_PLUGINS || '';
39
- const plugins = current.split(',').map((p) => p.trim());
40
- if (!plugins.includes(pluginName)) {
41
- proc.env.FAME_PLUGINS = current
42
- ? `${current},${pluginName}`
43
- : pluginName;
44
- }
45
- }
46
- __exportStar(require("./naylence/agent/index.js"), exports);
47
- var plugin_js_2 = require("./plugin.js");
48
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(plugin_js_2).default; } });
17
+ __exportStar(require("./agent-isomorphic.js"), exports);
49
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,6BAA2B;AAC3B,4DAAiC;AAKjC,CAAC,KAAK,IAAI,EAAE;IACV,IAAI,CAAC;QACH,MAAM,mBAAM,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,sDAAsD,EAAE,GAAG,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC,CAAC,EAAE,CAAC;AAEL,MAAM,CAAC,GAAG,CAAC,OAAO,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAQ,CAAC;AACrJ,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACjF,MAAM,MAAM,GACV,OAAO,OAAO,KAAK,WAAW;IAC9B,OAAO,CAAC,QAAQ,IAAI,IAAI;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC;AAIhC,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAC/B,MAAM,UAAU,GAAG,qBAAqB,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAChE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,OAAO;YAC7B,CAAC,CAAC,GAAG,OAAO,IAAI,UAAU,EAAE;YAC5B,CAAC,CAAC,UAAU,CAAC;IACjB,CAAC;AACH,CAAC;AAED,4DAA0C;AAG1C,yCAAsC;AAA7B,qHAAA,OAAO,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAMA,wDAAsC"}
@@ -0,0 +1,5 @@
1
+ export declare const MODULES: readonly [];
2
+ export type FactoryModuleSpec = (typeof MODULES)[number];
3
+ export type FactoryModuleLoader = () => Promise<Record<string, unknown>>;
4
+ export declare const MODULE_LOADERS: Record<FactoryModuleSpec, FactoryModuleLoader>;
5
+ export declare const NODE_ONLY_FACTORY_MODULES: Set<never>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NODE_ONLY_FACTORY_MODULES = exports.MODULE_LOADERS = exports.MODULES = void 0;
4
+ exports.MODULES = [];
5
+ exports.MODULE_LOADERS = {};
6
+ exports.NODE_ONLY_FACTORY_MODULES = new Set([]);
7
+ //# sourceMappingURL=factory-manifest.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory-manifest.browser.js","sourceRoot":"","sources":["../../../../src/naylence/agent/factory-manifest.browser.ts"],"names":[],"mappings":";;;AAOa,QAAA,OAAO,GAAG,EAAW,CAAC;AAKtB,QAAA,cAAc,GAAmD,EAE7E,CAAC;AAGW,QAAA,yBAAyB,GAAG,IAAI,GAAG,CAAoB,EAEnE,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const MODULES: readonly ["./gateway/agent-http-gateway-listener-factory.js"];
2
+ export type FactoryModuleSpec = (typeof MODULES)[number];
3
+ export type FactoryModuleLoader = () => Promise<Record<string, unknown>>;
4
+ export declare const MODULE_LOADERS: Record<FactoryModuleSpec, FactoryModuleLoader>;
5
+ export declare const NODE_ONLY_FACTORY_MODULES: Set<"./gateway/agent-http-gateway-listener-factory.js">;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.NODE_ONLY_FACTORY_MODULES = exports.MODULE_LOADERS = exports.MODULES = void 0;
37
+ exports.MODULES = [
38
+ "./gateway/agent-http-gateway-listener-factory.js"
39
+ ];
40
+ exports.MODULE_LOADERS = {
41
+ "./gateway/agent-http-gateway-listener-factory.js": () => Promise.resolve().then(() => __importStar(require("./gateway/agent-http-gateway-listener-factory.js"))),
42
+ };
43
+ exports.NODE_ONLY_FACTORY_MODULES = new Set([
44
+ "./gateway/agent-http-gateway-listener-factory.js",
45
+ ]);
46
+ //# sourceMappingURL=factory-manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory-manifest.js","sourceRoot":"","sources":["../../../../src/naylence/agent/factory-manifest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOa,QAAA,OAAO,GAAG;IACrB,kDAAkD;CAC1C,CAAC;AAKE,QAAA,cAAc,GAAmD;IAC5E,kDAAkD,EAAE,GAAG,EAAE,mDAAqD,kDAAkD,GAAC;CAClK,CAAC;AAGW,QAAA,yBAAyB,GAAG,IAAI,GAAG,CAAoB;IAClE,kDAAkD;CACnD,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { GatewayLimits } from './agent-http-gateway-listener.js';
2
+ import type { Authorizer, HttpServer, TransportListener, TransportListenerConfig } from '@naylence/runtime/node';
3
+ export interface AgentHttpGatewayListenerFactoryConfig extends TransportListenerConfig {
4
+ type: 'AgentHttpGatewayListener';
5
+ basePath?: string;
6
+ authorizer?: Record<string, unknown> | null;
7
+ limits?: GatewayLimits;
8
+ }
9
+ export interface CreateAgentHttpGatewayListenerOptions {
10
+ httpServer?: HttpServer;
11
+ authorizer?: Authorizer | null;
12
+ }
13
+ export declare const FACTORY_META: {
14
+ readonly base: "TransportListenerFactory";
15
+ readonly key: "AgentHttpGatewayListener";
16
+ };
17
+ export declare class AgentHttpGatewayListenerFactory {
18
+ readonly type = "AgentHttpGatewayListener";
19
+ readonly priority = 1000;
20
+ create(config?: AgentHttpGatewayListenerFactoryConfig | Record<string, unknown> | null, ...factoryArgs: unknown[]): Promise<TransportListener>;
21
+ private _createDefaultHttpServer;
22
+ }
23
+ export default AgentHttpGatewayListenerFactory;
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.AgentHttpGatewayListenerFactory = exports.FACTORY_META = void 0;
37
+ const TRANSPORT_LISTENER_FACTORY_BASE_TYPE = 'TransportListenerFactory';
38
+ let runtimeNodeModulePromise = null;
39
+ async function getRuntimeNodeModule() {
40
+ if (!runtimeNodeModulePromise) {
41
+ runtimeNodeModulePromise = Promise.resolve().then(() => __importStar(require('@naylence/runtime/node')));
42
+ }
43
+ return runtimeNodeModulePromise;
44
+ }
45
+ let gatewayListenerModulePromise = null;
46
+ async function getGatewayListenerModule() {
47
+ if (!gatewayListenerModulePromise) {
48
+ gatewayListenerModulePromise = Promise.resolve().then(() => __importStar(require('./agent-http-gateway-listener.js')));
49
+ }
50
+ return gatewayListenerModulePromise;
51
+ }
52
+ function addServerEventListener(server, listeners) {
53
+ if (!server || !Array.isArray(listeners)) {
54
+ return;
55
+ }
56
+ const candidate = server;
57
+ if (!candidate || typeof candidate !== 'object') {
58
+ return;
59
+ }
60
+ const listener = candidate;
61
+ if (typeof listener.priority === 'number' && !listeners.includes(listener)) {
62
+ listeners.push(listener);
63
+ }
64
+ }
65
+ function normalizeConfig(config) {
66
+ const record = (config ?? {});
67
+ const hostValue = typeof record.host === 'string' && record.host.trim().length > 0 ? record.host.trim() : '0.0.0.0';
68
+ const rawPort = record.port;
69
+ let portValue = 0;
70
+ if (typeof rawPort === 'number' && Number.isFinite(rawPort)) {
71
+ portValue = rawPort;
72
+ }
73
+ else if (typeof rawPort === 'string') {
74
+ const parsed = Number.parseInt(rawPort.trim(), 10);
75
+ if (Number.isFinite(parsed)) {
76
+ portValue = parsed;
77
+ }
78
+ }
79
+ const basePathValue = typeof record.basePath === 'string' && record.basePath.trim().length > 0
80
+ ? record.basePath.trim()
81
+ : '/fame/v1/gateway';
82
+ const rawAuthorizer = record.authorizer ?? null;
83
+ const authorizerValue = rawAuthorizer && typeof rawAuthorizer === 'object' && !Array.isArray(rawAuthorizer)
84
+ ? rawAuthorizer
85
+ : null;
86
+ const rawLimits = record.limits ?? null;
87
+ const limitsValue = rawLimits && typeof rawLimits === 'object' && !Array.isArray(rawLimits)
88
+ ? rawLimits
89
+ : null;
90
+ return {
91
+ type: 'AgentHttpGatewayListener',
92
+ host: hostValue,
93
+ port: portValue,
94
+ basePath: basePathValue,
95
+ authorizer: authorizerValue,
96
+ limits: limitsValue,
97
+ };
98
+ }
99
+ exports.FACTORY_META = {
100
+ base: TRANSPORT_LISTENER_FACTORY_BASE_TYPE,
101
+ key: 'AgentHttpGatewayListener',
102
+ };
103
+ class AgentHttpGatewayListenerFactory {
104
+ constructor() {
105
+ this.type = 'AgentHttpGatewayListener';
106
+ this.priority = 1000;
107
+ }
108
+ async create(config, ...factoryArgs) {
109
+ const normalized = normalizeConfig(config);
110
+ const [firstArg, ...remainingArgs] = factoryArgs;
111
+ const eventListeners = Array.isArray(firstArg) ? firstArg : [];
112
+ const optionsSource = Array.isArray(firstArg) ? (remainingArgs[0] ?? null) : firstArg;
113
+ const options = optionsSource;
114
+ const { AgentHttpGatewayListener } = await getGatewayListenerModule();
115
+ const httpServer = options?.httpServer ?? (await this._createDefaultHttpServer(normalized));
116
+ addServerEventListener(httpServer, eventListeners);
117
+ let authorizer = options?.authorizer ?? null;
118
+ if (!authorizer && normalized.authorizer) {
119
+ const runtimeNode = await getRuntimeNodeModule();
120
+ const AuthorizerFactory = runtimeNode.AuthorizerFactory;
121
+ authorizer =
122
+ (await AuthorizerFactory.createAuthorizer(normalized.authorizer, {
123
+ validate: false,
124
+ })) ?? null;
125
+ }
126
+ return new AgentHttpGatewayListener({
127
+ httpServer,
128
+ basePath: normalized.basePath,
129
+ ...(authorizer ? { authorizer } : {}),
130
+ ...(normalized.limits ? { limits: normalized.limits } : {}),
131
+ });
132
+ }
133
+ async _createDefaultHttpServer(normalized) {
134
+ const runtimeNode = await getRuntimeNodeModule();
135
+ const DefaultHttpServer = runtimeNode.DefaultHttpServer;
136
+ return await DefaultHttpServer.getOrCreate({
137
+ host: normalized.host,
138
+ port: normalized.port,
139
+ });
140
+ }
141
+ }
142
+ exports.AgentHttpGatewayListenerFactory = AgentHttpGatewayListenerFactory;
143
+ exports.default = AgentHttpGatewayListenerFactory;
144
+ //# sourceMappingURL=agent-http-gateway-listener-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-http-gateway-listener-factory.js","sourceRoot":"","sources":["../../../../../src/naylence/agent/gateway/agent-http-gateway-listener-factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,oCAAoC,GAAG,0BAA0B,CAAC;AAyBxE,IAAI,wBAAwB,GAAwB,IAAI,CAAC;AAMzD,KAAK,UAAU,oBAAoB;IACjC,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAE9B,wBAAwB,qDAAuD,wBAAwB,GAAC,CAAC;IAC3G,CAAC;IACD,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAED,IAAI,4BAA4B,GAAkF,IAAI,CAAC;AAEvH,KAAK,UAAU,wBAAwB;IACrC,IAAI,CAAC,4BAA4B,EAAE,CAAC;QAElC,4BAA4B,qDAAuD,kCAAkC,GAAC,CAAC;IACzH,CAAC;IACD,OAAO,4BAA4B,CAAC;AACtC,CAAC;AAED,SAAS,sBAAsB,CAAC,MAAqC,EAAE,SAA8B;IACnG,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACzC,OAAO;IACT,CAAC;IACD,MAAM,SAAS,GAAG,MAAiB,CAAC;IACpC,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO;IACT,CAAC;IACD,MAAM,QAAQ,GAAG,SAA8B,CAAC;IAChD,IAAI,OAAO,QAAQ,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3E,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,MAA+E;IACtG,MAAM,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C5F,sBAAsB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAEnD,IAAI,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,IAAI,CAAC;QAC7C,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;YACzC,MAAM,WAAW,GAAG,MAAM,oBAAoB,EAAE,CAAC;YACjD,MAAM,iBAAiB,GAAG,WAAW,CAAC,iBAAiB,CAAC;YACxD,UAAU;gBACR,CAAC,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,UAAU,CAAC,UAAU,EAAE;oBAC/D,QAAQ,EAAE,KAAK;iBAChB,CAAC,CAAC,IAAI,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,wBAAwB,CAAC;YAClC,UAAU;YACV,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,wBAAwB,CAAC,UAA4B;QACjE,MAAM,WAAW,GAAG,MAAM,oBAAoB,EAAE,CAAC;QACjD,MAAM,iBAAiB,GAAG,WAAW,CAAC,iBAAiB,CAAC;QACxD,OAAO,MAAM,iBAAiB,CAAC,WAAW,CAAC;YACzC,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,IAAI,EAAE,UAAU,CAAC,IAAI;SACtB,CAAC,CAAC;IACL,CAAC;CACF;AA5CD,0EA4CC;AAED,kBAAe,+BAA+B,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { TransportListener, type Authorizer, type HttpRouter, type HttpServer, type NodeLike } from '@naylence/runtime/node';
2
+ export interface GatewayLimits {
3
+ maxMethodLength?: number;
4
+ maxTargetAddrLength?: number;
5
+ maxTypeLength?: number;
6
+ maxCapabilities?: number;
7
+ maxCapabilityLength?: number;
8
+ bodyLimitBytes?: number;
9
+ }
10
+ export interface AgentHttpGatewayListenerParams {
11
+ httpServer: HttpServer;
12
+ basePath?: string;
13
+ authorizer?: Authorizer | null;
14
+ limits?: GatewayLimits;
15
+ }
16
+ export declare class AgentHttpGatewayListener extends TransportListener {
17
+ private readonly _httpServer;
18
+ private readonly _authorizer;
19
+ private readonly _basePath;
20
+ private readonly _limits;
21
+ private _node;
22
+ private _routerRegistered;
23
+ constructor(params: AgentHttpGatewayListenerParams);
24
+ get httpServer(): HttpServer;
25
+ onNodeInitialized(node: NodeLike): Promise<void>;
26
+ onNodeStarted(): Promise<void>;
27
+ onNodeStopped(): Promise<void>;
28
+ createRouter(): Promise<HttpRouter>;
29
+ private _handleRpc;
30
+ private _handleMessage;
31
+ private _parseRpcRequest;
32
+ private _parseMessageRequest;
33
+ private _parseTimeoutValue;
34
+ private _normalizeTimeout;
35
+ private _invokeRpc;
36
+ private _sendMessage;
37
+ private _authenticateRequest;
38
+ private _resolveAuthorizer;
39
+ private _mapError;
40
+ }