hono-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 +60 -13
- package/dist/a2a/apcore-a2a.service.d.ts.map +1 -1
- package/dist/a2a/apcore-a2a.service.js +3 -0
- package/dist/a2a/apcore-a2a.service.js.map +1 -1
- package/dist/bridge/binding-loader.d.ts.map +1 -1
- package/dist/bridge/binding-loader.js +14 -16
- package/dist/bridge/binding-loader.js.map +1 -1
- package/dist/cli/apcore-cli.service.d.ts +4 -1
- package/dist/cli/apcore-cli.service.d.ts.map +1 -1
- package/dist/cli/apcore-cli.service.js +102 -2
- package/dist/cli/apcore-cli.service.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +4 -1
- package/dist/cli.js.map +1 -1
- package/dist/core/apcore.d.ts +15 -48
- package/dist/core/apcore.d.ts.map +1 -1
- package/dist/core/apcore.js +29 -97
- package/dist/core/apcore.js.map +1 -1
- package/dist/core/apcore.node.d.ts +65 -0
- package/dist/core/apcore.node.d.ts.map +1 -0
- package/dist/core/apcore.node.js +120 -0
- package/dist/core/apcore.node.js.map +1 -0
- package/dist/core/executor.d.ts +10 -2
- package/dist/core/executor.d.ts.map +1 -1
- package/dist/core/executor.js +26 -1
- package/dist/core/executor.js.map +1 -1
- package/dist/core/middleware.d.ts +2 -2
- package/dist/core/middleware.d.ts.map +1 -1
- package/dist/core/middleware.js.map +1 -1
- package/dist/core/registry.d.ts +1 -1
- package/dist/core/registry.d.ts.map +1 -1
- package/dist/core/registry.js +4 -1
- package/dist/core/registry.js.map +1 -1
- package/dist/edge.d.ts +25 -0
- package/dist/edge.d.ts.map +1 -0
- package/dist/edge.js +54 -0
- package/dist/edge.js.map +1 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- 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 +3 -1
- package/dist/mcp/apcore-mcp.service.js.map +1 -1
- package/dist/output/yaml-writer.d.ts +7 -1
- package/dist/output/yaml-writer.d.ts.map +1 -1
- package/dist/output/yaml-writer.js +17 -4
- package/dist/output/yaml-writer.js.map +1 -1
- package/dist/scanners/hono-route-scanner.d.ts +2 -2
- package/dist/scanners/hono-route-scanner.d.ts.map +1 -1
- package/dist/scanners/hono-route-scanner.js +48 -6
- package/dist/scanners/hono-route-scanner.js.map +1 -1
- package/dist/tools/define-tool.d.ts +1 -1
- package/dist/tools/define-tool.d.ts.map +1 -1
- package/dist/tools/define-tool.js +4 -1
- package/dist/tools/define-tool.js.map +1 -1
- package/dist/types.d.ts +38 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/module-factory.d.ts.map +1 -1
- package/dist/utils/module-factory.js +53 -3
- package/dist/utils/module-factory.js.map +1 -1
- package/package.json +45 -11
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ you already have.
|
|
|
14
14
|
- **Annotation inference** — `GET` → readonly + cacheable, `PUT` → idempotent, `DELETE` → destructive (RFC 9110 safe-method semantics)
|
|
15
15
|
- **Multi-schema** — TypeBox, Zod 3, Zod 4, and plain JSON Schema, auto-detected through a priority chain
|
|
16
16
|
- **Context, ACL, and identity** — the `apcore()` middleware builds a per-request apcore `Context` with W3C trace propagation, so ACL rules govern your routes too
|
|
17
|
-
- **Runtime-agnostic core** —
|
|
17
|
+
- **Runtime-agnostic core** — the `browser` / `worker` / `workerd` export conditions resolve to `hono-apcore/edge`, a core-only entry with no MCP, CLI, A2A, YAML file I/O, or static `node:*` imports; CI bundles it on every push
|
|
18
18
|
- **CLI** — `hono-apcore scan | serve | export` works against a plain Hono app
|
|
19
19
|
- **YAML bindings** — register modules declaratively, without touching source
|
|
20
20
|
|
|
@@ -35,7 +35,10 @@ npm install @sinclair/typebox # TypeBox schemas (recommende
|
|
|
35
35
|
npm install zod # Zod schemas
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
**Requirements:** Node.js >=
|
|
38
|
+
**Requirements:** Node.js >= 20, Hono >= 4 (tested with Hono 4.13).
|
|
39
|
+
SDK minimums: apcore-js 0.32.3, apcore-toolkit 0.14.1; optional peers
|
|
40
|
+
apcore-mcp 0.23.4, apcore-cli 0.12.7, and apcore-a2a 0.8.5.
|
|
41
|
+
See [SDK upgrade notes](./docs/sdk-upgrade.md) for compatibility changes and new options.
|
|
39
42
|
|
|
40
43
|
## Quick start
|
|
41
44
|
|
|
@@ -132,7 +135,8 @@ const sendEmail = defineTool({
|
|
|
132
135
|
| --- | --- |
|
|
133
136
|
| `id` | Used verbatim. Otherwise `"<namespace>.<name>"`, with `name` snake-cased |
|
|
134
137
|
| `inputSchema` / `outputSchema` | TypeBox, Zod, or plain JSON Schema |
|
|
135
|
-
| `annotations` |
|
|
138
|
+
| `annotations` | Partial SDK annotations, including `discoverable` and `extra` |
|
|
139
|
+
| `metadata` / `display` / `version` | SDK metadata (including `async: true`), sparse surface display overlay, module version |
|
|
136
140
|
| `params` | Per-parameter prose merged into the input schema. JavaScript cannot read a function's leading comments at run time the way Python reads a docstring, so this is explicit |
|
|
137
141
|
| `handler` | `(inputs, context) => result`. A non-object result is wrapped as `{ result }` |
|
|
138
142
|
|
|
@@ -194,6 +198,8 @@ it.
|
|
|
194
198
|
|
|
195
199
|
```ts
|
|
196
200
|
createApcore({
|
|
201
|
+
config?: Config, // shared SDK configuration, including extension roots
|
|
202
|
+
executorOptions?: { strategy?, approvalHandler?, policy?, toggleState?, eventEmitter? },
|
|
197
203
|
extensionsDir?: string | null, // scanned by Registry.discover()
|
|
198
204
|
acl?: ACL, // enforced by the Executor on every call
|
|
199
205
|
middleware?: Middleware[], // apcore middleware installed on the Executor
|
|
@@ -220,6 +226,11 @@ createApcore({
|
|
|
220
226
|
| `toOpenaiTools(opts?)` | OpenAI-compatible function definitions |
|
|
221
227
|
| `close()` | Shut down the MCP and A2A surfaces |
|
|
222
228
|
|
|
229
|
+
The executor also exposes `callWithTrace(id, inputs?, context?, { strategy? })`
|
|
230
|
+
and `addStepMiddleware(middleware)`. Strategies can be SDK instances or registered
|
|
231
|
+
names. `config` is passed to both SDK objects; an explicitly configured
|
|
232
|
+
`extensions.root` or `extensions.roots` is discovered during `init()`.
|
|
233
|
+
|
|
223
234
|
### `apcore(instance | options, middlewareOptions?)`
|
|
224
235
|
|
|
225
236
|
Hono middleware that puts the instance and a per-request apcore `Context` on the
|
|
@@ -310,6 +321,7 @@ whichever the host app installs (or neither) is fine. Register your own with
|
|
|
310
321
|
Register modules without touching source:
|
|
311
322
|
|
|
312
323
|
```yaml
|
|
324
|
+
spec_version: "1.0"
|
|
313
325
|
bindings:
|
|
314
326
|
- module_id: email.send
|
|
315
327
|
target: EmailService.send
|
|
@@ -318,6 +330,10 @@ bindings:
|
|
|
318
330
|
type: object
|
|
319
331
|
properties:
|
|
320
332
|
to: { type: string }
|
|
333
|
+
output_schema:
|
|
334
|
+
type: object
|
|
335
|
+
properties:
|
|
336
|
+
sent: { type: boolean }
|
|
321
337
|
tags: [email, mutate]
|
|
322
338
|
annotations:
|
|
323
339
|
readonly: false
|
|
@@ -330,7 +346,11 @@ await ap.loadBindings('./bindings.yaml', resolverFromObjects({ EmailService: mai
|
|
|
330
346
|
```
|
|
331
347
|
|
|
332
348
|
Going the other way, `writeBindingsFile()` serialises scanned modules back out —
|
|
333
|
-
which is what `hono-apcore scan --format yaml` does.
|
|
349
|
+
which is what `hono-apcore scan --format yaml` does. The toolkit parser rejects
|
|
350
|
+
unknown document/entry keys and one-sided inline schema pairs. Supply both
|
|
351
|
+
schemas or neither; move custom entry data into `metadata`. YAML annotations
|
|
352
|
+
use snake_case (`requires_approval`); TypeScript tool annotations use camelCase
|
|
353
|
+
(`requiresApproval`).
|
|
334
354
|
|
|
335
355
|
### CLI
|
|
336
356
|
|
|
@@ -352,6 +372,10 @@ apcore. TypeScript entries need a loader:
|
|
|
352
372
|
npx tsx node_modules/.bin/hono-apcore scan ./src/app.ts
|
|
353
373
|
```
|
|
354
374
|
|
|
375
|
+
The optional `ap.cli.createProgram()` builds application module commands such
|
|
376
|
+
as `demo ping`, sharing the application's executor, ACL, middleware and approval
|
|
377
|
+
handler. It also adapts CLI `--trace` / `--strategy` calls to the core SDK.
|
|
378
|
+
|
|
355
379
|
### Configuration (`APCORE_*`)
|
|
356
380
|
|
|
357
381
|
The canonical settings every apcore integration implements, read from the
|
|
@@ -371,13 +395,28 @@ environment and overridable via `settings`:
|
|
|
371
395
|
| `APCORE_HOST` | str | `"0.0.0.0"` | Bind address when the transport is not stdio |
|
|
372
396
|
| `APCORE_PORT` | int | `8808` | Bind port when the transport is not stdio |
|
|
373
397
|
|
|
374
|
-
###
|
|
398
|
+
### Entry points and edge builds
|
|
399
|
+
|
|
400
|
+
`hono-apcore` ships two entries:
|
|
401
|
+
|
|
402
|
+
| Entry | Contents |
|
|
403
|
+
| --- | --- |
|
|
404
|
+
| `hono-apcore` (Node default) | Core, MCP, CLI, A2A, YAML bindings loaded from disk |
|
|
405
|
+
| `hono-apcore/edge` | Core only: tools, route scanning, context, schema, ACL, config |
|
|
375
406
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
407
|
+
Bundlers honouring the `browser`, `worker`, or `workerd` condition get
|
|
408
|
+
`hono-apcore/edge` from the bare `hono-apcore` specifier automatically. If your
|
|
409
|
+
bundler does not apply those conditions (some Deno/Bun setups), import the
|
|
410
|
+
subpath explicitly:
|
|
411
|
+
|
|
412
|
+
```ts
|
|
413
|
+
import { createApcore, defineTool } from 'hono-apcore/edge';
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
The edge entry deliberately excludes the optional MCP, CLI, and A2A surfaces,
|
|
417
|
+
file-backed YAML bindings, and the Node-only `Config` / `registerSysModules`
|
|
418
|
+
re-exports. The Node entry still re-exports all of them for backward
|
|
419
|
+
compatibility. Import peer symbols from their own packages:
|
|
381
420
|
|
|
382
421
|
```ts
|
|
383
422
|
import { JWTAuthenticator, getCurrentIdentity } from 'apcore-mcp';
|
|
@@ -385,9 +424,17 @@ import { createCli } from 'apcore-cli';
|
|
|
385
424
|
import { A2AClient } from 'apcore-a2a';
|
|
386
425
|
```
|
|
387
426
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
427
|
+
Surface subpaths are also available: `hono-apcore/mcp`, `hono-apcore/cli`, and
|
|
428
|
+
`hono-apcore/a2a`.
|
|
429
|
+
|
|
430
|
+
CI bundles both `dist/edge.js` and a consumer importing `hono-apcore` with
|
|
431
|
+
browser conditions, and fails if the entry chunk or any lazy chunk reaches
|
|
432
|
+
`node:http` / `node:https` or an optional apcore peer.
|
|
433
|
+
|
|
434
|
+
The edge entry's own chunk has no `node:*` imports. `apcore-js` still emits
|
|
435
|
+
lazy chunks for its Node-only registry discovery methods (`node:fs`,
|
|
436
|
+
`node:path`); those are never loaded unless you call `Registry.discover()` or
|
|
437
|
+
set `extensionsDir`.
|
|
391
438
|
|
|
392
439
|
## Examples
|
|
393
440
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apcore-a2a.service.d.ts","sourceRoot":"","sources":["../../src/a2a/apcore-a2a.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;;;;;;;;;;GAUG;AACH,qBAAa,gBAAgB;IAIzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,OAAO,CAAC,UAAU,CAAS;gBAGR,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,cAAc,EACxB,OAAO,GAAE,gBAAqB;IAGjD,0DAA0D;IAC1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{
|
|
|
71
71
|
metrics: opts.metrics,
|
|
72
72
|
logLevel: opts.logLevel,
|
|
73
73
|
shutdownTimeout: opts.shutdownTimeout,
|
|
74
|
+
pushNotifications: opts.pushNotifications,
|
|
75
|
+
sysModules: opts.sysModules,
|
|
76
|
+
discloseRefusalReason: opts.discloseRefusalReason,
|
|
74
77
|
};
|
|
75
78
|
for (const key of Object.keys(result)) {
|
|
76
79
|
if (result[key] === undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apcore-a2a.service.js","sourceRoot":"","sources":["../../src/a2a/apcore-a2a.service.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,gBAAgB;IAIR;IACA;IACA;IALX,UAAU,GAAG,KAAK,CAAC;IAE3B,YACmB,QAAwB,EACxB,QAAwB,EACxB,UAA4B,EAAE;QAF9B,aAAQ,GAAR,QAAQ,CAAgB;QACxB,aAAQ,GAAR,QAAQ,CAAgB;QACxB,YAAO,GAAP,OAAO,CAAuB;IAC9C,CAAC;IAEJ,0DAA0D;IAC1D,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,yDAAyD;IACzD,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACtB,KAA0D,CACzD,IAAI,CAAC,QAAQ,CAAC,GAAG,EACjB,IAAI,CAAC,YAAY,EAAE,CACpB,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,SAAqC;QACpD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;QAClD,OAAQ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C7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;SAClD,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS;gBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;QACpD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -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":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAM1D;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,MAAM,EAAE,MAAM,KACX,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC;AAEnF;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,cAAc,CAcnF;AAED;;;;;;GAMG;AACH,qBAAa,eAAe;IAExB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;gBADd,QAAQ,EAAE,cAAc,EACxB,aAAa,CAAC,EAAE,cAAc,YAAA;IAGjD;;;;;OAKG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAgCxD;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAIxD"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
1
|
import * as yaml from 'js-yaml';
|
|
3
|
-
import {
|
|
4
|
-
import { EMPTY_OBJECT_SCHEMA, normalizeResult,
|
|
2
|
+
import { parseBindingDocument } from 'apcore-toolkit/browser';
|
|
3
|
+
import { EMPTY_OBJECT_SCHEMA, normalizeResult, } from '../utils/module-factory.js';
|
|
5
4
|
/**
|
|
6
5
|
* Builds a resolver over a map of named service objects.
|
|
7
6
|
*
|
|
@@ -46,27 +45,25 @@ export class ApBindingLoader {
|
|
|
46
45
|
* @returns The module IDs that were registered.
|
|
47
46
|
*/
|
|
48
47
|
async loadFromString(content) {
|
|
49
|
-
const parsed =
|
|
50
|
-
|
|
48
|
+
const parsed = yaml.load(content);
|
|
49
|
+
// Preserve empty documents; validate non-empty documents with the SDK parser.
|
|
50
|
+
const empty = parsed == null || (typeof parsed === 'object' && !Array.isArray(parsed) && Object.keys(parsed).length === 0);
|
|
51
|
+
const bindings = parseBindingDocument(empty ? { bindings: [] } : parsed);
|
|
51
52
|
const ids = [];
|
|
52
53
|
for (const binding of bindings) {
|
|
53
|
-
const moduleId = binding.module_id;
|
|
54
54
|
const handler = this.resolveTarget?.(binding.target);
|
|
55
55
|
const execute = handler
|
|
56
56
|
? async (inputs, context) => normalizeResult(await handler(inputs, context))
|
|
57
57
|
: async () => ({
|
|
58
58
|
error: `No handler resolved for binding target "${binding.target}"`,
|
|
59
59
|
});
|
|
60
|
-
const scanned =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
outputSchema: binding.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
annotations: toModuleAnnotations(binding.annotations),
|
|
68
|
-
documentation: binding.documentation ?? null,
|
|
69
|
-
});
|
|
60
|
+
const scanned = {
|
|
61
|
+
...binding,
|
|
62
|
+
inputSchema: Object.keys(binding.inputSchema).length
|
|
63
|
+
? binding.inputSchema : { ...EMPTY_OBJECT_SCHEMA },
|
|
64
|
+
outputSchema: Object.keys(binding.outputSchema).length
|
|
65
|
+
? binding.outputSchema : { ...EMPTY_OBJECT_SCHEMA },
|
|
66
|
+
};
|
|
70
67
|
ids.push(await this.registry.registerScanned(scanned, execute));
|
|
71
68
|
}
|
|
72
69
|
return ids;
|
|
@@ -78,6 +75,7 @@ export class ApBindingLoader {
|
|
|
78
75
|
* @returns The module IDs that were registered.
|
|
79
76
|
*/
|
|
80
77
|
async loadFromFile(filePath) {
|
|
78
|
+
const { readFile } = await import('node:fs/promises');
|
|
81
79
|
return this.loadFromString(await readFile(filePath, 'utf-8'));
|
|
82
80
|
}
|
|
83
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-loader.js","sourceRoot":"","sources":["../../src/bridge/binding-loader.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"binding-loader.js","sourceRoot":"","sources":["../../src/bridge/binding-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EACL,mBAAmB,EACnB,eAAe,GAChB,MAAM,4BAA4B,CAAC;AAYpC;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA+B;IACjE,OAAO,CAAC,MAAc,EAAE,EAAE;QACxB,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,MAAM,CAAC,KAAK,CA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a,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAErD,MAAM,OAAO,GAAmB,OAAO;gBACrC,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAC5E,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;oBACX,KAAK,EAAE,2CAA2C,OAAO,CAAC,MAAM,GAAG;iBACpE,CAAC,CAAC;YAEP,MAAM,OAAO,GAAG;gBACd,GAAG,OAAO;gBACV,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM;oBAClD,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,mBAAmB,EAAE;gBACpD,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM;oBACpD,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,mBAAmB,EAAE;aACtD,CAAC;YAEF,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAClE,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,QAAgB;QACjC,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAChE,CAAC;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ApcoreExecutor } from '../core/executor.js';
|
|
1
2
|
import type { ApcoreRegistry } from '../core/registry.js';
|
|
2
3
|
import type { ApcoreCliOptions } from '../types.js';
|
|
3
4
|
/**
|
|
@@ -18,8 +19,10 @@ import type { ApcoreCliOptions } from '../types.js';
|
|
|
18
19
|
export declare class ApcoreCliService {
|
|
19
20
|
private readonly registry;
|
|
20
21
|
private readonly options;
|
|
22
|
+
private readonly executor?;
|
|
21
23
|
private configured;
|
|
22
|
-
|
|
24
|
+
private readonly callOptions;
|
|
25
|
+
constructor(registry: ApcoreRegistry, options?: ApcoreCliOptions, executor?: ApcoreExecutor | undefined);
|
|
23
26
|
/** Number of modules currently registered. */
|
|
24
27
|
get moduleCount(): number;
|
|
25
28
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apcore-cli.service.d.ts","sourceRoot":"","sources":["../../src/cli/apcore-cli.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apcore-cli.service.d.ts","sourceRoot":"","sources":["../../src/cli/apcore-cli.service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,gBAAgB;IASzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAV5B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAIvB;gBAGc,QAAQ,EAAE,cAAc,EACxB,OAAO,GAAE,gBAAqB,EAC9B,QAAQ,CAAC,EAAE,cAAc,YAAA;IAG5C,8CAA8C;IAC9C,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;;;;;;;OAQG;IACG,aAAa,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAsG7D;;;OAGG;IACG,gBAAgB,CACpB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAahB,yEAAyE;IACnE,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnD,iFAAiF;IAC3E,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrD;;;OAGG;YACW,kBAAkB;CAWjC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { CallbackApprovalHandler, Context as ApcoreContext, createApprovalResult, Executor } from 'apcore-js';
|
|
2
|
+
import { annotationsToDict } from 'apcore-toolkit/browser';
|
|
3
|
+
import { ApcoreExecutor } from '../core/executor.js';
|
|
1
4
|
/**
|
|
2
5
|
* Exposes `apcore-cli` for a Hono app: build a Commander program whose
|
|
3
6
|
* commands are the app's registered apcore modules.
|
|
@@ -16,10 +19,13 @@
|
|
|
16
19
|
export class ApcoreCliService {
|
|
17
20
|
registry;
|
|
18
21
|
options;
|
|
22
|
+
executor;
|
|
19
23
|
configured = false;
|
|
20
|
-
|
|
24
|
+
callOptions = new WeakMap();
|
|
25
|
+
constructor(registry, options = {}, executor) {
|
|
21
26
|
this.registry = registry;
|
|
22
27
|
this.options = options;
|
|
28
|
+
this.executor = executor;
|
|
23
29
|
}
|
|
24
30
|
/** Number of modules currently registered. */
|
|
25
31
|
get moduleCount() {
|
|
@@ -37,7 +43,101 @@ export class ApcoreCliService {
|
|
|
37
43
|
async createProgram(extensionsDir) {
|
|
38
44
|
const cli = await import('apcore-cli');
|
|
39
45
|
await this.applyModuleOptions();
|
|
40
|
-
|
|
46
|
+
const executor = this.executor ?? new ApcoreExecutor(new Executor({ registry: this.registry.raw }));
|
|
47
|
+
const raw = executor.raw;
|
|
48
|
+
let approvalOptions = { autoApprove: false, timeout: undefined };
|
|
49
|
+
// Child Contexts share data, so approval options follow nested SDK calls
|
|
50
|
+
// without adding integration keys to the public context or global state.
|
|
51
|
+
const callOptions = this.callOptions;
|
|
52
|
+
const cliContext = (context) => context ?? cli.buildCliContext() ?? ApcoreContext.create();
|
|
53
|
+
const runWithContext = async (id, context, run) => {
|
|
54
|
+
const ctx = cliContext(context);
|
|
55
|
+
callOptions.set(ctx.data, { ...approvalOptions, moduleId: id });
|
|
56
|
+
try {
|
|
57
|
+
return await run(ctx);
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
callOptions.delete(ctx.data);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const fallback = new CallbackApprovalHandler(async (request) => {
|
|
64
|
+
const options = callOptions.get(request.context.data);
|
|
65
|
+
// CLI's own annotation precheck has already completed for the root
|
|
66
|
+
// command. Nested calls and ACL/policy-only requirements still ask here.
|
|
67
|
+
if (options?.moduleId === request.moduleId &&
|
|
68
|
+
this.registry.getDefinition(request.moduleId)?.annotations?.requiresApproval) {
|
|
69
|
+
return createApprovalResult({ status: 'approved', approvedBy: 'cli_precheck' });
|
|
70
|
+
}
|
|
71
|
+
const terminal = new cli.CliApprovalHandler(options?.autoApprove, options?.timeout);
|
|
72
|
+
const result = await terminal.requestApproval({
|
|
73
|
+
module_id: request.moduleId,
|
|
74
|
+
requires_approval: true,
|
|
75
|
+
annotations: annotationsToDict(request.annotations),
|
|
76
|
+
});
|
|
77
|
+
return createApprovalResult({
|
|
78
|
+
status: result.status,
|
|
79
|
+
approvedBy: result.approved_by,
|
|
80
|
+
reason: result.reason,
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
// CLI 0.12 reads wire-format annotation keys. Keep that projection at
|
|
84
|
+
// the surface boundary; the shared Registry retains SDK annotations.
|
|
85
|
+
const registry = {
|
|
86
|
+
list: () => this.registry.list(),
|
|
87
|
+
getDefinition: (id) => {
|
|
88
|
+
const definition = this.registry.getDefinition(id);
|
|
89
|
+
return definition ? {
|
|
90
|
+
...definition,
|
|
91
|
+
annotations: annotationsToDict(definition.annotations) ?? undefined,
|
|
92
|
+
} : null;
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
// Adapt the CLI's two-argument stream and third-position trace options.
|
|
96
|
+
// Only supply its approval fallback when the host has no handler.
|
|
97
|
+
const cliExecutor = {
|
|
98
|
+
registry,
|
|
99
|
+
call: (id, input, context) => runWithContext(id, context, (ctx) => raw.call(id, input, ctx)),
|
|
100
|
+
validate: raw.validate.bind(raw),
|
|
101
|
+
stream: async function* (id, input) {
|
|
102
|
+
const ctx = cliContext();
|
|
103
|
+
callOptions.set(ctx.data, { ...approvalOptions, moduleId: id });
|
|
104
|
+
try {
|
|
105
|
+
yield* raw.stream(id, input, ctx);
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
callOptions.delete(ctx.data);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
callWithTrace: (id, input, options) => runWithContext(id, undefined, (ctx) => executor.callWithTrace(id, input, ctx, options)),
|
|
112
|
+
describePipeline: raw.describePipeline.bind(raw),
|
|
113
|
+
listStrategies: raw.listStrategies.bind(raw),
|
|
114
|
+
currentStrategy: raw.currentStrategy,
|
|
115
|
+
governanceState: raw.governanceState.bind(raw),
|
|
116
|
+
setAcl: raw.setAcl.bind(raw),
|
|
117
|
+
setApprovalHandler: () => {
|
|
118
|
+
if (!raw.governanceState().approvalHandlerConfigured)
|
|
119
|
+
raw.setApprovalHandler(fallback);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
const bridge = cliExecutor;
|
|
123
|
+
const program = cli.createCli({
|
|
124
|
+
extensionsDir: extensionsDir ?? this.options.extensionsDir,
|
|
125
|
+
progName: this.options.progName,
|
|
126
|
+
allOptions: this.options.verboseHelp ?? false,
|
|
127
|
+
registry,
|
|
128
|
+
executor: bridge,
|
|
129
|
+
});
|
|
130
|
+
program.hook('preAction', (_parent, command) => {
|
|
131
|
+
const options = command.opts();
|
|
132
|
+
approvalOptions = { autoApprove: options.yes === true, timeout: options.approvalTimeout };
|
|
133
|
+
});
|
|
134
|
+
const modules = new cli.GroupedModuleGroup(registry, bridge);
|
|
135
|
+
for (const name of modules.listCommands()) {
|
|
136
|
+
const command = modules.getCommand(name);
|
|
137
|
+
if (command)
|
|
138
|
+
program.addCommand(command);
|
|
139
|
+
}
|
|
140
|
+
return program;
|
|
41
141
|
}
|
|
42
142
|
/**
|
|
43
143
|
* Add `--help --man` support to an existing Commander program, so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apcore-cli.service.js","sourceRoot":"","sources":["../../src/cli/apcore-cli.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apcore-cli.service.js","sourceRoot":"","sources":["../../src/cli/apcore-cli.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,OAAO,IAAI,aAAa,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE9G,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,gBAAgB;IASR;IACA;IACA;IAVX,UAAU,GAAG,KAAK,CAAC;IACV,WAAW,GAAG,IAAI,OAAO,EAItC,CAAC;IAEL,YACmB,QAAwB,EACxB,UAA4B,EAAE,EAC9B,QAAyB;QAFzB,aAAQ,GAAR,QAAQ,CAAgB;QACxB,YAAO,GAAP,OAAO,CAAuB;QAC9B,aAAQ,GAAR,QAAQ,CAAiB;IACzC,CAAC;IAEJ,8CAA8C;IAC9C,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,aAAa,CAAC,aAAsB;QACxC,MAAM,GAAG,GA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MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;QAErC,GAAG,CAAC,gBAOL,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,SAAS,CAAC,CAAC;IAC3F,CAAC;IAED,yEAAyE;IACzE,KAAK,CAAC,UAAU,CAAC,GAAkB;QACjC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;QACtC,GAAG,CAAC,UAA2C,CAAC,GAAG,CAAC,CAAC;IACxD,CAAC;IAED,iFAAiF;IACjF,KAAK,CAAC,cAAc,CAAC,OAAgB;QACnC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;QACtC,GAAG,CAAC,cAA6C,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,kBAAkB;QAC9B,IAAI,IAAI,CAAC,UAAU;YAAE,OAAO;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QAEvB,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACvC,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YAC3C,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;CACF"}
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA4OA,6EAA6E;AAC7E,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,CAqDlF"}
|
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import { writeFile } from 'node:fs/promises';
|
|
|
4
4
|
import { pathToFileURL } from 'node:url';
|
|
5
5
|
import { resolve as resolvePath } from 'node:path';
|
|
6
6
|
import { formatModules } from 'apcore-toolkit';
|
|
7
|
-
import { HonoApcore } from './core/apcore.js';
|
|
7
|
+
import { HonoApcore } from './core/apcore.node.js';
|
|
8
8
|
import { HonoRouteScanner } from './scanners/hono-route-scanner.js';
|
|
9
9
|
import { renderBindingsYaml, writeBindingsFile } from './output/yaml-writer.js';
|
|
10
10
|
import { ApcoreMcpService } from './mcp/apcore-mcp.service.js';
|
|
@@ -156,6 +156,9 @@ async function commandServe(entry, values) {
|
|
|
156
156
|
const settings = loadSettings();
|
|
157
157
|
await instance.init(app ?? undefined, routeOptions(values, instance));
|
|
158
158
|
if (values['bindings']) {
|
|
159
|
+
if (typeof instance.loadBindings !== 'function') {
|
|
160
|
+
throw new Error('--bindings requires an app built from the Node entry (hono-apcore), not hono-apcore/edge.');
|
|
161
|
+
}
|
|
159
162
|
await instance.loadBindings(values['bindings']);
|
|
160
163
|
}
|
|
161
164
|
// A zero-config entry (a bare Hono app) still gets an MCP surface here, so
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,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,IAAI,IAAI,KAAK,CAAC;YAAE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC1C,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;QACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3F,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/core/apcore.d.ts
CHANGED
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
import { ApcoreRegistry } from './registry.js';
|
|
2
2
|
import { ApcoreExecutor } from './executor.js';
|
|
3
|
-
import { ApcoreMcpService } from '../mcp/apcore-mcp.service.js';
|
|
4
|
-
import { ApcoreCliService } from '../cli/apcore-cli.service.js';
|
|
5
|
-
import { ApcoreA2aService } from '../a2a/apcore-a2a.service.js';
|
|
6
3
|
import { HonoContextFactory } from '../context/hono-context.factory.js';
|
|
7
4
|
import type { HonoAppLike } from '../scanners/hono-route-scanner.js';
|
|
8
|
-
import type { TargetResolver } from '../bridge/binding-loader.js';
|
|
9
|
-
import type { MountableApp } from '../mcp/mount.js';
|
|
10
|
-
import type { McpApp } from '../mcp/apcore-mcp.service.js';
|
|
11
5
|
import type { ApcoreSettings } from '../config.js';
|
|
12
|
-
import type { ApToolDefinition,
|
|
6
|
+
import type { ApToolDefinition, HonoApcoreCoreOptions, RegisterMethodOptions, RegisterObjectOptions, RouteScanOptions } from '../types.js';
|
|
13
7
|
/**
|
|
14
|
-
*
|
|
8
|
+
* Core entry point for wiring apcore into a Hono app.
|
|
15
9
|
*
|
|
16
10
|
* Owns the apcore `Registry` and `Executor`, the tool/route registration
|
|
17
|
-
* surface, and
|
|
18
|
-
*
|
|
11
|
+
* surface, and route scanning. This is the implementation behind both package
|
|
12
|
+
* entries: the Node subclass adds MCP, CLI, A2A, and YAML bindings, while the
|
|
13
|
+
* edge entry exposes this class directly.
|
|
19
14
|
*
|
|
20
15
|
* @example
|
|
21
16
|
* ```ts
|
|
22
|
-
* const ap = createApcore({
|
|
23
|
-
* tools: [listTodos, addTodo],
|
|
24
|
-
* mcp: { explorer: true, allowExecute: true },
|
|
25
|
-
* });
|
|
17
|
+
* const ap = createApcore({ tools: [listTodos, addTodo] });
|
|
26
18
|
*
|
|
27
19
|
* app.use('*', apcore(ap));
|
|
28
20
|
* await ap.init(app); // register tools, scan routes
|
|
29
|
-
* await ap.mountMcp(app); // serve MCP on the same port
|
|
30
21
|
* ```
|
|
31
22
|
*/
|
|
32
23
|
export declare class HonoApcore {
|
|
33
|
-
private readonly options;
|
|
34
24
|
/** Canonical `APCORE_*` settings, environment merged with `options.settings`. */
|
|
35
25
|
readonly settings: ApcoreSettings;
|
|
36
26
|
/** Registry wrapper — register and inspect modules. */
|
|
@@ -39,12 +29,10 @@ export declare class HonoApcore {
|
|
|
39
29
|
readonly executor: ApcoreExecutor;
|
|
40
30
|
/** Builds per-request apcore `Context` objects from Hono requests. */
|
|
41
31
|
readonly contextFactory: HonoContextFactory;
|
|
42
|
-
|
|
43
|
-
private readonly _cli;
|
|
44
|
-
private readonly _a2a;
|
|
32
|
+
protected readonly options: HonoApcoreCoreOptions;
|
|
45
33
|
private readonly scanner;
|
|
46
34
|
private initPromise;
|
|
47
|
-
constructor(options?:
|
|
35
|
+
constructor(options?: HonoApcoreCoreOptions);
|
|
48
36
|
/**
|
|
49
37
|
* The route-scan options this instance would use: the `APCORE_*` settings
|
|
50
38
|
* with the constructor's `routes` block layered on top.
|
|
@@ -53,12 +41,6 @@ export declare class HonoApcore {
|
|
|
53
41
|
* produces the same module set the app itself registers.
|
|
54
42
|
*/
|
|
55
43
|
get routeOptions(): RouteScanOptions;
|
|
56
|
-
/** The MCP service, or `null` when `options.mcp` was omitted. */
|
|
57
|
-
get mcp(): ApcoreMcpService | null;
|
|
58
|
-
/** The CLI service, or `null` when `options.cli` was omitted. */
|
|
59
|
-
get cli(): ApcoreCliService | null;
|
|
60
|
-
/** The A2A service, or `null` when `options.a2a` was omitted. */
|
|
61
|
-
get a2a(): ApcoreA2aService | null;
|
|
62
44
|
/** Register one tool definition. Returns its module ID. */
|
|
63
45
|
registerTool(tool: ApToolDefinition): Promise<string>;
|
|
64
46
|
/** Register several tool definitions. Returns their module IDs. */
|
|
@@ -78,13 +60,6 @@ export declare class HonoApcore {
|
|
|
78
60
|
* @returns The module IDs that were registered.
|
|
79
61
|
*/
|
|
80
62
|
scanRoutes(app: HonoAppLike, options?: RouteScanOptions): Promise<string[]>;
|
|
81
|
-
/**
|
|
82
|
-
* Load a YAML bindings file and register its entries.
|
|
83
|
-
*
|
|
84
|
-
* @param filePath - Path to the YAML file. Defaults to `options.bindings`.
|
|
85
|
-
* @param resolveTarget - Resolves each entry's `target` to a live handler.
|
|
86
|
-
*/
|
|
87
|
-
loadBindings(filePath?: string, resolveTarget?: TargetResolver): Promise<string[]>;
|
|
88
63
|
/**
|
|
89
64
|
* Discover extensions, register the configured tools and bindings, scan the
|
|
90
65
|
* app's routes, and start any surface configured to run standalone.
|
|
@@ -105,25 +80,17 @@ export declare class HonoApcore {
|
|
|
105
80
|
private mergeRouteOptions;
|
|
106
81
|
private runInit;
|
|
107
82
|
/**
|
|
108
|
-
*
|
|
109
|
-
* MCP. Node runtime only — see {@link mountMcp}.
|
|
83
|
+
* Register file-backed bindings before routes are scanned.
|
|
110
84
|
*
|
|
111
|
-
*
|
|
85
|
+
* The core entry leaves this empty; the Node entry loads YAML from disk.
|
|
112
86
|
*/
|
|
113
|
-
|
|
87
|
+
protected loadConfiguredBindings(): Promise<void>;
|
|
114
88
|
/**
|
|
115
|
-
*
|
|
89
|
+
* Start configured standalone surfaces after every module is registered.
|
|
116
90
|
*
|
|
117
|
-
*
|
|
91
|
+
* The core entry leaves this empty; the Node entry starts MCP, CLI, and A2A.
|
|
118
92
|
*/
|
|
119
|
-
|
|
120
|
-
embedAnnotations?: boolean;
|
|
121
|
-
strict?: boolean;
|
|
122
|
-
tags?: string[];
|
|
123
|
-
prefix?: string;
|
|
124
|
-
}): Promise<unknown[]>;
|
|
125
|
-
/** Shut down the MCP and A2A surfaces. */
|
|
126
|
-
close(): Promise<void>;
|
|
93
|
+
protected startSurfaces(): Promise<void>;
|
|
127
94
|
}
|
|
128
95
|
/**
|
|
129
96
|
* Create a {@link HonoApcore} instance.
|
|
@@ -131,5 +98,5 @@ export declare class HonoApcore {
|
|
|
131
98
|
* Sugar for `new HonoApcore(options)`, matching the `createX()` style the
|
|
132
99
|
* Hono ecosystem uses.
|
|
133
100
|
*/
|
|
134
|
-
export declare function createApcore(options?:
|
|
101
|
+
export declare function createApcore(options?: HonoApcoreCoreOptions): HonoApcore;
|
|
135
102
|
//# sourceMappingURL=apcore.d.ts.map
|