@lushly-dev/afd-server 2.2.1 → 2.4.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 +468 -6
- package/dist/approval-crypto.d.ts +26 -4
- package/dist/approval-crypto.d.ts.map +1 -1
- package/dist/approval-crypto.js +90 -7
- package/dist/approval-crypto.js.map +1 -1
- package/dist/approval-relay.d.ts +5 -5
- package/dist/approval-relay.d.ts.map +1 -1
- package/dist/approval.d.ts +6 -1
- package/dist/approval.d.ts.map +1 -1
- package/dist/approval.js +43 -32
- package/dist/approval.js.map +1 -1
- package/dist/bootstrap/afd-context.d.ts +2 -27
- package/dist/bootstrap/afd-context.d.ts.map +1 -1
- package/dist/bootstrap/afd-context.js +6 -36
- package/dist/bootstrap/afd-context.js.map +1 -1
- package/dist/bootstrap/afd-help.d.ts +24 -2
- package/dist/bootstrap/afd-help.d.ts.map +1 -1
- package/dist/bootstrap/afd-help.js +17 -2
- package/dist/bootstrap/afd-help.js.map +1 -1
- package/dist/bootstrap/described-command.d.ts +1 -0
- package/dist/bootstrap/described-command.d.ts.map +1 -1
- package/dist/bootstrap/described-command.js.map +1 -1
- package/dist/bootstrap/registry.d.ts +13 -0
- package/dist/bootstrap/registry.d.ts.map +1 -1
- package/dist/bootstrap/registry.js +30 -1
- package/dist/bootstrap/registry.js.map +1 -1
- package/dist/command-allow.d.ts +31 -0
- package/dist/command-allow.d.ts.map +1 -0
- package/dist/command-allow.js +55 -0
- package/dist/command-allow.js.map +1 -0
- package/dist/command-names.d.ts +17 -0
- package/dist/command-names.d.ts.map +1 -1
- package/dist/command-names.js +55 -0
- package/dist/command-names.js.map +1 -1
- package/dist/command-routing.d.ts +10 -3
- package/dist/command-routing.d.ts.map +1 -1
- package/dist/command-routing.js +18 -7
- package/dist/command-routing.js.map +1 -1
- package/dist/confirmation-gate.d.ts +32 -0
- package/dist/confirmation-gate.d.ts.map +1 -0
- package/dist/confirmation-gate.js +140 -0
- package/dist/confirmation-gate.js.map +1 -0
- package/dist/confirmations.d.ts +15 -23
- package/dist/confirmations.d.ts.map +1 -1
- package/dist/confirmations.js +8 -127
- package/dist/confirmations.js.map +1 -1
- package/dist/context-fields-describe.d.ts +18 -0
- package/dist/context-fields-describe.d.ts.map +1 -0
- package/dist/context-fields-describe.js +17 -0
- package/dist/context-fields-describe.js.map +1 -0
- package/dist/context-fields.d.ts +50 -0
- package/dist/context-fields.d.ts.map +1 -0
- package/dist/context-fields.js +146 -0
- package/dist/context-fields.js.map +1 -0
- package/dist/context-scope.d.ts +29 -2
- package/dist/context-scope.d.ts.map +1 -1
- package/dist/context-scope.js +37 -1
- package/dist/context-scope.js.map +1 -1
- package/dist/credentials.d.ts +17 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +16 -0
- package/dist/credentials.js.map +1 -0
- package/dist/define-core.d.ts +213 -0
- package/dist/define-core.d.ts.map +1 -0
- package/dist/define-core.js +161 -0
- package/dist/define-core.js.map +1 -0
- package/dist/define.d.ts +13 -8
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +13 -8
- package/dist/define.js.map +1 -1
- package/dist/direct-registry.d.ts +154 -7
- package/dist/direct-registry.d.ts.map +1 -1
- package/dist/direct-registry.js +111 -13
- package/dist/direct-registry.js.map +1 -1
- package/dist/direct-tool-surface.d.ts +66 -0
- package/dist/direct-tool-surface.d.ts.map +1 -0
- package/dist/direct-tool-surface.js +162 -0
- package/dist/direct-tool-surface.js.map +1 -0
- package/dist/direct.d.ts +68 -0
- package/dist/direct.d.ts.map +1 -0
- package/dist/direct.js +66 -0
- package/dist/direct.js.map +1 -0
- package/dist/execution.d.ts +11 -1
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +18 -4
- package/dist/execution.js.map +1 -1
- package/dist/frontmatter.d.ts +16 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/frontmatter.js +111 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/http-handler.d.ts +11 -2
- package/dist/http-handler.d.ts.map +1 -1
- package/dist/http-handler.js +46 -15
- package/dist/http-handler.js.map +1 -1
- package/dist/http-security.d.ts.map +1 -1
- package/dist/http-security.js.map +1 -1
- package/dist/http-sessions.d.ts +12 -4
- package/dist/http-sessions.d.ts.map +1 -1
- package/dist/http-sessions.js +4 -4
- package/dist/http-sessions.js.map +1 -1
- package/dist/http-sse.js.map +1 -1
- package/dist/index.d.ts +16 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/issue-message.d.ts +20 -0
- package/dist/issue-message.d.ts.map +1 -0
- package/dist/issue-message.js +55 -0
- package/dist/issue-message.js.map +1 -0
- package/dist/journal-replay.d.ts +7 -0
- package/dist/journal-replay.d.ts.map +1 -1
- package/dist/journal-replay.js +18 -1
- package/dist/journal-replay.js.map +1 -1
- package/dist/journal.d.ts +9 -1
- package/dist/journal.d.ts.map +1 -1
- package/dist/journal.js +44 -1
- package/dist/journal.js.map +1 -1
- package/dist/json-rpc.d.ts +2 -2
- package/dist/json-rpc.d.ts.map +1 -1
- package/dist/json-rpc.js.map +1 -1
- package/dist/json-schema.d.ts +30 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +25 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/lazy-tools.d.ts +3 -0
- package/dist/lazy-tools.d.ts.map +1 -1
- package/dist/lazy-tools.js +2 -0
- package/dist/lazy-tools.js.map +1 -1
- package/dist/mcp-auth-bearer.d.ts +23 -0
- package/dist/mcp-auth-bearer.d.ts.map +1 -0
- package/dist/mcp-auth-bearer.js +50 -0
- package/dist/mcp-auth-bearer.js.map +1 -0
- package/dist/mcp-auth-jwt.d.ts +178 -0
- package/dist/mcp-auth-jwt.d.ts.map +1 -0
- package/dist/mcp-auth-jwt.js +365 -0
- package/dist/mcp-auth-jwt.js.map +1 -0
- package/dist/mcp-auth-resource.d.ts +74 -0
- package/dist/mcp-auth-resource.d.ts.map +1 -0
- package/dist/mcp-auth-resource.js +196 -0
- package/dist/mcp-auth-resource.js.map +1 -0
- package/dist/mcp-auth-rules.d.ts +135 -0
- package/dist/mcp-auth-rules.d.ts.map +1 -0
- package/dist/mcp-auth-rules.js +306 -0
- package/dist/mcp-auth-rules.js.map +1 -0
- package/dist/mcp-auth.d.ts +81 -0
- package/dist/mcp-auth.d.ts.map +1 -0
- package/dist/mcp-auth.js +256 -0
- package/dist/mcp-auth.js.map +1 -0
- package/dist/mcp-modern.d.ts +29 -5
- package/dist/mcp-modern.d.ts.map +1 -1
- package/dist/mcp-modern.js +99 -19
- package/dist/mcp-modern.js.map +1 -1
- package/dist/meta-argument.d.ts +42 -0
- package/dist/meta-argument.d.ts.map +1 -0
- package/dist/meta-argument.js +102 -0
- package/dist/meta-argument.js.map +1 -0
- package/dist/meta-keys.d.ts +29 -0
- package/dist/meta-keys.d.ts.map +1 -0
- package/dist/meta-keys.js +90 -0
- package/dist/meta-keys.js.map +1 -0
- package/dist/meta-tools.d.ts +8 -1
- package/dist/meta-tools.d.ts.map +1 -1
- package/dist/meta-tools.js +17 -7
- package/dist/meta-tools.js.map +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +0 -1
- package/dist/middleware.js.map +1 -1
- package/dist/patterns.d.ts +46 -0
- package/dist/patterns.d.ts.map +1 -0
- package/dist/patterns.js +38 -0
- package/dist/patterns.js.map +1 -0
- package/dist/principal-binding.d.ts +42 -0
- package/dist/principal-binding.d.ts.map +1 -0
- package/dist/principal-binding.js +70 -0
- package/dist/principal-binding.js.map +1 -0
- package/dist/request-context.d.ts +7 -1
- package/dist/request-context.d.ts.map +1 -1
- package/dist/request-context.js +14 -3
- package/dist/request-context.js.map +1 -1
- package/dist/resources.d.ts +122 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +256 -0
- package/dist/resources.js.map +1 -0
- package/dist/schema.d.ts +7 -171
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +10 -135
- package/dist/schema.js.map +1 -1
- package/dist/server-types.d.ts +94 -7
- package/dist/server-types.d.ts.map +1 -1
- package/dist/server-types.js +2 -0
- package/dist/server-types.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +45 -31
- package/dist/server.js.map +1 -1
- package/dist/skills.d.ts +95 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +340 -0
- package/dist/skills.js.map +1 -0
- package/dist/strict-json.d.ts +17 -0
- package/dist/strict-json.d.ts.map +1 -0
- package/dist/strict-json.js +93 -0
- package/dist/strict-json.js.map +1 -0
- package/dist/tool-router.d.ts +13 -1
- package/dist/tool-router.d.ts.map +1 -1
- package/dist/tool-router.js +44 -10
- package/dist/tool-router.js.map +1 -1
- package/dist/tools.d.ts +10 -5
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +48 -22
- package/dist/tools.js.map +1 -1
- package/dist/validation.d.ts +6 -45
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +25 -58
- package/dist/validation.js.map +1 -1
- package/dist/verified-credentials.d.ts +34 -0
- package/dist/verified-credentials.d.ts.map +1 -0
- package/dist/verified-credentials.js +51 -0
- package/dist/verified-credentials.js.map +1 -0
- package/package.json +18 -6
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The command definition every path ends in, with no JSON Schema conversion.
|
|
3
|
+
*
|
|
4
|
+
* Module-graph rule: nothing here, and nothing `createDirectRegistry` or `createJournalMiddleware`
|
|
5
|
+
* reach, imports `zod` at run time, only `zod/v4/core`, so a host on Zod Mini loads neither classic
|
|
6
|
+
* Zod nor `toJSONSchema`. `entry-points.test.ts` enforces it. `defineCommand`, in `schema.ts`, adds
|
|
7
|
+
* the conversion for everyone else.
|
|
8
|
+
*/
|
|
9
|
+
import { validateCommandName } from '@lushly-dev/afd-core/commands';
|
|
10
|
+
import { validateInput } from './validation.js';
|
|
11
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
12
|
+
// MAIN FUNCTION
|
|
13
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
14
|
+
/**
|
|
15
|
+
* Define a command whose JSON Schema you already have, so nothing converts it at run time. The
|
|
16
|
+
* lean path: it takes a classic or a Zod Mini schema, and a host that defines every command this
|
|
17
|
+
* way bundles neither classic Zod nor `toJSONSchema`.
|
|
18
|
+
*
|
|
19
|
+
* `jsonSchema` is what every surface shows, unless `advertisedInputSchema` replaces it, and `input`
|
|
20
|
+
* validates every call. Nothing compares the two, so hold them equal in a test, against
|
|
21
|
+
* `zodToJsonSchema(schema)`. `output` is not converted either: pass `outputJsonSchema` to advertise it.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import * as z from 'zod/mini';
|
|
26
|
+
* import { defineCommandWithSchema, success } from '@lushly-dev/afd-server/define';
|
|
27
|
+
*
|
|
28
|
+
* const panelOpen = defineCommandWithSchema({
|
|
29
|
+
* name: 'panel-open',
|
|
30
|
+
* description: 'Open a panel',
|
|
31
|
+
* input: z.object({ id: z.string() }),
|
|
32
|
+
* jsonSchema: {
|
|
33
|
+
* type: 'object',
|
|
34
|
+
* properties: { id: { type: 'string' } },
|
|
35
|
+
* required: ['id'],
|
|
36
|
+
* },
|
|
37
|
+
* async handler(input) {
|
|
38
|
+
* return success({ id: input.id, open: true });
|
|
39
|
+
* },
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function defineCommandWithSchema(options) {
|
|
44
|
+
const nameCheck = validateCommandName(options.name);
|
|
45
|
+
if (!nameCheck.valid) {
|
|
46
|
+
console.warn(`[AFD] ${nameCheck.reason}`);
|
|
47
|
+
}
|
|
48
|
+
const { advertisedInputSchema, outputJsonSchema } = options;
|
|
49
|
+
if (advertisedInputSchema !== undefined &&
|
|
50
|
+
!(isJsonObject(advertisedInputSchema) && advertisedInputSchema.type === 'object')) {
|
|
51
|
+
throw new Error(`command "${options.name}": advertisedInputSchema must be a JSON Schema object whose type is "object"`);
|
|
52
|
+
}
|
|
53
|
+
if (!isJsonObject(options.jsonSchema)) {
|
|
54
|
+
throw new Error(`command "${options.name}": jsonSchema must be an object`);
|
|
55
|
+
}
|
|
56
|
+
// An advertised schema replaces the given one on every surface; the Zod schema still validates.
|
|
57
|
+
const jsonSchema = advertisedInputSchema ?? options.jsonSchema;
|
|
58
|
+
// Build tags with automatic handoff tags if handoff is enabled
|
|
59
|
+
const tags = buildHandoffTags(options.tags, options.handoff, options.handoffProtocol);
|
|
60
|
+
// Validate examples against input schema at define-time
|
|
61
|
+
if (options.examples) {
|
|
62
|
+
for (const example of options.examples) {
|
|
63
|
+
const parsed = validateInput(options.input, example.input);
|
|
64
|
+
if (!parsed.success) {
|
|
65
|
+
const issues = parsed.errors.map((e) => `${e.path}: ${e.message}`).join(', ');
|
|
66
|
+
throw new Error(`Example "${example.title}" for command "${options.name}" fails schema validation: ${issues}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const { name, description, handler, examples, contexts, toolMeta } = options;
|
|
71
|
+
const metadata = {
|
|
72
|
+
title: options.title,
|
|
73
|
+
category: options.category,
|
|
74
|
+
mutation: options.mutation,
|
|
75
|
+
version: options.version,
|
|
76
|
+
tags,
|
|
77
|
+
requires: options.requires,
|
|
78
|
+
executionTime: options.executionTime,
|
|
79
|
+
errors: options.errors,
|
|
80
|
+
handoff: options.handoff,
|
|
81
|
+
handoffProtocol: options.handoffProtocol,
|
|
82
|
+
destructive: options.destructive,
|
|
83
|
+
confirmPrompt: options.confirmPrompt,
|
|
84
|
+
undoable: options.undoable,
|
|
85
|
+
approval: options.approval,
|
|
86
|
+
expose: options.expose,
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
name,
|
|
90
|
+
description,
|
|
91
|
+
inputSchema: options.input,
|
|
92
|
+
jsonSchema,
|
|
93
|
+
handler,
|
|
94
|
+
...metadata,
|
|
95
|
+
examples,
|
|
96
|
+
outputSchema: options.output,
|
|
97
|
+
outputJsonSchema,
|
|
98
|
+
contexts,
|
|
99
|
+
toolMeta,
|
|
100
|
+
toCommandDefinition() {
|
|
101
|
+
return {
|
|
102
|
+
name,
|
|
103
|
+
description,
|
|
104
|
+
...metadata,
|
|
105
|
+
// Examples are raw inputs (before defaults and transforms); core types them by the
|
|
106
|
+
// handler input, which differs only for schemas with defaults or transforms.
|
|
107
|
+
examples: examples,
|
|
108
|
+
contexts,
|
|
109
|
+
toolMeta,
|
|
110
|
+
parameters: jsonSchemaToParameters(jsonSchema),
|
|
111
|
+
returns: outputJsonSchema,
|
|
112
|
+
handler: handler,
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function isJsonObject(value) {
|
|
118
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Build tags array with automatic handoff tags if handoff is enabled.
|
|
122
|
+
* Adds 'handoff' tag and optionally 'handoff:{protocol}' tag.
|
|
123
|
+
*/
|
|
124
|
+
function buildHandoffTags(existingTags, handoff, handoffProtocol) {
|
|
125
|
+
if (!handoff) {
|
|
126
|
+
return existingTags;
|
|
127
|
+
}
|
|
128
|
+
const tags = new Set(existingTags ?? []);
|
|
129
|
+
tags.add('handoff');
|
|
130
|
+
if (handoffProtocol) {
|
|
131
|
+
tags.add(`handoff:${handoffProtocol}`);
|
|
132
|
+
}
|
|
133
|
+
return Array.from(tags);
|
|
134
|
+
}
|
|
135
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
136
|
+
// SCHEMA CONVERSION HELPERS
|
|
137
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
138
|
+
/**
|
|
139
|
+
* Convert JSON Schema to CommandParameter array for @lushly-dev/afd-core compatibility.
|
|
140
|
+
*/
|
|
141
|
+
export function jsonSchemaToParameters(schema) {
|
|
142
|
+
const parameters = [];
|
|
143
|
+
if (schema.type === 'object' && schema.properties) {
|
|
144
|
+
// Handle required - it might be an array or undefined
|
|
145
|
+
const requiredFields = Array.isArray(schema.required) ? schema.required : [];
|
|
146
|
+
for (const [name, propSchema] of Object.entries(schema.properties)) {
|
|
147
|
+
const prop = propSchema;
|
|
148
|
+
parameters.push({
|
|
149
|
+
name,
|
|
150
|
+
type: prop.type ?? 'string',
|
|
151
|
+
description: prop.description ?? `Parameter: ${name}`,
|
|
152
|
+
required: requiredFields.includes(name),
|
|
153
|
+
default: prop.default,
|
|
154
|
+
enum: prop.enum,
|
|
155
|
+
schema: prop,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return parameters;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=define-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-core.js","sourceRoot":"","sources":["../src/define-core.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGpE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA0NhD,kFAAkF;AAClF,gBAAgB;AAChB,kFAAkF;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,uBAAuB,CACtC,OAKC;IAED,MAAM,SAAS,GAAG,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;IAC5D,IACC,qBAAqB,KAAK,SAAS;QACnC,CAAC,CAAC,YAAY,CAAC,qBAAqB,CAAC,IAAI,qBAAqB,CAAC,IAAI,KAAK,QAAQ,CAAC,EAChF,CA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OAAO,UAAU,CAAC;AACnB,CAAC"}
|
package/dist/define.d.ts
CHANGED
|
@@ -8,14 +8,17 @@
|
|
|
8
8
|
* packages and in-app agents.
|
|
9
9
|
*
|
|
10
10
|
* The root entry (`@lushly-dev/afd-server`) still exports everything below,
|
|
11
|
-
* plus `createMcpServer
|
|
12
|
-
*
|
|
11
|
+
* plus `createMcpServer` and `createMcpHandler`, which need Node.js. The
|
|
12
|
+
* `/direct` entry adds `createDirectRegistry`, the journal and the middleware
|
|
13
|
+
* that run without Node.js.
|
|
13
14
|
*
|
|
14
|
-
* Module-graph rule: this file and `schema.ts`
|
|
15
|
-
* `@lushly-dev/afd-core` only through its
|
|
16
|
-
* (`/commands`, `/result`)
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* Module-graph rule: this file, `define-core.ts` and `schema.ts` take runtime
|
|
16
|
+
* values from `@lushly-dev/afd-core` only through its narrow subpaths
|
|
17
|
+
* (`/commands`, `/result`), so the entry stays the smallest way to define
|
|
18
|
+
* commands. `defineCommandWithSchema` also keeps `zod` and `toJSONSchema` out: a
|
|
19
|
+
* host on Zod Mini that uses only it loads `zod/v4/core` alone.
|
|
20
|
+
* `entry-points.test.ts` bundles this entry with esbuild for the browser to
|
|
21
|
+
* enforce both.
|
|
19
22
|
*
|
|
20
23
|
* @example
|
|
21
24
|
* ```typescript
|
|
@@ -38,5 +41,7 @@
|
|
|
38
41
|
export type { ApprovalDecision, ApprovalPolicy, CommandContext, CommandError, CommandExample, CommandResult, ExposeOptions, JsonSchema, } from '@lushly-dev/afd-core';
|
|
39
42
|
export { defaultExpose } from '@lushly-dev/afd-core/commands';
|
|
40
43
|
export { error, failure, isFailure, isSuccess, success } from '@lushly-dev/afd-core/result';
|
|
41
|
-
export {
|
|
44
|
+
export { defineCommandWithSchema, type ZodCommandDefinition, type ZodCommandOptions, } from './define-core.js';
|
|
45
|
+
export { zodToJsonSchema } from './json-schema.js';
|
|
46
|
+
export { defineCommand, getRequiredFields, isObjectSchema } from './schema.js';
|
|
42
47
|
//# sourceMappingURL=define.d.ts.map
|
package/dist/define.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAIH,YAAY,EACX,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,UAAU,GACV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EACN,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/define.js
CHANGED
|
@@ -8,14 +8,17 @@
|
|
|
8
8
|
* packages and in-app agents.
|
|
9
9
|
*
|
|
10
10
|
* The root entry (`@lushly-dev/afd-server`) still exports everything below,
|
|
11
|
-
* plus `createMcpServer
|
|
12
|
-
*
|
|
11
|
+
* plus `createMcpServer` and `createMcpHandler`, which need Node.js. The
|
|
12
|
+
* `/direct` entry adds `createDirectRegistry`, the journal and the middleware
|
|
13
|
+
* that run without Node.js.
|
|
13
14
|
*
|
|
14
|
-
* Module-graph rule: this file and `schema.ts`
|
|
15
|
-
* `@lushly-dev/afd-core` only through its
|
|
16
|
-
* (`/commands`, `/result`)
|
|
17
|
-
*
|
|
18
|
-
*
|
|
15
|
+
* Module-graph rule: this file, `define-core.ts` and `schema.ts` take runtime
|
|
16
|
+
* values from `@lushly-dev/afd-core` only through its narrow subpaths
|
|
17
|
+
* (`/commands`, `/result`), so the entry stays the smallest way to define
|
|
18
|
+
* commands. `defineCommandWithSchema` also keeps `zod` and `toJSONSchema` out: a
|
|
19
|
+
* host on Zod Mini that uses only it loads `zod/v4/core` alone.
|
|
20
|
+
* `entry-points.test.ts` bundles this entry with esbuild for the browser to
|
|
21
|
+
* enforce both.
|
|
19
22
|
*
|
|
20
23
|
* @example
|
|
21
24
|
* ```typescript
|
|
@@ -37,5 +40,7 @@
|
|
|
37
40
|
*/
|
|
38
41
|
export { defaultExpose } from '@lushly-dev/afd-core/commands';
|
|
39
42
|
export { error, failure, isFailure, isSuccess, success } from '@lushly-dev/afd-core/result';
|
|
40
|
-
export {
|
|
43
|
+
export { defineCommandWithSchema, } from './define-core.js';
|
|
44
|
+
export { zodToJsonSchema } from './json-schema.js';
|
|
45
|
+
export { defineCommand, getRequiredFields, isObjectSchema } from './schema.js';
|
|
41
46
|
//# sourceMappingURL=define.js.map
|
package/dist/define.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAcH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EACN,uBAAuB,GAGvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -5,9 +5,23 @@
|
|
|
5
5
|
* `createMcpServer()`: Zod input validation, middleware, error sanitization and
|
|
6
6
|
* `onCommand`/`onError` hooks. It only lists and runs the commands exposed to
|
|
7
7
|
* one interface, `'agent'` by default.
|
|
8
|
+
*
|
|
9
|
+
* With `contexts`, each call names its active context in the `activeContext` call option, as an
|
|
10
|
+
* MCP 2026-07-28 request names it in `_meta["dev.afd/context"]`; the registry keeps no context
|
|
11
|
+
* state between calls. With `tools: createDirectToolSurface()`, it also lists and routes the MCP
|
|
12
|
+
* tool surface: the module-graph rule below keeps that surface out of a registry that does not
|
|
13
|
+
* ask for it. The `allow` call option, which `DirectClient` passes from its own `allow`, narrows
|
|
14
|
+
* one call to the commands a trusted predicate permits, at every level the call reaches.
|
|
15
|
+
*
|
|
16
|
+
* Module-graph rule: this module imports only types from the tool router, the tool list, the
|
|
17
|
+
* meta-tools and `bootstrap/`, so a registry built without `tools` does not bundle them.
|
|
18
|
+
* `entry-points.test.ts` holds it to that with a size budget.
|
|
8
19
|
*/
|
|
9
|
-
import type { Actor, Clock, CommandContext, CommandMiddleware, CommandResult, ExposeOptions, JsonSchema, RandomSource } from '@lushly-dev/afd-core';
|
|
20
|
+
import type { Actor, BatchRequest, BatchResult, Clock, CommandContext, CommandError, CommandMiddleware, CommandResult, ExposeOptions, JsonSchema, PipelineRequest, PipelineResult, RandomSource } from '@lushly-dev/afd-core';
|
|
21
|
+
import { type ContextField } from './context-fields.js';
|
|
22
|
+
import type { McpToolDefinition } from './meta-tools.js';
|
|
10
23
|
import type { ZodCommandDefinition } from './schema.js';
|
|
24
|
+
import type { ContextConfig, ToolStrategy } from './server-types.js';
|
|
11
25
|
/** An interface a command can be exposed to (`palette`, `mcp`, `agent`, `cli`). */
|
|
12
26
|
export type ExposeInterface = keyof ExposeOptions;
|
|
13
27
|
/**
|
|
@@ -39,12 +53,121 @@ export interface DirectRegistryOptions {
|
|
|
39
53
|
* actor (`human` unless configured), so this only applies to direct `execute()` calls.
|
|
40
54
|
*/
|
|
41
55
|
actor?: Actor;
|
|
56
|
+
/**
|
|
57
|
+
* Request values the host declares (`spec/context-fields.md`). A call sets each on its context
|
|
58
|
+
* under the field's name; it is validated before middleware runs, and an invalid or missing
|
|
59
|
+
* required one fails the call with `VALIDATION_ERROR`.
|
|
60
|
+
*/
|
|
61
|
+
contextFields?: readonly ContextField[];
|
|
62
|
+
/**
|
|
63
|
+
* The contexts commands can be scoped to, as for `createMcpServer`. A call names its context
|
|
64
|
+
* in the `activeContext` option of {@link DirectCommandRegistry.execute}; a command whose
|
|
65
|
+
* `contexts` leave it out fails with `COMMAND_NOT_IN_CONTEXT`. Without `activeContext` every
|
|
66
|
+
* command is available, as on MCP with no context selected.
|
|
67
|
+
*/
|
|
68
|
+
contexts?: ContextConfig[];
|
|
69
|
+
/**
|
|
70
|
+
* The MCP tool surface: pass `createDirectToolSurface()` to list tools with
|
|
71
|
+
* {@link DirectCommandRegistry.listTools} and route the meta-tools, the context tools and,
|
|
72
|
+
* with `bootstrap: true`, the bootstrap tools through `execute`, as an MCP server with the
|
|
73
|
+
* same commands, contexts and strategy does. Without it, the registry runs only the commands
|
|
74
|
+
* it is given, and does not load the tool router.
|
|
75
|
+
*/
|
|
76
|
+
tools?: DirectToolSurface;
|
|
77
|
+
}
|
|
78
|
+
/** Options of one {@link DirectCommandRegistry.execute} call, passed beside the command context. */
|
|
79
|
+
export interface DirectExecuteOptions {
|
|
80
|
+
/**
|
|
81
|
+
* The context the call runs in: one of the registry's `contexts`, as MCP 2026-07-28 names it
|
|
82
|
+
* in `_meta["dev.afd/context"]`. It applies to this call only, including the commands it runs
|
|
83
|
+
* through `afd-call`, `afd-batch` and `afd-pipe`; handlers cannot read or change it. An
|
|
84
|
+
* unknown name fails with `CONTEXT_NOT_FOUND` before anything runs. Default: none, so every
|
|
85
|
+
* command is available.
|
|
86
|
+
*/
|
|
87
|
+
activeContext?: string;
|
|
88
|
+
/**
|
|
89
|
+
* The commands this call may run: a trusted, in-process predicate over names, such as
|
|
90
|
+
* `DirectClient`'s `allow`. It covers the name called and every command the call runs: the
|
|
91
|
+
* `afd-call` target, each `afd-batch` item, each `afd-pipe` step and a grouped tool's action.
|
|
92
|
+
* A name it rejects (or a throw) fails with `COMMAND_NOT_ALLOWED` and does not run, and
|
|
93
|
+
* `afd-discover`, `afd-detail` and the bootstrap tools leave such commands out. Handlers
|
|
94
|
+
* cannot read or change it; it may be called more than once per name. Default: none, so every
|
|
95
|
+
* exposed command runs.
|
|
96
|
+
*/
|
|
97
|
+
allow?: (command: string) => boolean;
|
|
98
|
+
}
|
|
99
|
+
/** Options of {@link DirectCommandRegistry.listTools}. */
|
|
100
|
+
export interface DirectListToolsOptions {
|
|
101
|
+
/** The strategy to list by. Default: the tool surface's. */
|
|
102
|
+
strategy?: ToolStrategy;
|
|
103
|
+
/** The context to list in, as for {@link DirectExecuteOptions.activeContext}. Default: none. */
|
|
104
|
+
activeContext?: string;
|
|
105
|
+
/**
|
|
106
|
+
* List only what this predicate permits, as for {@link DirectExecuteOptions.allow}: the
|
|
107
|
+
* commands it rejects are left out (grouped tools list only the actions it permits), and so
|
|
108
|
+
* are the tool names it rejects. Default: none.
|
|
109
|
+
*/
|
|
110
|
+
allow?: (command: string) => boolean;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The MCP tool surface of a registry, from `createDirectToolSurface()`. Pass it as the `tools`
|
|
114
|
+
* option of {@link createDirectRegistry}; the registry calls `attach` once.
|
|
115
|
+
*/
|
|
116
|
+
export interface DirectToolSurface {
|
|
117
|
+
/** The strategy `listTools` uses by default, and that grouped tool calls route by. */
|
|
118
|
+
readonly strategy: ToolStrategy;
|
|
119
|
+
/** Connect the surface to one registry. Called by `createDirectRegistry`. */
|
|
120
|
+
attach(host: DirectToolHost): DirectToolBinding;
|
|
121
|
+
}
|
|
122
|
+
/** What {@link createDirectRegistry} gives its tool surface. */
|
|
123
|
+
export interface DirectToolHost {
|
|
124
|
+
readonly interface: ExposeInterface;
|
|
125
|
+
readonly contexts: readonly ContextConfig[];
|
|
126
|
+
readonly contextFields: readonly ContextField[];
|
|
127
|
+
readonly devMode: boolean;
|
|
128
|
+
/** The registered commands, in order, before the surface adds its own. */
|
|
129
|
+
readonly commands: readonly ZodCommandDefinition[];
|
|
130
|
+
/** Whether a command is exposed to the registry's interface. */
|
|
131
|
+
isExposed(command: Pick<ZodCommandDefinition, 'expose'>): boolean;
|
|
132
|
+
/** The registry's engine, which the router runs commands through. */
|
|
133
|
+
executeCommand(name: string, input: unknown, context?: CommandContext): Promise<CommandResult>;
|
|
134
|
+
executeBatch(request: BatchRequest, context?: CommandContext): Promise<BatchResult>;
|
|
135
|
+
executePipeline(request: PipelineRequest, context?: CommandContext): Promise<PipelineResult>;
|
|
136
|
+
}
|
|
137
|
+
/** A tool surface attached to one registry. */
|
|
138
|
+
export interface DirectToolBinding {
|
|
139
|
+
/** The commands the surface registers: the context tools, then the bootstrap tools. */
|
|
140
|
+
readonly commands: readonly ZodCommandDefinition[];
|
|
141
|
+
/** Whether `name` is a tool the router handles that is not a command (a meta-tool or group). */
|
|
142
|
+
routes(name: string): boolean;
|
|
143
|
+
/** Route one tool call; the result is the JSON an MCP client reads. */
|
|
144
|
+
callTool(name: string, input: unknown, context: CommandContext): Promise<unknown>;
|
|
145
|
+
/**
|
|
146
|
+
* Apply a meta-tool's `meta` argument (`meta-argument.ts`) to an in-process call, where the
|
|
147
|
+
* `activeContext` option and the declared fields' values on the context stand for `_meta`.
|
|
148
|
+
*/
|
|
149
|
+
liftMetaArgument(name: string, input: unknown, context: CommandContext, activeContext: string | undefined): {
|
|
150
|
+
ok: true;
|
|
151
|
+
input: unknown;
|
|
152
|
+
context: CommandContext;
|
|
153
|
+
activeContext: string | undefined;
|
|
154
|
+
} | {
|
|
155
|
+
ok: false;
|
|
156
|
+
error: CommandError;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* The tool list of an MCP server with the same commands, contexts and strategy, narrowed to
|
|
160
|
+
* what `allow` permits when it is given.
|
|
161
|
+
*/
|
|
162
|
+
listTools(strategy: ToolStrategy | undefined, activeContext: string | null, allow?: (command: string) => boolean): McpToolDefinition[];
|
|
42
163
|
}
|
|
43
164
|
/**
|
|
44
165
|
* Summary of a command the registry exposes, for building tool declarations.
|
|
45
166
|
*/
|
|
46
167
|
export interface DirectRegistryCommand {
|
|
47
168
|
name: string;
|
|
169
|
+
/** Display label, when the command sets one. */
|
|
170
|
+
title?: string;
|
|
48
171
|
description: string;
|
|
49
172
|
category?: string;
|
|
50
173
|
mutation?: boolean;
|
|
@@ -61,18 +184,41 @@ export interface DirectRegistryCommand {
|
|
|
61
184
|
export interface DirectCommandRegistry {
|
|
62
185
|
/** The interface this registry serves. */
|
|
63
186
|
readonly interface: ExposeInterface;
|
|
187
|
+
/** The declared context fields, so `replayJournal` can tell which recorded values still apply. */
|
|
188
|
+
readonly contextFields: readonly ContextField[];
|
|
64
189
|
/**
|
|
65
190
|
* Validate the input with the command's Zod schema, then run the command
|
|
66
191
|
* through the middleware. Returns `COMMAND_NOT_FOUND` for unknown names,
|
|
67
|
-
* `COMMAND_NOT_EXPOSED` for commands not exposed to this interface
|
|
192
|
+
* `COMMAND_NOT_EXPOSED` for commands not exposed to this interface,
|
|
193
|
+
* `CONTEXT_NOT_FOUND` for an unknown `activeContext`, `COMMAND_NOT_IN_CONTEXT` for a
|
|
194
|
+
* command outside it, `COMMAND_NOT_ALLOWED` for a name the `allow` option rejects, and
|
|
68
195
|
* `VALIDATION_ERROR` for invalid input; the handler does not run for any of them.
|
|
196
|
+
*
|
|
197
|
+
* With a tool surface, a meta-tool name (`afd-call`, `afd-batch`, `afd-pipe`,
|
|
198
|
+
* `afd-discover`, `afd-detail`), or a grouped tool name when the surface's strategy is
|
|
199
|
+
* `grouped`, runs through the MCP server's tool router, and the result is the JSON an MCP
|
|
200
|
+
* client reads: `afd-batch` gives a `BatchResult` and `afd-pipe` a `PipelineResult`.
|
|
201
|
+
*/
|
|
202
|
+
execute<T>(name: string, input?: unknown, context?: CommandContext, options?: DirectExecuteOptions): Promise<CommandResult<T>>;
|
|
203
|
+
/**
|
|
204
|
+
* The tools an MCP server with the same commands, contexts and strategy lists, from the
|
|
205
|
+
* server's own tool list. Needs a tool surface (`tools: createDirectToolSurface()`).
|
|
206
|
+
*
|
|
207
|
+
* @throws TypeError without a tool surface; RangeError for an unknown `activeContext`, as
|
|
208
|
+
* MCP answers `tools/list` with an invalid-params error
|
|
209
|
+
*/
|
|
210
|
+
listTools(options?: DirectListToolsOptions): McpToolDefinition[];
|
|
211
|
+
/**
|
|
212
|
+
* Names of the commands exposed to this interface, the tool surface's context and bootstrap
|
|
213
|
+
* tools included.
|
|
69
214
|
*/
|
|
70
|
-
execute<T>(name: string, input?: unknown, context?: CommandContext): Promise<CommandResult<T>>;
|
|
71
|
-
/** Names of the commands exposed to this interface. */
|
|
72
215
|
listCommandNames(): string[];
|
|
73
216
|
/** Commands exposed to this interface, with their input schemas. */
|
|
74
217
|
listCommands(): DirectRegistryCommand[];
|
|
75
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* Whether `execute` runs `name`: a command registered and exposed to this interface or, with
|
|
220
|
+
* a tool surface, a tool name its router handles (a meta-tool, or a grouped tool).
|
|
221
|
+
*/
|
|
76
222
|
hasCommand(name: string): boolean;
|
|
77
223
|
}
|
|
78
224
|
/**
|
|
@@ -92,8 +238,9 @@ export declare function isExposedTo(command: Pick<ZodCommandDefinition, 'expose'
|
|
|
92
238
|
* that are not exposed to the chosen interface.
|
|
93
239
|
*
|
|
94
240
|
* @param commands - Commands created with `defineCommand()`
|
|
95
|
-
* @param options - Interface, middleware and
|
|
96
|
-
* @throws If two commands share a name
|
|
241
|
+
* @param options - Interface, middleware, hooks, contexts and the tool surface
|
|
242
|
+
* @throws If two commands share a name; with a tool surface, also for a reserved name or an
|
|
243
|
+
* invalid `firstClassTools`, as `createMcpServer` does
|
|
97
244
|
*
|
|
98
245
|
* @example
|
|
99
246
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"direct-registry.d.ts","sourceRoot":"","sources":["../src/direct-registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"direct-registry.d.ts","sourceRoot":"","sources":["../src/direct-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACX,KAAK,EACL,YAAY,EACZ,WAAW,EACX,KAAK,EACL,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,UAAU,EACV,eAAe,EACf,cAAc,EACd,YAAY,EACZ,MAAM,sBAAsB,CAAC;AAS9B,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,qBAAqB,CAAC;AAG5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAErE,mFAAmF;AACnF,MAAM,MAAM,eAAe,GAAG,MAAM,aAAa,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAE5B,uFAAuF;IACvF,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEjC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,qFAAqF;IACrF,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAE7E,wDAAwD;IACxD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEjC,yEAAyE;IACzE,KAAK,CAAC,EAAE,KAAK,CAA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