nestjs-apcore 0.3.2 → 0.5.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/README.md +98 -7
- package/dist/a2a/apcore-a2a.module.d.ts +19 -0
- package/dist/a2a/apcore-a2a.module.d.ts.map +1 -0
- package/dist/a2a/apcore-a2a.module.js +68 -0
- package/dist/a2a/apcore-a2a.module.js.map +1 -0
- package/dist/a2a/apcore-a2a.service.d.ts +58 -0
- package/dist/a2a/apcore-a2a.service.d.ts.map +1 -0
- package/dist/a2a/apcore-a2a.service.js +145 -0
- package/dist/a2a/apcore-a2a.service.js.map +1 -0
- package/dist/bridge/binding-loader.d.ts +1 -1
- package/dist/bridge/binding-loader.d.ts.map +1 -1
- package/dist/bridge/binding-loader.js +11 -4
- package/dist/bridge/binding-loader.js.map +1 -1
- package/dist/cli/apcore-cli.module.d.ts +18 -0
- package/dist/cli/apcore-cli.module.d.ts.map +1 -0
- package/dist/cli/apcore-cli.module.js +62 -0
- package/dist/cli/apcore-cli.module.js.map +1 -0
- package/dist/cli/apcore-cli.service.d.ts +55 -0
- package/dist/cli/apcore-cli.service.d.ts.map +1 -0
- package/dist/cli/apcore-cli.service.js +106 -0
- package/dist/cli/apcore-cli.service.js.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -1
- package/dist/context/nest-context.factory.d.ts +36 -0
- package/dist/context/nest-context.factory.d.ts.map +1 -0
- package/dist/context/nest-context.factory.js +82 -0
- package/dist/context/nest-context.factory.js.map +1 -0
- package/dist/core/apcore-executor.service.d.ts +1 -1
- package/dist/core/apcore-executor.service.d.ts.map +1 -1
- package/dist/core/apcore-registry.service.d.ts +3 -3
- package/dist/core/apcore-registry.service.d.ts.map +1 -1
- package/dist/core/apcore-registry.service.js +14 -7
- package/dist/core/apcore-registry.service.js.map +1 -1
- package/dist/core/apcore.module.d.ts.map +1 -1
- package/dist/core/apcore.module.js +14 -0
- package/dist/core/apcore.module.js.map +1 -1
- package/dist/decorators/ap-tool-scanner.service.d.ts +1 -1
- package/dist/decorators/ap-tool-scanner.service.d.ts.map +1 -1
- package/dist/decorators/ap-tool-scanner.service.js +13 -6
- package/dist/decorators/ap-tool-scanner.service.js.map +1 -1
- package/dist/index.d.ts +18 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/apcore-mcp.service.d.ts.map +1 -1
- package/dist/mcp/apcore-mcp.service.js.map +1 -1
- package/dist/types.d.ts +100 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +20 -10
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createCli, configureManHelp } from 'apcore-cli';
|
|
2
|
+
import { ApcoreRegistryService } from '../core/apcore-registry.service.js';
|
|
3
|
+
import type { ApcoreCliModuleOptions } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* NestJS-injectable service that exposes apcore-cli utilities.
|
|
6
|
+
*
|
|
7
|
+
* Wraps `createCli`, `buildProgramManPage`, and `configureManHelp` from
|
|
8
|
+
* `apcore-cli`, applying module-level defaults (docsUrl, verboseHelp) on
|
|
9
|
+
* construction so that injected consumers get a pre-configured CLI builder.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const program = cliService.createProgram();
|
|
14
|
+
* cliService.configureManHelp(program, 'my-tool', '1.0.0', 'My Tool');
|
|
15
|
+
* program.parse();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class ApcoreCliService {
|
|
19
|
+
private readonly registry;
|
|
20
|
+
private readonly options;
|
|
21
|
+
constructor(registry: ApcoreRegistryService, options: ApcoreCliModuleOptions);
|
|
22
|
+
/**
|
|
23
|
+
* Build and return a Commander program.
|
|
24
|
+
*
|
|
25
|
+
* Built-in apcore options (`--input`, `--yes`, `--large-input`, `--format`)
|
|
26
|
+
* are hidden by default; pass `--help --verbose` at runtime (or set
|
|
27
|
+
* `verboseHelp: true` in module options) to show them.
|
|
28
|
+
*
|
|
29
|
+
* @param extensionsDir Override the extensions directory (default: value from options).
|
|
30
|
+
*/
|
|
31
|
+
createProgram(extensionsDir?: string): ReturnType<typeof createCli>;
|
|
32
|
+
/**
|
|
33
|
+
* Add `--help --man` support to an existing Commander program.
|
|
34
|
+
*
|
|
35
|
+
* When the user runs `<prog> --help --man`, the full man page is written to
|
|
36
|
+
* stdout. Enabled by `apcore-cli` 0.4.0's `configureManHelp()`.
|
|
37
|
+
*/
|
|
38
|
+
configureManHelp(program: Parameters<typeof configureManHelp>[0], progName: string, version: string, description?: string, docsUrl?: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Update the docs URL used by man pages and per-command help output.
|
|
41
|
+
*
|
|
42
|
+
* Delegates to `apcore-cli`'s module-level `setDocsUrl()`.
|
|
43
|
+
*/
|
|
44
|
+
setDocsUrl(url: string | null): void;
|
|
45
|
+
/**
|
|
46
|
+
* Toggle verbose help mode.
|
|
47
|
+
*
|
|
48
|
+
* When `true`, `--help` shows all options including built-in apcore options.
|
|
49
|
+
* Delegates to `apcore-cli`'s module-level `setVerboseHelp()`.
|
|
50
|
+
*/
|
|
51
|
+
setVerboseHelp(verbose: boolean): void;
|
|
52
|
+
/** Number of modules currently in the registry. */
|
|
53
|
+
get moduleCount(): number;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=apcore-cli.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apcore-cli.service.d.ts","sourceRoot":"","sources":["../../src/cli/apcore-cli.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EAGT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,qBACa,gBAAgB;IAGzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAEzB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAFP,QAAQ,EAAE,qBAAqB,EAE/B,OAAO,EAAE,sBAAsB;IAclD;;;;;;;;OAQG;IACH,aAAa,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC;IAYnE;;;;;OAKG;IACH,gBAAgB,CACd,OAAO,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAC/C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,GACf,IAAI;IAcP;;;;OAIG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAIpC;;;;;OAKG;IACH,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAQtC,mDAAmD;IACnD,IAAI,WAAW,IAAI,MAAM,CAExB;CACF"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Injectable, Inject } from '@nestjs/common';
|
|
14
|
+
import { createCli, setDocsUrl, setVerboseHelp, configureManHelp, } from 'apcore-cli';
|
|
15
|
+
import { ApcoreRegistryService } from '../core/apcore-registry.service.js';
|
|
16
|
+
import { APCORE_CLI_MODULE_OPTIONS } from '../constants.js';
|
|
17
|
+
/**
|
|
18
|
+
* NestJS-injectable service that exposes apcore-cli utilities.
|
|
19
|
+
*
|
|
20
|
+
* Wraps `createCli`, `buildProgramManPage`, and `configureManHelp` from
|
|
21
|
+
* `apcore-cli`, applying module-level defaults (docsUrl, verboseHelp) on
|
|
22
|
+
* construction so that injected consumers get a pre-configured CLI builder.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const program = cliService.createProgram();
|
|
27
|
+
* cliService.configureManHelp(program, 'my-tool', '1.0.0', 'My Tool');
|
|
28
|
+
* program.parse();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
let ApcoreCliService = class ApcoreCliService {
|
|
32
|
+
registry;
|
|
33
|
+
options;
|
|
34
|
+
constructor(registry, options) {
|
|
35
|
+
this.registry = registry;
|
|
36
|
+
this.options = options;
|
|
37
|
+
if (options.docsUrl !== undefined) {
|
|
38
|
+
setDocsUrl(options.docsUrl);
|
|
39
|
+
}
|
|
40
|
+
if (options.verboseHelp !== undefined) {
|
|
41
|
+
setVerboseHelp(options.verboseHelp);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// -------------------------------------------------------------------------
|
|
45
|
+
// Program builder
|
|
46
|
+
// -------------------------------------------------------------------------
|
|
47
|
+
/**
|
|
48
|
+
* Build and return a Commander program.
|
|
49
|
+
*
|
|
50
|
+
* Built-in apcore options (`--input`, `--yes`, `--large-input`, `--format`)
|
|
51
|
+
* are hidden by default; pass `--help --verbose` at runtime (or set
|
|
52
|
+
* `verboseHelp: true` in module options) to show them.
|
|
53
|
+
*
|
|
54
|
+
* @param extensionsDir Override the extensions directory (default: value from options).
|
|
55
|
+
*/
|
|
56
|
+
createProgram(extensionsDir) {
|
|
57
|
+
return createCli(extensionsDir ?? this.options.extensionsDir, this.options.progName, this.options.verboseHelp ?? false);
|
|
58
|
+
}
|
|
59
|
+
// -------------------------------------------------------------------------
|
|
60
|
+
// Man page / help
|
|
61
|
+
// -------------------------------------------------------------------------
|
|
62
|
+
/**
|
|
63
|
+
* Add `--help --man` support to an existing Commander program.
|
|
64
|
+
*
|
|
65
|
+
* When the user runs `<prog> --help --man`, the full man page is written to
|
|
66
|
+
* stdout. Enabled by `apcore-cli` 0.4.0's `configureManHelp()`.
|
|
67
|
+
*/
|
|
68
|
+
configureManHelp(program, progName, version, description, docsUrl) {
|
|
69
|
+
configureManHelp(program, progName, version, description, docsUrl ?? this.options.docsUrl ?? undefined);
|
|
70
|
+
}
|
|
71
|
+
// -------------------------------------------------------------------------
|
|
72
|
+
// Runtime configuration
|
|
73
|
+
// -------------------------------------------------------------------------
|
|
74
|
+
/**
|
|
75
|
+
* Update the docs URL used by man pages and per-command help output.
|
|
76
|
+
*
|
|
77
|
+
* Delegates to `apcore-cli`'s module-level `setDocsUrl()`.
|
|
78
|
+
*/
|
|
79
|
+
setDocsUrl(url) {
|
|
80
|
+
setDocsUrl(url);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Toggle verbose help mode.
|
|
84
|
+
*
|
|
85
|
+
* When `true`, `--help` shows all options including built-in apcore options.
|
|
86
|
+
* Delegates to `apcore-cli`'s module-level `setVerboseHelp()`.
|
|
87
|
+
*/
|
|
88
|
+
setVerboseHelp(verbose) {
|
|
89
|
+
setVerboseHelp(verbose);
|
|
90
|
+
}
|
|
91
|
+
// -------------------------------------------------------------------------
|
|
92
|
+
// Registry accessors
|
|
93
|
+
// -------------------------------------------------------------------------
|
|
94
|
+
/** Number of modules currently in the registry. */
|
|
95
|
+
get moduleCount() {
|
|
96
|
+
return this.registry.count;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
ApcoreCliService = __decorate([
|
|
100
|
+
Injectable(),
|
|
101
|
+
__param(0, Inject(ApcoreRegistryService)),
|
|
102
|
+
__param(1, Inject(APCORE_CLI_MODULE_OPTIONS)),
|
|
103
|
+
__metadata("design:paramtypes", [ApcoreRegistryService, Object])
|
|
104
|
+
], ApcoreCliService);
|
|
105
|
+
export { ApcoreCliService };
|
|
106
|
+
//# sourceMappingURL=apcore-cli.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apcore-cli.service.js","sourceRoot":"","sources":["../../src/cli/apcore-cli.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAG5D;;;;;;;;;;;;;GAaG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAGR;IAEA;IAJnB,YAEmB,QAA+B,EAE/B,OAA+B;QAF/B,aAAQ,GAAR,QAAQ,CAAuB;QAE/B,YAAO,GAAP,OAAO,CAAwB;QAEhD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAClC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QACD,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACtC,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,kBAAkB;IAClB,4EAA4E;IAE5E;;;;;;;;OAQG;IACH,aAAa,CAAC,aAAsB;QAClC,OAAO,SAAS,CACd,aAAa,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,EAC3C,IAAI,CAAC,OAAO,CAAC,QAAQ,EACrB,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,KAAK,CAClC,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,kBAAkB;IAClB,4EAA4E;IAE5E;;;;;OAKG;IACH,gBAAgB,CACd,OAA+C,EAC/C,QAAgB,EAChB,OAAe,EACf,WAAoB,EACpB,OAAgB;QAEhB,gBAAgB,CACd,OAAO,EACP,QAAQ,EACR,OAAO,EACP,WAAW,EACX,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,SAAS,CAC7C,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,wBAAwB;IACxB,4EAA4E;IAE5E;;;;OAIG;IACH,UAAU,CAAC,GAAkB;QAC3B,UAAU,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,cAAc,CAAC,OAAgB;QAC7B,cAAc,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,4EAA4E;IAC5E,qBAAqB;IACrB,4EAA4E;IAE5E,mDAAmD;IACnD,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC7B,CAAC;CACF,CAAA;AA7FY,gBAAgB;IAD5B,UAAU,EAAE;IAGR,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAE7B,WAAA,MAAM,CAAC,yBAAyB,CAAC,CAAA;qCADP,qBAAqB;GAHvC,gBAAgB,CA6F5B"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const APCORE_MODULE_OPTIONS: "APCORE_MODULE_OPTIONS";
|
|
2
2
|
export declare const APCORE_MCP_MODULE_OPTIONS: "APCORE_MCP_MODULE_OPTIONS";
|
|
3
|
+
export declare const APCORE_CLI_MODULE_OPTIONS: "APCORE_CLI_MODULE_OPTIONS";
|
|
4
|
+
export declare const APCORE_A2A_MODULE_OPTIONS: "APCORE_A2A_MODULE_OPTIONS";
|
|
3
5
|
export declare const AP_TOOL_METADATA_KEY: "apcore:tool";
|
|
4
6
|
export declare const AP_MODULE_METADATA_KEY: "apcore:module";
|
|
5
7
|
export declare const AP_CONTEXT_METADATA_KEY: "apcore:context";
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,EAAG,uBAAgC,CAAC;AACtE,eAAO,MAAM,yBAAyB,EAAG,2BAAoC,CAAC;AAG9E,eAAO,MAAM,oBAAoB,EAAG,aAAsB,CAAC;AAC3D,eAAO,MAAM,sBAAsB,EAAG,eAAwB,CAAC;AAC/D,eAAO,MAAM,uBAAuB,EAAG,gBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,qBAAqB,EAAG,uBAAgC,CAAC;AACtE,eAAO,MAAM,yBAAyB,EAAG,2BAAoC,CAAC;AAC9E,eAAO,MAAM,yBAAyB,EAAG,2BAAoC,CAAC;AAC9E,eAAO,MAAM,yBAAyB,EAAG,2BAAoC,CAAC;AAG9E,eAAO,MAAM,oBAAoB,EAAG,aAAsB,CAAC;AAC3D,eAAO,MAAM,sBAAsB,EAAG,eAAwB,CAAC;AAC/D,eAAO,MAAM,uBAAuB,EAAG,gBAAyB,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// NestJS dependency-injection tokens
|
|
2
2
|
export const APCORE_MODULE_OPTIONS = 'APCORE_MODULE_OPTIONS';
|
|
3
3
|
export const APCORE_MCP_MODULE_OPTIONS = 'APCORE_MCP_MODULE_OPTIONS';
|
|
4
|
+
export const APCORE_CLI_MODULE_OPTIONS = 'APCORE_CLI_MODULE_OPTIONS';
|
|
5
|
+
export const APCORE_A2A_MODULE_OPTIONS = 'APCORE_A2A_MODULE_OPTIONS';
|
|
4
6
|
// Reflect metadata keys used by decorators
|
|
5
7
|
export const AP_TOOL_METADATA_KEY = 'apcore:tool';
|
|
6
8
|
export const AP_MODULE_METADATA_KEY = 'apcore:module';
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAgC,CAAC;AACtE,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAAoC,CAAC;AAE9E,2CAA2C;AAC3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAsB,CAAC;AAC3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAwB,CAAC;AAC/D,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAgC,CAAC;AACtE,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAAoC,CAAC;AAC9E,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAAoC,CAAC;AAC9E,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAAoC,CAAC;AAE9E,2CAA2C;AAC3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAsB,CAAC;AAC3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAwB,CAAC;AAC/D,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAyB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Context } from 'apcore-js';
|
|
2
|
+
/** Minimal request shape required by NestContextFactory (Express and Fastify compatible). */
|
|
3
|
+
export interface NestRequest {
|
|
4
|
+
headers: Record<string, string | string[] | undefined>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Creates apcore Context objects from NestJS HTTP requests.
|
|
8
|
+
*
|
|
9
|
+
* Identity extraction priority:
|
|
10
|
+
* 1. `x-user-id` header
|
|
11
|
+
* 2. `Authorization: Bearer <token>` header (identity id = "bearer")
|
|
12
|
+
* 3. Falls back to anonymous identity
|
|
13
|
+
*
|
|
14
|
+
* W3C Trace Context propagation:
|
|
15
|
+
* When a `traceparent` header is present, its trace_id is used via
|
|
16
|
+
* Context.create — strict 32-hex validation and W3C-invalid rejection
|
|
17
|
+
* are enforced by the SDK, not this factory. See PROTOCOL_SPEC §10.5.
|
|
18
|
+
*
|
|
19
|
+
* Correlation ID:
|
|
20
|
+
* If `x-correlation-id` or `x-request-id` is present, the value is
|
|
21
|
+
* stored in context.data["x-correlation-id"] alongside traceId so
|
|
22
|
+
* existing log pipelines remain correlatable.
|
|
23
|
+
*/
|
|
24
|
+
export declare class NestContextFactory {
|
|
25
|
+
/**
|
|
26
|
+
* Create an apcore Context from a NestJS HTTP request.
|
|
27
|
+
*
|
|
28
|
+
* @param req - Request object (from @Req() decorator or an interceptor).
|
|
29
|
+
* Compatible with Express and Fastify request shapes.
|
|
30
|
+
*/
|
|
31
|
+
createContext(req: NestRequest): Context;
|
|
32
|
+
private _extractTraceParent;
|
|
33
|
+
private _extractIdentity;
|
|
34
|
+
private _extractData;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=nest-context.factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-context.factory.d.ts","sourceRoot":"","sources":["../../src/context/nest-context.factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAgC,MAAM,WAAW,CAAC;AAGlE,6FAA6F;AAC7F,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;CACxD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBACa,kBAAkB;IAC7B;;;;;OAKG;IACH,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO;IAOxC,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,YAAY;CASrB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Injectable } from '@nestjs/common';
|
|
8
|
+
import { Context, TraceContext, createIdentity } from 'apcore-js';
|
|
9
|
+
/**
|
|
10
|
+
* Creates apcore Context objects from NestJS HTTP requests.
|
|
11
|
+
*
|
|
12
|
+
* Identity extraction priority:
|
|
13
|
+
* 1. `x-user-id` header
|
|
14
|
+
* 2. `Authorization: Bearer <token>` header (identity id = "bearer")
|
|
15
|
+
* 3. Falls back to anonymous identity
|
|
16
|
+
*
|
|
17
|
+
* W3C Trace Context propagation:
|
|
18
|
+
* When a `traceparent` header is present, its trace_id is used via
|
|
19
|
+
* Context.create — strict 32-hex validation and W3C-invalid rejection
|
|
20
|
+
* are enforced by the SDK, not this factory. See PROTOCOL_SPEC §10.5.
|
|
21
|
+
*
|
|
22
|
+
* Correlation ID:
|
|
23
|
+
* If `x-correlation-id` or `x-request-id` is present, the value is
|
|
24
|
+
* stored in context.data["x-correlation-id"] alongside traceId so
|
|
25
|
+
* existing log pipelines remain correlatable.
|
|
26
|
+
*/
|
|
27
|
+
let NestContextFactory = class NestContextFactory {
|
|
28
|
+
/**
|
|
29
|
+
* Create an apcore Context from a NestJS HTTP request.
|
|
30
|
+
*
|
|
31
|
+
* @param req - Request object (from @Req() decorator or an interceptor).
|
|
32
|
+
* Compatible with Express and Fastify request shapes.
|
|
33
|
+
*/
|
|
34
|
+
createContext(req) {
|
|
35
|
+
const identity = this._extractIdentity(req);
|
|
36
|
+
const traceParent = this._extractTraceParent(req);
|
|
37
|
+
const data = this._extractData(req);
|
|
38
|
+
return Context.create(identity, traceParent, null, data);
|
|
39
|
+
}
|
|
40
|
+
_extractTraceParent(req) {
|
|
41
|
+
const headers = _normalizeHeaders(req.headers);
|
|
42
|
+
return TraceContext.extract(headers);
|
|
43
|
+
}
|
|
44
|
+
_extractIdentity(req) {
|
|
45
|
+
const headers = req.headers;
|
|
46
|
+
const userId = headers['x-user-id'];
|
|
47
|
+
if (typeof userId === 'string' && userId.length > 0) {
|
|
48
|
+
return createIdentity(userId, 'user');
|
|
49
|
+
}
|
|
50
|
+
const auth = headers['authorization'];
|
|
51
|
+
if (typeof auth === 'string' && auth.toLowerCase().startsWith('bearer ')) {
|
|
52
|
+
return createIdentity('bearer', 'api_key');
|
|
53
|
+
}
|
|
54
|
+
return createIdentity('anonymous', 'anonymous');
|
|
55
|
+
}
|
|
56
|
+
_extractData(req) {
|
|
57
|
+
const data = {};
|
|
58
|
+
const headers = req.headers;
|
|
59
|
+
const correlationId = headers['x-correlation-id'] ?? headers['x-request-id'];
|
|
60
|
+
if (typeof correlationId === 'string' && correlationId.length > 0) {
|
|
61
|
+
data['x-correlation-id'] = correlationId;
|
|
62
|
+
}
|
|
63
|
+
return data;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
NestContextFactory = __decorate([
|
|
67
|
+
Injectable()
|
|
68
|
+
], NestContextFactory);
|
|
69
|
+
export { NestContextFactory };
|
|
70
|
+
function _normalizeHeaders(headers) {
|
|
71
|
+
const result = {};
|
|
72
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
73
|
+
if (typeof value === 'string') {
|
|
74
|
+
result[key.toLowerCase()] = value;
|
|
75
|
+
}
|
|
76
|
+
else if (Array.isArray(value) && value.length > 0) {
|
|
77
|
+
result[key.toLowerCase()] = value[0];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=nest-context.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-context.factory.js","sourceRoot":"","sources":["../../src/context/nest-context.factory.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAQlE;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B;;;;;OAKG;IACH,aAAa,CAAC,GAAgB;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;QAClD,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3D,CAAC;IAEO,mBAAmB,CAAC,GAAgB;QAC1C,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC/C,OAAO,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAEO,gBAAgB,CAAC,GAAgB;QACvC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAE5B,MAAM,MAAM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,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpD,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACxC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -41,6 +41,6 @@ export declare class ApcoreExecutorService {
|
|
|
41
41
|
* @param inputs Key/value inputs to validate (defaults to `{}`).
|
|
42
42
|
* @param context Optional execution context for call-chain checks.
|
|
43
43
|
*/
|
|
44
|
-
validate(moduleId: string, inputs?: Record<string, unknown>, context?: Context | null): PreflightResult
|
|
44
|
+
validate(moduleId: string, inputs?: Record<string, unknown>, context?: Context | null): Promise<PreflightResult>;
|
|
45
45
|
}
|
|
46
46
|
//# sourceMappingURL=apcore-executor.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apcore-executor.service.d.ts","sourceRoot":"","sources":["../../src/core/apcore-executor.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE1D;;;;;GAKG;AACH,qBACa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,QAAQ;IAM/C,yDAAyD;IACzD,IAAI,GAAG,IAAI,QAAQ,CAElB;IAED;;;;;;;OAOG;IACG,IAAI,CACR,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,GACvB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAInC;;;;;;;;;OASG;IACI,MAAM,CACX,Q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QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,GACvB,OAAO,CAAC,eAAe,CAAC;CAG5B"}
|
|
@@ -13,7 +13,7 @@ export declare class ApcoreRegistryService {
|
|
|
13
13
|
constructor(registry: Registry);
|
|
14
14
|
/** Return the underlying apcore-js Registry instance. */
|
|
15
15
|
get raw(): Registry;
|
|
16
|
-
register(moduleId: string, module: unknown): void
|
|
16
|
+
register(moduleId: string, module: unknown): Promise<void>;
|
|
17
17
|
unregister(moduleId: string): boolean;
|
|
18
18
|
get(moduleId: string): unknown | null;
|
|
19
19
|
has(moduleId: string): boolean;
|
|
@@ -54,7 +54,7 @@ export declare class ApcoreRegistryService {
|
|
|
54
54
|
*
|
|
55
55
|
* @returns The module ID under which the method was registered.
|
|
56
56
|
*/
|
|
57
|
-
registerMethod(options: RegisterMethodOptions): string
|
|
57
|
+
registerMethod(options: RegisterMethodOptions): Promise<string>;
|
|
58
58
|
/**
|
|
59
59
|
* Register multiple methods from a service instance as FunctionModules.
|
|
60
60
|
*
|
|
@@ -64,6 +64,6 @@ export declare class ApcoreRegistryService {
|
|
|
64
64
|
*
|
|
65
65
|
* @returns An array of module IDs that were registered.
|
|
66
66
|
*/
|
|
67
|
-
registerService(options: RegisterServiceOptions): string[]
|
|
67
|
+
registerService(options: RegisterServiceOptions): Promise<string[]>;
|
|
68
68
|
}
|
|
69
69
|
//# sourceMappingURL=apcore-registry.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apcore-registry.service.d.ts","sourceRoot":"","sources":["../../src/core/apcore-registry.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apcore-registry.service.d.ts","sourceRoot":"","sources":["../../src/core/apcore-registry.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAQ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CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IAYlF;;;;;;;OAOG;IACG,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAiDrE;;;;;;;;OAQG;IACG,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAwD1E"}
|
|
@@ -8,7 +8,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { Injectable } from '@nestjs/common';
|
|
11
|
-
|
|
11
|
+
/** Normalize a raw execute result to a plain Record<string, unknown>. */
|
|
12
|
+
function normalizeResult(raw) {
|
|
13
|
+
if (raw === null || raw === undefined)
|
|
14
|
+
return {};
|
|
15
|
+
if (typeof raw === 'object' && !Array.isArray(raw))
|
|
16
|
+
return raw;
|
|
17
|
+
return { result: raw };
|
|
18
|
+
}
|
|
12
19
|
import { createScannedModule, moduleToDict, modulesToDicts } from 'apcore-toolkit';
|
|
13
20
|
import { normalizeClassName, normalizeMethodName, generateModuleId, } from '../utils/id-generator.js';
|
|
14
21
|
import { scannedModuleToFunctionModule, toModuleAnnotations, } from '../utils/module-factory.js';
|
|
@@ -47,8 +54,8 @@ let ApcoreRegistryService = class ApcoreRegistryService {
|
|
|
47
54
|
return this.registry;
|
|
48
55
|
}
|
|
49
56
|
// ---- delegated methods ----
|
|
50
|
-
register(moduleId, module) {
|
|
51
|
-
this.registry.register(moduleId, module);
|
|
57
|
+
async register(moduleId, module) {
|
|
58
|
+
await this.registry.register(moduleId, module);
|
|
52
59
|
}
|
|
53
60
|
unregister(moduleId) {
|
|
54
61
|
return this.registry.unregister(moduleId);
|
|
@@ -132,7 +139,7 @@ let ApcoreRegistryService = class ApcoreRegistryService {
|
|
|
132
139
|
*
|
|
133
140
|
* @returns The module ID under which the method was registered.
|
|
134
141
|
*/
|
|
135
|
-
registerMethod(options) {
|
|
142
|
+
async registerMethod(options) {
|
|
136
143
|
const { instance, method, description, id, inputSchema, outputSchema, annotations, tags, documentation, examples, } = options;
|
|
137
144
|
// Validate the method exists on the instance
|
|
138
145
|
const fn = instance[method];
|
|
@@ -159,7 +166,7 @@ let ApcoreRegistryService = class ApcoreRegistryService {
|
|
|
159
166
|
return normalizeResult(raw);
|
|
160
167
|
};
|
|
161
168
|
const fm = scannedModuleToFunctionModule(scanned, execute);
|
|
162
|
-
this.registry.register(moduleId, fm);
|
|
169
|
+
await this.registry.register(moduleId, fm);
|
|
163
170
|
return moduleId;
|
|
164
171
|
}
|
|
165
172
|
/**
|
|
@@ -171,7 +178,7 @@ let ApcoreRegistryService = class ApcoreRegistryService {
|
|
|
171
178
|
*
|
|
172
179
|
* @returns An array of module IDs that were registered.
|
|
173
180
|
*/
|
|
174
|
-
registerService(options) {
|
|
181
|
+
async registerService(options) {
|
|
175
182
|
const { instance, description, methods, exclude = [], namespace, annotations, tags, methodOptions = {}, } = options;
|
|
176
183
|
// Determine which methods to register
|
|
177
184
|
let methodNames;
|
|
@@ -189,7 +196,7 @@ let ApcoreRegistryService = class ApcoreRegistryService {
|
|
|
189
196
|
const normalizedMethod = normalizeMethodName(methodName);
|
|
190
197
|
const methodDesc = perMethodOpts.description ?? description ?? `${methodName}`;
|
|
191
198
|
const moduleId = perMethodOpts.id ?? `${ns}.${normalizedMethod}`;
|
|
192
|
-
const id = this.registerMethod({
|
|
199
|
+
const id = await this.registerMethod({
|
|
193
200
|
instance,
|
|
194
201
|
method: methodName,
|
|
195
202
|
description: methodDesc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apcore-registry.service.js","sourceRoot":"","sources":["../../src/core/apcore-registry.service.ts"],"names":[],"mappings":";;;;;;;;;A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;YAC7D,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;YAEzD,MAAM,UAAU,GACd,aAAa,CAAC,WAAW,IAAI,WAAW,IAAI,GAAG,UAAU,EAAE,CAAC;YAE9D,MAAM,QAAQ,GAAG,aAAa,CAAC,EAAE,IAAI,GAAG,EAAE,IAAI,gBAAgB,EAAE,CAAC;YAEjE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC;gBACnC,QAAQ;gBACR,MAAM,EAAE,UAAU;gBAClB,WAAW,EAAE,UAAU;gBACvB,EAAE,EAAE,QAAQ;gBACZ,WAAW,EAAE,aAAa,CAAC,WAAW;gBACtC,YAAY,EAAE,aAAa,CAAC,YAAY;gBACxC,WAAW,EAAE,aAAa,CAAC,WAAW,IAAI,WAAW;gBACrD,IAAI,EAAE,aAAa,CAAC,IAAI,IAAI,IAAI;gBAChC,aAAa,EAAE,aAAa,CAAC,aAAa;gBAC1C,QAAQ,EAAE,aAAa,CAAC,QAAQ;aACjC,CAAC,CAAC;YAEH,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;CACF,CAAA;AAlOY,qBAAqB;IADjC,UAAU,EAAE;;GACA,qBAAqB,CAkOjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apcore.module.d.ts","sourceRoot":"","sources":["../../src/core/apcore.module.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"apcore.module.d.ts","sourceRoot":"","sources":["../../src/core/apcore.module.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,gBAAgB,CAAC;AAUpE,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;GASG;AACH,qBAEa,YAAY;IACvB;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,mBAAwB,GAAG,aAAa;IA2ChE;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa;CAwDtE"}
|
|
@@ -11,6 +11,8 @@ import { ApcoreRegistryService } from './apcore-registry.service.js';
|
|
|
11
11
|
import { ApcoreExecutorService } from './apcore-executor.service.js';
|
|
12
12
|
import { ApToolScannerService } from '../decorators/ap-tool-scanner.service.js';
|
|
13
13
|
import { ApcoreMcpModule } from '../mcp/apcore-mcp.module.js';
|
|
14
|
+
import { ApcoreCliModule } from '../cli/apcore-cli.module.js';
|
|
15
|
+
import { ApcoreA2aModule } from '../a2a/apcore-a2a.module.js';
|
|
14
16
|
import { APCORE_MODULE_OPTIONS } from '../constants.js';
|
|
15
17
|
/**
|
|
16
18
|
* Main NestJS dynamic module for the apcore ecosystem.
|
|
@@ -45,6 +47,12 @@ let ApcoreModule = ApcoreModule_1 = class ApcoreModule {
|
|
|
45
47
|
if (options.mcp) {
|
|
46
48
|
imports.push(ApcoreMcpModule.forRoot(options.mcp));
|
|
47
49
|
}
|
|
50
|
+
if (options.cli) {
|
|
51
|
+
imports.push(ApcoreCliModule.forRoot(options.cli));
|
|
52
|
+
}
|
|
53
|
+
if (options.a2a) {
|
|
54
|
+
imports.push(ApcoreA2aModule.forRoot(options.a2a));
|
|
55
|
+
}
|
|
48
56
|
return {
|
|
49
57
|
module: ApcoreModule_1,
|
|
50
58
|
imports,
|
|
@@ -73,6 +81,12 @@ let ApcoreModule = ApcoreModule_1 = class ApcoreModule {
|
|
|
73
81
|
if (options.mcp) {
|
|
74
82
|
imports.push(ApcoreMcpModule.forRoot(options.mcp));
|
|
75
83
|
}
|
|
84
|
+
if (options.cli) {
|
|
85
|
+
imports.push(ApcoreCliModule.forRoot(options.cli));
|
|
86
|
+
}
|
|
87
|
+
if (options.a2a) {
|
|
88
|
+
imports.push(ApcoreA2aModule.forRoot(options.a2a));
|
|
89
|
+
}
|
|
76
90
|
return {
|
|
77
91
|
module: ApcoreModule_1,
|
|
78
92
|
imports,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apcore.module.js","sourceRoot":"","sources":["../../src/core/apcore.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAMxD;;;;;;;;;GASG;AAGI,IAAM,YAAY,oBAAlB,MAAM,YAAY;IACvB;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CAAC,UAA+B,EAAE;QAC9C,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC;YAC5B,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,IAAI;SAC7C,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC;YAC5B,QAAQ;YACR,GAAG,EAAG,OAAO,CAAC,GAAkB,IAAI,IAAI;YACxC,WAAW,EAAG,OAAO,CAAC,UAA2B,IAAI,IAAI;SAC1D,CAAC,CAAC;QAEH,MAAM,eAAe,GAAG,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAC5D,MAAM,eAAe,GAAG,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAE5D,MAAM,OAAO,GAAU,EAAE,CAAC;QAC1B,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,OAAO,CAAC,IA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C9B,UAAU,EAAE,CACV,IAAyB,EACzB,eAAsC,EACtC,EAAE;wBACF,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC;4BAC5B,QAAQ,EAAE,eAAe,CAAC,GAAG;4BAC7B,GAAG,EAAG,IAAI,CAAC,GAAkB,IAAI,IAAI;4BACrC,WAAW,EAAG,IAAI,CAAC,UAA2B,IAAI,IAAI;yBACvD,CAAC,CAAC;wBACH,OAAO,IAAI,qBAAqB,CAAC,QAAQ,CAAC,CAAC;oBAC7C,CAAC;oBACD,MAAM,EAAE,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;iBACvD;gBACD,oBAAoB;aACrB;YACD,OAAO,EAAE;gBACP,qBAAqB;gBACrB,qBAAqB;gBACrB,qBAAqB;gBACrB,oBAAoB;aACrB;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAjHY,YAAY;IAFxB,MAAM,EAAE;IACR,MAAM,CAAC,EAAE,CAAC;GACE,YAAY,CAiHxB"}
|
|
@@ -37,7 +37,7 @@ export declare class ApToolScannerService extends BaseScanner implements OnModul
|
|
|
37
37
|
/** Configure include/exclude filters applied during scanAndRegister(). */
|
|
38
38
|
setScanOptions(options: ScanOptions): void;
|
|
39
39
|
getSourceName(): string;
|
|
40
|
-
onModuleInit(): void
|
|
40
|
+
onModuleInit(): Promise<void>;
|
|
41
41
|
/**
|
|
42
42
|
* Scan all NestJS providers for @ApTool decorated methods.
|
|
43
43
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ap-tool-scanner.service.d.ts","sourceRoot":"","sources":["../../src/decorators/ap-tool-scanner.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ap-tool-scanner.service.d.ts","sourceRoot":"","sources":["../../src/decorators/ap-tool-scanner.service.ts"],"names":[],"mappings":"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|
|
13
13
|
import { Inject, Injectable, Logger } from '@nestjs/common';
|
|
14
14
|
import { ModulesContainer } from '@nestjs/core';
|
|
15
|
-
import { normalizeResult } from 'apcore-js';
|
|
16
15
|
import { BaseScanner, createScannedModule, enrichSchemaDescriptions } from 'apcore-toolkit';
|
|
16
|
+
/** Normalize a raw execute result to a plain Record<string, unknown>. */
|
|
17
|
+
function normalizeResult(raw) {
|
|
18
|
+
if (raw === null || raw === undefined)
|
|
19
|
+
return {};
|
|
20
|
+
if (typeof raw === 'object' && !Array.isArray(raw))
|
|
21
|
+
return raw;
|
|
22
|
+
return { result: raw };
|
|
23
|
+
}
|
|
17
24
|
import { ApcoreRegistryService } from '../core/apcore-registry.service.js';
|
|
18
25
|
import { SchemaExtractor } from '../schema/schema-extractor.service.js';
|
|
19
26
|
import { AP_TOOL_METADATA_KEY, AP_MODULE_METADATA_KEY, AP_CONTEXT_METADATA_KEY, } from '../constants.js';
|
|
@@ -69,8 +76,8 @@ let ApToolScannerService = class ApToolScannerService extends BaseScanner {
|
|
|
69
76
|
getSourceName() {
|
|
70
77
|
return 'nestjs-decorators';
|
|
71
78
|
}
|
|
72
|
-
onModuleInit() {
|
|
73
|
-
this.scanAndRegister();
|
|
79
|
+
async onModuleInit() {
|
|
80
|
+
await this.scanAndRegister();
|
|
74
81
|
}
|
|
75
82
|
/**
|
|
76
83
|
* Scan all NestJS providers for @ApTool decorated methods.
|
|
@@ -111,11 +118,11 @@ let ApToolScannerService = class ApToolScannerService extends BaseScanner {
|
|
|
111
118
|
/**
|
|
112
119
|
* Scan, deduplicate, filter, then register all discovered modules.
|
|
113
120
|
*/
|
|
114
|
-
scanAndRegister() {
|
|
121
|
+
async scanAndRegister() {
|
|
115
122
|
let scannedModules = this.scan();
|
|
116
123
|
// Apply include/exclude filtering via inherited BaseScanner.filterModules()
|
|
117
124
|
if (this._scanOptions.include || this._scanOptions.exclude) {
|
|
118
|
-
scannedModules = this.filterModules(scannedModules, this._scanOptions);
|
|
125
|
+
scannedModules = this.filterModules(scannedModules, this._scanOptions.include, this._scanOptions.exclude);
|
|
119
126
|
}
|
|
120
127
|
for (const mod of scannedModules) {
|
|
121
128
|
const execute = this._executeFns.get(mod.moduleId);
|
|
@@ -124,7 +131,7 @@ let ApToolScannerService = class ApToolScannerService extends BaseScanner {
|
|
|
124
131
|
continue;
|
|
125
132
|
}
|
|
126
133
|
const fm = scannedModuleToFunctionModule(mod, execute);
|
|
127
|
-
this.registry.register(mod.moduleId, fm);
|
|
134
|
+
await this.registry.register(mod.moduleId, fm);
|
|
128
135
|
}
|
|
129
136
|
}
|
|
130
137
|
/**
|