@notation/factory-cursor 0.5.5 → 0.6.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/runtime/runner.ts +14 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notation/factory-cursor",
3
- "version": "0.5.5",
3
+ "version": "0.6.0",
4
4
  "author": "Daniel Grant",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,9 +24,9 @@
24
24
  "valibot": "^1.1.0"
25
25
  },
26
26
  "peerDependencies": {
27
- "@notation/factory": "^0.5.5"
27
+ "@notation/factory": "^0.6.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@notation/factory": "0.5.5"
30
+ "@notation/factory": "0.6.0"
31
31
  }
32
32
  }
package/runtime/runner.ts CHANGED
@@ -11,6 +11,7 @@ type StreamEvent = {
11
11
  is_error?: boolean;
12
12
  session_id?: string;
13
13
  message?: { content?: { type: string; text?: string }[] };
14
+ tool_call?: Record<string, { args?: unknown; name?: string; arguments?: unknown } | undefined>;
14
15
  };
15
16
 
16
17
  const parseLine = (line: string): StreamEvent | undefined => {
@@ -106,6 +107,19 @@ const cursor: RuntimeRunner = {
106
107
  const event = parseLine(line);
107
108
  return event?.type === "system" && event.subtype === "init" ? event.model : undefined;
108
109
  },
110
+ session: (line) => parseLine(line)?.session_id,
111
+ // Each tool call is in the output twice, once as it starts and once as it
112
+ // completes. Its one key names the tool, such as `shellToolCall`. Other
113
+ // tools, such as an MCP server's, are under `function`, with their own name.
114
+ tools: (line) => {
115
+ const event = parseLine(line);
116
+ if (event?.type !== "tool_call" || event.subtype !== "started" || !event.tool_call) return [];
117
+ return Object.entries(event.tool_call).flatMap(([key, call]) => {
118
+ if (!call) return [];
119
+ if (key === "function") return call.name ? [{ name: call.name, input: call.arguments }] : [];
120
+ return [{ name: key.replace(/ToolCall$/, ""), input: call.args }];
121
+ });
122
+ },
109
123
  };
110
124
 
111
125
  export default cursor;