-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtools.ts
More file actions
119 lines (115 loc) · 3.59 KB
/
tools.ts
File metadata and controls
119 lines (115 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* NESTchat — Tool Definitions
*
* Add these to your TOOLS array in the worker (MCP tool list)
* and to your CHAT_TOOLS in the gateway (OpenAI function calling format).
*/
// ─── MCP Tool Definitions (for worker TOOLS array) ──────────────────────────
export const NESTCHAT_MCP_TOOLS = [
{
name: "nestchat_persist",
description: "Store chat messages and session to D1. Called by gateway after each response.",
inputSchema: {
type: "object",
properties: {
session_id: { type: "string", description: "Session identifier (generated by client)" },
room: { type: "string", description: "Which room: chat, workshop, porch (default: chat)" },
messages: {
type: "array",
items: {
type: "object",
properties: {
role: { type: "string" },
content: { type: "string" },
tool_calls: { type: "string", description: "JSON string of tool calls if any" }
}
},
description: "Array of messages to persist"
}
},
required: ["session_id", "messages"]
}
},
{
name: "nestchat_summarize",
description: "Generate and vectorize a summary for a chat session.",
inputSchema: {
type: "object",
properties: {
session_id: { type: "number", description: "D1 session ID to summarize" }
},
required: ["session_id"]
}
},
{
name: "nestchat_search",
description: "Semantic search across chat summaries. Find past conversations by meaning.",
inputSchema: {
type: "object",
properties: {
query: { type: "string", description: "What to search for" },
limit: { type: "number", description: "Max results (default 10)" },
room: { type: "string", description: "Filter by room (optional)" }
},
required: ["query"]
}
},
{
name: "nestchat_history",
description: "Fetch full message history for a specific chat session.",
inputSchema: {
type: "object",
properties: {
session_id: { type: "number", description: "D1 session ID" }
},
required: ["session_id"]
}
}
];
// ─── Gateway Tool Definitions (OpenAI function calling format) ──────────────
export const NESTCHAT_GATEWAY_TOOLS = [
{
type: 'function' as const,
function: {
name: 'nestchat_search',
description: 'Search past conversations by meaning. Semantic search across chat summaries.',
parameters: {
type: 'object',
properties: {
query: { type: 'string', description: 'What to search for' },
limit: { type: 'number', description: 'Max results (default 10)' },
room: { type: 'string', description: 'Filter by room (optional)' }
},
required: ['query']
}
}
},
{
type: 'function' as const,
function: {
name: 'nestchat_history',
description: 'Fetch full message history for a chat session by ID.',
parameters: {
type: 'object',
properties: {
session_id: { type: 'number', description: 'Session ID from search results' }
},
required: ['session_id']
}
}
},
{
type: 'function' as const,
function: {
name: 'nestchat_summarize',
description: 'Generate and vectorize a summary for a chat session.',
parameters: {
type: 'object',
properties: {
session_id: { type: 'number', description: 'D1 session ID' }
},
required: ['session_id']
}
}
}
];