@artyfacts/claude 1.2.3 → 1.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/dist/chunk-7ULDABOE.mjs +755 -0
- package/dist/cli.js +15 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +225 -7
- package/dist/index.d.ts +225 -7
- package/dist/index.js +5200 -3
- package/dist/index.mjs +5174 -2
- package/package.json +1 -1
- package/src/executor-with-tools.ts +402 -0
- package/src/index.ts +34 -0
- package/src/listener.ts +16 -1
- package/src/tools/api-client.ts +68 -0
- package/src/tools/handlers.ts +460 -0
- package/src/tools/index.ts +30 -0
- package/src/tools/registry.ts +780 -0
- package/src/tools/types.ts +82 -0
|
@@ -0,0 +1,780 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artyfacts Tools Registry
|
|
3
|
+
*
|
|
4
|
+
* Defines all tools available to agents for interacting with Artyfacts.
|
|
5
|
+
* Tools are mapped to permissions - agents only get tools they have permission for.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Tool, ToolHandler, ToolSchema } from './types';
|
|
9
|
+
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// Tool Schemas (JSON Schema format for Claude)
|
|
12
|
+
// =============================================================================
|
|
13
|
+
|
|
14
|
+
const schemas: Record<string, ToolSchema> = {
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Section Tools
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
get_section: {
|
|
19
|
+
name: 'get_section',
|
|
20
|
+
description: 'Read a section by ID. Returns the section content, type, and metadata.',
|
|
21
|
+
input_schema: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
section_id: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'The UUID of the section to read',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
required: ['section_id'],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
list_sections: {
|
|
34
|
+
name: 'list_sections',
|
|
35
|
+
description: 'List all sections of an artifact. Returns sections in order with their content and metadata.',
|
|
36
|
+
input_schema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
artifact_id: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'The UUID of the artifact',
|
|
42
|
+
},
|
|
43
|
+
type: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
enum: ['content', 'task', 'decision'],
|
|
46
|
+
description: 'Optional: filter by section type',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
required: ['artifact_id'],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
create_section: {
|
|
54
|
+
name: 'create_section',
|
|
55
|
+
description: 'Add a new section to an artifact. Use for documenting analysis, recommendations, or any structured content.',
|
|
56
|
+
input_schema: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
artifact_id: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'The UUID of the artifact to add the section to',
|
|
62
|
+
},
|
|
63
|
+
heading: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
description: 'The section heading/title',
|
|
66
|
+
},
|
|
67
|
+
content: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: 'The section content (supports Markdown)',
|
|
70
|
+
},
|
|
71
|
+
type: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
enum: ['content', 'task', 'decision'],
|
|
74
|
+
default: 'content',
|
|
75
|
+
description: 'Section type. Use "content" for documentation, "task" for actionable items, "decision" for choices needing approval.',
|
|
76
|
+
},
|
|
77
|
+
position: {
|
|
78
|
+
type: 'number',
|
|
79
|
+
description: 'Optional: position in the section order (0-indexed). Defaults to end.',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
required: ['artifact_id', 'heading', 'content'],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
update_section: {
|
|
87
|
+
name: 'update_section',
|
|
88
|
+
description: 'Update an existing section content or metadata.',
|
|
89
|
+
input_schema: {
|
|
90
|
+
type: 'object',
|
|
91
|
+
properties: {
|
|
92
|
+
section_id: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
description: 'The UUID of the section to update',
|
|
95
|
+
},
|
|
96
|
+
heading: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
description: 'New heading (optional)',
|
|
99
|
+
},
|
|
100
|
+
content: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
description: 'New content (optional)',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
required: ['section_id'],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
delete_section: {
|
|
110
|
+
name: 'delete_section',
|
|
111
|
+
description: 'Remove a section from an artifact. Use with caution.',
|
|
112
|
+
input_schema: {
|
|
113
|
+
type: 'object',
|
|
114
|
+
properties: {
|
|
115
|
+
section_id: {
|
|
116
|
+
type: 'string',
|
|
117
|
+
description: 'The UUID of the section to delete',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
required: ['section_id'],
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
// Artifact Tools
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
get_artifact: {
|
|
128
|
+
name: 'get_artifact',
|
|
129
|
+
description: 'Read an artifact by ID. Returns title, content, status, and metadata.',
|
|
130
|
+
input_schema: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
properties: {
|
|
133
|
+
artifact_id: {
|
|
134
|
+
type: 'string',
|
|
135
|
+
description: 'The UUID of the artifact',
|
|
136
|
+
},
|
|
137
|
+
include_sections: {
|
|
138
|
+
type: 'boolean',
|
|
139
|
+
default: false,
|
|
140
|
+
description: 'Whether to include all sections in the response',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
required: ['artifact_id'],
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
list_artifacts: {
|
|
148
|
+
name: 'list_artifacts',
|
|
149
|
+
description: 'List artifacts with optional filters. Returns summaries, not full content.',
|
|
150
|
+
input_schema: {
|
|
151
|
+
type: 'object',
|
|
152
|
+
properties: {
|
|
153
|
+
type: {
|
|
154
|
+
type: 'string',
|
|
155
|
+
enum: ['goal', 'spec', 'doc', 'research', 'report'],
|
|
156
|
+
description: 'Filter by artifact type',
|
|
157
|
+
},
|
|
158
|
+
status: {
|
|
159
|
+
type: 'string',
|
|
160
|
+
enum: ['draft', 'active', 'completed', 'archived'],
|
|
161
|
+
description: 'Filter by status',
|
|
162
|
+
},
|
|
163
|
+
parent_id: {
|
|
164
|
+
type: 'string',
|
|
165
|
+
description: 'Filter by parent artifact ID',
|
|
166
|
+
},
|
|
167
|
+
limit: {
|
|
168
|
+
type: 'number',
|
|
169
|
+
default: 20,
|
|
170
|
+
description: 'Max results to return',
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
required: [],
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
search_artifacts: {
|
|
178
|
+
name: 'search_artifacts',
|
|
179
|
+
description: 'Search artifacts by text query. Returns matching artifacts ranked by relevance.',
|
|
180
|
+
input_schema: {
|
|
181
|
+
type: 'object',
|
|
182
|
+
properties: {
|
|
183
|
+
query: {
|
|
184
|
+
type: 'string',
|
|
185
|
+
description: 'Search query text',
|
|
186
|
+
},
|
|
187
|
+
type: {
|
|
188
|
+
type: 'string',
|
|
189
|
+
enum: ['goal', 'spec', 'doc', 'research', 'report'],
|
|
190
|
+
description: 'Optional: filter by type',
|
|
191
|
+
},
|
|
192
|
+
limit: {
|
|
193
|
+
type: 'number',
|
|
194
|
+
default: 10,
|
|
195
|
+
description: 'Max results',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
required: ['query'],
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
create_artifact: {
|
|
203
|
+
name: 'create_artifact',
|
|
204
|
+
description: 'Create a new artifact (document, spec, goal, etc.).',
|
|
205
|
+
input_schema: {
|
|
206
|
+
type: 'object',
|
|
207
|
+
properties: {
|
|
208
|
+
title: {
|
|
209
|
+
type: 'string',
|
|
210
|
+
description: 'Artifact title',
|
|
211
|
+
},
|
|
212
|
+
type: {
|
|
213
|
+
type: 'string',
|
|
214
|
+
enum: ['goal', 'spec', 'doc', 'research', 'report', 'runbook'],
|
|
215
|
+
description: 'Artifact type',
|
|
216
|
+
},
|
|
217
|
+
content: {
|
|
218
|
+
type: 'string',
|
|
219
|
+
description: 'Initial content (Markdown)',
|
|
220
|
+
},
|
|
221
|
+
summary: {
|
|
222
|
+
type: 'string',
|
|
223
|
+
description: 'Brief summary/description',
|
|
224
|
+
},
|
|
225
|
+
parent_id: {
|
|
226
|
+
type: 'string',
|
|
227
|
+
description: 'Optional: parent artifact ID for hierarchy',
|
|
228
|
+
},
|
|
229
|
+
tags: {
|
|
230
|
+
type: 'array',
|
|
231
|
+
items: { type: 'string' },
|
|
232
|
+
description: 'Optional: tags for categorization',
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
required: ['title', 'type'],
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
update_artifact: {
|
|
240
|
+
name: 'update_artifact',
|
|
241
|
+
description: 'Update artifact metadata (title, status, summary).',
|
|
242
|
+
input_schema: {
|
|
243
|
+
type: 'object',
|
|
244
|
+
properties: {
|
|
245
|
+
artifact_id: {
|
|
246
|
+
type: 'string',
|
|
247
|
+
description: 'The UUID of the artifact',
|
|
248
|
+
},
|
|
249
|
+
title: {
|
|
250
|
+
type: 'string',
|
|
251
|
+
description: 'New title',
|
|
252
|
+
},
|
|
253
|
+
summary: {
|
|
254
|
+
type: 'string',
|
|
255
|
+
description: 'New summary',
|
|
256
|
+
},
|
|
257
|
+
status: {
|
|
258
|
+
type: 'string',
|
|
259
|
+
enum: ['draft', 'active', 'completed', 'archived'],
|
|
260
|
+
description: 'New status',
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
required: ['artifact_id'],
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
link_artifacts: {
|
|
268
|
+
name: 'link_artifacts',
|
|
269
|
+
description: 'Create a parent-child relationship between artifacts.',
|
|
270
|
+
input_schema: {
|
|
271
|
+
type: 'object',
|
|
272
|
+
properties: {
|
|
273
|
+
parent_id: {
|
|
274
|
+
type: 'string',
|
|
275
|
+
description: 'The parent artifact UUID',
|
|
276
|
+
},
|
|
277
|
+
child_id: {
|
|
278
|
+
type: 'string',
|
|
279
|
+
description: 'The child artifact UUID',
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
required: ['parent_id', 'child_id'],
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
// ---------------------------------------------------------------------------
|
|
287
|
+
// Agent Tools
|
|
288
|
+
// ---------------------------------------------------------------------------
|
|
289
|
+
get_agent: {
|
|
290
|
+
name: 'get_agent',
|
|
291
|
+
description: 'Read agent details including role, capabilities, and permissions.',
|
|
292
|
+
input_schema: {
|
|
293
|
+
type: 'object',
|
|
294
|
+
properties: {
|
|
295
|
+
agent_id: {
|
|
296
|
+
type: 'string',
|
|
297
|
+
description: 'The agent ID (slug or UUID)',
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
required: ['agent_id'],
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
|
|
304
|
+
list_agents: {
|
|
305
|
+
name: 'list_agents',
|
|
306
|
+
description: 'List all agents in the organization.',
|
|
307
|
+
input_schema: {
|
|
308
|
+
type: 'object',
|
|
309
|
+
properties: {
|
|
310
|
+
role: {
|
|
311
|
+
type: 'string',
|
|
312
|
+
description: 'Optional: filter by role',
|
|
313
|
+
},
|
|
314
|
+
status: {
|
|
315
|
+
type: 'string',
|
|
316
|
+
enum: ['active', 'inactive'],
|
|
317
|
+
description: 'Optional: filter by status',
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
required: [],
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
|
|
324
|
+
create_agent: {
|
|
325
|
+
name: 'create_agent',
|
|
326
|
+
description: 'Create a new AI agent with specified role, capabilities, and system prompt.',
|
|
327
|
+
input_schema: {
|
|
328
|
+
type: 'object',
|
|
329
|
+
properties: {
|
|
330
|
+
id: {
|
|
331
|
+
type: 'string',
|
|
332
|
+
description: 'Agent ID/slug (lowercase, hyphens, e.g., "content-writer")',
|
|
333
|
+
},
|
|
334
|
+
name: {
|
|
335
|
+
type: 'string',
|
|
336
|
+
description: 'Display name (e.g., "Content Writer")',
|
|
337
|
+
},
|
|
338
|
+
role: {
|
|
339
|
+
type: 'string',
|
|
340
|
+
description: 'Agent role/title (e.g., "Senior Content Writer")',
|
|
341
|
+
},
|
|
342
|
+
description: {
|
|
343
|
+
type: 'string',
|
|
344
|
+
description: 'Brief description of what this agent does',
|
|
345
|
+
},
|
|
346
|
+
system_prompt: {
|
|
347
|
+
type: 'string',
|
|
348
|
+
description: 'System prompt that defines agent behavior and personality',
|
|
349
|
+
},
|
|
350
|
+
capabilities: {
|
|
351
|
+
type: 'array',
|
|
352
|
+
items: { type: 'string' },
|
|
353
|
+
description: 'List of capabilities (e.g., ["content-creation", "research"])',
|
|
354
|
+
},
|
|
355
|
+
permissions: {
|
|
356
|
+
type: 'array',
|
|
357
|
+
items: { type: 'string' },
|
|
358
|
+
description: 'List of permissions (e.g., ["sections:write", "artifacts:read"])',
|
|
359
|
+
},
|
|
360
|
+
model: {
|
|
361
|
+
type: 'string',
|
|
362
|
+
description: 'Optional: preferred model (defaults to org default)',
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
required: ['id', 'name', 'role', 'description', 'system_prompt'],
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
update_agent: {
|
|
370
|
+
name: 'update_agent',
|
|
371
|
+
description: 'Update an existing agent configuration.',
|
|
372
|
+
input_schema: {
|
|
373
|
+
type: 'object',
|
|
374
|
+
properties: {
|
|
375
|
+
agent_id: {
|
|
376
|
+
type: 'string',
|
|
377
|
+
description: 'The agent ID to update',
|
|
378
|
+
},
|
|
379
|
+
name: {
|
|
380
|
+
type: 'string',
|
|
381
|
+
description: 'New display name',
|
|
382
|
+
},
|
|
383
|
+
role: {
|
|
384
|
+
type: 'string',
|
|
385
|
+
description: 'New role',
|
|
386
|
+
},
|
|
387
|
+
description: {
|
|
388
|
+
type: 'string',
|
|
389
|
+
description: 'New description',
|
|
390
|
+
},
|
|
391
|
+
system_prompt: {
|
|
392
|
+
type: 'string',
|
|
393
|
+
description: 'New system prompt',
|
|
394
|
+
},
|
|
395
|
+
capabilities: {
|
|
396
|
+
type: 'array',
|
|
397
|
+
items: { type: 'string' },
|
|
398
|
+
description: 'New capabilities list',
|
|
399
|
+
},
|
|
400
|
+
permissions: {
|
|
401
|
+
type: 'array',
|
|
402
|
+
items: { type: 'string' },
|
|
403
|
+
description: 'New permissions list',
|
|
404
|
+
},
|
|
405
|
+
status: {
|
|
406
|
+
type: 'string',
|
|
407
|
+
enum: ['active', 'inactive'],
|
|
408
|
+
description: 'Agent status',
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
required: ['agent_id'],
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
|
|
415
|
+
// ---------------------------------------------------------------------------
|
|
416
|
+
// Task Tools
|
|
417
|
+
// ---------------------------------------------------------------------------
|
|
418
|
+
get_task: {
|
|
419
|
+
name: 'get_task',
|
|
420
|
+
description: 'Read task details including status, content, and dependencies.',
|
|
421
|
+
input_schema: {
|
|
422
|
+
type: 'object',
|
|
423
|
+
properties: {
|
|
424
|
+
task_id: {
|
|
425
|
+
type: 'string',
|
|
426
|
+
description: 'The task UUID or section_id',
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
required: ['task_id'],
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
|
|
433
|
+
list_tasks: {
|
|
434
|
+
name: 'list_tasks',
|
|
435
|
+
description: 'List tasks with optional filters.',
|
|
436
|
+
input_schema: {
|
|
437
|
+
type: 'object',
|
|
438
|
+
properties: {
|
|
439
|
+
artifact_id: {
|
|
440
|
+
type: 'string',
|
|
441
|
+
description: 'Filter by artifact',
|
|
442
|
+
},
|
|
443
|
+
status: {
|
|
444
|
+
type: 'string',
|
|
445
|
+
enum: ['pending', 'in_progress', 'blocked', 'done'],
|
|
446
|
+
description: 'Filter by status',
|
|
447
|
+
},
|
|
448
|
+
assignee: {
|
|
449
|
+
type: 'string',
|
|
450
|
+
description: 'Filter by assigned agent',
|
|
451
|
+
},
|
|
452
|
+
limit: {
|
|
453
|
+
type: 'number',
|
|
454
|
+
default: 20,
|
|
455
|
+
description: 'Max results',
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
required: [],
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
|
|
462
|
+
create_task: {
|
|
463
|
+
name: 'create_task',
|
|
464
|
+
description: 'Create a new task on an artifact.',
|
|
465
|
+
input_schema: {
|
|
466
|
+
type: 'object',
|
|
467
|
+
properties: {
|
|
468
|
+
artifact_id: {
|
|
469
|
+
type: 'string',
|
|
470
|
+
description: 'The artifact to add the task to',
|
|
471
|
+
},
|
|
472
|
+
heading: {
|
|
473
|
+
type: 'string',
|
|
474
|
+
description: 'Task title/heading',
|
|
475
|
+
},
|
|
476
|
+
content: {
|
|
477
|
+
type: 'string',
|
|
478
|
+
description: 'Task description and requirements',
|
|
479
|
+
},
|
|
480
|
+
assignee: {
|
|
481
|
+
type: 'string',
|
|
482
|
+
description: 'Optional: agent ID to assign to',
|
|
483
|
+
},
|
|
484
|
+
depends_on: {
|
|
485
|
+
type: 'array',
|
|
486
|
+
items: { type: 'string' },
|
|
487
|
+
description: 'Optional: section_ids of tasks this depends on',
|
|
488
|
+
},
|
|
489
|
+
priority: {
|
|
490
|
+
type: 'number',
|
|
491
|
+
enum: [1, 2, 3],
|
|
492
|
+
description: 'Optional: priority (1=high, 2=medium, 3=low)',
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
required: ['artifact_id', 'heading', 'content'],
|
|
496
|
+
},
|
|
497
|
+
},
|
|
498
|
+
|
|
499
|
+
complete_task: {
|
|
500
|
+
name: 'complete_task',
|
|
501
|
+
description: 'Mark a task as completed with output.',
|
|
502
|
+
input_schema: {
|
|
503
|
+
type: 'object',
|
|
504
|
+
properties: {
|
|
505
|
+
task_id: {
|
|
506
|
+
type: 'string',
|
|
507
|
+
description: 'The task UUID or section_id',
|
|
508
|
+
},
|
|
509
|
+
output: {
|
|
510
|
+
type: 'string',
|
|
511
|
+
description: 'The task output/deliverable',
|
|
512
|
+
},
|
|
513
|
+
summary: {
|
|
514
|
+
type: 'string',
|
|
515
|
+
description: 'Brief summary of what was accomplished',
|
|
516
|
+
},
|
|
517
|
+
output_url: {
|
|
518
|
+
type: 'string',
|
|
519
|
+
description: 'Optional: URL to output (PR, doc, etc.)',
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
required: ['task_id', 'summary'],
|
|
523
|
+
},
|
|
524
|
+
},
|
|
525
|
+
|
|
526
|
+
block_task: {
|
|
527
|
+
name: 'block_task',
|
|
528
|
+
description: 'Mark a task as blocked with a reason.',
|
|
529
|
+
input_schema: {
|
|
530
|
+
type: 'object',
|
|
531
|
+
properties: {
|
|
532
|
+
task_id: {
|
|
533
|
+
type: 'string',
|
|
534
|
+
description: 'The task UUID or section_id',
|
|
535
|
+
},
|
|
536
|
+
reason: {
|
|
537
|
+
type: 'string',
|
|
538
|
+
description: 'Why the task is blocked',
|
|
539
|
+
},
|
|
540
|
+
blocker_type: {
|
|
541
|
+
type: 'string',
|
|
542
|
+
enum: ['dependency', 'approval', 'information', 'technical'],
|
|
543
|
+
description: 'Type of blocker',
|
|
544
|
+
},
|
|
545
|
+
},
|
|
546
|
+
required: ['task_id', 'reason'],
|
|
547
|
+
},
|
|
548
|
+
},
|
|
549
|
+
|
|
550
|
+
// ---------------------------------------------------------------------------
|
|
551
|
+
// Blocker Tools
|
|
552
|
+
// ---------------------------------------------------------------------------
|
|
553
|
+
get_blocker: {
|
|
554
|
+
name: 'get_blocker',
|
|
555
|
+
description: 'Read blocker/decision details.',
|
|
556
|
+
input_schema: {
|
|
557
|
+
type: 'object',
|
|
558
|
+
properties: {
|
|
559
|
+
blocker_id: {
|
|
560
|
+
type: 'string',
|
|
561
|
+
description: 'The blocker UUID',
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
required: ['blocker_id'],
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
|
|
568
|
+
list_blockers: {
|
|
569
|
+
name: 'list_blockers',
|
|
570
|
+
description: 'List blockers/decisions with optional filters.',
|
|
571
|
+
input_schema: {
|
|
572
|
+
type: 'object',
|
|
573
|
+
properties: {
|
|
574
|
+
status: {
|
|
575
|
+
type: 'string',
|
|
576
|
+
enum: ['pending', 'resolved'],
|
|
577
|
+
description: 'Filter by status',
|
|
578
|
+
},
|
|
579
|
+
artifact_id: {
|
|
580
|
+
type: 'string',
|
|
581
|
+
description: 'Filter by artifact',
|
|
582
|
+
},
|
|
583
|
+
kind: {
|
|
584
|
+
type: 'string',
|
|
585
|
+
enum: ['decision', 'approval', 'information'],
|
|
586
|
+
description: 'Filter by blocker type',
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
required: [],
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
|
|
593
|
+
create_blocker: {
|
|
594
|
+
name: 'create_blocker',
|
|
595
|
+
description: 'Create a blocker/decision that needs human input.',
|
|
596
|
+
input_schema: {
|
|
597
|
+
type: 'object',
|
|
598
|
+
properties: {
|
|
599
|
+
title: {
|
|
600
|
+
type: 'string',
|
|
601
|
+
description: 'Blocker title/question',
|
|
602
|
+
},
|
|
603
|
+
description: {
|
|
604
|
+
type: 'string',
|
|
605
|
+
description: 'Detailed description of what needs to be decided',
|
|
606
|
+
},
|
|
607
|
+
kind: {
|
|
608
|
+
type: 'string',
|
|
609
|
+
enum: ['decision', 'approval', 'information'],
|
|
610
|
+
description: 'Type of blocker',
|
|
611
|
+
},
|
|
612
|
+
options: {
|
|
613
|
+
type: 'array',
|
|
614
|
+
items: {
|
|
615
|
+
type: 'object',
|
|
616
|
+
properties: {
|
|
617
|
+
name: { type: 'string' },
|
|
618
|
+
description: { type: 'string' },
|
|
619
|
+
},
|
|
620
|
+
},
|
|
621
|
+
description: 'For decisions: the options to choose from',
|
|
622
|
+
},
|
|
623
|
+
artifact_id: {
|
|
624
|
+
type: 'string',
|
|
625
|
+
description: 'Optional: related artifact',
|
|
626
|
+
},
|
|
627
|
+
task_id: {
|
|
628
|
+
type: 'string',
|
|
629
|
+
description: 'Optional: related task (will block it)',
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
required: ['title', 'description', 'kind'],
|
|
633
|
+
},
|
|
634
|
+
},
|
|
635
|
+
|
|
636
|
+
resolve_blocker: {
|
|
637
|
+
name: 'resolve_blocker',
|
|
638
|
+
description: 'Resolve a blocker with a decision (usually done by humans, but agents can too if permitted).',
|
|
639
|
+
input_schema: {
|
|
640
|
+
type: 'object',
|
|
641
|
+
properties: {
|
|
642
|
+
blocker_id: {
|
|
643
|
+
type: 'string',
|
|
644
|
+
description: 'The blocker UUID',
|
|
645
|
+
},
|
|
646
|
+
decision: {
|
|
647
|
+
type: 'string',
|
|
648
|
+
description: 'The decision/resolution',
|
|
649
|
+
},
|
|
650
|
+
notes: {
|
|
651
|
+
type: 'string',
|
|
652
|
+
description: 'Optional: additional context',
|
|
653
|
+
},
|
|
654
|
+
},
|
|
655
|
+
required: ['blocker_id', 'decision'],
|
|
656
|
+
},
|
|
657
|
+
},
|
|
658
|
+
|
|
659
|
+
// ---------------------------------------------------------------------------
|
|
660
|
+
// Organization Tools
|
|
661
|
+
// ---------------------------------------------------------------------------
|
|
662
|
+
get_org_context: {
|
|
663
|
+
name: 'get_org_context',
|
|
664
|
+
description: 'Get organization context including name, industry, size, and preferences.',
|
|
665
|
+
input_schema: {
|
|
666
|
+
type: 'object',
|
|
667
|
+
properties: {},
|
|
668
|
+
required: [],
|
|
669
|
+
},
|
|
670
|
+
},
|
|
671
|
+
|
|
672
|
+
get_project: {
|
|
673
|
+
name: 'get_project',
|
|
674
|
+
description: 'Get project details.',
|
|
675
|
+
input_schema: {
|
|
676
|
+
type: 'object',
|
|
677
|
+
properties: {
|
|
678
|
+
project_id: {
|
|
679
|
+
type: 'string',
|
|
680
|
+
description: 'Project UUID or slug',
|
|
681
|
+
},
|
|
682
|
+
},
|
|
683
|
+
required: ['project_id'],
|
|
684
|
+
},
|
|
685
|
+
},
|
|
686
|
+
|
|
687
|
+
list_projects: {
|
|
688
|
+
name: 'list_projects',
|
|
689
|
+
description: 'List all projects in the organization.',
|
|
690
|
+
input_schema: {
|
|
691
|
+
type: 'object',
|
|
692
|
+
properties: {
|
|
693
|
+
status: {
|
|
694
|
+
type: 'string',
|
|
695
|
+
enum: ['active', 'archived'],
|
|
696
|
+
description: 'Filter by status',
|
|
697
|
+
},
|
|
698
|
+
},
|
|
699
|
+
required: [],
|
|
700
|
+
},
|
|
701
|
+
},
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
// =============================================================================
|
|
705
|
+
// Permission Mapping
|
|
706
|
+
// =============================================================================
|
|
707
|
+
|
|
708
|
+
export const permissionToTools: Record<string, string[]> = {
|
|
709
|
+
'sections:read': ['get_section', 'list_sections'],
|
|
710
|
+
'sections:write': ['create_section', 'update_section', 'delete_section'],
|
|
711
|
+
'artifacts:read': ['get_artifact', 'list_artifacts', 'search_artifacts'],
|
|
712
|
+
'artifacts:write': ['create_artifact', 'update_artifact', 'link_artifacts'],
|
|
713
|
+
'agents:read': ['get_agent', 'list_agents'],
|
|
714
|
+
'agents:write': ['create_agent', 'update_agent'],
|
|
715
|
+
'tasks:read': ['get_task', 'list_tasks'],
|
|
716
|
+
'tasks:write': ['create_task', 'complete_task', 'block_task'],
|
|
717
|
+
'blockers:read': ['get_blocker', 'list_blockers'],
|
|
718
|
+
'blockers:write': ['create_blocker', 'resolve_blocker'],
|
|
719
|
+
'org:read': ['get_org_context', 'get_project', 'list_projects'],
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
// =============================================================================
|
|
723
|
+
// Exports
|
|
724
|
+
// =============================================================================
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Get all tool schemas
|
|
728
|
+
*/
|
|
729
|
+
export function getAllToolSchemas(): ToolSchema[] {
|
|
730
|
+
return Object.values(schemas);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Get tool schema by name
|
|
735
|
+
*/
|
|
736
|
+
export function getToolSchema(name: string): ToolSchema | undefined {
|
|
737
|
+
return schemas[name];
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Get tools available for a set of permissions
|
|
742
|
+
*/
|
|
743
|
+
export function getToolsForPermissions(permissions: string[]): ToolSchema[] {
|
|
744
|
+
const toolNames = new Set<string>();
|
|
745
|
+
|
|
746
|
+
for (const permission of permissions) {
|
|
747
|
+
const tools = permissionToTools[permission] || [];
|
|
748
|
+
tools.forEach(t => toolNames.add(t));
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
return Array.from(toolNames)
|
|
752
|
+
.map(name => schemas[name])
|
|
753
|
+
.filter(Boolean);
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Check if a tool is allowed for a set of permissions
|
|
758
|
+
*/
|
|
759
|
+
export function isToolAllowed(toolName: string, permissions: string[]): boolean {
|
|
760
|
+
for (const permission of permissions) {
|
|
761
|
+
if (permissionToTools[permission]?.includes(toolName)) {
|
|
762
|
+
return true;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return false;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Get the permission required for a tool
|
|
770
|
+
*/
|
|
771
|
+
export function getRequiredPermission(toolName: string): string | undefined {
|
|
772
|
+
for (const [permission, tools] of Object.entries(permissionToTools)) {
|
|
773
|
+
if (tools.includes(toolName)) {
|
|
774
|
+
return permission;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
return undefined;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
export { schemas };
|