@nuvin/session 0.2.0-rc.6 → 0.2.0-rc.7

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.
@@ -11,6 +11,11 @@ export type TodoItem = {
11
11
  status: TodoStatus;
12
12
  priority?: "high" | "medium" | "low";
13
13
  };
14
+ export type McpToolIdentity = {
15
+ serverName?: string;
16
+ toolName: string;
17
+ };
18
+ export declare function parseMcpToolIdentity(toolName: string, structured?: unknown): McpToolIdentity;
14
19
  /**
15
20
  * Returns the status glyph for a given tool message status.
16
21
  * Moved from CLI parts.tsx so the glyph logic is shared across platforms.
@@ -1 +1 @@
1
- {"version":3,"file":"tool-preview.d.ts","sourceRoot":"","sources":["../../src/state/tool-preview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIvE,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,cAAc,KAAK,WAAW,CAAC;AAE5E,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;AAEjE,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;CACtC,CAAC;AAgZF;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAcpE;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,WAAW,CAGrF;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,cAAc,GAAG,MA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,6 +16,34 @@ function asObj(value) {
16
16
  if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
17
17
  return value;
18
18
  }
19
+ function parseMcpToolIdentity(toolName, structured) {
20
+ const obj = asObj(structured);
21
+ const structuredServer = str(obj, "serverName");
22
+ const structuredTool = str(obj, "toolName");
23
+ if (structuredServer && structuredTool) {
24
+ return { serverName: structuredServer, toolName: structuredTool };
25
+ }
26
+ if (!toolName.startsWith("mcp_")) {
27
+ return { toolName };
28
+ }
29
+ const rest = toolName.slice("mcp_".length);
30
+ if (rest.length === 0) {
31
+ return { toolName };
32
+ }
33
+ const segments = rest.split("_").filter((part) => part.length > 0);
34
+ const [firstSegment, ...toolSegments] = segments;
35
+ if (!firstSegment) {
36
+ return { toolName };
37
+ }
38
+ if (toolSegments.length === 0) {
39
+ return { toolName: firstSegment };
40
+ }
41
+ const parsedTool = toolSegments.join("_");
42
+ return {
43
+ serverName: firstSegment,
44
+ toolName: parsedTool.length > 0 ? parsedTool : toolName
45
+ };
46
+ }
19
47
  var Bash_fmt = (msg) => {
20
48
  const input = asObj(msg.input);
21
49
  const command = str(input, "command") ?? msg.summary;
@@ -298,6 +326,29 @@ function genericStatusPhrase(status) {
298
326
  return "Denied";
299
327
  }
300
328
  }
329
+ var Mcp_fmt = (msg) => {
330
+ const { serverName, toolName } = parseMcpToolIdentity(msg.toolName, msg.structured);
331
+ let phrase;
332
+ switch (msg.status) {
333
+ case "pending":
334
+ phrase = `Waiting to call ${toolName}`;
335
+ break;
336
+ case "approved":
337
+ case "running":
338
+ phrase = `Calling ${toolName}`;
339
+ break;
340
+ case "error":
341
+ phrase = `${toolName} call failed`;
342
+ break;
343
+ case "rejected":
344
+ phrase = `Skipped ${toolName}`;
345
+ break;
346
+ case "ok":
347
+ phrase = `Called ${toolName}`;
348
+ break;
349
+ }
350
+ return { phrase, mainArg: serverName };
351
+ };
301
352
  var Unknown_fmt = (msg) => ({
302
353
  mainArg: msg.summary || void 0,
303
354
  phrase: genericStatusPhrase(msg.status)
@@ -338,7 +389,7 @@ function getToolStatusGlyph(status) {
338
389
  }
339
390
  }
340
391
  function getToolPreview(toolName, message) {
341
- const formatter = FORMATTERS[toolName] ?? Unknown_fmt;
392
+ const formatter = FORMATTERS[toolName] ?? (toolName.startsWith("mcp_") ? Mcp_fmt : Unknown_fmt);
342
393
  return formatter(message);
343
394
  }
344
395
  function formatToolPreviewLine(message) {
@@ -360,5 +411,6 @@ export {
360
411
  formatToolPreviewLine,
361
412
  getTodoItems,
362
413
  getToolPreview,
363
- getToolStatusGlyph
414
+ getToolStatusGlyph,
415
+ parseMcpToolIdentity
364
416
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvin/session",
3
- "version": "0.2.0-rc.6",
3
+ "version": "0.2.0-rc.7",
4
4
  "private": false,
5
5
  "description": "Headless session layer for Nuvin: state reducers, wire protocol, session controller",
6
6
  "license": "Apache-2.0",