nestjs-apcore 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -56
- package/dist/bridge/binding-loader.d.ts +2 -2
- package/dist/bridge/binding-loader.d.ts.map +1 -1
- package/dist/bridge/binding-loader.js +16 -30
- package/dist/bridge/binding-loader.js.map +1 -1
- package/dist/core/apcore-executor.service.d.ts +7 -3
- package/dist/core/apcore-executor.service.d.ts.map +1 -1
- package/dist/core/apcore-executor.service.js +7 -3
- package/dist/core/apcore-executor.service.js.map +1 -1
- package/dist/core/apcore-registry.service.d.ts +26 -9
- package/dist/core/apcore-registry.service.d.ts.map +1 -1
- package/dist/core/apcore-registry.service.js +71 -38
- package/dist/core/apcore-registry.service.js.map +1 -1
- package/dist/core/apcore.module.d.ts +4 -1
- package/dist/core/apcore.module.d.ts.map +1 -1
- package/dist/core/apcore.module.js +20 -2
- package/dist/core/apcore.module.js.map +1 -1
- package/dist/decorators/ap-tool-scanner.service.d.ts +46 -7
- package/dist/decorators/ap-tool-scanner.service.d.ts.map +1 -1
- package/dist/decorators/ap-tool-scanner.service.js +110 -56
- package/dist/decorators/ap-tool-scanner.service.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/apcore-mcp.service.d.ts +21 -3
- package/dist/mcp/apcore-mcp.service.d.ts.map +1 -1
- package/dist/mcp/apcore-mcp.service.js +58 -41
- package/dist/mcp/apcore-mcp.service.js.map +1 -1
- package/dist/types.d.ts +23 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/module-factory.d.ts +29 -0
- package/dist/utils/module-factory.d.ts.map +1 -0
- package/dist/utils/module-factory.js +45 -0
- package/dist/utils/module-factory.js.map +1 -0
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -5,7 +5,8 @@ NestJS adapter for the [apcore](https://github.com/aipartnerup/apcore-js) AI-Per
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Decorator-driven** — Mark methods with `@ApTool` and classes with `@ApModule` to expose them as AI tools
|
|
8
|
-
- **Auto-discovery** —
|
|
8
|
+
- **Auto-discovery** — tools are scanned and registered at startup automatically
|
|
9
|
+
- **One-stop setup** — `ApcoreModule.forRoot()` handles Registry, Executor, Scanner, and optional MCP server in a single call
|
|
9
10
|
- **Multi-schema support** — TypeBox, Zod, class-validator DTOs, and plain JSON Schema, auto-detected via a priority chain
|
|
10
11
|
- **MCP server built-in** — Serve tools over stdio, Streamable HTTP, or SSE transports with optional Tool Explorer UI
|
|
11
12
|
- **OpenAI-compatible** — Convert registered tools to OpenAI function-calling format with `toOpenaiTools()`
|
|
@@ -36,26 +37,26 @@ npm install @sinclair/typebox # TypeBoxAdapter (recommended)
|
|
|
36
37
|
|
|
37
38
|
## Quick Start
|
|
38
39
|
|
|
39
|
-
### 1. Wire up
|
|
40
|
+
### 1. Wire up the module
|
|
40
41
|
|
|
41
42
|
```typescript
|
|
42
43
|
// app.module.ts
|
|
43
44
|
import { Module } from '@nestjs/common';
|
|
44
|
-
import { ApcoreModule
|
|
45
|
+
import { ApcoreModule } from 'nestjs-apcore';
|
|
45
46
|
|
|
46
47
|
@Module({
|
|
47
48
|
imports: [
|
|
48
|
-
ApcoreModule.forRoot({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
ApcoreModule.forRoot({
|
|
50
|
+
mcp: {
|
|
51
|
+
transport: 'streamable-http',
|
|
52
|
+
port: 8000,
|
|
53
|
+
name: 'my-app',
|
|
54
|
+
explorer: true,
|
|
55
|
+
allowExecute: true,
|
|
56
|
+
},
|
|
55
57
|
}),
|
|
56
58
|
TodoModule,
|
|
57
59
|
],
|
|
58
|
-
providers: [ApToolScannerService],
|
|
59
60
|
})
|
|
60
61
|
export class AppModule {}
|
|
61
62
|
```
|
|
@@ -127,47 +128,64 @@ Your service is now available as:
|
|
|
127
128
|
|
|
128
129
|
## API Reference
|
|
129
130
|
|
|
130
|
-
###
|
|
131
|
+
### ApcoreModule
|
|
131
132
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
Provides the core `Registry` and `Executor` as NestJS singletons.
|
|
133
|
+
The single entry point. Provides the core `Registry`, `Executor`, and `ApToolScannerService` as global NestJS singletons. Optionally integrates the MCP server.
|
|
135
134
|
|
|
136
135
|
```typescript
|
|
137
|
-
// Sync
|
|
138
|
-
ApcoreModule.forRoot({
|
|
136
|
+
// Sync — with MCP server
|
|
137
|
+
ApcoreModule.forRoot({
|
|
138
|
+
extensionsDir?: string | null,
|
|
139
|
+
acl?: unknown,
|
|
140
|
+
middleware?: unknown[],
|
|
141
|
+
mcp?: ApcoreMcpModuleOptions, // if provided, MCP server starts automatically
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
// Sync — without MCP (Registry + Executor only)
|
|
145
|
+
ApcoreModule.forRoot()
|
|
139
146
|
|
|
140
147
|
// Async (e.g. inject ConfigService)
|
|
141
|
-
ApcoreModule.forRootAsync({
|
|
148
|
+
ApcoreModule.forRootAsync({
|
|
149
|
+
imports: [ConfigModule],
|
|
150
|
+
useFactory: (config: ConfigService) => ({
|
|
151
|
+
extensionsDir: config.get('EXTENSIONS_DIR'),
|
|
152
|
+
}),
|
|
153
|
+
inject: [ConfigService],
|
|
154
|
+
mcp: { transport: 'streamable-http', port: 8000 }, // static, evaluated at definition time
|
|
155
|
+
})
|
|
142
156
|
```
|
|
143
157
|
|
|
144
|
-
####
|
|
158
|
+
#### MCP Options
|
|
145
159
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
160
|
+
| Field | Type | Description |
|
|
161
|
+
|---|---|---|
|
|
162
|
+
| `transport` | `'stdio' \| 'streamable-http' \| 'sse'` | Transport protocol |
|
|
163
|
+
| `host` | `string` | Bind host |
|
|
164
|
+
| `port` | `number` | Bind port |
|
|
165
|
+
| `name` | `string` | Server name |
|
|
166
|
+
| `version` | `string` | Server version |
|
|
167
|
+
| `explorer` | `boolean` | Enable Tool Explorer web UI |
|
|
168
|
+
| `allowExecute` | `boolean` | Allow tool execution from Explorer |
|
|
169
|
+
| `authenticator` | `Authenticator` | JWT or custom auth strategy |
|
|
170
|
+
| `tags` | `string[]` | Only expose tools with these tags |
|
|
171
|
+
| `prefix` | `string` | Only expose tools with this ID prefix |
|
|
172
|
+
| `logLevel` | `string` | `'DEBUG' \| 'INFO' \| 'WARNING' \| 'ERROR' \| 'CRITICAL'` |
|
|
173
|
+
| `metricsCollector` | `MetricsExporter` | Enables `/metrics` Prometheus endpoint |
|
|
174
|
+
| `onStartup` | `() => void` | Callback after server starts |
|
|
175
|
+
| `onShutdown` | `() => void` | Callback before server stops |
|
|
176
|
+
|
|
177
|
+
#### Standalone MCP Module
|
|
178
|
+
|
|
179
|
+
If you prefer to configure the MCP server separately (e.g. different lifecycle), you can import `ApcoreMcpModule` directly:
|
|
149
180
|
|
|
150
181
|
```typescript
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
version?: string,
|
|
157
|
-
tags?: string[], // only expose tools matching these tags
|
|
158
|
-
prefix?: string, // only expose tools with this ID prefix
|
|
159
|
-
explorer?: boolean, // enable Tool Explorer web UI
|
|
160
|
-
explorerPrefix?: string, // URL prefix for the Explorer
|
|
161
|
-
allowExecute?: boolean, // allow execution from Explorer
|
|
162
|
-
dynamic?: boolean, // enable dynamic tool list updates
|
|
163
|
-
validateInputs?: boolean,
|
|
164
|
-
logLevel?: 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR' | 'CRITICAL',
|
|
165
|
-
authenticator?: Authenticator, // JWT or custom auth
|
|
166
|
-
exemptPaths?: string[], // paths that bypass auth (default: ['/health', '/metrics'])
|
|
167
|
-
metricsCollector?: { exportPrometheus(): string },
|
|
168
|
-
onStartup?: () => void | Promise<void>,
|
|
169
|
-
onShutdown?: () => void | Promise<void>,
|
|
182
|
+
@Module({
|
|
183
|
+
imports: [
|
|
184
|
+
ApcoreModule.forRoot(),
|
|
185
|
+
ApcoreMcpModule.forRoot({ transport: 'streamable-http', port: 8000 }),
|
|
186
|
+
],
|
|
170
187
|
})
|
|
188
|
+
export class AppModule {}
|
|
171
189
|
```
|
|
172
190
|
|
|
173
191
|
### Decorators
|
|
@@ -242,17 +260,20 @@ bindings:
|
|
|
242
260
|
|
|
243
261
|
### JWT Authentication
|
|
244
262
|
|
|
245
|
-
Enable JWT auth by passing a `JWTAuthenticator`
|
|
263
|
+
Enable JWT auth by passing a `JWTAuthenticator` in the `mcp` config. The Explorer UI and `/health` endpoint are always exempt.
|
|
246
264
|
|
|
247
265
|
```typescript
|
|
248
|
-
import { JWTAuthenticator, getCurrentIdentity } from 'nestjs-apcore';
|
|
266
|
+
import { ApcoreModule, JWTAuthenticator, getCurrentIdentity } from 'nestjs-apcore';
|
|
249
267
|
|
|
250
268
|
// In app.module.ts
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
269
|
+
ApcoreModule.forRoot({
|
|
270
|
+
mcp: {
|
|
271
|
+
transport: 'streamable-http',
|
|
272
|
+
port: 8000,
|
|
273
|
+
authenticator: process.env.JWT_SECRET
|
|
274
|
+
? new JWTAuthenticator({ secret: process.env.JWT_SECRET })
|
|
275
|
+
: undefined,
|
|
276
|
+
},
|
|
256
277
|
})
|
|
257
278
|
|
|
258
279
|
// Inside any @ApTool method
|
|
@@ -262,8 +283,6 @@ list(inputs: Record<string, unknown>) {
|
|
|
262
283
|
}
|
|
263
284
|
```
|
|
264
285
|
|
|
265
|
-
`JWTAuthenticator` options: `secret`, `algorithms` (default `['HS256']`), `audience`, `issuer`, `claimMapping`, `requireClaims`, `requireAuth` (default `true`).
|
|
266
|
-
|
|
267
286
|
### Re-exported Utilities
|
|
268
287
|
|
|
269
288
|
From `apcore-mcp`:
|
|
@@ -272,7 +291,7 @@ From `apcore-mcp`:
|
|
|
272
291
|
|
|
273
292
|
## Examples
|
|
274
293
|
|
|
275
|
-
The `demo/` directory contains a full working app with Todo and Weather services:
|
|
294
|
+
The [`demo/`](./demo) directory contains a full working app with Todo and Weather services:
|
|
276
295
|
|
|
277
296
|
```bash
|
|
278
297
|
cd demo
|
|
@@ -280,12 +299,15 @@ npm install
|
|
|
280
299
|
npx tsx src/main.ts
|
|
281
300
|
```
|
|
282
301
|
|
|
283
|
-
|
|
302
|
+
## Detailed Documentation
|
|
284
303
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
304
|
+
For in-depth documentation on each subsystem, see [`docs/features/`](./docs/features/):
|
|
305
|
+
|
|
306
|
+
- [Feature Overview](./docs/features/overview.md) — architecture and dependency graph
|
|
307
|
+
- [MCP Server Integration](./docs/features/mcp-server-integration.md) — module configuration, services API, dual-server architecture
|
|
308
|
+
- [@ApTool Decorator + Scanner](./docs/features/aptool-decorator-scanner.md) — decorators, ID generation, scan process
|
|
309
|
+
- [Schema Extraction](./docs/features/schema-extraction.md) — adapter chain, supported types, custom adapters
|
|
310
|
+
- [NestJS DI Bridge](./docs/features/di-bridge.md) — `registerMethod()`, `registerService()`, YAML bindings
|
|
289
311
|
|
|
290
312
|
## Scripts
|
|
291
313
|
|
|
@@ -7,8 +7,8 @@ export type InstanceProvider = (className: string) => object | undefined;
|
|
|
7
7
|
* NestJS injectable service that loads YAML binding files and registers
|
|
8
8
|
* modules with the ApcoreRegistryService.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Uses apcore-toolkit's {@link createScannedModule} to produce standardised
|
|
11
|
+
* intermediates, then converts to FunctionModule via the shared factory.
|
|
12
12
|
*/
|
|
13
13
|
export declare class ApBindingLoader {
|
|
14
14
|
private readonly registry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-loader.d.ts","sourceRoot":"","sources":["../../src/bridge/binding-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"binding-loader.d.ts","sourceRoot":"","sources":["../../src/bridge/binding-loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AA2B3E;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAEzE;;;;;;GAMG;AACH,qBACa,eAAe;IAGxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAGzB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;gBAHjB,QAAQ,EAAE,qBAAqB,EAG/B,gBAAgB,CAAC,EAAE,gBAAgB,YAAA;IAGtD;;;;;;OAMG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IAmDzC;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAIxD"}
|
|
@@ -13,31 +13,16 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
13
13
|
import { Injectable, Inject, Optional } from '@nestjs/common';
|
|
14
14
|
import * as yaml from 'js-yaml';
|
|
15
15
|
import { readFile } from 'node:fs/promises';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { normalizeResult } from 'apcore-js';
|
|
17
|
+
import { createScannedModule } from 'apcore-toolkit';
|
|
18
18
|
import { ApcoreRegistryService } from '../core/apcore-registry.service.js';
|
|
19
|
-
|
|
20
|
-
* Normalize a method return value to a Record<string, unknown>.
|
|
21
|
-
*
|
|
22
|
-
* - null / undefined -> {}
|
|
23
|
-
* - non-object (string, number, boolean) or array -> { result: value }
|
|
24
|
-
* - object -> returned as-is
|
|
25
|
-
*/
|
|
26
|
-
function normalizeReturnValue(value) {
|
|
27
|
-
if (value == null) {
|
|
28
|
-
return {};
|
|
29
|
-
}
|
|
30
|
-
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
31
|
-
return { result: value };
|
|
32
|
-
}
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
19
|
+
import { scannedModuleToFunctionModule, toModuleAnnotations, } from '../utils/module-factory.js';
|
|
35
20
|
/**
|
|
36
21
|
* NestJS injectable service that loads YAML binding files and registers
|
|
37
22
|
* modules with the ApcoreRegistryService.
|
|
38
23
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
24
|
+
* Uses apcore-toolkit's {@link createScannedModule} to produce standardised
|
|
25
|
+
* intermediates, then converts to FunctionModule via the shared factory.
|
|
41
26
|
*/
|
|
42
27
|
let ApBindingLoader = class ApBindingLoader {
|
|
43
28
|
registry;
|
|
@@ -65,12 +50,12 @@ let ApBindingLoader = class ApBindingLoader {
|
|
|
65
50
|
if (this.instanceProvider) {
|
|
66
51
|
instance = this.instanceProvider(className);
|
|
67
52
|
}
|
|
68
|
-
// Build the execute function
|
|
53
|
+
// Build the bound execute function
|
|
69
54
|
let execute;
|
|
70
55
|
if (instance && methodName in instance) {
|
|
71
56
|
execute = async (inputs) => {
|
|
72
57
|
const raw = await instance[methodName](inputs);
|
|
73
|
-
return
|
|
58
|
+
return normalizeResult(raw);
|
|
74
59
|
};
|
|
75
60
|
}
|
|
76
61
|
else {
|
|
@@ -80,18 +65,19 @@ let ApBindingLoader = class ApBindingLoader {
|
|
|
80
65
|
};
|
|
81
66
|
};
|
|
82
67
|
}
|
|
83
|
-
|
|
68
|
+
// Build ScannedModule intermediate via toolkit
|
|
69
|
+
const scanned = createScannedModule({
|
|
84
70
|
moduleId,
|
|
85
71
|
description: binding.description,
|
|
86
|
-
inputSchema: binding.input_schema ??
|
|
87
|
-
outputSchema: binding.output_schema ??
|
|
88
|
-
tags: binding.tags ??
|
|
89
|
-
|
|
72
|
+
inputSchema: binding.input_schema ?? { type: 'object', properties: {} },
|
|
73
|
+
outputSchema: binding.output_schema ?? { type: 'object', properties: {} },
|
|
74
|
+
tags: binding.tags ?? [],
|
|
75
|
+
target: binding.target,
|
|
76
|
+
annotations: toModuleAnnotations(binding.annotations),
|
|
90
77
|
documentation: binding.documentation ?? null,
|
|
91
|
-
examples: null,
|
|
92
|
-
execute,
|
|
93
78
|
});
|
|
94
|
-
|
|
79
|
+
const fm = scannedModuleToFunctionModule(scanned, execute);
|
|
80
|
+
this.registry.register(moduleId, fm);
|
|
95
81
|
ids.push(moduleId);
|
|
96
82
|
}
|
|
97
83
|
return ids;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-loader.js","sourceRoot":"","sources":["../../src/bridge/binding-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"binding-loader.js","sourceRoot":"","sources":["../../src/bridge/binding-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EACL,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AA4BpC;;;;;;GAMG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAGP;IAGA;IALnB,YAEmB,QAA+B,EAG/B,gBAAmC;QAHnC,aAAQ,GAAR,QAAQ,CAAuB;QAG/B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I,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;gBACpG,YAAY,EAAG,OAAO,CAAC,aAAyC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;gBACtG,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;gBACxB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,WAAW,EAAE,mBAAmB,CAAC,OAAO,CAAC,WAAkB,CAAC;gBAC5D,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,IAAI;aAC7C,CAAC,CAAC;YAEH,MAAM,EAAE,GAAG,6BAA6B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC3D,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACrC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,QAAgB;QACjC,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;CACF,CAAA;AA7EY,eAAe;IAD3B,UAAU,EAAE;IAGR,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAE7B,WAAA,QAAQ,EAAE,CAAA;IACV,WAAA,MAAM,CAAC,0BAA0B,CAAC,CAAA;qCAFR,qBAAqB;GAHvC,eAAe,CA6E3B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Executor } from 'apcore-js';
|
|
2
|
-
import type { Context,
|
|
2
|
+
import type { Context, PreflightResult } from 'apcore-js';
|
|
3
3
|
/**
|
|
4
4
|
* NestJS-injectable wrapper around the upstream apcore-js {@link Executor}.
|
|
5
5
|
*
|
|
@@ -34,9 +34,13 @@ export declare class ApcoreExecutorService {
|
|
|
34
34
|
/**
|
|
35
35
|
* Validate inputs against a module's input schema without executing it.
|
|
36
36
|
*
|
|
37
|
+
* Returns a PreflightResult containing per-check results, approval
|
|
38
|
+
* requirements, and overall validity.
|
|
39
|
+
*
|
|
37
40
|
* @param moduleId Fully-qualified module identifier.
|
|
38
|
-
* @param inputs Key/value inputs to validate.
|
|
41
|
+
* @param inputs Key/value inputs to validate (defaults to `{}`).
|
|
42
|
+
* @param context Optional execution context for call-chain checks.
|
|
39
43
|
*/
|
|
40
|
-
validate(moduleId: string, inputs
|
|
44
|
+
validate(moduleId: string, inputs?: Record<string, unknown>, context?: Context | null): PreflightResult;
|
|
41
45
|
}
|
|
42
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,
|
|
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,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACvC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,GACvB,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAI1C;;;;;;;;;OASG;IACH,QAAQ,CACN,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,GACvB,eAAe;CAGnB"}
|
|
@@ -53,11 +53,15 @@ let ApcoreExecutorService = class ApcoreExecutorService {
|
|
|
53
53
|
/**
|
|
54
54
|
* Validate inputs against a module's input schema without executing it.
|
|
55
55
|
*
|
|
56
|
+
* Returns a PreflightResult containing per-check results, approval
|
|
57
|
+
* requirements, and overall validity.
|
|
58
|
+
*
|
|
56
59
|
* @param moduleId Fully-qualified module identifier.
|
|
57
|
-
* @param inputs Key/value inputs to validate.
|
|
60
|
+
* @param inputs Key/value inputs to validate (defaults to `{}`).
|
|
61
|
+
* @param context Optional execution context for call-chain checks.
|
|
58
62
|
*/
|
|
59
|
-
validate(moduleId, inputs) {
|
|
60
|
-
return this.executor.validate(moduleId, inputs);
|
|
63
|
+
validate(moduleId, inputs, context) {
|
|
64
|
+
return this.executor.validate(moduleId, inputs ?? {}, context);
|
|
61
65
|
}
|
|
62
66
|
};
|
|
63
67
|
ApcoreExecutorService = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apcore-executor.service.js","sourceRoot":"","sources":["../../src/core/apcore-executor.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C;;;;;GAKG;AAEI,IAAM,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C;IAC7D,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,CAAC,MAAM,CACX,QAAgB,EAChB,MAAuC,EACvC,OAAwB;QAExB,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;;;OASG;IACH,QAAQ,CACN,QAAgB,EAChB,MAAgC,EAChC,OAAwB;QAExB,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;CACF,CAAA;AA/DY,qBAAqB;IADjC,UAAU,EAAE;;GACA,qBAAqB,CA+DjC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Registry } from 'apcore-js';
|
|
2
2
|
import type { ModuleDescriptor } from 'apcore-js';
|
|
3
|
+
import type { ScannedModule } from 'apcore-toolkit';
|
|
3
4
|
import type { RegisterMethodOptions, RegisterServiceOptions } from '../types.js';
|
|
4
5
|
/**
|
|
5
6
|
* NestJS-injectable service that wraps an upstream apcore-js Registry,
|
|
6
7
|
* delegating core operations and adding convenience methods for
|
|
7
|
-
* registering NestJS service methods
|
|
8
|
+
* registering NestJS service methods via apcore-toolkit's ScannedModule
|
|
9
|
+
* intermediate representation.
|
|
8
10
|
*/
|
|
9
11
|
export declare class ApcoreRegistryService {
|
|
10
12
|
private readonly registry;
|
|
@@ -24,16 +26,31 @@ export declare class ApcoreRegistryService {
|
|
|
24
26
|
discover(): Promise<number>;
|
|
25
27
|
get count(): number;
|
|
26
28
|
/**
|
|
27
|
-
*
|
|
29
|
+
* Convert a registered module's descriptor to a toolkit ScannedModule.
|
|
30
|
+
*
|
|
31
|
+
* Returns `null` if the module is not found.
|
|
32
|
+
*/
|
|
33
|
+
toScannedModule(moduleId: string): ScannedModule | null;
|
|
34
|
+
/**
|
|
35
|
+
* Serialise a registered module to a plain snake_case dictionary
|
|
36
|
+
* via apcore-toolkit's `moduleToDict()`.
|
|
28
37
|
*
|
|
29
|
-
*
|
|
30
|
-
|
|
38
|
+
* Returns `null` if the module is not found.
|
|
39
|
+
*/
|
|
40
|
+
toDict(moduleId: string): Record<string, unknown> | null;
|
|
41
|
+
/**
|
|
42
|
+
* Serialise all registered modules (optionally filtered by tags/prefix)
|
|
43
|
+
* to an array of snake_case dictionaries via apcore-toolkit.
|
|
44
|
+
*/
|
|
45
|
+
toDicts(options?: {
|
|
46
|
+
tags?: string[];
|
|
47
|
+
prefix?: string;
|
|
48
|
+
}): Record<string, unknown>[];
|
|
49
|
+
/**
|
|
50
|
+
* Register a single method from a service instance as a FunctionModule.
|
|
31
51
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* - null / undefined -> {}
|
|
35
|
-
* - non-object -> { result: value }
|
|
36
|
-
* - object -> returned as-is
|
|
52
|
+
* Produces a toolkit {@link ScannedModule} intermediate, then converts it
|
|
53
|
+
* to a FunctionModule with the method bound to the service instance.
|
|
37
54
|
*
|
|
38
55
|
* @returns The module ID under which the method was registered.
|
|
39
56
|
*/
|
|
@@ -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":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAkCjF;;;;;GAKG;AACH,qBACa,qBAAqB;IACpB,OAAO,CAAC,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,EAAE,sBAAsB,GAAG,MAAM,EAAE;CAwD3D"}
|
|
@@ -8,25 +8,10 @@ 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
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { normalizeResult } from 'apcore-js';
|
|
12
|
+
import { createScannedModule, moduleToDict, modulesToDicts } from 'apcore-toolkit';
|
|
13
13
|
import { normalizeClassName, normalizeMethodName, generateModuleId, } from '../utils/id-generator.js';
|
|
14
|
-
|
|
15
|
-
* Normalize a method return value to a Record<string, unknown>.
|
|
16
|
-
*
|
|
17
|
-
* - null / undefined -> {}
|
|
18
|
-
* - non-object (string, number, boolean) -> { result: value }
|
|
19
|
-
* - object -> returned as-is
|
|
20
|
-
*/
|
|
21
|
-
function normalizeReturnValue(value) {
|
|
22
|
-
if (value == null) {
|
|
23
|
-
return {};
|
|
24
|
-
}
|
|
25
|
-
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
26
|
-
return { result: value };
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
14
|
+
import { scannedModuleToFunctionModule, toModuleAnnotations, } from '../utils/module-factory.js';
|
|
30
15
|
/**
|
|
31
16
|
* Collect all own method names from a prototype chain up to (but not
|
|
32
17
|
* including) Object.prototype. Excludes 'constructor'.
|
|
@@ -48,7 +33,8 @@ function getAllMethodNames(instance) {
|
|
|
48
33
|
/**
|
|
49
34
|
* NestJS-injectable service that wraps an upstream apcore-js Registry,
|
|
50
35
|
* delegating core operations and adding convenience methods for
|
|
51
|
-
* registering NestJS service methods
|
|
36
|
+
* registering NestJS service methods via apcore-toolkit's ScannedModule
|
|
37
|
+
* intermediate representation.
|
|
52
38
|
*/
|
|
53
39
|
let ApcoreRegistryService = class ApcoreRegistryService {
|
|
54
40
|
registry;
|
|
@@ -88,18 +74,61 @@ let ApcoreRegistryService = class ApcoreRegistryService {
|
|
|
88
74
|
get count() {
|
|
89
75
|
return this.registry.count;
|
|
90
76
|
}
|
|
77
|
+
// ---- serialisation helpers (via apcore-toolkit) ----
|
|
78
|
+
/**
|
|
79
|
+
* Convert a registered module's descriptor to a toolkit ScannedModule.
|
|
80
|
+
*
|
|
81
|
+
* Returns `null` if the module is not found.
|
|
82
|
+
*/
|
|
83
|
+
toScannedModule(moduleId) {
|
|
84
|
+
const def = this.registry.getDefinition(moduleId);
|
|
85
|
+
if (!def)
|
|
86
|
+
return null;
|
|
87
|
+
return createScannedModule({
|
|
88
|
+
moduleId: def.moduleId,
|
|
89
|
+
description: def.description,
|
|
90
|
+
inputSchema: def.inputSchema,
|
|
91
|
+
outputSchema: def.outputSchema,
|
|
92
|
+
tags: def.tags ?? [],
|
|
93
|
+
target: moduleId,
|
|
94
|
+
annotations: def.annotations ?? null,
|
|
95
|
+
documentation: def.documentation ?? null,
|
|
96
|
+
examples: (def.examples ?? []),
|
|
97
|
+
metadata: def.metadata ?? {},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Serialise a registered module to a plain snake_case dictionary
|
|
102
|
+
* via apcore-toolkit's `moduleToDict()`.
|
|
103
|
+
*
|
|
104
|
+
* Returns `null` if the module is not found.
|
|
105
|
+
*/
|
|
106
|
+
toDict(moduleId) {
|
|
107
|
+
const scanned = this.toScannedModule(moduleId);
|
|
108
|
+
if (!scanned)
|
|
109
|
+
return null;
|
|
110
|
+
return moduleToDict(scanned);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Serialise all registered modules (optionally filtered by tags/prefix)
|
|
114
|
+
* to an array of snake_case dictionaries via apcore-toolkit.
|
|
115
|
+
*/
|
|
116
|
+
toDicts(options) {
|
|
117
|
+
const ids = this.registry.list(options);
|
|
118
|
+
const scanned = [];
|
|
119
|
+
for (const id of ids) {
|
|
120
|
+
const s = this.toScannedModule(id);
|
|
121
|
+
if (s)
|
|
122
|
+
scanned.push(s);
|
|
123
|
+
}
|
|
124
|
+
return modulesToDicts(scanned);
|
|
125
|
+
}
|
|
91
126
|
// ---- NestJS convenience methods ----
|
|
92
127
|
/**
|
|
93
128
|
* Register a single method from a service instance as a FunctionModule.
|
|
94
129
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* The execute function calls the method on the bound instance and
|
|
99
|
-
* normalizes the return value:
|
|
100
|
-
* - null / undefined -> {}
|
|
101
|
-
* - non-object -> { result: value }
|
|
102
|
-
* - object -> returned as-is
|
|
130
|
+
* Produces a toolkit {@link ScannedModule} intermediate, then converts it
|
|
131
|
+
* to a FunctionModule with the method bound to the service instance.
|
|
103
132
|
*
|
|
104
133
|
* @returns The module ID under which the method was registered.
|
|
105
134
|
*/
|
|
@@ -112,21 +141,25 @@ let ApcoreRegistryService = class ApcoreRegistryService {
|
|
|
112
141
|
}
|
|
113
142
|
const className = instance.constructor.name;
|
|
114
143
|
const moduleId = generateModuleId(className, method, true, id);
|
|
115
|
-
|
|
144
|
+
// Build ScannedModule intermediate via toolkit
|
|
145
|
+
const scanned = createScannedModule({
|
|
116
146
|
moduleId,
|
|
117
147
|
description,
|
|
118
|
-
inputSchema: inputSchema ??
|
|
119
|
-
outputSchema: outputSchema ??
|
|
120
|
-
tags: tags ??
|
|
121
|
-
|
|
148
|
+
inputSchema: inputSchema ?? { type: 'object', properties: {} },
|
|
149
|
+
outputSchema: outputSchema ?? { type: 'object', properties: {} },
|
|
150
|
+
tags: tags ?? [],
|
|
151
|
+
target: `${className}.${method}`,
|
|
152
|
+
annotations: toModuleAnnotations(annotations),
|
|
122
153
|
documentation: documentation ?? null,
|
|
123
|
-
examples: examples ??
|
|
124
|
-
execute: async (inputs) => {
|
|
125
|
-
const raw = await fn.call(instance, inputs);
|
|
126
|
-
return normalizeReturnValue(raw);
|
|
127
|
-
},
|
|
154
|
+
examples: examples ?? [],
|
|
128
155
|
});
|
|
129
|
-
|
|
156
|
+
// Bound execute function using normalizeResult from apcore-js
|
|
157
|
+
const execute = async (inputs) => {
|
|
158
|
+
const raw = await fn.call(instance, inputs);
|
|
159
|
+
return normalizeResult(raw);
|
|
160
|
+
};
|
|
161
|
+
const fm = scannedModuleToFunctionModule(scanned, execute);
|
|
162
|
+
this.registry.register(moduleId, fm);
|
|
130
163
|
return moduleId;
|
|
131
164
|
}
|
|
132
165
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apcore-registry.service.js","sourceRoot":"","sources":["../../src/core/apcore-registry.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"apcore-registry.service.js","sourceRoot":"","sources":["../../src/core/apcore-registry.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAG5C,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGnF,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAEpC;;;GAGG;AACH,SAAS,iBAAiB,CAAC,QAAgB;IACzC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,IAAI,KAAK,GAAkB,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAkB,CAAC;IAE5E,OAAO,KAAK,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;QAC3C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;YACrD,IACE,IAAI,KAAK,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,IAAI,EAAE,CAAC;YAEtD,kEAAkE;YAClE,MAAM,EAAE,GACN,SAAS,IAAI,kBAAkB,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;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,IAAI,CAAC,cAAc,CAAC;gBAC7B,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"}
|
|
@@ -6,6 +6,9 @@ import type { ApcoreModuleOptions, ApcoreModuleAsyncOptions } from '../types.js'
|
|
|
6
6
|
* Marked `@Global()` so that {@link ApcoreRegistryService} and
|
|
7
7
|
* {@link ApcoreExecutorService} are available application-wide without
|
|
8
8
|
* importing this module into every feature module.
|
|
9
|
+
*
|
|
10
|
+
* Now also handles automatic tool discovery via {@link ApToolScannerService}
|
|
11
|
+
* and optional MCP server integration.
|
|
9
12
|
*/
|
|
10
13
|
export declare class ApcoreModule {
|
|
11
14
|
/**
|
|
@@ -15,7 +18,7 @@ export declare class ApcoreModule {
|
|
|
15
18
|
* wraps them in NestJS-injectable services, and exports them together with
|
|
16
19
|
* the raw options token.
|
|
17
20
|
*/
|
|
18
|
-
static forRoot(options
|
|
21
|
+
static forRoot(options?: ApcoreModuleOptions): DynamicModule;
|
|
19
22
|
/**
|
|
20
23
|
* Asynchronous configuration using the `useFactory` / `inject` pattern.
|
|
21
24
|
*
|
|
@@ -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;AAQpE,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;IAqChE;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa;CAkDtE"}
|