@lanework/contracts 0.0.0-stage → 0.3.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.
- package/LICENSE +21 -0
- package/README.md +35 -2
- package/package.json +32 -4
- package/src/agent-notes.ts +46 -0
- package/src/auth.ts +251 -0
- package/src/boards.ts +932 -0
- package/src/checkpoints.ts +96 -0
- package/src/common.ts +85 -0
- package/src/endpoints.ts +435 -0
- package/src/index.ts +18 -0
- package/src/sync.ts +148 -0
- package/src/tools/board.ts +590 -0
- package/src/tools/control.ts +519 -0
- package/src/tools/index.ts +40 -0
- package/src/tools/kit.ts +233 -0
- package/src/tools/outputs.ts +279 -0
- package/src/tools/schema.ts +149 -0
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
// The lanework-control tools (FE-155): one MCP tool per action of the
|
|
2
|
+
// `lanework-control` CLI, so an agent can call the app's control server
|
|
3
|
+
// without a shell. A conversation's own actions (`sessions.*`, `memory.*`,
|
|
4
|
+
// `conductors.create`) are checked by `parseSessionRequest` in
|
|
5
|
+
// `apps/desktop/shared/conductor-sessions.ts`; a run's (`list`, `delegate`,
|
|
6
|
+
// …) by `parseControlRequest` in `apps/desktop/shared/orchestration.ts`.
|
|
7
|
+
// The input shapes here mirror those parsers; the parsers stay the judge.
|
|
8
|
+
//
|
|
9
|
+
// NOTE: This package may not import from `apps/`, so the limits and enums
|
|
10
|
+
// below are copies of the app's (see {@link CONTROL_TOOL_LIMITS}). When a
|
|
11
|
+
// parser changes shape or limit, change it here in the same commit.
|
|
12
|
+
// Descriptions are literals: they sit in an agent's cached prompt prefix.
|
|
13
|
+
import type { ToolContract, ToolParam } from "./schema";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Who may call a tool.
|
|
17
|
+
*
|
|
18
|
+
* - `conductor`: only a conductor's own conversation (sessions, memory).
|
|
19
|
+
* - `lead`: only the lead of an orchestration run.
|
|
20
|
+
* - `any`: any conversation the app started.
|
|
21
|
+
*/
|
|
22
|
+
export type ControlToolRole = "conductor" | "lead" | "any";
|
|
23
|
+
|
|
24
|
+
export type ControlToolName =
|
|
25
|
+
| "sessions_start"
|
|
26
|
+
| "sessions_list"
|
|
27
|
+
| "sessions_read"
|
|
28
|
+
| "sessions_send"
|
|
29
|
+
| "memory_read"
|
|
30
|
+
| "memory_append"
|
|
31
|
+
| "memory_write"
|
|
32
|
+
| "conductors_create"
|
|
33
|
+
| "models_list"
|
|
34
|
+
| "run_list"
|
|
35
|
+
| "run_delegate"
|
|
36
|
+
| "run_get"
|
|
37
|
+
| "run_wait"
|
|
38
|
+
| "run_respond"
|
|
39
|
+
| "run_answer"
|
|
40
|
+
| "run_steer"
|
|
41
|
+
| "run_message"
|
|
42
|
+
| "run_retry"
|
|
43
|
+
| "run_cancel"
|
|
44
|
+
| "run_review"
|
|
45
|
+
| "run_finish";
|
|
46
|
+
|
|
47
|
+
/** The wire action each tool sends, as the CLI's first argument names it. */
|
|
48
|
+
export type ControlToolAction =
|
|
49
|
+
| "sessions.start"
|
|
50
|
+
| "sessions.list"
|
|
51
|
+
| "sessions.read"
|
|
52
|
+
| "sessions.send"
|
|
53
|
+
| "memory.read"
|
|
54
|
+
| "memory.append"
|
|
55
|
+
| "memory.write"
|
|
56
|
+
| "conductors.create"
|
|
57
|
+
| "models.list"
|
|
58
|
+
| "list"
|
|
59
|
+
| "delegate"
|
|
60
|
+
| "get"
|
|
61
|
+
| "wait"
|
|
62
|
+
| "respond"
|
|
63
|
+
| "answer"
|
|
64
|
+
| "steer"
|
|
65
|
+
| "message"
|
|
66
|
+
| "retry"
|
|
67
|
+
| "cancel"
|
|
68
|
+
| "review"
|
|
69
|
+
| "finish";
|
|
70
|
+
|
|
71
|
+
/** One lanework-control tool: the MCP contract plus where it goes. */
|
|
72
|
+
export interface ControlToolContract extends ToolContract<ControlToolName> {
|
|
73
|
+
/** The action the control server receives. */
|
|
74
|
+
action: ControlToolAction;
|
|
75
|
+
role: ControlToolRole;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The app's limits, as the parsers enforce them. Copies: the names are the
|
|
80
|
+
* app's constants (`shared/orchestration.ts`, `shared/conductor-sessions.ts`,
|
|
81
|
+
* `shared/terminal.ts`).
|
|
82
|
+
*/
|
|
83
|
+
export const CONTROL_TOOL_LIMITS = {
|
|
84
|
+
TITLE_MAX: 160,
|
|
85
|
+
PROMPT_MAX: 30_000,
|
|
86
|
+
FILES_MAX: 64,
|
|
87
|
+
WAIT_MAX_SECONDS: 25,
|
|
88
|
+
AGENT_NAME_MAX: 120,
|
|
89
|
+
READ_LIMIT_MAX: 5,
|
|
90
|
+
READ_LIMIT_DEFAULT: 2,
|
|
91
|
+
READ_CHARS_MIN: 200,
|
|
92
|
+
READ_CHARS_MAX: 6000,
|
|
93
|
+
READ_CHARS_DEFAULT: 1500,
|
|
94
|
+
MEMORY_NOTES_MAX: 8000,
|
|
95
|
+
LEAD_NAME_MAX: 60,
|
|
96
|
+
LEAD_INSTRUCTIONS_MAX: 20_000,
|
|
97
|
+
LEAD_CONTEXT_FILES_MAX: 20,
|
|
98
|
+
} as const;
|
|
99
|
+
|
|
100
|
+
const L = CONTROL_TOOL_LIMITS;
|
|
101
|
+
|
|
102
|
+
/** The app's `EFFORTS`. */
|
|
103
|
+
const EFFORTS = ["low", "medium", "high", "xhigh", "max"] as const;
|
|
104
|
+
/** The app's `TERMINAL_AGENTS` and `WORKER_AGENTS`. */
|
|
105
|
+
const AGENTS = ["claude", "codex", "opencode"] as const;
|
|
106
|
+
/** The app's `LEAD_AGENTS`: OpenCode never leads. */
|
|
107
|
+
const LEAD_AGENTS = ["claude", "codex"] as const;
|
|
108
|
+
/** The app's `PERMISSIONS`. */
|
|
109
|
+
const PERMISSIONS = [
|
|
110
|
+
"manual",
|
|
111
|
+
"acceptEdits",
|
|
112
|
+
"auto",
|
|
113
|
+
"bypassPermissions",
|
|
114
|
+
] as const;
|
|
115
|
+
/** The app's `LEAD_ICONS`. */
|
|
116
|
+
const LEAD_ICONS = [
|
|
117
|
+
"Robot02Icon",
|
|
118
|
+
"Brain02Icon",
|
|
119
|
+
"Flowchart01Icon",
|
|
120
|
+
"Target02Icon",
|
|
121
|
+
"Shield01Icon",
|
|
122
|
+
"MagicWand01Icon",
|
|
123
|
+
"SparklesIcon",
|
|
124
|
+
"Wrench01Icon",
|
|
125
|
+
"Layers01Icon",
|
|
126
|
+
"Idea01Icon",
|
|
127
|
+
"FlashIcon",
|
|
128
|
+
"AiChipIcon",
|
|
129
|
+
] as const;
|
|
130
|
+
|
|
131
|
+
// ── Shared parameter shapes ─────────────────────────────────────────────────
|
|
132
|
+
|
|
133
|
+
const EFFORT: ToolParam = {
|
|
134
|
+
type: "string",
|
|
135
|
+
enum: EFFORTS,
|
|
136
|
+
description: "Reasoning effort",
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const NOTIFY: ToolParam = {
|
|
140
|
+
type: "boolean",
|
|
141
|
+
description:
|
|
142
|
+
"Default true: Lanework tells you once the session's turn ends, so you review it",
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const SESSION_ID: ToolParam = {
|
|
146
|
+
type: "string",
|
|
147
|
+
description: "A sessionId from sessions_list",
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const TASK_ID: ToolParam = {
|
|
151
|
+
type: "string",
|
|
152
|
+
description: "A taskId from run_list: 1-64 letters, digits, - or _",
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const REQUEST_ID: ToolParam = {
|
|
156
|
+
type: "string",
|
|
157
|
+
description: "The requestId of the task's needsInput",
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const WORKER_TEXT: ToolParam = {
|
|
161
|
+
type: "string",
|
|
162
|
+
description: `Instructions for the worker, at most ${L.PROMPT_MAX} characters`,
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const SCOPES: ToolParam = {
|
|
166
|
+
type: "string[]",
|
|
167
|
+
description: `The write scope: at most ${L.FILES_MAX} project-relative paths; a directory covers what is under it, ["."] the whole checkout, [] edits no file`,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// ── The tools ───────────────────────────────────────────────────────────────
|
|
171
|
+
|
|
172
|
+
/** Every lanework-control tool: a conversation's own first, then a run's. */
|
|
173
|
+
// NOTE: Built in a pure IIFE: its descriptions read the limits, which
|
|
174
|
+
// esbuild cannot prove side-effect free, so a bundle that imports the
|
|
175
|
+
// package for anything else (the checkpoint hook) would keep the whole list.
|
|
176
|
+
export const CONTROL_TOOLS: readonly ControlToolContract[] =
|
|
177
|
+
/* @__PURE__ */ ((): ControlToolContract[] => [
|
|
178
|
+
{
|
|
179
|
+
name: "sessions_start",
|
|
180
|
+
action: "sessions.start",
|
|
181
|
+
role: "conductor",
|
|
182
|
+
description:
|
|
183
|
+
"Start a separate session in this project's checkout and submit the prompt as its first turn. It runs on your permission mode, under the title, and is yours alone: the user reaches it through you. agent defaults to yours; model and effort to yours on your agent, else that agent's default (OpenCode's model is provider/model). Unless notifyOnComplete is false, Lanework tells you once its turn ends: review it then and report to the user. Returns as soon as it started, with its sessionId. At most 4 of your sessions may work at once.",
|
|
184
|
+
readOnly: false,
|
|
185
|
+
properties: {
|
|
186
|
+
title: {
|
|
187
|
+
type: "string",
|
|
188
|
+
description: `A short title, at most ${L.AGENT_NAME_MAX} characters`,
|
|
189
|
+
},
|
|
190
|
+
prompt: {
|
|
191
|
+
type: "string",
|
|
192
|
+
description: `Self-contained instructions, at most ${L.PROMPT_MAX} characters`,
|
|
193
|
+
},
|
|
194
|
+
agent: {
|
|
195
|
+
type: "string",
|
|
196
|
+
enum: AGENTS,
|
|
197
|
+
description: "The CLI it runs on",
|
|
198
|
+
},
|
|
199
|
+
model: {
|
|
200
|
+
type: "string",
|
|
201
|
+
description: "A model id; provider/model when agent is opencode",
|
|
202
|
+
},
|
|
203
|
+
effort: EFFORT,
|
|
204
|
+
taskId: {
|
|
205
|
+
type: "string",
|
|
206
|
+
description: 'The board card it works on, e.g. "FE-98"',
|
|
207
|
+
},
|
|
208
|
+
notifyOnComplete: NOTIFY,
|
|
209
|
+
},
|
|
210
|
+
required: ["title", "prompt"],
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: "sessions_list",
|
|
214
|
+
action: "sessions.list",
|
|
215
|
+
role: "conductor",
|
|
216
|
+
description:
|
|
217
|
+
"The sessions you started, newest first, with their status: working, waiting (on the user), idle, failed or terminal.",
|
|
218
|
+
readOnly: true,
|
|
219
|
+
properties: {},
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: "sessions_read",
|
|
223
|
+
action: "sessions.read",
|
|
224
|
+
role: "conductor",
|
|
225
|
+
description:
|
|
226
|
+
"The last exchanges of one of your sessions, prompts and replies only, each cut to maxChars.",
|
|
227
|
+
readOnly: true,
|
|
228
|
+
properties: {
|
|
229
|
+
sessionId: SESSION_ID,
|
|
230
|
+
limit: {
|
|
231
|
+
type: "integer",
|
|
232
|
+
minimum: 1,
|
|
233
|
+
maximum: L.READ_LIMIT_MAX,
|
|
234
|
+
description: `Exchanges returned; default ${L.READ_LIMIT_DEFAULT}`,
|
|
235
|
+
},
|
|
236
|
+
maxChars: {
|
|
237
|
+
type: "integer",
|
|
238
|
+
minimum: L.READ_CHARS_MIN,
|
|
239
|
+
maximum: L.READ_CHARS_MAX,
|
|
240
|
+
description: `Each message cut to this; default ${L.READ_CHARS_DEFAULT}`,
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
required: ["sessionId"],
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "sessions_send",
|
|
247
|
+
action: "sessions.send",
|
|
248
|
+
role: "conductor",
|
|
249
|
+
description:
|
|
250
|
+
"A follow-up to one of your sessions. Refused while it works or waits on the user. notifyOnComplete works as in sessions_start.",
|
|
251
|
+
readOnly: false,
|
|
252
|
+
properties: {
|
|
253
|
+
sessionId: SESSION_ID,
|
|
254
|
+
prompt: {
|
|
255
|
+
type: "string",
|
|
256
|
+
description: `The follow-up, at most ${L.PROMPT_MAX} characters`,
|
|
257
|
+
},
|
|
258
|
+
notifyOnComplete: NOTIFY,
|
|
259
|
+
},
|
|
260
|
+
required: ["sessionId", "prompt"],
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: "memory_read",
|
|
264
|
+
action: "memory.read",
|
|
265
|
+
role: "conductor",
|
|
266
|
+
description:
|
|
267
|
+
"What you remember of this project across your conversations: your last 30 sessions with a summary each, the last 20 orchestration runs you led with each worker's outcome, and your notes. Read it before you plan.",
|
|
268
|
+
readOnly: true,
|
|
269
|
+
properties: {},
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
name: "memory_append",
|
|
273
|
+
action: "memory.append",
|
|
274
|
+
role: "conductor",
|
|
275
|
+
description:
|
|
276
|
+
"Add one fact to your notes for this project, on a new line; the rest stays. Prefer it to memory_write for one new decision or fact. Refused when the notes would grow past 8000 characters: then rewrite them shorter with memory_write.",
|
|
277
|
+
readOnly: false,
|
|
278
|
+
properties: {
|
|
279
|
+
text: {
|
|
280
|
+
type: "string",
|
|
281
|
+
description: "The fact to add, non-empty",
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
required: ["text"],
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
name: "memory_write",
|
|
288
|
+
action: "memory.write",
|
|
289
|
+
role: "conductor",
|
|
290
|
+
description:
|
|
291
|
+
'Replace your notes for this project, at most 8000 characters: send everything worth keeping, the old notes are gone. "" clears them. Use it only for a full rewrite; memory_append adds one fact. Lanework keeps the ledger.',
|
|
292
|
+
readOnly: false,
|
|
293
|
+
properties: {
|
|
294
|
+
notes: {
|
|
295
|
+
type: "string",
|
|
296
|
+
description: `The whole notes, at most ${L.MEMORY_NOTES_MAX} characters`,
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
required: ["notes"],
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: "models_list",
|
|
303
|
+
action: "models.list",
|
|
304
|
+
role: "any",
|
|
305
|
+
description:
|
|
306
|
+
"The models a proposal's tasks may name, grouped by agent (OpenCode ids grouped by provider: the id is provider/model), and for a conductor how each model fared in its past runs. Call it before naming a model; or leave agent and model null for Lanework to pick by tier.",
|
|
307
|
+
readOnly: true,
|
|
308
|
+
properties: {
|
|
309
|
+
agent: {
|
|
310
|
+
type: "string",
|
|
311
|
+
enum: AGENTS,
|
|
312
|
+
description: "Only this agent's models",
|
|
313
|
+
},
|
|
314
|
+
query: {
|
|
315
|
+
type: "string",
|
|
316
|
+
description: "Only ids containing this text, e.g. sonnet or glm",
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
name: "conductors_create",
|
|
322
|
+
action: "conductors.create",
|
|
323
|
+
role: "any",
|
|
324
|
+
description:
|
|
325
|
+
"Save a conductor of your own in this project, as the Conductors rail's dialog would, and return its id. Only name is required: agent, model and effort default to yours, instructions to the dialog's template, contextFiles to none, permission to the composer's default. Never replaces one: a taken id gets -2, -3. It does not start the conductor; the user opens it from the rail.",
|
|
326
|
+
readOnly: false,
|
|
327
|
+
properties: {
|
|
328
|
+
name: {
|
|
329
|
+
type: "string",
|
|
330
|
+
description: `One line, at most ${L.LEAD_NAME_MAX} characters`,
|
|
331
|
+
},
|
|
332
|
+
instructions: {
|
|
333
|
+
type: "string",
|
|
334
|
+
description: `Its instructions, markdown, at most ${L.LEAD_INSTRUCTIONS_MAX} characters`,
|
|
335
|
+
},
|
|
336
|
+
icon: { type: "string", enum: LEAD_ICONS },
|
|
337
|
+
agent: { type: "string", enum: LEAD_AGENTS },
|
|
338
|
+
model: { type: "string", description: "A model id" },
|
|
339
|
+
effort: EFFORT,
|
|
340
|
+
contextFiles: {
|
|
341
|
+
type: "string[]",
|
|
342
|
+
description: `At most ${L.LEAD_CONTEXT_FILES_MAX} project-relative paths`,
|
|
343
|
+
},
|
|
344
|
+
permission: { type: "string", enum: PERMISSIONS },
|
|
345
|
+
},
|
|
346
|
+
required: ["name"],
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: "run_list",
|
|
350
|
+
action: "list",
|
|
351
|
+
role: "lead",
|
|
352
|
+
description:
|
|
353
|
+
"The run, every task with its status and latest result, and the agent/model ids run_delegate may name (run.choices).",
|
|
354
|
+
readOnly: true,
|
|
355
|
+
properties: {},
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
name: "run_delegate",
|
|
359
|
+
action: "delegate",
|
|
360
|
+
role: "lead",
|
|
361
|
+
description:
|
|
362
|
+
"Queue a worker and return its taskId. files is its write scope. With no model, Jev picks a tier when it is on and sure, otherwise the standard tier runs it. dependsOn holds taskIds that must be reviewed (accepted) before this one starts. A scope beyond what the user approved, or naming agent config (.claude, .codex, .mcp.json, .vscode, .husky, .lanework), waits for the user on the run's panel: the task shows scopeApproval.",
|
|
363
|
+
readOnly: false,
|
|
364
|
+
properties: {
|
|
365
|
+
title: {
|
|
366
|
+
type: "string",
|
|
367
|
+
description: `A short title, at most ${L.TITLE_MAX} characters`,
|
|
368
|
+
},
|
|
369
|
+
prompt: {
|
|
370
|
+
type: "string",
|
|
371
|
+
description: `Self-contained instructions, at most ${L.PROMPT_MAX} characters`,
|
|
372
|
+
},
|
|
373
|
+
files: SCOPES,
|
|
374
|
+
agent: { type: "string", enum: AGENTS },
|
|
375
|
+
model: {
|
|
376
|
+
type: "string",
|
|
377
|
+
description: "A model id from run_list; provider/model for opencode",
|
|
378
|
+
},
|
|
379
|
+
effort: EFFORT,
|
|
380
|
+
dependsOn: { type: "string[]", description: "taskIds" },
|
|
381
|
+
},
|
|
382
|
+
required: ["title", "prompt", "files"],
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: "run_get",
|
|
386
|
+
action: "get",
|
|
387
|
+
role: "lead",
|
|
388
|
+
description:
|
|
389
|
+
"One task, with its latest result. A tool approval it waits on shows in needsInput with the tool's input (secrets redacted): decide on that, not on summary.",
|
|
390
|
+
readOnly: true,
|
|
391
|
+
properties: { taskId: TASK_ID },
|
|
392
|
+
required: ["taskId"],
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "run_wait",
|
|
396
|
+
action: "wait",
|
|
397
|
+
role: "lead",
|
|
398
|
+
description:
|
|
399
|
+
"Block until a task changes, or until the timeout. changed lists the taskIds that moved; it is empty on a timeout or when nothing is left running or queued. For one short wait only: never loop on it; end your turn instead, and Lanework sends you a turn when a task needs you.",
|
|
400
|
+
readOnly: true,
|
|
401
|
+
properties: {
|
|
402
|
+
timeoutSeconds: {
|
|
403
|
+
type: "integer",
|
|
404
|
+
minimum: 0,
|
|
405
|
+
maximum: L.WAIT_MAX_SECONDS,
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
name: "run_respond",
|
|
411
|
+
action: "respond",
|
|
412
|
+
role: "lead",
|
|
413
|
+
description:
|
|
414
|
+
"Allow or deny the tool a worker is waiting on (its needsInput). It stays stopped until you decide.",
|
|
415
|
+
readOnly: false,
|
|
416
|
+
properties: {
|
|
417
|
+
taskId: TASK_ID,
|
|
418
|
+
requestId: REQUEST_ID,
|
|
419
|
+
decision: { type: "string", enum: ["allow", "deny"] },
|
|
420
|
+
},
|
|
421
|
+
required: ["taskId", "requestId", "decision"],
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
name: "run_answer",
|
|
425
|
+
action: "answer",
|
|
426
|
+
role: "lead",
|
|
427
|
+
description:
|
|
428
|
+
"Answer the question a worker asked (its text and options come from needsInput), or skip it. Pass exactly one of answers and skip.",
|
|
429
|
+
readOnly: false,
|
|
430
|
+
properties: {
|
|
431
|
+
taskId: TASK_ID,
|
|
432
|
+
requestId: REQUEST_ID,
|
|
433
|
+
answers: {
|
|
434
|
+
type: "string-map",
|
|
435
|
+
description: "1-8 entries: question text to answer, each a string",
|
|
436
|
+
},
|
|
437
|
+
skip: { type: "boolean", description: "true to skip the question" },
|
|
438
|
+
},
|
|
439
|
+
required: ["taskId", "requestId"],
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
name: "run_steer",
|
|
443
|
+
action: "steer",
|
|
444
|
+
role: "lead",
|
|
445
|
+
description:
|
|
446
|
+
"Redirect a worker that is still running, without discarding what it has done. Use it the moment one drifts; run_message only lands once it has stopped.",
|
|
447
|
+
readOnly: false,
|
|
448
|
+
properties: { taskId: TASK_ID, text: WORKER_TEXT },
|
|
449
|
+
required: ["taskId", "text"],
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
name: "run_message",
|
|
453
|
+
action: "message",
|
|
454
|
+
role: "lead",
|
|
455
|
+
description:
|
|
456
|
+
"Give a stopped worker another turn in its own scope; it keeps its session, worktree and history.",
|
|
457
|
+
readOnly: false,
|
|
458
|
+
properties: { taskId: TASK_ID, text: WORKER_TEXT },
|
|
459
|
+
required: ["taskId", "text"],
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
name: "run_retry",
|
|
463
|
+
action: "retry",
|
|
464
|
+
role: "lead",
|
|
465
|
+
description:
|
|
466
|
+
"Retry a stopped worker with corrected write scopes. Use it only when the extra files are really needed. Scopes beyond what the user approved wait for them, as with run_delegate.",
|
|
467
|
+
readOnly: false,
|
|
468
|
+
properties: { taskId: TASK_ID, text: WORKER_TEXT, files: SCOPES },
|
|
469
|
+
required: ["taskId", "text", "files"],
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
name: "run_cancel",
|
|
473
|
+
action: "cancel",
|
|
474
|
+
role: "lead",
|
|
475
|
+
description: "Cancel a task, running or still queued.",
|
|
476
|
+
readOnly: false,
|
|
477
|
+
properties: { taskId: TASK_ID },
|
|
478
|
+
required: ["taskId"],
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
name: "run_review",
|
|
482
|
+
action: "review",
|
|
483
|
+
role: "lead",
|
|
484
|
+
description: "Accept a completed task's result.",
|
|
485
|
+
readOnly: false,
|
|
486
|
+
properties: { taskId: TASK_ID },
|
|
487
|
+
required: ["taskId"],
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
name: "run_finish",
|
|
491
|
+
action: "finish",
|
|
492
|
+
role: "lead",
|
|
493
|
+
description: "End the run, once every task is accepted or cancelled.",
|
|
494
|
+
readOnly: false,
|
|
495
|
+
properties: {},
|
|
496
|
+
},
|
|
497
|
+
])();
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* The tools a conversation may call: `any` tools always, `conductor` tools
|
|
501
|
+
* for a conductor's own conversation, `lead` tools for a run's lead. In
|
|
502
|
+
* {@link CONTROL_TOOLS}'s order.
|
|
503
|
+
*/
|
|
504
|
+
export function controlToolsFor(roles: {
|
|
505
|
+
conductor: boolean;
|
|
506
|
+
lead: boolean;
|
|
507
|
+
}): ControlToolContract[] {
|
|
508
|
+
return CONTROL_TOOLS.filter(
|
|
509
|
+
(tool) =>
|
|
510
|
+
tool.role === "any" ||
|
|
511
|
+
(tool.role === "conductor" && roles.conductor) ||
|
|
512
|
+
(tool.role === "lead" && roles.lead),
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** One control tool by its MCP name; undefined when there is none. */
|
|
517
|
+
export function controlTool(name: string): ControlToolContract | undefined {
|
|
518
|
+
return CONTROL_TOOLS.find((tool) => tool.name === name);
|
|
519
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// The tool contract (FE-152): every tool an agent can call on Lanework, by
|
|
2
|
+
// name, description, read-only flag, input schema and answer type. The board
|
|
3
|
+
// MCP servers (cloud and offline) serve `BOARD_TOOLS`; lanework-kit (the
|
|
4
|
+
// `lwk` CLI and its MCP server) serves `KIT_TOOLS`.
|
|
5
|
+
//
|
|
6
|
+
// NOTE: `apps/desktop/scripts/mcp-parity.mjs` checks the offline board server
|
|
7
|
+
// against this file in `bun run gate`. Descriptions are literals: they sit in
|
|
8
|
+
// an agent's cached prompt prefix.
|
|
9
|
+
import {
|
|
10
|
+
BOARD_TOOLS,
|
|
11
|
+
type BoardToolName,
|
|
12
|
+
type BoardToolOutputs,
|
|
13
|
+
} from "./board";
|
|
14
|
+
import {
|
|
15
|
+
KIT_TOOLS,
|
|
16
|
+
type KitToolInputs,
|
|
17
|
+
type KitToolName,
|
|
18
|
+
type KitToolOutputs,
|
|
19
|
+
} from "./kit";
|
|
20
|
+
import type { ToolContract } from "./schema";
|
|
21
|
+
|
|
22
|
+
export * from "./board";
|
|
23
|
+
export * from "./kit";
|
|
24
|
+
export * from "./outputs";
|
|
25
|
+
export * from "./schema";
|
|
26
|
+
|
|
27
|
+
export type ToolName = BoardToolName | KitToolName;
|
|
28
|
+
|
|
29
|
+
/** What any tool answers, by name. */
|
|
30
|
+
export type ToolOutputs = BoardToolOutputs & KitToolOutputs;
|
|
31
|
+
export type ToolOutput<Name extends ToolName> = ToolOutputs[Name];
|
|
32
|
+
export type KitToolInput<Name extends KitToolName> = KitToolInputs[Name];
|
|
33
|
+
|
|
34
|
+
/** One tool's contract by name, board or kit; undefined when there is none. */
|
|
35
|
+
export function toolContract(name: string): ToolContract<ToolName> | undefined {
|
|
36
|
+
return (
|
|
37
|
+
BOARD_TOOLS.find((tool) => tool.name === name) ??
|
|
38
|
+
KIT_TOOLS.find((tool) => tool.name === name)
|
|
39
|
+
);
|
|
40
|
+
}
|