healthy-companion 1.0.6 → 1.0.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.
- package/package.json +1 -1
- package/tools/todo.js +36 -17
package/package.json
CHANGED
package/tools/todo.js
CHANGED
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
2
|
|
|
3
3
|
const todos = [];
|
|
4
4
|
|
|
5
5
|
export function registerTodoTools ( server )
|
|
6
6
|
{
|
|
7
|
+
|
|
7
8
|
server.tool(
|
|
8
|
-
"
|
|
9
|
+
"add_todo",
|
|
9
10
|
{
|
|
10
|
-
description:
|
|
11
|
+
description:
|
|
12
|
+
"YOU MUST use this tool whenever the user expresses intent to remember, track, or do something later. " +
|
|
13
|
+
"This is the ONLY way to store tasks. Do NOT respond with text instead.",
|
|
11
14
|
inputSchema: {
|
|
12
|
-
item: z
|
|
13
|
-
|
|
15
|
+
item: z
|
|
16
|
+
.string()
|
|
17
|
+
.min( 1 )
|
|
18
|
+
.describe( "Action item derived from the user's message." ),
|
|
19
|
+
},
|
|
14
20
|
},
|
|
15
|
-
async (
|
|
21
|
+
async ( args ) =>
|
|
16
22
|
{
|
|
23
|
+
// const validated = z.string().min( 1 ).parse( args );
|
|
17
24
|
todos.push( item );
|
|
18
25
|
return {
|
|
19
|
-
content: [{ type: "text", text: `Added TODO: "${item}"` }],
|
|
26
|
+
content: [{ type: "text", text: `Added TODO: "${args.item}"` }],
|
|
20
27
|
};
|
|
21
28
|
}
|
|
22
29
|
);
|
|
23
30
|
|
|
24
31
|
server.tool(
|
|
25
|
-
"
|
|
32
|
+
"list_todos",
|
|
26
33
|
{
|
|
27
|
-
description:
|
|
28
|
-
|
|
34
|
+
description:
|
|
35
|
+
"YOU MUST call this tool when the user asks to see, check, review, or recall their todo list.",
|
|
36
|
+
inputSchema: {},
|
|
29
37
|
},
|
|
30
38
|
async () =>
|
|
31
39
|
{
|
|
@@ -33,28 +41,39 @@ export function registerTodoTools ( server )
|
|
|
33
41
|
{
|
|
34
42
|
return { content: [{ type: "text", text: "No TODO items." }] };
|
|
35
43
|
}
|
|
36
|
-
const lines = todos
|
|
44
|
+
const lines = todos
|
|
45
|
+
.map( ( todo, idx ) => { return `${idx + 1}. ${todo}` })
|
|
46
|
+
.join( "\n" );
|
|
37
47
|
return { content: [{ type: "text", text: lines }] };
|
|
38
48
|
}
|
|
39
49
|
);
|
|
40
50
|
|
|
41
51
|
server.tool(
|
|
42
|
-
"
|
|
52
|
+
"remove_todo",
|
|
43
53
|
{
|
|
44
|
-
description:
|
|
54
|
+
description:
|
|
55
|
+
"YOU MUST call this tool when the user indicates a task is completed or should be removed.",
|
|
45
56
|
inputSchema: {
|
|
46
|
-
index: z
|
|
47
|
-
|
|
57
|
+
index: z
|
|
58
|
+
.number()
|
|
59
|
+
.int()
|
|
60
|
+
.positive()
|
|
61
|
+
.describe( "1-based index of the todo item to remove" ),
|
|
62
|
+
},
|
|
48
63
|
},
|
|
49
64
|
async ({ index }) =>
|
|
50
65
|
{
|
|
51
66
|
const i = index - 1;
|
|
52
67
|
if ( i < 0 || i >= todos.length )
|
|
53
68
|
{
|
|
54
|
-
return {
|
|
69
|
+
return {
|
|
70
|
+
content: [{ type: "text", text: `Invalid index: ${index}` }],
|
|
71
|
+
};
|
|
55
72
|
}
|
|
56
73
|
const removed = todos.splice( i, 1 )[0];
|
|
57
|
-
return {
|
|
74
|
+
return {
|
|
75
|
+
content: [{ type: "text", text: `Removed TODO: "${removed}"` }],
|
|
76
|
+
};
|
|
58
77
|
}
|
|
59
78
|
);
|
|
60
79
|
}
|