@lushly-dev/afd-server 0.6.0 → 2.0.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 +320 -14
- package/dist/bootstrap/afd-context.d.ts +11 -2
- package/dist/bootstrap/afd-context.d.ts.map +1 -1
- package/dist/bootstrap/afd-context.js +56 -11
- package/dist/bootstrap/afd-context.js.map +1 -1
- package/dist/bootstrap/afd-docs.d.ts +6 -3
- package/dist/bootstrap/afd-docs.d.ts.map +1 -1
- package/dist/bootstrap/afd-docs.js +14 -9
- package/dist/bootstrap/afd-docs.js.map +1 -1
- package/dist/bootstrap/afd-help.d.ts +6 -3
- package/dist/bootstrap/afd-help.d.ts.map +1 -1
- package/dist/bootstrap/afd-help.js +10 -8
- package/dist/bootstrap/afd-help.js.map +1 -1
- package/dist/bootstrap/afd-schema.d.ts +8 -4
- package/dist/bootstrap/afd-schema.d.ts.map +1 -1
- package/dist/bootstrap/afd-schema.js +55 -42
- package/dist/bootstrap/afd-schema.js.map +1 -1
- package/dist/bootstrap/described-command.d.ts +32 -0
- package/dist/bootstrap/described-command.d.ts.map +1 -0
- package/dist/bootstrap/described-command.js +12 -0
- package/dist/bootstrap/described-command.js.map +1 -0
- package/dist/bootstrap/index.d.ts +1 -0
- package/dist/bootstrap/index.d.ts.map +1 -1
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/bootstrap/json-schema-to-ts.d.ts +27 -0
- package/dist/bootstrap/json-schema-to-ts.d.ts.map +1 -0
- package/dist/bootstrap/json-schema-to-ts.js +154 -0
- package/dist/bootstrap/json-schema-to-ts.js.map +1 -0
- package/dist/bootstrap/registry.d.ts +17 -6
- package/dist/bootstrap/registry.d.ts.map +1 -1
- package/dist/bootstrap/registry.js +32 -5
- package/dist/bootstrap/registry.js.map +1 -1
- package/dist/command-names.d.ts +19 -0
- package/dist/command-names.d.ts.map +1 -0
- package/dist/command-names.js +33 -0
- package/dist/command-names.js.map +1 -0
- package/dist/command-routing.d.ts +47 -0
- package/dist/command-routing.d.ts.map +1 -0
- package/dist/command-routing.js +75 -0
- package/dist/command-routing.js.map +1 -0
- package/dist/context-scope.d.ts +26 -0
- package/dist/context-scope.d.ts.map +1 -0
- package/dist/context-scope.js +31 -0
- package/dist/context-scope.js.map +1 -0
- package/dist/define.d.ts +42 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +41 -0
- package/dist/define.js.map +1 -0
- package/dist/direct-registry.d.ts +103 -0
- package/dist/direct-registry.d.ts.map +1 -0
- package/dist/direct-registry.js +102 -0
- package/dist/direct-registry.js.map +1 -0
- package/dist/execution.d.ts +9 -0
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +105 -321
- package/dist/execution.js.map +1 -1
- package/dist/http-handler.d.ts +24 -17
- package/dist/http-handler.d.ts.map +1 -1
- package/dist/http-handler.js +282 -253
- package/dist/http-handler.js.map +1 -1
- package/dist/http-security.d.ts +23 -0
- package/dist/http-security.d.ts.map +1 -0
- package/dist/http-security.js +101 -0
- package/dist/http-security.js.map +1 -0
- package/dist/http-sessions.d.ts +33 -0
- package/dist/http-sessions.d.ts.map +1 -0
- package/dist/http-sessions.js +65 -0
- package/dist/http-sessions.js.map +1 -0
- package/dist/http-sse.d.ts +30 -0
- package/dist/http-sse.d.ts.map +1 -0
- package/dist/http-sse.js +70 -0
- package/dist/http-sse.js.map +1 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/json-rpc.d.ts +56 -0
- package/dist/json-rpc.d.ts.map +1 -0
- package/dist/json-rpc.js +73 -0
- package/dist/json-rpc.js.map +1 -0
- package/dist/lazy-tools.d.ts +2 -12
- package/dist/lazy-tools.d.ts.map +1 -1
- package/dist/lazy-tools.js +9 -14
- package/dist/lazy-tools.js.map +1 -1
- package/dist/meta-tools.d.ts +122 -0
- package/dist/meta-tools.d.ts.map +1 -0
- package/dist/meta-tools.js +156 -0
- package/dist/meta-tools.js.map +1 -0
- package/dist/middleware.d.ts +34 -7
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +82 -40
- package/dist/middleware.js.map +1 -1
- package/dist/schema.d.ts +27 -6
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +17 -12
- package/dist/schema.js.map +1 -1
- package/dist/server-types.d.ts +100 -13
- package/dist/server-types.d.ts.map +1 -1
- package/dist/server-types.js.map +1 -1
- package/dist/server.d.ts +10 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +165 -48
- package/dist/server.js.map +1 -1
- package/dist/tool-router.d.ts +6 -5
- package/dist/tool-router.d.ts.map +1 -1
- package/dist/tool-router.js +104 -120
- package/dist/tool-router.js.map +1 -1
- package/dist/tools.d.ts +10 -420
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +99 -208
- package/dist/tools.js.map +1 -1
- package/package.json +13 -8
package/dist/tool-router.js
CHANGED
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Used by both stdio and HTTP transports to eliminate routing duplication.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { failure, isBatchRequest, isPipelineRequest, truncateName } from '@lushly-dev/afd-core';
|
|
8
|
+
import { commandAction, commandGroup, filterByContext, isAccessibleInContext, notFoundSuggestion, notInContextError, } from './command-routing.js';
|
|
9
|
+
import { resolveContextState } from './context-scope.js';
|
|
8
10
|
import { executeDetail, executeDiscover } from './lazy-tools.js';
|
|
11
|
+
import { batchArgsSchema, callArgsSchema, checkMetaArgs, detailArgsSchema, discoverArgsSchema, parseMetaArgs, pipeArgsSchema, } from './meta-tools.js';
|
|
9
12
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
10
13
|
// EMPTY PIPELINE RESULT (for invalid pipeline requests)
|
|
11
14
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
@@ -27,48 +30,49 @@ const emptyPipelineResult = {
|
|
|
27
30
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
28
31
|
// ROUTER
|
|
29
32
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
33
|
+
/**
|
|
34
|
+
* Wrap a result as MCP tool content. The JSON is compact: the text is read by an
|
|
35
|
+
* agent, and indentation only adds tokens.
|
|
36
|
+
*/
|
|
30
37
|
function resultContent(data, isError) {
|
|
31
38
|
return {
|
|
32
|
-
content: [{ type: 'text', text: JSON.stringify(data
|
|
39
|
+
content: [{ type: 'text', text: JSON.stringify(data) }],
|
|
33
40
|
isError,
|
|
34
41
|
};
|
|
35
42
|
}
|
|
36
43
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* - No active context (everything visible)
|
|
40
|
-
* - Command has no contexts array (universal / backward compat)
|
|
41
|
-
* - Command's contexts include the active context
|
|
44
|
+
* The `COMMAND_NOT_IN_CONTEXT` tool result when `cmd` exists but is outside the
|
|
45
|
+
* active context; undefined otherwise (a missing command is left to execution).
|
|
42
46
|
*/
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (!cmd.contexts?.length)
|
|
49
|
-
return true;
|
|
50
|
-
return cmd.contexts.includes(activeContext);
|
|
47
|
+
function contextDenial(cmd, commandName, contextState) {
|
|
48
|
+
const activeContext = contextState?.getActive();
|
|
49
|
+
if (!cmd || !activeContext || isAccessibleInContext(cmd, activeContext))
|
|
50
|
+
return undefined;
|
|
51
|
+
return resultContent({ success: false, error: notInContextError(commandName, activeContext) }, true);
|
|
51
52
|
}
|
|
52
53
|
/**
|
|
53
54
|
* Create a tool call router that dispatches to the appropriate execution function.
|
|
54
55
|
*/
|
|
55
56
|
export function createToolRouter(deps) {
|
|
56
|
-
const { executeCommand, executeBatch, executePipeline, commands, toolStrategy, groupByFn, devMode, allCommands, exposedCommandNames,
|
|
57
|
-
|
|
57
|
+
const { executeCommand, executeBatch, executePipeline, commands, toolStrategy, groupByFn, devMode, allCommands, exposedCommandNames, } = deps;
|
|
58
|
+
/**
|
|
59
|
+
* Route one tool call.
|
|
60
|
+
*
|
|
61
|
+
* @param callContext - Base `CommandContext` for commands this call runs (request values,
|
|
62
|
+
* `signal`, and the caller's context state); each execution adds its own `traceId`.
|
|
63
|
+
*/
|
|
64
|
+
return async function routeToolCall(toolName, args, callContext = {}) {
|
|
65
|
+
const contextState = resolveContextState(callContext, deps.contextState);
|
|
66
|
+
const traced = (prefix) => ({
|
|
67
|
+
...callContext,
|
|
68
|
+
traceId: `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
69
|
+
});
|
|
58
70
|
// Handle afd-call (available in all strategies)
|
|
59
71
|
if (toolName === 'afd-call') {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
success: false,
|
|
65
|
-
error: {
|
|
66
|
-
code: 'VALIDATION_ERROR',
|
|
67
|
-
message: 'Missing required field: command',
|
|
68
|
-
suggestion: 'Provide { command: "command-name", input: {...} }',
|
|
69
|
-
},
|
|
70
|
-
}, true);
|
|
71
|
-
}
|
|
72
|
+
const parsed = parseMetaArgs(toolName, callArgsSchema, args, 'Provide { command: "command-name", input: {...} }');
|
|
73
|
+
if (!parsed.success)
|
|
74
|
+
return resultContent(parsed.result, true);
|
|
75
|
+
const { command: commandName, input } = parsed.data;
|
|
72
76
|
// Check if command exists in the exposed commands
|
|
73
77
|
const cmd = commands.find((c) => c.name === commandName);
|
|
74
78
|
if (!cmd) {
|
|
@@ -84,88 +88,92 @@ export function createToolRouter(deps) {
|
|
|
84
88
|
},
|
|
85
89
|
}, true);
|
|
86
90
|
}
|
|
87
|
-
// Not found at all — suggest
|
|
88
|
-
const
|
|
89
|
-
const suggestions = findSimilarTools(commandName, allNames, 3);
|
|
90
|
-
const suggestionText = suggestions.length > 0
|
|
91
|
-
? `Did you mean '${suggestions[0]}'? Use afd-discover to list all commands.`
|
|
92
|
-
: 'Use afd-discover to list all commands.';
|
|
91
|
+
// Not found at all — suggest a few close matches the caller can use
|
|
92
|
+
const callable = filterByContext(commands, contextState?.getActive());
|
|
93
93
|
return resultContent({
|
|
94
94
|
success: false,
|
|
95
95
|
error: {
|
|
96
96
|
code: 'COMMAND_NOT_FOUND',
|
|
97
|
-
message: `Command '${commandName}' not found`,
|
|
98
|
-
suggestion:
|
|
97
|
+
message: `Command '${truncateName(commandName)}' not found`,
|
|
98
|
+
suggestion: notFoundSuggestion(commandName, callable.map((c) => c.name)),
|
|
99
99
|
},
|
|
100
100
|
}, true);
|
|
101
101
|
}
|
|
102
102
|
// Context check: validate the command is accessible in current context
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return resultContent({
|
|
107
|
-
success: false,
|
|
108
|
-
error: {
|
|
109
|
-
code: 'COMMAND_NOT_IN_CONTEXT',
|
|
110
|
-
message: `Command '${commandName}' is not available in context '${activeContext}'`,
|
|
111
|
-
suggestion: 'Use afd-context-list to see available contexts, or afd-context-enter to switch.',
|
|
112
|
-
},
|
|
113
|
-
}, true);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
103
|
+
const denied = contextDenial(cmd, commandName, contextState);
|
|
104
|
+
if (denied)
|
|
105
|
+
return denied;
|
|
116
106
|
// Execute through the execution engine (full middleware chain)
|
|
117
|
-
const result = await executeCommand(commandName,
|
|
118
|
-
traceId: `afd-call-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
119
|
-
});
|
|
107
|
+
const result = await executeCommand(commandName, input ?? {}, traced('afd-call'));
|
|
120
108
|
return resultContent(result, !result.success);
|
|
121
109
|
}
|
|
122
|
-
// Handle afd-discover (lazy strategy
|
|
110
|
+
// Handle afd-discover (listed by the lazy strategy, routable in all)
|
|
123
111
|
if (toolName === 'afd-discover') {
|
|
112
|
+
const parsed = parseMetaArgs(toolName, discoverArgsSchema, args, 'Provide optional { category, tag, tagMode, search, includeMutation, limit, offset }');
|
|
113
|
+
if (!parsed.success)
|
|
114
|
+
return resultContent(parsed.result, true);
|
|
124
115
|
// Filter by active context when context state is available
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
? commands.filter((cmd) => !cmd.contexts?.length || cmd.contexts.includes(activeContext))
|
|
128
|
-
: commands;
|
|
129
|
-
const result = executeDiscover(discoverCommands, (args ?? {}));
|
|
116
|
+
const discoverCommands = filterByContext(commands, contextState?.getActive());
|
|
117
|
+
const result = executeDiscover(discoverCommands, parsed.data);
|
|
130
118
|
return resultContent(result, false);
|
|
131
119
|
}
|
|
132
|
-
// Handle afd-detail (lazy
|
|
120
|
+
// Handle afd-detail (listed by the lazy and grouped strategies, routable in all)
|
|
133
121
|
if (toolName === 'afd-detail') {
|
|
122
|
+
const parsed = parseMetaArgs(toolName, detailArgsSchema, args, 'Provide { command: "command-name" } or { command: ["name-1", "name-2"] } (max 10)');
|
|
123
|
+
if (!parsed.success)
|
|
124
|
+
return resultContent(parsed.result, true);
|
|
134
125
|
const exposedNames = exposedCommandNames ?? new Set(commands.map((c) => c.name));
|
|
135
|
-
const allCmds = allCommands ?? commands;
|
|
136
126
|
// Filter by active context so agents cannot inspect commands outside their context
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
? allCmds.filter((cmd) => !cmd.contexts?.length || cmd.contexts.includes(activeContext))
|
|
140
|
-
: allCmds;
|
|
141
|
-
const result = executeDetail(contextFilteredCmds, exposedNames, (args ?? {}));
|
|
127
|
+
const contextFilteredCmds = filterByContext(allCommands ?? commands, contextState?.getActive());
|
|
128
|
+
const result = executeDetail(contextFilteredCmds, exposedNames, parsed.data);
|
|
142
129
|
return resultContent(result, false);
|
|
143
130
|
}
|
|
144
131
|
// Handle built-in afd-batch tool
|
|
145
132
|
if (toolName === 'afd-batch') {
|
|
146
|
-
|
|
133
|
+
// The Zod schema pinpoints shape errors; isBatchRequest is the envelope check
|
|
134
|
+
// shared with POST /batch. Both report INVALID_BATCH_REQUEST.
|
|
135
|
+
const check = checkMetaArgs(batchArgsSchema, args);
|
|
136
|
+
if (!check.success || !isBatchRequest(args)) {
|
|
137
|
+
const usage = 'Provide { commands: [...] } with command objects';
|
|
147
138
|
return resultContent({
|
|
148
139
|
success: false,
|
|
149
140
|
error: {
|
|
150
141
|
code: 'INVALID_BATCH_REQUEST',
|
|
151
142
|
message: 'Invalid batch request format',
|
|
152
|
-
suggestion:
|
|
143
|
+
suggestion: check.success ? usage : `${check.suggestion}. ${usage}`,
|
|
144
|
+
...(!check.success && { details: { errors: check.errors } }),
|
|
153
145
|
},
|
|
154
146
|
}, true);
|
|
155
147
|
}
|
|
156
|
-
const result = await executeBatch(args,
|
|
157
|
-
traceId: `batch-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
158
|
-
});
|
|
148
|
+
const result = await executeBatch(args, traced('batch'));
|
|
159
149
|
return resultContent(result, !result.success);
|
|
160
150
|
}
|
|
161
151
|
// Handle built-in afd-pipe tool
|
|
162
152
|
if (toolName === 'afd-pipe') {
|
|
163
|
-
|
|
164
|
-
|
|
153
|
+
// As for afd-batch: Zod pinpoints shape errors, and isPipelineRequest checks the
|
|
154
|
+
// whole envelope (including `when` conditions). Both report INVALID_PIPELINE_REQUEST.
|
|
155
|
+
const check = checkMetaArgs(pipeArgsSchema, args);
|
|
156
|
+
if (!check.success || !isPipelineRequest(args)) {
|
|
157
|
+
const usage = 'Provide steps with nonempty command names, object inputs, valid conditions, and correctly typed options; input must be JSON';
|
|
158
|
+
return resultContent({
|
|
159
|
+
...emptyPipelineResult,
|
|
160
|
+
steps: [
|
|
161
|
+
{
|
|
162
|
+
index: -1,
|
|
163
|
+
command: '',
|
|
164
|
+
status: 'failure',
|
|
165
|
+
executionTimeMs: 0,
|
|
166
|
+
error: {
|
|
167
|
+
code: 'INVALID_PIPELINE_REQUEST',
|
|
168
|
+
message: 'Invalid pipeline request envelope',
|
|
169
|
+
suggestion: check.success ? usage : `${check.suggestion}. ${usage}`,
|
|
170
|
+
...(!check.success && { details: { errors: check.errors } }),
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
}, true);
|
|
165
175
|
}
|
|
166
|
-
const result = await executePipeline(args,
|
|
167
|
-
traceId: `pipeline-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
168
|
-
});
|
|
176
|
+
const result = await executePipeline(args, traced('pipeline'));
|
|
169
177
|
const hasFailed = result.steps.some((s) => s.status === 'failure');
|
|
170
178
|
return resultContent(result, hasFailed);
|
|
171
179
|
}
|
|
@@ -178,38 +186,27 @@ export function createToolRouter(deps) {
|
|
|
178
186
|
console.error(`[MCP Debug] Grouped tool call: toolName=${toolName}, action=${action}, args=${JSON.stringify(args)}`);
|
|
179
187
|
}
|
|
180
188
|
if (action && typeof action === 'string') {
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
success: false,
|
|
189
|
-
error: {
|
|
190
|
-
code: 'COMMAND_NOT_IN_CONTEXT',
|
|
191
|
-
message: `Command '${actualCommandName}' is not available in context '${activeContext}'`,
|
|
192
|
-
suggestion: 'Use afd-context-list to see available contexts, or afd-context-enter to switch.',
|
|
193
|
-
},
|
|
194
|
-
}, true);
|
|
195
|
-
}
|
|
189
|
+
const candidates = commands.filter((command) => commandGroup(command, groupByFn) === toolName && commandAction(command) === action);
|
|
190
|
+
if (candidates.length !== 1) {
|
|
191
|
+
return resultContent(failure({
|
|
192
|
+
code: candidates.length ? 'AMBIGUOUS_ACTION' : 'COMMAND_NOT_FOUND',
|
|
193
|
+
message: `Action '${truncateName(action)}' does not identify one command in group '${truncateName(toolName)}'`,
|
|
194
|
+
suggestion: 'Use afd-call with the full command name, or list tools to find a valid action.',
|
|
195
|
+
}), true);
|
|
196
196
|
}
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
const actualCommandName = candidates[0]?.name;
|
|
198
|
+
// Context check for grouped strategy
|
|
199
|
+
const denied = contextDenial(candidates[0], actualCommandName, contextState);
|
|
200
|
+
if (denied)
|
|
201
|
+
return denied;
|
|
202
|
+
const result = await executeCommand(actualCommandName, commandParams, traced('trace'));
|
|
200
203
|
return resultContent(result, !result.success);
|
|
201
204
|
}
|
|
202
205
|
// In grouped mode, if tool is a known group but action is missing/invalid,
|
|
203
206
|
// return a helpful error instead of falling through
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (groupNames.has(toolName)) {
|
|
208
|
-
const groupCommands = commands.filter((cmd) => getGroup(cmd) === toolName);
|
|
209
|
-
const availableActions = groupCommands.map((cmd) => {
|
|
210
|
-
const parts = cmd.name.split('-');
|
|
211
|
-
return parts.length > 1 ? parts.slice(1).join('-') : cmd.name;
|
|
212
|
-
});
|
|
207
|
+
const groupCommands = commands.filter((cmd) => commandGroup(cmd, groupByFn) === toolName);
|
|
208
|
+
if (groupCommands.length > 0) {
|
|
209
|
+
const availableActions = groupCommands.map(commandAction);
|
|
213
210
|
return resultContent({
|
|
214
211
|
success: false,
|
|
215
212
|
error: {
|
|
@@ -223,23 +220,10 @@ export function createToolRouter(deps) {
|
|
|
223
220
|
}
|
|
224
221
|
// Handle user-defined commands (individual mode or direct command calls)
|
|
225
222
|
// Context check: validate the command is accessible in current context
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return resultContent({
|
|
231
|
-
success: false,
|
|
232
|
-
error: {
|
|
233
|
-
code: 'COMMAND_NOT_IN_CONTEXT',
|
|
234
|
-
message: `Command '${toolName}' is not available in context '${activeContext}'`,
|
|
235
|
-
suggestion: 'Use afd-context-list to see available contexts, or afd-context-enter to switch.',
|
|
236
|
-
},
|
|
237
|
-
}, true);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
const result = await executeCommand(toolName, args ?? {}, {
|
|
241
|
-
traceId: `trace-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
242
|
-
});
|
|
223
|
+
const denied = contextDenial(commands.find((c) => c.name === toolName), toolName, contextState);
|
|
224
|
+
if (denied)
|
|
225
|
+
return denied;
|
|
226
|
+
const result = await executeCommand(toolName, args ?? {}, traced('trace'));
|
|
243
227
|
return resultContent(result, !result.success);
|
|
244
228
|
};
|
|
245
229
|
}
|
package/dist/tool-router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-router.js","sourceRoot":"","sources":["../src/tool-router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tool-router.js","sourceRoot":"","sources":["../src/tool-router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEhG,OAAO,EACN,aAAa,EACb,YAAY,EACZ,eAAe,EAEf,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EACN,eAAe,EACf,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,cAAc,GACd,MAAM,iBAAiB,CAAC;AAgCzB,kFAAkF;AAClF,wDAAwD;AACxD,kFAAkF;AAElF,MAAM,mBAAmB,GAAG;IAC3B,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE;QACT,UAAU,EAAE,CAAC;QACb,mBAAmB,EAAE,EAAE;QACvB,SAAS,EAAE,EAAE;QACb,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,EAAE;QACX,YAAY,EAAE,EAAE;QAChB,eAAe,EAAE,CAAC;QAClB,cAAc,EAAE,CAAC;QACjB,UAAU,EAAE,CAAC;KACb;IACD,KAAK,EAAE,EAAE;CACT,CAAC;AAEF,kFAAkF;AAClF,SAAS;AACT,kFAAkF;AAElF;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