@alpic-ai/insights 0.0.0-dev.6f73a04 → 0.0.0-dev.6ff2e01
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/dist/index.d.mts +5 -4
- package/dist/index.mjs +12 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
1
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
3
|
|
|
3
4
|
//#region src/intent-middleware.d.ts
|
|
@@ -38,16 +39,16 @@ declare function intentMiddleware(options?: IntentMiddlewareOptions): McpMiddlew
|
|
|
38
39
|
//#endregion
|
|
39
40
|
//#region src/capture-intents.d.ts
|
|
40
41
|
/**
|
|
41
|
-
* Captures the user's natural-language
|
|
42
|
+
* Captures the user's natural-language intent behind each tool call on a vanilla
|
|
42
43
|
* `@modelcontextprotocol/sdk` server. Accepts the high-level `McpServer` or the
|
|
43
44
|
* low-level `Server` and patches the `tools/list` and `tools/call` request
|
|
44
|
-
* handlers to surface the captured
|
|
45
|
-
* `
|
|
45
|
+
* handlers to surface the captured intent via `options.handler` (or, when
|
|
46
|
+
* `ALPIC_INTENT_META_KEY` is set, via the response `_meta`).
|
|
46
47
|
*
|
|
47
48
|
* Already-registered handlers are wrapped immediately; future registrations
|
|
48
49
|
* (e.g. tools added after this call) are wrapped via a `Map.set` proxy so order
|
|
49
50
|
* of calls relative to `registerTool` does not matter.
|
|
50
51
|
*/
|
|
51
|
-
declare const captureIntents: (server: McpServer, options?: IntentMiddlewareOptions) => void;
|
|
52
|
+
declare const captureIntents: (server: McpServer | Server, options?: IntentMiddlewareOptions) => void;
|
|
52
53
|
//#endregion
|
|
53
54
|
export { type IntentMiddlewareOptions, type McpMiddlewareFn, type PromptData, captureIntents, intentMiddleware };
|
package/dist/index.mjs
CHANGED
|
@@ -67,7 +67,14 @@ Examples:
|
|
|
67
67
|
const parsedRequest = CallToolRequestSchema.safeParse(request);
|
|
68
68
|
if (!parsedRequest.success) return next();
|
|
69
69
|
const toolName = parsedRequest.data.params.name;
|
|
70
|
-
if (toolsFilter && !toolsFilter.has(toolName))
|
|
70
|
+
if (toolsFilter && !toolsFilter.has(toolName)) {
|
|
71
|
+
const args = parsedRequest.data.params.arguments ?? {};
|
|
72
|
+
if (USER_INTENT_FIELD in args) {
|
|
73
|
+
delete args[USER_INTENT_FIELD];
|
|
74
|
+
request.params.arguments = args;
|
|
75
|
+
}
|
|
76
|
+
return next();
|
|
77
|
+
}
|
|
71
78
|
const promptField = argumentNameOverride[toolName] ?? USER_INTENT_FIELD;
|
|
72
79
|
const args = parsedRequest.data.params.arguments ?? {};
|
|
73
80
|
const userPrompt = typeof args[promptField] === "string" ? args[promptField] : void 0;
|
|
@@ -98,13 +105,13 @@ Examples:
|
|
|
98
105
|
}
|
|
99
106
|
//#endregion
|
|
100
107
|
//#region src/capture-intents.ts
|
|
101
|
-
const INSTALLED_MARKER = "
|
|
108
|
+
const INSTALLED_MARKER = "__alpicCaptureIntentsInstalled";
|
|
102
109
|
/**
|
|
103
|
-
* Captures the user's natural-language
|
|
110
|
+
* Captures the user's natural-language intent behind each tool call on a vanilla
|
|
104
111
|
* `@modelcontextprotocol/sdk` server. Accepts the high-level `McpServer` or the
|
|
105
112
|
* low-level `Server` and patches the `tools/list` and `tools/call` request
|
|
106
|
-
* handlers to surface the captured
|
|
107
|
-
* `
|
|
113
|
+
* handlers to surface the captured intent via `options.handler` (or, when
|
|
114
|
+
* `ALPIC_INTENT_META_KEY` is set, via the response `_meta`).
|
|
108
115
|
*
|
|
109
116
|
* Already-registered handlers are wrapped immediately; future registrations
|
|
110
117
|
* (e.g. tools added after this call) are wrapped via a `Map.set` proxy so order
|