hono-apcore 0.1.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.
Files changed (139) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +426 -0
  3. package/dist/a2a/apcore-a2a.service.d.ts +44 -0
  4. package/dist/a2a/apcore-a2a.service.d.ts.map +1 -0
  5. package/dist/a2a/apcore-a2a.service.js +82 -0
  6. package/dist/a2a/apcore-a2a.service.js.map +1 -0
  7. package/dist/a2a/index.d.ts +2 -0
  8. package/dist/a2a/index.d.ts.map +1 -0
  9. package/dist/a2a/index.js +2 -0
  10. package/dist/a2a/index.js.map +1 -0
  11. package/dist/bridge/binding-loader.d.ts +45 -0
  12. package/dist/bridge/binding-loader.d.ts.map +1 -0
  13. package/dist/bridge/binding-loader.js +84 -0
  14. package/dist/bridge/binding-loader.js.map +1 -0
  15. package/dist/bridge/index.d.ts +3 -0
  16. package/dist/bridge/index.d.ts.map +1 -0
  17. package/dist/bridge/index.js +2 -0
  18. package/dist/bridge/index.js.map +1 -0
  19. package/dist/cli/apcore-cli.service.d.ts +50 -0
  20. package/dist/cli/apcore-cli.service.d.ts.map +1 -0
  21. package/dist/cli/apcore-cli.service.js +76 -0
  22. package/dist/cli/apcore-cli.service.js.map +1 -0
  23. package/dist/cli/index.d.ts +2 -0
  24. package/dist/cli/index.d.ts.map +1 -0
  25. package/dist/cli/index.js +2 -0
  26. package/dist/cli/index.js.map +1 -0
  27. package/dist/cli.d.ts +4 -0
  28. package/dist/cli.d.ts.map +1 -0
  29. package/dist/cli.js +247 -0
  30. package/dist/cli.js.map +1 -0
  31. package/dist/config.d.ts +55 -0
  32. package/dist/config.d.ts.map +1 -0
  33. package/dist/config.js +86 -0
  34. package/dist/config.js.map +1 -0
  35. package/dist/constants.d.ts +27 -0
  36. package/dist/constants.d.ts.map +1 -0
  37. package/dist/constants.js +27 -0
  38. package/dist/constants.js.map +1 -0
  39. package/dist/context/hono-context.factory.d.ts +61 -0
  40. package/dist/context/hono-context.factory.d.ts.map +1 -0
  41. package/dist/context/hono-context.factory.js +117 -0
  42. package/dist/context/hono-context.factory.js.map +1 -0
  43. package/dist/context/index.d.ts +3 -0
  44. package/dist/context/index.d.ts.map +1 -0
  45. package/dist/context/index.js +2 -0
  46. package/dist/context/index.js.map +1 -0
  47. package/dist/core/apcore.d.ts +135 -0
  48. package/dist/core/apcore.d.ts.map +1 -0
  49. package/dist/core/apcore.js +257 -0
  50. package/dist/core/apcore.js.map +1 -0
  51. package/dist/core/executor.d.ts +32 -0
  52. package/dist/core/executor.d.ts.map +1 -0
  53. package/dist/core/executor.js +41 -0
  54. package/dist/core/executor.js.map +1 -0
  55. package/dist/core/middleware.d.ts +61 -0
  56. package/dist/core/middleware.d.ts.map +1 -0
  57. package/dist/core/middleware.js +51 -0
  58. package/dist/core/middleware.js.map +1 -0
  59. package/dist/core/registry.d.ts +79 -0
  60. package/dist/core/registry.d.ts.map +1 -0
  61. package/dist/core/registry.js +218 -0
  62. package/dist/core/registry.js.map +1 -0
  63. package/dist/index.d.ts +33 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +71 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/mcp/apcore-mcp.service.d.ts +83 -0
  68. package/dist/mcp/apcore-mcp.service.d.ts.map +1 -0
  69. package/dist/mcp/apcore-mcp.service.js +189 -0
  70. package/dist/mcp/apcore-mcp.service.js.map +1 -0
  71. package/dist/mcp/index.d.ts +5 -0
  72. package/dist/mcp/index.d.ts.map +1 -0
  73. package/dist/mcp/index.js +3 -0
  74. package/dist/mcp/index.js.map +1 -0
  75. package/dist/mcp/mount.d.ts +51 -0
  76. package/dist/mcp/mount.d.ts.map +1 -0
  77. package/dist/mcp/mount.js +95 -0
  78. package/dist/mcp/mount.js.map +1 -0
  79. package/dist/output/index.d.ts +3 -0
  80. package/dist/output/index.d.ts.map +1 -0
  81. package/dist/output/index.js +2 -0
  82. package/dist/output/index.js.map +1 -0
  83. package/dist/output/yaml-writer.d.ts +31 -0
  84. package/dist/output/yaml-writer.d.ts.map +1 -0
  85. package/dist/output/yaml-writer.js +49 -0
  86. package/dist/output/yaml-writer.js.map +1 -0
  87. package/dist/scanners/hono-route-scanner.d.ts +60 -0
  88. package/dist/scanners/hono-route-scanner.d.ts.map +1 -0
  89. package/dist/scanners/hono-route-scanner.js +217 -0
  90. package/dist/scanners/hono-route-scanner.js.map +1 -0
  91. package/dist/scanners/index.d.ts +3 -0
  92. package/dist/scanners/index.d.ts.map +1 -0
  93. package/dist/scanners/index.js +2 -0
  94. package/dist/scanners/index.js.map +1 -0
  95. package/dist/schema/adapters/json-schema.adapter.d.ts +23 -0
  96. package/dist/schema/adapters/json-schema.adapter.d.ts.map +1 -0
  97. package/dist/schema/adapters/json-schema.adapter.js +40 -0
  98. package/dist/schema/adapters/json-schema.adapter.js.map +1 -0
  99. package/dist/schema/adapters/schema-adapter.interface.d.ts +24 -0
  100. package/dist/schema/adapters/schema-adapter.interface.d.ts.map +1 -0
  101. package/dist/schema/adapters/schema-adapter.interface.js +2 -0
  102. package/dist/schema/adapters/schema-adapter.interface.js.map +1 -0
  103. package/dist/schema/adapters/typebox.adapter.d.ts +26 -0
  104. package/dist/schema/adapters/typebox.adapter.d.ts.map +1 -0
  105. package/dist/schema/adapters/typebox.adapter.js +39 -0
  106. package/dist/schema/adapters/typebox.adapter.js.map +1 -0
  107. package/dist/schema/adapters/zod.adapter.d.ts +17 -0
  108. package/dist/schema/adapters/zod.adapter.d.ts.map +1 -0
  109. package/dist/schema/adapters/zod.adapter.js +372 -0
  110. package/dist/schema/adapters/zod.adapter.js.map +1 -0
  111. package/dist/schema/index.d.ts +6 -0
  112. package/dist/schema/index.d.ts.map +1 -0
  113. package/dist/schema/index.js +5 -0
  114. package/dist/schema/index.js.map +1 -0
  115. package/dist/schema/schema-extractor.d.ts +51 -0
  116. package/dist/schema/schema-extractor.d.ts.map +1 -0
  117. package/dist/schema/schema-extractor.js +89 -0
  118. package/dist/schema/schema-extractor.js.map +1 -0
  119. package/dist/tools/define-tool.d.ts +68 -0
  120. package/dist/tools/define-tool.d.ts.map +1 -0
  121. package/dist/tools/define-tool.js +122 -0
  122. package/dist/tools/define-tool.js.map +1 -0
  123. package/dist/tools/index.d.ts +3 -0
  124. package/dist/tools/index.d.ts.map +1 -0
  125. package/dist/tools/index.js +2 -0
  126. package/dist/tools/index.js.map +1 -0
  127. package/dist/types.d.ts +246 -0
  128. package/dist/types.d.ts.map +1 -0
  129. package/dist/types.js +2 -0
  130. package/dist/types.js.map +1 -0
  131. package/dist/utils/id-generator.d.ts +52 -0
  132. package/dist/utils/id-generator.d.ts.map +1 -0
  133. package/dist/utils/id-generator.js +87 -0
  134. package/dist/utils/id-generator.js.map +1 -0
  135. package/dist/utils/module-factory.d.ts +34 -0
  136. package/dist/utils/module-factory.d.ts.map +1 -0
  137. package/dist/utils/module-factory.js +59 -0
  138. package/dist/utils/module-factory.js.map +1 -0
  139. package/package.json +109 -0
@@ -0,0 +1,61 @@
1
+ import type { Context as HonoContext, MiddlewareHandler } from 'hono';
2
+ import type { Context as ApcoreContext } from 'apcore-js';
3
+ import { HonoContextFactory } from '../context/hono-context.factory.js';
4
+ import type { HonoApcore } from './apcore.js';
5
+ import type { HonoApcoreOptions } from '../types.js';
6
+ declare module 'hono' {
7
+ interface ContextVariableMap {
8
+ /** The {@link HonoApcore} instance installed by the `apcore()` middleware. */
9
+ apcore: HonoApcore;
10
+ /** The per-request apcore `Context` (identity, trace, correlation id). */
11
+ apcoreContext: ApcoreContext;
12
+ }
13
+ }
14
+ /** Options for the {@link apcore} middleware. */
15
+ export interface ApcoreMiddlewareOptions {
16
+ /** Factory used to build the per-request apcore `Context`. */
17
+ contextFactory?: HonoContextFactory;
18
+ /**
19
+ * Skip building a per-request `Context`. Set this when a route never calls
20
+ * modules through the executor and you want to shave the work.
21
+ */
22
+ skipContext?: boolean;
23
+ }
24
+ /**
25
+ * Hono middleware that puts the apcore instance and a per-request apcore
26
+ * `Context` on the Hono context.
27
+ *
28
+ * Downstream handlers read them with {@link getApcore} and
29
+ * {@link getApcoreContext} — or, since the variable map is augmented,
30
+ * directly via `c.get('apcore')`.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const ap = createApcore({ mcp: { explorer: true } });
35
+ * app.use('*', apcore(ap));
36
+ *
37
+ * app.get('/orders', async (c) => {
38
+ * const result = await getApcore(c).executor.call('orders.list', {}, getApcoreContext(c));
39
+ * return c.json(result);
40
+ * });
41
+ * ```
42
+ *
43
+ * @param instance - An existing {@link HonoApcore}, or options to build one.
44
+ * Passing options is a convenience for simple apps; keep a reference to the
45
+ * instance when you need to register tools or mount MCP.
46
+ */
47
+ export declare function apcore(instance: HonoApcore, options?: ApcoreMiddlewareOptions): MiddlewareHandler;
48
+ export declare function apcore(options?: HonoApcoreOptions & ApcoreMiddlewareOptions): MiddlewareHandler;
49
+ /**
50
+ * Read the {@link HonoApcore} instance the `apcore()` middleware installed.
51
+ *
52
+ * @throws {Error} When the middleware has not run for this request.
53
+ */
54
+ export declare function getApcore(c: HonoContext): HonoApcore;
55
+ /**
56
+ * Read the per-request apcore `Context` the `apcore()` middleware built.
57
+ *
58
+ * @throws {Error} When the middleware has not run, or ran with `skipContext`.
59
+ */
60
+ export declare function getApcoreContext(c: HonoContext): ApcoreContext;
61
+ //# sourceMappingURL=middleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/core/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,WAAW,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,kBAAkB;QAC1B,8EAA8E;QAC9E,MAAM,EAAE,UAAU,CAAC;QACnB,0EAA0E;QAC1E,aAAa,EAAE,aAAa,CAAC;KAC9B;CACF;AAED,iDAAiD;AACjD,MAAM,WAAW,uBAAuB;IACtC,8DAA8D;IAC9D,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,UAAU,EACpB,OAAO,CAAC,EAAE,uBAAuB,GAChC,iBAAiB,CAAC;AACrB,wBAAgB,MAAM,CACpB,OAAO,CAAC,EAAE,iBAAiB,GAAG,uBAAuB,GACpD,iBAAiB,CAAC;AAsCrB;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,WAAW,GAAG,UAAU,CAQpD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,WAAW,GAAG,aAAa,CAQ9D"}
@@ -0,0 +1,51 @@
1
+ import { APCORE_CONTEXT_VAR, APCORE_VAR } from '../constants.js';
2
+ import { HonoContextFactory } from '../context/hono-context.factory.js';
3
+ export function apcore(instanceOrOptions, maybeOptions) {
4
+ // Resolved lazily so this module never imports the class eagerly — that
5
+ // would make apcore.ts and middleware.ts a hard import cycle.
6
+ const isInstance = instanceOrOptions !== undefined &&
7
+ typeof instanceOrOptions.registerTool === 'function';
8
+ const instance = isInstance ? instanceOrOptions : undefined;
9
+ const options = (isInstance ? maybeOptions : instanceOrOptions);
10
+ let resolved = instance;
11
+ const contextFactory = options?.contextFactory ?? new HonoContextFactory();
12
+ const skipContext = options?.skipContext ?? false;
13
+ return async function apcoreMiddleware(c, next) {
14
+ if (!resolved) {
15
+ const { HonoApcore: Ctor } = await import('./apcore.js');
16
+ resolved = new Ctor(options ?? {});
17
+ await resolved.init();
18
+ }
19
+ await resolved.ready();
20
+ c.set(APCORE_VAR, resolved);
21
+ if (!skipContext) {
22
+ c.set(APCORE_CONTEXT_VAR, contextFactory.createContext(c));
23
+ }
24
+ await next();
25
+ };
26
+ }
27
+ /**
28
+ * Read the {@link HonoApcore} instance the `apcore()` middleware installed.
29
+ *
30
+ * @throws {Error} When the middleware has not run for this request.
31
+ */
32
+ export function getApcore(c) {
33
+ const instance = c.get(APCORE_VAR);
34
+ if (!instance) {
35
+ throw new Error('No apcore instance on the Hono context. Install the apcore() middleware before this route.');
36
+ }
37
+ return instance;
38
+ }
39
+ /**
40
+ * Read the per-request apcore `Context` the `apcore()` middleware built.
41
+ *
42
+ * @throws {Error} When the middleware has not run, or ran with `skipContext`.
43
+ */
44
+ export function getApcoreContext(c) {
45
+ const context = c.get(APCORE_CONTEXT_VAR);
46
+ if (!context) {
47
+ throw new Error('No apcore Context on the Hono context. Install the apcore() middleware without skipContext.');
48
+ }
49
+ return context;
50
+ }
51
+ //# sourceMappingURL=middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/core/middleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAsDxE,MAAM,UAAU,MAAM,CACpB,iBAA8E,EAC9E,YAAsC;IAEtC,wEAAwE;IACxE,8DAA8D;IAC9D,MAAM,UAAU,GACd,iBAAiB,KAAK,SAAS;QAC/B,OAAQ,iBAAgC,CAAC,YAAY,KAAK,UAAU,CAAC;IAEvE,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAE,iBAAgC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAEjD,CA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CAC9F,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,79 @@
1
+ import type { ModuleDescriptor, Registry } from 'apcore-js';
2
+ import type { ScannedModule } from 'apcore-toolkit';
3
+ import type { ApToolDefinition, RegisterMethodOptions, RegisterObjectOptions } from '../types.js';
4
+ import type { BoundExecuteFn } from '../utils/module-factory.js';
5
+ import type { ToolConversionOptions } from '../tools/define-tool.js';
6
+ /**
7
+ * Thin wrapper around the upstream apcore-js `Registry`.
8
+ *
9
+ * Delegates the core operations and adds the registration conveniences a
10
+ * Hono app wants: registering a {@link ApToolDefinition}, a single method of
11
+ * a service object, or every method at once.
12
+ */
13
+ export declare class ApcoreRegistry {
14
+ private readonly registry;
15
+ constructor(registry: Registry);
16
+ /** The underlying apcore-js `Registry`. */
17
+ get raw(): Registry;
18
+ register(moduleId: string, module: unknown): Promise<void>;
19
+ unregister(moduleId: string): boolean;
20
+ get(moduleId: string): unknown | null;
21
+ has(moduleId: string): boolean;
22
+ list(options?: {
23
+ tags?: string[];
24
+ prefix?: string;
25
+ }): string[];
26
+ getDefinition(moduleId: string): ModuleDescriptor | null;
27
+ on(event: string, callback: (moduleId: string, module: unknown) => void): void;
28
+ discover(): Promise<number>;
29
+ get count(): number;
30
+ /**
31
+ * Convert a registered module's descriptor into a toolkit `ScannedModule`.
32
+ *
33
+ * Returns `null` when the module is not registered.
34
+ */
35
+ toScannedModule(moduleId: string): ScannedModule | null;
36
+ /**
37
+ * Serialise one registered module to a snake_case dictionary via
38
+ * apcore-toolkit's `moduleToDict()`. Returns `null` when not found.
39
+ */
40
+ toDict(moduleId: string): Record<string, unknown> | null;
41
+ /** Serialise every registered module (optionally filtered) to dictionaries. */
42
+ toDicts(options?: {
43
+ tags?: string[];
44
+ prefix?: string;
45
+ }): Record<string, unknown>[];
46
+ /**
47
+ * Register a scanned module together with its bound execute function.
48
+ *
49
+ * The lowest-level entry point — the tool registrar, the route scanner, and
50
+ * the YAML binding loader all funnel through here.
51
+ */
52
+ registerScanned(module: ScannedModule, execute: BoundExecuteFn): Promise<string>;
53
+ /**
54
+ * Register a single {@link ApToolDefinition}.
55
+ *
56
+ * @returns The module ID it was registered under.
57
+ */
58
+ registerTool(tool: ApToolDefinition, options?: ToolConversionOptions): Promise<string>;
59
+ /** Register several tool definitions, preserving their order. */
60
+ registerTools(tools: ApToolDefinition[], options?: ToolConversionOptions): Promise<string[]>;
61
+ /**
62
+ * Register one method of a service object as a module.
63
+ *
64
+ * @returns The module ID it was registered under.
65
+ * @throws {Error} When `method` is not a function on `instance`.
66
+ */
67
+ registerMethod(options: RegisterMethodOptions): Promise<string>;
68
+ /**
69
+ * Register several — or every — method of a service object.
70
+ *
71
+ * With `methods: '*'`, public methods are discovered by walking the
72
+ * prototype chain and own enumerable properties, minus anything in
73
+ * `exclude`.
74
+ *
75
+ * @returns The module IDs that were registered.
76
+ */
77
+ registerObject(options: RegisterObjectOptions): Promise<string[]>;
78
+ }
79
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/core/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAQrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AA+BrE;;;;;;GAMG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,QAAQ;IAM/C,2CAA2C;IAC3C,IAAI,GAAG,IAAI,QAAQ,CAElB;IAMK,QAAQ,CAAC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C,MAAM,CAAC;IAKlB,iEAAiE;IAC3D,aAAa,CACjB,KAAK,EAAE,gBAAgB,EAAE,EACzB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,MAAM,EAAE,CAAC;IAQpB;;;;;OAKG;IACG,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IA4CrE;;;;;;;;OAQG;IACG,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAyCxE"}
@@ -0,0 +1,218 @@
1
+ import { createScannedModule, moduleToDict, modulesToDicts } from 'apcore-toolkit';
2
+ import { generateModuleId, normalizeName, normalizeMethodName } from '../utils/id-generator.js';
3
+ import { EMPTY_OBJECT_SCHEMA, normalizeResult, scannedModuleToFunctionModule, toModuleAnnotations, } from '../utils/module-factory.js';
4
+ import { toolToScannedModule } from '../tools/define-tool.js';
5
+ /**
6
+ * Collect every own method name along an object's prototype chain, stopping
7
+ * before `Object.prototype`. `constructor` is excluded.
8
+ *
9
+ * Own enumerable function-valued properties are included too, so object
10
+ * literals of arrow functions register as readily as class instances.
11
+ */
12
+ function getAllMethodNames(instance) {
13
+ const methods = new Set();
14
+ for (const [name, value] of Object.entries(instance)) {
15
+ if (typeof value === 'function')
16
+ methods.add(name);
17
+ }
18
+ let proto = Object.getPrototypeOf(instance);
19
+ while (proto && proto !== Object.prototype) {
20
+ for (const name of Object.getOwnPropertyNames(proto)) {
21
+ if (name === 'constructor')
22
+ continue;
23
+ const descriptor = Object.getOwnPropertyDescriptor(proto, name);
24
+ if (descriptor && typeof descriptor.value === 'function') {
25
+ methods.add(name);
26
+ }
27
+ }
28
+ proto = Object.getPrototypeOf(proto);
29
+ }
30
+ return [...methods];
31
+ }
32
+ /**
33
+ * Thin wrapper around the upstream apcore-js `Registry`.
34
+ *
35
+ * Delegates the core operations and adds the registration conveniences a
36
+ * Hono app wants: registering a {@link ApToolDefinition}, a single method of
37
+ * a service object, or every method at once.
38
+ */
39
+ export class ApcoreRegistry {
40
+ registry;
41
+ constructor(registry) {
42
+ this.registry = registry;
43
+ }
44
+ // -------------------------------------------------------------------------
45
+ // Raw access
46
+ // -------------------------------------------------------------------------
47
+ /** The underlying apcore-js `Registry`. */
48
+ get raw() {
49
+ return this.registry;
50
+ }
51
+ // -------------------------------------------------------------------------
52
+ // Delegated operations
53
+ // -------------------------------------------------------------------------
54
+ async register(moduleId, module) {
55
+ await this.registry.register(moduleId, module);
56
+ }
57
+ unregister(moduleId) {
58
+ return this.registry.unregister(moduleId);
59
+ }
60
+ get(moduleId) {
61
+ return this.registry.get(moduleId);
62
+ }
63
+ has(moduleId) {
64
+ return this.registry.has(moduleId);
65
+ }
66
+ list(options) {
67
+ return this.registry.list(options);
68
+ }
69
+ getDefinition(moduleId) {
70
+ return this.registry.getDefinition(moduleId);
71
+ }
72
+ on(event, callback) {
73
+ this.registry.on(event, callback);
74
+ }
75
+ discover() {
76
+ return this.registry.discover();
77
+ }
78
+ get count() {
79
+ return this.registry.count;
80
+ }
81
+ // -------------------------------------------------------------------------
82
+ // Serialisation helpers (via apcore-toolkit)
83
+ // -------------------------------------------------------------------------
84
+ /**
85
+ * Convert a registered module's descriptor into a toolkit `ScannedModule`.
86
+ *
87
+ * Returns `null` when the module is not registered.
88
+ */
89
+ toScannedModule(moduleId) {
90
+ const def = this.registry.getDefinition(moduleId);
91
+ if (!def)
92
+ return null;
93
+ return createScannedModule({
94
+ moduleId: def.moduleId,
95
+ description: def.description,
96
+ inputSchema: def.inputSchema,
97
+ outputSchema: def.outputSchema,
98
+ tags: def.tags ?? [],
99
+ target: moduleId,
100
+ annotations: def.annotations ?? null,
101
+ documentation: def.documentation ?? null,
102
+ examples: (def.examples ?? []),
103
+ metadata: def.metadata ?? {},
104
+ });
105
+ }
106
+ /**
107
+ * Serialise one registered module to a snake_case dictionary via
108
+ * apcore-toolkit's `moduleToDict()`. Returns `null` when not found.
109
+ */
110
+ toDict(moduleId) {
111
+ const scanned = this.toScannedModule(moduleId);
112
+ return scanned ? moduleToDict(scanned) : null;
113
+ }
114
+ /** Serialise every registered module (optionally filtered) to dictionaries. */
115
+ toDicts(options) {
116
+ const scanned = [];
117
+ for (const id of this.registry.list(options)) {
118
+ const module = this.toScannedModule(id);
119
+ if (module)
120
+ scanned.push(module);
121
+ }
122
+ return modulesToDicts(scanned);
123
+ }
124
+ // -------------------------------------------------------------------------
125
+ // Registration conveniences
126
+ // -------------------------------------------------------------------------
127
+ /**
128
+ * Register a scanned module together with its bound execute function.
129
+ *
130
+ * The lowest-level entry point — the tool registrar, the route scanner, and
131
+ * the YAML binding loader all funnel through here.
132
+ */
133
+ async registerScanned(module, execute) {
134
+ await this.registry.register(module.moduleId, scannedModuleToFunctionModule(module, execute));
135
+ return module.moduleId;
136
+ }
137
+ /**
138
+ * Register a single {@link ApToolDefinition}.
139
+ *
140
+ * @returns The module ID it was registered under.
141
+ */
142
+ async registerTool(tool, options) {
143
+ const { module, execute } = toolToScannedModule(tool, options);
144
+ return this.registerScanned(module, execute);
145
+ }
146
+ /** Register several tool definitions, preserving their order. */
147
+ async registerTools(tools, options) {
148
+ const ids = [];
149
+ for (const tool of tools) {
150
+ ids.push(await this.registerTool(tool, options));
151
+ }
152
+ return ids;
153
+ }
154
+ /**
155
+ * Register one method of a service object as a module.
156
+ *
157
+ * @returns The module ID it was registered under.
158
+ * @throws {Error} When `method` is not a function on `instance`.
159
+ */
160
+ async registerMethod(options) {
161
+ const { instance, method, description, id, inputSchema, outputSchema, annotations, tags, documentation, examples, } = options;
162
+ const fn = instance[method];
163
+ if (typeof fn !== 'function') {
164
+ throw new Error(`Method "${method}" does not exist on ${instance.constructor?.name ?? 'object'}`);
165
+ }
166
+ const objectName = instance.constructor?.name ?? 'object';
167
+ const moduleId = generateModuleId(objectName, method, true, id);
168
+ const scanned = createScannedModule({
169
+ moduleId,
170
+ description,
171
+ inputSchema: inputSchema ?? { ...EMPTY_OBJECT_SCHEMA },
172
+ outputSchema: outputSchema ?? { ...EMPTY_OBJECT_SCHEMA },
173
+ tags: tags ?? [],
174
+ target: `${objectName}.${method}`,
175
+ annotations: toModuleAnnotations(annotations),
176
+ documentation: documentation ?? null,
177
+ examples: examples ?? [],
178
+ });
179
+ const execute = async (inputs, context) => {
180
+ const raw = await fn.call(instance, inputs, context);
181
+ return normalizeResult(raw);
182
+ };
183
+ return this.registerScanned(scanned, execute);
184
+ }
185
+ /**
186
+ * Register several — or every — method of a service object.
187
+ *
188
+ * With `methods: '*'`, public methods are discovered by walking the
189
+ * prototype chain and own enumerable properties, minus anything in
190
+ * `exclude`.
191
+ *
192
+ * @returns The module IDs that were registered.
193
+ */
194
+ async registerObject(options) {
195
+ const { instance, description, methods, exclude = [], namespace, annotations, tags, methodOptions = {}, } = options;
196
+ const methodNames = (methods === '*' ? getAllMethodNames(instance) : methods).filter((name) => !exclude.includes(name));
197
+ const ns = namespace ?? normalizeName(instance.constructor?.name ?? 'object');
198
+ const registeredIds = [];
199
+ for (const methodName of methodNames) {
200
+ const perMethod = methodOptions[methodName] ?? {};
201
+ const moduleId = perMethod.id ?? `${ns}.${normalizeMethodName(methodName)}`;
202
+ registeredIds.push(await this.registerMethod({
203
+ instance,
204
+ method: methodName,
205
+ description: perMethod.description ?? description ?? methodName,
206
+ id: moduleId,
207
+ inputSchema: perMethod.inputSchema,
208
+ outputSchema: perMethod.outputSchema,
209
+ annotations: perMethod.annotations ?? annotations,
210
+ tags: perMethod.tags ?? tags,
211
+ documentation: perMethod.documentation,
212
+ examples: perMethod.examples,
213
+ }));
214
+ }
215
+ return registeredIds;
216
+ }
217
+ }
218
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/core/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAOnF,OAAO,EAAE,gBAAgB,EAAE,aAAa,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AC,CAAC,CAAC;QAE5C,MAAM,EAAE,GAAG,SAAS,IAAI,aAAa,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,QAAQ,CAAC,CAAC;QAC9E,MAAM,aAAa,GAAa,EAAE,CAAC;QAEnC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,MAAM,SAAS,GAAG,aAAa,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YAClD,MAAM,QAAQ,GAAG,SAAS,CAAC,EAAE,IAAI,GAAG,EAAE,IAAI,mBAAmB,CAAC,UAAU,CAAC,EAAE,CAAC;YAE5E,aAAa,CAAC,IAAI,CAChB,MAAM,IAAI,CAAC,cAAc,CAAC;gBACxB,QAAQ;gBACR,MAAM,EAAE,UAAU;gBAClB,WAAW,EAAE,SAAS,CAAC,WAAW,IAAI,WAAW,IAAI,UAAU;gBAC/D,EAAE,EAAE,QAAQ;gBACZ,WAAW,EAAE,SAAS,CAAC,WAAW;gBAClC,YAAY,EAAE,SAAS,CAAC,YAAY;gBACpC,WAAW,EAAE,SAAS,CAAC,WAAW,IAAI,WAAW;gBACjD,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,IAAI;gBAC5B,aAAa,EAAE,SAAS,CAAC,aAAa;gBACtC,QAAQ,EAAE,SAAS,CAAC,QAAQ;aAC7B,CAAC,CACH,CAAC;QACJ,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,33 @@
1
+ export { HonoApcore, createApcore } from './core/apcore.js';
2
+ export { ApcoreRegistry } from './core/registry.js';
3
+ export { ApcoreExecutor } from './core/executor.js';
4
+ export { apcore, getApcore, getApcoreContext } from './core/middleware.js';
5
+ export type { ApcoreMiddlewareOptions } from './core/middleware.js';
6
+ export { defineTool, defineToolset, resolveToolId, toolToScannedModule } from './tools/index.js';
7
+ export type { ToolConversionOptions } from './tools/index.js';
8
+ export { HonoRouteScanner, buildRequestUrl } from './scanners/index.js';
9
+ export type { HonoAppLike } from './scanners/index.js';
10
+ export { HonoContextFactory, defaultContextFactory, toHeaders } from './context/index.js';
11
+ export type { HeaderSource } from './context/index.js';
12
+ export { SchemaExtractor, SchemaExtractionError, defaultSchemaExtractor, TypeBoxAdapter, ZodAdapter, JsonSchemaAdapter, } from './schema/index.js';
13
+ export type { SchemaAdapter } from './schema/index.js';
14
+ export { ApcoreMcpService, mountMcp, toHonoHandler, RESPONSE_ALREADY_SENT } from './mcp/index.js';
15
+ export type { McpApp, MountableApp } from './mcp/index.js';
16
+ export { ApcoreCliService } from './cli/index.js';
17
+ export { ApcoreA2aService } from './a2a/index.js';
18
+ export { ApBindingLoader, resolverFromObjects } from './bridge/index.js';
19
+ export type { TargetResolver } from './bridge/index.js';
20
+ export { modulesToBindings, renderBindingsYaml, writeBindingsFile } from './output/index.js';
21
+ export type { BindingRecord } from './output/index.js';
22
+ export { loadSettings, toMcpTransport, APCORE_SETTING_DEFAULTS } from './config.js';
23
+ export type { ApcoreSettings, EnvSource } from './config.js';
24
+ export { toSnakeCase, normalizeName, normalizeMethodName, generateModuleId, applyModulePrefix, } from './utils/id-generator.js';
25
+ export { scannedModuleToFunctionModule, toModuleAnnotations, normalizeResult, EMPTY_OBJECT_SCHEMA, } from './utils/module-factory.js';
26
+ export type { BoundExecuteFn } from './utils/module-factory.js';
27
+ export { APCORE_VAR, APCORE_CONTEXT_VAR, APCORE_ENV_PREFIX, DEFAULT_MCP_ENDPOINT, DEFAULT_EXPLORER_PREFIX, HONO_ALREADY_SENT_HEADER, } from './constants.js';
28
+ export { Registry, Executor, Context as ApcoreRequestContext, createIdentity, ACL, Config, FunctionModule, TraceContext, registerSysModules, ACLDeniedError, ModuleError, ModuleNotFoundError, ModuleExecuteError, SchemaValidationError, ErrorCodes, DEFAULT_ANNOTATIONS, VERSION as APCORE_VERSION, } from 'apcore-js';
29
+ export { BaseScanner, createScannedModule, cloneModule, filterModules, deduplicateIds, moduleToDict, modulesToDicts, annotationsToDict, formatModule, formatModules, toMarkdown, enrichSchemaDescriptions, resolveHttpVerb, generateSuggestedAlias, hasPathParams, extractPathParamNames, substitutePathParams, SCANNER_VERB_MAP, } from 'apcore-toolkit';
30
+ export type { ScannedModule } from 'apcore-toolkit';
31
+ export type { Identity } from 'apcore-js';
32
+ export type { ModuleAnnotations, ModuleExample, Module, Context, ModuleDescriptor, PreflightResult, PreflightCheckResult, ValidationResult, ApToolAnnotations, ApToolExample, ApToolHandler, ApToolDefinition, ApToolsetOptions, HonoApcoreOptions, ApcoreMcpOptions, ApcoreCliOptions, ApcoreA2aOptions, MountMcpOptions, RouteScanOptions, RouteOverride, RegisterMethodOptions, RegisterObjectOptions, } from './types.js';
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAKpE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACjG,YAAY,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAK9D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACxE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKvD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC1F,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD,OAA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AAoB,EAC/B,cAAc,EACd,GAAG,EACH,MAAM,EACN,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,EACV,mBAAmB,EACnB,OAAO,IAAI,cAAc,GAC1B,MAAM,WAAW,CAAC;AAKnB,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,UAAU,EACV,wBAAwB,EACxB,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAOpD,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,YAAY,EAEV,iBAAiB,EACjB,aAAa,EACb,MAAM,EACN,OAAO,EACP,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAEhB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAEhB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EAEf,gBAAgB,EAChB,aAAa,EAEb,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,71 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Core
3
+ // ---------------------------------------------------------------------------
4
+ export { HonoApcore, createApcore } from './core/apcore.js';
5
+ export { ApcoreRegistry } from './core/registry.js';
6
+ export { ApcoreExecutor } from './core/executor.js';
7
+ export { apcore, getApcore, getApcoreContext } from './core/middleware.js';
8
+ // ---------------------------------------------------------------------------
9
+ // Tools
10
+ // ---------------------------------------------------------------------------
11
+ export { defineTool, defineToolset, resolveToolId, toolToScannedModule } from './tools/index.js';
12
+ // ---------------------------------------------------------------------------
13
+ // Route scanning
14
+ // ---------------------------------------------------------------------------
15
+ export { HonoRouteScanner, buildRequestUrl } from './scanners/index.js';
16
+ // ---------------------------------------------------------------------------
17
+ // Context
18
+ // ---------------------------------------------------------------------------
19
+ export { HonoContextFactory, defaultContextFactory, toHeaders } from './context/index.js';
20
+ // ---------------------------------------------------------------------------
21
+ // Schema
22
+ // ---------------------------------------------------------------------------
23
+ export { SchemaExtractor, SchemaExtractionError, defaultSchemaExtractor, TypeBoxAdapter, ZodAdapter, JsonSchemaAdapter, } from './schema/index.js';
24
+ // ---------------------------------------------------------------------------
25
+ // MCP
26
+ // ---------------------------------------------------------------------------
27
+ export { ApcoreMcpService, mountMcp, toHonoHandler, RESPONSE_ALREADY_SENT } from './mcp/index.js';
28
+ // ---------------------------------------------------------------------------
29
+ // CLI
30
+ // ---------------------------------------------------------------------------
31
+ export { ApcoreCliService } from './cli/index.js';
32
+ // ---------------------------------------------------------------------------
33
+ // A2A
34
+ // ---------------------------------------------------------------------------
35
+ export { ApcoreA2aService } from './a2a/index.js';
36
+ // ---------------------------------------------------------------------------
37
+ // YAML bindings
38
+ // ---------------------------------------------------------------------------
39
+ export { ApBindingLoader, resolverFromObjects } from './bridge/index.js';
40
+ // ---------------------------------------------------------------------------
41
+ // Output writers
42
+ // ---------------------------------------------------------------------------
43
+ export { modulesToBindings, renderBindingsYaml, writeBindingsFile } from './output/index.js';
44
+ // ---------------------------------------------------------------------------
45
+ // Configuration
46
+ // ---------------------------------------------------------------------------
47
+ export { loadSettings, toMcpTransport, APCORE_SETTING_DEFAULTS } from './config.js';
48
+ // ---------------------------------------------------------------------------
49
+ // Utilities
50
+ // ---------------------------------------------------------------------------
51
+ export { toSnakeCase, normalizeName, normalizeMethodName, generateModuleId, applyModulePrefix, } from './utils/id-generator.js';
52
+ export { scannedModuleToFunctionModule, toModuleAnnotations, normalizeResult, EMPTY_OBJECT_SCHEMA, } from './utils/module-factory.js';
53
+ // ---------------------------------------------------------------------------
54
+ // Constants
55
+ // ---------------------------------------------------------------------------
56
+ export { APCORE_VAR, APCORE_CONTEXT_VAR, APCORE_ENV_PREFIX, DEFAULT_MCP_ENDPOINT, DEFAULT_EXPLORER_PREFIX, HONO_ALREADY_SENT_HEADER, } from './constants.js';
57
+ // ---------------------------------------------------------------------------
58
+ // apcore-js re-exports
59
+ //
60
+ // The core SDK is a hard dependency, so these are always importable straight
61
+ // from `hono-apcore`. The MCP, CLI, and A2A packages are *optional* peers and
62
+ // are deliberately not re-exported — importing them eagerly would pull
63
+ // `node:http` into edge builds. Import those symbols from `apcore-mcp`,
64
+ // `apcore-cli`, and `apcore-a2a` directly.
65
+ // ---------------------------------------------------------------------------
66
+ export { Registry, Executor, Context as ApcoreRequestContext, createIdentity, ACL, Config, FunctionModule, TraceContext, registerSysModules, ACLDeniedError, ModuleError, ModuleNotFoundError, ModuleExecuteError, SchemaValidationError, ErrorCodes, DEFAULT_ANNOTATIONS, VERSION as APCORE_VERSION, } from 'apcore-js';
67
+ // ---------------------------------------------------------------------------
68
+ // apcore-toolkit re-exports (scanning and serialisation helpers)
69
+ // ---------------------------------------------------------------------------
70
+ export { BaseScanner, createScannedModule, cloneModule, filterModules, deduplicateIds, moduleToDict, modulesToDicts, annotationsToDict, formatModule, formatModules, toMarkdown, enrichSchemaDescriptions, resolveHttpVerb, generateSuggestedAlias, hasPathParams, extractPathParamNames, substitutePathParams, SCANNER_VERB_MAP, } from 'apcore-toolkit';
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO;AACP,8EAA8E;AAC9E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,o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core/executor.js';
2
+ import type { ApcoreRegistry } from '../core/registry.js';
3
+ import type { ApcoreMcpOptions } from '../types.js';
4
+ /**
5
+ * The embeddable MCP app returned by `apcore-mcp`'s `asyncServe()`.
6
+ *
7
+ * `handler` is a Node.js `(req, res)` function — see
8
+ * {@link mountMcp} for wiring it into a Hono app on the Node runtime.
9
+ */
10
+ export interface McpApp {
11
+ handler: (req: unknown, res: unknown) => Promise<void>;
12
+ close: () => Promise<void>;
13
+ }
14
+ /**
15
+ * Manages the MCP (Model Context Protocol) server for a Hono app.
16
+ *
17
+ * `apcore-mcp` is an **optional** peer dependency and is loaded lazily, so
18
+ * importing `hono-apcore` stays safe on runtimes without `node:http`
19
+ * (Workers, Deno, Bun) as long as the MCP surface goes unused there.
20
+ *
21
+ * Two deployment shapes are supported:
22
+ *
23
+ * - **Standalone** — {@link start} runs an MCP server on its own port, next
24
+ * to the Hono HTTP server. Configure `transport` to enable it.
25
+ * - **Embedded** — {@link asyncServe} returns a request handler that
26
+ * {@link mountMcp} wires into the Hono app itself, so one port serves both.
27
+ */
28
+ export declare class ApcoreMcpService {
29
+ private readonly registry;
30
+ private readonly executor;
31
+ private readonly options;
32
+ private _isRunning;
33
+ private _app;
34
+ constructor(registry: ApcoreRegistry, executor: ApcoreExecutor, options: ApcoreMcpOptions);
35
+ /** Whether a standalone MCP server has been started. */
36
+ get isRunning(): boolean;
37
+ /** The embedded MCP app, once {@link asyncServe} has built one. */
38
+ get app(): McpApp | null;
39
+ /** Number of tools exposed, honouring the module-level `tags` / `prefix`. */
40
+ get toolCount(): number;
41
+ /**
42
+ * Start a standalone MCP server using the configured transport.
43
+ *
44
+ * With `transport: 'stdio'` this occupies the process's stdio, so it is the
45
+ * right choice for a CLI-launched MCP server and the wrong one for a web
46
+ * process — use {@link asyncServe} there.
47
+ *
48
+ * @param overrides - Per-call option overrides, e.g. the flags the
49
+ * `hono-apcore serve` command accepts.
50
+ */
51
+ start(overrides?: Partial<ApcoreMcpOptions>): Promise<void>;
52
+ /**
53
+ * Build an embeddable MCP request handler without starting a server.
54
+ *
55
+ * Repeated calls return the same app; call {@link stop} to tear it down.
56
+ *
57
+ * @param options - Per-call overrides for endpoint and Explorer settings.
58
+ */
59
+ asyncServe(options?: {
60
+ endpoint?: string;
61
+ explorer?: boolean;
62
+ explorerPrefix?: string;
63
+ allowExecute?: boolean;
64
+ dynamic?: boolean;
65
+ }): Promise<McpApp>;
66
+ /** Tear down the embedded MCP app and mark the service stopped. */
67
+ stop(): Promise<void>;
68
+ /** Stop, then start the standalone MCP server. */
69
+ restart(): Promise<void>;
70
+ /**
71
+ * Convert the registered modules to OpenAI-compatible tool definitions,
72
+ * ready to hand to a chat-completions `tools` parameter.
73
+ */
74
+ toOpenaiTools(options?: {
75
+ embedAnnotations?: boolean;
76
+ strict?: boolean;
77
+ tags?: string[];
78
+ prefix?: string;
79
+ }): Promise<unknown[]>;
80
+ /** Collect the defined values for `keys`, applying any option renames. */
81
+ private collectOptions;
82
+ }
83
+ //# sourceMappingURL=apcore-mcp.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apcore-mcp.service.d.ts","sourceRoot":"","sources":["../../src/mcp/apcore-mcp.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AA+CD;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,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