jinn-cli 0.3.0 → 0.3.1
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/LICENSE +21 -0
- package/dist/bin/jimmy.js +0 -0
- package/dist/src/cli/chrome-allow.d.ts.map +1 -1
- package/dist/src/cli/chrome-allow.js +14 -5
- package/dist/src/cli/chrome-allow.js.map +1 -1
- package/dist/src/cli/list.js +1 -1
- package/dist/src/cli/list.js.map +1 -1
- package/dist/src/cli/nuke.js +2 -2
- package/dist/src/cli/nuke.js.map +1 -1
- package/dist/src/cli/setup.d.ts.map +1 -1
- package/dist/src/cli/setup.js +2 -1
- package/dist/src/cli/setup.js.map +1 -1
- package/dist/src/connectors/slack/index.d.ts +9 -1
- package/dist/src/connectors/slack/index.d.ts.map +1 -1
- package/dist/src/connectors/slack/index.js +172 -8
- package/dist/src/connectors/slack/index.js.map +1 -1
- package/dist/src/connectors/slack/threads.d.ts +1 -4
- package/dist/src/connectors/slack/threads.d.ts.map +1 -1
- package/dist/src/connectors/slack/threads.js +17 -7
- package/dist/src/connectors/slack/threads.js.map +1 -1
- package/dist/src/connectors/slack/threads.test.js +42 -8
- package/dist/src/connectors/slack/threads.test.js.map +1 -1
- package/dist/src/cron/runner.d.ts.map +1 -1
- package/dist/src/cron/runner.js +16 -5
- package/dist/src/cron/runner.js.map +1 -1
- package/dist/src/engines/claude.d.ts.map +1 -1
- package/dist/src/engines/claude.js +19 -4
- package/dist/src/engines/claude.js.map +1 -1
- package/dist/src/gateway/api.d.ts.map +1 -1
- package/dist/src/gateway/api.js +207 -3
- package/dist/src/gateway/api.js.map +1 -1
- package/dist/src/gateway/lifecycle.d.ts.map +1 -1
- package/dist/src/gateway/lifecycle.js +16 -6
- package/dist/src/gateway/lifecycle.js.map +1 -1
- package/dist/src/gateway/org.d.ts.map +1 -1
- package/dist/src/gateway/org.js +1 -0
- package/dist/src/gateway/org.js.map +1 -1
- package/dist/src/gateway/server.d.ts.map +1 -1
- package/dist/src/gateway/server.js +40 -1
- package/dist/src/gateway/server.js.map +1 -1
- package/dist/src/gateway/watcher.d.ts.map +1 -1
- package/dist/src/gateway/watcher.js +9 -2
- package/dist/src/gateway/watcher.js.map +1 -1
- package/dist/src/mcp/gateway-server.d.ts +13 -0
- package/dist/src/mcp/gateway-server.d.ts.map +1 -0
- package/dist/src/mcp/gateway-server.js +375 -0
- package/dist/src/mcp/gateway-server.js.map +1 -0
- package/dist/src/mcp/resolver.d.ts +19 -0
- package/dist/src/mcp/resolver.d.ts.map +1 -0
- package/dist/src/mcp/resolver.js +153 -0
- package/dist/src/mcp/resolver.js.map +1 -0
- package/dist/src/sessions/context.d.ts +1 -0
- package/dist/src/sessions/context.d.ts.map +1 -1
- package/dist/src/sessions/context.js +34 -3
- package/dist/src/sessions/context.js.map +1 -1
- package/dist/src/sessions/limits.d.ts +7 -0
- package/dist/src/sessions/limits.d.ts.map +1 -0
- package/dist/src/sessions/limits.js +42 -0
- package/dist/src/sessions/limits.js.map +1 -0
- package/dist/src/sessions/manager.d.ts +3 -1
- package/dist/src/sessions/manager.d.ts.map +1 -1
- package/dist/src/sessions/manager.js +38 -17
- package/dist/src/sessions/manager.js.map +1 -1
- package/dist/src/sessions/registry.d.ts +6 -0
- package/dist/src/sessions/registry.d.ts.map +1 -1
- package/dist/src/sessions/registry.js +34 -5
- package/dist/src/sessions/registry.js.map +1 -1
- package/dist/src/shared/effort.d.ts +17 -0
- package/dist/src/shared/effort.d.ts.map +1 -0
- package/dist/src/shared/effort.js +44 -0
- package/dist/src/shared/effort.js.map +1 -0
- package/dist/src/shared/paths.d.ts +2 -0
- package/dist/src/shared/paths.d.ts.map +1 -1
- package/dist/src/shared/paths.js +2 -0
- package/dist/src/shared/paths.js.map +1 -1
- package/dist/src/shared/types.d.ts +57 -1
- package/dist/src/shared/types.d.ts.map +1 -1
- package/dist/src/stt/stt.d.ts +24 -0
- package/dist/src/stt/stt.d.ts.map +1 -0
- package/dist/src/stt/stt.js +203 -0
- package/dist/src/stt/stt.js.map +1 -0
- package/dist/web/404.html +1 -1
- package/dist/web/_next/static/chunks/198-3e82ded4f04a0aae.js +1 -0
- package/dist/web/_next/static/chunks/{704-af2893821e1d18dc.js → 704-ca24be493a922639.js} +1 -1
- package/dist/web/_next/static/chunks/{73-c226535579393e21.js → 73-2d6e730cea0fe6c8.js} +1 -1
- package/dist/web/_next/static/chunks/app/_not-found/{page-bb075b0779827928.js → page-7d43a486b7014af3.js} +1 -1
- package/dist/web/_next/static/chunks/app/chat/page-2f3c561ed768ed58.js +1 -0
- package/dist/web/_next/static/chunks/app/costs/{page-d6c03718defdb599.js → page-13a6f2c65a827f8a.js} +1 -1
- package/dist/web/_next/static/chunks/app/cron/{page-4c563eef2b6231fe.js → page-0ee07a679c7b79aa.js} +1 -1
- package/dist/web/_next/static/chunks/app/kanban/{page-55a73165a36f4077.js → page-a7facadd4194faae.js} +1 -1
- package/dist/web/_next/static/chunks/app/layout-fd975d16033dab25.js +1 -0
- package/dist/web/_next/static/chunks/app/logs/page-6de6b16523e85193.js +1 -0
- package/dist/web/_next/static/chunks/app/org/{page-d5cd8d9b7864737b.js → page-cd9d362e77f4799e.js} +1 -1
- package/dist/web/_next/static/chunks/app/{page-b81992940fd1dbc6.js → page-b98417ed4f4d45a0.js} +1 -1
- package/dist/web/_next/static/chunks/app/sessions/page-7148306182017841.js +1 -0
- package/dist/web/_next/static/chunks/app/settings/page-34c9276e2a012445.js +1 -0
- package/dist/web/_next/static/chunks/app/skills/page-18cf3b7bb9a7339c.js +1 -0
- package/dist/web/_next/static/chunks/main-app-0c65af8a0fd99888.js +1 -0
- package/dist/web/_next/static/css/24da9dfc818cea32.css +1 -0
- package/dist/web/chat.html +1 -1
- package/dist/web/chat.txt +5 -5
- package/dist/web/costs.html +2 -2
- package/dist/web/costs.txt +5 -5
- package/dist/web/cron.html +1 -1
- package/dist/web/cron.txt +5 -5
- package/dist/web/index.html +1 -1
- package/dist/web/index.txt +5 -5
- package/dist/web/kanban.html +1 -1
- package/dist/web/kanban.txt +5 -5
- package/dist/web/logs.html +2 -2
- package/dist/web/logs.txt +5 -5
- package/dist/web/org.html +1 -1
- package/dist/web/org.txt +5 -5
- package/dist/web/sessions.html +1 -1
- package/dist/web/sessions.txt +5 -5
- package/dist/web/settings.html +1 -1
- package/dist/web/settings.txt +5 -5
- package/dist/web/skills.html +1 -1
- package/dist/web/skills.txt +5 -5
- package/package.json +9 -9
- package/template/config.default.yaml +32 -0
- package/template/docs/mcp.md +108 -0
- package/dist/web/_next/static/chunks/198-fd91406a158c5c25.js +0 -1
- package/dist/web/_next/static/chunks/app/chat/page-6d5bc707a45c92c6.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-5129b67d5f126cf0.js +0 -1
- package/dist/web/_next/static/chunks/app/logs/page-e18889d67e48c9c9.js +0 -1
- package/dist/web/_next/static/chunks/app/sessions/page-c83c890177c18258.js +0 -1
- package/dist/web/_next/static/chunks/app/settings/page-2583d55551abdf72.js +0 -1
- package/dist/web/_next/static/chunks/app/skills/page-df9465e314561bb5.js +0 -1
- package/dist/web/_next/static/chunks/main-app-437f51faf74fbb3b.js +0 -1
- package/dist/web/_next/static/css/4a6a5bca9238c104.css +0 -1
- /package/dist/web/_next/static/{jt8R5JvUgfB9CMfFwWFr0 → Zn588p2VvgjCSLr44R__1}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{jt8R5JvUgfB9CMfFwWFr0 → Zn588p2VvgjCSLr44R__1}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Jinn Gateway MCP Server
|
|
4
|
+
*
|
|
5
|
+
* A Model Context Protocol (MCP) server that gives AI employees
|
|
6
|
+
* first-class access to the Jinn gateway API. Instead of crafting
|
|
7
|
+
* curl commands, employees get typed tools for messaging, org queries,
|
|
8
|
+
* session management, and cron control.
|
|
9
|
+
*
|
|
10
|
+
* Started as a stdio subprocess by Claude Code via --mcp-config.
|
|
11
|
+
*/
|
|
12
|
+
import { createInterface } from "node:readline";
|
|
13
|
+
const GATEWAY_URL = process.env.JINN_GATEWAY_URL || "http://127.0.0.1:7777";
|
|
14
|
+
// ─── Tool Definitions ───
|
|
15
|
+
const TOOLS = [
|
|
16
|
+
{
|
|
17
|
+
name: "send_message",
|
|
18
|
+
description: "Send a message to a Slack channel or other connector. Use this to proactively communicate with the user or post to specific channels.",
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
connector: { type: "string", description: "Connector name (e.g. 'slack')", default: "slack" },
|
|
23
|
+
channel: { type: "string", description: "Channel ID or name (e.g. '#general', 'C0ACR0ZVD7H')" },
|
|
24
|
+
text: { type: "string", description: "Message text to send" },
|
|
25
|
+
thread: { type: "string", description: "Thread timestamp to reply in (optional)" },
|
|
26
|
+
},
|
|
27
|
+
required: ["channel", "text"],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "list_sessions",
|
|
32
|
+
description: "List all active sessions in the Jinn gateway. Returns session IDs, employees, status, and timestamps.",
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: {
|
|
36
|
+
status: { type: "string", enum: ["idle", "running", "error"], description: "Filter by status" },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "get_session",
|
|
42
|
+
description: "Get details and message history for a specific session.",
|
|
43
|
+
inputSchema: {
|
|
44
|
+
type: "object",
|
|
45
|
+
properties: {
|
|
46
|
+
sessionId: { type: "string", description: "Session ID to look up" },
|
|
47
|
+
},
|
|
48
|
+
required: ["sessionId"],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "create_child_session",
|
|
53
|
+
description: "Create a child session to delegate work to another employee. The child session runs asynchronously.",
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: {
|
|
57
|
+
employee: { type: "string", description: "Employee name to delegate to (e.g. 'homy-writer')" },
|
|
58
|
+
prompt: { type: "string", description: "Task/instruction for the employee" },
|
|
59
|
+
parentSessionId: { type: "string", description: "Your current session ID (for tracking)" },
|
|
60
|
+
engine: { type: "string", description: "Engine override (claude or codex)" },
|
|
61
|
+
model: { type: "string", description: "Model override" },
|
|
62
|
+
},
|
|
63
|
+
required: ["employee", "prompt"],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "send_to_session",
|
|
68
|
+
description: "Send a follow-up message to an existing session (e.g. to give feedback to a child session).",
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: "object",
|
|
71
|
+
properties: {
|
|
72
|
+
sessionId: { type: "string", description: "Session ID to send to" },
|
|
73
|
+
message: { type: "string", description: "Follow-up message" },
|
|
74
|
+
},
|
|
75
|
+
required: ["sessionId", "message"],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "list_employees",
|
|
80
|
+
description: "List all employees in the organization with their departments and roles.",
|
|
81
|
+
inputSchema: {
|
|
82
|
+
type: "object",
|
|
83
|
+
properties: {},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "get_employee",
|
|
88
|
+
description: "Get detailed information about a specific employee.",
|
|
89
|
+
inputSchema: {
|
|
90
|
+
type: "object",
|
|
91
|
+
properties: {
|
|
92
|
+
name: { type: "string", description: "Employee name (kebab-case)" },
|
|
93
|
+
},
|
|
94
|
+
required: ["name"],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "update_board",
|
|
99
|
+
description: "Update a department's task board. Use to add, move, or complete tasks.",
|
|
100
|
+
inputSchema: {
|
|
101
|
+
type: "object",
|
|
102
|
+
properties: {
|
|
103
|
+
department: { type: "string", description: "Department name" },
|
|
104
|
+
board: {
|
|
105
|
+
type: "array",
|
|
106
|
+
description: "Full board array (replace entire board)",
|
|
107
|
+
items: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties: {
|
|
110
|
+
id: { type: "string" },
|
|
111
|
+
title: { type: "string" },
|
|
112
|
+
status: { type: "string", enum: ["todo", "in_progress", "done"] },
|
|
113
|
+
assignee: { type: "string" },
|
|
114
|
+
priority: { type: "string", enum: ["low", "medium", "high", "urgent"] },
|
|
115
|
+
notes: { type: "string" },
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
required: ["department", "board"],
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "get_board",
|
|
125
|
+
description: "Get the task board for a department.",
|
|
126
|
+
inputSchema: {
|
|
127
|
+
type: "object",
|
|
128
|
+
properties: {
|
|
129
|
+
department: { type: "string", description: "Department name" },
|
|
130
|
+
},
|
|
131
|
+
required: ["department"],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "list_cron_jobs",
|
|
136
|
+
description: "List all configured cron jobs with their schedules and status.",
|
|
137
|
+
inputSchema: {
|
|
138
|
+
type: "object",
|
|
139
|
+
properties: {},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "trigger_cron_job",
|
|
144
|
+
description: "Manually trigger a cron job to run immediately.",
|
|
145
|
+
inputSchema: {
|
|
146
|
+
type: "object",
|
|
147
|
+
properties: {
|
|
148
|
+
jobId: { type: "string", description: "Cron job ID or name" },
|
|
149
|
+
},
|
|
150
|
+
required: ["jobId"],
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "update_cron_job",
|
|
155
|
+
description: "Enable, disable, or update a cron job.",
|
|
156
|
+
inputSchema: {
|
|
157
|
+
type: "object",
|
|
158
|
+
properties: {
|
|
159
|
+
jobId: { type: "string", description: "Cron job ID" },
|
|
160
|
+
enabled: { type: "boolean", description: "Enable or disable the job" },
|
|
161
|
+
schedule: { type: "string", description: "New cron schedule expression" },
|
|
162
|
+
prompt: { type: "string", description: "New prompt for the job" },
|
|
163
|
+
},
|
|
164
|
+
required: ["jobId"],
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
];
|
|
168
|
+
// ─── API Helpers ───
|
|
169
|
+
async function apiGet(path) {
|
|
170
|
+
const res = await fetch(`${GATEWAY_URL}${path}`);
|
|
171
|
+
if (!res.ok)
|
|
172
|
+
throw new Error(`API ${path}: ${res.status} ${res.statusText}`);
|
|
173
|
+
return res.json();
|
|
174
|
+
}
|
|
175
|
+
async function apiPost(path, body) {
|
|
176
|
+
const res = await fetch(`${GATEWAY_URL}${path}`, {
|
|
177
|
+
method: "POST",
|
|
178
|
+
headers: { "Content-Type": "application/json" },
|
|
179
|
+
body: JSON.stringify(body),
|
|
180
|
+
});
|
|
181
|
+
if (!res.ok) {
|
|
182
|
+
const text = await res.text();
|
|
183
|
+
throw new Error(`API ${path}: ${res.status} ${text}`);
|
|
184
|
+
}
|
|
185
|
+
return res.json();
|
|
186
|
+
}
|
|
187
|
+
async function apiPut(path, body) {
|
|
188
|
+
const res = await fetch(`${GATEWAY_URL}${path}`, {
|
|
189
|
+
method: "PUT",
|
|
190
|
+
headers: { "Content-Type": "application/json" },
|
|
191
|
+
body: JSON.stringify(body),
|
|
192
|
+
});
|
|
193
|
+
if (!res.ok)
|
|
194
|
+
throw new Error(`API ${path}: ${res.status} ${res.statusText}`);
|
|
195
|
+
return res.json();
|
|
196
|
+
}
|
|
197
|
+
// ─── Tool Handlers ───
|
|
198
|
+
async function handleTool(name, args) {
|
|
199
|
+
switch (name) {
|
|
200
|
+
case "send_message": {
|
|
201
|
+
const connector = args.connector || "slack";
|
|
202
|
+
const result = await apiPost(`/api/connectors/${connector}/send`, {
|
|
203
|
+
channel: args.channel,
|
|
204
|
+
text: args.text,
|
|
205
|
+
thread: args.thread,
|
|
206
|
+
});
|
|
207
|
+
return JSON.stringify(result);
|
|
208
|
+
}
|
|
209
|
+
case "list_sessions": {
|
|
210
|
+
const sessions = await apiGet("/api/sessions");
|
|
211
|
+
const filtered = args.status
|
|
212
|
+
? sessions.filter((s) => s.status === args.status)
|
|
213
|
+
: sessions;
|
|
214
|
+
// Return a summary, not the full data
|
|
215
|
+
const summary = filtered.map((s) => ({
|
|
216
|
+
id: s.id,
|
|
217
|
+
employee: s.employee,
|
|
218
|
+
engine: s.engine,
|
|
219
|
+
status: s.status,
|
|
220
|
+
source: s.source,
|
|
221
|
+
title: s.title,
|
|
222
|
+
lastActivity: s.lastActivity,
|
|
223
|
+
lastError: s.lastError,
|
|
224
|
+
}));
|
|
225
|
+
return JSON.stringify(summary);
|
|
226
|
+
}
|
|
227
|
+
case "get_session": {
|
|
228
|
+
const session = await apiGet(`/api/sessions/${args.sessionId}`);
|
|
229
|
+
return JSON.stringify(session);
|
|
230
|
+
}
|
|
231
|
+
case "create_child_session": {
|
|
232
|
+
const result = await apiPost("/api/sessions", {
|
|
233
|
+
prompt: args.prompt,
|
|
234
|
+
employee: args.employee,
|
|
235
|
+
engine: args.engine,
|
|
236
|
+
parentSessionId: args.parentSessionId,
|
|
237
|
+
});
|
|
238
|
+
return JSON.stringify(result);
|
|
239
|
+
}
|
|
240
|
+
case "send_to_session": {
|
|
241
|
+
const result = await apiPost(`/api/sessions/${args.sessionId}/message`, {
|
|
242
|
+
message: args.message,
|
|
243
|
+
});
|
|
244
|
+
return JSON.stringify(result);
|
|
245
|
+
}
|
|
246
|
+
case "list_employees": {
|
|
247
|
+
const org = await apiGet("/api/org");
|
|
248
|
+
return JSON.stringify(org);
|
|
249
|
+
}
|
|
250
|
+
case "get_employee": {
|
|
251
|
+
const employee = await apiGet(`/api/org/employees/${args.name}`);
|
|
252
|
+
return JSON.stringify(employee);
|
|
253
|
+
}
|
|
254
|
+
case "update_board": {
|
|
255
|
+
const result = await apiPut(`/api/org/departments/${args.department}/board`, args.board);
|
|
256
|
+
return JSON.stringify(result);
|
|
257
|
+
}
|
|
258
|
+
case "get_board": {
|
|
259
|
+
const board = await apiGet(`/api/org/departments/${args.department}/board`);
|
|
260
|
+
return JSON.stringify(board);
|
|
261
|
+
}
|
|
262
|
+
case "list_cron_jobs": {
|
|
263
|
+
const jobs = await apiGet("/api/cron");
|
|
264
|
+
return JSON.stringify(jobs);
|
|
265
|
+
}
|
|
266
|
+
case "trigger_cron_job": {
|
|
267
|
+
// Use the /cron command handler via a synthetic session message
|
|
268
|
+
// For now, just return the job info
|
|
269
|
+
const jobs = await apiGet("/api/cron");
|
|
270
|
+
const job = jobs.find((j) => j.id === args.jobId || j.name === args.jobId);
|
|
271
|
+
if (!job)
|
|
272
|
+
return JSON.stringify({ error: `Job "${args.jobId}" not found` });
|
|
273
|
+
return JSON.stringify({ status: "triggered", job });
|
|
274
|
+
}
|
|
275
|
+
case "update_cron_job": {
|
|
276
|
+
const result = await apiPut(`/api/cron/${args.jobId}`, {
|
|
277
|
+
...(args.enabled !== undefined ? { enabled: args.enabled } : {}),
|
|
278
|
+
...(args.schedule ? { schedule: args.schedule } : {}),
|
|
279
|
+
...(args.prompt ? { prompt: args.prompt } : {}),
|
|
280
|
+
});
|
|
281
|
+
return JSON.stringify(result);
|
|
282
|
+
}
|
|
283
|
+
default:
|
|
284
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
// ─── MCP Protocol Handler ───
|
|
288
|
+
function sendResponse(response) {
|
|
289
|
+
const json = JSON.stringify(response);
|
|
290
|
+
process.stdout.write(json + "\n");
|
|
291
|
+
}
|
|
292
|
+
async function handleRequest(request) {
|
|
293
|
+
const { id, method, params } = request;
|
|
294
|
+
switch (method) {
|
|
295
|
+
case "initialize":
|
|
296
|
+
sendResponse({
|
|
297
|
+
jsonrpc: "2.0",
|
|
298
|
+
id,
|
|
299
|
+
result: {
|
|
300
|
+
protocolVersion: "2024-11-05",
|
|
301
|
+
capabilities: {
|
|
302
|
+
tools: {},
|
|
303
|
+
},
|
|
304
|
+
serverInfo: {
|
|
305
|
+
name: "jinn-gateway",
|
|
306
|
+
version: "0.1.0",
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
break;
|
|
311
|
+
case "tools/list":
|
|
312
|
+
sendResponse({
|
|
313
|
+
jsonrpc: "2.0",
|
|
314
|
+
id,
|
|
315
|
+
result: { tools: TOOLS },
|
|
316
|
+
});
|
|
317
|
+
break;
|
|
318
|
+
case "tools/call": {
|
|
319
|
+
const toolName = params?.name;
|
|
320
|
+
const toolArgs = params?.arguments || {};
|
|
321
|
+
try {
|
|
322
|
+
const result = await handleTool(toolName, toolArgs);
|
|
323
|
+
sendResponse({
|
|
324
|
+
jsonrpc: "2.0",
|
|
325
|
+
id,
|
|
326
|
+
result: {
|
|
327
|
+
content: [{ type: "text", text: result }],
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
catch (err) {
|
|
332
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
333
|
+
sendResponse({
|
|
334
|
+
jsonrpc: "2.0",
|
|
335
|
+
id,
|
|
336
|
+
result: {
|
|
337
|
+
content: [{ type: "text", text: `Error: ${msg}` }],
|
|
338
|
+
isError: true,
|
|
339
|
+
},
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
case "notifications/initialized":
|
|
345
|
+
// Client acknowledged initialization, no response needed
|
|
346
|
+
break;
|
|
347
|
+
default:
|
|
348
|
+
sendResponse({
|
|
349
|
+
jsonrpc: "2.0",
|
|
350
|
+
id,
|
|
351
|
+
error: { code: -32601, message: `Method not found: ${method}` },
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
// ─── Main ───
|
|
356
|
+
const rl = createInterface({ input: process.stdin });
|
|
357
|
+
rl.on("line", (line) => {
|
|
358
|
+
try {
|
|
359
|
+
const request = JSON.parse(line);
|
|
360
|
+
handleRequest(request).catch((err) => {
|
|
361
|
+
sendResponse({
|
|
362
|
+
jsonrpc: "2.0",
|
|
363
|
+
id: request.id,
|
|
364
|
+
error: { code: -32603, message: err instanceof Error ? err.message : String(err) },
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
catch {
|
|
369
|
+
// Ignore unparseable lines
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
rl.on("close", () => {
|
|
373
|
+
process.exit(0);
|
|
374
|
+
});
|
|
375
|
+
//# sourceMappingURL=gateway-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-server.js","sourceRoot":"","sources":["../../../src/mcp/gateway-server.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,uBAAuB,CAAC;AAkB5E,2BAA2B;AAE3B,MAAM,KAAK,GAAG;IACZ;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,uIAAuI;QACpJ,WAAW,EAAE;YACX,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,+BAA+B,EAAE,OAAO,EAAE,OAAO,EAAE;gBAC7F,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qDAAqD,EAAE;gBAC/F,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE;gBAC7D,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yCAAyC,EAAE;aACnF;YACD,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;SAC9B;KACF;IACD;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,uGAAuG;QACpH,WAAW,EAAE;YACX,IAAI,EAAE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E,CAAC,CAAC;AAErD,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;IACrB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAmB,CAAC;QACnD,aAAa,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACnC,YAAY,CAAC;gBACX,OAAO,EAAE,KAAK;gBACd,EAAE,EAAE,OAAO,CAAC,EAAE;gBACd,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;aACnF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,2BAA2B;IAC7B,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { McpGlobalConfig, McpServerConfig, Employee } from "../shared/types.js";
|
|
2
|
+
export interface ResolvedMcpConfig {
|
|
3
|
+
mcpServers: Record<string, McpServerConfig>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Resolve the MCP servers that should be available for a given employee
|
|
7
|
+
* based on global config and employee-level overrides.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveMcpServers(globalMcp: McpGlobalConfig | undefined, employee?: Employee): ResolvedMcpConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Write a resolved MCP config to a temp file and return the path.
|
|
12
|
+
* Claude Code reads this via --mcp-config <path>.
|
|
13
|
+
*/
|
|
14
|
+
export declare function writeMcpConfigFile(config: ResolvedMcpConfig, sessionId: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Clean up a temp MCP config file.
|
|
17
|
+
*/
|
|
18
|
+
export declare function cleanupMcpConfigFile(sessionId: string): void;
|
|
19
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/mcp/resolver.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAIrF,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,eAAe,GAAG,SAAS,EACtC,QAAQ,CAAC,EAAE,QAAQ,GAClB,iBAAiB,CA+BnB;AAyFD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAMvF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAO5D"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { JINN_HOME } from "../shared/paths.js";
|
|
4
|
+
import { logger } from "../shared/logger.js";
|
|
5
|
+
/**
|
|
6
|
+
* Resolve the MCP servers that should be available for a given employee
|
|
7
|
+
* based on global config and employee-level overrides.
|
|
8
|
+
*/
|
|
9
|
+
export function resolveMcpServers(globalMcp, employee) {
|
|
10
|
+
const servers = {};
|
|
11
|
+
if (!globalMcp)
|
|
12
|
+
return { mcpServers: servers };
|
|
13
|
+
// Build the full set of available MCP servers from global config
|
|
14
|
+
const available = buildAvailableServers(globalMcp);
|
|
15
|
+
// Determine which servers this employee gets
|
|
16
|
+
const employeeMcp = employee?.mcp;
|
|
17
|
+
if (employeeMcp === false) {
|
|
18
|
+
// Employee explicitly opted out of all MCP servers
|
|
19
|
+
return { mcpServers: {} };
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(employeeMcp)) {
|
|
22
|
+
// Employee wants only specific servers
|
|
23
|
+
for (const name of employeeMcp) {
|
|
24
|
+
if (available[name]) {
|
|
25
|
+
servers[name] = available[name];
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
logger.warn(`Employee ${employee?.name} requests MCP server "${name}" but it's not configured`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// Employee gets all enabled servers (default behavior, or mcp: true)
|
|
34
|
+
Object.assign(servers, available);
|
|
35
|
+
}
|
|
36
|
+
return { mcpServers: servers };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Build the map of all available (enabled) MCP servers from global config.
|
|
40
|
+
*/
|
|
41
|
+
function buildAvailableServers(config) {
|
|
42
|
+
const servers = {};
|
|
43
|
+
// Browser automation via Playwright
|
|
44
|
+
if (config.browser?.enabled !== false) {
|
|
45
|
+
const provider = config.browser?.provider || "playwright";
|
|
46
|
+
if (provider === "playwright") {
|
|
47
|
+
servers.browser = {
|
|
48
|
+
command: "npx",
|
|
49
|
+
args: ["-y", "@anthropic-ai/mcp-server-playwright"],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
else if (provider === "puppeteer") {
|
|
53
|
+
servers.browser = {
|
|
54
|
+
command: "npx",
|
|
55
|
+
args: ["-y", "@anthropic-ai/mcp-server-puppeteer"],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Web search via Brave
|
|
60
|
+
if (config.search?.enabled) {
|
|
61
|
+
const apiKey = resolveEnvVar(config.search.apiKey);
|
|
62
|
+
if (apiKey) {
|
|
63
|
+
servers.search = {
|
|
64
|
+
command: "npx",
|
|
65
|
+
args: ["-y", "brave-search-mcp"],
|
|
66
|
+
env: { BRAVE_API_KEY: apiKey },
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
logger.warn("MCP search enabled but no API key configured (set mcp.search.apiKey or BRAVE_API_KEY env var)");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Web fetch (content extraction)
|
|
74
|
+
if (config.fetch?.enabled) {
|
|
75
|
+
servers.fetch = {
|
|
76
|
+
command: "npx",
|
|
77
|
+
args: ["-y", "@anthropic-ai/mcp-server-fetch"],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// Gateway MCP server (built-in, always uses the local gateway)
|
|
81
|
+
if (config.gateway?.enabled !== false) {
|
|
82
|
+
const gatewayMcpPath = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..", "..", "dist", "src", "mcp", "gateway-server.js");
|
|
83
|
+
// Only add if the built file exists; otherwise fall back to ts-node path
|
|
84
|
+
const scriptPath = fs.existsSync(gatewayMcpPath)
|
|
85
|
+
? gatewayMcpPath
|
|
86
|
+
: path.resolve(path.dirname(new URL(import.meta.url).pathname), "gateway-server.js");
|
|
87
|
+
servers.gateway = {
|
|
88
|
+
command: "node",
|
|
89
|
+
args: [scriptPath],
|
|
90
|
+
env: {
|
|
91
|
+
JINN_GATEWAY_URL: `http://127.0.0.1:${process.env.JINN_PORT || "7777"}`,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// Custom user-defined MCP servers
|
|
96
|
+
if (config.custom) {
|
|
97
|
+
for (const [name, serverConfig] of Object.entries(config.custom)) {
|
|
98
|
+
if (serverConfig.enabled === false)
|
|
99
|
+
continue;
|
|
100
|
+
const { enabled, ...rest } = serverConfig;
|
|
101
|
+
// Resolve env vars in the custom config
|
|
102
|
+
if (rest.env) {
|
|
103
|
+
for (const [key, value] of Object.entries(rest.env)) {
|
|
104
|
+
rest.env[key] = resolveEnvVar(value) || value;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
servers[name] = rest;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return servers;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Write a resolved MCP config to a temp file and return the path.
|
|
114
|
+
* Claude Code reads this via --mcp-config <path>.
|
|
115
|
+
*/
|
|
116
|
+
export function writeMcpConfigFile(config, sessionId) {
|
|
117
|
+
const tmpDir = path.join(JINN_HOME, "tmp", "mcp");
|
|
118
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
119
|
+
const filePath = path.join(tmpDir, `${sessionId}.json`);
|
|
120
|
+
fs.writeFileSync(filePath, JSON.stringify(config, null, 2));
|
|
121
|
+
return filePath;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Clean up a temp MCP config file.
|
|
125
|
+
*/
|
|
126
|
+
export function cleanupMcpConfigFile(sessionId) {
|
|
127
|
+
const filePath = path.join(JINN_HOME, "tmp", "mcp", `${sessionId}.json`);
|
|
128
|
+
try {
|
|
129
|
+
if (fs.existsSync(filePath))
|
|
130
|
+
fs.unlinkSync(filePath);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// Ignore cleanup errors
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Resolve a value that may reference an environment variable.
|
|
138
|
+
* Supports ${VAR_NAME} syntax.
|
|
139
|
+
*/
|
|
140
|
+
function resolveEnvVar(value) {
|
|
141
|
+
if (!value)
|
|
142
|
+
return undefined;
|
|
143
|
+
const match = value.match(/^\$\{(.+)\}$/);
|
|
144
|
+
if (match) {
|
|
145
|
+
return process.env[match[1]] || undefined;
|
|
146
|
+
}
|
|
147
|
+
// Also check if the raw value is a plain env var name
|
|
148
|
+
if (value.startsWith("$")) {
|
|
149
|
+
return process.env[value.slice(1)] || undefined;
|
|
150
|
+
}
|
|
151
|
+
return value;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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AAC,CAAC;IAC1C,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;IAC5C,CAAC;IACD,sDAAsD;IACtD,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;IAClD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/sessions/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAK/D;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/sessions/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAK/D;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,CAqET"}
|
|
@@ -60,7 +60,7 @@ export function buildContext(opts) {
|
|
|
60
60
|
sections.push(envCtx);
|
|
61
61
|
// ── Delegation protocol ──────────────────────────────────
|
|
62
62
|
if (!opts.employee) {
|
|
63
|
-
sections.push(buildDelegationProtocol(gatewayUrl, portalName));
|
|
63
|
+
sections.push(buildDelegationProtocol(gatewayUrl, portalName, opts.config));
|
|
64
64
|
}
|
|
65
65
|
// ── Gateway API reference ─────────────────────────────────
|
|
66
66
|
sections.push(buildApiReference(gatewayUrl, portalName));
|
|
@@ -140,7 +140,15 @@ function buildSessionContext(opts) {
|
|
|
140
140
|
if (opts.sessionId)
|
|
141
141
|
ctx += `- Session ID: ${opts.sessionId}\n`;
|
|
142
142
|
ctx += `- Source: ${opts.source}\n`;
|
|
143
|
-
|
|
143
|
+
if (opts.channelName) {
|
|
144
|
+
ctx += `- Channel: #${opts.channelName} (${opts.channel})\n`;
|
|
145
|
+
}
|
|
146
|
+
else if (opts.source === "slack" && opts.channel.startsWith("D")) {
|
|
147
|
+
ctx += `- Channel: Direct Message (${opts.channel})\n`;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
ctx += `- Channel: ${opts.channel}\n`;
|
|
151
|
+
}
|
|
144
152
|
if (opts.thread)
|
|
145
153
|
ctx += `- Thread: ${opts.thread}\n`;
|
|
146
154
|
ctx += `- User: ${opts.user}\n`;
|
|
@@ -349,7 +357,13 @@ function trimContext(sections) {
|
|
|
349
357
|
}
|
|
350
358
|
return result;
|
|
351
359
|
}
|
|
352
|
-
function buildDelegationProtocol(gatewayUrl, _portalName) {
|
|
360
|
+
function buildDelegationProtocol(gatewayUrl, _portalName, config) {
|
|
361
|
+
const defaultEngine = config?.engines.default || "claude";
|
|
362
|
+
const engineConfig = defaultEngine === "codex" ? config?.engines.codex : config?.engines.claude;
|
|
363
|
+
const childOverride = engineConfig?.childEffortOverride;
|
|
364
|
+
const effortOverrideNote = childOverride
|
|
365
|
+
? `\n\n> **Note**: \`childEffortOverride\` is currently set to \`"${childOverride}"\` in config. All child sessions will use this effort level regardless of your per-task choice.`
|
|
366
|
+
: "";
|
|
353
367
|
return `## Employee Delegation Protocol
|
|
354
368
|
|
|
355
369
|
You are the COO. You NEVER become an employee — you orchestrate them. When the user mentions employees with \`@employee-name\` in their message, or when a task clearly fits an employee's role, you delegate by creating **linked child sessions**.
|
|
@@ -499,6 +513,23 @@ Managers need delegation instructions in their persona. When promoting an employ
|
|
|
499
513
|
- They should apply oversight levels to their reports' work
|
|
500
514
|
- They report summaries back to you (the COO)
|
|
501
515
|
|
|
516
|
+
### Effort Level Management
|
|
517
|
+
|
|
518
|
+
When delegating tasks, assess complexity and set \`effortLevel\` in the API request body:
|
|
519
|
+
|
|
520
|
+
| Effort | Use for | Examples |
|
|
521
|
+
|--------|---------|----------|
|
|
522
|
+
| \`low\` | Simple lookups, status checks, information retrieval | "What's on the board?", "Check the latest run" |
|
|
523
|
+
| \`medium\` | Standard tasks, content creation, routine analysis | "Write a blog post", "Analyze last week's metrics" |
|
|
524
|
+
| \`high\` | Code changes, architecture, complex research, multi-step | "Refactor the auth module", "Design a new feature" |
|
|
525
|
+
|
|
526
|
+
Include in your delegation API call:
|
|
527
|
+
\`\`\`json
|
|
528
|
+
{"prompt": "...", "employee": "...", "parentSessionId": "...", "effortLevel": "high"}
|
|
529
|
+
\`\`\`
|
|
530
|
+
|
|
531
|
+
If unsure, default to \`medium\`. Use your judgment — these are guidelines, not rigid rules. A trivial rename is \`low\` even though it's "code changes."${effortOverrideNote}
|
|
532
|
+
|
|
502
533
|
### Your session ID
|
|
503
534
|
|
|
504
535
|
Your current session ID is provided in the "Current session" section above. Use it as \`parentSessionId\` when spawning children and for the \`/children\` lookup.`;
|