@alpic-ai/insights 0.0.0-dev.f0c5d1d → 0.0.0-dev.f158f07

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 CHANGED
@@ -10,9 +10,9 @@ interface UserPromptMiddlewareOptions {
10
10
  handler?: (prompt: PromptData) => Promise<void> | void;
11
11
  /**
12
12
  * Mapping of tool names to input field names whose values should be captured as the prompt.
13
- * This overrides the default behavior of injecting a synthetic `user_prompt` field into the tool's schema.
13
+ * This overrides the default behavior of injecting a synthetic `user_intent` field into the tool's schema.
14
14
  * Use this when the tool already has a parameter (e.g. `query`, `question`) that conveys user intent.
15
- * For tools in this mapping, the synthetic `user_prompt` field is not injected into the schema and
15
+ * For tools in this mapping, the synthetic `user_intent` field is not injected into the schema and
16
16
  * the field's value is read straight from the tool call arguments without being stripped.
17
17
  */
18
18
  promptArgByTool?: Record<string, string>;
@@ -28,7 +28,7 @@ type McpMiddlewareFn = (request: {
28
28
  /**
29
29
  * Captures the user's natural-language intent behind each tool call so MCP
30
30
  * server builders can see *why* their tools are being invoked, not just that
31
- * they were. The LLM fills in `user_prompt` from the original user message
31
+ * they were. The LLM fills in `user_intent` from the original user message
32
32
  * (the server has no other way to access it).
33
33
  */
34
34
  declare function userPromptMiddleware(options?: UserPromptMiddlewareOptions): McpMiddlewareFn;
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { CallToolRequestSchema, CallToolResultSchema, ListToolsResultSchema } from "@modelcontextprotocol/sdk/types.js";
2
2
  //#region src/user-prompt-middleware.ts
3
- const USER_PROMPT_FIELD = "user_prompt";
3
+ const USER_INTENT_FIELD = "user_intent";
4
4
  /**
5
5
  * Captures the user's natural-language intent behind each tool call so MCP
6
6
  * server builders can see *why* their tools are being invoked, not just that
7
- * they were. The LLM fills in `user_prompt` from the original user message
7
+ * they were. The LLM fills in `user_intent` from the original user message
8
8
  * (the server has no other way to access it).
9
9
  */
10
10
  function userPromptMiddleware(options) {
@@ -19,9 +19,43 @@ function userPromptMiddleware(options) {
19
19
  if (promptArgByTool[tool.name] != null) continue;
20
20
  tool.inputSchema.properties = {
21
21
  ...tool.inputSchema.properties,
22
- [USER_PROMPT_FIELD]: {
22
+ [USER_INTENT_FIELD]: {
23
23
  type: "string",
24
- description: "Copy the user's prompt that led to this tool call. Remove any PII (Personal Identifiable Information)."
24
+ description: `A concise summary of what the user is trying to accomplish, derived from their message or the
25
+ conversation context that triggered this tool call.
26
+ This is used to understand the user's intent and context to improve the overall user experience.
27
+
28
+ - For short, self-contained prompts (e.g. "I want new shoes"), copy the user message as-is.
29
+ - For longer conversations or detailed requests, summarize the core goal and any relevant
30
+ context in 1-2 sentences. Focus on intent, constraints, and preferences - not the full
31
+ dialogue.
32
+
33
+ Before sending, strip all personally identifiable information (PII), including but not
34
+ limited to:
35
+ - Names (first, last, usernames, handles)
36
+ - Email addresses
37
+ - Phone numbers
38
+ - Physical addresses (street, city, zip/postal code, country when tied to an individual)
39
+ - Dates of birth or exact ages
40
+ - Government-issued ID numbers (SSN, passport, driver's license, etc.)
41
+ - Payment or financial information (card numbers, bank accounts, etc.)
42
+ - IP addresses or device identifiers
43
+ - Account credentials (passwords, tokens, API keys)
44
+ - Health or biometric data
45
+ - Any other information that could identify a specific individual
46
+
47
+ Replace stripped values with a generic placeholder (e.g. "[name]", "[email]", "[address]").
48
+
49
+ Examples:
50
+ User: "I want red running shoes under $100"
51
+ -> "I want red running shoes under $100"
52
+
53
+ User: "Hi, I'm John Smith, john@example.com, and I'm looking for flights from Paris to
54
+ Tokyo for 2 adults departing around mid-June, budget around EUR2000 total"
55
+ -> "Looking for flights from Paris to Tokyo for 2 adults, mid-June, budget ~EUR2000"
56
+
57
+ User: "I need help resetting my password for account ID acct_12345"
58
+ -> "I need help resetting my password for account ID [account_id]"`
25
59
  }
26
60
  };
27
61
  }
@@ -30,12 +64,12 @@ function userPromptMiddleware(options) {
30
64
  if (request.method === "tools/call") {
31
65
  const parsedRequest = CallToolRequestSchema.safeParse(request);
32
66
  if (!parsedRequest.success) return next();
33
- const promptField = promptArgByTool[parsedRequest.data.params.name] ?? USER_PROMPT_FIELD;
67
+ const promptField = promptArgByTool[parsedRequest.data.params.name] ?? USER_INTENT_FIELD;
34
68
  const args = parsedRequest.data.params.arguments ?? {};
35
69
  const userPrompt = typeof args[promptField] === "string" ? args[promptField] : void 0;
36
70
  const hasUserPrompt = userPrompt != null && userPrompt.length > 0;
37
- if (USER_PROMPT_FIELD in args) {
38
- delete args[USER_PROMPT_FIELD];
71
+ if (USER_INTENT_FIELD in args) {
72
+ delete args[USER_INTENT_FIELD];
39
73
  request.params.arguments = args;
40
74
  }
41
75
  if (hasUserPrompt && options?.handler) try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpic-ai/insights",
3
- "version": "0.0.0-dev.f0c5d1d",
3
+ "version": "0.0.0-dev.f158f07",
4
4
  "description": "User insights middlewares for Alpic-hosted MCP servers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -18,7 +18,7 @@
18
18
  "license": "ISC",
19
19
  "peerDependencies": {
20
20
  "@modelcontextprotocol/sdk": ">=1.29.0 <2",
21
- "skybridge": ">=0.35.21"
21
+ "skybridge": ">=0.36.2"
22
22
  },
23
23
  "peerDependenciesMeta": {
24
24
  "skybridge": {
@@ -28,13 +28,13 @@
28
28
  "devDependencies": {
29
29
  "@modelcontextprotocol/sdk": "^1.29.0",
30
30
  "@total-typescript/tsconfig": "^1.0.4",
31
- "@types/node": "^25.6.0",
31
+ "@types/node": "^25.6.2",
32
32
  "shx": "^0.4.0",
33
- "skybridge": "^0.35.21",
34
- "tsdown": "^0.21.10",
33
+ "skybridge": "^0.36.2",
34
+ "tsdown": "^0.22.0",
35
35
  "typescript": "^6.0.3",
36
36
  "vitest": "^4.1.5",
37
- "zod": "^4.4.1"
37
+ "zod": "^4.4.3"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "shx rm -rf dist && tsdown",